From aaf7737713756fd9c762283f61db6bc0fc9bf146 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 Oct 2025 20:23:03 +0000 Subject: [PATCH] initial commit --- .devcontainer/Dockerfile | 23 + .devcontainer/devcontainer.json | 20 + .gitattributes | 5 + .github/workflows/ci.yml | 85 + .gitignore | 7 + .stats.yml | 4 + LICENSE | 201 + README.md | 689 +- SECURITY.md | 23 + build.gradle.kts | 49 + buildSrc/build.gradle.kts | 12 + .../main/kotlin/langsmith-api.java.gradle.kts | 136 + .../kotlin/langsmith-api.kotlin.gradle.kts | 106 + .../kotlin/langsmith-api.publish.gradle.kts | 60 + gradle.properties | 18 + gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 43583 bytes gradle/wrapper/gradle-wrapper.properties | 7 + gradlew | 251 + gradlew.bat | 94 + .../build.gradle.kts | 14 + .../client/okhttp/LangsmithApiOkHttpClient.kt | 332 + .../okhttp/LangsmithApiOkHttpClientAsync.kt | 332 + .../api/client/okhttp/OkHttpClient.kt | 251 + langsmith-api-java-core/build.gradle.kts | 41 + .../api/client/LangsmithApiClient.kt | 96 + .../api/client/LangsmithApiClientAsync.kt | 97 + .../api/client/LangsmithApiClientAsyncImpl.kt | 112 + .../api/client/LangsmithApiClientImpl.kt | 111 + .../api/core/BaseDeserializer.kt | 44 + .../langsmith_api/api/core/BaseSerializer.kt | 6 + .../com/langsmith_api/api/core/Check.kt | 96 + .../langsmith_api/api/core/ClientOptions.kt | 519 + .../langsmith_api/api/core/DefaultSleeper.kt | 28 + .../langsmith_api/api/core/ObjectMappers.kt | 167 + .../com/langsmith_api/api/core/Params.kt | 16 + .../api/core/PhantomReachable.kt | 56 + .../core/PhantomReachableExecutorService.kt | 58 + .../api/core/PhantomReachableSleeper.kt | 23 + .../langsmith_api/api/core/PrepareRequest.kt | 24 + .../com/langsmith_api/api/core/Properties.kt | 42 + .../langsmith_api/api/core/RequestOptions.kt | 46 + .../com/langsmith_api/api/core/Sleeper.kt | 21 + .../com/langsmith_api/api/core/Timeout.kt | 171 + .../com/langsmith_api/api/core/Utils.kt | 115 + .../com/langsmith_api/api/core/Values.kt | 723 + .../api/core/handlers/EmptyHandler.kt | 12 + .../api/core/handlers/ErrorHandler.kt | 84 + .../api/core/handlers/JsonHandler.kt | 20 + .../api/core/handlers/StringHandler.kt | 13 + .../api/core/http/AsyncStreamResponse.kt | 157 + .../langsmith_api/api/core/http/Headers.kt | 115 + .../langsmith_api/api/core/http/HttpClient.kt | 26 + .../langsmith_api/api/core/http/HttpMethod.kt | 13 + .../api/core/http/HttpRequest.kt | 146 + .../api/core/http/HttpRequestBodies.kt | 130 + .../api/core/http/HttpRequestBody.kt | 25 + .../api/core/http/HttpResponse.kt | 22 + .../api/core/http/HttpResponseFor.kt | 25 + ...ntomReachableClosingAsyncStreamResponse.kt | 56 + .../http/PhantomReachableClosingHttpClient.kt | 26 + .../PhantomReachableClosingStreamResponse.kt | 21 + .../api/core/http/QueryParams.kt | 129 + .../api/core/http/RetryingHttpClient.kt | 265 + .../api/core/http/StreamResponse.kt | 19 + .../api/errors/BadRequestException.kt | 80 + .../api/errors/InternalServerException.kt | 91 + .../api/errors/LangsmithApiException.kt | 5 + .../LangsmithApiInvalidDataException.kt | 6 + .../api/errors/LangsmithApiIoException.kt | 6 + .../errors/LangsmithApiRetryableException.kt | 15 + .../errors/LangsmithApiServiceException.kt | 17 + .../api/errors/NotFoundException.kt | 76 + .../api/errors/PermissionDeniedException.kt | 80 + .../api/errors/RateLimitException.kt | 80 + .../api/errors/UnauthorizedException.kt | 80 + .../errors/UnexpectedStatusCodeException.kt | 92 + .../errors/UnprocessableEntityException.kt | 80 + .../api/models/api/v1/V1EventsParams.kt | 731 + .../api/models/api/v1/V1EventsResponse.kt | 113 + .../api/models/api/v1/V1LoginParams.kt | 210 + .../api/models/api/v1/V1LoginResponse.kt | 175 + .../api/models/api/v1/V1RetrieveOkParams.kt | 170 + .../api/models/api/v1/V1RetrieveOkResponse.kt | 114 + .../api/models/api/v1/V1UpdateParams.kt | 441 + .../api/models/api/v1/V1UpdateResponse.kt | 167 + .../api/models/api/v1/ace/AceExecuteParams.kt | 557 + .../models/api/v1/ace/AceExecuteResponse.kt | 113 + .../AnnotationQueueAnnotationQueuesParams.kt | 1344 ++ .../AnnotationQueueDeleteParams.kt | 232 + .../AnnotationQueueDeleteResponse.kt | 119 + .../AnnotationQueueExportParams.kt | 487 + .../AnnotationQueueExportResponse.kt | 119 + .../AnnotationQueuePopulateParams.kt | 506 + .../AnnotationQueuePopulateResponse.kt | 121 + ...tionQueueRetrieveAnnotationQueuesParams.kt | 323 + ...onQueueRetrieveAnnotationQueuesResponse.kt | 707 + .../AnnotationQueueRetrieveParams.kt | 250 + .../AnnotationQueueRetrieveQueuesParams.kt | 199 + .../AnnotationQueueRetrieveSizeParams.kt | 198 + ...otationQueueRetrieveTotalArchivedParams.kt | 236 + .../AnnotationQueueRetrieveTotalSizeParams.kt | 199 + .../AnnotationQueueRubricItemSchema.kt | 516 + .../annotationqueues/AnnotationQueueSchema.kt | 666 + .../AnnotationQueueSizeSchema.kt | 171 + .../AnnotationQueueUpdateParams.kt | 499 + .../AnnotationQueueUpdateResponse.kt | 119 + .../RunSchemaWithAnnotationQueueInfo.kt | 2948 +++ .../annotationqueues/runs/RunCreateParams.kt | 228 + .../runs/RunCreateResponse.kt | 322 + .../annotationqueues/runs/RunDeleteParams.kt | 597 + .../runs/RunDeleteResponse.kt | 113 + .../v1/annotationqueues/runs/RunListParams.kt | 287 + .../annotationqueues/runs/RunUpdateParams.kt | 521 + .../runs/RunUpdateResponse.kt | 113 + .../api/v1/apikey/ApiKeyApiKeyParams.kt | 225 + .../api/v1/apikey/ApiKeyDeleteParams.kt | 229 + .../v1/apikey/ApiKeyRetrieveApiKeyParams.kt | 172 + .../v1/apikey/current/CurrentCreateParams.kt | 225 + .../v1/apikey/current/CurrentDeleteParams.kt | 230 + .../v1/apikey/current/CurrentListParams.kt | 171 + .../models/api/v1/bulkexports/BulkExport.kt | 907 + .../BulkExportBulkExportsParams.kt | 926 + .../v1/bulkexports/BulkExportCompression.kt | 149 + .../api/v1/bulkexports/BulkExportFormat.kt | 130 + .../BulkExportRetrieveBulkExportsParams.kt | 179 + .../bulkexports/BulkExportRetrieveParams.kt | 194 + .../v1/bulkexports/BulkExportUpdateParams.kt | 295 + .../destinations/BulkExportDestination.kt | 479 + .../BulkExportDestinationS3Config.kt | 297 + .../destinations/BulkExportDestinationType.kt | 134 + .../destinations/DestinationCreateParams.kt | 887 + .../destinations/DestinationListParams.kt | 170 + .../destinations/DestinationRetrieveParams.kt | 197 + .../api/v1/bulkexports/runs/BulkExportRun.kt | 1216 ++ .../api/v1/bulkexports/runs/RunListParams.kt | 190 + .../v1/bulkexports/runs/RunRetrieveParams.kt | 217 + .../models/api/v1/charts/ChartCreateParams.kt | 204 + .../models/api/v1/charts/ChartDeleteParams.kt | 229 + .../api/v1/charts/ChartDeleteResponse.kt | 113 + .../api/v1/charts/ChartPreviewParams.kt | 205 + .../models/api/v1/charts/ChartUpdateParams.kt | 224 + .../models/api/v1/charts/CustomChartCreate.kt | 888 + .../models/api/v1/charts/CustomChartMetric.kt | 276 + .../v1/charts/CustomChartPreviewRequest.kt | 440 + .../api/v1/charts/CustomChartResponse.kt | 431 + .../models/api/v1/charts/CustomChartSeries.kt | 1013 + .../api/v1/charts/CustomChartSeriesFilters.kt | 293 + .../models/api/v1/charts/CustomChartType.kt | 137 + .../models/api/v1/charts/CustomChartUpdate.kt | 2394 +++ .../api/v1/charts/CustomChartsDataPoint.kt | 469 + .../api/v1/charts/CustomChartsRequest.kt | 413 + .../api/v1/charts/CustomChartsResponse.kt | 195 + .../api/v1/charts/HostProjectChartMetric.kt | 187 + .../v1/charts/SingleCustomChartResponse.kt | 500 + .../charts/SingleCustomChartResponseBase.kt | 193 + .../section/CustomChartsSectionCreate.kt | 254 + .../section/CustomChartsSectionResponse.kt | 418 + .../section/CustomChartsSectionUpdate.kt | 775 + .../v1/charts/section/SectionCloneParams.kt | 460 + .../v1/charts/section/SectionCreateParams.kt | 205 + .../v1/charts/section/SectionDeleteParams.kt | 229 + .../charts/section/SectionDeleteResponse.kt | 114 + .../v1/charts/section/SectionListParams.kt | 323 + .../v1/charts/section/SectionUpdateParams.kt | 225 + .../api/models/api/v1/comments/Comment.kt | 581 + .../api/v1/comments/CommentRetrieveParams.kt | 285 + .../api/v1/comments/CommentUpdateParams.kt | 258 + .../api/v1/comments/CreateCommentRequest.kt | 170 + .../api/v1/comments/ListCommentsResponse.kt | 225 + .../api/v1/comments/like/LikeCreateParams.kt | 274 + .../v1/comments/like/LikeCreateResponse.kt | 113 + .../v1/comments/like/LikeDeleteAllParams.kt | 274 + .../v1/comments/like/LikeDeleteAllResponse.kt | 114 + .../api/v1/commits/CommitManifestResponse.kt | 504 + .../api/v1/commits/CommitRetrieveParams.kt | 303 + .../api/v1/commits/CommitUpdateParams.kt | 843 + .../api/v1/commits/CommitUpdateResponse.kt | 181 + .../api/v1/commits/CommitWithLookups.kt | 602 + .../api/models/api/v1/datasets/DataType.kt | 140 + .../api/models/api/v1/datasets/Dataset.kt | 705 + .../api/v1/datasets/DatasetCloneParams.kt | 860 + .../api/v1/datasets/DatasetCloneResponse.kt | 114 + .../api/v1/datasets/DatasetCreateParams.kt | 958 + .../api/v1/datasets/DatasetDeleteParams.kt | 229 + .../api/v1/datasets/DatasetDeleteResponse.kt | 114 + .../api/v1/datasets/DatasetGenerateParams.kt | 532 + .../v1/datasets/DatasetGenerateResponse.kt | 115 + .../api/v1/datasets/DatasetListParams.kt | 481 + .../v1/datasets/DatasetRetrieveCsvParams.kt | 222 + .../v1/datasets/DatasetRetrieveCsvResponse.kt | 118 + .../v1/datasets/DatasetRetrieveJsonlParams.kt | 224 + .../datasets/DatasetRetrieveJsonlResponse.kt | 118 + .../datasets/DatasetRetrieveOpenAIFtParams.kt | 225 + .../DatasetRetrieveOpenAIFtResponse.kt | 121 + .../datasets/DatasetRetrieveOpenAIParams.kt | 224 + .../datasets/DatasetRetrieveOpenAIResponse.kt | 119 + .../api/v1/datasets/DatasetRetrieveParams.kt | 193 + .../datasets/DatasetRetrieveVersionParams.kt | 229 + .../api/v1/datasets/DatasetSearchParams.kt | 571 + .../api/v1/datasets/DatasetSearchResponse.kt | 386 + .../datasets/DatasetStudioExperimentParams.kt | 587 + .../DatasetStudioExperimentResponse.kt | 121 + .../api/v1/datasets/DatasetTransformation.kt | 397 + .../api/v1/datasets/DatasetUpdateParams.kt | 2169 +++ .../api/v1/datasets/DatasetUpdateResponse.kt | 520 + .../v1/datasets/DatasetUpdateTagsParams.kt | 704 + .../datasets/DatasetUploadExperimentParams.kt | 1579 ++ .../DatasetUploadExperimentResponse.kt | 224 + .../api/v1/datasets/DatasetUploadParams.kt | 1356 ++ .../models/api/v1/datasets/DatasetVersion.kt | 224 + .../v1/datasets/FeedbackCreateCoreSchema.kt | 1490 ++ .../api/models/api/v1/datasets/Missing.kt | 158 + .../api/v1/datasets/SortByDatasetColumn.kt | 162 + .../comparative/ComparativeCreateParams.kt | 874 + .../comparative/ComparativeCreateResponse.kt | 432 + .../comparative/ComparativeDeleteParams.kt | 241 + .../comparative/ComparativeDeleteResponse.kt | 118 + .../comparative/ComparativeListParams.kt | 332 + .../comparative/ComparativeListResponse.kt | 502 + .../comparative/SimpleExperimentInfo.kt | 205 + .../SortByComparativeExperimentColumn.kt | 144 + .../experiments/ExperimentGroupedParams.kt | 977 + .../experiments/ExperimentGroupedResponse.kt | 118 + .../api/v1/datasets/group/GroupRunsParams.kt | 976 + .../v1/datasets/group/GroupRunsResponse.kt | 1205 ++ .../v1/datasets/index/IndexCreateParams.kt | 408 + .../v1/datasets/index/IndexCreateResponse.kt | 113 + .../v1/datasets/index/IndexDeleteAllParams.kt | 229 + .../datasets/index/IndexDeleteAllResponse.kt | 114 + .../api/v1/datasets/index/IndexListParams.kt | 189 + .../v1/datasets/index/IndexListResponse.kt | 260 + .../api/v1/datasets/index/IndexSyncParams.kt | 229 + .../v1/datasets/index/IndexSyncResponse.kt | 113 + .../PlaygroundExperimentBatchParams.kt | 1915 ++ .../PlaygroundExperimentBatchResponse.kt | 121 + .../PlaygroundExperimentStreamParams.kt | 1836 ++ .../PlaygroundExperimentStreamResponse.kt | 121 + .../playgroundexperiment/RunnableConfig.kt | 597 + .../playgroundexperiment/RunnerContextEnum.kt | 137 + .../api/v1/datasets/runs/ExampleWithRuns.kt | 483 + .../api/v1/datasets/runs/ExampleWithRunsCh.kt | 2068 +++ .../runs/QueryExampleSchemaWithRuns.kt | 1011 + .../v1/datasets/runs/QueryFeedbackDelta.kt | 544 + .../api/v1/datasets/runs/RunCreateParams.kt | 254 + .../api/v1/datasets/runs/RunCreateResponse.kt | 207 + .../api/v1/datasets/runs/RunDeltaParams.kt | 227 + .../v1/datasets/runs/SessionFeedbackDelta.kt | 281 + .../v1/datasets/share/DatasetShareSchema.kt | 209 + .../v1/datasets/share/ShareCreateParams.kt | 261 + .../v1/datasets/share/ShareDeleteAllParams.kt | 229 + .../datasets/share/ShareDeleteAllResponse.kt | 114 + .../api/v1/datasets/share/ShareListParams.kt | 189 + .../v1/datasets/splits/SplitCreateParams.kt | 584 + .../api/v1/datasets/splits/SplitListParams.kt | 306 + .../v1/datasets/versions/VersionListParams.kt | 273 + .../versions/VersionRetrieveDiffParams.kt | 406 + .../versions/VersionRetrieveDiffResponse.kt | 305 + .../api/v1/examples/AttachmentsOperations.kt | 312 + .../api/models/api/v1/examples/Example.kt | 433 + .../api/v1/examples/ExampleCreateParams.kt | 210 + .../api/v1/examples/ExampleDeleteAllParams.kt | 250 + .../v1/examples/ExampleDeleteAllResponse.kt | 115 + .../api/v1/examples/ExampleDeleteParams.kt | 229 + .../api/v1/examples/ExampleDeleteResponse.kt | 114 + .../api/v1/examples/ExampleListParams.kt | 669 + .../v1/examples/ExampleRetrieveCountParams.kt | 407 + .../api/v1/examples/ExampleRetrieveParams.kt | 306 + .../models/api/v1/examples/ExampleSelect.kt | 183 + .../api/v1/examples/ExampleUpdateParams.kt | 699 + .../api/v1/examples/bulk/BulkCreateParams.kt | 210 + .../v1/examples/bulk/BulkCreateResponse.kt | 113 + .../v1/examples/bulk/BulkPatchAllParams.kt | 776 + .../v1/examples/bulk/BulkPatchAllResponse.kt | 114 + .../validate/ExampleValidationResult.kt | 622 + .../examples/validate/ValidateBulkParams.kt | 210 + .../examples/validate/ValidateCreateParams.kt | 210 + .../api/v1/feedback/ApiFeedbackSource.kt | 163 + .../api/v1/feedback/AppFeedbackSource.kt | 163 + .../api/v1/feedback/AutoEvalFeedbackSource.kt | 163 + .../api/v1/feedback/FeedbackCreateParams.kt | 206 + .../api/v1/feedback/FeedbackCreateSchema.kt | 1626 ++ .../api/v1/feedback/FeedbackDeleteParams.kt | 229 + .../api/v1/feedback/FeedbackDeleteResponse.kt | 114 + .../api/v1/feedback/FeedbackEagerParams.kt | 211 + .../models/api/v1/feedback/FeedbackLevel.kt | 136 + .../api/v1/feedback/FeedbackListParams.kt | 461 + .../api/v1/feedback/FeedbackRetrieveParams.kt | 223 + .../models/api/v1/feedback/FeedbackSchema.kt | 1650 ++ .../api/v1/feedback/FeedbackUpdateParams.kt | 1298 ++ .../api/v1/feedback/ModelFeedbackSource.kt | 163 + .../api/models/api/v1/feedback/SourceType.kt | 146 + .../v1/feedback/formulas/FeedbackFormula.kt | 612 + .../FeedbackFormulaWeightedVariable.kt | 245 + .../feedback/formulas/FormulaCreateParams.kt | 867 + .../feedback/formulas/FormulaDeleteParams.kt | 237 + .../formulas/FormulaDeleteResponse.kt | 114 + .../v1/feedback/formulas/FormulaListParams.kt | 247 + .../formulas/FormulaRetrieveParams.kt | 197 + .../feedback/formulas/FormulaUpdateParams.kt | 751 + .../tokens/FeedbackIngestTokenCreateSchema.kt | 345 + .../tokens/FeedbackIngestTokenSchema.kt | 285 + .../v1/feedback/tokens/TokenCreateParams.kt | 440 + .../v1/feedback/tokens/TokenCreateResponse.kt | 230 + .../api/v1/feedback/tokens/TokenListParams.kt | 201 + .../v1/feedback/tokens/TokenRetrieveParams.kt | 428 + .../feedback/tokens/TokenRetrieveResponse.kt | 114 + .../v1/feedback/tokens/TokenUpdateParams.kt | 1206 ++ .../v1/feedback/tokens/TokenUpdateResponse.kt | 113 + .../api/v1/feedbackconfigs/FeedbackConfig.kt | 640 + .../FeedbackConfigFeedbackConfigsParams.kt | 602 + ...backConfigRetrieveFeedbackConfigsParams.kt | 234 + .../feedbackconfigs/FeedbackConfigSchema.kt | 358 + ...edbackConfigUpdateFeedbackConfigsParams.kt | 608 + .../api/models/api/v1/info/InfoListParams.kt | 170 + .../models/api/v1/info/InfoListResponse.kt | 914 + .../api/v1/info/InfoRetrieveHealthParams.kt | 170 + .../api/v1/info/InfoRetrieveHealthResponse.kt | 182 + .../api/v1/me/MeRetrieveLsUserIdParams.kt | 170 + .../OnboardingStateCreateParams.kt | 213 + .../OnboardingStateListParams.kt | 172 + .../OnboardingStateUpdateParams.kt | 241 + .../UserOnboardingStateResponse.kt | 542 + .../ModelPriceMapDeleteParams.kt | 232 + .../ModelPriceMapDeleteResponse.kt | 118 + .../ModelPriceMapModelPriceMapParams.kt | 1613 ++ .../ModelPriceMapModelPriceMapResponse.kt | 121 + ...odelPriceMapRetrieveModelPriceMapParams.kt | 180 + ...elPriceMapRetrieveModelPriceMapResponse.kt | 122 + .../ModelPriceMapUpdateParams.kt | 1628 ++ .../ModelPriceMapUpdateResponse.kt | 118 + .../api/models/api/v1/oauth/OAuthProvider.kt | 129 + .../v1/oauth/OAuthRetrieveCallbackParams.kt | 195 + .../v1/oauth/OAuthRetrieveCallbackResponse.kt | 119 + .../oauth/OAuthRetrieveCurrentUserParams.kt | 196 + .../oauth/OAuthRetrieveCurrentUserResponse.kt | 121 + .../api/v1/oauth/OAuthRetrieveLogoutParams.kt | 195 + .../v1/oauth/OAuthRetrieveLogoutResponse.kt | 118 + .../api/v1/oauth/OAuthRetrieveParams.kt | 189 + .../api/v1/oauth/OAuthRetrieveResponse.kt | 114 + .../api/v1/orgcharts/OrgChartCreateParams.kt | 205 + .../api/v1/orgcharts/OrgChartDeleteParams.kt | 229 + .../v1/orgcharts/OrgChartDeleteResponse.kt | 114 + .../v1/orgcharts/OrgChartOrgChartsParams.kt | 205 + .../api/v1/orgcharts/OrgChartPreviewParams.kt | 206 + .../api/v1/orgcharts/OrgChartUpdateParams.kt | 225 + .../section/CustomChartsRequestBase.kt | 308 + .../orgcharts/section/SectionCreateParams.kt | 206 + .../orgcharts/section/SectionDeleteParams.kt | 229 + .../section/SectionDeleteResponse.kt | 114 + .../v1/orgcharts/section/SectionListParams.kt | 323 + .../orgcharts/section/SectionUpdateParams.kt | 226 + .../api/models/api/v1/orgs/OrgCreateParams.kt | 485 + .../api/models/api/v1/orgs/OrgListParams.kt | 221 + .../v1/orgs/OrgRetrievePermissionsParams.kt | 172 + .../v1/orgs/OrgRetrievePermissionsResponse.kt | 254 + .../api/v1/orgs/OrganizationPgSchemaSlim.kt | 802 + .../api/models/api/v1/orgs/PaymentPlanTier.kt | 196 + ...tConfirmCheckoutSessionCompletionParams.kt | 432 + ...onfirmCheckoutSessionCompletionResponse.kt | 123 + .../api/v1/orgs/current/CurrentListParams.kt | 170 + .../v1/orgs/current/CurrentListResponse.kt | 891 + .../current/CurrentPaymentMethodParams.kt | 702 + .../current/CurrentPaymentMethodResponse.kt | 118 + .../api/v1/orgs/current/CurrentPlanParams.kt | 592 + .../v1/orgs/current/CurrentPlanResponse.kt | 113 + .../current/CurrentRetrieveDashboardParams.kt | 491 + .../CurrentRetrieveDashboardResponse.kt | 181 + .../CurrentSetDefaultSsoProvisionParams.kt | 217 + .../CurrentSetDefaultSsoProvisionResponse.kt | 122 + .../api/v1/orgs/current/CurrentSetupParams.kt | 210 + .../v1/orgs/current/CurrentSetupResponse.kt | 178 + .../CurrentStripeAccountLinksParams.kt | 419 + .../CurrentStripeAccountLinksResponse.kt | 121 + .../CurrentStripeCheckoutSessionParams.kt | 491 + .../CurrentStripeCheckoutSessionResponse.kt | 122 + .../CurrentUpdateLoginMethodsParams.kt | 412 + .../CurrentUpdateLoginMethodsResponse.kt | 121 + .../orgs/current/CustomerVisiblePlanInfo.kt | 255 + .../api/v1/orgs/current/OrganizationConfig.kt | 2417 +++ .../v1/orgs/current/StripeCustomerAddress.kt | 347 + .../orgs/current/StripePaymentMethodInfo.kt | 315 + .../api/models/api/v1/orgs/current/Wallet.kt | 225 + .../orgs/current/billing/BillingListParams.kt | 170 + .../current/billing/BillingListResponse.kt | 752 + .../billing/BillingRetrieveUsageParams.kt | 245 + .../billing/BillingRetrieveUsageResponse.kt | 540 + .../BusinessInfoBusinessInfoParams.kt | 625 + .../BusinessInfoBusinessInfoResponse.kt | 121 + .../BusinessInfoRetrieveBusinessInfoParams.kt | 179 + ...usinessInfoRetrieveBusinessInfoResponse.kt | 295 + .../businessinfo/StripeBusinessBillingInfo.kt | 217 + .../orgs/current/businessinfo/StripeTaxId.kt | 205 + .../v1/orgs/current/info/InfoListParams.kt | 170 + .../orgs/current/info/InfoPatchAllParams.kt | 900 + .../v1/orgs/current/info/OrganizationInfo.kt | 849 + .../v1/orgs/current/members/AccessScope.kt | 133 + .../orgs/current/members/MemberBatchParams.kt | 207 + .../current/members/MemberCreateParams.kt | 204 + .../current/members/MemberDeleteParams.kt | 229 + .../current/members/MemberDeleteResponse.kt | 114 + .../orgs/current/members/MemberListParams.kt | 170 + .../current/members/MemberListResponse.kt | 290 + .../members/MemberRetrieveActiveParams.kt | 303 + .../current/members/MemberUpdateParams.kt | 539 + .../current/members/MemberUpdateResponse.kt | 114 + .../orgs/current/members/OrgMemberIdentity.kt | 818 + .../orgs/current/members/PendingIdentity.kt | 777 + .../current/members/PendingIdentityCreate.kt | 428 + .../current/members/basic/BasicBatchParams.kt | 727 + .../members/basic/BasicBatchResponse.kt | 442 + .../members/pending/OrgPendingIdentity.kt | 830 + .../members/pending/PendingDeleteAllParams.kt | 230 + .../pending/PendingDeleteAllResponse.kt | 115 + .../members/pending/PendingListParams.kt | 244 + .../PersonalAccessTokenDeleteParams.kt | 235 + ...alAccessTokenPersonalAccessTokensParams.kt | 234 + ...TokenRetrievePersonalAccessTokensParams.kt | 183 + .../models/api/v1/orgs/current/roles/Role.kt | 440 + .../v1/orgs/current/roles/RoleCreateParams.kt | 577 + .../v1/orgs/current/roles/RoleDeleteParams.kt | 229 + .../v1/orgs/current/roles/RoleListParams.kt | 170 + .../v1/orgs/current/roles/RoleUpdateParams.kt | 601 + .../servicekeys/ApiKeyCreateRequest.kt | 438 + .../servicekeys/ApiKeyCreateResponse.kt | 510 + .../current/servicekeys/ApiKeyGetResponse.kt | 475 + .../servicekeys/ServiceKeyDeleteParams.kt | 230 + .../ServiceKeyRetrieveServiceKeysParams.kt | 179 + .../ServiceKeyServiceKeysParams.kt | 227 + .../orgs/current/ssosettings/SsoProvider.kt | 448 + .../ssosettings/SsoSettingDeleteParams.kt | 230 + .../SsoSettingRetrieveSsoSettingsParams.kt | 179 + .../SsoSettingSsoSettingsParams.kt | 856 + .../ssosettings/SsoSettingUpdateParams.kt | 695 + .../v1/orgs/current/user/ProviderUserSlim.kt | 1032 ++ .../user/UserRetrieveLoginMethodsParams.kt | 173 + .../orgs/members/MemberUpdateBasicParams.kt | 454 + .../orgs/members/MemberUpdateBasicResponse.kt | 118 + .../models/api/v1/orgs/pending/Identity.kt | 520 + .../api/v1/orgs/pending/PendingClaimParams.kt | 235 + .../v1/orgs/pending/PendingDeleteParams.kt | 235 + .../v1/orgs/pending/PendingDeleteResponse.kt | 114 + .../api/v1/orgs/pending/PendingListParams.kt | 170 + .../api/v1/orgs/ttlsettings/TraceTier.kt | 133 + .../TtlSettingRetrieveTtlSettingsParams.kt | 179 + .../TtlSettingUpdateTtlSettingsParams.kt | 210 + .../api/v1/orgs/ttlsettings/TtlSettings.kt | 602 + .../ttlsettings/UpsertTtlSettingsRequest.kt | 261 + .../PlaygroundSavedOptions.kt | 176 + .../PlaygroundSettingDeleteParams.kt | 244 + .../PlaygroundSettingDeleteResponse.kt | 121 + ...aygroundSettingPlaygroundSettingsParams.kt | 582 + ...SettingRetrievePlaygroundSettingsParams.kt | 181 + .../PlaygroundSettingUpdateParams.kt | 572 + .../PlaygroundSettingsResponse.kt | 384 + .../models/api/v1/prompts/InvalidToolCall.kt | 555 + .../api/v1/prompts/PromptCanvasParams.kt | 15204 ++++++++++++++++ .../api/v1/prompts/PromptCanvasResponse.kt | 114 + .../v1/prompts/PromptInvokePromptParams.kt | 535 + .../v1/prompts/PromptInvokePromptResponse.kt | 118 + .../api/models/api/v1/prompts/ToolCall.kt | 386 + .../models/api/v1/prompts/UsageMetadata.kt | 869 + .../promptwebhooks/EPromptWebhookTrigger.kt | 144 + .../api/v1/promptwebhooks/PromptWebhook.kt | 514 + .../PromptWebhookDeleteParams.kt | 232 + .../PromptWebhookDeleteResponse.kt | 118 + .../PromptWebhookPromptWebhooksParams.kt | 785 + .../PromptWebhookRetrieveParams.kt | 195 + ...omptWebhookRetrievePromptWebhooksParams.kt | 180 + .../promptwebhooks/PromptWebhookTestParams.kt | 1243 ++ .../PromptWebhookTestResponse.kt | 114 + .../PromptWebhookUpdateParams.kt | 729 + .../public_/PublicRetrieveFeedbacksParams.kt | 424 + .../v1/public_/datasets/DatasetListParams.kt | 283 + .../public_/datasets/DatasetListResponse.kt | 533 + .../DatasetRetrieveComparativeParams.kt | 316 + .../DatasetRetrieveComparativeResponse.kt | 428 + .../datasets/DatasetRetrieveFeedbackParams.kt | 424 + .../DatasetRetrieveSessionsBulkParams.kt | 217 + .../datasets/DatasetRetrieveSessionsParams.kt | 406 + .../public_/datasets/runs/RunDeltaParams.kt | 228 + .../datasets/runs/RunGenerateQueryParams.kt | 231 + .../datasets/runs/RunPublicDatasetSchema.kt | 2348 +++ .../public_/datasets/runs/RunQueryParams.kt | 227 + .../public_/datasets/runs/RunQueryResponse.kt | 365 + .../datasets/runs/RunRetrieveParams.kt | 258 + .../api/v1/public_/datasets/runs/RunStats.kt | 1307 ++ .../public_/datasets/runs/RunStatsParams.kt | 227 + .../v1/public_/examples/ExampleListParams.kt | 427 + .../examples/ExampleRetrieveCountParams.kt | 363 + .../v1/public_/examples/ExampleRunsParams.kt | 231 + .../public_/examples/ExampleRunsResponse.kt | 700 + .../api/v1/public_/runs/RunListParams.kt | 234 + .../api/v1/public_/runs/RunPublicSchema.kt | 2311 +++ .../api/v1/public_/runs/RunQueryParams.kt | 431 + .../api/v1/public_/runs/RunQueryResponse.kt | 363 + .../api/v1/public_/runs/RunRetrieveParams.kt | 258 + .../SchemaRetrieveMessageJsonParams.kt | 198 + .../SchemaRetrieveMessageJsonResponse.kt | 121 + .../SchemaRetrieveTooldefJsonParams.kt | 198 + .../SchemaRetrieveTooldefJsonResponse.kt | 121 + .../models/api/v1/repos/CreateRepoResponse.kt | 172 + .../api/models/api/v1/repos/DemoConfig.kt | 290 + .../v1/repos/EPromptOptimizationAlgorithm.kt | 143 + .../models/api/v1/repos/GetRepoResponse.kt | 172 + .../api/models/api/v1/repos/PromptimConfig.kt | 517 + .../models/api/v1/repos/RepoCreateParams.kt | 699 + .../models/api/v1/repos/RepoDeleteParams.kt | 258 + .../models/api/v1/repos/RepoDeleteResponse.kt | 113 + .../api/models/api/v1/repos/RepoForkParams.kt | 750 + .../api/models/api/v1/repos/RepoListParams.kt | 1002 + .../models/api/v1/repos/RepoListResponse.kt | 223 + .../api/v1/repos/RepoOptimizeJobParams.kt | 748 + .../api/v1/repos/RepoOptimizeJobResponse.kt | 181 + .../models/api/v1/repos/RepoRetrieveParams.kt | 217 + .../models/api/v1/repos/RepoUpdateParams.kt | 754 + .../models/api/v1/repos/RepoWithLookups.kt | 1094 ++ .../EPromptOptimizationJobStatus.kt | 155 + .../OptimizationJobDeleteParams.kt | 272 + .../OptimizationJobDeleteResponse.kt | 119 + .../OptimizationJobOptimizationJobsParams.kt | 718 + ...zationJobRetrieveOptimizationJobsParams.kt | 223 + .../OptimizationJobRetrieveParams.kt | 230 + .../OptimizationJobRetrieveResponse.kt | 750 + .../OptimizationJobUpdateParams.kt | 518 + .../optimizationjobs/PromptOptimizationJob.kt | 695 + .../PromptOptimizationResult.kt | 244 + .../logs/EPromptOptimizationJobLogType.kt | 155 + .../optimizationjobs/logs/LogCreateParams.kt | 545 + .../optimizationjobs/logs/LogDeleteParams.kt | 284 + .../logs/LogDeleteResponse.kt | 113 + .../optimizationjobs/logs/LogListParams.kt | 229 + .../logs/LogRetrieveParams.kt | 241 + .../logs/PromptOptimizationJobLog.kt | 330 + .../api/models/api/v1/repos/tags/RepoTag.kt | 396 + .../api/v1/repos/tags/TagCreateParams.kt | 776 + .../api/v1/repos/tags/TagDeleteParams.kt | 271 + .../api/v1/repos/tags/TagDeleteResponse.kt | 113 + .../models/api/v1/repos/tags/TagListParams.kt | 217 + .../api/v1/repos/tags/TagRetrieveParams.kt | 229 + .../api/v1/repos/tags/TagUpdateParams.kt | 728 + .../api/v1/runs/BodyParamsForRunSchema.kt | 1754 ++ .../runs/RequestBodyForRunsGenerateQuery.kt | 391 + .../runs/ResponseBodyForRunsGenerateQuery.kt | 316 + .../api/models/api/v1/runs/RunDeleteParams.kt | 650 + .../models/api/v1/runs/RunDeleteResponse.kt | 113 + .../api/v1/runs/RunGenerateQueryParams.kt | 205 + .../api/models/api/v1/runs/RunQueryParams.kt | 206 + .../models/api/v1/runs/RunQueryResponse.kt | 503 + .../models/api/v1/runs/RunRetrieveParams.kt | 291 + .../api/models/api/v1/runs/RunSchema.kt | 2770 +++ .../api/models/api/v1/runs/RunStatsParams.kt | 206 + .../models/api/v1/runs/RunStatsQueryParams.kt | 1428 ++ .../models/api/v1/runs/RunStatsResponse.kt | 299 + .../api/models/api/v1/runs/RunTypeEnum.kt | 164 + .../api/models/api/v1/runs/RunUpdateParams.kt | 229 + .../models/api/v1/runs/RunUpdateResponse.kt | 113 + .../v1/runs/RunsFilterDataSourceTypeEnum.kt | 162 + .../api/v1/runs/group/GroupCreateParams.kt | 224 + .../api/v1/runs/group/GroupCreateResponse.kt | 113 + .../api/v1/runs/group/GroupStatsParams.kt | 204 + .../api/v1/runs/group/GroupStatsResponse.kt | 1355 ++ .../api/v1/runs/group/RunGroupRequest.kt | 514 + .../v1/runs/rules/CodeEvaluatorTopLevel.kt | 336 + .../api/v1/runs/rules/EvaluatorTopLevel.kt | 605 + .../api/v1/runs/rules/RuleCreateParams.kt | 2316 +++ .../api/v1/runs/rules/RuleDeleteParams.kt | 229 + .../api/v1/runs/rules/RuleDeleteResponse.kt | 113 + .../api/v1/runs/rules/RuleListParams.kt | 393 + .../v1/runs/rules/RuleLogActionResponse.kt | 315 + .../models/api/v1/runs/rules/RuleLogSchema.kt | 716 + .../rules/RuleRetrieveLastAppliedParams.kt | 196 + .../v1/runs/rules/RuleRetrieveLogsParams.kt | 277 + .../api/v1/runs/rules/RuleUpdateParams.kt | 2152 +++ .../rules/RunRulesPagerdutyAlertSchema.kt | 551 + .../api/v1/runs/rules/RunRulesSchema.kt | 1759 ++ .../v1/runs/rules/RunRulesWebhookSchema.kt | 307 + .../runs/rules/trigger/TriggerCreateParams.kt | 486 + .../rules/trigger/TriggerCreateResponse.kt | 114 + .../api/v1/runs/share/RunShareSchema.kt | 207 + .../api/v1/runs/share/ShareCreateParams.kt | 229 + .../api/v1/runs/share/ShareDeleteAllParams.kt | 229 + .../v1/runs/share/ShareDeleteAllResponse.kt | 114 + .../api/v1/runs/share/ShareListParams.kt | 189 + .../ServiceAccountDeleteParams.kt | 240 + .../ServiceAccountDeleteResponse.kt | 383 + ...iceAccountRetrieveServiceAccountsParams.kt | 180 + ...eAccountRetrieveServiceAccountsResponse.kt | 388 + .../ServiceAccountServiceAccountsParams.kt | 707 + .../ServiceAccountServiceAccountsResponse.kt | 440 + .../api/v1/sessions/CustomChartsSection.kt | 762 + .../v1/sessions/CustomChartsSectionRequest.kt | 349 + .../models/api/v1/sessions/RunStatsGroupBy.kt | 387 + .../api/v1/sessions/SessionCreateParams.kt | 947 + .../api/v1/sessions/SessionDashboardParams.kt | 249 + .../api/v1/sessions/SessionDeleteAllParams.kt | 250 + .../v1/sessions/SessionDeleteAllResponse.kt | 115 + .../api/v1/sessions/SessionDeleteParams.kt | 229 + .../api/v1/sessions/SessionDeleteResponse.kt | 114 + .../api/v1/sessions/SessionListParams.kt | 551 + .../sessions/SessionRetrieveMetadataParams.kt | 296 + .../SessionRetrieveMetadataResponse.kt | 117 + .../api/v1/sessions/SessionRetrieveParams.kt | 264 + .../api/v1/sessions/SessionSortableColumns.kt | 174 + .../api/v1/sessions/SessionUpdateParams.kt | 726 + .../models/api/v1/sessions/TimedeltaInput.kt | 216 + .../models/api/v1/sessions/TracerSession.kt | 1352 ++ .../TracerSessionWithoutVirtualFields.kt | 568 + .../insights/CreateRunClusteringJobRequest.kt | 983 + .../sessions/insights/InsightCreateParams.kt | 232 + .../insights/InsightCreateResponse.kt | 277 + .../sessions/insights/InsightDeleteParams.kt | 258 + .../insights/InsightDeleteResponse.kt | 205 + .../v1/sessions/insights/InsightListParams.kt | 239 + .../sessions/insights/InsightListResponse.kt | 611 + .../insights/InsightRetrieveParams.kt | 229 + .../insights/InsightRetrieveResponse.kt | 349 + .../insights/InsightRetrieveRunsParams.kt | 455 + .../insights/InsightRetrieveRunsResponse.kt | 230 + .../sessions/insights/InsightUpdateParams.kt | 442 + .../insights/InsightUpdateResponse.kt | 205 + .../insights/configs/ConfigCreateParams.kt | 581 + .../insights/configs/ConfigDeleteParams.kt | 258 + .../insights/configs/ConfigDeleteResponse.kt | 205 + .../insights/configs/ConfigGenerateParams.kt | 729 + .../configs/ConfigGenerateResponse.kt | 362 + .../insights/configs/ConfigListParams.kt | 223 + .../insights/configs/ConfigListResponse.kt | 507 + .../insights/configs/ConfigUpdateParams.kt | 580 + .../CreateClusteringJobConfigResponse.kt | 293 + .../configs/SavedRunClusteringJobRequest.kt | 732 + .../api/v1/sessions/views/FilterView.kt | 548 + .../api/v1/sessions/views/FilterViewType.kt | 135 + .../api/v1/sessions/views/ViewCreateParams.kt | 822 + .../api/v1/sessions/views/ViewDeleteParams.kt | 258 + .../v1/sessions/views/ViewDeleteResponse.kt | 113 + .../api/v1/sessions/views/ViewListParams.kt | 212 + .../v1/sessions/views/ViewRetrieveParams.kt | 217 + .../api/v1/sessions/views/ViewUpdateParams.kt | 830 + .../v1/settings/AppHubCrudTenantsTenant.kt | 294 + .../api/v1/settings/SettingHandleParams.kt | 423 + .../api/v1/settings/SettingListParams.kt | 170 + .../models/api/v1/sso/SsoRetrieveParams.kt | 194 + .../models/api/v1/sso/SsoRetrieveResponse.kt | 260 + .../EmailVerificationConfirmParams.kt | 409 + .../EmailVerificationConfirmResponse.kt | 121 + .../EmailVerificationSendParams.kt | 487 + .../EmailVerificationSendResponse.kt | 119 + .../EmailVerificationStatusParams.kt | 488 + .../EmailVerificationStatusResponse.kt | 175 + .../models/api/v1/tenants/AppSchemasTenant.kt | 428 + .../api/v1/tenants/TenantCreateParams.kt | 700 + .../models/api/v1/tenants/TenantForUser.kt | 590 + .../models/api/v1/tenants/TenantListParams.kt | 224 + .../TtlSettingRetrieveTtlSettingsParams.kt | 179 + .../TtlSettingUpdateTtlSettingsParams.kt | 211 + .../models/api/v1/usagelimits/UsageLimit.kt | 367 + .../v1/usagelimits/UsageLimitDeleteParams.kt | 235 + .../usagelimits/UsageLimitDeleteResponse.kt | 115 + .../UsageLimitRetrieveOrgParams.kt | 172 + .../UsageLimitRetrieveUsageLimitsParams.kt | 179 + .../api/v1/usagelimits/UsageLimitType.kt | 136 + .../UsageLimitUpdateUsageLimitsParams.kt | 553 + .../v1/workspaces/WorkspaceCreateParams.kt | 556 + .../v1/workspaces/WorkspaceDeleteParams.kt | 234 + .../v1/workspaces/WorkspaceDeleteResponse.kt | 115 + .../api/v1/workspaces/WorkspaceListParams.kt | 206 + .../v1/workspaces/WorkspaceUpdateParams.kt | 438 + .../current/CurrentRetrieveStatsParams.kt | 208 + .../current/CurrentRetrieveStatsResponse.kt | 428 + .../CurrentRetrieveUsageLimitsParams.kt | 178 + .../CurrentRetrieveUsageLimitsResponse.kt | 434 + .../current/members/MemberBatchParams.kt | 208 + .../current/members/MemberCreateParams.kt | 685 + .../current/members/MemberDeleteParams.kt | 229 + .../current/members/MemberDeleteResponse.kt | 114 + .../current/members/MemberIdentity.kt | 767 + .../current/members/MemberListParams.kt | 170 + .../current/members/MemberListResponse.kt | 283 + .../members/MemberRetrieveActiveParams.kt | 303 + .../current/members/MemberUpdateParams.kt | 510 + .../current/members/MemberUpdateResponse.kt | 114 + .../members/pending/PendingDeleteAllParams.kt | 230 + .../pending/PendingDeleteAllResponse.kt | 115 + .../members/pending/PendingListParams.kt | 244 + .../current/secrets/SecretCreateParams.kt | 413 + .../current/secrets/SecretCreateResponse.kt | 114 + .../current/secrets/SecretListParams.kt | 170 + .../current/secrets/SecretListResponse.kt | 167 + .../secrets/SecretRetrieveEncryptedParams.kt | 330 + .../SecretRetrieveEncryptedResponse.kt | 183 + .../current/shared/SharedDeleteAllParams.kt | 417 + .../current/shared/SharedDeleteAllResponse.kt | 115 + .../current/shared/SharedListParams.kt | 221 + .../current/shared/SharedListResponse.kt | 1178 ++ .../workspaces/current/taggings/Resource.kt | 251 + .../v1/workspaces/current/taggings/Tagging.kt | 327 + .../current/taggings/TaggingCreateParams.kt | 558 + .../current/taggings/TaggingDeleteParams.kt | 229 + .../current/taggings/TaggingDeleteResponse.kt | 114 + .../current/taggings/TaggingListParams.kt | 190 + .../current/taggings/TaggingListResponse.kt | 794 + .../v1/workspaces/current/tagkeys/TagKey.kt | 323 + .../current/tagkeys/TagKeyDeleteParams.kt | 229 + .../current/tagkeys/TagKeyDeleteResponse.kt | 114 + .../current/tagkeys/TagKeyRetrieveParams.kt | 189 + .../tagkeys/TagKeyRetrieveTagKeysParams.kt | 172 + .../current/tagkeys/TagKeyTagKeysParams.kt | 481 + .../current/tagkeys/TagKeyUpdateParams.kt | 478 + .../current/tagkeys/tagvalues/TagValue.kt | 356 + .../tagkeys/tagvalues/TagValueDeleteParams.kt | 258 + .../tagvalues/TagValueDeleteResponse.kt | 114 + .../tagvalues/TagValueRetrieveParams.kt | 217 + .../TagValueRetrieveTagValuesParams.kt | 198 + .../tagvalues/TagValueTagValuesParams.kt | 504 + .../tagkeys/tagvalues/TagValueUpdateParams.kt | 501 + .../workspaces/current/tags/ResourceType.kt | 163 + .../workspaces/current/tags/TagListParams.kt | 170 + .../current/tags/TagListResponse.kt | 372 + .../current/tags/TagResourcesParams.kt | 423 + .../current/tags/TagResourcesResponse.kt | 109 + .../current/tags/TagRetrieveResourceParams.kt | 214 + .../tags/TagRetrieveResourceResponse.kt | 782 + .../workspaces/pending/PendingClaimParams.kt | 235 + .../pending/PendingClaimResponse.kt | 114 + .../workspaces/pending/PendingDeleteParams.kt | 229 + .../pending/PendingDeleteResponse.kt | 114 + .../workspaces/pending/PendingListParams.kt | 170 + .../experimentviewoverrides/ColumnOverride.kt | 423 + .../ExperimentViewOverride.kt | 313 + .../ExperimentViewOverrideCreateParams.kt | 493 + .../ExperimentViewOverrideDeleteParams.kt | 274 + .../ExperimentViewOverrideListParams.kt | 210 + .../ExperimentViewOverrideRetrieveParams.kt | 234 + .../ExperimentViewOverrideUpdateParams.kt | 504 + .../feedback/FeedbackIngestBatchParams.kt | 1727 ++ .../feedback/FeedbackIngestBatchResponse.kt | 114 + .../models/platform/alerts/AlertActionBase.kt | 383 + .../platform/alerts/AlertCreateParams.kt | 527 + .../platform/alerts/AlertDeleteParams.kt | 258 + .../platform/alerts/AlertDeleteResponse.kt | 109 + .../platform/alerts/AlertRetrieveParams.kt | 218 + .../models/platform/alerts/AlertRuleBase.kt | 1182 ++ .../platform/alerts/AlertRuleResponse.kt | 1916 ++ .../models/platform/alerts/AlertTestParams.kt | 232 + .../platform/alerts/AlertTestResponse.kt | 109 + .../platform/alerts/AlertUpdateParams.kt | 536 + .../platform/alerts/AlertUpdateResponse.kt | 109 + .../examples/ExampleHardDeleteParams.kt | 532 + .../examples/ExampleHardDeleteResponse.kt | 212 + .../datasets/examples/ExampleUpdateParams.kt | 858 + .../examples/ExampleUpdateResponse.kt | 210 + .../datasets/examples/ExampleUploadParams.kt | 780 + .../examples/ExampleUploadResponse.kt | 210 + .../current/accesspolicies/AccessPolicy.kt | 443 + .../AccessPolicyCreateParams.kt | 709 + .../AccessPolicyCreateResponse.kt | 155 + .../AccessPolicyDeleteParams.kt | 238 + .../accesspolicies/AccessPolicyListParams.kt | 170 + .../AccessPolicyListResponse.kt | 182 + .../AccessPolicyRetrieveParams.kt | 200 + .../current/accesspolicies/ConditionGroup.kt | 1208 ++ .../accesspolicies/roles/RoleAttachParams.kt | 572 + .../com/langsmith_api/api/models/runs/Run.kt | 1759 ++ .../api/models/runs/RunCreateParams.kt | 203 + .../api/models/runs/RunCreateResponse.kt | 109 + .../api/models/runs/RunIngestBatchParams.kt | 494 + .../api/models/runs/RunIngestBatchResponse.kt | 110 + .../models/runs/RunIngestMultipartParams.kt | 825 + .../models/runs/RunIngestMultipartResponse.kt | 114 + .../api/models/runs/RunUpdateParams.kt | 224 + .../api/models/runs/RunUpdateResponse.kt | 109 + .../api/services/async/ApiServiceAsync.kt | 37 + .../api/services/async/ApiServiceAsyncImpl.kt | 42 + .../api/services/async/DatasetServiceAsync.kt | 41 + .../services/async/DatasetServiceAsyncImpl.kt | 47 + .../services/async/FeedbackServiceAsync.kt | 67 + .../async/FeedbackServiceAsyncImpl.kt | 86 + .../services/async/PlatformServiceAsync.kt | 51 + .../async/PlatformServiceAsyncImpl.kt | 66 + .../api/services/async/RunServiceAsync.kt | 254 + .../api/services/async/RunServiceAsyncImpl.kt | 207 + .../api/services/async/api/V1ServiceAsync.kt | 357 + .../services/async/api/V1ServiceAsyncImpl.kt | 610 + .../services/async/api/v1/AceServiceAsync.kt | 62 + .../async/api/v1/AceServiceAsyncImpl.kt | 86 + .../api/v1/AnnotationQueueServiceAsync.kt | 827 + .../api/v1/AnnotationQueueServiceAsyncImpl.kt | 559 + .../async/api/v1/ApiKeyServiceAsync.kt | 243 + .../async/api/v1/ApiKeyServiceAsyncImpl.kt | 181 + .../async/api/v1/BulkExportServiceAsync.kt | 274 + .../api/v1/BulkExportServiceAsyncImpl.kt | 235 + .../async/api/v1/ChartServiceAsync.kt | 295 + .../async/api/v1/ChartServiceAsyncImpl.kt | 225 + .../async/api/v1/CommentServiceAsync.kt | 155 + .../async/api/v1/CommentServiceAsyncImpl.kt | 158 + .../async/api/v1/CommitServiceAsync.kt | 149 + .../async/api/v1/CommitServiceAsyncImpl.kt | 146 + .../async/api/v1/DatasetServiceAsync.kt | 1066 ++ .../async/api/v1/DatasetServiceAsyncImpl.kt | 864 + .../async/api/v1/ExampleServiceAsync.kt | 410 + .../async/api/v1/ExampleServiceAsyncImpl.kt | 348 + .../api/v1/FeedbackConfigServiceAsync.kt | 152 + .../api/v1/FeedbackConfigServiceAsyncImpl.kt | 165 + .../async/api/v1/FeedbackServiceAsync.kt | 442 + .../async/api/v1/FeedbackServiceAsyncImpl.kt | 315 + .../services/async/api/v1/InfoServiceAsync.kt | 127 + .../async/api/v1/InfoServiceAsyncImpl.kt | 123 + .../services/async/api/v1/MeServiceAsync.kt | 85 + .../async/api/v1/MeServiceAsyncImpl.kt | 91 + .../async/api/v1/ModelPriceMapServiceAsync.kt | 257 + .../api/v1/ModelPriceMapServiceAsyncImpl.kt | 214 + .../async/api/v1/OAuthServiceAsync.kt | 371 + .../async/api/v1/OAuthServiceAsyncImpl.kt | 215 + .../async/api/v1/OrgChartServiceAsync.kt | 359 + .../async/api/v1/OrgChartServiceAsyncImpl.kt | 265 + .../services/async/api/v1/OrgServiceAsync.kt | 176 + .../async/api/v1/OrgServiceAsyncImpl.kt | 213 + .../api/v1/PlaygroundSettingServiceAsync.kt | 305 + .../v1/PlaygroundSettingServiceAsyncImpl.kt | 215 + .../async/api/v1/PromptServiceAsync.kt | 94 + .../async/api/v1/PromptServiceAsyncImpl.kt | 126 + .../async/api/v1/PromptWebhookServiceAsync.kt | 381 + .../api/v1/PromptWebhookServiceAsyncImpl.kt | 292 + .../async/api/v1/PublicServiceAsync.kt | 141 + .../async/api/v1/PublicServiceAsyncImpl.kt | 137 + .../services/async/api/v1/RepoServiceAsync.kt | 355 + .../async/api/v1/RepoServiceAsyncImpl.kt | 388 + .../services/async/api/v1/RunServiceAsync.kt | 421 + .../async/api/v1/RunServiceAsyncImpl.kt | 329 + .../api/v1/ServiceAccountServiceAsync.kt | 210 + .../api/v1/ServiceAccountServiceAsyncImpl.kt | 175 + .../async/api/v1/SessionServiceAsync.kt | 546 + .../async/api/v1/SessionServiceAsyncImpl.kt | 402 + .../async/api/v1/SettingServiceAsync.kt | 110 + .../async/api/v1/SettingServiceAsyncImpl.kt | 124 + .../services/async/api/v1/SsoServiceAsync.kt | 121 + .../async/api/v1/SsoServiceAsyncImpl.kt | 104 + .../async/api/v1/TenantServiceAsync.kt | 111 + .../async/api/v1/TenantServiceAsyncImpl.kt | 125 + .../async/api/v1/TtlSettingServiceAsync.kt | 151 + .../api/v1/TtlSettingServiceAsyncImpl.kt | 124 + .../async/api/v1/UsageLimitServiceAsync.kt | 240 + .../api/v1/UsageLimitServiceAsyncImpl.kt | 207 + .../async/api/v1/WorkspaceServiceAsync.kt | 260 + .../async/api/v1/WorkspaceServiceAsyncImpl.kt | 236 + .../v1/annotationqueues/RunServiceAsync.kt | 301 + .../annotationqueues/RunServiceAsyncImpl.kt | 233 + .../api/v1/apikey/CurrentServiceAsync.kt | 257 + .../api/v1/apikey/CurrentServiceAsyncImpl.kt | 173 + .../v1/bulkexports/DestinationServiceAsync.kt | 191 + .../DestinationServiceAsyncImpl.kt | 173 + .../api/v1/bulkexports/RunServiceAsync.kt | 163 + .../api/v1/bulkexports/RunServiceAsyncImpl.kt | 137 + .../api/v1/charts/SectionServiceAsync.kt | 326 + .../api/v1/charts/SectionServiceAsyncImpl.kt | 250 + .../async/api/v1/comments/LikeServiceAsync.kt | 151 + .../api/v1/comments/LikeServiceAsyncImpl.kt | 150 + .../v1/datasets/ComparativeServiceAsync.kt | 236 + .../datasets/ComparativeServiceAsyncImpl.kt | 173 + .../api/v1/datasets/ExperimentServiceAsync.kt | 97 + .../v1/datasets/ExperimentServiceAsyncImpl.kt | 98 + .../api/v1/datasets/GroupServiceAsync.kt | 92 + .../api/v1/datasets/GroupServiceAsyncImpl.kt | 91 + .../api/v1/datasets/IndexServiceAsync.kt | 348 + .../api/v1/datasets/IndexServiceAsyncImpl.kt | 219 + .../PlaygroundExperimentServiceAsync.kt | 96 + .../PlaygroundExperimentServiceAsyncImpl.kt | 131 + .../async/api/v1/datasets/RunServiceAsync.kt | 153 + .../api/v1/datasets/RunServiceAsyncImpl.kt | 135 + .../api/v1/datasets/ShareServiceAsync.kt | 277 + .../api/v1/datasets/ShareServiceAsyncImpl.kt | 176 + .../api/v1/datasets/SplitServiceAsync.kt | 160 + .../api/v1/datasets/SplitServiceAsyncImpl.kt | 119 + .../api/v1/datasets/VersionServiceAsync.kt | 175 + .../v1/datasets/VersionServiceAsyncImpl.kt | 138 + .../async/api/v1/examples/BulkServiceAsync.kt | 110 + .../api/v1/examples/BulkServiceAsyncImpl.kt | 126 + .../api/v1/examples/ValidateServiceAsync.kt | 128 + .../v1/examples/ValidateServiceAsyncImpl.kt | 125 + .../api/v1/feedback/FormulaServiceAsync.kt | 329 + .../v1/feedback/FormulaServiceAsyncImpl.kt | 252 + .../api/v1/feedback/TokenServiceAsync.kt | 247 + .../api/v1/feedback/TokenServiceAsyncImpl.kt | 212 + .../api/v1/me/OnboardingStateServiceAsync.kt | 218 + .../v1/me/OnboardingStateServiceAsyncImpl.kt | 170 + .../api/v1/orgcharts/SectionServiceAsync.kt | 282 + .../v1/orgcharts/SectionServiceAsyncImpl.kt | 211 + .../async/api/v1/orgs/CurrentServiceAsync.kt | 429 + .../api/v1/orgs/CurrentServiceAsyncImpl.kt | 570 + .../async/api/v1/orgs/MemberServiceAsync.kt | 85 + .../api/v1/orgs/MemberServiceAsyncImpl.kt | 86 + .../async/api/v1/orgs/PendingServiceAsync.kt | 238 + .../api/v1/orgs/PendingServiceAsyncImpl.kt | 173 + .../api/v1/orgs/TtlSettingServiceAsync.kt | 151 + .../api/v1/orgs/TtlSettingServiceAsyncImpl.kt | 124 + .../v1/orgs/current/BillingServiceAsync.kt | 113 + .../orgs/current/BillingServiceAsyncImpl.kt | 123 + .../orgs/current/BusinessInfoServiceAsync.kt | 143 + .../current/BusinessInfoServiceAsyncImpl.kt | 125 + .../api/v1/orgs/current/InfoServiceAsync.kt | 123 + .../v1/orgs/current/InfoServiceAsyncImpl.kt | 124 + .../api/v1/orgs/current/MemberServiceAsync.kt | 382 + .../v1/orgs/current/MemberServiceAsyncImpl.kt | 329 + .../PersonalAccessTokenServiceAsync.kt | 245 + .../PersonalAccessTokenServiceAsyncImpl.kt | 183 + .../api/v1/orgs/current/RoleServiceAsync.kt | 217 + .../v1/orgs/current/RoleServiceAsyncImpl.kt | 207 + .../v1/orgs/current/ServiceKeyServiceAsync.kt | 229 + .../current/ServiceKeyServiceAsyncImpl.kt | 176 + .../v1/orgs/current/SsoSettingServiceAsync.kt | 257 + .../current/SsoSettingServiceAsyncImpl.kt | 224 + .../api/v1/orgs/current/UserServiceAsync.kt | 84 + .../v1/orgs/current/UserServiceAsyncImpl.kt | 84 + .../orgs/current/members/BasicServiceAsync.kt | 64 + .../current/members/BasicServiceAsyncImpl.kt | 86 + .../current/members/PendingServiceAsync.kt | 166 + .../members/PendingServiceAsyncImpl.kt | 138 + .../api/v1/public_/DatasetServiceAsync.kt | 398 + .../api/v1/public_/DatasetServiceAsyncImpl.kt | 286 + .../api/v1/public_/ExampleServiceAsync.kt | 241 + .../api/v1/public_/ExampleServiceAsyncImpl.kt | 182 + .../async/api/v1/public_/RunServiceAsync.kt | 239 + .../api/v1/public_/RunServiceAsyncImpl.kt | 181 + .../api/v1/public_/SchemaServiceAsync.kt | 205 + .../api/v1/public_/SchemaServiceAsyncImpl.kt | 145 + .../v1/public_/datasets/RunServiceAsync.kt | 313 + .../public_/datasets/RunServiceAsyncImpl.kt | 302 + .../v1/repos/OptimizationJobServiceAsync.kt | 335 + .../repos/OptimizationJobServiceAsyncImpl.kt | 311 + .../async/api/v1/repos/TagServiceAsync.kt | 290 + .../async/api/v1/repos/TagServiceAsyncImpl.kt | 294 + .../repos/optimizationjobs/LogServiceAsync.kt | 258 + .../optimizationjobs/LogServiceAsyncImpl.kt | 254 + .../async/api/v1/runs/GroupServiceAsync.kt | 146 + .../api/v1/runs/GroupServiceAsyncImpl.kt | 126 + .../async/api/v1/runs/RuleServiceAsync.kt | 394 + .../async/api/v1/runs/RuleServiceAsyncImpl.kt | 313 + .../async/api/v1/runs/ShareServiceAsync.kt | 266 + .../api/v1/runs/ShareServiceAsyncImpl.kt | 176 + .../api/v1/runs/rules/TriggerServiceAsync.kt | 84 + .../v1/runs/rules/TriggerServiceAsyncImpl.kt | 86 + .../api/v1/sessions/InsightServiceAsync.kt | 407 + .../v1/sessions/InsightServiceAsyncImpl.kt | 346 + .../async/api/v1/sessions/ViewServiceAsync.kt | 317 + .../api/v1/sessions/ViewServiceAsyncImpl.kt | 279 + .../sessions/insights/ConfigServiceAsync.kt | 344 + .../insights/ConfigServiceAsyncImpl.kt | 299 + .../v1/sso/EmailVerificationServiceAsync.kt | 124 + .../sso/EmailVerificationServiceAsyncImpl.kt | 168 + .../api/v1/workspaces/CurrentServiceAsync.kt | 168 + .../v1/workspaces/CurrentServiceAsyncImpl.kt | 195 + .../api/v1/workspaces/PendingServiceAsync.kt | 252 + .../v1/workspaces/PendingServiceAsyncImpl.kt | 182 + .../workspaces/current/MemberServiceAsync.kt | 339 + .../current/MemberServiceAsyncImpl.kt | 318 + .../workspaces/current/SecretServiceAsync.kt | 140 + .../current/SecretServiceAsyncImpl.kt | 164 + .../workspaces/current/SharedServiceAsync.kt | 130 + .../current/SharedServiceAsyncImpl.kt | 125 + .../workspaces/current/TagKeyServiceAsync.kt | 337 + .../current/TagKeyServiceAsyncImpl.kt | 282 + .../v1/workspaces/current/TagServiceAsync.kt | 136 + .../workspaces/current/TagServiceAsyncImpl.kt | 164 + .../workspaces/current/TaggingServiceAsync.kt | 188 + .../current/TaggingServiceAsyncImpl.kt | 176 + .../current/members/PendingServiceAsync.kt | 166 + .../members/PendingServiceAsyncImpl.kt | 138 + .../current/tagkeys/TagValueServiceAsync.kt | 336 + .../tagkeys/TagValueServiceAsyncImpl.kt | 301 + .../ExperimentViewOverrideServiceAsync.kt | 417 + .../ExperimentViewOverrideServiceAsyncImpl.kt | 255 + .../async/platform/AlertServiceAsync.kt | 344 + .../async/platform/AlertServiceAsyncImpl.kt | 262 + .../async/platform/DatasetServiceAsync.kt | 41 + .../async/platform/DatasetServiceAsyncImpl.kt | 42 + .../async/platform/OrgServiceAsync.kt | 37 + .../async/platform/OrgServiceAsyncImpl.kt | 42 + .../platform/datasets/ExampleServiceAsync.kt | 192 + .../datasets/ExampleServiceAsyncImpl.kt | 167 + .../platform/orgs/CurrentServiceAsync.kt | 41 + .../platform/orgs/CurrentServiceAsyncImpl.kt | 44 + .../orgs/current/AccessPolicyServiceAsync.kt | 295 + .../current/AccessPolicyServiceAsyncImpl.kt | 223 + .../accesspolicies/RoleServiceAsync.kt | 109 + .../accesspolicies/RoleServiceAsyncImpl.kt | 86 + .../api/services/blocking/ApiService.kt | 37 + .../api/services/blocking/ApiServiceImpl.kt | 41 + .../api/services/blocking/DatasetService.kt | 37 + .../services/blocking/DatasetServiceImpl.kt | 45 + .../api/services/blocking/FeedbackService.kt | 63 + .../services/blocking/FeedbackServiceImpl.kt | 82 + .../api/services/blocking/PlatformService.kt | 47 + .../services/blocking/PlatformServiceImpl.kt | 66 + .../api/services/blocking/RunService.kt | 256 + .../api/services/blocking/RunServiceImpl.kt | 193 + .../api/services/blocking/api/V1Service.kt | 354 + .../services/blocking/api/V1ServiceImpl.kt | 578 + .../services/blocking/api/v1/AceService.kt | 62 + .../blocking/api/v1/AceServiceImpl.kt | 81 + .../blocking/api/v1/AnnotationQueueService.kt | 826 + .../api/v1/AnnotationQueueServiceImpl.kt | 521 + .../services/blocking/api/v1/ApiKeyService.kt | 241 + .../blocking/api/v1/ApiKeyServiceImpl.kt | 171 + .../blocking/api/v1/BulkExportService.kt | 272 + .../blocking/api/v1/BulkExportServiceImpl.kt | 220 + .../services/blocking/api/v1/ChartService.kt | 292 + .../blocking/api/v1/ChartServiceImpl.kt | 212 + .../blocking/api/v1/CommentService.kt | 149 + .../blocking/api/v1/CommentServiceImpl.kt | 148 + .../services/blocking/api/v1/CommitService.kt | 143 + .../blocking/api/v1/CommitServiceImpl.kt | 139 + .../blocking/api/v1/DatasetService.kt | 1060 ++ .../blocking/api/v1/DatasetServiceImpl.kt | 796 + .../blocking/api/v1/ExampleService.kt | 406 + .../blocking/api/v1/ExampleServiceImpl.kt | 317 + .../blocking/api/v1/FeedbackConfigService.kt | 152 + .../api/v1/FeedbackConfigServiceImpl.kt | 153 + .../blocking/api/v1/FeedbackService.kt | 434 + .../blocking/api/v1/FeedbackServiceImpl.kt | 296 + .../services/blocking/api/v1/InfoService.kt | 128 + .../blocking/api/v1/InfoServiceImpl.kt | 112 + .../api/services/blocking/api/v1/MeService.kt | 85 + .../services/blocking/api/v1/MeServiceImpl.kt | 85 + .../blocking/api/v1/ModelPriceMapService.kt | 259 + .../api/v1/ModelPriceMapServiceImpl.kt | 201 + .../services/blocking/api/v1/OAuthService.kt | 373 + .../blocking/api/v1/OAuthServiceImpl.kt | 202 + .../blocking/api/v1/OrgChartService.kt | 353 + .../blocking/api/v1/OrgChartServiceImpl.kt | 249 + .../services/blocking/api/v1/OrgService.kt | 175 + .../blocking/api/v1/OrgServiceImpl.kt | 200 + .../api/v1/PlaygroundSettingService.kt | 310 + .../api/v1/PlaygroundSettingServiceImpl.kt | 198 + .../services/blocking/api/v1/PromptService.kt | 90 + .../blocking/api/v1/PromptServiceImpl.kt | 119 + .../blocking/api/v1/PromptWebhookService.kt | 379 + .../api/v1/PromptWebhookServiceImpl.kt | 273 + .../services/blocking/api/v1/PublicService.kt | 138 + .../blocking/api/v1/PublicServiceImpl.kt | 133 + .../services/blocking/api/v1/RepoService.kt | 344 + .../blocking/api/v1/RepoServiceImpl.kt | 358 + .../services/blocking/api/v1/RunService.kt | 420 + .../blocking/api/v1/RunServiceImpl.kt | 300 + .../blocking/api/v1/ServiceAccountService.kt | 213 + .../api/v1/ServiceAccountServiceImpl.kt | 163 + .../blocking/api/v1/SessionService.kt | 545 + .../blocking/api/v1/SessionServiceImpl.kt | 377 + .../blocking/api/v1/SettingService.kt | 105 + .../blocking/api/v1/SettingServiceImpl.kt | 117 + .../services/blocking/api/v1/SsoService.kt | 119 + .../blocking/api/v1/SsoServiceImpl.kt | 99 + .../services/blocking/api/v1/TenantService.kt | 105 + .../blocking/api/v1/TenantServiceImpl.kt | 118 + .../blocking/api/v1/TtlSettingService.kt | 151 + .../blocking/api/v1/TtlSettingServiceImpl.kt | 117 + .../blocking/api/v1/UsageLimitService.kt | 236 + .../blocking/api/v1/UsageLimitServiceImpl.kt | 194 + .../blocking/api/v1/WorkspaceService.kt | 252 + .../blocking/api/v1/WorkspaceServiceImpl.kt | 223 + .../api/v1/annotationqueues/RunService.kt | 299 + .../api/v1/annotationqueues/RunServiceImpl.kt | 219 + .../blocking/api/v1/apikey/CurrentService.kt | 250 + .../api/v1/apikey/CurrentServiceImpl.kt | 163 + .../api/v1/bulkexports/DestinationService.kt | 189 + .../v1/bulkexports/DestinationServiceImpl.kt | 163 + .../blocking/api/v1/bulkexports/RunService.kt | 162 + .../api/v1/bulkexports/RunServiceImpl.kt | 126 + .../blocking/api/v1/charts/SectionService.kt | 322 + .../api/v1/charts/SectionServiceImpl.kt | 234 + .../blocking/api/v1/comments/LikeService.kt | 148 + .../api/v1/comments/LikeServiceImpl.kt | 142 + .../api/v1/datasets/ComparativeService.kt | 234 + .../api/v1/datasets/ComparativeServiceImpl.kt | 163 + .../api/v1/datasets/ExperimentService.kt | 93 + .../api/v1/datasets/ExperimentServiceImpl.kt | 94 + .../blocking/api/v1/datasets/GroupService.kt | 89 + .../api/v1/datasets/GroupServiceImpl.kt | 84 + .../blocking/api/v1/datasets/IndexService.kt | 340 + .../api/v1/datasets/IndexServiceImpl.kt | 200 + .../datasets/PlaygroundExperimentService.kt | 97 + .../PlaygroundExperimentServiceImpl.kt | 121 + .../blocking/api/v1/datasets/RunService.kt | 151 + .../api/v1/datasets/RunServiceImpl.kt | 127 + .../blocking/api/v1/datasets/ShareService.kt | 269 + .../api/v1/datasets/ShareServiceImpl.kt | 166 + .../blocking/api/v1/datasets/SplitService.kt | 154 + .../api/v1/datasets/SplitServiceImpl.kt | 106 + .../api/v1/datasets/VersionService.kt | 170 + .../api/v1/datasets/VersionServiceImpl.kt | 131 + .../blocking/api/v1/examples/BulkService.kt | 109 + .../api/v1/examples/BulkServiceImpl.kt | 118 + .../api/v1/examples/ValidateService.kt | 124 + .../api/v1/examples/ValidateServiceImpl.kt | 118 + .../api/v1/feedback/FormulaService.kt | 318 + .../api/v1/feedback/FormulaServiceImpl.kt | 236 + .../blocking/api/v1/feedback/TokenService.kt | 241 + .../api/v1/feedback/TokenServiceImpl.kt | 199 + .../api/v1/me/OnboardingStateService.kt | 218 + .../api/v1/me/OnboardingStateServiceImpl.kt | 158 + .../api/v1/orgcharts/SectionService.kt | 279 + .../api/v1/orgcharts/SectionServiceImpl.kt | 198 + .../blocking/api/v1/orgs/CurrentService.kt | 430 + .../api/v1/orgs/CurrentServiceImpl.kt | 531 + .../blocking/api/v1/orgs/MemberService.kt | 83 + .../blocking/api/v1/orgs/MemberServiceImpl.kt | 82 + .../blocking/api/v1/orgs/PendingService.kt | 233 + .../api/v1/orgs/PendingServiceImpl.kt | 160 + .../blocking/api/v1/orgs/TtlSettingService.kt | 151 + .../api/v1/orgs/TtlSettingServiceImpl.kt | 117 + .../api/v1/orgs/current/BillingService.kt | 108 + .../api/v1/orgs/current/BillingServiceImpl.kt | 116 + .../v1/orgs/current/BusinessInfoService.kt | 146 + .../orgs/current/BusinessInfoServiceImpl.kt | 118 + .../api/v1/orgs/current/InfoService.kt | 121 + .../api/v1/orgs/current/InfoServiceImpl.kt | 113 + .../api/v1/orgs/current/MemberService.kt | 379 + .../api/v1/orgs/current/MemberServiceImpl.kt | 310 + .../current/PersonalAccessTokenService.kt | 246 + .../current/PersonalAccessTokenServiceImpl.kt | 168 + .../api/v1/orgs/current/RoleService.kt | 218 + .../api/v1/orgs/current/RoleServiceImpl.kt | 181 + .../api/v1/orgs/current/ServiceKeyService.kt | 227 + .../v1/orgs/current/ServiceKeyServiceImpl.kt | 166 + .../api/v1/orgs/current/SsoSettingService.kt | 253 + .../v1/orgs/current/SsoSettingServiceImpl.kt | 211 + .../api/v1/orgs/current/UserService.kt | 85 + .../api/v1/orgs/current/UserServiceImpl.kt | 79 + .../v1/orgs/current/members/BasicService.kt | 62 + .../orgs/current/members/BasicServiceImpl.kt | 82 + .../v1/orgs/current/members/PendingService.kt | 159 + .../current/members/PendingServiceImpl.kt | 131 + .../blocking/api/v1/public_/DatasetService.kt | 391 + .../api/v1/public_/DatasetServiceImpl.kt | 270 + .../blocking/api/v1/public_/ExampleService.kt | 239 + .../api/v1/public_/ExampleServiceImpl.kt | 169 + .../blocking/api/v1/public_/RunService.kt | 233 + .../blocking/api/v1/public_/RunServiceImpl.kt | 164 + .../blocking/api/v1/public_/SchemaService.kt | 211 + .../api/v1/public_/SchemaServiceImpl.kt | 138 + .../api/v1/public_/datasets/RunService.kt | 310 + .../api/v1/public_/datasets/RunServiceImpl.kt | 279 + .../api/v1/repos/OptimizationJobService.kt | 337 + .../v1/repos/OptimizationJobServiceImpl.kt | 293 + .../blocking/api/v1/repos/TagService.kt | 286 + .../blocking/api/v1/repos/TagServiceImpl.kt | 265 + .../v1/repos/optimizationjobs/LogService.kt | 253 + .../repos/optimizationjobs/LogServiceImpl.kt | 240 + .../blocking/api/v1/runs/GroupService.kt | 143 + .../blocking/api/v1/runs/GroupServiceImpl.kt | 119 + .../blocking/api/v1/runs/RuleService.kt | 391 + .../blocking/api/v1/runs/RuleServiceImpl.kt | 287 + .../blocking/api/v1/runs/ShareService.kt | 260 + .../blocking/api/v1/runs/ShareServiceImpl.kt | 163 + .../api/v1/runs/rules/TriggerService.kt | 79 + .../api/v1/runs/rules/TriggerServiceImpl.kt | 82 + .../api/v1/sessions/InsightService.kt | 396 + .../api/v1/sessions/InsightServiceImpl.kt | 327 + .../blocking/api/v1/sessions/ViewService.kt | 309 + .../api/v1/sessions/ViewServiceImpl.kt | 250 + .../api/v1/sessions/insights/ConfigService.kt | 334 + .../v1/sessions/insights/ConfigServiceImpl.kt | 283 + .../api/v1/sso/EmailVerificationService.kt | 125 + .../v1/sso/EmailVerificationServiceImpl.kt | 156 + .../api/v1/workspaces/CurrentService.kt | 165 + .../api/v1/workspaces/CurrentServiceImpl.kt | 188 + .../api/v1/workspaces/PendingService.kt | 245 + .../api/v1/workspaces/PendingServiceImpl.kt | 172 + .../v1/workspaces/current/MemberService.kt | 334 + .../workspaces/current/MemberServiceImpl.kt | 296 + .../v1/workspaces/current/SecretService.kt | 135 + .../workspaces/current/SecretServiceImpl.kt | 154 + .../v1/workspaces/current/SharedService.kt | 125 + .../workspaces/current/SharedServiceImpl.kt | 118 + .../v1/workspaces/current/TagKeyService.kt | 328 + .../workspaces/current/TagKeyServiceImpl.kt | 257 + .../api/v1/workspaces/current/TagService.kt | 135 + .../v1/workspaces/current/TagServiceImpl.kt | 153 + .../v1/workspaces/current/TaggingService.kt | 184 + .../workspaces/current/TaggingServiceImpl.kt | 163 + .../current/members/PendingService.kt | 159 + .../current/members/PendingServiceImpl.kt | 131 + .../current/tagkeys/TagValueService.kt | 331 + .../current/tagkeys/TagValueServiceImpl.kt | 282 + .../datasets/ExperimentViewOverrideService.kt | 413 + .../ExperimentViewOverrideServiceImpl.kt | 236 + .../blocking/platform/AlertService.kt | 335 + .../blocking/platform/AlertServiceImpl.kt | 243 + .../blocking/platform/DatasetService.kt | 37 + .../blocking/platform/DatasetServiceImpl.kt | 42 + .../services/blocking/platform/OrgService.kt | 37 + .../blocking/platform/OrgServiceImpl.kt | 41 + .../platform/datasets/ExampleService.kt | 187 + .../platform/datasets/ExampleServiceImpl.kt | 157 + .../blocking/platform/orgs/CurrentService.kt | 37 + .../platform/orgs/CurrentServiceImpl.kt | 44 + .../orgs/current/AccessPolicyService.kt | 291 + .../orgs/current/AccessPolicyServiceImpl.kt | 208 + .../current/accesspolicies/RoleService.kt | 103 + .../current/accesspolicies/RoleServiceImpl.kt | 79 + .../proguard/langsmith-api-java-core.pro | 32 + .../langsmith_api/api/TestServerExtension.kt | 62 + .../api/core/ClientOptionsTest.kt | 39 + .../api/core/ObjectMappersTest.kt | 102 + .../api/core/PhantomReachableTest.kt | 27 + .../com/langsmith_api/api/core/UtilsTest.kt | 33 + .../com/langsmith_api/api/core/ValuesTest.kt | 144 + .../api/core/http/AsyncStreamResponseTest.kt | 268 + .../api/core/http/HeadersTest.kt | 242 + .../api/core/http/QueryParamsTest.kt | 180 + .../api/core/http/RetryingHttpClientTest.kt | 356 + .../api/models/api/v1/V1EventsParamsTest.kt | 53 + .../api/models/api/v1/V1EventsResponseTest.kt | 30 + .../api/models/api/v1/V1LoginParamsTest.kt | 13 + .../api/models/api/v1/V1LoginResponseTest.kt | 32 + .../models/api/v1/V1RetrieveOkParamsTest.kt | 13 + .../models/api/v1/V1RetrieveOkResponseTest.kt | 30 + .../api/models/api/v1/V1UpdateParamsTest.kt | 33 + .../api/models/api/v1/V1UpdateResponseTest.kt | 32 + .../models/api/v1/ace/AceExecuteParamsTest.kt | 35 + .../api/v1/ace/AceExecuteResponseTest.kt | 30 + ...notationQueueAnnotationQueuesParamsTest.kt | 120 + .../AnnotationQueueDeleteParamsTest.kt | 28 + .../AnnotationQueueDeleteResponseTest.kt | 31 + .../AnnotationQueueExportParamsTest.kt | 56 + .../AnnotationQueueExportResponseTest.kt | 31 + .../AnnotationQueuePopulateParamsTest.kt | 31 + .../AnnotationQueuePopulateResponseTest.kt | 31 + ...QueueRetrieveAnnotationQueuesParamsTest.kt | 64 + ...eueRetrieveAnnotationQueuesResponseTest.kt | 87 + .../AnnotationQueueRetrieveParamsTest.kt | 61 + ...AnnotationQueueRetrieveQueuesParamsTest.kt | 28 + .../AnnotationQueueRetrieveSizeParamsTest.kt | 28 + ...ionQueueRetrieveTotalArchivedParamsTest.kt | 64 + ...otationQueueRetrieveTotalSizeParamsTest.kt | 28 + .../AnnotationQueueRubricItemSchemaTest.kt | 75 + .../AnnotationQueueSchemaTest.kt | 78 + .../AnnotationQueueSizeSchemaTest.kt | 32 + .../AnnotationQueueUpdateParamsTest.kt | 57 + .../AnnotationQueueUpdateResponseTest.kt | 31 + .../RunSchemaWithAnnotationQueueInfoTest.kt | 312 + .../runs/RunCreateParamsTest.kt | 43 + .../runs/RunCreateResponseTest.kt | 53 + .../runs/RunDeleteParamsTest.kt | 57 + .../runs/RunDeleteResponseTest.kt | 30 + .../runs/RunListParamsTest.kt | 63 + .../runs/RunUpdateParamsTest.kt | 62 + .../runs/RunUpdateResponseTest.kt | 30 + .../api/v1/apikey/ApiKeyApiKeyParamsTest.kt | 69 + .../api/v1/apikey/ApiKeyDeleteParamsTest.kt | 24 + .../apikey/ApiKeyRetrieveApiKeyParamsTest.kt | 13 + .../apikey/current/CurrentCreateParamsTest.kt | 69 + .../apikey/current/CurrentDeleteParamsTest.kt | 24 + .../apikey/current/CurrentListParamsTest.kt | 13 + .../BulkExportBulkExportsParamsTest.kt | 66 + ...BulkExportRetrieveBulkExportsParamsTest.kt | 13 + .../BulkExportRetrieveParamsTest.kt | 28 + .../api/v1/bulkexports/BulkExportTest.kt | 86 + .../bulkexports/BulkExportUpdateParamsTest.kt | 38 + .../BulkExportDestinationS3ConfigTest.kt | 53 + .../destinations/BulkExportDestinationTest.kt | 89 + .../DestinationCreateParamsTest.kt | 96 + .../destinations/DestinationListParamsTest.kt | 13 + .../DestinationRetrieveParamsTest.kt | 28 + .../v1/bulkexports/runs/BulkExportRunTest.kt | 110 + .../v1/bulkexports/runs/RunListParamsTest.kt | 24 + .../bulkexports/runs/RunRetrieveParamsTest.kt | 31 + .../api/v1/charts/ChartCreateParamsTest.kt | 189 + .../api/v1/charts/ChartDeleteParamsTest.kt | 24 + .../api/v1/charts/ChartDeleteResponseTest.kt | 30 + .../api/v1/charts/ChartPreviewParamsTest.kt | 227 + .../api/v1/charts/ChartUpdateParamsTest.kt | 191 + .../api/v1/charts/CustomChartCreateTest.kt | 153 + .../charts/CustomChartPreviewRequestTest.kt | 181 + .../api/v1/charts/CustomChartResponseTest.kt | 138 + .../v1/charts/CustomChartSeriesFiltersTest.kt | 49 + .../api/v1/charts/CustomChartSeriesTest.kt | 103 + .../api/v1/charts/CustomChartUpdateTest.kt | 170 + .../v1/charts/CustomChartsDataPointTest.kt | 50 + .../api/v1/charts/CustomChartsRequestTest.kt | 63 + .../api/v1/charts/CustomChartsResponseTest.kt | 424 + .../SingleCustomChartResponseBaseTest.kt | 62 + .../charts/SingleCustomChartResponseTest.kt | 185 + .../section/CustomChartsSectionCreateTest.kt | 44 + .../CustomChartsSectionResponseTest.kt | 60 + .../section/CustomChartsSectionUpdateTest.kt | 47 + .../charts/section/SectionCloneParamsTest.kt | 38 + .../charts/section/SectionCreateParamsTest.kt | 61 + .../charts/section/SectionDeleteParamsTest.kt | 24 + .../section/SectionDeleteResponseTest.kt | 30 + .../charts/section/SectionListParamsTest.kt | 64 + .../charts/section/SectionUpdateParamsTest.kt | 75 + .../v1/comments/CommentRetrieveParamsTest.kt | 68 + .../api/models/api/v1/comments/CommentTest.kt | 66 + .../v1/comments/CommentUpdateParamsTest.kt | 51 + .../v1/comments/CreateCommentRequestTest.kt | 32 + .../v1/comments/ListCommentsResponseTest.kt | 85 + .../v1/comments/like/LikeCreateParamsTest.kt | 34 + .../comments/like/LikeCreateResponseTest.kt | 30 + .../comments/like/LikeDeleteAllParamsTest.kt | 34 + .../like/LikeDeleteAllResponseTest.kt | 30 + .../v1/commits/CommitManifestResponseTest.kt | 73 + .../v1/commits/CommitRetrieveParamsTest.kt | 68 + .../api/v1/commits/CommitUpdateParamsTest.kt | 73 + .../v1/commits/CommitUpdateResponseTest.kt | 86 + .../api/v1/commits/CommitWithLookupsTest.kt | 76 + .../api/v1/datasets/DatasetCloneParamsTest.kt | 59 + .../v1/datasets/DatasetCloneResponseTest.kt | 30 + .../v1/datasets/DatasetCreateParamsTest.kt | 89 + .../v1/datasets/DatasetDeleteParamsTest.kt | 24 + .../v1/datasets/DatasetDeleteResponseTest.kt | 30 + .../v1/datasets/DatasetGenerateParamsTest.kt | 61 + .../datasets/DatasetGenerateResponseTest.kt | 30 + .../api/v1/datasets/DatasetListParamsTest.kt | 76 + .../datasets/DatasetRetrieveCsvParamsTest.kt | 57 + .../DatasetRetrieveCsvResponseTest.kt | 30 + .../DatasetRetrieveJsonlParamsTest.kt | 57 + .../DatasetRetrieveJsonlResponseTest.kt | 30 + .../DatasetRetrieveOpenAIFtParamsTest.kt | 57 + .../DatasetRetrieveOpenAIFtResponseTest.kt | 31 + .../DatasetRetrieveOpenAIParamsTest.kt | 57 + .../DatasetRetrieveOpenAIResponseTest.kt | 31 + .../v1/datasets/DatasetRetrieveParamsTest.kt | 26 + .../DatasetRetrieveVersionParamsTest.kt | 64 + .../v1/datasets/DatasetSearchParamsTest.kt | 66 + .../v1/datasets/DatasetSearchResponseTest.kt | 61 + .../DatasetStudioExperimentParamsTest.kt | 50 + .../DatasetStudioExperimentResponseTest.kt | 31 + .../api/models/api/v1/datasets/DatasetTest.kt | 105 + .../v1/datasets/DatasetTransformationTest.kt | 46 + .../v1/datasets/DatasetUpdateParamsTest.kt | 174 + .../v1/datasets/DatasetUpdateResponseTest.kt | 94 + .../datasets/DatasetUpdateTagsParamsTest.kt | 53 + .../DatasetUploadExperimentParamsTest.kt | 325 + .../DatasetUploadExperimentResponseTest.kt | 221 + .../v1/datasets/DatasetUploadParamsTest.kt | 111 + .../api/v1/datasets/DatasetVersionTest.kt | 44 + .../datasets/FeedbackCreateCoreSchemaTest.kt | 134 + .../api/models/api/v1/datasets/MissingTest.kt | 27 + .../ComparativeCreateParamsTest.kt | 65 + .../ComparativeCreateResponseTest.kt | 66 + .../ComparativeDeleteParamsTest.kt | 28 + .../ComparativeDeleteResponseTest.kt | 30 + .../comparative/ComparativeListParamsTest.kt | 78 + .../ComparativeListResponseTest.kt | 88 + .../comparative/SimpleExperimentInfoTest.kt | 41 + .../ExperimentGroupedParamsTest.kt | 80 + .../ExperimentGroupedResponseTest.kt | 30 + .../v1/datasets/group/GroupRunsParamsTest.kt | 80 + .../datasets/group/GroupRunsResponseTest.kt | 458 + .../datasets/index/IndexCreateParamsTest.kt | 48 + .../datasets/index/IndexCreateResponseTest.kt | 30 + .../index/IndexDeleteAllParamsTest.kt | 24 + .../index/IndexDeleteAllResponseTest.kt | 30 + .../v1/datasets/index/IndexListParamsTest.kt | 24 + .../datasets/index/IndexListResponseTest.kt | 46 + .../v1/datasets/index/IndexSyncParamsTest.kt | 24 + .../datasets/index/IndexSyncResponseTest.kt | 30 + .../PlaygroundExperimentBatchParamsTest.kt | 164 + .../PlaygroundExperimentBatchResponseTest.kt | 31 + .../PlaygroundExperimentStreamParamsTest.kt | 161 + .../PlaygroundExperimentStreamResponseTest.kt | 33 + .../RunnableConfigTest.kt | 64 + .../v1/datasets/runs/ExampleWithRunsChTest.kt | 204 + .../v1/datasets/runs/ExampleWithRunsTest.kt | 308 + .../runs/QueryExampleSchemaWithRunsTest.kt | 92 + .../datasets/runs/QueryFeedbackDeltaTest.kt | 73 + .../v1/datasets/runs/RunCreateParamsTest.kt | 185 + .../v1/datasets/runs/RunCreateResponseTest.kt | 404 + .../v1/datasets/runs/RunDeltaParamsTest.kt | 119 + .../datasets/runs/SessionFeedbackDeltaTest.kt | 82 + .../datasets/share/DatasetShareSchemaTest.kt | 42 + .../datasets/share/ShareCreateParamsTest.kt | 52 + .../share/ShareDeleteAllParamsTest.kt | 24 + .../share/ShareDeleteAllResponseTest.kt | 30 + .../v1/datasets/share/ShareListParamsTest.kt | 24 + .../datasets/splits/SplitCreateParamsTest.kt | 65 + .../v1/datasets/splits/SplitListParamsTest.kt | 53 + .../versions/VersionListParamsTest.kt | 65 + .../versions/VersionRetrieveDiffParamsTest.kt | 54 + .../VersionRetrieveDiffResponseTest.kt | 47 + .../v1/examples/AttachmentsOperationsTest.kt | 56 + .../v1/examples/ExampleCreateParamsTest.kt | 13 + .../v1/examples/ExampleDeleteAllParamsTest.kt | 37 + .../examples/ExampleDeleteAllResponseTest.kt | 30 + .../v1/examples/ExampleDeleteParamsTest.kt | 24 + .../v1/examples/ExampleDeleteResponseTest.kt | 30 + .../api/v1/examples/ExampleListParamsTest.kt | 80 + .../ExampleRetrieveCountParamsTest.kt | 62 + .../v1/examples/ExampleRetrieveParamsTest.kt | 57 + .../api/models/api/v1/examples/ExampleTest.kt | 64 + .../v1/examples/ExampleUpdateParamsTest.kt | 100 + .../v1/examples/bulk/BulkCreateParamsTest.kt | 13 + .../examples/bulk/BulkCreateResponseTest.kt | 30 + .../examples/bulk/BulkPatchAllParamsTest.kt | 110 + .../examples/bulk/BulkPatchAllResponseTest.kt | 30 + .../validate/ExampleValidationResultTest.kt | 74 + .../validate/ValidateBulkParamsTest.kt | 13 + .../validate/ValidateCreateParamsTest.kt | 13 + .../api/v1/feedback/ApiFeedbackSourceTest.kt | 42 + .../api/v1/feedback/AppFeedbackSourceTest.kt | 42 + .../v1/feedback/AutoEvalFeedbackSourceTest.kt | 43 + .../v1/feedback/FeedbackCreateParamsTest.kt | 143 + .../v1/feedback/FeedbackCreateSchemaTest.kt | 138 + .../v1/feedback/FeedbackDeleteParamsTest.kt | 26 + .../v1/feedback/FeedbackDeleteResponseTest.kt | 30 + .../v1/feedback/FeedbackEagerParamsTest.kt | 143 + .../api/v1/feedback/FeedbackListParamsTest.kt | 83 + .../v1/feedback/FeedbackRetrieveParamsTest.kt | 56 + .../api/v1/feedback/FeedbackSchemaTest.kt | 119 + .../v1/feedback/FeedbackUpdateParamsTest.kt | 93 + .../v1/feedback/ModelFeedbackSourceTest.kt | 42 + .../feedback/formulas/FeedbackFormulaTest.kt | 67 + .../FeedbackFormulaWeightedVariableTest.kt | 36 + .../formulas/FormulaCreateParamsTest.kt | 62 + .../formulas/FormulaDeleteParamsTest.kt | 28 + .../formulas/FormulaDeleteResponseTest.kt | 30 + .../formulas/FormulaListParamsTest.kt | 52 + .../formulas/FormulaRetrieveParamsTest.kt | 28 + .../formulas/FormulaUpdateParamsTest.kt | 56 + .../FeedbackIngestTokenCreateSchemaTest.kt | 83 + .../tokens/FeedbackIngestTokenSchemaTest.kt | 49 + .../feedback/tokens/TokenCreateParamsTest.kt | 110 + .../tokens/TokenCreateResponseTest.kt | 118 + .../v1/feedback/tokens/TokenListParamsTest.kt | 27 + .../tokens/TokenRetrieveParamsTest.kt | 65 + .../tokens/TokenRetrieveResponseTest.kt | 30 + .../feedback/tokens/TokenUpdateParamsTest.kt | 64 + .../tokens/TokenUpdateResponseTest.kt | 30 + ...FeedbackConfigFeedbackConfigsParamsTest.kt | 75 + ...ConfigRetrieveFeedbackConfigsParamsTest.kt | 46 + .../FeedbackConfigSchemaTest.kt | 79 + .../v1/feedbackconfigs/FeedbackConfigTest.kt | 49 + ...ckConfigUpdateFeedbackConfigsParamsTest.kt | 68 + .../models/api/v1/info/InfoListParamsTest.kt | 13 + .../api/v1/info/InfoListResponseTest.kt | 98 + .../v1/info/InfoRetrieveHealthParamsTest.kt | 13 + .../v1/info/InfoRetrieveHealthResponseTest.kt | 34 + .../api/v1/me/MeRetrieveLsUserIdParamsTest.kt | 13 + .../OnboardingStateCreateParamsTest.kt | 13 + .../OnboardingStateListParamsTest.kt | 13 + .../OnboardingStateUpdateParamsTest.kt | 23 + .../UserOnboardingStateResponseTest.kt | 72 + .../ModelPriceMapDeleteParamsTest.kt | 24 + .../ModelPriceMapDeleteResponseTest.kt | 30 + .../ModelPriceMapModelPriceMapParamsTest.kt | 103 + .../ModelPriceMapModelPriceMapResponseTest.kt | 33 + ...PriceMapRetrieveModelPriceMapParamsTest.kt | 13 + ...iceMapRetrieveModelPriceMapResponseTest.kt | 33 + .../ModelPriceMapUpdateParamsTest.kt | 120 + .../ModelPriceMapUpdateResponseTest.kt | 30 + .../oauth/OAuthRetrieveCallbackParamsTest.kt | 24 + .../OAuthRetrieveCallbackResponseTest.kt | 31 + .../OAuthRetrieveCurrentUserParamsTest.kt | 24 + .../OAuthRetrieveCurrentUserResponseTest.kt | 31 + .../v1/oauth/OAuthRetrieveLogoutParamsTest.kt | 23 + .../oauth/OAuthRetrieveLogoutResponseTest.kt | 30 + .../api/v1/oauth/OAuthRetrieveParamsTest.kt | 23 + .../api/v1/oauth/OAuthRetrieveResponseTest.kt | 30 + .../v1/orgcharts/OrgChartCreateParamsTest.kt | 194 + .../v1/orgcharts/OrgChartDeleteParamsTest.kt | 24 + .../orgcharts/OrgChartDeleteResponseTest.kt | 30 + .../orgcharts/OrgChartOrgChartsParamsTest.kt | 74 + .../v1/orgcharts/OrgChartPreviewParamsTest.kt | 232 + .../v1/orgcharts/OrgChartUpdateParamsTest.kt | 196 + .../section/CustomChartsRequestBaseTest.kt | 55 + .../section/SectionCreateParamsTest.kt | 62 + .../section/SectionDeleteParamsTest.kt | 24 + .../section/SectionDeleteResponseTest.kt | 30 + .../section/SectionListParamsTest.kt | 64 + .../section/SectionUpdateParamsTest.kt | 76 + .../models/api/v1/orgs/OrgCreateParamsTest.kt | 24 + .../models/api/v1/orgs/OrgListParamsTest.kt | 36 + .../orgs/OrgRetrievePermissionsParamsTest.kt | 13 + .../OrgRetrievePermissionsResponseTest.kt | 46 + .../v1/orgs/OrganizationPgSchemaSlimTest.kt | 88 + ...firmCheckoutSessionCompletionParamsTest.kt | 28 + ...rmCheckoutSessionCompletionResponseTest.kt | 33 + .../v1/orgs/current/CurrentListParamsTest.kt | 13 + .../orgs/current/CurrentListResponseTest.kt | 323 + .../current/CurrentPaymentMethodParamsTest.kt | 113 + .../CurrentPaymentMethodResponseTest.kt | 30 + .../v1/orgs/current/CurrentPlanParamsTest.kt | 23 + .../orgs/current/CurrentPlanResponseTest.kt | 30 + .../CurrentRetrieveDashboardParamsTest.kt | 34 + .../CurrentRetrieveDashboardResponseTest.kt | 35 + ...CurrentSetDefaultSsoProvisionParamsTest.kt | 13 + ...rrentSetDefaultSsoProvisionResponseTest.kt | 33 + .../v1/orgs/current/CurrentSetupParamsTest.kt | 13 + .../orgs/current/CurrentSetupResponseTest.kt | 34 + .../CurrentStripeAccountLinksParamsTest.kt | 23 + .../CurrentStripeAccountLinksResponseTest.kt | 31 + .../CurrentStripeCheckoutSessionParamsTest.kt | 31 + ...urrentStripeCheckoutSessionResponseTest.kt | 33 + .../CurrentUpdateLoginMethodsParamsTest.kt | 23 + .../CurrentUpdateLoginMethodsResponseTest.kt | 31 + .../current/CustomerVisiblePlanInfoTest.kt | 48 + .../v1/orgs/current/OrganizationConfigTest.kt | 198 + .../orgs/current/StripeCustomerAddressTest.kt | 53 + .../current/StripePaymentMethodInfoTest.kt | 50 + .../models/api/v1/orgs/current/WalletTest.kt | 30 + .../current/billing/BillingListParamsTest.kt | 13 + .../billing/BillingListResponseTest.kt | 315 + .../billing/BillingRetrieveUsageParamsTest.kt | 60 + .../BillingRetrieveUsageResponseTest.kt | 71 + .../BusinessInfoBusinessInfoParamsTest.kt | 88 + .../BusinessInfoBusinessInfoResponseTest.kt | 31 + ...inessInfoRetrieveBusinessInfoParamsTest.kt | 13 + ...essInfoRetrieveBusinessInfoResponseTest.kt | 94 + .../StripeBusinessBillingInfoTest.kt | 70 + .../current/businessinfo/StripeTaxIdTest.kt | 33 + .../orgs/current/info/InfoListParamsTest.kt | 13 + .../current/info/InfoPatchAllParamsTest.kt | 50 + .../orgs/current/info/OrganizationInfoTest.kt | 260 + .../current/members/MemberBatchParamsTest.kt | 71 + .../current/members/MemberCreateParamsTest.kt | 71 + .../current/members/MemberDeleteParamsTest.kt | 24 + .../members/MemberDeleteResponseTest.kt | 30 + .../current/members/MemberListParamsTest.kt | 13 + .../current/members/MemberListResponseTest.kt | 224 + .../members/MemberRetrieveActiveParamsTest.kt | 61 + .../current/members/MemberUpdateParamsTest.kt | 54 + .../members/MemberUpdateResponseTest.kt | 30 + .../current/members/OrgMemberIdentityTest.kt | 147 + .../members/PendingIdentityCreateTest.kt | 59 + .../current/members/PendingIdentityTest.kt | 89 + .../members/basic/BasicBatchParamsTest.kt | 77 + .../members/basic/BasicBatchResponseTest.kt | 62 + .../members/pending/OrgPendingIdentityTest.kt | 94 + .../pending/PendingDeleteAllParamsTest.kt | 26 + .../pending/PendingDeleteAllResponseTest.kt | 30 + .../members/pending/PendingListParamsTest.kt | 40 + .../PersonalAccessTokenDeleteParamsTest.kt | 28 + ...cessTokenPersonalAccessTokensParamsTest.kt | 73 + ...nRetrievePersonalAccessTokensParamsTest.kt | 13 + .../current/roles/RoleCreateParamsTest.kt | 34 + .../current/roles/RoleDeleteParamsTest.kt | 24 + .../orgs/current/roles/RoleListParamsTest.kt | 13 + .../api/v1/orgs/current/roles/RoleTest.kt | 54 + .../current/roles/RoleUpdateParamsTest.kt | 51 + .../servicekeys/ApiKeyCreateRequestTest.kt | 61 + .../servicekeys/ApiKeyCreateResponseTest.kt | 67 + .../servicekeys/ApiKeyGetResponseTest.kt | 64 + .../servicekeys/ServiceKeyDeleteParamsTest.kt | 26 + ...ServiceKeyRetrieveServiceKeysParamsTest.kt | 13 + .../ServiceKeyServiceKeysParamsTest.kt | 72 + .../current/ssosettings/SsoProviderTest.kt | 58 + .../ssosettings/SsoSettingDeleteParamsTest.kt | 24 + ...SsoSettingRetrieveSsoSettingsParamsTest.kt | 13 + .../SsoSettingSsoSettingsParamsTest.kt | 70 + .../ssosettings/SsoSettingUpdateParamsTest.kt | 59 + .../orgs/current/user/ProviderUserSlimTest.kt | 87 + .../UserRetrieveLoginMethodsParamsTest.kt | 13 + .../members/MemberUpdateBasicParamsTest.kt | 32 + .../members/MemberUpdateBasicResponseTest.kt | 30 + .../api/v1/orgs/pending/IdentityTest.kt | 67 + .../v1/orgs/pending/PendingClaimParamsTest.kt | 26 + .../orgs/pending/PendingDeleteParamsTest.kt | 26 + .../orgs/pending/PendingDeleteResponseTest.kt | 30 + .../v1/orgs/pending/PendingListParamsTest.kt | 13 + ...TtlSettingRetrieveTtlSettingsParamsTest.kt | 13 + .../TtlSettingUpdateTtlSettingsParamsTest.kt | 64 + .../v1/orgs/ttlsettings/TtlSettingsTest.kt | 62 + .../UpsertTtlSettingsRequestTest.kt | 45 + .../PlaygroundSavedOptionsTest.kt | 32 + .../PlaygroundSettingDeleteParamsTest.kt | 28 + .../PlaygroundSettingDeleteResponseTest.kt | 31 + ...oundSettingPlaygroundSettingsParamsTest.kt | 51 + ...ingRetrievePlaygroundSettingsParamsTest.kt | 13 + .../PlaygroundSettingUpdateParamsTest.kt | 63 + .../PlaygroundSettingsResponseTest.kt | 63 + .../api/v1/prompts/InvalidToolCallTest.kt | 54 + .../api/v1/prompts/PromptCanvasParamsTest.kt | 295 + .../v1/prompts/PromptCanvasResponseTest.kt | 30 + .../prompts/PromptInvokePromptParamsTest.kt | 45 + .../prompts/PromptInvokePromptResponseTest.kt | 30 + .../api/models/api/v1/prompts/ToolCallTest.kt | 48 + .../api/v1/prompts/UsageMetadataTest.kt | 74 + .../PromptWebhookDeleteParamsTest.kt | 28 + .../PromptWebhookDeleteResponseTest.kt | 30 + .../PromptWebhookPromptWebhooksParamsTest.kt | 56 + .../PromptWebhookRetrieveParamsTest.kt | 28 + ...WebhookRetrievePromptWebhooksParamsTest.kt | 13 + .../v1/promptwebhooks/PromptWebhookTest.kt | 70 + .../PromptWebhookTestParamsTest.kt | 129 + .../PromptWebhookTestResponseTest.kt | 37 + .../PromptWebhookUpdateParamsTest.kt | 68 + .../PublicRetrieveFeedbacksParamsTest.kt | 92 + .../public_/datasets/DatasetListParamsTest.kt | 66 + .../datasets/DatasetListResponseTest.kt | 95 + .../DatasetRetrieveComparativeParamsTest.kt | 76 + .../DatasetRetrieveComparativeResponseTest.kt | 84 + .../DatasetRetrieveFeedbackParamsTest.kt | 92 + .../DatasetRetrieveSessionsBulkParamsTest.kt | 29 + .../DatasetRetrieveSessionsParamsTest.kt | 126 + .../datasets/runs/RunDeltaParamsTest.kt | 120 + .../runs/RunGenerateQueryParamsTest.kt | 77 + .../runs/RunPublicDatasetSchemaTest.kt | 256 + .../datasets/runs/RunQueryParamsTest.kt | 142 + .../datasets/runs/RunQueryResponseTest.kt | 262 + .../datasets/runs/RunRetrieveParamsTest.kt | 61 + .../datasets/runs/RunStatsParamsTest.kt | 155 + .../v1/public_/datasets/runs/RunStatsTest.kt | 126 + .../public_/examples/ExampleListParamsTest.kt | 76 + .../ExampleRetrieveCountParamsTest.kt | 70 + .../public_/examples/ExampleRunsParamsTest.kt | 132 + .../examples/ExampleRunsResponseTest.kt | 382 + .../api/v1/public_/runs/RunListParamsTest.kt | 52 + .../v1/public_/runs/RunPublicSchemaTest.kt | 243 + .../api/v1/public_/runs/RunQueryParamsTest.kt | 49 + .../v1/public_/runs/RunQueryResponseTest.kt | 259 + .../v1/public_/runs/RunRetrieveParamsTest.kt | 61 + .../SchemaRetrieveMessageJsonParamsTest.kt | 23 + .../SchemaRetrieveMessageJsonResponseTest.kt | 31 + .../SchemaRetrieveTooldefJsonParamsTest.kt | 23 + .../SchemaRetrieveTooldefJsonResponseTest.kt | 31 + .../api/v1/repos/CreateRepoResponseTest.kt | 162 + .../api/models/api/v1/repos/DemoConfigTest.kt | 48 + .../api/v1/repos/GetRepoResponseTest.kt | 162 + .../models/api/v1/repos/PromptimConfigTest.kt | 63 + .../api/v1/repos/RepoCreateParamsTest.kt | 51 + .../api/v1/repos/RepoDeleteParamsTest.kt | 24 + .../api/v1/repos/RepoDeleteResponseTest.kt | 30 + .../models/api/v1/repos/RepoForkParamsTest.kt | 66 + .../models/api/v1/repos/RepoListParamsTest.kt | 88 + .../api/v1/repos/RepoListResponseTest.kt | 165 + .../api/v1/repos/RepoOptimizeJobParamsTest.kt | 73 + .../v1/repos/RepoOptimizeJobResponseTest.kt | 39 + .../api/v1/repos/RepoRetrieveParamsTest.kt | 24 + .../api/v1/repos/RepoUpdateParamsTest.kt | 62 + .../api/v1/repos/RepoWithLookupsTest.kt | 154 + .../OptimizationJobDeleteParamsTest.kt | 34 + .../OptimizationJobDeleteResponseTest.kt | 31 + ...timizationJobOptimizationJobsParamsTest.kt | 104 + ...onJobRetrieveOptimizationJobsParamsTest.kt | 28 + .../OptimizationJobRetrieveParamsTest.kt | 34 + .../OptimizationJobRetrieveResponseTest.kt | 166 + .../OptimizationJobUpdateParamsTest.kt | 85 + .../PromptOptimizationJobTest.kt | 128 + .../PromptOptimizationResultTest.kt | 46 + .../logs/LogCreateParamsTest.kt | 76 + .../logs/LogDeleteParamsTest.kt | 37 + .../logs/LogDeleteResponseTest.kt | 30 + .../logs/LogListParamsTest.kt | 34 + .../logs/LogRetrieveParamsTest.kt | 37 + .../logs/PromptOptimizationJobLogTest.kt | 57 + .../models/api/v1/repos/tags/RepoTagTest.kt | 54 + .../api/v1/repos/tags/TagCreateParamsTest.kt | 70 + .../api/v1/repos/tags/TagDeleteParamsTest.kt | 26 + .../v1/repos/tags/TagDeleteResponseTest.kt | 30 + .../api/v1/repos/tags/TagListParamsTest.kt | 24 + .../v1/repos/tags/TagRetrieveParamsTest.kt | 26 + .../api/v1/repos/tags/TagUpdateParamsTest.kt | 69 + .../api/v1/runs/BodyParamsForRunSchemaTest.kt | 117 + .../RequestBodyForRunsGenerateQueryTest.kt | 44 + .../ResponseBodyForRunsGenerateQueryTest.kt | 56 + .../models/api/v1/runs/RunDeleteParamsTest.kt | 57 + .../api/v1/runs/RunDeleteResponseTest.kt | 30 + .../api/v1/runs/RunGenerateQueryParamsTest.kt | 58 + .../models/api/v1/runs/RunQueryParamsTest.kt | 123 + .../api/v1/runs/RunQueryResponseTest.kt | 308 + .../api/v1/runs/RunRetrieveParamsTest.kt | 66 + .../api/models/api/v1/runs/RunSchemaTest.kt | 275 + .../models/api/v1/runs/RunStatsParamsTest.kt | 136 + .../api/v1/runs/RunStatsQueryParamsTest.kt | 130 + .../api/v1/runs/RunStatsResponseTest.kt | 222 + .../models/api/v1/runs/RunUpdateParamsTest.kt | 23 + .../api/v1/runs/RunUpdateResponseTest.kt | 30 + .../v1/runs/group/GroupCreateParamsTest.kt | 126 + .../v1/runs/group/GroupCreateResponseTest.kt | 30 + .../api/v1/runs/group/GroupStatsParamsTest.kt | 83 + .../v1/runs/group/GroupStatsResponseTest.kt | 132 + .../api/v1/runs/group/RunGroupRequestTest.kt | 59 + .../runs/rules/CodeEvaluatorTopLevelTest.kt | 41 + .../v1/runs/rules/EvaluatorTopLevelTest.kt | 94 + .../api/v1/runs/rules/RuleCreateParamsTest.kt | 244 + .../api/v1/runs/rules/RuleDeleteParamsTest.kt | 24 + .../v1/runs/rules/RuleDeleteResponseTest.kt | 30 + .../api/v1/runs/rules/RuleListParamsTest.kt | 55 + .../runs/rules/RuleLogActionResponseTest.kt | 42 + .../api/v1/runs/rules/RuleLogSchemaTest.kt | 162 + .../RuleRetrieveLastAppliedParamsTest.kt | 28 + .../runs/rules/RuleRetrieveLogsParamsTest.kt | 66 + .../api/v1/runs/rules/RuleUpdateParamsTest.kt | 261 + .../rules/RunRulesPagerdutyAlertSchemaTest.kt | 49 + .../api/v1/runs/rules/RunRulesSchemaTest.kt | 280 + .../runs/rules/RunRulesWebhookSchemaTest.kt | 55 + .../rules/trigger/TriggerCreateParamsTest.kt | 40 + .../trigger/TriggerCreateResponseTest.kt | 30 + .../api/v1/runs/share/RunShareSchemaTest.kt | 41 + .../v1/runs/share/ShareCreateParamsTest.kt | 24 + .../v1/runs/share/ShareDeleteAllParamsTest.kt | 24 + .../runs/share/ShareDeleteAllResponseTest.kt | 30 + .../api/v1/runs/share/ShareListParamsTest.kt | 23 + .../ServiceAccountDeleteParamsTest.kt | 28 + .../ServiceAccountDeleteResponseTest.kt | 59 + ...ccountRetrieveServiceAccountsParamsTest.kt | 13 + ...ountRetrieveServiceAccountsResponseTest.kt | 60 + ...ServiceAccountServiceAccountsParamsTest.kt | 57 + ...rviceAccountServiceAccountsResponseTest.kt | 64 + .../CustomChartsSectionRequestTest.kt | 76 + .../v1/sessions/CustomChartsSectionTest.kt | 398 + .../api/v1/sessions/RunStatsGroupByTest.kt | 44 + .../v1/sessions/SessionCreateParamsTest.kt | 95 + .../v1/sessions/SessionDashboardParamsTest.kt | 148 + .../v1/sessions/SessionDeleteAllParamsTest.kt | 37 + .../sessions/SessionDeleteAllResponseTest.kt | 30 + .../v1/sessions/SessionDeleteParamsTest.kt | 24 + .../v1/sessions/SessionDeleteResponseTest.kt | 30 + .../api/v1/sessions/SessionListParamsTest.kt | 143 + .../SessionRetrieveMetadataParamsTest.kt | 70 + .../SessionRetrieveMetadataResponseTest.kt | 38 + .../v1/sessions/SessionRetrieveParamsTest.kt | 94 + .../v1/sessions/SessionUpdateParamsTest.kt | 66 + .../api/v1/sessions/TimedeltaInputTest.kt | 34 + .../api/v1/sessions/TracerSessionTest.kt | 134 + .../TracerSessionWithoutVirtualFieldsTest.kt | 80 + .../CreateRunClusteringJobRequestTest.kt | 108 + .../insights/InsightCreateParamsTest.kt | 131 + .../insights/InsightCreateResponseTest.kt | 47 + .../insights/InsightDeleteParamsTest.kt | 31 + .../insights/InsightDeleteResponseTest.kt | 41 + .../insights/InsightListParamsTest.kt | 54 + .../insights/InsightListResponseTest.kt | 74 + .../insights/InsightRetrieveParamsTest.kt | 34 + .../insights/InsightRetrieveResponseTest.kt | 54 + .../insights/InsightRetrieveRunsParamsTest.kt | 77 + .../InsightRetrieveRunsResponseTest.kt | 43 + .../insights/InsightUpdateParamsTest.kt | 47 + .../insights/InsightUpdateResponseTest.kt | 35 + .../configs/ConfigCreateParamsTest.kt | 141 + .../configs/ConfigDeleteParamsTest.kt | 31 + .../configs/ConfigDeleteResponseTest.kt | 41 + .../configs/ConfigGenerateParamsTest.kt | 86 + .../configs/ConfigGenerateResponseTest.kt | 58 + .../insights/configs/ConfigListParamsTest.kt | 52 + .../configs/ConfigListResponseTest.kt | 112 + .../configs/ConfigUpdateParamsTest.kt | 139 + .../CreateClusteringJobConfigResponseTest.kt | 99 + .../SavedRunClusteringJobRequestTest.kt | 79 + .../api/v1/sessions/views/FilterViewTest.kt | 68 + .../v1/sessions/views/ViewCreateParamsTest.kt | 71 + .../v1/sessions/views/ViewDeleteParamsTest.kt | 31 + .../sessions/views/ViewDeleteResponseTest.kt | 30 + .../v1/sessions/views/ViewListParamsTest.kt | 51 + .../sessions/views/ViewRetrieveParamsTest.kt | 31 + .../v1/sessions/views/ViewUpdateParamsTest.kt | 72 + .../settings/AppHubCrudTenantsTenantTest.kt | 49 + .../v1/settings/SettingHandleParamsTest.kt | 23 + .../api/v1/settings/SettingListParamsTest.kt | 13 + .../api/v1/sso/SsoRetrieveParamsTest.kt | 23 + .../api/v1/sso/SsoRetrieveResponseTest.kt | 47 + .../EmailVerificationConfirmParamsTest.kt | 23 + .../EmailVerificationConfirmResponseTest.kt | 31 + .../EmailVerificationSendParamsTest.kt | 31 + .../EmailVerificationSendResponseTest.kt | 31 + .../EmailVerificationStatusParamsTest.kt | 31 + .../EmailVerificationStatusResponseTest.kt | 41 + .../api/v1/tenants/AppSchemasTenantTest.kt | 59 + .../api/v1/tenants/TenantCreateParamsTest.kt | 49 + .../api/v1/tenants/TenantForUserTest.kt | 71 + .../api/v1/tenants/TenantListParamsTest.kt | 39 + ...TtlSettingRetrieveTtlSettingsParamsTest.kt | 13 + .../TtlSettingUpdateTtlSettingsParamsTest.kt | 66 + .../usagelimits/UsageLimitDeleteParamsTest.kt | 28 + .../UsageLimitDeleteResponseTest.kt | 30 + .../UsageLimitRetrieveOrgParamsTest.kt | 13 + ...UsageLimitRetrieveUsageLimitsParamsTest.kt | 13 + .../api/v1/usagelimits/UsageLimitTest.kt | 56 + .../UsageLimitUpdateUsageLimitsParamsTest.kt | 48 + .../workspaces/WorkspaceCreateParamsTest.kt | 43 + .../workspaces/WorkspaceDeleteParamsTest.kt | 26 + .../workspaces/WorkspaceDeleteResponseTest.kt | 30 + .../v1/workspaces/WorkspaceListParamsTest.kt | 34 + .../workspaces/WorkspaceUpdateParamsTest.kt | 43 + .../current/CurrentRetrieveStatsParamsTest.kt | 46 + .../CurrentRetrieveStatsResponseTest.kt | 57 + .../CurrentRetrieveUsageLimitsParamsTest.kt | 13 + .../CurrentRetrieveUsageLimitsResponseTest.kt | 46 + .../current/members/MemberBatchParamsTest.kt | 72 + .../current/members/MemberCreateParamsTest.kt | 47 + .../current/members/MemberDeleteParamsTest.kt | 24 + .../members/MemberDeleteResponseTest.kt | 30 + .../current/members/MemberIdentityTest.kt | 144 + .../current/members/MemberListParamsTest.kt | 13 + .../current/members/MemberListResponseTest.kt | 218 + .../members/MemberRetrieveActiveParamsTest.kt | 61 + .../current/members/MemberUpdateParamsTest.kt | 59 + .../members/MemberUpdateResponseTest.kt | 30 + .../pending/PendingDeleteAllParamsTest.kt | 26 + .../pending/PendingDeleteAllResponseTest.kt | 30 + .../members/pending/PendingListParamsTest.kt | 40 + .../current/secrets/SecretCreateParamsTest.kt | 29 + .../secrets/SecretCreateResponseTest.kt | 30 + .../current/secrets/SecretListParamsTest.kt | 13 + .../current/secrets/SecretListResponseTest.kt | 32 + .../SecretRetrieveEncryptedParamsTest.kt | 30 + .../SecretRetrieveEncryptedResponseTest.kt | 36 + .../shared/SharedDeleteAllParamsTest.kt | 37 + .../shared/SharedDeleteAllResponseTest.kt | 30 + .../current/shared/SharedListParamsTest.kt | 34 + .../current/shared/SharedListResponseTest.kt | 72 + .../current/taggings/ResourceTest.kt | 44 + .../taggings/TaggingCreateParamsTest.kt | 35 + .../taggings/TaggingDeleteParamsTest.kt | 24 + .../taggings/TaggingDeleteResponseTest.kt | 30 + .../current/taggings/TaggingListParamsTest.kt | 39 + .../taggings/TaggingListResponseTest.kt | 208 + .../current/taggings/TaggingTest.kt | 49 + .../current/tagkeys/TagKeyDeleteParamsTest.kt | 24 + .../tagkeys/TagKeyDeleteResponseTest.kt | 30 + .../tagkeys/TagKeyRetrieveParamsTest.kt | 24 + .../TagKeyRetrieveTagKeysParamsTest.kt | 13 + .../tagkeys/TagKeyTagKeysParamsTest.kt | 33 + .../workspaces/current/tagkeys/TagKeyTest.kt | 48 + .../current/tagkeys/TagKeyUpdateParamsTest.kt | 51 + .../tagvalues/TagValueDeleteParamsTest.kt | 31 + .../tagvalues/TagValueDeleteResponseTest.kt | 30 + .../tagvalues/TagValueRetrieveParamsTest.kt | 31 + .../TagValueRetrieveTagValuesParamsTest.kt | 28 + .../tagvalues/TagValueTagValuesParamsTest.kt | 59 + .../current/tagkeys/tagvalues/TagValueTest.kt | 54 + .../tagvalues/TagValueUpdateParamsTest.kt | 60 + .../current/tags/TagListParamsTest.kt | 13 + .../current/tags/TagListResponseTest.kt | 86 + .../current/tags/TagResourcesParamsTest.kt | 44 + .../current/tags/TagResourcesResponseTest.kt | 111 + .../tags/TagRetrieveResourceParamsTest.kt | 37 + .../tags/TagRetrieveResourceResponseTest.kt | 114 + .../pending/PendingClaimParamsTest.kt | 24 + .../pending/PendingClaimResponseTest.kt | 30 + .../pending/PendingDeleteParamsTest.kt | 24 + .../pending/PendingDeleteResponseTest.kt | 30 + .../pending/PendingListParamsTest.kt | 13 + .../ColumnOverrideTest.kt | 66 + .../ExperimentViewOverrideCreateParamsTest.kt | 95 + .../ExperimentViewOverrideDeleteParamsTest.kt | 32 + .../ExperimentViewOverrideListParamsTest.kt | 29 + ...xperimentViewOverrideRetrieveParamsTest.kt | 32 + .../ExperimentViewOverrideTest.kt | 89 + .../ExperimentViewOverrideUpdateParamsTest.kt | 100 + .../feedback/FeedbackIngestBatchParamsTest.kt | 162 + .../FeedbackIngestBatchResponseTest.kt | 37 + .../platform/alerts/AlertActionBaseTest.kt | 48 + .../platform/alerts/AlertCreateParamsTest.kt | 181 + .../platform/alerts/AlertDeleteParamsTest.kt | 32 + .../alerts/AlertDeleteResponseTest.kt | 37 + .../alerts/AlertRetrieveParamsTest.kt | 32 + .../platform/alerts/AlertRuleBaseTest.kt | 74 + .../platform/alerts/AlertRuleResponseTest.kt | 126 + .../platform/alerts/AlertTestParamsTest.kt | 25 + .../platform/alerts/AlertTestResponseTest.kt | 37 + .../platform/alerts/AlertUpdateParamsTest.kt | 186 + .../alerts/AlertUpdateResponseTest.kt | 37 + .../examples/ExampleHardDeleteParamsTest.kt | 25 + .../examples/ExampleHardDeleteResponseTest.kt | 43 + .../examples/ExampleUpdateParamsTest.kt | 103 + .../examples/ExampleUpdateResponseTest.kt | 43 + .../examples/ExampleUploadParamsTest.kt | 104 + .../examples/ExampleUploadResponseTest.kt | 43 + .../AccessPolicyCreateParamsTest.kt | 105 + .../AccessPolicyCreateResponseTest.kt | 32 + .../AccessPolicyDeleteParamsTest.kt | 29 + .../AccessPolicyListParamsTest.kt | 13 + .../AccessPolicyListResponseTest.kt | 118 + .../AccessPolicyRetrieveParamsTest.kt | 29 + .../accesspolicies/AccessPolicyTest.kt | 104 + .../accesspolicies/ConditionGroupTest.kt | 68 + .../roles/RoleAttachParamsTest.kt | 48 + .../api/models/runs/RunCreateParamsTest.kt | 195 + .../api/models/runs/RunCreateResponseTest.kt | 37 + .../models/runs/RunIngestBatchParamsTest.kt | 354 + .../models/runs/RunIngestBatchResponseTest.kt | 37 + .../runs/RunIngestMultipartParamsTest.kt | 73 + .../runs/RunIngestMultipartResponseTest.kt | 37 + .../langsmith_api/api/models/runs/RunTest.kt | 166 + .../api/models/runs/RunUpdateParamsTest.kt | 214 + .../api/models/runs/RunUpdateResponseTest.kt | 37 + .../api/services/ErrorHandlingTest.kt | 798 + .../api/services/ServiceParamsTest.kt | 80 + .../async/FeedbackServiceAsyncTest.kt | 83 + .../api/services/async/RunServiceAsyncTest.kt | 321 + .../services/async/api/V1ServiceAsyncTest.kt | 98 + .../async/api/v1/AceServiceAsyncTest.kt | 40 + .../api/v1/AnnotationQueueServiceAsyncTest.kt | 301 + .../async/api/v1/ApiKeyServiceAsyncTest.kt | 81 + .../api/v1/BulkExportServiceAsyncTest.kt | 102 + .../async/api/v1/ChartServiceAsyncTest.kt | 242 + .../async/api/v1/CommentServiceAsyncTest.kt | 69 + .../async/api/v1/CommitServiceAsyncTest.kt | 72 + .../async/api/v1/DatasetServiceAsyncTest.kt | 600 + .../async/api/v1/ExampleServiceAsyncTest.kt | 193 + .../api/v1/FeedbackConfigServiceAsyncTest.kt | 109 + .../async/api/v1/FeedbackServiceAsyncTest.kt | 241 + .../async/api/v1/InfoServiceAsyncTest.kt | 49 + .../async/api/v1/MeServiceAsyncTest.kt | 30 + .../api/v1/ModelPriceMapServiceAsyncTest.kt | 133 + .../async/api/v1/OAuthServiceAsyncTest.kt | 86 + .../async/api/v1/OrgChartServiceAsyncTest.kt | 272 + .../async/api/v1/OrgServiceAsyncTest.kt | 73 + .../v1/PlaygroundSettingServiceAsyncTest.kt | 107 + .../async/api/v1/PromptServiceAsyncTest.kt | 148 + .../api/v1/PromptWebhookServiceAsyncTest.kt | 173 + .../async/api/v1/PublicServiceAsyncTest.kt | 49 + .../async/api/v1/RepoServiceAsyncTest.kt | 221 + .../async/api/v1/RunServiceAsyncTest.kt | 217 + .../api/v1/ServiceAccountServiceAsyncTest.kt | 80 + .../async/api/v1/SessionServiceAsyncTest.kt | 263 + .../async/api/v1/SettingServiceAsyncTest.kt | 53 + .../async/api/v1/SsoServiceAsyncTest.kt | 31 + .../async/api/v1/TenantServiceAsyncTest.kt | 63 + .../api/v1/TtlSettingServiceAsyncTest.kt | 58 + .../api/v1/UsageLimitServiceAsyncTest.kt | 94 + .../async/api/v1/WorkspaceServiceAsyncTest.kt | 102 + .../annotationqueues/RunServiceAsyncTest.kt | 121 + .../api/v1/apikey/CurrentServiceAsyncTest.kt | 81 + .../DestinationServiceAsyncTest.kt | 94 + .../api/v1/bulkexports/RunServiceAsyncTest.kt | 56 + .../api/v1/charts/SectionServiceAsyncTest.kt | 144 + .../api/v1/comments/LikeServiceAsyncTest.kt | 65 + .../datasets/ComparativeServiceAsyncTest.kt | 97 + .../v1/datasets/ExperimentServiceAsyncTest.kt | 46 + .../api/v1/datasets/GroupServiceAsyncTest.kt | 44 + .../api/v1/datasets/IndexServiceAsyncTest.kt | 92 + .../PlaygroundExperimentServiceAsyncTest.kt | 131 + .../api/v1/datasets/RunServiceAsyncTest.kt | 103 + .../api/v1/datasets/ShareServiceAsyncTest.kt | 77 + .../api/v1/datasets/SplitServiceAsyncTest.kt | 64 + .../v1/datasets/VersionServiceAsyncTest.kt | 68 + .../api/v1/examples/BulkServiceAsyncTest.kt | 77 + .../v1/examples/ValidateServiceAsyncTest.kt | 49 + .../v1/feedback/FormulaServiceAsyncTest.kt | 137 + .../api/v1/feedback/TokenServiceAsyncTest.kt | 143 + .../v1/me/OnboardingStateServiceAsyncTest.kt | 67 + .../v1/orgcharts/SectionServiceAsyncTest.kt | 119 + .../api/v1/orgs/CurrentServiceAsyncTest.kt | 247 + .../api/v1/orgs/MemberServiceAsyncTest.kt | 35 + .../api/v1/orgs/PendingServiceAsyncTest.kt | 67 + .../api/v1/orgs/TtlSettingServiceAsyncTest.kt | 58 + .../orgs/current/BillingServiceAsyncTest.kt | 58 + .../current/BusinessInfoServiceAsyncTest.kt | 75 + .../v1/orgs/current/InfoServiceAsyncTest.kt | 60 + .../v1/orgs/current/MemberServiceAsyncTest.kt | 168 + .../PersonalAccessTokenServiceAsyncTest.kt | 85 + .../v1/orgs/current/RoleServiceAsyncTest.kt | 102 + .../current/ServiceKeyServiceAsyncTest.kt | 81 + .../current/SsoSettingServiceAsyncTest.kt | 111 + .../v1/orgs/current/UserServiceAsyncTest.kt | 31 + .../current/members/BasicServiceAsyncTest.kt | 49 + .../members/PendingServiceAsyncTest.kt | 53 + .../api/v1/public_/DatasetServiceAsyncTest.kt | 167 + .../api/v1/public_/ExampleServiceAsyncTest.kt | 120 + .../api/v1/public_/RunServiceAsyncTest.kt | 89 + .../api/v1/public_/SchemaServiceAsyncTest.kt | 49 + .../public_/datasets/RunServiceAsyncTest.kt | 225 + .../repos/OptimizationJobServiceAsyncTest.kt | 168 + .../async/api/v1/repos/TagServiceAsyncTest.kt | 133 + .../optimizationjobs/LogServiceAsyncTest.kt | 124 + .../api/v1/runs/GroupServiceAsyncTest.kt | 79 + .../async/api/v1/runs/RuleServiceAsyncTest.kt | 292 + .../api/v1/runs/ShareServiceAsyncTest.kt | 69 + .../v1/runs/rules/TriggerServiceAsyncTest.kt | 38 + .../v1/sessions/InsightServiceAsyncTest.kt | 198 + .../api/v1/sessions/ViewServiceAsyncTest.kt | 150 + .../insights/ConfigServiceAsyncTest.kt | 199 + .../sso/EmailVerificationServiceAsyncTest.kt | 85 + .../v1/workspaces/CurrentServiceAsyncTest.kt | 55 + .../v1/workspaces/PendingServiceAsyncTest.kt | 67 + .../current/MemberServiceAsyncTest.kt | 166 + .../current/SecretServiceAsyncTest.kt | 79 + .../current/SharedServiceAsyncTest.kt | 57 + .../current/TagKeyServiceAsyncTest.kt | 115 + .../workspaces/current/TagServiceAsyncTest.kt | 86 + .../current/TaggingServiceAsyncTest.kt | 82 + .../members/PendingServiceAsyncTest.kt | 53 + .../tagkeys/TagValueServiceAsyncTest.kt | 135 + .../ExperimentViewOverrideServiceAsyncTest.kt | 160 + .../async/platform/AlertServiceAsyncTest.kt | 183 + .../datasets/ExampleServiceAsyncTest.kt | 93 + .../current/AccessPolicyServiceAsyncTest.kt | 117 + .../accesspolicies/RoleServiceAsyncTest.kt | 38 + .../services/blocking/FeedbackServiceTest.kt | 82 + .../api/services/blocking/RunServiceTest.kt | 317 + .../services/blocking/api/V1ServiceTest.kt | 94 + .../blocking/api/v1/AceServiceTest.kt | 39 + .../api/v1/AnnotationQueueServiceTest.kt | 289 + .../blocking/api/v1/ApiKeyServiceTest.kt | 77 + .../blocking/api/v1/BulkExportServiceTest.kt | 97 + .../blocking/api/v1/ChartServiceTest.kt | 238 + .../blocking/api/v1/CommentServiceTest.kt | 67 + .../blocking/api/v1/CommitServiceTest.kt | 70 + .../blocking/api/v1/DatasetServiceTest.kt | 583 + .../blocking/api/v1/ExampleServiceTest.kt | 184 + .../api/v1/FeedbackConfigServiceTest.kt | 106 + .../blocking/api/v1/FeedbackServiceTest.kt | 235 + .../blocking/api/v1/InfoServiceTest.kt | 47 + .../services/blocking/api/v1/MeServiceTest.kt | 28 + .../api/v1/ModelPriceMapServiceTest.kt | 128 + .../blocking/api/v1/OAuthServiceTest.kt | 82 + .../blocking/api/v1/OrgChartServiceTest.kt | 267 + .../blocking/api/v1/OrgServiceTest.kt | 70 + .../api/v1/PlaygroundSettingServiceTest.kt | 102 + .../blocking/api/v1/PromptServiceTest.kt | 146 + .../api/v1/PromptWebhookServiceTest.kt | 165 + .../blocking/api/v1/PublicServiceTest.kt | 48 + .../blocking/api/v1/RepoServiceTest.kt | 212 + .../blocking/api/v1/RunServiceTest.kt | 211 + .../api/v1/ServiceAccountServiceTest.kt | 76 + .../blocking/api/v1/SessionServiceTest.kt | 255 + .../blocking/api/v1/SettingServiceTest.kt | 51 + .../blocking/api/v1/SsoServiceTest.kt | 30 + .../blocking/api/v1/TenantServiceTest.kt | 61 + .../blocking/api/v1/TtlSettingServiceTest.kt | 56 + .../blocking/api/v1/UsageLimitServiceTest.kt | 90 + .../blocking/api/v1/WorkspaceServiceTest.kt | 98 + .../api/v1/annotationqueues/RunServiceTest.kt | 117 + .../api/v1/apikey/CurrentServiceTest.kt | 77 + .../v1/bulkexports/DestinationServiceTest.kt | 91 + .../api/v1/bulkexports/RunServiceTest.kt | 54 + .../api/v1/charts/SectionServiceTest.kt | 139 + .../api/v1/comments/LikeServiceTest.kt | 63 + .../api/v1/datasets/ComparativeServiceTest.kt | 93 + .../api/v1/datasets/ExperimentServiceTest.kt | 45 + .../api/v1/datasets/GroupServiceTest.kt | 43 + .../api/v1/datasets/IndexServiceTest.kt | 88 + .../PlaygroundExperimentServiceTest.kt | 129 + .../api/v1/datasets/RunServiceTest.kt | 101 + .../api/v1/datasets/ShareServiceTest.kt | 73 + .../api/v1/datasets/SplitServiceTest.kt | 58 + .../api/v1/datasets/VersionServiceTest.kt | 66 + .../api/v1/examples/BulkServiceTest.kt | 75 + .../api/v1/examples/ValidateServiceTest.kt | 47 + .../api/v1/feedback/FormulaServiceTest.kt | 131 + .../api/v1/feedback/TokenServiceTest.kt | 139 + .../api/v1/me/OnboardingStateServiceTest.kt | 64 + .../api/v1/orgcharts/SectionServiceTest.kt | 115 + .../api/v1/orgs/CurrentServiceTest.kt | 237 + .../blocking/api/v1/orgs/MemberServiceTest.kt | 34 + .../api/v1/orgs/PendingServiceTest.kt | 64 + .../api/v1/orgs/TtlSettingServiceTest.kt | 56 + .../api/v1/orgs/current/BillingServiceTest.kt | 56 + .../orgs/current/BusinessInfoServiceTest.kt | 73 + .../api/v1/orgs/current/InfoServiceTest.kt | 58 + .../api/v1/orgs/current/MemberServiceTest.kt | 162 + .../current/PersonalAccessTokenServiceTest.kt | 78 + .../api/v1/orgs/current/RoleServiceTest.kt | 98 + .../v1/orgs/current/ServiceKeyServiceTest.kt | 77 + .../v1/orgs/current/SsoSettingServiceTest.kt | 106 + .../api/v1/orgs/current/UserServiceTest.kt | 30 + .../orgs/current/members/BasicServiceTest.kt | 48 + .../current/members/PendingServiceTest.kt | 51 + .../api/v1/public_/DatasetServiceTest.kt | 162 + .../api/v1/public_/ExampleServiceTest.kt | 115 + .../blocking/api/v1/public_/RunServiceTest.kt | 86 + .../api/v1/public_/SchemaServiceTest.kt | 47 + .../api/v1/public_/datasets/RunServiceTest.kt | 220 + .../v1/repos/OptimizationJobServiceTest.kt | 163 + .../blocking/api/v1/repos/TagServiceTest.kt | 127 + .../repos/optimizationjobs/LogServiceTest.kt | 120 + .../blocking/api/v1/runs/GroupServiceTest.kt | 77 + .../blocking/api/v1/runs/RuleServiceTest.kt | 285 + .../blocking/api/v1/runs/ShareServiceTest.kt | 66 + .../api/v1/runs/rules/TriggerServiceTest.kt | 37 + .../api/v1/sessions/InsightServiceTest.kt | 192 + .../api/v1/sessions/ViewServiceTest.kt | 145 + .../v1/sessions/insights/ConfigServiceTest.kt | 194 + .../v1/sso/EmailVerificationServiceTest.kt | 82 + .../api/v1/workspaces/CurrentServiceTest.kt | 53 + .../api/v1/workspaces/PendingServiceTest.kt | 64 + .../workspaces/current/MemberServiceTest.kt | 160 + .../workspaces/current/SecretServiceTest.kt | 76 + .../workspaces/current/SharedServiceTest.kt | 54 + .../workspaces/current/TagKeyServiceTest.kt | 110 + .../v1/workspaces/current/TagServiceTest.kt | 83 + .../workspaces/current/TaggingServiceTest.kt | 79 + .../current/members/PendingServiceTest.kt | 51 + .../current/tagkeys/TagValueServiceTest.kt | 129 + .../ExperimentViewOverrideServiceTest.kt | 153 + .../blocking/platform/AlertServiceTest.kt | 178 + .../platform/datasets/ExampleServiceTest.kt | 90 + .../orgs/current/AccessPolicyServiceTest.kt | 111 + .../current/accesspolicies/RoleServiceTest.kt | 35 + langsmith-api-java-example/build.gradle.kts | 28 + langsmith-api-java-lib/.keep | 4 + .../build.gradle.kts | 101 + .../api/proguard/ProGuardCompatibilityTest.kt | 338 + langsmith-api-java-proguard-test/test.pro | 9 + langsmith-api-java/build.gradle.kts | 29 + scripts/build | 8 + scripts/fast-format | 46 + scripts/format | 21 + scripts/java-format | 7 + scripts/kotlin-format | 7 + scripts/lint | 23 + scripts/mock | 41 + scripts/test | 56 + settings.gradle.kts | 14 + 2096 files changed, 462625 insertions(+), 1 deletion(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .gitattributes create mode 100644 .github/workflows/ci.yml create mode 100644 .gitignore create mode 100644 .stats.yml create mode 100644 LICENSE create mode 100644 SECURITY.md create mode 100644 build.gradle.kts create mode 100644 buildSrc/build.gradle.kts create mode 100644 buildSrc/src/main/kotlin/langsmith-api.java.gradle.kts create mode 100644 buildSrc/src/main/kotlin/langsmith-api.kotlin.gradle.kts create mode 100644 buildSrc/src/main/kotlin/langsmith-api.publish.gradle.kts create mode 100644 gradle.properties create mode 100644 gradle/wrapper/gradle-wrapper.jar create mode 100644 gradle/wrapper/gradle-wrapper.properties create mode 100755 gradlew create mode 100644 gradlew.bat create mode 100644 langsmith-api-java-client-okhttp/build.gradle.kts create mode 100644 langsmith-api-java-client-okhttp/src/main/kotlin/com/langsmith_api/api/client/okhttp/LangsmithApiOkHttpClient.kt create mode 100644 langsmith-api-java-client-okhttp/src/main/kotlin/com/langsmith_api/api/client/okhttp/LangsmithApiOkHttpClientAsync.kt create mode 100644 langsmith-api-java-client-okhttp/src/main/kotlin/com/langsmith_api/api/client/okhttp/OkHttpClient.kt create mode 100644 langsmith-api-java-core/build.gradle.kts create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/client/LangsmithApiClient.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/client/LangsmithApiClientAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/client/LangsmithApiClientAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/client/LangsmithApiClientImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/BaseDeserializer.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/BaseSerializer.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/Check.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/ClientOptions.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/DefaultSleeper.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/ObjectMappers.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/Params.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/PhantomReachable.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/PhantomReachableExecutorService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/PhantomReachableSleeper.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/PrepareRequest.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/Properties.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/RequestOptions.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/Sleeper.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/Timeout.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/Utils.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/Values.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/handlers/EmptyHandler.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/handlers/ErrorHandler.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/handlers/JsonHandler.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/handlers/StringHandler.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/AsyncStreamResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/Headers.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/HttpClient.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/HttpMethod.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/HttpRequest.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/HttpRequestBodies.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/HttpRequestBody.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/HttpResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/HttpResponseFor.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/PhantomReachableClosingAsyncStreamResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/PhantomReachableClosingHttpClient.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/PhantomReachableClosingStreamResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/QueryParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/RetryingHttpClient.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/StreamResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/BadRequestException.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/InternalServerException.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/LangsmithApiException.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/LangsmithApiInvalidDataException.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/LangsmithApiIoException.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/LangsmithApiRetryableException.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/LangsmithApiServiceException.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/NotFoundException.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/PermissionDeniedException.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/RateLimitException.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/UnauthorizedException.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/UnexpectedStatusCodeException.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/UnprocessableEntityException.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/V1EventsParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/V1EventsResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/V1LoginParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/V1LoginResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/V1RetrieveOkParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/V1RetrieveOkResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/V1UpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/V1UpdateResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/ace/AceExecuteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/ace/AceExecuteResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueAnnotationQueuesParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueDeleteResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueExportParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueExportResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueuePopulateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueuePopulateResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveAnnotationQueuesParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveAnnotationQueuesResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveQueuesParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveSizeParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveTotalArchivedParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveTotalSizeParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRubricItemSchema.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueSchema.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueSizeSchema.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueUpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueUpdateResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/RunSchemaWithAnnotationQueueInfo.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunCreateResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunDeleteResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunUpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunUpdateResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/apikey/ApiKeyApiKeyParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/apikey/ApiKeyDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/apikey/ApiKeyRetrieveApiKeyParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/apikey/current/CurrentCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/apikey/current/CurrentDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/apikey/current/CurrentListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExport.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportBulkExportsParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportCompression.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportFormat.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportRetrieveBulkExportsParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportRetrieveParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportUpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/BulkExportDestination.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/BulkExportDestinationS3Config.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/BulkExportDestinationType.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/DestinationCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/DestinationListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/DestinationRetrieveParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/runs/BulkExportRun.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/runs/RunListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/runs/RunRetrieveParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartDeleteResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartPreviewParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartUpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartCreate.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartMetric.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartPreviewRequest.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartSeries.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartSeriesFilters.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartType.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartUpdate.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartsDataPoint.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartsRequest.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartsResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/HostProjectChartMetric.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/SingleCustomChartResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/SingleCustomChartResponseBase.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/section/CustomChartsSectionCreate.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/section/CustomChartsSectionResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/section/CustomChartsSectionUpdate.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionCloneParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionDeleteResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionUpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/comments/Comment.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/comments/CommentRetrieveParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/comments/CommentUpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/comments/CreateCommentRequest.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/comments/ListCommentsResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/comments/like/LikeCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/comments/like/LikeCreateResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/comments/like/LikeDeleteAllParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/comments/like/LikeDeleteAllResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitManifestResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitRetrieveParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitUpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitUpdateResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitWithLookups.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DataType.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/Dataset.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetCloneParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetCloneResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetDeleteResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetGenerateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetGenerateResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveCsvParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveCsvResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveJsonlParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveJsonlResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveOpenAIFtParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveOpenAIFtResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveOpenAIParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveOpenAIResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveVersionParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetSearchParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetSearchResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetStudioExperimentParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetStudioExperimentResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetTransformation.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUpdateResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUpdateTagsParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUploadExperimentParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUploadExperimentResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUploadParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetVersion.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/FeedbackCreateCoreSchema.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/Missing.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/SortByDatasetColumn.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeCreateResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeDeleteResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeListResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/SimpleExperimentInfo.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/SortByComparativeExperimentColumn.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/experiments/ExperimentGroupedParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/experiments/ExperimentGroupedResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/group/GroupRunsParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/group/GroupRunsResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexCreateResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexDeleteAllParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexDeleteAllResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexListResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexSyncParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexSyncResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/PlaygroundExperimentBatchParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/PlaygroundExperimentBatchResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/PlaygroundExperimentStreamParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/PlaygroundExperimentStreamResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/RunnableConfig.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/RunnerContextEnum.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/ExampleWithRuns.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/ExampleWithRunsCh.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/QueryExampleSchemaWithRuns.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/QueryFeedbackDelta.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/RunCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/RunCreateResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/RunDeltaParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/SessionFeedbackDelta.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/DatasetShareSchema.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/ShareCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/ShareDeleteAllParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/ShareDeleteAllResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/ShareListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/splits/SplitCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/splits/SplitListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/versions/VersionListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/versions/VersionRetrieveDiffParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/versions/VersionRetrieveDiffResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/AttachmentsOperations.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/Example.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleDeleteAllParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleDeleteAllResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleDeleteResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleRetrieveCountParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleRetrieveParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleSelect.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleUpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/bulk/BulkCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/bulk/BulkCreateResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/bulk/BulkPatchAllParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/bulk/BulkPatchAllResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/validate/ExampleValidationResult.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/validate/ValidateBulkParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/validate/ValidateCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/ApiFeedbackSource.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/AppFeedbackSource.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/AutoEvalFeedbackSource.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackCreateSchema.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackDeleteResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackEagerParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackLevel.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackRetrieveParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackSchema.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackUpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/ModelFeedbackSource.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/SourceType.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FeedbackFormula.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FeedbackFormulaWeightedVariable.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaDeleteResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaRetrieveParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaUpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/FeedbackIngestTokenCreateSchema.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/FeedbackIngestTokenSchema.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenCreateResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenRetrieveParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenRetrieveResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenUpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenUpdateResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfig.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfigFeedbackConfigsParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfigRetrieveFeedbackConfigsParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfigSchema.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfigUpdateFeedbackConfigsParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/info/InfoListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/info/InfoListResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/info/InfoRetrieveHealthParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/info/InfoRetrieveHealthResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/me/MeRetrieveLsUserIdParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/me/onboardingstate/OnboardingStateCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/me/onboardingstate/OnboardingStateListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/me/onboardingstate/OnboardingStateUpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/me/onboardingstate/UserOnboardingStateResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapDeleteResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapModelPriceMapParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapModelPriceMapResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapRetrieveModelPriceMapParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapRetrieveModelPriceMapResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapUpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapUpdateResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthProvider.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveCallbackParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveCallbackResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveCurrentUserParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveCurrentUserResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveLogoutParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveLogoutResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartDeleteResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartOrgChartsParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartPreviewParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartUpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/CustomChartsRequestBase.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionDeleteResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionUpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrgCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrgListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrgRetrievePermissionsParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrgRetrievePermissionsResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrganizationPgSchemaSlim.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/PaymentPlanTier.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentConfirmCheckoutSessionCompletionParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentConfirmCheckoutSessionCompletionResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentListResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentPaymentMethodParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentPaymentMethodResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentPlanParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentPlanResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentRetrieveDashboardParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentRetrieveDashboardResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentSetDefaultSsoProvisionParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentSetDefaultSsoProvisionResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentSetupParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentSetupResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentStripeAccountLinksParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentStripeAccountLinksResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentStripeCheckoutSessionParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentStripeCheckoutSessionResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentUpdateLoginMethodsParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentUpdateLoginMethodsResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CustomerVisiblePlanInfo.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/OrganizationConfig.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/StripeCustomerAddress.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/StripePaymentMethodInfo.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/Wallet.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/billing/BillingListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/billing/BillingListResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/billing/BillingRetrieveUsageParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/billing/BillingRetrieveUsageResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/BusinessInfoBusinessInfoParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/BusinessInfoBusinessInfoResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/BusinessInfoRetrieveBusinessInfoParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/BusinessInfoRetrieveBusinessInfoResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/StripeBusinessBillingInfo.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/StripeTaxId.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/info/InfoListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/info/InfoPatchAllParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/info/OrganizationInfo.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/AccessScope.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberBatchParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberDeleteResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberListResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberRetrieveActiveParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberUpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberUpdateResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/OrgMemberIdentity.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/PendingIdentity.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/PendingIdentityCreate.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/basic/BasicBatchParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/basic/BasicBatchResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/pending/OrgPendingIdentity.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/pending/PendingDeleteAllParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/pending/PendingDeleteAllResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/pending/PendingListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/personalaccesstokens/PersonalAccessTokenDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/personalaccesstokens/PersonalAccessTokenPersonalAccessTokensParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/personalaccesstokens/PersonalAccessTokenRetrievePersonalAccessTokensParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/Role.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/RoleCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/RoleDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/RoleListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/RoleUpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ApiKeyCreateRequest.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ApiKeyCreateResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ApiKeyGetResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ServiceKeyDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ServiceKeyRetrieveServiceKeysParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ServiceKeyServiceKeysParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoProvider.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoSettingDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoSettingRetrieveSsoSettingsParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoSettingSsoSettingsParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoSettingUpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/user/ProviderUserSlim.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/user/UserRetrieveLoginMethodsParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/members/MemberUpdateBasicParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/members/MemberUpdateBasicResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/Identity.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/PendingClaimParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/PendingDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/PendingDeleteResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/PendingListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/ttlsettings/TraceTier.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/ttlsettings/TtlSettingRetrieveTtlSettingsParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/ttlsettings/TtlSettingUpdateTtlSettingsParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/ttlsettings/TtlSettings.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/ttlsettings/UpsertTtlSettingsRequest.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSavedOptions.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingDeleteResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingPlaygroundSettingsParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingRetrievePlaygroundSettingsParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingUpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingsResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/prompts/InvalidToolCall.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/prompts/PromptCanvasParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/prompts/PromptCanvasResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/prompts/PromptInvokePromptParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/prompts/PromptInvokePromptResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/prompts/ToolCall.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/prompts/UsageMetadata.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/EPromptWebhookTrigger.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhook.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookDeleteResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookPromptWebhooksParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookRetrieveParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookRetrievePromptWebhooksParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookTestParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookTestResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookUpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/PublicRetrieveFeedbacksParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetListResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveComparativeParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveComparativeResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveFeedbackParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveSessionsBulkParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveSessionsParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunDeltaParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunGenerateQueryParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunPublicDatasetSchema.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunQueryParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunQueryResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunRetrieveParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunStats.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunStatsParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/examples/ExampleListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/examples/ExampleRetrieveCountParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/examples/ExampleRunsParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/examples/ExampleRunsResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunPublicSchema.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunQueryParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunQueryResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunRetrieveParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/schemas/SchemaRetrieveMessageJsonParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/schemas/SchemaRetrieveMessageJsonResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/schemas/SchemaRetrieveTooldefJsonParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/schemas/SchemaRetrieveTooldefJsonResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/CreateRepoResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/DemoConfig.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/EPromptOptimizationAlgorithm.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/GetRepoResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/PromptimConfig.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoDeleteResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoForkParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoListResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoOptimizeJobParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoOptimizeJobResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoRetrieveParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoUpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoWithLookups.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/EPromptOptimizationJobStatus.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobDeleteResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobOptimizationJobsParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobRetrieveOptimizationJobsParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobRetrieveParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobRetrieveResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobUpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/PromptOptimizationJob.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/PromptOptimizationResult.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/EPromptOptimizationJobLogType.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogDeleteResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogRetrieveParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/PromptOptimizationJobLog.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/RepoTag.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagDeleteResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagRetrieveParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagUpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/BodyParamsForRunSchema.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RequestBodyForRunsGenerateQuery.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/ResponseBodyForRunsGenerateQuery.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunDeleteResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunGenerateQueryParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunQueryParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunQueryResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunRetrieveParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunSchema.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunStatsParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunStatsQueryParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunStatsResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunTypeEnum.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunUpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunUpdateResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunsFilterDataSourceTypeEnum.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/group/GroupCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/group/GroupCreateResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/group/GroupStatsParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/group/GroupStatsResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/group/RunGroupRequest.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/CodeEvaluatorTopLevel.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/EvaluatorTopLevel.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleDeleteResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleLogActionResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleLogSchema.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleRetrieveLastAppliedParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleRetrieveLogsParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleUpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RunRulesPagerdutyAlertSchema.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RunRulesSchema.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RunRulesWebhookSchema.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/trigger/TriggerCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/trigger/TriggerCreateResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/share/RunShareSchema.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/share/ShareCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/share/ShareDeleteAllParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/share/ShareDeleteAllResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/share/ShareListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountDeleteResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountRetrieveServiceAccountsParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountRetrieveServiceAccountsResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountServiceAccountsParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountServiceAccountsResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/CustomChartsSection.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/CustomChartsSectionRequest.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/RunStatsGroupBy.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDashboardParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDeleteAllParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDeleteAllResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDeleteResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionRetrieveMetadataParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionRetrieveMetadataResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionRetrieveParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionSortableColumns.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionUpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/TimedeltaInput.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/TracerSession.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/TracerSessionWithoutVirtualFields.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/CreateRunClusteringJobRequest.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightCreateResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightDeleteResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightListResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightRetrieveParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightRetrieveResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightRetrieveRunsParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightRetrieveRunsResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightUpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightUpdateResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigDeleteResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigGenerateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigGenerateResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigListResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigUpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/CreateClusteringJobConfigResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/SavedRunClusteringJobRequest.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/FilterView.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/FilterViewType.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewDeleteResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewRetrieveParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewUpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/settings/AppHubCrudTenantsTenant.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/settings/SettingHandleParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/settings/SettingListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sso/SsoRetrieveParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sso/SsoRetrieveResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationConfirmParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationConfirmResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationSendParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationSendResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationStatusParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationStatusResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/tenants/AppSchemasTenant.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/tenants/TenantCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/tenants/TenantForUser.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/tenants/TenantListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/ttlsettings/TtlSettingRetrieveTtlSettingsParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/ttlsettings/TtlSettingUpdateTtlSettingsParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimit.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitDeleteResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitRetrieveOrgParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitRetrieveUsageLimitsParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitType.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitUpdateUsageLimitsParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceDeleteResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceUpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/CurrentRetrieveStatsParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/CurrentRetrieveStatsResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/CurrentRetrieveUsageLimitsParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/CurrentRetrieveUsageLimitsResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberBatchParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberDeleteResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberIdentity.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberListResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberRetrieveActiveParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberUpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberUpdateResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/pending/PendingDeleteAllParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/pending/PendingDeleteAllResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/pending/PendingListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretCreateResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretListResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretRetrieveEncryptedParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretRetrieveEncryptedResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/shared/SharedDeleteAllParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/shared/SharedDeleteAllResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/shared/SharedListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/shared/SharedListResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/Resource.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/Tagging.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingDeleteResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingListResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKey.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyDeleteResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyRetrieveParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyRetrieveTagKeysParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyTagKeysParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyUpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValue.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueDeleteResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueRetrieveParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueRetrieveTagValuesParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueTagValuesParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueUpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/ResourceType.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagListResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagResourcesParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagResourcesResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagRetrieveResourceParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagRetrieveResourceResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingClaimParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingClaimResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingDeleteResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ColumnOverride.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverride.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideRetrieveParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideUpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/feedback/FeedbackIngestBatchParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/feedback/FeedbackIngestBatchResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertActionBase.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertDeleteResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertRetrieveParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertRuleBase.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertRuleResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertTestParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertTestResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertUpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertUpdateResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleHardDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleHardDeleteResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleUpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleUpdateResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleUploadParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleUploadResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicy.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyCreateResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyDeleteParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyListParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyListResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyRetrieveParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/ConditionGroup.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/roles/RoleAttachParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/runs/Run.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/runs/RunCreateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/runs/RunCreateResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/runs/RunIngestBatchParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/runs/RunIngestBatchResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/runs/RunIngestMultipartParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/runs/RunIngestMultipartResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/runs/RunUpdateParams.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/runs/RunUpdateResponse.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/ApiServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/ApiServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/DatasetServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/DatasetServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/FeedbackServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/FeedbackServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/PlatformServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/PlatformServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/RunServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/RunServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/V1ServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/V1ServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/AceServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/AceServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/AnnotationQueueServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/AnnotationQueueServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ApiKeyServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ApiKeyServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/BulkExportServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/BulkExportServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ChartServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ChartServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/CommentServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/CommentServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/CommitServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/CommitServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/DatasetServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/DatasetServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ExampleServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ExampleServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/FeedbackConfigServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/FeedbackConfigServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/FeedbackServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/FeedbackServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/InfoServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/InfoServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/MeServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/MeServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ModelPriceMapServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ModelPriceMapServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/OAuthServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/OAuthServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/OrgChartServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/OrgChartServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/OrgServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/OrgServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/PlaygroundSettingServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/PlaygroundSettingServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/PromptServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/PromptServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/PromptWebhookServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/PromptWebhookServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/PublicServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/PublicServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/RepoServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/RepoServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/RunServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/RunServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ServiceAccountServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ServiceAccountServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/SessionServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/SessionServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/SettingServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/SettingServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/SsoServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/SsoServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/TenantServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/TenantServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/TtlSettingServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/TtlSettingServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/UsageLimitServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/UsageLimitServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/WorkspaceServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/WorkspaceServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/annotationqueues/RunServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/annotationqueues/RunServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/apikey/CurrentServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/apikey/CurrentServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/bulkexports/DestinationServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/bulkexports/DestinationServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/bulkexports/RunServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/bulkexports/RunServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/charts/SectionServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/charts/SectionServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/comments/LikeServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/comments/LikeServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/ComparativeServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/ComparativeServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/ExperimentServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/ExperimentServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/GroupServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/GroupServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/IndexServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/IndexServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/PlaygroundExperimentServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/PlaygroundExperimentServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/RunServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/RunServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/ShareServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/ShareServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/SplitServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/SplitServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/VersionServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/VersionServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/examples/BulkServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/examples/BulkServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/examples/ValidateServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/examples/ValidateServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/feedback/FormulaServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/feedback/FormulaServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/feedback/TokenServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/feedback/TokenServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/me/OnboardingStateServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/me/OnboardingStateServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgcharts/SectionServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgcharts/SectionServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/CurrentServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/CurrentServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/MemberServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/MemberServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/PendingServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/PendingServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/TtlSettingServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/TtlSettingServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/BillingServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/BillingServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/BusinessInfoServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/BusinessInfoServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/InfoServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/InfoServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/MemberServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/MemberServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/PersonalAccessTokenServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/PersonalAccessTokenServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/RoleServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/RoleServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/ServiceKeyServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/ServiceKeyServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/SsoSettingServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/SsoSettingServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/UserServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/UserServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/members/BasicServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/members/BasicServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/members/PendingServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/members/PendingServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/DatasetServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/DatasetServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/ExampleServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/ExampleServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/RunServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/RunServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/SchemaServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/SchemaServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/datasets/RunServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/datasets/RunServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/repos/OptimizationJobServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/repos/OptimizationJobServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/repos/TagServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/repos/TagServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/repos/optimizationjobs/LogServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/repos/optimizationjobs/LogServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/runs/GroupServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/runs/GroupServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/runs/RuleServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/runs/RuleServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/runs/ShareServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/runs/ShareServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/runs/rules/TriggerServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/runs/rules/TriggerServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/sessions/InsightServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/sessions/InsightServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/sessions/ViewServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/sessions/ViewServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/sessions/insights/ConfigServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/sessions/insights/ConfigServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/sso/EmailVerificationServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/sso/EmailVerificationServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/CurrentServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/CurrentServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/PendingServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/PendingServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/MemberServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/MemberServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/SecretServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/SecretServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/SharedServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/SharedServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/TagKeyServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/TagKeyServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/TagServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/TagServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/TaggingServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/TaggingServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/members/PendingServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/members/PendingServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/tagkeys/TagValueServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/tagkeys/TagValueServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/datasets/ExperimentViewOverrideServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/datasets/ExperimentViewOverrideServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/AlertServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/AlertServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/DatasetServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/DatasetServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/OrgServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/OrgServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/datasets/ExampleServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/datasets/ExampleServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/orgs/CurrentServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/orgs/CurrentServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/orgs/current/AccessPolicyServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/orgs/current/AccessPolicyServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/orgs/current/accesspolicies/RoleServiceAsync.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/orgs/current/accesspolicies/RoleServiceAsyncImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/ApiService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/ApiServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/DatasetService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/DatasetServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/FeedbackService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/FeedbackServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/PlatformService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/PlatformServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/RunService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/RunServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/V1Service.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/V1ServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/AceService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/AceServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/AnnotationQueueService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/AnnotationQueueServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ApiKeyService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ApiKeyServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/BulkExportService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/BulkExportServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ChartService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ChartServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/CommentService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/CommentServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/CommitService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/CommitServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/DatasetService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/DatasetServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ExampleService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ExampleServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/FeedbackConfigService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/FeedbackConfigServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/FeedbackService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/FeedbackServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/InfoService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/InfoServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/MeService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/MeServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ModelPriceMapService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ModelPriceMapServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/OAuthService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/OAuthServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/OrgChartService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/OrgChartServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/OrgService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/OrgServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/PlaygroundSettingService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/PlaygroundSettingServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/PromptService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/PromptServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/PromptWebhookService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/PromptWebhookServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/PublicService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/PublicServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/RepoService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/RepoServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/RunService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/RunServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ServiceAccountService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ServiceAccountServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/SessionService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/SessionServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/SettingService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/SettingServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/SsoService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/SsoServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/TenantService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/TenantServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/TtlSettingService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/TtlSettingServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/UsageLimitService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/UsageLimitServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/WorkspaceService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/WorkspaceServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/annotationqueues/RunService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/annotationqueues/RunServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/apikey/CurrentService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/apikey/CurrentServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/bulkexports/DestinationService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/bulkexports/DestinationServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/bulkexports/RunService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/bulkexports/RunServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/charts/SectionService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/charts/SectionServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/comments/LikeService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/comments/LikeServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/ComparativeService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/ComparativeServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/ExperimentService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/ExperimentServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/GroupService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/GroupServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/IndexService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/IndexServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/PlaygroundExperimentService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/PlaygroundExperimentServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/RunService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/RunServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/ShareService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/ShareServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/SplitService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/SplitServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/VersionService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/VersionServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/examples/BulkService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/examples/BulkServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/examples/ValidateService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/examples/ValidateServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/feedback/FormulaService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/feedback/FormulaServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/feedback/TokenService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/feedback/TokenServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/me/OnboardingStateService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/me/OnboardingStateServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgcharts/SectionService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgcharts/SectionServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/CurrentService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/CurrentServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/MemberService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/MemberServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/PendingService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/PendingServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/TtlSettingService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/TtlSettingServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/BillingService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/BillingServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/BusinessInfoService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/BusinessInfoServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/InfoService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/InfoServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/MemberService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/MemberServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/PersonalAccessTokenService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/PersonalAccessTokenServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/RoleService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/RoleServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/ServiceKeyService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/ServiceKeyServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/SsoSettingService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/SsoSettingServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/UserService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/UserServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/members/BasicService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/members/BasicServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/members/PendingService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/members/PendingServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/DatasetService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/DatasetServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/ExampleService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/ExampleServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/RunService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/RunServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/SchemaService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/SchemaServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/datasets/RunService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/datasets/RunServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/repos/OptimizationJobService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/repos/OptimizationJobServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/repos/TagService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/repos/TagServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/repos/optimizationjobs/LogService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/repos/optimizationjobs/LogServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/GroupService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/GroupServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/RuleService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/RuleServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/ShareService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/ShareServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/rules/TriggerService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/rules/TriggerServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/sessions/InsightService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/sessions/InsightServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/sessions/ViewService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/sessions/ViewServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/sessions/insights/ConfigService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/sessions/insights/ConfigServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/sso/EmailVerificationService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/sso/EmailVerificationServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/CurrentService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/CurrentServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/PendingService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/PendingServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/MemberService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/MemberServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/SecretService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/SecretServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/SharedService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/SharedServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/TagKeyService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/TagKeyServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/TagService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/TagServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/TaggingService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/TaggingServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/members/PendingService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/members/PendingServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/tagkeys/TagValueService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/tagkeys/TagValueServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/datasets/ExperimentViewOverrideService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/datasets/ExperimentViewOverrideServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/AlertService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/AlertServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/DatasetService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/DatasetServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/OrgService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/OrgServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/datasets/ExampleService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/datasets/ExampleServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/orgs/CurrentService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/orgs/CurrentServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/orgs/current/AccessPolicyService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/orgs/current/AccessPolicyServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/orgs/current/accesspolicies/RoleService.kt create mode 100644 langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/orgs/current/accesspolicies/RoleServiceImpl.kt create mode 100644 langsmith-api-java-core/src/main/resources/META-INF/proguard/langsmith-api-java-core.pro create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/TestServerExtension.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/core/ClientOptionsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/core/ObjectMappersTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/core/PhantomReachableTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/core/UtilsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/core/ValuesTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/core/http/AsyncStreamResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/core/http/HeadersTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/core/http/QueryParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/core/http/RetryingHttpClientTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/V1EventsParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/V1EventsResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/V1LoginParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/V1LoginResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/V1RetrieveOkParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/V1RetrieveOkResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/V1UpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/V1UpdateResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/ace/AceExecuteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/ace/AceExecuteResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueAnnotationQueuesParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueDeleteResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueExportParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueExportResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueuePopulateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueuePopulateResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveAnnotationQueuesParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveAnnotationQueuesResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveQueuesParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveSizeParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveTotalArchivedParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveTotalSizeParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRubricItemSchemaTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueSchemaTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueSizeSchemaTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueUpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueUpdateResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/RunSchemaWithAnnotationQueueInfoTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunCreateResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunDeleteResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunUpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunUpdateResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/apikey/ApiKeyApiKeyParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/apikey/ApiKeyDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/apikey/ApiKeyRetrieveApiKeyParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/apikey/current/CurrentCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/apikey/current/CurrentDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/apikey/current/CurrentListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportBulkExportsParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportRetrieveBulkExportsParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportRetrieveParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportUpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/BulkExportDestinationS3ConfigTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/BulkExportDestinationTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/DestinationCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/DestinationListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/DestinationRetrieveParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/runs/BulkExportRunTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/runs/RunListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/runs/RunRetrieveParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartDeleteResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartPreviewParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartUpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartCreateTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartPreviewRequestTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartSeriesFiltersTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartSeriesTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartUpdateTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartsDataPointTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartsRequestTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartsResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/SingleCustomChartResponseBaseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/SingleCustomChartResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/section/CustomChartsSectionCreateTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/section/CustomChartsSectionResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/section/CustomChartsSectionUpdateTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionCloneParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionDeleteResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionUpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/comments/CommentRetrieveParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/comments/CommentTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/comments/CommentUpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/comments/CreateCommentRequestTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/comments/ListCommentsResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/comments/like/LikeCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/comments/like/LikeCreateResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/comments/like/LikeDeleteAllParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/comments/like/LikeDeleteAllResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitManifestResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitRetrieveParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitUpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitUpdateResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitWithLookupsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetCloneParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetCloneResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetDeleteResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetGenerateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetGenerateResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveCsvParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveCsvResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveJsonlParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveJsonlResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveOpenAIFtParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveOpenAIFtResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveOpenAIParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveOpenAIResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveVersionParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetSearchParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetSearchResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetStudioExperimentParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetStudioExperimentResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetTransformationTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUpdateResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUpdateTagsParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUploadExperimentParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUploadExperimentResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUploadParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetVersionTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/FeedbackCreateCoreSchemaTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/MissingTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeCreateResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeDeleteResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeListResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/SimpleExperimentInfoTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/experiments/ExperimentGroupedParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/experiments/ExperimentGroupedResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/group/GroupRunsParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/group/GroupRunsResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexCreateResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexDeleteAllParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexDeleteAllResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexListResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexSyncParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexSyncResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/PlaygroundExperimentBatchParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/PlaygroundExperimentBatchResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/PlaygroundExperimentStreamParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/PlaygroundExperimentStreamResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/RunnableConfigTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/ExampleWithRunsChTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/ExampleWithRunsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/QueryExampleSchemaWithRunsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/QueryFeedbackDeltaTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/RunCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/RunCreateResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/RunDeltaParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/SessionFeedbackDeltaTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/DatasetShareSchemaTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/ShareCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/ShareDeleteAllParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/ShareDeleteAllResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/ShareListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/splits/SplitCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/splits/SplitListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/versions/VersionListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/versions/VersionRetrieveDiffParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/versions/VersionRetrieveDiffResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/AttachmentsOperationsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleDeleteAllParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleDeleteAllResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleDeleteResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleRetrieveCountParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleRetrieveParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleUpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/bulk/BulkCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/bulk/BulkCreateResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/bulk/BulkPatchAllParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/bulk/BulkPatchAllResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/validate/ExampleValidationResultTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/validate/ValidateBulkParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/validate/ValidateCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/ApiFeedbackSourceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/AppFeedbackSourceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/AutoEvalFeedbackSourceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackCreateSchemaTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackDeleteResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackEagerParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackRetrieveParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackSchemaTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackUpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/ModelFeedbackSourceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FeedbackFormulaTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FeedbackFormulaWeightedVariableTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaDeleteResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaRetrieveParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaUpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/FeedbackIngestTokenCreateSchemaTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/FeedbackIngestTokenSchemaTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenCreateResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenRetrieveParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenRetrieveResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenUpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenUpdateResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfigFeedbackConfigsParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfigRetrieveFeedbackConfigsParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfigSchemaTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfigTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfigUpdateFeedbackConfigsParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/info/InfoListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/info/InfoListResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/info/InfoRetrieveHealthParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/info/InfoRetrieveHealthResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/me/MeRetrieveLsUserIdParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/me/onboardingstate/OnboardingStateCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/me/onboardingstate/OnboardingStateListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/me/onboardingstate/OnboardingStateUpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/me/onboardingstate/UserOnboardingStateResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapDeleteResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapModelPriceMapParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapModelPriceMapResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapRetrieveModelPriceMapParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapRetrieveModelPriceMapResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapUpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapUpdateResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveCallbackParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveCallbackResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveCurrentUserParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveCurrentUserResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveLogoutParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveLogoutResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartDeleteResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartOrgChartsParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartPreviewParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartUpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/CustomChartsRequestBaseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionDeleteResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionUpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrgCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrgListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrgRetrievePermissionsParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrgRetrievePermissionsResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrganizationPgSchemaSlimTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentConfirmCheckoutSessionCompletionParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentConfirmCheckoutSessionCompletionResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentListResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentPaymentMethodParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentPaymentMethodResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentPlanParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentPlanResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentRetrieveDashboardParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentRetrieveDashboardResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentSetDefaultSsoProvisionParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentSetDefaultSsoProvisionResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentSetupParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentSetupResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentStripeAccountLinksParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentStripeAccountLinksResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentStripeCheckoutSessionParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentStripeCheckoutSessionResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentUpdateLoginMethodsParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentUpdateLoginMethodsResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CustomerVisiblePlanInfoTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/OrganizationConfigTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/StripeCustomerAddressTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/StripePaymentMethodInfoTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/WalletTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/billing/BillingListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/billing/BillingListResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/billing/BillingRetrieveUsageParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/billing/BillingRetrieveUsageResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/BusinessInfoBusinessInfoParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/BusinessInfoBusinessInfoResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/BusinessInfoRetrieveBusinessInfoParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/BusinessInfoRetrieveBusinessInfoResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/StripeBusinessBillingInfoTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/StripeTaxIdTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/info/InfoListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/info/InfoPatchAllParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/info/OrganizationInfoTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberBatchParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberDeleteResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberListResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberRetrieveActiveParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberUpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberUpdateResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/OrgMemberIdentityTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/PendingIdentityCreateTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/PendingIdentityTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/basic/BasicBatchParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/basic/BasicBatchResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/pending/OrgPendingIdentityTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/pending/PendingDeleteAllParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/pending/PendingDeleteAllResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/pending/PendingListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/personalaccesstokens/PersonalAccessTokenDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/personalaccesstokens/PersonalAccessTokenPersonalAccessTokensParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/personalaccesstokens/PersonalAccessTokenRetrievePersonalAccessTokensParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/RoleCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/RoleDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/RoleListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/RoleTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/RoleUpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ApiKeyCreateRequestTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ApiKeyCreateResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ApiKeyGetResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ServiceKeyDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ServiceKeyRetrieveServiceKeysParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ServiceKeyServiceKeysParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoProviderTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoSettingDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoSettingRetrieveSsoSettingsParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoSettingSsoSettingsParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoSettingUpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/user/ProviderUserSlimTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/user/UserRetrieveLoginMethodsParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/members/MemberUpdateBasicParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/members/MemberUpdateBasicResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/IdentityTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/PendingClaimParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/PendingDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/PendingDeleteResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/PendingListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/ttlsettings/TtlSettingRetrieveTtlSettingsParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/ttlsettings/TtlSettingUpdateTtlSettingsParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/ttlsettings/TtlSettingsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/ttlsettings/UpsertTtlSettingsRequestTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSavedOptionsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingDeleteResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingPlaygroundSettingsParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingRetrievePlaygroundSettingsParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingUpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingsResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/prompts/InvalidToolCallTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/prompts/PromptCanvasParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/prompts/PromptCanvasResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/prompts/PromptInvokePromptParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/prompts/PromptInvokePromptResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/prompts/ToolCallTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/prompts/UsageMetadataTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookDeleteResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookPromptWebhooksParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookRetrieveParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookRetrievePromptWebhooksParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookTestParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookTestResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookUpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/PublicRetrieveFeedbacksParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetListResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveComparativeParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveComparativeResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveFeedbackParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveSessionsBulkParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveSessionsParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunDeltaParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunGenerateQueryParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunPublicDatasetSchemaTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunQueryParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunQueryResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunRetrieveParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunStatsParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunStatsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/examples/ExampleListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/examples/ExampleRetrieveCountParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/examples/ExampleRunsParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/examples/ExampleRunsResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunPublicSchemaTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunQueryParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunQueryResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunRetrieveParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/schemas/SchemaRetrieveMessageJsonParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/schemas/SchemaRetrieveMessageJsonResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/schemas/SchemaRetrieveTooldefJsonParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/schemas/SchemaRetrieveTooldefJsonResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/CreateRepoResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/DemoConfigTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/GetRepoResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/PromptimConfigTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoDeleteResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoForkParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoListResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoOptimizeJobParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoOptimizeJobResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoRetrieveParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoUpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoWithLookupsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobDeleteResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobOptimizationJobsParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobRetrieveOptimizationJobsParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobRetrieveParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobRetrieveResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobUpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/PromptOptimizationJobTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/PromptOptimizationResultTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogDeleteResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogRetrieveParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/PromptOptimizationJobLogTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/RepoTagTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagDeleteResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagRetrieveParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagUpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/BodyParamsForRunSchemaTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RequestBodyForRunsGenerateQueryTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/ResponseBodyForRunsGenerateQueryTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunDeleteResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunGenerateQueryParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunQueryParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunQueryResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunRetrieveParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunSchemaTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunStatsParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunStatsQueryParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunStatsResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunUpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunUpdateResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/group/GroupCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/group/GroupCreateResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/group/GroupStatsParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/group/GroupStatsResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/group/RunGroupRequestTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/CodeEvaluatorTopLevelTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/EvaluatorTopLevelTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleDeleteResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleLogActionResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleLogSchemaTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleRetrieveLastAppliedParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleRetrieveLogsParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleUpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RunRulesPagerdutyAlertSchemaTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RunRulesSchemaTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RunRulesWebhookSchemaTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/trigger/TriggerCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/trigger/TriggerCreateResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/share/RunShareSchemaTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/share/ShareCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/share/ShareDeleteAllParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/share/ShareDeleteAllResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/share/ShareListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountDeleteResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountRetrieveServiceAccountsParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountRetrieveServiceAccountsResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountServiceAccountsParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountServiceAccountsResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/CustomChartsSectionRequestTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/CustomChartsSectionTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/RunStatsGroupByTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDashboardParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDeleteAllParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDeleteAllResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDeleteResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionRetrieveMetadataParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionRetrieveMetadataResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionRetrieveParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionUpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/TimedeltaInputTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/TracerSessionTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/TracerSessionWithoutVirtualFieldsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/CreateRunClusteringJobRequestTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightCreateResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightDeleteResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightListResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightRetrieveParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightRetrieveResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightRetrieveRunsParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightRetrieveRunsResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightUpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightUpdateResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigDeleteResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigGenerateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigGenerateResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigListResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigUpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/CreateClusteringJobConfigResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/SavedRunClusteringJobRequestTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/FilterViewTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewDeleteResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewRetrieveParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewUpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/settings/AppHubCrudTenantsTenantTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/settings/SettingHandleParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/settings/SettingListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sso/SsoRetrieveParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sso/SsoRetrieveResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationConfirmParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationConfirmResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationSendParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationSendResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationStatusParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationStatusResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/tenants/AppSchemasTenantTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/tenants/TenantCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/tenants/TenantForUserTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/tenants/TenantListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/ttlsettings/TtlSettingRetrieveTtlSettingsParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/ttlsettings/TtlSettingUpdateTtlSettingsParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitDeleteResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitRetrieveOrgParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitRetrieveUsageLimitsParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitUpdateUsageLimitsParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceDeleteResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceUpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/CurrentRetrieveStatsParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/CurrentRetrieveStatsResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/CurrentRetrieveUsageLimitsParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/CurrentRetrieveUsageLimitsResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberBatchParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberDeleteResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberIdentityTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberListResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberRetrieveActiveParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberUpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberUpdateResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/pending/PendingDeleteAllParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/pending/PendingDeleteAllResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/pending/PendingListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretCreateResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretListResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretRetrieveEncryptedParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretRetrieveEncryptedResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/shared/SharedDeleteAllParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/shared/SharedDeleteAllResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/shared/SharedListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/shared/SharedListResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/ResourceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingDeleteResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingListResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyDeleteResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyRetrieveParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyRetrieveTagKeysParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyTagKeysParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyUpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueDeleteResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueRetrieveParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueRetrieveTagValuesParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueTagValuesParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueUpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagListResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagResourcesParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagResourcesResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagRetrieveResourceParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagRetrieveResourceResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingClaimParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingClaimResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingDeleteResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ColumnOverrideTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideRetrieveParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideUpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/feedback/FeedbackIngestBatchParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/feedback/FeedbackIngestBatchResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertActionBaseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertDeleteResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertRetrieveParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertRuleBaseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertRuleResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertTestParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertTestResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertUpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertUpdateResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleHardDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleHardDeleteResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleUpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleUpdateResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleUploadParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleUploadResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyCreateResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyDeleteParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyListParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyListResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyRetrieveParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/ConditionGroupTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/roles/RoleAttachParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/runs/RunCreateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/runs/RunCreateResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/runs/RunIngestBatchParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/runs/RunIngestBatchResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/runs/RunIngestMultipartParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/runs/RunIngestMultipartResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/runs/RunTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/runs/RunUpdateParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/runs/RunUpdateResponseTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/ErrorHandlingTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/ServiceParamsTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/FeedbackServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/RunServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/V1ServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/AceServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/AnnotationQueueServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/ApiKeyServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/BulkExportServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/ChartServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/CommentServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/CommitServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/DatasetServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/ExampleServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/FeedbackConfigServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/FeedbackServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/InfoServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/MeServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/ModelPriceMapServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/OAuthServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/OrgChartServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/OrgServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/PlaygroundSettingServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/PromptServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/PromptWebhookServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/PublicServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/RepoServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/RunServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/ServiceAccountServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/SessionServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/SettingServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/SsoServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/TenantServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/TtlSettingServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/UsageLimitServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/WorkspaceServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/annotationqueues/RunServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/apikey/CurrentServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/bulkexports/DestinationServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/bulkexports/RunServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/charts/SectionServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/comments/LikeServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/ComparativeServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/ExperimentServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/GroupServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/IndexServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/PlaygroundExperimentServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/RunServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/ShareServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/SplitServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/VersionServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/examples/BulkServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/examples/ValidateServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/feedback/FormulaServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/feedback/TokenServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/me/OnboardingStateServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgcharts/SectionServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/CurrentServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/MemberServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/PendingServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/TtlSettingServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/BillingServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/BusinessInfoServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/InfoServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/MemberServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/PersonalAccessTokenServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/RoleServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/ServiceKeyServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/SsoSettingServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/UserServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/members/BasicServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/members/PendingServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/public_/DatasetServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/public_/ExampleServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/public_/RunServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/public_/SchemaServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/public_/datasets/RunServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/repos/OptimizationJobServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/repos/TagServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/repos/optimizationjobs/LogServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/runs/GroupServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/runs/RuleServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/runs/ShareServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/runs/rules/TriggerServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/sessions/InsightServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/sessions/ViewServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/sessions/insights/ConfigServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/sso/EmailVerificationServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/CurrentServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/PendingServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/MemberServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/SecretServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/SharedServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/TagKeyServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/TagServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/TaggingServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/members/PendingServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/tagkeys/TagValueServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/datasets/ExperimentViewOverrideServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/platform/AlertServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/platform/datasets/ExampleServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/platform/orgs/current/AccessPolicyServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/platform/orgs/current/accesspolicies/RoleServiceAsyncTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/FeedbackServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/RunServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/V1ServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/AceServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/AnnotationQueueServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/ApiKeyServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/BulkExportServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/ChartServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/CommentServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/CommitServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/DatasetServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/ExampleServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/FeedbackConfigServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/FeedbackServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/InfoServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/MeServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/ModelPriceMapServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/OAuthServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/OrgChartServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/OrgServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/PlaygroundSettingServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/PromptServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/PromptWebhookServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/PublicServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/RepoServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/RunServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/ServiceAccountServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/SessionServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/SettingServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/SsoServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/TenantServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/TtlSettingServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/UsageLimitServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/WorkspaceServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/annotationqueues/RunServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/apikey/CurrentServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/bulkexports/DestinationServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/bulkexports/RunServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/charts/SectionServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/comments/LikeServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/ComparativeServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/ExperimentServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/GroupServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/IndexServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/PlaygroundExperimentServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/RunServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/ShareServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/SplitServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/VersionServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/examples/BulkServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/examples/ValidateServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/feedback/FormulaServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/feedback/TokenServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/me/OnboardingStateServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgcharts/SectionServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/CurrentServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/MemberServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/PendingServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/TtlSettingServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/BillingServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/BusinessInfoServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/InfoServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/MemberServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/PersonalAccessTokenServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/RoleServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/ServiceKeyServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/SsoSettingServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/UserServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/members/BasicServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/members/PendingServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/DatasetServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/ExampleServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/RunServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/SchemaServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/datasets/RunServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/repos/OptimizationJobServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/repos/TagServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/repos/optimizationjobs/LogServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/GroupServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/RuleServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/ShareServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/rules/TriggerServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/sessions/InsightServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/sessions/ViewServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/sessions/insights/ConfigServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/sso/EmailVerificationServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/CurrentServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/PendingServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/MemberServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/SecretServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/SharedServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/TagKeyServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/TagServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/TaggingServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/members/PendingServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/tagkeys/TagValueServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/datasets/ExperimentViewOverrideServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/platform/AlertServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/platform/datasets/ExampleServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/platform/orgs/current/AccessPolicyServiceTest.kt create mode 100644 langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/platform/orgs/current/accesspolicies/RoleServiceTest.kt create mode 100644 langsmith-api-java-example/build.gradle.kts create mode 100644 langsmith-api-java-lib/.keep create mode 100644 langsmith-api-java-proguard-test/build.gradle.kts create mode 100644 langsmith-api-java-proguard-test/src/test/kotlin/com/langsmith_api/api/proguard/ProGuardCompatibilityTest.kt create mode 100644 langsmith-api-java-proguard-test/test.pro create mode 100644 langsmith-api-java/build.gradle.kts create mode 100755 scripts/build create mode 100755 scripts/fast-format create mode 100755 scripts/format create mode 100755 scripts/java-format create mode 100755 scripts/kotlin-format create mode 100755 scripts/lint create mode 100755 scripts/mock create mode 100755 scripts/test create mode 100644 settings.gradle.kts diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..bd8e2619 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,23 @@ +# syntax=docker/dockerfile:1 +FROM debian:bookworm-slim + +RUN apt-get update && apt-get install -y --no-install-recommends \ + libxkbcommon0 \ + ca-certificates \ + ca-certificates-java \ + make \ + curl \ + git \ + openjdk-17-jdk-headless \ + unzip \ + libc++1 \ + vim \ + && apt-get clean autoclean + +# Ensure UTF-8 encoding +ENV LANG=C.UTF-8 +ENV LC_ALL=C.UTF-8 + +WORKDIR /workspace + +COPY . /workspace diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..d55fc4d6 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,20 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/debian +{ + "name": "Debian", + "build": { + "dockerfile": "Dockerfile" + } + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..022b8414 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +# +# https://help.github.com/articles/dealing-with-line-endings/ +# +# These are explicitly windows files and should use crlf +*.bat text eol=crlf diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..72cc5bb5 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,85 @@ +name: CI +on: + push: + branches-ignore: + - 'generated' + - 'codegen/**' + - 'integrated/**' + - 'stl-preview-head/**' + - 'stl-preview-base/**' + pull_request: + branches-ignore: + - 'stl-preview-head/**' + - 'stl-preview-base/**' + +jobs: + lint: + timeout-minutes: 15 + name: lint + runs-on: ${{ github.repository == 'stainless-sdks/langsmith-api-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + + steps: + - uses: actions/checkout@v4 + + - name: Set up Java + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: | + 8 + 21 + cache: gradle + + - name: Set up Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: Run lints + run: ./scripts/lint + + build: + timeout-minutes: 15 + name: build + runs-on: ${{ github.repository == 'stainless-sdks/langsmith-api-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + + steps: + - uses: actions/checkout@v4 + + - name: Set up Java + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: | + 8 + 21 + cache: gradle + + - name: Set up Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: Build SDK + run: ./scripts/build + + test: + timeout-minutes: 15 + name: test + runs-on: ${{ github.repository == 'stainless-sdks/langsmith-api-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + steps: + - uses: actions/checkout@v4 + + - name: Set up Java + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: | + 8 + 21 + cache: gradle + + - name: Set up Gradle + uses: gradle/gradle-build-action@v2 + + - name: Run tests + run: ./scripts/test diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..b1346e6d --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.prism.log +.gradle +.idea +.kotlin +build/ +codegen.log +kls_database.db diff --git a/.stats.yml b/.stats.yml new file mode 100644 index 00000000..7047ea0f --- /dev/null +++ b/.stats.yml @@ -0,0 +1,4 @@ +configured_endpoints: 360 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/langsmith%2Flangsmith-api-f59df55f3cc03529735b4b0e27c41593522ec65be46def87c7949084f7af29b6.yml +openapi_spec_hash: b879256ce4f4743c542a10743517dc31 +config_hash: ec5e205362dc0cc8afa4a3aaa46cc06d diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..8765f0c2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2025 Langsmith API + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md index 9725c81d..7ea0130f 100644 --- a/README.md +++ b/README.md @@ -1 +1,688 @@ -# langsmith-api-java \ No newline at end of file +# Langsmith API Java API Library + +[![Maven Central](https://img.shields.io/maven-central/v/com.langsmith_api.api/langsmith-api-java)](https://central.sonatype.com/artifact/com.langsmith_api.api/langsmith-api-java/0.0.1) +[![javadoc](https://javadoc.io/badge2/com.langsmith_api.api/langsmith-api-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.langsmith_api.api/langsmith-api-java/0.0.1) + +The Langsmith API Java SDK provides convenient access to the Langsmith API REST API from applications written in Java. + +It is generated with [Stainless](https://www.stainless.com/). + +Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.langsmith_api.api/langsmith-api-java/0.0.1). + +## Installation + +### Gradle + +```kotlin +implementation("com.langsmith_api.api:langsmith-api-java:0.0.1") +``` + +### Maven + +```xml + + com.langsmith_api.api + langsmith-api-java + 0.0.1 + +``` + +## Requirements + +This library requires Java 8 or later. + +## Usage + +```java +import com.langsmith_api.api.client.LangsmithApiClient; +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient; +import com.langsmith_api.api.models.api.v1.sessions.CustomChartsSection; +import com.langsmith_api.api.models.api.v1.sessions.CustomChartsSectionRequest; +import com.langsmith_api.api.models.api.v1.sessions.SessionDashboardParams; + +// Configures using the `langsmithapi.apiKey`, `langsmithapi.tenantId`, `langsmithapi.bearerToken`, `langsmithapi.organizationId` and `langsmithapi.baseUrl` system properties +// Or configures using the `LANGSMITH_API_API_KEY`, `LANGSMITH_API_TENANT_ID`, `LANGSMITH_API_BEARER_TOKEN`, `LANGSMITH_API_ORGANIZATION_ID` and `LANGSMITH_API_BASE_URL` environment variables +LangsmithApiClient client = LangsmithApiOkHttpClient.fromEnv(); + +SessionDashboardParams params = SessionDashboardParams.builder() + .sessionId("REPLACE_ME") + .customChartsSectionRequest(CustomChartsSectionRequest.builder().build()) + .build(); +CustomChartsSection customChartsSection = client.api().v1().sessions().dashboard(params); +``` + +## Client configuration + +Configure the client using system properties or environment variables: + +```java +import com.langsmith_api.api.client.LangsmithApiClient; +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient; + +// Configures using the `langsmithapi.apiKey`, `langsmithapi.tenantId`, `langsmithapi.bearerToken`, `langsmithapi.organizationId` and `langsmithapi.baseUrl` system properties +// Or configures using the `LANGSMITH_API_API_KEY`, `LANGSMITH_API_TENANT_ID`, `LANGSMITH_API_BEARER_TOKEN`, `LANGSMITH_API_ORGANIZATION_ID` and `LANGSMITH_API_BASE_URL` environment variables +LangsmithApiClient client = LangsmithApiOkHttpClient.fromEnv(); +``` + +Or manually: + +```java +import com.langsmith_api.api.client.LangsmithApiClient; +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient; + +LangsmithApiClient client = LangsmithApiOkHttpClient.builder() + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build(); +``` + +Or using a combination of the two approaches: + +```java +import com.langsmith_api.api.client.LangsmithApiClient; +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient; + +LangsmithApiClient client = LangsmithApiOkHttpClient.builder() + // Configures using the `langsmithapi.apiKey`, `langsmithapi.tenantId`, `langsmithapi.bearerToken`, `langsmithapi.organizationId` and `langsmithapi.baseUrl` system properties + // Or configures using the `LANGSMITH_API_API_KEY`, `LANGSMITH_API_TENANT_ID`, `LANGSMITH_API_BEARER_TOKEN`, `LANGSMITH_API_ORGANIZATION_ID` and `LANGSMITH_API_BASE_URL` environment variables + .fromEnv() + .apiKey("My API Key") + .build(); +``` + +See this table for the available options: + +| Setter | System property | Environment variable | Required | Default value | +| ---------------- | ----------------------------- | ------------------------------- | -------- | --------------------------- | +| `apiKey` | `langsmithapi.apiKey` | `LANGSMITH_API_API_KEY` | false | - | +| `tenantId` | `langsmithapi.tenantId` | `LANGSMITH_API_TENANT_ID` | false | - | +| `bearerToken` | `langsmithapi.bearerToken` | `LANGSMITH_API_BEARER_TOKEN` | false | - | +| `organizationId` | `langsmithapi.organizationId` | `LANGSMITH_API_ORGANIZATION_ID` | false | - | +| `baseUrl` | `langsmithapi.baseUrl` | `LANGSMITH_API_BASE_URL` | true | `"https://api.example.com"` | + +System properties take precedence over environment variables. + +> [!TIP] +> Don't create more than one client in the same application. Each client has a connection pool and +> thread pools, which are more efficient to share between requests. + +### Modifying configuration + +To temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service: + +```java +import com.langsmith_api.api.client.LangsmithApiClient; + +LangsmithApiClient clientWithOptions = client.withOptions(optionsBuilder -> { + optionsBuilder.baseUrl("https://example.com"); + optionsBuilder.maxRetries(42); +}); +``` + +The `withOptions()` method does not affect the original client or service. + +## Requests and responses + +To send a request to the Langsmith API API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class. + +For example, `client.api().v1().sessions().dashboard(...)` should be called with an instance of `SessionDashboardParams`, and it will return an instance of `CustomChartsSection`. + +## Immutability + +Each class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it. + +Each class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy. + +Because each class is immutable, builder modification will _never_ affect already built class instances. + +## Asynchronous execution + +The default client is synchronous. To switch to asynchronous execution, call the `async()` method: + +```java +import com.langsmith_api.api.client.LangsmithApiClient; +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient; +import com.langsmith_api.api.models.api.v1.sessions.CustomChartsSection; +import com.langsmith_api.api.models.api.v1.sessions.CustomChartsSectionRequest; +import com.langsmith_api.api.models.api.v1.sessions.SessionDashboardParams; +import java.util.concurrent.CompletableFuture; + +// Configures using the `langsmithapi.apiKey`, `langsmithapi.tenantId`, `langsmithapi.bearerToken`, `langsmithapi.organizationId` and `langsmithapi.baseUrl` system properties +// Or configures using the `LANGSMITH_API_API_KEY`, `LANGSMITH_API_TENANT_ID`, `LANGSMITH_API_BEARER_TOKEN`, `LANGSMITH_API_ORGANIZATION_ID` and `LANGSMITH_API_BASE_URL` environment variables +LangsmithApiClient client = LangsmithApiOkHttpClient.fromEnv(); + +SessionDashboardParams params = SessionDashboardParams.builder() + .sessionId("REPLACE_ME") + .customChartsSectionRequest(CustomChartsSectionRequest.builder().build()) + .build(); +CompletableFuture customChartsSection = client.async().api().v1().sessions().dashboard(params); +``` + +Or create an asynchronous client from the beginning: + +```java +import com.langsmith_api.api.client.LangsmithApiClientAsync; +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync; +import com.langsmith_api.api.models.api.v1.sessions.CustomChartsSection; +import com.langsmith_api.api.models.api.v1.sessions.CustomChartsSectionRequest; +import com.langsmith_api.api.models.api.v1.sessions.SessionDashboardParams; +import java.util.concurrent.CompletableFuture; + +// Configures using the `langsmithapi.apiKey`, `langsmithapi.tenantId`, `langsmithapi.bearerToken`, `langsmithapi.organizationId` and `langsmithapi.baseUrl` system properties +// Or configures using the `LANGSMITH_API_API_KEY`, `LANGSMITH_API_TENANT_ID`, `LANGSMITH_API_BEARER_TOKEN`, `LANGSMITH_API_ORGANIZATION_ID` and `LANGSMITH_API_BASE_URL` environment variables +LangsmithApiClientAsync client = LangsmithApiOkHttpClientAsync.fromEnv(); + +SessionDashboardParams params = SessionDashboardParams.builder() + .sessionId("REPLACE_ME") + .customChartsSectionRequest(CustomChartsSectionRequest.builder().build()) + .build(); +CompletableFuture customChartsSection = client.api().v1().sessions().dashboard(params); +``` + +The asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s. + +## File uploads + +The SDK defines methods that accept files. + +To upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html): + +```java +import com.langsmith_api.api.models.api.v1.examples.Example; +import com.langsmith_api.api.models.api.v1.examples.ExampleUpdateParams; +import java.nio.file.Paths; + +ExampleUpdateParams params = ExampleUpdateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addInputKey("string") + .file(Paths.get("/path/to/file")) + .build(); +List examples = client.api().v1().examples().update(params); +``` + +Or an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html): + +```java +import com.langsmith_api.api.models.api.v1.examples.Example; +import com.langsmith_api.api.models.api.v1.examples.ExampleUpdateParams; +import java.net.URL; + +ExampleUpdateParams params = ExampleUpdateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addInputKey("string") + .file(new URL("https://example.com//path/to/file").openStream()) + .build(); +List examples = client.api().v1().examples().update(params); +``` + +Or a `byte[]` array: + +```java +import com.langsmith_api.api.models.api.v1.examples.Example; +import com.langsmith_api.api.models.api.v1.examples.ExampleUpdateParams; + +ExampleUpdateParams params = ExampleUpdateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addInputKey("string") + .file("content".getBytes()) + .build(); +List examples = client.api().v1().examples().update(params); +``` + +Note that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/Values.kt): + +```java +import com.langsmith_api.api.core.MultipartField; +import com.langsmith_api.api.models.api.v1.examples.Example; +import com.langsmith_api.api.models.api.v1.examples.ExampleUpdateParams; +import java.io.InputStream; +import java.net.URL; + +ExampleUpdateParams params = ExampleUpdateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addInputKey("string") + .file(MultipartField.builder() + .value(new URL("https://example.com//path/to/file").openStream()) + .filename("/path/to/file") + .build()) + .build(); +List examples = client.api().v1().examples().update(params); +``` + +## Raw responses + +The SDK defines methods that deserialize responses into instances of Java classes. However, these methods don't provide access to the response headers, status code, or the raw response body. + +To access this data, prefix any HTTP method call on a client or service with `withRawResponse()`: + +```java +import com.langsmith_api.api.core.http.Headers; +import com.langsmith_api.api.core.http.HttpResponseFor; +import com.langsmith_api.api.models.api.v1.sessions.CustomChartsSection; +import com.langsmith_api.api.models.api.v1.sessions.CustomChartsSectionRequest; +import com.langsmith_api.api.models.api.v1.sessions.SessionDashboardParams; + +SessionDashboardParams params = SessionDashboardParams.builder() + .sessionId("REPLACE_ME") + .customChartsSectionRequest(CustomChartsSectionRequest.builder().build()) + .build(); +HttpResponseFor customChartsSection = client.api().v1().sessions().withRawResponse().dashboard(params); + +int statusCode = customChartsSection.statusCode(); +Headers headers = customChartsSection.headers(); +``` + +You can still deserialize the response into an instance of a Java class if needed: + +```java +import com.langsmith_api.api.models.api.v1.sessions.CustomChartsSection; + +CustomChartsSection parsedCustomChartsSection = customChartsSection.parse(); +``` + +## Error handling + +The SDK throws custom unchecked exception types: + +- [`LangsmithApiServiceException`](langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/LangsmithApiServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code: + + | Status | Exception | + | ------ | ---------------------------------------------------------------------------------------------------------------------------------------- | + | 400 | [`BadRequestException`](langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/BadRequestException.kt) | + | 401 | [`UnauthorizedException`](langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/UnauthorizedException.kt) | + | 403 | [`PermissionDeniedException`](langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/PermissionDeniedException.kt) | + | 404 | [`NotFoundException`](langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/NotFoundException.kt) | + | 422 | [`UnprocessableEntityException`](langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/UnprocessableEntityException.kt) | + | 429 | [`RateLimitException`](langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/RateLimitException.kt) | + | 5xx | [`InternalServerException`](langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/InternalServerException.kt) | + | others | [`UnexpectedStatusCodeException`](langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/UnexpectedStatusCodeException.kt) | + +- [`LangsmithApiIoException`](langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/LangsmithApiIoException.kt): I/O networking errors. + +- [`LangsmithApiRetryableException`](langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/LangsmithApiRetryableException.kt): Generic error indicating a failure that could be retried by the client. + +- [`LangsmithApiInvalidDataException`](langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/LangsmithApiInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that's supposed to be required, but the API unexpectedly omitted it from the response. + +- [`LangsmithApiException`](langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/LangsmithApiException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class. + +## Logging + +The SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor). + +Enable logging by setting the `LANGSMITH_API_LOG` environment variable to `info`: + +```sh +$ export LANGSMITH_API_LOG=info +``` + +Or to `debug` for more verbose logging: + +```sh +$ export LANGSMITH_API_LOG=debug +``` + +## ProGuard and R8 + +Although the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `langsmith-api-java-core` is published with a [configuration file](langsmith-api-java-core/src/main/resources/META-INF/proguard/langsmith-api-java-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage). + +ProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary. + +## Jackson + +The SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default. + +The SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config). + +If the SDK threw an exception, but you're _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`LangsmithApiOkHttpClient`](langsmith-api-java-client-okhttp/src/main/kotlin/com/langsmith_api/api/client/okhttp/LangsmithApiOkHttpClient.kt) or [`LangsmithApiOkHttpClientAsync`](langsmith-api-java-client-okhttp/src/main/kotlin/com/langsmith_api/api/client/okhttp/LangsmithApiOkHttpClientAsync.kt). + +> [!CAUTION] +> We make no guarantee that the SDK works correctly when the Jackson version check is disabled. + +## Network options + +### Retries + +The SDK automatically retries 2 times by default, with a short exponential backoff between requests. + +Only the following error types are retried: + +- Connection errors (for example, due to a network connectivity problem) +- 408 Request Timeout +- 409 Conflict +- 429 Rate Limit +- 5xx Internal + +The API may also explicitly instruct the SDK to retry or not retry a request. + +To set a custom number of retries, configure the client using the `maxRetries` method: + +```java +import com.langsmith_api.api.client.LangsmithApiClient; +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient; + +LangsmithApiClient client = LangsmithApiOkHttpClient.builder() + .fromEnv() + .maxRetries(4) + .build(); +``` + +### Timeouts + +Requests time out after 1 minute by default. + +To set a custom timeout, configure the method call using the `timeout` method: + +```java +import com.langsmith_api.api.models.api.v1.sessions.CustomChartsSection; + +CustomChartsSection customChartsSection = client.api().v1().sessions().dashboard( + params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build() +); +``` + +Or configure the default for all method calls at the client level: + +```java +import com.langsmith_api.api.client.LangsmithApiClient; +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient; +import java.time.Duration; + +LangsmithApiClient client = LangsmithApiOkHttpClient.builder() + .fromEnv() + .timeout(Duration.ofSeconds(30)) + .build(); +``` + +### Proxies + +To route requests through a proxy, configure the client using the `proxy` method: + +```java +import com.langsmith_api.api.client.LangsmithApiClient; +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient; +import java.net.InetSocketAddress; +import java.net.Proxy; + +LangsmithApiClient client = LangsmithApiOkHttpClient.builder() + .fromEnv() + .proxy(new Proxy( + Proxy.Type.HTTP, new InetSocketAddress( + "https://example.com", 8080 + ) + )) + .build(); +``` + +### HTTPS + +> [!NOTE] +> Most applications should not call these methods, and instead use the system defaults. The defaults include +> special optimizations that can be lost if the implementations are modified. + +To configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods: + +```java +import com.langsmith_api.api.client.LangsmithApiClient; +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient; + +LangsmithApiClient client = LangsmithApiOkHttpClient.builder() + .fromEnv() + // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa. + .sslSocketFactory(yourSSLSocketFactory) + .trustManager(yourTrustManager) + .hostnameVerifier(yourHostnameVerifier) + .build(); +``` + +### Custom HTTP client + +The SDK consists of three artifacts: + +- `langsmith-api-java-core` + - Contains core SDK logic + - Does not depend on [OkHttp](https://square.github.io/okhttp) + - Exposes [`LangsmithApiClient`](langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/client/LangsmithApiClient.kt), [`LangsmithApiClientAsync`](langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/client/LangsmithApiClientAsync.kt), [`LangsmithApiClientImpl`](langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/client/LangsmithApiClientImpl.kt), and [`LangsmithApiClientAsyncImpl`](langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/client/LangsmithApiClientAsyncImpl.kt), all of which can work with any HTTP client +- `langsmith-api-java-client-okhttp` + - Depends on [OkHttp](https://square.github.io/okhttp) + - Exposes [`LangsmithApiOkHttpClient`](langsmith-api-java-client-okhttp/src/main/kotlin/com/langsmith_api/api/client/okhttp/LangsmithApiOkHttpClient.kt) and [`LangsmithApiOkHttpClientAsync`](langsmith-api-java-client-okhttp/src/main/kotlin/com/langsmith_api/api/client/okhttp/LangsmithApiOkHttpClientAsync.kt), which provide a way to construct [`LangsmithApiClientImpl`](langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/client/LangsmithApiClientImpl.kt) and [`LangsmithApiClientAsyncImpl`](langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/client/LangsmithApiClientAsyncImpl.kt), respectively, using OkHttp +- `langsmith-api-java` + - Depends on and exposes the APIs of both `langsmith-api-java-core` and `langsmith-api-java-client-okhttp` + - Does not have its own logic + +This structure allows replacing the SDK's default HTTP client without pulling in unnecessary dependencies. + +#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html) + +> [!TIP] +> Try the available [network options](#network-options) before replacing the default client. + +To use a customized `OkHttpClient`: + +1. Replace your [`langsmith-api-java` dependency](#installation) with `langsmith-api-java-core` +2. Copy `langsmith-api-java-client-okhttp`'s [`OkHttpClient`](langsmith-api-java-client-okhttp/src/main/kotlin/com/langsmith_api/api/client/okhttp/OkHttpClient.kt) class into your code and customize it +3. Construct [`LangsmithApiClientImpl`](langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/client/LangsmithApiClientImpl.kt) or [`LangsmithApiClientAsyncImpl`](langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/client/LangsmithApiClientAsyncImpl.kt), similarly to [`LangsmithApiOkHttpClient`](langsmith-api-java-client-okhttp/src/main/kotlin/com/langsmith_api/api/client/okhttp/LangsmithApiOkHttpClient.kt) or [`LangsmithApiOkHttpClientAsync`](langsmith-api-java-client-okhttp/src/main/kotlin/com/langsmith_api/api/client/okhttp/LangsmithApiOkHttpClientAsync.kt), using your customized client + +### Completely custom HTTP client + +To use a completely custom HTTP client: + +1. Replace your [`langsmith-api-java` dependency](#installation) with `langsmith-api-java-core` +2. Write a class that implements the [`HttpClient`](langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/HttpClient.kt) interface +3. Construct [`LangsmithApiClientImpl`](langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/client/LangsmithApiClientImpl.kt) or [`LangsmithApiClientAsyncImpl`](langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/client/LangsmithApiClientAsyncImpl.kt), similarly to [`LangsmithApiOkHttpClient`](langsmith-api-java-client-okhttp/src/main/kotlin/com/langsmith_api/api/client/okhttp/LangsmithApiOkHttpClient.kt) or [`LangsmithApiOkHttpClientAsync`](langsmith-api-java-client-okhttp/src/main/kotlin/com/langsmith_api/api/client/okhttp/LangsmithApiOkHttpClientAsync.kt), using your new client class + +## Undocumented API functionality + +The SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API. + +### Parameters + +To set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class: + +```java +import com.langsmith_api.api.core.JsonValue; +import com.langsmith_api.api.models.api.v1.sessions.SessionDashboardParams; + +SessionDashboardParams params = SessionDashboardParams.builder() + .putAdditionalHeader("Secret-Header", "42") + .putAdditionalQueryParam("secret_query_param", "42") + .putAdditionalBodyProperty("secretProperty", JsonValue.from("42")) + .build(); +``` + +These can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods. + +To set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/Values.kt) object to its setter: + +```java +import com.langsmith_api.api.models.api.v1.sessions.CustomChartsSectionRequest; +import com.langsmith_api.api.models.api.v1.sessions.SessionDashboardParams; + +SessionDashboardParams params = SessionDashboardParams.builder() + .customChartsSectionRequest(CustomChartsSectionRequest.builder().build()) + .build(); +``` + +The most straightforward way to create a [`JsonValue`](langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/Values.kt) is using its `from(...)` method: + +```java +import com.langsmith_api.api.core.JsonValue; +import java.util.List; +import java.util.Map; + +// Create primitive JSON values +JsonValue nullValue = JsonValue.from(null); +JsonValue booleanValue = JsonValue.from(true); +JsonValue numberValue = JsonValue.from(42); +JsonValue stringValue = JsonValue.from("Hello World!"); + +// Create a JSON array value equivalent to `["Hello", "World"]` +JsonValue arrayValue = JsonValue.from(List.of( + "Hello", "World" +)); + +// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }` +JsonValue objectValue = JsonValue.from(Map.of( + "a", 1, + "b", 2 +)); + +// Create an arbitrarily nested JSON equivalent to: +// { +// "a": [1, 2], +// "b": [3, 4] +// } +JsonValue complexValue = JsonValue.from(Map.of( + "a", List.of( + 1, 2 + ), + "b", List.of( + 3, 4 + ) +)); +``` + +Normally a `Builder` class's `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset. + +To forcibly omit a required parameter or property, pass [`JsonMissing`](langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/Values.kt): + +```java +import com.langsmith_api.api.core.JsonMissing; +import com.langsmith_api.api.models.api.v1.sessions.CustomChartsSectionRequest; +import com.langsmith_api.api.models.api.v1.sessions.SessionDashboardParams; + +SessionDashboardParams params = SessionDashboardParams.builder() + .customChartsSectionRequest(CustomChartsSectionRequest.builder().build()) + .sessionId(JsonMissing.of()) + .build(); +``` + +### Response properties + +To access undocumented response properties, call the `_additionalProperties()` method: + +```java +import com.langsmith_api.api.core.JsonValue; +import java.util.Map; + +Map additionalProperties = client.api().v1().sessions().dashboard(params)._additionalProperties(); +JsonValue secretPropertyValue = additionalProperties.get("secretProperty"); + +String result = secretPropertyValue.accept(new JsonValue.Visitor<>() { + @Override + public String visitNull() { + return "It's null!"; + } + + @Override + public String visitBoolean(boolean value) { + return "It's a boolean!"; + } + + @Override + public String visitNumber(Number value) { + return "It's a number!"; + } + + // Other methods include `visitMissing`, `visitString`, `visitArray`, and `visitObject` + // The default implementation of each unimplemented method delegates to `visitDefault`, which throws by default, but can also be overridden +}); +``` + +To access a property's raw JSON value, which may be undocumented, call its `_` prefixed method: + +```java +import com.langsmith_api.api.core.JsonField; +import java.util.Optional; + +JsonField field = client.api().v1().sessions().dashboard(params)._field(); + +if (field.isMissing()) { + // The property is absent from the JSON response +} else if (field.isNull()) { + // The property was set to literal null +} else { + // Check if value was provided as a string + // Other methods include `asNumber()`, `asBoolean()`, etc. + Optional jsonString = field.asString(); + + // Try to deserialize into a custom type + MyClass myObject = field.asUnknown().orElseThrow().convert(MyClass.class); +} +``` + +### Response validation + +In rare cases, the API may return a response that doesn't match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else. + +By default, the SDK will not throw an exception in this case. It will throw [`LangsmithApiInvalidDataException`](langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/LangsmithApiInvalidDataException.kt) only if you directly access the property. + +If you would prefer to check that the response is completely well-typed upfront, then either call `validate()`: + +```java +import com.langsmith_api.api.models.api.v1.sessions.CustomChartsSection; + +CustomChartsSection customChartsSection = client.api().v1().sessions().dashboard(params).validate(); +``` + +Or configure the method call to validate the response using the `responseValidation` method: + +```java +import com.langsmith_api.api.models.api.v1.sessions.CustomChartsSection; + +CustomChartsSection customChartsSection = client.api().v1().sessions().dashboard( + params, RequestOptions.builder().responseValidation(true).build() +); +``` + +Or configure the default for all method calls at the client level: + +```java +import com.langsmith_api.api.client.LangsmithApiClient; +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient; + +LangsmithApiClient client = LangsmithApiOkHttpClient.builder() + .fromEnv() + .responseValidation(true) + .build(); +``` + +## FAQ + +### Why don't you use plain `enum` classes? + +Java `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value. + +### Why do you represent fields using `JsonField` instead of just plain `T`? + +Using `JsonField` enables a few features: + +- Allowing usage of [undocumented API functionality](#undocumented-api-functionality) +- Lazily [validating the API response against the expected shape](#response-validation) +- Representing absent vs explicitly null values + +### Why don't you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)? + +It is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don't want to introduce a breaking change every time we add a field to a class. + +### Why don't you use checked exceptions? + +Checked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason. + +Checked exceptions: + +- Are verbose to handle +- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error +- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function) +- Don't play well with lambdas (also due to the function coloring problem) + +## Semantic versioning + +This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions: + +1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_ +2. Changes that we do not expect to impact the vast majority of users in practice. + +We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience. + +We are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/langsmith-api-java/issues) with questions, bugs, or suggestions. diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..63f114eb --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,23 @@ +# Security Policy + +## Reporting Security Issues + +This SDK is generated by [Stainless Software Inc](http://stainless.com). Stainless takes security seriously, and encourages you to report any security vulnerability promptly so that appropriate action can be taken. + +To report a security issue, please contact the Stainless team at security@stainless.com. + +## Responsible Disclosure + +We appreciate the efforts of security researchers and individuals who help us maintain the security of +SDKs we generate. If you believe you have found a security vulnerability, please adhere to responsible +disclosure practices by allowing us a reasonable amount of time to investigate and address the issue +before making any information public. + +## Reporting Non-SDK Related Security Issues + +If you encounter security issues that are not directly related to SDKs but pertain to the services +or products provided by Langsmith API, please follow the respective company's security reporting guidelines. + +--- + +Thank you for helping us keep the SDKs and systems they interact with secure. diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 00000000..1673190d --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,49 @@ +plugins { + id("io.github.gradle-nexus.publish-plugin") version "1.1.0" + id("org.jetbrains.dokka") version "2.0.0" +} + +repositories { + mavenCentral() +} + +allprojects { + group = "com.langsmith_api.api" + version = "0.0.1" +} + +subprojects { + // These are populated with dependencies by `buildSrc` scripts. + tasks.register("format") { + group = "Verification" + description = "Formats all source files." + } + tasks.register("lint") { + group = "Verification" + description = "Verifies all source files are formatted." + } + apply(plugin = "org.jetbrains.dokka") +} + +subprojects { + apply(plugin = "org.jetbrains.dokka") +} + +// Avoid race conditions between `dokkaJavadocCollector` and `dokkaJavadocJar` tasks +tasks.named("dokkaJavadocCollector").configure { + subprojects.flatMap { it.tasks } + .filter { it.project.name != "langsmith-api-java" && it.name == "dokkaJavadocJar" } + .forEach { mustRunAfter(it) } +} + +nexusPublishing { + repositories { + sonatype { + nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) + snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) + + username.set(System.getenv("SONATYPE_USERNAME")) + password.set(System.getenv("SONATYPE_PASSWORD")) + } + } +} diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 00000000..0b141353 --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,12 @@ +plugins { + `kotlin-dsl` + kotlin("jvm") version "1.9.20" +} + +repositories { + gradlePluginPortal() +} + +dependencies { + implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20") +} diff --git a/buildSrc/src/main/kotlin/langsmith-api.java.gradle.kts b/buildSrc/src/main/kotlin/langsmith-api.java.gradle.kts new file mode 100644 index 00000000..81d5d32b --- /dev/null +++ b/buildSrc/src/main/kotlin/langsmith-api.java.gradle.kts @@ -0,0 +1,136 @@ +import org.gradle.api.tasks.testing.logging.TestExceptionFormat + +plugins { + `java-library` +} + +repositories { + mavenCentral() +} + +configure { + withJavadocJar() + withSourcesJar() +} + +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(21)) + } + + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} + +tasks.withType().configureEach { + options.compilerArgs.add("-Werror") + options.release.set(8) +} + +tasks.named("javadocJar") { + setZip64(true) +} + +tasks.named("jar") { + manifest { + attributes(mapOf( + "Implementation-Title" to project.name, + "Implementation-Version" to project.version + )) + } +} + +tasks.withType().configureEach { + useJUnitPlatform() + + // Run tests in parallel to some degree. + maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1) + forkEvery = 100 + + testLogging { + exceptionFormat = TestExceptionFormat.FULL + } +} + +val palantir by configurations.creating +dependencies { + palantir("com.palantir.javaformat:palantir-java-format:2.73.0") +} + +fun registerPalantir( + name: String, + description: String, +) { + val javaName = "${name}Java" + tasks.register(javaName) { + group = "Verification" + this.description = description + + classpath = palantir + mainClass = "com.palantir.javaformat.java.Main" + + // Avoid an `IllegalAccessError` on Java 9+. + jvmArgs( + "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", + ) + + // Use paths relative to the current module. + val argumentFile = + project.layout.buildDirectory.file("palantir-$name-args.txt").get().asFile + val lastRunTimeFile = + project.layout.buildDirectory.file("palantir-$name-last-run.txt").get().asFile + + // Read the time when this task was last executed for this module (if ever). + val lastRunTime = lastRunTimeFile.takeIf { it.exists() }?.readText()?.toLongOrNull() ?: 0L + + // Use a `fileTree` relative to the module's source directory. + val javaFiles = project.fileTree("src") { include("**/*.java") } + + // Determine if any files need to be formatted or linted and continue only if there is at least + // one file. + onlyIf { javaFiles.any { it.lastModified() > lastRunTime } } + + inputs.files(javaFiles) + + doFirst { + // Create the argument file and set the preferred formatting style. + argumentFile.parentFile.mkdirs() + argumentFile.writeText("--palantir\n") + + if (name == "lint") { + // For lint, do a dry run, so no files are modified. Set the exit code to 1 (instead of + // the default 0) if any files need to be formatted, indicating that linting has failed. + argumentFile.appendText("--dry-run\n") + argumentFile.appendText("--set-exit-if-changed\n") + } else { + // `--dry-run` and `--replace` (for in-place formatting) are mutually exclusive. + argumentFile.appendText("--replace\n") + } + + // Write the modified files to the argument file. + javaFiles.filter { it.lastModified() > lastRunTime } + .forEach { argumentFile.appendText("${it.absolutePath}\n") } + } + + doLast { + // Record the last execution time for later up-to-date checking. + lastRunTimeFile.writeText(System.currentTimeMillis().toString()) + } + + // Pass the argument file using the @ symbol + args = listOf("@${argumentFile.absolutePath}") + + outputs.upToDateWhen { javaFiles.none { it.lastModified() > lastRunTime } } + } + + tasks.named(name) { + dependsOn(tasks.named(javaName)) + } +} + +registerPalantir(name = "format", description = "Formats all Java source files.") +registerPalantir(name = "lint", description = "Verifies all Java source files are formatted.") diff --git a/buildSrc/src/main/kotlin/langsmith-api.kotlin.gradle.kts b/buildSrc/src/main/kotlin/langsmith-api.kotlin.gradle.kts new file mode 100644 index 00000000..f123b67e --- /dev/null +++ b/buildSrc/src/main/kotlin/langsmith-api.kotlin.gradle.kts @@ -0,0 +1,106 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.dsl.KotlinVersion + +plugins { + id("langsmith-api.java") + kotlin("jvm") +} + +repositories { + mavenCentral() +} + +kotlin { + jvmToolchain { + languageVersion.set(JavaLanguageVersion.of(21)) + } + + compilerOptions { + freeCompilerArgs = listOf( + "-Xjvm-default=all", + "-Xjdk-release=1.8", + // Suppress deprecation warnings because we may still reference and test deprecated members. + // TODO: Replace with `-Xsuppress-warning=DEPRECATION` once we use Kotlin compiler 2.1.0+. + "-nowarn", + ) + jvmTarget.set(JvmTarget.JVM_1_8) + languageVersion.set(KotlinVersion.KOTLIN_1_8) + apiVersion.set(KotlinVersion.KOTLIN_1_8) + coreLibrariesVersion = "1.8.0" + } +} + +tasks.withType().configureEach { + systemProperty("junit.jupiter.execution.parallel.enabled", true) + systemProperty("junit.jupiter.execution.parallel.mode.default", "concurrent") +} + +val ktfmt by configurations.creating +dependencies { + ktfmt("com.facebook:ktfmt:0.56") +} + +fun registerKtfmt( + name: String, + description: String, +) { + val kotlinName = "${name}Kotlin" + tasks.register(kotlinName) { + group = "Verification" + this.description = description + + classpath = ktfmt + mainClass = "com.facebook.ktfmt.cli.Main" + + // Use paths relative to the current module. + val argumentFile = project.layout.buildDirectory.file("ktfmt-$name-args.txt").get().asFile + val lastRunTimeFile = + project.layout.buildDirectory.file("ktfmt-$name-last-run.txt").get().asFile + + // Read the time when this task was last executed for this module (if ever). + val lastRunTime = lastRunTimeFile.takeIf { it.exists() }?.readText()?.toLongOrNull() ?: 0L + + // Use a `fileTree` relative to the module's source directory. + val kotlinFiles = project.fileTree("src") { include("**/*.kt") } + + // Determine if any files need to be formatted or linted and continue only if there is at least + // one file (otherwise Ktfmt will fail). + onlyIf { kotlinFiles.any { it.lastModified() > lastRunTime } } + + inputs.files(kotlinFiles) + + doFirst { + // Create the argument file and set the preferred formatting style. + argumentFile.parentFile.mkdirs() + argumentFile.writeText("--kotlinlang-style\n") + + if (name == "lint") { + // For lint, do a dry run, so no files are modified. Set the exit code to 1 (instead of + // the default 0) if any files need to be formatted, indicating that linting has failed. + argumentFile.appendText("--dry-run\n") + argumentFile.appendText("--set-exit-if-changed\n") + } + + // Write the modified files to the argument file. + kotlinFiles.filter { it.lastModified() > lastRunTime } + .forEach { argumentFile.appendText("${it.absolutePath}\n") } + } + + doLast { + // Record the last execution time for later up-to-date checking. + lastRunTimeFile.writeText(System.currentTimeMillis().toString()) + } + + // Pass the argument file using the @ symbol + args = listOf("@${argumentFile.absolutePath}") + + outputs.upToDateWhen { kotlinFiles.none { it.lastModified() > lastRunTime } } + } + + tasks.named(name) { + dependsOn(tasks.named(kotlinName)) + } +} + +registerKtfmt(name = "format", description = "Formats all Kotlin source files.") +registerKtfmt(name = "lint", description = "Verifies all Kotlin source files are formatted.") diff --git a/buildSrc/src/main/kotlin/langsmith-api.publish.gradle.kts b/buildSrc/src/main/kotlin/langsmith-api.publish.gradle.kts new file mode 100644 index 00000000..b88fa7b3 --- /dev/null +++ b/buildSrc/src/main/kotlin/langsmith-api.publish.gradle.kts @@ -0,0 +1,60 @@ +plugins { + `maven-publish` + signing +} + +configure { + publications { + register("maven") { + from(components["java"]) + + pom { + name.set("LangSmith") + description.set("The LangSmith API is used to programmatically create and manage LangSmith\nresources.\n\n## Host\n\nhttps://api.smith.langchain.com\n\n## Authentication\n\nTo authenticate with the LangSmith API, set the `X-Api-Key` header to a valid\n[LangSmith API key](https://docs.langchain.com/langsmith/create-account-api-key#create-an-api-key).") + url.set("https://www.github.com/stainless-sdks/langsmith-api-java") + + licenses { + license { + name.set("Apache-2.0") + } + } + + developers { + developer { + name.set("Langsmith API") + } + } + + scm { + connection.set("scm:git:git://github.com/stainless-sdks/langsmith-api-java.git") + developerConnection.set("scm:git:git://github.com/stainless-sdks/langsmith-api-java.git") + url.set("https://github.com/stainless-sdks/langsmith-api-java") + } + + versionMapping { + allVariants { + fromResolutionResult() + } + } + } + } + } +} + +signing { + val signingKeyId = System.getenv("GPG_SIGNING_KEY_ID")?.ifBlank { null } + val signingKey = System.getenv("GPG_SIGNING_KEY")?.ifBlank { null } + val signingPassword = System.getenv("GPG_SIGNING_PASSWORD")?.ifBlank { null } + if (signingKey != null && signingPassword != null) { + useInMemoryPgpKeys( + signingKeyId, + signingKey, + signingPassword, + ) + sign(publishing.publications["maven"]) + } +} + +tasks.named("publish") { + dependsOn(":closeAndReleaseSonatypeStagingRepository") +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 00000000..6680f9ce --- /dev/null +++ b/gradle.properties @@ -0,0 +1,18 @@ +org.gradle.caching=true +org.gradle.configuration-cache=true +org.gradle.parallel=true +org.gradle.daemon=false +# These options improve our compilation and test performance. They are inherited by the Kotlin daemon. +org.gradle.jvmargs=\ + -Xms2g \ + -Xmx8g \ + -XX:+UseParallelGC \ + -XX:InitialCodeCacheSize=256m \ + -XX:ReservedCodeCacheSize=1G \ + -XX:MetaspaceSize=512m \ + -XX:MaxMetaspaceSize=2G \ + -XX:TieredStopAtLevel=1 \ + -XX:GCTimeRatio=4 \ + -XX:CICompilerCount=4 \ + -XX:+OptimizeStringConcat \ + -XX:+UseStringDeduplication diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..a4b76b9530d66f5e68d973ea569d8e19de379189 GIT binary patch literal 43583 zcma&N1CXTcmMvW9vTb(Rwr$&4wr$(C?dmSu>@vG-+vuvg^_??!{yS%8zW-#zn-LkA z5&1^$^{lnmUON?}LBF8_K|(?T0Ra(xUH{($5eN!MR#ZihR#HxkUPe+_R8Cn`RRs(P z_^*#_XlXmGv7!4;*Y%p4nw?{bNp@UZHv1?Um8r6)Fei3p@ClJn0ECfg1hkeuUU@Or zDaPa;U3fE=3L}DooL;8f;P0ipPt0Z~9P0)lbStMS)ag54=uL9ia-Lm3nh|@(Y?B`; zx_#arJIpXH!U{fbCbI^17}6Ri*H<>OLR%c|^mh8+)*h~K8Z!9)DPf zR2h?lbDZQ`p9P;&DQ4F0sur@TMa!Y}S8irn(%d-gi0*WxxCSk*A?3lGh=gcYN?FGl z7D=Js!i~0=u3rox^eO3i@$0=n{K1lPNU zwmfjRVmLOCRfe=seV&P*1Iq=^i`502keY8Uy-WNPwVNNtJFx?IwAyRPZo2Wo1+S(xF37LJZ~%i)kpFQ3Fw=mXfd@>%+)RpYQLnr}B~~zoof(JVm^^&f zxKV^+3D3$A1G;qh4gPVjhrC8e(VYUHv#dy^)(RoUFM?o%W-EHxufuWf(l*@-l+7vt z=l`qmR56K~F|v<^Pd*p~1_y^P0P^aPC##d8+HqX4IR1gu+7w#~TBFphJxF)T$2WEa zxa?H&6=Qe7d(#tha?_1uQys2KtHQ{)Qco)qwGjrdNL7thd^G5i8Os)CHqc>iOidS} z%nFEDdm=GXBw=yXe1W-ShHHFb?Cc70+$W~z_+}nAoHFYI1MV1wZegw*0y^tC*s%3h zhD3tN8b=Gv&rj}!SUM6|ajSPp*58KR7MPpI{oAJCtY~JECm)*m_x>AZEu>DFgUcby z1Qaw8lU4jZpQ_$;*7RME+gq1KySGG#Wql>aL~k9tLrSO()LWn*q&YxHEuzmwd1?aAtI zBJ>P=&$=l1efe1CDU;`Fd+_;&wI07?V0aAIgc(!{a z0Jg6Y=inXc3^n!U0Atk`iCFIQooHqcWhO(qrieUOW8X(x?(RD}iYDLMjSwffH2~tB z)oDgNBLB^AJBM1M^c5HdRx6fBfka`(LD-qrlh5jqH~);#nw|iyp)()xVYak3;Ybik z0j`(+69aK*B>)e_p%=wu8XC&9e{AO4c~O1U`5X9}?0mrd*m$_EUek{R?DNSh(=br# z#Q61gBzEpmy`$pA*6!87 zSDD+=@fTY7<4A?GLqpA?Pb2z$pbCc4B4zL{BeZ?F-8`s$?>*lXXtn*NC61>|*w7J* z$?!iB{6R-0=KFmyp1nnEmLsA-H0a6l+1uaH^g%c(p{iT&YFrbQ$&PRb8Up#X3@Zsk zD^^&LK~111%cqlP%!_gFNa^dTYT?rhkGl}5=fL{a`UViaXWI$k-UcHJwmaH1s=S$4 z%4)PdWJX;hh5UoK?6aWoyLxX&NhNRqKam7tcOkLh{%j3K^4Mgx1@i|Pi&}<^5>hs5 zm8?uOS>%)NzT(%PjVPGa?X%`N2TQCKbeH2l;cTnHiHppPSJ<7y-yEIiC!P*ikl&!B z%+?>VttCOQM@ShFguHVjxX^?mHX^hSaO_;pnyh^v9EumqSZTi+#f&_Vaija0Q-e*| z7ulQj6Fs*bbmsWp{`auM04gGwsYYdNNZcg|ph0OgD>7O}Asn7^Z=eI>`$2*v78;sj-}oMoEj&@)9+ycEOo92xSyY344^ z11Hb8^kdOvbf^GNAK++bYioknrpdN>+u8R?JxG=!2Kd9r=YWCOJYXYuM0cOq^FhEd zBg2puKy__7VT3-r*dG4c62Wgxi52EMCQ`bKgf*#*ou(D4-ZN$+mg&7$u!! z-^+Z%;-3IDwqZ|K=ah85OLwkO zKxNBh+4QHh)u9D?MFtpbl)us}9+V!D%w9jfAMYEb>%$A;u)rrI zuBudh;5PN}_6J_}l55P3l_)&RMlH{m!)ai-i$g)&*M`eN$XQMw{v^r@-125^RRCF0 z^2>|DxhQw(mtNEI2Kj(;KblC7x=JlK$@78`O~>V!`|1Lm-^JR$-5pUANAnb(5}B}JGjBsliK4& zk6y(;$e&h)lh2)L=bvZKbvh@>vLlreBdH8No2>$#%_Wp1U0N7Ank!6$dFSi#xzh|( zRi{Uw%-4W!{IXZ)fWx@XX6;&(m_F%c6~X8hx=BN1&q}*( zoaNjWabE{oUPb!Bt$eyd#$5j9rItB-h*5JiNi(v^e|XKAj*8(k<5-2$&ZBR5fF|JA z9&m4fbzNQnAU}r8ab>fFV%J0z5awe#UZ|bz?Ur)U9bCIKWEzi2%A+5CLqh?}K4JHi z4vtM;+uPsVz{Lfr;78W78gC;z*yTch~4YkLr&m-7%-xc ztw6Mh2d>_iO*$Rd8(-Cr1_V8EO1f*^@wRoSozS) zy1UoC@pruAaC8Z_7~_w4Q6n*&B0AjOmMWa;sIav&gu z|J5&|{=a@vR!~k-OjKEgPFCzcJ>#A1uL&7xTDn;{XBdeM}V=l3B8fE1--DHjSaxoSjNKEM9|U9#m2<3>n{Iuo`r3UZp;>GkT2YBNAh|b z^jTq-hJp(ebZh#Lk8hVBP%qXwv-@vbvoREX$TqRGTgEi$%_F9tZES@z8Bx}$#5eeG zk^UsLBH{bc2VBW)*EdS({yw=?qmevwi?BL6*=12k9zM5gJv1>y#ML4!)iiPzVaH9% zgSImetD@dam~e>{LvVh!phhzpW+iFvWpGT#CVE5TQ40n%F|p(sP5mXxna+Ev7PDwA zamaV4m*^~*xV+&p;W749xhb_X=$|LD;FHuB&JL5?*Y2-oIT(wYY2;73<^#46S~Gx| z^cez%V7x$81}UWqS13Gz80379Rj;6~WdiXWOSsdmzY39L;Hg3MH43o*y8ibNBBH`(av4|u;YPq%{R;IuYow<+GEsf@R?=@tT@!}?#>zIIn0CoyV!hq3mw zHj>OOjfJM3F{RG#6ujzo?y32m^tgSXf@v=J$ELdJ+=5j|=F-~hP$G&}tDZsZE?5rX ztGj`!S>)CFmdkccxM9eGIcGnS2AfK#gXwj%esuIBNJQP1WV~b~+D7PJTmWGTSDrR` zEAu4B8l>NPuhsk5a`rReSya2nfV1EK01+G!x8aBdTs3Io$u5!6n6KX%uv@DxAp3F@{4UYg4SWJtQ-W~0MDb|j-$lwVn znAm*Pl!?Ps&3wO=R115RWKb*JKoexo*)uhhHBncEDMSVa_PyA>k{Zm2(wMQ(5NM3# z)jkza|GoWEQo4^s*wE(gHz?Xsg4`}HUAcs42cM1-qq_=+=!Gk^y710j=66(cSWqUe zklbm8+zB_syQv5A2rj!Vbw8;|$@C!vfNmNV!yJIWDQ>{+2x zKjuFX`~~HKG~^6h5FntRpnnHt=D&rq0>IJ9#F0eM)Y-)GpRjiN7gkA8wvnG#K=q{q z9dBn8_~wm4J<3J_vl|9H{7q6u2A!cW{bp#r*-f{gOV^e=8S{nc1DxMHFwuM$;aVI^ zz6A*}m8N-&x8;aunp1w7_vtB*pa+OYBw=TMc6QK=mbA-|Cf* zvyh8D4LRJImooUaSb7t*fVfih<97Gf@VE0|z>NcBwBQze);Rh!k3K_sfunToZY;f2 z^HmC4KjHRVg+eKYj;PRN^|E0>Gj_zagfRbrki68I^#~6-HaHg3BUW%+clM1xQEdPYt_g<2K+z!$>*$9nQ>; zf9Bei{?zY^-e{q_*|W#2rJG`2fy@{%6u0i_VEWTq$*(ZN37|8lFFFt)nCG({r!q#9 z5VK_kkSJ3?zOH)OezMT{!YkCuSSn!K#-Rhl$uUM(bq*jY? zi1xbMVthJ`E>d>(f3)~fozjg^@eheMF6<)I`oeJYx4*+M&%c9VArn(OM-wp%M<-`x z7sLP1&3^%Nld9Dhm@$3f2}87!quhI@nwd@3~fZl_3LYW-B?Ia>ui`ELg z&Qfe!7m6ze=mZ`Ia9$z|ARSw|IdMpooY4YiPN8K z4B(ts3p%2i(Td=tgEHX z0UQ_>URBtG+-?0E;E7Ld^dyZ;jjw0}XZ(}-QzC6+NN=40oDb2^v!L1g9xRvE#@IBR zO!b-2N7wVfLV;mhEaXQ9XAU+>=XVA6f&T4Z-@AX!leJ8obP^P^wP0aICND?~w&NykJ#54x3_@r7IDMdRNy4Hh;h*!u(Ol(#0bJdwEo$5437-UBjQ+j=Ic>Q2z` zJNDf0yO6@mr6y1#n3)s(W|$iE_i8r@Gd@!DWDqZ7J&~gAm1#~maIGJ1sls^gxL9LLG_NhU!pTGty!TbhzQnu)I*S^54U6Yu%ZeCg`R>Q zhBv$n5j0v%O_j{QYWG!R9W?5_b&67KB$t}&e2LdMvd(PxN6Ir!H4>PNlerpBL>Zvyy!yw z-SOo8caEpDt(}|gKPBd$qND5#a5nju^O>V&;f890?yEOfkSG^HQVmEbM3Ugzu+UtH zC(INPDdraBN?P%kE;*Ae%Wto&sgw(crfZ#Qy(<4nk;S|hD3j{IQRI6Yq|f^basLY; z-HB&Je%Gg}Jt@={_C{L$!RM;$$|iD6vu#3w?v?*;&()uB|I-XqEKqZPS!reW9JkLewLb!70T7n`i!gNtb1%vN- zySZj{8-1>6E%H&=V}LM#xmt`J3XQoaD|@XygXjdZ1+P77-=;=eYpoEQ01B@L*a(uW zrZeZz?HJsw_4g0vhUgkg@VF8<-X$B8pOqCuWAl28uB|@r`19DTUQQsb^pfqB6QtiT z*`_UZ`fT}vtUY#%sq2{rchyfu*pCg;uec2$-$N_xgjZcoumE5vSI{+s@iLWoz^Mf; zuI8kDP{!XY6OP~q5}%1&L}CtfH^N<3o4L@J@zg1-mt{9L`s^z$Vgb|mr{@WiwAqKg zp#t-lhrU>F8o0s1q_9y`gQNf~Vb!F%70f}$>i7o4ho$`uciNf=xgJ>&!gSt0g;M>*x4-`U)ysFW&Vs^Vk6m%?iuWU+o&m(2Jm26Y(3%TL; zA7T)BP{WS!&xmxNw%J=$MPfn(9*^*TV;$JwRy8Zl*yUZi8jWYF>==j~&S|Xinsb%c z2?B+kpet*muEW7@AzjBA^wAJBY8i|#C{WtO_or&Nj2{=6JTTX05}|H>N2B|Wf!*3_ z7hW*j6p3TvpghEc6-wufFiY!%-GvOx*bZrhZu+7?iSrZL5q9}igiF^*R3%DE4aCHZ zqu>xS8LkW+Auv%z-<1Xs92u23R$nk@Pk}MU5!gT|c7vGlEA%G^2th&Q*zfg%-D^=f z&J_}jskj|Q;73NP4<4k*Y%pXPU2Thoqr+5uH1yEYM|VtBPW6lXaetokD0u z9qVek6Q&wk)tFbQ8(^HGf3Wp16gKmr>G;#G(HRBx?F`9AIRboK+;OfHaLJ(P>IP0w zyTbTkx_THEOs%Q&aPrxbZrJlio+hCC_HK<4%f3ZoSAyG7Dn`=X=&h@m*|UYO-4Hq0 z-Bq&+Ie!S##4A6OGoC~>ZW`Y5J)*ouaFl_e9GA*VSL!O_@xGiBw!AF}1{tB)z(w%c zS1Hmrb9OC8>0a_$BzeiN?rkPLc9%&;1CZW*4}CDDNr2gcl_3z+WC15&H1Zc2{o~i) z)LLW=WQ{?ricmC`G1GfJ0Yp4Dy~Ba;j6ZV4r{8xRs`13{dD!xXmr^Aga|C=iSmor% z8hi|pTXH)5Yf&v~exp3o+sY4B^^b*eYkkCYl*T{*=-0HniSA_1F53eCb{x~1k3*`W zr~};p1A`k{1DV9=UPnLDgz{aJH=-LQo<5%+Em!DNN252xwIf*wF_zS^!(XSm(9eoj z=*dXG&n0>)_)N5oc6v!>-bd(2ragD8O=M|wGW z!xJQS<)u70m&6OmrF0WSsr@I%T*c#Qo#Ha4d3COcX+9}hM5!7JIGF>7<~C(Ear^Sn zm^ZFkV6~Ula6+8S?oOROOA6$C&q&dp`>oR-2Ym3(HT@O7Sd5c~+kjrmM)YmgPH*tL zX+znN>`tv;5eOfX?h{AuX^LK~V#gPCu=)Tigtq9&?7Xh$qN|%A$?V*v=&-2F$zTUv z`C#WyIrChS5|Kgm_GeudCFf;)!WH7FI60j^0o#65o6`w*S7R@)88n$1nrgU(oU0M9 zx+EuMkC>(4j1;m6NoGqEkpJYJ?vc|B zOlwT3t&UgL!pX_P*6g36`ZXQ; z9~Cv}ANFnJGp(;ZhS(@FT;3e)0)Kp;h^x;$*xZn*k0U6-&FwI=uOGaODdrsp-!K$Ac32^c{+FhI-HkYd5v=`PGsg%6I`4d9Jy)uW0y%) zm&j^9WBAp*P8#kGJUhB!L?a%h$hJgQrx!6KCB_TRo%9{t0J7KW8!o1B!NC)VGLM5! zpZy5Jc{`r{1e(jd%jsG7k%I+m#CGS*BPA65ZVW~fLYw0dA-H_}O zrkGFL&P1PG9p2(%QiEWm6x;U-U&I#;Em$nx-_I^wtgw3xUPVVu zqSuKnx&dIT-XT+T10p;yjo1Y)z(x1fb8Dzfn8e yu?e%!_ptzGB|8GrCfu%p?(_ zQccdaaVK$5bz;*rnyK{_SQYM>;aES6Qs^lj9lEs6_J+%nIiuQC*fN;z8md>r_~Mfl zU%p5Dt_YT>gQqfr@`cR!$NWr~+`CZb%dn;WtzrAOI>P_JtsB76PYe*<%H(y>qx-`Kq!X_; z<{RpAqYhE=L1r*M)gNF3B8r(<%8mo*SR2hu zccLRZwGARt)Hlo1euqTyM>^!HK*!Q2P;4UYrysje@;(<|$&%vQekbn|0Ruu_Io(w4#%p6ld2Yp7tlA`Y$cciThP zKzNGIMPXX%&Ud0uQh!uQZz|FB`4KGD?3!ND?wQt6!n*f4EmCoJUh&b?;B{|lxs#F- z31~HQ`SF4x$&v00@(P+j1pAaj5!s`)b2RDBp*PB=2IB>oBF!*6vwr7Dp%zpAx*dPr zb@Zjq^XjN?O4QcZ*O+8>)|HlrR>oD*?WQl5ri3R#2?*W6iJ>>kH%KnnME&TT@ZzrHS$Q%LC?n|e>V+D+8D zYc4)QddFz7I8#}y#Wj6>4P%34dZH~OUDb?uP%-E zwjXM(?Sg~1!|wI(RVuxbu)-rH+O=igSho_pDCw(c6b=P zKk4ATlB?bj9+HHlh<_!&z0rx13K3ZrAR8W)!@Y}o`?a*JJsD+twZIv`W)@Y?Amu_u zz``@-e2X}27$i(2=9rvIu5uTUOVhzwu%mNazS|lZb&PT;XE2|B&W1>=B58#*!~D&) zfVmJGg8UdP*fx(>Cj^?yS^zH#o-$Q-*$SnK(ZVFkw+er=>N^7!)FtP3y~Xxnu^nzY zikgB>Nj0%;WOltWIob|}%lo?_C7<``a5hEkx&1ku$|)i>Rh6@3h*`slY=9U}(Ql_< zaNG*J8vb&@zpdhAvv`?{=zDedJ23TD&Zg__snRAH4eh~^oawdYi6A3w8<Ozh@Kw)#bdktM^GVb zrG08?0bG?|NG+w^&JvD*7LAbjED{_Zkc`3H!My>0u5Q}m!+6VokMLXxl`Mkd=g&Xx z-a>m*#G3SLlhbKB!)tnzfWOBV;u;ftU}S!NdD5+YtOjLg?X}dl>7m^gOpihrf1;PY zvll&>dIuUGs{Qnd- zwIR3oIrct8Va^Tm0t#(bJD7c$Z7DO9*7NnRZorrSm`b`cxz>OIC;jSE3DO8`hX955ui`s%||YQtt2 z5DNA&pG-V+4oI2s*x^>-$6J?p=I>C|9wZF8z;VjR??Icg?1w2v5Me+FgAeGGa8(3S z4vg*$>zC-WIVZtJ7}o9{D-7d>zCe|z#<9>CFve-OPAYsneTb^JH!Enaza#j}^mXy1 z+ULn^10+rWLF6j2>Ya@@Kq?26>AqK{A_| zQKb*~F1>sE*=d?A?W7N2j?L09_7n+HGi{VY;MoTGr_)G9)ot$p!-UY5zZ2Xtbm=t z@dpPSGwgH=QtIcEulQNI>S-#ifbnO5EWkI;$A|pxJd885oM+ zGZ0_0gDvG8q2xebj+fbCHYfAXuZStH2j~|d^sBAzo46(K8n59+T6rzBwK)^rfPT+B zyIFw)9YC-V^rhtK`!3jrhmW-sTmM+tPH+;nwjL#-SjQPUZ53L@A>y*rt(#M(qsiB2 zx6B)dI}6Wlsw%bJ8h|(lhkJVogQZA&n{?Vgs6gNSXzuZpEyu*xySy8ro07QZ7Vk1!3tJphN_5V7qOiyK8p z#@jcDD8nmtYi1^l8ml;AF<#IPK?!pqf9D4moYk>d99Im}Jtwj6c#+A;f)CQ*f-hZ< z=p_T86jog%!p)D&5g9taSwYi&eP z#JuEK%+NULWus;0w32-SYFku#i}d~+{Pkho&^{;RxzP&0!RCm3-9K6`>KZpnzS6?L z^H^V*s!8<>x8bomvD%rh>Zp3>Db%kyin;qtl+jAv8Oo~1g~mqGAC&Qi_wy|xEt2iz zWAJEfTV%cl2Cs<1L&DLRVVH05EDq`pH7Oh7sR`NNkL%wi}8n>IXcO40hp+J+sC!W?!krJf!GJNE8uj zg-y~Ns-<~D?yqbzVRB}G>0A^f0!^N7l=$m0OdZuqAOQqLc zX?AEGr1Ht+inZ-Qiwnl@Z0qukd__a!C*CKuGdy5#nD7VUBM^6OCpxCa2A(X;e0&V4 zM&WR8+wErQ7UIc6LY~Q9x%Sn*Tn>>P`^t&idaOEnOd(Ufw#>NoR^1QdhJ8s`h^|R_ zXX`c5*O~Xdvh%q;7L!_!ohf$NfEBmCde|#uVZvEo>OfEq%+Ns7&_f$OR9xsihRpBb z+cjk8LyDm@U{YN>+r46?nn{7Gh(;WhFw6GAxtcKD+YWV?uge>;+q#Xx4!GpRkVZYu zzsF}1)7$?%s9g9CH=Zs+B%M_)+~*j3L0&Q9u7!|+T`^O{xE6qvAP?XWv9_MrZKdo& z%IyU)$Q95AB4!#hT!_dA>4e@zjOBD*Y=XjtMm)V|+IXzjuM;(l+8aA5#Kaz_$rR6! zj>#&^DidYD$nUY(D$mH`9eb|dtV0b{S>H6FBfq>t5`;OxA4Nn{J(+XihF(stSche7$es&~N$epi&PDM_N`As;*9D^L==2Q7Z2zD+CiU(|+-kL*VG+&9!Yb3LgPy?A zm7Z&^qRG_JIxK7-FBzZI3Q<;{`DIxtc48k> zc|0dmX;Z=W$+)qE)~`yn6MdoJ4co;%!`ddy+FV538Y)j(vg}5*k(WK)KWZ3WaOG!8 z!syGn=s{H$odtpqFrT#JGM*utN7B((abXnpDM6w56nhw}OY}0TiTG1#f*VFZr+^-g zbP10`$LPq_;PvrA1XXlyx2uM^mrjTzX}w{yuLo-cOClE8MMk47T25G8M!9Z5ypOSV zAJUBGEg5L2fY)ZGJb^E34R2zJ?}Vf>{~gB!8=5Z) z9y$>5c)=;o0HeHHSuE4U)#vG&KF|I%-cF6f$~pdYJWk_dD}iOA>iA$O$+4%@>JU08 zS`ep)$XLPJ+n0_i@PkF#ri6T8?ZeAot$6JIYHm&P6EB=BiaNY|aA$W0I+nz*zkz_z zkEru!tj!QUffq%)8y0y`T&`fuus-1p>=^hnBiBqD^hXrPs`PY9tU3m0np~rISY09> z`P3s=-kt_cYcxWd{de@}TwSqg*xVhp;E9zCsnXo6z z?f&Sv^U7n4`xr=mXle94HzOdN!2kB~4=%)u&N!+2;z6UYKUDqi-s6AZ!haB;@&B`? z_TRX0%@suz^TRdCb?!vNJYPY8L_}&07uySH9%W^Tc&1pia6y1q#?*Drf}GjGbPjBS zbOPcUY#*$3sL2x4v_i*Y=N7E$mR}J%|GUI(>WEr+28+V z%v5{#e!UF*6~G&%;l*q*$V?&r$Pp^sE^i-0$+RH3ERUUdQ0>rAq2(2QAbG}$y{de( z>{qD~GGuOk559Y@%$?N^1ApVL_a704>8OD%8Y%8B;FCt%AoPu8*D1 zLB5X>b}Syz81pn;xnB}%0FnwazlWfUV)Z-~rZg6~b z6!9J$EcE&sEbzcy?CI~=boWA&eeIa%z(7SE^qgVLz??1Vbc1*aRvc%Mri)AJaAG!p z$X!_9Ds;Zz)f+;%s&dRcJt2==P{^j3bf0M=nJd&xwUGlUFn?H=2W(*2I2Gdu zv!gYCwM10aeus)`RIZSrCK=&oKaO_Ry~D1B5!y0R=%!i2*KfXGYX&gNv_u+n9wiR5 z*e$Zjju&ODRW3phN925%S(jL+bCHv6rZtc?!*`1TyYXT6%Ju=|X;6D@lq$8T zW{Y|e39ioPez(pBH%k)HzFITXHvnD6hw^lIoUMA;qAJ^CU?top1fo@s7xT13Fvn1H z6JWa-6+FJF#x>~+A;D~;VDs26>^oH0EI`IYT2iagy23?nyJ==i{g4%HrAf1-*v zK1)~@&(KkwR7TL}L(A@C_S0G;-GMDy=MJn2$FP5s<%wC)4jC5PXoxrQBFZ_k0P{{s@sz+gX`-!=T8rcB(=7vW}^K6oLWMmp(rwDh}b zwaGGd>yEy6fHv%jM$yJXo5oMAQ>c9j`**}F?MCry;T@47@r?&sKHgVe$MCqk#Z_3S z1GZI~nOEN*P~+UaFGnj{{Jo@16`(qVNtbU>O0Hf57-P>x8Jikp=`s8xWs^dAJ9lCQ z)GFm+=OV%AMVqVATtN@|vp61VVAHRn87}%PC^RAzJ%JngmZTasWBAWsoAqBU+8L8u z4A&Pe?fmTm0?mK-BL9t+{y7o(7jm+RpOhL9KnY#E&qu^}B6=K_dB}*VlSEiC9fn)+V=J;OnN)Ta5v66ic1rG+dGAJ1 z1%Zb_+!$=tQ~lxQrzv3x#CPb?CekEkA}0MYSgx$Jdd}q8+R=ma$|&1a#)TQ=l$1tQ z=tL9&_^vJ)Pk}EDO-va`UCT1m#Uty1{v^A3P~83_#v^ozH}6*9mIjIr;t3Uv%@VeW zGL6(CwCUp)Jq%G0bIG%?{_*Y#5IHf*5M@wPo6A{$Um++Co$wLC=J1aoG93&T7Ho}P z=mGEPP7GbvoG!uD$k(H3A$Z))+i{Hy?QHdk>3xSBXR0j!11O^mEe9RHmw!pvzv?Ua~2_l2Yh~_!s1qS`|0~0)YsbHSz8!mG)WiJE| z2f($6TQtt6L_f~ApQYQKSb=`053LgrQq7G@98#igV>y#i==-nEjQ!XNu9 z~;mE+gtj4IDDNQJ~JVk5Ux6&LCSFL!y=>79kE9=V}J7tD==Ga+IW zX)r7>VZ9dY=V&}DR))xUoV!u(Z|%3ciQi_2jl}3=$Agc(`RPb z8kEBpvY>1FGQ9W$n>Cq=DIpski};nE)`p3IUw1Oz0|wxll^)4dq3;CCY@RyJgFgc# zKouFh!`?Xuo{IMz^xi-h=StCis_M7yq$u) z?XHvw*HP0VgR+KR6wI)jEMX|ssqYvSf*_3W8zVTQzD?3>H!#>InzpSO)@SC8q*ii- z%%h}_#0{4JG;Jm`4zg};BPTGkYamx$Xo#O~lBirRY)q=5M45n{GCfV7h9qwyu1NxOMoP4)jjZMxmT|IQQh0U7C$EbnMN<3)Kk?fFHYq$d|ICu>KbY_hO zTZM+uKHe(cIZfEqyzyYSUBZa8;Fcut-GN!HSA9ius`ltNebF46ZX_BbZNU}}ZOm{M2&nANL9@0qvih15(|`S~z}m&h!u4x~(%MAO$jHRWNfuxWF#B)E&g3ghSQ9|> z(MFaLQj)NE0lowyjvg8z0#m6FIuKE9lDO~Glg}nSb7`~^&#(Lw{}GVOS>U)m8bF}x zVjbXljBm34Cs-yM6TVusr+3kYFjr28STT3g056y3cH5Tmge~ASxBj z%|yb>$eF;WgrcOZf569sDZOVwoo%8>XO>XQOX1OyN9I-SQgrm;U;+#3OI(zrWyow3 zk==|{lt2xrQ%FIXOTejR>;wv(Pb8u8}BUpx?yd(Abh6? zsoO3VYWkeLnF43&@*#MQ9-i-d0t*xN-UEyNKeyNMHw|A(k(_6QKO=nKMCxD(W(Yop zsRQ)QeL4X3Lxp^L%wzi2-WVSsf61dqliPUM7srDB?Wm6Lzn0&{*}|IsKQW;02(Y&| zaTKv|`U(pSzuvR6Rduu$wzK_W-Y-7>7s?G$)U}&uK;<>vU}^^ns@Z!p+9?St1s)dG zK%y6xkPyyS1$~&6v{kl?Md6gwM|>mt6Upm>oa8RLD^8T{0?HC!Z>;(Bob7el(DV6x zi`I)$&E&ngwFS@bi4^xFLAn`=fzTC;aimE^!cMI2n@Vo%Ae-ne`RF((&5y6xsjjAZ zVguVoQ?Z9uk$2ON;ersE%PU*xGO@T*;j1BO5#TuZKEf(mB7|g7pcEA=nYJ{s3vlbg zd4-DUlD{*6o%Gc^N!Nptgay>j6E5;3psI+C3Q!1ZIbeCubW%w4pq9)MSDyB{HLm|k zxv-{$$A*pS@csolri$Ge<4VZ}e~78JOL-EVyrbxKra^d{?|NnPp86!q>t<&IP07?Z z^>~IK^k#OEKgRH+LjllZXk7iA>2cfH6+(e&9ku5poo~6y{GC5>(bRK7hwjiurqAiZ zg*DmtgY}v83IjE&AbiWgMyFbaRUPZ{lYiz$U^&Zt2YjG<%m((&_JUbZcfJ22(>bi5 z!J?<7AySj0JZ&<-qXX;mcV!f~>G=sB0KnjWca4}vrtunD^1TrpfeS^4dvFr!65knK zZh`d;*VOkPs4*-9kL>$GP0`(M!j~B;#x?Ba~&s6CopvO86oM?-? zOw#dIRc;6A6T?B`Qp%^<U5 z19x(ywSH$_N+Io!6;e?`tWaM$`=Db!gzx|lQ${DG!zb1Zl&|{kX0y6xvO1o z220r<-oaS^^R2pEyY;=Qllqpmue|5yI~D|iI!IGt@iod{Opz@*ml^w2bNs)p`M(Io z|E;;m*Xpjd9l)4G#KaWfV(t8YUn@A;nK^#xgv=LtnArX|vWQVuw3}B${h+frU2>9^ z!l6)!Uo4`5k`<<;E(ido7M6lKTgWezNLq>U*=uz&s=cc$1%>VrAeOoUtA|T6gO4>UNqsdK=NF*8|~*sl&wI=x9-EGiq*aqV!(VVXA57 zw9*o6Ir8Lj1npUXvlevtn(_+^X5rzdR>#(}4YcB9O50q97%rW2me5_L=%ffYPUSRc z!vv?Kv>dH994Qi>U(a<0KF6NH5b16enCp+mw^Hb3Xs1^tThFpz!3QuN#}KBbww`(h z7GO)1olDqy6?T$()R7y%NYx*B0k_2IBiZ14&8|JPFxeMF{vW>HF-Vi3+ZOI=+qP}n zw(+!WcTd~4ZJX1!ZM&y!+uyt=&i!+~d(V%GjH;-NsEEv6nS1TERt|RHh!0>W4+4pp z1-*EzAM~i`+1f(VEHI8So`S`akPfPTfq*`l{Fz`hS%k#JS0cjT2mS0#QLGf=J?1`he3W*;m4)ce8*WFq1sdP=~$5RlH1EdWm|~dCvKOi4*I_96{^95p#B<(n!d?B z=o`0{t+&OMwKcxiBECznJcfH!fL(z3OvmxP#oWd48|mMjpE||zdiTBdWelj8&Qosv zZFp@&UgXuvJw5y=q6*28AtxZzo-UUpkRW%ne+Ylf!V-0+uQXBW=5S1o#6LXNtY5!I z%Rkz#(S8Pjz*P7bqB6L|M#Er{|QLae-Y{KA>`^} z@lPjeX>90X|34S-7}ZVXe{wEei1<{*e8T-Nbj8JmD4iwcE+Hg_zhkPVm#=@b$;)h6 z<<6y`nPa`f3I6`!28d@kdM{uJOgM%`EvlQ5B2bL)Sl=|y@YB3KeOzz=9cUW3clPAU z^sYc}xf9{4Oj?L5MOlYxR{+>w=vJjvbyO5}ptT(o6dR|ygO$)nVCvNGnq(6;bHlBd zl?w-|plD8spjDF03g5ip;W3Z z><0{BCq!Dw;h5~#1BuQilq*TwEu)qy50@+BE4bX28+7erX{BD4H)N+7U`AVEuREE8 z;X?~fyhF-x_sRfHIj~6f(+^@H)D=ngP;mwJjxhQUbUdzk8f94Ab%59-eRIq?ZKrwD z(BFI=)xrUlgu(b|hAysqK<}8bslmNNeD=#JW*}^~Nrswn^xw*nL@Tx!49bfJecV&KC2G4q5a!NSv)06A_5N3Y?veAz;Gv+@U3R% z)~UA8-0LvVE{}8LVDOHzp~2twReqf}ODIyXMM6=W>kL|OHcx9P%+aJGYi_Om)b!xe zF40Vntn0+VP>o<$AtP&JANjXBn7$}C@{+@3I@cqlwR2MdwGhVPxlTIcRVu@Ho-wO` z_~Or~IMG)A_`6-p)KPS@cT9mu9RGA>dVh5wY$NM9-^c@N=hcNaw4ITjm;iWSP^ZX| z)_XpaI61<+La+U&&%2a z0za$)-wZP@mwSELo#3!PGTt$uy0C(nTT@9NX*r3Ctw6J~7A(m#8fE)0RBd`TdKfAT zCf@$MAxjP`O(u9s@c0Fd@|}UQ6qp)O5Q5DPCeE6mSIh|Rj{$cAVIWsA=xPKVKxdhg zLzPZ`3CS+KIO;T}0Ip!fAUaNU>++ZJZRk@I(h<)RsJUhZ&Ru9*!4Ptn;gX^~4E8W^TSR&~3BAZc#HquXn)OW|TJ`CTahk+{qe`5+ixON^zA9IFd8)kc%*!AiLu z>`SFoZ5bW-%7}xZ>gpJcx_hpF$2l+533{gW{a7ce^B9sIdmLrI0)4yivZ^(Vh@-1q zFT!NQK$Iz^xu%|EOK=n>ug;(7J4OnS$;yWmq>A;hsD_0oAbLYhW^1Vdt9>;(JIYjf zdb+&f&D4@4AS?!*XpH>8egQvSVX`36jMd>$+RgI|pEg))^djhGSo&#lhS~9%NuWfX zDDH;3T*GzRT@5=7ibO>N-6_XPBYxno@mD_3I#rDD?iADxX`! zh*v8^i*JEMzyN#bGEBz7;UYXki*Xr(9xXax(_1qVW=Ml)kSuvK$coq2A(5ZGhs_pF z$*w}FbN6+QDseuB9=fdp_MTs)nQf!2SlROQ!gBJBCXD&@-VurqHj0wm@LWX-TDmS= z71M__vAok|@!qgi#H&H%Vg-((ZfxPAL8AI{x|VV!9)ZE}_l>iWk8UPTGHs*?u7RfP z5MC&=c6X;XlUzrz5q?(!eO@~* zoh2I*%J7dF!!_!vXoSIn5o|wj1#_>K*&CIn{qSaRc&iFVxt*^20ngCL;QonIS>I5^ zMw8HXm>W0PGd*}Ko)f|~dDd%;Wu_RWI_d;&2g6R3S63Uzjd7dn%Svu-OKpx*o|N>F zZg=-~qLb~VRLpv`k zWSdfHh@?dp=s_X`{yxOlxE$4iuyS;Z-x!*E6eqmEm*j2bE@=ZI0YZ5%Yj29!5+J$4h{s($nakA`xgbO8w zi=*r}PWz#lTL_DSAu1?f%-2OjD}NHXp4pXOsCW;DS@BC3h-q4_l`<))8WgzkdXg3! zs1WMt32kS2E#L0p_|x+x**TFV=gn`m9BWlzF{b%6j-odf4{7a4y4Uaef@YaeuPhU8 zHBvRqN^;$Jizy+ z=zW{E5<>2gp$pH{M@S*!sJVQU)b*J5*bX4h>5VJve#Q6ga}cQ&iL#=(u+KroWrxa%8&~p{WEUF0il=db;-$=A;&9M{Rq`ouZ5m%BHT6%st%saGsD6)fQgLN}x@d3q>FC;=f%O3Cyg=Ke@Gh`XW za@RajqOE9UB6eE=zhG%|dYS)IW)&y&Id2n7r)6p_)vlRP7NJL(x4UbhlcFXWT8?K=%s7;z?Vjts?y2+r|uk8Wt(DM*73^W%pAkZa1Jd zNoE)8FvQA>Z`eR5Z@Ig6kS5?0h;`Y&OL2D&xnnAUzQz{YSdh0k zB3exx%A2TyI)M*EM6htrxSlep!Kk(P(VP`$p0G~f$smld6W1r_Z+o?=IB@^weq>5VYsYZZR@` z&XJFxd5{|KPZmVOSxc@^%71C@;z}}WhbF9p!%yLj3j%YOlPL5s>7I3vj25 z@xmf=*z%Wb4;Va6SDk9cv|r*lhZ`(y_*M@>q;wrn)oQx%B(2A$9(74>;$zmQ!4fN; z>XurIk-7@wZys<+7XL@0Fhe-f%*=(weaQEdR9Eh6>Kl-EcI({qoZqyzziGwpg-GM#251sK_ z=3|kitS!j%;fpc@oWn65SEL73^N&t>Ix37xgs= zYG%eQDJc|rqHFia0!_sm7`@lvcv)gfy(+KXA@E{3t1DaZ$DijWAcA)E0@X?2ziJ{v z&KOYZ|DdkM{}t+@{@*6ge}m%xfjIxi%qh`=^2Rwz@w0cCvZ&Tc#UmCDbVwABrON^x zEBK43FO@weA8s7zggCOWhMvGGE`baZ62cC)VHyy!5Zbt%ieH+XN|OLbAFPZWyC6)p z4P3%8sq9HdS3=ih^0OOlqTPbKuzQ?lBEI{w^ReUO{V?@`ARsL|S*%yOS=Z%sF)>-y z(LAQdhgAcuF6LQjRYfdbD1g4o%tV4EiK&ElLB&^VZHbrV1K>tHTO{#XTo>)2UMm`2 z^t4s;vnMQgf-njU-RVBRw0P0-m#d-u`(kq7NL&2T)TjI_@iKuPAK-@oH(J8?%(e!0Ir$yG32@CGUPn5w4)+9@8c&pGx z+K3GKESI4*`tYlmMHt@br;jBWTei&(a=iYslc^c#RU3Q&sYp zSG){)V<(g7+8W!Wxeb5zJb4XE{I|&Y4UrFWr%LHkdQ;~XU zgy^dH-Z3lmY+0G~?DrC_S4@=>0oM8Isw%g(id10gWkoz2Q%7W$bFk@mIzTCcIB(K8 zc<5h&ZzCdT=9n-D>&a8vl+=ZF*`uTvQviG_bLde*k>{^)&0o*b05x$MO3gVLUx`xZ z43j+>!u?XV)Yp@MmG%Y`+COH2?nQcMrQ%k~6#O%PeD_WvFO~Kct za4XoCM_X!c5vhRkIdV=xUB3xI2NNStK*8_Zl!cFjOvp-AY=D;5{uXj}GV{LK1~IE2 z|KffUiBaStRr;10R~K2VVtf{TzM7FaPm;Y(zQjILn+tIPSrJh&EMf6evaBKIvi42-WYU9Vhj~3< zZSM-B;E`g_o8_XTM9IzEL=9Lb^SPhe(f(-`Yh=X6O7+6ALXnTcUFpI>ekl6v)ZQeNCg2 z^H|{SKXHU*%nBQ@I3It0m^h+6tvI@FS=MYS$ZpBaG7j#V@P2ZuYySbp@hA# ze(kc;P4i_-_UDP?%<6>%tTRih6VBgScKU^BV6Aoeg6Uh(W^#J^V$Xo^4#Ekp ztqQVK^g9gKMTHvV7nb64UU7p~!B?>Y0oFH5T7#BSW#YfSB@5PtE~#SCCg3p^o=NkMk$<8- z6PT*yIKGrvne7+y3}_!AC8NNeI?iTY(&nakN>>U-zT0wzZf-RuyZk^X9H-DT_*wk= z;&0}6LsGtfVa1q)CEUPlx#(ED@-?H<1_FrHU#z5^P3lEB|qsxEyn%FOpjx z3S?~gvoXy~L(Q{Jh6*i~=f%9kM1>RGjBzQh_SaIDfSU_9!<>*Pm>l)cJD@wlyxpBV z4Fmhc2q=R_wHCEK69<*wG%}mgD1=FHi4h!98B-*vMu4ZGW~%IrYSLGU{^TuseqVgV zLP<%wirIL`VLyJv9XG_p8w@Q4HzNt-o;U@Au{7%Ji;53!7V8Rv0^Lu^Vf*sL>R(;c zQG_ZuFl)Mh-xEIkGu}?_(HwkB2jS;HdPLSxVU&Jxy9*XRG~^HY(f0g8Q}iqnVmgjI zfd=``2&8GsycjR?M%(zMjn;tn9agcq;&rR!Hp z$B*gzHsQ~aXw8c|a(L^LW(|`yGc!qOnV(ZjU_Q-4z1&0;jG&vAKuNG=F|H?@m5^N@ zq{E!1n;)kNTJ>|Hb2ODt-7U~-MOIFo%9I)_@7fnX+eMMNh>)V$IXesJpBn|uo8f~#aOFytCT zf9&%MCLf8mp4kwHTcojWmM3LU=#|{3L>E}SKwOd?%{HogCZ_Z1BSA}P#O(%H$;z7XyJ^sjGX;j5 zrzp>|Ud;*&VAU3x#f{CKwY7Vc{%TKKqmB@oTHA9;>?!nvMA;8+Jh=cambHz#J18x~ zs!dF>$*AnsQ{{82r5Aw&^7eRCdvcgyxH?*DV5(I$qXh^zS>us*I66_MbL8y4d3ULj z{S(ipo+T3Ag!+5`NU2sc+@*m{_X|&p#O-SAqF&g_n7ObB82~$p%fXA5GLHMC+#qqL zdt`sJC&6C2)=juQ_!NeD>U8lDVpAOkW*khf7MCcs$A(wiIl#B9HM%~GtQ^}yBPjT@ z+E=|A!Z?A(rwzZ;T}o6pOVqHzTr*i;Wrc%&36kc@jXq~+w8kVrs;%=IFdACoLAcCAmhFNpbP8;s`zG|HC2Gv?I~w4ITy=g$`0qMQdkijLSOtX6xW%Z9Nw<;M- zMN`c7=$QxN00DiSjbVt9Mi6-pjv*j(_8PyV-il8Q-&TwBwH1gz1uoxs6~uU}PrgWB zIAE_I-a1EqlIaGQNbcp@iI8W1sm9fBBNOk(k&iLBe%MCo#?xI$%ZmGA?=)M9D=0t7 zc)Q0LnI)kCy{`jCGy9lYX%mUsDWwsY`;jE(;Us@gmWPqjmXL+Hu#^;k%eT>{nMtzj zsV`Iy6leTA8-PndszF;N^X@CJrTw5IIm!GPeu)H2#FQitR{1p;MasQVAG3*+=9FYK zw*k!HT(YQorfQj+1*mCV458(T5=fH`um$gS38hw(OqVMyunQ;rW5aPbF##A3fGH6h z@W)i9Uff?qz`YbK4c}JzQpuxuE3pcQO)%xBRZp{zJ^-*|oryTxJ-rR+MXJ)!f=+pp z10H|DdGd2exhi+hftcYbM0_}C0ZI-2vh+$fU1acsB-YXid7O|=9L!3e@$H*6?G*Zp z%qFB(sgl=FcC=E4CYGp4CN>=M8#5r!RU!u+FJVlH6=gI5xHVD&k;Ta*M28BsxfMV~ zLz+@6TxnfLhF@5=yQo^1&S}cmTN@m!7*c6z;}~*!hNBjuE>NLVl2EwN!F+)0$R1S! zR|lF%n!9fkZ@gPW|x|B={V6x3`=jS*$Pu0+5OWf?wnIy>Y1MbbGSncpKO0qE(qO=ts z!~@&!N`10S593pVQu4FzpOh!tvg}p%zCU(aV5=~K#bKi zHdJ1>tQSrhW%KOky;iW+O_n;`l9~omqM%sdxdLtI`TrJzN6BQz+7xOl*rM>xVI2~# z)7FJ^Dc{DC<%~VS?@WXzuOG$YPLC;>#vUJ^MmtbSL`_yXtNKa$Hk+l-c!aC7gn(Cg ze?YPYZ(2Jw{SF6MiO5(%_pTo7j@&DHNW`|lD`~{iH+_eSTS&OC*2WTT*a`?|9w1dh zh1nh@$a}T#WE5$7Od~NvSEU)T(W$p$s5fe^GpG+7fdJ9=enRT9$wEk+ZaB>G3$KQO zgq?-rZZnIv!p#>Ty~}c*Lb_jxJg$eGM*XwHUwuQ|o^}b3^T6Bxx{!?va8aC@-xK*H ztJBFvFfsSWu89%@b^l3-B~O!CXs)I6Y}y#0C0U0R0WG zybjroj$io0j}3%P7zADXOwHwafT#uu*zfM!oD$6aJx7+WL%t-@6^rD_a_M?S^>c;z zMK580bZXo1f*L$CuMeM4Mp!;P@}b~$cd(s5*q~FP+NHSq;nw3fbWyH)i2)-;gQl{S zZO!T}A}fC}vUdskGSq&{`oxt~0i?0xhr6I47_tBc`fqaSrMOzR4>0H^;A zF)hX1nfHs)%Zb-(YGX;=#2R6C{BG;k=?FfP?9{_uFLri~-~AJ;jw({4MU7e*d)?P@ zXX*GkNY9ItFjhwgAIWq7Y!ksbMzfqpG)IrqKx9q{zu%Mdl+{Dis#p9q`02pr1LG8R z@As?eG!>IoROgS!@J*to<27coFc1zpkh?w=)h9CbYe%^Q!Ui46Y*HO0mr% zEff-*$ndMNw}H2a5@BsGj5oFfd!T(F&0$<{GO!Qdd?McKkorh=5{EIjDTHU`So>8V zBA-fqVLb2;u7UhDV1xMI?y>fe3~4urv3%PX)lDw+HYa;HFkaLqi4c~VtCm&Ca+9C~ zge+67hp#R9`+Euq59WhHX&7~RlXn=--m8$iZ~~1C8cv^2(qO#X0?vl91gzUKBeR1J z^p4!!&7)3#@@X&2aF2-)1Ffcc^F8r|RtdL2X%HgN&XU-KH2SLCbpw?J5xJ*!F-ypZ zMG%AJ!Pr&}`LW?E!K~=(NJxuSVTRCGJ$2a*Ao=uUDSys!OFYu!Vs2IT;xQ6EubLIl z+?+nMGeQQhh~??0!s4iQ#gm3!BpMpnY?04kK375e((Uc7B3RMj;wE?BCoQGu=UlZt!EZ1Q*auI)dj3Jj{Ujgt zW5hd~-HWBLI_3HuO) zNrb^XzPsTIb=*a69wAAA3J6AAZZ1VsYbIG}a`=d6?PjM)3EPaDpW2YP$|GrBX{q*! z$KBHNif)OKMBCFP5>!1d=DK>8u+Upm-{hj5o|Wn$vh1&K!lVfDB&47lw$tJ?d5|=B z^(_9=(1T3Fte)z^>|3**n}mIX;mMN5v2F#l(q*CvU{Ga`@VMp#%rQkDBy7kYbmb-q z<5!4iuB#Q_lLZ8}h|hPODI^U6`gzLJre9u3k3c#%86IKI*^H-@I48Bi*@avYm4v!n0+v zWu{M{&F8#p9cx+gF0yTB_<2QUrjMPo9*7^-uP#~gGW~y3nfPAoV%amgr>PSyVAd@l)}8#X zR5zV6t*uKJZL}?NYvPVK6J0v4iVpwiN|>+t3aYiZSp;m0!(1`bHO}TEtWR1tY%BPB z(W!0DmXbZAsT$iC13p4f>u*ZAy@JoLAkJhzFf1#4;#1deO8#8d&89}en&z!W&A3++^1(;>0SB1*54d@y&9Pn;^IAf3GiXbfT`_>{R+Xv; zQvgL>+0#8-laO!j#-WB~(I>l0NCMt_;@Gp_f0#^c)t?&#Xh1-7RR0@zPyBz!U#0Av zT?}n({(p?p7!4S2ZBw)#KdCG)uPnZe+U|0{BW!m)9 zi_9$F?m<`2!`JNFv+w8MK_K)qJ^aO@7-Ig>cM4-r0bi=>?B_2mFNJ}aE3<+QCzRr*NA!QjHw# z`1OsvcoD0?%jq{*7b!l|L1+Tw0TTAM4XMq7*ntc-Ived>Sj_ZtS|uVdpfg1_I9knY z2{GM_j5sDC7(W&}#s{jqbybqJWyn?{PW*&cQIU|*v8YGOKKlGl@?c#TCnmnAkAzV- zmK={|1G90zz=YUvC}+fMqts0d4vgA%t6Jhjv?d;(Z}(Ep8fTZfHA9``fdUHkA+z3+ zhh{ohP%Bj?T~{i0sYCQ}uC#5BwN`skI7`|c%kqkyWIQ;!ysvA8H`b-t()n6>GJj6xlYDu~8qX{AFo$Cm3d|XFL=4uvc?Keb zzb0ZmMoXca6Mob>JqkNuoP>B2Z>D`Q(TvrG6m`j}-1rGP!g|qoL=$FVQYxJQjFn33lODt3Wb1j8VR zlR++vIT6^DtYxAv_hxupbLLN3e0%A%a+hWTKDV3!Fjr^cWJ{scsAdfhpI)`Bms^M6 zQG$waKgFr=c|p9Piug=fcJvZ1ThMnNhQvBAg-8~b1?6wL*WyqXhtj^g(Ke}mEfZVM zJuLNTUVh#WsE*a6uqiz`b#9ZYg3+2%=C(6AvZGc=u&<6??!slB1a9K)=VL zY9EL^mfyKnD zSJyYBc_>G;5RRnrNgzJz#Rkn3S1`mZgO`(r5;Hw6MveN(URf_XS-r58Cn80K)ArH4 z#Rrd~LG1W&@ttw85cjp8xV&>$b%nSXH_*W}7Ch2pg$$c0BdEo-HWRTZcxngIBJad> z;C>b{jIXjb_9Jis?NZJsdm^EG}e*pR&DAy0EaSGi3XWTa(>C%tz1n$u?5Fb z1qtl?;_yjYo)(gB^iQq?=jusF%kywm?CJP~zEHi0NbZ);$(H$w(Hy@{i>$wcVRD_X|w-~(0Z9BJyh zhNh;+eQ9BEIs;tPz%jSVnfCP!3L&9YtEP;svoj_bNzeGSQIAjd zBss@A;)R^WAu-37RQrM%{DfBNRx>v!G31Z}8-El9IOJlb_MSoMu2}GDYycNaf>uny z+8xykD-7ONCM!APry_Lw6-yT>5!tR}W;W`C)1>pxSs5o1z#j7%m=&=7O4hz+Lsqm` z*>{+xsabZPr&X=}G@obTb{nPTkccJX8w3CG7X+1+t{JcMabv~UNv+G?txRqXib~c^Mo}`q{$`;EBNJ;#F*{gvS12kV?AZ%O0SFB$^ zn+}!HbmEj}w{Vq(G)OGAzH}R~kS^;(-s&=ectz8vN!_)Yl$$U@HNTI-pV`LSj7Opu zTZ5zZ)-S_{GcEQPIQXLQ#oMS`HPu{`SQiAZ)m1at*Hy%3xma|>o`h%E%8BEbi9p0r zVjcsh<{NBKQ4eKlXU|}@XJ#@uQw*$4BxKn6#W~I4T<^f99~(=}a`&3(ur8R9t+|AQ zWkQx7l}wa48-jO@ft2h+7qn%SJtL%~890FG0s5g*kNbL3I&@brh&f6)TlM`K^(bhr zJWM6N6x3flOw$@|C@kPi7yP&SP?bzP-E|HSXQXG>7gk|R9BTj`e=4de9C6+H7H7n# z#GJeVs1mtHhLDmVO?LkYRQc`DVOJ_vdl8VUihO-j#t=0T3%Fc1f9F73ufJz*adn*p zc%&vi(4NqHu^R>sAT_0EDjVR8bc%wTz#$;%NU-kbDyL_dg0%TFafZwZ?5KZpcuaO54Z9hX zD$u>q!-9`U6-D`E#`W~fIfiIF5_m6{fvM)b1NG3xf4Auw;Go~Fu7cth#DlUn{@~yu z=B;RT*dp?bO}o%4x7k9v{r=Y@^YQ^UUm(Qmliw8brO^=NP+UOohLYiaEB3^DB56&V zK?4jV61B|1Uj_5fBKW;8LdwOFZKWp)g{B%7g1~DgO&N& z#lisxf?R~Z@?3E$Mms$$JK8oe@X`5m98V*aV6Ua}8Xs2#A!{x?IP|N(%nxsH?^c{& z@vY&R1QmQs83BW28qAmJfS7MYi=h(YK??@EhjL-t*5W!p z^gYX!Q6-vBqcv~ruw@oMaU&qp0Fb(dbVzm5xJN%0o_^@fWq$oa3X?9s%+b)x4w-q5Koe(@j6Ez7V@~NRFvd zfBH~)U5!ix3isg`6be__wBJp=1@yfsCMw1C@y+9WYD9_C%{Q~7^0AF2KFryfLlUP# zwrtJEcH)jm48!6tUcxiurAMaiD04C&tPe6DI0#aoqz#Bt0_7_*X*TsF7u*zv(iEfA z;$@?XVu~oX#1YXtceQL{dSneL&*nDug^OW$DSLF0M1Im|sSX8R26&)<0Fbh^*l6!5wfSu8MpMoh=2l z^^0Sr$UpZp*9oqa23fcCfm7`ya2<4wzJ`Axt7e4jJrRFVf?nY~2&tRL* zd;6_njcz01c>$IvN=?K}9ie%Z(BO@JG2J}fT#BJQ+f5LFSgup7i!xWRKw6)iITjZU z%l6hPZia>R!`aZjwCp}I zg)%20;}f+&@t;(%5;RHL>K_&7MH^S+7<|(SZH!u zznW|jz$uA`P9@ZWtJgv$EFp>)K&Gt+4C6#*khZQXS*S~6N%JDT$r`aJDs9|uXWdbg zBwho$phWx}x!qy8&}6y5Vr$G{yGSE*r$^r{}pw zVTZKvikRZ`J_IJrjc=X1uw?estdwm&bEahku&D04HD+0Bm~q#YGS6gp!KLf$A{%Qd z&&yX@Hp>~(wU{|(#U&Bf92+1i&Q*-S+=y=3pSZy$#8Uc$#7oiJUuO{cE6=tsPhwPe| zxQpK>`Dbka`V)$}e6_OXKLB%i76~4N*zA?X+PrhH<&)}prET;kel24kW%+9))G^JI zsq7L{P}^#QsZViX%KgxBvEugr>ZmFqe^oAg?{EI=&_O#e)F3V#rc z8$4}0Zr19qd3tE4#$3_f=Bbx9oV6VO!d3(R===i-7p=Vj`520w0D3W6lQfY48}!D* z&)lZMG;~er2qBoI2gsX+Ts-hnpS~NYRDtPd^FPzn!^&yxRy#CSz(b&E*tL|jIkq|l zf%>)7Dtu>jCf`-7R#*GhGn4FkYf;B$+9IxmqH|lf6$4irg{0ept__%)V*R_OK=T06 zyT_m-o@Kp6U{l5h>W1hGq*X#8*y@<;vsOFqEjTQXFEotR+{3}ODDnj;o0@!bB5x=N z394FojuGOtVKBlVRLtHp%EJv_G5q=AgF)SKyRN5=cGBjDWv4LDn$IL`*=~J7u&Dy5 zrMc83y+w^F&{?X(KOOAl-sWZDb{9X9#jrQtmrEXD?;h-}SYT7yM(X_6qksM=K_a;Z z3u0qT0TtaNvDER_8x*rxXw&C^|h{P1qxK|@pS7vdlZ#P z7PdB7MmC2}%sdzAxt>;WM1s0??`1983O4nFK|hVAbHcZ3x{PzytQLkCVk7hA!Lo` zEJH?4qw|}WH{dc4z%aB=0XqsFW?^p=X}4xnCJXK%c#ItOSjdSO`UXJyuc8bh^Cf}8 z@Ht|vXd^6{Fgai8*tmyRGmD_s_nv~r^Fy7j`Bu`6=G)5H$i7Q7lvQnmea&TGvJp9a|qOrUymZ$6G|Ly z#zOCg++$3iB$!6!>215A4!iryregKuUT344X)jQb3|9qY>c0LO{6Vby05n~VFzd?q zgGZv&FGlkiH*`fTurp>B8v&nSxNz)=5IF$=@rgND4d`!AaaX;_lK~)-U8la_Wa8i?NJC@BURO*sUW)E9oyv3RG^YGfN%BmxzjlT)bp*$<| zX3tt?EAy<&K+bhIuMs-g#=d1}N_?isY)6Ay$mDOKRh z4v1asEGWoAp=srraLW^h&_Uw|6O+r;wns=uwYm=JN4Q!quD8SQRSeEcGh|Eb5Jg8m zOT}u;N|x@aq)=&;wufCc^#)5U^VcZw;d_wwaoh9$p@Xrc{DD6GZUqZ ziC6OT^zSq@-lhbgR8B+e;7_Giv;DK5gn^$bs<6~SUadiosfewWDJu`XsBfOd1|p=q zE>m=zF}!lObA%ePey~gqU8S6h-^J2Y?>7)L2+%8kV}Gp=h`Xm_}rlm)SyUS=`=S7msKu zC|T!gPiI1rWGb1z$Md?0YJQ;%>uPLOXf1Z>N~`~JHJ!^@D5kSXQ4ugnFZ>^`zH8CAiZmp z6Ms|#2gcGsQ{{u7+Nb9sA?U>(0e$5V1|WVwY`Kn)rsnnZ4=1u=7u!4WexZD^IQ1Jk zfF#NLe>W$3m&C^ULjdw+5|)-BSHwpegdyt9NYC{3@QtMfd8GrIWDu`gd0nv-3LpGCh@wgBaG z176tikL!_NXM+Bv#7q^cyn9$XSeZR6#!B4JE@GVH zoobHZN_*RF#@_SVYKkQ_igme-Y5U}cV(hkR#k1c{bQNMji zU7aE`?dHyx=1`kOYZo_8U7?3-7vHOp`Qe%Z*i+FX!s?6huNp0iCEW-Z7E&jRWmUW_ z67j>)Ew!yq)hhG4o?^z}HWH-e=es#xJUhDRc4B51M4~E-l5VZ!&zQq`gWe`?}#b~7w1LH4Xa-UCT5LXkXQWheBa2YJYbyQ zl1pXR%b(KCXMO0OsXgl0P0Og<{(@&z1aokU-Pq`eQq*JYgt8xdFQ6S z6Z3IFSua8W&M#`~*L#r>Jfd6*BzJ?JFdBR#bDv$_0N!_5vnmo@!>vULcDm`MFU823 zpG9pqjqz^FE5zMDoGqhs5OMmC{Y3iVcl>F}5Rs24Y5B^mYQ;1T&ks@pIApHOdrzXF z-SdX}Hf{X;TaSxG_T$0~#RhqKISGKNK47}0*x&nRIPtmdwxc&QT3$8&!3fWu1eZ_P zJveQj^hJL#Sn!*4k`3}(d(aasl&7G0j0-*_2xtAnoX1@9+h zO#c>YQg60Z;o{Bi=3i7S`Ic+ZE>K{(u|#)9y}q*j8uKQ1^>+(BI}m%1v3$=4ojGBc zm+o1*!T&b}-lVvZqIUBc8V}QyFEgm#oyIuC{8WqUNV{Toz`oxhYpP!_p2oHHh5P@iB*NVo~2=GQm+8Yrkm2Xjc_VyHg1c0>+o~@>*Qzo zHVBJS>$$}$_4EniTI;b1WShX<5-p#TPB&!;lP!lBVBbLOOxh6FuYloD%m;n{r|;MU3!q4AVkua~fieeWu2 zQAQ$ue(IklX6+V;F1vCu-&V?I3d42FgWgsb_e^29ol}HYft?{SLf>DrmOp9o!t>I^ zY7fBCk+E8n_|apgM|-;^=#B?6RnFKlN`oR)`e$+;D=yO-(U^jV;rft^G_zl`n7qnM zL z*-Y4Phq+ZI1$j$F-f;`CD#|`-T~OM5Q>x}a>B~Gb3-+9i>Lfr|Ca6S^8g*{*?_5!x zH_N!SoRP=gX1?)q%>QTY!r77e2j9W(I!uAz{T`NdNmPBBUzi2{`XMB^zJGGwFWeA9 z{fk33#*9SO0)DjROug+(M)I-pKA!CX;IY(#gE!UxXVsa)X!UftIN98{pt#4MJHOhY zM$_l}-TJlxY?LS6Nuz1T<44m<4i^8k@D$zuCPrkmz@sdv+{ciyFJG2Zwy&%c7;atIeTdh!a(R^QXnu1Oq1b42*OQFWnyQ zWeQrdvP|w_idy53Wa<{QH^lFmEd+VlJkyiC>6B#s)F;w-{c;aKIm;Kp50HnA-o3lY z9B~F$gJ@yYE#g#X&3ADx&tO+P_@mnQTz9gv30_sTsaGXkfNYXY{$(>*PEN3QL>I!k zp)KibPhrfX3%Z$H6SY`rXGYS~143wZrG2;=FLj50+VM6soI~up_>fU(2Wl@{BRsMi zO%sL3x?2l1cXTF)k&moNsHfQrQ+wu(gBt{sk#CU=UhrvJIncy@tJX5klLjgMn>~h= zg|FR&;@eh|C7`>s_9c~0-{IAPV){l|Ts`i=)AW;d9&KPc3fMeoTS%8@V~D8*h;&(^>yjT84MM}=%#LS7shLAuuj(0VAYoozhWjq z4LEr?wUe2^WGwdTIgWBkDUJa>YP@5d9^Rs$kCXmMRxuF*YMVrn?0NFyPl}>`&dqZb z<5eqR=ZG3>n2{6v6BvJ`YBZeeTtB88TAY(x0a58EWyuf>+^|x8Qa6wA|1Nb_p|nA zWWa}|z8a)--Wj`LqyFk_a3gN2>5{Rl_wbW?#by7&i*^hRknK%jwIH6=dQ8*-_{*x0j^DUfMX0`|K@6C<|1cgZ~D(e5vBFFm;HTZF(!vT8=T$K+|F)x3kqzBV4-=p1V(lzi(s7jdu0>LD#N=$Lk#3HkG!a zIF<7>%B7sRNzJ66KrFV76J<2bdYhxll0y2^_rdG=I%AgW4~)1Nvz=$1UkE^J%BxLo z+lUci`UcU062os*=`-j4IfSQA{w@y|3}Vk?i;&SSdh8n+$iHA#%ERL{;EpXl6u&8@ zzg}?hkEOUOJt?ZL=pWZFJ19mI1@P=$U5*Im1e_8Z${JsM>Ov?nh8Z zP5QvI!{Jy@&BP48%P2{Jr_VgzW;P@7)M9n|lDT|Ep#}7C$&ud&6>C^5ZiwKIg2McPU(4jhM!BD@@L(Gd*Nu$ji(ljZ<{FIeW_1Mmf;76{LU z-ywN~=uNN)Xi6$<12A9y)K%X|(W0p|&>>4OXB?IiYr||WKDOJPxiSe01NSV-h24^L z_>m$;|C+q!Mj**-qQ$L-*++en(g|hw;M!^%_h-iDjFHLo-n3JpB;p?+o2;`*jpvJU zLY^lt)Un4joij^^)O(CKs@7E%*!w>!HA4Q?0}oBJ7Nr8NQ7QmY^4~jvf0-`%waOLn zdNjAPaC0_7c|RVhw)+71NWjRi!y>C+Bl;Z`NiL^zn2*0kmj5gyhCLCxts*cWCdRI| zjsd=sT5BVJc^$GxP~YF$-U{-?kW6r@^vHXB%{CqYzU@1>dzf#3SYedJG-Rm6^RB7s zGM5PR(yKPKR)>?~vpUIeTP7A1sc8-knnJk*9)3t^e%izbdm>Y=W{$wm(cy1RB-19i za#828DMBY+ps#7Y8^6t)=Ea@%Nkt)O6JCx|ybC;Ap}Z@Zw~*}3P>MZLPb4Enxz9Wf zssobT^(R@KuShj8>@!1M7tm|2%-pYYDxz-5`rCbaTCG5{;Uxm z*g=+H1X8{NUvFGzz~wXa%Eo};I;~`37*WrRU&K0dPSB$yk(Z*@K&+mFal^?c zurbqB-+|Kb5|sznT;?Pj!+kgFY1#Dr;_%A(GIQC{3ct|{*Bji%FNa6c-thbpBkA;U zURV!Dr&X{0J}iht#-Qp2=xzuh(fM>zRoiGrYl5ttw2#r34gC41CCOC31m~^UPTK@s z6;A@)7O7_%C)>bnAXerYuAHdE93>j2N}H${zEc6&SbZ|-fiG*-qtGuy-qDelH(|u$ zorf8_T6Zqe#Ub!+e3oSyrskt_HyW_^5lrWt#30l)tHk|j$@YyEkXUOV;6B51L;M@=NIWZXU;GrAa(LGxO%|im%7F<-6N;en0Cr zLH>l*y?pMwt`1*cH~LdBPFY_l;~`N!Clyfr;7w<^X;&(ZiVdF1S5e(+Q%60zgh)s4 zn2yj$+mE=miVERP(g8}G4<85^-5f@qxh2ec?n+$A_`?qN=iyT1?U@t?V6DM~BIlBB z>u~eXm-aE>R0sQy!-I4xtCNi!!qh?R1!kKf6BoH2GG{L4%PAz0{Sh6xpuyI%*~u)s z%rLuFl)uQUCBQAtMyN;%)zFMx4loh7uTfKeB2Xif`lN?2gq6NhWhfz0u5WP9J>=V2 zo{mLtSy&BA!mSzs&CrKWq^y40JF5a&GSXIi2= z{EYb59J4}VwikL4P=>+mc6{($FNE@e=VUwG+KV21;<@lrN`mnz5jYGASyvz7BOG_6(p^eTxD-4O#lROgon;R35=|nj#eHIfJBYPWG>H>`dHKCDZ3`R{-?HO0mE~(5_WYcFmp8sU?wr*UkAQiNDGc6T zA%}GOLXlOWqL?WwfHO8MB#8M8*~Y*gz;1rWWoVSXP&IbKxbQ8+s%4Jnt?kDsq7btI zCDr0PZ)b;B%!lu&CT#RJzm{l{2fq|BcY85`w~3LSK<><@(2EdzFLt9Y_`;WXL6x`0 zDoQ?=?I@Hbr;*VVll1Gmd8*%tiXggMK81a+T(5Gx6;eNb8=uYn z5BG-0g>pP21NPn>$ntBh>`*})Fl|38oC^9Qz>~MAazH%3Q~Qb!ALMf$srexgPZ2@&c~+hxRi1;}+)-06)!#Mq<6GhP z-Q?qmgo${aFBApb5p}$1OJKTClfi8%PpnczyVKkoHw7Ml9e7ikrF0d~UB}i3vizos zXW4DN$SiEV9{faLt5bHy2a>33K%7Td-n5C*N;f&ZqAg#2hIqEb(y<&f4u5BWJ>2^4 z414GosL=Aom#m&=x_v<0-fp1r%oVJ{T-(xnomNJ(Dryv zh?vj+%=II_nV+@NR+(!fZZVM&(W6{6%9cm+o+Z6}KqzLw{(>E86uA1`_K$HqINlb1 zKelh3-jr2I9V?ych`{hta9wQ2c9=MM`2cC{m6^MhlL2{DLv7C^j z$xXBCnDl_;l|bPGMX@*tV)B!c|4oZyftUlP*?$YU9C_eAsuVHJ58?)zpbr30P*C`T z7y#ao`uE-SOG(Pi+`$=e^mle~)pRrdwL5)N;o{gpW21of(QE#U6w%*C~`v-z0QqBML!!5EeYA5IQB0 z^l01c;L6E(iytN!LhL}wfwP7W9PNAkb+)Cst?qg#$n;z41O4&v+8-zPs+XNb-q zIeeBCh#ivnFLUCwfS;p{LC0O7tm+Sf9Jn)~b%uwP{%69;QC)Ok0t%*a5M+=;y8j=v z#!*pp$9@!x;UMIs4~hP#pnfVc!%-D<+wsG@R2+J&%73lK|2G!EQC)O05TCV=&3g)C!lT=czLpZ@Sa%TYuoE?v8T8`V;e$#Zf2_Nj6nvBgh1)2 GZ~q4|mN%#X literal 0 HcmV?d00001 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..cea7a793 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100755 index 00000000..f3b75f3b --- /dev/null +++ b/gradlew @@ -0,0 +1,251 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 00000000..9d21a218 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,94 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/langsmith-api-java-client-okhttp/build.gradle.kts b/langsmith-api-java-client-okhttp/build.gradle.kts new file mode 100644 index 00000000..e1cabbea --- /dev/null +++ b/langsmith-api-java-client-okhttp/build.gradle.kts @@ -0,0 +1,14 @@ +plugins { + id("langsmith-api.kotlin") + id("langsmith-api.publish") +} + +dependencies { + api(project(":langsmith-api-java-core")) + + implementation("com.squareup.okhttp3:okhttp:4.12.0") + implementation("com.squareup.okhttp3:logging-interceptor:4.12.0") + + testImplementation(kotlin("test")) + testImplementation("org.assertj:assertj-core:3.25.3") +} diff --git a/langsmith-api-java-client-okhttp/src/main/kotlin/com/langsmith_api/api/client/okhttp/LangsmithApiOkHttpClient.kt b/langsmith-api-java-client-okhttp/src/main/kotlin/com/langsmith_api/api/client/okhttp/LangsmithApiOkHttpClient.kt new file mode 100644 index 00000000..eee3c2a5 --- /dev/null +++ b/langsmith-api-java-client-okhttp/src/main/kotlin/com/langsmith_api/api/client/okhttp/LangsmithApiOkHttpClient.kt @@ -0,0 +1,332 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.client.okhttp + +import com.fasterxml.jackson.databind.json.JsonMapper +import com.langsmith_api.api.client.LangsmithApiClient +import com.langsmith_api.api.client.LangsmithApiClientImpl +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.Sleeper +import com.langsmith_api.api.core.Timeout +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.HttpClient +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.jsonMapper +import java.net.Proxy +import java.time.Clock +import java.time.Duration +import java.util.Optional +import javax.net.ssl.HostnameVerifier +import javax.net.ssl.SSLSocketFactory +import javax.net.ssl.X509TrustManager +import kotlin.jvm.optionals.getOrNull + +/** + * A class that allows building an instance of [LangsmithApiClient] with [OkHttpClient] as the + * underlying [HttpClient]. + */ +class LangsmithApiOkHttpClient private constructor() { + + companion object { + + /** Returns a mutable builder for constructing an instance of [LangsmithApiClient]. */ + @JvmStatic fun builder() = Builder() + + /** + * Returns a client configured using system properties and environment variables. + * + * @see ClientOptions.Builder.fromEnv + */ + @JvmStatic fun fromEnv(): LangsmithApiClient = builder().fromEnv().build() + } + + /** A builder for [LangsmithApiOkHttpClient]. */ + class Builder internal constructor() { + + private var clientOptions: ClientOptions.Builder = ClientOptions.builder() + private var proxy: Proxy? = null + private var sslSocketFactory: SSLSocketFactory? = null + private var trustManager: X509TrustManager? = null + private var hostnameVerifier: HostnameVerifier? = null + + fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } + + /** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */ + fun proxy(proxy: Optional) = proxy(proxy.getOrNull()) + + /** + * The socket factory used to secure HTTPS connections. + * + * If this is set, then [trustManager] must also be set. + * + * If unset, then the system default is used. Most applications should not call this method, + * and instead use the system default. The default include special optimizations that can be + * lost if the implementation is modified. + */ + fun sslSocketFactory(sslSocketFactory: SSLSocketFactory?) = apply { + this.sslSocketFactory = sslSocketFactory + } + + /** Alias for calling [Builder.sslSocketFactory] with `sslSocketFactory.orElse(null)`. */ + fun sslSocketFactory(sslSocketFactory: Optional) = + sslSocketFactory(sslSocketFactory.getOrNull()) + + /** + * The trust manager used to secure HTTPS connections. + * + * If this is set, then [sslSocketFactory] must also be set. + * + * If unset, then the system default is used. Most applications should not call this method, + * and instead use the system default. The default include special optimizations that can be + * lost if the implementation is modified. + */ + fun trustManager(trustManager: X509TrustManager?) = apply { + this.trustManager = trustManager + } + + /** Alias for calling [Builder.trustManager] with `trustManager.orElse(null)`. */ + fun trustManager(trustManager: Optional) = + trustManager(trustManager.getOrNull()) + + /** + * The verifier used to confirm that response certificates apply to requested hostnames for + * HTTPS connections. + * + * If unset, then a default hostname verifier is used. + */ + fun hostnameVerifier(hostnameVerifier: HostnameVerifier?) = apply { + this.hostnameVerifier = hostnameVerifier + } + + /** Alias for calling [Builder.hostnameVerifier] with `hostnameVerifier.orElse(null)`. */ + fun hostnameVerifier(hostnameVerifier: Optional) = + hostnameVerifier(hostnameVerifier.getOrNull()) + + /** + * Whether to throw an exception if any of the Jackson versions detected at runtime are + * incompatible with the SDK's minimum supported Jackson version (2.13.4). + * + * Defaults to true. Use extreme caution when disabling this option. There is no guarantee + * that the SDK will work correctly when using an incompatible Jackson version. + */ + fun checkJacksonVersionCompatibility(checkJacksonVersionCompatibility: Boolean) = apply { + clientOptions.checkJacksonVersionCompatibility(checkJacksonVersionCompatibility) + } + + /** + * The Jackson JSON mapper to use for serializing and deserializing JSON. + * + * Defaults to [com.langsmith_api.api.core.jsonMapper]. The default is usually sufficient + * and rarely needs to be overridden. + */ + fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } + + /** + * The interface to use for delaying execution, like during retries. + * + * This is primarily useful for using fake delays in tests. + * + * Defaults to real execution delays. + * + * This class takes ownership of the sleeper and closes it when closed. + */ + fun sleeper(sleeper: Sleeper) = apply { clientOptions.sleeper(sleeper) } + + /** + * The clock to use for operations that require timing, like retries. + * + * This is primarily useful for using a fake clock in tests. + * + * Defaults to [Clock.systemUTC]. + */ + fun clock(clock: Clock) = apply { clientOptions.clock(clock) } + + /** + * The base URL to use for every request. + * + * Defaults to the production environment: `https://api.example.com`. + */ + fun baseUrl(baseUrl: String?) = apply { clientOptions.baseUrl(baseUrl) } + + /** Alias for calling [Builder.baseUrl] with `baseUrl.orElse(null)`. */ + fun baseUrl(baseUrl: Optional) = baseUrl(baseUrl.getOrNull()) + + /** + * Whether to call `validate` on every response before returning it. + * + * Defaults to false, which means the shape of the response will not be validated upfront. + * Instead, validation will only occur for the parts of the response that are accessed. + */ + fun responseValidation(responseValidation: Boolean) = apply { + clientOptions.responseValidation(responseValidation) + } + + /** + * Sets the maximum time allowed for various parts of an HTTP call's lifecycle, excluding + * retries. + * + * Defaults to [Timeout.default]. + */ + fun timeout(timeout: Timeout) = apply { clientOptions.timeout(timeout) } + + /** + * Sets the maximum time allowed for a complete HTTP call, not including retries. + * + * See [Timeout.request] for more details. + * + * For fine-grained control, pass a [Timeout] object. + */ + fun timeout(timeout: Duration) = apply { clientOptions.timeout(timeout) } + + /** + * The maximum number of times to retry failed requests, with a short exponential backoff + * between requests. + * + * Only the following error types are retried: + * - Connection errors (for example, due to a network connectivity problem) + * - 408 Request Timeout + * - 409 Conflict + * - 429 Rate Limit + * - 5xx Internal + * + * The API may also explicitly instruct the SDK to retry or not retry a request. + * + * Defaults to 2. + */ + fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } + + fun apiKey(apiKey: String?) = apply { clientOptions.apiKey(apiKey) } + + /** Alias for calling [Builder.apiKey] with `apiKey.orElse(null)`. */ + fun apiKey(apiKey: Optional) = apiKey(apiKey.getOrNull()) + + fun tenantId(tenantId: String?) = apply { clientOptions.tenantId(tenantId) } + + /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ + fun tenantId(tenantId: Optional) = tenantId(tenantId.getOrNull()) + + /** + * Bearer tokens are used to authenticate from the UI. Must also specify x-tenant-id or + * x-organization-id (for org scoped apis). + */ + fun bearerToken(bearerToken: String?) = apply { clientOptions.bearerToken(bearerToken) } + + /** Alias for calling [Builder.bearerToken] with `bearerToken.orElse(null)`. */ + fun bearerToken(bearerToken: Optional) = bearerToken(bearerToken.getOrNull()) + + fun organizationId(organizationId: String?) = apply { + clientOptions.organizationId(organizationId) + } + + /** Alias for calling [Builder.organizationId] with `organizationId.orElse(null)`. */ + fun organizationId(organizationId: Optional) = + organizationId(organizationId.getOrNull()) + + fun headers(headers: Headers) = apply { clientOptions.headers(headers) } + + fun headers(headers: Map>) = apply { + clientOptions.headers(headers) + } + + fun putHeader(name: String, value: String) = apply { clientOptions.putHeader(name, value) } + + fun putHeaders(name: String, values: Iterable) = apply { + clientOptions.putHeaders(name, values) + } + + fun putAllHeaders(headers: Headers) = apply { clientOptions.putAllHeaders(headers) } + + fun putAllHeaders(headers: Map>) = apply { + clientOptions.putAllHeaders(headers) + } + + fun replaceHeaders(name: String, value: String) = apply { + clientOptions.replaceHeaders(name, value) + } + + fun replaceHeaders(name: String, values: Iterable) = apply { + clientOptions.replaceHeaders(name, values) + } + + fun replaceAllHeaders(headers: Headers) = apply { clientOptions.replaceAllHeaders(headers) } + + fun replaceAllHeaders(headers: Map>) = apply { + clientOptions.replaceAllHeaders(headers) + } + + fun removeHeaders(name: String) = apply { clientOptions.removeHeaders(name) } + + fun removeAllHeaders(names: Set) = apply { clientOptions.removeAllHeaders(names) } + + fun queryParams(queryParams: QueryParams) = apply { clientOptions.queryParams(queryParams) } + + fun queryParams(queryParams: Map>) = apply { + clientOptions.queryParams(queryParams) + } + + fun putQueryParam(key: String, value: String) = apply { + clientOptions.putQueryParam(key, value) + } + + fun putQueryParams(key: String, values: Iterable) = apply { + clientOptions.putQueryParams(key, values) + } + + fun putAllQueryParams(queryParams: QueryParams) = apply { + clientOptions.putAllQueryParams(queryParams) + } + + fun putAllQueryParams(queryParams: Map>) = apply { + clientOptions.putAllQueryParams(queryParams) + } + + fun replaceQueryParams(key: String, value: String) = apply { + clientOptions.replaceQueryParams(key, value) + } + + fun replaceQueryParams(key: String, values: Iterable) = apply { + clientOptions.replaceQueryParams(key, values) + } + + fun replaceAllQueryParams(queryParams: QueryParams) = apply { + clientOptions.replaceAllQueryParams(queryParams) + } + + fun replaceAllQueryParams(queryParams: Map>) = apply { + clientOptions.replaceAllQueryParams(queryParams) + } + + fun removeQueryParams(key: String) = apply { clientOptions.removeQueryParams(key) } + + fun removeAllQueryParams(keys: Set) = apply { + clientOptions.removeAllQueryParams(keys) + } + + /** + * Updates configuration using system properties and environment variables. + * + * @see ClientOptions.Builder.fromEnv + */ + fun fromEnv() = apply { clientOptions.fromEnv() } + + /** + * Returns an immutable instance of [LangsmithApiClient]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LangsmithApiClient = + LangsmithApiClientImpl( + clientOptions + .httpClient( + OkHttpClient.builder() + .timeout(clientOptions.timeout()) + .proxy(proxy) + .sslSocketFactory(sslSocketFactory) + .trustManager(trustManager) + .hostnameVerifier(hostnameVerifier) + .build() + ) + .build() + ) + } +} diff --git a/langsmith-api-java-client-okhttp/src/main/kotlin/com/langsmith_api/api/client/okhttp/LangsmithApiOkHttpClientAsync.kt b/langsmith-api-java-client-okhttp/src/main/kotlin/com/langsmith_api/api/client/okhttp/LangsmithApiOkHttpClientAsync.kt new file mode 100644 index 00000000..8deb855e --- /dev/null +++ b/langsmith-api-java-client-okhttp/src/main/kotlin/com/langsmith_api/api/client/okhttp/LangsmithApiOkHttpClientAsync.kt @@ -0,0 +1,332 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.client.okhttp + +import com.fasterxml.jackson.databind.json.JsonMapper +import com.langsmith_api.api.client.LangsmithApiClientAsync +import com.langsmith_api.api.client.LangsmithApiClientAsyncImpl +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.Sleeper +import com.langsmith_api.api.core.Timeout +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.HttpClient +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.jsonMapper +import java.net.Proxy +import java.time.Clock +import java.time.Duration +import java.util.Optional +import javax.net.ssl.HostnameVerifier +import javax.net.ssl.SSLSocketFactory +import javax.net.ssl.X509TrustManager +import kotlin.jvm.optionals.getOrNull + +/** + * A class that allows building an instance of [LangsmithApiClientAsync] with [OkHttpClient] as the + * underlying [HttpClient]. + */ +class LangsmithApiOkHttpClientAsync private constructor() { + + companion object { + + /** Returns a mutable builder for constructing an instance of [LangsmithApiClientAsync]. */ + @JvmStatic fun builder() = Builder() + + /** + * Returns a client configured using system properties and environment variables. + * + * @see ClientOptions.Builder.fromEnv + */ + @JvmStatic fun fromEnv(): LangsmithApiClientAsync = builder().fromEnv().build() + } + + /** A builder for [LangsmithApiOkHttpClientAsync]. */ + class Builder internal constructor() { + + private var clientOptions: ClientOptions.Builder = ClientOptions.builder() + private var proxy: Proxy? = null + private var sslSocketFactory: SSLSocketFactory? = null + private var trustManager: X509TrustManager? = null + private var hostnameVerifier: HostnameVerifier? = null + + fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } + + /** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */ + fun proxy(proxy: Optional) = proxy(proxy.getOrNull()) + + /** + * The socket factory used to secure HTTPS connections. + * + * If this is set, then [trustManager] must also be set. + * + * If unset, then the system default is used. Most applications should not call this method, + * and instead use the system default. The default include special optimizations that can be + * lost if the implementation is modified. + */ + fun sslSocketFactory(sslSocketFactory: SSLSocketFactory?) = apply { + this.sslSocketFactory = sslSocketFactory + } + + /** Alias for calling [Builder.sslSocketFactory] with `sslSocketFactory.orElse(null)`. */ + fun sslSocketFactory(sslSocketFactory: Optional) = + sslSocketFactory(sslSocketFactory.getOrNull()) + + /** + * The trust manager used to secure HTTPS connections. + * + * If this is set, then [sslSocketFactory] must also be set. + * + * If unset, then the system default is used. Most applications should not call this method, + * and instead use the system default. The default include special optimizations that can be + * lost if the implementation is modified. + */ + fun trustManager(trustManager: X509TrustManager?) = apply { + this.trustManager = trustManager + } + + /** Alias for calling [Builder.trustManager] with `trustManager.orElse(null)`. */ + fun trustManager(trustManager: Optional) = + trustManager(trustManager.getOrNull()) + + /** + * The verifier used to confirm that response certificates apply to requested hostnames for + * HTTPS connections. + * + * If unset, then a default hostname verifier is used. + */ + fun hostnameVerifier(hostnameVerifier: HostnameVerifier?) = apply { + this.hostnameVerifier = hostnameVerifier + } + + /** Alias for calling [Builder.hostnameVerifier] with `hostnameVerifier.orElse(null)`. */ + fun hostnameVerifier(hostnameVerifier: Optional) = + hostnameVerifier(hostnameVerifier.getOrNull()) + + /** + * Whether to throw an exception if any of the Jackson versions detected at runtime are + * incompatible with the SDK's minimum supported Jackson version (2.13.4). + * + * Defaults to true. Use extreme caution when disabling this option. There is no guarantee + * that the SDK will work correctly when using an incompatible Jackson version. + */ + fun checkJacksonVersionCompatibility(checkJacksonVersionCompatibility: Boolean) = apply { + clientOptions.checkJacksonVersionCompatibility(checkJacksonVersionCompatibility) + } + + /** + * The Jackson JSON mapper to use for serializing and deserializing JSON. + * + * Defaults to [com.langsmith_api.api.core.jsonMapper]. The default is usually sufficient + * and rarely needs to be overridden. + */ + fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } + + /** + * The interface to use for delaying execution, like during retries. + * + * This is primarily useful for using fake delays in tests. + * + * Defaults to real execution delays. + * + * This class takes ownership of the sleeper and closes it when closed. + */ + fun sleeper(sleeper: Sleeper) = apply { clientOptions.sleeper(sleeper) } + + /** + * The clock to use for operations that require timing, like retries. + * + * This is primarily useful for using a fake clock in tests. + * + * Defaults to [Clock.systemUTC]. + */ + fun clock(clock: Clock) = apply { clientOptions.clock(clock) } + + /** + * The base URL to use for every request. + * + * Defaults to the production environment: `https://api.example.com`. + */ + fun baseUrl(baseUrl: String?) = apply { clientOptions.baseUrl(baseUrl) } + + /** Alias for calling [Builder.baseUrl] with `baseUrl.orElse(null)`. */ + fun baseUrl(baseUrl: Optional) = baseUrl(baseUrl.getOrNull()) + + /** + * Whether to call `validate` on every response before returning it. + * + * Defaults to false, which means the shape of the response will not be validated upfront. + * Instead, validation will only occur for the parts of the response that are accessed. + */ + fun responseValidation(responseValidation: Boolean) = apply { + clientOptions.responseValidation(responseValidation) + } + + /** + * Sets the maximum time allowed for various parts of an HTTP call's lifecycle, excluding + * retries. + * + * Defaults to [Timeout.default]. + */ + fun timeout(timeout: Timeout) = apply { clientOptions.timeout(timeout) } + + /** + * Sets the maximum time allowed for a complete HTTP call, not including retries. + * + * See [Timeout.request] for more details. + * + * For fine-grained control, pass a [Timeout] object. + */ + fun timeout(timeout: Duration) = apply { clientOptions.timeout(timeout) } + + /** + * The maximum number of times to retry failed requests, with a short exponential backoff + * between requests. + * + * Only the following error types are retried: + * - Connection errors (for example, due to a network connectivity problem) + * - 408 Request Timeout + * - 409 Conflict + * - 429 Rate Limit + * - 5xx Internal + * + * The API may also explicitly instruct the SDK to retry or not retry a request. + * + * Defaults to 2. + */ + fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } + + fun apiKey(apiKey: String?) = apply { clientOptions.apiKey(apiKey) } + + /** Alias for calling [Builder.apiKey] with `apiKey.orElse(null)`. */ + fun apiKey(apiKey: Optional) = apiKey(apiKey.getOrNull()) + + fun tenantId(tenantId: String?) = apply { clientOptions.tenantId(tenantId) } + + /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ + fun tenantId(tenantId: Optional) = tenantId(tenantId.getOrNull()) + + /** + * Bearer tokens are used to authenticate from the UI. Must also specify x-tenant-id or + * x-organization-id (for org scoped apis). + */ + fun bearerToken(bearerToken: String?) = apply { clientOptions.bearerToken(bearerToken) } + + /** Alias for calling [Builder.bearerToken] with `bearerToken.orElse(null)`. */ + fun bearerToken(bearerToken: Optional) = bearerToken(bearerToken.getOrNull()) + + fun organizationId(organizationId: String?) = apply { + clientOptions.organizationId(organizationId) + } + + /** Alias for calling [Builder.organizationId] with `organizationId.orElse(null)`. */ + fun organizationId(organizationId: Optional) = + organizationId(organizationId.getOrNull()) + + fun headers(headers: Headers) = apply { clientOptions.headers(headers) } + + fun headers(headers: Map>) = apply { + clientOptions.headers(headers) + } + + fun putHeader(name: String, value: String) = apply { clientOptions.putHeader(name, value) } + + fun putHeaders(name: String, values: Iterable) = apply { + clientOptions.putHeaders(name, values) + } + + fun putAllHeaders(headers: Headers) = apply { clientOptions.putAllHeaders(headers) } + + fun putAllHeaders(headers: Map>) = apply { + clientOptions.putAllHeaders(headers) + } + + fun replaceHeaders(name: String, value: String) = apply { + clientOptions.replaceHeaders(name, value) + } + + fun replaceHeaders(name: String, values: Iterable) = apply { + clientOptions.replaceHeaders(name, values) + } + + fun replaceAllHeaders(headers: Headers) = apply { clientOptions.replaceAllHeaders(headers) } + + fun replaceAllHeaders(headers: Map>) = apply { + clientOptions.replaceAllHeaders(headers) + } + + fun removeHeaders(name: String) = apply { clientOptions.removeHeaders(name) } + + fun removeAllHeaders(names: Set) = apply { clientOptions.removeAllHeaders(names) } + + fun queryParams(queryParams: QueryParams) = apply { clientOptions.queryParams(queryParams) } + + fun queryParams(queryParams: Map>) = apply { + clientOptions.queryParams(queryParams) + } + + fun putQueryParam(key: String, value: String) = apply { + clientOptions.putQueryParam(key, value) + } + + fun putQueryParams(key: String, values: Iterable) = apply { + clientOptions.putQueryParams(key, values) + } + + fun putAllQueryParams(queryParams: QueryParams) = apply { + clientOptions.putAllQueryParams(queryParams) + } + + fun putAllQueryParams(queryParams: Map>) = apply { + clientOptions.putAllQueryParams(queryParams) + } + + fun replaceQueryParams(key: String, value: String) = apply { + clientOptions.replaceQueryParams(key, value) + } + + fun replaceQueryParams(key: String, values: Iterable) = apply { + clientOptions.replaceQueryParams(key, values) + } + + fun replaceAllQueryParams(queryParams: QueryParams) = apply { + clientOptions.replaceAllQueryParams(queryParams) + } + + fun replaceAllQueryParams(queryParams: Map>) = apply { + clientOptions.replaceAllQueryParams(queryParams) + } + + fun removeQueryParams(key: String) = apply { clientOptions.removeQueryParams(key) } + + fun removeAllQueryParams(keys: Set) = apply { + clientOptions.removeAllQueryParams(keys) + } + + /** + * Updates configuration using system properties and environment variables. + * + * @see ClientOptions.Builder.fromEnv + */ + fun fromEnv() = apply { clientOptions.fromEnv() } + + /** + * Returns an immutable instance of [LangsmithApiClientAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LangsmithApiClientAsync = + LangsmithApiClientAsyncImpl( + clientOptions + .httpClient( + OkHttpClient.builder() + .timeout(clientOptions.timeout()) + .proxy(proxy) + .sslSocketFactory(sslSocketFactory) + .trustManager(trustManager) + .hostnameVerifier(hostnameVerifier) + .build() + ) + .build() + ) + } +} diff --git a/langsmith-api-java-client-okhttp/src/main/kotlin/com/langsmith_api/api/client/okhttp/OkHttpClient.kt b/langsmith-api-java-client-okhttp/src/main/kotlin/com/langsmith_api/api/client/okhttp/OkHttpClient.kt new file mode 100644 index 00000000..a91f3508 --- /dev/null +++ b/langsmith-api-java-client-okhttp/src/main/kotlin/com/langsmith_api/api/client/okhttp/OkHttpClient.kt @@ -0,0 +1,251 @@ +package com.langsmith_api.api.client.okhttp + +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.Timeout +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.HttpClient +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpRequestBody +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.errors.LangsmithApiIoException +import java.io.IOException +import java.io.InputStream +import java.net.Proxy +import java.time.Duration +import java.util.concurrent.CompletableFuture +import javax.net.ssl.HostnameVerifier +import javax.net.ssl.SSLSocketFactory +import javax.net.ssl.X509TrustManager +import okhttp3.Call +import okhttp3.Callback +import okhttp3.HttpUrl.Companion.toHttpUrl +import okhttp3.MediaType +import okhttp3.MediaType.Companion.toMediaType +import okhttp3.Request +import okhttp3.RequestBody +import okhttp3.RequestBody.Companion.toRequestBody +import okhttp3.Response +import okhttp3.logging.HttpLoggingInterceptor +import okio.BufferedSink + +class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpClient) : + HttpClient { + + override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { + val call = newCall(request, requestOptions) + + return try { + call.execute().toResponse() + } catch (e: IOException) { + throw LangsmithApiIoException("Request failed", e) + } finally { + request.body?.close() + } + } + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture { + val future = CompletableFuture() + + request.body?.run { future.whenComplete { _, _ -> close() } } + + newCall(request, requestOptions) + .enqueue( + object : Callback { + override fun onResponse(call: Call, response: Response) { + future.complete(response.toResponse()) + } + + override fun onFailure(call: Call, e: IOException) { + future.completeExceptionally(LangsmithApiIoException("Request failed", e)) + } + } + ) + + return future + } + + override fun close() { + okHttpClient.dispatcher.executorService.shutdown() + okHttpClient.connectionPool.evictAll() + okHttpClient.cache?.close() + } + + private fun newCall(request: HttpRequest, requestOptions: RequestOptions): Call { + val clientBuilder = okHttpClient.newBuilder() + + val logLevel = + when (System.getenv("LANGSMITH_API_LOG")?.lowercase()) { + "info" -> HttpLoggingInterceptor.Level.BASIC + "debug" -> HttpLoggingInterceptor.Level.BODY + else -> null + } + if (logLevel != null) { + clientBuilder.addNetworkInterceptor( + HttpLoggingInterceptor().setLevel(logLevel).apply { + redactHeader("X-API-Key") + redactHeader("X-Tenant-Id") + redactHeader("Authorization") + redactHeader("X-Organization-Id") + } + ) + } + + requestOptions.timeout?.let { + clientBuilder + .connectTimeout(it.connect()) + .readTimeout(it.read()) + .writeTimeout(it.write()) + .callTimeout(it.request()) + } + + val client = clientBuilder.build() + return client.newCall(request.toRequest(client)) + } + + private fun HttpRequest.toRequest(client: okhttp3.OkHttpClient): Request { + var body: RequestBody? = body?.toRequestBody() + if (body == null && requiresBody(method)) { + body = "".toRequestBody() + } + + val builder = Request.Builder().url(toUrl()).method(method.name, body) + headers.names().forEach { name -> + headers.values(name).forEach { builder.header(name, it) } + } + + if ( + !headers.names().contains("X-Stainless-Read-Timeout") && client.readTimeoutMillis != 0 + ) { + builder.header( + "X-Stainless-Read-Timeout", + Duration.ofMillis(client.readTimeoutMillis.toLong()).seconds.toString(), + ) + } + if (!headers.names().contains("X-Stainless-Timeout") && client.callTimeoutMillis != 0) { + builder.header( + "X-Stainless-Timeout", + Duration.ofMillis(client.callTimeoutMillis.toLong()).seconds.toString(), + ) + } + + return builder.build() + } + + /** `OkHttpClient` always requires a request body for some methods. */ + private fun requiresBody(method: HttpMethod): Boolean = + when (method) { + HttpMethod.POST, + HttpMethod.PUT, + HttpMethod.PATCH -> true + else -> false + } + + private fun HttpRequest.toUrl(): String { + val builder = baseUrl.toHttpUrl().newBuilder() + pathSegments.forEach(builder::addPathSegment) + queryParams.keys().forEach { key -> + queryParams.values(key).forEach { builder.addQueryParameter(key, it) } + } + + return builder.toString() + } + + private fun HttpRequestBody.toRequestBody(): RequestBody { + val mediaType = contentType()?.toMediaType() + val length = contentLength() + + return object : RequestBody() { + override fun contentType(): MediaType? = mediaType + + override fun contentLength(): Long = length + + override fun isOneShot(): Boolean = !repeatable() + + override fun writeTo(sink: BufferedSink) = writeTo(sink.outputStream()) + } + } + + private fun Response.toResponse(): HttpResponse { + val headers = headers.toHeaders() + + return object : HttpResponse { + override fun statusCode(): Int = code + + override fun headers(): Headers = headers + + override fun body(): InputStream = body!!.byteStream() + + override fun close() = body!!.close() + } + } + + private fun okhttp3.Headers.toHeaders(): Headers { + val headersBuilder = Headers.builder() + forEach { (name, value) -> headersBuilder.put(name, value) } + return headersBuilder.build() + } + + companion object { + @JvmStatic fun builder() = Builder() + } + + class Builder internal constructor() { + + private var timeout: Timeout = Timeout.default() + private var proxy: Proxy? = null + private var sslSocketFactory: SSLSocketFactory? = null + private var trustManager: X509TrustManager? = null + private var hostnameVerifier: HostnameVerifier? = null + + fun timeout(timeout: Timeout) = apply { this.timeout = timeout } + + fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) + + fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } + + fun sslSocketFactory(sslSocketFactory: SSLSocketFactory?) = apply { + this.sslSocketFactory = sslSocketFactory + } + + fun trustManager(trustManager: X509TrustManager?) = apply { + this.trustManager = trustManager + } + + fun hostnameVerifier(hostnameVerifier: HostnameVerifier?) = apply { + this.hostnameVerifier = hostnameVerifier + } + + fun build(): OkHttpClient = + OkHttpClient( + okhttp3.OkHttpClient.Builder() + .connectTimeout(timeout.connect()) + .readTimeout(timeout.read()) + .writeTimeout(timeout.write()) + .callTimeout(timeout.request()) + .proxy(proxy) + .apply { + val sslSocketFactory = sslSocketFactory + val trustManager = trustManager + if (sslSocketFactory != null && trustManager != null) { + sslSocketFactory(sslSocketFactory, trustManager) + } else { + check((sslSocketFactory != null) == (trustManager != null)) { + "Both or none of `sslSocketFactory` and `trustManager` must be set, but only one was set" + } + } + + hostnameVerifier?.let(::hostnameVerifier) + } + .build() + .apply { + // We usually make all our requests to the same host so it makes sense to + // raise the per-host limit to the overall limit. + dispatcher.maxRequestsPerHost = dispatcher.maxRequests + } + ) + } +} diff --git a/langsmith-api-java-core/build.gradle.kts b/langsmith-api-java-core/build.gradle.kts new file mode 100644 index 00000000..d4ccd9b9 --- /dev/null +++ b/langsmith-api-java-core/build.gradle.kts @@ -0,0 +1,41 @@ +plugins { + id("langsmith-api.kotlin") + id("langsmith-api.publish") +} + +configurations.all { + resolutionStrategy { + // Compile and test against a lower Jackson version to ensure we're compatible with it. + // We publish with a higher version (see below) to ensure users depend on a secure version by default. + force("com.fasterxml.jackson.core:jackson-core:2.13.4") + force("com.fasterxml.jackson.core:jackson-databind:2.13.4") + force("com.fasterxml.jackson.core:jackson-annotations:2.13.4") + force("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.13.4") + force("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.4") + force("com.fasterxml.jackson.module:jackson-module-kotlin:2.13.4") + } +} + +dependencies { + api("com.fasterxml.jackson.core:jackson-core:2.18.2") + api("com.fasterxml.jackson.core:jackson-databind:2.18.2") + api("com.google.errorprone:error_prone_annotations:2.33.0") + + implementation("com.fasterxml.jackson.core:jackson-annotations:2.18.2") + implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.18.2") + implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.2") + implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.18.2") + implementation("org.apache.httpcomponents.core5:httpcore5:5.2.4") + implementation("org.apache.httpcomponents.client5:httpclient5:5.3.1") + + testImplementation(kotlin("test")) + testImplementation(project(":langsmith-api-java-client-okhttp")) + testImplementation("com.github.tomakehurst:wiremock-jre8:2.35.2") + testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3") + testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.3") + testImplementation("org.junit-pioneer:junit-pioneer:1.9.1") + testImplementation("org.mockito:mockito-core:5.14.2") + testImplementation("org.mockito:mockito-junit-jupiter:5.14.2") + testImplementation("org.mockito.kotlin:mockito-kotlin:4.1.0") +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/client/LangsmithApiClient.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/client/LangsmithApiClient.kt new file mode 100644 index 00000000..cb80b8fd --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/client/LangsmithApiClient.kt @@ -0,0 +1,96 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.client + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.services.blocking.ApiService +import com.langsmith_api.api.services.blocking.DatasetService +import com.langsmith_api.api.services.blocking.FeedbackService +import com.langsmith_api.api.services.blocking.PlatformService +import com.langsmith_api.api.services.blocking.RunService +import java.util.function.Consumer + +/** + * A client for interacting with the Langsmith API REST API synchronously. You can also switch to + * asynchronous execution via the [async] method. + * + * This client performs best when you create a single instance and reuse it for all interactions + * with the REST API. This is because each client holds its own connection pool and thread pools. + * Reusing connections and threads reduces latency and saves memory. The client also handles rate + * limiting per client. This means that creating and using multiple instances at the same time will + * not respect rate limits. + * + * The threads and connections that are held will be released automatically if they remain idle. But + * if you are writing an application that needs to aggressively release unused resources, then you + * may call [close]. + */ +interface LangsmithApiClient { + + /** + * Returns a version of this client that uses asynchronous execution. + * + * The returned client shares its resources, like its connection pool and thread pools, with + * this client. + */ + fun async(): LangsmithApiClientAsync + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): LangsmithApiClient + + fun api(): ApiService + + fun datasets(): DatasetService + + fun feedback(): FeedbackService + + fun runs(): RunService + + fun platform(): PlatformService + + /** + * Closes this client, relinquishing any underlying resources. + * + * This is purposefully not inherited from [AutoCloseable] because the client is long-lived and + * usually should not be synchronously closed via try-with-resources. + * + * It's also usually not necessary to call this method at all. the default HTTP client + * automatically releases threads and connections if they remain idle, but if you are writing an + * application that needs to aggressively release unused resources, then you may call this + * method. + */ + fun close() + + /** + * A view of [LangsmithApiClient] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): LangsmithApiClient.WithRawResponse + + fun api(): ApiService.WithRawResponse + + fun datasets(): DatasetService.WithRawResponse + + fun feedback(): FeedbackService.WithRawResponse + + fun runs(): RunService.WithRawResponse + + fun platform(): PlatformService.WithRawResponse + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/client/LangsmithApiClientAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/client/LangsmithApiClientAsync.kt new file mode 100644 index 00000000..a71eb6a4 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/client/LangsmithApiClientAsync.kt @@ -0,0 +1,97 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.client + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.services.async.ApiServiceAsync +import com.langsmith_api.api.services.async.DatasetServiceAsync +import com.langsmith_api.api.services.async.FeedbackServiceAsync +import com.langsmith_api.api.services.async.PlatformServiceAsync +import com.langsmith_api.api.services.async.RunServiceAsync +import java.util.function.Consumer + +/** + * A client for interacting with the Langsmith API REST API asynchronously. You can also switch to + * synchronous execution via the [sync] method. + * + * This client performs best when you create a single instance and reuse it for all interactions + * with the REST API. This is because each client holds its own connection pool and thread pools. + * Reusing connections and threads reduces latency and saves memory. The client also handles rate + * limiting per client. This means that creating and using multiple instances at the same time will + * not respect rate limits. + * + * The threads and connections that are held will be released automatically if they remain idle. But + * if you are writing an application that needs to aggressively release unused resources, then you + * may call [close]. + */ +interface LangsmithApiClientAsync { + + /** + * Returns a version of this client that uses synchronous execution. + * + * The returned client shares its resources, like its connection pool and thread pools, with + * this client. + */ + fun sync(): LangsmithApiClient + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): LangsmithApiClientAsync + + fun api(): ApiServiceAsync + + fun datasets(): DatasetServiceAsync + + fun feedback(): FeedbackServiceAsync + + fun runs(): RunServiceAsync + + fun platform(): PlatformServiceAsync + + /** + * Closes this client, relinquishing any underlying resources. + * + * This is purposefully not inherited from [AutoCloseable] because the client is long-lived and + * usually should not be synchronously closed via try-with-resources. + * + * It's also usually not necessary to call this method at all. the default HTTP client + * automatically releases threads and connections if they remain idle, but if you are writing an + * application that needs to aggressively release unused resources, then you may call this + * method. + */ + fun close() + + /** + * A view of [LangsmithApiClientAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): LangsmithApiClientAsync.WithRawResponse + + fun api(): ApiServiceAsync.WithRawResponse + + fun datasets(): DatasetServiceAsync.WithRawResponse + + fun feedback(): FeedbackServiceAsync.WithRawResponse + + fun runs(): RunServiceAsync.WithRawResponse + + fun platform(): PlatformServiceAsync.WithRawResponse + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/client/LangsmithApiClientAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/client/LangsmithApiClientAsyncImpl.kt new file mode 100644 index 00000000..1dc5f149 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/client/LangsmithApiClientAsyncImpl.kt @@ -0,0 +1,112 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.client + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.getPackageVersion +import com.langsmith_api.api.services.async.ApiServiceAsync +import com.langsmith_api.api.services.async.ApiServiceAsyncImpl +import com.langsmith_api.api.services.async.DatasetServiceAsync +import com.langsmith_api.api.services.async.DatasetServiceAsyncImpl +import com.langsmith_api.api.services.async.FeedbackServiceAsync +import com.langsmith_api.api.services.async.FeedbackServiceAsyncImpl +import com.langsmith_api.api.services.async.PlatformServiceAsync +import com.langsmith_api.api.services.async.PlatformServiceAsyncImpl +import com.langsmith_api.api.services.async.RunServiceAsync +import com.langsmith_api.api.services.async.RunServiceAsyncImpl +import java.util.function.Consumer + +class LangsmithApiClientAsyncImpl(private val clientOptions: ClientOptions) : + LangsmithApiClientAsync { + + private val clientOptionsWithUserAgent = + if (clientOptions.headers.names().contains("User-Agent")) clientOptions + else + clientOptions + .toBuilder() + .putHeader("User-Agent", "${javaClass.simpleName}/Java ${getPackageVersion()}") + .build() + + // Pass the original clientOptions so that this client sets its own User-Agent. + private val sync: LangsmithApiClient by lazy { LangsmithApiClientImpl(clientOptions) } + + private val withRawResponse: LangsmithApiClientAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val api: ApiServiceAsync by lazy { ApiServiceAsyncImpl(clientOptionsWithUserAgent) } + + private val datasets: DatasetServiceAsync by lazy { + DatasetServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val feedback: FeedbackServiceAsync by lazy { + FeedbackServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val runs: RunServiceAsync by lazy { RunServiceAsyncImpl(clientOptionsWithUserAgent) } + + private val platform: PlatformServiceAsync by lazy { + PlatformServiceAsyncImpl(clientOptionsWithUserAgent) + } + + override fun sync(): LangsmithApiClient = sync + + override fun withRawResponse(): LangsmithApiClientAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): LangsmithApiClientAsync = + LangsmithApiClientAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun api(): ApiServiceAsync = api + + override fun datasets(): DatasetServiceAsync = datasets + + override fun feedback(): FeedbackServiceAsync = feedback + + override fun runs(): RunServiceAsync = runs + + override fun platform(): PlatformServiceAsync = platform + + override fun close() = clientOptions.close() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + LangsmithApiClientAsync.WithRawResponse { + + private val api: ApiServiceAsync.WithRawResponse by lazy { + ApiServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val datasets: DatasetServiceAsync.WithRawResponse by lazy { + DatasetServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val feedback: FeedbackServiceAsync.WithRawResponse by lazy { + FeedbackServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val runs: RunServiceAsync.WithRawResponse by lazy { + RunServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val platform: PlatformServiceAsync.WithRawResponse by lazy { + PlatformServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): LangsmithApiClientAsync.WithRawResponse = + LangsmithApiClientAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun api(): ApiServiceAsync.WithRawResponse = api + + override fun datasets(): DatasetServiceAsync.WithRawResponse = datasets + + override fun feedback(): FeedbackServiceAsync.WithRawResponse = feedback + + override fun runs(): RunServiceAsync.WithRawResponse = runs + + override fun platform(): PlatformServiceAsync.WithRawResponse = platform + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/client/LangsmithApiClientImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/client/LangsmithApiClientImpl.kt new file mode 100644 index 00000000..a8a38880 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/client/LangsmithApiClientImpl.kt @@ -0,0 +1,111 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.client + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.getPackageVersion +import com.langsmith_api.api.services.blocking.ApiService +import com.langsmith_api.api.services.blocking.ApiServiceImpl +import com.langsmith_api.api.services.blocking.DatasetService +import com.langsmith_api.api.services.blocking.DatasetServiceImpl +import com.langsmith_api.api.services.blocking.FeedbackService +import com.langsmith_api.api.services.blocking.FeedbackServiceImpl +import com.langsmith_api.api.services.blocking.PlatformService +import com.langsmith_api.api.services.blocking.PlatformServiceImpl +import com.langsmith_api.api.services.blocking.RunService +import com.langsmith_api.api.services.blocking.RunServiceImpl +import java.util.function.Consumer + +class LangsmithApiClientImpl(private val clientOptions: ClientOptions) : LangsmithApiClient { + + private val clientOptionsWithUserAgent = + if (clientOptions.headers.names().contains("User-Agent")) clientOptions + else + clientOptions + .toBuilder() + .putHeader("User-Agent", "${javaClass.simpleName}/Java ${getPackageVersion()}") + .build() + + // Pass the original clientOptions so that this client sets its own User-Agent. + private val async: LangsmithApiClientAsync by lazy { + LangsmithApiClientAsyncImpl(clientOptions) + } + + private val withRawResponse: LangsmithApiClient.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val api: ApiService by lazy { ApiServiceImpl(clientOptionsWithUserAgent) } + + private val datasets: DatasetService by lazy { DatasetServiceImpl(clientOptionsWithUserAgent) } + + private val feedback: FeedbackService by lazy { + FeedbackServiceImpl(clientOptionsWithUserAgent) + } + + private val runs: RunService by lazy { RunServiceImpl(clientOptionsWithUserAgent) } + + private val platform: PlatformService by lazy { + PlatformServiceImpl(clientOptionsWithUserAgent) + } + + override fun async(): LangsmithApiClientAsync = async + + override fun withRawResponse(): LangsmithApiClient.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): LangsmithApiClient = + LangsmithApiClientImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun api(): ApiService = api + + override fun datasets(): DatasetService = datasets + + override fun feedback(): FeedbackService = feedback + + override fun runs(): RunService = runs + + override fun platform(): PlatformService = platform + + override fun close() = clientOptions.close() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + LangsmithApiClient.WithRawResponse { + + private val api: ApiService.WithRawResponse by lazy { + ApiServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val datasets: DatasetService.WithRawResponse by lazy { + DatasetServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val feedback: FeedbackService.WithRawResponse by lazy { + FeedbackServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val runs: RunService.WithRawResponse by lazy { + RunServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val platform: PlatformService.WithRawResponse by lazy { + PlatformServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): LangsmithApiClient.WithRawResponse = + LangsmithApiClientImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun api(): ApiService.WithRawResponse = api + + override fun datasets(): DatasetService.WithRawResponse = datasets + + override fun feedback(): FeedbackService.WithRawResponse = feedback + + override fun runs(): RunService.WithRawResponse = runs + + override fun platform(): PlatformService.WithRawResponse = platform + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/BaseDeserializer.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/BaseDeserializer.kt new file mode 100644 index 00000000..ee90eaa9 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/BaseDeserializer.kt @@ -0,0 +1,44 @@ +package com.langsmith_api.api.core + +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 +import com.fasterxml.jackson.databind.DeserializationContext +import com.fasterxml.jackson.databind.JavaType +import com.fasterxml.jackson.databind.JsonDeserializer +import com.fasterxml.jackson.databind.JsonNode +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 { + + override fun createContextual( + context: DeserializationContext, + property: BeanProperty?, + ): JsonDeserializer { + return this + } + + override fun deserialize(parser: JsonParser, context: DeserializationContext): T { + return parser.codec.deserialize(parser.readValueAsTree()) + } + + protected abstract fun ObjectCodec.deserialize(node: JsonNode): T + + protected fun ObjectCodec.tryDeserialize(node: JsonNode, type: TypeReference): T? = + try { + readValue(treeAsTokens(node), type) + } catch (e: Exception) { + null + } + + protected fun ObjectCodec.tryDeserialize(node: JsonNode, type: JavaType): T? = + try { + readValue(treeAsTokens(node), type) + } catch (e: Exception) { + null + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/BaseSerializer.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/BaseSerializer.kt new file mode 100644 index 00000000..4b31853b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/BaseSerializer.kt @@ -0,0 +1,6 @@ +package com.langsmith_api.api.core + +import com.fasterxml.jackson.databind.ser.std.StdSerializer +import kotlin.reflect.KClass + +abstract class BaseSerializer(type: KClass) : StdSerializer(type.java) diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/Check.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/Check.kt new file mode 100644 index 00000000..f0a09caf --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/Check.kt @@ -0,0 +1,96 @@ +@file:JvmName("Check") + +package com.langsmith_api.api.core + +import com.fasterxml.jackson.core.Version +import com.fasterxml.jackson.core.util.VersionUtil + +fun checkRequired(name: String, condition: Boolean) = + check(condition) { "`$name` is required, but was not set" } + +fun checkRequired(name: String, value: T?): T = + checkNotNull(value) { "`$name` is required, but was not set" } + +@JvmSynthetic +internal fun checkKnown(name: String, value: JsonField): T = + value.asKnown().orElseThrow { + IllegalStateException("`$name` is not a known type: ${value.javaClass.simpleName}") + } + +@JvmSynthetic +internal fun checkKnown(name: String, value: MultipartField): T = + value.value.asKnown().orElseThrow { + IllegalStateException("`$name` is not a known type: ${value.javaClass.simpleName}") + } + +@JvmSynthetic +internal fun checkLength(name: String, value: String, length: Int): String = + value.also { + check(it.length == length) { "`$name` must have length $length, but was ${it.length}" } + } + +@JvmSynthetic +internal fun checkMinLength(name: String, value: String, minLength: Int): String = + value.also { + check(it.length >= minLength) { + if (minLength == 1) "`$name` must be non-empty, but was empty" + else "`$name` must have at least length $minLength, but was ${it.length}" + } + } + +@JvmSynthetic +internal fun checkMaxLength(name: String, value: String, maxLength: Int): String = + value.also { + check(it.length <= maxLength) { + "`$name` must have at most length $maxLength, but was ${it.length}" + } + } + +@JvmSynthetic +internal fun checkJacksonVersionCompatibility() { + val incompatibleJacksonVersions = + RUNTIME_JACKSON_VERSIONS.mapNotNull { + val badVersionReason = BAD_JACKSON_VERSIONS[it.toString()] + when { + it.majorVersion != MINIMUM_JACKSON_VERSION.majorVersion -> + it to "incompatible major version" + it.minorVersion < MINIMUM_JACKSON_VERSION.minorVersion -> + it to "minor version too low" + it.minorVersion == MINIMUM_JACKSON_VERSION.minorVersion && + it.patchLevel < MINIMUM_JACKSON_VERSION.patchLevel -> + it to "patch version too low" + badVersionReason != null -> it to badVersionReason + else -> null + } + } + check(incompatibleJacksonVersions.isEmpty()) { + """ +This SDK requires a minimum Jackson version of $MINIMUM_JACKSON_VERSION, but the following incompatible Jackson versions were detected at runtime: + +${incompatibleJacksonVersions.asSequence().map { (version, incompatibilityReason) -> + "- `${version.toFullString().replace("/", ":")}` ($incompatibilityReason)" +}.joinToString("\n")} + +This can happen if you are either: +1. Directly depending on different Jackson versions +2. Depending on some library that depends on different Jackson versions, potentially transitively + +Double-check that you are depending on compatible Jackson versions. + +See https://www.github.com/stainless-sdks/langsmith-api-java#jackson for more information. + """ + .trimIndent() + } +} + +private val MINIMUM_JACKSON_VERSION: Version = VersionUtil.parseVersion("2.13.4", null, null) +private val BAD_JACKSON_VERSIONS: Map = + mapOf("2.18.1" to "due to https://github.com/FasterXML/jackson-databind/issues/4639") +private val RUNTIME_JACKSON_VERSIONS: List = + listOf( + com.fasterxml.jackson.core.json.PackageVersion.VERSION, + com.fasterxml.jackson.databind.cfg.PackageVersion.VERSION, + com.fasterxml.jackson.datatype.jdk8.PackageVersion.VERSION, + com.fasterxml.jackson.datatype.jsr310.PackageVersion.VERSION, + com.fasterxml.jackson.module.kotlin.PackageVersion.VERSION, + ) diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/ClientOptions.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/ClientOptions.kt new file mode 100644 index 00000000..6e413f30 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/ClientOptions.kt @@ -0,0 +1,519 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.core + +import com.fasterxml.jackson.databind.json.JsonMapper +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.HttpClient +import com.langsmith_api.api.core.http.PhantomReachableClosingHttpClient +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.http.RetryingHttpClient +import java.time.Clock +import java.time.Duration +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** A class representing the SDK client configuration. */ +class ClientOptions +private constructor( + private val originalHttpClient: HttpClient, + /** + * The HTTP client to use in the SDK. + * + * Use the one published in `langsmith-api-java-client-okhttp` or implement your own. + * + * This class takes ownership of the client and closes it when closed. + */ + @get:JvmName("httpClient") val httpClient: HttpClient, + /** + * Whether to throw an exception if any of the Jackson versions detected at runtime are + * incompatible with the SDK's minimum supported Jackson version (2.13.4). + * + * Defaults to true. Use extreme caution when disabling this option. There is no guarantee that + * the SDK will work correctly when using an incompatible Jackson version. + */ + @get:JvmName("checkJacksonVersionCompatibility") val checkJacksonVersionCompatibility: Boolean, + /** + * The Jackson JSON mapper to use for serializing and deserializing JSON. + * + * Defaults to [com.langsmith_api.api.core.jsonMapper]. The default is usually sufficient and + * rarely needs to be overridden. + */ + @get:JvmName("jsonMapper") val jsonMapper: JsonMapper, + /** + * The interface to use for delaying execution, like during retries. + * + * This is primarily useful for using fake delays in tests. + * + * Defaults to real execution delays. + * + * This class takes ownership of the sleeper and closes it when closed. + */ + @get:JvmName("sleeper") val sleeper: Sleeper, + /** + * The clock to use for operations that require timing, like retries. + * + * This is primarily useful for using a fake clock in tests. + * + * Defaults to [Clock.systemUTC]. + */ + @get:JvmName("clock") val clock: Clock, + private val baseUrl: String?, + /** Headers to send with the request. */ + @get:JvmName("headers") val headers: Headers, + /** Query params to send with the request. */ + @get:JvmName("queryParams") val queryParams: QueryParams, + /** + * Whether to call `validate` on every response before returning it. + * + * Defaults to false, which means the shape of the response will not be validated upfront. + * Instead, validation will only occur for the parts of the response that are accessed. + */ + @get:JvmName("responseValidation") val responseValidation: Boolean, + /** + * Sets the maximum time allowed for various parts of an HTTP call's lifecycle, excluding + * retries. + * + * Defaults to [Timeout.default]. + */ + @get:JvmName("timeout") val timeout: Timeout, + /** + * The maximum number of times to retry failed requests, with a short exponential backoff + * between requests. + * + * Only the following error types are retried: + * - Connection errors (for example, due to a network connectivity problem) + * - 408 Request Timeout + * - 409 Conflict + * - 429 Rate Limit + * - 5xx Internal + * + * The API may also explicitly instruct the SDK to retry or not retry a request. + * + * Defaults to 2. + */ + @get:JvmName("maxRetries") val maxRetries: Int, + private val apiKey: String?, + private val tenantId: String?, + private val bearerToken: String?, + private val organizationId: String?, +) { + + init { + if (checkJacksonVersionCompatibility) { + checkJacksonVersionCompatibility() + } + } + + /** + * The base URL to use for every request. + * + * Defaults to the production environment: `https://api.example.com`. + */ + fun baseUrl(): String = baseUrl ?: PRODUCTION_URL + + fun apiKey(): Optional = Optional.ofNullable(apiKey) + + fun tenantId(): Optional = Optional.ofNullable(tenantId) + + /** + * Bearer tokens are used to authenticate from the UI. Must also specify x-tenant-id or + * x-organization-id (for org scoped apis). + */ + fun bearerToken(): Optional = Optional.ofNullable(bearerToken) + + fun organizationId(): Optional = Optional.ofNullable(organizationId) + + fun toBuilder() = Builder().from(this) + + companion object { + + const val PRODUCTION_URL = "https://api.example.com" + + /** + * Returns a mutable builder for constructing an instance of [ClientOptions]. + * + * The following fields are required: + * ```java + * .httpClient() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns options configured using system properties and environment variables. + * + * @see Builder.fromEnv + */ + @JvmStatic fun fromEnv(): ClientOptions = builder().fromEnv().build() + } + + /** A builder for [ClientOptions]. */ + class Builder internal constructor() { + + private var httpClient: HttpClient? = null + private var checkJacksonVersionCompatibility: Boolean = true + private var jsonMapper: JsonMapper = jsonMapper() + private var sleeper: Sleeper? = null + private var clock: Clock = Clock.systemUTC() + private var baseUrl: String? = null + private var headers: Headers.Builder = Headers.builder() + private var queryParams: QueryParams.Builder = QueryParams.builder() + private var responseValidation: Boolean = false + private var timeout: Timeout = Timeout.default() + private var maxRetries: Int = 2 + private var apiKey: String? = null + private var tenantId: String? = null + private var bearerToken: String? = null + private var organizationId: String? = null + + @JvmSynthetic + internal fun from(clientOptions: ClientOptions) = apply { + httpClient = clientOptions.originalHttpClient + checkJacksonVersionCompatibility = clientOptions.checkJacksonVersionCompatibility + jsonMapper = clientOptions.jsonMapper + sleeper = clientOptions.sleeper + clock = clientOptions.clock + baseUrl = clientOptions.baseUrl + headers = clientOptions.headers.toBuilder() + queryParams = clientOptions.queryParams.toBuilder() + responseValidation = clientOptions.responseValidation + timeout = clientOptions.timeout + maxRetries = clientOptions.maxRetries + apiKey = clientOptions.apiKey + tenantId = clientOptions.tenantId + bearerToken = clientOptions.bearerToken + organizationId = clientOptions.organizationId + } + + /** + * The HTTP client to use in the SDK. + * + * Use the one published in `langsmith-api-java-client-okhttp` or implement your own. + * + * This class takes ownership of the client and closes it when closed. + */ + fun httpClient(httpClient: HttpClient) = apply { + this.httpClient = PhantomReachableClosingHttpClient(httpClient) + } + + /** + * Whether to throw an exception if any of the Jackson versions detected at runtime are + * incompatible with the SDK's minimum supported Jackson version (2.13.4). + * + * Defaults to true. Use extreme caution when disabling this option. There is no guarantee + * that the SDK will work correctly when using an incompatible Jackson version. + */ + fun checkJacksonVersionCompatibility(checkJacksonVersionCompatibility: Boolean) = apply { + this.checkJacksonVersionCompatibility = checkJacksonVersionCompatibility + } + + /** + * The Jackson JSON mapper to use for serializing and deserializing JSON. + * + * Defaults to [com.langsmith_api.api.core.jsonMapper]. The default is usually sufficient + * and rarely needs to be overridden. + */ + fun jsonMapper(jsonMapper: JsonMapper) = apply { this.jsonMapper = jsonMapper } + + /** + * The interface to use for delaying execution, like during retries. + * + * This is primarily useful for using fake delays in tests. + * + * Defaults to real execution delays. + * + * This class takes ownership of the sleeper and closes it when closed. + */ + fun sleeper(sleeper: Sleeper) = apply { this.sleeper = PhantomReachableSleeper(sleeper) } + + /** + * The clock to use for operations that require timing, like retries. + * + * This is primarily useful for using a fake clock in tests. + * + * Defaults to [Clock.systemUTC]. + */ + fun clock(clock: Clock) = apply { this.clock = clock } + + /** + * The base URL to use for every request. + * + * Defaults to the production environment: `https://api.example.com`. + */ + fun baseUrl(baseUrl: String?) = apply { this.baseUrl = baseUrl } + + /** Alias for calling [Builder.baseUrl] with `baseUrl.orElse(null)`. */ + fun baseUrl(baseUrl: Optional) = baseUrl(baseUrl.getOrNull()) + + /** + * Whether to call `validate` on every response before returning it. + * + * Defaults to false, which means the shape of the response will not be validated upfront. + * Instead, validation will only occur for the parts of the response that are accessed. + */ + fun responseValidation(responseValidation: Boolean) = apply { + this.responseValidation = responseValidation + } + + /** + * Sets the maximum time allowed for various parts of an HTTP call's lifecycle, excluding + * retries. + * + * Defaults to [Timeout.default]. + */ + fun timeout(timeout: Timeout) = apply { this.timeout = timeout } + + /** + * Sets the maximum time allowed for a complete HTTP call, not including retries. + * + * See [Timeout.request] for more details. + * + * For fine-grained control, pass a [Timeout] object. + */ + fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) + + /** + * The maximum number of times to retry failed requests, with a short exponential backoff + * between requests. + * + * Only the following error types are retried: + * - Connection errors (for example, due to a network connectivity problem) + * - 408 Request Timeout + * - 409 Conflict + * - 429 Rate Limit + * - 5xx Internal + * + * The API may also explicitly instruct the SDK to retry or not retry a request. + * + * Defaults to 2. + */ + fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } + + fun apiKey(apiKey: String?) = apply { this.apiKey = apiKey } + + /** Alias for calling [Builder.apiKey] with `apiKey.orElse(null)`. */ + fun apiKey(apiKey: Optional) = apiKey(apiKey.getOrNull()) + + fun tenantId(tenantId: String?) = apply { this.tenantId = tenantId } + + /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ + fun tenantId(tenantId: Optional) = tenantId(tenantId.getOrNull()) + + /** + * Bearer tokens are used to authenticate from the UI. Must also specify x-tenant-id or + * x-organization-id (for org scoped apis). + */ + fun bearerToken(bearerToken: String?) = apply { this.bearerToken = bearerToken } + + /** Alias for calling [Builder.bearerToken] with `bearerToken.orElse(null)`. */ + fun bearerToken(bearerToken: Optional) = bearerToken(bearerToken.getOrNull()) + + fun organizationId(organizationId: String?) = apply { this.organizationId = organizationId } + + /** Alias for calling [Builder.organizationId] with `organizationId.orElse(null)`. */ + fun organizationId(organizationId: Optional) = + organizationId(organizationId.getOrNull()) + + fun headers(headers: Headers) = apply { + this.headers.clear() + putAllHeaders(headers) + } + + fun headers(headers: Map>) = apply { + this.headers.clear() + putAllHeaders(headers) + } + + fun putHeader(name: String, value: String) = apply { headers.put(name, value) } + + fun putHeaders(name: String, values: Iterable) = apply { headers.put(name, values) } + + fun putAllHeaders(headers: Headers) = apply { this.headers.putAll(headers) } + + fun putAllHeaders(headers: Map>) = apply { + this.headers.putAll(headers) + } + + fun replaceHeaders(name: String, value: String) = apply { headers.replace(name, value) } + + fun replaceHeaders(name: String, values: Iterable) = apply { + headers.replace(name, values) + } + + fun replaceAllHeaders(headers: Headers) = apply { this.headers.replaceAll(headers) } + + fun replaceAllHeaders(headers: Map>) = apply { + this.headers.replaceAll(headers) + } + + fun removeHeaders(name: String) = apply { headers.remove(name) } + + fun removeAllHeaders(names: Set) = apply { headers.removeAll(names) } + + fun queryParams(queryParams: QueryParams) = apply { + this.queryParams.clear() + putAllQueryParams(queryParams) + } + + fun queryParams(queryParams: Map>) = apply { + this.queryParams.clear() + putAllQueryParams(queryParams) + } + + fun putQueryParam(key: String, value: String) = apply { queryParams.put(key, value) } + + fun putQueryParams(key: String, values: Iterable) = apply { + queryParams.put(key, values) + } + + fun putAllQueryParams(queryParams: QueryParams) = apply { + this.queryParams.putAll(queryParams) + } + + fun putAllQueryParams(queryParams: Map>) = apply { + this.queryParams.putAll(queryParams) + } + + fun replaceQueryParams(key: String, value: String) = apply { + queryParams.replace(key, value) + } + + fun replaceQueryParams(key: String, values: Iterable) = apply { + queryParams.replace(key, values) + } + + fun replaceAllQueryParams(queryParams: QueryParams) = apply { + this.queryParams.replaceAll(queryParams) + } + + fun replaceAllQueryParams(queryParams: Map>) = apply { + this.queryParams.replaceAll(queryParams) + } + + fun removeQueryParams(key: String) = apply { queryParams.remove(key) } + + fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) } + + fun timeout(): Timeout = timeout + + /** + * Updates configuration using system properties and environment variables. + * + * See this table for the available options: + * + * |Setter |System property |Environment variable |Required|Default value | + * |----------------|-----------------------------|-------------------------------|--------|---------------------------| + * |`apiKey` |`langsmithapi.apiKey` |`LANGSMITH_API_API_KEY` |false |- | + * |`tenantId` |`langsmithapi.tenantId` |`LANGSMITH_API_TENANT_ID` |false |- | + * |`bearerToken` |`langsmithapi.bearerToken` |`LANGSMITH_API_BEARER_TOKEN` |false |- | + * |`organizationId`|`langsmithapi.organizationId`|`LANGSMITH_API_ORGANIZATION_ID`|false |- | + * |`baseUrl` |`langsmithapi.baseUrl` |`LANGSMITH_API_BASE_URL` |true |`"https://api.example.com"`| + * + * System properties take precedence over environment variables. + */ + fun fromEnv() = apply { + (System.getProperty("langsmithapi.baseUrl") ?: System.getenv("LANGSMITH_API_BASE_URL")) + ?.let { baseUrl(it) } + (System.getProperty("langsmithapi.apiKey") ?: System.getenv("LANGSMITH_API_API_KEY")) + ?.let { apiKey(it) } + (System.getProperty("langsmithapi.tenantId") + ?: System.getenv("LANGSMITH_API_TENANT_ID")) + ?.let { tenantId(it) } + (System.getProperty("langsmithapi.bearerToken") + ?: System.getenv("LANGSMITH_API_BEARER_TOKEN")) + ?.let { bearerToken(it) } + (System.getProperty("langsmithapi.organizationId") + ?: System.getenv("LANGSMITH_API_ORGANIZATION_ID")) + ?.let { organizationId(it) } + } + + /** + * Returns an immutable instance of [ClientOptions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .httpClient() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ClientOptions { + val httpClient = checkRequired("httpClient", httpClient) + val sleeper = sleeper ?: PhantomReachableSleeper(DefaultSleeper()) + + val headers = Headers.builder() + val queryParams = QueryParams.builder() + headers.put("X-Stainless-Lang", "java") + headers.put("X-Stainless-Arch", getOsArch()) + headers.put("X-Stainless-OS", getOsName()) + headers.put("X-Stainless-OS-Version", getOsVersion()) + headers.put("X-Stainless-Package-Version", getPackageVersion()) + headers.put("X-Stainless-Runtime", "JRE") + headers.put("X-Stainless-Runtime-Version", getJavaVersion()) + apiKey?.let { + if (!it.isEmpty()) { + headers.put("X-API-Key", it) + } + } + tenantId?.let { + if (!it.isEmpty()) { + headers.put("X-Tenant-Id", it) + } + } + bearerToken?.let { + if (!it.isEmpty()) { + headers.put("Authorization", "Bearer $it") + } + } + organizationId?.let { + if (!it.isEmpty()) { + headers.put("X-Organization-Id", it) + } + } + headers.replaceAll(this.headers.build()) + queryParams.replaceAll(this.queryParams.build()) + + return ClientOptions( + httpClient, + RetryingHttpClient.builder() + .httpClient(httpClient) + .sleeper(sleeper) + .clock(clock) + .maxRetries(maxRetries) + .build(), + checkJacksonVersionCompatibility, + jsonMapper, + sleeper, + clock, + baseUrl, + headers.build(), + queryParams.build(), + responseValidation, + timeout, + maxRetries, + apiKey, + tenantId, + bearerToken, + organizationId, + ) + } + } + + /** + * Closes these client options, relinquishing any underlying resources. + * + * This is purposefully not inherited from [AutoCloseable] because the client options are + * long-lived and usually should not be synchronously closed via try-with-resources. + * + * It's also usually not necessary to call this method at all. the default client automatically + * releases threads and connections if they remain idle, but if you are writing an application + * that needs to aggressively release unused resources, then you may call this method. + */ + fun close() { + httpClient.close() + sleeper.close() + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/DefaultSleeper.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/DefaultSleeper.kt new file mode 100644 index 00000000..add76517 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/DefaultSleeper.kt @@ -0,0 +1,28 @@ +package com.langsmith_api.api.core + +import java.time.Duration +import java.util.Timer +import java.util.TimerTask +import java.util.concurrent.CompletableFuture + +class DefaultSleeper : Sleeper { + + private val timer = Timer("DefaultSleeper", true) + + override fun sleep(duration: Duration) = Thread.sleep(duration.toMillis()) + + override fun sleepAsync(duration: Duration): CompletableFuture { + val future = CompletableFuture() + timer.schedule( + object : TimerTask() { + override fun run() { + future.complete(null) + } + }, + duration.toMillis(), + ) + return future + } + + override fun close() = timer.cancel() +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/ObjectMappers.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/ObjectMappers.kt new file mode 100644 index 00000000..e1b57f9a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/ObjectMappers.kt @@ -0,0 +1,167 @@ +@file:JvmName("ObjectMappers") + +package com.langsmith_api.api.core + +import com.fasterxml.jackson.annotation.JsonInclude +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.JsonParseException +import com.fasterxml.jackson.core.JsonParser +import com.fasterxml.jackson.databind.DeserializationContext +import com.fasterxml.jackson.databind.DeserializationFeature +import com.fasterxml.jackson.databind.MapperFeature +import com.fasterxml.jackson.databind.SerializationFeature +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.cfg.CoercionAction +import com.fasterxml.jackson.databind.cfg.CoercionInputShape +import com.fasterxml.jackson.databind.deser.std.StdDeserializer +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.databind.module.SimpleModule +import com.fasterxml.jackson.databind.type.LogicalType +import com.fasterxml.jackson.datatype.jdk8.Jdk8Module +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule +import com.fasterxml.jackson.module.kotlin.kotlinModule +import java.io.InputStream +import java.time.DateTimeException +import java.time.LocalDate +import java.time.LocalDateTime +import java.time.ZonedDateTime +import java.time.format.DateTimeFormatter +import java.time.temporal.ChronoField + +fun jsonMapper(): JsonMapper = + JsonMapper.builder() + .addModule(kotlinModule()) + .addModule(Jdk8Module()) + .addModule(JavaTimeModule()) + .addModule( + SimpleModule() + .addSerializer(InputStreamSerializer) + .addDeserializer(LocalDateTime::class.java, LenientLocalDateTimeDeserializer()) + ) + .withCoercionConfig(LogicalType.Boolean) { + it.setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Integer) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Float) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Textual) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Array) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Collection) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Map) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.POJO) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + } + .serializationInclusion(JsonInclude.Include.NON_ABSENT) + .disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE) + .disable(SerializationFeature.FLUSH_AFTER_WRITE_VALUE) + .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) + .disable(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS) + .disable(MapperFeature.ALLOW_COERCION_OF_SCALARS) + .disable(MapperFeature.AUTO_DETECT_CREATORS) + .disable(MapperFeature.AUTO_DETECT_FIELDS) + .disable(MapperFeature.AUTO_DETECT_GETTERS) + .disable(MapperFeature.AUTO_DETECT_IS_GETTERS) + .disable(MapperFeature.AUTO_DETECT_SETTERS) + .build() + +/** A serializer that serializes [InputStream] to bytes. */ +private object InputStreamSerializer : BaseSerializer(InputStream::class) { + + private fun readResolve(): Any = InputStreamSerializer + + override fun serialize( + value: InputStream?, + gen: JsonGenerator?, + serializers: SerializerProvider?, + ) { + if (value == null) { + gen?.writeNull() + } else { + value.use { gen?.writeBinary(it.readBytes()) } + } + } +} + +/** + * A deserializer that can deserialize [LocalDateTime] from datetimes, dates, and zoned datetimes. + */ +private class LenientLocalDateTimeDeserializer : + StdDeserializer(LocalDateTime::class.java) { + + companion object { + + private val DATE_TIME_FORMATTERS = + listOf( + DateTimeFormatter.ISO_LOCAL_DATE_TIME, + DateTimeFormatter.ISO_LOCAL_DATE, + DateTimeFormatter.ISO_ZONED_DATE_TIME, + ) + } + + override fun logicalType(): LogicalType = LogicalType.DateTime + + override fun deserialize(p: JsonParser, context: DeserializationContext?): LocalDateTime { + val exceptions = mutableListOf() + + for (formatter in DATE_TIME_FORMATTERS) { + try { + val temporal = formatter.parse(p.text) + + return when { + !temporal.isSupported(ChronoField.HOUR_OF_DAY) -> + LocalDate.from(temporal).atStartOfDay() + !temporal.isSupported(ChronoField.OFFSET_SECONDS) -> + LocalDateTime.from(temporal) + else -> ZonedDateTime.from(temporal).toLocalDateTime() + } + } catch (e: DateTimeException) { + exceptions.add(e) + } + } + + throw JsonParseException(p, "Cannot parse `LocalDateTime` from value: ${p.text}").apply { + exceptions.forEach { addSuppressed(it) } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/Params.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/Params.kt new file mode 100644 index 00000000..5756990d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/Params.kt @@ -0,0 +1,16 @@ +package com.langsmith_api.api.core + +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams + +/** An interface representing parameters passed to a service method. */ +interface Params { + /** The full set of headers in the parameters, including both fixed and additional headers. */ + fun _headers(): Headers + + /** + * The full set of query params in the parameters, including both fixed and additional query + * params. + */ + fun _queryParams(): QueryParams +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/PhantomReachable.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/PhantomReachable.kt new file mode 100644 index 00000000..5ad63c67 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/PhantomReachable.kt @@ -0,0 +1,56 @@ +@file:JvmName("PhantomReachable") + +package com.langsmith_api.api.core + +import com.langsmith_api.api.errors.LangsmithApiException +import java.lang.reflect.InvocationTargetException + +/** + * Closes [closeable] when [observed] becomes only phantom reachable. + * + * This is a wrapper around a Java 9+ [java.lang.ref.Cleaner], or a no-op in older Java versions. + */ +@JvmSynthetic +internal fun closeWhenPhantomReachable(observed: Any, closeable: AutoCloseable) { + check(observed !== closeable) { + "`observed` cannot be the same object as `closeable` because it would never become phantom reachable" + } + closeWhenPhantomReachable(observed, closeable::close) +} + +/** + * Calls [close] when [observed] becomes only phantom reachable. + * + * This is a wrapper around a Java 9+ [java.lang.ref.Cleaner], or a no-op in older Java versions. + */ +@JvmSynthetic +internal fun closeWhenPhantomReachable(observed: Any, close: () -> Unit) { + closeWhenPhantomReachable?.let { it(observed, close) } +} + +private val closeWhenPhantomReachable: ((Any, () -> Unit) -> Unit)? by lazy { + try { + val cleanerClass = Class.forName("java.lang.ref.Cleaner") + val cleanerCreate = cleanerClass.getMethod("create") + val cleanerRegister = + cleanerClass.getMethod("register", Any::class.java, Runnable::class.java) + val cleanerObject = cleanerCreate.invoke(null); + + { observed, close -> + try { + cleanerRegister.invoke(cleanerObject, observed, Runnable { close() }) + } catch (e: ReflectiveOperationException) { + if (e is InvocationTargetException) { + when (val cause = e.cause) { + is RuntimeException, + is Error -> throw cause + } + } + throw LangsmithApiException("Unexpected reflective invocation failure", e) + } + } + } catch (e: ReflectiveOperationException) { + // We're running Java 8, which has no Cleaner. + null + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/PhantomReachableExecutorService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/PhantomReachableExecutorService.kt new file mode 100644 index 00000000..3ae81d7d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/PhantomReachableExecutorService.kt @@ -0,0 +1,58 @@ +package com.langsmith_api.api.core + +import java.util.concurrent.Callable +import java.util.concurrent.ExecutorService +import java.util.concurrent.Future +import java.util.concurrent.TimeUnit + +/** + * A delegating wrapper around an [ExecutorService] that shuts it down once it's only phantom + * reachable. + * + * This class ensures the [ExecutorService] is shut down even if the user forgets to do it. + */ +internal class PhantomReachableExecutorService(private val executorService: ExecutorService) : + ExecutorService { + init { + closeWhenPhantomReachable(this) { executorService.shutdown() } + } + + override fun execute(command: Runnable) = executorService.execute(command) + + override fun shutdown() = executorService.shutdown() + + override fun shutdownNow(): MutableList = executorService.shutdownNow() + + override fun isShutdown(): Boolean = executorService.isShutdown + + override fun isTerminated(): Boolean = executorService.isTerminated + + override fun awaitTermination(timeout: Long, unit: TimeUnit): Boolean = + executorService.awaitTermination(timeout, unit) + + override fun submit(task: Callable): Future = executorService.submit(task) + + override fun submit(task: Runnable, result: T): Future = + executorService.submit(task, result) + + override fun submit(task: Runnable): Future<*> = executorService.submit(task) + + override fun invokeAll( + tasks: MutableCollection> + ): MutableList> = executorService.invokeAll(tasks) + + override fun invokeAll( + tasks: MutableCollection>, + timeout: Long, + unit: TimeUnit, + ): MutableList> = executorService.invokeAll(tasks, timeout, unit) + + override fun invokeAny(tasks: MutableCollection>): T = + executorService.invokeAny(tasks) + + override fun invokeAny( + tasks: MutableCollection>, + timeout: Long, + unit: TimeUnit, + ): T = executorService.invokeAny(tasks, timeout, unit) +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/PhantomReachableSleeper.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/PhantomReachableSleeper.kt new file mode 100644 index 00000000..4652b566 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/PhantomReachableSleeper.kt @@ -0,0 +1,23 @@ +package com.langsmith_api.api.core + +import java.time.Duration +import java.util.concurrent.CompletableFuture + +/** + * A delegating wrapper around a [Sleeper] that closes it once it's only phantom reachable. + * + * This class ensures the [Sleeper] is closed even if the user forgets to do it. + */ +internal class PhantomReachableSleeper(private val sleeper: Sleeper) : Sleeper { + + init { + closeWhenPhantomReachable(this, sleeper) + } + + override fun sleep(duration: Duration) = sleeper.sleep(duration) + + override fun sleepAsync(duration: Duration): CompletableFuture = + sleeper.sleepAsync(duration) + + override fun close() = sleeper.close() +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/PrepareRequest.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/PrepareRequest.kt new file mode 100644 index 00000000..614c77b6 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/PrepareRequest.kt @@ -0,0 +1,24 @@ +@file:JvmName("PrepareRequest") + +package com.langsmith_api.api.core + +import com.langsmith_api.api.core.http.HttpRequest +import java.util.concurrent.CompletableFuture + +@JvmSynthetic +internal fun HttpRequest.prepare(clientOptions: ClientOptions, params: Params): HttpRequest = + toBuilder() + .putAllQueryParams(clientOptions.queryParams) + .replaceAllQueryParams(params._queryParams()) + .putAllHeaders(clientOptions.headers) + .replaceAllHeaders(params._headers()) + .build() + +@JvmSynthetic +internal fun HttpRequest.prepareAsync( + clientOptions: ClientOptions, + params: Params, +): CompletableFuture = + // This async version exists to make it easier to add async specific preparation logic in the + // future. + CompletableFuture.completedFuture(prepare(clientOptions, params)) diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/Properties.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/Properties.kt new file mode 100644 index 00000000..c2b3da71 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/Properties.kt @@ -0,0 +1,42 @@ +@file:JvmName("Properties") + +package com.langsmith_api.api.core + +import com.langsmith_api.api.client.LangsmithApiClient + +fun getOsArch(): String { + val osArch = System.getProperty("os.arch") + + return when (osArch) { + null -> "unknown" + "i386", + "x32", + "x86" -> "x32" + "amd64", + "x86_64" -> "x64" + "arm" -> "arm" + "aarch64" -> "arm64" + else -> "other:$osArch" + } +} + +fun getOsName(): String { + val osName = System.getProperty("os.name") + val vendorUrl = System.getProperty("java.vendor.url") + + return when { + osName == null -> "Unknown" + osName.startsWith("Linux") && vendorUrl == "http://www.android.com/" -> "Android" + osName.startsWith("Linux") -> "Linux" + osName.startsWith("Mac OS") -> "MacOS" + osName.startsWith("Windows") -> "Windows" + else -> "Other:$osName" + } +} + +fun getOsVersion(): String = System.getProperty("os.version", "unknown") + +fun getPackageVersion(): String = + LangsmithApiClient::class.java.`package`.implementationVersion ?: "unknown" + +fun getJavaVersion(): String = System.getProperty("java.version", "unknown") diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/RequestOptions.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/RequestOptions.kt new file mode 100644 index 00000000..9aed2710 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/RequestOptions.kt @@ -0,0 +1,46 @@ +package com.langsmith_api.api.core + +import java.time.Duration + +class RequestOptions private constructor(val responseValidation: Boolean?, val timeout: Timeout?) { + + companion object { + + private val NONE = builder().build() + + @JvmStatic fun none() = NONE + + @JvmSynthetic + internal fun from(clientOptions: ClientOptions): RequestOptions = + builder() + .responseValidation(clientOptions.responseValidation) + .timeout(clientOptions.timeout) + .build() + + @JvmStatic fun builder() = Builder() + } + + fun applyDefaults(options: RequestOptions): RequestOptions = + RequestOptions( + responseValidation = responseValidation ?: options.responseValidation, + timeout = + if (options.timeout != null && timeout != null) timeout.assign(options.timeout) + else timeout ?: options.timeout, + ) + + class Builder internal constructor() { + + private var responseValidation: Boolean? = null + private var timeout: Timeout? = null + + fun responseValidation(responseValidation: Boolean) = apply { + this.responseValidation = responseValidation + } + + fun timeout(timeout: Timeout) = apply { this.timeout = timeout } + + fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) + + fun build(): RequestOptions = RequestOptions(responseValidation, timeout) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/Sleeper.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/Sleeper.kt new file mode 100644 index 00000000..5a23acac --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/Sleeper.kt @@ -0,0 +1,21 @@ +package com.langsmith_api.api.core + +import java.time.Duration +import java.util.concurrent.CompletableFuture + +/** + * An interface for delaying execution for a specified amount of time. + * + * Useful for testing and cleaning up resources. + */ +interface Sleeper : AutoCloseable { + + /** Synchronously pauses execution for the given [duration]. */ + fun sleep(duration: Duration) + + /** Asynchronously pauses execution for the given [duration]. */ + fun sleepAsync(duration: Duration): CompletableFuture + + /** Overridden from [AutoCloseable] to not have a checked exception in its signature. */ + override fun close() +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/Timeout.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/Timeout.kt new file mode 100644 index 00000000..cae61f7b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/Timeout.kt @@ -0,0 +1,171 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.core + +import java.time.Duration +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** A class containing timeouts for various processing phases of a request. */ +class Timeout +private constructor( + private val connect: Duration?, + private val read: Duration?, + private val write: Duration?, + private val request: Duration?, +) { + + /** + * The maximum time allowed to establish a connection with a host. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `Duration.ofMinutes(1)`. + */ + fun connect(): Duration = connect ?: Duration.ofMinutes(1) + + /** + * The maximum time allowed between two data packets when waiting for the server’s response. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `request()`. + */ + fun read(): Duration = read ?: request() + + /** + * The maximum time allowed between two data packets when sending the request to the server. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `request()`. + */ + fun write(): Duration = write ?: request() + + /** + * The maximum time allowed for a complete HTTP call, not including retries. + * + * This includes resolving DNS, connecting, writing the request body, server processing, as well + * as reading the response body. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `Duration.ofMinutes(1)`. + */ + fun request(): Duration = request ?: Duration.ofMinutes(1) + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun default() = builder().build() + + /** Returns a mutable builder for constructing an instance of [Timeout]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Timeout]. */ + class Builder internal constructor() { + + private var connect: Duration? = null + private var read: Duration? = null + private var write: Duration? = null + private var request: Duration? = null + + @JvmSynthetic + internal fun from(timeout: Timeout) = apply { + connect = timeout.connect + read = timeout.read + write = timeout.write + request = timeout.request + } + + /** + * The maximum time allowed to establish a connection with a host. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `Duration.ofMinutes(1)`. + */ + fun connect(connect: Duration?) = apply { this.connect = connect } + + /** Alias for calling [Builder.connect] with `connect.orElse(null)`. */ + fun connect(connect: Optional) = connect(connect.getOrNull()) + + /** + * The maximum time allowed between two data packets when waiting for the server’s response. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `request()`. + */ + fun read(read: Duration?) = apply { this.read = read } + + /** Alias for calling [Builder.read] with `read.orElse(null)`. */ + fun read(read: Optional) = read(read.getOrNull()) + + /** + * The maximum time allowed between two data packets when sending the request to the server. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `request()`. + */ + fun write(write: Duration?) = apply { this.write = write } + + /** Alias for calling [Builder.write] with `write.orElse(null)`. */ + fun write(write: Optional) = write(write.getOrNull()) + + /** + * The maximum time allowed for a complete HTTP call, not including retries. + * + * This includes resolving DNS, connecting, writing the request body, server processing, as + * well as reading the response body. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `Duration.ofMinutes(1)`. + */ + fun request(request: Duration?) = apply { this.request = request } + + /** Alias for calling [Builder.request] with `request.orElse(null)`. */ + fun request(request: Optional) = request(request.getOrNull()) + + /** + * Returns an immutable instance of [Timeout]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Timeout = Timeout(connect, read, write, request) + } + + @JvmSynthetic + internal fun assign(target: Timeout): Timeout = + target + .toBuilder() + .apply { + connect?.let(this::connect) + read?.let(this::read) + write?.let(this::write) + request?.let(this::request) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Timeout && + connect == other.connect && + read == other.read && + write == other.write && + request == other.request + } + + override fun hashCode(): Int = Objects.hash(connect, read, write, request) + + override fun toString() = + "Timeout{connect=$connect, read=$read, write=$write, request=$request}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/Utils.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/Utils.kt new file mode 100644 index 00000000..c6a148bf --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/Utils.kt @@ -0,0 +1,115 @@ +@file:JvmName("Utils") + +package com.langsmith_api.api.core + +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.SortedMap +import java.util.concurrent.CompletableFuture +import java.util.concurrent.locks.Lock + +@JvmSynthetic +internal fun T?.getOrThrow(name: String): T = + this ?: throw LangsmithApiInvalidDataException("`${name}` is not present") + +@JvmSynthetic +internal fun List.toImmutable(): List = + if (isEmpty()) Collections.emptyList() else Collections.unmodifiableList(toList()) + +@JvmSynthetic +internal fun Map.toImmutable(): Map = + if (isEmpty()) immutableEmptyMap() else Collections.unmodifiableMap(toMap()) + +@JvmSynthetic internal fun immutableEmptyMap(): Map = Collections.emptyMap() + +@JvmSynthetic +internal fun , V> SortedMap.toImmutable(): SortedMap = + if (isEmpty()) Collections.emptySortedMap() + else Collections.unmodifiableSortedMap(toSortedMap(comparator())) + +/** + * Returns all elements that yield the largest value for the given function, or an empty list if + * there are zero elements. + * + * This is similar to [Sequence.maxByOrNull] except it returns _all_ elements that yield the largest + * value; not just the first one. + */ +@JvmSynthetic +internal fun > Sequence.allMaxBy(selector: (T) -> R): List { + var maxValue: R? = null + val maxElements = mutableListOf() + + val iterator = iterator() + while (iterator.hasNext()) { + val element = iterator.next() + val value = selector(element) + if (maxValue == null || value > maxValue) { + maxValue = value + maxElements.clear() + maxElements.add(element) + } else if (value == maxValue) { + maxElements.add(element) + } + } + + return maxElements +} + +/** + * Returns whether [this] is equal to [other]. + * + * This differs from [Object.equals] because it also deeply equates arrays based on their contents, + * even when there are arrays directly nested within other arrays. + */ +@JvmSynthetic +internal infix fun Any?.contentEquals(other: Any?): Boolean = + arrayOf(this).contentDeepEquals(arrayOf(other)) + +/** + * Returns a hash of the given sequence of [values]. + * + * This differs from [java.util.Objects.hash] because it also deeply hashes arrays based on their + * contents, even when there are arrays directly nested within other arrays. + */ +@JvmSynthetic internal fun contentHash(vararg values: Any?): Int = values.contentDeepHashCode() + +/** + * Returns a [String] representation of [this]. + * + * This differs from [Object.toString] because it also deeply stringifies arrays based on their + * contents, even when there are arrays directly nested within other arrays. + */ +@JvmSynthetic +internal fun Any?.contentToString(): String { + var string = arrayOf(this).contentDeepToString() + if (string.startsWith('[')) { + string = string.substring(1) + } + if (string.endsWith(']')) { + string = string.substring(0, string.length - 1) + } + return string +} + +internal interface Enum + +/** + * Executes the given [action] while holding the lock, returning a [CompletableFuture] with the + * result. + * + * @param action The asynchronous action to execute while holding the lock + * @return A [CompletableFuture] that completes with the result of the action + */ +@JvmSynthetic +internal fun Lock.withLockAsync(action: () -> CompletableFuture): CompletableFuture { + lock() + val future = + try { + action() + } catch (e: Throwable) { + unlock() + throw e + } + future.whenComplete { _, _ -> unlock() } + return future +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/Values.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/Values.kt new file mode 100644 index 00000000..a5617b6f --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/Values.kt @@ -0,0 +1,723 @@ +package com.langsmith_api.api.core + +import com.fasterxml.jackson.annotation.JacksonAnnotationsInside +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonInclude +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.core.type.TypeReference +import com.fasterxml.jackson.databind.BeanProperty +import com.fasterxml.jackson.databind.DeserializationContext +import com.fasterxml.jackson.databind.JavaType +import com.fasterxml.jackson.databind.JsonDeserializer +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.node.JsonNodeType.ARRAY +import com.fasterxml.jackson.databind.node.JsonNodeType.BINARY +import com.fasterxml.jackson.databind.node.JsonNodeType.BOOLEAN +import com.fasterxml.jackson.databind.node.JsonNodeType.MISSING +import com.fasterxml.jackson.databind.node.JsonNodeType.NULL +import com.fasterxml.jackson.databind.node.JsonNodeType.NUMBER +import com.fasterxml.jackson.databind.node.JsonNodeType.OBJECT +import com.fasterxml.jackson.databind.node.JsonNodeType.POJO +import com.fasterxml.jackson.databind.node.JsonNodeType.STRING +import com.fasterxml.jackson.databind.ser.std.NullSerializer +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.io.InputStream +import java.util.Objects +import java.util.Optional + +/** + * A class representing a serializable JSON field. + * + * It can either be a [KnownValue] value of type [T], matching the type the SDK expects, or an + * arbitrary JSON value that bypasses the type system (via [JsonValue]). + */ +@JsonDeserialize(using = JsonField.Deserializer::class) +sealed class JsonField { + + /** + * Returns whether this field is missing, which means it will be omitted from the serialized + * JSON entirely. + */ + fun isMissing(): Boolean = this is JsonMissing + + /** Whether this field is explicitly set to `null`. */ + fun isNull(): Boolean = this is JsonNull + + /** + * Returns an [Optional] containing this field's "known" value, meaning it matches the type the + * SDK expects, or an empty [Optional] if this field contains an arbitrary [JsonValue]. + * + * This is the opposite of [asUnknown]. + */ + fun asKnown(): + Optional< + // Safe because `Optional` is effectively covariant, but Kotlin doesn't know that. + @UnsafeVariance + T + > = Optional.ofNullable((this as? KnownValue)?.value) + + /** + * Returns an [Optional] containing this field's arbitrary [JsonValue], meaning it mismatches + * the type the SDK expects, or an empty [Optional] if this field contains a "known" value. + * + * This is the opposite of [asKnown]. + */ + fun asUnknown(): Optional = Optional.ofNullable(this as? JsonValue) + + /** + * Returns an [Optional] containing this field's boolean value, or an empty [Optional] if it + * doesn't contain a boolean. + * + * This method checks for both a [KnownValue] containing a boolean and for [JsonBoolean]. + */ + fun asBoolean(): Optional = + when (this) { + is JsonBoolean -> Optional.of(value) + is KnownValue -> Optional.ofNullable(value as? Boolean) + else -> Optional.empty() + } + + /** + * Returns an [Optional] containing this field's numerical value, or an empty [Optional] if it + * doesn't contain a number. + * + * This method checks for both a [KnownValue] containing a number and for [JsonNumber]. + */ + fun asNumber(): Optional = + when (this) { + is JsonNumber -> Optional.of(value) + is KnownValue -> Optional.ofNullable(value as? Number) + else -> Optional.empty() + } + + /** + * Returns an [Optional] containing this field's string value, or an empty [Optional] if it + * doesn't contain a string. + * + * This method checks for both a [KnownValue] containing a string and for [JsonString]. + */ + fun asString(): Optional = + when (this) { + is JsonString -> Optional.of(value) + is KnownValue -> Optional.ofNullable(value as? String) + else -> Optional.empty() + } + + fun asStringOrThrow(): String = + asString().orElseThrow { LangsmithApiInvalidDataException("Value is not a string") } + + /** + * Returns an [Optional] containing this field's list value, or an empty [Optional] if it + * doesn't contain a list. + * + * This method checks for both a [KnownValue] containing a list and for [JsonArray]. + */ + fun asArray(): Optional> = + when (this) { + is JsonArray -> Optional.of(values) + is KnownValue -> + Optional.ofNullable( + (value as? List<*>)?.map { + try { + JsonValue.from(it) + } catch (e: IllegalArgumentException) { + // The known value is a list, but not all values are convertible to + // `JsonValue`. + return Optional.empty() + } + } + ) + else -> Optional.empty() + } + + /** + * Returns an [Optional] containing this field's map value, or an empty [Optional] if it doesn't + * contain a map. + * + * This method checks for both a [KnownValue] containing a map and for [JsonObject]. + */ + fun asObject(): Optional> = + when (this) { + is JsonObject -> Optional.of(values) + is KnownValue -> + Optional.ofNullable( + (value as? Map<*, *>) + ?.map { (key, value) -> + if (key !is String) { + return Optional.empty() + } + + val jsonValue = + try { + JsonValue.from(value) + } catch (e: IllegalArgumentException) { + // The known value is a map, but not all items are convertible + // to `JsonValue`. + return Optional.empty() + } + + key to jsonValue + } + ?.toMap() + ) + else -> Optional.empty() + } + + @JvmSynthetic + internal fun getRequired(name: String): T = + when (this) { + is KnownValue -> value + is JsonMissing -> throw LangsmithApiInvalidDataException("`$name` is not set") + is JsonNull -> throw LangsmithApiInvalidDataException("`$name` is null") + else -> throw LangsmithApiInvalidDataException("`$name` is invalid, received $this") + } + + @JvmSynthetic + internal fun getOptional( + name: String + ): Optional< + // Safe because `Optional` is effectively covariant, but Kotlin doesn't know that. + @UnsafeVariance + T + > = + when (this) { + is KnownValue -> Optional.of(value) + is JsonMissing, + is JsonNull -> Optional.empty() + else -> throw LangsmithApiInvalidDataException("`$name` is invalid, received $this") + } + + @JvmSynthetic + internal fun map(transform: (T) -> R): JsonField = + when (this) { + is KnownValue -> KnownValue.of(transform(value)) + is JsonValue -> this + } + + @JvmSynthetic internal fun accept(consume: (T) -> Unit) = asKnown().ifPresent(consume) + + /** Returns the result of calling the [visitor] method corresponding to this field's state. */ + fun accept(visitor: Visitor): R = + when (this) { + is KnownValue -> visitor.visitKnown(value) + is JsonValue -> accept(visitor as JsonValue.Visitor) + } + + /** + * An interface that defines how to map each possible state of a `JsonField` to a value of + * type [R]. + */ + interface Visitor : JsonValue.Visitor { + + fun visitKnown(value: T): R = visitDefault() + } + + companion object { + + /** Returns a [JsonField] containing the given "known" [value]. */ + @JvmStatic fun of(value: T): JsonField = KnownValue.of(value) + + /** + * Returns a [JsonField] containing the given "known" [value], or [JsonNull] if [value] is + * null. + */ + @JvmStatic + fun ofNullable(value: T?): JsonField = + when (value) { + null -> JsonNull.of() + else -> KnownValue.of(value) + } + } + + /** + * This class is a Jackson filter that can be used to exclude missing properties from objects. + * This filter should not be used directly and should instead use the @ExcludeMissing + * annotation. + */ + class IsMissing { + + override fun equals(other: Any?): Boolean = other is JsonMissing + + override fun hashCode(): Int = Objects.hash() + } + + class Deserializer(private val type: JavaType? = null) : + BaseDeserializer>(JsonField::class) { + + override fun createContextual( + context: DeserializationContext, + property: BeanProperty?, + ): JsonDeserializer> = Deserializer(context.contextualType?.containedType(0)) + + override fun ObjectCodec.deserialize(node: JsonNode): JsonField<*> = + type?.let { tryDeserialize(node, type) }?.let { of(it) } + ?: JsonValue.fromJsonNode(node) + + override fun getNullValue(context: DeserializationContext): JsonField<*> = JsonNull.of() + } +} + +/** + * A class representing an arbitrary JSON value. + * + * It is immutable and assignable to any [JsonField], regardless of its expected type (i.e. its + * generic type argument). + */ +@JsonDeserialize(using = JsonValue.Deserializer::class) +sealed class JsonValue : JsonField() { + + fun convert(type: TypeReference): R? = JSON_MAPPER.convertValue(this, type) + + fun convert(type: Class): R? = JSON_MAPPER.convertValue(this, type) + + /** Returns the result of calling the [visitor] method corresponding to this value's variant. */ + fun accept(visitor: Visitor): R = + when (this) { + is JsonMissing -> visitor.visitMissing() + is JsonNull -> visitor.visitNull() + is JsonBoolean -> visitor.visitBoolean(value) + is JsonNumber -> visitor.visitNumber(value) + is JsonString -> visitor.visitString(value) + is JsonArray -> visitor.visitArray(values) + is JsonObject -> visitor.visitObject(values) + } + + /** + * An interface that defines how to map each variant state of a [JsonValue] to a value of type + * [R]. + */ + 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() + + /** + * The default implementation for unimplemented visitor methods. + * + * @throws IllegalArgumentException in the default implementation. + */ + fun visitDefault(): R = throw IllegalArgumentException("Unexpected value") + } + + companion object { + + private val JSON_MAPPER = jsonMapper() + + /** + * Converts the given [value] to a [JsonValue]. + * + * This method works best on primitive types, [List] values, [Map] values, and nested + * combinations of these. For example: + * ```java + * // Create primitive JSON values + * JsonValue nullValue = JsonValue.from(null); + * JsonValue booleanValue = JsonValue.from(true); + * JsonValue numberValue = JsonValue.from(42); + * JsonValue stringValue = JsonValue.from("Hello World!"); + * + * // Create a JSON array value equivalent to `["Hello", "World"]` + * JsonValue arrayValue = JsonValue.from(List.of("Hello", "World")); + * + * // Create a JSON object value equivalent to `{ "a": 1, "b": 2 }` + * JsonValue objectValue = JsonValue.from(Map.of( + * "a", 1, + * "b", 2 + * )); + * + * // Create an arbitrarily nested JSON equivalent to: + * // { + * // "a": [1, 2], + * // "b": [3, 4] + * // } + * JsonValue complexValue = JsonValue.from(Map.of( + * "a", List.of(1, 2), + * "b", List.of(3, 4) + * )); + * ``` + * + * @throws IllegalArgumentException if [value] is not JSON serializable. + */ + @JvmStatic + fun from(value: Any?): JsonValue = + when (value) { + null -> JsonNull.of() + is JsonValue -> value + else -> JSON_MAPPER.convertValue(value, JsonValue::class.java) + } + + /** + * Returns a [JsonValue] converted from the given Jackson [JsonNode]. + * + * @throws IllegalStateException for unsupported node types. + */ + @JvmStatic + fun fromJsonNode(node: JsonNode): JsonValue = + when (node.nodeType) { + MISSING -> JsonMissing.of() + NULL -> JsonNull.of() + 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() + ) + BINARY, + POJO, + null -> throw IllegalStateException("Unexpected JsonNode type: ${node.nodeType}") + } + } + + class Deserializer : BaseDeserializer(JsonValue::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): JsonValue = fromJsonNode(node) + + override fun getNullValue(context: DeserializationContext?): JsonValue = JsonNull.of() + } +} + +/** + * A class representing a "known" JSON serializable value of type [T], matching the type the SDK + * expects. + * + * It is assignable to `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) { + return true + } + + return other is KnownValue<*> && value contentEquals other.value + } + + override fun hashCode() = contentHash(value) + + override fun toString() = value.contentToString() + + companion object { + + /** Returns a [KnownValue] containing the given [value]. */ + @JsonCreator @JvmStatic fun of(value: T) = KnownValue(value) + } +} + +/** + * A [JsonValue] representing an omitted JSON field. + * + * An instance of this class will cause a JSON field to be omitted from the serialized JSON + * entirely. + */ +@JsonSerialize(using = JsonMissing.Serializer::class) +class JsonMissing : JsonValue() { + + override fun toString() = "" + + companion object { + + private val INSTANCE: JsonMissing = JsonMissing() + + /** Returns the singleton instance of [JsonMissing]. */ + @JvmStatic fun of() = INSTANCE + } + + class Serializer : BaseSerializer(JsonMissing::class) { + + override fun serialize( + value: JsonMissing, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + throw IllegalStateException("JsonMissing cannot be serialized") + } + } +} + +/** A [JsonValue] representing a JSON `null` value. */ +@JsonSerialize(using = NullSerializer::class) +class JsonNull : JsonValue() { + + override fun toString() = "null" + + companion object { + + private val INSTANCE: JsonNull = JsonNull() + + /** Returns the singleton instance of [JsonMissing]. */ + @JsonCreator @JvmStatic fun of() = INSTANCE + } +} + +/** A [JsonValue] representing a JSON boolean value. */ +class JsonBoolean +private constructor( + @get:com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: Boolean +) : JsonValue() { + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is JsonBoolean && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + /** Returns a [JsonBoolean] containing the given [value]. */ + @JsonCreator @JvmStatic fun of(value: Boolean) = JsonBoolean(value) + } +} + +/** A [JsonValue] representing a JSON number value. */ +class JsonNumber +private constructor( + @get:com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: Number +) : JsonValue() { + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is JsonNumber && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + /** Returns a [JsonNumber] containing the given [value]. */ + @JsonCreator @JvmStatic fun of(value: Number) = JsonNumber(value) + } +} + +/** A [JsonValue] representing a JSON string value. */ +class JsonString +private constructor( + @get:com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: String +) : JsonValue() { + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is JsonString && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value + + companion object { + + /** Returns a [JsonString] containing the given [value]. */ + @JsonCreator @JvmStatic fun of(value: String) = JsonString(value) + } +} + +/** A [JsonValue] representing a JSON array value. */ +class JsonArray +private constructor( + @get:com.fasterxml.jackson.annotation.JsonValue + @get:JvmName("values") + val values: List +) : JsonValue() { + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is JsonArray && values == other.values + } + + override fun hashCode() = values.hashCode() + + override fun toString() = values.toString() + + companion object { + + /** Returns a [JsonArray] containing the given [values]. */ + @JsonCreator @JvmStatic fun of(values: List) = JsonArray(values.toImmutable()) + } +} + +/** A [JsonValue] representing a JSON object value. */ +class JsonObject +private constructor( + @get:com.fasterxml.jackson.annotation.JsonValue + @get:JvmName("values") + val values: Map +) : JsonValue() { + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is JsonObject && values == other.values + } + + override fun hashCode() = values.hashCode() + + override fun toString() = values.toString() + + companion object { + + /** Returns a [JsonObject] containing the given [values]. */ + @JsonCreator + @JvmStatic + fun of(values: Map) = JsonObject(values.toImmutable()) + } +} + +/** A Jackson annotation for excluding fields set to [JsonMissing] from the serialized JSON. */ +@JacksonAnnotationsInside +@JsonInclude(JsonInclude.Include.CUSTOM, valueFilter = JsonField.IsMissing::class) +annotation class ExcludeMissing + +/** A class representing a field in a `multipart/form-data` request. */ +class MultipartField +private constructor( + /** A [JsonField] value, which will be serialized to zero or more parts. */ + @get:com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: JsonField, + /** A content type for the serialized parts. */ + @get:JvmName("contentType") val contentType: String, + private val filename: String?, +) { + + companion object { + + /** + * Returns a [MultipartField] containing the given [value] as a [KnownValue]. + * + * [contentType] will be set to `application/octet-stream` if [value] is binary data, or + * `text/plain; charset=utf-8` otherwise. + */ + @JvmStatic fun of(value: T?) = builder().value(value).build() + + /** + * Returns a [MultipartField] containing the given [value]. + * + * [contentType] will be set to `application/octet-stream` if [value] is binary data, or + * `text/plain; charset=utf-8` otherwise. + */ + @JvmStatic fun of(value: JsonField) = builder().value(value).build() + + /** + * Returns a mutable builder for constructing an instance of [MultipartField]. + * + * The following fields are required: + * ```java + * .value() + * ``` + * + * If [contentType] is unset, then it will be set to `application/octet-stream` if [value] + * is binary data, or `text/plain; charset=utf-8` otherwise. + */ + @JvmStatic fun builder() = Builder() + } + + /** Returns the filename directive that will be included in the serialized field. */ + fun filename(): Optional = Optional.ofNullable(filename) + + @JvmSynthetic + internal fun map(transform: (T) -> R): MultipartField = + builder().value(value.map(transform)).contentType(contentType).filename(filename).build() + + /** A builder for [MultipartField]. */ + class Builder internal constructor() { + + private var value: JsonField? = null + private var contentType: String? = null + private var filename: String? = null + + fun value(value: JsonField) = apply { this.value = value } + + fun value(value: T?) = value(JsonField.ofNullable(value)) + + fun contentType(contentType: String) = apply { this.contentType = contentType } + + fun filename(filename: String?) = apply { this.filename = filename } + + /** Alias for calling [Builder.filename] with `filename.orElse(null)`. */ + fun filename(filename: Optional) = filename(filename.orElse(null)) + + /** + * Returns an immutable instance of [MultipartField]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .value() + * ``` + * + * If [contentType] is unset, then it will be set to `application/octet-stream` if [value] + * is binary data, or `text/plain; charset=utf-8` otherwise. + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MultipartField { + val value = checkRequired("value", value) + return MultipartField( + value, + contentType + ?: if ( + value is KnownValue && + (value.value is InputStream || value.value is ByteArray) + ) + "application/octet-stream" + else "text/plain; charset=utf-8", + filename, + ) + } + } + + private val hashCode: Int by lazy { contentHash(value, contentType, filename) } + + override fun hashCode(): Int = hashCode + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MultipartField<*> && + value == other.value && + contentType == other.contentType && + filename == other.filename + } + + override fun toString(): String = + "MultipartField{value=$value, contentType=$contentType, filename=$filename}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/handlers/EmptyHandler.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/handlers/EmptyHandler.kt new file mode 100644 index 00000000..662ff09a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/handlers/EmptyHandler.kt @@ -0,0 +1,12 @@ +@file:JvmName("EmptyHandler") + +package com.langsmith_api.api.core.handlers + +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler + +@JvmSynthetic internal fun emptyHandler(): Handler = EmptyHandlerInternal + +private object EmptyHandlerInternal : Handler { + override fun handle(response: HttpResponse): Void? = null +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/handlers/ErrorHandler.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/handlers/ErrorHandler.kt new file mode 100644 index 00000000..bb8b5d9a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/handlers/ErrorHandler.kt @@ -0,0 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:JvmName("ErrorHandler") + +package com.langsmith_api.api.core.handlers + +import com.fasterxml.jackson.databind.json.JsonMapper +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.errors.BadRequestException +import com.langsmith_api.api.errors.InternalServerException +import com.langsmith_api.api.errors.NotFoundException +import com.langsmith_api.api.errors.PermissionDeniedException +import com.langsmith_api.api.errors.RateLimitException +import com.langsmith_api.api.errors.UnauthorizedException +import com.langsmith_api.api.errors.UnexpectedStatusCodeException +import com.langsmith_api.api.errors.UnprocessableEntityException + +@JvmSynthetic +internal fun errorBodyHandler(jsonMapper: JsonMapper): Handler { + val handler = jsonHandler(jsonMapper) + + return object : Handler { + override fun handle(response: HttpResponse): JsonValue = + try { + handler.handle(response) + } catch (e: Exception) { + JsonMissing.of() + } + } +} + +@JvmSynthetic +internal fun errorHandler(errorBodyHandler: Handler): Handler = + object : Handler { + override fun handle(response: HttpResponse): HttpResponse = + when (val statusCode = response.statusCode()) { + in 200..299 -> response + 400 -> + throw BadRequestException.builder() + .headers(response.headers()) + .body(errorBodyHandler.handle(response)) + .build() + 401 -> + throw UnauthorizedException.builder() + .headers(response.headers()) + .body(errorBodyHandler.handle(response)) + .build() + 403 -> + throw PermissionDeniedException.builder() + .headers(response.headers()) + .body(errorBodyHandler.handle(response)) + .build() + 404 -> + throw NotFoundException.builder() + .headers(response.headers()) + .body(errorBodyHandler.handle(response)) + .build() + 422 -> + throw UnprocessableEntityException.builder() + .headers(response.headers()) + .body(errorBodyHandler.handle(response)) + .build() + 429 -> + throw RateLimitException.builder() + .headers(response.headers()) + .body(errorBodyHandler.handle(response)) + .build() + in 500..599 -> + throw InternalServerException.builder() + .statusCode(statusCode) + .headers(response.headers()) + .body(errorBodyHandler.handle(response)) + .build() + else -> + throw UnexpectedStatusCodeException.builder() + .statusCode(statusCode) + .headers(response.headers()) + .body(errorBodyHandler.handle(response)) + .build() + } + } diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/handlers/JsonHandler.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/handlers/JsonHandler.kt new file mode 100644 index 00000000..0cb8ad81 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/handlers/JsonHandler.kt @@ -0,0 +1,20 @@ +@file:JvmName("JsonHandler") + +package com.langsmith_api.api.core.handlers + +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException + +@JvmSynthetic +internal inline fun jsonHandler(jsonMapper: JsonMapper): Handler = + object : Handler { + override fun handle(response: HttpResponse): T = + try { + jsonMapper.readValue(response.body(), jacksonTypeRef()) + } catch (e: Exception) { + throw LangsmithApiInvalidDataException("Error reading response", e) + } + } diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/handlers/StringHandler.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/handlers/StringHandler.kt new file mode 100644 index 00000000..aeedf0ca --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/handlers/StringHandler.kt @@ -0,0 +1,13 @@ +@file:JvmName("StringHandler") + +package com.langsmith_api.api.core.handlers + +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler + +@JvmSynthetic internal fun stringHandler(): Handler = StringHandlerInternal + +private object StringHandlerInternal : Handler { + override fun handle(response: HttpResponse): String = + response.body().readBytes().toString(Charsets.UTF_8) +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/AsyncStreamResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/AsyncStreamResponse.kt new file mode 100644 index 00000000..bbd63d2d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/AsyncStreamResponse.kt @@ -0,0 +1,157 @@ +package com.langsmith_api.api.core.http + +import com.langsmith_api.api.core.http.AsyncStreamResponse.Handler +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.concurrent.atomic.AtomicReference + +/** + * A class providing access to an API response as an asynchronous stream of chunks of type [T], + * where each chunk can be individually processed as soon as it arrives instead of waiting on the + * full response. + */ +interface AsyncStreamResponse { + + /** + * Registers [handler] to be called for events of this stream. + * + * [handler]'s methods will be called in the client's configured or default thread pool. + * + * @throws IllegalStateException if [subscribe] has already been called. + */ + fun subscribe(handler: Handler): AsyncStreamResponse + + /** + * Registers [handler] to be called for events of this stream. + * + * [handler]'s methods will be called in the given [executor]. + * + * @throws IllegalStateException if [subscribe] has already been called. + */ + fun subscribe(handler: Handler, executor: Executor): AsyncStreamResponse + + /** + * Returns a future that completes when a stream is fully consumed, errors, or gets closed + * early. + */ + fun onCompleteFuture(): CompletableFuture + + /** + * Closes this resource, relinquishing any underlying resources. + * + * This is purposefully not inherited from [AutoCloseable] because this response should not be + * synchronously closed via try-with-resources. + */ + fun close() + + /** A class for handling streaming events. */ + fun interface Handler { + + /** Called whenever a chunk is received. */ + fun onNext(value: T) + + /** + * Called when a stream is fully consumed, errors, or gets closed early. + * + * [onNext] will not be called once this method is called. + * + * @param error Non-empty if the stream completed due to an error. + */ + fun onComplete(error: Optional) {} + } +} + +@JvmSynthetic +internal fun CompletableFuture>.toAsync(streamHandlerExecutor: Executor) = + PhantomReachableClosingAsyncStreamResponse( + object : AsyncStreamResponse { + + private val onCompleteFuture = CompletableFuture() + private val state = AtomicReference(State.NEW) + + init { + this@toAsync.whenComplete { _, error -> + // If an error occurs from the original future, then we should resolve the + // `onCompleteFuture` even if `subscribe` has not been called. + error?.let(onCompleteFuture::completeExceptionally) + } + } + + override fun subscribe(handler: Handler): AsyncStreamResponse = + subscribe(handler, streamHandlerExecutor) + + override fun subscribe( + handler: Handler, + executor: Executor, + ): AsyncStreamResponse = apply { + // TODO(JDK): Use `compareAndExchange` once targeting JDK 9. + check(state.compareAndSet(State.NEW, State.SUBSCRIBED)) { + if (state.get() == State.SUBSCRIBED) "Cannot subscribe more than once" + else "Cannot subscribe after the response is closed" + } + + this@toAsync.whenCompleteAsync( + { streamResponse, futureError -> + if (state.get() == State.CLOSED) { + // Avoid doing any work if `close` was called before the future + // completed. + return@whenCompleteAsync + } + + if (futureError != null) { + // An error occurred before we started passing chunks to the handler. + handler.onComplete(Optional.of(futureError)) + return@whenCompleteAsync + } + + var streamError: Throwable? = null + try { + streamResponse.stream().forEach(handler::onNext) + } catch (e: Throwable) { + streamError = e + } + + try { + handler.onComplete(Optional.ofNullable(streamError)) + } finally { + try { + // Notify completion via the `onCompleteFuture` as well. This is in + // a separate `try-finally` block so that we still complete the + // future if `handler.onComplete` throws. + if (streamError == null) { + onCompleteFuture.complete(null) + } else { + onCompleteFuture.completeExceptionally(streamError) + } + } finally { + close() + } + } + }, + executor, + ) + } + + override fun onCompleteFuture(): CompletableFuture = onCompleteFuture + + override fun close() { + val previousState = state.getAndSet(State.CLOSED) + if (previousState == State.CLOSED) { + return + } + + this@toAsync.whenComplete { streamResponse, error -> streamResponse?.close() } + // When the stream is closed, we should always consider it closed. If it closed due + // to an error, then we will have already completed the future earlier, and this + // will be a no-op. + onCompleteFuture.complete(null) + } + } + ) + +private enum class State { + NEW, + SUBSCRIBED, + CLOSED, +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/Headers.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/Headers.kt new file mode 100644 index 00000000..87363b73 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/Headers.kt @@ -0,0 +1,115 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.core.http + +import com.langsmith_api.api.core.JsonArray +import com.langsmith_api.api.core.JsonBoolean +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonNull +import com.langsmith_api.api.core.JsonNumber +import com.langsmith_api.api.core.JsonObject +import com.langsmith_api.api.core.JsonString +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.toImmutable +import java.util.TreeMap + +class Headers +private constructor( + private val map: Map>, + @get:JvmName("size") val size: Int, +) { + + fun isEmpty(): Boolean = map.isEmpty() + + fun names(): Set = map.keys + + fun values(name: String): List = map[name].orEmpty() + + fun toBuilder(): Builder = Builder().putAll(map) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder internal constructor() { + + private val map: MutableMap> = + TreeMap(String.CASE_INSENSITIVE_ORDER) + private var size: Int = 0 + + fun put(name: String, value: JsonValue): Builder = apply { + when (value) { + is JsonMissing, + is JsonNull -> {} + is JsonBoolean -> put(name, value.value.toString()) + is JsonNumber -> put(name, value.value.toString()) + is JsonString -> put(name, value.value) + is JsonArray -> value.values.forEach { put(name, it) } + is JsonObject -> + value.values.forEach { (nestedName, value) -> put("$name.$nestedName", value) } + } + } + + fun put(name: String, value: String) = apply { + map.getOrPut(name) { mutableListOf() }.add(value) + size++ + } + + fun put(name: String, values: Iterable) = apply { values.forEach { put(name, it) } } + + fun putAll(headers: Map>) = apply { headers.forEach(::put) } + + fun putAll(headers: Headers) = apply { + headers.names().forEach { put(it, headers.values(it)) } + } + + fun replace(name: String, value: String) = apply { + remove(name) + put(name, value) + } + + fun replace(name: String, values: Iterable) = apply { + remove(name) + put(name, values) + } + + fun replaceAll(headers: Map>) = apply { + headers.forEach(::replace) + } + + fun replaceAll(headers: Headers) = apply { + headers.names().forEach { replace(it, headers.values(it)) } + } + + fun remove(name: String) = apply { size -= map.remove(name).orEmpty().size } + + fun removeAll(names: Set) = apply { names.forEach(::remove) } + + fun clear() = apply { + map.clear() + size = 0 + } + + fun build() = + Headers( + map.mapValuesTo(TreeMap(String.CASE_INSENSITIVE_ORDER)) { (_, values) -> + values.toImmutable() + } + .toImmutable(), + size, + ) + } + + override fun hashCode(): Int = map.hashCode() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Headers && map == other.map + } + + override fun toString(): String = "Headers{map=$map}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/HttpClient.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/HttpClient.kt new file mode 100644 index 00000000..5193dc9b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/HttpClient.kt @@ -0,0 +1,26 @@ +package com.langsmith_api.api.core.http + +import com.langsmith_api.api.core.RequestOptions +import java.lang.AutoCloseable +import java.util.concurrent.CompletableFuture + +interface HttpClient : AutoCloseable { + + fun execute( + request: HttpRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + fun execute(request: HttpRequest): HttpResponse = execute(request, RequestOptions.none()) + + fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + fun executeAsync(request: HttpRequest): CompletableFuture = + executeAsync(request, RequestOptions.none()) + + /** Overridden from [AutoCloseable] to not have a checked exception in its signature. */ + override fun close() +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/HttpMethod.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/HttpMethod.kt new file mode 100644 index 00000000..974f9971 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/HttpMethod.kt @@ -0,0 +1,13 @@ +package com.langsmith_api.api.core.http + +enum class HttpMethod { + GET, + HEAD, + POST, + PUT, + DELETE, + CONNECT, + OPTIONS, + TRACE, + PATCH, +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/HttpRequest.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/HttpRequest.kt new file mode 100644 index 00000000..2727d530 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/HttpRequest.kt @@ -0,0 +1,146 @@ +package com.langsmith_api.api.core.http + +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable + +class HttpRequest +private constructor( + @get:JvmName("method") val method: HttpMethod, + @get:JvmName("baseUrl") val baseUrl: String, + @get:JvmName("pathSegments") val pathSegments: List, + @get:JvmName("headers") val headers: Headers, + @get:JvmName("queryParams") val queryParams: QueryParams, + @get:JvmName("body") val body: HttpRequestBody?, +) { + + fun toBuilder(): Builder = Builder().from(this) + + override fun toString(): String = + "HttpRequest{method=$method, baseUrl=$baseUrl, pathSegments=$pathSegments, headers=$headers, queryParams=$queryParams, body=$body}" + + companion object { + @JvmStatic fun builder() = Builder() + } + + class Builder internal constructor() { + + private var method: HttpMethod? = null + private var baseUrl: String? = null + private var pathSegments: MutableList = mutableListOf() + private var headers: Headers.Builder = Headers.builder() + private var queryParams: QueryParams.Builder = QueryParams.builder() + private var body: HttpRequestBody? = null + + @JvmSynthetic + internal fun from(request: HttpRequest) = apply { + method = request.method + baseUrl = request.baseUrl + pathSegments = request.pathSegments.toMutableList() + headers = request.headers.toBuilder() + queryParams = request.queryParams.toBuilder() + body = request.body + } + + fun method(method: HttpMethod) = apply { this.method = method } + + fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl } + + fun addPathSegment(pathSegment: String) = apply { pathSegments.add(pathSegment) } + + fun addPathSegments(vararg pathSegments: String) = apply { + this.pathSegments.addAll(pathSegments) + } + + fun headers(headers: Headers) = apply { + this.headers.clear() + putAllHeaders(headers) + } + + fun headers(headers: Map>) = apply { + this.headers.clear() + putAllHeaders(headers) + } + + fun putHeader(name: String, value: String) = apply { headers.put(name, value) } + + fun putHeaders(name: String, values: Iterable) = apply { headers.put(name, values) } + + fun putAllHeaders(headers: Headers) = apply { this.headers.putAll(headers) } + + fun putAllHeaders(headers: Map>) = apply { + this.headers.putAll(headers) + } + + fun replaceHeaders(name: String, value: String) = apply { headers.replace(name, value) } + + fun replaceHeaders(name: String, values: Iterable) = apply { + headers.replace(name, values) + } + + fun replaceAllHeaders(headers: Headers) = apply { this.headers.replaceAll(headers) } + + fun replaceAllHeaders(headers: Map>) = apply { + this.headers.replaceAll(headers) + } + + fun removeHeaders(name: String) = apply { headers.remove(name) } + + fun removeAllHeaders(names: Set) = apply { headers.removeAll(names) } + + fun queryParams(queryParams: QueryParams) = apply { + this.queryParams.clear() + putAllQueryParams(queryParams) + } + + fun queryParams(queryParams: Map>) = apply { + this.queryParams.clear() + putAllQueryParams(queryParams) + } + + fun putQueryParam(key: String, value: String) = apply { queryParams.put(key, value) } + + fun putQueryParams(key: String, values: Iterable) = apply { + queryParams.put(key, values) + } + + fun putAllQueryParams(queryParams: QueryParams) = apply { + this.queryParams.putAll(queryParams) + } + + fun putAllQueryParams(queryParams: Map>) = apply { + this.queryParams.putAll(queryParams) + } + + fun replaceQueryParams(key: String, value: String) = apply { + queryParams.replace(key, value) + } + + fun replaceQueryParams(key: String, values: Iterable) = apply { + queryParams.replace(key, values) + } + + fun replaceAllQueryParams(queryParams: QueryParams) = apply { + this.queryParams.replaceAll(queryParams) + } + + fun replaceAllQueryParams(queryParams: Map>) = apply { + this.queryParams.replaceAll(queryParams) + } + + fun removeQueryParams(key: String) = apply { queryParams.remove(key) } + + fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) } + + fun body(body: HttpRequestBody) = apply { this.body = body } + + fun build(): HttpRequest = + HttpRequest( + checkRequired("method", method), + checkRequired("baseUrl", baseUrl), + pathSegments.toImmutable(), + headers.build(), + queryParams.build(), + body, + ) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/HttpRequestBodies.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/HttpRequestBodies.kt new file mode 100644 index 00000000..411241ac --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/HttpRequestBodies.kt @@ -0,0 +1,130 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:JvmName("HttpRequestBodies") + +package com.langsmith_api.api.core.http + +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.databind.node.JsonNodeType +import com.langsmith_api.api.core.MultipartField +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.io.InputStream +import java.io.OutputStream +import kotlin.jvm.optionals.getOrNull +import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder +import org.apache.hc.core5.http.ContentType +import org.apache.hc.core5.http.HttpEntity + +@JvmSynthetic +internal inline fun json(jsonMapper: JsonMapper, value: T): HttpRequestBody = + object : HttpRequestBody { + private val bytes: ByteArray by lazy { jsonMapper.writeValueAsBytes(value) } + + override fun writeTo(outputStream: OutputStream) = outputStream.write(bytes) + + override fun contentType(): String = "application/json" + + override fun contentLength(): Long = bytes.size.toLong() + + override fun repeatable(): Boolean = true + + override fun close() {} + } + +@JvmSynthetic +internal fun multipartFormData( + jsonMapper: JsonMapper, + fields: Map>, +): HttpRequestBody = + object : HttpRequestBody { + private val entity: HttpEntity by lazy { + MultipartEntityBuilder.create() + .apply { + fields.forEach { (name, field) -> + val knownValue = field.value.asKnown().getOrNull() + val parts = + if (knownValue is InputStream) { + // Read directly from the `InputStream` instead of reading it all + // into memory due to the `jsonMapper` serialization below. + sequenceOf(name to knownValue) + } else { + val node = jsonMapper.valueToTree(field.value) + serializePart(name, node) + } + + parts.forEach { (name, bytes) -> + addBinaryBody( + name, + bytes, + ContentType.parseLenient(field.contentType), + field.filename().getOrNull(), + ) + } + } + } + .build() + } + + private fun serializePart( + name: String, + node: JsonNode, + ): Sequence> = + when (node.nodeType) { + JsonNodeType.MISSING, + JsonNodeType.NULL -> emptySequence() + JsonNodeType.BINARY -> sequenceOf(name to node.binaryValue().inputStream()) + JsonNodeType.STRING -> sequenceOf(name to node.textValue().inputStream()) + JsonNodeType.BOOLEAN -> + sequenceOf(name to node.booleanValue().toString().inputStream()) + JsonNodeType.NUMBER -> + sequenceOf(name to node.numberValue().toString().inputStream()) + JsonNodeType.ARRAY -> + sequenceOf( + name to + node + .elements() + .asSequence() + .mapNotNull { element -> + when (element.nodeType) { + JsonNodeType.MISSING, + JsonNodeType.NULL -> null + JsonNodeType.STRING -> node.textValue() + JsonNodeType.BOOLEAN -> node.booleanValue().toString() + JsonNodeType.NUMBER -> node.numberValue().toString() + null, + JsonNodeType.BINARY, + JsonNodeType.ARRAY, + JsonNodeType.OBJECT, + JsonNodeType.POJO -> + throw LangsmithApiInvalidDataException( + "Unexpected JsonNode type in array: ${node.nodeType}" + ) + } + } + .joinToString(",") + .inputStream() + ) + JsonNodeType.OBJECT -> + node.fields().asSequence().flatMap { (key, value) -> + serializePart("$name[$key]", value) + } + JsonNodeType.POJO, + null -> + throw LangsmithApiInvalidDataException( + "Unexpected JsonNode type: ${node.nodeType}" + ) + } + + private fun String.inputStream(): InputStream = toByteArray().inputStream() + + override fun writeTo(outputStream: OutputStream) = entity.writeTo(outputStream) + + override fun contentType(): String = entity.contentType + + override fun contentLength(): Long = entity.contentLength + + override fun repeatable(): Boolean = entity.isRepeatable + + override fun close() = entity.close() + } diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/HttpRequestBody.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/HttpRequestBody.kt new file mode 100644 index 00000000..79a7eb9a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/HttpRequestBody.kt @@ -0,0 +1,25 @@ +package com.langsmith_api.api.core.http + +import java.io.OutputStream +import java.lang.AutoCloseable + +interface HttpRequestBody : AutoCloseable { + + fun writeTo(outputStream: OutputStream) + + fun contentType(): String? + + fun contentLength(): Long + + /** + * 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. + */ + fun repeatable(): Boolean + + /** Overridden from [AutoCloseable] to not have a checked exception in its signature. */ + override fun close() +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/HttpResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/HttpResponse.kt new file mode 100644 index 00000000..79cf9bbb --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/HttpResponse.kt @@ -0,0 +1,22 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.core.http + +import java.io.InputStream + +interface HttpResponse : AutoCloseable { + + fun statusCode(): Int + + fun headers(): Headers + + fun body(): InputStream + + /** Overridden from [AutoCloseable] to not have a checked exception in its signature. */ + override fun close() + + interface Handler { + + fun handle(response: HttpResponse): T + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/HttpResponseFor.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/HttpResponseFor.kt new file mode 100644 index 00000000..ff5b7055 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/HttpResponseFor.kt @@ -0,0 +1,25 @@ +package com.langsmith_api.api.core.http + +import java.io.InputStream + +interface HttpResponseFor : HttpResponse { + + fun parse(): T +} + +@JvmSynthetic +internal fun HttpResponse.parseable(parse: () -> T): HttpResponseFor = + object : HttpResponseFor { + + private val parsed: T by lazy { parse() } + + override fun parse(): T = parsed + + override fun statusCode(): Int = this@parseable.statusCode() + + override fun headers(): Headers = this@parseable.headers() + + override fun body(): InputStream = this@parseable.body() + + override fun close() = this@parseable.close() + } diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/PhantomReachableClosingAsyncStreamResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/PhantomReachableClosingAsyncStreamResponse.kt new file mode 100644 index 00000000..a5d21a5e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/PhantomReachableClosingAsyncStreamResponse.kt @@ -0,0 +1,56 @@ +package com.langsmith_api.api.core.http + +import com.langsmith_api.api.core.closeWhenPhantomReachable +import com.langsmith_api.api.core.http.AsyncStreamResponse.Handler +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor + +/** + * A delegating wrapper around an `AsyncStreamResponse` that closes it once it's only phantom + * reachable. + * + * This class ensures the `AsyncStreamResponse` is closed even if the user forgets to close it. + */ +internal class PhantomReachableClosingAsyncStreamResponse( + private val asyncStreamResponse: AsyncStreamResponse +) : AsyncStreamResponse { + + /** + * An object used for keeping `asyncStreamResponse` open while the object is still reachable. + */ + private val reachabilityTracker = Object() + + init { + closeWhenPhantomReachable(reachabilityTracker, asyncStreamResponse::close) + } + + override fun subscribe(handler: Handler): AsyncStreamResponse = apply { + asyncStreamResponse.subscribe(TrackedHandler(handler, reachabilityTracker)) + } + + override fun subscribe(handler: Handler, executor: Executor): AsyncStreamResponse = + apply { + asyncStreamResponse.subscribe(TrackedHandler(handler, reachabilityTracker), executor) + } + + override fun onCompleteFuture(): CompletableFuture = + asyncStreamResponse.onCompleteFuture() + + override fun close() = asyncStreamResponse.close() +} + +/** + * A wrapper around a `Handler` that also references a `reachabilityTracker` object. + * + * Referencing the `reachabilityTracker` object prevents it from getting reclaimed while the handler + * is still reachable. + */ +private class TrackedHandler( + private val handler: Handler, + private val reachabilityTracker: Any, +) : Handler { + override fun onNext(value: T) = handler.onNext(value) + + override fun onComplete(error: Optional) = handler.onComplete(error) +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/PhantomReachableClosingHttpClient.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/PhantomReachableClosingHttpClient.kt new file mode 100644 index 00000000..e4110bfc --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/PhantomReachableClosingHttpClient.kt @@ -0,0 +1,26 @@ +package com.langsmith_api.api.core.http + +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.closeWhenPhantomReachable +import java.util.concurrent.CompletableFuture + +/** + * A delegating wrapper around an `HttpClient` that closes it once it's only phantom reachable. + * + * This class ensures the `HttpClient` is closed even if the user forgets to close it. + */ +internal class PhantomReachableClosingHttpClient(private val httpClient: HttpClient) : HttpClient { + init { + closeWhenPhantomReachable(this, httpClient) + } + + override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse = + httpClient.execute(request, requestOptions) + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture = httpClient.executeAsync(request, requestOptions) + + override fun close() = httpClient.close() +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/PhantomReachableClosingStreamResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/PhantomReachableClosingStreamResponse.kt new file mode 100644 index 00000000..dc10248f --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/PhantomReachableClosingStreamResponse.kt @@ -0,0 +1,21 @@ +package com.langsmith_api.api.core.http + +import com.langsmith_api.api.core.closeWhenPhantomReachable +import java.util.stream.Stream + +/** + * A delegating wrapper around a `StreamResponse` that closes it once it's only phantom reachable. + * + * This class ensures the `StreamResponse` is closed even if the user forgets to close it. + */ +internal class PhantomReachableClosingStreamResponse( + private val streamResponse: StreamResponse +) : StreamResponse { + init { + closeWhenPhantomReachable(this, streamResponse) + } + + override fun stream(): Stream = streamResponse.stream() + + override fun close() = streamResponse.close() +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/QueryParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/QueryParams.kt new file mode 100644 index 00000000..af25eb70 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/QueryParams.kt @@ -0,0 +1,129 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.core.http + +import com.langsmith_api.api.core.JsonArray +import com.langsmith_api.api.core.JsonBoolean +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonNull +import com.langsmith_api.api.core.JsonNumber +import com.langsmith_api.api.core.JsonObject +import com.langsmith_api.api.core.JsonString +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.toImmutable + +class QueryParams +private constructor( + private val map: Map>, + @get:JvmName("size") val size: Int, +) { + + fun isEmpty(): Boolean = map.isEmpty() + + fun keys(): Set = map.keys + + fun values(key: String): List = map[key].orEmpty() + + fun toBuilder(): Builder = Builder().putAll(map) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder internal constructor() { + + private val map: MutableMap> = mutableMapOf() + private var size: Int = 0 + + fun put(key: String, value: JsonValue): Builder = apply { + when (value) { + is JsonMissing, + is JsonNull -> {} + is JsonBoolean -> put(key, value.value.toString()) + is JsonNumber -> put(key, value.value.toString()) + is JsonString -> put(key, value.value) + is JsonArray -> + put( + key, + value.values + .asSequence() + .mapNotNull { + when (it) { + is JsonMissing, + is JsonNull -> null + is JsonBoolean -> it.value.toString() + is JsonNumber -> it.value.toString() + is JsonString -> it.value + is JsonArray, + is JsonObject -> + throw IllegalArgumentException( + "Cannot comma separate non-primitives in query params" + ) + } + } + .joinToString(","), + ) + is JsonObject -> + value.values.forEach { (nestedKey, value) -> put("$key[$nestedKey]", value) } + } + } + + fun put(key: String, value: String) = apply { + map.getOrPut(key) { mutableListOf() }.add(value) + size++ + } + + fun put(key: String, values: Iterable) = apply { values.forEach { put(key, it) } } + + fun putAll(queryParams: Map>) = apply { + queryParams.forEach(::put) + } + + fun putAll(queryParams: QueryParams) = apply { + queryParams.keys().forEach { put(it, queryParams.values(it)) } + } + + fun replace(key: String, value: String) = apply { + remove(key) + put(key, value) + } + + fun replace(key: String, values: Iterable) = apply { + remove(key) + put(key, values) + } + + fun replaceAll(queryParams: Map>) = apply { + queryParams.forEach(::replace) + } + + fun replaceAll(queryParams: QueryParams) = apply { + queryParams.keys().forEach { replace(it, queryParams.values(it)) } + } + + fun remove(key: String) = apply { size -= map.remove(key).orEmpty().size } + + fun removeAll(keys: Set) = apply { keys.forEach(::remove) } + + fun clear() = apply { + map.clear() + size = 0 + } + + fun build() = + QueryParams(map.mapValues { (_, values) -> values.toImmutable() }.toImmutable(), size) + } + + override fun hashCode(): Int = map.hashCode() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is QueryParams && map == other.map + } + + override fun toString(): String = "QueryParams{map=$map}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/RetryingHttpClient.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/RetryingHttpClient.kt new file mode 100644 index 00000000..5ce0a085 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/RetryingHttpClient.kt @@ -0,0 +1,265 @@ +package com.langsmith_api.api.core.http + +import com.langsmith_api.api.core.DefaultSleeper +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.Sleeper +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiIoException +import com.langsmith_api.api.errors.LangsmithApiRetryableException +import java.io.IOException +import java.time.Clock +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.time.format.DateTimeParseException +import java.time.temporal.ChronoUnit +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.concurrent.ThreadLocalRandom +import java.util.concurrent.TimeUnit +import java.util.function.Function +import kotlin.math.min +import kotlin.math.pow + +class RetryingHttpClient +private constructor( + private val httpClient: HttpClient, + private val sleeper: Sleeper, + private val clock: Clock, + private val maxRetries: Int, + private val idempotencyHeader: String?, +) : HttpClient { + + override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { + if (!isRetryable(request) || maxRetries <= 0) { + return httpClient.execute(request, requestOptions) + } + + var modifiedRequest = maybeAddIdempotencyHeader(request) + + // Don't send the current retry count in the headers if the caller set their own value. + val shouldSendRetryCount = + !modifiedRequest.headers.names().contains("X-Stainless-Retry-Count") + + var retries = 0 + + while (true) { + if (shouldSendRetryCount) { + modifiedRequest = setRetryCountHeader(modifiedRequest, retries) + } + + val response = + try { + val response = httpClient.execute(modifiedRequest, requestOptions) + if (++retries > maxRetries || !shouldRetry(response)) { + return response + } + + response + } catch (throwable: Throwable) { + if (++retries > maxRetries || !shouldRetry(throwable)) { + throw throwable + } + + null + } + + val backoffDuration = getRetryBackoffDuration(retries, response) + // All responses must be closed, so close the failed one before retrying. + response?.close() + sleeper.sleep(backoffDuration) + } + } + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture { + if (!isRetryable(request) || maxRetries <= 0) { + return httpClient.executeAsync(request, requestOptions) + } + + val modifiedRequest = maybeAddIdempotencyHeader(request) + + // Don't send the current retry count in the headers if the caller set their own value. + val shouldSendRetryCount = + !modifiedRequest.headers.names().contains("X-Stainless-Retry-Count") + + var retries = 0 + + fun executeWithRetries( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture { + val requestWithRetryCount = + if (shouldSendRetryCount) setRetryCountHeader(request, retries) else request + + return httpClient + .executeAsync(requestWithRetryCount, requestOptions) + .handleAsync( + fun( + response: HttpResponse?, + throwable: Throwable?, + ): CompletableFuture { + if (response != null) { + if (++retries > maxRetries || !shouldRetry(response)) { + return CompletableFuture.completedFuture(response) + } + } else { + if (++retries > maxRetries || !shouldRetry(throwable!!)) { + val failedFuture = CompletableFuture() + failedFuture.completeExceptionally(throwable) + return failedFuture + } + } + + val backoffDuration = getRetryBackoffDuration(retries, response) + // All responses must be closed, so close the failed one before retrying. + response?.close() + return sleeper.sleepAsync(backoffDuration).thenCompose { + executeWithRetries(requestWithRetryCount, requestOptions) + } + } + ) { + // Run in the same thread. + it.run() + } + .thenCompose(Function.identity()) + } + + return executeWithRetries(modifiedRequest, requestOptions) + } + + override fun close() { + httpClient.close() + sleeper.close() + } + + private fun isRetryable(request: HttpRequest): Boolean = + // Some requests, such as when a request body is being streamed, cannot be retried because + // the body data aren't available on subsequent attempts. + request.body?.repeatable() ?: true + + private fun setRetryCountHeader(request: HttpRequest, retries: Int): HttpRequest = + request.toBuilder().replaceHeaders("X-Stainless-Retry-Count", retries.toString()).build() + + private fun idempotencyKey(): String = "stainless-java-retry-${UUID.randomUUID()}" + + private fun maybeAddIdempotencyHeader(request: HttpRequest): HttpRequest { + if (idempotencyHeader == null || request.headers.names().contains(idempotencyHeader)) { + return request + } + + return request + .toBuilder() + // Set a header to uniquely identify the request when retried. + .putHeader(idempotencyHeader, idempotencyKey()) + .build() + } + + private fun shouldRetry(response: HttpResponse): Boolean { + // Note: this is not a standard header + val shouldRetryHeader = response.headers().values("X-Should-Retry").getOrNull(0) + val statusCode = response.statusCode() + + return when { + // If the server explicitly says whether to retry, obey + shouldRetryHeader == "true" -> true + shouldRetryHeader == "false" -> false + + // Retry on request timeouts + statusCode == 408 -> true + // Retry on lock timeouts + statusCode == 409 -> true + // Retry on rate limits + statusCode == 429 -> true + // Retry internal errors + statusCode >= 500 -> true + else -> false + } + } + + private fun shouldRetry(throwable: Throwable): Boolean = + // Only retry known retryable exceptions, other exceptions are not intended to be retried. + throwable is IOException || + throwable is LangsmithApiIoException || + throwable is LangsmithApiRetryableException + + private fun getRetryBackoffDuration(retries: Int, response: HttpResponse?): Duration { + // About the Retry-After header: + // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After + response + ?.headers() + ?.let { headers -> + headers + .values("Retry-After-Ms") + .getOrNull(0) + ?.toFloatOrNull() + ?.times(TimeUnit.MILLISECONDS.toNanos(1)) + ?: headers.values("Retry-After").getOrNull(0)?.let { retryAfter -> + retryAfter.toFloatOrNull()?.times(TimeUnit.SECONDS.toNanos(1)) + ?: try { + ChronoUnit.MILLIS.between( + OffsetDateTime.now(clock), + OffsetDateTime.parse( + retryAfter, + DateTimeFormatter.RFC_1123_DATE_TIME, + ), + ) + } catch (e: DateTimeParseException) { + null + } + } + } + ?.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) + + // Apply some jitter + val jitter = 1.0 - 0.25 * ThreadLocalRandom.current().nextDouble() + + return Duration.ofNanos((TimeUnit.SECONDS.toNanos(1) * backoffSeconds * jitter).toLong()) + } + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder internal constructor() { + + private var httpClient: HttpClient? = null + private var sleeper: Sleeper? = null + private var clock: Clock = Clock.systemUTC() + private var maxRetries: Int = 2 + private var idempotencyHeader: String? = null + + fun httpClient(httpClient: HttpClient) = apply { this.httpClient = httpClient } + + fun sleeper(sleeper: Sleeper) = apply { this.sleeper = sleeper } + + fun clock(clock: Clock) = apply { this.clock = clock } + + fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } + + fun idempotencyHeader(header: String) = apply { this.idempotencyHeader = header } + + fun build(): HttpClient = + RetryingHttpClient( + checkRequired("httpClient", httpClient), + sleeper ?: DefaultSleeper(), + clock, + maxRetries, + idempotencyHeader, + ) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/StreamResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/StreamResponse.kt new file mode 100644 index 00000000..0cb15531 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/core/http/StreamResponse.kt @@ -0,0 +1,19 @@ +package com.langsmith_api.api.core.http + +import java.util.stream.Stream + +interface StreamResponse : AutoCloseable { + + fun stream(): Stream + + /** Overridden from [AutoCloseable] to not have a checked exception in its signature. */ + override fun close() +} + +@JvmSynthetic +internal fun StreamResponse.map(transform: (T) -> R): StreamResponse = + object : StreamResponse { + override fun stream(): Stream = this@map.stream().map(transform) + + override fun close() = this@map.close() + } diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/BadRequestException.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/BadRequestException.kt new file mode 100644 index 00000000..f15878a7 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/BadRequestException.kt @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.errors + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BadRequestException +private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : + LangsmithApiServiceException("400: $body", cause) { + + override fun statusCode(): Int = 400 + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BadRequestException]. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BadRequestException]. */ + class Builder internal constructor() { + + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(badRequestException: BadRequestException) = apply { + headers = badRequestException.headers + body = badRequestException.body + cause = badRequestException.cause + } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) + + /** + * Returns an immutable instance of [BadRequestException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BadRequestException = + BadRequestException( + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/InternalServerException.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/InternalServerException.kt new file mode 100644 index 00000000..76a7a127 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/InternalServerException.kt @@ -0,0 +1,91 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.errors + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class InternalServerException +private constructor( + private val statusCode: Int, + private val headers: Headers, + private val body: JsonValue, + cause: Throwable?, +) : LangsmithApiServiceException("$statusCode: $body", cause) { + + override fun statusCode(): Int = statusCode + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InternalServerException]. + * + * The following fields are required: + * ```java + * .statusCode() + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InternalServerException]. */ + class Builder internal constructor() { + + private var statusCode: Int? = null + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(internalServerException: InternalServerException) = apply { + statusCode = internalServerException.statusCode + headers = internalServerException.headers + body = internalServerException.body + cause = internalServerException.cause + } + + fun statusCode(statusCode: Int) = apply { this.statusCode = statusCode } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) + + /** + * Returns an immutable instance of [InternalServerException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .statusCode() + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InternalServerException = + InternalServerException( + checkRequired("statusCode", statusCode), + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/LangsmithApiException.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/LangsmithApiException.kt new file mode 100644 index 00000000..280f3620 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/LangsmithApiException.kt @@ -0,0 +1,5 @@ +package com.langsmith_api.api.errors + +open class LangsmithApiException +@JvmOverloads +constructor(message: String? = null, cause: Throwable? = null) : RuntimeException(message, cause) diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/LangsmithApiInvalidDataException.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/LangsmithApiInvalidDataException.kt new file mode 100644 index 00000000..3be530c8 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/LangsmithApiInvalidDataException.kt @@ -0,0 +1,6 @@ +package com.langsmith_api.api.errors + +class LangsmithApiInvalidDataException +@JvmOverloads +constructor(message: String? = null, cause: Throwable? = null) : + LangsmithApiException(message, cause) diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/LangsmithApiIoException.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/LangsmithApiIoException.kt new file mode 100644 index 00000000..b8bfdecb --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/LangsmithApiIoException.kt @@ -0,0 +1,6 @@ +package com.langsmith_api.api.errors + +class LangsmithApiIoException +@JvmOverloads +constructor(message: String? = null, cause: Throwable? = null) : + LangsmithApiException(message, cause) diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/LangsmithApiRetryableException.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/LangsmithApiRetryableException.kt new file mode 100644 index 00000000..151f1df8 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/LangsmithApiRetryableException.kt @@ -0,0 +1,15 @@ +package com.langsmith_api.api.errors + +/** + * Exception that indicates a transient error that can be retried. + * + * When this exception is thrown during an HTTP request, the SDK will automatically retry the + * request up to the maximum number of retries. + * + * @param message A descriptive error message + * @param cause The underlying cause of this exception, if any + */ +class LangsmithApiRetryableException +@JvmOverloads +constructor(message: String? = null, cause: Throwable? = null) : + LangsmithApiException(message, cause) diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/LangsmithApiServiceException.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/LangsmithApiServiceException.kt new file mode 100644 index 00000000..a6bfa97c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/LangsmithApiServiceException.kt @@ -0,0 +1,17 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.errors + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.http.Headers + +abstract class LangsmithApiServiceException +protected constructor(message: String, cause: Throwable? = null) : + LangsmithApiException(message, cause) { + + abstract fun statusCode(): Int + + abstract fun headers(): Headers + + abstract fun body(): JsonValue +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/NotFoundException.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/NotFoundException.kt new file mode 100644 index 00000000..57c96855 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/NotFoundException.kt @@ -0,0 +1,76 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.errors + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class NotFoundException +private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : + LangsmithApiServiceException("404: $body", cause) { + + override fun statusCode(): Int = 404 + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [NotFoundException]. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NotFoundException]. */ + class Builder internal constructor() { + + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(notFoundException: NotFoundException) = apply { + headers = notFoundException.headers + body = notFoundException.body + cause = notFoundException.cause + } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) + + /** + * Returns an immutable instance of [NotFoundException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): NotFoundException = + NotFoundException(checkRequired("headers", headers), checkRequired("body", body), cause) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/PermissionDeniedException.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/PermissionDeniedException.kt new file mode 100644 index 00000000..35fb2ba2 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/PermissionDeniedException.kt @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.errors + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class PermissionDeniedException +private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : + LangsmithApiServiceException("403: $body", cause) { + + override fun statusCode(): Int = 403 + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PermissionDeniedException]. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PermissionDeniedException]. */ + class Builder internal constructor() { + + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(permissionDeniedException: PermissionDeniedException) = apply { + headers = permissionDeniedException.headers + body = permissionDeniedException.body + cause = permissionDeniedException.cause + } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) + + /** + * Returns an immutable instance of [PermissionDeniedException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PermissionDeniedException = + PermissionDeniedException( + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/RateLimitException.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/RateLimitException.kt new file mode 100644 index 00000000..25e99609 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/RateLimitException.kt @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.errors + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class RateLimitException +private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : + LangsmithApiServiceException("429: $body", cause) { + + override fun statusCode(): Int = 429 + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RateLimitException]. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RateLimitException]. */ + class Builder internal constructor() { + + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(rateLimitException: RateLimitException) = apply { + headers = rateLimitException.headers + body = rateLimitException.body + cause = rateLimitException.cause + } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) + + /** + * Returns an immutable instance of [RateLimitException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RateLimitException = + RateLimitException( + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/UnauthorizedException.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/UnauthorizedException.kt new file mode 100644 index 00000000..9b5f3050 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/UnauthorizedException.kt @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.errors + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class UnauthorizedException +private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : + LangsmithApiServiceException("401: $body", cause) { + + override fun statusCode(): Int = 401 + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnauthorizedException]. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnauthorizedException]. */ + class Builder internal constructor() { + + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(unauthorizedException: UnauthorizedException) = apply { + headers = unauthorizedException.headers + body = unauthorizedException.body + cause = unauthorizedException.cause + } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) + + /** + * Returns an immutable instance of [UnauthorizedException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnauthorizedException = + UnauthorizedException( + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/UnexpectedStatusCodeException.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/UnexpectedStatusCodeException.kt new file mode 100644 index 00000000..c20bbfa3 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/UnexpectedStatusCodeException.kt @@ -0,0 +1,92 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.errors + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class UnexpectedStatusCodeException +private constructor( + private val statusCode: Int, + private val headers: Headers, + private val body: JsonValue, + cause: Throwable?, +) : LangsmithApiServiceException("$statusCode: $body", cause) { + + override fun statusCode(): Int = statusCode + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnexpectedStatusCodeException]. + * + * The following fields are required: + * ```java + * .statusCode() + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnexpectedStatusCodeException]. */ + class Builder internal constructor() { + + private var statusCode: Int? = null + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(unexpectedStatusCodeException: UnexpectedStatusCodeException) = apply { + statusCode = unexpectedStatusCodeException.statusCode + headers = unexpectedStatusCodeException.headers + body = unexpectedStatusCodeException.body + cause = unexpectedStatusCodeException.cause + } + + fun statusCode(statusCode: Int) = apply { this.statusCode = statusCode } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) + + /** + * Returns an immutable instance of [UnexpectedStatusCodeException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .statusCode() + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnexpectedStatusCodeException = + UnexpectedStatusCodeException( + checkRequired("statusCode", statusCode), + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/UnprocessableEntityException.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/UnprocessableEntityException.kt new file mode 100644 index 00000000..8a91a91f --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/errors/UnprocessableEntityException.kt @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.errors + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class UnprocessableEntityException +private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : + LangsmithApiServiceException("422: $body", cause) { + + override fun statusCode(): Int = 422 + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnprocessableEntityException]. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnprocessableEntityException]. */ + class Builder internal constructor() { + + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(unprocessableEntityException: UnprocessableEntityException) = apply { + headers = unprocessableEntityException.headers + body = unprocessableEntityException.body + cause = unprocessableEntityException.cause + } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) + + /** + * Returns an immutable instance of [UnprocessableEntityException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnprocessableEntityException = + UnprocessableEntityException( + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/V1EventsParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/V1EventsParams.kt new file mode 100644 index 00000000..7d3b2257 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/V1EventsParams.kt @@ -0,0 +1,731 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1 + +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.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create Event */ +class V1EventsParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun eventType(): EventType = body.eventType() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun owner(): String = body.owner() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun repo(): String = body.repo() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun commit(): Optional = body.commit() + + /** + * Returns the raw JSON value of [eventType]. + * + * Unlike [eventType], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _eventType(): JsonField = body._eventType() + + /** + * Returns the raw JSON value of [owner]. + * + * Unlike [owner], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _owner(): JsonField = body._owner() + + /** + * Returns the raw JSON value of [repo]. + * + * Unlike [repo], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _repo(): JsonField = body._repo() + + /** + * Returns the raw JSON value of [commit]. + * + * Unlike [commit], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _commit(): JsonField = body._commit() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [V1EventsParams]. + * + * The following fields are required: + * ```java + * .eventType() + * .owner() + * .repo() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [V1EventsParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(v1EventsParams: V1EventsParams) = apply { + body = v1EventsParams.body.toBuilder() + additionalHeaders = v1EventsParams.additionalHeaders.toBuilder() + additionalQueryParams = v1EventsParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [eventType] + * - [owner] + * - [repo] + * - [commit] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun eventType(eventType: EventType) = apply { body.eventType(eventType) } + + /** + * Sets [Builder.eventType] to an arbitrary JSON value. + * + * You should usually call [Builder.eventType] with a well-typed [EventType] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun eventType(eventType: JsonField) = apply { body.eventType(eventType) } + + fun owner(owner: String) = apply { body.owner(owner) } + + /** + * Sets [Builder.owner] to an arbitrary JSON value. + * + * You should usually call [Builder.owner] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun owner(owner: JsonField) = apply { body.owner(owner) } + + fun repo(repo: String) = apply { body.repo(repo) } + + /** + * Sets [Builder.repo] to an arbitrary JSON value. + * + * You should usually call [Builder.repo] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun repo(repo: JsonField) = apply { body.repo(repo) } + + fun commit(commit: String?) = apply { body.commit(commit) } + + /** Alias for calling [Builder.commit] with `commit.orElse(null)`. */ + fun commit(commit: Optional) = commit(commit.getOrNull()) + + /** + * Sets [Builder.commit] to an arbitrary JSON value. + * + * You should usually call [Builder.commit] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun commit(commit: JsonField) = apply { body.commit(commit) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [V1EventsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .eventType() + * .owner() + * .repo() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): V1EventsParams = + V1EventsParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val eventType: JsonField, + private val owner: JsonField, + private val repo: JsonField, + private val commit: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + @JsonProperty("owner") @ExcludeMissing owner: JsonField = JsonMissing.of(), + @JsonProperty("repo") @ExcludeMissing repo: JsonField = JsonMissing.of(), + @JsonProperty("commit") @ExcludeMissing commit: JsonField = JsonMissing.of(), + ) : this(eventType, owner, repo, commit, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun eventType(): EventType = eventType.getRequired("event_type") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun owner(): String = owner.getRequired("owner") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun repo(): String = repo.getRequired("repo") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun commit(): Optional = commit.getOptional("commit") + + /** + * Returns the raw JSON value of [eventType]. + * + * Unlike [eventType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("event_type") + @ExcludeMissing + fun _eventType(): JsonField = eventType + + /** + * Returns the raw JSON value of [owner]. + * + * Unlike [owner], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("owner") @ExcludeMissing fun _owner(): JsonField = owner + + /** + * Returns the raw JSON value of [repo]. + * + * Unlike [repo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("repo") @ExcludeMissing fun _repo(): JsonField = repo + + /** + * Returns the raw JSON value of [commit]. + * + * Unlike [commit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("commit") @ExcludeMissing fun _commit(): JsonField = commit + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .eventType() + * .owner() + * .repo() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var eventType: JsonField? = null + private var owner: JsonField? = null + private var repo: JsonField? = null + private var commit: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + eventType = body.eventType + owner = body.owner + repo = body.repo + commit = body.commit + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun eventType(eventType: EventType) = eventType(JsonField.of(eventType)) + + /** + * Sets [Builder.eventType] to an arbitrary JSON value. + * + * You should usually call [Builder.eventType] with a well-typed [EventType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun eventType(eventType: JsonField) = apply { this.eventType = eventType } + + fun owner(owner: String) = owner(JsonField.of(owner)) + + /** + * Sets [Builder.owner] to an arbitrary JSON value. + * + * You should usually call [Builder.owner] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun owner(owner: JsonField) = apply { this.owner = owner } + + fun repo(repo: String) = repo(JsonField.of(repo)) + + /** + * Sets [Builder.repo] to an arbitrary JSON value. + * + * You should usually call [Builder.repo] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun repo(repo: JsonField) = apply { this.repo = repo } + + fun commit(commit: String?) = commit(JsonField.ofNullable(commit)) + + /** Alias for calling [Builder.commit] with `commit.orElse(null)`. */ + fun commit(commit: Optional) = commit(commit.getOrNull()) + + /** + * Sets [Builder.commit] to an arbitrary JSON value. + * + * You should usually call [Builder.commit] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun commit(commit: JsonField) = apply { this.commit = commit } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .eventType() + * .owner() + * .repo() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("eventType", eventType), + checkRequired("owner", owner), + checkRequired("repo", repo), + commit, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + eventType().validate() + owner() + repo() + commit() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + (if (owner.asKnown().isPresent) 1 else 0) + + (if (repo.asKnown().isPresent) 1 else 0) + + (if (commit.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + eventType == other.eventType && + owner == other.owner && + repo == other.repo && + commit == other.commit && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(eventType, owner, repo, commit, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{eventType=$eventType, owner=$owner, repo=$repo, commit=$commit, additionalProperties=$additionalProperties}" + } + + class EventType @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PLAYGROUND_VIEW = of("playground-view") + + @JvmField val PLAYGROUND_RUN = of("playground-run") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + PLAYGROUND_VIEW, + PLAYGROUND_RUN, + } + + /** + * An enum containing [EventType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [EventType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PLAYGROUND_VIEW, + PLAYGROUND_RUN, + /** + * An enum member indicating that [EventType] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PLAYGROUND_VIEW -> Value.PLAYGROUND_VIEW + PLAYGROUND_RUN -> Value.PLAYGROUND_RUN + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PLAYGROUND_VIEW -> Known.PLAYGROUND_VIEW + PLAYGROUND_RUN -> Known.PLAYGROUND_RUN + else -> throw LangsmithApiInvalidDataException("Unknown EventType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): EventType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is V1EventsParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "V1EventsParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/V1EventsResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/V1EventsResponse.kt new file mode 100644 index 00000000..cf7f3f65 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/V1EventsResponse.kt @@ -0,0 +1,113 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1 + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class V1EventsResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [V1EventsResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [V1EventsResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(v1EventsResponse: V1EventsResponse) = apply { + additionalProperties = v1EventsResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [V1EventsResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): V1EventsResponse = V1EventsResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): V1EventsResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is V1EventsResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "V1EventsResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/V1LoginParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/V1LoginParams.kt new file mode 100644 index 00000000..4aafc119 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/V1LoginParams.kt @@ -0,0 +1,210 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1 + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional + +/** Login */ +class V1LoginParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): V1LoginParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [V1LoginParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [V1LoginParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(v1LoginParams: V1LoginParams) = apply { + additionalHeaders = v1LoginParams.additionalHeaders.toBuilder() + additionalQueryParams = v1LoginParams.additionalQueryParams.toBuilder() + additionalBodyProperties = v1LoginParams.additionalBodyProperties.toMutableMap() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [V1LoginParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): V1LoginParams = + V1LoginParams( + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is V1LoginParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "V1LoginParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/V1LoginResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/V1LoginResponse.kt new file mode 100644 index 00000000..dbe57d59 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/V1LoginResponse.kt @@ -0,0 +1,175 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1 + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class V1LoginResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val accessToken: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("access_token") + @ExcludeMissing + accessToken: JsonField = JsonMissing.of() + ) : this(accessToken, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun accessToken(): String = accessToken.getRequired("access_token") + + /** + * Returns the raw JSON value of [accessToken]. + * + * Unlike [accessToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("access_token") + @ExcludeMissing + fun _accessToken(): JsonField = accessToken + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [V1LoginResponse]. + * + * The following fields are required: + * ```java + * .accessToken() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [V1LoginResponse]. */ + class Builder internal constructor() { + + private var accessToken: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(v1LoginResponse: V1LoginResponse) = apply { + accessToken = v1LoginResponse.accessToken + additionalProperties = v1LoginResponse.additionalProperties.toMutableMap() + } + + fun accessToken(accessToken: String) = accessToken(JsonField.of(accessToken)) + + /** + * Sets [Builder.accessToken] to an arbitrary JSON value. + * + * You should usually call [Builder.accessToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun accessToken(accessToken: JsonField) = apply { this.accessToken = accessToken } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [V1LoginResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accessToken() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): V1LoginResponse = + V1LoginResponse( + checkRequired("accessToken", accessToken), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): V1LoginResponse = apply { + if (validated) { + return@apply + } + + accessToken() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (accessToken.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is V1LoginResponse && + accessToken == other.accessToken && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(accessToken, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "V1LoginResponse{accessToken=$accessToken, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/V1RetrieveOkParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/V1RetrieveOkParams.kt new file mode 100644 index 00000000..48749e2a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/V1RetrieveOkParams.kt @@ -0,0 +1,170 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1 + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** Ok */ +class V1RetrieveOkParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): V1RetrieveOkParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [V1RetrieveOkParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [V1RetrieveOkParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(v1RetrieveOkParams: V1RetrieveOkParams) = apply { + additionalHeaders = v1RetrieveOkParams.additionalHeaders.toBuilder() + additionalQueryParams = v1RetrieveOkParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [V1RetrieveOkParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): V1RetrieveOkParams = + V1RetrieveOkParams(additionalHeaders.build(), additionalQueryParams.build()) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is V1RetrieveOkParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "V1RetrieveOkParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/V1RetrieveOkResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/V1RetrieveOkResponse.kt new file mode 100644 index 00000000..29c20b66 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/V1RetrieveOkResponse.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1 + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class V1RetrieveOkResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [V1RetrieveOkResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [V1RetrieveOkResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(v1RetrieveOkResponse: V1RetrieveOkResponse) = apply { + additionalProperties = v1RetrieveOkResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [V1RetrieveOkResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): V1RetrieveOkResponse = + V1RetrieveOkResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): V1RetrieveOkResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is V1RetrieveOkResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "V1RetrieveOkResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/V1UpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/V1UpdateParams.kt new file mode 100644 index 00000000..ab11cbac --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/V1UpdateParams.kt @@ -0,0 +1,441 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1 + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Like a repo. */ +class V1UpdateParams +private constructor( + private val owner: String, + private val repo: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun owner(): String = owner + + fun repo(): Optional = Optional.ofNullable(repo) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun like(): Boolean = body.like() + + /** + * Returns the raw JSON value of [like]. + * + * Unlike [like], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _like(): JsonField = body._like() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [V1UpdateParams]. + * + * The following fields are required: + * ```java + * .owner() + * .like() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [V1UpdateParams]. */ + class Builder internal constructor() { + + private var owner: String? = null + private var repo: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(v1UpdateParams: V1UpdateParams) = apply { + owner = v1UpdateParams.owner + repo = v1UpdateParams.repo + body = v1UpdateParams.body.toBuilder() + additionalHeaders = v1UpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = v1UpdateParams.additionalQueryParams.toBuilder() + } + + fun owner(owner: String) = apply { this.owner = owner } + + fun repo(repo: String?) = apply { this.repo = repo } + + /** Alias for calling [Builder.repo] with `repo.orElse(null)`. */ + fun repo(repo: Optional) = repo(repo.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [like] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun like(like: Boolean) = apply { body.like(like) } + + /** + * Sets [Builder.like] to an arbitrary JSON value. + * + * You should usually call [Builder.like] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun like(like: JsonField) = apply { body.like(like) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [V1UpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .owner() + * .like() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): V1UpdateParams = + V1UpdateParams( + checkRequired("owner", owner), + repo, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> owner + 1 -> repo ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val like: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("like") @ExcludeMissing like: JsonField = JsonMissing.of() + ) : this(like, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun like(): Boolean = like.getRequired("like") + + /** + * Returns the raw JSON value of [like]. + * + * Unlike [like], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("like") @ExcludeMissing fun _like(): JsonField = like + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .like() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var like: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + like = body.like + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun like(like: Boolean) = like(JsonField.of(like)) + + /** + * Sets [Builder.like] to an arbitrary JSON value. + * + * You should usually call [Builder.like] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun like(like: JsonField) = apply { this.like = like } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .like() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body(checkRequired("like", like), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + like() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (like.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + like == other.like && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(like, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Body{like=$like, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is V1UpdateParams && + owner == other.owner && + repo == other.repo && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(owner, repo, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "V1UpdateParams{owner=$owner, repo=$repo, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/V1UpdateResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/V1UpdateResponse.kt new file mode 100644 index 00000000..2a0005ee --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/V1UpdateResponse.kt @@ -0,0 +1,167 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1 + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class V1UpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val likes: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("likes") @ExcludeMissing likes: JsonField = JsonMissing.of() + ) : this(likes, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun likes(): Long = likes.getRequired("likes") + + /** + * Returns the raw JSON value of [likes]. + * + * Unlike [likes], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("likes") @ExcludeMissing fun _likes(): JsonField = likes + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [V1UpdateResponse]. + * + * The following fields are required: + * ```java + * .likes() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [V1UpdateResponse]. */ + class Builder internal constructor() { + + private var likes: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(v1UpdateResponse: V1UpdateResponse) = apply { + likes = v1UpdateResponse.likes + additionalProperties = v1UpdateResponse.additionalProperties.toMutableMap() + } + + fun likes(likes: Long) = likes(JsonField.of(likes)) + + /** + * Sets [Builder.likes] to an arbitrary JSON value. + * + * You should usually call [Builder.likes] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun likes(likes: JsonField) = apply { this.likes = likes } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [V1UpdateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .likes() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): V1UpdateResponse = + V1UpdateResponse(checkRequired("likes", likes), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): V1UpdateResponse = apply { + if (validated) { + return@apply + } + + likes() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (likes.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is V1UpdateResponse && + likes == other.likes && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(likes, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "V1UpdateResponse{likes=$likes, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/ace/AceExecuteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/ace/AceExecuteParams.kt new file mode 100644 index 00000000..fbd5004a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/ace/AceExecuteParams.kt @@ -0,0 +1,557 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.ace + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** Execute some custom code for testing purposes. */ +class AceExecuteParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun args(): List = body.args() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): String = body.code() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun language(): String = body.language() + + /** + * Returns the raw JSON value of [args]. + * + * Unlike [args], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _args(): JsonField> = body._args() + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _code(): JsonField = body._code() + + /** + * Returns the raw JSON value of [language]. + * + * Unlike [language], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _language(): JsonField = body._language() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AceExecuteParams]. + * + * The following fields are required: + * ```java + * .args() + * .code() + * .language() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AceExecuteParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(aceExecuteParams: AceExecuteParams) = apply { + body = aceExecuteParams.body.toBuilder() + additionalHeaders = aceExecuteParams.additionalHeaders.toBuilder() + additionalQueryParams = aceExecuteParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [args] + * - [code] + * - [language] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun args(args: List) = apply { body.args(args) } + + /** + * Sets [Builder.args] to an arbitrary JSON value. + * + * You should usually call [Builder.args] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun args(args: JsonField>) = apply { body.args(args) } + + /** + * Adds a single [JsonValue] to [args]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addArg(arg: JsonValue) = apply { body.addArg(arg) } + + fun code(code: String) = apply { body.code(code) } + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun code(code: JsonField) = apply { body.code(code) } + + fun language(language: String) = apply { body.language(language) } + + /** + * Sets [Builder.language] to an arbitrary JSON value. + * + * You should usually call [Builder.language] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun language(language: JsonField) = apply { body.language(language) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [AceExecuteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .args() + * .code() + * .language() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AceExecuteParams = + AceExecuteParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val args: JsonField>, + private val code: JsonField, + private val language: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("args") + @ExcludeMissing + args: JsonField> = JsonMissing.of(), + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("language") @ExcludeMissing language: JsonField = JsonMissing.of(), + ) : this(args, code, language, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun args(): List = args.getRequired("args") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): String = code.getRequired("code") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun language(): String = language.getRequired("language") + + /** + * Returns the raw JSON value of [args]. + * + * Unlike [args], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("args") @ExcludeMissing fun _args(): JsonField> = args + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [language]. + * + * Unlike [language], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("language") @ExcludeMissing fun _language(): JsonField = language + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .args() + * .code() + * .language() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var args: JsonField>? = null + private var code: JsonField? = null + private var language: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + args = body.args.map { it.toMutableList() } + code = body.code + language = body.language + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun args(args: List) = args(JsonField.of(args)) + + /** + * Sets [Builder.args] to an arbitrary JSON value. + * + * You should usually call [Builder.args] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun args(args: JsonField>) = apply { + this.args = args.map { it.toMutableList() } + } + + /** + * Adds a single [JsonValue] to [args]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addArg(arg: JsonValue) = apply { + args = + (args ?: JsonField.of(mutableListOf())).also { checkKnown("args", it).add(arg) } + } + + fun code(code: String) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun language(language: String) = language(JsonField.of(language)) + + /** + * Sets [Builder.language] to an arbitrary JSON value. + * + * You should usually call [Builder.language] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun language(language: JsonField) = apply { this.language = language } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .args() + * .code() + * .language() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("args", args).map { it.toImmutable() }, + checkRequired("code", code), + checkRequired("language", language), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + args() + code() + language() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (args.asKnown().getOrNull()?.size ?: 0) + + (if (code.asKnown().isPresent) 1 else 0) + + (if (language.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + args == other.args && + code == other.code && + language == other.language && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(args, code, language, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{args=$args, code=$code, language=$language, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AceExecuteParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "AceExecuteParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/ace/AceExecuteResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/ace/AceExecuteResponse.kt new file mode 100644 index 00000000..412983a6 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/ace/AceExecuteResponse.kt @@ -0,0 +1,113 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.ace + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class AceExecuteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [AceExecuteResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AceExecuteResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(aceExecuteResponse: AceExecuteResponse) = apply { + additionalProperties = aceExecuteResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AceExecuteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AceExecuteResponse = AceExecuteResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): AceExecuteResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AceExecuteResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "AceExecuteResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueAnnotationQueuesParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueAnnotationQueuesParams.kt new file mode 100644 index 00000000..b16d1629 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueAnnotationQueuesParams.kt @@ -0,0 +1,1344 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create Annotation Queue */ +class AnnotationQueueAnnotationQueuesParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = body.name() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional = body.id() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun createdAt(): Optional = body.createdAt() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun defaultDataset(): Optional = body.defaultDataset() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional = body.description() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun enableReservations(): Optional = body.enableReservations() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun numReviewersPerItem(): Optional = body.numReviewersPerItem() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun reservationMinutes(): Optional = body.reservationMinutes() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun rubricInstructions(): Optional = body.rubricInstructions() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun rubricItems(): Optional> = body.rubricItems() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun sessionIds(): Optional> = body.sessionIds() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun updatedAt(): Optional = body.updatedAt() + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _name(): JsonField = body._name() + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _id(): JsonField = body._id() + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _createdAt(): JsonField = body._createdAt() + + /** + * Returns the raw JSON value of [defaultDataset]. + * + * Unlike [defaultDataset], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _defaultDataset(): JsonField = body._defaultDataset() + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _description(): JsonField = body._description() + + /** + * Returns the raw JSON value of [enableReservations]. + * + * Unlike [enableReservations], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _enableReservations(): JsonField = body._enableReservations() + + /** + * Returns the raw JSON value of [numReviewersPerItem]. + * + * Unlike [numReviewersPerItem], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _numReviewersPerItem(): JsonField = body._numReviewersPerItem() + + /** + * Returns the raw JSON value of [reservationMinutes]. + * + * Unlike [reservationMinutes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _reservationMinutes(): JsonField = body._reservationMinutes() + + /** + * Returns the raw JSON value of [rubricInstructions]. + * + * Unlike [rubricInstructions], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _rubricInstructions(): JsonField = body._rubricInstructions() + + /** + * Returns the raw JSON value of [rubricItems]. + * + * Unlike [rubricItems], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _rubricItems(): JsonField> = body._rubricItems() + + /** + * Returns the raw JSON value of [sessionIds]. + * + * Unlike [sessionIds], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _sessionIds(): JsonField> = body._sessionIds() + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _updatedAt(): JsonField = body._updatedAt() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AnnotationQueueAnnotationQueuesParams]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AnnotationQueueAnnotationQueuesParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + annotationQueueAnnotationQueuesParams: AnnotationQueueAnnotationQueuesParams + ) = apply { + body = annotationQueueAnnotationQueuesParams.body.toBuilder() + additionalHeaders = annotationQueueAnnotationQueuesParams.additionalHeaders.toBuilder() + additionalQueryParams = + annotationQueueAnnotationQueuesParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [name] + * - [id] + * - [createdAt] + * - [defaultDataset] + * - [description] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun name(name: String) = apply { body.name(name) } + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { body.name(name) } + + fun id(id: String) = apply { body.id(id) } + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { body.id(id) } + + fun createdAt(createdAt: OffsetDateTime) = apply { body.createdAt(createdAt) } + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { body.createdAt(createdAt) } + + fun defaultDataset(defaultDataset: String?) = apply { body.defaultDataset(defaultDataset) } + + /** Alias for calling [Builder.defaultDataset] with `defaultDataset.orElse(null)`. */ + fun defaultDataset(defaultDataset: Optional) = + defaultDataset(defaultDataset.getOrNull()) + + /** + * Sets [Builder.defaultDataset] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultDataset] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun defaultDataset(defaultDataset: JsonField) = apply { + body.defaultDataset(defaultDataset) + } + + fun description(description: String?) = apply { body.description(description) } + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField) = apply { body.description(description) } + + fun enableReservations(enableReservations: Boolean?) = apply { + body.enableReservations(enableReservations) + } + + /** + * Alias for [Builder.enableReservations]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun enableReservations(enableReservations: Boolean) = + enableReservations(enableReservations as Boolean?) + + /** + * Alias for calling [Builder.enableReservations] with `enableReservations.orElse(null)`. + */ + fun enableReservations(enableReservations: Optional) = + enableReservations(enableReservations.getOrNull()) + + /** + * Sets [Builder.enableReservations] to an arbitrary JSON value. + * + * You should usually call [Builder.enableReservations] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun enableReservations(enableReservations: JsonField) = apply { + body.enableReservations(enableReservations) + } + + fun numReviewersPerItem(numReviewersPerItem: Long?) = apply { + body.numReviewersPerItem(numReviewersPerItem) + } + + /** + * Alias for [Builder.numReviewersPerItem]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun numReviewersPerItem(numReviewersPerItem: Long) = + numReviewersPerItem(numReviewersPerItem as Long?) + + /** + * Alias for calling [Builder.numReviewersPerItem] with `numReviewersPerItem.orElse(null)`. + */ + fun numReviewersPerItem(numReviewersPerItem: Optional) = + numReviewersPerItem(numReviewersPerItem.getOrNull()) + + /** + * Sets [Builder.numReviewersPerItem] to an arbitrary JSON value. + * + * You should usually call [Builder.numReviewersPerItem] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun numReviewersPerItem(numReviewersPerItem: JsonField) = apply { + body.numReviewersPerItem(numReviewersPerItem) + } + + fun reservationMinutes(reservationMinutes: Long?) = apply { + body.reservationMinutes(reservationMinutes) + } + + /** + * Alias for [Builder.reservationMinutes]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun reservationMinutes(reservationMinutes: Long) = + reservationMinutes(reservationMinutes as Long?) + + /** + * Alias for calling [Builder.reservationMinutes] with `reservationMinutes.orElse(null)`. + */ + fun reservationMinutes(reservationMinutes: Optional) = + reservationMinutes(reservationMinutes.getOrNull()) + + /** + * Sets [Builder.reservationMinutes] to an arbitrary JSON value. + * + * You should usually call [Builder.reservationMinutes] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun reservationMinutes(reservationMinutes: JsonField) = apply { + body.reservationMinutes(reservationMinutes) + } + + fun rubricInstructions(rubricInstructions: String?) = apply { + body.rubricInstructions(rubricInstructions) + } + + /** + * Alias for calling [Builder.rubricInstructions] with `rubricInstructions.orElse(null)`. + */ + fun rubricInstructions(rubricInstructions: Optional) = + rubricInstructions(rubricInstructions.getOrNull()) + + /** + * Sets [Builder.rubricInstructions] to an arbitrary JSON value. + * + * You should usually call [Builder.rubricInstructions] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rubricInstructions(rubricInstructions: JsonField) = apply { + body.rubricInstructions(rubricInstructions) + } + + fun rubricItems(rubricItems: List?) = apply { + body.rubricItems(rubricItems) + } + + /** Alias for calling [Builder.rubricItems] with `rubricItems.orElse(null)`. */ + fun rubricItems(rubricItems: Optional>) = + rubricItems(rubricItems.getOrNull()) + + /** + * Sets [Builder.rubricItems] to an arbitrary JSON value. + * + * You should usually call [Builder.rubricItems] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun rubricItems(rubricItems: JsonField>) = apply { + body.rubricItems(rubricItems) + } + + /** + * Adds a single [AnnotationQueueRubricItemSchema] to [rubricItems]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRubricItem(rubricItem: AnnotationQueueRubricItemSchema) = apply { + body.addRubricItem(rubricItem) + } + + fun sessionIds(sessionIds: List?) = apply { body.sessionIds(sessionIds) } + + /** Alias for calling [Builder.sessionIds] with `sessionIds.orElse(null)`. */ + fun sessionIds(sessionIds: Optional>) = sessionIds(sessionIds.getOrNull()) + + /** + * Sets [Builder.sessionIds] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionIds] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sessionIds(sessionIds: JsonField>) = apply { body.sessionIds(sessionIds) } + + /** + * Adds a single [String] to [sessionIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSessionId(sessionId: String) = apply { body.addSessionId(sessionId) } + + fun updatedAt(updatedAt: OffsetDateTime) = apply { body.updatedAt(updatedAt) } + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField) = apply { body.updatedAt(updatedAt) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [AnnotationQueueAnnotationQueuesParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AnnotationQueueAnnotationQueuesParams = + AnnotationQueueAnnotationQueuesParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** AnnotationQueue schema. */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val name: JsonField, + private val id: JsonField, + private val createdAt: JsonField, + private val defaultDataset: JsonField, + private val description: JsonField, + private val enableReservations: JsonField, + private val numReviewersPerItem: JsonField, + private val reservationMinutes: JsonField, + private val rubricInstructions: JsonField, + private val rubricItems: JsonField>, + private val sessionIds: JsonField>, + private val updatedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("default_dataset") + @ExcludeMissing + defaultDataset: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("enable_reservations") + @ExcludeMissing + enableReservations: JsonField = JsonMissing.of(), + @JsonProperty("num_reviewers_per_item") + @ExcludeMissing + numReviewersPerItem: JsonField = JsonMissing.of(), + @JsonProperty("reservation_minutes") + @ExcludeMissing + reservationMinutes: JsonField = JsonMissing.of(), + @JsonProperty("rubric_instructions") + @ExcludeMissing + rubricInstructions: JsonField = JsonMissing.of(), + @JsonProperty("rubric_items") + @ExcludeMissing + rubricItems: JsonField> = JsonMissing.of(), + @JsonProperty("session_ids") + @ExcludeMissing + sessionIds: JsonField> = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), + ) : this( + name, + id, + createdAt, + defaultDataset, + description, + enableReservations, + numReviewersPerItem, + reservationMinutes, + rubricInstructions, + rubricItems, + sessionIds, + updatedAt, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun createdAt(): Optional = createdAt.getOptional("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun defaultDataset(): Optional = defaultDataset.getOptional("default_dataset") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun enableReservations(): Optional = + enableReservations.getOptional("enable_reservations") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun numReviewersPerItem(): Optional = + numReviewersPerItem.getOptional("num_reviewers_per_item") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun reservationMinutes(): Optional = + reservationMinutes.getOptional("reservation_minutes") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun rubricInstructions(): Optional = + rubricInstructions.getOptional("rubric_instructions") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun rubricItems(): Optional> = + rubricItems.getOptional("rubric_items") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun sessionIds(): Optional> = sessionIds.getOptional("session_ids") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun updatedAt(): Optional = updatedAt.getOptional("updated_at") + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [defaultDataset]. + * + * Unlike [defaultDataset], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("default_dataset") + @ExcludeMissing + fun _defaultDataset(): JsonField = defaultDataset + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [enableReservations]. + * + * Unlike [enableReservations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("enable_reservations") + @ExcludeMissing + fun _enableReservations(): JsonField = enableReservations + + /** + * Returns the raw JSON value of [numReviewersPerItem]. + * + * Unlike [numReviewersPerItem], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("num_reviewers_per_item") + @ExcludeMissing + fun _numReviewersPerItem(): JsonField = numReviewersPerItem + + /** + * Returns the raw JSON value of [reservationMinutes]. + * + * Unlike [reservationMinutes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reservation_minutes") + @ExcludeMissing + fun _reservationMinutes(): JsonField = reservationMinutes + + /** + * Returns the raw JSON value of [rubricInstructions]. + * + * Unlike [rubricInstructions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rubric_instructions") + @ExcludeMissing + fun _rubricInstructions(): JsonField = rubricInstructions + + /** + * Returns the raw JSON value of [rubricItems]. + * + * Unlike [rubricItems], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rubric_items") + @ExcludeMissing + fun _rubricItems(): JsonField> = rubricItems + + /** + * Returns the raw JSON value of [sessionIds]. + * + * Unlike [sessionIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session_ids") + @ExcludeMissing + fun _sessionIds(): JsonField> = sessionIds + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField = updatedAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var name: JsonField? = null + private var id: JsonField = JsonMissing.of() + private var createdAt: JsonField = JsonMissing.of() + private var defaultDataset: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var enableReservations: JsonField = JsonMissing.of() + private var numReviewersPerItem: JsonField = JsonMissing.of() + private var reservationMinutes: JsonField = JsonMissing.of() + private var rubricInstructions: JsonField = JsonMissing.of() + private var rubricItems: JsonField>? = null + private var sessionIds: JsonField>? = null + private var updatedAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + name = body.name + id = body.id + createdAt = body.createdAt + defaultDataset = body.defaultDataset + description = body.description + enableReservations = body.enableReservations + numReviewersPerItem = body.numReviewersPerItem + reservationMinutes = body.reservationMinutes + rubricInstructions = body.rubricInstructions + rubricItems = body.rubricItems.map { it.toMutableList() } + sessionIds = body.sessionIds.map { it.toMutableList() } + updatedAt = body.updatedAt + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun defaultDataset(defaultDataset: String?) = + defaultDataset(JsonField.ofNullable(defaultDataset)) + + /** Alias for calling [Builder.defaultDataset] with `defaultDataset.orElse(null)`. */ + fun defaultDataset(defaultDataset: Optional) = + defaultDataset(defaultDataset.getOrNull()) + + /** + * Sets [Builder.defaultDataset] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultDataset] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun defaultDataset(defaultDataset: JsonField) = apply { + this.defaultDataset = defaultDataset + } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + fun enableReservations(enableReservations: Boolean?) = + enableReservations(JsonField.ofNullable(enableReservations)) + + /** + * Alias for [Builder.enableReservations]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun enableReservations(enableReservations: Boolean) = + enableReservations(enableReservations as Boolean?) + + /** + * Alias for calling [Builder.enableReservations] with + * `enableReservations.orElse(null)`. + */ + fun enableReservations(enableReservations: Optional) = + enableReservations(enableReservations.getOrNull()) + + /** + * Sets [Builder.enableReservations] to an arbitrary JSON value. + * + * You should usually call [Builder.enableReservations] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun enableReservations(enableReservations: JsonField) = apply { + this.enableReservations = enableReservations + } + + fun numReviewersPerItem(numReviewersPerItem: Long?) = + numReviewersPerItem(JsonField.ofNullable(numReviewersPerItem)) + + /** + * Alias for [Builder.numReviewersPerItem]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun numReviewersPerItem(numReviewersPerItem: Long) = + numReviewersPerItem(numReviewersPerItem as Long?) + + /** + * Alias for calling [Builder.numReviewersPerItem] with + * `numReviewersPerItem.orElse(null)`. + */ + fun numReviewersPerItem(numReviewersPerItem: Optional) = + numReviewersPerItem(numReviewersPerItem.getOrNull()) + + /** + * Sets [Builder.numReviewersPerItem] to an arbitrary JSON value. + * + * You should usually call [Builder.numReviewersPerItem] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun numReviewersPerItem(numReviewersPerItem: JsonField) = apply { + this.numReviewersPerItem = numReviewersPerItem + } + + fun reservationMinutes(reservationMinutes: Long?) = + reservationMinutes(JsonField.ofNullable(reservationMinutes)) + + /** + * Alias for [Builder.reservationMinutes]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun reservationMinutes(reservationMinutes: Long) = + reservationMinutes(reservationMinutes as Long?) + + /** + * Alias for calling [Builder.reservationMinutes] with + * `reservationMinutes.orElse(null)`. + */ + fun reservationMinutes(reservationMinutes: Optional) = + reservationMinutes(reservationMinutes.getOrNull()) + + /** + * Sets [Builder.reservationMinutes] to an arbitrary JSON value. + * + * You should usually call [Builder.reservationMinutes] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun reservationMinutes(reservationMinutes: JsonField) = apply { + this.reservationMinutes = reservationMinutes + } + + fun rubricInstructions(rubricInstructions: String?) = + rubricInstructions(JsonField.ofNullable(rubricInstructions)) + + /** + * Alias for calling [Builder.rubricInstructions] with + * `rubricInstructions.orElse(null)`. + */ + fun rubricInstructions(rubricInstructions: Optional) = + rubricInstructions(rubricInstructions.getOrNull()) + + /** + * Sets [Builder.rubricInstructions] to an arbitrary JSON value. + * + * You should usually call [Builder.rubricInstructions] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rubricInstructions(rubricInstructions: JsonField) = apply { + this.rubricInstructions = rubricInstructions + } + + fun rubricItems(rubricItems: List?) = + rubricItems(JsonField.ofNullable(rubricItems)) + + /** Alias for calling [Builder.rubricItems] with `rubricItems.orElse(null)`. */ + fun rubricItems(rubricItems: Optional>) = + rubricItems(rubricItems.getOrNull()) + + /** + * Sets [Builder.rubricItems] to an arbitrary JSON value. + * + * You should usually call [Builder.rubricItems] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun rubricItems(rubricItems: JsonField>) = apply { + this.rubricItems = rubricItems.map { it.toMutableList() } + } + + /** + * Adds a single [AnnotationQueueRubricItemSchema] to [rubricItems]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRubricItem(rubricItem: AnnotationQueueRubricItemSchema) = apply { + rubricItems = + (rubricItems ?: JsonField.of(mutableListOf())).also { + checkKnown("rubricItems", it).add(rubricItem) + } + } + + fun sessionIds(sessionIds: List?) = sessionIds(JsonField.ofNullable(sessionIds)) + + /** Alias for calling [Builder.sessionIds] with `sessionIds.orElse(null)`. */ + fun sessionIds(sessionIds: Optional>) = sessionIds(sessionIds.getOrNull()) + + /** + * Sets [Builder.sessionIds] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionIds] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sessionIds(sessionIds: JsonField>) = apply { + this.sessionIds = sessionIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [sessionIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSessionId(sessionId: String) = apply { + sessionIds = + (sessionIds ?: JsonField.of(mutableListOf())).also { + checkKnown("sessionIds", it).add(sessionId) + } + } + + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField) = apply { + this.updatedAt = updatedAt + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("name", name), + id, + createdAt, + defaultDataset, + description, + enableReservations, + numReviewersPerItem, + reservationMinutes, + rubricInstructions, + (rubricItems ?: JsonMissing.of()).map { it.toImmutable() }, + (sessionIds ?: JsonMissing.of()).map { it.toImmutable() }, + updatedAt, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + name() + id() + createdAt() + defaultDataset() + description() + enableReservations() + numReviewersPerItem() + reservationMinutes() + rubricInstructions() + rubricItems().ifPresent { it.forEach { it.validate() } } + sessionIds() + updatedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (name.asKnown().isPresent) 1 else 0) + + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (defaultDataset.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (enableReservations.asKnown().isPresent) 1 else 0) + + (if (numReviewersPerItem.asKnown().isPresent) 1 else 0) + + (if (reservationMinutes.asKnown().isPresent) 1 else 0) + + (if (rubricInstructions.asKnown().isPresent) 1 else 0) + + (rubricItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (sessionIds.asKnown().getOrNull()?.size ?: 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + name == other.name && + id == other.id && + createdAt == other.createdAt && + defaultDataset == other.defaultDataset && + description == other.description && + enableReservations == other.enableReservations && + numReviewersPerItem == other.numReviewersPerItem && + reservationMinutes == other.reservationMinutes && + rubricInstructions == other.rubricInstructions && + rubricItems == other.rubricItems && + sessionIds == other.sessionIds && + updatedAt == other.updatedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + name, + id, + createdAt, + defaultDataset, + description, + enableReservations, + numReviewersPerItem, + reservationMinutes, + rubricInstructions, + rubricItems, + sessionIds, + updatedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{name=$name, id=$id, createdAt=$createdAt, defaultDataset=$defaultDataset, description=$description, enableReservations=$enableReservations, numReviewersPerItem=$numReviewersPerItem, reservationMinutes=$reservationMinutes, rubricInstructions=$rubricInstructions, rubricItems=$rubricItems, sessionIds=$sessionIds, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AnnotationQueueAnnotationQueuesParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "AnnotationQueueAnnotationQueuesParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueDeleteParams.kt new file mode 100644 index 00000000..3f9b4246 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueDeleteParams.kt @@ -0,0 +1,232 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete Annotation Queue */ +class AnnotationQueueDeleteParams +private constructor( + private val queueId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun queueId(): Optional = Optional.ofNullable(queueId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): AnnotationQueueDeleteParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [AnnotationQueueDeleteParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AnnotationQueueDeleteParams]. */ + class Builder internal constructor() { + + private var queueId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(annotationQueueDeleteParams: AnnotationQueueDeleteParams) = apply { + queueId = annotationQueueDeleteParams.queueId + additionalHeaders = annotationQueueDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = annotationQueueDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + annotationQueueDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun queueId(queueId: String?) = apply { this.queueId = queueId } + + /** Alias for calling [Builder.queueId] with `queueId.orElse(null)`. */ + fun queueId(queueId: Optional) = queueId(queueId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [AnnotationQueueDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AnnotationQueueDeleteParams = + AnnotationQueueDeleteParams( + queueId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> queueId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AnnotationQueueDeleteParams && + queueId == other.queueId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(queueId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "AnnotationQueueDeleteParams{queueId=$queueId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueDeleteResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueDeleteResponse.kt new file mode 100644 index 00000000..c0596c65 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueDeleteResponse.kt @@ -0,0 +1,119 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class AnnotationQueueDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AnnotationQueueDeleteResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AnnotationQueueDeleteResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(annotationQueueDeleteResponse: AnnotationQueueDeleteResponse) = apply { + additionalProperties = annotationQueueDeleteResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AnnotationQueueDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AnnotationQueueDeleteResponse = + AnnotationQueueDeleteResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): AnnotationQueueDeleteResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AnnotationQueueDeleteResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AnnotationQueueDeleteResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueExportParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueExportParams.kt new file mode 100644 index 00000000..16fba31a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueExportParams.kt @@ -0,0 +1,487 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Export Annotation Queue Archived Runs */ +class AnnotationQueueExportParams +private constructor( + private val queueId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun queueId(): Optional = Optional.ofNullable(queueId) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endTime(): Optional = body.endTime() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun startTime(): Optional = body.startTime() + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _endTime(): JsonField = body._endTime() + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _startTime(): JsonField = body._startTime() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): AnnotationQueueExportParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [AnnotationQueueExportParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AnnotationQueueExportParams]. */ + class Builder internal constructor() { + + private var queueId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(annotationQueueExportParams: AnnotationQueueExportParams) = apply { + queueId = annotationQueueExportParams.queueId + body = annotationQueueExportParams.body.toBuilder() + additionalHeaders = annotationQueueExportParams.additionalHeaders.toBuilder() + additionalQueryParams = annotationQueueExportParams.additionalQueryParams.toBuilder() + } + + fun queueId(queueId: String?) = apply { this.queueId = queueId } + + /** Alias for calling [Builder.queueId] with `queueId.orElse(null)`. */ + fun queueId(queueId: Optional) = queueId(queueId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [endTime] + * - [startTime] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun endTime(endTime: OffsetDateTime?) = apply { body.endTime(endTime) } + + /** Alias for calling [Builder.endTime] with `endTime.orElse(null)`. */ + fun endTime(endTime: Optional) = endTime(endTime.getOrNull()) + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endTime(endTime: JsonField) = apply { body.endTime(endTime) } + + fun startTime(startTime: OffsetDateTime?) = apply { body.startTime(startTime) } + + /** Alias for calling [Builder.startTime] with `startTime.orElse(null)`. */ + fun startTime(startTime: Optional) = startTime(startTime.getOrNull()) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField) = apply { body.startTime(startTime) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [AnnotationQueueExportParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AnnotationQueueExportParams = + AnnotationQueueExportParams( + queueId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> queueId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Export annotation queue runs request schema. */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val endTime: JsonField, + private val startTime: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("end_time") + @ExcludeMissing + endTime: JsonField = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField = JsonMissing.of(), + ) : this(endTime, startTime, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun endTime(): Optional = endTime.getOptional("end_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun startTime(): Optional = startTime.getOptional("start_time") + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_time") + @ExcludeMissing + fun _endTime(): JsonField = endTime + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_time") + @ExcludeMissing + fun _startTime(): JsonField = startTime + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var endTime: JsonField = JsonMissing.of() + private var startTime: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + endTime = body.endTime + startTime = body.startTime + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun endTime(endTime: OffsetDateTime?) = endTime(JsonField.ofNullable(endTime)) + + /** Alias for calling [Builder.endTime] with `endTime.orElse(null)`. */ + fun endTime(endTime: Optional) = endTime(endTime.getOrNull()) + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endTime(endTime: JsonField) = apply { this.endTime = endTime } + + fun startTime(startTime: OffsetDateTime?) = startTime(JsonField.ofNullable(startTime)) + + /** Alias for calling [Builder.startTime] with `startTime.orElse(null)`. */ + fun startTime(startTime: Optional) = startTime(startTime.getOrNull()) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField) = apply { + this.startTime = startTime + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = Body(endTime, startTime, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + endTime() + startTime() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (endTime.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + endTime == other.endTime && + startTime == other.startTime && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(endTime, startTime, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{endTime=$endTime, startTime=$startTime, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AnnotationQueueExportParams && + queueId == other.queueId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(queueId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "AnnotationQueueExportParams{queueId=$queueId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueExportResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueExportResponse.kt new file mode 100644 index 00000000..2a79cc11 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueExportResponse.kt @@ -0,0 +1,119 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class AnnotationQueueExportResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AnnotationQueueExportResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AnnotationQueueExportResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(annotationQueueExportResponse: AnnotationQueueExportResponse) = apply { + additionalProperties = annotationQueueExportResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AnnotationQueueExportResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AnnotationQueueExportResponse = + AnnotationQueueExportResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): AnnotationQueueExportResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AnnotationQueueExportResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AnnotationQueueExportResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueuePopulateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueuePopulateParams.kt new file mode 100644 index 00000000..9f1868f3 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueuePopulateParams.kt @@ -0,0 +1,506 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** Populate annotation queue with runs from an experiment. */ +class AnnotationQueuePopulateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun queueId(): String = body.queueId() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun sessionIds(): List = body.sessionIds() + + /** + * Returns the raw JSON value of [queueId]. + * + * Unlike [queueId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _queueId(): JsonField = body._queueId() + + /** + * Returns the raw JSON value of [sessionIds]. + * + * Unlike [sessionIds], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _sessionIds(): JsonField> = body._sessionIds() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AnnotationQueuePopulateParams]. + * + * The following fields are required: + * ```java + * .queueId() + * .sessionIds() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AnnotationQueuePopulateParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(annotationQueuePopulateParams: AnnotationQueuePopulateParams) = apply { + body = annotationQueuePopulateParams.body.toBuilder() + additionalHeaders = annotationQueuePopulateParams.additionalHeaders.toBuilder() + additionalQueryParams = annotationQueuePopulateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [queueId] + * - [sessionIds] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun queueId(queueId: String) = apply { body.queueId(queueId) } + + /** + * Sets [Builder.queueId] to an arbitrary JSON value. + * + * You should usually call [Builder.queueId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun queueId(queueId: JsonField) = apply { body.queueId(queueId) } + + fun sessionIds(sessionIds: List) = apply { body.sessionIds(sessionIds) } + + /** + * Sets [Builder.sessionIds] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionIds] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sessionIds(sessionIds: JsonField>) = apply { body.sessionIds(sessionIds) } + + /** + * Adds a single [String] to [sessionIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSessionId(sessionId: String) = apply { body.addSessionId(sessionId) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [AnnotationQueuePopulateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .queueId() + * .sessionIds() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AnnotationQueuePopulateParams = + AnnotationQueuePopulateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val queueId: JsonField, + private val sessionIds: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("queue_id") @ExcludeMissing queueId: JsonField = JsonMissing.of(), + @JsonProperty("session_ids") + @ExcludeMissing + sessionIds: JsonField> = JsonMissing.of(), + ) : this(queueId, sessionIds, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun queueId(): String = queueId.getRequired("queue_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun sessionIds(): List = sessionIds.getRequired("session_ids") + + /** + * Returns the raw JSON value of [queueId]. + * + * Unlike [queueId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("queue_id") @ExcludeMissing fun _queueId(): JsonField = queueId + + /** + * Returns the raw JSON value of [sessionIds]. + * + * Unlike [sessionIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session_ids") + @ExcludeMissing + fun _sessionIds(): JsonField> = sessionIds + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .queueId() + * .sessionIds() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var queueId: JsonField? = null + private var sessionIds: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + queueId = body.queueId + sessionIds = body.sessionIds.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun queueId(queueId: String) = queueId(JsonField.of(queueId)) + + /** + * Sets [Builder.queueId] to an arbitrary JSON value. + * + * You should usually call [Builder.queueId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun queueId(queueId: JsonField) = apply { this.queueId = queueId } + + fun sessionIds(sessionIds: List) = sessionIds(JsonField.of(sessionIds)) + + /** + * Sets [Builder.sessionIds] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionIds] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sessionIds(sessionIds: JsonField>) = apply { + this.sessionIds = sessionIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [sessionIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSessionId(sessionId: String) = apply { + sessionIds = + (sessionIds ?: JsonField.of(mutableListOf())).also { + checkKnown("sessionIds", it).add(sessionId) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .queueId() + * .sessionIds() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("queueId", queueId), + checkRequired("sessionIds", sessionIds).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + queueId() + sessionIds() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (queueId.asKnown().isPresent) 1 else 0) + + (sessionIds.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + queueId == other.queueId && + sessionIds == other.sessionIds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(queueId, sessionIds, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{queueId=$queueId, sessionIds=$sessionIds, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AnnotationQueuePopulateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "AnnotationQueuePopulateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueuePopulateResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueuePopulateResponse.kt new file mode 100644 index 00000000..8bbb1085 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueuePopulateResponse.kt @@ -0,0 +1,121 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class AnnotationQueuePopulateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AnnotationQueuePopulateResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AnnotationQueuePopulateResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(annotationQueuePopulateResponse: AnnotationQueuePopulateResponse) = + apply { + additionalProperties = + annotationQueuePopulateResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AnnotationQueuePopulateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AnnotationQueuePopulateResponse = + AnnotationQueuePopulateResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): AnnotationQueuePopulateResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AnnotationQueuePopulateResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AnnotationQueuePopulateResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveAnnotationQueuesParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveAnnotationQueuesParams.kt new file mode 100644 index 00000000..dfdde1e4 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveAnnotationQueuesParams.kt @@ -0,0 +1,323 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get Annotation Queues */ +class AnnotationQueueRetrieveAnnotationQueuesParams +private constructor( + private val datasetId: String?, + private val ids: List?, + private val limit: Long?, + private val name: String?, + private val nameContains: String?, + private val offset: Long?, + private val tagValueId: List?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun datasetId(): Optional = Optional.ofNullable(datasetId) + + fun ids(): Optional> = Optional.ofNullable(ids) + + fun limit(): Optional = Optional.ofNullable(limit) + + fun name(): Optional = Optional.ofNullable(name) + + fun nameContains(): Optional = Optional.ofNullable(nameContains) + + fun offset(): Optional = Optional.ofNullable(offset) + + fun tagValueId(): Optional> = Optional.ofNullable(tagValueId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): AnnotationQueueRetrieveAnnotationQueuesParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [AnnotationQueueRetrieveAnnotationQueuesParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AnnotationQueueRetrieveAnnotationQueuesParams]. */ + class Builder internal constructor() { + + private var datasetId: String? = null + private var ids: MutableList? = null + private var limit: Long? = null + private var name: String? = null + private var nameContains: String? = null + private var offset: Long? = null + private var tagValueId: MutableList? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + annotationQueueRetrieveAnnotationQueuesParams: + AnnotationQueueRetrieveAnnotationQueuesParams + ) = apply { + datasetId = annotationQueueRetrieveAnnotationQueuesParams.datasetId + ids = annotationQueueRetrieveAnnotationQueuesParams.ids?.toMutableList() + limit = annotationQueueRetrieveAnnotationQueuesParams.limit + name = annotationQueueRetrieveAnnotationQueuesParams.name + nameContains = annotationQueueRetrieveAnnotationQueuesParams.nameContains + offset = annotationQueueRetrieveAnnotationQueuesParams.offset + tagValueId = annotationQueueRetrieveAnnotationQueuesParams.tagValueId?.toMutableList() + additionalHeaders = + annotationQueueRetrieveAnnotationQueuesParams.additionalHeaders.toBuilder() + additionalQueryParams = + annotationQueueRetrieveAnnotationQueuesParams.additionalQueryParams.toBuilder() + } + + fun datasetId(datasetId: String?) = apply { this.datasetId = datasetId } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional) = datasetId(datasetId.getOrNull()) + + fun ids(ids: List?) = apply { this.ids = ids?.toMutableList() } + + /** Alias for calling [Builder.ids] with `ids.orElse(null)`. */ + fun ids(ids: Optional>) = ids(ids.getOrNull()) + + /** + * Adds a single [String] to [ids]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addId(id: String) = apply { ids = (ids ?: mutableListOf()).apply { add(id) } } + + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional) = limit(limit.getOrNull()) + + fun name(name: String?) = apply { this.name = name } + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional) = name(name.getOrNull()) + + fun nameContains(nameContains: String?) = apply { this.nameContains = nameContains } + + /** Alias for calling [Builder.nameContains] with `nameContains.orElse(null)`. */ + fun nameContains(nameContains: Optional) = nameContains(nameContains.getOrNull()) + + fun offset(offset: Long?) = apply { this.offset = offset } + + /** + * Alias for [Builder.offset]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun offset(offset: Long) = offset(offset as Long?) + + /** Alias for calling [Builder.offset] with `offset.orElse(null)`. */ + fun offset(offset: Optional) = offset(offset.getOrNull()) + + fun tagValueId(tagValueId: List?) = apply { + this.tagValueId = tagValueId?.toMutableList() + } + + /** Alias for calling [Builder.tagValueId] with `tagValueId.orElse(null)`. */ + fun tagValueId(tagValueId: Optional>) = tagValueId(tagValueId.getOrNull()) + + /** + * Adds a single [String] to [Builder.tagValueId]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTagValueId(tagValueId: String) = apply { + this.tagValueId = (this.tagValueId ?: mutableListOf()).apply { add(tagValueId) } + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [AnnotationQueueRetrieveAnnotationQueuesParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AnnotationQueueRetrieveAnnotationQueuesParams = + AnnotationQueueRetrieveAnnotationQueuesParams( + datasetId, + ids?.toImmutable(), + limit, + name, + nameContains, + offset, + tagValueId?.toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + datasetId?.let { put("dataset_id", it) } + ids?.let { put("ids", it.joinToString(",")) } + limit?.let { put("limit", it.toString()) } + name?.let { put("name", it) } + nameContains?.let { put("name_contains", it) } + offset?.let { put("offset", it.toString()) } + tagValueId?.let { put("tag_value_id", it.joinToString(",")) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AnnotationQueueRetrieveAnnotationQueuesParams && + datasetId == other.datasetId && + ids == other.ids && + limit == other.limit && + name == other.name && + nameContains == other.nameContains && + offset == other.offset && + tagValueId == other.tagValueId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + datasetId, + ids, + limit, + name, + nameContains, + offset, + tagValueId, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "AnnotationQueueRetrieveAnnotationQueuesParams{datasetId=$datasetId, ids=$ids, limit=$limit, name=$name, nameContains=$nameContains, offset=$offset, tagValueId=$tagValueId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveAnnotationQueuesResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveAnnotationQueuesResponse.kt new file mode 100644 index 00000000..01db3ec2 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveAnnotationQueuesResponse.kt @@ -0,0 +1,707 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** AnnotationQueue schema with size. */ +class AnnotationQueueRetrieveAnnotationQueuesResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val name: JsonField, + private val tenantId: JsonField, + private val totalRuns: JsonField, + private val createdAt: JsonField, + private val defaultDataset: JsonField, + private val description: JsonField, + private val enableReservations: JsonField, + private val numReviewersPerItem: JsonField, + private val reservationMinutes: JsonField, + private val runRuleId: JsonField, + private val sourceRuleId: JsonField, + private val updatedAt: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("tenant_id") @ExcludeMissing tenantId: JsonField = JsonMissing.of(), + @JsonProperty("total_runs") @ExcludeMissing totalRuns: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("default_dataset") + @ExcludeMissing + defaultDataset: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("enable_reservations") + @ExcludeMissing + enableReservations: JsonField = JsonMissing.of(), + @JsonProperty("num_reviewers_per_item") + @ExcludeMissing + numReviewersPerItem: JsonField = JsonMissing.of(), + @JsonProperty("reservation_minutes") + @ExcludeMissing + reservationMinutes: JsonField = JsonMissing.of(), + @JsonProperty("run_rule_id") + @ExcludeMissing + runRuleId: JsonField = JsonMissing.of(), + @JsonProperty("source_rule_id") + @ExcludeMissing + sourceRuleId: JsonField = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), + ) : this( + id, + name, + tenantId, + totalRuns, + createdAt, + defaultDataset, + description, + enableReservations, + numReviewersPerItem, + reservationMinutes, + runRuleId, + sourceRuleId, + updatedAt, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tenantId(): String = tenantId.getRequired("tenant_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun totalRuns(): Long = totalRuns.getRequired("total_runs") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun createdAt(): Optional = createdAt.getOptional("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun defaultDataset(): Optional = defaultDataset.getOptional("default_dataset") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun enableReservations(): Optional = + enableReservations.getOptional("enable_reservations") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun numReviewersPerItem(): Optional = + numReviewersPerItem.getOptional("num_reviewers_per_item") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun reservationMinutes(): Optional = reservationMinutes.getOptional("reservation_minutes") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun runRuleId(): Optional = runRuleId.getOptional("run_rule_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun sourceRuleId(): Optional = sourceRuleId.getOptional("source_rule_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun updatedAt(): Optional = updatedAt.getOptional("updated_at") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_id") @ExcludeMissing fun _tenantId(): JsonField = tenantId + + /** + * Returns the raw JSON value of [totalRuns]. + * + * Unlike [totalRuns], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total_runs") @ExcludeMissing fun _totalRuns(): JsonField = totalRuns + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [defaultDataset]. + * + * Unlike [defaultDataset], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("default_dataset") + @ExcludeMissing + fun _defaultDataset(): JsonField = defaultDataset + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [enableReservations]. + * + * Unlike [enableReservations], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("enable_reservations") + @ExcludeMissing + fun _enableReservations(): JsonField = enableReservations + + /** + * Returns the raw JSON value of [numReviewersPerItem]. + * + * Unlike [numReviewersPerItem], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("num_reviewers_per_item") + @ExcludeMissing + fun _numReviewersPerItem(): JsonField = numReviewersPerItem + + /** + * Returns the raw JSON value of [reservationMinutes]. + * + * Unlike [reservationMinutes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reservation_minutes") + @ExcludeMissing + fun _reservationMinutes(): JsonField = reservationMinutes + + /** + * Returns the raw JSON value of [runRuleId]. + * + * Unlike [runRuleId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_rule_id") @ExcludeMissing fun _runRuleId(): JsonField = runRuleId + + /** + * Returns the raw JSON value of [sourceRuleId]. + * + * Unlike [sourceRuleId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("source_rule_id") + @ExcludeMissing + fun _sourceRuleId(): JsonField = sourceRuleId + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField = updatedAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AnnotationQueueRetrieveAnnotationQueuesResponse]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .tenantId() + * .totalRuns() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AnnotationQueueRetrieveAnnotationQueuesResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var name: JsonField? = null + private var tenantId: JsonField? = null + private var totalRuns: JsonField? = null + private var createdAt: JsonField = JsonMissing.of() + private var defaultDataset: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var enableReservations: JsonField = JsonMissing.of() + private var numReviewersPerItem: JsonField = JsonMissing.of() + private var reservationMinutes: JsonField = JsonMissing.of() + private var runRuleId: JsonField = JsonMissing.of() + private var sourceRuleId: JsonField = JsonMissing.of() + private var updatedAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + annotationQueueRetrieveAnnotationQueuesResponse: + AnnotationQueueRetrieveAnnotationQueuesResponse + ) = apply { + id = annotationQueueRetrieveAnnotationQueuesResponse.id + name = annotationQueueRetrieveAnnotationQueuesResponse.name + tenantId = annotationQueueRetrieveAnnotationQueuesResponse.tenantId + totalRuns = annotationQueueRetrieveAnnotationQueuesResponse.totalRuns + createdAt = annotationQueueRetrieveAnnotationQueuesResponse.createdAt + defaultDataset = annotationQueueRetrieveAnnotationQueuesResponse.defaultDataset + description = annotationQueueRetrieveAnnotationQueuesResponse.description + enableReservations = annotationQueueRetrieveAnnotationQueuesResponse.enableReservations + numReviewersPerItem = + annotationQueueRetrieveAnnotationQueuesResponse.numReviewersPerItem + reservationMinutes = annotationQueueRetrieveAnnotationQueuesResponse.reservationMinutes + runRuleId = annotationQueueRetrieveAnnotationQueuesResponse.runRuleId + sourceRuleId = annotationQueueRetrieveAnnotationQueuesResponse.sourceRuleId + updatedAt = annotationQueueRetrieveAnnotationQueuesResponse.updatedAt + additionalProperties = + annotationQueueRetrieveAnnotationQueuesResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tenantId(tenantId: JsonField) = apply { this.tenantId = tenantId } + + fun totalRuns(totalRuns: Long) = totalRuns(JsonField.of(totalRuns)) + + /** + * Sets [Builder.totalRuns] to an arbitrary JSON value. + * + * You should usually call [Builder.totalRuns] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun totalRuns(totalRuns: JsonField) = apply { this.totalRuns = totalRuns } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + fun defaultDataset(defaultDataset: String?) = + defaultDataset(JsonField.ofNullable(defaultDataset)) + + /** Alias for calling [Builder.defaultDataset] with `defaultDataset.orElse(null)`. */ + fun defaultDataset(defaultDataset: Optional) = + defaultDataset(defaultDataset.getOrNull()) + + /** + * Sets [Builder.defaultDataset] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultDataset] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun defaultDataset(defaultDataset: JsonField) = apply { + this.defaultDataset = defaultDataset + } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField) = apply { this.description = description } + + fun enableReservations(enableReservations: Boolean?) = + enableReservations(JsonField.ofNullable(enableReservations)) + + /** + * Alias for [Builder.enableReservations]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun enableReservations(enableReservations: Boolean) = + enableReservations(enableReservations as Boolean?) + + /** + * Alias for calling [Builder.enableReservations] with `enableReservations.orElse(null)`. + */ + fun enableReservations(enableReservations: Optional) = + enableReservations(enableReservations.getOrNull()) + + /** + * Sets [Builder.enableReservations] to an arbitrary JSON value. + * + * You should usually call [Builder.enableReservations] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun enableReservations(enableReservations: JsonField) = apply { + this.enableReservations = enableReservations + } + + fun numReviewersPerItem(numReviewersPerItem: Long?) = + numReviewersPerItem(JsonField.ofNullable(numReviewersPerItem)) + + /** + * Alias for [Builder.numReviewersPerItem]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun numReviewersPerItem(numReviewersPerItem: Long) = + numReviewersPerItem(numReviewersPerItem as Long?) + + /** + * Alias for calling [Builder.numReviewersPerItem] with `numReviewersPerItem.orElse(null)`. + */ + fun numReviewersPerItem(numReviewersPerItem: Optional) = + numReviewersPerItem(numReviewersPerItem.getOrNull()) + + /** + * Sets [Builder.numReviewersPerItem] to an arbitrary JSON value. + * + * You should usually call [Builder.numReviewersPerItem] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun numReviewersPerItem(numReviewersPerItem: JsonField) = apply { + this.numReviewersPerItem = numReviewersPerItem + } + + fun reservationMinutes(reservationMinutes: Long?) = + reservationMinutes(JsonField.ofNullable(reservationMinutes)) + + /** + * Alias for [Builder.reservationMinutes]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun reservationMinutes(reservationMinutes: Long) = + reservationMinutes(reservationMinutes as Long?) + + /** + * Alias for calling [Builder.reservationMinutes] with `reservationMinutes.orElse(null)`. + */ + fun reservationMinutes(reservationMinutes: Optional) = + reservationMinutes(reservationMinutes.getOrNull()) + + /** + * Sets [Builder.reservationMinutes] to an arbitrary JSON value. + * + * You should usually call [Builder.reservationMinutes] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun reservationMinutes(reservationMinutes: JsonField) = apply { + this.reservationMinutes = reservationMinutes + } + + fun runRuleId(runRuleId: String?) = runRuleId(JsonField.ofNullable(runRuleId)) + + /** Alias for calling [Builder.runRuleId] with `runRuleId.orElse(null)`. */ + fun runRuleId(runRuleId: Optional) = runRuleId(runRuleId.getOrNull()) + + /** + * Sets [Builder.runRuleId] to an arbitrary JSON value. + * + * You should usually call [Builder.runRuleId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun runRuleId(runRuleId: JsonField) = apply { this.runRuleId = runRuleId } + + fun sourceRuleId(sourceRuleId: String?) = sourceRuleId(JsonField.ofNullable(sourceRuleId)) + + /** Alias for calling [Builder.sourceRuleId] with `sourceRuleId.orElse(null)`. */ + fun sourceRuleId(sourceRuleId: Optional) = sourceRuleId(sourceRuleId.getOrNull()) + + /** + * Sets [Builder.sourceRuleId] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceRuleId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun sourceRuleId(sourceRuleId: JsonField) = apply { + this.sourceRuleId = sourceRuleId + } + + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AnnotationQueueRetrieveAnnotationQueuesResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .tenantId() + * .totalRuns() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AnnotationQueueRetrieveAnnotationQueuesResponse = + AnnotationQueueRetrieveAnnotationQueuesResponse( + checkRequired("id", id), + checkRequired("name", name), + checkRequired("tenantId", tenantId), + checkRequired("totalRuns", totalRuns), + createdAt, + defaultDataset, + description, + enableReservations, + numReviewersPerItem, + reservationMinutes, + runRuleId, + sourceRuleId, + updatedAt, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AnnotationQueueRetrieveAnnotationQueuesResponse = apply { + if (validated) { + return@apply + } + + id() + name() + tenantId() + totalRuns() + createdAt() + defaultDataset() + description() + enableReservations() + numReviewersPerItem() + reservationMinutes() + runRuleId() + sourceRuleId() + updatedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + (if (totalRuns.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (defaultDataset.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (enableReservations.asKnown().isPresent) 1 else 0) + + (if (numReviewersPerItem.asKnown().isPresent) 1 else 0) + + (if (reservationMinutes.asKnown().isPresent) 1 else 0) + + (if (runRuleId.asKnown().isPresent) 1 else 0) + + (if (sourceRuleId.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AnnotationQueueRetrieveAnnotationQueuesResponse && + id == other.id && + name == other.name && + tenantId == other.tenantId && + totalRuns == other.totalRuns && + createdAt == other.createdAt && + defaultDataset == other.defaultDataset && + description == other.description && + enableReservations == other.enableReservations && + numReviewersPerItem == other.numReviewersPerItem && + reservationMinutes == other.reservationMinutes && + runRuleId == other.runRuleId && + sourceRuleId == other.sourceRuleId && + updatedAt == other.updatedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + name, + tenantId, + totalRuns, + createdAt, + defaultDataset, + description, + enableReservations, + numReviewersPerItem, + reservationMinutes, + runRuleId, + sourceRuleId, + updatedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AnnotationQueueRetrieveAnnotationQueuesResponse{id=$id, name=$name, tenantId=$tenantId, totalRuns=$totalRuns, createdAt=$createdAt, defaultDataset=$defaultDataset, description=$description, enableReservations=$enableReservations, numReviewersPerItem=$numReviewersPerItem, reservationMinutes=$reservationMinutes, runRuleId=$runRuleId, sourceRuleId=$sourceRuleId, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveParams.kt new file mode 100644 index 00000000..480b6c73 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveParams.kt @@ -0,0 +1,250 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get a run from an annotation queue */ +class AnnotationQueueRetrieveParams +private constructor( + private val queueId: String, + private val index: Long?, + private val includeExtra: Boolean?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun queueId(): String = queueId + + fun index(): Optional = Optional.ofNullable(index) + + fun includeExtra(): Optional = Optional.ofNullable(includeExtra) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AnnotationQueueRetrieveParams]. + * + * The following fields are required: + * ```java + * .queueId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AnnotationQueueRetrieveParams]. */ + class Builder internal constructor() { + + private var queueId: String? = null + private var index: Long? = null + private var includeExtra: Boolean? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(annotationQueueRetrieveParams: AnnotationQueueRetrieveParams) = apply { + queueId = annotationQueueRetrieveParams.queueId + index = annotationQueueRetrieveParams.index + includeExtra = annotationQueueRetrieveParams.includeExtra + additionalHeaders = annotationQueueRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = annotationQueueRetrieveParams.additionalQueryParams.toBuilder() + } + + fun queueId(queueId: String) = apply { this.queueId = queueId } + + fun index(index: Long?) = apply { this.index = index } + + /** + * Alias for [Builder.index]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun index(index: Long) = index(index as Long?) + + /** Alias for calling [Builder.index] with `index.orElse(null)`. */ + fun index(index: Optional) = index(index.getOrNull()) + + fun includeExtra(includeExtra: Boolean?) = apply { this.includeExtra = includeExtra } + + /** + * Alias for [Builder.includeExtra]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun includeExtra(includeExtra: Boolean) = includeExtra(includeExtra as Boolean?) + + /** Alias for calling [Builder.includeExtra] with `includeExtra.orElse(null)`. */ + fun includeExtra(includeExtra: Optional) = includeExtra(includeExtra.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [AnnotationQueueRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .queueId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AnnotationQueueRetrieveParams = + AnnotationQueueRetrieveParams( + checkRequired("queueId", queueId), + index, + includeExtra, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> queueId + 1 -> index?.toString() ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + includeExtra?.let { put("include_extra", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AnnotationQueueRetrieveParams && + queueId == other.queueId && + index == other.index && + includeExtra == other.includeExtra && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(queueId, index, includeExtra, additionalHeaders, additionalQueryParams) + + override fun toString() = + "AnnotationQueueRetrieveParams{queueId=$queueId, index=$index, includeExtra=$includeExtra, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveQueuesParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveQueuesParams.kt new file mode 100644 index 00000000..bfd0b185 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveQueuesParams.kt @@ -0,0 +1,199 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get Annotation Queues For Run */ +class AnnotationQueueRetrieveQueuesParams +private constructor( + private val runId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun runId(): Optional = Optional.ofNullable(runId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): AnnotationQueueRetrieveQueuesParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [AnnotationQueueRetrieveQueuesParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AnnotationQueueRetrieveQueuesParams]. */ + class Builder internal constructor() { + + private var runId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + annotationQueueRetrieveQueuesParams: AnnotationQueueRetrieveQueuesParams + ) = apply { + runId = annotationQueueRetrieveQueuesParams.runId + additionalHeaders = annotationQueueRetrieveQueuesParams.additionalHeaders.toBuilder() + additionalQueryParams = + annotationQueueRetrieveQueuesParams.additionalQueryParams.toBuilder() + } + + fun runId(runId: String?) = apply { this.runId = runId } + + /** Alias for calling [Builder.runId] with `runId.orElse(null)`. */ + fun runId(runId: Optional) = runId(runId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [AnnotationQueueRetrieveQueuesParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AnnotationQueueRetrieveQueuesParams = + AnnotationQueueRetrieveQueuesParams( + runId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> runId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AnnotationQueueRetrieveQueuesParams && + runId == other.runId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(runId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "AnnotationQueueRetrieveQueuesParams{runId=$runId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveSizeParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveSizeParams.kt new file mode 100644 index 00000000..16f4e1ff --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveSizeParams.kt @@ -0,0 +1,198 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get Size From Annotation Queue */ +class AnnotationQueueRetrieveSizeParams +private constructor( + private val queueId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun queueId(): Optional = Optional.ofNullable(queueId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): AnnotationQueueRetrieveSizeParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [AnnotationQueueRetrieveSizeParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AnnotationQueueRetrieveSizeParams]. */ + class Builder internal constructor() { + + private var queueId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(annotationQueueRetrieveSizeParams: AnnotationQueueRetrieveSizeParams) = + apply { + queueId = annotationQueueRetrieveSizeParams.queueId + additionalHeaders = annotationQueueRetrieveSizeParams.additionalHeaders.toBuilder() + additionalQueryParams = + annotationQueueRetrieveSizeParams.additionalQueryParams.toBuilder() + } + + fun queueId(queueId: String?) = apply { this.queueId = queueId } + + /** Alias for calling [Builder.queueId] with `queueId.orElse(null)`. */ + fun queueId(queueId: Optional) = queueId(queueId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [AnnotationQueueRetrieveSizeParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AnnotationQueueRetrieveSizeParams = + AnnotationQueueRetrieveSizeParams( + queueId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> queueId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AnnotationQueueRetrieveSizeParams && + queueId == other.queueId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(queueId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "AnnotationQueueRetrieveSizeParams{queueId=$queueId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveTotalArchivedParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveTotalArchivedParams.kt new file mode 100644 index 00000000..6384519a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveTotalArchivedParams.kt @@ -0,0 +1,236 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get Total Archived From Annotation Queue */ +class AnnotationQueueRetrieveTotalArchivedParams +private constructor( + private val queueId: String?, + private val endTime: OffsetDateTime?, + private val startTime: OffsetDateTime?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun queueId(): Optional = Optional.ofNullable(queueId) + + fun endTime(): Optional = Optional.ofNullable(endTime) + + fun startTime(): Optional = Optional.ofNullable(startTime) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): AnnotationQueueRetrieveTotalArchivedParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [AnnotationQueueRetrieveTotalArchivedParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AnnotationQueueRetrieveTotalArchivedParams]. */ + class Builder internal constructor() { + + private var queueId: String? = null + private var endTime: OffsetDateTime? = null + private var startTime: OffsetDateTime? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + annotationQueueRetrieveTotalArchivedParams: AnnotationQueueRetrieveTotalArchivedParams + ) = apply { + queueId = annotationQueueRetrieveTotalArchivedParams.queueId + endTime = annotationQueueRetrieveTotalArchivedParams.endTime + startTime = annotationQueueRetrieveTotalArchivedParams.startTime + additionalHeaders = + annotationQueueRetrieveTotalArchivedParams.additionalHeaders.toBuilder() + additionalQueryParams = + annotationQueueRetrieveTotalArchivedParams.additionalQueryParams.toBuilder() + } + + fun queueId(queueId: String?) = apply { this.queueId = queueId } + + /** Alias for calling [Builder.queueId] with `queueId.orElse(null)`. */ + fun queueId(queueId: Optional) = queueId(queueId.getOrNull()) + + fun endTime(endTime: OffsetDateTime?) = apply { this.endTime = endTime } + + /** Alias for calling [Builder.endTime] with `endTime.orElse(null)`. */ + fun endTime(endTime: Optional) = endTime(endTime.getOrNull()) + + fun startTime(startTime: OffsetDateTime?) = apply { this.startTime = startTime } + + /** Alias for calling [Builder.startTime] with `startTime.orElse(null)`. */ + fun startTime(startTime: Optional) = startTime(startTime.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [AnnotationQueueRetrieveTotalArchivedParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AnnotationQueueRetrieveTotalArchivedParams = + AnnotationQueueRetrieveTotalArchivedParams( + queueId, + endTime, + startTime, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> queueId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + endTime?.let { put("end_time", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) } + startTime?.let { + put("start_time", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AnnotationQueueRetrieveTotalArchivedParams && + queueId == other.queueId && + endTime == other.endTime && + startTime == other.startTime && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(queueId, endTime, startTime, additionalHeaders, additionalQueryParams) + + override fun toString() = + "AnnotationQueueRetrieveTotalArchivedParams{queueId=$queueId, endTime=$endTime, startTime=$startTime, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveTotalSizeParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveTotalSizeParams.kt new file mode 100644 index 00000000..b257434c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveTotalSizeParams.kt @@ -0,0 +1,199 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get Total Size From Annotation Queue */ +class AnnotationQueueRetrieveTotalSizeParams +private constructor( + private val queueId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun queueId(): Optional = Optional.ofNullable(queueId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): AnnotationQueueRetrieveTotalSizeParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [AnnotationQueueRetrieveTotalSizeParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AnnotationQueueRetrieveTotalSizeParams]. */ + class Builder internal constructor() { + + private var queueId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + annotationQueueRetrieveTotalSizeParams: AnnotationQueueRetrieveTotalSizeParams + ) = apply { + queueId = annotationQueueRetrieveTotalSizeParams.queueId + additionalHeaders = annotationQueueRetrieveTotalSizeParams.additionalHeaders.toBuilder() + additionalQueryParams = + annotationQueueRetrieveTotalSizeParams.additionalQueryParams.toBuilder() + } + + fun queueId(queueId: String?) = apply { this.queueId = queueId } + + /** Alias for calling [Builder.queueId] with `queueId.orElse(null)`. */ + fun queueId(queueId: Optional) = queueId(queueId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [AnnotationQueueRetrieveTotalSizeParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AnnotationQueueRetrieveTotalSizeParams = + AnnotationQueueRetrieveTotalSizeParams( + queueId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> queueId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AnnotationQueueRetrieveTotalSizeParams && + queueId == other.queueId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(queueId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "AnnotationQueueRetrieveTotalSizeParams{queueId=$queueId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRubricItemSchema.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRubricItemSchema.kt new file mode 100644 index 00000000..6404143f --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRubricItemSchema.kt @@ -0,0 +1,516 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class AnnotationQueueRubricItemSchema +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val feedbackKey: JsonField, + private val description: JsonField, + private val scoreDescriptions: JsonField, + private val valueDescriptions: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("feedback_key") + @ExcludeMissing + feedbackKey: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("score_descriptions") + @ExcludeMissing + scoreDescriptions: JsonField = JsonMissing.of(), + @JsonProperty("value_descriptions") + @ExcludeMissing + valueDescriptions: JsonField = JsonMissing.of(), + ) : this(feedbackKey, description, scoreDescriptions, valueDescriptions, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun feedbackKey(): String = feedbackKey.getRequired("feedback_key") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun scoreDescriptions(): Optional = + scoreDescriptions.getOptional("score_descriptions") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun valueDescriptions(): Optional = + valueDescriptions.getOptional("value_descriptions") + + /** + * Returns the raw JSON value of [feedbackKey]. + * + * Unlike [feedbackKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feedback_key") + @ExcludeMissing + fun _feedbackKey(): JsonField = feedbackKey + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [scoreDescriptions]. + * + * Unlike [scoreDescriptions], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("score_descriptions") + @ExcludeMissing + fun _scoreDescriptions(): JsonField = scoreDescriptions + + /** + * Returns the raw JSON value of [valueDescriptions]. + * + * Unlike [valueDescriptions], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("value_descriptions") + @ExcludeMissing + fun _valueDescriptions(): JsonField = valueDescriptions + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AnnotationQueueRubricItemSchema]. + * + * The following fields are required: + * ```java + * .feedbackKey() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AnnotationQueueRubricItemSchema]. */ + class Builder internal constructor() { + + private var feedbackKey: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var scoreDescriptions: JsonField = JsonMissing.of() + private var valueDescriptions: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(annotationQueueRubricItemSchema: AnnotationQueueRubricItemSchema) = + apply { + feedbackKey = annotationQueueRubricItemSchema.feedbackKey + description = annotationQueueRubricItemSchema.description + scoreDescriptions = annotationQueueRubricItemSchema.scoreDescriptions + valueDescriptions = annotationQueueRubricItemSchema.valueDescriptions + additionalProperties = + annotationQueueRubricItemSchema.additionalProperties.toMutableMap() + } + + fun feedbackKey(feedbackKey: String) = feedbackKey(JsonField.of(feedbackKey)) + + /** + * Sets [Builder.feedbackKey] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun feedbackKey(feedbackKey: JsonField) = apply { this.feedbackKey = feedbackKey } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField) = apply { this.description = description } + + fun scoreDescriptions(scoreDescriptions: ScoreDescriptions?) = + scoreDescriptions(JsonField.ofNullable(scoreDescriptions)) + + /** Alias for calling [Builder.scoreDescriptions] with `scoreDescriptions.orElse(null)`. */ + fun scoreDescriptions(scoreDescriptions: Optional) = + scoreDescriptions(scoreDescriptions.getOrNull()) + + /** + * Sets [Builder.scoreDescriptions] to an arbitrary JSON value. + * + * You should usually call [Builder.scoreDescriptions] with a well-typed [ScoreDescriptions] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun scoreDescriptions(scoreDescriptions: JsonField) = apply { + this.scoreDescriptions = scoreDescriptions + } + + fun valueDescriptions(valueDescriptions: ValueDescriptions?) = + valueDescriptions(JsonField.ofNullable(valueDescriptions)) + + /** Alias for calling [Builder.valueDescriptions] with `valueDescriptions.orElse(null)`. */ + fun valueDescriptions(valueDescriptions: Optional) = + valueDescriptions(valueDescriptions.getOrNull()) + + /** + * Sets [Builder.valueDescriptions] to an arbitrary JSON value. + * + * You should usually call [Builder.valueDescriptions] with a well-typed [ValueDescriptions] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun valueDescriptions(valueDescriptions: JsonField) = apply { + this.valueDescriptions = valueDescriptions + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AnnotationQueueRubricItemSchema]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .feedbackKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AnnotationQueueRubricItemSchema = + AnnotationQueueRubricItemSchema( + checkRequired("feedbackKey", feedbackKey), + description, + scoreDescriptions, + valueDescriptions, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AnnotationQueueRubricItemSchema = apply { + if (validated) { + return@apply + } + + feedbackKey() + description() + scoreDescriptions().ifPresent { it.validate() } + valueDescriptions().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (feedbackKey.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (scoreDescriptions.asKnown().getOrNull()?.validity() ?: 0) + + (valueDescriptions.asKnown().getOrNull()?.validity() ?: 0) + + class ScoreDescriptions + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ScoreDescriptions]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScoreDescriptions]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(scoreDescriptions: ScoreDescriptions) = apply { + additionalProperties = scoreDescriptions.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ScoreDescriptions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ScoreDescriptions = ScoreDescriptions(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ScoreDescriptions = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScoreDescriptions && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "ScoreDescriptions{additionalProperties=$additionalProperties}" + } + + class ValueDescriptions + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ValueDescriptions]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ValueDescriptions]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(valueDescriptions: ValueDescriptions) = apply { + additionalProperties = valueDescriptions.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ValueDescriptions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ValueDescriptions = ValueDescriptions(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ValueDescriptions = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ValueDescriptions && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "ValueDescriptions{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AnnotationQueueRubricItemSchema && + feedbackKey == other.feedbackKey && + description == other.description && + scoreDescriptions == other.scoreDescriptions && + valueDescriptions == other.valueDescriptions && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + feedbackKey, + description, + scoreDescriptions, + valueDescriptions, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AnnotationQueueRubricItemSchema{feedbackKey=$feedbackKey, description=$description, scoreDescriptions=$scoreDescriptions, valueDescriptions=$valueDescriptions, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueSchema.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueSchema.kt new file mode 100644 index 00000000..fcf2644f --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueSchema.kt @@ -0,0 +1,666 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** AnnotationQueue schema. */ +class AnnotationQueueSchema +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val name: JsonField, + private val tenantId: JsonField, + private val createdAt: JsonField, + private val defaultDataset: JsonField, + private val description: JsonField, + private val enableReservations: JsonField, + private val numReviewersPerItem: JsonField, + private val reservationMinutes: JsonField, + private val runRuleId: JsonField, + private val sourceRuleId: JsonField, + private val updatedAt: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("tenant_id") @ExcludeMissing tenantId: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("default_dataset") + @ExcludeMissing + defaultDataset: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("enable_reservations") + @ExcludeMissing + enableReservations: JsonField = JsonMissing.of(), + @JsonProperty("num_reviewers_per_item") + @ExcludeMissing + numReviewersPerItem: JsonField = JsonMissing.of(), + @JsonProperty("reservation_minutes") + @ExcludeMissing + reservationMinutes: JsonField = JsonMissing.of(), + @JsonProperty("run_rule_id") + @ExcludeMissing + runRuleId: JsonField = JsonMissing.of(), + @JsonProperty("source_rule_id") + @ExcludeMissing + sourceRuleId: JsonField = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), + ) : this( + id, + name, + tenantId, + createdAt, + defaultDataset, + description, + enableReservations, + numReviewersPerItem, + reservationMinutes, + runRuleId, + sourceRuleId, + updatedAt, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tenantId(): String = tenantId.getRequired("tenant_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun createdAt(): Optional = createdAt.getOptional("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun defaultDataset(): Optional = defaultDataset.getOptional("default_dataset") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun enableReservations(): Optional = + enableReservations.getOptional("enable_reservations") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun numReviewersPerItem(): Optional = + numReviewersPerItem.getOptional("num_reviewers_per_item") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun reservationMinutes(): Optional = reservationMinutes.getOptional("reservation_minutes") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun runRuleId(): Optional = runRuleId.getOptional("run_rule_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun sourceRuleId(): Optional = sourceRuleId.getOptional("source_rule_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun updatedAt(): Optional = updatedAt.getOptional("updated_at") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_id") @ExcludeMissing fun _tenantId(): JsonField = tenantId + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [defaultDataset]. + * + * Unlike [defaultDataset], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("default_dataset") + @ExcludeMissing + fun _defaultDataset(): JsonField = defaultDataset + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [enableReservations]. + * + * Unlike [enableReservations], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("enable_reservations") + @ExcludeMissing + fun _enableReservations(): JsonField = enableReservations + + /** + * Returns the raw JSON value of [numReviewersPerItem]. + * + * Unlike [numReviewersPerItem], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("num_reviewers_per_item") + @ExcludeMissing + fun _numReviewersPerItem(): JsonField = numReviewersPerItem + + /** + * Returns the raw JSON value of [reservationMinutes]. + * + * Unlike [reservationMinutes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reservation_minutes") + @ExcludeMissing + fun _reservationMinutes(): JsonField = reservationMinutes + + /** + * Returns the raw JSON value of [runRuleId]. + * + * Unlike [runRuleId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_rule_id") @ExcludeMissing fun _runRuleId(): JsonField = runRuleId + + /** + * Returns the raw JSON value of [sourceRuleId]. + * + * Unlike [sourceRuleId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("source_rule_id") + @ExcludeMissing + fun _sourceRuleId(): JsonField = sourceRuleId + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField = updatedAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AnnotationQueueSchema]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .tenantId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AnnotationQueueSchema]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var name: JsonField? = null + private var tenantId: JsonField? = null + private var createdAt: JsonField = JsonMissing.of() + private var defaultDataset: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var enableReservations: JsonField = JsonMissing.of() + private var numReviewersPerItem: JsonField = JsonMissing.of() + private var reservationMinutes: JsonField = JsonMissing.of() + private var runRuleId: JsonField = JsonMissing.of() + private var sourceRuleId: JsonField = JsonMissing.of() + private var updatedAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(annotationQueueSchema: AnnotationQueueSchema) = apply { + id = annotationQueueSchema.id + name = annotationQueueSchema.name + tenantId = annotationQueueSchema.tenantId + createdAt = annotationQueueSchema.createdAt + defaultDataset = annotationQueueSchema.defaultDataset + description = annotationQueueSchema.description + enableReservations = annotationQueueSchema.enableReservations + numReviewersPerItem = annotationQueueSchema.numReviewersPerItem + reservationMinutes = annotationQueueSchema.reservationMinutes + runRuleId = annotationQueueSchema.runRuleId + sourceRuleId = annotationQueueSchema.sourceRuleId + updatedAt = annotationQueueSchema.updatedAt + additionalProperties = annotationQueueSchema.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tenantId(tenantId: JsonField) = apply { this.tenantId = tenantId } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + fun defaultDataset(defaultDataset: String?) = + defaultDataset(JsonField.ofNullable(defaultDataset)) + + /** Alias for calling [Builder.defaultDataset] with `defaultDataset.orElse(null)`. */ + fun defaultDataset(defaultDataset: Optional) = + defaultDataset(defaultDataset.getOrNull()) + + /** + * Sets [Builder.defaultDataset] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultDataset] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun defaultDataset(defaultDataset: JsonField) = apply { + this.defaultDataset = defaultDataset + } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField) = apply { this.description = description } + + fun enableReservations(enableReservations: Boolean?) = + enableReservations(JsonField.ofNullable(enableReservations)) + + /** + * Alias for [Builder.enableReservations]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun enableReservations(enableReservations: Boolean) = + enableReservations(enableReservations as Boolean?) + + /** + * Alias for calling [Builder.enableReservations] with `enableReservations.orElse(null)`. + */ + fun enableReservations(enableReservations: Optional) = + enableReservations(enableReservations.getOrNull()) + + /** + * Sets [Builder.enableReservations] to an arbitrary JSON value. + * + * You should usually call [Builder.enableReservations] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun enableReservations(enableReservations: JsonField) = apply { + this.enableReservations = enableReservations + } + + fun numReviewersPerItem(numReviewersPerItem: Long?) = + numReviewersPerItem(JsonField.ofNullable(numReviewersPerItem)) + + /** + * Alias for [Builder.numReviewersPerItem]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun numReviewersPerItem(numReviewersPerItem: Long) = + numReviewersPerItem(numReviewersPerItem as Long?) + + /** + * Alias for calling [Builder.numReviewersPerItem] with `numReviewersPerItem.orElse(null)`. + */ + fun numReviewersPerItem(numReviewersPerItem: Optional) = + numReviewersPerItem(numReviewersPerItem.getOrNull()) + + /** + * Sets [Builder.numReviewersPerItem] to an arbitrary JSON value. + * + * You should usually call [Builder.numReviewersPerItem] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun numReviewersPerItem(numReviewersPerItem: JsonField) = apply { + this.numReviewersPerItem = numReviewersPerItem + } + + fun reservationMinutes(reservationMinutes: Long?) = + reservationMinutes(JsonField.ofNullable(reservationMinutes)) + + /** + * Alias for [Builder.reservationMinutes]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun reservationMinutes(reservationMinutes: Long) = + reservationMinutes(reservationMinutes as Long?) + + /** + * Alias for calling [Builder.reservationMinutes] with `reservationMinutes.orElse(null)`. + */ + fun reservationMinutes(reservationMinutes: Optional) = + reservationMinutes(reservationMinutes.getOrNull()) + + /** + * Sets [Builder.reservationMinutes] to an arbitrary JSON value. + * + * You should usually call [Builder.reservationMinutes] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun reservationMinutes(reservationMinutes: JsonField) = apply { + this.reservationMinutes = reservationMinutes + } + + fun runRuleId(runRuleId: String?) = runRuleId(JsonField.ofNullable(runRuleId)) + + /** Alias for calling [Builder.runRuleId] with `runRuleId.orElse(null)`. */ + fun runRuleId(runRuleId: Optional) = runRuleId(runRuleId.getOrNull()) + + /** + * Sets [Builder.runRuleId] to an arbitrary JSON value. + * + * You should usually call [Builder.runRuleId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun runRuleId(runRuleId: JsonField) = apply { this.runRuleId = runRuleId } + + fun sourceRuleId(sourceRuleId: String?) = sourceRuleId(JsonField.ofNullable(sourceRuleId)) + + /** Alias for calling [Builder.sourceRuleId] with `sourceRuleId.orElse(null)`. */ + fun sourceRuleId(sourceRuleId: Optional) = sourceRuleId(sourceRuleId.getOrNull()) + + /** + * Sets [Builder.sourceRuleId] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceRuleId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun sourceRuleId(sourceRuleId: JsonField) = apply { + this.sourceRuleId = sourceRuleId + } + + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AnnotationQueueSchema]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .tenantId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AnnotationQueueSchema = + AnnotationQueueSchema( + checkRequired("id", id), + checkRequired("name", name), + checkRequired("tenantId", tenantId), + createdAt, + defaultDataset, + description, + enableReservations, + numReviewersPerItem, + reservationMinutes, + runRuleId, + sourceRuleId, + updatedAt, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AnnotationQueueSchema = apply { + if (validated) { + return@apply + } + + id() + name() + tenantId() + createdAt() + defaultDataset() + description() + enableReservations() + numReviewersPerItem() + reservationMinutes() + runRuleId() + sourceRuleId() + updatedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (defaultDataset.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (enableReservations.asKnown().isPresent) 1 else 0) + + (if (numReviewersPerItem.asKnown().isPresent) 1 else 0) + + (if (reservationMinutes.asKnown().isPresent) 1 else 0) + + (if (runRuleId.asKnown().isPresent) 1 else 0) + + (if (sourceRuleId.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AnnotationQueueSchema && + id == other.id && + name == other.name && + tenantId == other.tenantId && + createdAt == other.createdAt && + defaultDataset == other.defaultDataset && + description == other.description && + enableReservations == other.enableReservations && + numReviewersPerItem == other.numReviewersPerItem && + reservationMinutes == other.reservationMinutes && + runRuleId == other.runRuleId && + sourceRuleId == other.sourceRuleId && + updatedAt == other.updatedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + name, + tenantId, + createdAt, + defaultDataset, + description, + enableReservations, + numReviewersPerItem, + reservationMinutes, + runRuleId, + sourceRuleId, + updatedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AnnotationQueueSchema{id=$id, name=$name, tenantId=$tenantId, createdAt=$createdAt, defaultDataset=$defaultDataset, description=$description, enableReservations=$enableReservations, numReviewersPerItem=$numReviewersPerItem, reservationMinutes=$reservationMinutes, runRuleId=$runRuleId, sourceRuleId=$sourceRuleId, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueSizeSchema.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueSizeSchema.kt new file mode 100644 index 00000000..fe236e1d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueSizeSchema.kt @@ -0,0 +1,171 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +/** Size of an Annotation Queue */ +class AnnotationQueueSizeSchema +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val size: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("size") @ExcludeMissing size: JsonField = JsonMissing.of() + ) : this(size, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun size(): Long = size.getRequired("size") + + /** + * Returns the raw JSON value of [size]. + * + * Unlike [size], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("size") @ExcludeMissing fun _size(): JsonField = size + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AnnotationQueueSizeSchema]. + * + * The following fields are required: + * ```java + * .size() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AnnotationQueueSizeSchema]. */ + class Builder internal constructor() { + + private var size: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(annotationQueueSizeSchema: AnnotationQueueSizeSchema) = apply { + size = annotationQueueSizeSchema.size + additionalProperties = annotationQueueSizeSchema.additionalProperties.toMutableMap() + } + + fun size(size: Long) = size(JsonField.of(size)) + + /** + * Sets [Builder.size] to an arbitrary JSON value. + * + * You should usually call [Builder.size] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun size(size: JsonField) = apply { this.size = size } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AnnotationQueueSizeSchema]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .size() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AnnotationQueueSizeSchema = + AnnotationQueueSizeSchema( + checkRequired("size", size), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AnnotationQueueSizeSchema = apply { + if (validated) { + return@apply + } + + size() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (size.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AnnotationQueueSizeSchema && + size == other.size && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(size, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AnnotationQueueSizeSchema{size=$size, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueUpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueUpdateParams.kt new file mode 100644 index 00000000..88eddf18 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueUpdateParams.kt @@ -0,0 +1,499 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create Identity Annotation Queue Run Status */ +class AnnotationQueueUpdateParams +private constructor( + private val annotationQueueRunId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun annotationQueueRunId(): Optional = Optional.ofNullable(annotationQueueRunId) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun overrideAddedAt(): Optional = body.overrideAddedAt() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun status(): Optional = body.status() + + /** + * Returns the raw JSON value of [overrideAddedAt]. + * + * Unlike [overrideAddedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _overrideAddedAt(): JsonField = body._overrideAddedAt() + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _status(): JsonField = body._status() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): AnnotationQueueUpdateParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [AnnotationQueueUpdateParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AnnotationQueueUpdateParams]. */ + class Builder internal constructor() { + + private var annotationQueueRunId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(annotationQueueUpdateParams: AnnotationQueueUpdateParams) = apply { + annotationQueueRunId = annotationQueueUpdateParams.annotationQueueRunId + body = annotationQueueUpdateParams.body.toBuilder() + additionalHeaders = annotationQueueUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = annotationQueueUpdateParams.additionalQueryParams.toBuilder() + } + + fun annotationQueueRunId(annotationQueueRunId: String?) = apply { + this.annotationQueueRunId = annotationQueueRunId + } + + /** + * Alias for calling [Builder.annotationQueueRunId] with + * `annotationQueueRunId.orElse(null)`. + */ + fun annotationQueueRunId(annotationQueueRunId: Optional) = + annotationQueueRunId(annotationQueueRunId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [overrideAddedAt] + * - [status] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun overrideAddedAt(overrideAddedAt: OffsetDateTime?) = apply { + body.overrideAddedAt(overrideAddedAt) + } + + /** Alias for calling [Builder.overrideAddedAt] with `overrideAddedAt.orElse(null)`. */ + fun overrideAddedAt(overrideAddedAt: Optional) = + overrideAddedAt(overrideAddedAt.getOrNull()) + + /** + * Sets [Builder.overrideAddedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.overrideAddedAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun overrideAddedAt(overrideAddedAt: JsonField) = apply { + body.overrideAddedAt(overrideAddedAt) + } + + fun status(status: String?) = apply { body.status(status) } + + /** Alias for calling [Builder.status] with `status.orElse(null)`. */ + fun status(status: Optional) = status(status.getOrNull()) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { body.status(status) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [AnnotationQueueUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AnnotationQueueUpdateParams = + AnnotationQueueUpdateParams( + annotationQueueRunId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> annotationQueueRunId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Identity annotation queue run status create schema. */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val overrideAddedAt: JsonField, + private val status: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("override_added_at") + @ExcludeMissing + overrideAddedAt: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + ) : this(overrideAddedAt, status, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun overrideAddedAt(): Optional = + overrideAddedAt.getOptional("override_added_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * Returns the raw JSON value of [overrideAddedAt]. + * + * Unlike [overrideAddedAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("override_added_at") + @ExcludeMissing + fun _overrideAddedAt(): JsonField = overrideAddedAt + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var overrideAddedAt: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + overrideAddedAt = body.overrideAddedAt + status = body.status + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun overrideAddedAt(overrideAddedAt: OffsetDateTime?) = + overrideAddedAt(JsonField.ofNullable(overrideAddedAt)) + + /** Alias for calling [Builder.overrideAddedAt] with `overrideAddedAt.orElse(null)`. */ + fun overrideAddedAt(overrideAddedAt: Optional) = + overrideAddedAt(overrideAddedAt.getOrNull()) + + /** + * Sets [Builder.overrideAddedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.overrideAddedAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun overrideAddedAt(overrideAddedAt: JsonField) = apply { + this.overrideAddedAt = overrideAddedAt + } + + fun status(status: String?) = status(JsonField.ofNullable(status)) + + /** Alias for calling [Builder.status] with `status.orElse(null)`. */ + fun status(status: Optional) = status(status.getOrNull()) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = Body(overrideAddedAt, status, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + overrideAddedAt() + status() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (overrideAddedAt.asKnown().isPresent) 1 else 0) + + (if (status.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + overrideAddedAt == other.overrideAddedAt && + status == other.status && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(overrideAddedAt, status, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{overrideAddedAt=$overrideAddedAt, status=$status, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AnnotationQueueUpdateParams && + annotationQueueRunId == other.annotationQueueRunId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(annotationQueueRunId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "AnnotationQueueUpdateParams{annotationQueueRunId=$annotationQueueRunId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueUpdateResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueUpdateResponse.kt new file mode 100644 index 00000000..6f968f83 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueUpdateResponse.kt @@ -0,0 +1,119 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class AnnotationQueueUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AnnotationQueueUpdateResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AnnotationQueueUpdateResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(annotationQueueUpdateResponse: AnnotationQueueUpdateResponse) = apply { + additionalProperties = annotationQueueUpdateResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AnnotationQueueUpdateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AnnotationQueueUpdateResponse = + AnnotationQueueUpdateResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): AnnotationQueueUpdateResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AnnotationQueueUpdateResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AnnotationQueueUpdateResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/RunSchemaWithAnnotationQueueInfo.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/RunSchemaWithAnnotationQueueInfo.kt new file mode 100644 index 00000000..2c02ff58 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/RunSchemaWithAnnotationQueueInfo.kt @@ -0,0 +1,2948 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TraceTier +import com.langsmith_api.api.models.api.v1.runs.RunTypeEnum +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Run schema with annotation queue info. */ +class RunSchemaWithAnnotationQueueInfo +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val appPath: JsonField, + private val dottedOrder: JsonField, + private val name: JsonField, + private val queueRunId: JsonField, + private val runType: JsonField, + private val sessionId: JsonField, + private val status: JsonField, + private val traceId: JsonField, + private val addedAt: JsonField, + private val childRunIds: JsonField>, + private val completionCost: JsonField, + private val completionCostDetails: JsonField, + private val completionTokenDetails: JsonField, + private val completionTokens: JsonField, + private val directChildRunIds: JsonField>, + private val effectiveAddedAt: JsonField, + private val endTime: JsonField, + private val error: JsonField, + private val events: JsonField>, + private val executionOrder: JsonField, + private val extra: JsonValue, + private val feedbackStats: JsonField, + private val firstTokenTime: JsonField, + private val inDataset: JsonField, + private val inputs: JsonValue, + private val inputsPreview: JsonField, + private val inputsS3Urls: JsonValue, + private val lastQueuedAt: JsonField, + private val lastReviewedTime: JsonField, + private val manifestId: JsonField, + private val manifestS3Id: JsonField, + private val outputs: JsonValue, + private val outputsPreview: JsonField, + private val outputsS3Urls: JsonValue, + private val parentRunId: JsonField, + private val parentRunIds: JsonField>, + private val priceModelId: JsonField, + private val promptCost: JsonField, + private val promptCostDetails: JsonField, + private val promptTokenDetails: JsonField, + private val promptTokens: JsonField, + private val referenceDatasetId: JsonField, + private val referenceExampleId: JsonField, + private val s3Urls: JsonValue, + private val serialized: JsonValue, + private val shareToken: JsonField, + private val startTime: JsonField, + private val tags: JsonField>, + private val threadId: JsonField, + private val totalCost: JsonField, + private val totalTokens: JsonField, + private val traceFirstReceivedAt: JsonField, + private val traceMaxStartTime: JsonField, + private val traceMinStartTime: JsonField, + private val traceTier: JsonField, + private val traceUpgrade: JsonField, + private val ttlSeconds: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("app_path") @ExcludeMissing appPath: JsonField = JsonMissing.of(), + @JsonProperty("dotted_order") + @ExcludeMissing + dottedOrder: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("queue_run_id") + @ExcludeMissing + queueRunId: JsonField = JsonMissing.of(), + @JsonProperty("run_type") + @ExcludeMissing + runType: JsonField = JsonMissing.of(), + @JsonProperty("session_id") @ExcludeMissing sessionId: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("trace_id") @ExcludeMissing traceId: JsonField = JsonMissing.of(), + @JsonProperty("added_at") + @ExcludeMissing + addedAt: JsonField = JsonMissing.of(), + @JsonProperty("child_run_ids") + @ExcludeMissing + childRunIds: JsonField> = JsonMissing.of(), + @JsonProperty("completion_cost") + @ExcludeMissing + completionCost: JsonField = JsonMissing.of(), + @JsonProperty("completion_cost_details") + @ExcludeMissing + completionCostDetails: JsonField = JsonMissing.of(), + @JsonProperty("completion_token_details") + @ExcludeMissing + completionTokenDetails: JsonField = JsonMissing.of(), + @JsonProperty("completion_tokens") + @ExcludeMissing + completionTokens: JsonField = JsonMissing.of(), + @JsonProperty("direct_child_run_ids") + @ExcludeMissing + directChildRunIds: JsonField> = JsonMissing.of(), + @JsonProperty("effective_added_at") + @ExcludeMissing + effectiveAddedAt: JsonField = JsonMissing.of(), + @JsonProperty("end_time") + @ExcludeMissing + endTime: JsonField = JsonMissing.of(), + @JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(), + @JsonProperty("events") + @ExcludeMissing + events: JsonField> = JsonMissing.of(), + @JsonProperty("execution_order") + @ExcludeMissing + executionOrder: JsonField = JsonMissing.of(), + @JsonProperty("extra") @ExcludeMissing extra: JsonValue = JsonMissing.of(), + @JsonProperty("feedback_stats") + @ExcludeMissing + feedbackStats: JsonField = JsonMissing.of(), + @JsonProperty("first_token_time") + @ExcludeMissing + firstTokenTime: JsonField = JsonMissing.of(), + @JsonProperty("in_dataset") + @ExcludeMissing + inDataset: JsonField = JsonMissing.of(), + @JsonProperty("inputs") @ExcludeMissing inputs: JsonValue = JsonMissing.of(), + @JsonProperty("inputs_preview") + @ExcludeMissing + inputsPreview: JsonField = JsonMissing.of(), + @JsonProperty("inputs_s3_urls") @ExcludeMissing inputsS3Urls: JsonValue = JsonMissing.of(), + @JsonProperty("last_queued_at") + @ExcludeMissing + lastQueuedAt: JsonField = JsonMissing.of(), + @JsonProperty("last_reviewed_time") + @ExcludeMissing + lastReviewedTime: JsonField = JsonMissing.of(), + @JsonProperty("manifest_id") + @ExcludeMissing + manifestId: JsonField = JsonMissing.of(), + @JsonProperty("manifest_s3_id") + @ExcludeMissing + manifestS3Id: JsonField = JsonMissing.of(), + @JsonProperty("outputs") @ExcludeMissing outputs: JsonValue = JsonMissing.of(), + @JsonProperty("outputs_preview") + @ExcludeMissing + outputsPreview: JsonField = JsonMissing.of(), + @JsonProperty("outputs_s3_urls") + @ExcludeMissing + outputsS3Urls: JsonValue = JsonMissing.of(), + @JsonProperty("parent_run_id") + @ExcludeMissing + parentRunId: JsonField = JsonMissing.of(), + @JsonProperty("parent_run_ids") + @ExcludeMissing + parentRunIds: JsonField> = JsonMissing.of(), + @JsonProperty("price_model_id") + @ExcludeMissing + priceModelId: JsonField = JsonMissing.of(), + @JsonProperty("prompt_cost") + @ExcludeMissing + promptCost: JsonField = JsonMissing.of(), + @JsonProperty("prompt_cost_details") + @ExcludeMissing + promptCostDetails: JsonField = JsonMissing.of(), + @JsonProperty("prompt_token_details") + @ExcludeMissing + promptTokenDetails: JsonField = JsonMissing.of(), + @JsonProperty("prompt_tokens") + @ExcludeMissing + promptTokens: JsonField = JsonMissing.of(), + @JsonProperty("reference_dataset_id") + @ExcludeMissing + referenceDatasetId: JsonField = JsonMissing.of(), + @JsonProperty("reference_example_id") + @ExcludeMissing + referenceExampleId: JsonField = JsonMissing.of(), + @JsonProperty("s3_urls") @ExcludeMissing s3Urls: JsonValue = JsonMissing.of(), + @JsonProperty("serialized") @ExcludeMissing serialized: JsonValue = JsonMissing.of(), + @JsonProperty("share_token") + @ExcludeMissing + shareToken: JsonField = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing tags: JsonField> = JsonMissing.of(), + @JsonProperty("thread_id") @ExcludeMissing threadId: JsonField = JsonMissing.of(), + @JsonProperty("total_cost") @ExcludeMissing totalCost: JsonField = JsonMissing.of(), + @JsonProperty("total_tokens") + @ExcludeMissing + totalTokens: JsonField = JsonMissing.of(), + @JsonProperty("trace_first_received_at") + @ExcludeMissing + traceFirstReceivedAt: JsonField = JsonMissing.of(), + @JsonProperty("trace_max_start_time") + @ExcludeMissing + traceMaxStartTime: JsonField = JsonMissing.of(), + @JsonProperty("trace_min_start_time") + @ExcludeMissing + traceMinStartTime: JsonField = JsonMissing.of(), + @JsonProperty("trace_tier") + @ExcludeMissing + traceTier: JsonField = JsonMissing.of(), + @JsonProperty("trace_upgrade") + @ExcludeMissing + traceUpgrade: JsonField = JsonMissing.of(), + @JsonProperty("ttl_seconds") @ExcludeMissing ttlSeconds: JsonField = JsonMissing.of(), + ) : this( + id, + appPath, + dottedOrder, + name, + queueRunId, + runType, + sessionId, + status, + traceId, + addedAt, + childRunIds, + completionCost, + completionCostDetails, + completionTokenDetails, + completionTokens, + directChildRunIds, + effectiveAddedAt, + endTime, + error, + events, + executionOrder, + extra, + feedbackStats, + firstTokenTime, + inDataset, + inputs, + inputsPreview, + inputsS3Urls, + lastQueuedAt, + lastReviewedTime, + manifestId, + manifestS3Id, + outputs, + outputsPreview, + outputsS3Urls, + parentRunId, + parentRunIds, + priceModelId, + promptCost, + promptCostDetails, + promptTokenDetails, + promptTokens, + referenceDatasetId, + referenceExampleId, + s3Urls, + serialized, + shareToken, + startTime, + tags, + threadId, + totalCost, + totalTokens, + traceFirstReceivedAt, + traceMaxStartTime, + traceMinStartTime, + traceTier, + traceUpgrade, + ttlSeconds, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun appPath(): String = appPath.getRequired("app_path") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun dottedOrder(): String = dottedOrder.getRequired("dotted_order") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun queueRunId(): String = queueRunId.getRequired("queue_run_id") + + /** + * Enum for run types. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun runType(): RunTypeEnum = runType.getRequired("run_type") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun sessionId(): String = sessionId.getRequired("session_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): String = status.getRequired("status") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun traceId(): String = traceId.getRequired("trace_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun addedAt(): Optional = addedAt.getOptional("added_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun childRunIds(): Optional> = childRunIds.getOptional("child_run_ids") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun completionCost(): Optional = completionCost.getOptional("completion_cost") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun completionCostDetails(): Optional = + completionCostDetails.getOptional("completion_cost_details") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun completionTokenDetails(): Optional = + completionTokenDetails.getOptional("completion_token_details") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun completionTokens(): Optional = completionTokens.getOptional("completion_tokens") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun directChildRunIds(): Optional> = + directChildRunIds.getOptional("direct_child_run_ids") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun effectiveAddedAt(): Optional = + effectiveAddedAt.getOptional("effective_added_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endTime(): Optional = endTime.getOptional("end_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun error(): Optional = error.getOptional("error") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun events(): Optional> = events.getOptional("events") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun executionOrder(): Optional = executionOrder.getOptional("execution_order") + + @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonValue = extra + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun feedbackStats(): Optional = feedbackStats.getOptional("feedback_stats") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun firstTokenTime(): Optional = firstTokenTime.getOptional("first_token_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun inDataset(): Optional = inDataset.getOptional("in_dataset") + + @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonValue = inputs + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun inputsPreview(): Optional = inputsPreview.getOptional("inputs_preview") + + @JsonProperty("inputs_s3_urls") @ExcludeMissing fun _inputsS3Urls(): JsonValue = inputsS3Urls + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun lastQueuedAt(): Optional = lastQueuedAt.getOptional("last_queued_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun lastReviewedTime(): Optional = + lastReviewedTime.getOptional("last_reviewed_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun manifestId(): Optional = manifestId.getOptional("manifest_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun manifestS3Id(): Optional = manifestS3Id.getOptional("manifest_s3_id") + + @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonValue = outputs + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun outputsPreview(): Optional = outputsPreview.getOptional("outputs_preview") + + @JsonProperty("outputs_s3_urls") @ExcludeMissing fun _outputsS3Urls(): JsonValue = outputsS3Urls + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun parentRunId(): Optional = parentRunId.getOptional("parent_run_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun parentRunIds(): Optional> = parentRunIds.getOptional("parent_run_ids") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun priceModelId(): Optional = priceModelId.getOptional("price_model_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun promptCost(): Optional = promptCost.getOptional("prompt_cost") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun promptCostDetails(): Optional = + promptCostDetails.getOptional("prompt_cost_details") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun promptTokenDetails(): Optional = + promptTokenDetails.getOptional("prompt_token_details") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun promptTokens(): Optional = promptTokens.getOptional("prompt_tokens") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceDatasetId(): Optional = + referenceDatasetId.getOptional("reference_dataset_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceExampleId(): Optional = + referenceExampleId.getOptional("reference_example_id") + + @JsonProperty("s3_urls") @ExcludeMissing fun _s3Urls(): JsonValue = s3Urls + + @JsonProperty("serialized") @ExcludeMissing fun _serialized(): JsonValue = serialized + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun shareToken(): Optional = shareToken.getOptional("share_token") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun startTime(): Optional = startTime.getOptional("start_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tags(): Optional> = tags.getOptional("tags") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun threadId(): Optional = threadId.getOptional("thread_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun totalCost(): Optional = totalCost.getOptional("total_cost") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun totalTokens(): Optional = totalTokens.getOptional("total_tokens") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun traceFirstReceivedAt(): Optional = + traceFirstReceivedAt.getOptional("trace_first_received_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun traceMaxStartTime(): Optional = + traceMaxStartTime.getOptional("trace_max_start_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun traceMinStartTime(): Optional = + traceMinStartTime.getOptional("trace_min_start_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun traceTier(): Optional = traceTier.getOptional("trace_tier") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun traceUpgrade(): Optional = traceUpgrade.getOptional("trace_upgrade") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun ttlSeconds(): Optional = ttlSeconds.getOptional("ttl_seconds") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [appPath]. + * + * Unlike [appPath], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("app_path") @ExcludeMissing fun _appPath(): JsonField = appPath + + /** + * Returns the raw JSON value of [dottedOrder]. + * + * Unlike [dottedOrder], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dotted_order") + @ExcludeMissing + fun _dottedOrder(): JsonField = dottedOrder + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [queueRunId]. + * + * Unlike [queueRunId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("queue_run_id") @ExcludeMissing fun _queueRunId(): JsonField = queueRunId + + /** + * Returns the raw JSON value of [runType]. + * + * Unlike [runType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_type") @ExcludeMissing fun _runType(): JsonField = runType + + /** + * Returns the raw JSON value of [sessionId]. + * + * Unlike [sessionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session_id") @ExcludeMissing fun _sessionId(): JsonField = sessionId + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [traceId]. + * + * Unlike [traceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trace_id") @ExcludeMissing fun _traceId(): JsonField = traceId + + /** + * Returns the raw JSON value of [addedAt]. + * + * Unlike [addedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("added_at") @ExcludeMissing fun _addedAt(): JsonField = addedAt + + /** + * Returns the raw JSON value of [childRunIds]. + * + * Unlike [childRunIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("child_run_ids") + @ExcludeMissing + fun _childRunIds(): JsonField> = childRunIds + + /** + * Returns the raw JSON value of [completionCost]. + * + * Unlike [completionCost], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("completion_cost") + @ExcludeMissing + fun _completionCost(): JsonField = completionCost + + /** + * Returns the raw JSON value of [completionCostDetails]. + * + * Unlike [completionCostDetails], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("completion_cost_details") + @ExcludeMissing + fun _completionCostDetails(): JsonField = completionCostDetails + + /** + * Returns the raw JSON value of [completionTokenDetails]. + * + * Unlike [completionTokenDetails], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("completion_token_details") + @ExcludeMissing + fun _completionTokenDetails(): JsonField = completionTokenDetails + + /** + * Returns the raw JSON value of [completionTokens]. + * + * Unlike [completionTokens], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("completion_tokens") + @ExcludeMissing + fun _completionTokens(): JsonField = completionTokens + + /** + * Returns the raw JSON value of [directChildRunIds]. + * + * Unlike [directChildRunIds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("direct_child_run_ids") + @ExcludeMissing + fun _directChildRunIds(): JsonField> = directChildRunIds + + /** + * Returns the raw JSON value of [effectiveAddedAt]. + * + * Unlike [effectiveAddedAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("effective_added_at") + @ExcludeMissing + fun _effectiveAddedAt(): JsonField = effectiveAddedAt + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_time") @ExcludeMissing fun _endTime(): JsonField = endTime + + /** + * Returns the raw JSON value of [error]. + * + * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error + + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events + + /** + * Returns the raw JSON value of [executionOrder]. + * + * Unlike [executionOrder], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("execution_order") + @ExcludeMissing + fun _executionOrder(): JsonField = executionOrder + + /** + * Returns the raw JSON value of [feedbackStats]. + * + * Unlike [feedbackStats], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feedback_stats") + @ExcludeMissing + fun _feedbackStats(): JsonField = feedbackStats + + /** + * Returns the raw JSON value of [firstTokenTime]. + * + * Unlike [firstTokenTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("first_token_time") + @ExcludeMissing + fun _firstTokenTime(): JsonField = firstTokenTime + + /** + * Returns the raw JSON value of [inDataset]. + * + * Unlike [inDataset], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("in_dataset") @ExcludeMissing fun _inDataset(): JsonField = inDataset + + /** + * Returns the raw JSON value of [inputsPreview]. + * + * Unlike [inputsPreview], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inputs_preview") + @ExcludeMissing + fun _inputsPreview(): JsonField = inputsPreview + + /** + * Returns the raw JSON value of [lastQueuedAt]. + * + * Unlike [lastQueuedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("last_queued_at") + @ExcludeMissing + fun _lastQueuedAt(): JsonField = lastQueuedAt + + /** + * Returns the raw JSON value of [lastReviewedTime]. + * + * Unlike [lastReviewedTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("last_reviewed_time") + @ExcludeMissing + fun _lastReviewedTime(): JsonField = lastReviewedTime + + /** + * Returns the raw JSON value of [manifestId]. + * + * Unlike [manifestId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("manifest_id") @ExcludeMissing fun _manifestId(): JsonField = manifestId + + /** + * Returns the raw JSON value of [manifestS3Id]. + * + * Unlike [manifestS3Id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("manifest_s3_id") + @ExcludeMissing + fun _manifestS3Id(): JsonField = manifestS3Id + + /** + * Returns the raw JSON value of [outputsPreview]. + * + * Unlike [outputsPreview], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outputs_preview") + @ExcludeMissing + fun _outputsPreview(): JsonField = outputsPreview + + /** + * Returns the raw JSON value of [parentRunId]. + * + * Unlike [parentRunId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("parent_run_id") + @ExcludeMissing + fun _parentRunId(): JsonField = parentRunId + + /** + * Returns the raw JSON value of [parentRunIds]. + * + * Unlike [parentRunIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("parent_run_ids") + @ExcludeMissing + fun _parentRunIds(): JsonField> = parentRunIds + + /** + * Returns the raw JSON value of [priceModelId]. + * + * Unlike [priceModelId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_model_id") + @ExcludeMissing + fun _priceModelId(): JsonField = priceModelId + + /** + * Returns the raw JSON value of [promptCost]. + * + * Unlike [promptCost], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prompt_cost") @ExcludeMissing fun _promptCost(): JsonField = promptCost + + /** + * Returns the raw JSON value of [promptCostDetails]. + * + * Unlike [promptCostDetails], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("prompt_cost_details") + @ExcludeMissing + fun _promptCostDetails(): JsonField = promptCostDetails + + /** + * Returns the raw JSON value of [promptTokenDetails]. + * + * Unlike [promptTokenDetails], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("prompt_token_details") + @ExcludeMissing + fun _promptTokenDetails(): JsonField = promptTokenDetails + + /** + * Returns the raw JSON value of [promptTokens]. + * + * Unlike [promptTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prompt_tokens") + @ExcludeMissing + fun _promptTokens(): JsonField = promptTokens + + /** + * Returns the raw JSON value of [referenceDatasetId]. + * + * Unlike [referenceDatasetId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reference_dataset_id") + @ExcludeMissing + fun _referenceDatasetId(): JsonField = referenceDatasetId + + /** + * Returns the raw JSON value of [referenceExampleId]. + * + * Unlike [referenceExampleId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reference_example_id") + @ExcludeMissing + fun _referenceExampleId(): JsonField = referenceExampleId + + /** + * Returns the raw JSON value of [shareToken]. + * + * Unlike [shareToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("share_token") @ExcludeMissing fun _shareToken(): JsonField = shareToken + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_time") + @ExcludeMissing + fun _startTime(): JsonField = startTime + + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + + /** + * Returns the raw JSON value of [threadId]. + * + * Unlike [threadId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("thread_id") @ExcludeMissing fun _threadId(): JsonField = threadId + + /** + * Returns the raw JSON value of [totalCost]. + * + * Unlike [totalCost], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total_cost") @ExcludeMissing fun _totalCost(): JsonField = totalCost + + /** + * Returns the raw JSON value of [totalTokens]. + * + * Unlike [totalTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total_tokens") @ExcludeMissing fun _totalTokens(): JsonField = totalTokens + + /** + * Returns the raw JSON value of [traceFirstReceivedAt]. + * + * Unlike [traceFirstReceivedAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("trace_first_received_at") + @ExcludeMissing + fun _traceFirstReceivedAt(): JsonField = traceFirstReceivedAt + + /** + * Returns the raw JSON value of [traceMaxStartTime]. + * + * Unlike [traceMaxStartTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("trace_max_start_time") + @ExcludeMissing + fun _traceMaxStartTime(): JsonField = traceMaxStartTime + + /** + * Returns the raw JSON value of [traceMinStartTime]. + * + * Unlike [traceMinStartTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("trace_min_start_time") + @ExcludeMissing + fun _traceMinStartTime(): JsonField = traceMinStartTime + + /** + * Returns the raw JSON value of [traceTier]. + * + * Unlike [traceTier], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trace_tier") @ExcludeMissing fun _traceTier(): JsonField = traceTier + + /** + * Returns the raw JSON value of [traceUpgrade]. + * + * Unlike [traceUpgrade], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trace_upgrade") + @ExcludeMissing + fun _traceUpgrade(): JsonField = traceUpgrade + + /** + * Returns the raw JSON value of [ttlSeconds]. + * + * Unlike [ttlSeconds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ttl_seconds") @ExcludeMissing fun _ttlSeconds(): JsonField = ttlSeconds + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [RunSchemaWithAnnotationQueueInfo]. + * + * The following fields are required: + * ```java + * .id() + * .appPath() + * .dottedOrder() + * .name() + * .queueRunId() + * .runType() + * .sessionId() + * .status() + * .traceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunSchemaWithAnnotationQueueInfo]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var appPath: JsonField? = null + private var dottedOrder: JsonField? = null + private var name: JsonField? = null + private var queueRunId: JsonField? = null + private var runType: JsonField? = null + private var sessionId: JsonField? = null + private var status: JsonField? = null + private var traceId: JsonField? = null + private var addedAt: JsonField = JsonMissing.of() + private var childRunIds: JsonField>? = null + private var completionCost: JsonField = JsonMissing.of() + private var completionCostDetails: JsonField = JsonMissing.of() + private var completionTokenDetails: JsonField = JsonMissing.of() + private var completionTokens: JsonField = JsonMissing.of() + private var directChildRunIds: JsonField>? = null + private var effectiveAddedAt: JsonField = JsonMissing.of() + private var endTime: JsonField = JsonMissing.of() + private var error: JsonField = JsonMissing.of() + private var events: JsonField>? = null + private var executionOrder: JsonField = JsonMissing.of() + private var extra: JsonValue = JsonMissing.of() + private var feedbackStats: JsonField = JsonMissing.of() + private var firstTokenTime: JsonField = JsonMissing.of() + private var inDataset: JsonField = JsonMissing.of() + private var inputs: JsonValue = JsonMissing.of() + private var inputsPreview: JsonField = JsonMissing.of() + private var inputsS3Urls: JsonValue = JsonMissing.of() + private var lastQueuedAt: JsonField = JsonMissing.of() + private var lastReviewedTime: JsonField = JsonMissing.of() + private var manifestId: JsonField = JsonMissing.of() + private var manifestS3Id: JsonField = JsonMissing.of() + private var outputs: JsonValue = JsonMissing.of() + private var outputsPreview: JsonField = JsonMissing.of() + private var outputsS3Urls: JsonValue = JsonMissing.of() + private var parentRunId: JsonField = JsonMissing.of() + private var parentRunIds: JsonField>? = null + private var priceModelId: JsonField = JsonMissing.of() + private var promptCost: JsonField = JsonMissing.of() + private var promptCostDetails: JsonField = JsonMissing.of() + private var promptTokenDetails: JsonField = JsonMissing.of() + private var promptTokens: JsonField = JsonMissing.of() + private var referenceDatasetId: JsonField = JsonMissing.of() + private var referenceExampleId: JsonField = JsonMissing.of() + private var s3Urls: JsonValue = JsonMissing.of() + private var serialized: JsonValue = JsonMissing.of() + private var shareToken: JsonField = JsonMissing.of() + private var startTime: JsonField = JsonMissing.of() + private var tags: JsonField>? = null + private var threadId: JsonField = JsonMissing.of() + private var totalCost: JsonField = JsonMissing.of() + private var totalTokens: JsonField = JsonMissing.of() + private var traceFirstReceivedAt: JsonField = JsonMissing.of() + private var traceMaxStartTime: JsonField = JsonMissing.of() + private var traceMinStartTime: JsonField = JsonMissing.of() + private var traceTier: JsonField = JsonMissing.of() + private var traceUpgrade: JsonField = JsonMissing.of() + private var ttlSeconds: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(runSchemaWithAnnotationQueueInfo: RunSchemaWithAnnotationQueueInfo) = + apply { + id = runSchemaWithAnnotationQueueInfo.id + appPath = runSchemaWithAnnotationQueueInfo.appPath + dottedOrder = runSchemaWithAnnotationQueueInfo.dottedOrder + name = runSchemaWithAnnotationQueueInfo.name + queueRunId = runSchemaWithAnnotationQueueInfo.queueRunId + runType = runSchemaWithAnnotationQueueInfo.runType + sessionId = runSchemaWithAnnotationQueueInfo.sessionId + status = runSchemaWithAnnotationQueueInfo.status + traceId = runSchemaWithAnnotationQueueInfo.traceId + addedAt = runSchemaWithAnnotationQueueInfo.addedAt + childRunIds = + runSchemaWithAnnotationQueueInfo.childRunIds.map { it.toMutableList() } + completionCost = runSchemaWithAnnotationQueueInfo.completionCost + completionCostDetails = runSchemaWithAnnotationQueueInfo.completionCostDetails + completionTokenDetails = runSchemaWithAnnotationQueueInfo.completionTokenDetails + completionTokens = runSchemaWithAnnotationQueueInfo.completionTokens + directChildRunIds = + runSchemaWithAnnotationQueueInfo.directChildRunIds.map { it.toMutableList() } + effectiveAddedAt = runSchemaWithAnnotationQueueInfo.effectiveAddedAt + endTime = runSchemaWithAnnotationQueueInfo.endTime + error = runSchemaWithAnnotationQueueInfo.error + events = runSchemaWithAnnotationQueueInfo.events.map { it.toMutableList() } + executionOrder = runSchemaWithAnnotationQueueInfo.executionOrder + extra = runSchemaWithAnnotationQueueInfo.extra + feedbackStats = runSchemaWithAnnotationQueueInfo.feedbackStats + firstTokenTime = runSchemaWithAnnotationQueueInfo.firstTokenTime + inDataset = runSchemaWithAnnotationQueueInfo.inDataset + inputs = runSchemaWithAnnotationQueueInfo.inputs + inputsPreview = runSchemaWithAnnotationQueueInfo.inputsPreview + inputsS3Urls = runSchemaWithAnnotationQueueInfo.inputsS3Urls + lastQueuedAt = runSchemaWithAnnotationQueueInfo.lastQueuedAt + lastReviewedTime = runSchemaWithAnnotationQueueInfo.lastReviewedTime + manifestId = runSchemaWithAnnotationQueueInfo.manifestId + manifestS3Id = runSchemaWithAnnotationQueueInfo.manifestS3Id + outputs = runSchemaWithAnnotationQueueInfo.outputs + outputsPreview = runSchemaWithAnnotationQueueInfo.outputsPreview + outputsS3Urls = runSchemaWithAnnotationQueueInfo.outputsS3Urls + parentRunId = runSchemaWithAnnotationQueueInfo.parentRunId + parentRunIds = + runSchemaWithAnnotationQueueInfo.parentRunIds.map { it.toMutableList() } + priceModelId = runSchemaWithAnnotationQueueInfo.priceModelId + promptCost = runSchemaWithAnnotationQueueInfo.promptCost + promptCostDetails = runSchemaWithAnnotationQueueInfo.promptCostDetails + promptTokenDetails = runSchemaWithAnnotationQueueInfo.promptTokenDetails + promptTokens = runSchemaWithAnnotationQueueInfo.promptTokens + referenceDatasetId = runSchemaWithAnnotationQueueInfo.referenceDatasetId + referenceExampleId = runSchemaWithAnnotationQueueInfo.referenceExampleId + s3Urls = runSchemaWithAnnotationQueueInfo.s3Urls + serialized = runSchemaWithAnnotationQueueInfo.serialized + shareToken = runSchemaWithAnnotationQueueInfo.shareToken + startTime = runSchemaWithAnnotationQueueInfo.startTime + tags = runSchemaWithAnnotationQueueInfo.tags.map { it.toMutableList() } + threadId = runSchemaWithAnnotationQueueInfo.threadId + totalCost = runSchemaWithAnnotationQueueInfo.totalCost + totalTokens = runSchemaWithAnnotationQueueInfo.totalTokens + traceFirstReceivedAt = runSchemaWithAnnotationQueueInfo.traceFirstReceivedAt + traceMaxStartTime = runSchemaWithAnnotationQueueInfo.traceMaxStartTime + traceMinStartTime = runSchemaWithAnnotationQueueInfo.traceMinStartTime + traceTier = runSchemaWithAnnotationQueueInfo.traceTier + traceUpgrade = runSchemaWithAnnotationQueueInfo.traceUpgrade + ttlSeconds = runSchemaWithAnnotationQueueInfo.ttlSeconds + additionalProperties = + runSchemaWithAnnotationQueueInfo.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun appPath(appPath: String) = appPath(JsonField.of(appPath)) + + /** + * Sets [Builder.appPath] to an arbitrary JSON value. + * + * You should usually call [Builder.appPath] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun appPath(appPath: JsonField) = apply { this.appPath = appPath } + + fun dottedOrder(dottedOrder: String) = dottedOrder(JsonField.of(dottedOrder)) + + /** + * Sets [Builder.dottedOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.dottedOrder] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dottedOrder(dottedOrder: JsonField) = apply { this.dottedOrder = dottedOrder } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun queueRunId(queueRunId: String) = queueRunId(JsonField.of(queueRunId)) + + /** + * Sets [Builder.queueRunId] to an arbitrary JSON value. + * + * You should usually call [Builder.queueRunId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun queueRunId(queueRunId: JsonField) = apply { this.queueRunId = queueRunId } + + /** Enum for run types. */ + fun runType(runType: RunTypeEnum) = runType(JsonField.of(runType)) + + /** + * Sets [Builder.runType] to an arbitrary JSON value. + * + * You should usually call [Builder.runType] with a well-typed [RunTypeEnum] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun runType(runType: JsonField) = apply { this.runType = runType } + + fun sessionId(sessionId: String) = sessionId(JsonField.of(sessionId)) + + /** + * Sets [Builder.sessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun sessionId(sessionId: JsonField) = apply { this.sessionId = sessionId } + + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun traceId(traceId: String) = traceId(JsonField.of(traceId)) + + /** + * Sets [Builder.traceId] to an arbitrary JSON value. + * + * You should usually call [Builder.traceId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun traceId(traceId: JsonField) = apply { this.traceId = traceId } + + fun addedAt(addedAt: OffsetDateTime?) = addedAt(JsonField.ofNullable(addedAt)) + + /** Alias for calling [Builder.addedAt] with `addedAt.orElse(null)`. */ + fun addedAt(addedAt: Optional) = addedAt(addedAt.getOrNull()) + + /** + * Sets [Builder.addedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.addedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun addedAt(addedAt: JsonField) = apply { this.addedAt = addedAt } + + fun childRunIds(childRunIds: List?) = childRunIds(JsonField.ofNullable(childRunIds)) + + /** Alias for calling [Builder.childRunIds] with `childRunIds.orElse(null)`. */ + fun childRunIds(childRunIds: Optional>) = childRunIds(childRunIds.getOrNull()) + + /** + * Sets [Builder.childRunIds] to an arbitrary JSON value. + * + * You should usually call [Builder.childRunIds] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun childRunIds(childRunIds: JsonField>) = apply { + this.childRunIds = childRunIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [childRunIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChildRunId(childRunId: String) = apply { + childRunIds = + (childRunIds ?: JsonField.of(mutableListOf())).also { + checkKnown("childRunIds", it).add(childRunId) + } + } + + fun completionCost(completionCost: String?) = + completionCost(JsonField.ofNullable(completionCost)) + + /** Alias for calling [Builder.completionCost] with `completionCost.orElse(null)`. */ + fun completionCost(completionCost: Optional) = + completionCost(completionCost.getOrNull()) + + /** + * Sets [Builder.completionCost] to an arbitrary JSON value. + * + * You should usually call [Builder.completionCost] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun completionCost(completionCost: JsonField) = apply { + this.completionCost = completionCost + } + + fun completionCostDetails(completionCostDetails: CompletionCostDetails?) = + completionCostDetails(JsonField.ofNullable(completionCostDetails)) + + /** + * Alias for calling [Builder.completionCostDetails] with + * `completionCostDetails.orElse(null)`. + */ + fun completionCostDetails(completionCostDetails: Optional) = + completionCostDetails(completionCostDetails.getOrNull()) + + /** + * Sets [Builder.completionCostDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.completionCostDetails] with a well-typed + * [CompletionCostDetails] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun completionCostDetails(completionCostDetails: JsonField) = apply { + this.completionCostDetails = completionCostDetails + } + + fun completionTokenDetails(completionTokenDetails: CompletionTokenDetails?) = + completionTokenDetails(JsonField.ofNullable(completionTokenDetails)) + + /** + * Alias for calling [Builder.completionTokenDetails] with + * `completionTokenDetails.orElse(null)`. + */ + fun completionTokenDetails(completionTokenDetails: Optional) = + completionTokenDetails(completionTokenDetails.getOrNull()) + + /** + * Sets [Builder.completionTokenDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.completionTokenDetails] with a well-typed + * [CompletionTokenDetails] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun completionTokenDetails(completionTokenDetails: JsonField) = + apply { + this.completionTokenDetails = completionTokenDetails + } + + fun completionTokens(completionTokens: Long) = + completionTokens(JsonField.of(completionTokens)) + + /** + * Sets [Builder.completionTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.completionTokens] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun completionTokens(completionTokens: JsonField) = apply { + this.completionTokens = completionTokens + } + + fun directChildRunIds(directChildRunIds: List?) = + directChildRunIds(JsonField.ofNullable(directChildRunIds)) + + /** Alias for calling [Builder.directChildRunIds] with `directChildRunIds.orElse(null)`. */ + fun directChildRunIds(directChildRunIds: Optional>) = + directChildRunIds(directChildRunIds.getOrNull()) + + /** + * Sets [Builder.directChildRunIds] to an arbitrary JSON value. + * + * You should usually call [Builder.directChildRunIds] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun directChildRunIds(directChildRunIds: JsonField>) = apply { + this.directChildRunIds = directChildRunIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [directChildRunIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addDirectChildRunId(directChildRunId: String) = apply { + directChildRunIds = + (directChildRunIds ?: JsonField.of(mutableListOf())).also { + checkKnown("directChildRunIds", it).add(directChildRunId) + } + } + + fun effectiveAddedAt(effectiveAddedAt: OffsetDateTime?) = + effectiveAddedAt(JsonField.ofNullable(effectiveAddedAt)) + + /** Alias for calling [Builder.effectiveAddedAt] with `effectiveAddedAt.orElse(null)`. */ + fun effectiveAddedAt(effectiveAddedAt: Optional) = + effectiveAddedAt(effectiveAddedAt.getOrNull()) + + /** + * Sets [Builder.effectiveAddedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.effectiveAddedAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun effectiveAddedAt(effectiveAddedAt: JsonField) = apply { + this.effectiveAddedAt = effectiveAddedAt + } + + fun endTime(endTime: OffsetDateTime?) = endTime(JsonField.ofNullable(endTime)) + + /** Alias for calling [Builder.endTime] with `endTime.orElse(null)`. */ + fun endTime(endTime: Optional) = endTime(endTime.getOrNull()) + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endTime(endTime: JsonField) = apply { this.endTime = endTime } + + fun error(error: String?) = error(JsonField.ofNullable(error)) + + /** Alias for calling [Builder.error] with `error.orElse(null)`. */ + fun error(error: Optional) = error(error.getOrNull()) + + /** + * Sets [Builder.error] to an arbitrary JSON value. + * + * You should usually call [Builder.error] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun error(error: JsonField) = apply { this.error = error } + + fun events(events: List?) = events(JsonField.ofNullable(events)) + + /** Alias for calling [Builder.events] with `events.orElse(null)`. */ + fun events(events: Optional>) = events(events.getOrNull()) + + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } + + /** + * Adds a single [JsonValue] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvent(event: JsonValue) = apply { + events = + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) + } + } + + fun executionOrder(executionOrder: Long) = executionOrder(JsonField.of(executionOrder)) + + /** + * Sets [Builder.executionOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.executionOrder] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun executionOrder(executionOrder: JsonField) = apply { + this.executionOrder = executionOrder + } + + fun extra(extra: JsonValue) = apply { this.extra = extra } + + fun feedbackStats(feedbackStats: FeedbackStats?) = + feedbackStats(JsonField.ofNullable(feedbackStats)) + + /** Alias for calling [Builder.feedbackStats] with `feedbackStats.orElse(null)`. */ + fun feedbackStats(feedbackStats: Optional) = + feedbackStats(feedbackStats.getOrNull()) + + /** + * Sets [Builder.feedbackStats] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackStats] with a well-typed [FeedbackStats] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun feedbackStats(feedbackStats: JsonField) = apply { + this.feedbackStats = feedbackStats + } + + fun firstTokenTime(firstTokenTime: OffsetDateTime?) = + firstTokenTime(JsonField.ofNullable(firstTokenTime)) + + /** Alias for calling [Builder.firstTokenTime] with `firstTokenTime.orElse(null)`. */ + fun firstTokenTime(firstTokenTime: Optional) = + firstTokenTime(firstTokenTime.getOrNull()) + + /** + * Sets [Builder.firstTokenTime] to an arbitrary JSON value. + * + * You should usually call [Builder.firstTokenTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun firstTokenTime(firstTokenTime: JsonField) = apply { + this.firstTokenTime = firstTokenTime + } + + fun inDataset(inDataset: Boolean?) = inDataset(JsonField.ofNullable(inDataset)) + + /** + * Alias for [Builder.inDataset]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun inDataset(inDataset: Boolean) = inDataset(inDataset as Boolean?) + + /** Alias for calling [Builder.inDataset] with `inDataset.orElse(null)`. */ + fun inDataset(inDataset: Optional) = inDataset(inDataset.getOrNull()) + + /** + * Sets [Builder.inDataset] to an arbitrary JSON value. + * + * You should usually call [Builder.inDataset] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun inDataset(inDataset: JsonField) = apply { this.inDataset = inDataset } + + fun inputs(inputs: JsonValue) = apply { this.inputs = inputs } + + fun inputsPreview(inputsPreview: String?) = + inputsPreview(JsonField.ofNullable(inputsPreview)) + + /** Alias for calling [Builder.inputsPreview] with `inputsPreview.orElse(null)`. */ + fun inputsPreview(inputsPreview: Optional) = + inputsPreview(inputsPreview.getOrNull()) + + /** + * Sets [Builder.inputsPreview] to an arbitrary JSON value. + * + * You should usually call [Builder.inputsPreview] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun inputsPreview(inputsPreview: JsonField) = apply { + this.inputsPreview = inputsPreview + } + + fun inputsS3Urls(inputsS3Urls: JsonValue) = apply { this.inputsS3Urls = inputsS3Urls } + + fun lastQueuedAt(lastQueuedAt: OffsetDateTime?) = + lastQueuedAt(JsonField.ofNullable(lastQueuedAt)) + + /** Alias for calling [Builder.lastQueuedAt] with `lastQueuedAt.orElse(null)`. */ + fun lastQueuedAt(lastQueuedAt: Optional) = + lastQueuedAt(lastQueuedAt.getOrNull()) + + /** + * Sets [Builder.lastQueuedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.lastQueuedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lastQueuedAt(lastQueuedAt: JsonField) = apply { + this.lastQueuedAt = lastQueuedAt + } + + fun lastReviewedTime(lastReviewedTime: OffsetDateTime?) = + lastReviewedTime(JsonField.ofNullable(lastReviewedTime)) + + /** Alias for calling [Builder.lastReviewedTime] with `lastReviewedTime.orElse(null)`. */ + fun lastReviewedTime(lastReviewedTime: Optional) = + lastReviewedTime(lastReviewedTime.getOrNull()) + + /** + * Sets [Builder.lastReviewedTime] to an arbitrary JSON value. + * + * You should usually call [Builder.lastReviewedTime] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun lastReviewedTime(lastReviewedTime: JsonField) = apply { + this.lastReviewedTime = lastReviewedTime + } + + fun manifestId(manifestId: String?) = manifestId(JsonField.ofNullable(manifestId)) + + /** Alias for calling [Builder.manifestId] with `manifestId.orElse(null)`. */ + fun manifestId(manifestId: Optional) = manifestId(manifestId.getOrNull()) + + /** + * Sets [Builder.manifestId] to an arbitrary JSON value. + * + * You should usually call [Builder.manifestId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun manifestId(manifestId: JsonField) = apply { this.manifestId = manifestId } + + fun manifestS3Id(manifestS3Id: String?) = manifestS3Id(JsonField.ofNullable(manifestS3Id)) + + /** Alias for calling [Builder.manifestS3Id] with `manifestS3Id.orElse(null)`. */ + fun manifestS3Id(manifestS3Id: Optional) = manifestS3Id(manifestS3Id.getOrNull()) + + /** + * Sets [Builder.manifestS3Id] to an arbitrary JSON value. + * + * You should usually call [Builder.manifestS3Id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun manifestS3Id(manifestS3Id: JsonField) = apply { + this.manifestS3Id = manifestS3Id + } + + fun outputs(outputs: JsonValue) = apply { this.outputs = outputs } + + fun outputsPreview(outputsPreview: String?) = + outputsPreview(JsonField.ofNullable(outputsPreview)) + + /** Alias for calling [Builder.outputsPreview] with `outputsPreview.orElse(null)`. */ + fun outputsPreview(outputsPreview: Optional) = + outputsPreview(outputsPreview.getOrNull()) + + /** + * Sets [Builder.outputsPreview] to an arbitrary JSON value. + * + * You should usually call [Builder.outputsPreview] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun outputsPreview(outputsPreview: JsonField) = apply { + this.outputsPreview = outputsPreview + } + + fun outputsS3Urls(outputsS3Urls: JsonValue) = apply { this.outputsS3Urls = outputsS3Urls } + + fun parentRunId(parentRunId: String?) = parentRunId(JsonField.ofNullable(parentRunId)) + + /** Alias for calling [Builder.parentRunId] with `parentRunId.orElse(null)`. */ + fun parentRunId(parentRunId: Optional) = parentRunId(parentRunId.getOrNull()) + + /** + * Sets [Builder.parentRunId] to an arbitrary JSON value. + * + * You should usually call [Builder.parentRunId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun parentRunId(parentRunId: JsonField) = apply { this.parentRunId = parentRunId } + + fun parentRunIds(parentRunIds: List?) = + parentRunIds(JsonField.ofNullable(parentRunIds)) + + /** Alias for calling [Builder.parentRunIds] with `parentRunIds.orElse(null)`. */ + fun parentRunIds(parentRunIds: Optional>) = + parentRunIds(parentRunIds.getOrNull()) + + /** + * Sets [Builder.parentRunIds] to an arbitrary JSON value. + * + * You should usually call [Builder.parentRunIds] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun parentRunIds(parentRunIds: JsonField>) = apply { + this.parentRunIds = parentRunIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [parentRunIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addParentRunId(parentRunId: String) = apply { + parentRunIds = + (parentRunIds ?: JsonField.of(mutableListOf())).also { + checkKnown("parentRunIds", it).add(parentRunId) + } + } + + fun priceModelId(priceModelId: String?) = priceModelId(JsonField.ofNullable(priceModelId)) + + /** Alias for calling [Builder.priceModelId] with `priceModelId.orElse(null)`. */ + fun priceModelId(priceModelId: Optional) = priceModelId(priceModelId.getOrNull()) + + /** + * Sets [Builder.priceModelId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceModelId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun priceModelId(priceModelId: JsonField) = apply { + this.priceModelId = priceModelId + } + + fun promptCost(promptCost: String?) = promptCost(JsonField.ofNullable(promptCost)) + + /** Alias for calling [Builder.promptCost] with `promptCost.orElse(null)`. */ + fun promptCost(promptCost: Optional) = promptCost(promptCost.getOrNull()) + + /** + * Sets [Builder.promptCost] to an arbitrary JSON value. + * + * You should usually call [Builder.promptCost] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun promptCost(promptCost: JsonField) = apply { this.promptCost = promptCost } + + fun promptCostDetails(promptCostDetails: PromptCostDetails?) = + promptCostDetails(JsonField.ofNullable(promptCostDetails)) + + /** Alias for calling [Builder.promptCostDetails] with `promptCostDetails.orElse(null)`. */ + fun promptCostDetails(promptCostDetails: Optional) = + promptCostDetails(promptCostDetails.getOrNull()) + + /** + * Sets [Builder.promptCostDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.promptCostDetails] with a well-typed [PromptCostDetails] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun promptCostDetails(promptCostDetails: JsonField) = apply { + this.promptCostDetails = promptCostDetails + } + + fun promptTokenDetails(promptTokenDetails: PromptTokenDetails?) = + promptTokenDetails(JsonField.ofNullable(promptTokenDetails)) + + /** + * Alias for calling [Builder.promptTokenDetails] with `promptTokenDetails.orElse(null)`. + */ + fun promptTokenDetails(promptTokenDetails: Optional) = + promptTokenDetails(promptTokenDetails.getOrNull()) + + /** + * Sets [Builder.promptTokenDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.promptTokenDetails] with a well-typed + * [PromptTokenDetails] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun promptTokenDetails(promptTokenDetails: JsonField) = apply { + this.promptTokenDetails = promptTokenDetails + } + + fun promptTokens(promptTokens: Long) = promptTokens(JsonField.of(promptTokens)) + + /** + * Sets [Builder.promptTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.promptTokens] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun promptTokens(promptTokens: JsonField) = apply { this.promptTokens = promptTokens } + + fun referenceDatasetId(referenceDatasetId: String?) = + referenceDatasetId(JsonField.ofNullable(referenceDatasetId)) + + /** + * Alias for calling [Builder.referenceDatasetId] with `referenceDatasetId.orElse(null)`. + */ + fun referenceDatasetId(referenceDatasetId: Optional) = + referenceDatasetId(referenceDatasetId.getOrNull()) + + /** + * Sets [Builder.referenceDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceDatasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun referenceDatasetId(referenceDatasetId: JsonField) = apply { + this.referenceDatasetId = referenceDatasetId + } + + fun referenceExampleId(referenceExampleId: String?) = + referenceExampleId(JsonField.ofNullable(referenceExampleId)) + + /** + * Alias for calling [Builder.referenceExampleId] with `referenceExampleId.orElse(null)`. + */ + fun referenceExampleId(referenceExampleId: Optional) = + referenceExampleId(referenceExampleId.getOrNull()) + + /** + * Sets [Builder.referenceExampleId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceExampleId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun referenceExampleId(referenceExampleId: JsonField) = apply { + this.referenceExampleId = referenceExampleId + } + + fun s3Urls(s3Urls: JsonValue) = apply { this.s3Urls = s3Urls } + + fun serialized(serialized: JsonValue) = apply { this.serialized = serialized } + + fun shareToken(shareToken: String?) = shareToken(JsonField.ofNullable(shareToken)) + + /** Alias for calling [Builder.shareToken] with `shareToken.orElse(null)`. */ + fun shareToken(shareToken: Optional) = shareToken(shareToken.getOrNull()) + + /** + * Sets [Builder.shareToken] to an arbitrary JSON value. + * + * You should usually call [Builder.shareToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun shareToken(shareToken: JsonField) = apply { this.shareToken = shareToken } + + fun startTime(startTime: OffsetDateTime) = startTime(JsonField.of(startTime)) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField) = apply { this.startTime = startTime } + + fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) + + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ + fun tags(tags: Optional>) = tags(tags.getOrNull()) + + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } + + fun threadId(threadId: String?) = threadId(JsonField.ofNullable(threadId)) + + /** Alias for calling [Builder.threadId] with `threadId.orElse(null)`. */ + fun threadId(threadId: Optional) = threadId(threadId.getOrNull()) + + /** + * Sets [Builder.threadId] to an arbitrary JSON value. + * + * You should usually call [Builder.threadId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun threadId(threadId: JsonField) = apply { this.threadId = threadId } + + fun totalCost(totalCost: String?) = totalCost(JsonField.ofNullable(totalCost)) + + /** Alias for calling [Builder.totalCost] with `totalCost.orElse(null)`. */ + fun totalCost(totalCost: Optional) = totalCost(totalCost.getOrNull()) + + /** + * Sets [Builder.totalCost] to an arbitrary JSON value. + * + * You should usually call [Builder.totalCost] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun totalCost(totalCost: JsonField) = apply { this.totalCost = totalCost } + + fun totalTokens(totalTokens: Long) = totalTokens(JsonField.of(totalTokens)) + + /** + * Sets [Builder.totalTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.totalTokens] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun totalTokens(totalTokens: JsonField) = apply { this.totalTokens = totalTokens } + + fun traceFirstReceivedAt(traceFirstReceivedAt: OffsetDateTime?) = + traceFirstReceivedAt(JsonField.ofNullable(traceFirstReceivedAt)) + + /** + * Alias for calling [Builder.traceFirstReceivedAt] with + * `traceFirstReceivedAt.orElse(null)`. + */ + fun traceFirstReceivedAt(traceFirstReceivedAt: Optional) = + traceFirstReceivedAt(traceFirstReceivedAt.getOrNull()) + + /** + * Sets [Builder.traceFirstReceivedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.traceFirstReceivedAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun traceFirstReceivedAt(traceFirstReceivedAt: JsonField) = apply { + this.traceFirstReceivedAt = traceFirstReceivedAt + } + + fun traceMaxStartTime(traceMaxStartTime: OffsetDateTime?) = + traceMaxStartTime(JsonField.ofNullable(traceMaxStartTime)) + + /** Alias for calling [Builder.traceMaxStartTime] with `traceMaxStartTime.orElse(null)`. */ + fun traceMaxStartTime(traceMaxStartTime: Optional) = + traceMaxStartTime(traceMaxStartTime.getOrNull()) + + /** + * Sets [Builder.traceMaxStartTime] to an arbitrary JSON value. + * + * You should usually call [Builder.traceMaxStartTime] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun traceMaxStartTime(traceMaxStartTime: JsonField) = apply { + this.traceMaxStartTime = traceMaxStartTime + } + + fun traceMinStartTime(traceMinStartTime: OffsetDateTime?) = + traceMinStartTime(JsonField.ofNullable(traceMinStartTime)) + + /** Alias for calling [Builder.traceMinStartTime] with `traceMinStartTime.orElse(null)`. */ + fun traceMinStartTime(traceMinStartTime: Optional) = + traceMinStartTime(traceMinStartTime.getOrNull()) + + /** + * Sets [Builder.traceMinStartTime] to an arbitrary JSON value. + * + * You should usually call [Builder.traceMinStartTime] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun traceMinStartTime(traceMinStartTime: JsonField) = apply { + this.traceMinStartTime = traceMinStartTime + } + + fun traceTier(traceTier: TraceTier?) = traceTier(JsonField.ofNullable(traceTier)) + + /** Alias for calling [Builder.traceTier] with `traceTier.orElse(null)`. */ + fun traceTier(traceTier: Optional) = traceTier(traceTier.getOrNull()) + + /** + * Sets [Builder.traceTier] to an arbitrary JSON value. + * + * You should usually call [Builder.traceTier] with a well-typed [TraceTier] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun traceTier(traceTier: JsonField) = apply { this.traceTier = traceTier } + + fun traceUpgrade(traceUpgrade: Boolean) = traceUpgrade(JsonField.of(traceUpgrade)) + + /** + * Sets [Builder.traceUpgrade] to an arbitrary JSON value. + * + * You should usually call [Builder.traceUpgrade] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun traceUpgrade(traceUpgrade: JsonField) = apply { + this.traceUpgrade = traceUpgrade + } + + fun ttlSeconds(ttlSeconds: Long?) = ttlSeconds(JsonField.ofNullable(ttlSeconds)) + + /** + * Alias for [Builder.ttlSeconds]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun ttlSeconds(ttlSeconds: Long) = ttlSeconds(ttlSeconds as Long?) + + /** Alias for calling [Builder.ttlSeconds] with `ttlSeconds.orElse(null)`. */ + fun ttlSeconds(ttlSeconds: Optional) = ttlSeconds(ttlSeconds.getOrNull()) + + /** + * Sets [Builder.ttlSeconds] to an arbitrary JSON value. + * + * You should usually call [Builder.ttlSeconds] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun ttlSeconds(ttlSeconds: JsonField) = apply { this.ttlSeconds = ttlSeconds } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RunSchemaWithAnnotationQueueInfo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .appPath() + * .dottedOrder() + * .name() + * .queueRunId() + * .runType() + * .sessionId() + * .status() + * .traceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RunSchemaWithAnnotationQueueInfo = + RunSchemaWithAnnotationQueueInfo( + checkRequired("id", id), + checkRequired("appPath", appPath), + checkRequired("dottedOrder", dottedOrder), + checkRequired("name", name), + checkRequired("queueRunId", queueRunId), + checkRequired("runType", runType), + checkRequired("sessionId", sessionId), + checkRequired("status", status), + checkRequired("traceId", traceId), + addedAt, + (childRunIds ?: JsonMissing.of()).map { it.toImmutable() }, + completionCost, + completionCostDetails, + completionTokenDetails, + completionTokens, + (directChildRunIds ?: JsonMissing.of()).map { it.toImmutable() }, + effectiveAddedAt, + endTime, + error, + (events ?: JsonMissing.of()).map { it.toImmutable() }, + executionOrder, + extra, + feedbackStats, + firstTokenTime, + inDataset, + inputs, + inputsPreview, + inputsS3Urls, + lastQueuedAt, + lastReviewedTime, + manifestId, + manifestS3Id, + outputs, + outputsPreview, + outputsS3Urls, + parentRunId, + (parentRunIds ?: JsonMissing.of()).map { it.toImmutable() }, + priceModelId, + promptCost, + promptCostDetails, + promptTokenDetails, + promptTokens, + referenceDatasetId, + referenceExampleId, + s3Urls, + serialized, + shareToken, + startTime, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + threadId, + totalCost, + totalTokens, + traceFirstReceivedAt, + traceMaxStartTime, + traceMinStartTime, + traceTier, + traceUpgrade, + ttlSeconds, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RunSchemaWithAnnotationQueueInfo = apply { + if (validated) { + return@apply + } + + id() + appPath() + dottedOrder() + name() + queueRunId() + runType().validate() + sessionId() + status() + traceId() + addedAt() + childRunIds() + completionCost() + completionCostDetails().ifPresent { it.validate() } + completionTokenDetails().ifPresent { it.validate() } + completionTokens() + directChildRunIds() + effectiveAddedAt() + endTime() + error() + events() + executionOrder() + feedbackStats().ifPresent { it.validate() } + firstTokenTime() + inDataset() + inputsPreview() + lastQueuedAt() + lastReviewedTime() + manifestId() + manifestS3Id() + outputsPreview() + parentRunId() + parentRunIds() + priceModelId() + promptCost() + promptCostDetails().ifPresent { it.validate() } + promptTokenDetails().ifPresent { it.validate() } + promptTokens() + referenceDatasetId() + referenceExampleId() + shareToken() + startTime() + tags() + threadId() + totalCost() + totalTokens() + traceFirstReceivedAt() + traceMaxStartTime() + traceMinStartTime() + traceTier().ifPresent { it.validate() } + traceUpgrade() + ttlSeconds() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (appPath.asKnown().isPresent) 1 else 0) + + (if (dottedOrder.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (queueRunId.asKnown().isPresent) 1 else 0) + + (runType.asKnown().getOrNull()?.validity() ?: 0) + + (if (sessionId.asKnown().isPresent) 1 else 0) + + (if (status.asKnown().isPresent) 1 else 0) + + (if (traceId.asKnown().isPresent) 1 else 0) + + (if (addedAt.asKnown().isPresent) 1 else 0) + + (childRunIds.asKnown().getOrNull()?.size ?: 0) + + (if (completionCost.asKnown().isPresent) 1 else 0) + + (completionCostDetails.asKnown().getOrNull()?.validity() ?: 0) + + (completionTokenDetails.asKnown().getOrNull()?.validity() ?: 0) + + (if (completionTokens.asKnown().isPresent) 1 else 0) + + (directChildRunIds.asKnown().getOrNull()?.size ?: 0) + + (if (effectiveAddedAt.asKnown().isPresent) 1 else 0) + + (if (endTime.asKnown().isPresent) 1 else 0) + + (if (error.asKnown().isPresent) 1 else 0) + + (events.asKnown().getOrNull()?.size ?: 0) + + (if (executionOrder.asKnown().isPresent) 1 else 0) + + (feedbackStats.asKnown().getOrNull()?.validity() ?: 0) + + (if (firstTokenTime.asKnown().isPresent) 1 else 0) + + (if (inDataset.asKnown().isPresent) 1 else 0) + + (if (inputsPreview.asKnown().isPresent) 1 else 0) + + (if (lastQueuedAt.asKnown().isPresent) 1 else 0) + + (if (lastReviewedTime.asKnown().isPresent) 1 else 0) + + (if (manifestId.asKnown().isPresent) 1 else 0) + + (if (manifestS3Id.asKnown().isPresent) 1 else 0) + + (if (outputsPreview.asKnown().isPresent) 1 else 0) + + (if (parentRunId.asKnown().isPresent) 1 else 0) + + (parentRunIds.asKnown().getOrNull()?.size ?: 0) + + (if (priceModelId.asKnown().isPresent) 1 else 0) + + (if (promptCost.asKnown().isPresent) 1 else 0) + + (promptCostDetails.asKnown().getOrNull()?.validity() ?: 0) + + (promptTokenDetails.asKnown().getOrNull()?.validity() ?: 0) + + (if (promptTokens.asKnown().isPresent) 1 else 0) + + (if (referenceDatasetId.asKnown().isPresent) 1 else 0) + + (if (referenceExampleId.asKnown().isPresent) 1 else 0) + + (if (shareToken.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + (tags.asKnown().getOrNull()?.size ?: 0) + + (if (threadId.asKnown().isPresent) 1 else 0) + + (if (totalCost.asKnown().isPresent) 1 else 0) + + (if (totalTokens.asKnown().isPresent) 1 else 0) + + (if (traceFirstReceivedAt.asKnown().isPresent) 1 else 0) + + (if (traceMaxStartTime.asKnown().isPresent) 1 else 0) + + (if (traceMinStartTime.asKnown().isPresent) 1 else 0) + + (traceTier.asKnown().getOrNull()?.validity() ?: 0) + + (if (traceUpgrade.asKnown().isPresent) 1 else 0) + + (if (ttlSeconds.asKnown().isPresent) 1 else 0) + + class CompletionCostDetails + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompletionCostDetails]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CompletionCostDetails]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(completionCostDetails: CompletionCostDetails) = apply { + additionalProperties = completionCostDetails.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompletionCostDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CompletionCostDetails = + CompletionCostDetails(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): CompletionCostDetails = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompletionCostDetails && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompletionCostDetails{additionalProperties=$additionalProperties}" + } + + class CompletionTokenDetails + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompletionTokenDetails]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CompletionTokenDetails]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(completionTokenDetails: CompletionTokenDetails) = apply { + additionalProperties = completionTokenDetails.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompletionTokenDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CompletionTokenDetails = + CompletionTokenDetails(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): CompletionTokenDetails = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompletionTokenDetails && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompletionTokenDetails{additionalProperties=$additionalProperties}" + } + + class FeedbackStats + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [FeedbackStats]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackStats]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(feedbackStats: FeedbackStats) = apply { + additionalProperties = feedbackStats.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FeedbackStats]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FeedbackStats = FeedbackStats(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): FeedbackStats = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackStats && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "FeedbackStats{additionalProperties=$additionalProperties}" + } + + class PromptCostDetails + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [PromptCostDetails]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PromptCostDetails]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(promptCostDetails: PromptCostDetails) = apply { + additionalProperties = promptCostDetails.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PromptCostDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PromptCostDetails = PromptCostDetails(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): PromptCostDetails = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PromptCostDetails && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "PromptCostDetails{additionalProperties=$additionalProperties}" + } + + class PromptTokenDetails + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [PromptTokenDetails]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PromptTokenDetails]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(promptTokenDetails: PromptTokenDetails) = apply { + additionalProperties = promptTokenDetails.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PromptTokenDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PromptTokenDetails = PromptTokenDetails(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): PromptTokenDetails = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PromptTokenDetails && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "PromptTokenDetails{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunSchemaWithAnnotationQueueInfo && + id == other.id && + appPath == other.appPath && + dottedOrder == other.dottedOrder && + name == other.name && + queueRunId == other.queueRunId && + runType == other.runType && + sessionId == other.sessionId && + status == other.status && + traceId == other.traceId && + addedAt == other.addedAt && + childRunIds == other.childRunIds && + completionCost == other.completionCost && + completionCostDetails == other.completionCostDetails && + completionTokenDetails == other.completionTokenDetails && + completionTokens == other.completionTokens && + directChildRunIds == other.directChildRunIds && + effectiveAddedAt == other.effectiveAddedAt && + endTime == other.endTime && + error == other.error && + events == other.events && + executionOrder == other.executionOrder && + extra == other.extra && + feedbackStats == other.feedbackStats && + firstTokenTime == other.firstTokenTime && + inDataset == other.inDataset && + inputs == other.inputs && + inputsPreview == other.inputsPreview && + inputsS3Urls == other.inputsS3Urls && + lastQueuedAt == other.lastQueuedAt && + lastReviewedTime == other.lastReviewedTime && + manifestId == other.manifestId && + manifestS3Id == other.manifestS3Id && + outputs == other.outputs && + outputsPreview == other.outputsPreview && + outputsS3Urls == other.outputsS3Urls && + parentRunId == other.parentRunId && + parentRunIds == other.parentRunIds && + priceModelId == other.priceModelId && + promptCost == other.promptCost && + promptCostDetails == other.promptCostDetails && + promptTokenDetails == other.promptTokenDetails && + promptTokens == other.promptTokens && + referenceDatasetId == other.referenceDatasetId && + referenceExampleId == other.referenceExampleId && + s3Urls == other.s3Urls && + serialized == other.serialized && + shareToken == other.shareToken && + startTime == other.startTime && + tags == other.tags && + threadId == other.threadId && + totalCost == other.totalCost && + totalTokens == other.totalTokens && + traceFirstReceivedAt == other.traceFirstReceivedAt && + traceMaxStartTime == other.traceMaxStartTime && + traceMinStartTime == other.traceMinStartTime && + traceTier == other.traceTier && + traceUpgrade == other.traceUpgrade && + ttlSeconds == other.ttlSeconds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + appPath, + dottedOrder, + name, + queueRunId, + runType, + sessionId, + status, + traceId, + addedAt, + childRunIds, + completionCost, + completionCostDetails, + completionTokenDetails, + completionTokens, + directChildRunIds, + effectiveAddedAt, + endTime, + error, + events, + executionOrder, + extra, + feedbackStats, + firstTokenTime, + inDataset, + inputs, + inputsPreview, + inputsS3Urls, + lastQueuedAt, + lastReviewedTime, + manifestId, + manifestS3Id, + outputs, + outputsPreview, + outputsS3Urls, + parentRunId, + parentRunIds, + priceModelId, + promptCost, + promptCostDetails, + promptTokenDetails, + promptTokens, + referenceDatasetId, + referenceExampleId, + s3Urls, + serialized, + shareToken, + startTime, + tags, + threadId, + totalCost, + totalTokens, + traceFirstReceivedAt, + traceMaxStartTime, + traceMinStartTime, + traceTier, + traceUpgrade, + ttlSeconds, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RunSchemaWithAnnotationQueueInfo{id=$id, appPath=$appPath, dottedOrder=$dottedOrder, name=$name, queueRunId=$queueRunId, runType=$runType, sessionId=$sessionId, status=$status, traceId=$traceId, addedAt=$addedAt, childRunIds=$childRunIds, completionCost=$completionCost, completionCostDetails=$completionCostDetails, completionTokenDetails=$completionTokenDetails, completionTokens=$completionTokens, directChildRunIds=$directChildRunIds, effectiveAddedAt=$effectiveAddedAt, endTime=$endTime, error=$error, events=$events, executionOrder=$executionOrder, extra=$extra, feedbackStats=$feedbackStats, firstTokenTime=$firstTokenTime, inDataset=$inDataset, inputs=$inputs, inputsPreview=$inputsPreview, inputsS3Urls=$inputsS3Urls, lastQueuedAt=$lastQueuedAt, lastReviewedTime=$lastReviewedTime, manifestId=$manifestId, manifestS3Id=$manifestS3Id, outputs=$outputs, outputsPreview=$outputsPreview, outputsS3Urls=$outputsS3Urls, parentRunId=$parentRunId, parentRunIds=$parentRunIds, priceModelId=$priceModelId, promptCost=$promptCost, promptCostDetails=$promptCostDetails, promptTokenDetails=$promptTokenDetails, promptTokens=$promptTokens, referenceDatasetId=$referenceDatasetId, referenceExampleId=$referenceExampleId, s3Urls=$s3Urls, serialized=$serialized, shareToken=$shareToken, startTime=$startTime, tags=$tags, threadId=$threadId, totalCost=$totalCost, totalTokens=$totalTokens, traceFirstReceivedAt=$traceFirstReceivedAt, traceMaxStartTime=$traceMaxStartTime, traceMinStartTime=$traceMinStartTime, traceTier=$traceTier, traceUpgrade=$traceUpgrade, ttlSeconds=$ttlSeconds, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunCreateParams.kt new file mode 100644 index 00000000..558aa37b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunCreateParams.kt @@ -0,0 +1,228 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues.runs + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Add Runs To Annotation Queue */ +class RunCreateParams +private constructor( + private val queueId: String?, + private val body: List, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun queueId(): Optional = Optional.ofNullable(queueId) + + fun body(): List = body + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RunCreateParams]. + * + * The following fields are required: + * ```java + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunCreateParams]. */ + class Builder internal constructor() { + + private var queueId: String? = null + private var body: MutableList? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(runCreateParams: RunCreateParams) = apply { + queueId = runCreateParams.queueId + body = runCreateParams.body.toMutableList() + additionalHeaders = runCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = runCreateParams.additionalQueryParams.toBuilder() + } + + fun queueId(queueId: String?) = apply { this.queueId = queueId } + + /** Alias for calling [Builder.queueId] with `queueId.orElse(null)`. */ + fun queueId(queueId: Optional) = queueId(queueId.getOrNull()) + + fun body(body: List) = apply { this.body = body.toMutableList() } + + /** + * Adds a single [String] to [Builder.body]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addBody(body: String) = apply { + this.body = (this.body ?: mutableListOf()).apply { add(body) } + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RunCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RunCreateParams = + RunCreateParams( + queueId, + checkRequired("body", body).toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): List = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> queueId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunCreateParams && + queueId == other.queueId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(queueId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "RunCreateParams{queueId=$queueId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunCreateResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunCreateResponse.kt new file mode 100644 index 00000000..9dbd69b8 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunCreateResponse.kt @@ -0,0 +1,322 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues.runs + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class RunCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val queueId: JsonField, + private val runId: JsonField, + private val addedAt: JsonField, + private val lastReviewedTime: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("queue_id") @ExcludeMissing queueId: JsonField = JsonMissing.of(), + @JsonProperty("run_id") @ExcludeMissing runId: JsonField = JsonMissing.of(), + @JsonProperty("added_at") + @ExcludeMissing + addedAt: JsonField = JsonMissing.of(), + @JsonProperty("last_reviewed_time") + @ExcludeMissing + lastReviewedTime: JsonField = JsonMissing.of(), + ) : this(id, queueId, runId, addedAt, lastReviewedTime, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun queueId(): String = queueId.getRequired("queue_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun runId(): String = runId.getRequired("run_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun addedAt(): Optional = addedAt.getOptional("added_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun lastReviewedTime(): Optional = + lastReviewedTime.getOptional("last_reviewed_time") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [queueId]. + * + * Unlike [queueId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("queue_id") @ExcludeMissing fun _queueId(): JsonField = queueId + + /** + * Returns the raw JSON value of [runId]. + * + * Unlike [runId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_id") @ExcludeMissing fun _runId(): JsonField = runId + + /** + * Returns the raw JSON value of [addedAt]. + * + * Unlike [addedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("added_at") @ExcludeMissing fun _addedAt(): JsonField = addedAt + + /** + * Returns the raw JSON value of [lastReviewedTime]. + * + * Unlike [lastReviewedTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("last_reviewed_time") + @ExcludeMissing + fun _lastReviewedTime(): JsonField = lastReviewedTime + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RunCreateResponse]. + * + * The following fields are required: + * ```java + * .id() + * .queueId() + * .runId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunCreateResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var queueId: JsonField? = null + private var runId: JsonField? = null + private var addedAt: JsonField = JsonMissing.of() + private var lastReviewedTime: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(runCreateResponse: RunCreateResponse) = apply { + id = runCreateResponse.id + queueId = runCreateResponse.queueId + runId = runCreateResponse.runId + addedAt = runCreateResponse.addedAt + lastReviewedTime = runCreateResponse.lastReviewedTime + additionalProperties = runCreateResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun queueId(queueId: String) = queueId(JsonField.of(queueId)) + + /** + * Sets [Builder.queueId] to an arbitrary JSON value. + * + * You should usually call [Builder.queueId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun queueId(queueId: JsonField) = apply { this.queueId = queueId } + + fun runId(runId: String) = runId(JsonField.of(runId)) + + /** + * Sets [Builder.runId] to an arbitrary JSON value. + * + * You should usually call [Builder.runId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun runId(runId: JsonField) = apply { this.runId = runId } + + fun addedAt(addedAt: OffsetDateTime) = addedAt(JsonField.of(addedAt)) + + /** + * Sets [Builder.addedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.addedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun addedAt(addedAt: JsonField) = apply { this.addedAt = addedAt } + + fun lastReviewedTime(lastReviewedTime: OffsetDateTime?) = + lastReviewedTime(JsonField.ofNullable(lastReviewedTime)) + + /** Alias for calling [Builder.lastReviewedTime] with `lastReviewedTime.orElse(null)`. */ + fun lastReviewedTime(lastReviewedTime: Optional) = + lastReviewedTime(lastReviewedTime.getOrNull()) + + /** + * Sets [Builder.lastReviewedTime] to an arbitrary JSON value. + * + * You should usually call [Builder.lastReviewedTime] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun lastReviewedTime(lastReviewedTime: JsonField) = apply { + this.lastReviewedTime = lastReviewedTime + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RunCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .queueId() + * .runId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RunCreateResponse = + RunCreateResponse( + checkRequired("id", id), + checkRequired("queueId", queueId), + checkRequired("runId", runId), + addedAt, + lastReviewedTime, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RunCreateResponse = apply { + if (validated) { + return@apply + } + + id() + queueId() + runId() + addedAt() + lastReviewedTime() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (queueId.asKnown().isPresent) 1 else 0) + + (if (runId.asKnown().isPresent) 1 else 0) + + (if (addedAt.asKnown().isPresent) 1 else 0) + + (if (lastReviewedTime.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunCreateResponse && + id == other.id && + queueId == other.queueId && + runId == other.runId && + addedAt == other.addedAt && + lastReviewedTime == other.lastReviewedTime && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, queueId, runId, addedAt, lastReviewedTime, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RunCreateResponse{id=$id, queueId=$queueId, runId=$runId, addedAt=$addedAt, lastReviewedTime=$lastReviewedTime, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunDeleteParams.kt new file mode 100644 index 00000000..42ac173c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunDeleteParams.kt @@ -0,0 +1,597 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues.runs + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete Runs From Annotation Queue */ +class RunDeleteParams +private constructor( + private val queueId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun queueId(): Optional = Optional.ofNullable(queueId) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun deleteAll(): Optional = body.deleteAll() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun excludeRunIds(): Optional> = body.excludeRunIds() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun runIds(): Optional> = body.runIds() + + /** + * Returns the raw JSON value of [deleteAll]. + * + * Unlike [deleteAll], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _deleteAll(): JsonField = body._deleteAll() + + /** + * Returns the raw JSON value of [excludeRunIds]. + * + * Unlike [excludeRunIds], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _excludeRunIds(): JsonField> = body._excludeRunIds() + + /** + * Returns the raw JSON value of [runIds]. + * + * Unlike [runIds], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _runIds(): JsonField> = body._runIds() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): RunDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [RunDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunDeleteParams]. */ + class Builder internal constructor() { + + private var queueId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(runDeleteParams: RunDeleteParams) = apply { + queueId = runDeleteParams.queueId + body = runDeleteParams.body.toBuilder() + additionalHeaders = runDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = runDeleteParams.additionalQueryParams.toBuilder() + } + + fun queueId(queueId: String?) = apply { this.queueId = queueId } + + /** Alias for calling [Builder.queueId] with `queueId.orElse(null)`. */ + fun queueId(queueId: Optional) = queueId(queueId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [deleteAll] + * - [excludeRunIds] + * - [runIds] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun deleteAll(deleteAll: Boolean) = apply { body.deleteAll(deleteAll) } + + /** + * Sets [Builder.deleteAll] to an arbitrary JSON value. + * + * You should usually call [Builder.deleteAll] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun deleteAll(deleteAll: JsonField) = apply { body.deleteAll(deleteAll) } + + fun excludeRunIds(excludeRunIds: List?) = apply { + body.excludeRunIds(excludeRunIds) + } + + /** Alias for calling [Builder.excludeRunIds] with `excludeRunIds.orElse(null)`. */ + fun excludeRunIds(excludeRunIds: Optional>) = + excludeRunIds(excludeRunIds.getOrNull()) + + /** + * Sets [Builder.excludeRunIds] to an arbitrary JSON value. + * + * You should usually call [Builder.excludeRunIds] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun excludeRunIds(excludeRunIds: JsonField>) = apply { + body.excludeRunIds(excludeRunIds) + } + + /** + * Adds a single [String] to [excludeRunIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExcludeRunId(excludeRunId: String) = apply { body.addExcludeRunId(excludeRunId) } + + fun runIds(runIds: List?) = apply { body.runIds(runIds) } + + /** Alias for calling [Builder.runIds] with `runIds.orElse(null)`. */ + fun runIds(runIds: Optional>) = runIds(runIds.getOrNull()) + + /** + * Sets [Builder.runIds] to an arbitrary JSON value. + * + * You should usually call [Builder.runIds] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun runIds(runIds: JsonField>) = apply { body.runIds(runIds) } + + /** + * Adds a single [String] to [runIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRunId(runId: String) = apply { body.addRunId(runId) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RunDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RunDeleteParams = + RunDeleteParams( + queueId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> queueId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val deleteAll: JsonField, + private val excludeRunIds: JsonField>, + private val runIds: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("delete_all") + @ExcludeMissing + deleteAll: JsonField = JsonMissing.of(), + @JsonProperty("exclude_run_ids") + @ExcludeMissing + excludeRunIds: JsonField> = JsonMissing.of(), + @JsonProperty("run_ids") + @ExcludeMissing + runIds: JsonField> = JsonMissing.of(), + ) : this(deleteAll, excludeRunIds, runIds, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun deleteAll(): Optional = deleteAll.getOptional("delete_all") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun excludeRunIds(): Optional> = excludeRunIds.getOptional("exclude_run_ids") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun runIds(): Optional> = runIds.getOptional("run_ids") + + /** + * Returns the raw JSON value of [deleteAll]. + * + * Unlike [deleteAll], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("delete_all") @ExcludeMissing fun _deleteAll(): JsonField = deleteAll + + /** + * Returns the raw JSON value of [excludeRunIds]. + * + * Unlike [excludeRunIds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("exclude_run_ids") + @ExcludeMissing + fun _excludeRunIds(): JsonField> = excludeRunIds + + /** + * Returns the raw JSON value of [runIds]. + * + * Unlike [runIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_ids") @ExcludeMissing fun _runIds(): JsonField> = runIds + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var deleteAll: JsonField = JsonMissing.of() + private var excludeRunIds: JsonField>? = null + private var runIds: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + deleteAll = body.deleteAll + excludeRunIds = body.excludeRunIds.map { it.toMutableList() } + runIds = body.runIds.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun deleteAll(deleteAll: Boolean) = deleteAll(JsonField.of(deleteAll)) + + /** + * Sets [Builder.deleteAll] to an arbitrary JSON value. + * + * You should usually call [Builder.deleteAll] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun deleteAll(deleteAll: JsonField) = apply { this.deleteAll = deleteAll } + + fun excludeRunIds(excludeRunIds: List?) = + excludeRunIds(JsonField.ofNullable(excludeRunIds)) + + /** Alias for calling [Builder.excludeRunIds] with `excludeRunIds.orElse(null)`. */ + fun excludeRunIds(excludeRunIds: Optional>) = + excludeRunIds(excludeRunIds.getOrNull()) + + /** + * Sets [Builder.excludeRunIds] to an arbitrary JSON value. + * + * You should usually call [Builder.excludeRunIds] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun excludeRunIds(excludeRunIds: JsonField>) = apply { + this.excludeRunIds = excludeRunIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [excludeRunIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExcludeRunId(excludeRunId: String) = apply { + excludeRunIds = + (excludeRunIds ?: JsonField.of(mutableListOf())).also { + checkKnown("excludeRunIds", it).add(excludeRunId) + } + } + + fun runIds(runIds: List?) = runIds(JsonField.ofNullable(runIds)) + + /** Alias for calling [Builder.runIds] with `runIds.orElse(null)`. */ + fun runIds(runIds: Optional>) = runIds(runIds.getOrNull()) + + /** + * Sets [Builder.runIds] to an arbitrary JSON value. + * + * You should usually call [Builder.runIds] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun runIds(runIds: JsonField>) = apply { + this.runIds = runIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [runIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRunId(runId: String) = apply { + runIds = + (runIds ?: JsonField.of(mutableListOf())).also { + checkKnown("runIds", it).add(runId) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = + Body( + deleteAll, + (excludeRunIds ?: JsonMissing.of()).map { it.toImmutable() }, + (runIds ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + deleteAll() + excludeRunIds() + runIds() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (deleteAll.asKnown().isPresent) 1 else 0) + + (excludeRunIds.asKnown().getOrNull()?.size ?: 0) + + (runIds.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + deleteAll == other.deleteAll && + excludeRunIds == other.excludeRunIds && + runIds == other.runIds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(deleteAll, excludeRunIds, runIds, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{deleteAll=$deleteAll, excludeRunIds=$excludeRunIds, runIds=$runIds, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunDeleteParams && + queueId == other.queueId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(queueId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "RunDeleteParams{queueId=$queueId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunDeleteResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunDeleteResponse.kt new file mode 100644 index 00000000..65c51d45 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunDeleteResponse.kt @@ -0,0 +1,113 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues.runs + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class RunDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [RunDeleteResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunDeleteResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(runDeleteResponse: RunDeleteResponse) = apply { + additionalProperties = runDeleteResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RunDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RunDeleteResponse = RunDeleteResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): RunDeleteResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunDeleteResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "RunDeleteResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunListParams.kt new file mode 100644 index 00000000..aac86237 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunListParams.kt @@ -0,0 +1,287 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues.runs + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get Runs From Annotation Queue */ +class RunListParams +private constructor( + private val queueId: String?, + private val archived: Boolean?, + private val includeStats: Boolean?, + private val limit: Long?, + private val offset: Long?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun queueId(): Optional = Optional.ofNullable(queueId) + + fun archived(): Optional = Optional.ofNullable(archived) + + fun includeStats(): Optional = Optional.ofNullable(includeStats) + + fun limit(): Optional = Optional.ofNullable(limit) + + fun offset(): Optional = Optional.ofNullable(offset) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): RunListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [RunListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunListParams]. */ + class Builder internal constructor() { + + private var queueId: String? = null + private var archived: Boolean? = null + private var includeStats: Boolean? = null + private var limit: Long? = null + private var offset: Long? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(runListParams: RunListParams) = apply { + queueId = runListParams.queueId + archived = runListParams.archived + includeStats = runListParams.includeStats + limit = runListParams.limit + offset = runListParams.offset + additionalHeaders = runListParams.additionalHeaders.toBuilder() + additionalQueryParams = runListParams.additionalQueryParams.toBuilder() + } + + fun queueId(queueId: String?) = apply { this.queueId = queueId } + + /** Alias for calling [Builder.queueId] with `queueId.orElse(null)`. */ + fun queueId(queueId: Optional) = queueId(queueId.getOrNull()) + + fun archived(archived: Boolean?) = apply { this.archived = archived } + + /** + * Alias for [Builder.archived]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun archived(archived: Boolean) = archived(archived as Boolean?) + + /** Alias for calling [Builder.archived] with `archived.orElse(null)`. */ + fun archived(archived: Optional) = archived(archived.getOrNull()) + + fun includeStats(includeStats: Boolean?) = apply { this.includeStats = includeStats } + + /** + * Alias for [Builder.includeStats]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun includeStats(includeStats: Boolean) = includeStats(includeStats as Boolean?) + + /** Alias for calling [Builder.includeStats] with `includeStats.orElse(null)`. */ + fun includeStats(includeStats: Optional) = includeStats(includeStats.getOrNull()) + + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional) = limit(limit.getOrNull()) + + fun offset(offset: Long?) = apply { this.offset = offset } + + /** + * Alias for [Builder.offset]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun offset(offset: Long) = offset(offset as Long?) + + /** Alias for calling [Builder.offset] with `offset.orElse(null)`. */ + fun offset(offset: Optional) = offset(offset.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RunListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RunListParams = + RunListParams( + queueId, + archived, + includeStats, + limit, + offset, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> queueId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + archived?.let { put("archived", it.toString()) } + includeStats?.let { put("include_stats", it.toString()) } + limit?.let { put("limit", it.toString()) } + offset?.let { put("offset", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunListParams && + queueId == other.queueId && + archived == other.archived && + includeStats == other.includeStats && + limit == other.limit && + offset == other.offset && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + queueId, + archived, + includeStats, + limit, + offset, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "RunListParams{queueId=$queueId, archived=$archived, includeStats=$includeStats, limit=$limit, offset=$offset, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunUpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunUpdateParams.kt new file mode 100644 index 00000000..6f39a604 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunUpdateParams.kt @@ -0,0 +1,521 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues.runs + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Update Run In Annotation Queue */ +class RunUpdateParams +private constructor( + private val queueId: String, + private val queueRunId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun queueId(): String = queueId + + fun queueRunId(): Optional = Optional.ofNullable(queueRunId) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun addedAt(): Optional = body.addedAt() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun lastReviewedTime(): Optional = body.lastReviewedTime() + + /** + * Returns the raw JSON value of [addedAt]. + * + * Unlike [addedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _addedAt(): JsonField = body._addedAt() + + /** + * Returns the raw JSON value of [lastReviewedTime]. + * + * Unlike [lastReviewedTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _lastReviewedTime(): JsonField = body._lastReviewedTime() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RunUpdateParams]. + * + * The following fields are required: + * ```java + * .queueId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunUpdateParams]. */ + class Builder internal constructor() { + + private var queueId: String? = null + private var queueRunId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(runUpdateParams: RunUpdateParams) = apply { + queueId = runUpdateParams.queueId + queueRunId = runUpdateParams.queueRunId + body = runUpdateParams.body.toBuilder() + additionalHeaders = runUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = runUpdateParams.additionalQueryParams.toBuilder() + } + + fun queueId(queueId: String) = apply { this.queueId = queueId } + + fun queueRunId(queueRunId: String?) = apply { this.queueRunId = queueRunId } + + /** Alias for calling [Builder.queueRunId] with `queueRunId.orElse(null)`. */ + fun queueRunId(queueRunId: Optional) = queueRunId(queueRunId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [addedAt] + * - [lastReviewedTime] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun addedAt(addedAt: OffsetDateTime?) = apply { body.addedAt(addedAt) } + + /** Alias for calling [Builder.addedAt] with `addedAt.orElse(null)`. */ + fun addedAt(addedAt: Optional) = addedAt(addedAt.getOrNull()) + + /** + * Sets [Builder.addedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.addedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun addedAt(addedAt: JsonField) = apply { body.addedAt(addedAt) } + + fun lastReviewedTime(lastReviewedTime: OffsetDateTime?) = apply { + body.lastReviewedTime(lastReviewedTime) + } + + /** Alias for calling [Builder.lastReviewedTime] with `lastReviewedTime.orElse(null)`. */ + fun lastReviewedTime(lastReviewedTime: Optional) = + lastReviewedTime(lastReviewedTime.getOrNull()) + + /** + * Sets [Builder.lastReviewedTime] to an arbitrary JSON value. + * + * You should usually call [Builder.lastReviewedTime] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun lastReviewedTime(lastReviewedTime: JsonField) = apply { + body.lastReviewedTime(lastReviewedTime) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RunUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .queueId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RunUpdateParams = + RunUpdateParams( + checkRequired("queueId", queueId), + queueRunId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> queueId + 1 -> queueRunId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val addedAt: JsonField, + private val lastReviewedTime: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("added_at") + @ExcludeMissing + addedAt: JsonField = JsonMissing.of(), + @JsonProperty("last_reviewed_time") + @ExcludeMissing + lastReviewedTime: JsonField = JsonMissing.of(), + ) : this(addedAt, lastReviewedTime, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun addedAt(): Optional = addedAt.getOptional("added_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun lastReviewedTime(): Optional = + lastReviewedTime.getOptional("last_reviewed_time") + + /** + * Returns the raw JSON value of [addedAt]. + * + * Unlike [addedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("added_at") + @ExcludeMissing + fun _addedAt(): JsonField = addedAt + + /** + * Returns the raw JSON value of [lastReviewedTime]. + * + * Unlike [lastReviewedTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("last_reviewed_time") + @ExcludeMissing + fun _lastReviewedTime(): JsonField = lastReviewedTime + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var addedAt: JsonField = JsonMissing.of() + private var lastReviewedTime: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + addedAt = body.addedAt + lastReviewedTime = body.lastReviewedTime + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun addedAt(addedAt: OffsetDateTime?) = addedAt(JsonField.ofNullable(addedAt)) + + /** Alias for calling [Builder.addedAt] with `addedAt.orElse(null)`. */ + fun addedAt(addedAt: Optional) = addedAt(addedAt.getOrNull()) + + /** + * Sets [Builder.addedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.addedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun addedAt(addedAt: JsonField) = apply { this.addedAt = addedAt } + + fun lastReviewedTime(lastReviewedTime: OffsetDateTime?) = + lastReviewedTime(JsonField.ofNullable(lastReviewedTime)) + + /** + * Alias for calling [Builder.lastReviewedTime] with `lastReviewedTime.orElse(null)`. + */ + fun lastReviewedTime(lastReviewedTime: Optional) = + lastReviewedTime(lastReviewedTime.getOrNull()) + + /** + * Sets [Builder.lastReviewedTime] to an arbitrary JSON value. + * + * You should usually call [Builder.lastReviewedTime] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun lastReviewedTime(lastReviewedTime: JsonField) = apply { + this.lastReviewedTime = lastReviewedTime + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = Body(addedAt, lastReviewedTime, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + addedAt() + lastReviewedTime() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (addedAt.asKnown().isPresent) 1 else 0) + + (if (lastReviewedTime.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + addedAt == other.addedAt && + lastReviewedTime == other.lastReviewedTime && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(addedAt, lastReviewedTime, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{addedAt=$addedAt, lastReviewedTime=$lastReviewedTime, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunUpdateParams && + queueId == other.queueId && + queueRunId == other.queueRunId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(queueId, queueRunId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "RunUpdateParams{queueId=$queueId, queueRunId=$queueRunId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunUpdateResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunUpdateResponse.kt new file mode 100644 index 00000000..df11b8e3 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunUpdateResponse.kt @@ -0,0 +1,113 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues.runs + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class RunUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [RunUpdateResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunUpdateResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(runUpdateResponse: RunUpdateResponse) = apply { + additionalProperties = runUpdateResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RunUpdateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RunUpdateResponse = RunUpdateResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): RunUpdateResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunUpdateResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "RunUpdateResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/apikey/ApiKeyApiKeyParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/apikey/ApiKeyApiKeyParams.kt new file mode 100644 index 00000000..dbe8b388 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/apikey/ApiKeyApiKeyParams.kt @@ -0,0 +1,225 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.apikey + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.immutableEmptyMap +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyCreateRequest +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Generate an api key for the user */ +class ApiKeyApiKeyParams +private constructor( + private val apiKeyCreateRequest: ApiKeyCreateRequest?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * API key POST schema. + * + * expires_at: Optional datetime when the API key will expire. workspaces: List of workspace + * UUIDs this key can access (feature-flagged). role_id: Optional UUID of the role to assign to + * API key. If not provided, uses default role based on read_only flag: + * - WORKSPACE_ADMIN if read_only is False + * - WORKSPACE_READER if read_only is True org_role_id: UUID of a org role for org-scoped keys + * If not provided, defaults to ORG_USER default_workspace_id: UUID of the default workspace + * for PATs. If not provided, uses the current logic (first available workspace). + */ + fun apiKeyCreateRequest(): Optional = + Optional.ofNullable(apiKeyCreateRequest) + + fun _additionalBodyProperties(): Map = + apiKeyCreateRequest?._additionalProperties() ?: immutableEmptyMap() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ApiKeyApiKeyParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ApiKeyApiKeyParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ApiKeyApiKeyParams]. */ + class Builder internal constructor() { + + private var apiKeyCreateRequest: ApiKeyCreateRequest? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(apiKeyApiKeyParams: ApiKeyApiKeyParams) = apply { + apiKeyCreateRequest = apiKeyApiKeyParams.apiKeyCreateRequest + additionalHeaders = apiKeyApiKeyParams.additionalHeaders.toBuilder() + additionalQueryParams = apiKeyApiKeyParams.additionalQueryParams.toBuilder() + } + + /** + * API key POST schema. + * + * expires_at: Optional datetime when the API key will expire. workspaces: List of workspace + * UUIDs this key can access (feature-flagged). role_id: Optional UUID of the role to assign + * to API key. If not provided, uses default role based on read_only flag: + * - WORKSPACE_ADMIN if read_only is False + * - WORKSPACE_READER if read_only is True org_role_id: UUID of a org role for org-scoped + * keys If not provided, defaults to ORG_USER default_workspace_id: UUID of the default + * workspace for PATs. If not provided, uses the current logic (first available + * workspace). + */ + fun apiKeyCreateRequest(apiKeyCreateRequest: ApiKeyCreateRequest?) = apply { + this.apiKeyCreateRequest = apiKeyCreateRequest + } + + /** + * Alias for calling [Builder.apiKeyCreateRequest] with `apiKeyCreateRequest.orElse(null)`. + */ + fun apiKeyCreateRequest(apiKeyCreateRequest: Optional) = + apiKeyCreateRequest(apiKeyCreateRequest.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ApiKeyApiKeyParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ApiKeyApiKeyParams = + ApiKeyApiKeyParams( + apiKeyCreateRequest, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Optional = Optional.ofNullable(apiKeyCreateRequest) + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ApiKeyApiKeyParams && + apiKeyCreateRequest == other.apiKeyCreateRequest && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(apiKeyCreateRequest, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ApiKeyApiKeyParams{apiKeyCreateRequest=$apiKeyCreateRequest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/apikey/ApiKeyDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/apikey/ApiKeyDeleteParams.kt new file mode 100644 index 00000000..2b69bf3d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/apikey/ApiKeyDeleteParams.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.apikey + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete an api key for the user */ +class ApiKeyDeleteParams +private constructor( + private val apiKeyId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun apiKeyId(): Optional = Optional.ofNullable(apiKeyId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ApiKeyDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ApiKeyDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ApiKeyDeleteParams]. */ + class Builder internal constructor() { + + private var apiKeyId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(apiKeyDeleteParams: ApiKeyDeleteParams) = apply { + apiKeyId = apiKeyDeleteParams.apiKeyId + additionalHeaders = apiKeyDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = apiKeyDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = apiKeyDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun apiKeyId(apiKeyId: String?) = apply { this.apiKeyId = apiKeyId } + + /** Alias for calling [Builder.apiKeyId] with `apiKeyId.orElse(null)`. */ + fun apiKeyId(apiKeyId: Optional) = apiKeyId(apiKeyId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [ApiKeyDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ApiKeyDeleteParams = + ApiKeyDeleteParams( + apiKeyId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> apiKeyId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ApiKeyDeleteParams && + apiKeyId == other.apiKeyId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(apiKeyId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "ApiKeyDeleteParams{apiKeyId=$apiKeyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/apikey/ApiKeyRetrieveApiKeyParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/apikey/ApiKeyRetrieveApiKeyParams.kt new file mode 100644 index 00000000..b0a0e8b3 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/apikey/ApiKeyRetrieveApiKeyParams.kt @@ -0,0 +1,172 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.apikey + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** Get the current tenant's API keys */ +class ApiKeyRetrieveApiKeyParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ApiKeyRetrieveApiKeyParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [ApiKeyRetrieveApiKeyParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ApiKeyRetrieveApiKeyParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(apiKeyRetrieveApiKeyParams: ApiKeyRetrieveApiKeyParams) = apply { + additionalHeaders = apiKeyRetrieveApiKeyParams.additionalHeaders.toBuilder() + additionalQueryParams = apiKeyRetrieveApiKeyParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ApiKeyRetrieveApiKeyParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ApiKeyRetrieveApiKeyParams = + ApiKeyRetrieveApiKeyParams(additionalHeaders.build(), additionalQueryParams.build()) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ApiKeyRetrieveApiKeyParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "ApiKeyRetrieveApiKeyParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/apikey/current/CurrentCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/apikey/current/CurrentCreateParams.kt new file mode 100644 index 00000000..cdb5f235 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/apikey/current/CurrentCreateParams.kt @@ -0,0 +1,225 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.apikey.current + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.immutableEmptyMap +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyCreateRequest +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** DEPRECATED: Use /orgs/current/personal-access-tokens instead */ +class CurrentCreateParams +private constructor( + private val apiKeyCreateRequest: ApiKeyCreateRequest?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * API key POST schema. + * + * expires_at: Optional datetime when the API key will expire. workspaces: List of workspace + * UUIDs this key can access (feature-flagged). role_id: Optional UUID of the role to assign to + * API key. If not provided, uses default role based on read_only flag: + * - WORKSPACE_ADMIN if read_only is False + * - WORKSPACE_READER if read_only is True org_role_id: UUID of a org role for org-scoped keys + * If not provided, defaults to ORG_USER default_workspace_id: UUID of the default workspace + * for PATs. If not provided, uses the current logic (first available workspace). + */ + fun apiKeyCreateRequest(): Optional = + Optional.ofNullable(apiKeyCreateRequest) + + fun _additionalBodyProperties(): Map = + apiKeyCreateRequest?._additionalProperties() ?: immutableEmptyMap() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): CurrentCreateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [CurrentCreateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CurrentCreateParams]. */ + class Builder internal constructor() { + + private var apiKeyCreateRequest: ApiKeyCreateRequest? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(currentCreateParams: CurrentCreateParams) = apply { + apiKeyCreateRequest = currentCreateParams.apiKeyCreateRequest + additionalHeaders = currentCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = currentCreateParams.additionalQueryParams.toBuilder() + } + + /** + * API key POST schema. + * + * expires_at: Optional datetime when the API key will expire. workspaces: List of workspace + * UUIDs this key can access (feature-flagged). role_id: Optional UUID of the role to assign + * to API key. If not provided, uses default role based on read_only flag: + * - WORKSPACE_ADMIN if read_only is False + * - WORKSPACE_READER if read_only is True org_role_id: UUID of a org role for org-scoped + * keys If not provided, defaults to ORG_USER default_workspace_id: UUID of the default + * workspace for PATs. If not provided, uses the current logic (first available + * workspace). + */ + fun apiKeyCreateRequest(apiKeyCreateRequest: ApiKeyCreateRequest?) = apply { + this.apiKeyCreateRequest = apiKeyCreateRequest + } + + /** + * Alias for calling [Builder.apiKeyCreateRequest] with `apiKeyCreateRequest.orElse(null)`. + */ + fun apiKeyCreateRequest(apiKeyCreateRequest: Optional) = + apiKeyCreateRequest(apiKeyCreateRequest.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [CurrentCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CurrentCreateParams = + CurrentCreateParams( + apiKeyCreateRequest, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Optional = Optional.ofNullable(apiKeyCreateRequest) + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CurrentCreateParams && + apiKeyCreateRequest == other.apiKeyCreateRequest && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(apiKeyCreateRequest, additionalHeaders, additionalQueryParams) + + override fun toString() = + "CurrentCreateParams{apiKeyCreateRequest=$apiKeyCreateRequest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/apikey/current/CurrentDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/apikey/current/CurrentDeleteParams.kt new file mode 100644 index 00000000..a801979a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/apikey/current/CurrentDeleteParams.kt @@ -0,0 +1,230 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.apikey.current + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** DEPRECATED: Use /orgs/current/personal-access-tokens/{pat_id} instead */ +@Deprecated("deprecated") +class CurrentDeleteParams +private constructor( + private val patId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun patId(): Optional = Optional.ofNullable(patId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): CurrentDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [CurrentDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CurrentDeleteParams]. */ + class Builder internal constructor() { + + private var patId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(currentDeleteParams: CurrentDeleteParams) = apply { + patId = currentDeleteParams.patId + additionalHeaders = currentDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = currentDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = currentDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun patId(patId: String?) = apply { this.patId = patId } + + /** Alias for calling [Builder.patId] with `patId.orElse(null)`. */ + fun patId(patId: Optional) = patId(patId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [CurrentDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CurrentDeleteParams = + CurrentDeleteParams( + patId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> patId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CurrentDeleteParams && + patId == other.patId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(patId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "CurrentDeleteParams{patId=$patId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/apikey/current/CurrentListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/apikey/current/CurrentListParams.kt new file mode 100644 index 00000000..39e3f032 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/apikey/current/CurrentListParams.kt @@ -0,0 +1,171 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.apikey.current + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** DEPRECATED: Use /orgs/current/personal-access-tokens instead */ +@Deprecated("deprecated") +class CurrentListParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): CurrentListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [CurrentListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CurrentListParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(currentListParams: CurrentListParams) = apply { + additionalHeaders = currentListParams.additionalHeaders.toBuilder() + additionalQueryParams = currentListParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [CurrentListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CurrentListParams = + CurrentListParams(additionalHeaders.build(), additionalQueryParams.build()) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CurrentListParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "CurrentListParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExport.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExport.kt new file mode 100644 index 00000000..3ca442e9 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExport.kt @@ -0,0 +1,907 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.bulkexports + +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.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BulkExport +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val bulkExportDestinationId: JsonField, + private val createdAt: JsonField, + private val finishedAt: JsonField, + private val sessionId: JsonField, + private val startTime: JsonField, + private val status: JsonField, + private val tenantId: JsonField, + private val updatedAt: JsonField, + private val compression: JsonField, + private val endTime: JsonField, + private val filter: JsonField, + private val format: JsonField, + private val intervalHours: JsonField, + private val sourceBulkExportId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("bulk_export_destination_id") + @ExcludeMissing + bulkExportDestinationId: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("finished_at") + @ExcludeMissing + finishedAt: JsonField = JsonMissing.of(), + @JsonProperty("session_id") @ExcludeMissing sessionId: JsonField = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("tenant_id") @ExcludeMissing tenantId: JsonField = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), + @JsonProperty("compression") + @ExcludeMissing + compression: JsonField = JsonMissing.of(), + @JsonProperty("end_time") + @ExcludeMissing + endTime: JsonField = JsonMissing.of(), + @JsonProperty("filter") @ExcludeMissing filter: JsonField = JsonMissing.of(), + @JsonProperty("format") + @ExcludeMissing + format: JsonField = JsonMissing.of(), + @JsonProperty("interval_hours") + @ExcludeMissing + intervalHours: JsonField = JsonMissing.of(), + @JsonProperty("source_bulk_export_id") + @ExcludeMissing + sourceBulkExportId: JsonField = JsonMissing.of(), + ) : this( + id, + bulkExportDestinationId, + createdAt, + finishedAt, + sessionId, + startTime, + status, + tenantId, + updatedAt, + compression, + endTime, + filter, + format, + intervalHours, + sourceBulkExportId, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun bulkExportDestinationId(): String = + bulkExportDestinationId.getRequired("bulk_export_destination_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun finishedAt(): Optional = finishedAt.getOptional("finished_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun sessionId(): String = sessionId.getRequired("session_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun startTime(): OffsetDateTime = startTime.getRequired("start_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tenantId(): String = tenantId.getRequired("tenant_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updatedAt(): OffsetDateTime = updatedAt.getRequired("updated_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun compression(): Optional = compression.getOptional("compression") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endTime(): Optional = endTime.getOptional("end_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun filter(): Optional = filter.getOptional("filter") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun format(): Optional = format.getOptional("format") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun intervalHours(): Optional = intervalHours.getOptional("interval_hours") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun sourceBulkExportId(): Optional = + sourceBulkExportId.getOptional("source_bulk_export_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [bulkExportDestinationId]. + * + * Unlike [bulkExportDestinationId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bulk_export_destination_id") + @ExcludeMissing + fun _bulkExportDestinationId(): JsonField = bulkExportDestinationId + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [finishedAt]. + * + * Unlike [finishedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("finished_at") + @ExcludeMissing + fun _finishedAt(): JsonField = finishedAt + + /** + * Returns the raw JSON value of [sessionId]. + * + * Unlike [sessionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session_id") @ExcludeMissing fun _sessionId(): JsonField = sessionId + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_time") + @ExcludeMissing + fun _startTime(): JsonField = startTime + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_id") @ExcludeMissing fun _tenantId(): JsonField = tenantId + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField = updatedAt + + /** + * Returns the raw JSON value of [compression]. + * + * Unlike [compression], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("compression") + @ExcludeMissing + fun _compression(): JsonField = compression + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_time") @ExcludeMissing fun _endTime(): JsonField = endTime + + /** + * Returns the raw JSON value of [filter]. + * + * Unlike [filter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField = filter + + /** + * Returns the raw JSON value of [format]. + * + * Unlike [format], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("format") @ExcludeMissing fun _format(): JsonField = format + + /** + * Returns the raw JSON value of [intervalHours]. + * + * Unlike [intervalHours], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("interval_hours") + @ExcludeMissing + fun _intervalHours(): JsonField = intervalHours + + /** + * Returns the raw JSON value of [sourceBulkExportId]. + * + * Unlike [sourceBulkExportId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("source_bulk_export_id") + @ExcludeMissing + fun _sourceBulkExportId(): JsonField = sourceBulkExportId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BulkExport]. + * + * The following fields are required: + * ```java + * .id() + * .bulkExportDestinationId() + * .createdAt() + * .finishedAt() + * .sessionId() + * .startTime() + * .status() + * .tenantId() + * .updatedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkExport]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var bulkExportDestinationId: JsonField? = null + private var createdAt: JsonField? = null + private var finishedAt: JsonField? = null + private var sessionId: JsonField? = null + private var startTime: JsonField? = null + private var status: JsonField? = null + private var tenantId: JsonField? = null + private var updatedAt: JsonField? = null + private var compression: JsonField = JsonMissing.of() + private var endTime: JsonField = JsonMissing.of() + private var filter: JsonField = JsonMissing.of() + private var format: JsonField = JsonMissing.of() + private var intervalHours: JsonField = JsonMissing.of() + private var sourceBulkExportId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkExport: BulkExport) = apply { + id = bulkExport.id + bulkExportDestinationId = bulkExport.bulkExportDestinationId + createdAt = bulkExport.createdAt + finishedAt = bulkExport.finishedAt + sessionId = bulkExport.sessionId + startTime = bulkExport.startTime + status = bulkExport.status + tenantId = bulkExport.tenantId + updatedAt = bulkExport.updatedAt + compression = bulkExport.compression + endTime = bulkExport.endTime + filter = bulkExport.filter + format = bulkExport.format + intervalHours = bulkExport.intervalHours + sourceBulkExportId = bulkExport.sourceBulkExportId + additionalProperties = bulkExport.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun bulkExportDestinationId(bulkExportDestinationId: String) = + bulkExportDestinationId(JsonField.of(bulkExportDestinationId)) + + /** + * Sets [Builder.bulkExportDestinationId] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkExportDestinationId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun bulkExportDestinationId(bulkExportDestinationId: JsonField) = apply { + this.bulkExportDestinationId = bulkExportDestinationId + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + fun finishedAt(finishedAt: OffsetDateTime?) = finishedAt(JsonField.ofNullable(finishedAt)) + + /** Alias for calling [Builder.finishedAt] with `finishedAt.orElse(null)`. */ + fun finishedAt(finishedAt: Optional) = finishedAt(finishedAt.getOrNull()) + + /** + * Sets [Builder.finishedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.finishedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun finishedAt(finishedAt: JsonField) = apply { + this.finishedAt = finishedAt + } + + fun sessionId(sessionId: String) = sessionId(JsonField.of(sessionId)) + + /** + * Sets [Builder.sessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun sessionId(sessionId: JsonField) = apply { this.sessionId = sessionId } + + fun startTime(startTime: OffsetDateTime) = startTime(JsonField.of(startTime)) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField) = apply { this.startTime = startTime } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tenantId(tenantId: JsonField) = apply { this.tenantId = tenantId } + + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } + + fun compression(compression: BulkExportCompression) = compression(JsonField.of(compression)) + + /** + * Sets [Builder.compression] to an arbitrary JSON value. + * + * You should usually call [Builder.compression] with a well-typed [BulkExportCompression] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun compression(compression: JsonField) = apply { + this.compression = compression + } + + fun endTime(endTime: OffsetDateTime?) = endTime(JsonField.ofNullable(endTime)) + + /** Alias for calling [Builder.endTime] with `endTime.orElse(null)`. */ + fun endTime(endTime: Optional) = endTime(endTime.getOrNull()) + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endTime(endTime: JsonField) = apply { this.endTime = endTime } + + fun filter(filter: String?) = filter(JsonField.ofNullable(filter)) + + /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ + fun filter(filter: Optional) = filter(filter.getOrNull()) + + /** + * Sets [Builder.filter] to an arbitrary JSON value. + * + * You should usually call [Builder.filter] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun filter(filter: JsonField) = apply { this.filter = filter } + + fun format(format: BulkExportFormat) = format(JsonField.of(format)) + + /** + * Sets [Builder.format] to an arbitrary JSON value. + * + * You should usually call [Builder.format] with a well-typed [BulkExportFormat] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun format(format: JsonField) = apply { this.format = format } + + fun intervalHours(intervalHours: Long?) = intervalHours(JsonField.ofNullable(intervalHours)) + + /** + * Alias for [Builder.intervalHours]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun intervalHours(intervalHours: Long) = intervalHours(intervalHours as Long?) + + /** Alias for calling [Builder.intervalHours] with `intervalHours.orElse(null)`. */ + fun intervalHours(intervalHours: Optional) = intervalHours(intervalHours.getOrNull()) + + /** + * Sets [Builder.intervalHours] to an arbitrary JSON value. + * + * You should usually call [Builder.intervalHours] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun intervalHours(intervalHours: JsonField) = apply { + this.intervalHours = intervalHours + } + + fun sourceBulkExportId(sourceBulkExportId: String?) = + sourceBulkExportId(JsonField.ofNullable(sourceBulkExportId)) + + /** + * Alias for calling [Builder.sourceBulkExportId] with `sourceBulkExportId.orElse(null)`. + */ + fun sourceBulkExportId(sourceBulkExportId: Optional) = + sourceBulkExportId(sourceBulkExportId.getOrNull()) + + /** + * Sets [Builder.sourceBulkExportId] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceBulkExportId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sourceBulkExportId(sourceBulkExportId: JsonField) = apply { + this.sourceBulkExportId = sourceBulkExportId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkExport]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .bulkExportDestinationId() + * .createdAt() + * .finishedAt() + * .sessionId() + * .startTime() + * .status() + * .tenantId() + * .updatedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkExport = + BulkExport( + checkRequired("id", id), + checkRequired("bulkExportDestinationId", bulkExportDestinationId), + checkRequired("createdAt", createdAt), + checkRequired("finishedAt", finishedAt), + checkRequired("sessionId", sessionId), + checkRequired("startTime", startTime), + checkRequired("status", status), + checkRequired("tenantId", tenantId), + checkRequired("updatedAt", updatedAt), + compression, + endTime, + filter, + format, + intervalHours, + sourceBulkExportId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkExport = apply { + if (validated) { + return@apply + } + + id() + bulkExportDestinationId() + createdAt() + finishedAt() + sessionId() + startTime() + status().validate() + tenantId() + updatedAt() + compression().ifPresent { it.validate() } + endTime() + filter() + format().ifPresent { it.validate() } + intervalHours() + sourceBulkExportId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (bulkExportDestinationId.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (finishedAt.asKnown().isPresent) 1 else 0) + + (if (sessionId.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (compression.asKnown().getOrNull()?.validity() ?: 0) + + (if (endTime.asKnown().isPresent) 1 else 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (format.asKnown().getOrNull()?.validity() ?: 0) + + (if (intervalHours.asKnown().isPresent) 1 else 0) + + (if (sourceBulkExportId.asKnown().isPresent) 1 else 0) + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CANCELLED = of("Cancelled") + + @JvmField val COMPLETED = of("Completed") + + @JvmField val CREATED = of("Created") + + @JvmField val INTERVAL_SCHEDULED = of("IntervalScheduled") + + @JvmField val FAILED = of("Failed") + + @JvmField val TIMED_OUT = of("TimedOut") + + @JvmField val RUNNING = of("Running") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + CANCELLED, + COMPLETED, + CREATED, + INTERVAL_SCHEDULED, + FAILED, + TIMED_OUT, + RUNNING, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CANCELLED, + COMPLETED, + CREATED, + INTERVAL_SCHEDULED, + FAILED, + TIMED_OUT, + RUNNING, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CANCELLED -> Value.CANCELLED + COMPLETED -> Value.COMPLETED + CREATED -> Value.CREATED + INTERVAL_SCHEDULED -> Value.INTERVAL_SCHEDULED + FAILED -> Value.FAILED + TIMED_OUT -> Value.TIMED_OUT + RUNNING -> Value.RUNNING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CANCELLED -> Known.CANCELLED + COMPLETED -> Known.COMPLETED + CREATED -> Known.CREATED + INTERVAL_SCHEDULED -> Known.INTERVAL_SCHEDULED + FAILED -> Known.FAILED + TIMED_OUT -> Known.TIMED_OUT + RUNNING -> Known.RUNNING + else -> throw LangsmithApiInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkExport && + id == other.id && + bulkExportDestinationId == other.bulkExportDestinationId && + createdAt == other.createdAt && + finishedAt == other.finishedAt && + sessionId == other.sessionId && + startTime == other.startTime && + status == other.status && + tenantId == other.tenantId && + updatedAt == other.updatedAt && + compression == other.compression && + endTime == other.endTime && + filter == other.filter && + format == other.format && + intervalHours == other.intervalHours && + sourceBulkExportId == other.sourceBulkExportId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + bulkExportDestinationId, + createdAt, + finishedAt, + sessionId, + startTime, + status, + tenantId, + updatedAt, + compression, + endTime, + filter, + format, + intervalHours, + sourceBulkExportId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkExport{id=$id, bulkExportDestinationId=$bulkExportDestinationId, createdAt=$createdAt, finishedAt=$finishedAt, sessionId=$sessionId, startTime=$startTime, status=$status, tenantId=$tenantId, updatedAt=$updatedAt, compression=$compression, endTime=$endTime, filter=$filter, format=$format, intervalHours=$intervalHours, sourceBulkExportId=$sourceBulkExportId, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportBulkExportsParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportBulkExportsParams.kt new file mode 100644 index 00000000..2eb3224e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportBulkExportsParams.kt @@ -0,0 +1,926 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.bulkexports + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create a new bulk export */ +class BulkExportBulkExportsParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun bulkExportDestinationId(): String = body.bulkExportDestinationId() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun sessionId(): String = body.sessionId() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun startTime(): OffsetDateTime = body.startTime() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun compression(): Optional = body.compression() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endTime(): Optional = body.endTime() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun filter(): Optional = body.filter() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun format(): Optional = body.format() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun intervalHours(): Optional = body.intervalHours() + + /** + * Returns the raw JSON value of [bulkExportDestinationId]. + * + * Unlike [bulkExportDestinationId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _bulkExportDestinationId(): JsonField = body._bulkExportDestinationId() + + /** + * Returns the raw JSON value of [sessionId]. + * + * Unlike [sessionId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _sessionId(): JsonField = body._sessionId() + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _startTime(): JsonField = body._startTime() + + /** + * Returns the raw JSON value of [compression]. + * + * Unlike [compression], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _compression(): JsonField = body._compression() + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _endTime(): JsonField = body._endTime() + + /** + * Returns the raw JSON value of [filter]. + * + * Unlike [filter], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _filter(): JsonField = body._filter() + + /** + * Returns the raw JSON value of [format]. + * + * Unlike [format], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _format(): JsonField = body._format() + + /** + * Returns the raw JSON value of [intervalHours]. + * + * Unlike [intervalHours], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _intervalHours(): JsonField = body._intervalHours() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BulkExportBulkExportsParams]. + * + * The following fields are required: + * ```java + * .bulkExportDestinationId() + * .sessionId() + * .startTime() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkExportBulkExportsParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(bulkExportBulkExportsParams: BulkExportBulkExportsParams) = apply { + body = bulkExportBulkExportsParams.body.toBuilder() + additionalHeaders = bulkExportBulkExportsParams.additionalHeaders.toBuilder() + additionalQueryParams = bulkExportBulkExportsParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [bulkExportDestinationId] + * - [sessionId] + * - [startTime] + * - [compression] + * - [endTime] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun bulkExportDestinationId(bulkExportDestinationId: String) = apply { + body.bulkExportDestinationId(bulkExportDestinationId) + } + + /** + * Sets [Builder.bulkExportDestinationId] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkExportDestinationId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun bulkExportDestinationId(bulkExportDestinationId: JsonField) = apply { + body.bulkExportDestinationId(bulkExportDestinationId) + } + + fun sessionId(sessionId: String) = apply { body.sessionId(sessionId) } + + /** + * Sets [Builder.sessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun sessionId(sessionId: JsonField) = apply { body.sessionId(sessionId) } + + fun startTime(startTime: OffsetDateTime) = apply { body.startTime(startTime) } + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField) = apply { body.startTime(startTime) } + + fun compression(compression: BulkExportCompression) = apply { + body.compression(compression) + } + + /** + * Sets [Builder.compression] to an arbitrary JSON value. + * + * You should usually call [Builder.compression] with a well-typed [BulkExportCompression] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun compression(compression: JsonField) = apply { + body.compression(compression) + } + + fun endTime(endTime: OffsetDateTime?) = apply { body.endTime(endTime) } + + /** Alias for calling [Builder.endTime] with `endTime.orElse(null)`. */ + fun endTime(endTime: Optional) = endTime(endTime.getOrNull()) + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endTime(endTime: JsonField) = apply { body.endTime(endTime) } + + fun filter(filter: String?) = apply { body.filter(filter) } + + /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ + fun filter(filter: Optional) = filter(filter.getOrNull()) + + /** + * Sets [Builder.filter] to an arbitrary JSON value. + * + * You should usually call [Builder.filter] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun filter(filter: JsonField) = apply { body.filter(filter) } + + fun format(format: BulkExportFormat) = apply { body.format(format) } + + /** + * Sets [Builder.format] to an arbitrary JSON value. + * + * You should usually call [Builder.format] with a well-typed [BulkExportFormat] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun format(format: JsonField) = apply { body.format(format) } + + fun intervalHours(intervalHours: Long?) = apply { body.intervalHours(intervalHours) } + + /** + * Alias for [Builder.intervalHours]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun intervalHours(intervalHours: Long) = intervalHours(intervalHours as Long?) + + /** Alias for calling [Builder.intervalHours] with `intervalHours.orElse(null)`. */ + fun intervalHours(intervalHours: Optional) = intervalHours(intervalHours.getOrNull()) + + /** + * Sets [Builder.intervalHours] to an arbitrary JSON value. + * + * You should usually call [Builder.intervalHours] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun intervalHours(intervalHours: JsonField) = apply { + body.intervalHours(intervalHours) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [BulkExportBulkExportsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bulkExportDestinationId() + * .sessionId() + * .startTime() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkExportBulkExportsParams = + BulkExportBulkExportsParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkExportDestinationId: JsonField, + private val sessionId: JsonField, + private val startTime: JsonField, + private val compression: JsonField, + private val endTime: JsonField, + private val filter: JsonField, + private val format: JsonField, + private val intervalHours: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_export_destination_id") + @ExcludeMissing + bulkExportDestinationId: JsonField = JsonMissing.of(), + @JsonProperty("session_id") + @ExcludeMissing + sessionId: JsonField = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField = JsonMissing.of(), + @JsonProperty("compression") + @ExcludeMissing + compression: JsonField = JsonMissing.of(), + @JsonProperty("end_time") + @ExcludeMissing + endTime: JsonField = JsonMissing.of(), + @JsonProperty("filter") @ExcludeMissing filter: JsonField = JsonMissing.of(), + @JsonProperty("format") + @ExcludeMissing + format: JsonField = JsonMissing.of(), + @JsonProperty("interval_hours") + @ExcludeMissing + intervalHours: JsonField = JsonMissing.of(), + ) : this( + bulkExportDestinationId, + sessionId, + startTime, + compression, + endTime, + filter, + format, + intervalHours, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun bulkExportDestinationId(): String = + bulkExportDestinationId.getRequired("bulk_export_destination_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun sessionId(): String = sessionId.getRequired("session_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun startTime(): OffsetDateTime = startTime.getRequired("start_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun compression(): Optional = compression.getOptional("compression") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun endTime(): Optional = endTime.getOptional("end_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun filter(): Optional = filter.getOptional("filter") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun format(): Optional = format.getOptional("format") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun intervalHours(): Optional = intervalHours.getOptional("interval_hours") + + /** + * Returns the raw JSON value of [bulkExportDestinationId]. + * + * Unlike [bulkExportDestinationId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bulk_export_destination_id") + @ExcludeMissing + fun _bulkExportDestinationId(): JsonField = bulkExportDestinationId + + /** + * Returns the raw JSON value of [sessionId]. + * + * Unlike [sessionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session_id") @ExcludeMissing fun _sessionId(): JsonField = sessionId + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_time") + @ExcludeMissing + fun _startTime(): JsonField = startTime + + /** + * Returns the raw JSON value of [compression]. + * + * Unlike [compression], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("compression") + @ExcludeMissing + fun _compression(): JsonField = compression + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_time") + @ExcludeMissing + fun _endTime(): JsonField = endTime + + /** + * Returns the raw JSON value of [filter]. + * + * Unlike [filter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField = filter + + /** + * Returns the raw JSON value of [format]. + * + * Unlike [format], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("format") @ExcludeMissing fun _format(): JsonField = format + + /** + * Returns the raw JSON value of [intervalHours]. + * + * Unlike [intervalHours], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("interval_hours") + @ExcludeMissing + fun _intervalHours(): JsonField = intervalHours + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .bulkExportDestinationId() + * .sessionId() + * .startTime() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var bulkExportDestinationId: JsonField? = null + private var sessionId: JsonField? = null + private var startTime: JsonField? = null + private var compression: JsonField = JsonMissing.of() + private var endTime: JsonField = JsonMissing.of() + private var filter: JsonField = JsonMissing.of() + private var format: JsonField = JsonMissing.of() + private var intervalHours: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + bulkExportDestinationId = body.bulkExportDestinationId + sessionId = body.sessionId + startTime = body.startTime + compression = body.compression + endTime = body.endTime + filter = body.filter + format = body.format + intervalHours = body.intervalHours + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun bulkExportDestinationId(bulkExportDestinationId: String) = + bulkExportDestinationId(JsonField.of(bulkExportDestinationId)) + + /** + * Sets [Builder.bulkExportDestinationId] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkExportDestinationId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun bulkExportDestinationId(bulkExportDestinationId: JsonField) = apply { + this.bulkExportDestinationId = bulkExportDestinationId + } + + fun sessionId(sessionId: String) = sessionId(JsonField.of(sessionId)) + + /** + * Sets [Builder.sessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sessionId(sessionId: JsonField) = apply { this.sessionId = sessionId } + + fun startTime(startTime: OffsetDateTime) = startTime(JsonField.of(startTime)) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField) = apply { + this.startTime = startTime + } + + fun compression(compression: BulkExportCompression) = + compression(JsonField.of(compression)) + + /** + * Sets [Builder.compression] to an arbitrary JSON value. + * + * You should usually call [Builder.compression] with a well-typed + * [BulkExportCompression] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun compression(compression: JsonField) = apply { + this.compression = compression + } + + fun endTime(endTime: OffsetDateTime?) = endTime(JsonField.ofNullable(endTime)) + + /** Alias for calling [Builder.endTime] with `endTime.orElse(null)`. */ + fun endTime(endTime: Optional) = endTime(endTime.getOrNull()) + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endTime(endTime: JsonField) = apply { this.endTime = endTime } + + fun filter(filter: String?) = filter(JsonField.ofNullable(filter)) + + /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ + fun filter(filter: Optional) = filter(filter.getOrNull()) + + /** + * Sets [Builder.filter] to an arbitrary JSON value. + * + * You should usually call [Builder.filter] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun filter(filter: JsonField) = apply { this.filter = filter } + + fun format(format: BulkExportFormat) = format(JsonField.of(format)) + + /** + * Sets [Builder.format] to an arbitrary JSON value. + * + * You should usually call [Builder.format] with a well-typed [BulkExportFormat] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun format(format: JsonField) = apply { this.format = format } + + fun intervalHours(intervalHours: Long?) = + intervalHours(JsonField.ofNullable(intervalHours)) + + /** + * Alias for [Builder.intervalHours]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun intervalHours(intervalHours: Long) = intervalHours(intervalHours as Long?) + + /** Alias for calling [Builder.intervalHours] with `intervalHours.orElse(null)`. */ + fun intervalHours(intervalHours: Optional) = + intervalHours(intervalHours.getOrNull()) + + /** + * Sets [Builder.intervalHours] to an arbitrary JSON value. + * + * You should usually call [Builder.intervalHours] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun intervalHours(intervalHours: JsonField) = apply { + this.intervalHours = intervalHours + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bulkExportDestinationId() + * .sessionId() + * .startTime() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("bulkExportDestinationId", bulkExportDestinationId), + checkRequired("sessionId", sessionId), + checkRequired("startTime", startTime), + compression, + endTime, + filter, + format, + intervalHours, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + bulkExportDestinationId() + sessionId() + startTime() + compression().ifPresent { it.validate() } + endTime() + filter() + format().ifPresent { it.validate() } + intervalHours() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bulkExportDestinationId.asKnown().isPresent) 1 else 0) + + (if (sessionId.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + (compression.asKnown().getOrNull()?.validity() ?: 0) + + (if (endTime.asKnown().isPresent) 1 else 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (format.asKnown().getOrNull()?.validity() ?: 0) + + (if (intervalHours.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + bulkExportDestinationId == other.bulkExportDestinationId && + sessionId == other.sessionId && + startTime == other.startTime && + compression == other.compression && + endTime == other.endTime && + filter == other.filter && + format == other.format && + intervalHours == other.intervalHours && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkExportDestinationId, + sessionId, + startTime, + compression, + endTime, + filter, + format, + intervalHours, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{bulkExportDestinationId=$bulkExportDestinationId, sessionId=$sessionId, startTime=$startTime, compression=$compression, endTime=$endTime, filter=$filter, format=$format, intervalHours=$intervalHours, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkExportBulkExportsParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "BulkExportBulkExportsParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportCompression.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportCompression.kt new file mode 100644 index 00000000..67476594 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportCompression.kt @@ -0,0 +1,149 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.bulkexports + +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException + +class BulkExportCompression @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't match + * any known member, and you want to know that value. For example, if the SDK is on an older + * version than the API, then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val NONE = of("none") + + @JvmField val GZIP = of("gzip") + + @JvmField val SNAPPY = of("snappy") + + @JvmField val ZSTANDARD = of("zstandard") + + @JvmStatic fun of(value: String) = BulkExportCompression(JsonField.of(value)) + } + + /** An enum containing [BulkExportCompression]'s known values. */ + enum class Known { + NONE, + GZIP, + SNAPPY, + ZSTANDARD, + } + + /** + * An enum containing [BulkExportCompression]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BulkExportCompression] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the SDK + * is on an older version than the API, then the API may respond with new members that the SDK + * is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + NONE, + GZIP, + SNAPPY, + ZSTANDARD, + /** + * An enum member indicating that [BulkExportCompression] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if + * the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want to + * throw for the unknown case. + */ + fun value(): Value = + when (this) { + NONE -> Value.NONE + GZIP -> Value.GZIP + SNAPPY -> Value.SNAPPY + ZSTANDARD -> Value.ZSTANDARD + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't want + * to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + NONE -> Known.NONE + GZIP -> Known.GZIP + SNAPPY -> Known.SNAPPY + ZSTANDARD -> Known.ZSTANDARD + else -> throw LangsmithApiInvalidDataException("Unknown BulkExportCompression: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): BulkExportCompression = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkExportCompression && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportFormat.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportFormat.kt new file mode 100644 index 00000000..55243574 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportFormat.kt @@ -0,0 +1,130 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.bulkexports + +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException + +class BulkExportFormat @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't match + * any known member, and you want to know that value. For example, if the SDK is on an older + * version than the API, then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PARQUET = of("Parquet") + + @JvmStatic fun of(value: String) = BulkExportFormat(JsonField.of(value)) + } + + /** An enum containing [BulkExportFormat]'s known values. */ + enum class Known { + PARQUET + } + + /** + * An enum containing [BulkExportFormat]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BulkExportFormat] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the SDK + * is on an older version than the API, then the API may respond with new members that the SDK + * is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PARQUET, + /** + * An enum member indicating that [BulkExportFormat] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if + * the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want to + * throw for the unknown case. + */ + fun value(): Value = + when (this) { + PARQUET -> Value.PARQUET + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't want + * to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PARQUET -> Known.PARQUET + else -> throw LangsmithApiInvalidDataException("Unknown BulkExportFormat: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): BulkExportFormat = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkExportFormat && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportRetrieveBulkExportsParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportRetrieveBulkExportsParams.kt new file mode 100644 index 00000000..fcf0e050 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportRetrieveBulkExportsParams.kt @@ -0,0 +1,179 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.bulkexports + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** Get the current workspace's bulk exports */ +class BulkExportRetrieveBulkExportsParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): BulkExportRetrieveBulkExportsParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [BulkExportRetrieveBulkExportsParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkExportRetrieveBulkExportsParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + bulkExportRetrieveBulkExportsParams: BulkExportRetrieveBulkExportsParams + ) = apply { + additionalHeaders = bulkExportRetrieveBulkExportsParams.additionalHeaders.toBuilder() + additionalQueryParams = + bulkExportRetrieveBulkExportsParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [BulkExportRetrieveBulkExportsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BulkExportRetrieveBulkExportsParams = + BulkExportRetrieveBulkExportsParams( + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkExportRetrieveBulkExportsParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "BulkExportRetrieveBulkExportsParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportRetrieveParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportRetrieveParams.kt new file mode 100644 index 00000000..a79fa642 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportRetrieveParams.kt @@ -0,0 +1,194 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.bulkexports + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get a single bulk export by ID */ +class BulkExportRetrieveParams +private constructor( + private val bulkExportId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun bulkExportId(): Optional = Optional.ofNullable(bulkExportId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): BulkExportRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [BulkExportRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkExportRetrieveParams]. */ + class Builder internal constructor() { + + private var bulkExportId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(bulkExportRetrieveParams: BulkExportRetrieveParams) = apply { + bulkExportId = bulkExportRetrieveParams.bulkExportId + additionalHeaders = bulkExportRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = bulkExportRetrieveParams.additionalQueryParams.toBuilder() + } + + fun bulkExportId(bulkExportId: String?) = apply { this.bulkExportId = bulkExportId } + + /** Alias for calling [Builder.bulkExportId] with `bulkExportId.orElse(null)`. */ + fun bulkExportId(bulkExportId: Optional) = bulkExportId(bulkExportId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [BulkExportRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BulkExportRetrieveParams = + BulkExportRetrieveParams( + bulkExportId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> bulkExportId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkExportRetrieveParams && + bulkExportId == other.bulkExportId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(bulkExportId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "BulkExportRetrieveParams{bulkExportId=$bulkExportId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportUpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportUpdateParams.kt new file mode 100644 index 00000000..49765d9c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportUpdateParams.kt @@ -0,0 +1,295 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.bulkexports + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Cancel a bulk export by ID */ +class BulkExportUpdateParams +private constructor( + private val bulkExportId: String?, + private val body: JsonValue, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun bulkExportId(): Optional = Optional.ofNullable(bulkExportId) + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("Cancelled") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + fun _status(): JsonValue = body._status() + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): BulkExportUpdateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [BulkExportUpdateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkExportUpdateParams]. */ + class Builder internal constructor() { + + private var bulkExportId: String? = null + private var body: JsonValue.Builder = JsonValue.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkExportUpdateParams: BulkExportUpdateParams) = apply { + bulkExportId = bulkExportUpdateParams.bulkExportId + body = bulkExportUpdateParams.body.toBuilder() + additionalHeaders = bulkExportUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = bulkExportUpdateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + bulkExportUpdateParams.additionalBodyProperties.toMutableMap() + } + + fun bulkExportId(bulkExportId: String?) = apply { this.bulkExportId = bulkExportId } + + /** Alias for calling [Builder.bulkExportId] with `bulkExportId.orElse(null)`. */ + fun bulkExportId(bulkExportId: Optional) = bulkExportId(bulkExportId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [status] + */ + fun body(body: JsonValue) = apply { this.body = body.toBuilder() } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("Cancelled") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun status(status: JsonValue) = apply { body.status(status) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [BulkExportUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BulkExportUpdateParams = + BulkExportUpdateParams( + bulkExportId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): JsonValue = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> bulkExportId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkExportUpdateParams && + bulkExportId == other.bulkExportId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + bulkExportId, + body, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "BulkExportUpdateParams{bulkExportId=$bulkExportId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/BulkExportDestination.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/BulkExportDestination.kt new file mode 100644 index 00000000..ead110f3 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/BulkExportDestination.kt @@ -0,0 +1,479 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.bulkexports.destinations + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BulkExportDestination +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val config: JsonField, + private val createdAt: JsonField, + private val credentialsKeys: JsonField>, + private val displayName: JsonField, + private val tenantId: JsonField, + private val updatedAt: JsonField, + private val destinationType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("config") + @ExcludeMissing + config: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credentials_keys") + @ExcludeMissing + credentialsKeys: JsonField> = JsonMissing.of(), + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField = JsonMissing.of(), + @JsonProperty("tenant_id") @ExcludeMissing tenantId: JsonField = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), + @JsonProperty("destination_type") + @ExcludeMissing + destinationType: JsonField = JsonMissing.of(), + ) : this( + id, + config, + createdAt, + credentialsKeys, + displayName, + tenantId, + updatedAt, + destinationType, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun config(): BulkExportDestinationS3Config = config.getRequired("config") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun credentialsKeys(): List = credentialsKeys.getRequired("credentials_keys") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun displayName(): String = displayName.getRequired("display_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tenantId(): String = tenantId.getRequired("tenant_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updatedAt(): OffsetDateTime = updatedAt.getRequired("updated_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun destinationType(): Optional = + destinationType.getOptional("destination_type") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("config") + @ExcludeMissing + fun _config(): JsonField = config + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [credentialsKeys]. + * + * Unlike [credentialsKeys], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("credentials_keys") + @ExcludeMissing + fun _credentialsKeys(): JsonField> = credentialsKeys + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField = displayName + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_id") @ExcludeMissing fun _tenantId(): JsonField = tenantId + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField = updatedAt + + /** + * Returns the raw JSON value of [destinationType]. + * + * Unlike [destinationType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("destination_type") + @ExcludeMissing + fun _destinationType(): JsonField = destinationType + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BulkExportDestination]. + * + * The following fields are required: + * ```java + * .id() + * .config() + * .createdAt() + * .credentialsKeys() + * .displayName() + * .tenantId() + * .updatedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkExportDestination]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var config: JsonField? = null + private var createdAt: JsonField? = null + private var credentialsKeys: JsonField>? = null + private var displayName: JsonField? = null + private var tenantId: JsonField? = null + private var updatedAt: JsonField? = null + private var destinationType: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkExportDestination: BulkExportDestination) = apply { + id = bulkExportDestination.id + config = bulkExportDestination.config + createdAt = bulkExportDestination.createdAt + credentialsKeys = bulkExportDestination.credentialsKeys.map { it.toMutableList() } + displayName = bulkExportDestination.displayName + tenantId = bulkExportDestination.tenantId + updatedAt = bulkExportDestination.updatedAt + destinationType = bulkExportDestination.destinationType + additionalProperties = bulkExportDestination.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun config(config: BulkExportDestinationS3Config) = config(JsonField.of(config)) + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed + * [BulkExportDestinationS3Config] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun config(config: JsonField) = apply { + this.config = config + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + fun credentialsKeys(credentialsKeys: List) = + credentialsKeys(JsonField.of(credentialsKeys)) + + /** + * Sets [Builder.credentialsKeys] to an arbitrary JSON value. + * + * You should usually call [Builder.credentialsKeys] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun credentialsKeys(credentialsKeys: JsonField>) = apply { + this.credentialsKeys = credentialsKeys.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [credentialsKeys]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCredentialsKey(credentialsKey: String) = apply { + credentialsKeys = + (credentialsKeys ?: JsonField.of(mutableListOf())).also { + checkKnown("credentialsKeys", it).add(credentialsKey) + } + } + + fun displayName(displayName: String) = displayName(JsonField.of(displayName)) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun displayName(displayName: JsonField) = apply { this.displayName = displayName } + + fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tenantId(tenantId: JsonField) = apply { this.tenantId = tenantId } + + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } + + fun destinationType(destinationType: BulkExportDestinationType) = + destinationType(JsonField.of(destinationType)) + + /** + * Sets [Builder.destinationType] to an arbitrary JSON value. + * + * You should usually call [Builder.destinationType] with a well-typed + * [BulkExportDestinationType] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun destinationType(destinationType: JsonField) = apply { + this.destinationType = destinationType + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkExportDestination]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .config() + * .createdAt() + * .credentialsKeys() + * .displayName() + * .tenantId() + * .updatedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkExportDestination = + BulkExportDestination( + checkRequired("id", id), + checkRequired("config", config), + checkRequired("createdAt", createdAt), + checkRequired("credentialsKeys", credentialsKeys).map { it.toImmutable() }, + checkRequired("displayName", displayName), + checkRequired("tenantId", tenantId), + checkRequired("updatedAt", updatedAt), + destinationType, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkExportDestination = apply { + if (validated) { + return@apply + } + + id() + config().validate() + createdAt() + credentialsKeys() + displayName() + tenantId() + updatedAt() + destinationType().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (config.asKnown().getOrNull()?.validity() ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (credentialsKeys.asKnown().getOrNull()?.size ?: 0) + + (if (displayName.asKnown().isPresent) 1 else 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (destinationType.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkExportDestination && + id == other.id && + config == other.config && + createdAt == other.createdAt && + credentialsKeys == other.credentialsKeys && + displayName == other.displayName && + tenantId == other.tenantId && + updatedAt == other.updatedAt && + destinationType == other.destinationType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + config, + createdAt, + credentialsKeys, + displayName, + tenantId, + updatedAt, + destinationType, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkExportDestination{id=$id, config=$config, createdAt=$createdAt, credentialsKeys=$credentialsKeys, displayName=$displayName, tenantId=$tenantId, updatedAt=$updatedAt, destinationType=$destinationType, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/BulkExportDestinationS3Config.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/BulkExportDestinationS3Config.kt new file mode 100644 index 00000000..7019cff4 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/BulkExportDestinationS3Config.kt @@ -0,0 +1,297 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.bulkexports.destinations + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BulkExportDestinationS3Config +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val bucketName: JsonField, + private val endpointUrl: JsonField, + private val prefix: JsonField, + private val region: JsonField, + private val s3AdditionalKwargs: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("bucket_name") + @ExcludeMissing + bucketName: JsonField = JsonMissing.of(), + @JsonProperty("endpoint_url") + @ExcludeMissing + endpointUrl: JsonField = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), + @JsonProperty("region") @ExcludeMissing region: JsonField = JsonMissing.of(), + @JsonProperty("s3_additional_kwargs") + @ExcludeMissing + s3AdditionalKwargs: JsonValue = JsonMissing.of(), + ) : this(bucketName, endpointUrl, prefix, region, s3AdditionalKwargs, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun bucketName(): Optional = bucketName.getOptional("bucket_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endpointUrl(): Optional = endpointUrl.getOptional("endpoint_url") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun prefix(): Optional = prefix.getOptional("prefix") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun region(): Optional = region.getOptional("region") + + @JsonProperty("s3_additional_kwargs") + @ExcludeMissing + fun _s3AdditionalKwargs(): JsonValue = s3AdditionalKwargs + + /** + * Returns the raw JSON value of [bucketName]. + * + * Unlike [bucketName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("bucket_name") @ExcludeMissing fun _bucketName(): JsonField = bucketName + + /** + * Returns the raw JSON value of [endpointUrl]. + * + * Unlike [endpointUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("endpoint_url") + @ExcludeMissing + fun _endpointUrl(): JsonField = endpointUrl + + /** + * Returns the raw JSON value of [prefix]. + * + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix + + /** + * Returns the raw JSON value of [region]. + * + * Unlike [region], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("region") @ExcludeMissing fun _region(): JsonField = region + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BulkExportDestinationS3Config]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkExportDestinationS3Config]. */ + class Builder internal constructor() { + + private var bucketName: JsonField = JsonMissing.of() + private var endpointUrl: JsonField = JsonMissing.of() + private var prefix: JsonField = JsonMissing.of() + private var region: JsonField = JsonMissing.of() + private var s3AdditionalKwargs: JsonValue = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkExportDestinationS3Config: BulkExportDestinationS3Config) = apply { + bucketName = bulkExportDestinationS3Config.bucketName + endpointUrl = bulkExportDestinationS3Config.endpointUrl + prefix = bulkExportDestinationS3Config.prefix + region = bulkExportDestinationS3Config.region + s3AdditionalKwargs = bulkExportDestinationS3Config.s3AdditionalKwargs + additionalProperties = bulkExportDestinationS3Config.additionalProperties.toMutableMap() + } + + fun bucketName(bucketName: String?) = bucketName(JsonField.ofNullable(bucketName)) + + /** Alias for calling [Builder.bucketName] with `bucketName.orElse(null)`. */ + fun bucketName(bucketName: Optional) = bucketName(bucketName.getOrNull()) + + /** + * Sets [Builder.bucketName] to an arbitrary JSON value. + * + * You should usually call [Builder.bucketName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun bucketName(bucketName: JsonField) = apply { this.bucketName = bucketName } + + fun endpointUrl(endpointUrl: String?) = endpointUrl(JsonField.ofNullable(endpointUrl)) + + /** Alias for calling [Builder.endpointUrl] with `endpointUrl.orElse(null)`. */ + fun endpointUrl(endpointUrl: Optional) = endpointUrl(endpointUrl.getOrNull()) + + /** + * Sets [Builder.endpointUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.endpointUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun endpointUrl(endpointUrl: JsonField) = apply { this.endpointUrl = endpointUrl } + + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) + + /** + * Sets [Builder.prefix] to an arbitrary JSON value. + * + * You should usually call [Builder.prefix] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun prefix(prefix: JsonField) = apply { this.prefix = prefix } + + fun region(region: String?) = region(JsonField.ofNullable(region)) + + /** Alias for calling [Builder.region] with `region.orElse(null)`. */ + fun region(region: Optional) = region(region.getOrNull()) + + /** + * Sets [Builder.region] to an arbitrary JSON value. + * + * You should usually call [Builder.region] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun region(region: JsonField) = apply { this.region = region } + + fun s3AdditionalKwargs(s3AdditionalKwargs: JsonValue) = apply { + this.s3AdditionalKwargs = s3AdditionalKwargs + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkExportDestinationS3Config]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BulkExportDestinationS3Config = + BulkExportDestinationS3Config( + bucketName, + endpointUrl, + prefix, + region, + s3AdditionalKwargs, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkExportDestinationS3Config = apply { + if (validated) { + return@apply + } + + bucketName() + endpointUrl() + prefix() + region() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bucketName.asKnown().isPresent) 1 else 0) + + (if (endpointUrl.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + + (if (region.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkExportDestinationS3Config && + bucketName == other.bucketName && + endpointUrl == other.endpointUrl && + prefix == other.prefix && + region == other.region && + s3AdditionalKwargs == other.s3AdditionalKwargs && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bucketName, + endpointUrl, + prefix, + region, + s3AdditionalKwargs, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkExportDestinationS3Config{bucketName=$bucketName, endpointUrl=$endpointUrl, prefix=$prefix, region=$region, s3AdditionalKwargs=$s3AdditionalKwargs, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/BulkExportDestinationType.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/BulkExportDestinationType.kt new file mode 100644 index 00000000..f2ac9628 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/BulkExportDestinationType.kt @@ -0,0 +1,134 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.bulkexports.destinations + +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException + +class BulkExportDestinationType +@JsonCreator +private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't match + * any known member, and you want to know that value. For example, if the SDK is on an older + * version than the API, then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val S3 = of("s3") + + @JvmStatic fun of(value: String) = BulkExportDestinationType(JsonField.of(value)) + } + + /** An enum containing [BulkExportDestinationType]'s known values. */ + enum class Known { + S3 + } + + /** + * An enum containing [BulkExportDestinationType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [BulkExportDestinationType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the SDK + * is on an older version than the API, then the API may respond with new members that the SDK + * is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + S3, + /** + * An enum member indicating that [BulkExportDestinationType] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if + * the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want to + * throw for the unknown case. + */ + fun value(): Value = + when (this) { + S3 -> Value.S3 + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't want + * to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + S3 -> Known.S3 + else -> + throw LangsmithApiInvalidDataException("Unknown BulkExportDestinationType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): BulkExportDestinationType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkExportDestinationType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/DestinationCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/DestinationCreateParams.kt new file mode 100644 index 00000000..f3dac8e9 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/DestinationCreateParams.kt @@ -0,0 +1,887 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.bulkexports.destinations + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create a new bulk export destination */ +class DestinationCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun config(): BulkExportDestinationS3Config = body.config() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun displayName(): String = body.displayName() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun credentials(): Optional = body.credentials() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun destinationType(): Optional = body.destinationType() + + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _config(): JsonField = body._config() + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _displayName(): JsonField = body._displayName() + + /** + * Returns the raw JSON value of [credentials]. + * + * Unlike [credentials], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _credentials(): JsonField = body._credentials() + + /** + * Returns the raw JSON value of [destinationType]. + * + * Unlike [destinationType], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _destinationType(): JsonField = body._destinationType() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DestinationCreateParams]. + * + * The following fields are required: + * ```java + * .config() + * .displayName() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DestinationCreateParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(destinationCreateParams: DestinationCreateParams) = apply { + body = destinationCreateParams.body.toBuilder() + additionalHeaders = destinationCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = destinationCreateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [config] + * - [displayName] + * - [credentials] + * - [destinationType] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun config(config: BulkExportDestinationS3Config) = apply { body.config(config) } + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed + * [BulkExportDestinationS3Config] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun config(config: JsonField) = apply { body.config(config) } + + fun displayName(displayName: String) = apply { body.displayName(displayName) } + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun displayName(displayName: JsonField) = apply { body.displayName(displayName) } + + fun credentials(credentials: Credentials?) = apply { body.credentials(credentials) } + + /** Alias for calling [Builder.credentials] with `credentials.orElse(null)`. */ + fun credentials(credentials: Optional) = credentials(credentials.getOrNull()) + + /** + * Sets [Builder.credentials] to an arbitrary JSON value. + * + * You should usually call [Builder.credentials] with a well-typed [Credentials] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun credentials(credentials: JsonField) = apply { + body.credentials(credentials) + } + + fun destinationType(destinationType: BulkExportDestinationType) = apply { + body.destinationType(destinationType) + } + + /** + * Sets [Builder.destinationType] to an arbitrary JSON value. + * + * You should usually call [Builder.destinationType] with a well-typed + * [BulkExportDestinationType] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun destinationType(destinationType: JsonField) = apply { + body.destinationType(destinationType) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [DestinationCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .config() + * .displayName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DestinationCreateParams = + DestinationCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val config: JsonField, + private val displayName: JsonField, + private val credentials: JsonField, + private val destinationType: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("config") + @ExcludeMissing + config: JsonField = JsonMissing.of(), + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField = JsonMissing.of(), + @JsonProperty("credentials") + @ExcludeMissing + credentials: JsonField = JsonMissing.of(), + @JsonProperty("destination_type") + @ExcludeMissing + destinationType: JsonField = JsonMissing.of(), + ) : this(config, displayName, credentials, destinationType, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun config(): BulkExportDestinationS3Config = config.getRequired("config") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun displayName(): String = displayName.getRequired("display_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun credentials(): Optional = credentials.getOptional("credentials") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun destinationType(): Optional = + destinationType.getOptional("destination_type") + + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("config") + @ExcludeMissing + fun _config(): JsonField = config + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField = displayName + + /** + * Returns the raw JSON value of [credentials]. + * + * Unlike [credentials], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("credentials") + @ExcludeMissing + fun _credentials(): JsonField = credentials + + /** + * Returns the raw JSON value of [destinationType]. + * + * Unlike [destinationType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("destination_type") + @ExcludeMissing + fun _destinationType(): JsonField = destinationType + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .config() + * .displayName() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var config: JsonField? = null + private var displayName: JsonField? = null + private var credentials: JsonField = JsonMissing.of() + private var destinationType: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + config = body.config + displayName = body.displayName + credentials = body.credentials + destinationType = body.destinationType + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun config(config: BulkExportDestinationS3Config) = config(JsonField.of(config)) + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed + * [BulkExportDestinationS3Config] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun config(config: JsonField) = apply { + this.config = config + } + + fun displayName(displayName: String) = displayName(JsonField.of(displayName)) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun displayName(displayName: JsonField) = apply { + this.displayName = displayName + } + + fun credentials(credentials: Credentials?) = + credentials(JsonField.ofNullable(credentials)) + + /** Alias for calling [Builder.credentials] with `credentials.orElse(null)`. */ + fun credentials(credentials: Optional) = + credentials(credentials.getOrNull()) + + /** + * Sets [Builder.credentials] to an arbitrary JSON value. + * + * You should usually call [Builder.credentials] with a well-typed [Credentials] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun credentials(credentials: JsonField) = apply { + this.credentials = credentials + } + + fun destinationType(destinationType: BulkExportDestinationType) = + destinationType(JsonField.of(destinationType)) + + /** + * Sets [Builder.destinationType] to an arbitrary JSON value. + * + * You should usually call [Builder.destinationType] with a well-typed + * [BulkExportDestinationType] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun destinationType(destinationType: JsonField) = apply { + this.destinationType = destinationType + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .config() + * .displayName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("config", config), + checkRequired("displayName", displayName), + credentials, + destinationType, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + config().validate() + displayName() + credentials().ifPresent { it.validate() } + destinationType().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (config.asKnown().getOrNull()?.validity() ?: 0) + + (if (displayName.asKnown().isPresent) 1 else 0) + + (credentials.asKnown().getOrNull()?.validity() ?: 0) + + (destinationType.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + config == other.config && + displayName == other.displayName && + credentials == other.credentials && + destinationType == other.destinationType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(config, displayName, credentials, destinationType, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{config=$config, displayName=$displayName, credentials=$credentials, destinationType=$destinationType, additionalProperties=$additionalProperties}" + } + + class Credentials + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val accessKeyId: JsonField, + private val secretAccessKey: JsonField, + private val sessionToken: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("access_key_id") + @ExcludeMissing + accessKeyId: JsonField = JsonMissing.of(), + @JsonProperty("secret_access_key") + @ExcludeMissing + secretAccessKey: JsonField = JsonMissing.of(), + @JsonProperty("session_token") + @ExcludeMissing + sessionToken: JsonField = JsonMissing.of(), + ) : this(accessKeyId, secretAccessKey, sessionToken, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun accessKeyId(): String = accessKeyId.getRequired("access_key_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun secretAccessKey(): String = secretAccessKey.getRequired("secret_access_key") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun sessionToken(): Optional = sessionToken.getOptional("session_token") + + /** + * Returns the raw JSON value of [accessKeyId]. + * + * Unlike [accessKeyId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("access_key_id") + @ExcludeMissing + fun _accessKeyId(): JsonField = accessKeyId + + /** + * Returns the raw JSON value of [secretAccessKey]. + * + * Unlike [secretAccessKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("secret_access_key") + @ExcludeMissing + fun _secretAccessKey(): JsonField = secretAccessKey + + /** + * Returns the raw JSON value of [sessionToken]. + * + * Unlike [sessionToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("session_token") + @ExcludeMissing + fun _sessionToken(): JsonField = sessionToken + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Credentials]. + * + * The following fields are required: + * ```java + * .accessKeyId() + * .secretAccessKey() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Credentials]. */ + class Builder internal constructor() { + + private var accessKeyId: JsonField? = null + private var secretAccessKey: JsonField? = null + private var sessionToken: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(credentials: Credentials) = apply { + accessKeyId = credentials.accessKeyId + secretAccessKey = credentials.secretAccessKey + sessionToken = credentials.sessionToken + additionalProperties = credentials.additionalProperties.toMutableMap() + } + + fun accessKeyId(accessKeyId: String) = accessKeyId(JsonField.of(accessKeyId)) + + /** + * Sets [Builder.accessKeyId] to an arbitrary JSON value. + * + * You should usually call [Builder.accessKeyId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun accessKeyId(accessKeyId: JsonField) = apply { + this.accessKeyId = accessKeyId + } + + fun secretAccessKey(secretAccessKey: String) = + secretAccessKey(JsonField.of(secretAccessKey)) + + /** + * Sets [Builder.secretAccessKey] to an arbitrary JSON value. + * + * You should usually call [Builder.secretAccessKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun secretAccessKey(secretAccessKey: JsonField) = apply { + this.secretAccessKey = secretAccessKey + } + + fun sessionToken(sessionToken: String?) = + sessionToken(JsonField.ofNullable(sessionToken)) + + /** Alias for calling [Builder.sessionToken] with `sessionToken.orElse(null)`. */ + fun sessionToken(sessionToken: Optional) = + sessionToken(sessionToken.getOrNull()) + + /** + * Sets [Builder.sessionToken] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sessionToken(sessionToken: JsonField) = apply { + this.sessionToken = sessionToken + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Credentials]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accessKeyId() + * .secretAccessKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Credentials = + Credentials( + checkRequired("accessKeyId", accessKeyId), + checkRequired("secretAccessKey", secretAccessKey), + sessionToken, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Credentials = apply { + if (validated) { + return@apply + } + + accessKeyId() + secretAccessKey() + sessionToken() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (accessKeyId.asKnown().isPresent) 1 else 0) + + (if (secretAccessKey.asKnown().isPresent) 1 else 0) + + (if (sessionToken.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Credentials && + accessKeyId == other.accessKeyId && + secretAccessKey == other.secretAccessKey && + sessionToken == other.sessionToken && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(accessKeyId, secretAccessKey, sessionToken, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Credentials{accessKeyId=$accessKeyId, secretAccessKey=$secretAccessKey, sessionToken=$sessionToken, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DestinationCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "DestinationCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/DestinationListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/DestinationListParams.kt new file mode 100644 index 00000000..6fed3e1c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/DestinationListParams.kt @@ -0,0 +1,170 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.bulkexports.destinations + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** Get the current workspace's bulk export destinations */ +class DestinationListParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): DestinationListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [DestinationListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DestinationListParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(destinationListParams: DestinationListParams) = apply { + additionalHeaders = destinationListParams.additionalHeaders.toBuilder() + additionalQueryParams = destinationListParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [DestinationListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DestinationListParams = + DestinationListParams(additionalHeaders.build(), additionalQueryParams.build()) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DestinationListParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "DestinationListParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/DestinationRetrieveParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/DestinationRetrieveParams.kt new file mode 100644 index 00000000..115b2f5a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/DestinationRetrieveParams.kt @@ -0,0 +1,197 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.bulkexports.destinations + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get a single bulk export destination by ID */ +class DestinationRetrieveParams +private constructor( + private val destinationId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun destinationId(): Optional = Optional.ofNullable(destinationId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): DestinationRetrieveParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [DestinationRetrieveParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DestinationRetrieveParams]. */ + class Builder internal constructor() { + + private var destinationId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(destinationRetrieveParams: DestinationRetrieveParams) = apply { + destinationId = destinationRetrieveParams.destinationId + additionalHeaders = destinationRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = destinationRetrieveParams.additionalQueryParams.toBuilder() + } + + fun destinationId(destinationId: String?) = apply { this.destinationId = destinationId } + + /** Alias for calling [Builder.destinationId] with `destinationId.orElse(null)`. */ + fun destinationId(destinationId: Optional) = + destinationId(destinationId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [DestinationRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DestinationRetrieveParams = + DestinationRetrieveParams( + destinationId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> destinationId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DestinationRetrieveParams && + destinationId == other.destinationId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(destinationId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "DestinationRetrieveParams{destinationId=$destinationId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/runs/BulkExportRun.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/runs/BulkExportRun.kt new file mode 100644 index 00000000..7b154919 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/runs/BulkExportRun.kt @@ -0,0 +1,1216 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.bulkexports.runs + +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.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BulkExportRun +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val bulkExportId: JsonField, + private val createdAt: JsonField, + private val finishedAt: JsonField, + private val metadata: JsonField, + private val status: JsonField, + private val updatedAt: JsonField, + private val errors: JsonValue, + private val retryNumber: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("bulk_export_id") + @ExcludeMissing + bulkExportId: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("finished_at") + @ExcludeMissing + finishedAt: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), + @JsonProperty("errors") @ExcludeMissing errors: JsonValue = JsonMissing.of(), + @JsonProperty("retry_number") + @ExcludeMissing + retryNumber: JsonField = JsonMissing.of(), + ) : this( + id, + bulkExportId, + createdAt, + finishedAt, + metadata, + status, + updatedAt, + errors, + retryNumber, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun bulkExportId(): String = bulkExportId.getRequired("bulk_export_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun finishedAt(): Optional = finishedAt.getOptional("finished_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updatedAt(): OffsetDateTime = updatedAt.getRequired("updated_at") + + @JsonProperty("errors") @ExcludeMissing fun _errors(): JsonValue = errors + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun retryNumber(): Optional = retryNumber.getOptional("retry_number") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [bulkExportId]. + * + * Unlike [bulkExportId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("bulk_export_id") + @ExcludeMissing + fun _bulkExportId(): JsonField = bulkExportId + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [finishedAt]. + * + * Unlike [finishedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("finished_at") + @ExcludeMissing + fun _finishedAt(): JsonField = finishedAt + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField = updatedAt + + /** + * Returns the raw JSON value of [retryNumber]. + * + * Unlike [retryNumber], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("retry_number") @ExcludeMissing fun _retryNumber(): JsonField = retryNumber + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BulkExportRun]. + * + * The following fields are required: + * ```java + * .id() + * .bulkExportId() + * .createdAt() + * .finishedAt() + * .metadata() + * .status() + * .updatedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkExportRun]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var bulkExportId: JsonField? = null + private var createdAt: JsonField? = null + private var finishedAt: JsonField? = null + private var metadata: JsonField? = null + private var status: JsonField? = null + private var updatedAt: JsonField? = null + private var errors: JsonValue = JsonMissing.of() + private var retryNumber: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkExportRun: BulkExportRun) = apply { + id = bulkExportRun.id + bulkExportId = bulkExportRun.bulkExportId + createdAt = bulkExportRun.createdAt + finishedAt = bulkExportRun.finishedAt + metadata = bulkExportRun.metadata + status = bulkExportRun.status + updatedAt = bulkExportRun.updatedAt + errors = bulkExportRun.errors + retryNumber = bulkExportRun.retryNumber + additionalProperties = bulkExportRun.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun bulkExportId(bulkExportId: String) = bulkExportId(JsonField.of(bulkExportId)) + + /** + * Sets [Builder.bulkExportId] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkExportId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun bulkExportId(bulkExportId: JsonField) = apply { + this.bulkExportId = bulkExportId + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + fun finishedAt(finishedAt: OffsetDateTime?) = finishedAt(JsonField.ofNullable(finishedAt)) + + /** Alias for calling [Builder.finishedAt] with `finishedAt.orElse(null)`. */ + fun finishedAt(finishedAt: Optional) = finishedAt(finishedAt.getOrNull()) + + /** + * Sets [Builder.finishedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.finishedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun finishedAt(finishedAt: JsonField) = apply { + this.finishedAt = finishedAt + } + + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } + + fun errors(errors: JsonValue) = apply { this.errors = errors } + + fun retryNumber(retryNumber: Long) = retryNumber(JsonField.of(retryNumber)) + + /** + * Sets [Builder.retryNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.retryNumber] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun retryNumber(retryNumber: JsonField) = apply { this.retryNumber = retryNumber } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkExportRun]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .bulkExportId() + * .createdAt() + * .finishedAt() + * .metadata() + * .status() + * .updatedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkExportRun = + BulkExportRun( + checkRequired("id", id), + checkRequired("bulkExportId", bulkExportId), + checkRequired("createdAt", createdAt), + checkRequired("finishedAt", finishedAt), + checkRequired("metadata", metadata), + checkRequired("status", status), + checkRequired("updatedAt", updatedAt), + errors, + retryNumber, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkExportRun = apply { + if (validated) { + return@apply + } + + id() + bulkExportId() + createdAt() + finishedAt() + metadata().validate() + status().validate() + updatedAt() + retryNumber() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (bulkExportId.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (finishedAt.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (if (retryNumber.asKnown().isPresent) 1 else 0) + + class Metadata + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val endTime: JsonField, + private val prefix: JsonField, + private val startTime: JsonField, + private val result: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("end_time") + @ExcludeMissing + endTime: JsonField = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField = JsonMissing.of(), + @JsonProperty("result") @ExcludeMissing result: JsonField = JsonMissing.of(), + ) : this(endTime, prefix, startTime, result, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun endTime(): OffsetDateTime = endTime.getRequired("end_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun prefix(): String = prefix.getRequired("prefix") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun startTime(): OffsetDateTime = startTime.getRequired("start_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun result(): Optional = result.getOptional("result") + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_time") + @ExcludeMissing + fun _endTime(): JsonField = endTime + + /** + * Returns the raw JSON value of [prefix]. + * + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_time") + @ExcludeMissing + fun _startTime(): JsonField = startTime + + /** + * Returns the raw JSON value of [result]. + * + * Unlike [result], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Metadata]. + * + * The following fields are required: + * ```java + * .endTime() + * .prefix() + * .startTime() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var endTime: JsonField? = null + private var prefix: JsonField? = null + private var startTime: JsonField? = null + private var result: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + endTime = metadata.endTime + prefix = metadata.prefix + startTime = metadata.startTime + result = metadata.result + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun endTime(endTime: OffsetDateTime) = endTime(JsonField.of(endTime)) + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endTime(endTime: JsonField) = apply { this.endTime = endTime } + + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) + + /** + * Sets [Builder.prefix] to an arbitrary JSON value. + * + * You should usually call [Builder.prefix] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun prefix(prefix: JsonField) = apply { this.prefix = prefix } + + fun startTime(startTime: OffsetDateTime) = startTime(JsonField.of(startTime)) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField) = apply { + this.startTime = startTime + } + + fun result(result: Result?) = result(JsonField.ofNullable(result)) + + /** Alias for calling [Builder.result] with `result.orElse(null)`. */ + fun result(result: Optional) = result(result.getOrNull()) + + /** + * Sets [Builder.result] to an arbitrary JSON value. + * + * You should usually call [Builder.result] with a well-typed [Result] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun result(result: JsonField) = apply { this.result = result } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .endTime() + * .prefix() + * .startTime() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Metadata = + Metadata( + checkRequired("endTime", endTime), + checkRequired("prefix", prefix), + checkRequired("startTime", startTime), + result, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + endTime() + prefix() + startTime() + result().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (endTime.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + (result.asKnown().getOrNull()?.validity() ?: 0) + + class Result + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val exportPath: JsonField, + private val exportedFiles: JsonField>, + private val latestCursor: JsonField, + private val rowsWritten: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("export_path") + @ExcludeMissing + exportPath: JsonField = JsonMissing.of(), + @JsonProperty("exported_files") + @ExcludeMissing + exportedFiles: JsonField> = JsonMissing.of(), + @JsonProperty("latest_cursor") + @ExcludeMissing + latestCursor: JsonField = JsonMissing.of(), + @JsonProperty("rows_written") + @ExcludeMissing + rowsWritten: JsonField = JsonMissing.of(), + ) : this(exportPath, exportedFiles, latestCursor, rowsWritten, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun exportPath(): String = exportPath.getRequired("export_path") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun exportedFiles(): List = exportedFiles.getRequired("exported_files") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun latestCursor(): Optional = latestCursor.getOptional("latest_cursor") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun rowsWritten(): Long = rowsWritten.getRequired("rows_written") + + /** + * Returns the raw JSON value of [exportPath]. + * + * Unlike [exportPath], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("export_path") + @ExcludeMissing + fun _exportPath(): JsonField = exportPath + + /** + * Returns the raw JSON value of [exportedFiles]. + * + * Unlike [exportedFiles], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("exported_files") + @ExcludeMissing + fun _exportedFiles(): JsonField> = exportedFiles + + /** + * Returns the raw JSON value of [latestCursor]. + * + * Unlike [latestCursor], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("latest_cursor") + @ExcludeMissing + fun _latestCursor(): JsonField = latestCursor + + /** + * Returns the raw JSON value of [rowsWritten]. + * + * Unlike [rowsWritten], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("rows_written") + @ExcludeMissing + fun _rowsWritten(): JsonField = rowsWritten + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Result]. + * + * The following fields are required: + * ```java + * .exportPath() + * .exportedFiles() + * .latestCursor() + * .rowsWritten() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Result]. */ + class Builder internal constructor() { + + private var exportPath: JsonField? = null + private var exportedFiles: JsonField>? = null + private var latestCursor: JsonField? = null + private var rowsWritten: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(result: Result) = apply { + exportPath = result.exportPath + exportedFiles = result.exportedFiles.map { it.toMutableList() } + latestCursor = result.latestCursor + rowsWritten = result.rowsWritten + additionalProperties = result.additionalProperties.toMutableMap() + } + + fun exportPath(exportPath: String) = exportPath(JsonField.of(exportPath)) + + /** + * Sets [Builder.exportPath] to an arbitrary JSON value. + * + * You should usually call [Builder.exportPath] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun exportPath(exportPath: JsonField) = apply { + this.exportPath = exportPath + } + + fun exportedFiles(exportedFiles: List) = + exportedFiles(JsonField.of(exportedFiles)) + + /** + * Sets [Builder.exportedFiles] to an arbitrary JSON value. + * + * You should usually call [Builder.exportedFiles] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun exportedFiles(exportedFiles: JsonField>) = apply { + this.exportedFiles = exportedFiles.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [exportedFiles]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExportedFile(exportedFile: String) = apply { + exportedFiles = + (exportedFiles ?: JsonField.of(mutableListOf())).also { + checkKnown("exportedFiles", it).add(exportedFile) + } + } + + fun latestCursor(latestCursor: String?) = + latestCursor(JsonField.ofNullable(latestCursor)) + + /** Alias for calling [Builder.latestCursor] with `latestCursor.orElse(null)`. */ + fun latestCursor(latestCursor: Optional) = + latestCursor(latestCursor.getOrNull()) + + /** + * Sets [Builder.latestCursor] to an arbitrary JSON value. + * + * You should usually call [Builder.latestCursor] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun latestCursor(latestCursor: JsonField) = apply { + this.latestCursor = latestCursor + } + + fun rowsWritten(rowsWritten: Long) = rowsWritten(JsonField.of(rowsWritten)) + + /** + * Sets [Builder.rowsWritten] to an arbitrary JSON value. + * + * You should usually call [Builder.rowsWritten] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun rowsWritten(rowsWritten: JsonField) = apply { + this.rowsWritten = rowsWritten + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Result]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .exportPath() + * .exportedFiles() + * .latestCursor() + * .rowsWritten() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Result = + Result( + checkRequired("exportPath", exportPath), + checkRequired("exportedFiles", exportedFiles).map { it.toImmutable() }, + checkRequired("latestCursor", latestCursor), + checkRequired("rowsWritten", rowsWritten), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Result = apply { + if (validated) { + return@apply + } + + exportPath() + exportedFiles() + latestCursor() + rowsWritten() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (exportPath.asKnown().isPresent) 1 else 0) + + (exportedFiles.asKnown().getOrNull()?.size ?: 0) + + (if (latestCursor.asKnown().isPresent) 1 else 0) + + (if (rowsWritten.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Result && + exportPath == other.exportPath && + exportedFiles == other.exportedFiles && + latestCursor == other.latestCursor && + rowsWritten == other.rowsWritten && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + exportPath, + exportedFiles, + latestCursor, + rowsWritten, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Result{exportPath=$exportPath, exportedFiles=$exportedFiles, latestCursor=$latestCursor, rowsWritten=$rowsWritten, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + endTime == other.endTime && + prefix == other.prefix && + startTime == other.startTime && + result == other.result && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(endTime, prefix, startTime, result, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Metadata{endTime=$endTime, prefix=$prefix, startTime=$startTime, result=$result, additionalProperties=$additionalProperties}" + } + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CANCELLED = of("Cancelled") + + @JvmField val COMPLETED = of("Completed") + + @JvmField val CREATED = of("Created") + + @JvmField val FAILED = of("Failed") + + @JvmField val TIMED_OUT = of("TimedOut") + + @JvmField val RUNNING = of("Running") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + CANCELLED, + COMPLETED, + CREATED, + FAILED, + TIMED_OUT, + RUNNING, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CANCELLED, + COMPLETED, + CREATED, + FAILED, + TIMED_OUT, + RUNNING, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CANCELLED -> Value.CANCELLED + COMPLETED -> Value.COMPLETED + CREATED -> Value.CREATED + FAILED -> Value.FAILED + TIMED_OUT -> Value.TIMED_OUT + RUNNING -> Value.RUNNING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CANCELLED -> Known.CANCELLED + COMPLETED -> Known.COMPLETED + CREATED -> Known.CREATED + FAILED -> Known.FAILED + TIMED_OUT -> Known.TIMED_OUT + RUNNING -> Known.RUNNING + else -> throw LangsmithApiInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkExportRun && + id == other.id && + bulkExportId == other.bulkExportId && + createdAt == other.createdAt && + finishedAt == other.finishedAt && + metadata == other.metadata && + status == other.status && + updatedAt == other.updatedAt && + errors == other.errors && + retryNumber == other.retryNumber && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + bulkExportId, + createdAt, + finishedAt, + metadata, + status, + updatedAt, + errors, + retryNumber, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkExportRun{id=$id, bulkExportId=$bulkExportId, createdAt=$createdAt, finishedAt=$finishedAt, metadata=$metadata, status=$status, updatedAt=$updatedAt, errors=$errors, retryNumber=$retryNumber, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/runs/RunListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/runs/RunListParams.kt new file mode 100644 index 00000000..a1c8772b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/runs/RunListParams.kt @@ -0,0 +1,190 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.bulkexports.runs + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get a bulk export's runs */ +class RunListParams +private constructor( + private val bulkExportId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun bulkExportId(): Optional = Optional.ofNullable(bulkExportId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): RunListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [RunListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunListParams]. */ + class Builder internal constructor() { + + private var bulkExportId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(runListParams: RunListParams) = apply { + bulkExportId = runListParams.bulkExportId + additionalHeaders = runListParams.additionalHeaders.toBuilder() + additionalQueryParams = runListParams.additionalQueryParams.toBuilder() + } + + fun bulkExportId(bulkExportId: String?) = apply { this.bulkExportId = bulkExportId } + + /** Alias for calling [Builder.bulkExportId] with `bulkExportId.orElse(null)`. */ + fun bulkExportId(bulkExportId: Optional) = bulkExportId(bulkExportId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RunListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RunListParams = + RunListParams(bulkExportId, additionalHeaders.build(), additionalQueryParams.build()) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> bulkExportId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunListParams && + bulkExportId == other.bulkExportId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(bulkExportId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "RunListParams{bulkExportId=$bulkExportId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/runs/RunRetrieveParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/runs/RunRetrieveParams.kt new file mode 100644 index 00000000..7573bdeb --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/runs/RunRetrieveParams.kt @@ -0,0 +1,217 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.bulkexports.runs + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get a single bulk export's run by ID */ +class RunRetrieveParams +private constructor( + private val bulkExportId: String, + private val runId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun bulkExportId(): String = bulkExportId + + fun runId(): Optional = Optional.ofNullable(runId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RunRetrieveParams]. + * + * The following fields are required: + * ```java + * .bulkExportId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunRetrieveParams]. */ + class Builder internal constructor() { + + private var bulkExportId: String? = null + private var runId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(runRetrieveParams: RunRetrieveParams) = apply { + bulkExportId = runRetrieveParams.bulkExportId + runId = runRetrieveParams.runId + additionalHeaders = runRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = runRetrieveParams.additionalQueryParams.toBuilder() + } + + fun bulkExportId(bulkExportId: String) = apply { this.bulkExportId = bulkExportId } + + fun runId(runId: String?) = apply { this.runId = runId } + + /** Alias for calling [Builder.runId] with `runId.orElse(null)`. */ + fun runId(runId: Optional) = runId(runId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RunRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bulkExportId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RunRetrieveParams = + RunRetrieveParams( + checkRequired("bulkExportId", bulkExportId), + runId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> bulkExportId + 1 -> runId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunRetrieveParams && + bulkExportId == other.bulkExportId && + runId == other.runId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(bulkExportId, runId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "RunRetrieveParams{bulkExportId=$bulkExportId, runId=$runId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartCreateParams.kt new file mode 100644 index 00000000..5d1e6542 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartCreateParams.kt @@ -0,0 +1,204 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** Create a new chart. */ +class ChartCreateParams +private constructor( + private val customChartCreate: CustomChartCreate, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun customChartCreate(): CustomChartCreate = customChartCreate + + fun _additionalBodyProperties(): Map = + customChartCreate._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ChartCreateParams]. + * + * The following fields are required: + * ```java + * .customChartCreate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChartCreateParams]. */ + class Builder internal constructor() { + + private var customChartCreate: CustomChartCreate? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(chartCreateParams: ChartCreateParams) = apply { + customChartCreate = chartCreateParams.customChartCreate + additionalHeaders = chartCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = chartCreateParams.additionalQueryParams.toBuilder() + } + + fun customChartCreate(customChartCreate: CustomChartCreate) = apply { + this.customChartCreate = customChartCreate + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ChartCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .customChartCreate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChartCreateParams = + ChartCreateParams( + checkRequired("customChartCreate", customChartCreate), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): CustomChartCreate = customChartCreate + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChartCreateParams && + customChartCreate == other.customChartCreate && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(customChartCreate, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ChartCreateParams{customChartCreate=$customChartCreate, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartDeleteParams.kt new file mode 100644 index 00000000..4a6bf66f --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartDeleteParams.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete a chart. */ +class ChartDeleteParams +private constructor( + private val chartId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun chartId(): Optional = Optional.ofNullable(chartId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ChartDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ChartDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChartDeleteParams]. */ + class Builder internal constructor() { + + private var chartId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(chartDeleteParams: ChartDeleteParams) = apply { + chartId = chartDeleteParams.chartId + additionalHeaders = chartDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = chartDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = chartDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun chartId(chartId: String?) = apply { this.chartId = chartId } + + /** Alias for calling [Builder.chartId] with `chartId.orElse(null)`. */ + fun chartId(chartId: Optional) = chartId(chartId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [ChartDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ChartDeleteParams = + ChartDeleteParams( + chartId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> chartId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChartDeleteParams && + chartId == other.chartId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(chartId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "ChartDeleteParams{chartId=$chartId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartDeleteResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartDeleteResponse.kt new file mode 100644 index 00000000..ebaf7612 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartDeleteResponse.kt @@ -0,0 +1,113 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class ChartDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ChartDeleteResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChartDeleteResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(chartDeleteResponse: ChartDeleteResponse) = apply { + additionalProperties = chartDeleteResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChartDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ChartDeleteResponse = ChartDeleteResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): ChartDeleteResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChartDeleteResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "ChartDeleteResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartPreviewParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartPreviewParams.kt new file mode 100644 index 00000000..a3e8b4e3 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartPreviewParams.kt @@ -0,0 +1,205 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** Get a preview for a chart without actually creating it. */ +class ChartPreviewParams +private constructor( + private val customChartPreviewRequest: CustomChartPreviewRequest, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun customChartPreviewRequest(): CustomChartPreviewRequest = customChartPreviewRequest + + fun _additionalBodyProperties(): Map = + customChartPreviewRequest._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ChartPreviewParams]. + * + * The following fields are required: + * ```java + * .customChartPreviewRequest() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChartPreviewParams]. */ + class Builder internal constructor() { + + private var customChartPreviewRequest: CustomChartPreviewRequest? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(chartPreviewParams: ChartPreviewParams) = apply { + customChartPreviewRequest = chartPreviewParams.customChartPreviewRequest + additionalHeaders = chartPreviewParams.additionalHeaders.toBuilder() + additionalQueryParams = chartPreviewParams.additionalQueryParams.toBuilder() + } + + fun customChartPreviewRequest(customChartPreviewRequest: CustomChartPreviewRequest) = + apply { + this.customChartPreviewRequest = customChartPreviewRequest + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ChartPreviewParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .customChartPreviewRequest() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChartPreviewParams = + ChartPreviewParams( + checkRequired("customChartPreviewRequest", customChartPreviewRequest), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): CustomChartPreviewRequest = customChartPreviewRequest + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChartPreviewParams && + customChartPreviewRequest == other.customChartPreviewRequest && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(customChartPreviewRequest, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ChartPreviewParams{customChartPreviewRequest=$customChartPreviewRequest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartUpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartUpdateParams.kt new file mode 100644 index 00000000..680e7c82 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartUpdateParams.kt @@ -0,0 +1,224 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Update a chart. */ +class ChartUpdateParams +private constructor( + private val chartId: String?, + private val customChartUpdate: CustomChartUpdate, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun chartId(): Optional = Optional.ofNullable(chartId) + + fun customChartUpdate(): CustomChartUpdate = customChartUpdate + + fun _additionalBodyProperties(): Map = + customChartUpdate._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ChartUpdateParams]. + * + * The following fields are required: + * ```java + * .customChartUpdate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChartUpdateParams]. */ + class Builder internal constructor() { + + private var chartId: String? = null + private var customChartUpdate: CustomChartUpdate? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(chartUpdateParams: ChartUpdateParams) = apply { + chartId = chartUpdateParams.chartId + customChartUpdate = chartUpdateParams.customChartUpdate + additionalHeaders = chartUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = chartUpdateParams.additionalQueryParams.toBuilder() + } + + fun chartId(chartId: String?) = apply { this.chartId = chartId } + + /** Alias for calling [Builder.chartId] with `chartId.orElse(null)`. */ + fun chartId(chartId: Optional) = chartId(chartId.getOrNull()) + + fun customChartUpdate(customChartUpdate: CustomChartUpdate) = apply { + this.customChartUpdate = customChartUpdate + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ChartUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .customChartUpdate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChartUpdateParams = + ChartUpdateParams( + chartId, + checkRequired("customChartUpdate", customChartUpdate), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): CustomChartUpdate = customChartUpdate + + fun _pathParam(index: Int): String = + when (index) { + 0 -> chartId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChartUpdateParams && + chartId == other.chartId && + customChartUpdate == other.customChartUpdate && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(chartId, customChartUpdate, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ChartUpdateParams{chartId=$chartId, customChartUpdate=$customChartUpdate, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartCreate.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartCreate.kt new file mode 100644 index 00000000..2adedd01 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartCreate.kt @@ -0,0 +1,888 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.sessions.RunStatsGroupBy +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class CustomChartCreate +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val chartType: JsonField, + private val series: JsonField>, + private val title: JsonField, + private val commonFilters: JsonField, + private val description: JsonField, + private val index: JsonField, + private val metadata: JsonValue, + private val sectionId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("chart_type") + @ExcludeMissing + chartType: JsonField = JsonMissing.of(), + @JsonProperty("series") @ExcludeMissing series: JsonField> = JsonMissing.of(), + @JsonProperty("title") @ExcludeMissing title: JsonField = JsonMissing.of(), + @JsonProperty("common_filters") + @ExcludeMissing + commonFilters: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("index") @ExcludeMissing index: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("section_id") @ExcludeMissing sectionId: JsonField = JsonMissing.of(), + ) : this( + chartType, + series, + title, + commonFilters, + description, + index, + metadata, + sectionId, + mutableMapOf(), + ) + + /** + * Enum for custom chart types. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun chartType(): CustomChartType = chartType.getRequired("chart_type") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun series(): List = series.getRequired("series") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun title(): String = title.getRequired("title") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun commonFilters(): Optional = + commonFilters.getOptional("common_filters") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun index(): Optional = index.getOptional("index") + + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun sectionId(): Optional = sectionId.getOptional("section_id") + + /** + * Returns the raw JSON value of [chartType]. + * + * Unlike [chartType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("chart_type") + @ExcludeMissing + fun _chartType(): JsonField = chartType + + /** + * Returns the raw JSON value of [series]. + * + * Unlike [series], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("series") @ExcludeMissing fun _series(): JsonField> = series + + /** + * Returns the raw JSON value of [title]. + * + * Unlike [title], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("title") @ExcludeMissing fun _title(): JsonField = title + + /** + * Returns the raw JSON value of [commonFilters]. + * + * Unlike [commonFilters], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("common_filters") + @ExcludeMissing + fun _commonFilters(): JsonField = commonFilters + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [index]. + * + * Unlike [index], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("index") @ExcludeMissing fun _index(): JsonField = index + + /** + * Returns the raw JSON value of [sectionId]. + * + * Unlike [sectionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("section_id") @ExcludeMissing fun _sectionId(): JsonField = sectionId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CustomChartCreate]. + * + * The following fields are required: + * ```java + * .chartType() + * .series() + * .title() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomChartCreate]. */ + class Builder internal constructor() { + + private var chartType: JsonField? = null + private var series: JsonField>? = null + private var title: JsonField? = null + private var commonFilters: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var index: JsonField = JsonMissing.of() + private var metadata: JsonValue = JsonMissing.of() + private var sectionId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customChartCreate: CustomChartCreate) = apply { + chartType = customChartCreate.chartType + series = customChartCreate.series.map { it.toMutableList() } + title = customChartCreate.title + commonFilters = customChartCreate.commonFilters + description = customChartCreate.description + index = customChartCreate.index + metadata = customChartCreate.metadata + sectionId = customChartCreate.sectionId + additionalProperties = customChartCreate.additionalProperties.toMutableMap() + } + + /** Enum for custom chart types. */ + fun chartType(chartType: CustomChartType) = chartType(JsonField.of(chartType)) + + /** + * Sets [Builder.chartType] to an arbitrary JSON value. + * + * You should usually call [Builder.chartType] with a well-typed [CustomChartType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun chartType(chartType: JsonField) = apply { this.chartType = chartType } + + fun series(series: List) = series(JsonField.of(series)) + + /** + * Sets [Builder.series] to an arbitrary JSON value. + * + * You should usually call [Builder.series] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun series(series: JsonField>) = apply { + this.series = series.map { it.toMutableList() } + } + + /** + * Adds a single [Series] to [Builder.series]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSeries(series: Series) = apply { + this.series = + (this.series ?: JsonField.of(mutableListOf())).also { + checkKnown("series", it).add(series) + } + } + + fun title(title: String) = title(JsonField.of(title)) + + /** + * Sets [Builder.title] to an arbitrary JSON value. + * + * You should usually call [Builder.title] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun title(title: JsonField) = apply { this.title = title } + + fun commonFilters(commonFilters: CustomChartSeriesFilters?) = + commonFilters(JsonField.ofNullable(commonFilters)) + + /** Alias for calling [Builder.commonFilters] with `commonFilters.orElse(null)`. */ + fun commonFilters(commonFilters: Optional) = + commonFilters(commonFilters.getOrNull()) + + /** + * Sets [Builder.commonFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.commonFilters] with a well-typed + * [CustomChartSeriesFilters] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun commonFilters(commonFilters: JsonField) = apply { + this.commonFilters = commonFilters + } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField) = apply { this.description = description } + + fun index(index: Long?) = index(JsonField.ofNullable(index)) + + /** + * Alias for [Builder.index]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun index(index: Long) = index(index as Long?) + + /** Alias for calling [Builder.index] with `index.orElse(null)`. */ + fun index(index: Optional) = index(index.getOrNull()) + + /** + * Sets [Builder.index] to an arbitrary JSON value. + * + * You should usually call [Builder.index] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun index(index: JsonField) = apply { this.index = index } + + fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + + fun sectionId(sectionId: String?) = sectionId(JsonField.ofNullable(sectionId)) + + /** Alias for calling [Builder.sectionId] with `sectionId.orElse(null)`. */ + fun sectionId(sectionId: Optional) = sectionId(sectionId.getOrNull()) + + /** + * Sets [Builder.sectionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sectionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun sectionId(sectionId: JsonField) = apply { this.sectionId = sectionId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomChartCreate]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .chartType() + * .series() + * .title() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomChartCreate = + CustomChartCreate( + checkRequired("chartType", chartType), + checkRequired("series", series).map { it.toImmutable() }, + checkRequired("title", title), + commonFilters, + description, + index, + metadata, + sectionId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CustomChartCreate = apply { + if (validated) { + return@apply + } + + chartType().validate() + series().forEach { it.validate() } + title() + commonFilters().ifPresent { it.validate() } + description() + index() + sectionId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (chartType.asKnown().getOrNull()?.validity() ?: 0) + + (series.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (title.asKnown().isPresent) 1 else 0) + + (commonFilters.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (index.asKnown().isPresent) 1 else 0) + + (if (sectionId.asKnown().isPresent) 1 else 0) + + class Series + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val metric: JsonField, + private val name: JsonField, + private val feedbackKey: JsonField, + private val filters: JsonField, + private val groupBy: JsonField, + private val projectMetric: JsonField, + private val workspaceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("metric") + @ExcludeMissing + metric: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("feedback_key") + @ExcludeMissing + feedbackKey: JsonField = JsonMissing.of(), + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField = JsonMissing.of(), + @JsonProperty("group_by") + @ExcludeMissing + groupBy: JsonField = JsonMissing.of(), + @JsonProperty("project_metric") + @ExcludeMissing + projectMetric: JsonField = JsonMissing.of(), + @JsonProperty("workspace_id") + @ExcludeMissing + workspaceId: JsonField = JsonMissing.of(), + ) : this( + metric, + name, + feedbackKey, + filters, + groupBy, + projectMetric, + workspaceId, + mutableMapOf(), + ) + + /** + * Metrics you can chart. Feedback metrics are not available for organization-scoped charts. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun metric(): CustomChartMetric = metric.getRequired("metric") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun feedbackKey(): Optional = feedbackKey.getOptional("feedback_key") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun filters(): Optional = filters.getOptional("filters") + + /** + * Group by param for run stats. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun groupBy(): Optional = groupBy.getOptional("group_by") + + /** + * LGP Metrics you can chart. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun projectMetric(): Optional = + projectMetric.getOptional("project_metric") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun workspaceId(): Optional = workspaceId.getOptional("workspace_id") + + /** + * Returns the raw JSON value of [metric]. + * + * Unlike [metric], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metric") @ExcludeMissing fun _metric(): JsonField = metric + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [feedbackKey]. + * + * Unlike [feedbackKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feedback_key") + @ExcludeMissing + fun _feedbackKey(): JsonField = feedbackKey + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField = filters + + /** + * Returns the raw JSON value of [groupBy]. + * + * Unlike [groupBy], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("group_by") + @ExcludeMissing + fun _groupBy(): JsonField = groupBy + + /** + * Returns the raw JSON value of [projectMetric]. + * + * Unlike [projectMetric], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("project_metric") + @ExcludeMissing + fun _projectMetric(): JsonField = projectMetric + + /** + * Returns the raw JSON value of [workspaceId]. + * + * Unlike [workspaceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("workspace_id") + @ExcludeMissing + fun _workspaceId(): JsonField = workspaceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Series]. + * + * The following fields are required: + * ```java + * .metric() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Series]. */ + class Builder internal constructor() { + + private var metric: JsonField? = null + private var name: JsonField? = null + private var feedbackKey: JsonField = JsonMissing.of() + private var filters: JsonField = JsonMissing.of() + private var groupBy: JsonField = JsonMissing.of() + private var projectMetric: JsonField = JsonMissing.of() + private var workspaceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(series: Series) = apply { + metric = series.metric + name = series.name + feedbackKey = series.feedbackKey + filters = series.filters + groupBy = series.groupBy + projectMetric = series.projectMetric + workspaceId = series.workspaceId + additionalProperties = series.additionalProperties.toMutableMap() + } + + /** + * Metrics you can chart. Feedback metrics are not available for organization-scoped + * charts. + */ + fun metric(metric: CustomChartMetric) = metric(JsonField.of(metric)) + + /** + * Sets [Builder.metric] to an arbitrary JSON value. + * + * You should usually call [Builder.metric] with a well-typed [CustomChartMetric] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metric(metric: JsonField) = apply { this.metric = metric } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun feedbackKey(feedbackKey: String?) = feedbackKey(JsonField.ofNullable(feedbackKey)) + + /** Alias for calling [Builder.feedbackKey] with `feedbackKey.orElse(null)`. */ + fun feedbackKey(feedbackKey: Optional) = feedbackKey(feedbackKey.getOrNull()) + + /** + * Sets [Builder.feedbackKey] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun feedbackKey(feedbackKey: JsonField) = apply { + this.feedbackKey = feedbackKey + } + + fun filters(filters: CustomChartSeriesFilters?) = filters(JsonField.ofNullable(filters)) + + /** Alias for calling [Builder.filters] with `filters.orElse(null)`. */ + fun filters(filters: Optional) = filters(filters.getOrNull()) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed + * [CustomChartSeriesFilters] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField) = apply { + this.filters = filters + } + + /** Group by param for run stats. */ + fun groupBy(groupBy: RunStatsGroupBy?) = groupBy(JsonField.ofNullable(groupBy)) + + /** Alias for calling [Builder.groupBy] with `groupBy.orElse(null)`. */ + fun groupBy(groupBy: Optional) = groupBy(groupBy.getOrNull()) + + /** + * Sets [Builder.groupBy] to an arbitrary JSON value. + * + * You should usually call [Builder.groupBy] with a well-typed [RunStatsGroupBy] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupBy(groupBy: JsonField) = apply { this.groupBy = groupBy } + + /** LGP Metrics you can chart. */ + fun projectMetric(projectMetric: HostProjectChartMetric?) = + projectMetric(JsonField.ofNullable(projectMetric)) + + /** Alias for calling [Builder.projectMetric] with `projectMetric.orElse(null)`. */ + fun projectMetric(projectMetric: Optional) = + projectMetric(projectMetric.getOrNull()) + + /** + * Sets [Builder.projectMetric] to an arbitrary JSON value. + * + * You should usually call [Builder.projectMetric] with a well-typed + * [HostProjectChartMetric] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun projectMetric(projectMetric: JsonField) = apply { + this.projectMetric = projectMetric + } + + fun workspaceId(workspaceId: String?) = workspaceId(JsonField.ofNullable(workspaceId)) + + /** Alias for calling [Builder.workspaceId] with `workspaceId.orElse(null)`. */ + fun workspaceId(workspaceId: Optional) = workspaceId(workspaceId.getOrNull()) + + /** + * Sets [Builder.workspaceId] to an arbitrary JSON value. + * + * You should usually call [Builder.workspaceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun workspaceId(workspaceId: JsonField) = apply { + this.workspaceId = workspaceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Series]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .metric() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Series = + Series( + checkRequired("metric", metric), + checkRequired("name", name), + feedbackKey, + filters, + groupBy, + projectMetric, + workspaceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Series = apply { + if (validated) { + return@apply + } + + metric().validate() + name() + feedbackKey() + filters().ifPresent { it.validate() } + groupBy().ifPresent { it.validate() } + projectMetric().ifPresent { it.validate() } + workspaceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (metric.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (feedbackKey.asKnown().isPresent) 1 else 0) + + (filters.asKnown().getOrNull()?.validity() ?: 0) + + (groupBy.asKnown().getOrNull()?.validity() ?: 0) + + (projectMetric.asKnown().getOrNull()?.validity() ?: 0) + + (if (workspaceId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Series && + metric == other.metric && + name == other.name && + feedbackKey == other.feedbackKey && + filters == other.filters && + groupBy == other.groupBy && + projectMetric == other.projectMetric && + workspaceId == other.workspaceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + metric, + name, + feedbackKey, + filters, + groupBy, + projectMetric, + workspaceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Series{metric=$metric, name=$name, feedbackKey=$feedbackKey, filters=$filters, groupBy=$groupBy, projectMetric=$projectMetric, workspaceId=$workspaceId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomChartCreate && + chartType == other.chartType && + series == other.series && + title == other.title && + commonFilters == other.commonFilters && + description == other.description && + index == other.index && + metadata == other.metadata && + sectionId == other.sectionId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + chartType, + series, + title, + commonFilters, + description, + index, + metadata, + sectionId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomChartCreate{chartType=$chartType, series=$series, title=$title, commonFilters=$commonFilters, description=$description, index=$index, metadata=$metadata, sectionId=$sectionId, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartMetric.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartMetric.kt new file mode 100644 index 00000000..8083c8db --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartMetric.kt @@ -0,0 +1,276 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts + +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException + +/** Metrics you can chart. Feedback metrics are not available for organization-scoped charts. */ +class CustomChartMetric @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't match + * any known member, and you want to know that value. For example, if the SDK is on an older + * version than the API, then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val RUN_COUNT = of("run_count") + + @JvmField val LATENCY_P50 = of("latency_p50") + + @JvmField val LATENCY_P99 = of("latency_p99") + + @JvmField val LATENCY_AVG = of("latency_avg") + + @JvmField val FIRST_TOKEN_P50 = of("first_token_p50") + + @JvmField val FIRST_TOKEN_P99 = of("first_token_p99") + + @JvmField val TOTAL_TOKENS = of("total_tokens") + + @JvmField val PROMPT_TOKENS = of("prompt_tokens") + + @JvmField val COMPLETION_TOKENS = of("completion_tokens") + + @JvmField val MEDIAN_TOKENS = of("median_tokens") + + @JvmField val COMPLETION_TOKENS_P50 = of("completion_tokens_p50") + + @JvmField val PROMPT_TOKENS_P50 = of("prompt_tokens_p50") + + @JvmField val TOKENS_P99 = of("tokens_p99") + + @JvmField val COMPLETION_TOKENS_P99 = of("completion_tokens_p99") + + @JvmField val PROMPT_TOKENS_P99 = of("prompt_tokens_p99") + + @JvmField val FEEDBACK = of("feedback") + + @JvmField val FEEDBACK_SCORE_AVG = of("feedback_score_avg") + + @JvmField val FEEDBACK_VALUES = of("feedback_values") + + @JvmField val TOTAL_COST = of("total_cost") + + @JvmField val PROMPT_COST = of("prompt_cost") + + @JvmField val COMPLETION_COST = of("completion_cost") + + @JvmField val ERROR_RATE = of("error_rate") + + @JvmField val STREAMING_RATE = of("streaming_rate") + + @JvmField val COST_P50 = of("cost_p50") + + @JvmField val COST_P99 = of("cost_p99") + + @JvmStatic fun of(value: String) = CustomChartMetric(JsonField.of(value)) + } + + /** An enum containing [CustomChartMetric]'s known values. */ + enum class Known { + RUN_COUNT, + LATENCY_P50, + LATENCY_P99, + LATENCY_AVG, + FIRST_TOKEN_P50, + FIRST_TOKEN_P99, + TOTAL_TOKENS, + PROMPT_TOKENS, + COMPLETION_TOKENS, + MEDIAN_TOKENS, + COMPLETION_TOKENS_P50, + PROMPT_TOKENS_P50, + TOKENS_P99, + COMPLETION_TOKENS_P99, + PROMPT_TOKENS_P99, + FEEDBACK, + FEEDBACK_SCORE_AVG, + FEEDBACK_VALUES, + TOTAL_COST, + PROMPT_COST, + COMPLETION_COST, + ERROR_RATE, + STREAMING_RATE, + COST_P50, + COST_P99, + } + + /** + * An enum containing [CustomChartMetric]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [CustomChartMetric] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the SDK + * is on an older version than the API, then the API may respond with new members that the SDK + * is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + RUN_COUNT, + LATENCY_P50, + LATENCY_P99, + LATENCY_AVG, + FIRST_TOKEN_P50, + FIRST_TOKEN_P99, + TOTAL_TOKENS, + PROMPT_TOKENS, + COMPLETION_TOKENS, + MEDIAN_TOKENS, + COMPLETION_TOKENS_P50, + PROMPT_TOKENS_P50, + TOKENS_P99, + COMPLETION_TOKENS_P99, + PROMPT_TOKENS_P99, + FEEDBACK, + FEEDBACK_SCORE_AVG, + FEEDBACK_VALUES, + TOTAL_COST, + PROMPT_COST, + COMPLETION_COST, + ERROR_RATE, + STREAMING_RATE, + COST_P50, + COST_P99, + /** + * An enum member indicating that [CustomChartMetric] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if + * the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want to + * throw for the unknown case. + */ + fun value(): Value = + when (this) { + RUN_COUNT -> Value.RUN_COUNT + LATENCY_P50 -> Value.LATENCY_P50 + LATENCY_P99 -> Value.LATENCY_P99 + LATENCY_AVG -> Value.LATENCY_AVG + FIRST_TOKEN_P50 -> Value.FIRST_TOKEN_P50 + FIRST_TOKEN_P99 -> Value.FIRST_TOKEN_P99 + TOTAL_TOKENS -> Value.TOTAL_TOKENS + PROMPT_TOKENS -> Value.PROMPT_TOKENS + COMPLETION_TOKENS -> Value.COMPLETION_TOKENS + MEDIAN_TOKENS -> Value.MEDIAN_TOKENS + COMPLETION_TOKENS_P50 -> Value.COMPLETION_TOKENS_P50 + PROMPT_TOKENS_P50 -> Value.PROMPT_TOKENS_P50 + TOKENS_P99 -> Value.TOKENS_P99 + COMPLETION_TOKENS_P99 -> Value.COMPLETION_TOKENS_P99 + PROMPT_TOKENS_P99 -> Value.PROMPT_TOKENS_P99 + FEEDBACK -> Value.FEEDBACK + FEEDBACK_SCORE_AVG -> Value.FEEDBACK_SCORE_AVG + FEEDBACK_VALUES -> Value.FEEDBACK_VALUES + TOTAL_COST -> Value.TOTAL_COST + PROMPT_COST -> Value.PROMPT_COST + COMPLETION_COST -> Value.COMPLETION_COST + ERROR_RATE -> Value.ERROR_RATE + STREAMING_RATE -> Value.STREAMING_RATE + COST_P50 -> Value.COST_P50 + COST_P99 -> Value.COST_P99 + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't want + * to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + RUN_COUNT -> Known.RUN_COUNT + LATENCY_P50 -> Known.LATENCY_P50 + LATENCY_P99 -> Known.LATENCY_P99 + LATENCY_AVG -> Known.LATENCY_AVG + FIRST_TOKEN_P50 -> Known.FIRST_TOKEN_P50 + FIRST_TOKEN_P99 -> Known.FIRST_TOKEN_P99 + TOTAL_TOKENS -> Known.TOTAL_TOKENS + PROMPT_TOKENS -> Known.PROMPT_TOKENS + COMPLETION_TOKENS -> Known.COMPLETION_TOKENS + MEDIAN_TOKENS -> Known.MEDIAN_TOKENS + COMPLETION_TOKENS_P50 -> Known.COMPLETION_TOKENS_P50 + PROMPT_TOKENS_P50 -> Known.PROMPT_TOKENS_P50 + TOKENS_P99 -> Known.TOKENS_P99 + COMPLETION_TOKENS_P99 -> Known.COMPLETION_TOKENS_P99 + PROMPT_TOKENS_P99 -> Known.PROMPT_TOKENS_P99 + FEEDBACK -> Known.FEEDBACK + FEEDBACK_SCORE_AVG -> Known.FEEDBACK_SCORE_AVG + FEEDBACK_VALUES -> Known.FEEDBACK_VALUES + TOTAL_COST -> Known.TOTAL_COST + PROMPT_COST -> Known.PROMPT_COST + COMPLETION_COST -> Known.COMPLETION_COST + ERROR_RATE -> Known.ERROR_RATE + STREAMING_RATE -> Known.STREAMING_RATE + COST_P50 -> Known.COST_P50 + COST_P99 -> Known.COST_P99 + else -> throw LangsmithApiInvalidDataException("Unknown CustomChartMetric: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): CustomChartMetric = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomChartMetric && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartPreviewRequest.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartPreviewRequest.kt new file mode 100644 index 00000000..20186517 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartPreviewRequest.kt @@ -0,0 +1,440 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.orgcharts.section.CustomChartsRequestBase +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class CustomChartPreviewRequest +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val bucketInfo: JsonField, + private val chart: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("bucket_info") + @ExcludeMissing + bucketInfo: JsonField = JsonMissing.of(), + @JsonProperty("chart") @ExcludeMissing chart: JsonField = JsonMissing.of(), + ) : this(bucketInfo, chart, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun bucketInfo(): CustomChartsRequestBase = bucketInfo.getRequired("bucket_info") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun chart(): Chart = chart.getRequired("chart") + + /** + * Returns the raw JSON value of [bucketInfo]. + * + * Unlike [bucketInfo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("bucket_info") + @ExcludeMissing + fun _bucketInfo(): JsonField = bucketInfo + + /** + * Returns the raw JSON value of [chart]. + * + * Unlike [chart], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("chart") @ExcludeMissing fun _chart(): JsonField = chart + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CustomChartPreviewRequest]. + * + * The following fields are required: + * ```java + * .bucketInfo() + * .chart() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomChartPreviewRequest]. */ + class Builder internal constructor() { + + private var bucketInfo: JsonField? = null + private var chart: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customChartPreviewRequest: CustomChartPreviewRequest) = apply { + bucketInfo = customChartPreviewRequest.bucketInfo + chart = customChartPreviewRequest.chart + additionalProperties = customChartPreviewRequest.additionalProperties.toMutableMap() + } + + fun bucketInfo(bucketInfo: CustomChartsRequestBase) = bucketInfo(JsonField.of(bucketInfo)) + + /** + * Sets [Builder.bucketInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.bucketInfo] with a well-typed [CustomChartsRequestBase] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun bucketInfo(bucketInfo: JsonField) = apply { + this.bucketInfo = bucketInfo + } + + fun chart(chart: Chart) = chart(JsonField.of(chart)) + + /** + * Sets [Builder.chart] to an arbitrary JSON value. + * + * You should usually call [Builder.chart] with a well-typed [Chart] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun chart(chart: JsonField) = apply { this.chart = chart } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomChartPreviewRequest]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bucketInfo() + * .chart() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomChartPreviewRequest = + CustomChartPreviewRequest( + checkRequired("bucketInfo", bucketInfo), + checkRequired("chart", chart), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CustomChartPreviewRequest = apply { + if (validated) { + return@apply + } + + bucketInfo().validate() + chart().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (bucketInfo.asKnown().getOrNull()?.validity() ?: 0) + + (chart.asKnown().getOrNull()?.validity() ?: 0) + + class Chart + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val series: JsonField>, + private val commonFilters: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("series") + @ExcludeMissing + series: JsonField> = JsonMissing.of(), + @JsonProperty("common_filters") + @ExcludeMissing + commonFilters: JsonField = JsonMissing.of(), + ) : this(series, commonFilters, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun series(): List = series.getRequired("series") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun commonFilters(): Optional = + commonFilters.getOptional("common_filters") + + /** + * Returns the raw JSON value of [series]. + * + * Unlike [series], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("series") + @ExcludeMissing + fun _series(): JsonField> = series + + /** + * Returns the raw JSON value of [commonFilters]. + * + * Unlike [commonFilters], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("common_filters") + @ExcludeMissing + fun _commonFilters(): JsonField = commonFilters + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Chart]. + * + * The following fields are required: + * ```java + * .series() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Chart]. */ + class Builder internal constructor() { + + private var series: JsonField>? = null + private var commonFilters: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(chart: Chart) = apply { + series = chart.series.map { it.toMutableList() } + commonFilters = chart.commonFilters + additionalProperties = chart.additionalProperties.toMutableMap() + } + + fun series(series: List) = series(JsonField.of(series)) + + /** + * Sets [Builder.series] to an arbitrary JSON value. + * + * You should usually call [Builder.series] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun series(series: JsonField>) = apply { + this.series = series.map { it.toMutableList() } + } + + /** + * Adds a single [CustomChartSeries] to [Builder.series]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSeries(series: CustomChartSeries) = apply { + this.series = + (this.series ?: JsonField.of(mutableListOf())).also { + checkKnown("series", it).add(series) + } + } + + fun commonFilters(commonFilters: CustomChartSeriesFilters?) = + commonFilters(JsonField.ofNullable(commonFilters)) + + /** Alias for calling [Builder.commonFilters] with `commonFilters.orElse(null)`. */ + fun commonFilters(commonFilters: Optional) = + commonFilters(commonFilters.getOrNull()) + + /** + * Sets [Builder.commonFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.commonFilters] with a well-typed + * [CustomChartSeriesFilters] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun commonFilters(commonFilters: JsonField) = apply { + this.commonFilters = commonFilters + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Chart]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .series() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Chart = + Chart( + checkRequired("series", series).map { it.toImmutable() }, + commonFilters, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Chart = apply { + if (validated) { + return@apply + } + + series().forEach { it.validate() } + commonFilters().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (series.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (commonFilters.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Chart && + series == other.series && + commonFilters == other.commonFilters && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(series, commonFilters, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Chart{series=$series, commonFilters=$commonFilters, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomChartPreviewRequest && + bucketInfo == other.bucketInfo && + chart == other.chart && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(bucketInfo, chart, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomChartPreviewRequest{bucketInfo=$bucketInfo, chart=$chart, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartResponse.kt new file mode 100644 index 00000000..fdda709f --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartResponse.kt @@ -0,0 +1,431 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class CustomChartResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val chartType: JsonField, + private val index: JsonField, + private val sectionId: JsonField, + private val series: JsonField>, + private val title: JsonField, + private val description: JsonField, + private val metadata: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("chart_type") + @ExcludeMissing + chartType: JsonField = JsonMissing.of(), + @JsonProperty("index") @ExcludeMissing index: JsonField = JsonMissing.of(), + @JsonProperty("section_id") @ExcludeMissing sectionId: JsonField = JsonMissing.of(), + @JsonProperty("series") + @ExcludeMissing + series: JsonField> = JsonMissing.of(), + @JsonProperty("title") @ExcludeMissing title: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + ) : this(id, chartType, index, sectionId, series, title, description, metadata, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * Enum for custom chart types. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun chartType(): CustomChartType = chartType.getRequired("chart_type") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun index(): Long = index.getRequired("index") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun sectionId(): String = sectionId.getRequired("section_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun series(): Optional> = series.getOptional("series") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun title(): String = title.getRequired("title") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [chartType]. + * + * Unlike [chartType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("chart_type") + @ExcludeMissing + fun _chartType(): JsonField = chartType + + /** + * Returns the raw JSON value of [index]. + * + * Unlike [index], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("index") @ExcludeMissing fun _index(): JsonField = index + + /** + * Returns the raw JSON value of [sectionId]. + * + * Unlike [sectionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("section_id") @ExcludeMissing fun _sectionId(): JsonField = sectionId + + /** + * Returns the raw JSON value of [series]. + * + * Unlike [series], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("series") + @ExcludeMissing + fun _series(): JsonField> = series + + /** + * Returns the raw JSON value of [title]. + * + * Unlike [title], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("title") @ExcludeMissing fun _title(): JsonField = title + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CustomChartResponse]. + * + * The following fields are required: + * ```java + * .id() + * .chartType() + * .index() + * .sectionId() + * .series() + * .title() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomChartResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var chartType: JsonField? = null + private var index: JsonField? = null + private var sectionId: JsonField? = null + private var series: JsonField>? = null + private var title: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var metadata: JsonValue = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customChartResponse: CustomChartResponse) = apply { + id = customChartResponse.id + chartType = customChartResponse.chartType + index = customChartResponse.index + sectionId = customChartResponse.sectionId + series = customChartResponse.series.map { it.toMutableList() } + title = customChartResponse.title + description = customChartResponse.description + metadata = customChartResponse.metadata + additionalProperties = customChartResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** Enum for custom chart types. */ + fun chartType(chartType: CustomChartType) = chartType(JsonField.of(chartType)) + + /** + * Sets [Builder.chartType] to an arbitrary JSON value. + * + * You should usually call [Builder.chartType] with a well-typed [CustomChartType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun chartType(chartType: JsonField) = apply { this.chartType = chartType } + + fun index(index: Long) = index(JsonField.of(index)) + + /** + * Sets [Builder.index] to an arbitrary JSON value. + * + * You should usually call [Builder.index] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun index(index: JsonField) = apply { this.index = index } + + fun sectionId(sectionId: String) = sectionId(JsonField.of(sectionId)) + + /** + * Sets [Builder.sectionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sectionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun sectionId(sectionId: JsonField) = apply { this.sectionId = sectionId } + + fun series(series: List?) = series(JsonField.ofNullable(series)) + + /** Alias for calling [Builder.series] with `series.orElse(null)`. */ + fun series(series: Optional>) = series(series.getOrNull()) + + /** + * Sets [Builder.series] to an arbitrary JSON value. + * + * You should usually call [Builder.series] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun series(series: JsonField>) = apply { + this.series = series.map { it.toMutableList() } + } + + /** + * Adds a single [CustomChartSeries] to [Builder.series]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSeries(series: CustomChartSeries) = apply { + this.series = + (this.series ?: JsonField.of(mutableListOf())).also { + checkKnown("series", it).add(series) + } + } + + fun title(title: String) = title(JsonField.of(title)) + + /** + * Sets [Builder.title] to an arbitrary JSON value. + * + * You should usually call [Builder.title] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun title(title: JsonField) = apply { this.title = title } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField) = apply { this.description = description } + + fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomChartResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .chartType() + * .index() + * .sectionId() + * .series() + * .title() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomChartResponse = + CustomChartResponse( + checkRequired("id", id), + checkRequired("chartType", chartType), + checkRequired("index", index), + checkRequired("sectionId", sectionId), + checkRequired("series", series).map { it.toImmutable() }, + checkRequired("title", title), + description, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CustomChartResponse = apply { + if (validated) { + return@apply + } + + id() + chartType().validate() + index() + sectionId() + series().ifPresent { it.forEach { it.validate() } } + title() + description() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (chartType.asKnown().getOrNull()?.validity() ?: 0) + + (if (index.asKnown().isPresent) 1 else 0) + + (if (sectionId.asKnown().isPresent) 1 else 0) + + (series.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (title.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomChartResponse && + id == other.id && + chartType == other.chartType && + index == other.index && + sectionId == other.sectionId && + series == other.series && + title == other.title && + description == other.description && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + chartType, + index, + sectionId, + series, + title, + description, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomChartResponse{id=$id, chartType=$chartType, index=$index, sectionId=$sectionId, series=$series, title=$title, description=$description, metadata=$metadata, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartSeries.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartSeries.kt new file mode 100644 index 00000000..972e96ba --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartSeries.kt @@ -0,0 +1,1013 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts + +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.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class CustomChartSeries +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val metric: JsonField, + private val name: JsonField, + private val feedbackKey: JsonField, + private val filters: JsonField, + private val groupBy: JsonField, + private val projectMetric: JsonField, + private val workspaceId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("metric") + @ExcludeMissing + metric: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("feedback_key") + @ExcludeMissing + feedbackKey: JsonField = JsonMissing.of(), + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField = JsonMissing.of(), + @JsonProperty("group_by") @ExcludeMissing groupBy: JsonField = JsonMissing.of(), + @JsonProperty("project_metric") + @ExcludeMissing + projectMetric: JsonField = JsonMissing.of(), + @JsonProperty("workspace_id") + @ExcludeMissing + workspaceId: JsonField = JsonMissing.of(), + ) : this( + id, + metric, + name, + feedbackKey, + filters, + groupBy, + projectMetric, + workspaceId, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * Metrics you can chart. Feedback metrics are not available for organization-scoped charts. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun metric(): CustomChartMetric = metric.getRequired("metric") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun feedbackKey(): Optional = feedbackKey.getOptional("feedback_key") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun filters(): Optional = filters.getOptional("filters") + + /** + * Include additional information about where the group_by param was set. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun groupBy(): Optional = groupBy.getOptional("group_by") + + /** + * LGP Metrics you can chart. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun projectMetric(): Optional = + projectMetric.getOptional("project_metric") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun workspaceId(): Optional = workspaceId.getOptional("workspace_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [metric]. + * + * Unlike [metric], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metric") @ExcludeMissing fun _metric(): JsonField = metric + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [feedbackKey]. + * + * Unlike [feedbackKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feedback_key") + @ExcludeMissing + fun _feedbackKey(): JsonField = feedbackKey + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField = filters + + /** + * Returns the raw JSON value of [groupBy]. + * + * Unlike [groupBy], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("group_by") @ExcludeMissing fun _groupBy(): JsonField = groupBy + + /** + * Returns the raw JSON value of [projectMetric]. + * + * Unlike [projectMetric], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("project_metric") + @ExcludeMissing + fun _projectMetric(): JsonField = projectMetric + + /** + * Returns the raw JSON value of [workspaceId]. + * + * Unlike [workspaceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("workspace_id") + @ExcludeMissing + fun _workspaceId(): JsonField = workspaceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CustomChartSeries]. + * + * The following fields are required: + * ```java + * .id() + * .metric() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomChartSeries]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var metric: JsonField? = null + private var name: JsonField? = null + private var feedbackKey: JsonField = JsonMissing.of() + private var filters: JsonField = JsonMissing.of() + private var groupBy: JsonField = JsonMissing.of() + private var projectMetric: JsonField = JsonMissing.of() + private var workspaceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customChartSeries: CustomChartSeries) = apply { + id = customChartSeries.id + metric = customChartSeries.metric + name = customChartSeries.name + feedbackKey = customChartSeries.feedbackKey + filters = customChartSeries.filters + groupBy = customChartSeries.groupBy + projectMetric = customChartSeries.projectMetric + workspaceId = customChartSeries.workspaceId + additionalProperties = customChartSeries.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * Metrics you can chart. Feedback metrics are not available for organization-scoped charts. + */ + fun metric(metric: CustomChartMetric) = metric(JsonField.of(metric)) + + /** + * Sets [Builder.metric] to an arbitrary JSON value. + * + * You should usually call [Builder.metric] with a well-typed [CustomChartMetric] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metric(metric: JsonField) = apply { this.metric = metric } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun feedbackKey(feedbackKey: String?) = feedbackKey(JsonField.ofNullable(feedbackKey)) + + /** Alias for calling [Builder.feedbackKey] with `feedbackKey.orElse(null)`. */ + fun feedbackKey(feedbackKey: Optional) = feedbackKey(feedbackKey.getOrNull()) + + /** + * Sets [Builder.feedbackKey] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun feedbackKey(feedbackKey: JsonField) = apply { this.feedbackKey = feedbackKey } + + fun filters(filters: CustomChartSeriesFilters?) = filters(JsonField.ofNullable(filters)) + + /** Alias for calling [Builder.filters] with `filters.orElse(null)`. */ + fun filters(filters: Optional) = filters(filters.getOrNull()) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed [CustomChartSeriesFilters] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun filters(filters: JsonField) = apply { this.filters = filters } + + /** Include additional information about where the group_by param was set. */ + fun groupBy(groupBy: GroupBy?) = groupBy(JsonField.ofNullable(groupBy)) + + /** Alias for calling [Builder.groupBy] with `groupBy.orElse(null)`. */ + fun groupBy(groupBy: Optional) = groupBy(groupBy.getOrNull()) + + /** + * Sets [Builder.groupBy] to an arbitrary JSON value. + * + * You should usually call [Builder.groupBy] with a well-typed [GroupBy] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun groupBy(groupBy: JsonField) = apply { this.groupBy = groupBy } + + /** LGP Metrics you can chart. */ + fun projectMetric(projectMetric: HostProjectChartMetric?) = + projectMetric(JsonField.ofNullable(projectMetric)) + + /** Alias for calling [Builder.projectMetric] with `projectMetric.orElse(null)`. */ + fun projectMetric(projectMetric: Optional) = + projectMetric(projectMetric.getOrNull()) + + /** + * Sets [Builder.projectMetric] to an arbitrary JSON value. + * + * You should usually call [Builder.projectMetric] with a well-typed + * [HostProjectChartMetric] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun projectMetric(projectMetric: JsonField) = apply { + this.projectMetric = projectMetric + } + + fun workspaceId(workspaceId: String?) = workspaceId(JsonField.ofNullable(workspaceId)) + + /** Alias for calling [Builder.workspaceId] with `workspaceId.orElse(null)`. */ + fun workspaceId(workspaceId: Optional) = workspaceId(workspaceId.getOrNull()) + + /** + * Sets [Builder.workspaceId] to an arbitrary JSON value. + * + * You should usually call [Builder.workspaceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun workspaceId(workspaceId: JsonField) = apply { this.workspaceId = workspaceId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomChartSeries]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .metric() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomChartSeries = + CustomChartSeries( + checkRequired("id", id), + checkRequired("metric", metric), + checkRequired("name", name), + feedbackKey, + filters, + groupBy, + projectMetric, + workspaceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CustomChartSeries = apply { + if (validated) { + return@apply + } + + id() + metric().validate() + name() + feedbackKey() + filters().ifPresent { it.validate() } + groupBy().ifPresent { it.validate() } + projectMetric().ifPresent { it.validate() } + workspaceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (metric.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (feedbackKey.asKnown().isPresent) 1 else 0) + + (filters.asKnown().getOrNull()?.validity() ?: 0) + + (groupBy.asKnown().getOrNull()?.validity() ?: 0) + + (projectMetric.asKnown().getOrNull()?.validity() ?: 0) + + (if (workspaceId.asKnown().isPresent) 1 else 0) + + /** Include additional information about where the group_by param was set. */ + class GroupBy + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val attribute: JsonField, + private val maxGroups: JsonField, + private val path: JsonField, + private val setBy: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("attribute") + @ExcludeMissing + attribute: JsonField = JsonMissing.of(), + @JsonProperty("max_groups") + @ExcludeMissing + maxGroups: JsonField = JsonMissing.of(), + @JsonProperty("path") @ExcludeMissing path: JsonField = JsonMissing.of(), + @JsonProperty("set_by") @ExcludeMissing setBy: JsonField = JsonMissing.of(), + ) : this(attribute, maxGroups, path, setBy, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun attribute(): Attribute = attribute.getRequired("attribute") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun maxGroups(): Optional = maxGroups.getOptional("max_groups") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun path(): Optional = path.getOptional("path") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun setBy(): Optional = setBy.getOptional("set_by") + + /** + * Returns the raw JSON value of [attribute]. + * + * Unlike [attribute], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("attribute") + @ExcludeMissing + fun _attribute(): JsonField = attribute + + /** + * Returns the raw JSON value of [maxGroups]. + * + * Unlike [maxGroups], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("max_groups") @ExcludeMissing fun _maxGroups(): JsonField = maxGroups + + /** + * Returns the raw JSON value of [path]. + * + * Unlike [path], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("path") @ExcludeMissing fun _path(): JsonField = path + + /** + * Returns the raw JSON value of [setBy]. + * + * Unlike [setBy], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("set_by") @ExcludeMissing fun _setBy(): JsonField = setBy + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [GroupBy]. + * + * The following fields are required: + * ```java + * .attribute() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupBy]. */ + class Builder internal constructor() { + + private var attribute: JsonField? = null + private var maxGroups: JsonField = JsonMissing.of() + private var path: JsonField = JsonMissing.of() + private var setBy: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupBy: GroupBy) = apply { + attribute = groupBy.attribute + maxGroups = groupBy.maxGroups + path = groupBy.path + setBy = groupBy.setBy + additionalProperties = groupBy.additionalProperties.toMutableMap() + } + + fun attribute(attribute: Attribute) = attribute(JsonField.of(attribute)) + + /** + * Sets [Builder.attribute] to an arbitrary JSON value. + * + * You should usually call [Builder.attribute] with a well-typed [Attribute] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun attribute(attribute: JsonField) = apply { this.attribute = attribute } + + fun maxGroups(maxGroups: Long) = maxGroups(JsonField.of(maxGroups)) + + /** + * Sets [Builder.maxGroups] to an arbitrary JSON value. + * + * You should usually call [Builder.maxGroups] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun maxGroups(maxGroups: JsonField) = apply { this.maxGroups = maxGroups } + + fun path(path: String?) = path(JsonField.ofNullable(path)) + + /** Alias for calling [Builder.path] with `path.orElse(null)`. */ + fun path(path: Optional) = path(path.getOrNull()) + + /** + * Sets [Builder.path] to an arbitrary JSON value. + * + * You should usually call [Builder.path] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun path(path: JsonField) = apply { this.path = path } + + fun setBy(setBy: SetBy?) = setBy(JsonField.ofNullable(setBy)) + + /** Alias for calling [Builder.setBy] with `setBy.orElse(null)`. */ + fun setBy(setBy: Optional) = setBy(setBy.getOrNull()) + + /** + * Sets [Builder.setBy] to an arbitrary JSON value. + * + * You should usually call [Builder.setBy] with a well-typed [SetBy] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun setBy(setBy: JsonField) = apply { this.setBy = setBy } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupBy]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .attribute() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupBy = + GroupBy( + checkRequired("attribute", attribute), + maxGroups, + path, + setBy, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupBy = apply { + if (validated) { + return@apply + } + + attribute().validate() + maxGroups() + path() + setBy().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (attribute.asKnown().getOrNull()?.validity() ?: 0) + + (if (maxGroups.asKnown().isPresent) 1 else 0) + + (if (path.asKnown().isPresent) 1 else 0) + + (setBy.asKnown().getOrNull()?.validity() ?: 0) + + class Attribute @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val NAME = of("name") + + @JvmField val RUN_TYPE = of("run_type") + + @JvmField val TAG = of("tag") + + @JvmField val METADATA = of("metadata") + + @JvmStatic fun of(value: String) = Attribute(JsonField.of(value)) + } + + /** An enum containing [Attribute]'s known values. */ + enum class Known { + NAME, + RUN_TYPE, + TAG, + METADATA, + } + + /** + * An enum containing [Attribute]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Attribute] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + NAME, + RUN_TYPE, + TAG, + METADATA, + /** + * An enum member indicating that [Attribute] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + NAME -> Value.NAME + RUN_TYPE -> Value.RUN_TYPE + TAG -> Value.TAG + METADATA -> Value.METADATA + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + NAME -> Known.NAME + RUN_TYPE -> Known.RUN_TYPE + TAG -> Known.TAG + METADATA -> Known.METADATA + else -> throw LangsmithApiInvalidDataException("Unknown Attribute: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Attribute = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Attribute && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class SetBy @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SECTION = of("section") + + @JvmField val SERIES = of("series") + + @JvmStatic fun of(value: String) = SetBy(JsonField.of(value)) + } + + /** An enum containing [SetBy]'s known values. */ + enum class Known { + SECTION, + SERIES, + } + + /** + * An enum containing [SetBy]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [SetBy] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SECTION, + SERIES, + /** + * An enum member indicating that [SetBy] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SECTION -> Value.SECTION + SERIES -> Value.SERIES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + SECTION -> Known.SECTION + SERIES -> Known.SERIES + else -> throw LangsmithApiInvalidDataException("Unknown SetBy: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): SetBy = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SetBy && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupBy && + attribute == other.attribute && + maxGroups == other.maxGroups && + path == other.path && + setBy == other.setBy && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(attribute, maxGroups, path, setBy, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupBy{attribute=$attribute, maxGroups=$maxGroups, path=$path, setBy=$setBy, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomChartSeries && + id == other.id && + metric == other.metric && + name == other.name && + feedbackKey == other.feedbackKey && + filters == other.filters && + groupBy == other.groupBy && + projectMetric == other.projectMetric && + workspaceId == other.workspaceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + metric, + name, + feedbackKey, + filters, + groupBy, + projectMetric, + workspaceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomChartSeries{id=$id, metric=$metric, name=$name, feedbackKey=$feedbackKey, filters=$filters, groupBy=$groupBy, projectMetric=$projectMetric, workspaceId=$workspaceId, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartSeriesFilters.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartSeriesFilters.kt new file mode 100644 index 00000000..e026bc94 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartSeriesFilters.kt @@ -0,0 +1,293 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class CustomChartSeriesFilters +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val filter: JsonField, + private val session: JsonField>, + private val traceFilter: JsonField, + private val treeFilter: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("filter") @ExcludeMissing filter: JsonField = JsonMissing.of(), + @JsonProperty("session") + @ExcludeMissing + session: JsonField> = JsonMissing.of(), + @JsonProperty("trace_filter") + @ExcludeMissing + traceFilter: JsonField = JsonMissing.of(), + @JsonProperty("tree_filter") + @ExcludeMissing + treeFilter: JsonField = JsonMissing.of(), + ) : this(filter, session, traceFilter, treeFilter, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun filter(): Optional = filter.getOptional("filter") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun session(): Optional> = session.getOptional("session") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun traceFilter(): Optional = traceFilter.getOptional("trace_filter") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun treeFilter(): Optional = treeFilter.getOptional("tree_filter") + + /** + * Returns the raw JSON value of [filter]. + * + * Unlike [filter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField = filter + + /** + * Returns the raw JSON value of [session]. + * + * Unlike [session], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session") @ExcludeMissing fun _session(): JsonField> = session + + /** + * Returns the raw JSON value of [traceFilter]. + * + * Unlike [traceFilter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trace_filter") + @ExcludeMissing + fun _traceFilter(): JsonField = traceFilter + + /** + * Returns the raw JSON value of [treeFilter]. + * + * Unlike [treeFilter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tree_filter") @ExcludeMissing fun _treeFilter(): JsonField = treeFilter + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [CustomChartSeriesFilters]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomChartSeriesFilters]. */ + class Builder internal constructor() { + + private var filter: JsonField = JsonMissing.of() + private var session: JsonField>? = null + private var traceFilter: JsonField = JsonMissing.of() + private var treeFilter: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customChartSeriesFilters: CustomChartSeriesFilters) = apply { + filter = customChartSeriesFilters.filter + session = customChartSeriesFilters.session.map { it.toMutableList() } + traceFilter = customChartSeriesFilters.traceFilter + treeFilter = customChartSeriesFilters.treeFilter + additionalProperties = customChartSeriesFilters.additionalProperties.toMutableMap() + } + + fun filter(filter: String?) = filter(JsonField.ofNullable(filter)) + + /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ + fun filter(filter: Optional) = filter(filter.getOrNull()) + + /** + * Sets [Builder.filter] to an arbitrary JSON value. + * + * You should usually call [Builder.filter] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun filter(filter: JsonField) = apply { this.filter = filter } + + fun session(session: List?) = session(JsonField.ofNullable(session)) + + /** Alias for calling [Builder.session] with `session.orElse(null)`. */ + fun session(session: Optional>) = session(session.getOrNull()) + + /** + * Sets [Builder.session] to an arbitrary JSON value. + * + * You should usually call [Builder.session] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun session(session: JsonField>) = apply { + this.session = session.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.session]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSession(session: String) = apply { + this.session = + (this.session ?: JsonField.of(mutableListOf())).also { + checkKnown("session", it).add(session) + } + } + + fun traceFilter(traceFilter: String?) = traceFilter(JsonField.ofNullable(traceFilter)) + + /** Alias for calling [Builder.traceFilter] with `traceFilter.orElse(null)`. */ + fun traceFilter(traceFilter: Optional) = traceFilter(traceFilter.getOrNull()) + + /** + * Sets [Builder.traceFilter] to an arbitrary JSON value. + * + * You should usually call [Builder.traceFilter] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun traceFilter(traceFilter: JsonField) = apply { this.traceFilter = traceFilter } + + fun treeFilter(treeFilter: String?) = treeFilter(JsonField.ofNullable(treeFilter)) + + /** Alias for calling [Builder.treeFilter] with `treeFilter.orElse(null)`. */ + fun treeFilter(treeFilter: Optional) = treeFilter(treeFilter.getOrNull()) + + /** + * Sets [Builder.treeFilter] to an arbitrary JSON value. + * + * You should usually call [Builder.treeFilter] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun treeFilter(treeFilter: JsonField) = apply { this.treeFilter = treeFilter } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomChartSeriesFilters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CustomChartSeriesFilters = + CustomChartSeriesFilters( + filter, + (session ?: JsonMissing.of()).map { it.toImmutable() }, + traceFilter, + treeFilter, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CustomChartSeriesFilters = apply { + if (validated) { + return@apply + } + + filter() + session() + traceFilter() + treeFilter() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (filter.asKnown().isPresent) 1 else 0) + + (session.asKnown().getOrNull()?.size ?: 0) + + (if (traceFilter.asKnown().isPresent) 1 else 0) + + (if (treeFilter.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomChartSeriesFilters && + filter == other.filter && + session == other.session && + traceFilter == other.traceFilter && + treeFilter == other.treeFilter && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(filter, session, traceFilter, treeFilter, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomChartSeriesFilters{filter=$filter, session=$session, traceFilter=$traceFilter, treeFilter=$treeFilter, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartType.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartType.kt new file mode 100644 index 00000000..4a207a6d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartType.kt @@ -0,0 +1,137 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts + +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException + +/** Enum for custom chart types. */ +class CustomChartType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't match + * any known member, and you want to know that value. For example, if the SDK is on an older + * version than the API, then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val LINE = of("line") + + @JvmField val BAR = of("bar") + + @JvmStatic fun of(value: String) = CustomChartType(JsonField.of(value)) + } + + /** An enum containing [CustomChartType]'s known values. */ + enum class Known { + LINE, + BAR, + } + + /** + * An enum containing [CustomChartType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [CustomChartType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the SDK + * is on an older version than the API, then the API may respond with new members that the SDK + * is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LINE, + BAR, + /** + * An enum member indicating that [CustomChartType] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if + * the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want to + * throw for the unknown case. + */ + fun value(): Value = + when (this) { + LINE -> Value.LINE + BAR -> Value.BAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't want + * to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + LINE -> Known.LINE + BAR -> Known.BAR + else -> throw LangsmithApiInvalidDataException("Unknown CustomChartType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): CustomChartType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomChartType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartUpdate.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartUpdate.kt new file mode 100644 index 00000000..ee40c233 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartUpdate.kt @@ -0,0 +1,2394 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts + +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 com.langsmith_api.api.core.BaseDeserializer +import com.langsmith_api.api.core.BaseSerializer +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.allMaxBy +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.datasets.Missing +import com.langsmith_api.api.models.api.v1.sessions.RunStatsGroupBy +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class CustomChartUpdate +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val chartType: JsonField, + private val commonFilters: JsonField, + private val description: JsonField, + private val index: JsonField, + private val metadata: JsonField, + private val sectionId: JsonField, + private val series: JsonField, + private val title: JsonField, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("chart_type") + @ExcludeMissing + chartType: JsonField<ChartType> = JsonMissing.of(), + @JsonProperty("common_filters") + @ExcludeMissing + commonFilters: JsonField<CommonFilters> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<Description> = JsonMissing.of(), + @JsonProperty("index") @ExcludeMissing index: JsonField<Index> = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField<Metadata> = JsonMissing.of(), + @JsonProperty("section_id") + @ExcludeMissing + sectionId: JsonField<SectionId> = JsonMissing.of(), + @JsonProperty("series") @ExcludeMissing series: JsonField<Series> = JsonMissing.of(), + @JsonProperty("title") @ExcludeMissing title: JsonField<Title> = JsonMissing.of(), + ) : this( + chartType, + commonFilters, + description, + index, + metadata, + sectionId, + series, + title, + mutableMapOf(), + ) + + /** + * Enum for custom chart types. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun chartType(): Optional<ChartType> = chartType.getOptional("chart_type") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun commonFilters(): Optional<CommonFilters> = commonFilters.getOptional("common_filters") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<Description> = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun index(): Optional<Index> = index.getOptional("index") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional<Metadata> = metadata.getOptional("metadata") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun sectionId(): Optional<SectionId> = sectionId.getOptional("section_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun series(): Optional<Series> = series.getOptional("series") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun title(): Optional<Title> = title.getOptional("title") + + /** + * Returns the raw JSON value of [chartType]. + * + * Unlike [chartType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("chart_type") @ExcludeMissing fun _chartType(): JsonField<ChartType> = chartType + + /** + * Returns the raw JSON value of [commonFilters]. + * + * Unlike [commonFilters], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("common_filters") + @ExcludeMissing + fun _commonFilters(): JsonField<CommonFilters> = commonFilters + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField<Description> = description + + /** + * Returns the raw JSON value of [index]. + * + * Unlike [index], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("index") @ExcludeMissing fun _index(): JsonField<Index> = index + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField<Metadata> = metadata + + /** + * Returns the raw JSON value of [sectionId]. + * + * Unlike [sectionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("section_id") @ExcludeMissing fun _sectionId(): JsonField<SectionId> = sectionId + + /** + * Returns the raw JSON value of [series]. + * + * Unlike [series], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("series") @ExcludeMissing fun _series(): JsonField<Series> = series + + /** + * Returns the raw JSON value of [title]. + * + * Unlike [title], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("title") @ExcludeMissing fun _title(): JsonField<Title> = title + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [CustomChartUpdate]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomChartUpdate]. */ + class Builder internal constructor() { + + private var chartType: JsonField<ChartType> = JsonMissing.of() + private var commonFilters: JsonField<CommonFilters> = JsonMissing.of() + private var description: JsonField<Description> = JsonMissing.of() + private var index: JsonField<Index> = JsonMissing.of() + private var metadata: JsonField<Metadata> = JsonMissing.of() + private var sectionId: JsonField<SectionId> = JsonMissing.of() + private var series: JsonField<Series> = JsonMissing.of() + private var title: JsonField<Title> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(customChartUpdate: CustomChartUpdate) = apply { + chartType = customChartUpdate.chartType + commonFilters = customChartUpdate.commonFilters + description = customChartUpdate.description + index = customChartUpdate.index + metadata = customChartUpdate.metadata + sectionId = customChartUpdate.sectionId + series = customChartUpdate.series + title = customChartUpdate.title + additionalProperties = customChartUpdate.additionalProperties.toMutableMap() + } + + /** Enum for custom chart types. */ + fun chartType(chartType: ChartType) = chartType(JsonField.of(chartType)) + + /** + * Sets [Builder.chartType] to an arbitrary JSON value. + * + * You should usually call [Builder.chartType] with a well-typed [ChartType] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun chartType(chartType: JsonField<ChartType>) = apply { this.chartType = chartType } + + /** Alias for calling [chartType] with `ChartType.ofCustom(custom)`. */ + fun chartType(custom: CustomChartType) = chartType(ChartType.ofCustom(custom)) + + /** Alias for calling [chartType] with `ChartType.ofMissing(missing)`. */ + fun chartType(missing: Missing) = chartType(ChartType.ofMissing(missing)) + + fun commonFilters(commonFilters: CommonFilters?) = + commonFilters(JsonField.ofNullable(commonFilters)) + + /** Alias for calling [Builder.commonFilters] with `commonFilters.orElse(null)`. */ + fun commonFilters(commonFilters: Optional<CommonFilters>) = + commonFilters(commonFilters.getOrNull()) + + /** + * Sets [Builder.commonFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.commonFilters] with a well-typed [CommonFilters] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun commonFilters(commonFilters: JsonField<CommonFilters>) = apply { + this.commonFilters = commonFilters + } + + /** + * Alias for calling [commonFilters] with + * `CommonFilters.ofCustomChartSeries(customChartSeries)`. + */ + fun commonFilters(customChartSeries: CustomChartSeriesFilters) = + commonFilters(CommonFilters.ofCustomChartSeries(customChartSeries)) + + /** Alias for calling [commonFilters] with `CommonFilters.ofMissing(missing)`. */ + fun commonFilters(missing: Missing) = commonFilters(CommonFilters.ofMissing(missing)) + + fun description(description: Description?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<Description>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [Description] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField<Description>) = apply { + this.description = description + } + + /** Alias for calling [description] with `Description.ofString(string)`. */ + fun description(string: String) = description(Description.ofString(string)) + + /** Alias for calling [description] with `Description.ofMissing(missing)`. */ + fun description(missing: Missing) = description(Description.ofMissing(missing)) + + fun index(index: Index) = index(JsonField.of(index)) + + /** + * Sets [Builder.index] to an arbitrary JSON value. + * + * You should usually call [Builder.index] with a well-typed [Index] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun index(index: JsonField<Index>) = apply { this.index = index } + + /** Alias for calling [index] with `Index.ofInteger(integer)`. */ + fun index(integer: Long) = index(Index.ofInteger(integer)) + + /** Alias for calling [index] with `Index.ofMissing(missing)`. */ + fun index(missing: Missing) = index(Index.ofMissing(missing)) + + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional<Metadata>) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField<Metadata>) = apply { this.metadata = metadata } + + /** Alias for calling [metadata] with `Metadata.ofJsonValue(jsonValue)`. */ + fun metadata(jsonValue: JsonValue) = metadata(Metadata.ofJsonValue(jsonValue)) + + /** Alias for calling [metadata] with `Metadata.ofMissing(missing)`. */ + fun metadata(missing: Missing) = metadata(Metadata.ofMissing(missing)) + + fun sectionId(sectionId: SectionId) = sectionId(JsonField.of(sectionId)) + + /** + * Sets [Builder.sectionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sectionId] with a well-typed [SectionId] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun sectionId(sectionId: JsonField<SectionId>) = apply { this.sectionId = sectionId } + + /** Alias for calling [sectionId] with `SectionId.ofString(string)`. */ + fun sectionId(string: String) = sectionId(SectionId.ofString(string)) + + /** Alias for calling [sectionId] with `SectionId.ofMissing(missing)`. */ + fun sectionId(missing: Missing) = sectionId(SectionId.ofMissing(missing)) + + fun series(series: Series) = series(JsonField.of(series)) + + /** + * Sets [Builder.series] to an arbitrary JSON value. + * + * You should usually call [Builder.series] with a well-typed [Series] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun series(series: JsonField<Series>) = apply { this.series = series } + + /** + * Alias for calling [series] with + * `Series.ofCustomChartSeriesUpdates(customChartSeriesUpdates)`. + */ + fun seriesOfCustomChartSeriesUpdates( + customChartSeriesUpdates: List<Series.CustomChartSeriesUpdate> + ) = series(Series.ofCustomChartSeriesUpdates(customChartSeriesUpdates)) + + /** Alias for calling [series] with `Series.ofMissing(missing)`. */ + fun series(missing: Missing) = series(Series.ofMissing(missing)) + + fun title(title: Title) = title(JsonField.of(title)) + + /** + * Sets [Builder.title] to an arbitrary JSON value. + * + * You should usually call [Builder.title] with a well-typed [Title] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun title(title: JsonField<Title>) = apply { this.title = title } + + /** Alias for calling [title] with `Title.ofString(string)`. */ + fun title(string: String) = title(Title.ofString(string)) + + /** Alias for calling [title] with `Title.ofMissing(missing)`. */ + fun title(missing: Missing) = title(Title.ofMissing(missing)) + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomChartUpdate]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CustomChartUpdate = + CustomChartUpdate( + chartType, + commonFilters, + description, + index, + metadata, + sectionId, + series, + title, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CustomChartUpdate = apply { + if (validated) { + return@apply + } + + chartType().ifPresent { it.validate() } + commonFilters().ifPresent { it.validate() } + description().ifPresent { it.validate() } + index().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + sectionId().ifPresent { it.validate() } + series().ifPresent { it.validate() } + title().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (chartType.asKnown().getOrNull()?.validity() ?: 0) + + (commonFilters.asKnown().getOrNull()?.validity() ?: 0) + + (description.asKnown().getOrNull()?.validity() ?: 0) + + (index.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (sectionId.asKnown().getOrNull()?.validity() ?: 0) + + (series.asKnown().getOrNull()?.validity() ?: 0) + + (title.asKnown().getOrNull()?.validity() ?: 0) + + /** Enum for custom chart types. */ + @JsonDeserialize(using = ChartType.Deserializer::class) + @JsonSerialize(using = ChartType.Serializer::class) + class ChartType + private constructor( + private val custom: CustomChartType? = null, + private val missing: Missing? = null, + private val _json: JsonValue? = null, + ) { + + /** Enum for custom chart types. */ + fun custom(): Optional<CustomChartType> = Optional.ofNullable(custom) + + fun missing(): Optional<Missing> = Optional.ofNullable(missing) + + fun isCustom(): Boolean = custom != null + + fun isMissing(): Boolean = missing != null + + /** Enum for custom chart types. */ + fun asCustom(): CustomChartType = custom.getOrThrow("custom") + + fun asMissing(): Missing = missing.getOrThrow("missing") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + custom != null -> visitor.visitCustom(custom) + missing != null -> visitor.visitMissing(missing) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): ChartType = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitCustom(custom: CustomChartType) { + custom.validate() + } + + override fun visitMissing(missing: Missing) { + missing.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitCustom(custom: CustomChartType) = custom.validity() + + override fun visitMissing(missing: Missing) = missing.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChartType && custom == other.custom && missing == other.missing + } + + override fun hashCode(): Int = Objects.hash(custom, missing) + + override fun toString(): String = + when { + custom != null -> "ChartType{custom=$custom}" + missing != null -> "ChartType{missing=$missing}" + _json != null -> "ChartType{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ChartType") + } + + companion object { + + /** Enum for custom chart types. */ + @JvmStatic fun ofCustom(custom: CustomChartType) = ChartType(custom = custom) + + @JvmStatic fun ofMissing(missing: Missing) = ChartType(missing = missing) + } + + /** + * An interface that defines how to map each variant of [ChartType] to a value of type [T]. + */ + interface Visitor<out T> { + + /** Enum for custom chart types. */ + fun visitCustom(custom: CustomChartType): T + + fun visitMissing(missing: Missing): T + + /** + * Maps an unknown variant of [ChartType] to a value of type [T]. + * + * An instance of [ChartType] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown ChartType: $json") + } + } + + internal class Deserializer : BaseDeserializer<ChartType>(ChartType::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ChartType { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<CustomChartType>())?.let { + ChartType(custom = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<Missing>())?.let { + ChartType(missing = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from array). + 0 -> ChartType(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<ChartType>(ChartType::class) { + + override fun serialize( + value: ChartType, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.custom != null -> generator.writeObject(value.custom) + value.missing != null -> generator.writeObject(value.missing) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ChartType") + } + } + } + } + + @JsonDeserialize(using = CommonFilters.Deserializer::class) + @JsonSerialize(using = CommonFilters.Serializer::class) + class CommonFilters + private constructor( + private val customChartSeries: CustomChartSeriesFilters? = null, + private val missing: Missing? = null, + private val _json: JsonValue? = null, + ) { + + fun customChartSeries(): Optional<CustomChartSeriesFilters> = + Optional.ofNullable(customChartSeries) + + fun missing(): Optional<Missing> = Optional.ofNullable(missing) + + fun isCustomChartSeries(): Boolean = customChartSeries != null + + fun isMissing(): Boolean = missing != null + + fun asCustomChartSeries(): CustomChartSeriesFilters = + customChartSeries.getOrThrow("customChartSeries") + + fun asMissing(): Missing = missing.getOrThrow("missing") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + customChartSeries != null -> visitor.visitCustomChartSeries(customChartSeries) + missing != null -> visitor.visitMissing(missing) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): CommonFilters = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitCustomChartSeries( + customChartSeries: CustomChartSeriesFilters + ) { + customChartSeries.validate() + } + + override fun visitMissing(missing: Missing) { + missing.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitCustomChartSeries( + customChartSeries: CustomChartSeriesFilters + ) = customChartSeries.validity() + + override fun visitMissing(missing: Missing) = missing.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CommonFilters && + customChartSeries == other.customChartSeries && + missing == other.missing + } + + override fun hashCode(): Int = Objects.hash(customChartSeries, missing) + + override fun toString(): String = + when { + customChartSeries != null -> "CommonFilters{customChartSeries=$customChartSeries}" + missing != null -> "CommonFilters{missing=$missing}" + _json != null -> "CommonFilters{_unknown=$_json}" + else -> throw IllegalStateException("Invalid CommonFilters") + } + + companion object { + + @JvmStatic + fun ofCustomChartSeries(customChartSeries: CustomChartSeriesFilters) = + CommonFilters(customChartSeries = customChartSeries) + + @JvmStatic fun ofMissing(missing: Missing) = CommonFilters(missing = missing) + } + + /** + * An interface that defines how to map each variant of [CommonFilters] to a value of type + * [T]. + */ + interface Visitor<out T> { + + fun visitCustomChartSeries(customChartSeries: CustomChartSeriesFilters): T + + fun visitMissing(missing: Missing): T + + /** + * Maps an unknown variant of [CommonFilters] to a value of type [T]. + * + * An instance of [CommonFilters] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown CommonFilters: $json") + } + } + + internal class Deserializer : BaseDeserializer<CommonFilters>(CommonFilters::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): CommonFilters { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<CustomChartSeriesFilters>())?.let { + CommonFilters(customChartSeries = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<Missing>())?.let { + CommonFilters(missing = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> CommonFilters(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<CommonFilters>(CommonFilters::class) { + + override fun serialize( + value: CommonFilters, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.customChartSeries != null -> + generator.writeObject(value.customChartSeries) + value.missing != null -> generator.writeObject(value.missing) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid CommonFilters") + } + } + } + } + + @JsonDeserialize(using = Description.Deserializer::class) + @JsonSerialize(using = Description.Serializer::class) + class Description + private constructor( + private val string: String? = null, + private val missing: Missing? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun missing(): Optional<Missing> = Optional.ofNullable(missing) + + fun isString(): Boolean = string != null + + fun isMissing(): Boolean = missing != null + + fun asString(): String = string.getOrThrow("string") + + fun asMissing(): Missing = missing.getOrThrow("missing") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + string != null -> visitor.visitString(string) + missing != null -> visitor.visitMissing(missing) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Description = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitString(string: String) {} + + override fun visitMissing(missing: Missing) { + missing.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitString(string: String) = 1 + + override fun visitMissing(missing: Missing) = missing.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Description && string == other.string && missing == other.missing + } + + override fun hashCode(): Int = Objects.hash(string, missing) + + override fun toString(): String = + when { + string != null -> "Description{string=$string}" + missing != null -> "Description{missing=$missing}" + _json != null -> "Description{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Description") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Description(string = string) + + @JvmStatic fun ofMissing(missing: Missing) = Description(missing = missing) + } + + /** + * An interface that defines how to map each variant of [Description] to a value of type + * [T]. + */ + interface Visitor<out T> { + + fun visitString(string: String): T + + fun visitMissing(missing: Missing): T + + /** + * Maps an unknown variant of [Description] to a value of type [T]. + * + * An instance of [Description] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Description: $json") + } + } + + internal class Deserializer : BaseDeserializer<Description>(Description::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Description { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<Missing>())?.let { + Description(missing = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<String>())?.let { + Description(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from array). + 0 -> Description(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Description>(Description::class) { + + override fun serialize( + value: Description, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.missing != null -> generator.writeObject(value.missing) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Description") + } + } + } + } + + @JsonDeserialize(using = Index.Deserializer::class) + @JsonSerialize(using = Index.Serializer::class) + class Index + private constructor( + private val integer: Long? = null, + private val missing: Missing? = null, + private val _json: JsonValue? = null, + ) { + + fun integer(): Optional<Long> = Optional.ofNullable(integer) + + fun missing(): Optional<Missing> = Optional.ofNullable(missing) + + fun isInteger(): Boolean = integer != null + + fun isMissing(): Boolean = missing != null + + fun asInteger(): Long = integer.getOrThrow("integer") + + fun asMissing(): Missing = missing.getOrThrow("missing") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + integer != null -> visitor.visitInteger(integer) + missing != null -> visitor.visitMissing(missing) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Index = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitInteger(integer: Long) {} + + override fun visitMissing(missing: Missing) { + missing.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitInteger(integer: Long) = 1 + + override fun visitMissing(missing: Missing) = missing.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Index && integer == other.integer && missing == other.missing + } + + override fun hashCode(): Int = Objects.hash(integer, missing) + + override fun toString(): String = + when { + integer != null -> "Index{integer=$integer}" + missing != null -> "Index{missing=$missing}" + _json != null -> "Index{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Index") + } + + companion object { + + @JvmStatic fun ofInteger(integer: Long) = Index(integer = integer) + + @JvmStatic fun ofMissing(missing: Missing) = Index(missing = missing) + } + + /** An interface that defines how to map each variant of [Index] to a value of type [T]. */ + interface Visitor<out T> { + + fun visitInteger(integer: Long): T + + fun visitMissing(missing: Missing): T + + /** + * Maps an unknown variant of [Index] to a value of type [T]. + * + * An instance of [Index] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Index: $json") + } + } + + internal class Deserializer : BaseDeserializer<Index>(Index::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Index { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<Missing>())?.let { + Index(missing = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<Long>())?.let { + Index(integer = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> Index(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Index>(Index::class) { + + override fun serialize( + value: Index, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.integer != null -> generator.writeObject(value.integer) + value.missing != null -> generator.writeObject(value.missing) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Index") + } + } + } + } + + @JsonDeserialize(using = Metadata.Deserializer::class) + @JsonSerialize(using = Metadata.Serializer::class) + class Metadata + private constructor( + private val jsonValue: JsonValue? = null, + private val missing: Missing? = null, + private val _json: JsonValue? = null, + ) { + + fun jsonValue(): Optional<JsonValue> = Optional.ofNullable(jsonValue) + + fun missing(): Optional<Missing> = Optional.ofNullable(missing) + + fun isJsonValue(): Boolean = jsonValue != null + + fun isMissing(): Boolean = missing != null + + fun asJsonValue(): JsonValue = jsonValue.getOrThrow("jsonValue") + + fun asMissing(): Missing = missing.getOrThrow("missing") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + jsonValue != null -> visitor.visitJsonValue(jsonValue) + missing != null -> visitor.visitMissing(missing) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitJsonValue(jsonValue: JsonValue) {} + + override fun visitMissing(missing: Missing) { + missing.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun visitMissing(missing: Missing) = missing.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && jsonValue == other.jsonValue && missing == other.missing + } + + override fun hashCode(): Int = Objects.hash(jsonValue, missing) + + override fun toString(): String = + when { + jsonValue != null -> "Metadata{jsonValue=$jsonValue}" + missing != null -> "Metadata{missing=$missing}" + _json != null -> "Metadata{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Metadata") + } + + companion object { + + @JvmStatic fun ofJsonValue(jsonValue: JsonValue) = Metadata(jsonValue = jsonValue) + + @JvmStatic fun ofMissing(missing: Missing) = Metadata(missing = missing) + } + + /** + * An interface that defines how to map each variant of [Metadata] to a value of type [T]. + */ + interface Visitor<out T> { + + fun visitJsonValue(jsonValue: JsonValue): T + + fun visitMissing(missing: Missing): T + + /** + * Maps an unknown variant of [Metadata] to a value of type [T]. + * + * An instance of [Metadata] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Metadata: $json") + } + } + + internal class Deserializer : BaseDeserializer<Metadata>(Metadata::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Metadata { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<Missing>())?.let { + Metadata(missing = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<JsonValue>())?.let { + Metadata(jsonValue = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants. + 0 -> Metadata(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Metadata>(Metadata::class) { + + override fun serialize( + value: Metadata, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.jsonValue != null -> generator.writeObject(value.jsonValue) + value.missing != null -> generator.writeObject(value.missing) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Metadata") + } + } + } + } + + @JsonDeserialize(using = SectionId.Deserializer::class) + @JsonSerialize(using = SectionId.Serializer::class) + class SectionId + private constructor( + private val string: String? = null, + private val missing: Missing? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun missing(): Optional<Missing> = Optional.ofNullable(missing) + + fun isString(): Boolean = string != null + + fun isMissing(): Boolean = missing != null + + fun asString(): String = string.getOrThrow("string") + + fun asMissing(): Missing = missing.getOrThrow("missing") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + string != null -> visitor.visitString(string) + missing != null -> visitor.visitMissing(missing) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): SectionId = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitString(string: String) {} + + override fun visitMissing(missing: Missing) { + missing.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitString(string: String) = 1 + + override fun visitMissing(missing: Missing) = missing.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SectionId && string == other.string && missing == other.missing + } + + override fun hashCode(): Int = Objects.hash(string, missing) + + override fun toString(): String = + when { + string != null -> "SectionId{string=$string}" + missing != null -> "SectionId{missing=$missing}" + _json != null -> "SectionId{_unknown=$_json}" + else -> throw IllegalStateException("Invalid SectionId") + } + + companion object { + + @JvmStatic fun ofString(string: String) = SectionId(string = string) + + @JvmStatic fun ofMissing(missing: Missing) = SectionId(missing = missing) + } + + /** + * An interface that defines how to map each variant of [SectionId] to a value of type [T]. + */ + interface Visitor<out T> { + + fun visitString(string: String): T + + fun visitMissing(missing: Missing): T + + /** + * Maps an unknown variant of [SectionId] to a value of type [T]. + * + * An instance of [SectionId] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown SectionId: $json") + } + } + + internal class Deserializer : BaseDeserializer<SectionId>(SectionId::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): SectionId { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<Missing>())?.let { + SectionId(missing = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<String>())?.let { + SectionId(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from array). + 0 -> SectionId(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<SectionId>(SectionId::class) { + + override fun serialize( + value: SectionId, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.missing != null -> generator.writeObject(value.missing) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid SectionId") + } + } + } + } + + @JsonDeserialize(using = Series.Deserializer::class) + @JsonSerialize(using = Series.Serializer::class) + class Series + private constructor( + private val customChartSeriesUpdates: List<CustomChartSeriesUpdate>? = null, + private val missing: Missing? = null, + private val _json: JsonValue? = null, + ) { + + fun customChartSeriesUpdates(): Optional<List<CustomChartSeriesUpdate>> = + Optional.ofNullable(customChartSeriesUpdates) + + fun missing(): Optional<Missing> = Optional.ofNullable(missing) + + fun isCustomChartSeriesUpdates(): Boolean = customChartSeriesUpdates != null + + fun isMissing(): Boolean = missing != null + + fun asCustomChartSeriesUpdates(): List<CustomChartSeriesUpdate> = + customChartSeriesUpdates.getOrThrow("customChartSeriesUpdates") + + fun asMissing(): Missing = missing.getOrThrow("missing") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + customChartSeriesUpdates != null -> + visitor.visitCustomChartSeriesUpdates(customChartSeriesUpdates) + missing != null -> visitor.visitMissing(missing) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Series = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitCustomChartSeriesUpdates( + customChartSeriesUpdates: List<CustomChartSeriesUpdate> + ) { + customChartSeriesUpdates.forEach { it.validate() } + } + + override fun visitMissing(missing: Missing) { + missing.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitCustomChartSeriesUpdates( + customChartSeriesUpdates: List<CustomChartSeriesUpdate> + ) = customChartSeriesUpdates.sumOf { it.validity().toInt() } + + override fun visitMissing(missing: Missing) = missing.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Series && + customChartSeriesUpdates == other.customChartSeriesUpdates && + missing == other.missing + } + + override fun hashCode(): Int = Objects.hash(customChartSeriesUpdates, missing) + + override fun toString(): String = + when { + customChartSeriesUpdates != null -> + "Series{customChartSeriesUpdates=$customChartSeriesUpdates}" + missing != null -> "Series{missing=$missing}" + _json != null -> "Series{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Series") + } + + companion object { + + @JvmStatic + fun ofCustomChartSeriesUpdates( + customChartSeriesUpdates: List<CustomChartSeriesUpdate> + ) = Series(customChartSeriesUpdates = customChartSeriesUpdates.toImmutable()) + + @JvmStatic fun ofMissing(missing: Missing) = Series(missing = missing) + } + + /** An interface that defines how to map each variant of [Series] to a value of type [T]. */ + interface Visitor<out T> { + + fun visitCustomChartSeriesUpdates( + customChartSeriesUpdates: List<CustomChartSeriesUpdate> + ): T + + fun visitMissing(missing: Missing): T + + /** + * Maps an unknown variant of [Series] to a value of type [T]. + * + * An instance of [Series] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Series: $json") + } + } + + internal class Deserializer : BaseDeserializer<Series>(Series::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Series { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<Missing>())?.let { + Series(missing = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<List<CustomChartSeriesUpdate>>()) + ?.let { Series(customChartSeriesUpdates = it, _json = json) }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> Series(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Series>(Series::class) { + + override fun serialize( + value: Series, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.customChartSeriesUpdates != null -> + generator.writeObject(value.customChartSeriesUpdates) + value.missing != null -> generator.writeObject(value.missing) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Series") + } + } + } + + class CustomChartSeriesUpdate + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val metric: JsonField<CustomChartMetric>, + private val name: JsonField<String>, + private val id: JsonField<String>, + private val feedbackKey: JsonField<String>, + private val filters: JsonField<CustomChartSeriesFilters>, + private val groupBy: JsonField<RunStatsGroupBy>, + private val projectMetric: JsonField<HostProjectChartMetric>, + private val workspaceId: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("metric") + @ExcludeMissing + metric: JsonField<CustomChartMetric> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("feedback_key") + @ExcludeMissing + feedbackKey: JsonField<String> = JsonMissing.of(), + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField<CustomChartSeriesFilters> = JsonMissing.of(), + @JsonProperty("group_by") + @ExcludeMissing + groupBy: JsonField<RunStatsGroupBy> = JsonMissing.of(), + @JsonProperty("project_metric") + @ExcludeMissing + projectMetric: JsonField<HostProjectChartMetric> = JsonMissing.of(), + @JsonProperty("workspace_id") + @ExcludeMissing + workspaceId: JsonField<String> = JsonMissing.of(), + ) : this( + metric, + name, + id, + feedbackKey, + filters, + groupBy, + projectMetric, + workspaceId, + mutableMapOf(), + ) + + /** + * Metrics you can chart. Feedback metrics are not available for organization-scoped + * charts. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun metric(): CustomChartMetric = metric.getRequired("metric") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun feedbackKey(): Optional<String> = feedbackKey.getOptional("feedback_key") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun filters(): Optional<CustomChartSeriesFilters> = filters.getOptional("filters") + + /** + * Group by param for run stats. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupBy(): Optional<RunStatsGroupBy> = groupBy.getOptional("group_by") + + /** + * LGP Metrics you can chart. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun projectMetric(): Optional<HostProjectChartMetric> = + projectMetric.getOptional("project_metric") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun workspaceId(): Optional<String> = workspaceId.getOptional("workspace_id") + + /** + * Returns the raw JSON value of [metric]. + * + * Unlike [metric], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metric") + @ExcludeMissing + fun _metric(): JsonField<CustomChartMetric> = metric + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [feedbackKey]. + * + * Unlike [feedbackKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("feedback_key") + @ExcludeMissing + fun _feedbackKey(): JsonField<String> = feedbackKey + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField<CustomChartSeriesFilters> = filters + + /** + * Returns the raw JSON value of [groupBy]. + * + * Unlike [groupBy], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("group_by") + @ExcludeMissing + fun _groupBy(): JsonField<RunStatsGroupBy> = groupBy + + /** + * Returns the raw JSON value of [projectMetric]. + * + * Unlike [projectMetric], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("project_metric") + @ExcludeMissing + fun _projectMetric(): JsonField<HostProjectChartMetric> = projectMetric + + /** + * Returns the raw JSON value of [workspaceId]. + * + * Unlike [workspaceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("workspace_id") + @ExcludeMissing + fun _workspaceId(): JsonField<String> = workspaceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CustomChartSeriesUpdate]. + * + * The following fields are required: + * ```java + * .metric() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomChartSeriesUpdate]. */ + class Builder internal constructor() { + + private var metric: JsonField<CustomChartMetric>? = null + private var name: JsonField<String>? = null + private var id: JsonField<String> = JsonMissing.of() + private var feedbackKey: JsonField<String> = JsonMissing.of() + private var filters: JsonField<CustomChartSeriesFilters> = JsonMissing.of() + private var groupBy: JsonField<RunStatsGroupBy> = JsonMissing.of() + private var projectMetric: JsonField<HostProjectChartMetric> = JsonMissing.of() + private var workspaceId: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(customChartSeriesUpdate: CustomChartSeriesUpdate) = apply { + metric = customChartSeriesUpdate.metric + name = customChartSeriesUpdate.name + id = customChartSeriesUpdate.id + feedbackKey = customChartSeriesUpdate.feedbackKey + filters = customChartSeriesUpdate.filters + groupBy = customChartSeriesUpdate.groupBy + projectMetric = customChartSeriesUpdate.projectMetric + workspaceId = customChartSeriesUpdate.workspaceId + additionalProperties = + customChartSeriesUpdate.additionalProperties.toMutableMap() + } + + /** + * Metrics you can chart. Feedback metrics are not available for organization-scoped + * charts. + */ + fun metric(metric: CustomChartMetric) = metric(JsonField.of(metric)) + + /** + * Sets [Builder.metric] to an arbitrary JSON value. + * + * You should usually call [Builder.metric] with a well-typed [CustomChartMetric] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun metric(metric: JsonField<CustomChartMetric>) = apply { this.metric = metric } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun id(id: String?) = id(JsonField.ofNullable(id)) + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<String>) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun feedbackKey(feedbackKey: String?) = + feedbackKey(JsonField.ofNullable(feedbackKey)) + + /** Alias for calling [Builder.feedbackKey] with `feedbackKey.orElse(null)`. */ + fun feedbackKey(feedbackKey: Optional<String>) = + feedbackKey(feedbackKey.getOrNull()) + + /** + * Sets [Builder.feedbackKey] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun feedbackKey(feedbackKey: JsonField<String>) = apply { + this.feedbackKey = feedbackKey + } + + fun filters(filters: CustomChartSeriesFilters?) = + filters(JsonField.ofNullable(filters)) + + /** Alias for calling [Builder.filters] with `filters.orElse(null)`. */ + fun filters(filters: Optional<CustomChartSeriesFilters>) = + filters(filters.getOrNull()) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed + * [CustomChartSeriesFilters] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField<CustomChartSeriesFilters>) = apply { + this.filters = filters + } + + /** Group by param for run stats. */ + fun groupBy(groupBy: RunStatsGroupBy?) = groupBy(JsonField.ofNullable(groupBy)) + + /** Alias for calling [Builder.groupBy] with `groupBy.orElse(null)`. */ + fun groupBy(groupBy: Optional<RunStatsGroupBy>) = groupBy(groupBy.getOrNull()) + + /** + * Sets [Builder.groupBy] to an arbitrary JSON value. + * + * You should usually call [Builder.groupBy] with a well-typed [RunStatsGroupBy] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun groupBy(groupBy: JsonField<RunStatsGroupBy>) = apply { this.groupBy = groupBy } + + /** LGP Metrics you can chart. */ + fun projectMetric(projectMetric: HostProjectChartMetric?) = + projectMetric(JsonField.ofNullable(projectMetric)) + + /** Alias for calling [Builder.projectMetric] with `projectMetric.orElse(null)`. */ + fun projectMetric(projectMetric: Optional<HostProjectChartMetric>) = + projectMetric(projectMetric.getOrNull()) + + /** + * Sets [Builder.projectMetric] to an arbitrary JSON value. + * + * You should usually call [Builder.projectMetric] with a well-typed + * [HostProjectChartMetric] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun projectMetric(projectMetric: JsonField<HostProjectChartMetric>) = apply { + this.projectMetric = projectMetric + } + + fun workspaceId(workspaceId: String?) = + workspaceId(JsonField.ofNullable(workspaceId)) + + /** Alias for calling [Builder.workspaceId] with `workspaceId.orElse(null)`. */ + fun workspaceId(workspaceId: Optional<String>) = + workspaceId(workspaceId.getOrNull()) + + /** + * Sets [Builder.workspaceId] to an arbitrary JSON value. + * + * You should usually call [Builder.workspaceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun workspaceId(workspaceId: JsonField<String>) = apply { + this.workspaceId = workspaceId + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomChartSeriesUpdate]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .metric() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomChartSeriesUpdate = + CustomChartSeriesUpdate( + checkRequired("metric", metric), + checkRequired("name", name), + id, + feedbackKey, + filters, + groupBy, + projectMetric, + workspaceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CustomChartSeriesUpdate = apply { + if (validated) { + return@apply + } + + metric().validate() + name() + id() + feedbackKey() + filters().ifPresent { it.validate() } + groupBy().ifPresent { it.validate() } + projectMetric().ifPresent { it.validate() } + workspaceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (metric.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (id.asKnown().isPresent) 1 else 0) + + (if (feedbackKey.asKnown().isPresent) 1 else 0) + + (filters.asKnown().getOrNull()?.validity() ?: 0) + + (groupBy.asKnown().getOrNull()?.validity() ?: 0) + + (projectMetric.asKnown().getOrNull()?.validity() ?: 0) + + (if (workspaceId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomChartSeriesUpdate && + metric == other.metric && + name == other.name && + id == other.id && + feedbackKey == other.feedbackKey && + filters == other.filters && + groupBy == other.groupBy && + projectMetric == other.projectMetric && + workspaceId == other.workspaceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + metric, + name, + id, + feedbackKey, + filters, + groupBy, + projectMetric, + workspaceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomChartSeriesUpdate{metric=$metric, name=$name, id=$id, feedbackKey=$feedbackKey, filters=$filters, groupBy=$groupBy, projectMetric=$projectMetric, workspaceId=$workspaceId, additionalProperties=$additionalProperties}" + } + } + + @JsonDeserialize(using = Title.Deserializer::class) + @JsonSerialize(using = Title.Serializer::class) + class Title + private constructor( + private val string: String? = null, + private val missing: Missing? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun missing(): Optional<Missing> = Optional.ofNullable(missing) + + fun isString(): Boolean = string != null + + fun isMissing(): Boolean = missing != null + + fun asString(): String = string.getOrThrow("string") + + fun asMissing(): Missing = missing.getOrThrow("missing") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + string != null -> visitor.visitString(string) + missing != null -> visitor.visitMissing(missing) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Title = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitString(string: String) {} + + override fun visitMissing(missing: Missing) { + missing.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitString(string: String) = 1 + + override fun visitMissing(missing: Missing) = missing.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Title && string == other.string && missing == other.missing + } + + override fun hashCode(): Int = Objects.hash(string, missing) + + override fun toString(): String = + when { + string != null -> "Title{string=$string}" + missing != null -> "Title{missing=$missing}" + _json != null -> "Title{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Title") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Title(string = string) + + @JvmStatic fun ofMissing(missing: Missing) = Title(missing = missing) + } + + /** An interface that defines how to map each variant of [Title] to a value of type [T]. */ + interface Visitor<out T> { + + fun visitString(string: String): T + + fun visitMissing(missing: Missing): T + + /** + * Maps an unknown variant of [Title] to a value of type [T]. + * + * An instance of [Title] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Title: $json") + } + } + + internal class Deserializer : BaseDeserializer<Title>(Title::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Title { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<Missing>())?.let { + Title(missing = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<String>())?.let { + Title(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from array). + 0 -> Title(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Title>(Title::class) { + + override fun serialize( + value: Title, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.missing != null -> generator.writeObject(value.missing) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Title") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomChartUpdate && + chartType == other.chartType && + commonFilters == other.commonFilters && + description == other.description && + index == other.index && + metadata == other.metadata && + sectionId == other.sectionId && + series == other.series && + title == other.title && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + chartType, + commonFilters, + description, + index, + metadata, + sectionId, + series, + title, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomChartUpdate{chartType=$chartType, commonFilters=$commonFilters, description=$description, index=$index, metadata=$metadata, sectionId=$sectionId, series=$series, title=$title, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartsDataPoint.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartsDataPoint.kt new file mode 100644 index 00000000..bebc21a2 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartsDataPoint.kt @@ -0,0 +1,469 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts + +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 com.langsmith_api.api.core.BaseDeserializer +import com.langsmith_api.api.core.BaseSerializer +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.allMaxBy +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class CustomChartsDataPoint +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val seriesId: JsonField<String>, + private val timestamp: JsonField<OffsetDateTime>, + private val value: JsonField<Value>, + private val group: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("series_id") @ExcludeMissing seriesId: JsonField<String> = JsonMissing.of(), + @JsonProperty("timestamp") + @ExcludeMissing + timestamp: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField<Value> = JsonMissing.of(), + @JsonProperty("group") @ExcludeMissing group: JsonField<String> = JsonMissing.of(), + ) : this(seriesId, timestamp, value, group, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun seriesId(): String = seriesId.getRequired("series_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun timestamp(): OffsetDateTime = timestamp.getRequired("timestamp") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun value(): Optional<Value> = value.getOptional("value") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun group(): Optional<String> = group.getOptional("group") + + /** + * Returns the raw JSON value of [seriesId]. + * + * Unlike [seriesId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("series_id") @ExcludeMissing fun _seriesId(): JsonField<String> = seriesId + + /** + * Returns the raw JSON value of [timestamp]. + * + * Unlike [timestamp], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("timestamp") + @ExcludeMissing + fun _timestamp(): JsonField<OffsetDateTime> = timestamp + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField<Value> = value + + /** + * Returns the raw JSON value of [group]. + * + * Unlike [group], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("group") @ExcludeMissing fun _group(): JsonField<String> = group + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CustomChartsDataPoint]. + * + * The following fields are required: + * ```java + * .seriesId() + * .timestamp() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomChartsDataPoint]. */ + class Builder internal constructor() { + + private var seriesId: JsonField<String>? = null + private var timestamp: JsonField<OffsetDateTime>? = null + private var value: JsonField<Value>? = null + private var group: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(customChartsDataPoint: CustomChartsDataPoint) = apply { + seriesId = customChartsDataPoint.seriesId + timestamp = customChartsDataPoint.timestamp + value = customChartsDataPoint.value + group = customChartsDataPoint.group + additionalProperties = customChartsDataPoint.additionalProperties.toMutableMap() + } + + fun seriesId(seriesId: String) = seriesId(JsonField.of(seriesId)) + + /** + * Sets [Builder.seriesId] to an arbitrary JSON value. + * + * You should usually call [Builder.seriesId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun seriesId(seriesId: JsonField<String>) = apply { this.seriesId = seriesId } + + fun timestamp(timestamp: OffsetDateTime) = timestamp(JsonField.of(timestamp)) + + /** + * Sets [Builder.timestamp] to an arbitrary JSON value. + * + * You should usually call [Builder.timestamp] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun timestamp(timestamp: JsonField<OffsetDateTime>) = apply { this.timestamp = timestamp } + + fun value(value: Value?) = value(JsonField.ofNullable(value)) + + /** Alias for calling [Builder.value] with `value.orElse(null)`. */ + fun value(value: Optional<Value>) = value(value.getOrNull()) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Value] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun value(value: JsonField<Value>) = apply { this.value = value } + + /** Alias for calling [value] with `Value.ofNumber(number)`. */ + fun value(number: Double) = value(Value.ofNumber(number)) + + /** Alias for calling [value] with `Value.ofJson(json)`. */ + fun value(json: JsonValue) = value(Value.ofJson(json)) + + fun group(group: String?) = group(JsonField.ofNullable(group)) + + /** Alias for calling [Builder.group] with `group.orElse(null)`. */ + fun group(group: Optional<String>) = group(group.getOrNull()) + + /** + * Sets [Builder.group] to an arbitrary JSON value. + * + * You should usually call [Builder.group] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun group(group: JsonField<String>) = apply { this.group = group } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomChartsDataPoint]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .seriesId() + * .timestamp() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomChartsDataPoint = + CustomChartsDataPoint( + checkRequired("seriesId", seriesId), + checkRequired("timestamp", timestamp), + checkRequired("value", value), + group, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CustomChartsDataPoint = apply { + if (validated) { + return@apply + } + + seriesId() + timestamp() + value().ifPresent { it.validate() } + group() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (seriesId.asKnown().isPresent) 1 else 0) + + (if (timestamp.asKnown().isPresent) 1 else 0) + + (value.asKnown().getOrNull()?.validity() ?: 0) + + (if (group.asKnown().isPresent) 1 else 0) + + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val number: Double? = null, + private val json: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional<Double> = Optional.ofNullable(number) + + fun json(): Optional<JsonValue> = Optional.ofNullable(json) + + fun isNumber(): Boolean = number != null + + fun isJson(): Boolean = json != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asJson(): JsonValue = json.getOrThrow("json") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + number != null -> visitor.visitNumber(number) + json != null -> visitor.visitJson(json) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Value = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitNumber(number: Double) {} + + override fun visitJson(json: JsonValue) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitNumber(number: Double) = 1 + + override fun visitJson(json: JsonValue) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && number == other.number && json == other.json + } + + override fun hashCode(): Int = Objects.hash(number, json) + + override fun toString(): String = + when { + number != null -> "Value{number=$number}" + json != null -> "Value{json=$json}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Value(number = number) + + @JvmStatic fun ofJson(json: JsonValue) = Value(json = json) + } + + /** An interface that defines how to map each variant of [Value] to a value of type [T]. */ + interface Visitor<out T> { + + fun visitNumber(number: Double): T + + fun visitJson(json: JsonValue): T + + /** + * Maps an unknown variant of [Value] to a value of type [T]. + * + * An instance of [Value] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Value: $json") + } + } + + internal class Deserializer : BaseDeserializer<Value>(Value::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Value { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<Double>())?.let { + Value(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<JsonValue>())?.let { + Value(json = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants. + 0 -> Value(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Value>(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.json != null -> generator.writeObject(value.json) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomChartsDataPoint && + seriesId == other.seriesId && + timestamp == other.timestamp && + value == other.value && + group == other.group && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(seriesId, timestamp, value, group, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomChartsDataPoint{seriesId=$seriesId, timestamp=$timestamp, value=$value, group=$group, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartsRequest.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartsRequest.kt new file mode 100644 index 00000000..2d0ccc43 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartsRequest.kt @@ -0,0 +1,413 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.sessions.TimedeltaInput +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class CustomChartsRequest +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val afterIndex: JsonField<Long>, + private val endTime: JsonField<OffsetDateTime>, + private val omitData: JsonField<Boolean>, + private val startTime: JsonField<OffsetDateTime>, + private val stride: JsonField<TimedeltaInput>, + private val tagValueId: JsonField<List<String>>, + private val timezone: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("after_index") @ExcludeMissing afterIndex: JsonField<Long> = JsonMissing.of(), + @JsonProperty("end_time") + @ExcludeMissing + endTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("omit_data") @ExcludeMissing omitData: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("stride") + @ExcludeMissing + stride: JsonField<TimedeltaInput> = JsonMissing.of(), + @JsonProperty("tag_value_id") + @ExcludeMissing + tagValueId: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("timezone") @ExcludeMissing timezone: JsonField<String> = JsonMissing.of(), + ) : this(afterIndex, endTime, omitData, startTime, stride, tagValueId, timezone, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun afterIndex(): Optional<Long> = afterIndex.getOptional("after_index") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endTime(): Optional<OffsetDateTime> = endTime.getOptional("end_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun omitData(): Optional<Boolean> = omitData.getOptional("omit_data") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun startTime(): Optional<OffsetDateTime> = startTime.getOptional("start_time") + + /** + * Timedelta input. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun stride(): Optional<TimedeltaInput> = stride.getOptional("stride") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tagValueId(): Optional<List<String>> = tagValueId.getOptional("tag_value_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun timezone(): Optional<String> = timezone.getOptional("timezone") + + /** + * Returns the raw JSON value of [afterIndex]. + * + * Unlike [afterIndex], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("after_index") @ExcludeMissing fun _afterIndex(): JsonField<Long> = afterIndex + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_time") @ExcludeMissing fun _endTime(): JsonField<OffsetDateTime> = endTime + + /** + * Returns the raw JSON value of [omitData]. + * + * Unlike [omitData], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("omit_data") @ExcludeMissing fun _omitData(): JsonField<Boolean> = omitData + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_time") + @ExcludeMissing + fun _startTime(): JsonField<OffsetDateTime> = startTime + + /** + * Returns the raw JSON value of [stride]. + * + * Unlike [stride], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("stride") @ExcludeMissing fun _stride(): JsonField<TimedeltaInput> = stride + + /** + * Returns the raw JSON value of [tagValueId]. + * + * Unlike [tagValueId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tag_value_id") + @ExcludeMissing + fun _tagValueId(): JsonField<List<String>> = tagValueId + + /** + * Returns the raw JSON value of [timezone]. + * + * Unlike [timezone], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("timezone") @ExcludeMissing fun _timezone(): JsonField<String> = timezone + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [CustomChartsRequest]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomChartsRequest]. */ + class Builder internal constructor() { + + private var afterIndex: JsonField<Long> = JsonMissing.of() + private var endTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var omitData: JsonField<Boolean> = JsonMissing.of() + private var startTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var stride: JsonField<TimedeltaInput> = JsonMissing.of() + private var tagValueId: JsonField<MutableList<String>>? = null + private var timezone: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(customChartsRequest: CustomChartsRequest) = apply { + afterIndex = customChartsRequest.afterIndex + endTime = customChartsRequest.endTime + omitData = customChartsRequest.omitData + startTime = customChartsRequest.startTime + stride = customChartsRequest.stride + tagValueId = customChartsRequest.tagValueId.map { it.toMutableList() } + timezone = customChartsRequest.timezone + additionalProperties = customChartsRequest.additionalProperties.toMutableMap() + } + + fun afterIndex(afterIndex: Long?) = afterIndex(JsonField.ofNullable(afterIndex)) + + /** + * Alias for [Builder.afterIndex]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun afterIndex(afterIndex: Long) = afterIndex(afterIndex as Long?) + + /** Alias for calling [Builder.afterIndex] with `afterIndex.orElse(null)`. */ + fun afterIndex(afterIndex: Optional<Long>) = afterIndex(afterIndex.getOrNull()) + + /** + * Sets [Builder.afterIndex] to an arbitrary JSON value. + * + * You should usually call [Builder.afterIndex] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun afterIndex(afterIndex: JsonField<Long>) = apply { this.afterIndex = afterIndex } + + fun endTime(endTime: OffsetDateTime?) = endTime(JsonField.ofNullable(endTime)) + + /** Alias for calling [Builder.endTime] with `endTime.orElse(null)`. */ + fun endTime(endTime: Optional<OffsetDateTime>) = endTime(endTime.getOrNull()) + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endTime(endTime: JsonField<OffsetDateTime>) = apply { this.endTime = endTime } + + fun omitData(omitData: Boolean) = omitData(JsonField.of(omitData)) + + /** + * Sets [Builder.omitData] to an arbitrary JSON value. + * + * You should usually call [Builder.omitData] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun omitData(omitData: JsonField<Boolean>) = apply { this.omitData = omitData } + + fun startTime(startTime: OffsetDateTime?) = startTime(JsonField.ofNullable(startTime)) + + /** Alias for calling [Builder.startTime] with `startTime.orElse(null)`. */ + fun startTime(startTime: Optional<OffsetDateTime>) = startTime(startTime.getOrNull()) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField<OffsetDateTime>) = apply { this.startTime = startTime } + + /** Timedelta input. */ + fun stride(stride: TimedeltaInput) = stride(JsonField.of(stride)) + + /** + * Sets [Builder.stride] to an arbitrary JSON value. + * + * You should usually call [Builder.stride] with a well-typed [TimedeltaInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun stride(stride: JsonField<TimedeltaInput>) = apply { this.stride = stride } + + fun tagValueId(tagValueId: List<String>?) = tagValueId(JsonField.ofNullable(tagValueId)) + + /** Alias for calling [Builder.tagValueId] with `tagValueId.orElse(null)`. */ + fun tagValueId(tagValueId: Optional<List<String>>) = tagValueId(tagValueId.getOrNull()) + + /** + * Sets [Builder.tagValueId] to an arbitrary JSON value. + * + * You should usually call [Builder.tagValueId] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tagValueId(tagValueId: JsonField<List<String>>) = apply { + this.tagValueId = tagValueId.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.tagValueId]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTagValueId(tagValueId: String) = apply { + this.tagValueId = + (this.tagValueId ?: JsonField.of(mutableListOf())).also { + checkKnown("tagValueId", it).add(tagValueId) + } + } + + fun timezone(timezone: String) = timezone(JsonField.of(timezone)) + + /** + * Sets [Builder.timezone] to an arbitrary JSON value. + * + * You should usually call [Builder.timezone] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun timezone(timezone: JsonField<String>) = apply { this.timezone = timezone } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomChartsRequest]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CustomChartsRequest = + CustomChartsRequest( + afterIndex, + endTime, + omitData, + startTime, + stride, + (tagValueId ?: JsonMissing.of()).map { it.toImmutable() }, + timezone, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CustomChartsRequest = apply { + if (validated) { + return@apply + } + + afterIndex() + endTime() + omitData() + startTime() + stride().ifPresent { it.validate() } + tagValueId() + timezone() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (afterIndex.asKnown().isPresent) 1 else 0) + + (if (endTime.asKnown().isPresent) 1 else 0) + + (if (omitData.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + (stride.asKnown().getOrNull()?.validity() ?: 0) + + (tagValueId.asKnown().getOrNull()?.size ?: 0) + + (if (timezone.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomChartsRequest && + afterIndex == other.afterIndex && + endTime == other.endTime && + omitData == other.omitData && + startTime == other.startTime && + stride == other.stride && + tagValueId == other.tagValueId && + timezone == other.timezone && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + afterIndex, + endTime, + omitData, + startTime, + stride, + tagValueId, + timezone, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomChartsRequest{afterIndex=$afterIndex, endTime=$endTime, omitData=$omitData, startTime=$startTime, stride=$stride, tagValueId=$tagValueId, timezone=$timezone, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartsResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartsResponse.kt new file mode 100644 index 00000000..03e14e3f --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartsResponse.kt @@ -0,0 +1,195 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.sessions.CustomChartsSection +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class CustomChartsResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val sections: JsonField<List<CustomChartsSection>>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("sections") + @ExcludeMissing + sections: JsonField<List<CustomChartsSection>> = JsonMissing.of() + ) : this(sections, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun sections(): List<CustomChartsSection> = sections.getRequired("sections") + + /** + * Returns the raw JSON value of [sections]. + * + * Unlike [sections], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sections") + @ExcludeMissing + fun _sections(): JsonField<List<CustomChartsSection>> = sections + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CustomChartsResponse]. + * + * The following fields are required: + * ```java + * .sections() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomChartsResponse]. */ + class Builder internal constructor() { + + private var sections: JsonField<MutableList<CustomChartsSection>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(customChartsResponse: CustomChartsResponse) = apply { + sections = customChartsResponse.sections.map { it.toMutableList() } + additionalProperties = customChartsResponse.additionalProperties.toMutableMap() + } + + fun sections(sections: List<CustomChartsSection>) = sections(JsonField.of(sections)) + + /** + * Sets [Builder.sections] to an arbitrary JSON value. + * + * You should usually call [Builder.sections] with a well-typed `List<CustomChartsSection>` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun sections(sections: JsonField<List<CustomChartsSection>>) = apply { + this.sections = sections.map { it.toMutableList() } + } + + /** + * Adds a single [CustomChartsSection] to [sections]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSection(section: CustomChartsSection) = apply { + sections = + (sections ?: JsonField.of(mutableListOf())).also { + checkKnown("sections", it).add(section) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomChartsResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .sections() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomChartsResponse = + CustomChartsResponse( + checkRequired("sections", sections).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CustomChartsResponse = apply { + if (validated) { + return@apply + } + + sections().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (sections.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomChartsResponse && + sections == other.sections && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(sections, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomChartsResponse{sections=$sections, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/HostProjectChartMetric.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/HostProjectChartMetric.kt new file mode 100644 index 00000000..8b1ad026 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/HostProjectChartMetric.kt @@ -0,0 +1,187 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts + +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException + +/** LGP Metrics you can chart. */ +class HostProjectChartMetric +@JsonCreator +private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't match + * any known member, and you want to know that value. For example, if the SDK is on an older + * version than the API, then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val MEMORY_USAGE = of("memory_usage") + + @JvmField val CPU_USAGE = of("cpu_usage") + + @JvmField val DISK_USAGE = of("disk_usage") + + @JvmField val RESTART_COUNT = of("restart_count") + + @JvmField val REPLICA_COUNT = of("replica_count") + + @JvmField val WORKER_COUNT = of("worker_count") + + @JvmField val LG_RUN_COUNT = of("lg_run_count") + + @JvmField val RESPONSES_PER_SECOND = of("responses_per_second") + + @JvmField val ERROR_RESPONSES_PER_SECOND = of("error_responses_per_second") + + @JvmField val P95_LATENCY = of("p95_latency") + + @JvmStatic fun of(value: String) = HostProjectChartMetric(JsonField.of(value)) + } + + /** An enum containing [HostProjectChartMetric]'s known values. */ + enum class Known { + MEMORY_USAGE, + CPU_USAGE, + DISK_USAGE, + RESTART_COUNT, + REPLICA_COUNT, + WORKER_COUNT, + LG_RUN_COUNT, + RESPONSES_PER_SECOND, + ERROR_RESPONSES_PER_SECOND, + P95_LATENCY, + } + + /** + * An enum containing [HostProjectChartMetric]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [HostProjectChartMetric] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the SDK + * is on an older version than the API, then the API may respond with new members that the SDK + * is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MEMORY_USAGE, + CPU_USAGE, + DISK_USAGE, + RESTART_COUNT, + REPLICA_COUNT, + WORKER_COUNT, + LG_RUN_COUNT, + RESPONSES_PER_SECOND, + ERROR_RESPONSES_PER_SECOND, + P95_LATENCY, + /** + * An enum member indicating that [HostProjectChartMetric] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if + * the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want to + * throw for the unknown case. + */ + fun value(): Value = + when (this) { + MEMORY_USAGE -> Value.MEMORY_USAGE + CPU_USAGE -> Value.CPU_USAGE + DISK_USAGE -> Value.DISK_USAGE + RESTART_COUNT -> Value.RESTART_COUNT + REPLICA_COUNT -> Value.REPLICA_COUNT + WORKER_COUNT -> Value.WORKER_COUNT + LG_RUN_COUNT -> Value.LG_RUN_COUNT + RESPONSES_PER_SECOND -> Value.RESPONSES_PER_SECOND + ERROR_RESPONSES_PER_SECOND -> Value.ERROR_RESPONSES_PER_SECOND + P95_LATENCY -> Value.P95_LATENCY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't want + * to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MEMORY_USAGE -> Known.MEMORY_USAGE + CPU_USAGE -> Known.CPU_USAGE + DISK_USAGE -> Known.DISK_USAGE + RESTART_COUNT -> Known.RESTART_COUNT + REPLICA_COUNT -> Known.REPLICA_COUNT + WORKER_COUNT -> Known.WORKER_COUNT + LG_RUN_COUNT -> Known.LG_RUN_COUNT + RESPONSES_PER_SECOND -> Known.RESPONSES_PER_SECOND + ERROR_RESPONSES_PER_SECOND -> Known.ERROR_RESPONSES_PER_SECOND + P95_LATENCY -> Known.P95_LATENCY + else -> throw LangsmithApiInvalidDataException("Unknown HostProjectChartMetric: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): HostProjectChartMetric = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is HostProjectChartMetric && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/SingleCustomChartResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/SingleCustomChartResponse.kt new file mode 100644 index 00000000..31178c31 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/SingleCustomChartResponse.kt @@ -0,0 +1,500 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class SingleCustomChartResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val chartType: JsonField<CustomChartType>, + private val data: JsonField<List<CustomChartsDataPoint>>, + private val index: JsonField<Long>, + private val series: JsonField<List<CustomChartSeries>>, + private val title: JsonField<String>, + private val commonFilters: JsonField<CustomChartSeriesFilters>, + private val description: JsonField<String>, + private val metadata: JsonValue, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("chart_type") + @ExcludeMissing + chartType: JsonField<CustomChartType> = JsonMissing.of(), + @JsonProperty("data") + @ExcludeMissing + data: JsonField<List<CustomChartsDataPoint>> = JsonMissing.of(), + @JsonProperty("index") @ExcludeMissing index: JsonField<Long> = JsonMissing.of(), + @JsonProperty("series") + @ExcludeMissing + series: JsonField<List<CustomChartSeries>> = JsonMissing.of(), + @JsonProperty("title") @ExcludeMissing title: JsonField<String> = JsonMissing.of(), + @JsonProperty("common_filters") + @ExcludeMissing + commonFilters: JsonField<CustomChartSeriesFilters> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + ) : this( + id, + chartType, + data, + index, + series, + title, + commonFilters, + description, + metadata, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * Enum for custom chart types. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun chartType(): CustomChartType = chartType.getRequired("chart_type") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): List<CustomChartsDataPoint> = data.getRequired("data") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun index(): Long = index.getRequired("index") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun series(): List<CustomChartSeries> = series.getRequired("series") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun title(): String = title.getRequired("title") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun commonFilters(): Optional<CustomChartSeriesFilters> = + commonFilters.getOptional("common_filters") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [chartType]. + * + * Unlike [chartType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("chart_type") + @ExcludeMissing + fun _chartType(): JsonField<CustomChartType> = chartType + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField<List<CustomChartsDataPoint>> = data + + /** + * Returns the raw JSON value of [index]. + * + * Unlike [index], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("index") @ExcludeMissing fun _index(): JsonField<Long> = index + + /** + * Returns the raw JSON value of [series]. + * + * Unlike [series], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("series") + @ExcludeMissing + fun _series(): JsonField<List<CustomChartSeries>> = series + + /** + * Returns the raw JSON value of [title]. + * + * Unlike [title], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("title") @ExcludeMissing fun _title(): JsonField<String> = title + + /** + * Returns the raw JSON value of [commonFilters]. + * + * Unlike [commonFilters], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("common_filters") + @ExcludeMissing + fun _commonFilters(): JsonField<CustomChartSeriesFilters> = commonFilters + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField<String> = description + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SingleCustomChartResponse]. + * + * The following fields are required: + * ```java + * .id() + * .chartType() + * .data() + * .index() + * .series() + * .title() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SingleCustomChartResponse]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var chartType: JsonField<CustomChartType>? = null + private var data: JsonField<MutableList<CustomChartsDataPoint>>? = null + private var index: JsonField<Long>? = null + private var series: JsonField<MutableList<CustomChartSeries>>? = null + private var title: JsonField<String>? = null + private var commonFilters: JsonField<CustomChartSeriesFilters> = JsonMissing.of() + private var description: JsonField<String> = JsonMissing.of() + private var metadata: JsonValue = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(singleCustomChartResponse: SingleCustomChartResponse) = apply { + id = singleCustomChartResponse.id + chartType = singleCustomChartResponse.chartType + data = singleCustomChartResponse.data.map { it.toMutableList() } + index = singleCustomChartResponse.index + series = singleCustomChartResponse.series.map { it.toMutableList() } + title = singleCustomChartResponse.title + commonFilters = singleCustomChartResponse.commonFilters + description = singleCustomChartResponse.description + metadata = singleCustomChartResponse.metadata + additionalProperties = singleCustomChartResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + /** Enum for custom chart types. */ + fun chartType(chartType: CustomChartType) = chartType(JsonField.of(chartType)) + + /** + * Sets [Builder.chartType] to an arbitrary JSON value. + * + * You should usually call [Builder.chartType] with a well-typed [CustomChartType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun chartType(chartType: JsonField<CustomChartType>) = apply { this.chartType = chartType } + + fun data(data: List<CustomChartsDataPoint>) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed `List<CustomChartsDataPoint>` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun data(data: JsonField<List<CustomChartsDataPoint>>) = apply { + this.data = data.map { it.toMutableList() } + } + + /** + * Adds a single [CustomChartsDataPoint] to [Builder.data]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addData(data: CustomChartsDataPoint) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + fun index(index: Long) = index(JsonField.of(index)) + + /** + * Sets [Builder.index] to an arbitrary JSON value. + * + * You should usually call [Builder.index] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun index(index: JsonField<Long>) = apply { this.index = index } + + fun series(series: List<CustomChartSeries>) = series(JsonField.of(series)) + + /** + * Sets [Builder.series] to an arbitrary JSON value. + * + * You should usually call [Builder.series] with a well-typed `List<CustomChartSeries>` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun series(series: JsonField<List<CustomChartSeries>>) = apply { + this.series = series.map { it.toMutableList() } + } + + /** + * Adds a single [CustomChartSeries] to [Builder.series]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSeries(series: CustomChartSeries) = apply { + this.series = + (this.series ?: JsonField.of(mutableListOf())).also { + checkKnown("series", it).add(series) + } + } + + fun title(title: String) = title(JsonField.of(title)) + + /** + * Sets [Builder.title] to an arbitrary JSON value. + * + * You should usually call [Builder.title] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun title(title: JsonField<String>) = apply { this.title = title } + + fun commonFilters(commonFilters: CustomChartSeriesFilters?) = + commonFilters(JsonField.ofNullable(commonFilters)) + + /** Alias for calling [Builder.commonFilters] with `commonFilters.orElse(null)`. */ + fun commonFilters(commonFilters: Optional<CustomChartSeriesFilters>) = + commonFilters(commonFilters.getOrNull()) + + /** + * Sets [Builder.commonFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.commonFilters] with a well-typed + * [CustomChartSeriesFilters] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun commonFilters(commonFilters: JsonField<CustomChartSeriesFilters>) = apply { + this.commonFilters = commonFilters + } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { this.description = description } + + fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SingleCustomChartResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .chartType() + * .data() + * .index() + * .series() + * .title() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SingleCustomChartResponse = + SingleCustomChartResponse( + checkRequired("id", id), + checkRequired("chartType", chartType), + checkRequired("data", data).map { it.toImmutable() }, + checkRequired("index", index), + checkRequired("series", series).map { it.toImmutable() }, + checkRequired("title", title), + commonFilters, + description, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SingleCustomChartResponse = apply { + if (validated) { + return@apply + } + + id() + chartType().validate() + data().forEach { it.validate() } + index() + series().forEach { it.validate() } + title() + commonFilters().ifPresent { it.validate() } + description() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (chartType.asKnown().getOrNull()?.validity() ?: 0) + + (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (index.asKnown().isPresent) 1 else 0) + + (series.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (title.asKnown().isPresent) 1 else 0) + + (commonFilters.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SingleCustomChartResponse && + id == other.id && + chartType == other.chartType && + data == other.data && + index == other.index && + series == other.series && + title == other.title && + commonFilters == other.commonFilters && + description == other.description && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + chartType, + data, + index, + series, + title, + commonFilters, + description, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SingleCustomChartResponse{id=$id, chartType=$chartType, data=$data, index=$index, series=$series, title=$title, commonFilters=$commonFilters, description=$description, metadata=$metadata, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/SingleCustomChartResponseBase.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/SingleCustomChartResponseBase.kt new file mode 100644 index 00000000..8341bef4 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/SingleCustomChartResponseBase.kt @@ -0,0 +1,193 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class SingleCustomChartResponseBase +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField<List<CustomChartsDataPoint>>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") + @ExcludeMissing + data: JsonField<List<CustomChartsDataPoint>> = JsonMissing.of() + ) : this(data, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): List<CustomChartsDataPoint> = data.getRequired("data") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField<List<CustomChartsDataPoint>> = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SingleCustomChartResponseBase]. + * + * The following fields are required: + * ```java + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SingleCustomChartResponseBase]. */ + class Builder internal constructor() { + + private var data: JsonField<MutableList<CustomChartsDataPoint>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(singleCustomChartResponseBase: SingleCustomChartResponseBase) = apply { + data = singleCustomChartResponseBase.data.map { it.toMutableList() } + additionalProperties = singleCustomChartResponseBase.additionalProperties.toMutableMap() + } + + fun data(data: List<CustomChartsDataPoint>) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed `List<CustomChartsDataPoint>` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun data(data: JsonField<List<CustomChartsDataPoint>>) = apply { + this.data = data.map { it.toMutableList() } + } + + /** + * Adds a single [CustomChartsDataPoint] to [Builder.data]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addData(data: CustomChartsDataPoint) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SingleCustomChartResponseBase]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .data() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SingleCustomChartResponseBase = + SingleCustomChartResponseBase( + checkRequired("data", data).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SingleCustomChartResponseBase = apply { + if (validated) { + return@apply + } + + data().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SingleCustomChartResponseBase && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(data, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SingleCustomChartResponseBase{data=$data, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/section/CustomChartsSectionCreate.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/section/CustomChartsSectionCreate.kt new file mode 100644 index 00000000..ecc5f92e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/section/CustomChartsSectionCreate.kt @@ -0,0 +1,254 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts.section + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class CustomChartsSectionCreate +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val title: JsonField<String>, + private val description: JsonField<String>, + private val index: JsonField<Long>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("title") @ExcludeMissing title: JsonField<String> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("index") @ExcludeMissing index: JsonField<Long> = JsonMissing.of(), + ) : this(title, description, index, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun title(): String = title.getRequired("title") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun index(): Optional<Long> = index.getOptional("index") + + /** + * Returns the raw JSON value of [title]. + * + * Unlike [title], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("title") @ExcludeMissing fun _title(): JsonField<String> = title + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [index]. + * + * Unlike [index], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("index") @ExcludeMissing fun _index(): JsonField<Long> = index + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CustomChartsSectionCreate]. + * + * The following fields are required: + * ```java + * .title() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomChartsSectionCreate]. */ + class Builder internal constructor() { + + private var title: JsonField<String>? = null + private var description: JsonField<String> = JsonMissing.of() + private var index: JsonField<Long> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(customChartsSectionCreate: CustomChartsSectionCreate) = apply { + title = customChartsSectionCreate.title + description = customChartsSectionCreate.description + index = customChartsSectionCreate.index + additionalProperties = customChartsSectionCreate.additionalProperties.toMutableMap() + } + + fun title(title: String) = title(JsonField.of(title)) + + /** + * Sets [Builder.title] to an arbitrary JSON value. + * + * You should usually call [Builder.title] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun title(title: JsonField<String>) = apply { this.title = title } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { this.description = description } + + fun index(index: Long?) = index(JsonField.ofNullable(index)) + + /** + * Alias for [Builder.index]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun index(index: Long) = index(index as Long?) + + /** Alias for calling [Builder.index] with `index.orElse(null)`. */ + fun index(index: Optional<Long>) = index(index.getOrNull()) + + /** + * Sets [Builder.index] to an arbitrary JSON value. + * + * You should usually call [Builder.index] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun index(index: JsonField<Long>) = apply { this.index = index } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomChartsSectionCreate]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .title() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomChartsSectionCreate = + CustomChartsSectionCreate( + checkRequired("title", title), + description, + index, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CustomChartsSectionCreate = apply { + if (validated) { + return@apply + } + + title() + description() + index() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (title.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (index.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomChartsSectionCreate && + title == other.title && + description == other.description && + index == other.index && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(title, description, index, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomChartsSectionCreate{title=$title, description=$description, index=$index, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/section/CustomChartsSectionResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/section/CustomChartsSectionResponse.kt new file mode 100644 index 00000000..5781af30 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/section/CustomChartsSectionResponse.kt @@ -0,0 +1,418 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts.section + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class CustomChartsSectionResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val title: JsonField<String>, + private val chartCount: JsonField<Long>, + private val createdAt: JsonField<OffsetDateTime>, + private val description: JsonField<String>, + private val index: JsonField<Long>, + private val modifiedAt: JsonField<OffsetDateTime>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("title") @ExcludeMissing title: JsonField<String> = JsonMissing.of(), + @JsonProperty("chart_count") @ExcludeMissing chartCount: JsonField<Long> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("index") @ExcludeMissing index: JsonField<Long> = JsonMissing.of(), + @JsonProperty("modified_at") + @ExcludeMissing + modifiedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + ) : this(id, title, chartCount, createdAt, description, index, modifiedAt, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun title(): String = title.getRequired("title") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun chartCount(): Optional<Long> = chartCount.getOptional("chart_count") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun createdAt(): Optional<OffsetDateTime> = createdAt.getOptional("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun index(): Optional<Long> = index.getOptional("index") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun modifiedAt(): Optional<OffsetDateTime> = modifiedAt.getOptional("modified_at") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [title]. + * + * Unlike [title], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("title") @ExcludeMissing fun _title(): JsonField<String> = title + + /** + * Returns the raw JSON value of [chartCount]. + * + * Unlike [chartCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("chart_count") @ExcludeMissing fun _chartCount(): JsonField<Long> = chartCount + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [index]. + * + * Unlike [index], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("index") @ExcludeMissing fun _index(): JsonField<Long> = index + + /** + * Returns the raw JSON value of [modifiedAt]. + * + * Unlike [modifiedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("modified_at") + @ExcludeMissing + fun _modifiedAt(): JsonField<OffsetDateTime> = modifiedAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CustomChartsSectionResponse]. + * + * The following fields are required: + * ```java + * .id() + * .title() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomChartsSectionResponse]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var title: JsonField<String>? = null + private var chartCount: JsonField<Long> = JsonMissing.of() + private var createdAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var description: JsonField<String> = JsonMissing.of() + private var index: JsonField<Long> = JsonMissing.of() + private var modifiedAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(customChartsSectionResponse: CustomChartsSectionResponse) = apply { + id = customChartsSectionResponse.id + title = customChartsSectionResponse.title + chartCount = customChartsSectionResponse.chartCount + createdAt = customChartsSectionResponse.createdAt + description = customChartsSectionResponse.description + index = customChartsSectionResponse.index + modifiedAt = customChartsSectionResponse.modifiedAt + additionalProperties = customChartsSectionResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun title(title: String) = title(JsonField.of(title)) + + /** + * Sets [Builder.title] to an arbitrary JSON value. + * + * You should usually call [Builder.title] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun title(title: JsonField<String>) = apply { this.title = title } + + fun chartCount(chartCount: Long?) = chartCount(JsonField.ofNullable(chartCount)) + + /** + * Alias for [Builder.chartCount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun chartCount(chartCount: Long) = chartCount(chartCount as Long?) + + /** Alias for calling [Builder.chartCount] with `chartCount.orElse(null)`. */ + fun chartCount(chartCount: Optional<Long>) = chartCount(chartCount.getOrNull()) + + /** + * Sets [Builder.chartCount] to an arbitrary JSON value. + * + * You should usually call [Builder.chartCount] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun chartCount(chartCount: JsonField<Long>) = apply { this.chartCount = chartCount } + + fun createdAt(createdAt: OffsetDateTime?) = createdAt(JsonField.ofNullable(createdAt)) + + /** Alias for calling [Builder.createdAt] with `createdAt.orElse(null)`. */ + fun createdAt(createdAt: Optional<OffsetDateTime>) = createdAt(createdAt.getOrNull()) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { this.description = description } + + fun index(index: Long?) = index(JsonField.ofNullable(index)) + + /** + * Alias for [Builder.index]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun index(index: Long) = index(index as Long?) + + /** Alias for calling [Builder.index] with `index.orElse(null)`. */ + fun index(index: Optional<Long>) = index(index.getOrNull()) + + /** + * Sets [Builder.index] to an arbitrary JSON value. + * + * You should usually call [Builder.index] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun index(index: JsonField<Long>) = apply { this.index = index } + + fun modifiedAt(modifiedAt: OffsetDateTime?) = modifiedAt(JsonField.ofNullable(modifiedAt)) + + /** Alias for calling [Builder.modifiedAt] with `modifiedAt.orElse(null)`. */ + fun modifiedAt(modifiedAt: Optional<OffsetDateTime>) = modifiedAt(modifiedAt.getOrNull()) + + /** + * Sets [Builder.modifiedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.modifiedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modifiedAt(modifiedAt: JsonField<OffsetDateTime>) = apply { + this.modifiedAt = modifiedAt + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomChartsSectionResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .title() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomChartsSectionResponse = + CustomChartsSectionResponse( + checkRequired("id", id), + checkRequired("title", title), + chartCount, + createdAt, + description, + index, + modifiedAt, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CustomChartsSectionResponse = apply { + if (validated) { + return@apply + } + + id() + title() + chartCount() + createdAt() + description() + index() + modifiedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (title.asKnown().isPresent) 1 else 0) + + (if (chartCount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (index.asKnown().isPresent) 1 else 0) + + (if (modifiedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomChartsSectionResponse && + id == other.id && + title == other.title && + chartCount == other.chartCount && + createdAt == other.createdAt && + description == other.description && + index == other.index && + modifiedAt == other.modifiedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + title, + chartCount, + createdAt, + description, + index, + modifiedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomChartsSectionResponse{id=$id, title=$title, chartCount=$chartCount, createdAt=$createdAt, description=$description, index=$index, modifiedAt=$modifiedAt, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/section/CustomChartsSectionUpdate.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/section/CustomChartsSectionUpdate.kt new file mode 100644 index 00000000..a47417a3 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/section/CustomChartsSectionUpdate.kt @@ -0,0 +1,775 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts.section + +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 com.langsmith_api.api.core.BaseDeserializer +import com.langsmith_api.api.core.BaseSerializer +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.allMaxBy +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.datasets.Missing +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class CustomChartsSectionUpdate +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val description: JsonField<Description>, + private val index: JsonField<Index>, + private val title: JsonField<Title>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("description") + @ExcludeMissing + description: JsonField<Description> = JsonMissing.of(), + @JsonProperty("index") @ExcludeMissing index: JsonField<Index> = JsonMissing.of(), + @JsonProperty("title") @ExcludeMissing title: JsonField<Title> = JsonMissing.of(), + ) : this(description, index, title, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<Description> = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun index(): Optional<Index> = index.getOptional("index") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun title(): Optional<Title> = title.getOptional("title") + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField<Description> = description + + /** + * Returns the raw JSON value of [index]. + * + * Unlike [index], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("index") @ExcludeMissing fun _index(): JsonField<Index> = index + + /** + * Returns the raw JSON value of [title]. + * + * Unlike [title], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("title") @ExcludeMissing fun _title(): JsonField<Title> = title + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CustomChartsSectionUpdate]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomChartsSectionUpdate]. */ + class Builder internal constructor() { + + private var description: JsonField<Description> = JsonMissing.of() + private var index: JsonField<Index> = JsonMissing.of() + private var title: JsonField<Title> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(customChartsSectionUpdate: CustomChartsSectionUpdate) = apply { + description = customChartsSectionUpdate.description + index = customChartsSectionUpdate.index + title = customChartsSectionUpdate.title + additionalProperties = customChartsSectionUpdate.additionalProperties.toMutableMap() + } + + fun description(description: Description?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<Description>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [Description] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField<Description>) = apply { + this.description = description + } + + /** Alias for calling [description] with `Description.ofString(string)`. */ + fun description(string: String) = description(Description.ofString(string)) + + /** Alias for calling [description] with `Description.ofMissing(missing)`. */ + fun description(missing: Missing) = description(Description.ofMissing(missing)) + + fun index(index: Index) = index(JsonField.of(index)) + + /** + * Sets [Builder.index] to an arbitrary JSON value. + * + * You should usually call [Builder.index] with a well-typed [Index] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun index(index: JsonField<Index>) = apply { this.index = index } + + /** Alias for calling [index] with `Index.ofInteger(integer)`. */ + fun index(integer: Long) = index(Index.ofInteger(integer)) + + /** Alias for calling [index] with `Index.ofMissing(missing)`. */ + fun index(missing: Missing) = index(Index.ofMissing(missing)) + + fun title(title: Title) = title(JsonField.of(title)) + + /** + * Sets [Builder.title] to an arbitrary JSON value. + * + * You should usually call [Builder.title] with a well-typed [Title] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun title(title: JsonField<Title>) = apply { this.title = title } + + /** Alias for calling [title] with `Title.ofString(string)`. */ + fun title(string: String) = title(Title.ofString(string)) + + /** Alias for calling [title] with `Title.ofMissing(missing)`. */ + fun title(missing: Missing) = title(Title.ofMissing(missing)) + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomChartsSectionUpdate]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CustomChartsSectionUpdate = + CustomChartsSectionUpdate( + description, + index, + title, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CustomChartsSectionUpdate = apply { + if (validated) { + return@apply + } + + description().ifPresent { it.validate() } + index().ifPresent { it.validate() } + title().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (description.asKnown().getOrNull()?.validity() ?: 0) + + (index.asKnown().getOrNull()?.validity() ?: 0) + + (title.asKnown().getOrNull()?.validity() ?: 0) + + @JsonDeserialize(using = Description.Deserializer::class) + @JsonSerialize(using = Description.Serializer::class) + class Description + private constructor( + private val string: String? = null, + private val missing: Missing? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun missing(): Optional<Missing> = Optional.ofNullable(missing) + + fun isString(): Boolean = string != null + + fun isMissing(): Boolean = missing != null + + fun asString(): String = string.getOrThrow("string") + + fun asMissing(): Missing = missing.getOrThrow("missing") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + string != null -> visitor.visitString(string) + missing != null -> visitor.visitMissing(missing) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Description = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitString(string: String) {} + + override fun visitMissing(missing: Missing) { + missing.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitString(string: String) = 1 + + override fun visitMissing(missing: Missing) = missing.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Description && string == other.string && missing == other.missing + } + + override fun hashCode(): Int = Objects.hash(string, missing) + + override fun toString(): String = + when { + string != null -> "Description{string=$string}" + missing != null -> "Description{missing=$missing}" + _json != null -> "Description{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Description") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Description(string = string) + + @JvmStatic fun ofMissing(missing: Missing) = Description(missing = missing) + } + + /** + * An interface that defines how to map each variant of [Description] to a value of type + * [T]. + */ + interface Visitor<out T> { + + fun visitString(string: String): T + + fun visitMissing(missing: Missing): T + + /** + * Maps an unknown variant of [Description] to a value of type [T]. + * + * An instance of [Description] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Description: $json") + } + } + + internal class Deserializer : BaseDeserializer<Description>(Description::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Description { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<Missing>())?.let { + Description(missing = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<String>())?.let { + Description(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from array). + 0 -> Description(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Description>(Description::class) { + + override fun serialize( + value: Description, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.missing != null -> generator.writeObject(value.missing) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Description") + } + } + } + } + + @JsonDeserialize(using = Index.Deserializer::class) + @JsonSerialize(using = Index.Serializer::class) + class Index + private constructor( + private val integer: Long? = null, + private val missing: Missing? = null, + private val _json: JsonValue? = null, + ) { + + fun integer(): Optional<Long> = Optional.ofNullable(integer) + + fun missing(): Optional<Missing> = Optional.ofNullable(missing) + + fun isInteger(): Boolean = integer != null + + fun isMissing(): Boolean = missing != null + + fun asInteger(): Long = integer.getOrThrow("integer") + + fun asMissing(): Missing = missing.getOrThrow("missing") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + integer != null -> visitor.visitInteger(integer) + missing != null -> visitor.visitMissing(missing) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Index = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitInteger(integer: Long) {} + + override fun visitMissing(missing: Missing) { + missing.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitInteger(integer: Long) = 1 + + override fun visitMissing(missing: Missing) = missing.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Index && integer == other.integer && missing == other.missing + } + + override fun hashCode(): Int = Objects.hash(integer, missing) + + override fun toString(): String = + when { + integer != null -> "Index{integer=$integer}" + missing != null -> "Index{missing=$missing}" + _json != null -> "Index{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Index") + } + + companion object { + + @JvmStatic fun ofInteger(integer: Long) = Index(integer = integer) + + @JvmStatic fun ofMissing(missing: Missing) = Index(missing = missing) + } + + /** An interface that defines how to map each variant of [Index] to a value of type [T]. */ + interface Visitor<out T> { + + fun visitInteger(integer: Long): T + + fun visitMissing(missing: Missing): T + + /** + * Maps an unknown variant of [Index] to a value of type [T]. + * + * An instance of [Index] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Index: $json") + } + } + + internal class Deserializer : BaseDeserializer<Index>(Index::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Index { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<Missing>())?.let { + Index(missing = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<Long>())?.let { + Index(integer = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> Index(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Index>(Index::class) { + + override fun serialize( + value: Index, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.integer != null -> generator.writeObject(value.integer) + value.missing != null -> generator.writeObject(value.missing) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Index") + } + } + } + } + + @JsonDeserialize(using = Title.Deserializer::class) + @JsonSerialize(using = Title.Serializer::class) + class Title + private constructor( + private val string: String? = null, + private val missing: Missing? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun missing(): Optional<Missing> = Optional.ofNullable(missing) + + fun isString(): Boolean = string != null + + fun isMissing(): Boolean = missing != null + + fun asString(): String = string.getOrThrow("string") + + fun asMissing(): Missing = missing.getOrThrow("missing") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + string != null -> visitor.visitString(string) + missing != null -> visitor.visitMissing(missing) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Title = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitString(string: String) {} + + override fun visitMissing(missing: Missing) { + missing.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitString(string: String) = 1 + + override fun visitMissing(missing: Missing) = missing.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Title && string == other.string && missing == other.missing + } + + override fun hashCode(): Int = Objects.hash(string, missing) + + override fun toString(): String = + when { + string != null -> "Title{string=$string}" + missing != null -> "Title{missing=$missing}" + _json != null -> "Title{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Title") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Title(string = string) + + @JvmStatic fun ofMissing(missing: Missing) = Title(missing = missing) + } + + /** An interface that defines how to map each variant of [Title] to a value of type [T]. */ + interface Visitor<out T> { + + fun visitString(string: String): T + + fun visitMissing(missing: Missing): T + + /** + * Maps an unknown variant of [Title] to a value of type [T]. + * + * An instance of [Title] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Title: $json") + } + } + + internal class Deserializer : BaseDeserializer<Title>(Title::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Title { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<Missing>())?.let { + Title(missing = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<String>())?.let { + Title(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from array). + 0 -> Title(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Title>(Title::class) { + + override fun serialize( + value: Title, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.missing != null -> generator.writeObject(value.missing) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Title") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomChartsSectionUpdate && + description == other.description && + index == other.index && + title == other.title && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(description, index, title, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomChartsSectionUpdate{description=$description, index=$index, title=$title, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionCloneParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionCloneParams.kt new file mode 100644 index 00000000..00edd9f3 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionCloneParams.kt @@ -0,0 +1,460 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts.section + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Clone a dashboard. */ +class SectionCloneParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun sectionId(): Optional<String> = body.sectionId() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun sessionId(): Optional<String> = body.sessionId() + + /** + * Returns the raw JSON value of [sectionId]. + * + * Unlike [sectionId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _sectionId(): JsonField<String> = body._sectionId() + + /** + * Returns the raw JSON value of [sessionId]. + * + * Unlike [sessionId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _sessionId(): JsonField<String> = body._sessionId() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): SectionCloneParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [SectionCloneParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SectionCloneParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(sectionCloneParams: SectionCloneParams) = apply { + body = sectionCloneParams.body.toBuilder() + additionalHeaders = sectionCloneParams.additionalHeaders.toBuilder() + additionalQueryParams = sectionCloneParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [sectionId] + * - [sessionId] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun sectionId(sectionId: String?) = apply { body.sectionId(sectionId) } + + /** Alias for calling [Builder.sectionId] with `sectionId.orElse(null)`. */ + fun sectionId(sectionId: Optional<String>) = sectionId(sectionId.getOrNull()) + + /** + * Sets [Builder.sectionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sectionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun sectionId(sectionId: JsonField<String>) = apply { body.sectionId(sectionId) } + + fun sessionId(sessionId: String?) = apply { body.sessionId(sessionId) } + + /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ + fun sessionId(sessionId: Optional<String>) = sessionId(sessionId.getOrNull()) + + /** + * Sets [Builder.sessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun sessionId(sessionId: JsonField<String>) = apply { body.sessionId(sessionId) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SectionCloneParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SectionCloneParams = + SectionCloneParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val sectionId: JsonField<String>, + private val sessionId: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("section_id") + @ExcludeMissing + sectionId: JsonField<String> = JsonMissing.of(), + @JsonProperty("session_id") + @ExcludeMissing + sessionId: JsonField<String> = JsonMissing.of(), + ) : this(sectionId, sessionId, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun sectionId(): Optional<String> = sectionId.getOptional("section_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun sessionId(): Optional<String> = sessionId.getOptional("session_id") + + /** + * Returns the raw JSON value of [sectionId]. + * + * Unlike [sectionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("section_id") @ExcludeMissing fun _sectionId(): JsonField<String> = sectionId + + /** + * Returns the raw JSON value of [sessionId]. + * + * Unlike [sessionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session_id") @ExcludeMissing fun _sessionId(): JsonField<String> = sessionId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var sectionId: JsonField<String> = JsonMissing.of() + private var sessionId: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + sectionId = body.sectionId + sessionId = body.sessionId + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun sectionId(sectionId: String?) = sectionId(JsonField.ofNullable(sectionId)) + + /** Alias for calling [Builder.sectionId] with `sectionId.orElse(null)`. */ + fun sectionId(sectionId: Optional<String>) = sectionId(sectionId.getOrNull()) + + /** + * Sets [Builder.sectionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sectionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sectionId(sectionId: JsonField<String>) = apply { this.sectionId = sectionId } + + fun sessionId(sessionId: String?) = sessionId(JsonField.ofNullable(sessionId)) + + /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ + fun sessionId(sessionId: Optional<String>) = sessionId(sessionId.getOrNull()) + + /** + * Sets [Builder.sessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sessionId(sessionId: JsonField<String>) = apply { this.sessionId = sessionId } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = Body(sectionId, sessionId, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + sectionId() + sessionId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (sectionId.asKnown().isPresent) 1 else 0) + + (if (sessionId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + sectionId == other.sectionId && + sessionId == other.sessionId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(sectionId, sessionId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{sectionId=$sectionId, sessionId=$sessionId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SectionCloneParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "SectionCloneParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionCreateParams.kt new file mode 100644 index 00000000..ef775b1d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionCreateParams.kt @@ -0,0 +1,205 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts.section + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** Create a new section. */ +class SectionCreateParams +private constructor( + private val customChartsSectionCreate: CustomChartsSectionCreate, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun customChartsSectionCreate(): CustomChartsSectionCreate = customChartsSectionCreate + + fun _additionalBodyProperties(): Map<String, JsonValue> = + customChartsSectionCreate._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SectionCreateParams]. + * + * The following fields are required: + * ```java + * .customChartsSectionCreate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SectionCreateParams]. */ + class Builder internal constructor() { + + private var customChartsSectionCreate: CustomChartsSectionCreate? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(sectionCreateParams: SectionCreateParams) = apply { + customChartsSectionCreate = sectionCreateParams.customChartsSectionCreate + additionalHeaders = sectionCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = sectionCreateParams.additionalQueryParams.toBuilder() + } + + fun customChartsSectionCreate(customChartsSectionCreate: CustomChartsSectionCreate) = + apply { + this.customChartsSectionCreate = customChartsSectionCreate + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SectionCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .customChartsSectionCreate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SectionCreateParams = + SectionCreateParams( + checkRequired("customChartsSectionCreate", customChartsSectionCreate), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): CustomChartsSectionCreate = customChartsSectionCreate + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SectionCreateParams && + customChartsSectionCreate == other.customChartsSectionCreate && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(customChartsSectionCreate, additionalHeaders, additionalQueryParams) + + override fun toString() = + "SectionCreateParams{customChartsSectionCreate=$customChartsSectionCreate, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionDeleteParams.kt new file mode 100644 index 00000000..b081fa89 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionDeleteParams.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts.section + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete a section. */ +class SectionDeleteParams +private constructor( + private val sectionId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun sectionId(): Optional<String> = Optional.ofNullable(sectionId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): SectionDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [SectionDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SectionDeleteParams]. */ + class Builder internal constructor() { + + private var sectionId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(sectionDeleteParams: SectionDeleteParams) = apply { + sectionId = sectionDeleteParams.sectionId + additionalHeaders = sectionDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = sectionDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = sectionDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun sectionId(sectionId: String?) = apply { this.sectionId = sectionId } + + /** Alias for calling [Builder.sectionId] with `sectionId.orElse(null)`. */ + fun sectionId(sectionId: Optional<String>) = sectionId(sectionId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [SectionDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SectionDeleteParams = + SectionDeleteParams( + sectionId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> sectionId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SectionDeleteParams && + sectionId == other.sectionId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(sectionId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "SectionDeleteParams{sectionId=$sectionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionDeleteResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionDeleteResponse.kt new file mode 100644 index 00000000..ba5adbe0 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionDeleteResponse.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts.section + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class SectionDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [SectionDeleteResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SectionDeleteResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(sectionDeleteResponse: SectionDeleteResponse) = apply { + additionalProperties = sectionDeleteResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SectionDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SectionDeleteResponse = + SectionDeleteResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): SectionDeleteResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SectionDeleteResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "SectionDeleteResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionListParams.kt new file mode 100644 index 00000000..533e2f61 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionListParams.kt @@ -0,0 +1,323 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts.section + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get all sections for the tenant. */ +class SectionListParams +private constructor( + private val ids: List<String>?, + private val limit: Long?, + private val offset: Long?, + private val sortBy: String?, + private val sortByDesc: Boolean?, + private val tagValueId: List<String>?, + private val titleContains: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun ids(): Optional<List<String>> = Optional.ofNullable(ids) + + fun limit(): Optional<Long> = Optional.ofNullable(limit) + + fun offset(): Optional<Long> = Optional.ofNullable(offset) + + fun sortBy(): Optional<String> = Optional.ofNullable(sortBy) + + fun sortByDesc(): Optional<Boolean> = Optional.ofNullable(sortByDesc) + + fun tagValueId(): Optional<List<String>> = Optional.ofNullable(tagValueId) + + fun titleContains(): Optional<String> = Optional.ofNullable(titleContains) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): SectionListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [SectionListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SectionListParams]. */ + class Builder internal constructor() { + + private var ids: MutableList<String>? = null + private var limit: Long? = null + private var offset: Long? = null + private var sortBy: String? = null + private var sortByDesc: Boolean? = null + private var tagValueId: MutableList<String>? = null + private var titleContains: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(sectionListParams: SectionListParams) = apply { + ids = sectionListParams.ids?.toMutableList() + limit = sectionListParams.limit + offset = sectionListParams.offset + sortBy = sectionListParams.sortBy + sortByDesc = sectionListParams.sortByDesc + tagValueId = sectionListParams.tagValueId?.toMutableList() + titleContains = sectionListParams.titleContains + additionalHeaders = sectionListParams.additionalHeaders.toBuilder() + additionalQueryParams = sectionListParams.additionalQueryParams.toBuilder() + } + + fun ids(ids: List<String>?) = apply { this.ids = ids?.toMutableList() } + + /** Alias for calling [Builder.ids] with `ids.orElse(null)`. */ + fun ids(ids: Optional<List<String>>) = ids(ids.getOrNull()) + + /** + * Adds a single [String] to [ids]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addId(id: String) = apply { ids = (ids ?: mutableListOf()).apply { add(id) } } + + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional<Long>) = limit(limit.getOrNull()) + + fun offset(offset: Long?) = apply { this.offset = offset } + + /** + * Alias for [Builder.offset]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun offset(offset: Long) = offset(offset as Long?) + + /** Alias for calling [Builder.offset] with `offset.orElse(null)`. */ + fun offset(offset: Optional<Long>) = offset(offset.getOrNull()) + + fun sortBy(sortBy: String?) = apply { this.sortBy = sortBy } + + /** Alias for calling [Builder.sortBy] with `sortBy.orElse(null)`. */ + fun sortBy(sortBy: Optional<String>) = sortBy(sortBy.getOrNull()) + + fun sortByDesc(sortByDesc: Boolean?) = apply { this.sortByDesc = sortByDesc } + + /** + * Alias for [Builder.sortByDesc]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun sortByDesc(sortByDesc: Boolean) = sortByDesc(sortByDesc as Boolean?) + + /** Alias for calling [Builder.sortByDesc] with `sortByDesc.orElse(null)`. */ + fun sortByDesc(sortByDesc: Optional<Boolean>) = sortByDesc(sortByDesc.getOrNull()) + + fun tagValueId(tagValueId: List<String>?) = apply { + this.tagValueId = tagValueId?.toMutableList() + } + + /** Alias for calling [Builder.tagValueId] with `tagValueId.orElse(null)`. */ + fun tagValueId(tagValueId: Optional<List<String>>) = tagValueId(tagValueId.getOrNull()) + + /** + * Adds a single [String] to [Builder.tagValueId]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTagValueId(tagValueId: String) = apply { + this.tagValueId = (this.tagValueId ?: mutableListOf()).apply { add(tagValueId) } + } + + fun titleContains(titleContains: String?) = apply { this.titleContains = titleContains } + + /** Alias for calling [Builder.titleContains] with `titleContains.orElse(null)`. */ + fun titleContains(titleContains: Optional<String>) = + titleContains(titleContains.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SectionListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SectionListParams = + SectionListParams( + ids?.toImmutable(), + limit, + offset, + sortBy, + sortByDesc, + tagValueId?.toImmutable(), + titleContains, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + ids?.let { put("ids", it.joinToString(",")) } + limit?.let { put("limit", it.toString()) } + offset?.let { put("offset", it.toString()) } + sortBy?.let { put("sort_by", it) } + sortByDesc?.let { put("sort_by_desc", it.toString()) } + tagValueId?.let { put("tag_value_id", it.joinToString(",")) } + titleContains?.let { put("title_contains", it) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SectionListParams && + ids == other.ids && + limit == other.limit && + offset == other.offset && + sortBy == other.sortBy && + sortByDesc == other.sortByDesc && + tagValueId == other.tagValueId && + titleContains == other.titleContains && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + ids, + limit, + offset, + sortBy, + sortByDesc, + tagValueId, + titleContains, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "SectionListParams{ids=$ids, limit=$limit, offset=$offset, sortBy=$sortBy, sortByDesc=$sortByDesc, tagValueId=$tagValueId, titleContains=$titleContains, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionUpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionUpdateParams.kt new file mode 100644 index 00000000..489dcc71 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionUpdateParams.kt @@ -0,0 +1,225 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts.section + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Update a section. */ +class SectionUpdateParams +private constructor( + private val sectionId: String?, + private val customChartsSectionUpdate: CustomChartsSectionUpdate, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun sectionId(): Optional<String> = Optional.ofNullable(sectionId) + + fun customChartsSectionUpdate(): CustomChartsSectionUpdate = customChartsSectionUpdate + + fun _additionalBodyProperties(): Map<String, JsonValue> = + customChartsSectionUpdate._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SectionUpdateParams]. + * + * The following fields are required: + * ```java + * .customChartsSectionUpdate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SectionUpdateParams]. */ + class Builder internal constructor() { + + private var sectionId: String? = null + private var customChartsSectionUpdate: CustomChartsSectionUpdate? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(sectionUpdateParams: SectionUpdateParams) = apply { + sectionId = sectionUpdateParams.sectionId + customChartsSectionUpdate = sectionUpdateParams.customChartsSectionUpdate + additionalHeaders = sectionUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = sectionUpdateParams.additionalQueryParams.toBuilder() + } + + fun sectionId(sectionId: String?) = apply { this.sectionId = sectionId } + + /** Alias for calling [Builder.sectionId] with `sectionId.orElse(null)`. */ + fun sectionId(sectionId: Optional<String>) = sectionId(sectionId.getOrNull()) + + fun customChartsSectionUpdate(customChartsSectionUpdate: CustomChartsSectionUpdate) = + apply { + this.customChartsSectionUpdate = customChartsSectionUpdate + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SectionUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .customChartsSectionUpdate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SectionUpdateParams = + SectionUpdateParams( + sectionId, + checkRequired("customChartsSectionUpdate", customChartsSectionUpdate), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): CustomChartsSectionUpdate = customChartsSectionUpdate + + fun _pathParam(index: Int): String = + when (index) { + 0 -> sectionId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SectionUpdateParams && + sectionId == other.sectionId && + customChartsSectionUpdate == other.customChartsSectionUpdate && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(sectionId, customChartsSectionUpdate, additionalHeaders, additionalQueryParams) + + override fun toString() = + "SectionUpdateParams{sectionId=$sectionId, customChartsSectionUpdate=$customChartsSectionUpdate, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/comments/Comment.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/comments/Comment.kt new file mode 100644 index 00000000..70434bfd --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/comments/Comment.kt @@ -0,0 +1,581 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.comments + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class Comment +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val commentOn: JsonField<String>, + private val content: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val numLikes: JsonField<Long>, + private val numSubComments: JsonField<Long>, + private val updatedAt: JsonField<OffsetDateTime>, + private val commentBy: JsonField<String>, + private val commentByName: JsonField<String>, + private val likedByAuthUser: JsonField<Boolean>, + private val parentId: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("comment_on") @ExcludeMissing commentOn: JsonField<String> = JsonMissing.of(), + @JsonProperty("content") @ExcludeMissing content: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("num_likes") @ExcludeMissing numLikes: JsonField<Long> = JsonMissing.of(), + @JsonProperty("num_sub_comments") + @ExcludeMissing + numSubComments: JsonField<Long> = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("comment_by") @ExcludeMissing commentBy: JsonField<String> = JsonMissing.of(), + @JsonProperty("comment_by_name") + @ExcludeMissing + commentByName: JsonField<String> = JsonMissing.of(), + @JsonProperty("liked_by_auth_user") + @ExcludeMissing + likedByAuthUser: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("parent_id") @ExcludeMissing parentId: JsonField<String> = JsonMissing.of(), + ) : this( + id, + commentOn, + content, + createdAt, + numLikes, + numSubComments, + updatedAt, + commentBy, + commentByName, + likedByAuthUser, + parentId, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun commentOn(): String = commentOn.getRequired("comment_on") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun content(): String = content.getRequired("content") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun numLikes(): Long = numLikes.getRequired("num_likes") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun numSubComments(): Long = numSubComments.getRequired("num_sub_comments") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updatedAt(): OffsetDateTime = updatedAt.getRequired("updated_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun commentBy(): Optional<String> = commentBy.getOptional("comment_by") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun commentByName(): Optional<String> = commentByName.getOptional("comment_by_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun likedByAuthUser(): Optional<Boolean> = likedByAuthUser.getOptional("liked_by_auth_user") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun parentId(): Optional<String> = parentId.getOptional("parent_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [commentOn]. + * + * Unlike [commentOn], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("comment_on") @ExcludeMissing fun _commentOn(): JsonField<String> = commentOn + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField<String> = content + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [numLikes]. + * + * Unlike [numLikes], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("num_likes") @ExcludeMissing fun _numLikes(): JsonField<Long> = numLikes + + /** + * Returns the raw JSON value of [numSubComments]. + * + * Unlike [numSubComments], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("num_sub_comments") + @ExcludeMissing + fun _numSubComments(): JsonField<Long> = numSubComments + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField<OffsetDateTime> = updatedAt + + /** + * Returns the raw JSON value of [commentBy]. + * + * Unlike [commentBy], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("comment_by") @ExcludeMissing fun _commentBy(): JsonField<String> = commentBy + + /** + * Returns the raw JSON value of [commentByName]. + * + * Unlike [commentByName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("comment_by_name") + @ExcludeMissing + fun _commentByName(): JsonField<String> = commentByName + + /** + * Returns the raw JSON value of [likedByAuthUser]. + * + * Unlike [likedByAuthUser], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("liked_by_auth_user") + @ExcludeMissing + fun _likedByAuthUser(): JsonField<Boolean> = likedByAuthUser + + /** + * Returns the raw JSON value of [parentId]. + * + * Unlike [parentId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("parent_id") @ExcludeMissing fun _parentId(): JsonField<String> = parentId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Comment]. + * + * The following fields are required: + * ```java + * .id() + * .commentOn() + * .content() + * .createdAt() + * .numLikes() + * .numSubComments() + * .updatedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Comment]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var commentOn: JsonField<String>? = null + private var content: JsonField<String>? = null + private var createdAt: JsonField<OffsetDateTime>? = null + private var numLikes: JsonField<Long>? = null + private var numSubComments: JsonField<Long>? = null + private var updatedAt: JsonField<OffsetDateTime>? = null + private var commentBy: JsonField<String> = JsonMissing.of() + private var commentByName: JsonField<String> = JsonMissing.of() + private var likedByAuthUser: JsonField<Boolean> = JsonMissing.of() + private var parentId: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(comment: Comment) = apply { + id = comment.id + commentOn = comment.commentOn + content = comment.content + createdAt = comment.createdAt + numLikes = comment.numLikes + numSubComments = comment.numSubComments + updatedAt = comment.updatedAt + commentBy = comment.commentBy + commentByName = comment.commentByName + likedByAuthUser = comment.likedByAuthUser + parentId = comment.parentId + additionalProperties = comment.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun commentOn(commentOn: String) = commentOn(JsonField.of(commentOn)) + + /** + * Sets [Builder.commentOn] to an arbitrary JSON value. + * + * You should usually call [Builder.commentOn] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun commentOn(commentOn: JsonField<String>) = apply { this.commentOn = commentOn } + + fun content(content: String) = content(JsonField.of(content)) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun content(content: JsonField<String>) = apply { this.content = content } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun numLikes(numLikes: Long) = numLikes(JsonField.of(numLikes)) + + /** + * Sets [Builder.numLikes] to an arbitrary JSON value. + * + * You should usually call [Builder.numLikes] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun numLikes(numLikes: JsonField<Long>) = apply { this.numLikes = numLikes } + + fun numSubComments(numSubComments: Long) = numSubComments(JsonField.of(numSubComments)) + + /** + * Sets [Builder.numSubComments] to an arbitrary JSON value. + * + * You should usually call [Builder.numSubComments] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun numSubComments(numSubComments: JsonField<Long>) = apply { + this.numSubComments = numSubComments + } + + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField<OffsetDateTime>) = apply { this.updatedAt = updatedAt } + + fun commentBy(commentBy: String?) = commentBy(JsonField.ofNullable(commentBy)) + + /** Alias for calling [Builder.commentBy] with `commentBy.orElse(null)`. */ + fun commentBy(commentBy: Optional<String>) = commentBy(commentBy.getOrNull()) + + /** + * Sets [Builder.commentBy] to an arbitrary JSON value. + * + * You should usually call [Builder.commentBy] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun commentBy(commentBy: JsonField<String>) = apply { this.commentBy = commentBy } + + fun commentByName(commentByName: String?) = + commentByName(JsonField.ofNullable(commentByName)) + + /** Alias for calling [Builder.commentByName] with `commentByName.orElse(null)`. */ + fun commentByName(commentByName: Optional<String>) = + commentByName(commentByName.getOrNull()) + + /** + * Sets [Builder.commentByName] to an arbitrary JSON value. + * + * You should usually call [Builder.commentByName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun commentByName(commentByName: JsonField<String>) = apply { + this.commentByName = commentByName + } + + fun likedByAuthUser(likedByAuthUser: Boolean?) = + likedByAuthUser(JsonField.ofNullable(likedByAuthUser)) + + /** + * Alias for [Builder.likedByAuthUser]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun likedByAuthUser(likedByAuthUser: Boolean) = likedByAuthUser(likedByAuthUser as Boolean?) + + /** Alias for calling [Builder.likedByAuthUser] with `likedByAuthUser.orElse(null)`. */ + fun likedByAuthUser(likedByAuthUser: Optional<Boolean>) = + likedByAuthUser(likedByAuthUser.getOrNull()) + + /** + * Sets [Builder.likedByAuthUser] to an arbitrary JSON value. + * + * You should usually call [Builder.likedByAuthUser] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun likedByAuthUser(likedByAuthUser: JsonField<Boolean>) = apply { + this.likedByAuthUser = likedByAuthUser + } + + fun parentId(parentId: String?) = parentId(JsonField.ofNullable(parentId)) + + /** Alias for calling [Builder.parentId] with `parentId.orElse(null)`. */ + fun parentId(parentId: Optional<String>) = parentId(parentId.getOrNull()) + + /** + * Sets [Builder.parentId] to an arbitrary JSON value. + * + * You should usually call [Builder.parentId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun parentId(parentId: JsonField<String>) = apply { this.parentId = parentId } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Comment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .commentOn() + * .content() + * .createdAt() + * .numLikes() + * .numSubComments() + * .updatedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Comment = + Comment( + checkRequired("id", id), + checkRequired("commentOn", commentOn), + checkRequired("content", content), + checkRequired("createdAt", createdAt), + checkRequired("numLikes", numLikes), + checkRequired("numSubComments", numSubComments), + checkRequired("updatedAt", updatedAt), + commentBy, + commentByName, + likedByAuthUser, + parentId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Comment = apply { + if (validated) { + return@apply + } + + id() + commentOn() + content() + createdAt() + numLikes() + numSubComments() + updatedAt() + commentBy() + commentByName() + likedByAuthUser() + parentId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (commentOn.asKnown().isPresent) 1 else 0) + + (if (content.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (numLikes.asKnown().isPresent) 1 else 0) + + (if (numSubComments.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (if (commentBy.asKnown().isPresent) 1 else 0) + + (if (commentByName.asKnown().isPresent) 1 else 0) + + (if (likedByAuthUser.asKnown().isPresent) 1 else 0) + + (if (parentId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Comment && + id == other.id && + commentOn == other.commentOn && + content == other.content && + createdAt == other.createdAt && + numLikes == other.numLikes && + numSubComments == other.numSubComments && + updatedAt == other.updatedAt && + commentBy == other.commentBy && + commentByName == other.commentByName && + likedByAuthUser == other.likedByAuthUser && + parentId == other.parentId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + commentOn, + content, + createdAt, + numLikes, + numSubComments, + updatedAt, + commentBy, + commentByName, + likedByAuthUser, + parentId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Comment{id=$id, commentOn=$commentOn, content=$content, createdAt=$createdAt, numLikes=$numLikes, numSubComments=$numSubComments, updatedAt=$updatedAt, commentBy=$commentBy, commentByName=$commentByName, likedByAuthUser=$likedByAuthUser, parentId=$parentId, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/comments/CommentRetrieveParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/comments/CommentRetrieveParams.kt new file mode 100644 index 00000000..d6e99b3d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/comments/CommentRetrieveParams.kt @@ -0,0 +1,285 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.comments + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get Sub Comments */ +class CommentRetrieveParams +private constructor( + private val owner: String, + private val repo: String, + private val parentCommentId: String?, + private val limit: Long?, + private val offset: Long?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun owner(): String = owner + + fun repo(): String = repo + + fun parentCommentId(): Optional<String> = Optional.ofNullable(parentCommentId) + + fun limit(): Optional<Long> = Optional.ofNullable(limit) + + fun offset(): Optional<Long> = Optional.ofNullable(offset) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CommentRetrieveParams]. + * + * The following fields are required: + * ```java + * .owner() + * .repo() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CommentRetrieveParams]. */ + class Builder internal constructor() { + + private var owner: String? = null + private var repo: String? = null + private var parentCommentId: String? = null + private var limit: Long? = null + private var offset: Long? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(commentRetrieveParams: CommentRetrieveParams) = apply { + owner = commentRetrieveParams.owner + repo = commentRetrieveParams.repo + parentCommentId = commentRetrieveParams.parentCommentId + limit = commentRetrieveParams.limit + offset = commentRetrieveParams.offset + additionalHeaders = commentRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = commentRetrieveParams.additionalQueryParams.toBuilder() + } + + fun owner(owner: String) = apply { this.owner = owner } + + fun repo(repo: String) = apply { this.repo = repo } + + fun parentCommentId(parentCommentId: String?) = apply { + this.parentCommentId = parentCommentId + } + + /** Alias for calling [Builder.parentCommentId] with `parentCommentId.orElse(null)`. */ + fun parentCommentId(parentCommentId: Optional<String>) = + parentCommentId(parentCommentId.getOrNull()) + + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional<Long>) = limit(limit.getOrNull()) + + fun offset(offset: Long?) = apply { this.offset = offset } + + /** + * Alias for [Builder.offset]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun offset(offset: Long) = offset(offset as Long?) + + /** Alias for calling [Builder.offset] with `offset.orElse(null)`. */ + fun offset(offset: Optional<Long>) = offset(offset.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [CommentRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .owner() + * .repo() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CommentRetrieveParams = + CommentRetrieveParams( + checkRequired("owner", owner), + checkRequired("repo", repo), + parentCommentId, + limit, + offset, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> owner + 1 -> repo + 2 -> parentCommentId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + limit?.let { put("limit", it.toString()) } + offset?.let { put("offset", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CommentRetrieveParams && + owner == other.owner && + repo == other.repo && + parentCommentId == other.parentCommentId && + limit == other.limit && + offset == other.offset && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + owner, + repo, + parentCommentId, + limit, + offset, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "CommentRetrieveParams{owner=$owner, repo=$repo, parentCommentId=$parentCommentId, limit=$limit, offset=$offset, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/comments/CommentUpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/comments/CommentUpdateParams.kt new file mode 100644 index 00000000..19114fab --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/comments/CommentUpdateParams.kt @@ -0,0 +1,258 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.comments + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create Sub Comment */ +class CommentUpdateParams +private constructor( + private val owner: String, + private val repo: String, + private val parentCommentId: String?, + private val createCommentRequest: CreateCommentRequest, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun owner(): String = owner + + fun repo(): String = repo + + fun parentCommentId(): Optional<String> = Optional.ofNullable(parentCommentId) + + fun createCommentRequest(): CreateCommentRequest = createCommentRequest + + fun _additionalBodyProperties(): Map<String, JsonValue> = + createCommentRequest._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CommentUpdateParams]. + * + * The following fields are required: + * ```java + * .owner() + * .repo() + * .createCommentRequest() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CommentUpdateParams]. */ + class Builder internal constructor() { + + private var owner: String? = null + private var repo: String? = null + private var parentCommentId: String? = null + private var createCommentRequest: CreateCommentRequest? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(commentUpdateParams: CommentUpdateParams) = apply { + owner = commentUpdateParams.owner + repo = commentUpdateParams.repo + parentCommentId = commentUpdateParams.parentCommentId + createCommentRequest = commentUpdateParams.createCommentRequest + additionalHeaders = commentUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = commentUpdateParams.additionalQueryParams.toBuilder() + } + + fun owner(owner: String) = apply { this.owner = owner } + + fun repo(repo: String) = apply { this.repo = repo } + + fun parentCommentId(parentCommentId: String?) = apply { + this.parentCommentId = parentCommentId + } + + /** Alias for calling [Builder.parentCommentId] with `parentCommentId.orElse(null)`. */ + fun parentCommentId(parentCommentId: Optional<String>) = + parentCommentId(parentCommentId.getOrNull()) + + fun createCommentRequest(createCommentRequest: CreateCommentRequest) = apply { + this.createCommentRequest = createCommentRequest + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [CommentUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .owner() + * .repo() + * .createCommentRequest() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CommentUpdateParams = + CommentUpdateParams( + checkRequired("owner", owner), + checkRequired("repo", repo), + parentCommentId, + checkRequired("createCommentRequest", createCommentRequest), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): CreateCommentRequest = createCommentRequest + + fun _pathParam(index: Int): String = + when (index) { + 0 -> owner + 1 -> repo + 2 -> parentCommentId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CommentUpdateParams && + owner == other.owner && + repo == other.repo && + parentCommentId == other.parentCommentId && + createCommentRequest == other.createCommentRequest && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + owner, + repo, + parentCommentId, + createCommentRequest, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "CommentUpdateParams{owner=$owner, repo=$repo, parentCommentId=$parentCommentId, createCommentRequest=$createCommentRequest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/comments/CreateCommentRequest.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/comments/CreateCommentRequest.kt new file mode 100644 index 00000000..4beffbde --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/comments/CreateCommentRequest.kt @@ -0,0 +1,170 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.comments + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class CreateCommentRequest +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val content: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("content") @ExcludeMissing content: JsonField<String> = JsonMissing.of() + ) : this(content, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun content(): String = content.getRequired("content") + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField<String> = content + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CreateCommentRequest]. + * + * The following fields are required: + * ```java + * .content() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreateCommentRequest]. */ + class Builder internal constructor() { + + private var content: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(createCommentRequest: CreateCommentRequest) = apply { + content = createCommentRequest.content + additionalProperties = createCommentRequest.additionalProperties.toMutableMap() + } + + fun content(content: String) = content(JsonField.of(content)) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun content(content: JsonField<String>) = apply { this.content = content } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CreateCommentRequest]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .content() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CreateCommentRequest = + CreateCommentRequest( + checkRequired("content", content), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CreateCommentRequest = apply { + if (validated) { + return@apply + } + + content() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (content.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreateCommentRequest && + content == other.content && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(content, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreateCommentRequest{content=$content, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/comments/ListCommentsResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/comments/ListCommentsResponse.kt new file mode 100644 index 00000000..a72ba3e4 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/comments/ListCommentsResponse.kt @@ -0,0 +1,225 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.comments + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class ListCommentsResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val comments: JsonField<List<Comment>>, + private val total: JsonField<Long>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("comments") + @ExcludeMissing + comments: JsonField<List<Comment>> = JsonMissing.of(), + @JsonProperty("total") @ExcludeMissing total: JsonField<Long> = JsonMissing.of(), + ) : this(comments, total, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun comments(): List<Comment> = comments.getRequired("comments") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun total(): Long = total.getRequired("total") + + /** + * Returns the raw JSON value of [comments]. + * + * Unlike [comments], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("comments") @ExcludeMissing fun _comments(): JsonField<List<Comment>> = comments + + /** + * Returns the raw JSON value of [total]. + * + * Unlike [total], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total") @ExcludeMissing fun _total(): JsonField<Long> = total + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ListCommentsResponse]. + * + * The following fields are required: + * ```java + * .comments() + * .total() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ListCommentsResponse]. */ + class Builder internal constructor() { + + private var comments: JsonField<MutableList<Comment>>? = null + private var total: JsonField<Long>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(listCommentsResponse: ListCommentsResponse) = apply { + comments = listCommentsResponse.comments.map { it.toMutableList() } + total = listCommentsResponse.total + additionalProperties = listCommentsResponse.additionalProperties.toMutableMap() + } + + fun comments(comments: List<Comment>) = comments(JsonField.of(comments)) + + /** + * Sets [Builder.comments] to an arbitrary JSON value. + * + * You should usually call [Builder.comments] with a well-typed `List<Comment>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun comments(comments: JsonField<List<Comment>>) = apply { + this.comments = comments.map { it.toMutableList() } + } + + /** + * Adds a single [Comment] to [comments]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addComment(comment: Comment) = apply { + comments = + (comments ?: JsonField.of(mutableListOf())).also { + checkKnown("comments", it).add(comment) + } + } + + fun total(total: Long) = total(JsonField.of(total)) + + /** + * Sets [Builder.total] to an arbitrary JSON value. + * + * You should usually call [Builder.total] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun total(total: JsonField<Long>) = apply { this.total = total } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ListCommentsResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .comments() + * .total() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ListCommentsResponse = + ListCommentsResponse( + checkRequired("comments", comments).map { it.toImmutable() }, + checkRequired("total", total), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ListCommentsResponse = apply { + if (validated) { + return@apply + } + + comments().forEach { it.validate() } + total() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (comments.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (total.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ListCommentsResponse && + comments == other.comments && + total == other.total && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(comments, total, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ListCommentsResponse{comments=$comments, total=$total, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/comments/like/LikeCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/comments/like/LikeCreateParams.kt new file mode 100644 index 00000000..6edf4cff --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/comments/like/LikeCreateParams.kt @@ -0,0 +1,274 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.comments.like + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Like Comment */ +class LikeCreateParams +private constructor( + private val owner: String, + private val repo: String, + private val parentCommentId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun owner(): String = owner + + fun repo(): String = repo + + fun parentCommentId(): Optional<String> = Optional.ofNullable(parentCommentId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LikeCreateParams]. + * + * The following fields are required: + * ```java + * .owner() + * .repo() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LikeCreateParams]. */ + class Builder internal constructor() { + + private var owner: String? = null + private var repo: String? = null + private var parentCommentId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(likeCreateParams: LikeCreateParams) = apply { + owner = likeCreateParams.owner + repo = likeCreateParams.repo + parentCommentId = likeCreateParams.parentCommentId + additionalHeaders = likeCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = likeCreateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = likeCreateParams.additionalBodyProperties.toMutableMap() + } + + fun owner(owner: String) = apply { this.owner = owner } + + fun repo(repo: String) = apply { this.repo = repo } + + fun parentCommentId(parentCommentId: String?) = apply { + this.parentCommentId = parentCommentId + } + + /** Alias for calling [Builder.parentCommentId] with `parentCommentId.orElse(null)`. */ + fun parentCommentId(parentCommentId: Optional<String>) = + parentCommentId(parentCommentId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [LikeCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .owner() + * .repo() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LikeCreateParams = + LikeCreateParams( + checkRequired("owner", owner), + checkRequired("repo", repo), + parentCommentId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> owner + 1 -> repo + 2 -> parentCommentId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LikeCreateParams && + owner == other.owner && + repo == other.repo && + parentCommentId == other.parentCommentId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + owner, + repo, + parentCommentId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "LikeCreateParams{owner=$owner, repo=$repo, parentCommentId=$parentCommentId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/comments/like/LikeCreateResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/comments/like/LikeCreateResponse.kt new file mode 100644 index 00000000..e0e70b7c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/comments/like/LikeCreateResponse.kt @@ -0,0 +1,113 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.comments.like + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class LikeCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [LikeCreateResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LikeCreateResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(likeCreateResponse: LikeCreateResponse) = apply { + additionalProperties = likeCreateResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LikeCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LikeCreateResponse = LikeCreateResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): LikeCreateResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LikeCreateResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "LikeCreateResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/comments/like/LikeDeleteAllParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/comments/like/LikeDeleteAllParams.kt new file mode 100644 index 00000000..0798f2e4 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/comments/like/LikeDeleteAllParams.kt @@ -0,0 +1,274 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.comments.like + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Unlike Comment */ +class LikeDeleteAllParams +private constructor( + private val owner: String, + private val repo: String, + private val parentCommentId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun owner(): String = owner + + fun repo(): String = repo + + fun parentCommentId(): Optional<String> = Optional.ofNullable(parentCommentId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LikeDeleteAllParams]. + * + * The following fields are required: + * ```java + * .owner() + * .repo() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LikeDeleteAllParams]. */ + class Builder internal constructor() { + + private var owner: String? = null + private var repo: String? = null + private var parentCommentId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(likeDeleteAllParams: LikeDeleteAllParams) = apply { + owner = likeDeleteAllParams.owner + repo = likeDeleteAllParams.repo + parentCommentId = likeDeleteAllParams.parentCommentId + additionalHeaders = likeDeleteAllParams.additionalHeaders.toBuilder() + additionalQueryParams = likeDeleteAllParams.additionalQueryParams.toBuilder() + additionalBodyProperties = likeDeleteAllParams.additionalBodyProperties.toMutableMap() + } + + fun owner(owner: String) = apply { this.owner = owner } + + fun repo(repo: String) = apply { this.repo = repo } + + fun parentCommentId(parentCommentId: String?) = apply { + this.parentCommentId = parentCommentId + } + + /** Alias for calling [Builder.parentCommentId] with `parentCommentId.orElse(null)`. */ + fun parentCommentId(parentCommentId: Optional<String>) = + parentCommentId(parentCommentId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [LikeDeleteAllParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .owner() + * .repo() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LikeDeleteAllParams = + LikeDeleteAllParams( + checkRequired("owner", owner), + checkRequired("repo", repo), + parentCommentId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> owner + 1 -> repo + 2 -> parentCommentId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LikeDeleteAllParams && + owner == other.owner && + repo == other.repo && + parentCommentId == other.parentCommentId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + owner, + repo, + parentCommentId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "LikeDeleteAllParams{owner=$owner, repo=$repo, parentCommentId=$parentCommentId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/comments/like/LikeDeleteAllResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/comments/like/LikeDeleteAllResponse.kt new file mode 100644 index 00000000..efb4d029 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/comments/like/LikeDeleteAllResponse.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.comments.like + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class LikeDeleteAllResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [LikeDeleteAllResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LikeDeleteAllResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(likeDeleteAllResponse: LikeDeleteAllResponse) = apply { + additionalProperties = likeDeleteAllResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LikeDeleteAllResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LikeDeleteAllResponse = + LikeDeleteAllResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): LikeDeleteAllResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LikeDeleteAllResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "LikeDeleteAllResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitManifestResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitManifestResponse.kt new file mode 100644 index 00000000..30d5345b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitManifestResponse.kt @@ -0,0 +1,504 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.commits + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Response model for get_commit_manifest. */ +class CommitManifestResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val commitHash: JsonField<String>, + private val manifest: JsonValue, + private val examples: JsonField<List<Example>>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("commit_hash") + @ExcludeMissing + commitHash: JsonField<String> = JsonMissing.of(), + @JsonProperty("manifest") @ExcludeMissing manifest: JsonValue = JsonMissing.of(), + @JsonProperty("examples") + @ExcludeMissing + examples: JsonField<List<Example>> = JsonMissing.of(), + ) : this(commitHash, manifest, examples, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun commitHash(): String = commitHash.getRequired("commit_hash") + + @JsonProperty("manifest") @ExcludeMissing fun _manifest(): JsonValue = manifest + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun examples(): Optional<List<Example>> = examples.getOptional("examples") + + /** + * Returns the raw JSON value of [commitHash]. + * + * Unlike [commitHash], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("commit_hash") @ExcludeMissing fun _commitHash(): JsonField<String> = commitHash + + /** + * Returns the raw JSON value of [examples]. + * + * Unlike [examples], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("examples") @ExcludeMissing fun _examples(): JsonField<List<Example>> = examples + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CommitManifestResponse]. + * + * The following fields are required: + * ```java + * .commitHash() + * .manifest() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CommitManifestResponse]. */ + class Builder internal constructor() { + + private var commitHash: JsonField<String>? = null + private var manifest: JsonValue? = null + private var examples: JsonField<MutableList<Example>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(commitManifestResponse: CommitManifestResponse) = apply { + commitHash = commitManifestResponse.commitHash + manifest = commitManifestResponse.manifest + examples = commitManifestResponse.examples.map { it.toMutableList() } + additionalProperties = commitManifestResponse.additionalProperties.toMutableMap() + } + + fun commitHash(commitHash: String) = commitHash(JsonField.of(commitHash)) + + /** + * Sets [Builder.commitHash] to an arbitrary JSON value. + * + * You should usually call [Builder.commitHash] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun commitHash(commitHash: JsonField<String>) = apply { this.commitHash = commitHash } + + fun manifest(manifest: JsonValue) = apply { this.manifest = manifest } + + fun examples(examples: List<Example>?) = examples(JsonField.ofNullable(examples)) + + /** Alias for calling [Builder.examples] with `examples.orElse(null)`. */ + fun examples(examples: Optional<List<Example>>) = examples(examples.getOrNull()) + + /** + * Sets [Builder.examples] to an arbitrary JSON value. + * + * You should usually call [Builder.examples] with a well-typed `List<Example>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun examples(examples: JsonField<List<Example>>) = apply { + this.examples = examples.map { it.toMutableList() } + } + + /** + * Adds a single [Example] to [examples]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExample(example: Example) = apply { + examples = + (examples ?: JsonField.of(mutableListOf())).also { + checkKnown("examples", it).add(example) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CommitManifestResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .commitHash() + * .manifest() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CommitManifestResponse = + CommitManifestResponse( + checkRequired("commitHash", commitHash), + checkRequired("manifest", manifest), + (examples ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CommitManifestResponse = apply { + if (validated) { + return@apply + } + + commitHash() + examples().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (commitHash.asKnown().isPresent) 1 else 0) + + (examples.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Response model for example runs */ + class Example + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField<String>, + private val sessionId: JsonField<String>, + private val inputs: JsonValue, + private val outputs: JsonValue, + private val startTime: JsonField<OffsetDateTime>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("session_id") + @ExcludeMissing + sessionId: JsonField<String> = JsonMissing.of(), + @JsonProperty("inputs") @ExcludeMissing inputs: JsonValue = JsonMissing.of(), + @JsonProperty("outputs") @ExcludeMissing outputs: JsonValue = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField<OffsetDateTime> = JsonMissing.of(), + ) : this(id, sessionId, inputs, outputs, startTime, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun sessionId(): String = sessionId.getRequired("session_id") + + @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonValue = inputs + + @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonValue = outputs + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun startTime(): Optional<OffsetDateTime> = startTime.getOptional("start_time") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [sessionId]. + * + * Unlike [sessionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session_id") @ExcludeMissing fun _sessionId(): JsonField<String> = sessionId + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_time") + @ExcludeMissing + fun _startTime(): JsonField<OffsetDateTime> = startTime + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Example]. + * + * The following fields are required: + * ```java + * .id() + * .sessionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Example]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var sessionId: JsonField<String>? = null + private var inputs: JsonValue = JsonMissing.of() + private var outputs: JsonValue = JsonMissing.of() + private var startTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(example: Example) = apply { + id = example.id + sessionId = example.sessionId + inputs = example.inputs + outputs = example.outputs + startTime = example.startTime + additionalProperties = example.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun sessionId(sessionId: String) = sessionId(JsonField.of(sessionId)) + + /** + * Sets [Builder.sessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sessionId(sessionId: JsonField<String>) = apply { this.sessionId = sessionId } + + fun inputs(inputs: JsonValue) = apply { this.inputs = inputs } + + fun outputs(outputs: JsonValue) = apply { this.outputs = outputs } + + fun startTime(startTime: OffsetDateTime?) = startTime(JsonField.ofNullable(startTime)) + + /** Alias for calling [Builder.startTime] with `startTime.orElse(null)`. */ + fun startTime(startTime: Optional<OffsetDateTime>) = startTime(startTime.getOrNull()) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField<OffsetDateTime>) = apply { + this.startTime = startTime + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Example]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .sessionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Example = + Example( + checkRequired("id", id), + checkRequired("sessionId", sessionId), + inputs, + outputs, + startTime, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Example = apply { + if (validated) { + return@apply + } + + id() + sessionId() + startTime() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (sessionId.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Example && + id == other.id && + sessionId == other.sessionId && + inputs == other.inputs && + outputs == other.outputs && + startTime == other.startTime && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, sessionId, inputs, outputs, startTime, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Example{id=$id, sessionId=$sessionId, inputs=$inputs, outputs=$outputs, startTime=$startTime, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CommitManifestResponse && + commitHash == other.commitHash && + manifest == other.manifest && + examples == other.examples && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(commitHash, manifest, examples, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CommitManifestResponse{commitHash=$commitHash, manifest=$manifest, examples=$examples, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitRetrieveParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitRetrieveParams.kt new file mode 100644 index 00000000..e158951b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitRetrieveParams.kt @@ -0,0 +1,303 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.commits + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Download a repo. */ +class CommitRetrieveParams +private constructor( + private val owner: String, + private val repo: String, + private val commit: String?, + private val getExamples: Boolean?, + private val includeModel: Boolean?, + private val isView: Boolean?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun owner(): String = owner + + fun repo(): String = repo + + fun commit(): Optional<String> = Optional.ofNullable(commit) + + fun getExamples(): Optional<Boolean> = Optional.ofNullable(getExamples) + + fun includeModel(): Optional<Boolean> = Optional.ofNullable(includeModel) + + fun isView(): Optional<Boolean> = Optional.ofNullable(isView) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CommitRetrieveParams]. + * + * The following fields are required: + * ```java + * .owner() + * .repo() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CommitRetrieveParams]. */ + class Builder internal constructor() { + + private var owner: String? = null + private var repo: String? = null + private var commit: String? = null + private var getExamples: Boolean? = null + private var includeModel: Boolean? = null + private var isView: Boolean? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(commitRetrieveParams: CommitRetrieveParams) = apply { + owner = commitRetrieveParams.owner + repo = commitRetrieveParams.repo + commit = commitRetrieveParams.commit + getExamples = commitRetrieveParams.getExamples + includeModel = commitRetrieveParams.includeModel + isView = commitRetrieveParams.isView + additionalHeaders = commitRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = commitRetrieveParams.additionalQueryParams.toBuilder() + } + + fun owner(owner: String) = apply { this.owner = owner } + + fun repo(repo: String) = apply { this.repo = repo } + + fun commit(commit: String?) = apply { this.commit = commit } + + /** Alias for calling [Builder.commit] with `commit.orElse(null)`. */ + fun commit(commit: Optional<String>) = commit(commit.getOrNull()) + + fun getExamples(getExamples: Boolean?) = apply { this.getExamples = getExamples } + + /** + * Alias for [Builder.getExamples]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun getExamples(getExamples: Boolean) = getExamples(getExamples as Boolean?) + + /** Alias for calling [Builder.getExamples] with `getExamples.orElse(null)`. */ + fun getExamples(getExamples: Optional<Boolean>) = getExamples(getExamples.getOrNull()) + + fun includeModel(includeModel: Boolean?) = apply { this.includeModel = includeModel } + + /** + * Alias for [Builder.includeModel]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun includeModel(includeModel: Boolean) = includeModel(includeModel as Boolean?) + + /** Alias for calling [Builder.includeModel] with `includeModel.orElse(null)`. */ + fun includeModel(includeModel: Optional<Boolean>) = includeModel(includeModel.getOrNull()) + + fun isView(isView: Boolean?) = apply { this.isView = isView } + + /** + * Alias for [Builder.isView]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun isView(isView: Boolean) = isView(isView as Boolean?) + + /** Alias for calling [Builder.isView] with `isView.orElse(null)`. */ + fun isView(isView: Optional<Boolean>) = isView(isView.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [CommitRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .owner() + * .repo() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CommitRetrieveParams = + CommitRetrieveParams( + checkRequired("owner", owner), + checkRequired("repo", repo), + commit, + getExamples, + includeModel, + isView, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> owner + 1 -> repo + 2 -> commit ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + getExamples?.let { put("get_examples", it.toString()) } + includeModel?.let { put("include_model", it.toString()) } + isView?.let { put("is_view", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CommitRetrieveParams && + owner == other.owner && + repo == other.repo && + commit == other.commit && + getExamples == other.getExamples && + includeModel == other.includeModel && + isView == other.isView && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + owner, + repo, + commit, + getExamples, + includeModel, + isView, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "CommitRetrieveParams{owner=$owner, repo=$repo, commit=$commit, getExamples=$getExamples, includeModel=$includeModel, isView=$isView, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitUpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitUpdateParams.kt new file mode 100644 index 00000000..607792db --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitUpdateParams.kt @@ -0,0 +1,843 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.commits + +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 com.langsmith_api.api.core.BaseDeserializer +import com.langsmith_api.api.core.BaseSerializer +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.allMaxBy +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Upload a repo. */ +class CommitUpdateParams +private constructor( + private val owner: String, + private val repo: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun owner(): String = owner + + fun repo(): Optional<String> = Optional.ofNullable(repo) + + fun _manifest(): JsonValue = body._manifest() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun exampleRunIds(): Optional<List<String>> = body.exampleRunIds() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun parentCommit(): Optional<String> = body.parentCommit() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun skipWebhooks(): Optional<SkipWebhooks> = body.skipWebhooks() + + /** + * Returns the raw JSON value of [exampleRunIds]. + * + * Unlike [exampleRunIds], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _exampleRunIds(): JsonField<List<String>> = body._exampleRunIds() + + /** + * Returns the raw JSON value of [parentCommit]. + * + * Unlike [parentCommit], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _parentCommit(): JsonField<String> = body._parentCommit() + + /** + * Returns the raw JSON value of [skipWebhooks]. + * + * Unlike [skipWebhooks], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _skipWebhooks(): JsonField<SkipWebhooks> = body._skipWebhooks() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CommitUpdateParams]. + * + * The following fields are required: + * ```java + * .owner() + * .manifest() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CommitUpdateParams]. */ + class Builder internal constructor() { + + private var owner: String? = null + private var repo: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(commitUpdateParams: CommitUpdateParams) = apply { + owner = commitUpdateParams.owner + repo = commitUpdateParams.repo + body = commitUpdateParams.body.toBuilder() + additionalHeaders = commitUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = commitUpdateParams.additionalQueryParams.toBuilder() + } + + fun owner(owner: String) = apply { this.owner = owner } + + fun repo(repo: String?) = apply { this.repo = repo } + + /** Alias for calling [Builder.repo] with `repo.orElse(null)`. */ + fun repo(repo: Optional<String>) = repo(repo.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [manifest] + * - [exampleRunIds] + * - [parentCommit] + * - [skipWebhooks] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun manifest(manifest: JsonValue) = apply { body.manifest(manifest) } + + fun exampleRunIds(exampleRunIds: List<String>?) = apply { + body.exampleRunIds(exampleRunIds) + } + + /** Alias for calling [Builder.exampleRunIds] with `exampleRunIds.orElse(null)`. */ + fun exampleRunIds(exampleRunIds: Optional<List<String>>) = + exampleRunIds(exampleRunIds.getOrNull()) + + /** + * Sets [Builder.exampleRunIds] to an arbitrary JSON value. + * + * You should usually call [Builder.exampleRunIds] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun exampleRunIds(exampleRunIds: JsonField<List<String>>) = apply { + body.exampleRunIds(exampleRunIds) + } + + /** + * Adds a single [String] to [exampleRunIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExampleRunId(exampleRunId: String) = apply { body.addExampleRunId(exampleRunId) } + + fun parentCommit(parentCommit: String?) = apply { body.parentCommit(parentCommit) } + + /** Alias for calling [Builder.parentCommit] with `parentCommit.orElse(null)`. */ + fun parentCommit(parentCommit: Optional<String>) = parentCommit(parentCommit.getOrNull()) + + /** + * Sets [Builder.parentCommit] to an arbitrary JSON value. + * + * You should usually call [Builder.parentCommit] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun parentCommit(parentCommit: JsonField<String>) = apply { + body.parentCommit(parentCommit) + } + + fun skipWebhooks(skipWebhooks: SkipWebhooks) = apply { body.skipWebhooks(skipWebhooks) } + + /** + * Sets [Builder.skipWebhooks] to an arbitrary JSON value. + * + * You should usually call [Builder.skipWebhooks] with a well-typed [SkipWebhooks] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun skipWebhooks(skipWebhooks: JsonField<SkipWebhooks>) = apply { + body.skipWebhooks(skipWebhooks) + } + + /** Alias for calling [skipWebhooks] with `SkipWebhooks.ofBool(bool)`. */ + fun skipWebhooks(bool: Boolean) = apply { body.skipWebhooks(bool) } + + /** Alias for calling [skipWebhooks] with `SkipWebhooks.ofStrings(strings)`. */ + fun skipWebhooksOfStrings(strings: List<String>) = apply { + body.skipWebhooksOfStrings(strings) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [CommitUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .owner() + * .manifest() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CommitUpdateParams = + CommitUpdateParams( + checkRequired("owner", owner), + repo, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> owner + 1 -> repo ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val manifest: JsonValue, + private val exampleRunIds: JsonField<List<String>>, + private val parentCommit: JsonField<String>, + private val skipWebhooks: JsonField<SkipWebhooks>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("manifest") @ExcludeMissing manifest: JsonValue = JsonMissing.of(), + @JsonProperty("example_run_ids") + @ExcludeMissing + exampleRunIds: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("parent_commit") + @ExcludeMissing + parentCommit: JsonField<String> = JsonMissing.of(), + @JsonProperty("skip_webhooks") + @ExcludeMissing + skipWebhooks: JsonField<SkipWebhooks> = JsonMissing.of(), + ) : this(manifest, exampleRunIds, parentCommit, skipWebhooks, mutableMapOf()) + + @JsonProperty("manifest") @ExcludeMissing fun _manifest(): JsonValue = manifest + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun exampleRunIds(): Optional<List<String>> = exampleRunIds.getOptional("example_run_ids") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun parentCommit(): Optional<String> = parentCommit.getOptional("parent_commit") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun skipWebhooks(): Optional<SkipWebhooks> = skipWebhooks.getOptional("skip_webhooks") + + /** + * Returns the raw JSON value of [exampleRunIds]. + * + * Unlike [exampleRunIds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("example_run_ids") + @ExcludeMissing + fun _exampleRunIds(): JsonField<List<String>> = exampleRunIds + + /** + * Returns the raw JSON value of [parentCommit]. + * + * Unlike [parentCommit], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("parent_commit") + @ExcludeMissing + fun _parentCommit(): JsonField<String> = parentCommit + + /** + * Returns the raw JSON value of [skipWebhooks]. + * + * Unlike [skipWebhooks], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("skip_webhooks") + @ExcludeMissing + fun _skipWebhooks(): JsonField<SkipWebhooks> = skipWebhooks + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .manifest() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var manifest: JsonValue? = null + private var exampleRunIds: JsonField<MutableList<String>>? = null + private var parentCommit: JsonField<String> = JsonMissing.of() + private var skipWebhooks: JsonField<SkipWebhooks> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + manifest = body.manifest + exampleRunIds = body.exampleRunIds.map { it.toMutableList() } + parentCommit = body.parentCommit + skipWebhooks = body.skipWebhooks + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun manifest(manifest: JsonValue) = apply { this.manifest = manifest } + + fun exampleRunIds(exampleRunIds: List<String>?) = + exampleRunIds(JsonField.ofNullable(exampleRunIds)) + + /** Alias for calling [Builder.exampleRunIds] with `exampleRunIds.orElse(null)`. */ + fun exampleRunIds(exampleRunIds: Optional<List<String>>) = + exampleRunIds(exampleRunIds.getOrNull()) + + /** + * Sets [Builder.exampleRunIds] to an arbitrary JSON value. + * + * You should usually call [Builder.exampleRunIds] with a well-typed `List<String>` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun exampleRunIds(exampleRunIds: JsonField<List<String>>) = apply { + this.exampleRunIds = exampleRunIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [exampleRunIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExampleRunId(exampleRunId: String) = apply { + exampleRunIds = + (exampleRunIds ?: JsonField.of(mutableListOf())).also { + checkKnown("exampleRunIds", it).add(exampleRunId) + } + } + + fun parentCommit(parentCommit: String?) = + parentCommit(JsonField.ofNullable(parentCommit)) + + /** Alias for calling [Builder.parentCommit] with `parentCommit.orElse(null)`. */ + fun parentCommit(parentCommit: Optional<String>) = + parentCommit(parentCommit.getOrNull()) + + /** + * Sets [Builder.parentCommit] to an arbitrary JSON value. + * + * You should usually call [Builder.parentCommit] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun parentCommit(parentCommit: JsonField<String>) = apply { + this.parentCommit = parentCommit + } + + fun skipWebhooks(skipWebhooks: SkipWebhooks) = skipWebhooks(JsonField.of(skipWebhooks)) + + /** + * Sets [Builder.skipWebhooks] to an arbitrary JSON value. + * + * You should usually call [Builder.skipWebhooks] with a well-typed [SkipWebhooks] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun skipWebhooks(skipWebhooks: JsonField<SkipWebhooks>) = apply { + this.skipWebhooks = skipWebhooks + } + + /** Alias for calling [skipWebhooks] with `SkipWebhooks.ofBool(bool)`. */ + fun skipWebhooks(bool: Boolean) = skipWebhooks(SkipWebhooks.ofBool(bool)) + + /** Alias for calling [skipWebhooks] with `SkipWebhooks.ofStrings(strings)`. */ + fun skipWebhooksOfStrings(strings: List<String>) = + skipWebhooks(SkipWebhooks.ofStrings(strings)) + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .manifest() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("manifest", manifest), + (exampleRunIds ?: JsonMissing.of()).map { it.toImmutable() }, + parentCommit, + skipWebhooks, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + exampleRunIds() + parentCommit() + skipWebhooks().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (exampleRunIds.asKnown().getOrNull()?.size ?: 0) + + (if (parentCommit.asKnown().isPresent) 1 else 0) + + (skipWebhooks.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + manifest == other.manifest && + exampleRunIds == other.exampleRunIds && + parentCommit == other.parentCommit && + skipWebhooks == other.skipWebhooks && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(manifest, exampleRunIds, parentCommit, skipWebhooks, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{manifest=$manifest, exampleRunIds=$exampleRunIds, parentCommit=$parentCommit, skipWebhooks=$skipWebhooks, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = SkipWebhooks.Deserializer::class) + @JsonSerialize(using = SkipWebhooks.Serializer::class) + class SkipWebhooks + private constructor( + private val bool: Boolean? = null, + private val strings: List<String>? = null, + private val _json: JsonValue? = null, + ) { + + fun bool(): Optional<Boolean> = Optional.ofNullable(bool) + + fun strings(): Optional<List<String>> = Optional.ofNullable(strings) + + fun isBool(): Boolean = bool != null + + fun isStrings(): Boolean = strings != null + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun asStrings(): List<String> = strings.getOrThrow("strings") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + bool != null -> visitor.visitBool(bool) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): SkipWebhooks = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitBool(bool: Boolean) {} + + override fun visitStrings(strings: List<String>) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitBool(bool: Boolean) = 1 + + override fun visitStrings(strings: List<String>) = strings.size + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SkipWebhooks && bool == other.bool && strings == other.strings + } + + override fun hashCode(): Int = Objects.hash(bool, strings) + + override fun toString(): String = + when { + bool != null -> "SkipWebhooks{bool=$bool}" + strings != null -> "SkipWebhooks{strings=$strings}" + _json != null -> "SkipWebhooks{_unknown=$_json}" + else -> throw IllegalStateException("Invalid SkipWebhooks") + } + + companion object { + + @JvmStatic fun ofBool(bool: Boolean) = SkipWebhooks(bool = bool) + + @JvmStatic + fun ofStrings(strings: List<String>) = SkipWebhooks(strings = strings.toImmutable()) + } + + /** + * An interface that defines how to map each variant of [SkipWebhooks] to a value of type + * [T]. + */ + interface Visitor<out T> { + + fun visitBool(bool: Boolean): T + + fun visitStrings(strings: List<String>): T + + /** + * Maps an unknown variant of [SkipWebhooks] to a value of type [T]. + * + * An instance of [SkipWebhooks] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown SkipWebhooks: $json") + } + } + + internal class Deserializer : BaseDeserializer<SkipWebhooks>(SkipWebhooks::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): SkipWebhooks { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<Boolean>())?.let { + SkipWebhooks(bool = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<List<String>>())?.let { + SkipWebhooks(strings = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from string). + 0 -> SkipWebhooks(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<SkipWebhooks>(SkipWebhooks::class) { + + override fun serialize( + value: SkipWebhooks, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.bool != null -> generator.writeObject(value.bool) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid SkipWebhooks") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CommitUpdateParams && + owner == other.owner && + repo == other.repo && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(owner, repo, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "CommitUpdateParams{owner=$owner, repo=$repo, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitUpdateResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitUpdateResponse.kt new file mode 100644 index 00000000..03417825 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitUpdateResponse.kt @@ -0,0 +1,181 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.commits + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class CommitUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val commit: JsonField<CommitWithLookups>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("commit") + @ExcludeMissing + commit: JsonField<CommitWithLookups> = JsonMissing.of() + ) : this(commit, mutableMapOf()) + + /** + * All database fields for commits, plus helpful computed fields and user info for private + * prompts. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun commit(): CommitWithLookups = commit.getRequired("commit") + + /** + * Returns the raw JSON value of [commit]. + * + * Unlike [commit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("commit") @ExcludeMissing fun _commit(): JsonField<CommitWithLookups> = commit + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CommitUpdateResponse]. + * + * The following fields are required: + * ```java + * .commit() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CommitUpdateResponse]. */ + class Builder internal constructor() { + + private var commit: JsonField<CommitWithLookups>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(commitUpdateResponse: CommitUpdateResponse) = apply { + commit = commitUpdateResponse.commit + additionalProperties = commitUpdateResponse.additionalProperties.toMutableMap() + } + + /** + * All database fields for commits, plus helpful computed fields and user info for private + * prompts. + */ + fun commit(commit: CommitWithLookups) = commit(JsonField.of(commit)) + + /** + * Sets [Builder.commit] to an arbitrary JSON value. + * + * You should usually call [Builder.commit] with a well-typed [CommitWithLookups] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun commit(commit: JsonField<CommitWithLookups>) = apply { this.commit = commit } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CommitUpdateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .commit() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CommitUpdateResponse = + CommitUpdateResponse( + checkRequired("commit", commit), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CommitUpdateResponse = apply { + if (validated) { + return@apply + } + + commit().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (commit.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CommitUpdateResponse && + commit == other.commit && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(commit, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CommitUpdateResponse{commit=$commit, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitWithLookups.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitWithLookups.kt new file mode 100644 index 00000000..fc730855 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitWithLookups.kt @@ -0,0 +1,602 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.commits + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * All database fields for commits, plus helpful computed fields and user info for private prompts. + */ +class CommitWithLookups +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val commitHash: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val exampleRunIds: JsonField<List<String>>, + private val manifest: JsonValue, + private val numDownloads: JsonField<Long>, + private val numViews: JsonField<Long>, + private val repoId: JsonField<String>, + private val updatedAt: JsonField<OffsetDateTime>, + private val fullName: JsonField<String>, + private val parentCommitHash: JsonField<String>, + private val parentId: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("commit_hash") + @ExcludeMissing + commitHash: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("example_run_ids") + @ExcludeMissing + exampleRunIds: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("manifest") @ExcludeMissing manifest: JsonValue = JsonMissing.of(), + @JsonProperty("num_downloads") + @ExcludeMissing + numDownloads: JsonField<Long> = JsonMissing.of(), + @JsonProperty("num_views") @ExcludeMissing numViews: JsonField<Long> = JsonMissing.of(), + @JsonProperty("repo_id") @ExcludeMissing repoId: JsonField<String> = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("full_name") @ExcludeMissing fullName: JsonField<String> = JsonMissing.of(), + @JsonProperty("parent_commit_hash") + @ExcludeMissing + parentCommitHash: JsonField<String> = JsonMissing.of(), + @JsonProperty("parent_id") @ExcludeMissing parentId: JsonField<String> = JsonMissing.of(), + ) : this( + id, + commitHash, + createdAt, + exampleRunIds, + manifest, + numDownloads, + numViews, + repoId, + updatedAt, + fullName, + parentCommitHash, + parentId, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun commitHash(): String = commitHash.getRequired("commit_hash") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun exampleRunIds(): List<String> = exampleRunIds.getRequired("example_run_ids") + + @JsonProperty("manifest") @ExcludeMissing fun _manifest(): JsonValue = manifest + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun numDownloads(): Long = numDownloads.getRequired("num_downloads") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun numViews(): Long = numViews.getRequired("num_views") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun repoId(): String = repoId.getRequired("repo_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updatedAt(): OffsetDateTime = updatedAt.getRequired("updated_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fullName(): Optional<String> = fullName.getOptional("full_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun parentCommitHash(): Optional<String> = parentCommitHash.getOptional("parent_commit_hash") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun parentId(): Optional<String> = parentId.getOptional("parent_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [commitHash]. + * + * Unlike [commitHash], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("commit_hash") @ExcludeMissing fun _commitHash(): JsonField<String> = commitHash + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [exampleRunIds]. + * + * Unlike [exampleRunIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("example_run_ids") + @ExcludeMissing + fun _exampleRunIds(): JsonField<List<String>> = exampleRunIds + + /** + * Returns the raw JSON value of [numDownloads]. + * + * Unlike [numDownloads], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("num_downloads") + @ExcludeMissing + fun _numDownloads(): JsonField<Long> = numDownloads + + /** + * Returns the raw JSON value of [numViews]. + * + * Unlike [numViews], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("num_views") @ExcludeMissing fun _numViews(): JsonField<Long> = numViews + + /** + * Returns the raw JSON value of [repoId]. + * + * Unlike [repoId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("repo_id") @ExcludeMissing fun _repoId(): JsonField<String> = repoId + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField<OffsetDateTime> = updatedAt + + /** + * Returns the raw JSON value of [fullName]. + * + * Unlike [fullName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("full_name") @ExcludeMissing fun _fullName(): JsonField<String> = fullName + + /** + * Returns the raw JSON value of [parentCommitHash]. + * + * Unlike [parentCommitHash], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("parent_commit_hash") + @ExcludeMissing + fun _parentCommitHash(): JsonField<String> = parentCommitHash + + /** + * Returns the raw JSON value of [parentId]. + * + * Unlike [parentId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("parent_id") @ExcludeMissing fun _parentId(): JsonField<String> = parentId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CommitWithLookups]. + * + * The following fields are required: + * ```java + * .id() + * .commitHash() + * .createdAt() + * .exampleRunIds() + * .manifest() + * .numDownloads() + * .numViews() + * .repoId() + * .updatedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CommitWithLookups]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var commitHash: JsonField<String>? = null + private var createdAt: JsonField<OffsetDateTime>? = null + private var exampleRunIds: JsonField<MutableList<String>>? = null + private var manifest: JsonValue? = null + private var numDownloads: JsonField<Long>? = null + private var numViews: JsonField<Long>? = null + private var repoId: JsonField<String>? = null + private var updatedAt: JsonField<OffsetDateTime>? = null + private var fullName: JsonField<String> = JsonMissing.of() + private var parentCommitHash: JsonField<String> = JsonMissing.of() + private var parentId: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(commitWithLookups: CommitWithLookups) = apply { + id = commitWithLookups.id + commitHash = commitWithLookups.commitHash + createdAt = commitWithLookups.createdAt + exampleRunIds = commitWithLookups.exampleRunIds.map { it.toMutableList() } + manifest = commitWithLookups.manifest + numDownloads = commitWithLookups.numDownloads + numViews = commitWithLookups.numViews + repoId = commitWithLookups.repoId + updatedAt = commitWithLookups.updatedAt + fullName = commitWithLookups.fullName + parentCommitHash = commitWithLookups.parentCommitHash + parentId = commitWithLookups.parentId + additionalProperties = commitWithLookups.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun commitHash(commitHash: String) = commitHash(JsonField.of(commitHash)) + + /** + * Sets [Builder.commitHash] to an arbitrary JSON value. + * + * You should usually call [Builder.commitHash] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun commitHash(commitHash: JsonField<String>) = apply { this.commitHash = commitHash } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun exampleRunIds(exampleRunIds: List<String>) = exampleRunIds(JsonField.of(exampleRunIds)) + + /** + * Sets [Builder.exampleRunIds] to an arbitrary JSON value. + * + * You should usually call [Builder.exampleRunIds] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun exampleRunIds(exampleRunIds: JsonField<List<String>>) = apply { + this.exampleRunIds = exampleRunIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [exampleRunIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExampleRunId(exampleRunId: String) = apply { + exampleRunIds = + (exampleRunIds ?: JsonField.of(mutableListOf())).also { + checkKnown("exampleRunIds", it).add(exampleRunId) + } + } + + fun manifest(manifest: JsonValue) = apply { this.manifest = manifest } + + fun numDownloads(numDownloads: Long) = numDownloads(JsonField.of(numDownloads)) + + /** + * Sets [Builder.numDownloads] to an arbitrary JSON value. + * + * You should usually call [Builder.numDownloads] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun numDownloads(numDownloads: JsonField<Long>) = apply { this.numDownloads = numDownloads } + + fun numViews(numViews: Long) = numViews(JsonField.of(numViews)) + + /** + * Sets [Builder.numViews] to an arbitrary JSON value. + * + * You should usually call [Builder.numViews] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun numViews(numViews: JsonField<Long>) = apply { this.numViews = numViews } + + fun repoId(repoId: String) = repoId(JsonField.of(repoId)) + + /** + * Sets [Builder.repoId] to an arbitrary JSON value. + * + * You should usually call [Builder.repoId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun repoId(repoId: JsonField<String>) = apply { this.repoId = repoId } + + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField<OffsetDateTime>) = apply { this.updatedAt = updatedAt } + + fun fullName(fullName: String?) = fullName(JsonField.ofNullable(fullName)) + + /** Alias for calling [Builder.fullName] with `fullName.orElse(null)`. */ + fun fullName(fullName: Optional<String>) = fullName(fullName.getOrNull()) + + /** + * Sets [Builder.fullName] to an arbitrary JSON value. + * + * You should usually call [Builder.fullName] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun fullName(fullName: JsonField<String>) = apply { this.fullName = fullName } + + fun parentCommitHash(parentCommitHash: String?) = + parentCommitHash(JsonField.ofNullable(parentCommitHash)) + + /** Alias for calling [Builder.parentCommitHash] with `parentCommitHash.orElse(null)`. */ + fun parentCommitHash(parentCommitHash: Optional<String>) = + parentCommitHash(parentCommitHash.getOrNull()) + + /** + * Sets [Builder.parentCommitHash] to an arbitrary JSON value. + * + * You should usually call [Builder.parentCommitHash] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun parentCommitHash(parentCommitHash: JsonField<String>) = apply { + this.parentCommitHash = parentCommitHash + } + + fun parentId(parentId: String?) = parentId(JsonField.ofNullable(parentId)) + + /** Alias for calling [Builder.parentId] with `parentId.orElse(null)`. */ + fun parentId(parentId: Optional<String>) = parentId(parentId.getOrNull()) + + /** + * Sets [Builder.parentId] to an arbitrary JSON value. + * + * You should usually call [Builder.parentId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun parentId(parentId: JsonField<String>) = apply { this.parentId = parentId } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CommitWithLookups]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .commitHash() + * .createdAt() + * .exampleRunIds() + * .manifest() + * .numDownloads() + * .numViews() + * .repoId() + * .updatedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CommitWithLookups = + CommitWithLookups( + checkRequired("id", id), + checkRequired("commitHash", commitHash), + checkRequired("createdAt", createdAt), + checkRequired("exampleRunIds", exampleRunIds).map { it.toImmutable() }, + checkRequired("manifest", manifest), + checkRequired("numDownloads", numDownloads), + checkRequired("numViews", numViews), + checkRequired("repoId", repoId), + checkRequired("updatedAt", updatedAt), + fullName, + parentCommitHash, + parentId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CommitWithLookups = apply { + if (validated) { + return@apply + } + + id() + commitHash() + createdAt() + exampleRunIds() + numDownloads() + numViews() + repoId() + updatedAt() + fullName() + parentCommitHash() + parentId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (commitHash.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (exampleRunIds.asKnown().getOrNull()?.size ?: 0) + + (if (numDownloads.asKnown().isPresent) 1 else 0) + + (if (numViews.asKnown().isPresent) 1 else 0) + + (if (repoId.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (if (fullName.asKnown().isPresent) 1 else 0) + + (if (parentCommitHash.asKnown().isPresent) 1 else 0) + + (if (parentId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CommitWithLookups && + id == other.id && + commitHash == other.commitHash && + createdAt == other.createdAt && + exampleRunIds == other.exampleRunIds && + manifest == other.manifest && + numDownloads == other.numDownloads && + numViews == other.numViews && + repoId == other.repoId && + updatedAt == other.updatedAt && + fullName == other.fullName && + parentCommitHash == other.parentCommitHash && + parentId == other.parentId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + commitHash, + createdAt, + exampleRunIds, + manifest, + numDownloads, + numViews, + repoId, + updatedAt, + fullName, + parentCommitHash, + parentId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CommitWithLookups{id=$id, commitHash=$commitHash, createdAt=$createdAt, exampleRunIds=$exampleRunIds, manifest=$manifest, numDownloads=$numDownloads, numViews=$numViews, repoId=$repoId, updatedAt=$updatedAt, fullName=$fullName, parentCommitHash=$parentCommitHash, parentId=$parentId, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DataType.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DataType.kt new file mode 100644 index 00000000..820c9510 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DataType.kt @@ -0,0 +1,140 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException + +/** Enum for dataset data types. */ +class DataType @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't match + * any known member, and you want to know that value. For example, if the SDK is on an older + * version than the API, then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val KV = of("kv") + + @JvmField val LLM = of("llm") + + @JvmField val CHAT = of("chat") + + @JvmStatic fun of(value: String) = DataType(JsonField.of(value)) + } + + /** An enum containing [DataType]'s known values. */ + enum class Known { + KV, + LLM, + CHAT, + } + + /** + * An enum containing [DataType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [DataType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the SDK + * is on an older version than the API, then the API may respond with new members that the SDK + * is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + KV, + LLM, + CHAT, + /** An enum member indicating that [DataType] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if + * the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want to + * throw for the unknown case. + */ + fun value(): Value = + when (this) { + KV -> Value.KV + LLM -> Value.LLM + CHAT -> Value.CHAT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't want + * to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + KV -> Known.KV + LLM -> Known.LLM + CHAT -> Known.CHAT + else -> throw LangsmithApiInvalidDataException("Unknown DataType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): DataType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DataType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/Dataset.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/Dataset.kt new file mode 100644 index 00000000..74687c99 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/Dataset.kt @@ -0,0 +1,705 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Dataset schema. */ +class Dataset +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val exampleCount: JsonField<Long>, + private val modifiedAt: JsonField<OffsetDateTime>, + private val name: JsonField<String>, + private val sessionCount: JsonField<Long>, + private val tenantId: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val dataType: JsonField<DataType>, + private val description: JsonField<String>, + private val externallyManaged: JsonField<Boolean>, + private val inputsSchemaDefinition: JsonValue, + private val lastSessionStartTime: JsonField<OffsetDateTime>, + private val metadata: JsonValue, + private val outputsSchemaDefinition: JsonValue, + private val transformations: JsonField<List<DatasetTransformation>>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("example_count") + @ExcludeMissing + exampleCount: JsonField<Long> = JsonMissing.of(), + @JsonProperty("modified_at") + @ExcludeMissing + modifiedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("session_count") + @ExcludeMissing + sessionCount: JsonField<Long> = JsonMissing.of(), + @JsonProperty("tenant_id") @ExcludeMissing tenantId: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("data_type") @ExcludeMissing dataType: JsonField<DataType> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("externally_managed") + @ExcludeMissing + externallyManaged: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("inputs_schema_definition") + @ExcludeMissing + inputsSchemaDefinition: JsonValue = JsonMissing.of(), + @JsonProperty("last_session_start_time") + @ExcludeMissing + lastSessionStartTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("outputs_schema_definition") + @ExcludeMissing + outputsSchemaDefinition: JsonValue = JsonMissing.of(), + @JsonProperty("transformations") + @ExcludeMissing + transformations: JsonField<List<DatasetTransformation>> = JsonMissing.of(), + ) : this( + id, + exampleCount, + modifiedAt, + name, + sessionCount, + tenantId, + createdAt, + dataType, + description, + externallyManaged, + inputsSchemaDefinition, + lastSessionStartTime, + metadata, + outputsSchemaDefinition, + transformations, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun exampleCount(): Long = exampleCount.getRequired("example_count") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun modifiedAt(): OffsetDateTime = modifiedAt.getRequired("modified_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun sessionCount(): Long = sessionCount.getRequired("session_count") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tenantId(): String = tenantId.getRequired("tenant_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun createdAt(): Optional<OffsetDateTime> = createdAt.getOptional("created_at") + + /** + * Enum for dataset data types. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dataType(): Optional<DataType> = dataType.getOptional("data_type") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externallyManaged(): Optional<Boolean> = externallyManaged.getOptional("externally_managed") + + @JsonProperty("inputs_schema_definition") + @ExcludeMissing + fun _inputsSchemaDefinition(): JsonValue = inputsSchemaDefinition + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun lastSessionStartTime(): Optional<OffsetDateTime> = + lastSessionStartTime.getOptional("last_session_start_time") + + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + + @JsonProperty("outputs_schema_definition") + @ExcludeMissing + fun _outputsSchemaDefinition(): JsonValue = outputsSchemaDefinition + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun transformations(): Optional<List<DatasetTransformation>> = + transformations.getOptional("transformations") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [exampleCount]. + * + * Unlike [exampleCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("example_count") + @ExcludeMissing + fun _exampleCount(): JsonField<Long> = exampleCount + + /** + * Returns the raw JSON value of [modifiedAt]. + * + * Unlike [modifiedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("modified_at") + @ExcludeMissing + fun _modifiedAt(): JsonField<OffsetDateTime> = modifiedAt + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [sessionCount]. + * + * Unlike [sessionCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session_count") + @ExcludeMissing + fun _sessionCount(): JsonField<Long> = sessionCount + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_id") @ExcludeMissing fun _tenantId(): JsonField<String> = tenantId + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [dataType]. + * + * Unlike [dataType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data_type") @ExcludeMissing fun _dataType(): JsonField<DataType> = dataType + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [externallyManaged]. + * + * Unlike [externallyManaged], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("externally_managed") + @ExcludeMissing + fun _externallyManaged(): JsonField<Boolean> = externallyManaged + + /** + * Returns the raw JSON value of [lastSessionStartTime]. + * + * Unlike [lastSessionStartTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("last_session_start_time") + @ExcludeMissing + fun _lastSessionStartTime(): JsonField<OffsetDateTime> = lastSessionStartTime + + /** + * Returns the raw JSON value of [transformations]. + * + * Unlike [transformations], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("transformations") + @ExcludeMissing + fun _transformations(): JsonField<List<DatasetTransformation>> = transformations + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Dataset]. + * + * The following fields are required: + * ```java + * .id() + * .exampleCount() + * .modifiedAt() + * .name() + * .sessionCount() + * .tenantId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Dataset]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var exampleCount: JsonField<Long>? = null + private var modifiedAt: JsonField<OffsetDateTime>? = null + private var name: JsonField<String>? = null + private var sessionCount: JsonField<Long>? = null + private var tenantId: JsonField<String>? = null + private var createdAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var dataType: JsonField<DataType> = JsonMissing.of() + private var description: JsonField<String> = JsonMissing.of() + private var externallyManaged: JsonField<Boolean> = JsonMissing.of() + private var inputsSchemaDefinition: JsonValue = JsonMissing.of() + private var lastSessionStartTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var metadata: JsonValue = JsonMissing.of() + private var outputsSchemaDefinition: JsonValue = JsonMissing.of() + private var transformations: JsonField<MutableList<DatasetTransformation>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(dataset: Dataset) = apply { + id = dataset.id + exampleCount = dataset.exampleCount + modifiedAt = dataset.modifiedAt + name = dataset.name + sessionCount = dataset.sessionCount + tenantId = dataset.tenantId + createdAt = dataset.createdAt + dataType = dataset.dataType + description = dataset.description + externallyManaged = dataset.externallyManaged + inputsSchemaDefinition = dataset.inputsSchemaDefinition + lastSessionStartTime = dataset.lastSessionStartTime + metadata = dataset.metadata + outputsSchemaDefinition = dataset.outputsSchemaDefinition + transformations = dataset.transformations.map { it.toMutableList() } + additionalProperties = dataset.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun exampleCount(exampleCount: Long) = exampleCount(JsonField.of(exampleCount)) + + /** + * Sets [Builder.exampleCount] to an arbitrary JSON value. + * + * You should usually call [Builder.exampleCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun exampleCount(exampleCount: JsonField<Long>) = apply { this.exampleCount = exampleCount } + + fun modifiedAt(modifiedAt: OffsetDateTime) = modifiedAt(JsonField.of(modifiedAt)) + + /** + * Sets [Builder.modifiedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.modifiedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modifiedAt(modifiedAt: JsonField<OffsetDateTime>) = apply { + this.modifiedAt = modifiedAt + } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun sessionCount(sessionCount: Long) = sessionCount(JsonField.of(sessionCount)) + + /** + * Sets [Builder.sessionCount] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun sessionCount(sessionCount: JsonField<Long>) = apply { this.sessionCount = sessionCount } + + fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tenantId(tenantId: JsonField<String>) = apply { this.tenantId = tenantId } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + /** Enum for dataset data types. */ + fun dataType(dataType: DataType?) = dataType(JsonField.ofNullable(dataType)) + + /** Alias for calling [Builder.dataType] with `dataType.orElse(null)`. */ + fun dataType(dataType: Optional<DataType>) = dataType(dataType.getOrNull()) + + /** + * Sets [Builder.dataType] to an arbitrary JSON value. + * + * You should usually call [Builder.dataType] with a well-typed [DataType] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dataType(dataType: JsonField<DataType>) = apply { this.dataType = dataType } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { this.description = description } + + fun externallyManaged(externallyManaged: Boolean?) = + externallyManaged(JsonField.ofNullable(externallyManaged)) + + /** + * Alias for [Builder.externallyManaged]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun externallyManaged(externallyManaged: Boolean) = + externallyManaged(externallyManaged as Boolean?) + + /** Alias for calling [Builder.externallyManaged] with `externallyManaged.orElse(null)`. */ + fun externallyManaged(externallyManaged: Optional<Boolean>) = + externallyManaged(externallyManaged.getOrNull()) + + /** + * Sets [Builder.externallyManaged] to an arbitrary JSON value. + * + * You should usually call [Builder.externallyManaged] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externallyManaged(externallyManaged: JsonField<Boolean>) = apply { + this.externallyManaged = externallyManaged + } + + fun inputsSchemaDefinition(inputsSchemaDefinition: JsonValue) = apply { + this.inputsSchemaDefinition = inputsSchemaDefinition + } + + fun lastSessionStartTime(lastSessionStartTime: OffsetDateTime?) = + lastSessionStartTime(JsonField.ofNullable(lastSessionStartTime)) + + /** + * Alias for calling [Builder.lastSessionStartTime] with + * `lastSessionStartTime.orElse(null)`. + */ + fun lastSessionStartTime(lastSessionStartTime: Optional<OffsetDateTime>) = + lastSessionStartTime(lastSessionStartTime.getOrNull()) + + /** + * Sets [Builder.lastSessionStartTime] to an arbitrary JSON value. + * + * You should usually call [Builder.lastSessionStartTime] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun lastSessionStartTime(lastSessionStartTime: JsonField<OffsetDateTime>) = apply { + this.lastSessionStartTime = lastSessionStartTime + } + + fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + + fun outputsSchemaDefinition(outputsSchemaDefinition: JsonValue) = apply { + this.outputsSchemaDefinition = outputsSchemaDefinition + } + + fun transformations(transformations: List<DatasetTransformation>?) = + transformations(JsonField.ofNullable(transformations)) + + /** Alias for calling [Builder.transformations] with `transformations.orElse(null)`. */ + fun transformations(transformations: Optional<List<DatasetTransformation>>) = + transformations(transformations.getOrNull()) + + /** + * Sets [Builder.transformations] to an arbitrary JSON value. + * + * You should usually call [Builder.transformations] with a well-typed + * `List<DatasetTransformation>` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun transformations(transformations: JsonField<List<DatasetTransformation>>) = apply { + this.transformations = transformations.map { it.toMutableList() } + } + + /** + * Adds a single [DatasetTransformation] to [transformations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTransformation(transformation: DatasetTransformation) = apply { + transformations = + (transformations ?: JsonField.of(mutableListOf())).also { + checkKnown("transformations", it).add(transformation) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Dataset]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .exampleCount() + * .modifiedAt() + * .name() + * .sessionCount() + * .tenantId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Dataset = + Dataset( + checkRequired("id", id), + checkRequired("exampleCount", exampleCount), + checkRequired("modifiedAt", modifiedAt), + checkRequired("name", name), + checkRequired("sessionCount", sessionCount), + checkRequired("tenantId", tenantId), + createdAt, + dataType, + description, + externallyManaged, + inputsSchemaDefinition, + lastSessionStartTime, + metadata, + outputsSchemaDefinition, + (transformations ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Dataset = apply { + if (validated) { + return@apply + } + + id() + exampleCount() + modifiedAt() + name() + sessionCount() + tenantId() + createdAt() + dataType().ifPresent { it.validate() } + description() + externallyManaged() + lastSessionStartTime() + transformations().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (exampleCount.asKnown().isPresent) 1 else 0) + + (if (modifiedAt.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (sessionCount.asKnown().isPresent) 1 else 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (dataType.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (externallyManaged.asKnown().isPresent) 1 else 0) + + (if (lastSessionStartTime.asKnown().isPresent) 1 else 0) + + (transformations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Dataset && + id == other.id && + exampleCount == other.exampleCount && + modifiedAt == other.modifiedAt && + name == other.name && + sessionCount == other.sessionCount && + tenantId == other.tenantId && + createdAt == other.createdAt && + dataType == other.dataType && + description == other.description && + externallyManaged == other.externallyManaged && + inputsSchemaDefinition == other.inputsSchemaDefinition && + lastSessionStartTime == other.lastSessionStartTime && + metadata == other.metadata && + outputsSchemaDefinition == other.outputsSchemaDefinition && + transformations == other.transformations && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + exampleCount, + modifiedAt, + name, + sessionCount, + tenantId, + createdAt, + dataType, + description, + externallyManaged, + inputsSchemaDefinition, + lastSessionStartTime, + metadata, + outputsSchemaDefinition, + transformations, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Dataset{id=$id, exampleCount=$exampleCount, modifiedAt=$modifiedAt, name=$name, sessionCount=$sessionCount, tenantId=$tenantId, createdAt=$createdAt, dataType=$dataType, description=$description, externallyManaged=$externallyManaged, inputsSchemaDefinition=$inputsSchemaDefinition, lastSessionStartTime=$lastSessionStartTime, metadata=$metadata, outputsSchemaDefinition=$outputsSchemaDefinition, transformations=$transformations, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetCloneParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetCloneParams.kt new file mode 100644 index 00000000..2276d78f --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetCloneParams.kt @@ -0,0 +1,860 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +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 com.langsmith_api.api.core.BaseDeserializer +import com.langsmith_api.api.core.BaseSerializer +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.allMaxBy +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Clone a dataset. */ +class DatasetCloneParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun sourceDatasetId(): String = body.sourceDatasetId() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun targetDatasetId(): String = body.targetDatasetId() + + /** + * Only modifications made on or before this time are included. If None, the latest version of + * the dataset is used. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun asOf(): Optional<AsOf> = body.asOf() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun examples(): Optional<List<String>> = body.examples() + + /** + * Returns the raw JSON value of [sourceDatasetId]. + * + * Unlike [sourceDatasetId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _sourceDatasetId(): JsonField<String> = body._sourceDatasetId() + + /** + * Returns the raw JSON value of [targetDatasetId]. + * + * Unlike [targetDatasetId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _targetDatasetId(): JsonField<String> = body._targetDatasetId() + + /** + * Returns the raw JSON value of [asOf]. + * + * Unlike [asOf], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _asOf(): JsonField<AsOf> = body._asOf() + + /** + * Returns the raw JSON value of [examples]. + * + * Unlike [examples], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _examples(): JsonField<List<String>> = body._examples() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DatasetCloneParams]. + * + * The following fields are required: + * ```java + * .sourceDatasetId() + * .targetDatasetId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DatasetCloneParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(datasetCloneParams: DatasetCloneParams) = apply { + body = datasetCloneParams.body.toBuilder() + additionalHeaders = datasetCloneParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetCloneParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [sourceDatasetId] + * - [targetDatasetId] + * - [asOf] + * - [examples] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun sourceDatasetId(sourceDatasetId: String) = apply { + body.sourceDatasetId(sourceDatasetId) + } + + /** + * Sets [Builder.sourceDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceDatasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sourceDatasetId(sourceDatasetId: JsonField<String>) = apply { + body.sourceDatasetId(sourceDatasetId) + } + + fun targetDatasetId(targetDatasetId: String) = apply { + body.targetDatasetId(targetDatasetId) + } + + /** + * Sets [Builder.targetDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.targetDatasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun targetDatasetId(targetDatasetId: JsonField<String>) = apply { + body.targetDatasetId(targetDatasetId) + } + + /** + * Only modifications made on or before this time are included. If None, the latest version + * of the dataset is used. + */ + fun asOf(asOf: AsOf?) = apply { body.asOf(asOf) } + + /** Alias for calling [Builder.asOf] with `asOf.orElse(null)`. */ + fun asOf(asOf: Optional<AsOf>) = asOf(asOf.getOrNull()) + + /** + * Sets [Builder.asOf] to an arbitrary JSON value. + * + * You should usually call [Builder.asOf] with a well-typed [AsOf] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun asOf(asOf: JsonField<AsOf>) = apply { body.asOf(asOf) } + + /** Alias for calling [asOf] with `AsOf.ofOffsetDateTime(offsetDateTime)`. */ + fun asOf(offsetDateTime: OffsetDateTime) = apply { body.asOf(offsetDateTime) } + + /** Alias for calling [asOf] with `AsOf.ofString(string)`. */ + fun asOf(string: String) = apply { body.asOf(string) } + + fun examples(examples: List<String>) = apply { body.examples(examples) } + + /** + * Sets [Builder.examples] to an arbitrary JSON value. + * + * You should usually call [Builder.examples] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun examples(examples: JsonField<List<String>>) = apply { body.examples(examples) } + + /** + * Adds a single [String] to [examples]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExample(example: String) = apply { body.addExample(example) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [DatasetCloneParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .sourceDatasetId() + * .targetDatasetId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DatasetCloneParams = + DatasetCloneParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val sourceDatasetId: JsonField<String>, + private val targetDatasetId: JsonField<String>, + private val asOf: JsonField<AsOf>, + private val examples: JsonField<List<String>>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("source_dataset_id") + @ExcludeMissing + sourceDatasetId: JsonField<String> = JsonMissing.of(), + @JsonProperty("target_dataset_id") + @ExcludeMissing + targetDatasetId: JsonField<String> = JsonMissing.of(), + @JsonProperty("as_of") @ExcludeMissing asOf: JsonField<AsOf> = JsonMissing.of(), + @JsonProperty("examples") + @ExcludeMissing + examples: JsonField<List<String>> = JsonMissing.of(), + ) : this(sourceDatasetId, targetDatasetId, asOf, examples, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun sourceDatasetId(): String = sourceDatasetId.getRequired("source_dataset_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun targetDatasetId(): String = targetDatasetId.getRequired("target_dataset_id") + + /** + * Only modifications made on or before this time are included. If None, the latest version + * of the dataset is used. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun asOf(): Optional<AsOf> = asOf.getOptional("as_of") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun examples(): Optional<List<String>> = examples.getOptional("examples") + + /** + * Returns the raw JSON value of [sourceDatasetId]. + * + * Unlike [sourceDatasetId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("source_dataset_id") + @ExcludeMissing + fun _sourceDatasetId(): JsonField<String> = sourceDatasetId + + /** + * Returns the raw JSON value of [targetDatasetId]. + * + * Unlike [targetDatasetId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("target_dataset_id") + @ExcludeMissing + fun _targetDatasetId(): JsonField<String> = targetDatasetId + + /** + * Returns the raw JSON value of [asOf]. + * + * Unlike [asOf], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("as_of") @ExcludeMissing fun _asOf(): JsonField<AsOf> = asOf + + /** + * Returns the raw JSON value of [examples]. + * + * Unlike [examples], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("examples") + @ExcludeMissing + fun _examples(): JsonField<List<String>> = examples + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .sourceDatasetId() + * .targetDatasetId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var sourceDatasetId: JsonField<String>? = null + private var targetDatasetId: JsonField<String>? = null + private var asOf: JsonField<AsOf> = JsonMissing.of() + private var examples: JsonField<MutableList<String>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + sourceDatasetId = body.sourceDatasetId + targetDatasetId = body.targetDatasetId + asOf = body.asOf + examples = body.examples.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun sourceDatasetId(sourceDatasetId: String) = + sourceDatasetId(JsonField.of(sourceDatasetId)) + + /** + * Sets [Builder.sourceDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceDatasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sourceDatasetId(sourceDatasetId: JsonField<String>) = apply { + this.sourceDatasetId = sourceDatasetId + } + + fun targetDatasetId(targetDatasetId: String) = + targetDatasetId(JsonField.of(targetDatasetId)) + + /** + * Sets [Builder.targetDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.targetDatasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun targetDatasetId(targetDatasetId: JsonField<String>) = apply { + this.targetDatasetId = targetDatasetId + } + + /** + * Only modifications made on or before this time are included. If None, the latest + * version of the dataset is used. + */ + fun asOf(asOf: AsOf?) = asOf(JsonField.ofNullable(asOf)) + + /** Alias for calling [Builder.asOf] with `asOf.orElse(null)`. */ + fun asOf(asOf: Optional<AsOf>) = asOf(asOf.getOrNull()) + + /** + * Sets [Builder.asOf] to an arbitrary JSON value. + * + * You should usually call [Builder.asOf] with a well-typed [AsOf] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun asOf(asOf: JsonField<AsOf>) = apply { this.asOf = asOf } + + /** Alias for calling [asOf] with `AsOf.ofOffsetDateTime(offsetDateTime)`. */ + fun asOf(offsetDateTime: OffsetDateTime) = asOf(AsOf.ofOffsetDateTime(offsetDateTime)) + + /** Alias for calling [asOf] with `AsOf.ofString(string)`. */ + fun asOf(string: String) = asOf(AsOf.ofString(string)) + + fun examples(examples: List<String>) = examples(JsonField.of(examples)) + + /** + * Sets [Builder.examples] to an arbitrary JSON value. + * + * You should usually call [Builder.examples] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun examples(examples: JsonField<List<String>>) = apply { + this.examples = examples.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [examples]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExample(example: String) = apply { + examples = + (examples ?: JsonField.of(mutableListOf())).also { + checkKnown("examples", it).add(example) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .sourceDatasetId() + * .targetDatasetId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("sourceDatasetId", sourceDatasetId), + checkRequired("targetDatasetId", targetDatasetId), + asOf, + (examples ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + sourceDatasetId() + targetDatasetId() + asOf().ifPresent { it.validate() } + examples() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (sourceDatasetId.asKnown().isPresent) 1 else 0) + + (if (targetDatasetId.asKnown().isPresent) 1 else 0) + + (asOf.asKnown().getOrNull()?.validity() ?: 0) + + (examples.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + sourceDatasetId == other.sourceDatasetId && + targetDatasetId == other.targetDatasetId && + asOf == other.asOf && + examples == other.examples && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(sourceDatasetId, targetDatasetId, asOf, examples, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{sourceDatasetId=$sourceDatasetId, targetDatasetId=$targetDatasetId, asOf=$asOf, examples=$examples, additionalProperties=$additionalProperties}" + } + + /** + * Only modifications made on or before this time are included. If None, the latest version of + * the dataset is used. + */ + @JsonDeserialize(using = AsOf.Deserializer::class) + @JsonSerialize(using = AsOf.Serializer::class) + class AsOf + private constructor( + private val offsetDateTime: OffsetDateTime? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun offsetDateTime(): Optional<OffsetDateTime> = Optional.ofNullable(offsetDateTime) + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun isOffsetDateTime(): Boolean = offsetDateTime != null + + fun isString(): Boolean = string != null + + fun asOffsetDateTime(): OffsetDateTime = offsetDateTime.getOrThrow("offsetDateTime") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + offsetDateTime != null -> visitor.visitOffsetDateTime(offsetDateTime) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): AsOf = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitOffsetDateTime(offsetDateTime: OffsetDateTime) {} + + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitOffsetDateTime(offsetDateTime: OffsetDateTime) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AsOf && offsetDateTime == other.offsetDateTime && string == other.string + } + + override fun hashCode(): Int = Objects.hash(offsetDateTime, string) + + override fun toString(): String = + when { + offsetDateTime != null -> "AsOf{offsetDateTime=$offsetDateTime}" + string != null -> "AsOf{string=$string}" + _json != null -> "AsOf{_unknown=$_json}" + else -> throw IllegalStateException("Invalid AsOf") + } + + companion object { + + @JvmStatic + fun ofOffsetDateTime(offsetDateTime: OffsetDateTime) = + AsOf(offsetDateTime = offsetDateTime) + + @JvmStatic fun ofString(string: String) = AsOf(string = string) + } + + /** An interface that defines how to map each variant of [AsOf] to a value of type [T]. */ + interface Visitor<out T> { + + fun visitOffsetDateTime(offsetDateTime: OffsetDateTime): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [AsOf] to a value of type [T]. + * + * An instance of [AsOf] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown AsOf: $json") + } + } + + internal class Deserializer : BaseDeserializer<AsOf>(AsOf::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): AsOf { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<OffsetDateTime>())?.let { + AsOf(offsetDateTime = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<String>())?.let { + AsOf(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> AsOf(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<AsOf>(AsOf::class) { + + override fun serialize( + value: AsOf, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.offsetDateTime != null -> generator.writeObject(value.offsetDateTime) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid AsOf") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetCloneParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "DatasetCloneParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetCloneResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetCloneResponse.kt new file mode 100644 index 00000000..587ff2ef --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetCloneResponse.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class DatasetCloneResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [DatasetCloneResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DatasetCloneResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(datasetCloneResponse: DatasetCloneResponse) = apply { + additionalProperties = datasetCloneResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DatasetCloneResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DatasetCloneResponse = + DatasetCloneResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): DatasetCloneResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetCloneResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "DatasetCloneResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetCreateParams.kt new file mode 100644 index 00000000..6a681b02 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetCreateParams.kt @@ -0,0 +1,958 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create a new dataset. */ +class DatasetCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = body.name() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional<String> = body.id() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun createdAt(): Optional<OffsetDateTime> = body.createdAt() + + /** + * Enum for dataset data types. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dataType(): Optional<DataType> = body.dataType() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = body.description() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externallyManaged(): Optional<Boolean> = body.externallyManaged() + + fun _extra(): JsonValue = body._extra() + + fun _inputsSchemaDefinition(): JsonValue = body._inputsSchemaDefinition() + + fun _outputsSchemaDefinition(): JsonValue = body._outputsSchemaDefinition() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun transformations(): Optional<List<DatasetTransformation>> = body.transformations() + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _name(): JsonField<String> = body._name() + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _id(): JsonField<String> = body._id() + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _createdAt(): JsonField<OffsetDateTime> = body._createdAt() + + /** + * Returns the raw JSON value of [dataType]. + * + * Unlike [dataType], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _dataType(): JsonField<DataType> = body._dataType() + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _description(): JsonField<String> = body._description() + + /** + * Returns the raw JSON value of [externallyManaged]. + * + * Unlike [externallyManaged], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _externallyManaged(): JsonField<Boolean> = body._externallyManaged() + + /** + * Returns the raw JSON value of [transformations]. + * + * Unlike [transformations], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _transformations(): JsonField<List<DatasetTransformation>> = body._transformations() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DatasetCreateParams]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DatasetCreateParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(datasetCreateParams: DatasetCreateParams) = apply { + body = datasetCreateParams.body.toBuilder() + additionalHeaders = datasetCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetCreateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [name] + * - [id] + * - [createdAt] + * - [dataType] + * - [description] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun name(name: String) = apply { body.name(name) } + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { body.name(name) } + + fun id(id: String?) = apply { body.id(id) } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<String>) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { body.id(id) } + + fun createdAt(createdAt: OffsetDateTime) = apply { body.createdAt(createdAt) } + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { body.createdAt(createdAt) } + + /** Enum for dataset data types. */ + fun dataType(dataType: DataType) = apply { body.dataType(dataType) } + + /** + * Sets [Builder.dataType] to an arbitrary JSON value. + * + * You should usually call [Builder.dataType] with a well-typed [DataType] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dataType(dataType: JsonField<DataType>) = apply { body.dataType(dataType) } + + fun description(description: String?) = apply { body.description(description) } + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { body.description(description) } + + fun externallyManaged(externallyManaged: Boolean?) = apply { + body.externallyManaged(externallyManaged) + } + + /** + * Alias for [Builder.externallyManaged]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun externallyManaged(externallyManaged: Boolean) = + externallyManaged(externallyManaged as Boolean?) + + /** Alias for calling [Builder.externallyManaged] with `externallyManaged.orElse(null)`. */ + fun externallyManaged(externallyManaged: Optional<Boolean>) = + externallyManaged(externallyManaged.getOrNull()) + + /** + * Sets [Builder.externallyManaged] to an arbitrary JSON value. + * + * You should usually call [Builder.externallyManaged] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externallyManaged(externallyManaged: JsonField<Boolean>) = apply { + body.externallyManaged(externallyManaged) + } + + fun extra(extra: JsonValue) = apply { body.extra(extra) } + + fun inputsSchemaDefinition(inputsSchemaDefinition: JsonValue) = apply { + body.inputsSchemaDefinition(inputsSchemaDefinition) + } + + fun outputsSchemaDefinition(outputsSchemaDefinition: JsonValue) = apply { + body.outputsSchemaDefinition(outputsSchemaDefinition) + } + + fun transformations(transformations: List<DatasetTransformation>?) = apply { + body.transformations(transformations) + } + + /** Alias for calling [Builder.transformations] with `transformations.orElse(null)`. */ + fun transformations(transformations: Optional<List<DatasetTransformation>>) = + transformations(transformations.getOrNull()) + + /** + * Sets [Builder.transformations] to an arbitrary JSON value. + * + * You should usually call [Builder.transformations] with a well-typed + * `List<DatasetTransformation>` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun transformations(transformations: JsonField<List<DatasetTransformation>>) = apply { + body.transformations(transformations) + } + + /** + * Adds a single [DatasetTransformation] to [transformations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTransformation(transformation: DatasetTransformation) = apply { + body.addTransformation(transformation) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [DatasetCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DatasetCreateParams = + DatasetCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Create class for Dataset. */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val name: JsonField<String>, + private val id: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val dataType: JsonField<DataType>, + private val description: JsonField<String>, + private val externallyManaged: JsonField<Boolean>, + private val extra: JsonValue, + private val inputsSchemaDefinition: JsonValue, + private val outputsSchemaDefinition: JsonValue, + private val transformations: JsonField<List<DatasetTransformation>>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("data_type") + @ExcludeMissing + dataType: JsonField<DataType> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("externally_managed") + @ExcludeMissing + externallyManaged: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("extra") @ExcludeMissing extra: JsonValue = JsonMissing.of(), + @JsonProperty("inputs_schema_definition") + @ExcludeMissing + inputsSchemaDefinition: JsonValue = JsonMissing.of(), + @JsonProperty("outputs_schema_definition") + @ExcludeMissing + outputsSchemaDefinition: JsonValue = JsonMissing.of(), + @JsonProperty("transformations") + @ExcludeMissing + transformations: JsonField<List<DatasetTransformation>> = JsonMissing.of(), + ) : this( + name, + id, + createdAt, + dataType, + description, + externallyManaged, + extra, + inputsSchemaDefinition, + outputsSchemaDefinition, + transformations, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun createdAt(): Optional<OffsetDateTime> = createdAt.getOptional("created_at") + + /** + * Enum for dataset data types. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun dataType(): Optional<DataType> = dataType.getOptional("data_type") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun externallyManaged(): Optional<Boolean> = + externallyManaged.getOptional("externally_managed") + + @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonValue = extra + + @JsonProperty("inputs_schema_definition") + @ExcludeMissing + fun _inputsSchemaDefinition(): JsonValue = inputsSchemaDefinition + + @JsonProperty("outputs_schema_definition") + @ExcludeMissing + fun _outputsSchemaDefinition(): JsonValue = outputsSchemaDefinition + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun transformations(): Optional<List<DatasetTransformation>> = + transformations.getOptional("transformations") + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [dataType]. + * + * Unlike [dataType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data_type") @ExcludeMissing fun _dataType(): JsonField<DataType> = dataType + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [externallyManaged]. + * + * Unlike [externallyManaged], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("externally_managed") + @ExcludeMissing + fun _externallyManaged(): JsonField<Boolean> = externallyManaged + + /** + * Returns the raw JSON value of [transformations]. + * + * Unlike [transformations], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("transformations") + @ExcludeMissing + fun _transformations(): JsonField<List<DatasetTransformation>> = transformations + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var name: JsonField<String>? = null + private var id: JsonField<String> = JsonMissing.of() + private var createdAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var dataType: JsonField<DataType> = JsonMissing.of() + private var description: JsonField<String> = JsonMissing.of() + private var externallyManaged: JsonField<Boolean> = JsonMissing.of() + private var extra: JsonValue = JsonMissing.of() + private var inputsSchemaDefinition: JsonValue = JsonMissing.of() + private var outputsSchemaDefinition: JsonValue = JsonMissing.of() + private var transformations: JsonField<MutableList<DatasetTransformation>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + name = body.name + id = body.id + createdAt = body.createdAt + dataType = body.dataType + description = body.description + externallyManaged = body.externallyManaged + extra = body.extra + inputsSchemaDefinition = body.inputsSchemaDefinition + outputsSchemaDefinition = body.outputsSchemaDefinition + transformations = body.transformations.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun id(id: String?) = id(JsonField.ofNullable(id)) + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<String>) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { + this.createdAt = createdAt + } + + /** Enum for dataset data types. */ + fun dataType(dataType: DataType) = dataType(JsonField.of(dataType)) + + /** + * Sets [Builder.dataType] to an arbitrary JSON value. + * + * You should usually call [Builder.dataType] with a well-typed [DataType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dataType(dataType: JsonField<DataType>) = apply { this.dataType = dataType } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField<String>) = apply { + this.description = description + } + + fun externallyManaged(externallyManaged: Boolean?) = + externallyManaged(JsonField.ofNullable(externallyManaged)) + + /** + * Alias for [Builder.externallyManaged]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun externallyManaged(externallyManaged: Boolean) = + externallyManaged(externallyManaged as Boolean?) + + /** + * Alias for calling [Builder.externallyManaged] with `externallyManaged.orElse(null)`. + */ + fun externallyManaged(externallyManaged: Optional<Boolean>) = + externallyManaged(externallyManaged.getOrNull()) + + /** + * Sets [Builder.externallyManaged] to an arbitrary JSON value. + * + * You should usually call [Builder.externallyManaged] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externallyManaged(externallyManaged: JsonField<Boolean>) = apply { + this.externallyManaged = externallyManaged + } + + fun extra(extra: JsonValue) = apply { this.extra = extra } + + fun inputsSchemaDefinition(inputsSchemaDefinition: JsonValue) = apply { + this.inputsSchemaDefinition = inputsSchemaDefinition + } + + fun outputsSchemaDefinition(outputsSchemaDefinition: JsonValue) = apply { + this.outputsSchemaDefinition = outputsSchemaDefinition + } + + fun transformations(transformations: List<DatasetTransformation>?) = + transformations(JsonField.ofNullable(transformations)) + + /** Alias for calling [Builder.transformations] with `transformations.orElse(null)`. */ + fun transformations(transformations: Optional<List<DatasetTransformation>>) = + transformations(transformations.getOrNull()) + + /** + * Sets [Builder.transformations] to an arbitrary JSON value. + * + * You should usually call [Builder.transformations] with a well-typed + * `List<DatasetTransformation>` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun transformations(transformations: JsonField<List<DatasetTransformation>>) = apply { + this.transformations = transformations.map { it.toMutableList() } + } + + /** + * Adds a single [DatasetTransformation] to [transformations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTransformation(transformation: DatasetTransformation) = apply { + transformations = + (transformations ?: JsonField.of(mutableListOf())).also { + checkKnown("transformations", it).add(transformation) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("name", name), + id, + createdAt, + dataType, + description, + externallyManaged, + extra, + inputsSchemaDefinition, + outputsSchemaDefinition, + (transformations ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + name() + id() + createdAt() + dataType().ifPresent { it.validate() } + description() + externallyManaged() + transformations().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (name.asKnown().isPresent) 1 else 0) + + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (dataType.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (externallyManaged.asKnown().isPresent) 1 else 0) + + (transformations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + name == other.name && + id == other.id && + createdAt == other.createdAt && + dataType == other.dataType && + description == other.description && + externallyManaged == other.externallyManaged && + extra == other.extra && + inputsSchemaDefinition == other.inputsSchemaDefinition && + outputsSchemaDefinition == other.outputsSchemaDefinition && + transformations == other.transformations && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + name, + id, + createdAt, + dataType, + description, + externallyManaged, + extra, + inputsSchemaDefinition, + outputsSchemaDefinition, + transformations, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{name=$name, id=$id, createdAt=$createdAt, dataType=$dataType, description=$description, externallyManaged=$externallyManaged, extra=$extra, inputsSchemaDefinition=$inputsSchemaDefinition, outputsSchemaDefinition=$outputsSchemaDefinition, transformations=$transformations, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "DatasetCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetDeleteParams.kt new file mode 100644 index 00000000..4e6ee61d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetDeleteParams.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete a specific dataset. */ +class DatasetDeleteParams +private constructor( + private val datasetId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun datasetId(): Optional<String> = Optional.ofNullable(datasetId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): DatasetDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [DatasetDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DatasetDeleteParams]. */ + class Builder internal constructor() { + + private var datasetId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(datasetDeleteParams: DatasetDeleteParams) = apply { + datasetId = datasetDeleteParams.datasetId + additionalHeaders = datasetDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = datasetDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun datasetId(datasetId: String?) = apply { this.datasetId = datasetId } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [DatasetDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DatasetDeleteParams = + DatasetDeleteParams( + datasetId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> datasetId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetDeleteParams && + datasetId == other.datasetId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(datasetId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "DatasetDeleteParams{datasetId=$datasetId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetDeleteResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetDeleteResponse.kt new file mode 100644 index 00000000..eb860c50 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetDeleteResponse.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class DatasetDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [DatasetDeleteResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DatasetDeleteResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(datasetDeleteResponse: DatasetDeleteResponse) = apply { + additionalProperties = datasetDeleteResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DatasetDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DatasetDeleteResponse = + DatasetDeleteResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): DatasetDeleteResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetDeleteResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "DatasetDeleteResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetGenerateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetGenerateParams.kt new file mode 100644 index 00000000..661fc466 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetGenerateParams.kt @@ -0,0 +1,532 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Generate synthetic examples for a dataset. */ +class DatasetGenerateParams +private constructor( + private val datasetId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun datasetId(): Optional<String> = Optional.ofNullable(datasetId) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun numExamples(): Long = body.numExamples() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun exampleIds(): Optional<List<String>> = body.exampleIds() + + /** + * Returns the raw JSON value of [numExamples]. + * + * Unlike [numExamples], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _numExamples(): JsonField<Long> = body._numExamples() + + /** + * Returns the raw JSON value of [exampleIds]. + * + * Unlike [exampleIds], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _exampleIds(): JsonField<List<String>> = body._exampleIds() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DatasetGenerateParams]. + * + * The following fields are required: + * ```java + * .numExamples() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DatasetGenerateParams]. */ + class Builder internal constructor() { + + private var datasetId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(datasetGenerateParams: DatasetGenerateParams) = apply { + datasetId = datasetGenerateParams.datasetId + body = datasetGenerateParams.body.toBuilder() + additionalHeaders = datasetGenerateParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetGenerateParams.additionalQueryParams.toBuilder() + } + + fun datasetId(datasetId: String?) = apply { this.datasetId = datasetId } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [numExamples] + * - [exampleIds] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun numExamples(numExamples: Long) = apply { body.numExamples(numExamples) } + + /** + * Sets [Builder.numExamples] to an arbitrary JSON value. + * + * You should usually call [Builder.numExamples] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun numExamples(numExamples: JsonField<Long>) = apply { body.numExamples(numExamples) } + + fun exampleIds(exampleIds: List<String>?) = apply { body.exampleIds(exampleIds) } + + /** Alias for calling [Builder.exampleIds] with `exampleIds.orElse(null)`. */ + fun exampleIds(exampleIds: Optional<List<String>>) = exampleIds(exampleIds.getOrNull()) + + /** + * Sets [Builder.exampleIds] to an arbitrary JSON value. + * + * You should usually call [Builder.exampleIds] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun exampleIds(exampleIds: JsonField<List<String>>) = apply { body.exampleIds(exampleIds) } + + /** + * Adds a single [String] to [exampleIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExampleId(exampleId: String) = apply { body.addExampleId(exampleId) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [DatasetGenerateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .numExamples() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DatasetGenerateParams = + DatasetGenerateParams( + datasetId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> datasetId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val numExamples: JsonField<Long>, + private val exampleIds: JsonField<List<String>>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("num_examples") + @ExcludeMissing + numExamples: JsonField<Long> = JsonMissing.of(), + @JsonProperty("example_ids") + @ExcludeMissing + exampleIds: JsonField<List<String>> = JsonMissing.of(), + ) : this(numExamples, exampleIds, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun numExamples(): Long = numExamples.getRequired("num_examples") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun exampleIds(): Optional<List<String>> = exampleIds.getOptional("example_ids") + + /** + * Returns the raw JSON value of [numExamples]. + * + * Unlike [numExamples], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("num_examples") + @ExcludeMissing + fun _numExamples(): JsonField<Long> = numExamples + + /** + * Returns the raw JSON value of [exampleIds]. + * + * Unlike [exampleIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("example_ids") + @ExcludeMissing + fun _exampleIds(): JsonField<List<String>> = exampleIds + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .numExamples() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var numExamples: JsonField<Long>? = null + private var exampleIds: JsonField<MutableList<String>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + numExamples = body.numExamples + exampleIds = body.exampleIds.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun numExamples(numExamples: Long) = numExamples(JsonField.of(numExamples)) + + /** + * Sets [Builder.numExamples] to an arbitrary JSON value. + * + * You should usually call [Builder.numExamples] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun numExamples(numExamples: JsonField<Long>) = apply { this.numExamples = numExamples } + + fun exampleIds(exampleIds: List<String>?) = exampleIds(JsonField.ofNullable(exampleIds)) + + /** Alias for calling [Builder.exampleIds] with `exampleIds.orElse(null)`. */ + fun exampleIds(exampleIds: Optional<List<String>>) = exampleIds(exampleIds.getOrNull()) + + /** + * Sets [Builder.exampleIds] to an arbitrary JSON value. + * + * You should usually call [Builder.exampleIds] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun exampleIds(exampleIds: JsonField<List<String>>) = apply { + this.exampleIds = exampleIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [exampleIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExampleId(exampleId: String) = apply { + exampleIds = + (exampleIds ?: JsonField.of(mutableListOf())).also { + checkKnown("exampleIds", it).add(exampleId) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .numExamples() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("numExamples", numExamples), + (exampleIds ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + numExamples() + exampleIds() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (numExamples.asKnown().isPresent) 1 else 0) + + (exampleIds.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + numExamples == other.numExamples && + exampleIds == other.exampleIds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(numExamples, exampleIds, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{numExamples=$numExamples, exampleIds=$exampleIds, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetGenerateParams && + datasetId == other.datasetId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(datasetId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "DatasetGenerateParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetGenerateResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetGenerateResponse.kt new file mode 100644 index 00000000..56b909f5 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetGenerateResponse.kt @@ -0,0 +1,115 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class DatasetGenerateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [DatasetGenerateResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DatasetGenerateResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(datasetGenerateResponse: DatasetGenerateResponse) = apply { + additionalProperties = datasetGenerateResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DatasetGenerateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DatasetGenerateResponse = + DatasetGenerateResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): DatasetGenerateResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetGenerateResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "DatasetGenerateResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetListParams.kt new file mode 100644 index 00000000..8fdbe764 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetListParams.kt @@ -0,0 +1,481 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get all datasets by query params and owner. */ +class DatasetListParams +private constructor( + private val id: List<String>?, + private val dataType: DataType?, + private val excludeCorrectionsDatasets: Boolean?, + private val limit: Long?, + private val metadata: String?, + private val name: String?, + private val nameContains: String?, + private val offset: Long?, + private val sortBy: SortByDatasetColumn?, + private val sortByDesc: Boolean?, + private val tagValueId: List<String>?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun id(): Optional<List<String>> = Optional.ofNullable(id) + + /** Enum for dataset data types. */ + fun dataType(): Optional<DataType> = Optional.ofNullable(dataType) + + fun excludeCorrectionsDatasets(): Optional<Boolean> = + Optional.ofNullable(excludeCorrectionsDatasets) + + fun limit(): Optional<Long> = Optional.ofNullable(limit) + + fun metadata(): Optional<String> = Optional.ofNullable(metadata) + + fun name(): Optional<String> = Optional.ofNullable(name) + + fun nameContains(): Optional<String> = Optional.ofNullable(nameContains) + + fun offset(): Optional<Long> = Optional.ofNullable(offset) + + /** Enum for available dataset columns to sort by. */ + fun sortBy(): Optional<SortByDatasetColumn> = Optional.ofNullable(sortBy) + + fun sortByDesc(): Optional<Boolean> = Optional.ofNullable(sortByDesc) + + fun tagValueId(): Optional<List<String>> = Optional.ofNullable(tagValueId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): DatasetListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [DatasetListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DatasetListParams]. */ + class Builder internal constructor() { + + private var id: MutableList<String>? = null + private var dataType: DataType? = null + private var excludeCorrectionsDatasets: Boolean? = null + private var limit: Long? = null + private var metadata: String? = null + private var name: String? = null + private var nameContains: String? = null + private var offset: Long? = null + private var sortBy: SortByDatasetColumn? = null + private var sortByDesc: Boolean? = null + private var tagValueId: MutableList<String>? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(datasetListParams: DatasetListParams) = apply { + id = datasetListParams.id?.toMutableList() + dataType = datasetListParams.dataType + excludeCorrectionsDatasets = datasetListParams.excludeCorrectionsDatasets + limit = datasetListParams.limit + metadata = datasetListParams.metadata + name = datasetListParams.name + nameContains = datasetListParams.nameContains + offset = datasetListParams.offset + sortBy = datasetListParams.sortBy + sortByDesc = datasetListParams.sortByDesc + tagValueId = datasetListParams.tagValueId?.toMutableList() + additionalHeaders = datasetListParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetListParams.additionalQueryParams.toBuilder() + } + + fun id(id: List<String>?) = apply { this.id = id?.toMutableList() } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<List<String>>) = id(id.getOrNull()) + + /** + * Adds a single [String] to [Builder.id]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addId(id: String) = apply { this.id = (this.id ?: mutableListOf()).apply { add(id) } } + + /** Enum for dataset data types. */ + fun dataType(dataType: DataType?) = apply { this.dataType = dataType } + + /** Alias for calling [Builder.dataType] with `dataType.orElse(null)`. */ + fun dataType(dataType: Optional<DataType>) = dataType(dataType.getOrNull()) + + /** Alias for calling [dataType] with `DataType.ofTypes(types)`. */ + fun dataTypeOfTypes(types: List<DataType>) = dataType(DataType.ofTypes(types)) + + /** Alias for calling [Builder.dataType] with `DataType.ofDataType(dataType)`. */ + fun dataType(dataType: DataType) = dataType(DataType.ofDataType(dataType)) + + fun excludeCorrectionsDatasets(excludeCorrectionsDatasets: Boolean?) = apply { + this.excludeCorrectionsDatasets = excludeCorrectionsDatasets + } + + /** + * Alias for [Builder.excludeCorrectionsDatasets]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun excludeCorrectionsDatasets(excludeCorrectionsDatasets: Boolean) = + excludeCorrectionsDatasets(excludeCorrectionsDatasets as Boolean?) + + /** + * Alias for calling [Builder.excludeCorrectionsDatasets] with + * `excludeCorrectionsDatasets.orElse(null)`. + */ + fun excludeCorrectionsDatasets(excludeCorrectionsDatasets: Optional<Boolean>) = + excludeCorrectionsDatasets(excludeCorrectionsDatasets.getOrNull()) + + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional<Long>) = limit(limit.getOrNull()) + + fun metadata(metadata: String?) = apply { this.metadata = metadata } + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional<String>) = metadata(metadata.getOrNull()) + + fun name(name: String?) = apply { this.name = name } + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional<String>) = name(name.getOrNull()) + + fun nameContains(nameContains: String?) = apply { this.nameContains = nameContains } + + /** Alias for calling [Builder.nameContains] with `nameContains.orElse(null)`. */ + fun nameContains(nameContains: Optional<String>) = nameContains(nameContains.getOrNull()) + + fun offset(offset: Long?) = apply { this.offset = offset } + + /** + * Alias for [Builder.offset]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun offset(offset: Long) = offset(offset as Long?) + + /** Alias for calling [Builder.offset] with `offset.orElse(null)`. */ + fun offset(offset: Optional<Long>) = offset(offset.getOrNull()) + + /** Enum for available dataset columns to sort by. */ + fun sortBy(sortBy: SortByDatasetColumn?) = apply { this.sortBy = sortBy } + + /** Alias for calling [Builder.sortBy] with `sortBy.orElse(null)`. */ + fun sortBy(sortBy: Optional<SortByDatasetColumn>) = sortBy(sortBy.getOrNull()) + + fun sortByDesc(sortByDesc: Boolean?) = apply { this.sortByDesc = sortByDesc } + + /** + * Alias for [Builder.sortByDesc]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun sortByDesc(sortByDesc: Boolean) = sortByDesc(sortByDesc as Boolean?) + + /** Alias for calling [Builder.sortByDesc] with `sortByDesc.orElse(null)`. */ + fun sortByDesc(sortByDesc: Optional<Boolean>) = sortByDesc(sortByDesc.getOrNull()) + + fun tagValueId(tagValueId: List<String>?) = apply { + this.tagValueId = tagValueId?.toMutableList() + } + + /** Alias for calling [Builder.tagValueId] with `tagValueId.orElse(null)`. */ + fun tagValueId(tagValueId: Optional<List<String>>) = tagValueId(tagValueId.getOrNull()) + + /** + * Adds a single [String] to [Builder.tagValueId]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTagValueId(tagValueId: String) = apply { + this.tagValueId = (this.tagValueId ?: mutableListOf()).apply { add(tagValueId) } + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [DatasetListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DatasetListParams = + DatasetListParams( + id?.toImmutable(), + dataType, + excludeCorrectionsDatasets, + limit, + metadata, + name, + nameContains, + offset, + sortBy, + sortByDesc, + tagValueId?.toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + id?.let { put("id", it.joinToString(",")) } + dataType?.accept( + object : DataType.Visitor<Unit> { + override fun visitTypes(types: List<DataType>) { + put("data_type", types.joinToString(",") { it.toString() }) + } + + override fun visitDataType(dataType: DataType) { + put("data_type", dataType.toString()) + } + } + ) + excludeCorrectionsDatasets?.let { + put("exclude_corrections_datasets", it.toString()) + } + limit?.let { put("limit", it.toString()) } + metadata?.let { put("metadata", it) } + name?.let { put("name", it) } + nameContains?.let { put("name_contains", it) } + offset?.let { put("offset", it.toString()) } + sortBy?.let { put("sort_by", it.toString()) } + sortByDesc?.let { put("sort_by_desc", it.toString()) } + tagValueId?.let { put("tag_value_id", it.joinToString(",")) } + putAll(additionalQueryParams) + } + .build() + + /** Enum for dataset data types. */ + class DataType + private constructor( + private val types: List<DataType>? = null, + private val dataType: DataType? = null, + ) { + + fun types(): Optional<List<DataType>> = Optional.ofNullable(types) + + /** Enum for dataset data types. */ + fun dataType(): Optional<DataType> = Optional.ofNullable(dataType) + + fun isTypes(): Boolean = types != null + + fun isDataType(): Boolean = dataType != null + + fun asTypes(): List<DataType> = types.getOrThrow("types") + + /** Enum for dataset data types. */ + fun asDataType(): DataType = dataType.getOrThrow("dataType") + + fun <T> accept(visitor: Visitor<T>): T = + when { + types != null -> visitor.visitTypes(types) + dataType != null -> visitor.visitDataType(dataType) + else -> throw IllegalStateException("Invalid DataType") + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DataType && types == other.types && dataType == other.dataType + } + + override fun hashCode(): Int = Objects.hash(types, dataType) + + override fun toString(): String = + when { + types != null -> "DataType{types=$types}" + dataType != null -> "DataType{dataType=$dataType}" + else -> throw IllegalStateException("Invalid DataType") + } + + companion object { + + @JvmStatic fun ofTypes(types: List<DataType>) = DataType(types = types.toImmutable()) + + /** Enum for dataset data types. */ + @JvmStatic fun ofDataType(dataType: DataType) = DataType(dataType = dataType) + } + + /** + * An interface that defines how to map each variant of [DataType] to a value of type [T]. + */ + interface Visitor<out T> { + + fun visitTypes(types: List<DataType>): T + + /** Enum for dataset data types. */ + fun visitDataType(dataType: DataType): T + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetListParams && + id == other.id && + dataType == other.dataType && + excludeCorrectionsDatasets == other.excludeCorrectionsDatasets && + limit == other.limit && + metadata == other.metadata && + name == other.name && + nameContains == other.nameContains && + offset == other.offset && + sortBy == other.sortBy && + sortByDesc == other.sortByDesc && + tagValueId == other.tagValueId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + id, + dataType, + excludeCorrectionsDatasets, + limit, + metadata, + name, + nameContains, + offset, + sortBy, + sortByDesc, + tagValueId, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "DatasetListParams{id=$id, dataType=$dataType, excludeCorrectionsDatasets=$excludeCorrectionsDatasets, limit=$limit, metadata=$metadata, name=$name, nameContains=$nameContains, offset=$offset, sortBy=$sortBy, sortByDesc=$sortByDesc, tagValueId=$tagValueId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveCsvParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveCsvParams.kt new file mode 100644 index 00000000..0c062c50 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveCsvParams.kt @@ -0,0 +1,222 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Download a dataset as CSV format. */ +class DatasetRetrieveCsvParams +private constructor( + private val datasetId: String?, + private val asOf: OffsetDateTime?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun datasetId(): Optional<String> = Optional.ofNullable(datasetId) + + /** + * Only modifications made on or before this time are included. If None, the latest version of + * the dataset is used. + */ + fun asOf(): Optional<OffsetDateTime> = Optional.ofNullable(asOf) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): DatasetRetrieveCsvParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [DatasetRetrieveCsvParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DatasetRetrieveCsvParams]. */ + class Builder internal constructor() { + + private var datasetId: String? = null + private var asOf: OffsetDateTime? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(datasetRetrieveCsvParams: DatasetRetrieveCsvParams) = apply { + datasetId = datasetRetrieveCsvParams.datasetId + asOf = datasetRetrieveCsvParams.asOf + additionalHeaders = datasetRetrieveCsvParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetRetrieveCsvParams.additionalQueryParams.toBuilder() + } + + fun datasetId(datasetId: String?) = apply { this.datasetId = datasetId } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + /** + * Only modifications made on or before this time are included. If None, the latest version + * of the dataset is used. + */ + fun asOf(asOf: OffsetDateTime?) = apply { this.asOf = asOf } + + /** Alias for calling [Builder.asOf] with `asOf.orElse(null)`. */ + fun asOf(asOf: Optional<OffsetDateTime>) = asOf(asOf.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [DatasetRetrieveCsvParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DatasetRetrieveCsvParams = + DatasetRetrieveCsvParams( + datasetId, + asOf, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> datasetId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + asOf?.let { put("as_of", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetRetrieveCsvParams && + datasetId == other.datasetId && + asOf == other.asOf && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(datasetId, asOf, additionalHeaders, additionalQueryParams) + + override fun toString() = + "DatasetRetrieveCsvParams{datasetId=$datasetId, asOf=$asOf, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveCsvResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveCsvResponse.kt new file mode 100644 index 00000000..74985df3 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveCsvResponse.kt @@ -0,0 +1,118 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class DatasetRetrieveCsvResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DatasetRetrieveCsvResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DatasetRetrieveCsvResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(datasetRetrieveCsvResponse: DatasetRetrieveCsvResponse) = apply { + additionalProperties = datasetRetrieveCsvResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DatasetRetrieveCsvResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DatasetRetrieveCsvResponse = + DatasetRetrieveCsvResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): DatasetRetrieveCsvResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetRetrieveCsvResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DatasetRetrieveCsvResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveJsonlParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveJsonlParams.kt new file mode 100644 index 00000000..eaa5cf27 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveJsonlParams.kt @@ -0,0 +1,224 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Download a dataset as CSV format. */ +class DatasetRetrieveJsonlParams +private constructor( + private val datasetId: String?, + private val asOf: OffsetDateTime?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun datasetId(): Optional<String> = Optional.ofNullable(datasetId) + + /** + * Only modifications made on or before this time are included. If None, the latest version of + * the dataset is used. + */ + fun asOf(): Optional<OffsetDateTime> = Optional.ofNullable(asOf) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): DatasetRetrieveJsonlParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [DatasetRetrieveJsonlParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DatasetRetrieveJsonlParams]. */ + class Builder internal constructor() { + + private var datasetId: String? = null + private var asOf: OffsetDateTime? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(datasetRetrieveJsonlParams: DatasetRetrieveJsonlParams) = apply { + datasetId = datasetRetrieveJsonlParams.datasetId + asOf = datasetRetrieveJsonlParams.asOf + additionalHeaders = datasetRetrieveJsonlParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetRetrieveJsonlParams.additionalQueryParams.toBuilder() + } + + fun datasetId(datasetId: String?) = apply { this.datasetId = datasetId } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + /** + * Only modifications made on or before this time are included. If None, the latest version + * of the dataset is used. + */ + fun asOf(asOf: OffsetDateTime?) = apply { this.asOf = asOf } + + /** Alias for calling [Builder.asOf] with `asOf.orElse(null)`. */ + fun asOf(asOf: Optional<OffsetDateTime>) = asOf(asOf.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [DatasetRetrieveJsonlParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DatasetRetrieveJsonlParams = + DatasetRetrieveJsonlParams( + datasetId, + asOf, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> datasetId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + asOf?.let { put("as_of", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetRetrieveJsonlParams && + datasetId == other.datasetId && + asOf == other.asOf && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(datasetId, asOf, additionalHeaders, additionalQueryParams) + + override fun toString() = + "DatasetRetrieveJsonlParams{datasetId=$datasetId, asOf=$asOf, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveJsonlResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveJsonlResponse.kt new file mode 100644 index 00000000..2b2dada6 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveJsonlResponse.kt @@ -0,0 +1,118 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class DatasetRetrieveJsonlResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DatasetRetrieveJsonlResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DatasetRetrieveJsonlResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(datasetRetrieveJsonlResponse: DatasetRetrieveJsonlResponse) = apply { + additionalProperties = datasetRetrieveJsonlResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DatasetRetrieveJsonlResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DatasetRetrieveJsonlResponse = + DatasetRetrieveJsonlResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): DatasetRetrieveJsonlResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetRetrieveJsonlResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DatasetRetrieveJsonlResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveOpenAIFtParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveOpenAIFtParams.kt new file mode 100644 index 00000000..0fad43fc --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveOpenAIFtParams.kt @@ -0,0 +1,225 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Download a dataset as OpenAI Jsonl format. */ +class DatasetRetrieveOpenAIFtParams +private constructor( + private val datasetId: String?, + private val asOf: OffsetDateTime?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun datasetId(): Optional<String> = Optional.ofNullable(datasetId) + + /** + * Only modifications made on or before this time are included. If None, the latest version of + * the dataset is used. + */ + fun asOf(): Optional<OffsetDateTime> = Optional.ofNullable(asOf) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): DatasetRetrieveOpenAIFtParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [DatasetRetrieveOpenAIFtParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DatasetRetrieveOpenAIFtParams]. */ + class Builder internal constructor() { + + private var datasetId: String? = null + private var asOf: OffsetDateTime? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(datasetRetrieveOpenAIFtParams: DatasetRetrieveOpenAIFtParams) = apply { + datasetId = datasetRetrieveOpenAIFtParams.datasetId + asOf = datasetRetrieveOpenAIFtParams.asOf + additionalHeaders = datasetRetrieveOpenAIFtParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetRetrieveOpenAIFtParams.additionalQueryParams.toBuilder() + } + + fun datasetId(datasetId: String?) = apply { this.datasetId = datasetId } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + /** + * Only modifications made on or before this time are included. If None, the latest version + * of the dataset is used. + */ + fun asOf(asOf: OffsetDateTime?) = apply { this.asOf = asOf } + + /** Alias for calling [Builder.asOf] with `asOf.orElse(null)`. */ + fun asOf(asOf: Optional<OffsetDateTime>) = asOf(asOf.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [DatasetRetrieveOpenAIFtParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DatasetRetrieveOpenAIFtParams = + DatasetRetrieveOpenAIFtParams( + datasetId, + asOf, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> datasetId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + asOf?.let { put("as_of", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetRetrieveOpenAIFtParams && + datasetId == other.datasetId && + asOf == other.asOf && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(datasetId, asOf, additionalHeaders, additionalQueryParams) + + override fun toString() = + "DatasetRetrieveOpenAIFtParams{datasetId=$datasetId, asOf=$asOf, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveOpenAIFtResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveOpenAIFtResponse.kt new file mode 100644 index 00000000..55feab55 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveOpenAIFtResponse.kt @@ -0,0 +1,121 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class DatasetRetrieveOpenAIFtResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [DatasetRetrieveOpenAIFtResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DatasetRetrieveOpenAIFtResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(datasetRetrieveOpenAIFtResponse: DatasetRetrieveOpenAIFtResponse) = + apply { + additionalProperties = + datasetRetrieveOpenAIFtResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DatasetRetrieveOpenAIFtResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DatasetRetrieveOpenAIFtResponse = + DatasetRetrieveOpenAIFtResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): DatasetRetrieveOpenAIFtResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetRetrieveOpenAIFtResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DatasetRetrieveOpenAIFtResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveOpenAIParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveOpenAIParams.kt new file mode 100644 index 00000000..2ecd3072 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveOpenAIParams.kt @@ -0,0 +1,224 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Download a dataset as OpenAI Evals Jsonl format. */ +class DatasetRetrieveOpenAIParams +private constructor( + private val datasetId: String?, + private val asOf: OffsetDateTime?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun datasetId(): Optional<String> = Optional.ofNullable(datasetId) + + /** + * Only modifications made on or before this time are included. If None, the latest version of + * the dataset is used. + */ + fun asOf(): Optional<OffsetDateTime> = Optional.ofNullable(asOf) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): DatasetRetrieveOpenAIParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [DatasetRetrieveOpenAIParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DatasetRetrieveOpenAIParams]. */ + class Builder internal constructor() { + + private var datasetId: String? = null + private var asOf: OffsetDateTime? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(datasetRetrieveOpenAIParams: DatasetRetrieveOpenAIParams) = apply { + datasetId = datasetRetrieveOpenAIParams.datasetId + asOf = datasetRetrieveOpenAIParams.asOf + additionalHeaders = datasetRetrieveOpenAIParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetRetrieveOpenAIParams.additionalQueryParams.toBuilder() + } + + fun datasetId(datasetId: String?) = apply { this.datasetId = datasetId } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + /** + * Only modifications made on or before this time are included. If None, the latest version + * of the dataset is used. + */ + fun asOf(asOf: OffsetDateTime?) = apply { this.asOf = asOf } + + /** Alias for calling [Builder.asOf] with `asOf.orElse(null)`. */ + fun asOf(asOf: Optional<OffsetDateTime>) = asOf(asOf.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [DatasetRetrieveOpenAIParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DatasetRetrieveOpenAIParams = + DatasetRetrieveOpenAIParams( + datasetId, + asOf, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> datasetId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + asOf?.let { put("as_of", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetRetrieveOpenAIParams && + datasetId == other.datasetId && + asOf == other.asOf && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(datasetId, asOf, additionalHeaders, additionalQueryParams) + + override fun toString() = + "DatasetRetrieveOpenAIParams{datasetId=$datasetId, asOf=$asOf, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveOpenAIResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveOpenAIResponse.kt new file mode 100644 index 00000000..d4740025 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveOpenAIResponse.kt @@ -0,0 +1,119 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class DatasetRetrieveOpenAIResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [DatasetRetrieveOpenAIResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DatasetRetrieveOpenAIResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(datasetRetrieveOpenAIResponse: DatasetRetrieveOpenAIResponse) = apply { + additionalProperties = datasetRetrieveOpenAIResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DatasetRetrieveOpenAIResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DatasetRetrieveOpenAIResponse = + DatasetRetrieveOpenAIResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): DatasetRetrieveOpenAIResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetRetrieveOpenAIResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DatasetRetrieveOpenAIResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveParams.kt new file mode 100644 index 00000000..f1bb0fb7 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveParams.kt @@ -0,0 +1,193 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get a specific dataset. */ +class DatasetRetrieveParams +private constructor( + private val datasetId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun datasetId(): Optional<String> = Optional.ofNullable(datasetId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): DatasetRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [DatasetRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DatasetRetrieveParams]. */ + class Builder internal constructor() { + + private var datasetId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(datasetRetrieveParams: DatasetRetrieveParams) = apply { + datasetId = datasetRetrieveParams.datasetId + additionalHeaders = datasetRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetRetrieveParams.additionalQueryParams.toBuilder() + } + + fun datasetId(datasetId: String?) = apply { this.datasetId = datasetId } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [DatasetRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DatasetRetrieveParams = + DatasetRetrieveParams( + datasetId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> datasetId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetRetrieveParams && + datasetId == other.datasetId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(datasetId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "DatasetRetrieveParams{datasetId=$datasetId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveVersionParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveVersionParams.kt new file mode 100644 index 00000000..ecb88248 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveVersionParams.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get dataset version by as_of or exact tag. */ +class DatasetRetrieveVersionParams +private constructor( + private val datasetId: String?, + private val asOf: OffsetDateTime?, + private val tag: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun datasetId(): Optional<String> = Optional.ofNullable(datasetId) + + fun asOf(): Optional<OffsetDateTime> = Optional.ofNullable(asOf) + + fun tag(): Optional<String> = Optional.ofNullable(tag) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): DatasetRetrieveVersionParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [DatasetRetrieveVersionParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DatasetRetrieveVersionParams]. */ + class Builder internal constructor() { + + private var datasetId: String? = null + private var asOf: OffsetDateTime? = null + private var tag: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(datasetRetrieveVersionParams: DatasetRetrieveVersionParams) = apply { + datasetId = datasetRetrieveVersionParams.datasetId + asOf = datasetRetrieveVersionParams.asOf + tag = datasetRetrieveVersionParams.tag + additionalHeaders = datasetRetrieveVersionParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetRetrieveVersionParams.additionalQueryParams.toBuilder() + } + + fun datasetId(datasetId: String?) = apply { this.datasetId = datasetId } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + fun asOf(asOf: OffsetDateTime?) = apply { this.asOf = asOf } + + /** Alias for calling [Builder.asOf] with `asOf.orElse(null)`. */ + fun asOf(asOf: Optional<OffsetDateTime>) = asOf(asOf.getOrNull()) + + fun tag(tag: String?) = apply { this.tag = tag } + + /** Alias for calling [Builder.tag] with `tag.orElse(null)`. */ + fun tag(tag: Optional<String>) = tag(tag.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [DatasetRetrieveVersionParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DatasetRetrieveVersionParams = + DatasetRetrieveVersionParams( + datasetId, + asOf, + tag, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> datasetId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + asOf?.let { put("as_of", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) } + tag?.let { put("tag", it) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetRetrieveVersionParams && + datasetId == other.datasetId && + asOf == other.asOf && + tag == other.tag && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(datasetId, asOf, tag, additionalHeaders, additionalQueryParams) + + override fun toString() = + "DatasetRetrieveVersionParams{datasetId=$datasetId, asOf=$asOf, tag=$tag, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetSearchParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetSearchParams.kt new file mode 100644 index 00000000..5af7a637 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetSearchParams.kt @@ -0,0 +1,571 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Search a dataset. */ +class DatasetSearchParams +private constructor( + private val datasetId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun datasetId(): Optional<String> = Optional.ofNullable(datasetId) + + fun _inputs(): JsonValue = body._inputs() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun debug(): Optional<Boolean> = body.debug() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun filter(): Optional<String> = body.filter() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun limit(): Optional<Long> = body.limit() + + /** + * Returns the raw JSON value of [debug]. + * + * Unlike [debug], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _debug(): JsonField<Boolean> = body._debug() + + /** + * Returns the raw JSON value of [filter]. + * + * Unlike [filter], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _filter(): JsonField<String> = body._filter() + + /** + * Returns the raw JSON value of [limit]. + * + * Unlike [limit], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _limit(): JsonField<Long> = body._limit() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DatasetSearchParams]. + * + * The following fields are required: + * ```java + * .inputs() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DatasetSearchParams]. */ + class Builder internal constructor() { + + private var datasetId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(datasetSearchParams: DatasetSearchParams) = apply { + datasetId = datasetSearchParams.datasetId + body = datasetSearchParams.body.toBuilder() + additionalHeaders = datasetSearchParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetSearchParams.additionalQueryParams.toBuilder() + } + + fun datasetId(datasetId: String?) = apply { this.datasetId = datasetId } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [inputs] + * - [debug] + * - [filter] + * - [limit] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun inputs(inputs: JsonValue) = apply { body.inputs(inputs) } + + fun debug(debug: Boolean) = apply { body.debug(debug) } + + /** + * Sets [Builder.debug] to an arbitrary JSON value. + * + * You should usually call [Builder.debug] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun debug(debug: JsonField<Boolean>) = apply { body.debug(debug) } + + fun filter(filter: String?) = apply { body.filter(filter) } + + /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ + fun filter(filter: Optional<String>) = filter(filter.getOrNull()) + + /** + * Sets [Builder.filter] to an arbitrary JSON value. + * + * You should usually call [Builder.filter] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun filter(filter: JsonField<String>) = apply { body.filter(filter) } + + fun limit(limit: Long) = apply { body.limit(limit) } + + /** + * Sets [Builder.limit] to an arbitrary JSON value. + * + * You should usually call [Builder.limit] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun limit(limit: JsonField<Long>) = apply { body.limit(limit) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [DatasetSearchParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .inputs() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DatasetSearchParams = + DatasetSearchParams( + datasetId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> datasetId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Dataset schema for serving. */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val inputs: JsonValue, + private val debug: JsonField<Boolean>, + private val filter: JsonField<String>, + private val limit: JsonField<Long>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("inputs") @ExcludeMissing inputs: JsonValue = JsonMissing.of(), + @JsonProperty("debug") @ExcludeMissing debug: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("filter") @ExcludeMissing filter: JsonField<String> = JsonMissing.of(), + @JsonProperty("limit") @ExcludeMissing limit: JsonField<Long> = JsonMissing.of(), + ) : this(inputs, debug, filter, limit, mutableMapOf()) + + @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonValue = inputs + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun debug(): Optional<Boolean> = debug.getOptional("debug") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun filter(): Optional<String> = filter.getOptional("filter") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun limit(): Optional<Long> = limit.getOptional("limit") + + /** + * Returns the raw JSON value of [debug]. + * + * Unlike [debug], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("debug") @ExcludeMissing fun _debug(): JsonField<Boolean> = debug + + /** + * Returns the raw JSON value of [filter]. + * + * Unlike [filter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField<String> = filter + + /** + * Returns the raw JSON value of [limit]. + * + * Unlike [limit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("limit") @ExcludeMissing fun _limit(): JsonField<Long> = limit + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .inputs() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var inputs: JsonValue? = null + private var debug: JsonField<Boolean> = JsonMissing.of() + private var filter: JsonField<String> = JsonMissing.of() + private var limit: JsonField<Long> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + inputs = body.inputs + debug = body.debug + filter = body.filter + limit = body.limit + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun inputs(inputs: JsonValue) = apply { this.inputs = inputs } + + fun debug(debug: Boolean) = debug(JsonField.of(debug)) + + /** + * Sets [Builder.debug] to an arbitrary JSON value. + * + * You should usually call [Builder.debug] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun debug(debug: JsonField<Boolean>) = apply { this.debug = debug } + + fun filter(filter: String?) = filter(JsonField.ofNullable(filter)) + + /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ + fun filter(filter: Optional<String>) = filter(filter.getOrNull()) + + /** + * Sets [Builder.filter] to an arbitrary JSON value. + * + * You should usually call [Builder.filter] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun filter(filter: JsonField<String>) = apply { this.filter = filter } + + fun limit(limit: Long) = limit(JsonField.of(limit)) + + /** + * Sets [Builder.limit] to an arbitrary JSON value. + * + * You should usually call [Builder.limit] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun limit(limit: JsonField<Long>) = apply { this.limit = limit } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .inputs() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("inputs", inputs), + debug, + filter, + limit, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + debug() + filter() + limit() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (debug.asKnown().isPresent) 1 else 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (if (limit.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + inputs == other.inputs && + debug == other.debug && + filter == other.filter && + limit == other.limit && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(inputs, debug, filter, limit, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{inputs=$inputs, debug=$debug, filter=$filter, limit=$limit, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetSearchParams && + datasetId == other.datasetId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(datasetId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "DatasetSearchParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetSearchResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetSearchResponse.kt new file mode 100644 index 00000000..416f5ab3 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetSearchResponse.kt @@ -0,0 +1,386 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** Dataset schema for serving. */ +class DatasetSearchResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val examples: JsonField<List<Example>>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("examples") + @ExcludeMissing + examples: JsonField<List<Example>> = JsonMissing.of() + ) : this(examples, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun examples(): List<Example> = examples.getRequired("examples") + + /** + * Returns the raw JSON value of [examples]. + * + * Unlike [examples], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("examples") @ExcludeMissing fun _examples(): JsonField<List<Example>> = examples + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DatasetSearchResponse]. + * + * The following fields are required: + * ```java + * .examples() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DatasetSearchResponse]. */ + class Builder internal constructor() { + + private var examples: JsonField<MutableList<Example>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(datasetSearchResponse: DatasetSearchResponse) = apply { + examples = datasetSearchResponse.examples.map { it.toMutableList() } + additionalProperties = datasetSearchResponse.additionalProperties.toMutableMap() + } + + fun examples(examples: List<Example>) = examples(JsonField.of(examples)) + + /** + * Sets [Builder.examples] to an arbitrary JSON value. + * + * You should usually call [Builder.examples] with a well-typed `List<Example>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun examples(examples: JsonField<List<Example>>) = apply { + this.examples = examples.map { it.toMutableList() } + } + + /** + * Adds a single [Example] to [examples]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExample(example: Example) = apply { + examples = + (examples ?: JsonField.of(mutableListOf())).also { + checkKnown("examples", it).add(example) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DatasetSearchResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .examples() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DatasetSearchResponse = + DatasetSearchResponse( + checkRequired("examples", examples).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DatasetSearchResponse = apply { + if (validated) { + return@apply + } + + examples().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (examples.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Dataset schema for serving. */ + class Example + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField<String>, + private val inputs: JsonValue, + private val outputs: JsonValue, + private val debugInfo: JsonValue, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("inputs") @ExcludeMissing inputs: JsonValue = JsonMissing.of(), + @JsonProperty("outputs") @ExcludeMissing outputs: JsonValue = JsonMissing.of(), + @JsonProperty("debug_info") @ExcludeMissing debugInfo: JsonValue = JsonMissing.of(), + ) : this(id, inputs, outputs, debugInfo, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonValue = inputs + + @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonValue = outputs + + @JsonProperty("debug_info") @ExcludeMissing fun _debugInfo(): JsonValue = debugInfo + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Example]. + * + * The following fields are required: + * ```java + * .id() + * .inputs() + * .outputs() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Example]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var inputs: JsonValue? = null + private var outputs: JsonValue? = null + private var debugInfo: JsonValue = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(example: Example) = apply { + id = example.id + inputs = example.inputs + outputs = example.outputs + debugInfo = example.debugInfo + additionalProperties = example.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun inputs(inputs: JsonValue) = apply { this.inputs = inputs } + + fun outputs(outputs: JsonValue) = apply { this.outputs = outputs } + + fun debugInfo(debugInfo: JsonValue) = apply { this.debugInfo = debugInfo } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Example]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .inputs() + * .outputs() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Example = + Example( + checkRequired("id", id), + checkRequired("inputs", inputs), + checkRequired("outputs", outputs), + debugInfo, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Example = apply { + if (validated) { + return@apply + } + + id() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Example && + id == other.id && + inputs == other.inputs && + outputs == other.outputs && + debugInfo == other.debugInfo && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, inputs, outputs, debugInfo, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Example{id=$id, inputs=$inputs, outputs=$outputs, debugInfo=$debugInfo, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetSearchResponse && + examples == other.examples && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(examples, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DatasetSearchResponse{examples=$examples, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetStudioExperimentParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetStudioExperimentParams.kt new file mode 100644 index 00000000..736bb6ae --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetStudioExperimentParams.kt @@ -0,0 +1,587 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Studio Experiment */ +class DatasetStudioExperimentParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun datasetId(): String = body.datasetId() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun projectName(): String = body.projectName() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun evaluatorRules(): Optional<List<String>> = body.evaluatorRules() + + /** + * Returns the raw JSON value of [datasetId]. + * + * Unlike [datasetId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _datasetId(): JsonField<String> = body._datasetId() + + /** + * Returns the raw JSON value of [projectName]. + * + * Unlike [projectName], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _projectName(): JsonField<String> = body._projectName() + + /** + * Returns the raw JSON value of [evaluatorRules]. + * + * Unlike [evaluatorRules], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _evaluatorRules(): JsonField<List<String>> = body._evaluatorRules() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [DatasetStudioExperimentParams]. + * + * The following fields are required: + * ```java + * .datasetId() + * .projectName() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DatasetStudioExperimentParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(datasetStudioExperimentParams: DatasetStudioExperimentParams) = apply { + body = datasetStudioExperimentParams.body.toBuilder() + additionalHeaders = datasetStudioExperimentParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetStudioExperimentParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [datasetId] + * - [projectName] + * - [evaluatorRules] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun datasetId(datasetId: String) = apply { body.datasetId(datasetId) } + + /** + * Sets [Builder.datasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun datasetId(datasetId: JsonField<String>) = apply { body.datasetId(datasetId) } + + fun projectName(projectName: String) = apply { body.projectName(projectName) } + + /** + * Sets [Builder.projectName] to an arbitrary JSON value. + * + * You should usually call [Builder.projectName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun projectName(projectName: JsonField<String>) = apply { body.projectName(projectName) } + + fun evaluatorRules(evaluatorRules: List<String>?) = apply { + body.evaluatorRules(evaluatorRules) + } + + /** Alias for calling [Builder.evaluatorRules] with `evaluatorRules.orElse(null)`. */ + fun evaluatorRules(evaluatorRules: Optional<List<String>>) = + evaluatorRules(evaluatorRules.getOrNull()) + + /** + * Sets [Builder.evaluatorRules] to an arbitrary JSON value. + * + * You should usually call [Builder.evaluatorRules] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun evaluatorRules(evaluatorRules: JsonField<List<String>>) = apply { + body.evaluatorRules(evaluatorRules) + } + + /** + * Adds a single [String] to [evaluatorRules]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvaluatorRule(evaluatorRule: String) = apply { body.addEvaluatorRule(evaluatorRule) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [DatasetStudioExperimentParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .datasetId() + * .projectName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DatasetStudioExperimentParams = + DatasetStudioExperimentParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val datasetId: JsonField<String>, + private val projectName: JsonField<String>, + private val evaluatorRules: JsonField<List<String>>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dataset_id") + @ExcludeMissing + datasetId: JsonField<String> = JsonMissing.of(), + @JsonProperty("project_name") + @ExcludeMissing + projectName: JsonField<String> = JsonMissing.of(), + @JsonProperty("evaluator_rules") + @ExcludeMissing + evaluatorRules: JsonField<List<String>> = JsonMissing.of(), + ) : this(datasetId, projectName, evaluatorRules, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun datasetId(): String = datasetId.getRequired("dataset_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun projectName(): String = projectName.getRequired("project_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun evaluatorRules(): Optional<List<String>> = evaluatorRules.getOptional("evaluator_rules") + + /** + * Returns the raw JSON value of [datasetId]. + * + * Unlike [datasetId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField<String> = datasetId + + /** + * Returns the raw JSON value of [projectName]. + * + * Unlike [projectName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("project_name") + @ExcludeMissing + fun _projectName(): JsonField<String> = projectName + + /** + * Returns the raw JSON value of [evaluatorRules]. + * + * Unlike [evaluatorRules], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("evaluator_rules") + @ExcludeMissing + fun _evaluatorRules(): JsonField<List<String>> = evaluatorRules + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .datasetId() + * .projectName() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var datasetId: JsonField<String>? = null + private var projectName: JsonField<String>? = null + private var evaluatorRules: JsonField<MutableList<String>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + datasetId = body.datasetId + projectName = body.projectName + evaluatorRules = body.evaluatorRules.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun datasetId(datasetId: String) = datasetId(JsonField.of(datasetId)) + + /** + * Sets [Builder.datasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun datasetId(datasetId: JsonField<String>) = apply { this.datasetId = datasetId } + + fun projectName(projectName: String) = projectName(JsonField.of(projectName)) + + /** + * Sets [Builder.projectName] to an arbitrary JSON value. + * + * You should usually call [Builder.projectName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun projectName(projectName: JsonField<String>) = apply { + this.projectName = projectName + } + + fun evaluatorRules(evaluatorRules: List<String>?) = + evaluatorRules(JsonField.ofNullable(evaluatorRules)) + + /** Alias for calling [Builder.evaluatorRules] with `evaluatorRules.orElse(null)`. */ + fun evaluatorRules(evaluatorRules: Optional<List<String>>) = + evaluatorRules(evaluatorRules.getOrNull()) + + /** + * Sets [Builder.evaluatorRules] to an arbitrary JSON value. + * + * You should usually call [Builder.evaluatorRules] with a well-typed `List<String>` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun evaluatorRules(evaluatorRules: JsonField<List<String>>) = apply { + this.evaluatorRules = evaluatorRules.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [evaluatorRules]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvaluatorRule(evaluatorRule: String) = apply { + evaluatorRules = + (evaluatorRules ?: JsonField.of(mutableListOf())).also { + checkKnown("evaluatorRules", it).add(evaluatorRule) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .datasetId() + * .projectName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("datasetId", datasetId), + checkRequired("projectName", projectName), + (evaluatorRules ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + datasetId() + projectName() + evaluatorRules() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (datasetId.asKnown().isPresent) 1 else 0) + + (if (projectName.asKnown().isPresent) 1 else 0) + + (evaluatorRules.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + datasetId == other.datasetId && + projectName == other.projectName && + evaluatorRules == other.evaluatorRules && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(datasetId, projectName, evaluatorRules, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{datasetId=$datasetId, projectName=$projectName, evaluatorRules=$evaluatorRules, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetStudioExperimentParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "DatasetStudioExperimentParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetStudioExperimentResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetStudioExperimentResponse.kt new file mode 100644 index 00000000..8ae9e79a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetStudioExperimentResponse.kt @@ -0,0 +1,121 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class DatasetStudioExperimentResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [DatasetStudioExperimentResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DatasetStudioExperimentResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(datasetStudioExperimentResponse: DatasetStudioExperimentResponse) = + apply { + additionalProperties = + datasetStudioExperimentResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DatasetStudioExperimentResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DatasetStudioExperimentResponse = + DatasetStudioExperimentResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): DatasetStudioExperimentResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetStudioExperimentResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DatasetStudioExperimentResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetTransformation.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetTransformation.kt new file mode 100644 index 00000000..719b27bf --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetTransformation.kt @@ -0,0 +1,397 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +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.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class DatasetTransformation +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val path: JsonField<List<String>>, + private val transformationType: JsonField<TransformationType>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("path") @ExcludeMissing path: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("transformation_type") + @ExcludeMissing + transformationType: JsonField<TransformationType> = JsonMissing.of(), + ) : this(path, transformationType, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun path(): List<String> = path.getRequired("path") + + /** + * Enum for dataset transformation types. Ordering determines the order in which transformations + * are applied if there are multiple transformations on the same path. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun transformationType(): TransformationType = + transformationType.getRequired("transformation_type") + + /** + * Returns the raw JSON value of [path]. + * + * Unlike [path], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("path") @ExcludeMissing fun _path(): JsonField<List<String>> = path + + /** + * Returns the raw JSON value of [transformationType]. + * + * Unlike [transformationType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("transformation_type") + @ExcludeMissing + fun _transformationType(): JsonField<TransformationType> = transformationType + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DatasetTransformation]. + * + * The following fields are required: + * ```java + * .path() + * .transformationType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DatasetTransformation]. */ + class Builder internal constructor() { + + private var path: JsonField<MutableList<String>>? = null + private var transformationType: JsonField<TransformationType>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(datasetTransformation: DatasetTransformation) = apply { + path = datasetTransformation.path.map { it.toMutableList() } + transformationType = datasetTransformation.transformationType + additionalProperties = datasetTransformation.additionalProperties.toMutableMap() + } + + fun path(path: List<String>) = path(JsonField.of(path)) + + /** + * Sets [Builder.path] to an arbitrary JSON value. + * + * You should usually call [Builder.path] with a well-typed `List<String>` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun path(path: JsonField<List<String>>) = apply { + this.path = path.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.path]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPath(path: String) = apply { + this.path = + (this.path ?: JsonField.of(mutableListOf())).also { + checkKnown("path", it).add(path) + } + } + + /** + * Enum for dataset transformation types. Ordering determines the order in which + * transformations are applied if there are multiple transformations on the same path. + */ + fun transformationType(transformationType: TransformationType) = + transformationType(JsonField.of(transformationType)) + + /** + * Sets [Builder.transformationType] to an arbitrary JSON value. + * + * You should usually call [Builder.transformationType] with a well-typed + * [TransformationType] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun transformationType(transformationType: JsonField<TransformationType>) = apply { + this.transformationType = transformationType + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DatasetTransformation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .path() + * .transformationType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DatasetTransformation = + DatasetTransformation( + checkRequired("path", path).map { it.toImmutable() }, + checkRequired("transformationType", transformationType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DatasetTransformation = apply { + if (validated) { + return@apply + } + + path() + transformationType().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (path.asKnown().getOrNull()?.size ?: 0) + + (transformationType.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Enum for dataset transformation types. Ordering determines the order in which transformations + * are applied if there are multiple transformations on the same path. + */ + class TransformationType + @JsonCreator + private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val CONVERT_TO_OPENAI_MESSAGE = of("convert_to_openai_message") + + @JvmField val CONVERT_TO_OPENAI_TOOL = of("convert_to_openai_tool") + + @JvmField val REMOVE_SYSTEM_MESSAGES = of("remove_system_messages") + + @JvmField val REMOVE_EXTRA_FIELDS = of("remove_extra_fields") + + @JvmField val EXTRACT_TOOLS_FROM_RUN = of("extract_tools_from_run") + + @JvmStatic fun of(value: String) = TransformationType(JsonField.of(value)) + } + + /** An enum containing [TransformationType]'s known values. */ + enum class Known { + CONVERT_TO_OPENAI_MESSAGE, + CONVERT_TO_OPENAI_TOOL, + REMOVE_SYSTEM_MESSAGES, + REMOVE_EXTRA_FIELDS, + EXTRACT_TOOLS_FROM_RUN, + } + + /** + * An enum containing [TransformationType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TransformationType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CONVERT_TO_OPENAI_MESSAGE, + CONVERT_TO_OPENAI_TOOL, + REMOVE_SYSTEM_MESSAGES, + REMOVE_EXTRA_FIELDS, + EXTRACT_TOOLS_FROM_RUN, + /** + * An enum member indicating that [TransformationType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CONVERT_TO_OPENAI_MESSAGE -> Value.CONVERT_TO_OPENAI_MESSAGE + CONVERT_TO_OPENAI_TOOL -> Value.CONVERT_TO_OPENAI_TOOL + REMOVE_SYSTEM_MESSAGES -> Value.REMOVE_SYSTEM_MESSAGES + REMOVE_EXTRA_FIELDS -> Value.REMOVE_EXTRA_FIELDS + EXTRACT_TOOLS_FROM_RUN -> Value.EXTRACT_TOOLS_FROM_RUN + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CONVERT_TO_OPENAI_MESSAGE -> Known.CONVERT_TO_OPENAI_MESSAGE + CONVERT_TO_OPENAI_TOOL -> Known.CONVERT_TO_OPENAI_TOOL + REMOVE_SYSTEM_MESSAGES -> Known.REMOVE_SYSTEM_MESSAGES + REMOVE_EXTRA_FIELDS -> Known.REMOVE_EXTRA_FIELDS + EXTRACT_TOOLS_FROM_RUN -> Known.EXTRACT_TOOLS_FROM_RUN + else -> throw LangsmithApiInvalidDataException("Unknown TransformationType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TransformationType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TransformationType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetTransformation && + path == other.path && + transformationType == other.transformationType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(path, transformationType, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DatasetTransformation{path=$path, transformationType=$transformationType, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUpdateParams.kt new file mode 100644 index 00000000..ba7417ff --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUpdateParams.kt @@ -0,0 +1,2169 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +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 com.langsmith_api.api.core.BaseDeserializer +import com.langsmith_api.api.core.BaseSerializer +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.allMaxBy +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Update a specific dataset. */ +class DatasetUpdateParams +private constructor( + private val datasetId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun datasetId(): Optional<String> = Optional.ofNullable(datasetId) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<Description> = body.description() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun inputsSchemaDefinition(): Optional<InputsSchemaDefinition> = body.inputsSchemaDefinition() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional<Metadata> = body.metadata() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional<Name> = body.name() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun outputsSchemaDefinition(): Optional<OutputsSchemaDefinition> = + body.outputsSchemaDefinition() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun patchExamples(): Optional<PatchExamples> = body.patchExamples() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun transformations(): Optional<Transformations> = body.transformations() + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _description(): JsonField<Description> = body._description() + + /** + * Returns the raw JSON value of [inputsSchemaDefinition]. + * + * Unlike [inputsSchemaDefinition], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _inputsSchemaDefinition(): JsonField<InputsSchemaDefinition> = + body._inputsSchemaDefinition() + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _metadata(): JsonField<Metadata> = body._metadata() + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _name(): JsonField<Name> = body._name() + + /** + * Returns the raw JSON value of [outputsSchemaDefinition]. + * + * Unlike [outputsSchemaDefinition], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _outputsSchemaDefinition(): JsonField<OutputsSchemaDefinition> = + body._outputsSchemaDefinition() + + /** + * Returns the raw JSON value of [patchExamples]. + * + * Unlike [patchExamples], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _patchExamples(): JsonField<PatchExamples> = body._patchExamples() + + /** + * Returns the raw JSON value of [transformations]. + * + * Unlike [transformations], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _transformations(): JsonField<Transformations> = body._transformations() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): DatasetUpdateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [DatasetUpdateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DatasetUpdateParams]. */ + class Builder internal constructor() { + + private var datasetId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(datasetUpdateParams: DatasetUpdateParams) = apply { + datasetId = datasetUpdateParams.datasetId + body = datasetUpdateParams.body.toBuilder() + additionalHeaders = datasetUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetUpdateParams.additionalQueryParams.toBuilder() + } + + fun datasetId(datasetId: String?) = apply { this.datasetId = datasetId } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [description] + * - [inputsSchemaDefinition] + * - [metadata] + * - [name] + * - [outputsSchemaDefinition] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun description(description: Description?) = apply { body.description(description) } + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<Description>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [Description] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField<Description>) = apply { + body.description(description) + } + + /** Alias for calling [description] with `Description.ofString(string)`. */ + fun description(string: String) = apply { body.description(string) } + + /** Alias for calling [description] with `Description.ofMissing(missing)`. */ + fun description(missing: Missing) = apply { body.description(missing) } + + fun inputsSchemaDefinition(inputsSchemaDefinition: InputsSchemaDefinition?) = apply { + body.inputsSchemaDefinition(inputsSchemaDefinition) + } + + /** + * Alias for calling [Builder.inputsSchemaDefinition] with + * `inputsSchemaDefinition.orElse(null)`. + */ + fun inputsSchemaDefinition(inputsSchemaDefinition: Optional<InputsSchemaDefinition>) = + inputsSchemaDefinition(inputsSchemaDefinition.getOrNull()) + + /** + * Sets [Builder.inputsSchemaDefinition] to an arbitrary JSON value. + * + * You should usually call [Builder.inputsSchemaDefinition] with a well-typed + * [InputsSchemaDefinition] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun inputsSchemaDefinition(inputsSchemaDefinition: JsonField<InputsSchemaDefinition>) = + apply { + body.inputsSchemaDefinition(inputsSchemaDefinition) + } + + /** + * Alias for calling [inputsSchemaDefinition] with + * `InputsSchemaDefinition.ofJsonValue(jsonValue)`. + */ + fun inputsSchemaDefinition(jsonValue: JsonValue) = apply { + body.inputsSchemaDefinition(jsonValue) + } + + /** + * Alias for calling [inputsSchemaDefinition] with + * `InputsSchemaDefinition.ofMissing(missing)`. + */ + fun inputsSchemaDefinition(missing: Missing) = apply { + body.inputsSchemaDefinition(missing) + } + + fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional<Metadata>) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField<Metadata>) = apply { body.metadata(metadata) } + + /** Alias for calling [metadata] with `Metadata.ofJsonValue(jsonValue)`. */ + fun metadata(jsonValue: JsonValue) = apply { body.metadata(jsonValue) } + + /** Alias for calling [metadata] with `Metadata.ofMissing(missing)`. */ + fun metadata(missing: Missing) = apply { body.metadata(missing) } + + fun name(name: Name?) = apply { body.name(name) } + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional<Name>) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [Name] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<Name>) = apply { body.name(name) } + + /** Alias for calling [name] with `Name.ofString(string)`. */ + fun name(string: String) = apply { body.name(string) } + + /** Alias for calling [name] with `Name.ofMissing(missing)`. */ + fun name(missing: Missing) = apply { body.name(missing) } + + fun outputsSchemaDefinition(outputsSchemaDefinition: OutputsSchemaDefinition?) = apply { + body.outputsSchemaDefinition(outputsSchemaDefinition) + } + + /** + * Alias for calling [Builder.outputsSchemaDefinition] with + * `outputsSchemaDefinition.orElse(null)`. + */ + fun outputsSchemaDefinition(outputsSchemaDefinition: Optional<OutputsSchemaDefinition>) = + outputsSchemaDefinition(outputsSchemaDefinition.getOrNull()) + + /** + * Sets [Builder.outputsSchemaDefinition] to an arbitrary JSON value. + * + * You should usually call [Builder.outputsSchemaDefinition] with a well-typed + * [OutputsSchemaDefinition] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun outputsSchemaDefinition(outputsSchemaDefinition: JsonField<OutputsSchemaDefinition>) = + apply { + body.outputsSchemaDefinition(outputsSchemaDefinition) + } + + /** + * Alias for calling [outputsSchemaDefinition] with + * `OutputsSchemaDefinition.ofJsonValue(jsonValue)`. + */ + fun outputsSchemaDefinition(jsonValue: JsonValue) = apply { + body.outputsSchemaDefinition(jsonValue) + } + + /** + * Alias for calling [outputsSchemaDefinition] with + * `OutputsSchemaDefinition.ofMissing(missing)`. + */ + fun outputsSchemaDefinition(missing: Missing) = apply { + body.outputsSchemaDefinition(missing) + } + + fun patchExamples(patchExamples: PatchExamples?) = apply { + body.patchExamples(patchExamples) + } + + /** Alias for calling [Builder.patchExamples] with `patchExamples.orElse(null)`. */ + fun patchExamples(patchExamples: Optional<PatchExamples>) = + patchExamples(patchExamples.getOrNull()) + + /** + * Sets [Builder.patchExamples] to an arbitrary JSON value. + * + * You should usually call [Builder.patchExamples] with a well-typed [PatchExamples] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun patchExamples(patchExamples: JsonField<PatchExamples>) = apply { + body.patchExamples(patchExamples) + } + + fun transformations(transformations: Transformations?) = apply { + body.transformations(transformations) + } + + /** Alias for calling [Builder.transformations] with `transformations.orElse(null)`. */ + fun transformations(transformations: Optional<Transformations>) = + transformations(transformations.getOrNull()) + + /** + * Sets [Builder.transformations] to an arbitrary JSON value. + * + * You should usually call [Builder.transformations] with a well-typed [Transformations] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun transformations(transformations: JsonField<Transformations>) = apply { + body.transformations(transformations) + } + + /** Alias for calling [transformations] with `Transformations.ofDataset(dataset)`. */ + fun transformationsOfDataset(dataset: List<DatasetTransformation>) = apply { + body.transformationsOfDataset(dataset) + } + + /** Alias for calling [transformations] with `Transformations.ofMissing(missing)`. */ + fun transformations(missing: Missing) = apply { body.transformations(missing) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [DatasetUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DatasetUpdateParams = + DatasetUpdateParams( + datasetId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> datasetId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Update class for Dataset. */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val description: JsonField<Description>, + private val inputsSchemaDefinition: JsonField<InputsSchemaDefinition>, + private val metadata: JsonField<Metadata>, + private val name: JsonField<Name>, + private val outputsSchemaDefinition: JsonField<OutputsSchemaDefinition>, + private val patchExamples: JsonField<PatchExamples>, + private val transformations: JsonField<Transformations>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("description") + @ExcludeMissing + description: JsonField<Description> = JsonMissing.of(), + @JsonProperty("inputs_schema_definition") + @ExcludeMissing + inputsSchemaDefinition: JsonField<InputsSchemaDefinition> = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField<Metadata> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<Name> = JsonMissing.of(), + @JsonProperty("outputs_schema_definition") + @ExcludeMissing + outputsSchemaDefinition: JsonField<OutputsSchemaDefinition> = JsonMissing.of(), + @JsonProperty("patch_examples") + @ExcludeMissing + patchExamples: JsonField<PatchExamples> = JsonMissing.of(), + @JsonProperty("transformations") + @ExcludeMissing + transformations: JsonField<Transformations> = JsonMissing.of(), + ) : this( + description, + inputsSchemaDefinition, + metadata, + name, + outputsSchemaDefinition, + patchExamples, + transformations, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional<Description> = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun inputsSchemaDefinition(): Optional<InputsSchemaDefinition> = + inputsSchemaDefinition.getOptional("inputs_schema_definition") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun metadata(): Optional<Metadata> = metadata.getOptional("metadata") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun name(): Optional<Name> = name.getOptional("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun outputsSchemaDefinition(): Optional<OutputsSchemaDefinition> = + outputsSchemaDefinition.getOptional("outputs_schema_definition") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun patchExamples(): Optional<PatchExamples> = patchExamples.getOptional("patch_examples") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun transformations(): Optional<Transformations> = + transformations.getOptional("transformations") + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField<Description> = description + + /** + * Returns the raw JSON value of [inputsSchemaDefinition]. + * + * Unlike [inputsSchemaDefinition], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("inputs_schema_definition") + @ExcludeMissing + fun _inputsSchemaDefinition(): JsonField<InputsSchemaDefinition> = inputsSchemaDefinition + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField<Metadata> = metadata + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<Name> = name + + /** + * Returns the raw JSON value of [outputsSchemaDefinition]. + * + * Unlike [outputsSchemaDefinition], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("outputs_schema_definition") + @ExcludeMissing + fun _outputsSchemaDefinition(): JsonField<OutputsSchemaDefinition> = outputsSchemaDefinition + + /** + * Returns the raw JSON value of [patchExamples]. + * + * Unlike [patchExamples], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("patch_examples") + @ExcludeMissing + fun _patchExamples(): JsonField<PatchExamples> = patchExamples + + /** + * Returns the raw JSON value of [transformations]. + * + * Unlike [transformations], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("transformations") + @ExcludeMissing + fun _transformations(): JsonField<Transformations> = transformations + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var description: JsonField<Description> = JsonMissing.of() + private var inputsSchemaDefinition: JsonField<InputsSchemaDefinition> = JsonMissing.of() + private var metadata: JsonField<Metadata> = JsonMissing.of() + private var name: JsonField<Name> = JsonMissing.of() + private var outputsSchemaDefinition: JsonField<OutputsSchemaDefinition> = + JsonMissing.of() + private var patchExamples: JsonField<PatchExamples> = JsonMissing.of() + private var transformations: JsonField<Transformations> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + description = body.description + inputsSchemaDefinition = body.inputsSchemaDefinition + metadata = body.metadata + name = body.name + outputsSchemaDefinition = body.outputsSchemaDefinition + patchExamples = body.patchExamples + transformations = body.transformations + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun description(description: Description?) = + description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<Description>) = + description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [Description] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField<Description>) = apply { + this.description = description + } + + /** Alias for calling [description] with `Description.ofString(string)`. */ + fun description(string: String) = description(Description.ofString(string)) + + /** Alias for calling [description] with `Description.ofMissing(missing)`. */ + fun description(missing: Missing) = description(Description.ofMissing(missing)) + + fun inputsSchemaDefinition(inputsSchemaDefinition: InputsSchemaDefinition?) = + inputsSchemaDefinition(JsonField.ofNullable(inputsSchemaDefinition)) + + /** + * Alias for calling [Builder.inputsSchemaDefinition] with + * `inputsSchemaDefinition.orElse(null)`. + */ + fun inputsSchemaDefinition(inputsSchemaDefinition: Optional<InputsSchemaDefinition>) = + inputsSchemaDefinition(inputsSchemaDefinition.getOrNull()) + + /** + * Sets [Builder.inputsSchemaDefinition] to an arbitrary JSON value. + * + * You should usually call [Builder.inputsSchemaDefinition] with a well-typed + * [InputsSchemaDefinition] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun inputsSchemaDefinition(inputsSchemaDefinition: JsonField<InputsSchemaDefinition>) = + apply { + this.inputsSchemaDefinition = inputsSchemaDefinition + } + + /** + * Alias for calling [inputsSchemaDefinition] with + * `InputsSchemaDefinition.ofJsonValue(jsonValue)`. + */ + fun inputsSchemaDefinition(jsonValue: JsonValue) = + inputsSchemaDefinition(InputsSchemaDefinition.ofJsonValue(jsonValue)) + + /** + * Alias for calling [inputsSchemaDefinition] with + * `InputsSchemaDefinition.ofMissing(missing)`. + */ + fun inputsSchemaDefinition(missing: Missing) = + inputsSchemaDefinition(InputsSchemaDefinition.ofMissing(missing)) + + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional<Metadata>) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField<Metadata>) = apply { this.metadata = metadata } + + /** Alias for calling [metadata] with `Metadata.ofJsonValue(jsonValue)`. */ + fun metadata(jsonValue: JsonValue) = metadata(Metadata.ofJsonValue(jsonValue)) + + /** Alias for calling [metadata] with `Metadata.ofMissing(missing)`. */ + fun metadata(missing: Missing) = metadata(Metadata.ofMissing(missing)) + + fun name(name: Name?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional<Name>) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [Name] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField<Name>) = apply { this.name = name } + + /** Alias for calling [name] with `Name.ofString(string)`. */ + fun name(string: String) = name(Name.ofString(string)) + + /** Alias for calling [name] with `Name.ofMissing(missing)`. */ + fun name(missing: Missing) = name(Name.ofMissing(missing)) + + fun outputsSchemaDefinition(outputsSchemaDefinition: OutputsSchemaDefinition?) = + outputsSchemaDefinition(JsonField.ofNullable(outputsSchemaDefinition)) + + /** + * Alias for calling [Builder.outputsSchemaDefinition] with + * `outputsSchemaDefinition.orElse(null)`. + */ + fun outputsSchemaDefinition( + outputsSchemaDefinition: Optional<OutputsSchemaDefinition> + ) = outputsSchemaDefinition(outputsSchemaDefinition.getOrNull()) + + /** + * Sets [Builder.outputsSchemaDefinition] to an arbitrary JSON value. + * + * You should usually call [Builder.outputsSchemaDefinition] with a well-typed + * [OutputsSchemaDefinition] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun outputsSchemaDefinition( + outputsSchemaDefinition: JsonField<OutputsSchemaDefinition> + ) = apply { this.outputsSchemaDefinition = outputsSchemaDefinition } + + /** + * Alias for calling [outputsSchemaDefinition] with + * `OutputsSchemaDefinition.ofJsonValue(jsonValue)`. + */ + fun outputsSchemaDefinition(jsonValue: JsonValue) = + outputsSchemaDefinition(OutputsSchemaDefinition.ofJsonValue(jsonValue)) + + /** + * Alias for calling [outputsSchemaDefinition] with + * `OutputsSchemaDefinition.ofMissing(missing)`. + */ + fun outputsSchemaDefinition(missing: Missing) = + outputsSchemaDefinition(OutputsSchemaDefinition.ofMissing(missing)) + + fun patchExamples(patchExamples: PatchExamples?) = + patchExamples(JsonField.ofNullable(patchExamples)) + + /** Alias for calling [Builder.patchExamples] with `patchExamples.orElse(null)`. */ + fun patchExamples(patchExamples: Optional<PatchExamples>) = + patchExamples(patchExamples.getOrNull()) + + /** + * Sets [Builder.patchExamples] to an arbitrary JSON value. + * + * You should usually call [Builder.patchExamples] with a well-typed [PatchExamples] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun patchExamples(patchExamples: JsonField<PatchExamples>) = apply { + this.patchExamples = patchExamples + } + + fun transformations(transformations: Transformations?) = + transformations(JsonField.ofNullable(transformations)) + + /** Alias for calling [Builder.transformations] with `transformations.orElse(null)`. */ + fun transformations(transformations: Optional<Transformations>) = + transformations(transformations.getOrNull()) + + /** + * Sets [Builder.transformations] to an arbitrary JSON value. + * + * You should usually call [Builder.transformations] with a well-typed [Transformations] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun transformations(transformations: JsonField<Transformations>) = apply { + this.transformations = transformations + } + + /** Alias for calling [transformations] with `Transformations.ofDataset(dataset)`. */ + fun transformationsOfDataset(dataset: List<DatasetTransformation>) = + transformations(Transformations.ofDataset(dataset)) + + /** Alias for calling [transformations] with `Transformations.ofMissing(missing)`. */ + fun transformations(missing: Missing) = + transformations(Transformations.ofMissing(missing)) + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = + Body( + description, + inputsSchemaDefinition, + metadata, + name, + outputsSchemaDefinition, + patchExamples, + transformations, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + description().ifPresent { it.validate() } + inputsSchemaDefinition().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + name().ifPresent { it.validate() } + outputsSchemaDefinition().ifPresent { it.validate() } + patchExamples().ifPresent { it.validate() } + transformations().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (description.asKnown().getOrNull()?.validity() ?: 0) + + (inputsSchemaDefinition.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (name.asKnown().getOrNull()?.validity() ?: 0) + + (outputsSchemaDefinition.asKnown().getOrNull()?.validity() ?: 0) + + (patchExamples.asKnown().getOrNull()?.validity() ?: 0) + + (transformations.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + description == other.description && + inputsSchemaDefinition == other.inputsSchemaDefinition && + metadata == other.metadata && + name == other.name && + outputsSchemaDefinition == other.outputsSchemaDefinition && + patchExamples == other.patchExamples && + transformations == other.transformations && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + description, + inputsSchemaDefinition, + metadata, + name, + outputsSchemaDefinition, + patchExamples, + transformations, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{description=$description, inputsSchemaDefinition=$inputsSchemaDefinition, metadata=$metadata, name=$name, outputsSchemaDefinition=$outputsSchemaDefinition, patchExamples=$patchExamples, transformations=$transformations, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = Description.Deserializer::class) + @JsonSerialize(using = Description.Serializer::class) + class Description + private constructor( + private val string: String? = null, + private val missing: Missing? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun missing(): Optional<Missing> = Optional.ofNullable(missing) + + fun isString(): Boolean = string != null + + fun isMissing(): Boolean = missing != null + + fun asString(): String = string.getOrThrow("string") + + fun asMissing(): Missing = missing.getOrThrow("missing") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + string != null -> visitor.visitString(string) + missing != null -> visitor.visitMissing(missing) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Description = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitString(string: String) {} + + override fun visitMissing(missing: Missing) { + missing.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitString(string: String) = 1 + + override fun visitMissing(missing: Missing) = missing.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Description && string == other.string && missing == other.missing + } + + override fun hashCode(): Int = Objects.hash(string, missing) + + override fun toString(): String = + when { + string != null -> "Description{string=$string}" + missing != null -> "Description{missing=$missing}" + _json != null -> "Description{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Description") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Description(string = string) + + @JvmStatic fun ofMissing(missing: Missing) = Description(missing = missing) + } + + /** + * An interface that defines how to map each variant of [Description] to a value of type + * [T]. + */ + interface Visitor<out T> { + + fun visitString(string: String): T + + fun visitMissing(missing: Missing): T + + /** + * Maps an unknown variant of [Description] to a value of type [T]. + * + * An instance of [Description] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Description: $json") + } + } + + internal class Deserializer : BaseDeserializer<Description>(Description::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Description { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<Missing>())?.let { + Description(missing = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<String>())?.let { + Description(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from array). + 0 -> Description(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Description>(Description::class) { + + override fun serialize( + value: Description, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.missing != null -> generator.writeObject(value.missing) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Description") + } + } + } + } + + @JsonDeserialize(using = InputsSchemaDefinition.Deserializer::class) + @JsonSerialize(using = InputsSchemaDefinition.Serializer::class) + class InputsSchemaDefinition + private constructor( + private val jsonValue: JsonValue? = null, + private val missing: Missing? = null, + private val _json: JsonValue? = null, + ) { + + fun jsonValue(): Optional<JsonValue> = Optional.ofNullable(jsonValue) + + fun missing(): Optional<Missing> = Optional.ofNullable(missing) + + fun isJsonValue(): Boolean = jsonValue != null + + fun isMissing(): Boolean = missing != null + + fun asJsonValue(): JsonValue = jsonValue.getOrThrow("jsonValue") + + fun asMissing(): Missing = missing.getOrThrow("missing") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + jsonValue != null -> visitor.visitJsonValue(jsonValue) + missing != null -> visitor.visitMissing(missing) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): InputsSchemaDefinition = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitJsonValue(jsonValue: JsonValue) {} + + override fun visitMissing(missing: Missing) { + missing.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun visitMissing(missing: Missing) = missing.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InputsSchemaDefinition && + jsonValue == other.jsonValue && + missing == other.missing + } + + override fun hashCode(): Int = Objects.hash(jsonValue, missing) + + override fun toString(): String = + when { + jsonValue != null -> "InputsSchemaDefinition{jsonValue=$jsonValue}" + missing != null -> "InputsSchemaDefinition{missing=$missing}" + _json != null -> "InputsSchemaDefinition{_unknown=$_json}" + else -> throw IllegalStateException("Invalid InputsSchemaDefinition") + } + + companion object { + + @JvmStatic + fun ofJsonValue(jsonValue: JsonValue) = InputsSchemaDefinition(jsonValue = jsonValue) + + @JvmStatic fun ofMissing(missing: Missing) = InputsSchemaDefinition(missing = missing) + } + + /** + * An interface that defines how to map each variant of [InputsSchemaDefinition] to a value + * of type [T]. + */ + interface Visitor<out T> { + + fun visitJsonValue(jsonValue: JsonValue): T + + fun visitMissing(missing: Missing): T + + /** + * Maps an unknown variant of [InputsSchemaDefinition] to a value of type [T]. + * + * An instance of [InputsSchemaDefinition] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the SDK + * is on an older version than the API, then the API may respond with new variants that + * the SDK is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown InputsSchemaDefinition: $json") + } + } + + internal class Deserializer : + BaseDeserializer<InputsSchemaDefinition>(InputsSchemaDefinition::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): InputsSchemaDefinition { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<Missing>())?.let { + InputsSchemaDefinition(missing = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<JsonValue>())?.let { + InputsSchemaDefinition(jsonValue = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants. + 0 -> InputsSchemaDefinition(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer<InputsSchemaDefinition>(InputsSchemaDefinition::class) { + + override fun serialize( + value: InputsSchemaDefinition, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.jsonValue != null -> generator.writeObject(value.jsonValue) + value.missing != null -> generator.writeObject(value.missing) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid InputsSchemaDefinition") + } + } + } + } + + @JsonDeserialize(using = Metadata.Deserializer::class) + @JsonSerialize(using = Metadata.Serializer::class) + class Metadata + private constructor( + private val jsonValue: JsonValue? = null, + private val missing: Missing? = null, + private val _json: JsonValue? = null, + ) { + + fun jsonValue(): Optional<JsonValue> = Optional.ofNullable(jsonValue) + + fun missing(): Optional<Missing> = Optional.ofNullable(missing) + + fun isJsonValue(): Boolean = jsonValue != null + + fun isMissing(): Boolean = missing != null + + fun asJsonValue(): JsonValue = jsonValue.getOrThrow("jsonValue") + + fun asMissing(): Missing = missing.getOrThrow("missing") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + jsonValue != null -> visitor.visitJsonValue(jsonValue) + missing != null -> visitor.visitMissing(missing) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitJsonValue(jsonValue: JsonValue) {} + + override fun visitMissing(missing: Missing) { + missing.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun visitMissing(missing: Missing) = missing.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && jsonValue == other.jsonValue && missing == other.missing + } + + override fun hashCode(): Int = Objects.hash(jsonValue, missing) + + override fun toString(): String = + when { + jsonValue != null -> "Metadata{jsonValue=$jsonValue}" + missing != null -> "Metadata{missing=$missing}" + _json != null -> "Metadata{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Metadata") + } + + companion object { + + @JvmStatic fun ofJsonValue(jsonValue: JsonValue) = Metadata(jsonValue = jsonValue) + + @JvmStatic fun ofMissing(missing: Missing) = Metadata(missing = missing) + } + + /** + * An interface that defines how to map each variant of [Metadata] to a value of type [T]. + */ + interface Visitor<out T> { + + fun visitJsonValue(jsonValue: JsonValue): T + + fun visitMissing(missing: Missing): T + + /** + * Maps an unknown variant of [Metadata] to a value of type [T]. + * + * An instance of [Metadata] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Metadata: $json") + } + } + + internal class Deserializer : BaseDeserializer<Metadata>(Metadata::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Metadata { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<Missing>())?.let { + Metadata(missing = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<JsonValue>())?.let { + Metadata(jsonValue = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants. + 0 -> Metadata(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Metadata>(Metadata::class) { + + override fun serialize( + value: Metadata, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.jsonValue != null -> generator.writeObject(value.jsonValue) + value.missing != null -> generator.writeObject(value.missing) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Metadata") + } + } + } + } + + @JsonDeserialize(using = Name.Deserializer::class) + @JsonSerialize(using = Name.Serializer::class) + class Name + private constructor( + private val string: String? = null, + private val missing: Missing? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun missing(): Optional<Missing> = Optional.ofNullable(missing) + + fun isString(): Boolean = string != null + + fun isMissing(): Boolean = missing != null + + fun asString(): String = string.getOrThrow("string") + + fun asMissing(): Missing = missing.getOrThrow("missing") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + string != null -> visitor.visitString(string) + missing != null -> visitor.visitMissing(missing) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Name = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitString(string: String) {} + + override fun visitMissing(missing: Missing) { + missing.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitString(string: String) = 1 + + override fun visitMissing(missing: Missing) = missing.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Name && string == other.string && missing == other.missing + } + + override fun hashCode(): Int = Objects.hash(string, missing) + + override fun toString(): String = + when { + string != null -> "Name{string=$string}" + missing != null -> "Name{missing=$missing}" + _json != null -> "Name{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Name") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Name(string = string) + + @JvmStatic fun ofMissing(missing: Missing) = Name(missing = missing) + } + + /** An interface that defines how to map each variant of [Name] to a value of type [T]. */ + interface Visitor<out T> { + + fun visitString(string: String): T + + fun visitMissing(missing: Missing): T + + /** + * Maps an unknown variant of [Name] to a value of type [T]. + * + * An instance of [Name] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Name: $json") + } + } + + internal class Deserializer : BaseDeserializer<Name>(Name::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Name { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<Missing>())?.let { + Name(missing = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<String>())?.let { + Name(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from array). + 0 -> Name(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Name>(Name::class) { + + override fun serialize( + value: Name, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.missing != null -> generator.writeObject(value.missing) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Name") + } + } + } + } + + @JsonDeserialize(using = OutputsSchemaDefinition.Deserializer::class) + @JsonSerialize(using = OutputsSchemaDefinition.Serializer::class) + class OutputsSchemaDefinition + private constructor( + private val jsonValue: JsonValue? = null, + private val missing: Missing? = null, + private val _json: JsonValue? = null, + ) { + + fun jsonValue(): Optional<JsonValue> = Optional.ofNullable(jsonValue) + + fun missing(): Optional<Missing> = Optional.ofNullable(missing) + + fun isJsonValue(): Boolean = jsonValue != null + + fun isMissing(): Boolean = missing != null + + fun asJsonValue(): JsonValue = jsonValue.getOrThrow("jsonValue") + + fun asMissing(): Missing = missing.getOrThrow("missing") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + jsonValue != null -> visitor.visitJsonValue(jsonValue) + missing != null -> visitor.visitMissing(missing) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): OutputsSchemaDefinition = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitJsonValue(jsonValue: JsonValue) {} + + override fun visitMissing(missing: Missing) { + missing.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun visitMissing(missing: Missing) = missing.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OutputsSchemaDefinition && + jsonValue == other.jsonValue && + missing == other.missing + } + + override fun hashCode(): Int = Objects.hash(jsonValue, missing) + + override fun toString(): String = + when { + jsonValue != null -> "OutputsSchemaDefinition{jsonValue=$jsonValue}" + missing != null -> "OutputsSchemaDefinition{missing=$missing}" + _json != null -> "OutputsSchemaDefinition{_unknown=$_json}" + else -> throw IllegalStateException("Invalid OutputsSchemaDefinition") + } + + companion object { + + @JvmStatic + fun ofJsonValue(jsonValue: JsonValue) = OutputsSchemaDefinition(jsonValue = jsonValue) + + @JvmStatic fun ofMissing(missing: Missing) = OutputsSchemaDefinition(missing = missing) + } + + /** + * An interface that defines how to map each variant of [OutputsSchemaDefinition] to a value + * of type [T]. + */ + interface Visitor<out T> { + + fun visitJsonValue(jsonValue: JsonValue): T + + fun visitMissing(missing: Missing): T + + /** + * Maps an unknown variant of [OutputsSchemaDefinition] to a value of type [T]. + * + * An instance of [OutputsSchemaDefinition] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the SDK + * is on an older version than the API, then the API may respond with new variants that + * the SDK is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown OutputsSchemaDefinition: $json") + } + } + + internal class Deserializer : + BaseDeserializer<OutputsSchemaDefinition>(OutputsSchemaDefinition::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): OutputsSchemaDefinition { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<Missing>())?.let { + OutputsSchemaDefinition(missing = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<JsonValue>())?.let { + OutputsSchemaDefinition(jsonValue = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants. + 0 -> OutputsSchemaDefinition(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer<OutputsSchemaDefinition>(OutputsSchemaDefinition::class) { + + override fun serialize( + value: OutputsSchemaDefinition, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.jsonValue != null -> generator.writeObject(value.jsonValue) + value.missing != null -> generator.writeObject(value.missing) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid OutputsSchemaDefinition") + } + } + } + } + + class PatchExamples + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [PatchExamples]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PatchExamples]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(patchExamples: PatchExamples) = apply { + additionalProperties = patchExamples.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PatchExamples]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PatchExamples = PatchExamples(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): PatchExamples = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PatchExamples && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "PatchExamples{additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = Transformations.Deserializer::class) + @JsonSerialize(using = Transformations.Serializer::class) + class Transformations + private constructor( + private val dataset: List<DatasetTransformation>? = null, + private val missing: Missing? = null, + private val _json: JsonValue? = null, + ) { + + fun dataset(): Optional<List<DatasetTransformation>> = Optional.ofNullable(dataset) + + fun missing(): Optional<Missing> = Optional.ofNullable(missing) + + fun isDataset(): Boolean = dataset != null + + fun isMissing(): Boolean = missing != null + + fun asDataset(): List<DatasetTransformation> = dataset.getOrThrow("dataset") + + fun asMissing(): Missing = missing.getOrThrow("missing") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + dataset != null -> visitor.visitDataset(dataset) + missing != null -> visitor.visitMissing(missing) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Transformations = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitDataset(dataset: List<DatasetTransformation>) { + dataset.forEach { it.validate() } + } + + override fun visitMissing(missing: Missing) { + missing.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitDataset(dataset: List<DatasetTransformation>) = + dataset.sumOf { it.validity().toInt() } + + override fun visitMissing(missing: Missing) = missing.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Transformations && dataset == other.dataset && missing == other.missing + } + + override fun hashCode(): Int = Objects.hash(dataset, missing) + + override fun toString(): String = + when { + dataset != null -> "Transformations{dataset=$dataset}" + missing != null -> "Transformations{missing=$missing}" + _json != null -> "Transformations{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Transformations") + } + + companion object { + + @JvmStatic + fun ofDataset(dataset: List<DatasetTransformation>) = + Transformations(dataset = dataset.toImmutable()) + + @JvmStatic fun ofMissing(missing: Missing) = Transformations(missing = missing) + } + + /** + * An interface that defines how to map each variant of [Transformations] to a value of type + * [T]. + */ + interface Visitor<out T> { + + fun visitDataset(dataset: List<DatasetTransformation>): T + + fun visitMissing(missing: Missing): T + + /** + * Maps an unknown variant of [Transformations] to a value of type [T]. + * + * An instance of [Transformations] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the SDK + * is on an older version than the API, then the API may respond with new variants that + * the SDK is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Transformations: $json") + } + } + + internal class Deserializer : BaseDeserializer<Transformations>(Transformations::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Transformations { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<Missing>())?.let { + Transformations(missing = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<List<DatasetTransformation>>()) + ?.let { Transformations(dataset = it, _json = json) }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> Transformations(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Transformations>(Transformations::class) { + + override fun serialize( + value: Transformations, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.dataset != null -> generator.writeObject(value.dataset) + value.missing != null -> generator.writeObject(value.missing) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Transformations") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetUpdateParams && + datasetId == other.datasetId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(datasetId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "DatasetUpdateParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUpdateResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUpdateResponse.kt new file mode 100644 index 00000000..7a077079 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUpdateResponse.kt @@ -0,0 +1,520 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class DatasetUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val name: JsonField<String>, + private val tenantId: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val dataType: JsonField<DataType>, + private val description: JsonField<String>, + private val externallyManaged: JsonField<Boolean>, + private val inputsSchemaDefinition: JsonValue, + private val outputsSchemaDefinition: JsonValue, + private val transformations: JsonField<List<DatasetTransformation>>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("tenant_id") @ExcludeMissing tenantId: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("data_type") @ExcludeMissing dataType: JsonField<DataType> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("externally_managed") + @ExcludeMissing + externallyManaged: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("inputs_schema_definition") + @ExcludeMissing + inputsSchemaDefinition: JsonValue = JsonMissing.of(), + @JsonProperty("outputs_schema_definition") + @ExcludeMissing + outputsSchemaDefinition: JsonValue = JsonMissing.of(), + @JsonProperty("transformations") + @ExcludeMissing + transformations: JsonField<List<DatasetTransformation>> = JsonMissing.of(), + ) : this( + id, + name, + tenantId, + createdAt, + dataType, + description, + externallyManaged, + inputsSchemaDefinition, + outputsSchemaDefinition, + transformations, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tenantId(): String = tenantId.getRequired("tenant_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun createdAt(): Optional<OffsetDateTime> = createdAt.getOptional("created_at") + + /** + * Enum for dataset data types. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dataType(): Optional<DataType> = dataType.getOptional("data_type") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externallyManaged(): Optional<Boolean> = externallyManaged.getOptional("externally_managed") + + @JsonProperty("inputs_schema_definition") + @ExcludeMissing + fun _inputsSchemaDefinition(): JsonValue = inputsSchemaDefinition + + @JsonProperty("outputs_schema_definition") + @ExcludeMissing + fun _outputsSchemaDefinition(): JsonValue = outputsSchemaDefinition + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun transformations(): Optional<List<DatasetTransformation>> = + transformations.getOptional("transformations") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_id") @ExcludeMissing fun _tenantId(): JsonField<String> = tenantId + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [dataType]. + * + * Unlike [dataType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data_type") @ExcludeMissing fun _dataType(): JsonField<DataType> = dataType + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [externallyManaged]. + * + * Unlike [externallyManaged], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("externally_managed") + @ExcludeMissing + fun _externallyManaged(): JsonField<Boolean> = externallyManaged + + /** + * Returns the raw JSON value of [transformations]. + * + * Unlike [transformations], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("transformations") + @ExcludeMissing + fun _transformations(): JsonField<List<DatasetTransformation>> = transformations + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DatasetUpdateResponse]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .tenantId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DatasetUpdateResponse]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var name: JsonField<String>? = null + private var tenantId: JsonField<String>? = null + private var createdAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var dataType: JsonField<DataType> = JsonMissing.of() + private var description: JsonField<String> = JsonMissing.of() + private var externallyManaged: JsonField<Boolean> = JsonMissing.of() + private var inputsSchemaDefinition: JsonValue = JsonMissing.of() + private var outputsSchemaDefinition: JsonValue = JsonMissing.of() + private var transformations: JsonField<MutableList<DatasetTransformation>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(datasetUpdateResponse: DatasetUpdateResponse) = apply { + id = datasetUpdateResponse.id + name = datasetUpdateResponse.name + tenantId = datasetUpdateResponse.tenantId + createdAt = datasetUpdateResponse.createdAt + dataType = datasetUpdateResponse.dataType + description = datasetUpdateResponse.description + externallyManaged = datasetUpdateResponse.externallyManaged + inputsSchemaDefinition = datasetUpdateResponse.inputsSchemaDefinition + outputsSchemaDefinition = datasetUpdateResponse.outputsSchemaDefinition + transformations = datasetUpdateResponse.transformations.map { it.toMutableList() } + additionalProperties = datasetUpdateResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tenantId(tenantId: JsonField<String>) = apply { this.tenantId = tenantId } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + /** Enum for dataset data types. */ + fun dataType(dataType: DataType?) = dataType(JsonField.ofNullable(dataType)) + + /** Alias for calling [Builder.dataType] with `dataType.orElse(null)`. */ + fun dataType(dataType: Optional<DataType>) = dataType(dataType.getOrNull()) + + /** + * Sets [Builder.dataType] to an arbitrary JSON value. + * + * You should usually call [Builder.dataType] with a well-typed [DataType] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dataType(dataType: JsonField<DataType>) = apply { this.dataType = dataType } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { this.description = description } + + fun externallyManaged(externallyManaged: Boolean?) = + externallyManaged(JsonField.ofNullable(externallyManaged)) + + /** + * Alias for [Builder.externallyManaged]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun externallyManaged(externallyManaged: Boolean) = + externallyManaged(externallyManaged as Boolean?) + + /** Alias for calling [Builder.externallyManaged] with `externallyManaged.orElse(null)`. */ + fun externallyManaged(externallyManaged: Optional<Boolean>) = + externallyManaged(externallyManaged.getOrNull()) + + /** + * Sets [Builder.externallyManaged] to an arbitrary JSON value. + * + * You should usually call [Builder.externallyManaged] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externallyManaged(externallyManaged: JsonField<Boolean>) = apply { + this.externallyManaged = externallyManaged + } + + fun inputsSchemaDefinition(inputsSchemaDefinition: JsonValue) = apply { + this.inputsSchemaDefinition = inputsSchemaDefinition + } + + fun outputsSchemaDefinition(outputsSchemaDefinition: JsonValue) = apply { + this.outputsSchemaDefinition = outputsSchemaDefinition + } + + fun transformations(transformations: List<DatasetTransformation>?) = + transformations(JsonField.ofNullable(transformations)) + + /** Alias for calling [Builder.transformations] with `transformations.orElse(null)`. */ + fun transformations(transformations: Optional<List<DatasetTransformation>>) = + transformations(transformations.getOrNull()) + + /** + * Sets [Builder.transformations] to an arbitrary JSON value. + * + * You should usually call [Builder.transformations] with a well-typed + * `List<DatasetTransformation>` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun transformations(transformations: JsonField<List<DatasetTransformation>>) = apply { + this.transformations = transformations.map { it.toMutableList() } + } + + /** + * Adds a single [DatasetTransformation] to [transformations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTransformation(transformation: DatasetTransformation) = apply { + transformations = + (transformations ?: JsonField.of(mutableListOf())).also { + checkKnown("transformations", it).add(transformation) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DatasetUpdateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .tenantId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DatasetUpdateResponse = + DatasetUpdateResponse( + checkRequired("id", id), + checkRequired("name", name), + checkRequired("tenantId", tenantId), + createdAt, + dataType, + description, + externallyManaged, + inputsSchemaDefinition, + outputsSchemaDefinition, + (transformations ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DatasetUpdateResponse = apply { + if (validated) { + return@apply + } + + id() + name() + tenantId() + createdAt() + dataType().ifPresent { it.validate() } + description() + externallyManaged() + transformations().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (dataType.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (externallyManaged.asKnown().isPresent) 1 else 0) + + (transformations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetUpdateResponse && + id == other.id && + name == other.name && + tenantId == other.tenantId && + createdAt == other.createdAt && + dataType == other.dataType && + description == other.description && + externallyManaged == other.externallyManaged && + inputsSchemaDefinition == other.inputsSchemaDefinition && + outputsSchemaDefinition == other.outputsSchemaDefinition && + transformations == other.transformations && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + name, + tenantId, + createdAt, + dataType, + description, + externallyManaged, + inputsSchemaDefinition, + outputsSchemaDefinition, + transformations, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DatasetUpdateResponse{id=$id, name=$name, tenantId=$tenantId, createdAt=$createdAt, dataType=$dataType, description=$description, externallyManaged=$externallyManaged, inputsSchemaDefinition=$inputsSchemaDefinition, outputsSchemaDefinition=$outputsSchemaDefinition, transformations=$transformations, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUpdateTagsParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUpdateTagsParams.kt new file mode 100644 index 00000000..ffb738b1 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUpdateTagsParams.kt @@ -0,0 +1,704 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +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 com.langsmith_api.api.core.BaseDeserializer +import com.langsmith_api.api.core.BaseSerializer +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.allMaxBy +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Set a tag on a dataset version. */ +class DatasetUpdateTagsParams +private constructor( + private val datasetId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun datasetId(): Optional<String> = Optional.ofNullable(datasetId) + + /** + * Only modifications made on or before this time are included. If None, the latest version of + * the dataset is used. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun asOf(): AsOf = body.asOf() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tag(): String = body.tag() + + /** + * Returns the raw JSON value of [asOf]. + * + * Unlike [asOf], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _asOf(): JsonField<AsOf> = body._asOf() + + /** + * Returns the raw JSON value of [tag]. + * + * Unlike [tag], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _tag(): JsonField<String> = body._tag() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DatasetUpdateTagsParams]. + * + * The following fields are required: + * ```java + * .asOf() + * .tag() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DatasetUpdateTagsParams]. */ + class Builder internal constructor() { + + private var datasetId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(datasetUpdateTagsParams: DatasetUpdateTagsParams) = apply { + datasetId = datasetUpdateTagsParams.datasetId + body = datasetUpdateTagsParams.body.toBuilder() + additionalHeaders = datasetUpdateTagsParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetUpdateTagsParams.additionalQueryParams.toBuilder() + } + + fun datasetId(datasetId: String?) = apply { this.datasetId = datasetId } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [asOf] + * - [tag] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * Only modifications made on or before this time are included. If None, the latest version + * of the dataset is used. + */ + fun asOf(asOf: AsOf) = apply { body.asOf(asOf) } + + /** + * Sets [Builder.asOf] to an arbitrary JSON value. + * + * You should usually call [Builder.asOf] with a well-typed [AsOf] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun asOf(asOf: JsonField<AsOf>) = apply { body.asOf(asOf) } + + /** Alias for calling [asOf] with `AsOf.ofOffsetDateTime(offsetDateTime)`. */ + fun asOf(offsetDateTime: OffsetDateTime) = apply { body.asOf(offsetDateTime) } + + /** Alias for calling [asOf] with `AsOf.ofString(string)`. */ + fun asOf(string: String) = apply { body.asOf(string) } + + fun tag(tag: String) = apply { body.tag(tag) } + + /** + * Sets [Builder.tag] to an arbitrary JSON value. + * + * You should usually call [Builder.tag] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tag(tag: JsonField<String>) = apply { body.tag(tag) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [DatasetUpdateTagsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .asOf() + * .tag() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DatasetUpdateTagsParams = + DatasetUpdateTagsParams( + datasetId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> datasetId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val asOf: JsonField<AsOf>, + private val tag: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("as_of") @ExcludeMissing asOf: JsonField<AsOf> = JsonMissing.of(), + @JsonProperty("tag") @ExcludeMissing tag: JsonField<String> = JsonMissing.of(), + ) : this(asOf, tag, mutableMapOf()) + + /** + * Only modifications made on or before this time are included. If None, the latest version + * of the dataset is used. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun asOf(): AsOf = asOf.getRequired("as_of") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tag(): String = tag.getRequired("tag") + + /** + * Returns the raw JSON value of [asOf]. + * + * Unlike [asOf], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("as_of") @ExcludeMissing fun _asOf(): JsonField<AsOf> = asOf + + /** + * Returns the raw JSON value of [tag]. + * + * Unlike [tag], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tag") @ExcludeMissing fun _tag(): JsonField<String> = tag + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .asOf() + * .tag() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var asOf: JsonField<AsOf>? = null + private var tag: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + asOf = body.asOf + tag = body.tag + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * Only modifications made on or before this time are included. If None, the latest + * version of the dataset is used. + */ + fun asOf(asOf: AsOf) = asOf(JsonField.of(asOf)) + + /** + * Sets [Builder.asOf] to an arbitrary JSON value. + * + * You should usually call [Builder.asOf] with a well-typed [AsOf] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun asOf(asOf: JsonField<AsOf>) = apply { this.asOf = asOf } + + /** Alias for calling [asOf] with `AsOf.ofOffsetDateTime(offsetDateTime)`. */ + fun asOf(offsetDateTime: OffsetDateTime) = asOf(AsOf.ofOffsetDateTime(offsetDateTime)) + + /** Alias for calling [asOf] with `AsOf.ofString(string)`. */ + fun asOf(string: String) = asOf(AsOf.ofString(string)) + + fun tag(tag: String) = tag(JsonField.of(tag)) + + /** + * Sets [Builder.tag] to an arbitrary JSON value. + * + * You should usually call [Builder.tag] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tag(tag: JsonField<String>) = apply { this.tag = tag } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .asOf() + * .tag() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("asOf", asOf), + checkRequired("tag", tag), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + asOf().validate() + tag() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (asOf.asKnown().getOrNull()?.validity() ?: 0) + (if (tag.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + asOf == other.asOf && + tag == other.tag && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(asOf, tag, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{asOf=$asOf, tag=$tag, additionalProperties=$additionalProperties}" + } + + /** + * Only modifications made on or before this time are included. If None, the latest version of + * the dataset is used. + */ + @JsonDeserialize(using = AsOf.Deserializer::class) + @JsonSerialize(using = AsOf.Serializer::class) + class AsOf + private constructor( + private val offsetDateTime: OffsetDateTime? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun offsetDateTime(): Optional<OffsetDateTime> = Optional.ofNullable(offsetDateTime) + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun isOffsetDateTime(): Boolean = offsetDateTime != null + + fun isString(): Boolean = string != null + + fun asOffsetDateTime(): OffsetDateTime = offsetDateTime.getOrThrow("offsetDateTime") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + offsetDateTime != null -> visitor.visitOffsetDateTime(offsetDateTime) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): AsOf = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitOffsetDateTime(offsetDateTime: OffsetDateTime) {} + + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitOffsetDateTime(offsetDateTime: OffsetDateTime) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AsOf && offsetDateTime == other.offsetDateTime && string == other.string + } + + override fun hashCode(): Int = Objects.hash(offsetDateTime, string) + + override fun toString(): String = + when { + offsetDateTime != null -> "AsOf{offsetDateTime=$offsetDateTime}" + string != null -> "AsOf{string=$string}" + _json != null -> "AsOf{_unknown=$_json}" + else -> throw IllegalStateException("Invalid AsOf") + } + + companion object { + + @JvmStatic + fun ofOffsetDateTime(offsetDateTime: OffsetDateTime) = + AsOf(offsetDateTime = offsetDateTime) + + @JvmStatic fun ofString(string: String) = AsOf(string = string) + } + + /** An interface that defines how to map each variant of [AsOf] to a value of type [T]. */ + interface Visitor<out T> { + + fun visitOffsetDateTime(offsetDateTime: OffsetDateTime): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [AsOf] to a value of type [T]. + * + * An instance of [AsOf] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown AsOf: $json") + } + } + + internal class Deserializer : BaseDeserializer<AsOf>(AsOf::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): AsOf { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<OffsetDateTime>())?.let { + AsOf(offsetDateTime = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<String>())?.let { + AsOf(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> AsOf(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<AsOf>(AsOf::class) { + + override fun serialize( + value: AsOf, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.offsetDateTime != null -> generator.writeObject(value.offsetDateTime) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid AsOf") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetUpdateTagsParams && + datasetId == other.datasetId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(datasetId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "DatasetUpdateTagsParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUploadExperimentParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUploadExperimentParams.kt new file mode 100644 index 00000000..89af1a19 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUploadExperimentParams.kt @@ -0,0 +1,1579 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Upload an experiment that has already been run. */ +class DatasetUploadExperimentParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun experimentEndTime(): OffsetDateTime = body.experimentEndTime() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun experimentName(): String = body.experimentName() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun experimentStartTime(): OffsetDateTime = body.experimentStartTime() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun results(): List<Result> = body.results() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun datasetDescription(): Optional<String> = body.datasetDescription() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun datasetId(): Optional<String> = body.datasetId() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun datasetName(): Optional<String> = body.datasetName() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun experimentDescription(): Optional<String> = body.experimentDescription() + + fun _experimentMetadata(): JsonValue = body._experimentMetadata() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun summaryExperimentScores(): Optional<List<FeedbackCreateCoreSchema>> = + body.summaryExperimentScores() + + /** + * Returns the raw JSON value of [experimentEndTime]. + * + * Unlike [experimentEndTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _experimentEndTime(): JsonField<OffsetDateTime> = body._experimentEndTime() + + /** + * Returns the raw JSON value of [experimentName]. + * + * Unlike [experimentName], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _experimentName(): JsonField<String> = body._experimentName() + + /** + * Returns the raw JSON value of [experimentStartTime]. + * + * Unlike [experimentStartTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _experimentStartTime(): JsonField<OffsetDateTime> = body._experimentStartTime() + + /** + * Returns the raw JSON value of [results]. + * + * Unlike [results], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _results(): JsonField<List<Result>> = body._results() + + /** + * Returns the raw JSON value of [datasetDescription]. + * + * Unlike [datasetDescription], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _datasetDescription(): JsonField<String> = body._datasetDescription() + + /** + * Returns the raw JSON value of [datasetId]. + * + * Unlike [datasetId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _datasetId(): JsonField<String> = body._datasetId() + + /** + * Returns the raw JSON value of [datasetName]. + * + * Unlike [datasetName], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _datasetName(): JsonField<String> = body._datasetName() + + /** + * Returns the raw JSON value of [experimentDescription]. + * + * Unlike [experimentDescription], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _experimentDescription(): JsonField<String> = body._experimentDescription() + + /** + * Returns the raw JSON value of [summaryExperimentScores]. + * + * Unlike [summaryExperimentScores], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _summaryExperimentScores(): JsonField<List<FeedbackCreateCoreSchema>> = + body._summaryExperimentScores() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [DatasetUploadExperimentParams]. + * + * The following fields are required: + * ```java + * .experimentEndTime() + * .experimentName() + * .experimentStartTime() + * .results() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DatasetUploadExperimentParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(datasetUploadExperimentParams: DatasetUploadExperimentParams) = apply { + body = datasetUploadExperimentParams.body.toBuilder() + additionalHeaders = datasetUploadExperimentParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetUploadExperimentParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [experimentEndTime] + * - [experimentName] + * - [experimentStartTime] + * - [results] + * - [datasetDescription] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun experimentEndTime(experimentEndTime: OffsetDateTime) = apply { + body.experimentEndTime(experimentEndTime) + } + + /** + * Sets [Builder.experimentEndTime] to an arbitrary JSON value. + * + * You should usually call [Builder.experimentEndTime] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun experimentEndTime(experimentEndTime: JsonField<OffsetDateTime>) = apply { + body.experimentEndTime(experimentEndTime) + } + + fun experimentName(experimentName: String) = apply { body.experimentName(experimentName) } + + /** + * Sets [Builder.experimentName] to an arbitrary JSON value. + * + * You should usually call [Builder.experimentName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun experimentName(experimentName: JsonField<String>) = apply { + body.experimentName(experimentName) + } + + fun experimentStartTime(experimentStartTime: OffsetDateTime) = apply { + body.experimentStartTime(experimentStartTime) + } + + /** + * Sets [Builder.experimentStartTime] to an arbitrary JSON value. + * + * You should usually call [Builder.experimentStartTime] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun experimentStartTime(experimentStartTime: JsonField<OffsetDateTime>) = apply { + body.experimentStartTime(experimentStartTime) + } + + fun results(results: List<Result>) = apply { body.results(results) } + + /** + * Sets [Builder.results] to an arbitrary JSON value. + * + * You should usually call [Builder.results] with a well-typed `List<Result>` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun results(results: JsonField<List<Result>>) = apply { body.results(results) } + + /** + * Adds a single [Result] to [results]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResult(result: Result) = apply { body.addResult(result) } + + fun datasetDescription(datasetDescription: String?) = apply { + body.datasetDescription(datasetDescription) + } + + /** + * Alias for calling [Builder.datasetDescription] with `datasetDescription.orElse(null)`. + */ + fun datasetDescription(datasetDescription: Optional<String>) = + datasetDescription(datasetDescription.getOrNull()) + + /** + * Sets [Builder.datasetDescription] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetDescription] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun datasetDescription(datasetDescription: JsonField<String>) = apply { + body.datasetDescription(datasetDescription) + } + + fun datasetId(datasetId: String?) = apply { body.datasetId(datasetId) } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + /** + * Sets [Builder.datasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun datasetId(datasetId: JsonField<String>) = apply { body.datasetId(datasetId) } + + fun datasetName(datasetName: String?) = apply { body.datasetName(datasetName) } + + /** Alias for calling [Builder.datasetName] with `datasetName.orElse(null)`. */ + fun datasetName(datasetName: Optional<String>) = datasetName(datasetName.getOrNull()) + + /** + * Sets [Builder.datasetName] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun datasetName(datasetName: JsonField<String>) = apply { body.datasetName(datasetName) } + + fun experimentDescription(experimentDescription: String?) = apply { + body.experimentDescription(experimentDescription) + } + + /** + * Alias for calling [Builder.experimentDescription] with + * `experimentDescription.orElse(null)`. + */ + fun experimentDescription(experimentDescription: Optional<String>) = + experimentDescription(experimentDescription.getOrNull()) + + /** + * Sets [Builder.experimentDescription] to an arbitrary JSON value. + * + * You should usually call [Builder.experimentDescription] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun experimentDescription(experimentDescription: JsonField<String>) = apply { + body.experimentDescription(experimentDescription) + } + + fun experimentMetadata(experimentMetadata: JsonValue) = apply { + body.experimentMetadata(experimentMetadata) + } + + fun summaryExperimentScores(summaryExperimentScores: List<FeedbackCreateCoreSchema>?) = + apply { + body.summaryExperimentScores(summaryExperimentScores) + } + + /** + * Alias for calling [Builder.summaryExperimentScores] with + * `summaryExperimentScores.orElse(null)`. + */ + fun summaryExperimentScores( + summaryExperimentScores: Optional<List<FeedbackCreateCoreSchema>> + ) = summaryExperimentScores(summaryExperimentScores.getOrNull()) + + /** + * Sets [Builder.summaryExperimentScores] to an arbitrary JSON value. + * + * You should usually call [Builder.summaryExperimentScores] with a well-typed + * `List<FeedbackCreateCoreSchema>` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun summaryExperimentScores( + summaryExperimentScores: JsonField<List<FeedbackCreateCoreSchema>> + ) = apply { body.summaryExperimentScores(summaryExperimentScores) } + + /** + * Adds a single [FeedbackCreateCoreSchema] to [summaryExperimentScores]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSummaryExperimentScore(summaryExperimentScore: FeedbackCreateCoreSchema) = apply { + body.addSummaryExperimentScore(summaryExperimentScore) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [DatasetUploadExperimentParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .experimentEndTime() + * .experimentName() + * .experimentStartTime() + * .results() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DatasetUploadExperimentParams = + DatasetUploadExperimentParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Class for uploading the results of an already-run experiment. */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val experimentEndTime: JsonField<OffsetDateTime>, + private val experimentName: JsonField<String>, + private val experimentStartTime: JsonField<OffsetDateTime>, + private val results: JsonField<List<Result>>, + private val datasetDescription: JsonField<String>, + private val datasetId: JsonField<String>, + private val datasetName: JsonField<String>, + private val experimentDescription: JsonField<String>, + private val experimentMetadata: JsonValue, + private val summaryExperimentScores: JsonField<List<FeedbackCreateCoreSchema>>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("experiment_end_time") + @ExcludeMissing + experimentEndTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("experiment_name") + @ExcludeMissing + experimentName: JsonField<String> = JsonMissing.of(), + @JsonProperty("experiment_start_time") + @ExcludeMissing + experimentStartTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("results") + @ExcludeMissing + results: JsonField<List<Result>> = JsonMissing.of(), + @JsonProperty("dataset_description") + @ExcludeMissing + datasetDescription: JsonField<String> = JsonMissing.of(), + @JsonProperty("dataset_id") + @ExcludeMissing + datasetId: JsonField<String> = JsonMissing.of(), + @JsonProperty("dataset_name") + @ExcludeMissing + datasetName: JsonField<String> = JsonMissing.of(), + @JsonProperty("experiment_description") + @ExcludeMissing + experimentDescription: JsonField<String> = JsonMissing.of(), + @JsonProperty("experiment_metadata") + @ExcludeMissing + experimentMetadata: JsonValue = JsonMissing.of(), + @JsonProperty("summary_experiment_scores") + @ExcludeMissing + summaryExperimentScores: JsonField<List<FeedbackCreateCoreSchema>> = JsonMissing.of(), + ) : this( + experimentEndTime, + experimentName, + experimentStartTime, + results, + datasetDescription, + datasetId, + datasetName, + experimentDescription, + experimentMetadata, + summaryExperimentScores, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun experimentEndTime(): OffsetDateTime = + experimentEndTime.getRequired("experiment_end_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun experimentName(): String = experimentName.getRequired("experiment_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun experimentStartTime(): OffsetDateTime = + experimentStartTime.getRequired("experiment_start_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun results(): List<Result> = results.getRequired("results") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun datasetDescription(): Optional<String> = + datasetDescription.getOptional("dataset_description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun datasetId(): Optional<String> = datasetId.getOptional("dataset_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun datasetName(): Optional<String> = datasetName.getOptional("dataset_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun experimentDescription(): Optional<String> = + experimentDescription.getOptional("experiment_description") + + @JsonProperty("experiment_metadata") + @ExcludeMissing + fun _experimentMetadata(): JsonValue = experimentMetadata + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun summaryExperimentScores(): Optional<List<FeedbackCreateCoreSchema>> = + summaryExperimentScores.getOptional("summary_experiment_scores") + + /** + * Returns the raw JSON value of [experimentEndTime]. + * + * Unlike [experimentEndTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("experiment_end_time") + @ExcludeMissing + fun _experimentEndTime(): JsonField<OffsetDateTime> = experimentEndTime + + /** + * Returns the raw JSON value of [experimentName]. + * + * Unlike [experimentName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("experiment_name") + @ExcludeMissing + fun _experimentName(): JsonField<String> = experimentName + + /** + * Returns the raw JSON value of [experimentStartTime]. + * + * Unlike [experimentStartTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("experiment_start_time") + @ExcludeMissing + fun _experimentStartTime(): JsonField<OffsetDateTime> = experimentStartTime + + /** + * Returns the raw JSON value of [results]. + * + * Unlike [results], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("results") @ExcludeMissing fun _results(): JsonField<List<Result>> = results + + /** + * Returns the raw JSON value of [datasetDescription]. + * + * Unlike [datasetDescription], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dataset_description") + @ExcludeMissing + fun _datasetDescription(): JsonField<String> = datasetDescription + + /** + * Returns the raw JSON value of [datasetId]. + * + * Unlike [datasetId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField<String> = datasetId + + /** + * Returns the raw JSON value of [datasetName]. + * + * Unlike [datasetName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dataset_name") + @ExcludeMissing + fun _datasetName(): JsonField<String> = datasetName + + /** + * Returns the raw JSON value of [experimentDescription]. + * + * Unlike [experimentDescription], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("experiment_description") + @ExcludeMissing + fun _experimentDescription(): JsonField<String> = experimentDescription + + /** + * Returns the raw JSON value of [summaryExperimentScores]. + * + * Unlike [summaryExperimentScores], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("summary_experiment_scores") + @ExcludeMissing + fun _summaryExperimentScores(): JsonField<List<FeedbackCreateCoreSchema>> = + summaryExperimentScores + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .experimentEndTime() + * .experimentName() + * .experimentStartTime() + * .results() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var experimentEndTime: JsonField<OffsetDateTime>? = null + private var experimentName: JsonField<String>? = null + private var experimentStartTime: JsonField<OffsetDateTime>? = null + private var results: JsonField<MutableList<Result>>? = null + private var datasetDescription: JsonField<String> = JsonMissing.of() + private var datasetId: JsonField<String> = JsonMissing.of() + private var datasetName: JsonField<String> = JsonMissing.of() + private var experimentDescription: JsonField<String> = JsonMissing.of() + private var experimentMetadata: JsonValue = JsonMissing.of() + private var summaryExperimentScores: JsonField<MutableList<FeedbackCreateCoreSchema>>? = + null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + experimentEndTime = body.experimentEndTime + experimentName = body.experimentName + experimentStartTime = body.experimentStartTime + results = body.results.map { it.toMutableList() } + datasetDescription = body.datasetDescription + datasetId = body.datasetId + datasetName = body.datasetName + experimentDescription = body.experimentDescription + experimentMetadata = body.experimentMetadata + summaryExperimentScores = body.summaryExperimentScores.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun experimentEndTime(experimentEndTime: OffsetDateTime) = + experimentEndTime(JsonField.of(experimentEndTime)) + + /** + * Sets [Builder.experimentEndTime] to an arbitrary JSON value. + * + * You should usually call [Builder.experimentEndTime] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun experimentEndTime(experimentEndTime: JsonField<OffsetDateTime>) = apply { + this.experimentEndTime = experimentEndTime + } + + fun experimentName(experimentName: String) = + experimentName(JsonField.of(experimentName)) + + /** + * Sets [Builder.experimentName] to an arbitrary JSON value. + * + * You should usually call [Builder.experimentName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun experimentName(experimentName: JsonField<String>) = apply { + this.experimentName = experimentName + } + + fun experimentStartTime(experimentStartTime: OffsetDateTime) = + experimentStartTime(JsonField.of(experimentStartTime)) + + /** + * Sets [Builder.experimentStartTime] to an arbitrary JSON value. + * + * You should usually call [Builder.experimentStartTime] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun experimentStartTime(experimentStartTime: JsonField<OffsetDateTime>) = apply { + this.experimentStartTime = experimentStartTime + } + + fun results(results: List<Result>) = results(JsonField.of(results)) + + /** + * Sets [Builder.results] to an arbitrary JSON value. + * + * You should usually call [Builder.results] with a well-typed `List<Result>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun results(results: JsonField<List<Result>>) = apply { + this.results = results.map { it.toMutableList() } + } + + /** + * Adds a single [Result] to [results]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResult(result: Result) = apply { + results = + (results ?: JsonField.of(mutableListOf())).also { + checkKnown("results", it).add(result) + } + } + + fun datasetDescription(datasetDescription: String?) = + datasetDescription(JsonField.ofNullable(datasetDescription)) + + /** + * Alias for calling [Builder.datasetDescription] with + * `datasetDescription.orElse(null)`. + */ + fun datasetDescription(datasetDescription: Optional<String>) = + datasetDescription(datasetDescription.getOrNull()) + + /** + * Sets [Builder.datasetDescription] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetDescription] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun datasetDescription(datasetDescription: JsonField<String>) = apply { + this.datasetDescription = datasetDescription + } + + fun datasetId(datasetId: String?) = datasetId(JsonField.ofNullable(datasetId)) + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + /** + * Sets [Builder.datasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun datasetId(datasetId: JsonField<String>) = apply { this.datasetId = datasetId } + + fun datasetName(datasetName: String?) = datasetName(JsonField.ofNullable(datasetName)) + + /** Alias for calling [Builder.datasetName] with `datasetName.orElse(null)`. */ + fun datasetName(datasetName: Optional<String>) = datasetName(datasetName.getOrNull()) + + /** + * Sets [Builder.datasetName] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun datasetName(datasetName: JsonField<String>) = apply { + this.datasetName = datasetName + } + + fun experimentDescription(experimentDescription: String?) = + experimentDescription(JsonField.ofNullable(experimentDescription)) + + /** + * Alias for calling [Builder.experimentDescription] with + * `experimentDescription.orElse(null)`. + */ + fun experimentDescription(experimentDescription: Optional<String>) = + experimentDescription(experimentDescription.getOrNull()) + + /** + * Sets [Builder.experimentDescription] to an arbitrary JSON value. + * + * You should usually call [Builder.experimentDescription] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun experimentDescription(experimentDescription: JsonField<String>) = apply { + this.experimentDescription = experimentDescription + } + + fun experimentMetadata(experimentMetadata: JsonValue) = apply { + this.experimentMetadata = experimentMetadata + } + + fun summaryExperimentScores(summaryExperimentScores: List<FeedbackCreateCoreSchema>?) = + summaryExperimentScores(JsonField.ofNullable(summaryExperimentScores)) + + /** + * Alias for calling [Builder.summaryExperimentScores] with + * `summaryExperimentScores.orElse(null)`. + */ + fun summaryExperimentScores( + summaryExperimentScores: Optional<List<FeedbackCreateCoreSchema>> + ) = summaryExperimentScores(summaryExperimentScores.getOrNull()) + + /** + * Sets [Builder.summaryExperimentScores] to an arbitrary JSON value. + * + * You should usually call [Builder.summaryExperimentScores] with a well-typed + * `List<FeedbackCreateCoreSchema>` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun summaryExperimentScores( + summaryExperimentScores: JsonField<List<FeedbackCreateCoreSchema>> + ) = apply { + this.summaryExperimentScores = summaryExperimentScores.map { it.toMutableList() } + } + + /** + * Adds a single [FeedbackCreateCoreSchema] to [summaryExperimentScores]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSummaryExperimentScore(summaryExperimentScore: FeedbackCreateCoreSchema) = + apply { + summaryExperimentScores = + (summaryExperimentScores ?: JsonField.of(mutableListOf())).also { + checkKnown("summaryExperimentScores", it).add(summaryExperimentScore) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .experimentEndTime() + * .experimentName() + * .experimentStartTime() + * .results() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("experimentEndTime", experimentEndTime), + checkRequired("experimentName", experimentName), + checkRequired("experimentStartTime", experimentStartTime), + checkRequired("results", results).map { it.toImmutable() }, + datasetDescription, + datasetId, + datasetName, + experimentDescription, + experimentMetadata, + (summaryExperimentScores ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + experimentEndTime() + experimentName() + experimentStartTime() + results().forEach { it.validate() } + datasetDescription() + datasetId() + datasetName() + experimentDescription() + summaryExperimentScores().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (experimentEndTime.asKnown().isPresent) 1 else 0) + + (if (experimentName.asKnown().isPresent) 1 else 0) + + (if (experimentStartTime.asKnown().isPresent) 1 else 0) + + (results.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (datasetDescription.asKnown().isPresent) 1 else 0) + + (if (datasetId.asKnown().isPresent) 1 else 0) + + (if (datasetName.asKnown().isPresent) 1 else 0) + + (if (experimentDescription.asKnown().isPresent) 1 else 0) + + (summaryExperimentScores.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + experimentEndTime == other.experimentEndTime && + experimentName == other.experimentName && + experimentStartTime == other.experimentStartTime && + results == other.results && + datasetDescription == other.datasetDescription && + datasetId == other.datasetId && + datasetName == other.datasetName && + experimentDescription == other.experimentDescription && + experimentMetadata == other.experimentMetadata && + summaryExperimentScores == other.summaryExperimentScores && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + experimentEndTime, + experimentName, + experimentStartTime, + results, + datasetDescription, + datasetId, + datasetName, + experimentDescription, + experimentMetadata, + summaryExperimentScores, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{experimentEndTime=$experimentEndTime, experimentName=$experimentName, experimentStartTime=$experimentStartTime, results=$results, datasetDescription=$datasetDescription, datasetId=$datasetId, datasetName=$datasetName, experimentDescription=$experimentDescription, experimentMetadata=$experimentMetadata, summaryExperimentScores=$summaryExperimentScores, additionalProperties=$additionalProperties}" + } + + /** Class for a single row in the uploaded experiment results. */ + class Result + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val endTime: JsonField<OffsetDateTime>, + private val inputs: JsonValue, + private val startTime: JsonField<OffsetDateTime>, + private val actualOutputs: JsonValue, + private val error: JsonField<String>, + private val evaluationScores: JsonField<List<FeedbackCreateCoreSchema>>, + private val expectedOutputs: JsonValue, + private val rowId: JsonField<String>, + private val runMetadata: JsonValue, + private val runName: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("end_time") + @ExcludeMissing + endTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("inputs") @ExcludeMissing inputs: JsonValue = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("actual_outputs") + @ExcludeMissing + actualOutputs: JsonValue = JsonMissing.of(), + @JsonProperty("error") @ExcludeMissing error: JsonField<String> = JsonMissing.of(), + @JsonProperty("evaluation_scores") + @ExcludeMissing + evaluationScores: JsonField<List<FeedbackCreateCoreSchema>> = JsonMissing.of(), + @JsonProperty("expected_outputs") + @ExcludeMissing + expectedOutputs: JsonValue = JsonMissing.of(), + @JsonProperty("row_id") @ExcludeMissing rowId: JsonField<String> = JsonMissing.of(), + @JsonProperty("run_metadata") @ExcludeMissing runMetadata: JsonValue = JsonMissing.of(), + @JsonProperty("run_name") @ExcludeMissing runName: JsonField<String> = JsonMissing.of(), + ) : this( + endTime, + inputs, + startTime, + actualOutputs, + error, + evaluationScores, + expectedOutputs, + rowId, + runMetadata, + runName, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun endTime(): OffsetDateTime = endTime.getRequired("end_time") + + @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonValue = inputs + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun startTime(): OffsetDateTime = startTime.getRequired("start_time") + + @JsonProperty("actual_outputs") + @ExcludeMissing + fun _actualOutputs(): JsonValue = actualOutputs + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun error(): Optional<String> = error.getOptional("error") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun evaluationScores(): Optional<List<FeedbackCreateCoreSchema>> = + evaluationScores.getOptional("evaluation_scores") + + @JsonProperty("expected_outputs") + @ExcludeMissing + fun _expectedOutputs(): JsonValue = expectedOutputs + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun rowId(): Optional<String> = rowId.getOptional("row_id") + + @JsonProperty("run_metadata") @ExcludeMissing fun _runMetadata(): JsonValue = runMetadata + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun runName(): Optional<String> = runName.getOptional("run_name") + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_time") + @ExcludeMissing + fun _endTime(): JsonField<OffsetDateTime> = endTime + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_time") + @ExcludeMissing + fun _startTime(): JsonField<OffsetDateTime> = startTime + + /** + * Returns the raw JSON value of [error]. + * + * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("error") @ExcludeMissing fun _error(): JsonField<String> = error + + /** + * Returns the raw JSON value of [evaluationScores]. + * + * Unlike [evaluationScores], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("evaluation_scores") + @ExcludeMissing + fun _evaluationScores(): JsonField<List<FeedbackCreateCoreSchema>> = evaluationScores + + /** + * Returns the raw JSON value of [rowId]. + * + * Unlike [rowId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("row_id") @ExcludeMissing fun _rowId(): JsonField<String> = rowId + + /** + * Returns the raw JSON value of [runName]. + * + * Unlike [runName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_name") @ExcludeMissing fun _runName(): JsonField<String> = runName + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Result]. + * + * The following fields are required: + * ```java + * .endTime() + * .inputs() + * .startTime() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Result]. */ + class Builder internal constructor() { + + private var endTime: JsonField<OffsetDateTime>? = null + private var inputs: JsonValue? = null + private var startTime: JsonField<OffsetDateTime>? = null + private var actualOutputs: JsonValue = JsonMissing.of() + private var error: JsonField<String> = JsonMissing.of() + private var evaluationScores: JsonField<MutableList<FeedbackCreateCoreSchema>>? = null + private var expectedOutputs: JsonValue = JsonMissing.of() + private var rowId: JsonField<String> = JsonMissing.of() + private var runMetadata: JsonValue = JsonMissing.of() + private var runName: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(result: Result) = apply { + endTime = result.endTime + inputs = result.inputs + startTime = result.startTime + actualOutputs = result.actualOutputs + error = result.error + evaluationScores = result.evaluationScores.map { it.toMutableList() } + expectedOutputs = result.expectedOutputs + rowId = result.rowId + runMetadata = result.runMetadata + runName = result.runName + additionalProperties = result.additionalProperties.toMutableMap() + } + + fun endTime(endTime: OffsetDateTime) = endTime(JsonField.of(endTime)) + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endTime(endTime: JsonField<OffsetDateTime>) = apply { this.endTime = endTime } + + fun inputs(inputs: JsonValue) = apply { this.inputs = inputs } + + fun startTime(startTime: OffsetDateTime) = startTime(JsonField.of(startTime)) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField<OffsetDateTime>) = apply { + this.startTime = startTime + } + + fun actualOutputs(actualOutputs: JsonValue) = apply { + this.actualOutputs = actualOutputs + } + + fun error(error: String?) = error(JsonField.ofNullable(error)) + + /** Alias for calling [Builder.error] with `error.orElse(null)`. */ + fun error(error: Optional<String>) = error(error.getOrNull()) + + /** + * Sets [Builder.error] to an arbitrary JSON value. + * + * You should usually call [Builder.error] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun error(error: JsonField<String>) = apply { this.error = error } + + fun evaluationScores(evaluationScores: List<FeedbackCreateCoreSchema>?) = + evaluationScores(JsonField.ofNullable(evaluationScores)) + + /** + * Alias for calling [Builder.evaluationScores] with `evaluationScores.orElse(null)`. + */ + fun evaluationScores(evaluationScores: Optional<List<FeedbackCreateCoreSchema>>) = + evaluationScores(evaluationScores.getOrNull()) + + /** + * Sets [Builder.evaluationScores] to an arbitrary JSON value. + * + * You should usually call [Builder.evaluationScores] with a well-typed + * `List<FeedbackCreateCoreSchema>` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun evaluationScores(evaluationScores: JsonField<List<FeedbackCreateCoreSchema>>) = + apply { + this.evaluationScores = evaluationScores.map { it.toMutableList() } + } + + /** + * Adds a single [FeedbackCreateCoreSchema] to [evaluationScores]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvaluationScore(evaluationScore: FeedbackCreateCoreSchema) = apply { + evaluationScores = + (evaluationScores ?: JsonField.of(mutableListOf())).also { + checkKnown("evaluationScores", it).add(evaluationScore) + } + } + + fun expectedOutputs(expectedOutputs: JsonValue) = apply { + this.expectedOutputs = expectedOutputs + } + + fun rowId(rowId: String?) = rowId(JsonField.ofNullable(rowId)) + + /** Alias for calling [Builder.rowId] with `rowId.orElse(null)`. */ + fun rowId(rowId: Optional<String>) = rowId(rowId.getOrNull()) + + /** + * Sets [Builder.rowId] to an arbitrary JSON value. + * + * You should usually call [Builder.rowId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rowId(rowId: JsonField<String>) = apply { this.rowId = rowId } + + fun runMetadata(runMetadata: JsonValue) = apply { this.runMetadata = runMetadata } + + fun runName(runName: String?) = runName(JsonField.ofNullable(runName)) + + /** Alias for calling [Builder.runName] with `runName.orElse(null)`. */ + fun runName(runName: Optional<String>) = runName(runName.getOrNull()) + + /** + * Sets [Builder.runName] to an arbitrary JSON value. + * + * You should usually call [Builder.runName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun runName(runName: JsonField<String>) = apply { this.runName = runName } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Result]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .endTime() + * .inputs() + * .startTime() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Result = + Result( + checkRequired("endTime", endTime), + checkRequired("inputs", inputs), + checkRequired("startTime", startTime), + actualOutputs, + error, + (evaluationScores ?: JsonMissing.of()).map { it.toImmutable() }, + expectedOutputs, + rowId, + runMetadata, + runName, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Result = apply { + if (validated) { + return@apply + } + + endTime() + startTime() + error() + evaluationScores().ifPresent { it.forEach { it.validate() } } + rowId() + runName() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (endTime.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + (if (error.asKnown().isPresent) 1 else 0) + + (evaluationScores.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (rowId.asKnown().isPresent) 1 else 0) + + (if (runName.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Result && + endTime == other.endTime && + inputs == other.inputs && + startTime == other.startTime && + actualOutputs == other.actualOutputs && + error == other.error && + evaluationScores == other.evaluationScores && + expectedOutputs == other.expectedOutputs && + rowId == other.rowId && + runMetadata == other.runMetadata && + runName == other.runName && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + endTime, + inputs, + startTime, + actualOutputs, + error, + evaluationScores, + expectedOutputs, + rowId, + runMetadata, + runName, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Result{endTime=$endTime, inputs=$inputs, startTime=$startTime, actualOutputs=$actualOutputs, error=$error, evaluationScores=$evaluationScores, expectedOutputs=$expectedOutputs, rowId=$rowId, runMetadata=$runMetadata, runName=$runName, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetUploadExperimentParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "DatasetUploadExperimentParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUploadExperimentResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUploadExperimentResponse.kt new file mode 100644 index 00000000..7b33d0dc --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUploadExperimentResponse.kt @@ -0,0 +1,224 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.sessions.TracerSession +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** Class for uploading the results of an already-run experiment. */ +class DatasetUploadExperimentResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val dataset: JsonField<Dataset>, + private val experiment: JsonField<TracerSession>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("dataset") @ExcludeMissing dataset: JsonField<Dataset> = JsonMissing.of(), + @JsonProperty("experiment") + @ExcludeMissing + experiment: JsonField<TracerSession> = JsonMissing.of(), + ) : this(dataset, experiment, mutableMapOf()) + + /** + * Dataset schema. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun dataset(): Dataset = dataset.getRequired("dataset") + + /** + * TracerSession schema. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun experiment(): TracerSession = experiment.getRequired("experiment") + + /** + * Returns the raw JSON value of [dataset]. + * + * Unlike [dataset], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dataset") @ExcludeMissing fun _dataset(): JsonField<Dataset> = dataset + + /** + * Returns the raw JSON value of [experiment]. + * + * Unlike [experiment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("experiment") + @ExcludeMissing + fun _experiment(): JsonField<TracerSession> = experiment + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [DatasetUploadExperimentResponse]. + * + * The following fields are required: + * ```java + * .dataset() + * .experiment() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DatasetUploadExperimentResponse]. */ + class Builder internal constructor() { + + private var dataset: JsonField<Dataset>? = null + private var experiment: JsonField<TracerSession>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(datasetUploadExperimentResponse: DatasetUploadExperimentResponse) = + apply { + dataset = datasetUploadExperimentResponse.dataset + experiment = datasetUploadExperimentResponse.experiment + additionalProperties = + datasetUploadExperimentResponse.additionalProperties.toMutableMap() + } + + /** Dataset schema. */ + fun dataset(dataset: Dataset) = dataset(JsonField.of(dataset)) + + /** + * Sets [Builder.dataset] to an arbitrary JSON value. + * + * You should usually call [Builder.dataset] with a well-typed [Dataset] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun dataset(dataset: JsonField<Dataset>) = apply { this.dataset = dataset } + + /** TracerSession schema. */ + fun experiment(experiment: TracerSession) = experiment(JsonField.of(experiment)) + + /** + * Sets [Builder.experiment] to an arbitrary JSON value. + * + * You should usually call [Builder.experiment] with a well-typed [TracerSession] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun experiment(experiment: JsonField<TracerSession>) = apply { + this.experiment = experiment + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DatasetUploadExperimentResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .dataset() + * .experiment() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DatasetUploadExperimentResponse = + DatasetUploadExperimentResponse( + checkRequired("dataset", dataset), + checkRequired("experiment", experiment), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DatasetUploadExperimentResponse = apply { + if (validated) { + return@apply + } + + dataset().validate() + experiment().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dataset.asKnown().getOrNull()?.validity() ?: 0) + + (experiment.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetUploadExperimentResponse && + dataset == other.dataset && + experiment == other.experiment && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(dataset, experiment, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DatasetUploadExperimentResponse{dataset=$dataset, experiment=$experiment, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUploadParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUploadParams.kt new file mode 100644 index 00000000..8e1783a5 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUploadParams.kt @@ -0,0 +1,1356 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.MultipartField +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.io.InputStream +import java.nio.file.Path +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.io.path.inputStream +import kotlin.io.path.name +import kotlin.jvm.optionals.getOrNull + +/** Create a new dataset from a CSV file. */ +class DatasetUploadParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun file(): InputStream = body.file() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun inputKeys(): List<String> = body.inputKeys() + + /** + * Enum for dataset data types. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dataType(): Optional<DataType> = body.dataType() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = body.description() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun inputKeyMappings(): Optional<String> = body.inputKeyMappings() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun inputsSchemaDefinition(): Optional<String> = body.inputsSchemaDefinition() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadataKeyMappings(): Optional<String> = body.metadataKeyMappings() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadataKeys(): Optional<List<String>> = body.metadataKeys() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional<String> = body.name() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun outputKeyMappings(): Optional<String> = body.outputKeyMappings() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun outputKeys(): Optional<List<String>> = body.outputKeys() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun outputsSchemaDefinition(): Optional<String> = body.outputsSchemaDefinition() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun transformations(): Optional<String> = body.transformations() + + /** + * Returns the raw multipart value of [file]. + * + * Unlike [file], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _file(): MultipartField<InputStream> = body._file() + + /** + * Returns the raw multipart value of [inputKeys]. + * + * Unlike [inputKeys], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _inputKeys(): MultipartField<List<String>> = body._inputKeys() + + /** + * Returns the raw multipart value of [dataType]. + * + * Unlike [dataType], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _dataType(): MultipartField<DataType> = body._dataType() + + /** + * Returns the raw multipart value of [description]. + * + * Unlike [description], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _description(): MultipartField<String> = body._description() + + /** + * Returns the raw multipart value of [inputKeyMappings]. + * + * Unlike [inputKeyMappings], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _inputKeyMappings(): MultipartField<String> = body._inputKeyMappings() + + /** + * Returns the raw multipart value of [inputsSchemaDefinition]. + * + * Unlike [inputsSchemaDefinition], this method doesn't throw if the multipart field has an + * unexpected type. + */ + fun _inputsSchemaDefinition(): MultipartField<String> = body._inputsSchemaDefinition() + + /** + * Returns the raw multipart value of [metadataKeyMappings]. + * + * Unlike [metadataKeyMappings], this method doesn't throw if the multipart field has an + * unexpected type. + */ + fun _metadataKeyMappings(): MultipartField<String> = body._metadataKeyMappings() + + /** + * Returns the raw multipart value of [metadataKeys]. + * + * Unlike [metadataKeys], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _metadataKeys(): MultipartField<List<String>> = body._metadataKeys() + + /** + * Returns the raw multipart value of [name]. + * + * Unlike [name], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _name(): MultipartField<String> = body._name() + + /** + * Returns the raw multipart value of [outputKeyMappings]. + * + * Unlike [outputKeyMappings], this method doesn't throw if the multipart field has an + * unexpected type. + */ + fun _outputKeyMappings(): MultipartField<String> = body._outputKeyMappings() + + /** + * Returns the raw multipart value of [outputKeys]. + * + * Unlike [outputKeys], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _outputKeys(): MultipartField<List<String>> = body._outputKeys() + + /** + * Returns the raw multipart value of [outputsSchemaDefinition]. + * + * Unlike [outputsSchemaDefinition], this method doesn't throw if the multipart field has an + * unexpected type. + */ + fun _outputsSchemaDefinition(): MultipartField<String> = body._outputsSchemaDefinition() + + /** + * Returns the raw multipart value of [transformations]. + * + * Unlike [transformations], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _transformations(): MultipartField<String> = body._transformations() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DatasetUploadParams]. + * + * The following fields are required: + * ```java + * .file() + * .inputKeys() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DatasetUploadParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(datasetUploadParams: DatasetUploadParams) = apply { + body = datasetUploadParams.body.toBuilder() + additionalHeaders = datasetUploadParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetUploadParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [file] + * - [inputKeys] + * - [dataType] + * - [description] + * - [inputKeyMappings] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun file(file: InputStream) = apply { body.file(file) } + + /** + * Sets [Builder.file] to an arbitrary multipart value. + * + * You should usually call [Builder.file] with a well-typed [InputStream] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun file(file: MultipartField<InputStream>) = apply { body.file(file) } + + fun file(file: ByteArray) = apply { body.file(file) } + + fun file(path: Path) = apply { body.file(path) } + + fun inputKeys(inputKeys: List<String>) = apply { body.inputKeys(inputKeys) } + + /** + * Sets [Builder.inputKeys] to an arbitrary multipart value. + * + * You should usually call [Builder.inputKeys] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inputKeys(inputKeys: MultipartField<List<String>>) = apply { body.inputKeys(inputKeys) } + + /** + * Adds a single [String] to [inputKeys]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addInputKey(inputKey: String) = apply { body.addInputKey(inputKey) } + + /** Enum for dataset data types. */ + fun dataType(dataType: DataType) = apply { body.dataType(dataType) } + + /** + * Sets [Builder.dataType] to an arbitrary multipart value. + * + * You should usually call [Builder.dataType] with a well-typed [DataType] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dataType(dataType: MultipartField<DataType>) = apply { body.dataType(dataType) } + + fun description(description: String?) = apply { body.description(description) } + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary multipart value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: MultipartField<String>) = apply { + body.description(description) + } + + fun inputKeyMappings(inputKeyMappings: String?) = apply { + body.inputKeyMappings(inputKeyMappings) + } + + /** Alias for calling [Builder.inputKeyMappings] with `inputKeyMappings.orElse(null)`. */ + fun inputKeyMappings(inputKeyMappings: Optional<String>) = + inputKeyMappings(inputKeyMappings.getOrNull()) + + /** + * Sets [Builder.inputKeyMappings] to an arbitrary multipart value. + * + * You should usually call [Builder.inputKeyMappings] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inputKeyMappings(inputKeyMappings: MultipartField<String>) = apply { + body.inputKeyMappings(inputKeyMappings) + } + + fun inputsSchemaDefinition(inputsSchemaDefinition: String?) = apply { + body.inputsSchemaDefinition(inputsSchemaDefinition) + } + + /** + * Alias for calling [Builder.inputsSchemaDefinition] with + * `inputsSchemaDefinition.orElse(null)`. + */ + fun inputsSchemaDefinition(inputsSchemaDefinition: Optional<String>) = + inputsSchemaDefinition(inputsSchemaDefinition.getOrNull()) + + /** + * Sets [Builder.inputsSchemaDefinition] to an arbitrary multipart value. + * + * You should usually call [Builder.inputsSchemaDefinition] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inputsSchemaDefinition(inputsSchemaDefinition: MultipartField<String>) = apply { + body.inputsSchemaDefinition(inputsSchemaDefinition) + } + + fun metadataKeyMappings(metadataKeyMappings: String?) = apply { + body.metadataKeyMappings(metadataKeyMappings) + } + + /** + * Alias for calling [Builder.metadataKeyMappings] with `metadataKeyMappings.orElse(null)`. + */ + fun metadataKeyMappings(metadataKeyMappings: Optional<String>) = + metadataKeyMappings(metadataKeyMappings.getOrNull()) + + /** + * Sets [Builder.metadataKeyMappings] to an arbitrary multipart value. + * + * You should usually call [Builder.metadataKeyMappings] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadataKeyMappings(metadataKeyMappings: MultipartField<String>) = apply { + body.metadataKeyMappings(metadataKeyMappings) + } + + fun metadataKeys(metadataKeys: List<String>) = apply { body.metadataKeys(metadataKeys) } + + /** + * Sets [Builder.metadataKeys] to an arbitrary multipart value. + * + * You should usually call [Builder.metadataKeys] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadataKeys(metadataKeys: MultipartField<List<String>>) = apply { + body.metadataKeys(metadataKeys) + } + + /** + * Adds a single [String] to [metadataKeys]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMetadataKey(metadataKey: String) = apply { body.addMetadataKey(metadataKey) } + + fun name(name: String?) = apply { body.name(name) } + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional<String>) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary multipart value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: MultipartField<String>) = apply { body.name(name) } + + fun outputKeyMappings(outputKeyMappings: String?) = apply { + body.outputKeyMappings(outputKeyMappings) + } + + /** Alias for calling [Builder.outputKeyMappings] with `outputKeyMappings.orElse(null)`. */ + fun outputKeyMappings(outputKeyMappings: Optional<String>) = + outputKeyMappings(outputKeyMappings.getOrNull()) + + /** + * Sets [Builder.outputKeyMappings] to an arbitrary multipart value. + * + * You should usually call [Builder.outputKeyMappings] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun outputKeyMappings(outputKeyMappings: MultipartField<String>) = apply { + body.outputKeyMappings(outputKeyMappings) + } + + fun outputKeys(outputKeys: List<String>) = apply { body.outputKeys(outputKeys) } + + /** + * Sets [Builder.outputKeys] to an arbitrary multipart value. + * + * You should usually call [Builder.outputKeys] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun outputKeys(outputKeys: MultipartField<List<String>>) = apply { + body.outputKeys(outputKeys) + } + + /** + * Adds a single [String] to [outputKeys]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addOutputKey(outputKey: String) = apply { body.addOutputKey(outputKey) } + + fun outputsSchemaDefinition(outputsSchemaDefinition: String?) = apply { + body.outputsSchemaDefinition(outputsSchemaDefinition) + } + + /** + * Alias for calling [Builder.outputsSchemaDefinition] with + * `outputsSchemaDefinition.orElse(null)`. + */ + fun outputsSchemaDefinition(outputsSchemaDefinition: Optional<String>) = + outputsSchemaDefinition(outputsSchemaDefinition.getOrNull()) + + /** + * Sets [Builder.outputsSchemaDefinition] to an arbitrary multipart value. + * + * You should usually call [Builder.outputsSchemaDefinition] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun outputsSchemaDefinition(outputsSchemaDefinition: MultipartField<String>) = apply { + body.outputsSchemaDefinition(outputsSchemaDefinition) + } + + fun transformations(transformations: String?) = apply { + body.transformations(transformations) + } + + /** Alias for calling [Builder.transformations] with `transformations.orElse(null)`. */ + fun transformations(transformations: Optional<String>) = + transformations(transformations.getOrNull()) + + /** + * Sets [Builder.transformations] to an arbitrary multipart value. + * + * You should usually call [Builder.transformations] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun transformations(transformations: MultipartField<String>) = apply { + body.transformations(transformations) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [DatasetUploadParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .file() + * .inputKeys() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DatasetUploadParams = + DatasetUploadParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Map<String, MultipartField<*>> = + (mapOf( + "file" to _file(), + "input_keys" to _inputKeys(), + "data_type" to _dataType(), + "description" to _description(), + "input_key_mappings" to _inputKeyMappings(), + "inputs_schema_definition" to _inputsSchemaDefinition(), + "metadata_key_mappings" to _metadataKeyMappings(), + "metadata_keys" to _metadataKeys(), + "name" to _name(), + "output_key_mappings" to _outputKeyMappings(), + "output_keys" to _outputKeys(), + "outputs_schema_definition" to _outputsSchemaDefinition(), + "transformations" to _transformations(), + ) + _additionalBodyProperties().mapValues { (_, value) -> MultipartField.of(value) }) + .toImmutable() + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + private constructor( + private val file: MultipartField<InputStream>, + private val inputKeys: MultipartField<List<String>>, + private val dataType: MultipartField<DataType>, + private val description: MultipartField<String>, + private val inputKeyMappings: MultipartField<String>, + private val inputsSchemaDefinition: MultipartField<String>, + private val metadataKeyMappings: MultipartField<String>, + private val metadataKeys: MultipartField<List<String>>, + private val name: MultipartField<String>, + private val outputKeyMappings: MultipartField<String>, + private val outputKeys: MultipartField<List<String>>, + private val outputsSchemaDefinition: MultipartField<String>, + private val transformations: MultipartField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun file(): InputStream = file.value.getRequired("file") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun inputKeys(): List<String> = inputKeys.value.getRequired("input_keys") + + /** + * Enum for dataset data types. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun dataType(): Optional<DataType> = dataType.value.getOptional("data_type") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.value.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun inputKeyMappings(): Optional<String> = + inputKeyMappings.value.getOptional("input_key_mappings") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun inputsSchemaDefinition(): Optional<String> = + inputsSchemaDefinition.value.getOptional("inputs_schema_definition") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun metadataKeyMappings(): Optional<String> = + metadataKeyMappings.value.getOptional("metadata_key_mappings") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun metadataKeys(): Optional<List<String>> = metadataKeys.value.getOptional("metadata_keys") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun name(): Optional<String> = name.value.getOptional("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun outputKeyMappings(): Optional<String> = + outputKeyMappings.value.getOptional("output_key_mappings") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun outputKeys(): Optional<List<String>> = outputKeys.value.getOptional("output_keys") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun outputsSchemaDefinition(): Optional<String> = + outputsSchemaDefinition.value.getOptional("outputs_schema_definition") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun transformations(): Optional<String> = + transformations.value.getOptional("transformations") + + /** + * Returns the raw multipart value of [file]. + * + * Unlike [file], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("file") @ExcludeMissing fun _file(): MultipartField<InputStream> = file + + /** + * Returns the raw multipart value of [inputKeys]. + * + * Unlike [inputKeys], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("input_keys") + @ExcludeMissing + fun _inputKeys(): MultipartField<List<String>> = inputKeys + + /** + * Returns the raw multipart value of [dataType]. + * + * Unlike [dataType], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("data_type") + @ExcludeMissing + fun _dataType(): MultipartField<DataType> = dataType + + /** + * Returns the raw multipart value of [description]. + * + * Unlike [description], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): MultipartField<String> = description + + /** + * Returns the raw multipart value of [inputKeyMappings]. + * + * Unlike [inputKeyMappings], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("input_key_mappings") + @ExcludeMissing + fun _inputKeyMappings(): MultipartField<String> = inputKeyMappings + + /** + * Returns the raw multipart value of [inputsSchemaDefinition]. + * + * Unlike [inputsSchemaDefinition], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("inputs_schema_definition") + @ExcludeMissing + fun _inputsSchemaDefinition(): MultipartField<String> = inputsSchemaDefinition + + /** + * Returns the raw multipart value of [metadataKeyMappings]. + * + * Unlike [metadataKeyMappings], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("metadata_key_mappings") + @ExcludeMissing + fun _metadataKeyMappings(): MultipartField<String> = metadataKeyMappings + + /** + * Returns the raw multipart value of [metadataKeys]. + * + * Unlike [metadataKeys], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("metadata_keys") + @ExcludeMissing + fun _metadataKeys(): MultipartField<List<String>> = metadataKeys + + /** + * Returns the raw multipart value of [name]. + * + * Unlike [name], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): MultipartField<String> = name + + /** + * Returns the raw multipart value of [outputKeyMappings]. + * + * Unlike [outputKeyMappings], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("output_key_mappings") + @ExcludeMissing + fun _outputKeyMappings(): MultipartField<String> = outputKeyMappings + + /** + * Returns the raw multipart value of [outputKeys]. + * + * Unlike [outputKeys], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("output_keys") + @ExcludeMissing + fun _outputKeys(): MultipartField<List<String>> = outputKeys + + /** + * Returns the raw multipart value of [outputsSchemaDefinition]. + * + * Unlike [outputsSchemaDefinition], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("outputs_schema_definition") + @ExcludeMissing + fun _outputsSchemaDefinition(): MultipartField<String> = outputsSchemaDefinition + + /** + * Returns the raw multipart value of [transformations]. + * + * Unlike [transformations], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("transformations") + @ExcludeMissing + fun _transformations(): MultipartField<String> = transformations + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .file() + * .inputKeys() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var file: MultipartField<InputStream>? = null + private var inputKeys: MultipartField<MutableList<String>>? = null + private var dataType: MultipartField<DataType> = MultipartField.of(null) + private var description: MultipartField<String> = MultipartField.of(null) + private var inputKeyMappings: MultipartField<String> = MultipartField.of(null) + private var inputsSchemaDefinition: MultipartField<String> = MultipartField.of(null) + private var metadataKeyMappings: MultipartField<String> = MultipartField.of(null) + private var metadataKeys: MultipartField<MutableList<String>>? = null + private var name: MultipartField<String> = MultipartField.of(null) + private var outputKeyMappings: MultipartField<String> = MultipartField.of(null) + private var outputKeys: MultipartField<MutableList<String>>? = null + private var outputsSchemaDefinition: MultipartField<String> = MultipartField.of(null) + private var transformations: MultipartField<String> = MultipartField.of(null) + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + file = body.file + inputKeys = body.inputKeys.map { it.toMutableList() } + dataType = body.dataType + description = body.description + inputKeyMappings = body.inputKeyMappings + inputsSchemaDefinition = body.inputsSchemaDefinition + metadataKeyMappings = body.metadataKeyMappings + metadataKeys = body.metadataKeys.map { it.toMutableList() } + name = body.name + outputKeyMappings = body.outputKeyMappings + outputKeys = body.outputKeys.map { it.toMutableList() } + outputsSchemaDefinition = body.outputsSchemaDefinition + transformations = body.transformations + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun file(file: InputStream) = file(MultipartField.of(file)) + + /** + * Sets [Builder.file] to an arbitrary multipart value. + * + * You should usually call [Builder.file] with a well-typed [InputStream] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun file(file: MultipartField<InputStream>) = apply { this.file = file } + + fun file(file: ByteArray) = file(file.inputStream()) + + fun file(path: Path) = + file( + MultipartField.builder<InputStream>() + .value(path.inputStream()) + .filename(path.name) + .build() + ) + + fun inputKeys(inputKeys: List<String>) = inputKeys(MultipartField.of(inputKeys)) + + /** + * Sets [Builder.inputKeys] to an arbitrary multipart value. + * + * You should usually call [Builder.inputKeys] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inputKeys(inputKeys: MultipartField<List<String>>) = apply { + this.inputKeys = inputKeys.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [inputKeys]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addInputKey(inputKey: String) = apply { + inputKeys = + (inputKeys ?: MultipartField.of(mutableListOf())).also { + checkKnown("inputKeys", it).add(inputKey) + } + } + + /** Enum for dataset data types. */ + fun dataType(dataType: DataType) = dataType(MultipartField.of(dataType)) + + /** + * Sets [Builder.dataType] to an arbitrary multipart value. + * + * You should usually call [Builder.dataType] with a well-typed [DataType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dataType(dataType: MultipartField<DataType>) = apply { this.dataType = dataType } + + fun description(description: String?) = description(MultipartField.of(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary multipart value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: MultipartField<String>) = apply { + this.description = description + } + + fun inputKeyMappings(inputKeyMappings: String?) = + inputKeyMappings(MultipartField.of(inputKeyMappings)) + + /** + * Alias for calling [Builder.inputKeyMappings] with `inputKeyMappings.orElse(null)`. + */ + fun inputKeyMappings(inputKeyMappings: Optional<String>) = + inputKeyMappings(inputKeyMappings.getOrNull()) + + /** + * Sets [Builder.inputKeyMappings] to an arbitrary multipart value. + * + * You should usually call [Builder.inputKeyMappings] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inputKeyMappings(inputKeyMappings: MultipartField<String>) = apply { + this.inputKeyMappings = inputKeyMappings + } + + fun inputsSchemaDefinition(inputsSchemaDefinition: String?) = + inputsSchemaDefinition(MultipartField.of(inputsSchemaDefinition)) + + /** + * Alias for calling [Builder.inputsSchemaDefinition] with + * `inputsSchemaDefinition.orElse(null)`. + */ + fun inputsSchemaDefinition(inputsSchemaDefinition: Optional<String>) = + inputsSchemaDefinition(inputsSchemaDefinition.getOrNull()) + + /** + * Sets [Builder.inputsSchemaDefinition] to an arbitrary multipart value. + * + * You should usually call [Builder.inputsSchemaDefinition] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun inputsSchemaDefinition(inputsSchemaDefinition: MultipartField<String>) = apply { + this.inputsSchemaDefinition = inputsSchemaDefinition + } + + fun metadataKeyMappings(metadataKeyMappings: String?) = + metadataKeyMappings(MultipartField.of(metadataKeyMappings)) + + /** + * Alias for calling [Builder.metadataKeyMappings] with + * `metadataKeyMappings.orElse(null)`. + */ + fun metadataKeyMappings(metadataKeyMappings: Optional<String>) = + metadataKeyMappings(metadataKeyMappings.getOrNull()) + + /** + * Sets [Builder.metadataKeyMappings] to an arbitrary multipart value. + * + * You should usually call [Builder.metadataKeyMappings] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadataKeyMappings(metadataKeyMappings: MultipartField<String>) = apply { + this.metadataKeyMappings = metadataKeyMappings + } + + fun metadataKeys(metadataKeys: List<String>) = + metadataKeys(MultipartField.of(metadataKeys)) + + /** + * Sets [Builder.metadataKeys] to an arbitrary multipart value. + * + * You should usually call [Builder.metadataKeys] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadataKeys(metadataKeys: MultipartField<List<String>>) = apply { + this.metadataKeys = metadataKeys.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [metadataKeys]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMetadataKey(metadataKey: String) = apply { + metadataKeys = + (metadataKeys ?: MultipartField.of(mutableListOf())).also { + checkKnown("metadataKeys", it).add(metadataKey) + } + } + + fun name(name: String?) = name(MultipartField.of(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional<String>) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary multipart value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: MultipartField<String>) = apply { this.name = name } + + fun outputKeyMappings(outputKeyMappings: String?) = + outputKeyMappings(MultipartField.of(outputKeyMappings)) + + /** + * Alias for calling [Builder.outputKeyMappings] with `outputKeyMappings.orElse(null)`. + */ + fun outputKeyMappings(outputKeyMappings: Optional<String>) = + outputKeyMappings(outputKeyMappings.getOrNull()) + + /** + * Sets [Builder.outputKeyMappings] to an arbitrary multipart value. + * + * You should usually call [Builder.outputKeyMappings] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun outputKeyMappings(outputKeyMappings: MultipartField<String>) = apply { + this.outputKeyMappings = outputKeyMappings + } + + fun outputKeys(outputKeys: List<String>) = outputKeys(MultipartField.of(outputKeys)) + + /** + * Sets [Builder.outputKeys] to an arbitrary multipart value. + * + * You should usually call [Builder.outputKeys] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun outputKeys(outputKeys: MultipartField<List<String>>) = apply { + this.outputKeys = outputKeys.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [outputKeys]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addOutputKey(outputKey: String) = apply { + outputKeys = + (outputKeys ?: MultipartField.of(mutableListOf())).also { + checkKnown("outputKeys", it).add(outputKey) + } + } + + fun outputsSchemaDefinition(outputsSchemaDefinition: String?) = + outputsSchemaDefinition(MultipartField.of(outputsSchemaDefinition)) + + /** + * Alias for calling [Builder.outputsSchemaDefinition] with + * `outputsSchemaDefinition.orElse(null)`. + */ + fun outputsSchemaDefinition(outputsSchemaDefinition: Optional<String>) = + outputsSchemaDefinition(outputsSchemaDefinition.getOrNull()) + + /** + * Sets [Builder.outputsSchemaDefinition] to an arbitrary multipart value. + * + * You should usually call [Builder.outputsSchemaDefinition] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun outputsSchemaDefinition(outputsSchemaDefinition: MultipartField<String>) = apply { + this.outputsSchemaDefinition = outputsSchemaDefinition + } + + fun transformations(transformations: String?) = + transformations(MultipartField.of(transformations)) + + /** Alias for calling [Builder.transformations] with `transformations.orElse(null)`. */ + fun transformations(transformations: Optional<String>) = + transformations(transformations.getOrNull()) + + /** + * Sets [Builder.transformations] to an arbitrary multipart value. + * + * You should usually call [Builder.transformations] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun transformations(transformations: MultipartField<String>) = apply { + this.transformations = transformations + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .file() + * .inputKeys() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("file", file), + checkRequired("inputKeys", inputKeys).map { it.toImmutable() }, + dataType, + description, + inputKeyMappings, + inputsSchemaDefinition, + metadataKeyMappings, + (metadataKeys ?: MultipartField.of(null)).map { it.toImmutable() }, + name, + outputKeyMappings, + (outputKeys ?: MultipartField.of(null)).map { it.toImmutable() }, + outputsSchemaDefinition, + transformations, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + file() + inputKeys() + dataType().ifPresent { it.validate() } + description() + inputKeyMappings() + inputsSchemaDefinition() + metadataKeyMappings() + metadataKeys() + name() + outputKeyMappings() + outputKeys() + outputsSchemaDefinition() + transformations() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + file == other.file && + inputKeys == other.inputKeys && + dataType == other.dataType && + description == other.description && + inputKeyMappings == other.inputKeyMappings && + inputsSchemaDefinition == other.inputsSchemaDefinition && + metadataKeyMappings == other.metadataKeyMappings && + metadataKeys == other.metadataKeys && + name == other.name && + outputKeyMappings == other.outputKeyMappings && + outputKeys == other.outputKeys && + outputsSchemaDefinition == other.outputsSchemaDefinition && + transformations == other.transformations && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + file, + inputKeys, + dataType, + description, + inputKeyMappings, + inputsSchemaDefinition, + metadataKeyMappings, + metadataKeys, + name, + outputKeyMappings, + outputKeys, + outputsSchemaDefinition, + transformations, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{file=$file, inputKeys=$inputKeys, dataType=$dataType, description=$description, inputKeyMappings=$inputKeyMappings, inputsSchemaDefinition=$inputsSchemaDefinition, metadataKeyMappings=$metadataKeyMappings, metadataKeys=$metadataKeys, name=$name, outputKeyMappings=$outputKeyMappings, outputKeys=$outputKeys, outputsSchemaDefinition=$outputsSchemaDefinition, transformations=$transformations, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetUploadParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "DatasetUploadParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetVersion.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetVersion.kt new file mode 100644 index 00000000..fea06947 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetVersion.kt @@ -0,0 +1,224 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Dataset version schema. */ +class DatasetVersion +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val asOf: JsonField<OffsetDateTime>, + private val tags: JsonField<List<String>>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("as_of") @ExcludeMissing asOf: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing tags: JsonField<List<String>> = JsonMissing.of(), + ) : this(asOf, tags, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun asOf(): OffsetDateTime = asOf.getRequired("as_of") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tags(): Optional<List<String>> = tags.getOptional("tags") + + /** + * Returns the raw JSON value of [asOf]. + * + * Unlike [asOf], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("as_of") @ExcludeMissing fun _asOf(): JsonField<OffsetDateTime> = asOf + + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField<List<String>> = tags + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DatasetVersion]. + * + * The following fields are required: + * ```java + * .asOf() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DatasetVersion]. */ + class Builder internal constructor() { + + private var asOf: JsonField<OffsetDateTime>? = null + private var tags: JsonField<MutableList<String>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(datasetVersion: DatasetVersion) = apply { + asOf = datasetVersion.asOf + tags = datasetVersion.tags.map { it.toMutableList() } + additionalProperties = datasetVersion.additionalProperties.toMutableMap() + } + + fun asOf(asOf: OffsetDateTime) = asOf(JsonField.of(asOf)) + + /** + * Sets [Builder.asOf] to an arbitrary JSON value. + * + * You should usually call [Builder.asOf] with a well-typed [OffsetDateTime] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun asOf(asOf: JsonField<OffsetDateTime>) = apply { this.asOf = asOf } + + fun tags(tags: List<String>?) = tags(JsonField.ofNullable(tags)) + + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ + fun tags(tags: Optional<List<String>>) = tags(tags.getOrNull()) + + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List<String>` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tags(tags: JsonField<List<String>>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DatasetVersion]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .asOf() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DatasetVersion = + DatasetVersion( + checkRequired("asOf", asOf), + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DatasetVersion = apply { + if (validated) { + return@apply + } + + asOf() + tags() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (asOf.asKnown().isPresent) 1 else 0) + (tags.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetVersion && + asOf == other.asOf && + tags == other.tags && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(asOf, tags, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DatasetVersion{asOf=$asOf, tags=$tags, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/FeedbackCreateCoreSchema.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/FeedbackCreateCoreSchema.kt new file mode 100644 index 00000000..b23d3a0f --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/FeedbackCreateCoreSchema.kt @@ -0,0 +1,1490 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +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 com.langsmith_api.api.core.BaseDeserializer +import com.langsmith_api.api.core.BaseSerializer +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.allMaxBy +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.feedback.ApiFeedbackSource +import com.langsmith_api.api.models.api.v1.feedback.AppFeedbackSource +import com.langsmith_api.api.models.api.v1.feedback.AutoEvalFeedbackSource +import com.langsmith_api.api.models.api.v1.feedback.ModelFeedbackSource +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfig +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Schema used for creating feedback without run id or session id. */ +class FeedbackCreateCoreSchema +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val key: JsonField<String>, + private val id: JsonField<String>, + private val comment: JsonField<String>, + private val comparativeExperimentId: JsonField<String>, + private val correction: JsonField<Correction>, + private val createdAt: JsonField<OffsetDateTime>, + private val extra: JsonValue, + private val feedbackConfig: JsonField<FeedbackConfig>, + private val feedbackGroupId: JsonField<String>, + private val feedbackSource: JsonField<FeedbackSource>, + private val modifiedAt: JsonField<OffsetDateTime>, + private val score: JsonField<Score>, + private val value: JsonField<Value>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("key") @ExcludeMissing key: JsonField<String> = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("comment") @ExcludeMissing comment: JsonField<String> = JsonMissing.of(), + @JsonProperty("comparative_experiment_id") + @ExcludeMissing + comparativeExperimentId: JsonField<String> = JsonMissing.of(), + @JsonProperty("correction") + @ExcludeMissing + correction: JsonField<Correction> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("extra") @ExcludeMissing extra: JsonValue = JsonMissing.of(), + @JsonProperty("feedback_config") + @ExcludeMissing + feedbackConfig: JsonField<FeedbackConfig> = JsonMissing.of(), + @JsonProperty("feedback_group_id") + @ExcludeMissing + feedbackGroupId: JsonField<String> = JsonMissing.of(), + @JsonProperty("feedback_source") + @ExcludeMissing + feedbackSource: JsonField<FeedbackSource> = JsonMissing.of(), + @JsonProperty("modified_at") + @ExcludeMissing + modifiedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("score") @ExcludeMissing score: JsonField<Score> = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField<Value> = JsonMissing.of(), + ) : this( + key, + id, + comment, + comparativeExperimentId, + correction, + createdAt, + extra, + feedbackConfig, + feedbackGroupId, + feedbackSource, + modifiedAt, + score, + value, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun key(): String = key.getRequired("key") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun comment(): Optional<String> = comment.getOptional("comment") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun comparativeExperimentId(): Optional<String> = + comparativeExperimentId.getOptional("comparative_experiment_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun correction(): Optional<Correction> = correction.getOptional("correction") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun createdAt(): Optional<OffsetDateTime> = createdAt.getOptional("created_at") + + @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonValue = extra + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun feedbackConfig(): Optional<FeedbackConfig> = feedbackConfig.getOptional("feedback_config") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun feedbackGroupId(): Optional<String> = feedbackGroupId.getOptional("feedback_group_id") + + /** + * Feedback from the LangChainPlus App. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun feedbackSource(): Optional<FeedbackSource> = feedbackSource.getOptional("feedback_source") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun modifiedAt(): Optional<OffsetDateTime> = modifiedAt.getOptional("modified_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun score(): Optional<Score> = score.getOptional("score") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun value(): Optional<Value> = value.getOptional("value") + + /** + * Returns the raw JSON value of [key]. + * + * Unlike [key], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("key") @ExcludeMissing fun _key(): JsonField<String> = key + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [comment]. + * + * Unlike [comment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("comment") @ExcludeMissing fun _comment(): JsonField<String> = comment + + /** + * Returns the raw JSON value of [comparativeExperimentId]. + * + * Unlike [comparativeExperimentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("comparative_experiment_id") + @ExcludeMissing + fun _comparativeExperimentId(): JsonField<String> = comparativeExperimentId + + /** + * Returns the raw JSON value of [correction]. + * + * Unlike [correction], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("correction") + @ExcludeMissing + fun _correction(): JsonField<Correction> = correction + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [feedbackConfig]. + * + * Unlike [feedbackConfig], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feedback_config") + @ExcludeMissing + fun _feedbackConfig(): JsonField<FeedbackConfig> = feedbackConfig + + /** + * Returns the raw JSON value of [feedbackGroupId]. + * + * Unlike [feedbackGroupId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feedback_group_id") + @ExcludeMissing + fun _feedbackGroupId(): JsonField<String> = feedbackGroupId + + /** + * Returns the raw JSON value of [feedbackSource]. + * + * Unlike [feedbackSource], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feedback_source") + @ExcludeMissing + fun _feedbackSource(): JsonField<FeedbackSource> = feedbackSource + + /** + * Returns the raw JSON value of [modifiedAt]. + * + * Unlike [modifiedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("modified_at") + @ExcludeMissing + fun _modifiedAt(): JsonField<OffsetDateTime> = modifiedAt + + /** + * Returns the raw JSON value of [score]. + * + * Unlike [score], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("score") @ExcludeMissing fun _score(): JsonField<Score> = score + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField<Value> = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [FeedbackCreateCoreSchema]. + * + * The following fields are required: + * ```java + * .key() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackCreateCoreSchema]. */ + class Builder internal constructor() { + + private var key: JsonField<String>? = null + private var id: JsonField<String> = JsonMissing.of() + private var comment: JsonField<String> = JsonMissing.of() + private var comparativeExperimentId: JsonField<String> = JsonMissing.of() + private var correction: JsonField<Correction> = JsonMissing.of() + private var createdAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var extra: JsonValue = JsonMissing.of() + private var feedbackConfig: JsonField<FeedbackConfig> = JsonMissing.of() + private var feedbackGroupId: JsonField<String> = JsonMissing.of() + private var feedbackSource: JsonField<FeedbackSource> = JsonMissing.of() + private var modifiedAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var score: JsonField<Score> = JsonMissing.of() + private var value: JsonField<Value> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(feedbackCreateCoreSchema: FeedbackCreateCoreSchema) = apply { + key = feedbackCreateCoreSchema.key + id = feedbackCreateCoreSchema.id + comment = feedbackCreateCoreSchema.comment + comparativeExperimentId = feedbackCreateCoreSchema.comparativeExperimentId + correction = feedbackCreateCoreSchema.correction + createdAt = feedbackCreateCoreSchema.createdAt + extra = feedbackCreateCoreSchema.extra + feedbackConfig = feedbackCreateCoreSchema.feedbackConfig + feedbackGroupId = feedbackCreateCoreSchema.feedbackGroupId + feedbackSource = feedbackCreateCoreSchema.feedbackSource + modifiedAt = feedbackCreateCoreSchema.modifiedAt + score = feedbackCreateCoreSchema.score + value = feedbackCreateCoreSchema.value + additionalProperties = feedbackCreateCoreSchema.additionalProperties.toMutableMap() + } + + fun key(key: String) = key(JsonField.of(key)) + + /** + * Sets [Builder.key] to an arbitrary JSON value. + * + * You should usually call [Builder.key] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun key(key: JsonField<String>) = apply { this.key = key } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun comment(comment: String?) = comment(JsonField.ofNullable(comment)) + + /** Alias for calling [Builder.comment] with `comment.orElse(null)`. */ + fun comment(comment: Optional<String>) = comment(comment.getOrNull()) + + /** + * Sets [Builder.comment] to an arbitrary JSON value. + * + * You should usually call [Builder.comment] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun comment(comment: JsonField<String>) = apply { this.comment = comment } + + fun comparativeExperimentId(comparativeExperimentId: String?) = + comparativeExperimentId(JsonField.ofNullable(comparativeExperimentId)) + + /** + * Alias for calling [Builder.comparativeExperimentId] with + * `comparativeExperimentId.orElse(null)`. + */ + fun comparativeExperimentId(comparativeExperimentId: Optional<String>) = + comparativeExperimentId(comparativeExperimentId.getOrNull()) + + /** + * Sets [Builder.comparativeExperimentId] to an arbitrary JSON value. + * + * You should usually call [Builder.comparativeExperimentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun comparativeExperimentId(comparativeExperimentId: JsonField<String>) = apply { + this.comparativeExperimentId = comparativeExperimentId + } + + fun correction(correction: Correction?) = correction(JsonField.ofNullable(correction)) + + /** Alias for calling [Builder.correction] with `correction.orElse(null)`. */ + fun correction(correction: Optional<Correction>) = correction(correction.getOrNull()) + + /** + * Sets [Builder.correction] to an arbitrary JSON value. + * + * You should usually call [Builder.correction] with a well-typed [Correction] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun correction(correction: JsonField<Correction>) = apply { this.correction = correction } + + /** Alias for calling [correction] with `Correction.ofJsonValue(jsonValue)`. */ + fun correction(jsonValue: JsonValue) = correction(Correction.ofJsonValue(jsonValue)) + + /** Alias for calling [correction] with `Correction.ofString(string)`. */ + fun correction(string: String) = correction(Correction.ofString(string)) + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun extra(extra: JsonValue) = apply { this.extra = extra } + + fun feedbackConfig(feedbackConfig: FeedbackConfig?) = + feedbackConfig(JsonField.ofNullable(feedbackConfig)) + + /** Alias for calling [Builder.feedbackConfig] with `feedbackConfig.orElse(null)`. */ + fun feedbackConfig(feedbackConfig: Optional<FeedbackConfig>) = + feedbackConfig(feedbackConfig.getOrNull()) + + /** + * Sets [Builder.feedbackConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackConfig] with a well-typed [FeedbackConfig] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun feedbackConfig(feedbackConfig: JsonField<FeedbackConfig>) = apply { + this.feedbackConfig = feedbackConfig + } + + fun feedbackGroupId(feedbackGroupId: String?) = + feedbackGroupId(JsonField.ofNullable(feedbackGroupId)) + + /** Alias for calling [Builder.feedbackGroupId] with `feedbackGroupId.orElse(null)`. */ + fun feedbackGroupId(feedbackGroupId: Optional<String>) = + feedbackGroupId(feedbackGroupId.getOrNull()) + + /** + * Sets [Builder.feedbackGroupId] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackGroupId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun feedbackGroupId(feedbackGroupId: JsonField<String>) = apply { + this.feedbackGroupId = feedbackGroupId + } + + /** Feedback from the LangChainPlus App. */ + fun feedbackSource(feedbackSource: FeedbackSource?) = + feedbackSource(JsonField.ofNullable(feedbackSource)) + + /** Alias for calling [Builder.feedbackSource] with `feedbackSource.orElse(null)`. */ + fun feedbackSource(feedbackSource: Optional<FeedbackSource>) = + feedbackSource(feedbackSource.getOrNull()) + + /** + * Sets [Builder.feedbackSource] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackSource] with a well-typed [FeedbackSource] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun feedbackSource(feedbackSource: JsonField<FeedbackSource>) = apply { + this.feedbackSource = feedbackSource + } + + /** Alias for calling [feedbackSource] with `FeedbackSource.ofApp(app)`. */ + fun feedbackSource(app: AppFeedbackSource) = feedbackSource(FeedbackSource.ofApp(app)) + + /** Alias for calling [feedbackSource] with `FeedbackSource.ofApi(api)`. */ + fun feedbackSource(api: ApiFeedbackSource) = feedbackSource(FeedbackSource.ofApi(api)) + + /** Alias for calling [feedbackSource] with `FeedbackSource.ofModel(model)`. */ + fun feedbackSource(model: ModelFeedbackSource) = + feedbackSource(FeedbackSource.ofModel(model)) + + /** Alias for calling [feedbackSource] with `FeedbackSource.ofAutoEval(autoEval)`. */ + fun feedbackSource(autoEval: AutoEvalFeedbackSource) = + feedbackSource(FeedbackSource.ofAutoEval(autoEval)) + + fun modifiedAt(modifiedAt: OffsetDateTime) = modifiedAt(JsonField.of(modifiedAt)) + + /** + * Sets [Builder.modifiedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.modifiedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modifiedAt(modifiedAt: JsonField<OffsetDateTime>) = apply { + this.modifiedAt = modifiedAt + } + + fun score(score: Score?) = score(JsonField.ofNullable(score)) + + /** Alias for calling [Builder.score] with `score.orElse(null)`. */ + fun score(score: Optional<Score>) = score(score.getOrNull()) + + /** + * Sets [Builder.score] to an arbitrary JSON value. + * + * You should usually call [Builder.score] with a well-typed [Score] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun score(score: JsonField<Score>) = apply { this.score = score } + + /** Alias for calling [score] with `Score.ofNumber(number)`. */ + fun score(number: Double) = score(Score.ofNumber(number)) + + /** Alias for calling [score] with `Score.ofBool(bool)`. */ + fun score(bool: Boolean) = score(Score.ofBool(bool)) + + fun value(value: Value?) = value(JsonField.ofNullable(value)) + + /** Alias for calling [Builder.value] with `value.orElse(null)`. */ + fun value(value: Optional<Value>) = value(value.getOrNull()) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Value] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun value(value: JsonField<Value>) = apply { this.value = value } + + /** Alias for calling [value] with `Value.ofNumber(number)`. */ + fun value(number: Double) = value(Value.ofNumber(number)) + + /** Alias for calling [value] with `Value.ofBool(bool)`. */ + fun value(bool: Boolean) = value(Value.ofBool(bool)) + + /** Alias for calling [value] with `Value.ofString(string)`. */ + fun value(string: String) = value(Value.ofString(string)) + + /** Alias for calling [value] with `Value.ofJson(json)`. */ + fun value(json: JsonValue) = value(Value.ofJson(json)) + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FeedbackCreateCoreSchema]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .key() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FeedbackCreateCoreSchema = + FeedbackCreateCoreSchema( + checkRequired("key", key), + id, + comment, + comparativeExperimentId, + correction, + createdAt, + extra, + feedbackConfig, + feedbackGroupId, + feedbackSource, + modifiedAt, + score, + value, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): FeedbackCreateCoreSchema = apply { + if (validated) { + return@apply + } + + key() + id() + comment() + comparativeExperimentId() + correction().ifPresent { it.validate() } + createdAt() + feedbackConfig().ifPresent { it.validate() } + feedbackGroupId() + feedbackSource().ifPresent { it.validate() } + modifiedAt() + score().ifPresent { it.validate() } + value().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (key.asKnown().isPresent) 1 else 0) + + (if (id.asKnown().isPresent) 1 else 0) + + (if (comment.asKnown().isPresent) 1 else 0) + + (if (comparativeExperimentId.asKnown().isPresent) 1 else 0) + + (correction.asKnown().getOrNull()?.validity() ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (feedbackConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (feedbackGroupId.asKnown().isPresent) 1 else 0) + + (feedbackSource.asKnown().getOrNull()?.validity() ?: 0) + + (if (modifiedAt.asKnown().isPresent) 1 else 0) + + (score.asKnown().getOrNull()?.validity() ?: 0) + + (value.asKnown().getOrNull()?.validity() ?: 0) + + @JsonDeserialize(using = Correction.Deserializer::class) + @JsonSerialize(using = Correction.Serializer::class) + class Correction + private constructor( + private val jsonValue: JsonValue? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun jsonValue(): Optional<JsonValue> = Optional.ofNullable(jsonValue) + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun isJsonValue(): Boolean = jsonValue != null + + fun isString(): Boolean = string != null + + fun asJsonValue(): JsonValue = jsonValue.getOrThrow("jsonValue") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + jsonValue != null -> visitor.visitJsonValue(jsonValue) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Correction = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitJsonValue(jsonValue: JsonValue) {} + + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Correction && jsonValue == other.jsonValue && string == other.string + } + + override fun hashCode(): Int = Objects.hash(jsonValue, string) + + override fun toString(): String = + when { + jsonValue != null -> "Correction{jsonValue=$jsonValue}" + string != null -> "Correction{string=$string}" + _json != null -> "Correction{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Correction") + } + + companion object { + + @JvmStatic fun ofJsonValue(jsonValue: JsonValue) = Correction(jsonValue = jsonValue) + + @JvmStatic fun ofString(string: String) = Correction(string = string) + } + + /** + * An interface that defines how to map each variant of [Correction] to a value of type [T]. + */ + interface Visitor<out T> { + + fun visitJsonValue(jsonValue: JsonValue): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [Correction] to a value of type [T]. + * + * An instance of [Correction] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Correction: $json") + } + } + + internal class Deserializer : BaseDeserializer<Correction>(Correction::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Correction { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<String>())?.let { + Correction(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<JsonValue>())?.let { + Correction(jsonValue = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants. + 0 -> Correction(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Correction>(Correction::class) { + + override fun serialize( + value: Correction, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.jsonValue != null -> generator.writeObject(value.jsonValue) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Correction") + } + } + } + } + + /** Feedback from the LangChainPlus App. */ + @JsonDeserialize(using = FeedbackSource.Deserializer::class) + @JsonSerialize(using = FeedbackSource.Serializer::class) + class FeedbackSource + private constructor( + private val app: AppFeedbackSource? = null, + private val api: ApiFeedbackSource? = null, + private val model: ModelFeedbackSource? = null, + private val autoEval: AutoEvalFeedbackSource? = null, + private val _json: JsonValue? = null, + ) { + + /** Feedback from the LangChainPlus App. */ + fun app(): Optional<AppFeedbackSource> = Optional.ofNullable(app) + + /** API feedback source. */ + fun api(): Optional<ApiFeedbackSource> = Optional.ofNullable(api) + + /** Model feedback source. */ + fun model(): Optional<ModelFeedbackSource> = Optional.ofNullable(model) + + /** Auto eval feedback source. */ + fun autoEval(): Optional<AutoEvalFeedbackSource> = Optional.ofNullable(autoEval) + + fun isApp(): Boolean = app != null + + fun isApi(): Boolean = api != null + + fun isModel(): Boolean = model != null + + fun isAutoEval(): Boolean = autoEval != null + + /** Feedback from the LangChainPlus App. */ + fun asApp(): AppFeedbackSource = app.getOrThrow("app") + + /** API feedback source. */ + fun asApi(): ApiFeedbackSource = api.getOrThrow("api") + + /** Model feedback source. */ + fun asModel(): ModelFeedbackSource = model.getOrThrow("model") + + /** Auto eval feedback source. */ + fun asAutoEval(): AutoEvalFeedbackSource = autoEval.getOrThrow("autoEval") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + app != null -> visitor.visitApp(app) + api != null -> visitor.visitApi(api) + model != null -> visitor.visitModel(model) + autoEval != null -> visitor.visitAutoEval(autoEval) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): FeedbackSource = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitApp(app: AppFeedbackSource) { + app.validate() + } + + override fun visitApi(api: ApiFeedbackSource) { + api.validate() + } + + override fun visitModel(model: ModelFeedbackSource) { + model.validate() + } + + override fun visitAutoEval(autoEval: AutoEvalFeedbackSource) { + autoEval.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitApp(app: AppFeedbackSource) = app.validity() + + override fun visitApi(api: ApiFeedbackSource) = api.validity() + + override fun visitModel(model: ModelFeedbackSource) = model.validity() + + override fun visitAutoEval(autoEval: AutoEvalFeedbackSource) = + autoEval.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackSource && + app == other.app && + api == other.api && + model == other.model && + autoEval == other.autoEval + } + + override fun hashCode(): Int = Objects.hash(app, api, model, autoEval) + + override fun toString(): String = + when { + app != null -> "FeedbackSource{app=$app}" + api != null -> "FeedbackSource{api=$api}" + model != null -> "FeedbackSource{model=$model}" + autoEval != null -> "FeedbackSource{autoEval=$autoEval}" + _json != null -> "FeedbackSource{_unknown=$_json}" + else -> throw IllegalStateException("Invalid FeedbackSource") + } + + companion object { + + /** Feedback from the LangChainPlus App. */ + @JvmStatic fun ofApp(app: AppFeedbackSource) = FeedbackSource(app = app) + + /** API feedback source. */ + @JvmStatic fun ofApi(api: ApiFeedbackSource) = FeedbackSource(api = api) + + /** Model feedback source. */ + @JvmStatic fun ofModel(model: ModelFeedbackSource) = FeedbackSource(model = model) + + /** Auto eval feedback source. */ + @JvmStatic + fun ofAutoEval(autoEval: AutoEvalFeedbackSource) = FeedbackSource(autoEval = autoEval) + } + + /** + * An interface that defines how to map each variant of [FeedbackSource] to a value of type + * [T]. + */ + interface Visitor<out T> { + + /** Feedback from the LangChainPlus App. */ + fun visitApp(app: AppFeedbackSource): T + + /** API feedback source. */ + fun visitApi(api: ApiFeedbackSource): T + + /** Model feedback source. */ + fun visitModel(model: ModelFeedbackSource): T + + /** Auto eval feedback source. */ + fun visitAutoEval(autoEval: AutoEvalFeedbackSource): T + + /** + * Maps an unknown variant of [FeedbackSource] to a value of type [T]. + * + * An instance of [FeedbackSource] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown FeedbackSource: $json") + } + } + + internal class Deserializer : BaseDeserializer<FeedbackSource>(FeedbackSource::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): FeedbackSource { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<AppFeedbackSource>())?.let { + FeedbackSource(app = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<ApiFeedbackSource>())?.let { + FeedbackSource(api = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<ModelFeedbackSource>())?.let { + FeedbackSource(model = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<AutoEvalFeedbackSource>())?.let { + FeedbackSource(autoEval = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> FeedbackSource(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<FeedbackSource>(FeedbackSource::class) { + + override fun serialize( + value: FeedbackSource, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.app != null -> generator.writeObject(value.app) + value.api != null -> generator.writeObject(value.api) + value.model != null -> generator.writeObject(value.model) + value.autoEval != null -> generator.writeObject(value.autoEval) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FeedbackSource") + } + } + } + } + + @JsonDeserialize(using = Score.Deserializer::class) + @JsonSerialize(using = Score.Serializer::class) + class Score + private constructor( + private val number: Double? = null, + private val bool: Boolean? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional<Double> = Optional.ofNullable(number) + + fun bool(): Optional<Boolean> = Optional.ofNullable(bool) + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Score = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Score && number == other.number && bool == other.bool + } + + override fun hashCode(): Int = Objects.hash(number, bool) + + override fun toString(): String = + when { + number != null -> "Score{number=$number}" + bool != null -> "Score{bool=$bool}" + _json != null -> "Score{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Score") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Score(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = Score(bool = bool) + } + + /** An interface that defines how to map each variant of [Score] to a value of type [T]. */ + interface Visitor<out T> { + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Maps an unknown variant of [Score] to a value of type [T]. + * + * An instance of [Score] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Score: $json") + } + } + + internal class Deserializer : BaseDeserializer<Score>(Score::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Score { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<Double>())?.let { + Score(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<Boolean>())?.let { + Score(bool = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from string). + 0 -> Score(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Score>(Score::class) { + + override fun serialize( + value: Score, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Score") + } + } + } + } + + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val number: Double? = null, + private val bool: Boolean? = null, + private val string: String? = null, + private val json: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional<Double> = Optional.ofNullable(number) + + fun bool(): Optional<Boolean> = Optional.ofNullable(bool) + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun json(): Optional<JsonValue> = Optional.ofNullable(json) + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun isString(): Boolean = string != null + + fun isJson(): Boolean = json != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun asString(): String = string.getOrThrow("string") + + fun asJson(): JsonValue = json.getOrThrow("json") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + string != null -> visitor.visitString(string) + json != null -> visitor.visitJson(json) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Value = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + + override fun visitString(string: String) {} + + override fun visitJson(json: JsonValue) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun visitString(string: String) = 1 + + override fun visitJson(json: JsonValue) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + number == other.number && + bool == other.bool && + string == other.string && + json == other.json + } + + override fun hashCode(): Int = Objects.hash(number, bool, string, json) + + override fun toString(): String = + when { + number != null -> "Value{number=$number}" + bool != null -> "Value{bool=$bool}" + string != null -> "Value{string=$string}" + json != null -> "Value{json=$json}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Value(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofJson(json: JsonValue) = Value(json = json) + } + + /** An interface that defines how to map each variant of [Value] to a value of type [T]. */ + interface Visitor<out T> { + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + fun visitString(string: String): T + + fun visitJson(json: JsonValue): T + + /** + * Maps an unknown variant of [Value] to a value of type [T]. + * + * An instance of [Value] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Value: $json") + } + } + + internal class Deserializer : BaseDeserializer<Value>(Value::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Value { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<Double>())?.let { + Value(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<Boolean>())?.let { + Value(bool = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<String>())?.let { + Value(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<JsonValue>())?.let { + Value(json = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants. + 0 -> Value(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Value>(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value.string != null -> generator.writeObject(value.string) + value.json != null -> generator.writeObject(value.json) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackCreateCoreSchema && + key == other.key && + id == other.id && + comment == other.comment && + comparativeExperimentId == other.comparativeExperimentId && + correction == other.correction && + createdAt == other.createdAt && + extra == other.extra && + feedbackConfig == other.feedbackConfig && + feedbackGroupId == other.feedbackGroupId && + feedbackSource == other.feedbackSource && + modifiedAt == other.modifiedAt && + score == other.score && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + key, + id, + comment, + comparativeExperimentId, + correction, + createdAt, + extra, + feedbackConfig, + feedbackGroupId, + feedbackSource, + modifiedAt, + score, + value, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FeedbackCreateCoreSchema{key=$key, id=$id, comment=$comment, comparativeExperimentId=$comparativeExperimentId, correction=$correction, createdAt=$createdAt, extra=$extra, feedbackConfig=$feedbackConfig, feedbackGroupId=$feedbackGroupId, feedbackSource=$feedbackSource, modifiedAt=$modifiedAt, score=$score, value=$value, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/Missing.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/Missing.kt new file mode 100644 index 00000000..b32aa730 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/Missing.kt @@ -0,0 +1,158 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class Missing +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val _missing: JsonValue, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("__missing__") @ExcludeMissing _missing: JsonValue = JsonMissing.of() + ) : this(_missing, mutableMapOf()) + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("__missing__") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("__missing__") @ExcludeMissing fun __missing(): JsonValue = _missing + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Missing]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Missing]. */ + class Builder internal constructor() { + + private var _missing: JsonValue = JsonValue.from("__missing__") + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(missing: Missing) = apply { + _missing = missing._missing + additionalProperties = missing.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("__missing__") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun _missing(_missing: JsonValue) = apply { this._missing = _missing } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Missing]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Missing = Missing(_missing, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Missing = apply { + if (validated) { + return@apply + } + + __missing().let { + if (it != JsonValue.from("__missing__")) { + throw LangsmithApiInvalidDataException("'_missing' is invalid, received $it") + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + _missing.let { if (it == JsonValue.from("__missing__")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Missing && + _missing == other._missing && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(_missing, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Missing{_missing=$_missing, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/SortByDatasetColumn.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/SortByDatasetColumn.kt new file mode 100644 index 00000000..aa60b5ba --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/SortByDatasetColumn.kt @@ -0,0 +1,162 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException + +/** Enum for available dataset columns to sort by. */ +class SortByDatasetColumn @JsonCreator private constructor(private val value: JsonField<String>) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't match + * any known member, and you want to know that value. For example, if the SDK is on an older + * version than the API, then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val NAME = of("name") + + @JvmField val CREATED_AT = of("created_at") + + @JvmField val LAST_SESSION_START_TIME = of("last_session_start_time") + + @JvmField val EXAMPLE_COUNT = of("example_count") + + @JvmField val SESSION_COUNT = of("session_count") + + @JvmField val MODIFIED_AT = of("modified_at") + + @JvmStatic fun of(value: String) = SortByDatasetColumn(JsonField.of(value)) + } + + /** An enum containing [SortByDatasetColumn]'s known values. */ + enum class Known { + NAME, + CREATED_AT, + LAST_SESSION_START_TIME, + EXAMPLE_COUNT, + SESSION_COUNT, + MODIFIED_AT, + } + + /** + * An enum containing [SortByDatasetColumn]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [SortByDatasetColumn] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the SDK + * is on an older version than the API, then the API may respond with new members that the SDK + * is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + NAME, + CREATED_AT, + LAST_SESSION_START_TIME, + EXAMPLE_COUNT, + SESSION_COUNT, + MODIFIED_AT, + /** + * An enum member indicating that [SortByDatasetColumn] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if + * the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want to + * throw for the unknown case. + */ + fun value(): Value = + when (this) { + NAME -> Value.NAME + CREATED_AT -> Value.CREATED_AT + LAST_SESSION_START_TIME -> Value.LAST_SESSION_START_TIME + EXAMPLE_COUNT -> Value.EXAMPLE_COUNT + SESSION_COUNT -> Value.SESSION_COUNT + MODIFIED_AT -> Value.MODIFIED_AT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't want + * to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + NAME -> Known.NAME + CREATED_AT -> Known.CREATED_AT + LAST_SESSION_START_TIME -> Known.LAST_SESSION_START_TIME + EXAMPLE_COUNT -> Known.EXAMPLE_COUNT + SESSION_COUNT -> Known.SESSION_COUNT + MODIFIED_AT -> Known.MODIFIED_AT + else -> throw LangsmithApiInvalidDataException("Unknown SortByDatasetColumn: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): SortByDatasetColumn = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SortByDatasetColumn && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeCreateParams.kt new file mode 100644 index 00000000..64b36119 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeCreateParams.kt @@ -0,0 +1,874 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.comparative + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create a comparative experiment. */ +class ComparativeCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun experimentIds(): List<String> = body.experimentIds() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun referenceDatasetId(): String = body.referenceDatasetId() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional<String> = body.id() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun createdAt(): Optional<OffsetDateTime> = body.createdAt() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = body.description() + + fun _extra(): JsonValue = body._extra() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun modifiedAt(): Optional<OffsetDateTime> = body.modifiedAt() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional<String> = body.name() + + /** + * Returns the raw JSON value of [experimentIds]. + * + * Unlike [experimentIds], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _experimentIds(): JsonField<List<String>> = body._experimentIds() + + /** + * Returns the raw JSON value of [referenceDatasetId]. + * + * Unlike [referenceDatasetId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _referenceDatasetId(): JsonField<String> = body._referenceDatasetId() + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _id(): JsonField<String> = body._id() + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _createdAt(): JsonField<OffsetDateTime> = body._createdAt() + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _description(): JsonField<String> = body._description() + + /** + * Returns the raw JSON value of [modifiedAt]. + * + * Unlike [modifiedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _modifiedAt(): JsonField<OffsetDateTime> = body._modifiedAt() + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _name(): JsonField<String> = body._name() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ComparativeCreateParams]. + * + * The following fields are required: + * ```java + * .experimentIds() + * .referenceDatasetId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ComparativeCreateParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(comparativeCreateParams: ComparativeCreateParams) = apply { + body = comparativeCreateParams.body.toBuilder() + additionalHeaders = comparativeCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = comparativeCreateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [experimentIds] + * - [referenceDatasetId] + * - [id] + * - [createdAt] + * - [description] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun experimentIds(experimentIds: List<String>) = apply { body.experimentIds(experimentIds) } + + /** + * Sets [Builder.experimentIds] to an arbitrary JSON value. + * + * You should usually call [Builder.experimentIds] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun experimentIds(experimentIds: JsonField<List<String>>) = apply { + body.experimentIds(experimentIds) + } + + /** + * Adds a single [String] to [experimentIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExperimentId(experimentId: String) = apply { body.addExperimentId(experimentId) } + + fun referenceDatasetId(referenceDatasetId: String) = apply { + body.referenceDatasetId(referenceDatasetId) + } + + /** + * Sets [Builder.referenceDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceDatasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun referenceDatasetId(referenceDatasetId: JsonField<String>) = apply { + body.referenceDatasetId(referenceDatasetId) + } + + fun id(id: String) = apply { body.id(id) } + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { body.id(id) } + + fun createdAt(createdAt: OffsetDateTime) = apply { body.createdAt(createdAt) } + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { body.createdAt(createdAt) } + + fun description(description: String?) = apply { body.description(description) } + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { body.description(description) } + + fun extra(extra: JsonValue) = apply { body.extra(extra) } + + fun modifiedAt(modifiedAt: OffsetDateTime) = apply { body.modifiedAt(modifiedAt) } + + /** + * Sets [Builder.modifiedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.modifiedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modifiedAt(modifiedAt: JsonField<OffsetDateTime>) = apply { + body.modifiedAt(modifiedAt) + } + + fun name(name: String?) = apply { body.name(name) } + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional<String>) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { body.name(name) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ComparativeCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .experimentIds() + * .referenceDatasetId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ComparativeCreateParams = + ComparativeCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Create class for ComparativeExperiment. */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val experimentIds: JsonField<List<String>>, + private val referenceDatasetId: JsonField<String>, + private val id: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val description: JsonField<String>, + private val extra: JsonValue, + private val modifiedAt: JsonField<OffsetDateTime>, + private val name: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("experiment_ids") + @ExcludeMissing + experimentIds: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("reference_dataset_id") + @ExcludeMissing + referenceDatasetId: JsonField<String> = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("extra") @ExcludeMissing extra: JsonValue = JsonMissing.of(), + @JsonProperty("modified_at") + @ExcludeMissing + modifiedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + ) : this( + experimentIds, + referenceDatasetId, + id, + createdAt, + description, + extra, + modifiedAt, + name, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun experimentIds(): List<String> = experimentIds.getRequired("experiment_ids") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun referenceDatasetId(): String = referenceDatasetId.getRequired("reference_dataset_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun createdAt(): Optional<OffsetDateTime> = createdAt.getOptional("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonValue = extra + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun modifiedAt(): Optional<OffsetDateTime> = modifiedAt.getOptional("modified_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun name(): Optional<String> = name.getOptional("name") + + /** + * Returns the raw JSON value of [experimentIds]. + * + * Unlike [experimentIds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("experiment_ids") + @ExcludeMissing + fun _experimentIds(): JsonField<List<String>> = experimentIds + + /** + * Returns the raw JSON value of [referenceDatasetId]. + * + * Unlike [referenceDatasetId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_dataset_id") + @ExcludeMissing + fun _referenceDatasetId(): JsonField<String> = referenceDatasetId + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [modifiedAt]. + * + * Unlike [modifiedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("modified_at") + @ExcludeMissing + fun _modifiedAt(): JsonField<OffsetDateTime> = modifiedAt + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .experimentIds() + * .referenceDatasetId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var experimentIds: JsonField<MutableList<String>>? = null + private var referenceDatasetId: JsonField<String>? = null + private var id: JsonField<String> = JsonMissing.of() + private var createdAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var description: JsonField<String> = JsonMissing.of() + private var extra: JsonValue = JsonMissing.of() + private var modifiedAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var name: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + experimentIds = body.experimentIds.map { it.toMutableList() } + referenceDatasetId = body.referenceDatasetId + id = body.id + createdAt = body.createdAt + description = body.description + extra = body.extra + modifiedAt = body.modifiedAt + name = body.name + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun experimentIds(experimentIds: List<String>) = + experimentIds(JsonField.of(experimentIds)) + + /** + * Sets [Builder.experimentIds] to an arbitrary JSON value. + * + * You should usually call [Builder.experimentIds] with a well-typed `List<String>` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun experimentIds(experimentIds: JsonField<List<String>>) = apply { + this.experimentIds = experimentIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [experimentIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExperimentId(experimentId: String) = apply { + experimentIds = + (experimentIds ?: JsonField.of(mutableListOf())).also { + checkKnown("experimentIds", it).add(experimentId) + } + } + + fun referenceDatasetId(referenceDatasetId: String) = + referenceDatasetId(JsonField.of(referenceDatasetId)) + + /** + * Sets [Builder.referenceDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceDatasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun referenceDatasetId(referenceDatasetId: JsonField<String>) = apply { + this.referenceDatasetId = referenceDatasetId + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { + this.createdAt = createdAt + } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField<String>) = apply { + this.description = description + } + + fun extra(extra: JsonValue) = apply { this.extra = extra } + + fun modifiedAt(modifiedAt: OffsetDateTime) = modifiedAt(JsonField.of(modifiedAt)) + + /** + * Sets [Builder.modifiedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.modifiedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modifiedAt(modifiedAt: JsonField<OffsetDateTime>) = apply { + this.modifiedAt = modifiedAt + } + + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional<String>) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .experimentIds() + * .referenceDatasetId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("experimentIds", experimentIds).map { it.toImmutable() }, + checkRequired("referenceDatasetId", referenceDatasetId), + id, + createdAt, + description, + extra, + modifiedAt, + name, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + experimentIds() + referenceDatasetId() + id() + createdAt() + description() + modifiedAt() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (experimentIds.asKnown().getOrNull()?.size ?: 0) + + (if (referenceDatasetId.asKnown().isPresent) 1 else 0) + + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (modifiedAt.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + experimentIds == other.experimentIds && + referenceDatasetId == other.referenceDatasetId && + id == other.id && + createdAt == other.createdAt && + description == other.description && + extra == other.extra && + modifiedAt == other.modifiedAt && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + experimentIds, + referenceDatasetId, + id, + createdAt, + description, + extra, + modifiedAt, + name, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{experimentIds=$experimentIds, referenceDatasetId=$referenceDatasetId, id=$id, createdAt=$createdAt, description=$description, extra=$extra, modifiedAt=$modifiedAt, name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComparativeCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ComparativeCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeCreateResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeCreateResponse.kt new file mode 100644 index 00000000..2e7c7e93 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeCreateResponse.kt @@ -0,0 +1,432 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.comparative + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** ComparativeExperiment schema. */ +class ComparativeCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val modifiedAt: JsonField<OffsetDateTime>, + private val referenceDatasetId: JsonField<String>, + private val tenantId: JsonField<String>, + private val description: JsonField<String>, + private val extra: JsonValue, + private val name: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("modified_at") + @ExcludeMissing + modifiedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("reference_dataset_id") + @ExcludeMissing + referenceDatasetId: JsonField<String> = JsonMissing.of(), + @JsonProperty("tenant_id") @ExcludeMissing tenantId: JsonField<String> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("extra") @ExcludeMissing extra: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + ) : this( + id, + createdAt, + modifiedAt, + referenceDatasetId, + tenantId, + description, + extra, + name, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun modifiedAt(): OffsetDateTime = modifiedAt.getRequired("modified_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun referenceDatasetId(): String = referenceDatasetId.getRequired("reference_dataset_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tenantId(): String = tenantId.getRequired("tenant_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonValue = extra + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional<String> = name.getOptional("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [modifiedAt]. + * + * Unlike [modifiedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("modified_at") + @ExcludeMissing + fun _modifiedAt(): JsonField<OffsetDateTime> = modifiedAt + + /** + * Returns the raw JSON value of [referenceDatasetId]. + * + * Unlike [referenceDatasetId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reference_dataset_id") + @ExcludeMissing + fun _referenceDatasetId(): JsonField<String> = referenceDatasetId + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_id") @ExcludeMissing fun _tenantId(): JsonField<String> = tenantId + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ComparativeCreateResponse]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .modifiedAt() + * .referenceDatasetId() + * .tenantId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ComparativeCreateResponse]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var createdAt: JsonField<OffsetDateTime>? = null + private var modifiedAt: JsonField<OffsetDateTime>? = null + private var referenceDatasetId: JsonField<String>? = null + private var tenantId: JsonField<String>? = null + private var description: JsonField<String> = JsonMissing.of() + private var extra: JsonValue = JsonMissing.of() + private var name: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(comparativeCreateResponse: ComparativeCreateResponse) = apply { + id = comparativeCreateResponse.id + createdAt = comparativeCreateResponse.createdAt + modifiedAt = comparativeCreateResponse.modifiedAt + referenceDatasetId = comparativeCreateResponse.referenceDatasetId + tenantId = comparativeCreateResponse.tenantId + description = comparativeCreateResponse.description + extra = comparativeCreateResponse.extra + name = comparativeCreateResponse.name + additionalProperties = comparativeCreateResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun modifiedAt(modifiedAt: OffsetDateTime) = modifiedAt(JsonField.of(modifiedAt)) + + /** + * Sets [Builder.modifiedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.modifiedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modifiedAt(modifiedAt: JsonField<OffsetDateTime>) = apply { + this.modifiedAt = modifiedAt + } + + fun referenceDatasetId(referenceDatasetId: String) = + referenceDatasetId(JsonField.of(referenceDatasetId)) + + /** + * Sets [Builder.referenceDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceDatasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun referenceDatasetId(referenceDatasetId: JsonField<String>) = apply { + this.referenceDatasetId = referenceDatasetId + } + + fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tenantId(tenantId: JsonField<String>) = apply { this.tenantId = tenantId } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { this.description = description } + + fun extra(extra: JsonValue) = apply { this.extra = extra } + + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional<String>) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ComparativeCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .modifiedAt() + * .referenceDatasetId() + * .tenantId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ComparativeCreateResponse = + ComparativeCreateResponse( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("modifiedAt", modifiedAt), + checkRequired("referenceDatasetId", referenceDatasetId), + checkRequired("tenantId", tenantId), + description, + extra, + name, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ComparativeCreateResponse = apply { + if (validated) { + return@apply + } + + id() + createdAt() + modifiedAt() + referenceDatasetId() + tenantId() + description() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (modifiedAt.asKnown().isPresent) 1 else 0) + + (if (referenceDatasetId.asKnown().isPresent) 1 else 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComparativeCreateResponse && + id == other.id && + createdAt == other.createdAt && + modifiedAt == other.modifiedAt && + referenceDatasetId == other.referenceDatasetId && + tenantId == other.tenantId && + description == other.description && + extra == other.extra && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + createdAt, + modifiedAt, + referenceDatasetId, + tenantId, + description, + extra, + name, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ComparativeCreateResponse{id=$id, createdAt=$createdAt, modifiedAt=$modifiedAt, referenceDatasetId=$referenceDatasetId, tenantId=$tenantId, description=$description, extra=$extra, name=$name, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeDeleteParams.kt new file mode 100644 index 00000000..70ea01de --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeDeleteParams.kt @@ -0,0 +1,241 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.comparative + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete a specific comparative experiment. */ +class ComparativeDeleteParams +private constructor( + private val comparativeExperimentId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun comparativeExperimentId(): Optional<String> = Optional.ofNullable(comparativeExperimentId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ComparativeDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ComparativeDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ComparativeDeleteParams]. */ + class Builder internal constructor() { + + private var comparativeExperimentId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(comparativeDeleteParams: ComparativeDeleteParams) = apply { + comparativeExperimentId = comparativeDeleteParams.comparativeExperimentId + additionalHeaders = comparativeDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = comparativeDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + comparativeDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun comparativeExperimentId(comparativeExperimentId: String?) = apply { + this.comparativeExperimentId = comparativeExperimentId + } + + /** + * Alias for calling [Builder.comparativeExperimentId] with + * `comparativeExperimentId.orElse(null)`. + */ + fun comparativeExperimentId(comparativeExperimentId: Optional<String>) = + comparativeExperimentId(comparativeExperimentId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [ComparativeDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ComparativeDeleteParams = + ComparativeDeleteParams( + comparativeExperimentId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> comparativeExperimentId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComparativeDeleteParams && + comparativeExperimentId == other.comparativeExperimentId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + comparativeExperimentId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "ComparativeDeleteParams{comparativeExperimentId=$comparativeExperimentId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeDeleteResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeDeleteResponse.kt new file mode 100644 index 00000000..d3995a43 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeDeleteResponse.kt @@ -0,0 +1,118 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.comparative + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class ComparativeDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ComparativeDeleteResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ComparativeDeleteResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(comparativeDeleteResponse: ComparativeDeleteResponse) = apply { + additionalProperties = comparativeDeleteResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ComparativeDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ComparativeDeleteResponse = + ComparativeDeleteResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): ComparativeDeleteResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComparativeDeleteResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ComparativeDeleteResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeListParams.kt new file mode 100644 index 00000000..eb693cfd --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeListParams.kt @@ -0,0 +1,332 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.comparative + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get all comparative experiments for a given dataset. */ +class ComparativeListParams +private constructor( + private val datasetId: String?, + private val id: List<String>?, + private val limit: Long?, + private val name: String?, + private val nameContains: String?, + private val offset: Long?, + private val sortBy: SortByComparativeExperimentColumn?, + private val sortByDesc: Boolean?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun datasetId(): Optional<String> = Optional.ofNullable(datasetId) + + fun id(): Optional<List<String>> = Optional.ofNullable(id) + + fun limit(): Optional<Long> = Optional.ofNullable(limit) + + fun name(): Optional<String> = Optional.ofNullable(name) + + fun nameContains(): Optional<String> = Optional.ofNullable(nameContains) + + fun offset(): Optional<Long> = Optional.ofNullable(offset) + + /** Enum for available comparative experiment columns to sort by. */ + fun sortBy(): Optional<SortByComparativeExperimentColumn> = Optional.ofNullable(sortBy) + + fun sortByDesc(): Optional<Boolean> = Optional.ofNullable(sortByDesc) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ComparativeListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ComparativeListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ComparativeListParams]. */ + class Builder internal constructor() { + + private var datasetId: String? = null + private var id: MutableList<String>? = null + private var limit: Long? = null + private var name: String? = null + private var nameContains: String? = null + private var offset: Long? = null + private var sortBy: SortByComparativeExperimentColumn? = null + private var sortByDesc: Boolean? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(comparativeListParams: ComparativeListParams) = apply { + datasetId = comparativeListParams.datasetId + id = comparativeListParams.id?.toMutableList() + limit = comparativeListParams.limit + name = comparativeListParams.name + nameContains = comparativeListParams.nameContains + offset = comparativeListParams.offset + sortBy = comparativeListParams.sortBy + sortByDesc = comparativeListParams.sortByDesc + additionalHeaders = comparativeListParams.additionalHeaders.toBuilder() + additionalQueryParams = comparativeListParams.additionalQueryParams.toBuilder() + } + + fun datasetId(datasetId: String?) = apply { this.datasetId = datasetId } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + fun id(id: List<String>?) = apply { this.id = id?.toMutableList() } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<List<String>>) = id(id.getOrNull()) + + /** + * Adds a single [String] to [Builder.id]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addId(id: String) = apply { this.id = (this.id ?: mutableListOf()).apply { add(id) } } + + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional<Long>) = limit(limit.getOrNull()) + + fun name(name: String?) = apply { this.name = name } + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional<String>) = name(name.getOrNull()) + + fun nameContains(nameContains: String?) = apply { this.nameContains = nameContains } + + /** Alias for calling [Builder.nameContains] with `nameContains.orElse(null)`. */ + fun nameContains(nameContains: Optional<String>) = nameContains(nameContains.getOrNull()) + + fun offset(offset: Long?) = apply { this.offset = offset } + + /** + * Alias for [Builder.offset]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun offset(offset: Long) = offset(offset as Long?) + + /** Alias for calling [Builder.offset] with `offset.orElse(null)`. */ + fun offset(offset: Optional<Long>) = offset(offset.getOrNull()) + + /** Enum for available comparative experiment columns to sort by. */ + fun sortBy(sortBy: SortByComparativeExperimentColumn?) = apply { this.sortBy = sortBy } + + /** Alias for calling [Builder.sortBy] with `sortBy.orElse(null)`. */ + fun sortBy(sortBy: Optional<SortByComparativeExperimentColumn>) = sortBy(sortBy.getOrNull()) + + fun sortByDesc(sortByDesc: Boolean?) = apply { this.sortByDesc = sortByDesc } + + /** + * Alias for [Builder.sortByDesc]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun sortByDesc(sortByDesc: Boolean) = sortByDesc(sortByDesc as Boolean?) + + /** Alias for calling [Builder.sortByDesc] with `sortByDesc.orElse(null)`. */ + fun sortByDesc(sortByDesc: Optional<Boolean>) = sortByDesc(sortByDesc.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ComparativeListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ComparativeListParams = + ComparativeListParams( + datasetId, + id?.toImmutable(), + limit, + name, + nameContains, + offset, + sortBy, + sortByDesc, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> datasetId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + id?.let { put("id", it.joinToString(",")) } + limit?.let { put("limit", it.toString()) } + name?.let { put("name", it) } + nameContains?.let { put("name_contains", it) } + offset?.let { put("offset", it.toString()) } + sortBy?.let { put("sort_by", it.toString()) } + sortByDesc?.let { put("sort_by_desc", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComparativeListParams && + datasetId == other.datasetId && + id == other.id && + limit == other.limit && + name == other.name && + nameContains == other.nameContains && + offset == other.offset && + sortBy == other.sortBy && + sortByDesc == other.sortByDesc && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + datasetId, + id, + limit, + name, + nameContains, + offset, + sortBy, + sortByDesc, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "ComparativeListParams{datasetId=$datasetId, id=$id, limit=$limit, name=$name, nameContains=$nameContains, offset=$offset, sortBy=$sortBy, sortByDesc=$sortByDesc, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeListResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeListResponse.kt new file mode 100644 index 00000000..9fdcda11 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeListResponse.kt @@ -0,0 +1,502 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.comparative + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** ComparativeExperiment schema. */ +class ComparativeListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val experimentsInfo: JsonField<List<SimpleExperimentInfo>>, + private val modifiedAt: JsonField<OffsetDateTime>, + private val referenceDatasetId: JsonField<String>, + private val tenantId: JsonField<String>, + private val description: JsonField<String>, + private val extra: JsonValue, + private val feedbackStats: JsonValue, + private val name: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("experiments_info") + @ExcludeMissing + experimentsInfo: JsonField<List<SimpleExperimentInfo>> = JsonMissing.of(), + @JsonProperty("modified_at") + @ExcludeMissing + modifiedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("reference_dataset_id") + @ExcludeMissing + referenceDatasetId: JsonField<String> = JsonMissing.of(), + @JsonProperty("tenant_id") @ExcludeMissing tenantId: JsonField<String> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("extra") @ExcludeMissing extra: JsonValue = JsonMissing.of(), + @JsonProperty("feedback_stats") @ExcludeMissing feedbackStats: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + ) : this( + id, + createdAt, + experimentsInfo, + modifiedAt, + referenceDatasetId, + tenantId, + description, + extra, + feedbackStats, + name, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun experimentsInfo(): List<SimpleExperimentInfo> = + experimentsInfo.getRequired("experiments_info") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun modifiedAt(): OffsetDateTime = modifiedAt.getRequired("modified_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun referenceDatasetId(): String = referenceDatasetId.getRequired("reference_dataset_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tenantId(): String = tenantId.getRequired("tenant_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonValue = extra + + @JsonProperty("feedback_stats") @ExcludeMissing fun _feedbackStats(): JsonValue = feedbackStats + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional<String> = name.getOptional("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [experimentsInfo]. + * + * Unlike [experimentsInfo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("experiments_info") + @ExcludeMissing + fun _experimentsInfo(): JsonField<List<SimpleExperimentInfo>> = experimentsInfo + + /** + * Returns the raw JSON value of [modifiedAt]. + * + * Unlike [modifiedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("modified_at") + @ExcludeMissing + fun _modifiedAt(): JsonField<OffsetDateTime> = modifiedAt + + /** + * Returns the raw JSON value of [referenceDatasetId]. + * + * Unlike [referenceDatasetId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reference_dataset_id") + @ExcludeMissing + fun _referenceDatasetId(): JsonField<String> = referenceDatasetId + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_id") @ExcludeMissing fun _tenantId(): JsonField<String> = tenantId + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ComparativeListResponse]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .experimentsInfo() + * .modifiedAt() + * .referenceDatasetId() + * .tenantId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ComparativeListResponse]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var createdAt: JsonField<OffsetDateTime>? = null + private var experimentsInfo: JsonField<MutableList<SimpleExperimentInfo>>? = null + private var modifiedAt: JsonField<OffsetDateTime>? = null + private var referenceDatasetId: JsonField<String>? = null + private var tenantId: JsonField<String>? = null + private var description: JsonField<String> = JsonMissing.of() + private var extra: JsonValue = JsonMissing.of() + private var feedbackStats: JsonValue = JsonMissing.of() + private var name: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(comparativeListResponse: ComparativeListResponse) = apply { + id = comparativeListResponse.id + createdAt = comparativeListResponse.createdAt + experimentsInfo = comparativeListResponse.experimentsInfo.map { it.toMutableList() } + modifiedAt = comparativeListResponse.modifiedAt + referenceDatasetId = comparativeListResponse.referenceDatasetId + tenantId = comparativeListResponse.tenantId + description = comparativeListResponse.description + extra = comparativeListResponse.extra + feedbackStats = comparativeListResponse.feedbackStats + name = comparativeListResponse.name + additionalProperties = comparativeListResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun experimentsInfo(experimentsInfo: List<SimpleExperimentInfo>) = + experimentsInfo(JsonField.of(experimentsInfo)) + + /** + * Sets [Builder.experimentsInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.experimentsInfo] with a well-typed + * `List<SimpleExperimentInfo>` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun experimentsInfo(experimentsInfo: JsonField<List<SimpleExperimentInfo>>) = apply { + this.experimentsInfo = experimentsInfo.map { it.toMutableList() } + } + + /** + * Adds a single [SimpleExperimentInfo] to [Builder.experimentsInfo]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExperimentsInfo(experimentsInfo: SimpleExperimentInfo) = apply { + this.experimentsInfo = + (this.experimentsInfo ?: JsonField.of(mutableListOf())).also { + checkKnown("experimentsInfo", it).add(experimentsInfo) + } + } + + fun modifiedAt(modifiedAt: OffsetDateTime) = modifiedAt(JsonField.of(modifiedAt)) + + /** + * Sets [Builder.modifiedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.modifiedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modifiedAt(modifiedAt: JsonField<OffsetDateTime>) = apply { + this.modifiedAt = modifiedAt + } + + fun referenceDatasetId(referenceDatasetId: String) = + referenceDatasetId(JsonField.of(referenceDatasetId)) + + /** + * Sets [Builder.referenceDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceDatasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun referenceDatasetId(referenceDatasetId: JsonField<String>) = apply { + this.referenceDatasetId = referenceDatasetId + } + + fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tenantId(tenantId: JsonField<String>) = apply { this.tenantId = tenantId } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { this.description = description } + + fun extra(extra: JsonValue) = apply { this.extra = extra } + + fun feedbackStats(feedbackStats: JsonValue) = apply { this.feedbackStats = feedbackStats } + + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional<String>) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ComparativeListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .experimentsInfo() + * .modifiedAt() + * .referenceDatasetId() + * .tenantId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ComparativeListResponse = + ComparativeListResponse( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("experimentsInfo", experimentsInfo).map { it.toImmutable() }, + checkRequired("modifiedAt", modifiedAt), + checkRequired("referenceDatasetId", referenceDatasetId), + checkRequired("tenantId", tenantId), + description, + extra, + feedbackStats, + name, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ComparativeListResponse = apply { + if (validated) { + return@apply + } + + id() + createdAt() + experimentsInfo().forEach { it.validate() } + modifiedAt() + referenceDatasetId() + tenantId() + description() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (experimentsInfo.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (modifiedAt.asKnown().isPresent) 1 else 0) + + (if (referenceDatasetId.asKnown().isPresent) 1 else 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComparativeListResponse && + id == other.id && + createdAt == other.createdAt && + experimentsInfo == other.experimentsInfo && + modifiedAt == other.modifiedAt && + referenceDatasetId == other.referenceDatasetId && + tenantId == other.tenantId && + description == other.description && + extra == other.extra && + feedbackStats == other.feedbackStats && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + createdAt, + experimentsInfo, + modifiedAt, + referenceDatasetId, + tenantId, + description, + extra, + feedbackStats, + name, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ComparativeListResponse{id=$id, createdAt=$createdAt, experimentsInfo=$experimentsInfo, modifiedAt=$modifiedAt, referenceDatasetId=$referenceDatasetId, tenantId=$tenantId, description=$description, extra=$extra, feedbackStats=$feedbackStats, name=$name, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/SimpleExperimentInfo.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/SimpleExperimentInfo.kt new file mode 100644 index 00000000..ffe553ff --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/SimpleExperimentInfo.kt @@ -0,0 +1,205 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.comparative + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +/** Simple experiment info schema for use with comparative experiments */ +class SimpleExperimentInfo +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val name: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + ) : this(id, name, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SimpleExperimentInfo]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SimpleExperimentInfo]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var name: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(simpleExperimentInfo: SimpleExperimentInfo) = apply { + id = simpleExperimentInfo.id + name = simpleExperimentInfo.name + additionalProperties = simpleExperimentInfo.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SimpleExperimentInfo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SimpleExperimentInfo = + SimpleExperimentInfo( + checkRequired("id", id), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SimpleExperimentInfo = apply { + if (validated) { + return@apply + } + + id() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SimpleExperimentInfo && + id == other.id && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SimpleExperimentInfo{id=$id, name=$name, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/SortByComparativeExperimentColumn.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/SortByComparativeExperimentColumn.kt new file mode 100644 index 00000000..ac5b8ff3 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/SortByComparativeExperimentColumn.kt @@ -0,0 +1,144 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.comparative + +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException + +/** Enum for available comparative experiment columns to sort by. */ +class SortByComparativeExperimentColumn +@JsonCreator +private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't match + * any known member, and you want to know that value. For example, if the SDK is on an older + * version than the API, then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val NAME = of("name") + + @JvmField val CREATED_AT = of("created_at") + + @JvmStatic fun of(value: String) = SortByComparativeExperimentColumn(JsonField.of(value)) + } + + /** An enum containing [SortByComparativeExperimentColumn]'s known values. */ + enum class Known { + NAME, + CREATED_AT, + } + + /** + * An enum containing [SortByComparativeExperimentColumn]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [SortByComparativeExperimentColumn] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the SDK + * is on an older version than the API, then the API may respond with new members that the SDK + * is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + NAME, + CREATED_AT, + /** + * An enum member indicating that [SortByComparativeExperimentColumn] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if + * the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want to + * throw for the unknown case. + */ + fun value(): Value = + when (this) { + NAME -> Value.NAME + CREATED_AT -> Value.CREATED_AT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't want + * to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + NAME -> Known.NAME + CREATED_AT -> Known.CREATED_AT + else -> + throw LangsmithApiInvalidDataException( + "Unknown SortByComparativeExperimentColumn: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): SortByComparativeExperimentColumn = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SortByComparativeExperimentColumn && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/experiments/ExperimentGroupedParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/experiments/ExperimentGroupedParams.kt new file mode 100644 index 00000000..90ebc48e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/experiments/ExperimentGroupedParams.kt @@ -0,0 +1,977 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.experiments + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Stream grouped and aggregated experiments. */ +class ExperimentGroupedParams +private constructor( + private val datasetId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun datasetId(): Optional<String> = Optional.ofNullable(datasetId) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun metadataKey(): String = body.metadataKey() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun datasetVersion(): Optional<String> = body.datasetVersion() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun experimentLimit(): Optional<Long> = body.experimentLimit() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun filter(): Optional<String> = body.filter() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun nameContains(): Optional<String> = body.nameContains() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun statsStartTime(): Optional<OffsetDateTime> = body.statsStartTime() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tagValueId(): Optional<List<String>> = body.tagValueId() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun useApproxStats(): Optional<Boolean> = body.useApproxStats() + + /** + * Returns the raw JSON value of [metadataKey]. + * + * Unlike [metadataKey], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _metadataKey(): JsonField<String> = body._metadataKey() + + /** + * Returns the raw JSON value of [datasetVersion]. + * + * Unlike [datasetVersion], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _datasetVersion(): JsonField<String> = body._datasetVersion() + + /** + * Returns the raw JSON value of [experimentLimit]. + * + * Unlike [experimentLimit], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _experimentLimit(): JsonField<Long> = body._experimentLimit() + + /** + * Returns the raw JSON value of [filter]. + * + * Unlike [filter], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _filter(): JsonField<String> = body._filter() + + /** + * Returns the raw JSON value of [nameContains]. + * + * Unlike [nameContains], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _nameContains(): JsonField<String> = body._nameContains() + + /** + * Returns the raw JSON value of [statsStartTime]. + * + * Unlike [statsStartTime], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _statsStartTime(): JsonField<OffsetDateTime> = body._statsStartTime() + + /** + * Returns the raw JSON value of [tagValueId]. + * + * Unlike [tagValueId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _tagValueId(): JsonField<List<String>> = body._tagValueId() + + /** + * Returns the raw JSON value of [useApproxStats]. + * + * Unlike [useApproxStats], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _useApproxStats(): JsonField<Boolean> = body._useApproxStats() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ExperimentGroupedParams]. + * + * The following fields are required: + * ```java + * .metadataKey() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExperimentGroupedParams]. */ + class Builder internal constructor() { + + private var datasetId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(experimentGroupedParams: ExperimentGroupedParams) = apply { + datasetId = experimentGroupedParams.datasetId + body = experimentGroupedParams.body.toBuilder() + additionalHeaders = experimentGroupedParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentGroupedParams.additionalQueryParams.toBuilder() + } + + fun datasetId(datasetId: String?) = apply { this.datasetId = datasetId } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [metadataKey] + * - [datasetVersion] + * - [experimentLimit] + * - [filter] + * - [nameContains] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun metadataKey(metadataKey: String) = apply { body.metadataKey(metadataKey) } + + /** + * Sets [Builder.metadataKey] to an arbitrary JSON value. + * + * You should usually call [Builder.metadataKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadataKey(metadataKey: JsonField<String>) = apply { body.metadataKey(metadataKey) } + + fun datasetVersion(datasetVersion: String?) = apply { body.datasetVersion(datasetVersion) } + + /** Alias for calling [Builder.datasetVersion] with `datasetVersion.orElse(null)`. */ + fun datasetVersion(datasetVersion: Optional<String>) = + datasetVersion(datasetVersion.getOrNull()) + + /** + * Sets [Builder.datasetVersion] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetVersion] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun datasetVersion(datasetVersion: JsonField<String>) = apply { + body.datasetVersion(datasetVersion) + } + + fun experimentLimit(experimentLimit: Long) = apply { body.experimentLimit(experimentLimit) } + + /** + * Sets [Builder.experimentLimit] to an arbitrary JSON value. + * + * You should usually call [Builder.experimentLimit] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun experimentLimit(experimentLimit: JsonField<Long>) = apply { + body.experimentLimit(experimentLimit) + } + + fun filter(filter: String?) = apply { body.filter(filter) } + + /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ + fun filter(filter: Optional<String>) = filter(filter.getOrNull()) + + /** + * Sets [Builder.filter] to an arbitrary JSON value. + * + * You should usually call [Builder.filter] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun filter(filter: JsonField<String>) = apply { body.filter(filter) } + + fun nameContains(nameContains: String?) = apply { body.nameContains(nameContains) } + + /** Alias for calling [Builder.nameContains] with `nameContains.orElse(null)`. */ + fun nameContains(nameContains: Optional<String>) = nameContains(nameContains.getOrNull()) + + /** + * Sets [Builder.nameContains] to an arbitrary JSON value. + * + * You should usually call [Builder.nameContains] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun nameContains(nameContains: JsonField<String>) = apply { + body.nameContains(nameContains) + } + + fun statsStartTime(statsStartTime: OffsetDateTime?) = apply { + body.statsStartTime(statsStartTime) + } + + /** Alias for calling [Builder.statsStartTime] with `statsStartTime.orElse(null)`. */ + fun statsStartTime(statsStartTime: Optional<OffsetDateTime>) = + statsStartTime(statsStartTime.getOrNull()) + + /** + * Sets [Builder.statsStartTime] to an arbitrary JSON value. + * + * You should usually call [Builder.statsStartTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun statsStartTime(statsStartTime: JsonField<OffsetDateTime>) = apply { + body.statsStartTime(statsStartTime) + } + + fun tagValueId(tagValueId: List<String>?) = apply { body.tagValueId(tagValueId) } + + /** Alias for calling [Builder.tagValueId] with `tagValueId.orElse(null)`. */ + fun tagValueId(tagValueId: Optional<List<String>>) = tagValueId(tagValueId.getOrNull()) + + /** + * Sets [Builder.tagValueId] to an arbitrary JSON value. + * + * You should usually call [Builder.tagValueId] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tagValueId(tagValueId: JsonField<List<String>>) = apply { body.tagValueId(tagValueId) } + + /** + * Adds a single [String] to [Builder.tagValueId]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTagValueId(tagValueId: String) = apply { body.addTagValueId(tagValueId) } + + fun useApproxStats(useApproxStats: Boolean) = apply { body.useApproxStats(useApproxStats) } + + /** + * Sets [Builder.useApproxStats] to an arbitrary JSON value. + * + * You should usually call [Builder.useApproxStats] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun useApproxStats(useApproxStats: JsonField<Boolean>) = apply { + body.useApproxStats(useApproxStats) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ExperimentGroupedParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .metadataKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ExperimentGroupedParams = + ExperimentGroupedParams( + datasetId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> datasetId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Schema for grouped experiment (tracer session) query. */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val metadataKey: JsonField<String>, + private val datasetVersion: JsonField<String>, + private val experimentLimit: JsonField<Long>, + private val filter: JsonField<String>, + private val nameContains: JsonField<String>, + private val statsStartTime: JsonField<OffsetDateTime>, + private val tagValueId: JsonField<List<String>>, + private val useApproxStats: JsonField<Boolean>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("metadata_key") + @ExcludeMissing + metadataKey: JsonField<String> = JsonMissing.of(), + @JsonProperty("dataset_version") + @ExcludeMissing + datasetVersion: JsonField<String> = JsonMissing.of(), + @JsonProperty("experiment_limit") + @ExcludeMissing + experimentLimit: JsonField<Long> = JsonMissing.of(), + @JsonProperty("filter") @ExcludeMissing filter: JsonField<String> = JsonMissing.of(), + @JsonProperty("name_contains") + @ExcludeMissing + nameContains: JsonField<String> = JsonMissing.of(), + @JsonProperty("stats_start_time") + @ExcludeMissing + statsStartTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("tag_value_id") + @ExcludeMissing + tagValueId: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("use_approx_stats") + @ExcludeMissing + useApproxStats: JsonField<Boolean> = JsonMissing.of(), + ) : this( + metadataKey, + datasetVersion, + experimentLimit, + filter, + nameContains, + statsStartTime, + tagValueId, + useApproxStats, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun metadataKey(): String = metadataKey.getRequired("metadata_key") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun datasetVersion(): Optional<String> = datasetVersion.getOptional("dataset_version") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun experimentLimit(): Optional<Long> = experimentLimit.getOptional("experiment_limit") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun filter(): Optional<String> = filter.getOptional("filter") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun nameContains(): Optional<String> = nameContains.getOptional("name_contains") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun statsStartTime(): Optional<OffsetDateTime> = + statsStartTime.getOptional("stats_start_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun tagValueId(): Optional<List<String>> = tagValueId.getOptional("tag_value_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun useApproxStats(): Optional<Boolean> = useApproxStats.getOptional("use_approx_stats") + + /** + * Returns the raw JSON value of [metadataKey]. + * + * Unlike [metadataKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata_key") + @ExcludeMissing + fun _metadataKey(): JsonField<String> = metadataKey + + /** + * Returns the raw JSON value of [datasetVersion]. + * + * Unlike [datasetVersion], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dataset_version") + @ExcludeMissing + fun _datasetVersion(): JsonField<String> = datasetVersion + + /** + * Returns the raw JSON value of [experimentLimit]. + * + * Unlike [experimentLimit], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("experiment_limit") + @ExcludeMissing + fun _experimentLimit(): JsonField<Long> = experimentLimit + + /** + * Returns the raw JSON value of [filter]. + * + * Unlike [filter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField<String> = filter + + /** + * Returns the raw JSON value of [nameContains]. + * + * Unlike [nameContains], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name_contains") + @ExcludeMissing + fun _nameContains(): JsonField<String> = nameContains + + /** + * Returns the raw JSON value of [statsStartTime]. + * + * Unlike [statsStartTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("stats_start_time") + @ExcludeMissing + fun _statsStartTime(): JsonField<OffsetDateTime> = statsStartTime + + /** + * Returns the raw JSON value of [tagValueId]. + * + * Unlike [tagValueId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tag_value_id") + @ExcludeMissing + fun _tagValueId(): JsonField<List<String>> = tagValueId + + /** + * Returns the raw JSON value of [useApproxStats]. + * + * Unlike [useApproxStats], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("use_approx_stats") + @ExcludeMissing + fun _useApproxStats(): JsonField<Boolean> = useApproxStats + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .metadataKey() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var metadataKey: JsonField<String>? = null + private var datasetVersion: JsonField<String> = JsonMissing.of() + private var experimentLimit: JsonField<Long> = JsonMissing.of() + private var filter: JsonField<String> = JsonMissing.of() + private var nameContains: JsonField<String> = JsonMissing.of() + private var statsStartTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var tagValueId: JsonField<MutableList<String>>? = null + private var useApproxStats: JsonField<Boolean> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + metadataKey = body.metadataKey + datasetVersion = body.datasetVersion + experimentLimit = body.experimentLimit + filter = body.filter + nameContains = body.nameContains + statsStartTime = body.statsStartTime + tagValueId = body.tagValueId.map { it.toMutableList() } + useApproxStats = body.useApproxStats + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun metadataKey(metadataKey: String) = metadataKey(JsonField.of(metadataKey)) + + /** + * Sets [Builder.metadataKey] to an arbitrary JSON value. + * + * You should usually call [Builder.metadataKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadataKey(metadataKey: JsonField<String>) = apply { + this.metadataKey = metadataKey + } + + fun datasetVersion(datasetVersion: String?) = + datasetVersion(JsonField.ofNullable(datasetVersion)) + + /** Alias for calling [Builder.datasetVersion] with `datasetVersion.orElse(null)`. */ + fun datasetVersion(datasetVersion: Optional<String>) = + datasetVersion(datasetVersion.getOrNull()) + + /** + * Sets [Builder.datasetVersion] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetVersion] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun datasetVersion(datasetVersion: JsonField<String>) = apply { + this.datasetVersion = datasetVersion + } + + fun experimentLimit(experimentLimit: Long) = + experimentLimit(JsonField.of(experimentLimit)) + + /** + * Sets [Builder.experimentLimit] to an arbitrary JSON value. + * + * You should usually call [Builder.experimentLimit] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun experimentLimit(experimentLimit: JsonField<Long>) = apply { + this.experimentLimit = experimentLimit + } + + fun filter(filter: String?) = filter(JsonField.ofNullable(filter)) + + /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ + fun filter(filter: Optional<String>) = filter(filter.getOrNull()) + + /** + * Sets [Builder.filter] to an arbitrary JSON value. + * + * You should usually call [Builder.filter] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun filter(filter: JsonField<String>) = apply { this.filter = filter } + + fun nameContains(nameContains: String?) = + nameContains(JsonField.ofNullable(nameContains)) + + /** Alias for calling [Builder.nameContains] with `nameContains.orElse(null)`. */ + fun nameContains(nameContains: Optional<String>) = + nameContains(nameContains.getOrNull()) + + /** + * Sets [Builder.nameContains] to an arbitrary JSON value. + * + * You should usually call [Builder.nameContains] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun nameContains(nameContains: JsonField<String>) = apply { + this.nameContains = nameContains + } + + fun statsStartTime(statsStartTime: OffsetDateTime?) = + statsStartTime(JsonField.ofNullable(statsStartTime)) + + /** Alias for calling [Builder.statsStartTime] with `statsStartTime.orElse(null)`. */ + fun statsStartTime(statsStartTime: Optional<OffsetDateTime>) = + statsStartTime(statsStartTime.getOrNull()) + + /** + * Sets [Builder.statsStartTime] to an arbitrary JSON value. + * + * You should usually call [Builder.statsStartTime] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun statsStartTime(statsStartTime: JsonField<OffsetDateTime>) = apply { + this.statsStartTime = statsStartTime + } + + fun tagValueId(tagValueId: List<String>?) = tagValueId(JsonField.ofNullable(tagValueId)) + + /** Alias for calling [Builder.tagValueId] with `tagValueId.orElse(null)`. */ + fun tagValueId(tagValueId: Optional<List<String>>) = tagValueId(tagValueId.getOrNull()) + + /** + * Sets [Builder.tagValueId] to an arbitrary JSON value. + * + * You should usually call [Builder.tagValueId] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tagValueId(tagValueId: JsonField<List<String>>) = apply { + this.tagValueId = tagValueId.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.tagValueId]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTagValueId(tagValueId: String) = apply { + this.tagValueId = + (this.tagValueId ?: JsonField.of(mutableListOf())).also { + checkKnown("tagValueId", it).add(tagValueId) + } + } + + fun useApproxStats(useApproxStats: Boolean) = + useApproxStats(JsonField.of(useApproxStats)) + + /** + * Sets [Builder.useApproxStats] to an arbitrary JSON value. + * + * You should usually call [Builder.useApproxStats] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun useApproxStats(useApproxStats: JsonField<Boolean>) = apply { + this.useApproxStats = useApproxStats + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .metadataKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("metadataKey", metadataKey), + datasetVersion, + experimentLimit, + filter, + nameContains, + statsStartTime, + (tagValueId ?: JsonMissing.of()).map { it.toImmutable() }, + useApproxStats, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + metadataKey() + datasetVersion() + experimentLimit() + filter() + nameContains() + statsStartTime() + tagValueId() + useApproxStats() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (metadataKey.asKnown().isPresent) 1 else 0) + + (if (datasetVersion.asKnown().isPresent) 1 else 0) + + (if (experimentLimit.asKnown().isPresent) 1 else 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (if (nameContains.asKnown().isPresent) 1 else 0) + + (if (statsStartTime.asKnown().isPresent) 1 else 0) + + (tagValueId.asKnown().getOrNull()?.size ?: 0) + + (if (useApproxStats.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + metadataKey == other.metadataKey && + datasetVersion == other.datasetVersion && + experimentLimit == other.experimentLimit && + filter == other.filter && + nameContains == other.nameContains && + statsStartTime == other.statsStartTime && + tagValueId == other.tagValueId && + useApproxStats == other.useApproxStats && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + metadataKey, + datasetVersion, + experimentLimit, + filter, + nameContains, + statsStartTime, + tagValueId, + useApproxStats, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{metadataKey=$metadataKey, datasetVersion=$datasetVersion, experimentLimit=$experimentLimit, filter=$filter, nameContains=$nameContains, statsStartTime=$statsStartTime, tagValueId=$tagValueId, useApproxStats=$useApproxStats, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExperimentGroupedParams && + datasetId == other.datasetId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(datasetId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ExperimentGroupedParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/experiments/ExperimentGroupedResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/experiments/ExperimentGroupedResponse.kt new file mode 100644 index 00000000..76e0a06e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/experiments/ExperimentGroupedResponse.kt @@ -0,0 +1,118 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.experiments + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class ExperimentGroupedResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ExperimentGroupedResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExperimentGroupedResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(experimentGroupedResponse: ExperimentGroupedResponse) = apply { + additionalProperties = experimentGroupedResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ExperimentGroupedResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ExperimentGroupedResponse = + ExperimentGroupedResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): ExperimentGroupedResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExperimentGroupedResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ExperimentGroupedResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/group/GroupRunsParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/group/GroupRunsParams.kt new file mode 100644 index 00000000..623b9a66 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/group/GroupRunsParams.kt @@ -0,0 +1,976 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.group + +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.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Fetch examples for a dataset, and fetch the runs for each example if they are associated with the + * given session_ids. + */ +class GroupRunsParams +private constructor( + private val datasetId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun datasetId(): Optional<String> = Optional.ofNullable(datasetId) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupBy(): GroupBy = body.groupBy() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun metadataKey(): String = body.metadataKey() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun sessionIds(): List<String> = body.sessionIds() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun limit(): Optional<Long> = body.limit() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun offset(): Optional<Long> = body.offset() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun perGroupLimit(): Optional<Long> = body.perGroupLimit() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun preview(): Optional<Boolean> = body.preview() + + /** + * Returns the raw JSON value of [groupBy]. + * + * Unlike [groupBy], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _groupBy(): JsonField<GroupBy> = body._groupBy() + + /** + * Returns the raw JSON value of [metadataKey]. + * + * Unlike [metadataKey], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _metadataKey(): JsonField<String> = body._metadataKey() + + /** + * Returns the raw JSON value of [sessionIds]. + * + * Unlike [sessionIds], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _sessionIds(): JsonField<List<String>> = body._sessionIds() + + /** + * Returns the raw JSON value of [limit]. + * + * Unlike [limit], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _limit(): JsonField<Long> = body._limit() + + /** + * Returns the raw JSON value of [offset]. + * + * Unlike [offset], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _offset(): JsonField<Long> = body._offset() + + /** + * Returns the raw JSON value of [perGroupLimit]. + * + * Unlike [perGroupLimit], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _perGroupLimit(): JsonField<Long> = body._perGroupLimit() + + /** + * Returns the raw JSON value of [preview]. + * + * Unlike [preview], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _preview(): JsonField<Boolean> = body._preview() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [GroupRunsParams]. + * + * The following fields are required: + * ```java + * .groupBy() + * .metadataKey() + * .sessionIds() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupRunsParams]. */ + class Builder internal constructor() { + + private var datasetId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(groupRunsParams: GroupRunsParams) = apply { + datasetId = groupRunsParams.datasetId + body = groupRunsParams.body.toBuilder() + additionalHeaders = groupRunsParams.additionalHeaders.toBuilder() + additionalQueryParams = groupRunsParams.additionalQueryParams.toBuilder() + } + + fun datasetId(datasetId: String?) = apply { this.datasetId = datasetId } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [groupBy] + * - [metadataKey] + * - [sessionIds] + * - [limit] + * - [offset] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun groupBy(groupBy: GroupBy) = apply { body.groupBy(groupBy) } + + /** + * Sets [Builder.groupBy] to an arbitrary JSON value. + * + * You should usually call [Builder.groupBy] with a well-typed [GroupBy] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun groupBy(groupBy: JsonField<GroupBy>) = apply { body.groupBy(groupBy) } + + fun metadataKey(metadataKey: String) = apply { body.metadataKey(metadataKey) } + + /** + * Sets [Builder.metadataKey] to an arbitrary JSON value. + * + * You should usually call [Builder.metadataKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadataKey(metadataKey: JsonField<String>) = apply { body.metadataKey(metadataKey) } + + fun sessionIds(sessionIds: List<String>) = apply { body.sessionIds(sessionIds) } + + /** + * Sets [Builder.sessionIds] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionIds] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sessionIds(sessionIds: JsonField<List<String>>) = apply { body.sessionIds(sessionIds) } + + /** + * Adds a single [String] to [sessionIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSessionId(sessionId: String) = apply { body.addSessionId(sessionId) } + + fun limit(limit: Long) = apply { body.limit(limit) } + + /** + * Sets [Builder.limit] to an arbitrary JSON value. + * + * You should usually call [Builder.limit] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun limit(limit: JsonField<Long>) = apply { body.limit(limit) } + + fun offset(offset: Long) = apply { body.offset(offset) } + + /** + * Sets [Builder.offset] to an arbitrary JSON value. + * + * You should usually call [Builder.offset] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun offset(offset: JsonField<Long>) = apply { body.offset(offset) } + + fun perGroupLimit(perGroupLimit: Long) = apply { body.perGroupLimit(perGroupLimit) } + + /** + * Sets [Builder.perGroupLimit] to an arbitrary JSON value. + * + * You should usually call [Builder.perGroupLimit] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun perGroupLimit(perGroupLimit: JsonField<Long>) = apply { + body.perGroupLimit(perGroupLimit) + } + + fun preview(preview: Boolean) = apply { body.preview(preview) } + + /** + * Sets [Builder.preview] to an arbitrary JSON value. + * + * You should usually call [Builder.preview] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun preview(preview: JsonField<Boolean>) = apply { body.preview(preview) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [GroupRunsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupBy() + * .metadataKey() + * .sessionIds() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupRunsParams = + GroupRunsParams( + datasetId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> datasetId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupBy: JsonField<GroupBy>, + private val metadataKey: JsonField<String>, + private val sessionIds: JsonField<List<String>>, + private val limit: JsonField<Long>, + private val offset: JsonField<Long>, + private val perGroupLimit: JsonField<Long>, + private val preview: JsonField<Boolean>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("group_by") + @ExcludeMissing + groupBy: JsonField<GroupBy> = JsonMissing.of(), + @JsonProperty("metadata_key") + @ExcludeMissing + metadataKey: JsonField<String> = JsonMissing.of(), + @JsonProperty("session_ids") + @ExcludeMissing + sessionIds: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("limit") @ExcludeMissing limit: JsonField<Long> = JsonMissing.of(), + @JsonProperty("offset") @ExcludeMissing offset: JsonField<Long> = JsonMissing.of(), + @JsonProperty("per_group_limit") + @ExcludeMissing + perGroupLimit: JsonField<Long> = JsonMissing.of(), + @JsonProperty("preview") @ExcludeMissing preview: JsonField<Boolean> = JsonMissing.of(), + ) : this( + groupBy, + metadataKey, + sessionIds, + limit, + offset, + perGroupLimit, + preview, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupBy(): GroupBy = groupBy.getRequired("group_by") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun metadataKey(): String = metadataKey.getRequired("metadata_key") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun sessionIds(): List<String> = sessionIds.getRequired("session_ids") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun limit(): Optional<Long> = limit.getOptional("limit") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun offset(): Optional<Long> = offset.getOptional("offset") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun perGroupLimit(): Optional<Long> = perGroupLimit.getOptional("per_group_limit") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun preview(): Optional<Boolean> = preview.getOptional("preview") + + /** + * Returns the raw JSON value of [groupBy]. + * + * Unlike [groupBy], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("group_by") @ExcludeMissing fun _groupBy(): JsonField<GroupBy> = groupBy + + /** + * Returns the raw JSON value of [metadataKey]. + * + * Unlike [metadataKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata_key") + @ExcludeMissing + fun _metadataKey(): JsonField<String> = metadataKey + + /** + * Returns the raw JSON value of [sessionIds]. + * + * Unlike [sessionIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session_ids") + @ExcludeMissing + fun _sessionIds(): JsonField<List<String>> = sessionIds + + /** + * Returns the raw JSON value of [limit]. + * + * Unlike [limit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("limit") @ExcludeMissing fun _limit(): JsonField<Long> = limit + + /** + * Returns the raw JSON value of [offset]. + * + * Unlike [offset], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("offset") @ExcludeMissing fun _offset(): JsonField<Long> = offset + + /** + * Returns the raw JSON value of [perGroupLimit]. + * + * Unlike [perGroupLimit], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("per_group_limit") + @ExcludeMissing + fun _perGroupLimit(): JsonField<Long> = perGroupLimit + + /** + * Returns the raw JSON value of [preview]. + * + * Unlike [preview], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("preview") @ExcludeMissing fun _preview(): JsonField<Boolean> = preview + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .groupBy() + * .metadataKey() + * .sessionIds() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var groupBy: JsonField<GroupBy>? = null + private var metadataKey: JsonField<String>? = null + private var sessionIds: JsonField<MutableList<String>>? = null + private var limit: JsonField<Long> = JsonMissing.of() + private var offset: JsonField<Long> = JsonMissing.of() + private var perGroupLimit: JsonField<Long> = JsonMissing.of() + private var preview: JsonField<Boolean> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + groupBy = body.groupBy + metadataKey = body.metadataKey + sessionIds = body.sessionIds.map { it.toMutableList() } + limit = body.limit + offset = body.offset + perGroupLimit = body.perGroupLimit + preview = body.preview + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun groupBy(groupBy: GroupBy) = groupBy(JsonField.of(groupBy)) + + /** + * Sets [Builder.groupBy] to an arbitrary JSON value. + * + * You should usually call [Builder.groupBy] with a well-typed [GroupBy] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupBy(groupBy: JsonField<GroupBy>) = apply { this.groupBy = groupBy } + + fun metadataKey(metadataKey: String) = metadataKey(JsonField.of(metadataKey)) + + /** + * Sets [Builder.metadataKey] to an arbitrary JSON value. + * + * You should usually call [Builder.metadataKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadataKey(metadataKey: JsonField<String>) = apply { + this.metadataKey = metadataKey + } + + fun sessionIds(sessionIds: List<String>) = sessionIds(JsonField.of(sessionIds)) + + /** + * Sets [Builder.sessionIds] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionIds] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sessionIds(sessionIds: JsonField<List<String>>) = apply { + this.sessionIds = sessionIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [sessionIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSessionId(sessionId: String) = apply { + sessionIds = + (sessionIds ?: JsonField.of(mutableListOf())).also { + checkKnown("sessionIds", it).add(sessionId) + } + } + + fun limit(limit: Long) = limit(JsonField.of(limit)) + + /** + * Sets [Builder.limit] to an arbitrary JSON value. + * + * You should usually call [Builder.limit] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun limit(limit: JsonField<Long>) = apply { this.limit = limit } + + fun offset(offset: Long) = offset(JsonField.of(offset)) + + /** + * Sets [Builder.offset] to an arbitrary JSON value. + * + * You should usually call [Builder.offset] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun offset(offset: JsonField<Long>) = apply { this.offset = offset } + + fun perGroupLimit(perGroupLimit: Long) = perGroupLimit(JsonField.of(perGroupLimit)) + + /** + * Sets [Builder.perGroupLimit] to an arbitrary JSON value. + * + * You should usually call [Builder.perGroupLimit] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun perGroupLimit(perGroupLimit: JsonField<Long>) = apply { + this.perGroupLimit = perGroupLimit + } + + fun preview(preview: Boolean) = preview(JsonField.of(preview)) + + /** + * Sets [Builder.preview] to an arbitrary JSON value. + * + * You should usually call [Builder.preview] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun preview(preview: JsonField<Boolean>) = apply { this.preview = preview } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupBy() + * .metadataKey() + * .sessionIds() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("groupBy", groupBy), + checkRequired("metadataKey", metadataKey), + checkRequired("sessionIds", sessionIds).map { it.toImmutable() }, + limit, + offset, + perGroupLimit, + preview, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + groupBy().validate() + metadataKey() + sessionIds() + limit() + offset() + perGroupLimit() + preview() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (groupBy.asKnown().getOrNull()?.validity() ?: 0) + + (if (metadataKey.asKnown().isPresent) 1 else 0) + + (sessionIds.asKnown().getOrNull()?.size ?: 0) + + (if (limit.asKnown().isPresent) 1 else 0) + + (if (offset.asKnown().isPresent) 1 else 0) + + (if (perGroupLimit.asKnown().isPresent) 1 else 0) + + (if (preview.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + groupBy == other.groupBy && + metadataKey == other.metadataKey && + sessionIds == other.sessionIds && + limit == other.limit && + offset == other.offset && + perGroupLimit == other.perGroupLimit && + preview == other.preview && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupBy, + metadataKey, + sessionIds, + limit, + offset, + perGroupLimit, + preview, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{groupBy=$groupBy, metadataKey=$metadataKey, sessionIds=$sessionIds, limit=$limit, offset=$offset, perGroupLimit=$perGroupLimit, preview=$preview, additionalProperties=$additionalProperties}" + } + + class GroupBy @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val RUN_METADATA = of("run_metadata") + + @JvmField val EXAMPLE_METADATA = of("example_metadata") + + @JvmStatic fun of(value: String) = GroupBy(JsonField.of(value)) + } + + /** An enum containing [GroupBy]'s known values. */ + enum class Known { + RUN_METADATA, + EXAMPLE_METADATA, + } + + /** + * An enum containing [GroupBy]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [GroupBy] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + RUN_METADATA, + EXAMPLE_METADATA, + /** An enum member indicating that [GroupBy] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + RUN_METADATA -> Value.RUN_METADATA + EXAMPLE_METADATA -> Value.EXAMPLE_METADATA + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + RUN_METADATA -> Known.RUN_METADATA + EXAMPLE_METADATA -> Known.EXAMPLE_METADATA + else -> throw LangsmithApiInvalidDataException("Unknown GroupBy: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): GroupBy = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupBy && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupRunsParams && + datasetId == other.datasetId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(datasetId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "GroupRunsParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/group/GroupRunsResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/group/GroupRunsResponse.kt new file mode 100644 index 00000000..a7800eeb --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/group/GroupRunsResponse.kt @@ -0,0 +1,1205 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.group + +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 com.langsmith_api.api.core.BaseDeserializer +import com.langsmith_api.api.core.BaseSerializer +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.allMaxBy +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.datasets.runs.ExampleWithRuns +import com.langsmith_api.api.models.api.v1.datasets.runs.ExampleWithRunsCh +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Grouped examples with runs. */ +class GroupRunsResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val groups: JsonField<List<Group>>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("groups") @ExcludeMissing groups: JsonField<List<Group>> = JsonMissing.of() + ) : this(groups, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groups(): List<Group> = groups.getRequired("groups") + + /** + * Returns the raw JSON value of [groups]. + * + * Unlike [groups], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("groups") @ExcludeMissing fun _groups(): JsonField<List<Group>> = groups + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [GroupRunsResponse]. + * + * The following fields are required: + * ```java + * .groups() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupRunsResponse]. */ + class Builder internal constructor() { + + private var groups: JsonField<MutableList<Group>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(groupRunsResponse: GroupRunsResponse) = apply { + groups = groupRunsResponse.groups.map { it.toMutableList() } + additionalProperties = groupRunsResponse.additionalProperties.toMutableMap() + } + + fun groups(groups: List<Group>) = groups(JsonField.of(groups)) + + /** + * Sets [Builder.groups] to an arbitrary JSON value. + * + * You should usually call [Builder.groups] with a well-typed `List<Group>` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groups(groups: JsonField<List<Group>>) = apply { + this.groups = groups.map { it.toMutableList() } + } + + /** + * Adds a single [Group] to [groups]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addGroup(group: Group) = apply { + groups = + (groups ?: JsonField.of(mutableListOf())).also { + checkKnown("groups", it).add(group) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupRunsResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groups() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupRunsResponse = + GroupRunsResponse( + checkRequired("groups", groups).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupRunsResponse = apply { + if (validated) { + return@apply + } + + groups().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (groups.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Group of examples with runs. */ + class Group + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val examples: JsonField<Examples>, + private val filter: JsonField<String>, + private val groupKey: JsonValue, + private val completionCost: JsonField<String>, + private val completionTokens: JsonField<Long>, + private val count: JsonField<Long>, + private val errorRate: JsonField<Double>, + private val feedbackStats: JsonValue, + private val latencyP50: JsonField<Double>, + private val latencyP99: JsonField<Double>, + private val maxStartTime: JsonField<OffsetDateTime>, + private val minStartTime: JsonField<OffsetDateTime>, + private val promptCost: JsonField<String>, + private val promptTokens: JsonField<Long>, + private val totalCost: JsonField<String>, + private val totalTokens: JsonField<Long>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("examples") + @ExcludeMissing + examples: JsonField<Examples> = JsonMissing.of(), + @JsonProperty("filter") @ExcludeMissing filter: JsonField<String> = JsonMissing.of(), + @JsonProperty("group_key") @ExcludeMissing groupKey: JsonValue = JsonMissing.of(), + @JsonProperty("completion_cost") + @ExcludeMissing + completionCost: JsonField<String> = JsonMissing.of(), + @JsonProperty("completion_tokens") + @ExcludeMissing + completionTokens: JsonField<Long> = JsonMissing.of(), + @JsonProperty("count") @ExcludeMissing count: JsonField<Long> = JsonMissing.of(), + @JsonProperty("error_rate") + @ExcludeMissing + errorRate: JsonField<Double> = JsonMissing.of(), + @JsonProperty("feedback_stats") + @ExcludeMissing + feedbackStats: JsonValue = JsonMissing.of(), + @JsonProperty("latency_p50") + @ExcludeMissing + latencyP50: JsonField<Double> = JsonMissing.of(), + @JsonProperty("latency_p99") + @ExcludeMissing + latencyP99: JsonField<Double> = JsonMissing.of(), + @JsonProperty("max_start_time") + @ExcludeMissing + maxStartTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("min_start_time") + @ExcludeMissing + minStartTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("prompt_cost") + @ExcludeMissing + promptCost: JsonField<String> = JsonMissing.of(), + @JsonProperty("prompt_tokens") + @ExcludeMissing + promptTokens: JsonField<Long> = JsonMissing.of(), + @JsonProperty("total_cost") + @ExcludeMissing + totalCost: JsonField<String> = JsonMissing.of(), + @JsonProperty("total_tokens") + @ExcludeMissing + totalTokens: JsonField<Long> = JsonMissing.of(), + ) : this( + examples, + filter, + groupKey, + completionCost, + completionTokens, + count, + errorRate, + feedbackStats, + latencyP50, + latencyP99, + maxStartTime, + minStartTime, + promptCost, + promptTokens, + totalCost, + totalTokens, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun examples(): Examples = examples.getRequired("examples") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun filter(): String = filter.getRequired("filter") + + @JsonProperty("group_key") @ExcludeMissing fun _groupKey(): JsonValue = groupKey + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun completionCost(): Optional<String> = completionCost.getOptional("completion_cost") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun completionTokens(): Optional<Long> = completionTokens.getOptional("completion_tokens") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun count(): Optional<Long> = count.getOptional("count") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun errorRate(): Optional<Double> = errorRate.getOptional("error_rate") + + @JsonProperty("feedback_stats") + @ExcludeMissing + fun _feedbackStats(): JsonValue = feedbackStats + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun latencyP50(): Optional<Double> = latencyP50.getOptional("latency_p50") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun latencyP99(): Optional<Double> = latencyP99.getOptional("latency_p99") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun maxStartTime(): Optional<OffsetDateTime> = maxStartTime.getOptional("max_start_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun minStartTime(): Optional<OffsetDateTime> = minStartTime.getOptional("min_start_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun promptCost(): Optional<String> = promptCost.getOptional("prompt_cost") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun promptTokens(): Optional<Long> = promptTokens.getOptional("prompt_tokens") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun totalCost(): Optional<String> = totalCost.getOptional("total_cost") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun totalTokens(): Optional<Long> = totalTokens.getOptional("total_tokens") + + /** + * Returns the raw JSON value of [examples]. + * + * Unlike [examples], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("examples") @ExcludeMissing fun _examples(): JsonField<Examples> = examples + + /** + * Returns the raw JSON value of [filter]. + * + * Unlike [filter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField<String> = filter + + /** + * Returns the raw JSON value of [completionCost]. + * + * Unlike [completionCost], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("completion_cost") + @ExcludeMissing + fun _completionCost(): JsonField<String> = completionCost + + /** + * Returns the raw JSON value of [completionTokens]. + * + * Unlike [completionTokens], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("completion_tokens") + @ExcludeMissing + fun _completionTokens(): JsonField<Long> = completionTokens + + /** + * Returns the raw JSON value of [count]. + * + * Unlike [count], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("count") @ExcludeMissing fun _count(): JsonField<Long> = count + + /** + * Returns the raw JSON value of [errorRate]. + * + * Unlike [errorRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("error_rate") @ExcludeMissing fun _errorRate(): JsonField<Double> = errorRate + + /** + * Returns the raw JSON value of [latencyP50]. + * + * Unlike [latencyP50], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("latency_p50") + @ExcludeMissing + fun _latencyP50(): JsonField<Double> = latencyP50 + + /** + * Returns the raw JSON value of [latencyP99]. + * + * Unlike [latencyP99], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("latency_p99") + @ExcludeMissing + fun _latencyP99(): JsonField<Double> = latencyP99 + + /** + * Returns the raw JSON value of [maxStartTime]. + * + * Unlike [maxStartTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("max_start_time") + @ExcludeMissing + fun _maxStartTime(): JsonField<OffsetDateTime> = maxStartTime + + /** + * Returns the raw JSON value of [minStartTime]. + * + * Unlike [minStartTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("min_start_time") + @ExcludeMissing + fun _minStartTime(): JsonField<OffsetDateTime> = minStartTime + + /** + * Returns the raw JSON value of [promptCost]. + * + * Unlike [promptCost], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prompt_cost") + @ExcludeMissing + fun _promptCost(): JsonField<String> = promptCost + + /** + * Returns the raw JSON value of [promptTokens]. + * + * Unlike [promptTokens], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("prompt_tokens") + @ExcludeMissing + fun _promptTokens(): JsonField<Long> = promptTokens + + /** + * Returns the raw JSON value of [totalCost]. + * + * Unlike [totalCost], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total_cost") @ExcludeMissing fun _totalCost(): JsonField<String> = totalCost + + /** + * Returns the raw JSON value of [totalTokens]. + * + * Unlike [totalTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total_tokens") + @ExcludeMissing + fun _totalTokens(): JsonField<Long> = totalTokens + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Group]. + * + * The following fields are required: + * ```java + * .examples() + * .filter() + * .groupKey() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Group]. */ + class Builder internal constructor() { + + private var examples: JsonField<Examples>? = null + private var filter: JsonField<String>? = null + private var groupKey: JsonValue? = null + private var completionCost: JsonField<String> = JsonMissing.of() + private var completionTokens: JsonField<Long> = JsonMissing.of() + private var count: JsonField<Long> = JsonMissing.of() + private var errorRate: JsonField<Double> = JsonMissing.of() + private var feedbackStats: JsonValue = JsonMissing.of() + private var latencyP50: JsonField<Double> = JsonMissing.of() + private var latencyP99: JsonField<Double> = JsonMissing.of() + private var maxStartTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var minStartTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var promptCost: JsonField<String> = JsonMissing.of() + private var promptTokens: JsonField<Long> = JsonMissing.of() + private var totalCost: JsonField<String> = JsonMissing.of() + private var totalTokens: JsonField<Long> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(group: Group) = apply { + examples = group.examples + filter = group.filter + groupKey = group.groupKey + completionCost = group.completionCost + completionTokens = group.completionTokens + count = group.count + errorRate = group.errorRate + feedbackStats = group.feedbackStats + latencyP50 = group.latencyP50 + latencyP99 = group.latencyP99 + maxStartTime = group.maxStartTime + minStartTime = group.minStartTime + promptCost = group.promptCost + promptTokens = group.promptTokens + totalCost = group.totalCost + totalTokens = group.totalTokens + additionalProperties = group.additionalProperties.toMutableMap() + } + + fun examples(examples: Examples) = examples(JsonField.of(examples)) + + /** + * Sets [Builder.examples] to an arbitrary JSON value. + * + * You should usually call [Builder.examples] with a well-typed [Examples] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun examples(examples: JsonField<Examples>) = apply { this.examples = examples } + + /** Alias for calling [examples] with `Examples.ofExampleWithRuns(exampleWithRuns)`. */ + fun examplesOfExampleWithRuns(exampleWithRuns: List<ExampleWithRuns>) = + examples(Examples.ofExampleWithRuns(exampleWithRuns)) + + /** + * Alias for calling [examples] with + * `Examples.ofExampleWithRunsChes(exampleWithRunsChes)`. + */ + fun examplesOfExampleWithRunsChes(exampleWithRunsChes: List<ExampleWithRunsCh>) = + examples(Examples.ofExampleWithRunsChes(exampleWithRunsChes)) + + fun filter(filter: String) = filter(JsonField.of(filter)) + + /** + * Sets [Builder.filter] to an arbitrary JSON value. + * + * You should usually call [Builder.filter] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun filter(filter: JsonField<String>) = apply { this.filter = filter } + + fun groupKey(groupKey: JsonValue) = apply { this.groupKey = groupKey } + + fun completionCost(completionCost: String?) = + completionCost(JsonField.ofNullable(completionCost)) + + /** Alias for calling [Builder.completionCost] with `completionCost.orElse(null)`. */ + fun completionCost(completionCost: Optional<String>) = + completionCost(completionCost.getOrNull()) + + /** + * Sets [Builder.completionCost] to an arbitrary JSON value. + * + * You should usually call [Builder.completionCost] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun completionCost(completionCost: JsonField<String>) = apply { + this.completionCost = completionCost + } + + fun completionTokens(completionTokens: Long?) = + completionTokens(JsonField.ofNullable(completionTokens)) + + /** + * Alias for [Builder.completionTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun completionTokens(completionTokens: Long) = + completionTokens(completionTokens as Long?) + + /** + * Alias for calling [Builder.completionTokens] with `completionTokens.orElse(null)`. + */ + fun completionTokens(completionTokens: Optional<Long>) = + completionTokens(completionTokens.getOrNull()) + + /** + * Sets [Builder.completionTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.completionTokens] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun completionTokens(completionTokens: JsonField<Long>) = apply { + this.completionTokens = completionTokens + } + + fun count(count: Long?) = count(JsonField.ofNullable(count)) + + /** + * Alias for [Builder.count]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun count(count: Long) = count(count as Long?) + + /** Alias for calling [Builder.count] with `count.orElse(null)`. */ + fun count(count: Optional<Long>) = count(count.getOrNull()) + + /** + * Sets [Builder.count] to an arbitrary JSON value. + * + * You should usually call [Builder.count] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun count(count: JsonField<Long>) = apply { this.count = count } + + fun errorRate(errorRate: Double?) = errorRate(JsonField.ofNullable(errorRate)) + + /** + * Alias for [Builder.errorRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun errorRate(errorRate: Double) = errorRate(errorRate as Double?) + + /** Alias for calling [Builder.errorRate] with `errorRate.orElse(null)`. */ + fun errorRate(errorRate: Optional<Double>) = errorRate(errorRate.getOrNull()) + + /** + * Sets [Builder.errorRate] to an arbitrary JSON value. + * + * You should usually call [Builder.errorRate] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun errorRate(errorRate: JsonField<Double>) = apply { this.errorRate = errorRate } + + fun feedbackStats(feedbackStats: JsonValue) = apply { + this.feedbackStats = feedbackStats + } + + fun latencyP50(latencyP50: Double?) = latencyP50(JsonField.ofNullable(latencyP50)) + + /** + * Alias for [Builder.latencyP50]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun latencyP50(latencyP50: Double) = latencyP50(latencyP50 as Double?) + + /** Alias for calling [Builder.latencyP50] with `latencyP50.orElse(null)`. */ + fun latencyP50(latencyP50: Optional<Double>) = latencyP50(latencyP50.getOrNull()) + + /** + * Sets [Builder.latencyP50] to an arbitrary JSON value. + * + * You should usually call [Builder.latencyP50] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun latencyP50(latencyP50: JsonField<Double>) = apply { this.latencyP50 = latencyP50 } + + fun latencyP99(latencyP99: Double?) = latencyP99(JsonField.ofNullable(latencyP99)) + + /** + * Alias for [Builder.latencyP99]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun latencyP99(latencyP99: Double) = latencyP99(latencyP99 as Double?) + + /** Alias for calling [Builder.latencyP99] with `latencyP99.orElse(null)`. */ + fun latencyP99(latencyP99: Optional<Double>) = latencyP99(latencyP99.getOrNull()) + + /** + * Sets [Builder.latencyP99] to an arbitrary JSON value. + * + * You should usually call [Builder.latencyP99] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun latencyP99(latencyP99: JsonField<Double>) = apply { this.latencyP99 = latencyP99 } + + fun maxStartTime(maxStartTime: OffsetDateTime?) = + maxStartTime(JsonField.ofNullable(maxStartTime)) + + /** Alias for calling [Builder.maxStartTime] with `maxStartTime.orElse(null)`. */ + fun maxStartTime(maxStartTime: Optional<OffsetDateTime>) = + maxStartTime(maxStartTime.getOrNull()) + + /** + * Sets [Builder.maxStartTime] to an arbitrary JSON value. + * + * You should usually call [Builder.maxStartTime] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun maxStartTime(maxStartTime: JsonField<OffsetDateTime>) = apply { + this.maxStartTime = maxStartTime + } + + fun minStartTime(minStartTime: OffsetDateTime?) = + minStartTime(JsonField.ofNullable(minStartTime)) + + /** Alias for calling [Builder.minStartTime] with `minStartTime.orElse(null)`. */ + fun minStartTime(minStartTime: Optional<OffsetDateTime>) = + minStartTime(minStartTime.getOrNull()) + + /** + * Sets [Builder.minStartTime] to an arbitrary JSON value. + * + * You should usually call [Builder.minStartTime] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun minStartTime(minStartTime: JsonField<OffsetDateTime>) = apply { + this.minStartTime = minStartTime + } + + fun promptCost(promptCost: String?) = promptCost(JsonField.ofNullable(promptCost)) + + /** Alias for calling [Builder.promptCost] with `promptCost.orElse(null)`. */ + fun promptCost(promptCost: Optional<String>) = promptCost(promptCost.getOrNull()) + + /** + * Sets [Builder.promptCost] to an arbitrary JSON value. + * + * You should usually call [Builder.promptCost] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun promptCost(promptCost: JsonField<String>) = apply { this.promptCost = promptCost } + + fun promptTokens(promptTokens: Long?) = promptTokens(JsonField.ofNullable(promptTokens)) + + /** + * Alias for [Builder.promptTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun promptTokens(promptTokens: Long) = promptTokens(promptTokens as Long?) + + /** Alias for calling [Builder.promptTokens] with `promptTokens.orElse(null)`. */ + fun promptTokens(promptTokens: Optional<Long>) = promptTokens(promptTokens.getOrNull()) + + /** + * Sets [Builder.promptTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.promptTokens] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun promptTokens(promptTokens: JsonField<Long>) = apply { + this.promptTokens = promptTokens + } + + fun totalCost(totalCost: String?) = totalCost(JsonField.ofNullable(totalCost)) + + /** Alias for calling [Builder.totalCost] with `totalCost.orElse(null)`. */ + fun totalCost(totalCost: Optional<String>) = totalCost(totalCost.getOrNull()) + + /** + * Sets [Builder.totalCost] to an arbitrary JSON value. + * + * You should usually call [Builder.totalCost] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun totalCost(totalCost: JsonField<String>) = apply { this.totalCost = totalCost } + + fun totalTokens(totalTokens: Long?) = totalTokens(JsonField.ofNullable(totalTokens)) + + /** + * Alias for [Builder.totalTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun totalTokens(totalTokens: Long) = totalTokens(totalTokens as Long?) + + /** Alias for calling [Builder.totalTokens] with `totalTokens.orElse(null)`. */ + fun totalTokens(totalTokens: Optional<Long>) = totalTokens(totalTokens.getOrNull()) + + /** + * Sets [Builder.totalTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.totalTokens] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun totalTokens(totalTokens: JsonField<Long>) = apply { this.totalTokens = totalTokens } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Group]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .examples() + * .filter() + * .groupKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Group = + Group( + checkRequired("examples", examples), + checkRequired("filter", filter), + checkRequired("groupKey", groupKey), + completionCost, + completionTokens, + count, + errorRate, + feedbackStats, + latencyP50, + latencyP99, + maxStartTime, + minStartTime, + promptCost, + promptTokens, + totalCost, + totalTokens, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Group = apply { + if (validated) { + return@apply + } + + examples().validate() + filter() + completionCost() + completionTokens() + count() + errorRate() + latencyP50() + latencyP99() + maxStartTime() + minStartTime() + promptCost() + promptTokens() + totalCost() + totalTokens() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (examples.asKnown().getOrNull()?.validity() ?: 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (if (completionCost.asKnown().isPresent) 1 else 0) + + (if (completionTokens.asKnown().isPresent) 1 else 0) + + (if (count.asKnown().isPresent) 1 else 0) + + (if (errorRate.asKnown().isPresent) 1 else 0) + + (if (latencyP50.asKnown().isPresent) 1 else 0) + + (if (latencyP99.asKnown().isPresent) 1 else 0) + + (if (maxStartTime.asKnown().isPresent) 1 else 0) + + (if (minStartTime.asKnown().isPresent) 1 else 0) + + (if (promptCost.asKnown().isPresent) 1 else 0) + + (if (promptTokens.asKnown().isPresent) 1 else 0) + + (if (totalCost.asKnown().isPresent) 1 else 0) + + (if (totalTokens.asKnown().isPresent) 1 else 0) + + @JsonDeserialize(using = Examples.Deserializer::class) + @JsonSerialize(using = Examples.Serializer::class) + class Examples + private constructor( + private val exampleWithRuns: List<ExampleWithRuns>? = null, + private val exampleWithRunsChes: List<ExampleWithRunsCh>? = null, + private val _json: JsonValue? = null, + ) { + + fun exampleWithRuns(): Optional<List<ExampleWithRuns>> = + Optional.ofNullable(exampleWithRuns) + + fun exampleWithRunsChes(): Optional<List<ExampleWithRunsCh>> = + Optional.ofNullable(exampleWithRunsChes) + + fun isExampleWithRuns(): Boolean = exampleWithRuns != null + + fun isExampleWithRunsChes(): Boolean = exampleWithRunsChes != null + + fun asExampleWithRuns(): List<ExampleWithRuns> = + exampleWithRuns.getOrThrow("exampleWithRuns") + + fun asExampleWithRunsChes(): List<ExampleWithRunsCh> = + exampleWithRunsChes.getOrThrow("exampleWithRunsChes") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + exampleWithRuns != null -> visitor.visitExampleWithRuns(exampleWithRuns) + exampleWithRunsChes != null -> + visitor.visitExampleWithRunsChes(exampleWithRunsChes) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Examples = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitExampleWithRuns(exampleWithRuns: List<ExampleWithRuns>) { + exampleWithRuns.forEach { it.validate() } + } + + override fun visitExampleWithRunsChes( + exampleWithRunsChes: List<ExampleWithRunsCh> + ) { + exampleWithRunsChes.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitExampleWithRuns(exampleWithRuns: List<ExampleWithRuns>) = + exampleWithRuns.sumOf { it.validity().toInt() } + + override fun visitExampleWithRunsChes( + exampleWithRunsChes: List<ExampleWithRunsCh> + ) = exampleWithRunsChes.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Examples && + exampleWithRuns == other.exampleWithRuns && + exampleWithRunsChes == other.exampleWithRunsChes + } + + override fun hashCode(): Int = Objects.hash(exampleWithRuns, exampleWithRunsChes) + + override fun toString(): String = + when { + exampleWithRuns != null -> "Examples{exampleWithRuns=$exampleWithRuns}" + exampleWithRunsChes != null -> + "Examples{exampleWithRunsChes=$exampleWithRunsChes}" + _json != null -> "Examples{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Examples") + } + + companion object { + + @JvmStatic + fun ofExampleWithRuns(exampleWithRuns: List<ExampleWithRuns>) = + Examples(exampleWithRuns = exampleWithRuns.toImmutable()) + + @JvmStatic + fun ofExampleWithRunsChes(exampleWithRunsChes: List<ExampleWithRunsCh>) = + Examples(exampleWithRunsChes = exampleWithRunsChes.toImmutable()) + } + + /** + * An interface that defines how to map each variant of [Examples] to a value of type + * [T]. + */ + interface Visitor<out T> { + + fun visitExampleWithRuns(exampleWithRuns: List<ExampleWithRuns>): T + + fun visitExampleWithRunsChes(exampleWithRunsChes: List<ExampleWithRunsCh>): T + + /** + * Maps an unknown variant of [Examples] to a value of type [T]. + * + * An instance of [Examples] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Examples: $json") + } + } + + internal class Deserializer : BaseDeserializer<Examples>(Examples::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Examples { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<List<ExampleWithRuns>>())?.let { + Examples(exampleWithRuns = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<List<ExampleWithRunsCh>>()) + ?.let { Examples(exampleWithRunsChes = it, _json = json) }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from boolean). + 0 -> Examples(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Examples>(Examples::class) { + + override fun serialize( + value: Examples, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.exampleWithRuns != null -> + generator.writeObject(value.exampleWithRuns) + value.exampleWithRunsChes != null -> + generator.writeObject(value.exampleWithRunsChes) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Examples") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Group && + examples == other.examples && + filter == other.filter && + groupKey == other.groupKey && + completionCost == other.completionCost && + completionTokens == other.completionTokens && + count == other.count && + errorRate == other.errorRate && + feedbackStats == other.feedbackStats && + latencyP50 == other.latencyP50 && + latencyP99 == other.latencyP99 && + maxStartTime == other.maxStartTime && + minStartTime == other.minStartTime && + promptCost == other.promptCost && + promptTokens == other.promptTokens && + totalCost == other.totalCost && + totalTokens == other.totalTokens && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + examples, + filter, + groupKey, + completionCost, + completionTokens, + count, + errorRate, + feedbackStats, + latencyP50, + latencyP99, + maxStartTime, + minStartTime, + promptCost, + promptTokens, + totalCost, + totalTokens, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Group{examples=$examples, filter=$filter, groupKey=$groupKey, completionCost=$completionCost, completionTokens=$completionTokens, count=$count, errorRate=$errorRate, feedbackStats=$feedbackStats, latencyP50=$latencyP50, latencyP99=$latencyP99, maxStartTime=$maxStartTime, minStartTime=$minStartTime, promptCost=$promptCost, promptTokens=$promptTokens, totalCost=$totalCost, totalTokens=$totalTokens, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupRunsResponse && + groups == other.groups && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(groups, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupRunsResponse{groups=$groups, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexCreateParams.kt new file mode 100644 index 00000000..7f7ad462 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexCreateParams.kt @@ -0,0 +1,408 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.index + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Index a dataset. */ +class IndexCreateParams +private constructor( + private val datasetId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun datasetId(): Optional<String> = Optional.ofNullable(datasetId) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tag(): Optional<String> = body.tag() + + /** + * Returns the raw JSON value of [tag]. + * + * Unlike [tag], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _tag(): JsonField<String> = body._tag() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): IndexCreateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [IndexCreateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [IndexCreateParams]. */ + class Builder internal constructor() { + + private var datasetId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(indexCreateParams: IndexCreateParams) = apply { + datasetId = indexCreateParams.datasetId + body = indexCreateParams.body.toBuilder() + additionalHeaders = indexCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = indexCreateParams.additionalQueryParams.toBuilder() + } + + fun datasetId(datasetId: String?) = apply { this.datasetId = datasetId } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [tag] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun tag(tag: String?) = apply { body.tag(tag) } + + /** Alias for calling [Builder.tag] with `tag.orElse(null)`. */ + fun tag(tag: Optional<String>) = tag(tag.getOrNull()) + + /** + * Sets [Builder.tag] to an arbitrary JSON value. + * + * You should usually call [Builder.tag] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tag(tag: JsonField<String>) = apply { body.tag(tag) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [IndexCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): IndexCreateParams = + IndexCreateParams( + datasetId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> datasetId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Dataset schema for serving. */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tag: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tag") @ExcludeMissing tag: JsonField<String> = JsonMissing.of() + ) : this(tag, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun tag(): Optional<String> = tag.getOptional("tag") + + /** + * Returns the raw JSON value of [tag]. + * + * Unlike [tag], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tag") @ExcludeMissing fun _tag(): JsonField<String> = tag + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var tag: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + tag = body.tag + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun tag(tag: String?) = tag(JsonField.ofNullable(tag)) + + /** Alias for calling [Builder.tag] with `tag.orElse(null)`. */ + fun tag(tag: Optional<String>) = tag(tag.getOrNull()) + + /** + * Sets [Builder.tag] to an arbitrary JSON value. + * + * You should usually call [Builder.tag] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tag(tag: JsonField<String>) = apply { this.tag = tag } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = Body(tag, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + tag() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (tag.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + tag == other.tag && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tag, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Body{tag=$tag, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is IndexCreateParams && + datasetId == other.datasetId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(datasetId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "IndexCreateParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexCreateResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexCreateResponse.kt new file mode 100644 index 00000000..f1e03eff --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexCreateResponse.kt @@ -0,0 +1,113 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.index + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class IndexCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [IndexCreateResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [IndexCreateResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(indexCreateResponse: IndexCreateResponse) = apply { + additionalProperties = indexCreateResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [IndexCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): IndexCreateResponse = IndexCreateResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): IndexCreateResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is IndexCreateResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "IndexCreateResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexDeleteAllParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexDeleteAllParams.kt new file mode 100644 index 00000000..43bb8221 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexDeleteAllParams.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.index + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Remove an index for a dataset. */ +class IndexDeleteAllParams +private constructor( + private val datasetId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun datasetId(): Optional<String> = Optional.ofNullable(datasetId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): IndexDeleteAllParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [IndexDeleteAllParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [IndexDeleteAllParams]. */ + class Builder internal constructor() { + + private var datasetId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(indexDeleteAllParams: IndexDeleteAllParams) = apply { + datasetId = indexDeleteAllParams.datasetId + additionalHeaders = indexDeleteAllParams.additionalHeaders.toBuilder() + additionalQueryParams = indexDeleteAllParams.additionalQueryParams.toBuilder() + additionalBodyProperties = indexDeleteAllParams.additionalBodyProperties.toMutableMap() + } + + fun datasetId(datasetId: String?) = apply { this.datasetId = datasetId } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [IndexDeleteAllParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): IndexDeleteAllParams = + IndexDeleteAllParams( + datasetId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> datasetId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is IndexDeleteAllParams && + datasetId == other.datasetId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(datasetId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "IndexDeleteAllParams{datasetId=$datasetId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexDeleteAllResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexDeleteAllResponse.kt new file mode 100644 index 00000000..9e3e3fa5 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexDeleteAllResponse.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.index + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class IndexDeleteAllResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [IndexDeleteAllResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [IndexDeleteAllResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(indexDeleteAllResponse: IndexDeleteAllResponse) = apply { + additionalProperties = indexDeleteAllResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [IndexDeleteAllResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): IndexDeleteAllResponse = + IndexDeleteAllResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): IndexDeleteAllResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is IndexDeleteAllResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "IndexDeleteAllResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexListParams.kt new file mode 100644 index 00000000..2220fa5a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexListParams.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.index + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get index info. */ +class IndexListParams +private constructor( + private val datasetId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun datasetId(): Optional<String> = Optional.ofNullable(datasetId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): IndexListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [IndexListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [IndexListParams]. */ + class Builder internal constructor() { + + private var datasetId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(indexListParams: IndexListParams) = apply { + datasetId = indexListParams.datasetId + additionalHeaders = indexListParams.additionalHeaders.toBuilder() + additionalQueryParams = indexListParams.additionalQueryParams.toBuilder() + } + + fun datasetId(datasetId: String?) = apply { this.datasetId = datasetId } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [IndexListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): IndexListParams = + IndexListParams(datasetId, additionalHeaders.build(), additionalQueryParams.build()) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> datasetId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is IndexListParams && + datasetId == other.datasetId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(datasetId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "IndexListParams{datasetId=$datasetId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexListResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexListResponse.kt new file mode 100644 index 00000000..1b58114b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexListResponse.kt @@ -0,0 +1,260 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.index + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Dataset schema for serving. */ +class IndexListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val datasetId: JsonField<String>, + private val lastUpdatedVersion: JsonField<OffsetDateTime>, + private val tag: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("dataset_id") @ExcludeMissing datasetId: JsonField<String> = JsonMissing.of(), + @JsonProperty("last_updated_version") + @ExcludeMissing + lastUpdatedVersion: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("tag") @ExcludeMissing tag: JsonField<String> = JsonMissing.of(), + ) : this(datasetId, lastUpdatedVersion, tag, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun datasetId(): String = datasetId.getRequired("dataset_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun lastUpdatedVersion(): Optional<OffsetDateTime> = + lastUpdatedVersion.getOptional("last_updated_version") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tag(): Optional<String> = tag.getOptional("tag") + + /** + * Returns the raw JSON value of [datasetId]. + * + * Unlike [datasetId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField<String> = datasetId + + /** + * Returns the raw JSON value of [lastUpdatedVersion]. + * + * Unlike [lastUpdatedVersion], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("last_updated_version") + @ExcludeMissing + fun _lastUpdatedVersion(): JsonField<OffsetDateTime> = lastUpdatedVersion + + /** + * Returns the raw JSON value of [tag]. + * + * Unlike [tag], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tag") @ExcludeMissing fun _tag(): JsonField<String> = tag + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [IndexListResponse]. + * + * The following fields are required: + * ```java + * .datasetId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [IndexListResponse]. */ + class Builder internal constructor() { + + private var datasetId: JsonField<String>? = null + private var lastUpdatedVersion: JsonField<OffsetDateTime> = JsonMissing.of() + private var tag: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(indexListResponse: IndexListResponse) = apply { + datasetId = indexListResponse.datasetId + lastUpdatedVersion = indexListResponse.lastUpdatedVersion + tag = indexListResponse.tag + additionalProperties = indexListResponse.additionalProperties.toMutableMap() + } + + fun datasetId(datasetId: String) = datasetId(JsonField.of(datasetId)) + + /** + * Sets [Builder.datasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun datasetId(datasetId: JsonField<String>) = apply { this.datasetId = datasetId } + + fun lastUpdatedVersion(lastUpdatedVersion: OffsetDateTime?) = + lastUpdatedVersion(JsonField.ofNullable(lastUpdatedVersion)) + + /** + * Alias for calling [Builder.lastUpdatedVersion] with `lastUpdatedVersion.orElse(null)`. + */ + fun lastUpdatedVersion(lastUpdatedVersion: Optional<OffsetDateTime>) = + lastUpdatedVersion(lastUpdatedVersion.getOrNull()) + + /** + * Sets [Builder.lastUpdatedVersion] to an arbitrary JSON value. + * + * You should usually call [Builder.lastUpdatedVersion] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun lastUpdatedVersion(lastUpdatedVersion: JsonField<OffsetDateTime>) = apply { + this.lastUpdatedVersion = lastUpdatedVersion + } + + fun tag(tag: String?) = tag(JsonField.ofNullable(tag)) + + /** Alias for calling [Builder.tag] with `tag.orElse(null)`. */ + fun tag(tag: Optional<String>) = tag(tag.getOrNull()) + + /** + * Sets [Builder.tag] to an arbitrary JSON value. + * + * You should usually call [Builder.tag] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tag(tag: JsonField<String>) = apply { this.tag = tag } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [IndexListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .datasetId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): IndexListResponse = + IndexListResponse( + checkRequired("datasetId", datasetId), + lastUpdatedVersion, + tag, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): IndexListResponse = apply { + if (validated) { + return@apply + } + + datasetId() + lastUpdatedVersion() + tag() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (datasetId.asKnown().isPresent) 1 else 0) + + (if (lastUpdatedVersion.asKnown().isPresent) 1 else 0) + + (if (tag.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is IndexListResponse && + datasetId == other.datasetId && + lastUpdatedVersion == other.lastUpdatedVersion && + tag == other.tag && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(datasetId, lastUpdatedVersion, tag, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "IndexListResponse{datasetId=$datasetId, lastUpdatedVersion=$lastUpdatedVersion, tag=$tag, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexSyncParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexSyncParams.kt new file mode 100644 index 00000000..4d0404f2 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexSyncParams.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.index + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Sync an index for a dataset. */ +class IndexSyncParams +private constructor( + private val datasetId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun datasetId(): Optional<String> = Optional.ofNullable(datasetId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): IndexSyncParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [IndexSyncParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [IndexSyncParams]. */ + class Builder internal constructor() { + + private var datasetId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(indexSyncParams: IndexSyncParams) = apply { + datasetId = indexSyncParams.datasetId + additionalHeaders = indexSyncParams.additionalHeaders.toBuilder() + additionalQueryParams = indexSyncParams.additionalQueryParams.toBuilder() + additionalBodyProperties = indexSyncParams.additionalBodyProperties.toMutableMap() + } + + fun datasetId(datasetId: String?) = apply { this.datasetId = datasetId } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [IndexSyncParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): IndexSyncParams = + IndexSyncParams( + datasetId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> datasetId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is IndexSyncParams && + datasetId == other.datasetId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(datasetId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "IndexSyncParams{datasetId=$datasetId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexSyncResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexSyncResponse.kt new file mode 100644 index 00000000..08c100c2 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexSyncResponse.kt @@ -0,0 +1,113 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.index + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class IndexSyncResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [IndexSyncResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [IndexSyncResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(indexSyncResponse: IndexSyncResponse) = apply { + additionalProperties = indexSyncResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [IndexSyncResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): IndexSyncResponse = IndexSyncResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): IndexSyncResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is IndexSyncResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "IndexSyncResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/PlaygroundExperimentBatchParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/PlaygroundExperimentBatchParams.kt new file mode 100644 index 00000000..934fead9 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/PlaygroundExperimentBatchParams.kt @@ -0,0 +1,1915 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.playgroundexperiment + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Dataset Handler */ +class PlaygroundExperimentBatchParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun datasetId(): String = body.datasetId() + + fun _manifest(): JsonValue = body._manifest() + + /** + * Configuration for a Runnable. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun options(): RunnableConfig = body.options() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun projectName(): String = body.projectName() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun secrets(): Secrets = body.secrets() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun batchSize(): Optional<Long> = body.batchSize() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun commit(): Optional<String> = body.commit() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun datasetSplits(): Optional<List<String>> = body.datasetSplits() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun evaluatorRules(): Optional<List<String>> = body.evaluatorRules() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun owner(): Optional<String> = body.owner() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun parallelToolCalls(): Optional<Boolean> = body.parallelToolCalls() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun repetitions(): Optional<Long> = body.repetitions() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun repoHandle(): Optional<String> = body.repoHandle() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun repoId(): Optional<String> = body.repoId() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun requestsPerSecond(): Optional<Long> = body.requestsPerSecond() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun runId(): Optional<String> = body.runId() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun runnerContext(): Optional<RunnerContextEnum> = body.runnerContext() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun toolChoice(): Optional<String> = body.toolChoice() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tools(): Optional<List<JsonValue>> = body.tools() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun useOrFallbackToWorkspaceSecrets(): Optional<Boolean> = + body.useOrFallbackToWorkspaceSecrets() + + /** + * Returns the raw JSON value of [datasetId]. + * + * Unlike [datasetId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _datasetId(): JsonField<String> = body._datasetId() + + /** + * Returns the raw JSON value of [options]. + * + * Unlike [options], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _options(): JsonField<RunnableConfig> = body._options() + + /** + * Returns the raw JSON value of [projectName]. + * + * Unlike [projectName], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _projectName(): JsonField<String> = body._projectName() + + /** + * Returns the raw JSON value of [secrets]. + * + * Unlike [secrets], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _secrets(): JsonField<Secrets> = body._secrets() + + /** + * Returns the raw JSON value of [batchSize]. + * + * Unlike [batchSize], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _batchSize(): JsonField<Long> = body._batchSize() + + /** + * Returns the raw JSON value of [commit]. + * + * Unlike [commit], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _commit(): JsonField<String> = body._commit() + + /** + * Returns the raw JSON value of [datasetSplits]. + * + * Unlike [datasetSplits], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _datasetSplits(): JsonField<List<String>> = body._datasetSplits() + + /** + * Returns the raw JSON value of [evaluatorRules]. + * + * Unlike [evaluatorRules], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _evaluatorRules(): JsonField<List<String>> = body._evaluatorRules() + + /** + * Returns the raw JSON value of [owner]. + * + * Unlike [owner], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _owner(): JsonField<String> = body._owner() + + /** + * Returns the raw JSON value of [parallelToolCalls]. + * + * Unlike [parallelToolCalls], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _parallelToolCalls(): JsonField<Boolean> = body._parallelToolCalls() + + /** + * Returns the raw JSON value of [repetitions]. + * + * Unlike [repetitions], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _repetitions(): JsonField<Long> = body._repetitions() + + /** + * Returns the raw JSON value of [repoHandle]. + * + * Unlike [repoHandle], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _repoHandle(): JsonField<String> = body._repoHandle() + + /** + * Returns the raw JSON value of [repoId]. + * + * Unlike [repoId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _repoId(): JsonField<String> = body._repoId() + + /** + * Returns the raw JSON value of [requestsPerSecond]. + * + * Unlike [requestsPerSecond], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _requestsPerSecond(): JsonField<Long> = body._requestsPerSecond() + + /** + * Returns the raw JSON value of [runId]. + * + * Unlike [runId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _runId(): JsonField<String> = body._runId() + + /** + * Returns the raw JSON value of [runnerContext]. + * + * Unlike [runnerContext], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _runnerContext(): JsonField<RunnerContextEnum> = body._runnerContext() + + /** + * Returns the raw JSON value of [toolChoice]. + * + * Unlike [toolChoice], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _toolChoice(): JsonField<String> = body._toolChoice() + + /** + * Returns the raw JSON value of [tools]. + * + * Unlike [tools], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _tools(): JsonField<List<JsonValue>> = body._tools() + + /** + * Returns the raw JSON value of [useOrFallbackToWorkspaceSecrets]. + * + * Unlike [useOrFallbackToWorkspaceSecrets], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _useOrFallbackToWorkspaceSecrets(): JsonField<Boolean> = + body._useOrFallbackToWorkspaceSecrets() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PlaygroundExperimentBatchParams]. + * + * The following fields are required: + * ```java + * .datasetId() + * .manifest() + * .options() + * .projectName() + * .secrets() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PlaygroundExperimentBatchParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(playgroundExperimentBatchParams: PlaygroundExperimentBatchParams) = + apply { + body = playgroundExperimentBatchParams.body.toBuilder() + additionalHeaders = playgroundExperimentBatchParams.additionalHeaders.toBuilder() + additionalQueryParams = + playgroundExperimentBatchParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [datasetId] + * - [manifest] + * - [options] + * - [projectName] + * - [secrets] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun datasetId(datasetId: String) = apply { body.datasetId(datasetId) } + + /** + * Sets [Builder.datasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun datasetId(datasetId: JsonField<String>) = apply { body.datasetId(datasetId) } + + fun manifest(manifest: JsonValue) = apply { body.manifest(manifest) } + + /** Configuration for a Runnable. */ + fun options(options: RunnableConfig) = apply { body.options(options) } + + /** + * Sets [Builder.options] to an arbitrary JSON value. + * + * You should usually call [Builder.options] with a well-typed [RunnableConfig] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun options(options: JsonField<RunnableConfig>) = apply { body.options(options) } + + fun projectName(projectName: String) = apply { body.projectName(projectName) } + + /** + * Sets [Builder.projectName] to an arbitrary JSON value. + * + * You should usually call [Builder.projectName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun projectName(projectName: JsonField<String>) = apply { body.projectName(projectName) } + + fun secrets(secrets: Secrets) = apply { body.secrets(secrets) } + + /** + * Sets [Builder.secrets] to an arbitrary JSON value. + * + * You should usually call [Builder.secrets] with a well-typed [Secrets] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun secrets(secrets: JsonField<Secrets>) = apply { body.secrets(secrets) } + + fun batchSize(batchSize: Long?) = apply { body.batchSize(batchSize) } + + /** + * Alias for [Builder.batchSize]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun batchSize(batchSize: Long) = batchSize(batchSize as Long?) + + /** Alias for calling [Builder.batchSize] with `batchSize.orElse(null)`. */ + fun batchSize(batchSize: Optional<Long>) = batchSize(batchSize.getOrNull()) + + /** + * Sets [Builder.batchSize] to an arbitrary JSON value. + * + * You should usually call [Builder.batchSize] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun batchSize(batchSize: JsonField<Long>) = apply { body.batchSize(batchSize) } + + fun commit(commit: String?) = apply { body.commit(commit) } + + /** Alias for calling [Builder.commit] with `commit.orElse(null)`. */ + fun commit(commit: Optional<String>) = commit(commit.getOrNull()) + + /** + * Sets [Builder.commit] to an arbitrary JSON value. + * + * You should usually call [Builder.commit] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun commit(commit: JsonField<String>) = apply { body.commit(commit) } + + fun datasetSplits(datasetSplits: List<String>?) = apply { + body.datasetSplits(datasetSplits) + } + + /** Alias for calling [Builder.datasetSplits] with `datasetSplits.orElse(null)`. */ + fun datasetSplits(datasetSplits: Optional<List<String>>) = + datasetSplits(datasetSplits.getOrNull()) + + /** + * Sets [Builder.datasetSplits] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetSplits] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun datasetSplits(datasetSplits: JsonField<List<String>>) = apply { + body.datasetSplits(datasetSplits) + } + + /** + * Adds a single [String] to [datasetSplits]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addDatasetSplit(datasetSplit: String) = apply { body.addDatasetSplit(datasetSplit) } + + fun evaluatorRules(evaluatorRules: List<String>?) = apply { + body.evaluatorRules(evaluatorRules) + } + + /** Alias for calling [Builder.evaluatorRules] with `evaluatorRules.orElse(null)`. */ + fun evaluatorRules(evaluatorRules: Optional<List<String>>) = + evaluatorRules(evaluatorRules.getOrNull()) + + /** + * Sets [Builder.evaluatorRules] to an arbitrary JSON value. + * + * You should usually call [Builder.evaluatorRules] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun evaluatorRules(evaluatorRules: JsonField<List<String>>) = apply { + body.evaluatorRules(evaluatorRules) + } + + /** + * Adds a single [String] to [evaluatorRules]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvaluatorRule(evaluatorRule: String) = apply { body.addEvaluatorRule(evaluatorRule) } + + fun owner(owner: String?) = apply { body.owner(owner) } + + /** Alias for calling [Builder.owner] with `owner.orElse(null)`. */ + fun owner(owner: Optional<String>) = owner(owner.getOrNull()) + + /** + * Sets [Builder.owner] to an arbitrary JSON value. + * + * You should usually call [Builder.owner] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun owner(owner: JsonField<String>) = apply { body.owner(owner) } + + fun parallelToolCalls(parallelToolCalls: Boolean?) = apply { + body.parallelToolCalls(parallelToolCalls) + } + + /** + * Alias for [Builder.parallelToolCalls]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun parallelToolCalls(parallelToolCalls: Boolean) = + parallelToolCalls(parallelToolCalls as Boolean?) + + /** Alias for calling [Builder.parallelToolCalls] with `parallelToolCalls.orElse(null)`. */ + fun parallelToolCalls(parallelToolCalls: Optional<Boolean>) = + parallelToolCalls(parallelToolCalls.getOrNull()) + + /** + * Sets [Builder.parallelToolCalls] to an arbitrary JSON value. + * + * You should usually call [Builder.parallelToolCalls] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun parallelToolCalls(parallelToolCalls: JsonField<Boolean>) = apply { + body.parallelToolCalls(parallelToolCalls) + } + + fun repetitions(repetitions: Long) = apply { body.repetitions(repetitions) } + + /** + * Sets [Builder.repetitions] to an arbitrary JSON value. + * + * You should usually call [Builder.repetitions] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun repetitions(repetitions: JsonField<Long>) = apply { body.repetitions(repetitions) } + + fun repoHandle(repoHandle: String?) = apply { body.repoHandle(repoHandle) } + + /** Alias for calling [Builder.repoHandle] with `repoHandle.orElse(null)`. */ + fun repoHandle(repoHandle: Optional<String>) = repoHandle(repoHandle.getOrNull()) + + /** + * Sets [Builder.repoHandle] to an arbitrary JSON value. + * + * You should usually call [Builder.repoHandle] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun repoHandle(repoHandle: JsonField<String>) = apply { body.repoHandle(repoHandle) } + + fun repoId(repoId: String?) = apply { body.repoId(repoId) } + + /** Alias for calling [Builder.repoId] with `repoId.orElse(null)`. */ + fun repoId(repoId: Optional<String>) = repoId(repoId.getOrNull()) + + /** + * Sets [Builder.repoId] to an arbitrary JSON value. + * + * You should usually call [Builder.repoId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun repoId(repoId: JsonField<String>) = apply { body.repoId(repoId) } + + fun requestsPerSecond(requestsPerSecond: Long?) = apply { + body.requestsPerSecond(requestsPerSecond) + } + + /** + * Alias for [Builder.requestsPerSecond]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun requestsPerSecond(requestsPerSecond: Long) = + requestsPerSecond(requestsPerSecond as Long?) + + /** Alias for calling [Builder.requestsPerSecond] with `requestsPerSecond.orElse(null)`. */ + fun requestsPerSecond(requestsPerSecond: Optional<Long>) = + requestsPerSecond(requestsPerSecond.getOrNull()) + + /** + * Sets [Builder.requestsPerSecond] to an arbitrary JSON value. + * + * You should usually call [Builder.requestsPerSecond] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun requestsPerSecond(requestsPerSecond: JsonField<Long>) = apply { + body.requestsPerSecond(requestsPerSecond) + } + + fun runId(runId: String?) = apply { body.runId(runId) } + + /** Alias for calling [Builder.runId] with `runId.orElse(null)`. */ + fun runId(runId: Optional<String>) = runId(runId.getOrNull()) + + /** + * Sets [Builder.runId] to an arbitrary JSON value. + * + * You should usually call [Builder.runId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun runId(runId: JsonField<String>) = apply { body.runId(runId) } + + fun runnerContext(runnerContext: RunnerContextEnum?) = apply { + body.runnerContext(runnerContext) + } + + /** Alias for calling [Builder.runnerContext] with `runnerContext.orElse(null)`. */ + fun runnerContext(runnerContext: Optional<RunnerContextEnum>) = + runnerContext(runnerContext.getOrNull()) + + /** + * Sets [Builder.runnerContext] to an arbitrary JSON value. + * + * You should usually call [Builder.runnerContext] with a well-typed [RunnerContextEnum] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun runnerContext(runnerContext: JsonField<RunnerContextEnum>) = apply { + body.runnerContext(runnerContext) + } + + fun toolChoice(toolChoice: String?) = apply { body.toolChoice(toolChoice) } + + /** Alias for calling [Builder.toolChoice] with `toolChoice.orElse(null)`. */ + fun toolChoice(toolChoice: Optional<String>) = toolChoice(toolChoice.getOrNull()) + + /** + * Sets [Builder.toolChoice] to an arbitrary JSON value. + * + * You should usually call [Builder.toolChoice] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolChoice(toolChoice: JsonField<String>) = apply { body.toolChoice(toolChoice) } + + fun tools(tools: List<JsonValue>?) = apply { body.tools(tools) } + + /** Alias for calling [Builder.tools] with `tools.orElse(null)`. */ + fun tools(tools: Optional<List<JsonValue>>) = tools(tools.getOrNull()) + + /** + * Sets [Builder.tools] to an arbitrary JSON value. + * + * You should usually call [Builder.tools] with a well-typed `List<JsonValue>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tools(tools: JsonField<List<JsonValue>>) = apply { body.tools(tools) } + + /** + * Adds a single [JsonValue] to [tools]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTool(tool: JsonValue) = apply { body.addTool(tool) } + + fun useOrFallbackToWorkspaceSecrets(useOrFallbackToWorkspaceSecrets: Boolean) = apply { + body.useOrFallbackToWorkspaceSecrets(useOrFallbackToWorkspaceSecrets) + } + + /** + * Sets [Builder.useOrFallbackToWorkspaceSecrets] to an arbitrary JSON value. + * + * You should usually call [Builder.useOrFallbackToWorkspaceSecrets] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun useOrFallbackToWorkspaceSecrets(useOrFallbackToWorkspaceSecrets: JsonField<Boolean>) = + apply { + body.useOrFallbackToWorkspaceSecrets(useOrFallbackToWorkspaceSecrets) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [PlaygroundExperimentBatchParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .datasetId() + * .manifest() + * .options() + * .projectName() + * .secrets() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PlaygroundExperimentBatchParams = + PlaygroundExperimentBatchParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val datasetId: JsonField<String>, + private val manifest: JsonValue, + private val options: JsonField<RunnableConfig>, + private val projectName: JsonField<String>, + private val secrets: JsonField<Secrets>, + private val batchSize: JsonField<Long>, + private val commit: JsonField<String>, + private val datasetSplits: JsonField<List<String>>, + private val evaluatorRules: JsonField<List<String>>, + private val owner: JsonField<String>, + private val parallelToolCalls: JsonField<Boolean>, + private val repetitions: JsonField<Long>, + private val repoHandle: JsonField<String>, + private val repoId: JsonField<String>, + private val requestsPerSecond: JsonField<Long>, + private val runId: JsonField<String>, + private val runnerContext: JsonField<RunnerContextEnum>, + private val toolChoice: JsonField<String>, + private val tools: JsonField<List<JsonValue>>, + private val useOrFallbackToWorkspaceSecrets: JsonField<Boolean>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dataset_id") + @ExcludeMissing + datasetId: JsonField<String> = JsonMissing.of(), + @JsonProperty("manifest") @ExcludeMissing manifest: JsonValue = JsonMissing.of(), + @JsonProperty("options") + @ExcludeMissing + options: JsonField<RunnableConfig> = JsonMissing.of(), + @JsonProperty("project_name") + @ExcludeMissing + projectName: JsonField<String> = JsonMissing.of(), + @JsonProperty("secrets") @ExcludeMissing secrets: JsonField<Secrets> = JsonMissing.of(), + @JsonProperty("batch_size") + @ExcludeMissing + batchSize: JsonField<Long> = JsonMissing.of(), + @JsonProperty("commit") @ExcludeMissing commit: JsonField<String> = JsonMissing.of(), + @JsonProperty("dataset_splits") + @ExcludeMissing + datasetSplits: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("evaluator_rules") + @ExcludeMissing + evaluatorRules: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("owner") @ExcludeMissing owner: JsonField<String> = JsonMissing.of(), + @JsonProperty("parallel_tool_calls") + @ExcludeMissing + parallelToolCalls: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("repetitions") + @ExcludeMissing + repetitions: JsonField<Long> = JsonMissing.of(), + @JsonProperty("repo_handle") + @ExcludeMissing + repoHandle: JsonField<String> = JsonMissing.of(), + @JsonProperty("repo_id") @ExcludeMissing repoId: JsonField<String> = JsonMissing.of(), + @JsonProperty("requests_per_second") + @ExcludeMissing + requestsPerSecond: JsonField<Long> = JsonMissing.of(), + @JsonProperty("run_id") @ExcludeMissing runId: JsonField<String> = JsonMissing.of(), + @JsonProperty("runner_context") + @ExcludeMissing + runnerContext: JsonField<RunnerContextEnum> = JsonMissing.of(), + @JsonProperty("tool_choice") + @ExcludeMissing + toolChoice: JsonField<String> = JsonMissing.of(), + @JsonProperty("tools") + @ExcludeMissing + tools: JsonField<List<JsonValue>> = JsonMissing.of(), + @JsonProperty("use_or_fallback_to_workspace_secrets") + @ExcludeMissing + useOrFallbackToWorkspaceSecrets: JsonField<Boolean> = JsonMissing.of(), + ) : this( + datasetId, + manifest, + options, + projectName, + secrets, + batchSize, + commit, + datasetSplits, + evaluatorRules, + owner, + parallelToolCalls, + repetitions, + repoHandle, + repoId, + requestsPerSecond, + runId, + runnerContext, + toolChoice, + tools, + useOrFallbackToWorkspaceSecrets, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun datasetId(): String = datasetId.getRequired("dataset_id") + + @JsonProperty("manifest") @ExcludeMissing fun _manifest(): JsonValue = manifest + + /** + * Configuration for a Runnable. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun options(): RunnableConfig = options.getRequired("options") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun projectName(): String = projectName.getRequired("project_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun secrets(): Secrets = secrets.getRequired("secrets") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun batchSize(): Optional<Long> = batchSize.getOptional("batch_size") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun commit(): Optional<String> = commit.getOptional("commit") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun datasetSplits(): Optional<List<String>> = datasetSplits.getOptional("dataset_splits") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun evaluatorRules(): Optional<List<String>> = evaluatorRules.getOptional("evaluator_rules") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun owner(): Optional<String> = owner.getOptional("owner") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun parallelToolCalls(): Optional<Boolean> = + parallelToolCalls.getOptional("parallel_tool_calls") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun repetitions(): Optional<Long> = repetitions.getOptional("repetitions") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun repoHandle(): Optional<String> = repoHandle.getOptional("repo_handle") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun repoId(): Optional<String> = repoId.getOptional("repo_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun requestsPerSecond(): Optional<Long> = + requestsPerSecond.getOptional("requests_per_second") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun runId(): Optional<String> = runId.getOptional("run_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun runnerContext(): Optional<RunnerContextEnum> = + runnerContext.getOptional("runner_context") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun toolChoice(): Optional<String> = toolChoice.getOptional("tool_choice") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun tools(): Optional<List<JsonValue>> = tools.getOptional("tools") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun useOrFallbackToWorkspaceSecrets(): Optional<Boolean> = + useOrFallbackToWorkspaceSecrets.getOptional("use_or_fallback_to_workspace_secrets") + + /** + * Returns the raw JSON value of [datasetId]. + * + * Unlike [datasetId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField<String> = datasetId + + /** + * Returns the raw JSON value of [options]. + * + * Unlike [options], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("options") @ExcludeMissing fun _options(): JsonField<RunnableConfig> = options + + /** + * Returns the raw JSON value of [projectName]. + * + * Unlike [projectName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("project_name") + @ExcludeMissing + fun _projectName(): JsonField<String> = projectName + + /** + * Returns the raw JSON value of [secrets]. + * + * Unlike [secrets], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("secrets") @ExcludeMissing fun _secrets(): JsonField<Secrets> = secrets + + /** + * Returns the raw JSON value of [batchSize]. + * + * Unlike [batchSize], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("batch_size") @ExcludeMissing fun _batchSize(): JsonField<Long> = batchSize + + /** + * Returns the raw JSON value of [commit]. + * + * Unlike [commit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("commit") @ExcludeMissing fun _commit(): JsonField<String> = commit + + /** + * Returns the raw JSON value of [datasetSplits]. + * + * Unlike [datasetSplits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dataset_splits") + @ExcludeMissing + fun _datasetSplits(): JsonField<List<String>> = datasetSplits + + /** + * Returns the raw JSON value of [evaluatorRules]. + * + * Unlike [evaluatorRules], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("evaluator_rules") + @ExcludeMissing + fun _evaluatorRules(): JsonField<List<String>> = evaluatorRules + + /** + * Returns the raw JSON value of [owner]. + * + * Unlike [owner], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("owner") @ExcludeMissing fun _owner(): JsonField<String> = owner + + /** + * Returns the raw JSON value of [parallelToolCalls]. + * + * Unlike [parallelToolCalls], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("parallel_tool_calls") + @ExcludeMissing + fun _parallelToolCalls(): JsonField<Boolean> = parallelToolCalls + + /** + * Returns the raw JSON value of [repetitions]. + * + * Unlike [repetitions], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("repetitions") + @ExcludeMissing + fun _repetitions(): JsonField<Long> = repetitions + + /** + * Returns the raw JSON value of [repoHandle]. + * + * Unlike [repoHandle], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("repo_handle") + @ExcludeMissing + fun _repoHandle(): JsonField<String> = repoHandle + + /** + * Returns the raw JSON value of [repoId]. + * + * Unlike [repoId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("repo_id") @ExcludeMissing fun _repoId(): JsonField<String> = repoId + + /** + * Returns the raw JSON value of [requestsPerSecond]. + * + * Unlike [requestsPerSecond], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("requests_per_second") + @ExcludeMissing + fun _requestsPerSecond(): JsonField<Long> = requestsPerSecond + + /** + * Returns the raw JSON value of [runId]. + * + * Unlike [runId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_id") @ExcludeMissing fun _runId(): JsonField<String> = runId + + /** + * Returns the raw JSON value of [runnerContext]. + * + * Unlike [runnerContext], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("runner_context") + @ExcludeMissing + fun _runnerContext(): JsonField<RunnerContextEnum> = runnerContext + + /** + * Returns the raw JSON value of [toolChoice]. + * + * Unlike [toolChoice], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tool_choice") + @ExcludeMissing + fun _toolChoice(): JsonField<String> = toolChoice + + /** + * Returns the raw JSON value of [tools]. + * + * Unlike [tools], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tools") @ExcludeMissing fun _tools(): JsonField<List<JsonValue>> = tools + + /** + * Returns the raw JSON value of [useOrFallbackToWorkspaceSecrets]. + * + * Unlike [useOrFallbackToWorkspaceSecrets], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("use_or_fallback_to_workspace_secrets") + @ExcludeMissing + fun _useOrFallbackToWorkspaceSecrets(): JsonField<Boolean> = useOrFallbackToWorkspaceSecrets + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .datasetId() + * .manifest() + * .options() + * .projectName() + * .secrets() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var datasetId: JsonField<String>? = null + private var manifest: JsonValue? = null + private var options: JsonField<RunnableConfig>? = null + private var projectName: JsonField<String>? = null + private var secrets: JsonField<Secrets>? = null + private var batchSize: JsonField<Long> = JsonMissing.of() + private var commit: JsonField<String> = JsonMissing.of() + private var datasetSplits: JsonField<MutableList<String>>? = null + private var evaluatorRules: JsonField<MutableList<String>>? = null + private var owner: JsonField<String> = JsonMissing.of() + private var parallelToolCalls: JsonField<Boolean> = JsonMissing.of() + private var repetitions: JsonField<Long> = JsonMissing.of() + private var repoHandle: JsonField<String> = JsonMissing.of() + private var repoId: JsonField<String> = JsonMissing.of() + private var requestsPerSecond: JsonField<Long> = JsonMissing.of() + private var runId: JsonField<String> = JsonMissing.of() + private var runnerContext: JsonField<RunnerContextEnum> = JsonMissing.of() + private var toolChoice: JsonField<String> = JsonMissing.of() + private var tools: JsonField<MutableList<JsonValue>>? = null + private var useOrFallbackToWorkspaceSecrets: JsonField<Boolean> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + datasetId = body.datasetId + manifest = body.manifest + options = body.options + projectName = body.projectName + secrets = body.secrets + batchSize = body.batchSize + commit = body.commit + datasetSplits = body.datasetSplits.map { it.toMutableList() } + evaluatorRules = body.evaluatorRules.map { it.toMutableList() } + owner = body.owner + parallelToolCalls = body.parallelToolCalls + repetitions = body.repetitions + repoHandle = body.repoHandle + repoId = body.repoId + requestsPerSecond = body.requestsPerSecond + runId = body.runId + runnerContext = body.runnerContext + toolChoice = body.toolChoice + tools = body.tools.map { it.toMutableList() } + useOrFallbackToWorkspaceSecrets = body.useOrFallbackToWorkspaceSecrets + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun datasetId(datasetId: String) = datasetId(JsonField.of(datasetId)) + + /** + * Sets [Builder.datasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun datasetId(datasetId: JsonField<String>) = apply { this.datasetId = datasetId } + + fun manifest(manifest: JsonValue) = apply { this.manifest = manifest } + + /** Configuration for a Runnable. */ + fun options(options: RunnableConfig) = options(JsonField.of(options)) + + /** + * Sets [Builder.options] to an arbitrary JSON value. + * + * You should usually call [Builder.options] with a well-typed [RunnableConfig] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun options(options: JsonField<RunnableConfig>) = apply { this.options = options } + + fun projectName(projectName: String) = projectName(JsonField.of(projectName)) + + /** + * Sets [Builder.projectName] to an arbitrary JSON value. + * + * You should usually call [Builder.projectName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun projectName(projectName: JsonField<String>) = apply { + this.projectName = projectName + } + + fun secrets(secrets: Secrets) = secrets(JsonField.of(secrets)) + + /** + * Sets [Builder.secrets] to an arbitrary JSON value. + * + * You should usually call [Builder.secrets] with a well-typed [Secrets] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun secrets(secrets: JsonField<Secrets>) = apply { this.secrets = secrets } + + fun batchSize(batchSize: Long?) = batchSize(JsonField.ofNullable(batchSize)) + + /** + * Alias for [Builder.batchSize]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun batchSize(batchSize: Long) = batchSize(batchSize as Long?) + + /** Alias for calling [Builder.batchSize] with `batchSize.orElse(null)`. */ + fun batchSize(batchSize: Optional<Long>) = batchSize(batchSize.getOrNull()) + + /** + * Sets [Builder.batchSize] to an arbitrary JSON value. + * + * You should usually call [Builder.batchSize] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun batchSize(batchSize: JsonField<Long>) = apply { this.batchSize = batchSize } + + fun commit(commit: String?) = commit(JsonField.ofNullable(commit)) + + /** Alias for calling [Builder.commit] with `commit.orElse(null)`. */ + fun commit(commit: Optional<String>) = commit(commit.getOrNull()) + + /** + * Sets [Builder.commit] to an arbitrary JSON value. + * + * You should usually call [Builder.commit] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun commit(commit: JsonField<String>) = apply { this.commit = commit } + + fun datasetSplits(datasetSplits: List<String>?) = + datasetSplits(JsonField.ofNullable(datasetSplits)) + + /** Alias for calling [Builder.datasetSplits] with `datasetSplits.orElse(null)`. */ + fun datasetSplits(datasetSplits: Optional<List<String>>) = + datasetSplits(datasetSplits.getOrNull()) + + /** + * Sets [Builder.datasetSplits] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetSplits] with a well-typed `List<String>` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun datasetSplits(datasetSplits: JsonField<List<String>>) = apply { + this.datasetSplits = datasetSplits.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [datasetSplits]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addDatasetSplit(datasetSplit: String) = apply { + datasetSplits = + (datasetSplits ?: JsonField.of(mutableListOf())).also { + checkKnown("datasetSplits", it).add(datasetSplit) + } + } + + fun evaluatorRules(evaluatorRules: List<String>?) = + evaluatorRules(JsonField.ofNullable(evaluatorRules)) + + /** Alias for calling [Builder.evaluatorRules] with `evaluatorRules.orElse(null)`. */ + fun evaluatorRules(evaluatorRules: Optional<List<String>>) = + evaluatorRules(evaluatorRules.getOrNull()) + + /** + * Sets [Builder.evaluatorRules] to an arbitrary JSON value. + * + * You should usually call [Builder.evaluatorRules] with a well-typed `List<String>` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun evaluatorRules(evaluatorRules: JsonField<List<String>>) = apply { + this.evaluatorRules = evaluatorRules.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [evaluatorRules]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvaluatorRule(evaluatorRule: String) = apply { + evaluatorRules = + (evaluatorRules ?: JsonField.of(mutableListOf())).also { + checkKnown("evaluatorRules", it).add(evaluatorRule) + } + } + + fun owner(owner: String?) = owner(JsonField.ofNullable(owner)) + + /** Alias for calling [Builder.owner] with `owner.orElse(null)`. */ + fun owner(owner: Optional<String>) = owner(owner.getOrNull()) + + /** + * Sets [Builder.owner] to an arbitrary JSON value. + * + * You should usually call [Builder.owner] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun owner(owner: JsonField<String>) = apply { this.owner = owner } + + fun parallelToolCalls(parallelToolCalls: Boolean?) = + parallelToolCalls(JsonField.ofNullable(parallelToolCalls)) + + /** + * Alias for [Builder.parallelToolCalls]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun parallelToolCalls(parallelToolCalls: Boolean) = + parallelToolCalls(parallelToolCalls as Boolean?) + + /** + * Alias for calling [Builder.parallelToolCalls] with `parallelToolCalls.orElse(null)`. + */ + fun parallelToolCalls(parallelToolCalls: Optional<Boolean>) = + parallelToolCalls(parallelToolCalls.getOrNull()) + + /** + * Sets [Builder.parallelToolCalls] to an arbitrary JSON value. + * + * You should usually call [Builder.parallelToolCalls] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun parallelToolCalls(parallelToolCalls: JsonField<Boolean>) = apply { + this.parallelToolCalls = parallelToolCalls + } + + fun repetitions(repetitions: Long) = repetitions(JsonField.of(repetitions)) + + /** + * Sets [Builder.repetitions] to an arbitrary JSON value. + * + * You should usually call [Builder.repetitions] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun repetitions(repetitions: JsonField<Long>) = apply { this.repetitions = repetitions } + + fun repoHandle(repoHandle: String?) = repoHandle(JsonField.ofNullable(repoHandle)) + + /** Alias for calling [Builder.repoHandle] with `repoHandle.orElse(null)`. */ + fun repoHandle(repoHandle: Optional<String>) = repoHandle(repoHandle.getOrNull()) + + /** + * Sets [Builder.repoHandle] to an arbitrary JSON value. + * + * You should usually call [Builder.repoHandle] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun repoHandle(repoHandle: JsonField<String>) = apply { this.repoHandle = repoHandle } + + fun repoId(repoId: String?) = repoId(JsonField.ofNullable(repoId)) + + /** Alias for calling [Builder.repoId] with `repoId.orElse(null)`. */ + fun repoId(repoId: Optional<String>) = repoId(repoId.getOrNull()) + + /** + * Sets [Builder.repoId] to an arbitrary JSON value. + * + * You should usually call [Builder.repoId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun repoId(repoId: JsonField<String>) = apply { this.repoId = repoId } + + fun requestsPerSecond(requestsPerSecond: Long?) = + requestsPerSecond(JsonField.ofNullable(requestsPerSecond)) + + /** + * Alias for [Builder.requestsPerSecond]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun requestsPerSecond(requestsPerSecond: Long) = + requestsPerSecond(requestsPerSecond as Long?) + + /** + * Alias for calling [Builder.requestsPerSecond] with `requestsPerSecond.orElse(null)`. + */ + fun requestsPerSecond(requestsPerSecond: Optional<Long>) = + requestsPerSecond(requestsPerSecond.getOrNull()) + + /** + * Sets [Builder.requestsPerSecond] to an arbitrary JSON value. + * + * You should usually call [Builder.requestsPerSecond] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun requestsPerSecond(requestsPerSecond: JsonField<Long>) = apply { + this.requestsPerSecond = requestsPerSecond + } + + fun runId(runId: String?) = runId(JsonField.ofNullable(runId)) + + /** Alias for calling [Builder.runId] with `runId.orElse(null)`. */ + fun runId(runId: Optional<String>) = runId(runId.getOrNull()) + + /** + * Sets [Builder.runId] to an arbitrary JSON value. + * + * You should usually call [Builder.runId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun runId(runId: JsonField<String>) = apply { this.runId = runId } + + fun runnerContext(runnerContext: RunnerContextEnum?) = + runnerContext(JsonField.ofNullable(runnerContext)) + + /** Alias for calling [Builder.runnerContext] with `runnerContext.orElse(null)`. */ + fun runnerContext(runnerContext: Optional<RunnerContextEnum>) = + runnerContext(runnerContext.getOrNull()) + + /** + * Sets [Builder.runnerContext] to an arbitrary JSON value. + * + * You should usually call [Builder.runnerContext] with a well-typed [RunnerContextEnum] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun runnerContext(runnerContext: JsonField<RunnerContextEnum>) = apply { + this.runnerContext = runnerContext + } + + fun toolChoice(toolChoice: String?) = toolChoice(JsonField.ofNullable(toolChoice)) + + /** Alias for calling [Builder.toolChoice] with `toolChoice.orElse(null)`. */ + fun toolChoice(toolChoice: Optional<String>) = toolChoice(toolChoice.getOrNull()) + + /** + * Sets [Builder.toolChoice] to an arbitrary JSON value. + * + * You should usually call [Builder.toolChoice] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun toolChoice(toolChoice: JsonField<String>) = apply { this.toolChoice = toolChoice } + + fun tools(tools: List<JsonValue>?) = tools(JsonField.ofNullable(tools)) + + /** Alias for calling [Builder.tools] with `tools.orElse(null)`. */ + fun tools(tools: Optional<List<JsonValue>>) = tools(tools.getOrNull()) + + /** + * Sets [Builder.tools] to an arbitrary JSON value. + * + * You should usually call [Builder.tools] with a well-typed `List<JsonValue>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tools(tools: JsonField<List<JsonValue>>) = apply { + this.tools = tools.map { it.toMutableList() } + } + + /** + * Adds a single [JsonValue] to [tools]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTool(tool: JsonValue) = apply { + tools = + (tools ?: JsonField.of(mutableListOf())).also { + checkKnown("tools", it).add(tool) + } + } + + fun useOrFallbackToWorkspaceSecrets(useOrFallbackToWorkspaceSecrets: Boolean) = + useOrFallbackToWorkspaceSecrets(JsonField.of(useOrFallbackToWorkspaceSecrets)) + + /** + * Sets [Builder.useOrFallbackToWorkspaceSecrets] to an arbitrary JSON value. + * + * You should usually call [Builder.useOrFallbackToWorkspaceSecrets] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun useOrFallbackToWorkspaceSecrets( + useOrFallbackToWorkspaceSecrets: JsonField<Boolean> + ) = apply { this.useOrFallbackToWorkspaceSecrets = useOrFallbackToWorkspaceSecrets } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .datasetId() + * .manifest() + * .options() + * .projectName() + * .secrets() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("datasetId", datasetId), + checkRequired("manifest", manifest), + checkRequired("options", options), + checkRequired("projectName", projectName), + checkRequired("secrets", secrets), + batchSize, + commit, + (datasetSplits ?: JsonMissing.of()).map { it.toImmutable() }, + (evaluatorRules ?: JsonMissing.of()).map { it.toImmutable() }, + owner, + parallelToolCalls, + repetitions, + repoHandle, + repoId, + requestsPerSecond, + runId, + runnerContext, + toolChoice, + (tools ?: JsonMissing.of()).map { it.toImmutable() }, + useOrFallbackToWorkspaceSecrets, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + datasetId() + options().validate() + projectName() + secrets().validate() + batchSize() + commit() + datasetSplits() + evaluatorRules() + owner() + parallelToolCalls() + repetitions() + repoHandle() + repoId() + requestsPerSecond() + runId() + runnerContext().ifPresent { it.validate() } + toolChoice() + tools() + useOrFallbackToWorkspaceSecrets() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (datasetId.asKnown().isPresent) 1 else 0) + + (options.asKnown().getOrNull()?.validity() ?: 0) + + (if (projectName.asKnown().isPresent) 1 else 0) + + (secrets.asKnown().getOrNull()?.validity() ?: 0) + + (if (batchSize.asKnown().isPresent) 1 else 0) + + (if (commit.asKnown().isPresent) 1 else 0) + + (datasetSplits.asKnown().getOrNull()?.size ?: 0) + + (evaluatorRules.asKnown().getOrNull()?.size ?: 0) + + (if (owner.asKnown().isPresent) 1 else 0) + + (if (parallelToolCalls.asKnown().isPresent) 1 else 0) + + (if (repetitions.asKnown().isPresent) 1 else 0) + + (if (repoHandle.asKnown().isPresent) 1 else 0) + + (if (repoId.asKnown().isPresent) 1 else 0) + + (if (requestsPerSecond.asKnown().isPresent) 1 else 0) + + (if (runId.asKnown().isPresent) 1 else 0) + + (runnerContext.asKnown().getOrNull()?.validity() ?: 0) + + (if (toolChoice.asKnown().isPresent) 1 else 0) + + (tools.asKnown().getOrNull()?.size ?: 0) + + (if (useOrFallbackToWorkspaceSecrets.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + datasetId == other.datasetId && + manifest == other.manifest && + options == other.options && + projectName == other.projectName && + secrets == other.secrets && + batchSize == other.batchSize && + commit == other.commit && + datasetSplits == other.datasetSplits && + evaluatorRules == other.evaluatorRules && + owner == other.owner && + parallelToolCalls == other.parallelToolCalls && + repetitions == other.repetitions && + repoHandle == other.repoHandle && + repoId == other.repoId && + requestsPerSecond == other.requestsPerSecond && + runId == other.runId && + runnerContext == other.runnerContext && + toolChoice == other.toolChoice && + tools == other.tools && + useOrFallbackToWorkspaceSecrets == other.useOrFallbackToWorkspaceSecrets && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + datasetId, + manifest, + options, + projectName, + secrets, + batchSize, + commit, + datasetSplits, + evaluatorRules, + owner, + parallelToolCalls, + repetitions, + repoHandle, + repoId, + requestsPerSecond, + runId, + runnerContext, + toolChoice, + tools, + useOrFallbackToWorkspaceSecrets, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{datasetId=$datasetId, manifest=$manifest, options=$options, projectName=$projectName, secrets=$secrets, batchSize=$batchSize, commit=$commit, datasetSplits=$datasetSplits, evaluatorRules=$evaluatorRules, owner=$owner, parallelToolCalls=$parallelToolCalls, repetitions=$repetitions, repoHandle=$repoHandle, repoId=$repoId, requestsPerSecond=$requestsPerSecond, runId=$runId, runnerContext=$runnerContext, toolChoice=$toolChoice, tools=$tools, useOrFallbackToWorkspaceSecrets=$useOrFallbackToWorkspaceSecrets, additionalProperties=$additionalProperties}" + } + + class Secrets + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Secrets]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Secrets]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(secrets: Secrets) = apply { + additionalProperties = secrets.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Secrets]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Secrets = Secrets(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Secrets = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Secrets && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Secrets{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PlaygroundExperimentBatchParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "PlaygroundExperimentBatchParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/PlaygroundExperimentBatchResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/PlaygroundExperimentBatchResponse.kt new file mode 100644 index 00000000..33ef0195 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/PlaygroundExperimentBatchResponse.kt @@ -0,0 +1,121 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.playgroundexperiment + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class PlaygroundExperimentBatchResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PlaygroundExperimentBatchResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PlaygroundExperimentBatchResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(playgroundExperimentBatchResponse: PlaygroundExperimentBatchResponse) = + apply { + additionalProperties = + playgroundExperimentBatchResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PlaygroundExperimentBatchResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PlaygroundExperimentBatchResponse = + PlaygroundExperimentBatchResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): PlaygroundExperimentBatchResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PlaygroundExperimentBatchResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PlaygroundExperimentBatchResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/PlaygroundExperimentStreamParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/PlaygroundExperimentStreamParams.kt new file mode 100644 index 00000000..300fecdd --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/PlaygroundExperimentStreamParams.kt @@ -0,0 +1,1836 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.playgroundexperiment + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Stream Dataset Handler */ +class PlaygroundExperimentStreamParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun datasetId(): String = body.datasetId() + + fun _manifest(): JsonValue = body._manifest() + + /** + * Configuration for a Runnable. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun options(): RunnableConfig = body.options() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun projectName(): String = body.projectName() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun secrets(): Secrets = body.secrets() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun commit(): Optional<String> = body.commit() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun datasetSplits(): Optional<List<String>> = body.datasetSplits() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun evaluatorRules(): Optional<List<String>> = body.evaluatorRules() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun owner(): Optional<String> = body.owner() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun parallelToolCalls(): Optional<Boolean> = body.parallelToolCalls() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun repetitions(): Optional<Long> = body.repetitions() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun repoHandle(): Optional<String> = body.repoHandle() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun repoId(): Optional<String> = body.repoId() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun requestsPerSecond(): Optional<Long> = body.requestsPerSecond() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun runId(): Optional<String> = body.runId() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun runnerContext(): Optional<RunnerContextEnum> = body.runnerContext() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun toolChoice(): Optional<String> = body.toolChoice() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tools(): Optional<List<JsonValue>> = body.tools() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun useOrFallbackToWorkspaceSecrets(): Optional<Boolean> = + body.useOrFallbackToWorkspaceSecrets() + + /** + * Returns the raw JSON value of [datasetId]. + * + * Unlike [datasetId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _datasetId(): JsonField<String> = body._datasetId() + + /** + * Returns the raw JSON value of [options]. + * + * Unlike [options], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _options(): JsonField<RunnableConfig> = body._options() + + /** + * Returns the raw JSON value of [projectName]. + * + * Unlike [projectName], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _projectName(): JsonField<String> = body._projectName() + + /** + * Returns the raw JSON value of [secrets]. + * + * Unlike [secrets], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _secrets(): JsonField<Secrets> = body._secrets() + + /** + * Returns the raw JSON value of [commit]. + * + * Unlike [commit], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _commit(): JsonField<String> = body._commit() + + /** + * Returns the raw JSON value of [datasetSplits]. + * + * Unlike [datasetSplits], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _datasetSplits(): JsonField<List<String>> = body._datasetSplits() + + /** + * Returns the raw JSON value of [evaluatorRules]. + * + * Unlike [evaluatorRules], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _evaluatorRules(): JsonField<List<String>> = body._evaluatorRules() + + /** + * Returns the raw JSON value of [owner]. + * + * Unlike [owner], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _owner(): JsonField<String> = body._owner() + + /** + * Returns the raw JSON value of [parallelToolCalls]. + * + * Unlike [parallelToolCalls], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _parallelToolCalls(): JsonField<Boolean> = body._parallelToolCalls() + + /** + * Returns the raw JSON value of [repetitions]. + * + * Unlike [repetitions], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _repetitions(): JsonField<Long> = body._repetitions() + + /** + * Returns the raw JSON value of [repoHandle]. + * + * Unlike [repoHandle], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _repoHandle(): JsonField<String> = body._repoHandle() + + /** + * Returns the raw JSON value of [repoId]. + * + * Unlike [repoId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _repoId(): JsonField<String> = body._repoId() + + /** + * Returns the raw JSON value of [requestsPerSecond]. + * + * Unlike [requestsPerSecond], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _requestsPerSecond(): JsonField<Long> = body._requestsPerSecond() + + /** + * Returns the raw JSON value of [runId]. + * + * Unlike [runId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _runId(): JsonField<String> = body._runId() + + /** + * Returns the raw JSON value of [runnerContext]. + * + * Unlike [runnerContext], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _runnerContext(): JsonField<RunnerContextEnum> = body._runnerContext() + + /** + * Returns the raw JSON value of [toolChoice]. + * + * Unlike [toolChoice], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _toolChoice(): JsonField<String> = body._toolChoice() + + /** + * Returns the raw JSON value of [tools]. + * + * Unlike [tools], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _tools(): JsonField<List<JsonValue>> = body._tools() + + /** + * Returns the raw JSON value of [useOrFallbackToWorkspaceSecrets]. + * + * Unlike [useOrFallbackToWorkspaceSecrets], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _useOrFallbackToWorkspaceSecrets(): JsonField<Boolean> = + body._useOrFallbackToWorkspaceSecrets() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PlaygroundExperimentStreamParams]. + * + * The following fields are required: + * ```java + * .datasetId() + * .manifest() + * .options() + * .projectName() + * .secrets() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PlaygroundExperimentStreamParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(playgroundExperimentStreamParams: PlaygroundExperimentStreamParams) = + apply { + body = playgroundExperimentStreamParams.body.toBuilder() + additionalHeaders = playgroundExperimentStreamParams.additionalHeaders.toBuilder() + additionalQueryParams = + playgroundExperimentStreamParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [datasetId] + * - [manifest] + * - [options] + * - [projectName] + * - [secrets] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun datasetId(datasetId: String) = apply { body.datasetId(datasetId) } + + /** + * Sets [Builder.datasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun datasetId(datasetId: JsonField<String>) = apply { body.datasetId(datasetId) } + + fun manifest(manifest: JsonValue) = apply { body.manifest(manifest) } + + /** Configuration for a Runnable. */ + fun options(options: RunnableConfig) = apply { body.options(options) } + + /** + * Sets [Builder.options] to an arbitrary JSON value. + * + * You should usually call [Builder.options] with a well-typed [RunnableConfig] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun options(options: JsonField<RunnableConfig>) = apply { body.options(options) } + + fun projectName(projectName: String) = apply { body.projectName(projectName) } + + /** + * Sets [Builder.projectName] to an arbitrary JSON value. + * + * You should usually call [Builder.projectName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun projectName(projectName: JsonField<String>) = apply { body.projectName(projectName) } + + fun secrets(secrets: Secrets) = apply { body.secrets(secrets) } + + /** + * Sets [Builder.secrets] to an arbitrary JSON value. + * + * You should usually call [Builder.secrets] with a well-typed [Secrets] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun secrets(secrets: JsonField<Secrets>) = apply { body.secrets(secrets) } + + fun commit(commit: String?) = apply { body.commit(commit) } + + /** Alias for calling [Builder.commit] with `commit.orElse(null)`. */ + fun commit(commit: Optional<String>) = commit(commit.getOrNull()) + + /** + * Sets [Builder.commit] to an arbitrary JSON value. + * + * You should usually call [Builder.commit] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun commit(commit: JsonField<String>) = apply { body.commit(commit) } + + fun datasetSplits(datasetSplits: List<String>?) = apply { + body.datasetSplits(datasetSplits) + } + + /** Alias for calling [Builder.datasetSplits] with `datasetSplits.orElse(null)`. */ + fun datasetSplits(datasetSplits: Optional<List<String>>) = + datasetSplits(datasetSplits.getOrNull()) + + /** + * Sets [Builder.datasetSplits] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetSplits] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun datasetSplits(datasetSplits: JsonField<List<String>>) = apply { + body.datasetSplits(datasetSplits) + } + + /** + * Adds a single [String] to [datasetSplits]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addDatasetSplit(datasetSplit: String) = apply { body.addDatasetSplit(datasetSplit) } + + fun evaluatorRules(evaluatorRules: List<String>?) = apply { + body.evaluatorRules(evaluatorRules) + } + + /** Alias for calling [Builder.evaluatorRules] with `evaluatorRules.orElse(null)`. */ + fun evaluatorRules(evaluatorRules: Optional<List<String>>) = + evaluatorRules(evaluatorRules.getOrNull()) + + /** + * Sets [Builder.evaluatorRules] to an arbitrary JSON value. + * + * You should usually call [Builder.evaluatorRules] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun evaluatorRules(evaluatorRules: JsonField<List<String>>) = apply { + body.evaluatorRules(evaluatorRules) + } + + /** + * Adds a single [String] to [evaluatorRules]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvaluatorRule(evaluatorRule: String) = apply { body.addEvaluatorRule(evaluatorRule) } + + fun owner(owner: String?) = apply { body.owner(owner) } + + /** Alias for calling [Builder.owner] with `owner.orElse(null)`. */ + fun owner(owner: Optional<String>) = owner(owner.getOrNull()) + + /** + * Sets [Builder.owner] to an arbitrary JSON value. + * + * You should usually call [Builder.owner] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun owner(owner: JsonField<String>) = apply { body.owner(owner) } + + fun parallelToolCalls(parallelToolCalls: Boolean?) = apply { + body.parallelToolCalls(parallelToolCalls) + } + + /** + * Alias for [Builder.parallelToolCalls]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun parallelToolCalls(parallelToolCalls: Boolean) = + parallelToolCalls(parallelToolCalls as Boolean?) + + /** Alias for calling [Builder.parallelToolCalls] with `parallelToolCalls.orElse(null)`. */ + fun parallelToolCalls(parallelToolCalls: Optional<Boolean>) = + parallelToolCalls(parallelToolCalls.getOrNull()) + + /** + * Sets [Builder.parallelToolCalls] to an arbitrary JSON value. + * + * You should usually call [Builder.parallelToolCalls] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun parallelToolCalls(parallelToolCalls: JsonField<Boolean>) = apply { + body.parallelToolCalls(parallelToolCalls) + } + + fun repetitions(repetitions: Long) = apply { body.repetitions(repetitions) } + + /** + * Sets [Builder.repetitions] to an arbitrary JSON value. + * + * You should usually call [Builder.repetitions] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun repetitions(repetitions: JsonField<Long>) = apply { body.repetitions(repetitions) } + + fun repoHandle(repoHandle: String?) = apply { body.repoHandle(repoHandle) } + + /** Alias for calling [Builder.repoHandle] with `repoHandle.orElse(null)`. */ + fun repoHandle(repoHandle: Optional<String>) = repoHandle(repoHandle.getOrNull()) + + /** + * Sets [Builder.repoHandle] to an arbitrary JSON value. + * + * You should usually call [Builder.repoHandle] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun repoHandle(repoHandle: JsonField<String>) = apply { body.repoHandle(repoHandle) } + + fun repoId(repoId: String?) = apply { body.repoId(repoId) } + + /** Alias for calling [Builder.repoId] with `repoId.orElse(null)`. */ + fun repoId(repoId: Optional<String>) = repoId(repoId.getOrNull()) + + /** + * Sets [Builder.repoId] to an arbitrary JSON value. + * + * You should usually call [Builder.repoId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun repoId(repoId: JsonField<String>) = apply { body.repoId(repoId) } + + fun requestsPerSecond(requestsPerSecond: Long?) = apply { + body.requestsPerSecond(requestsPerSecond) + } + + /** + * Alias for [Builder.requestsPerSecond]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun requestsPerSecond(requestsPerSecond: Long) = + requestsPerSecond(requestsPerSecond as Long?) + + /** Alias for calling [Builder.requestsPerSecond] with `requestsPerSecond.orElse(null)`. */ + fun requestsPerSecond(requestsPerSecond: Optional<Long>) = + requestsPerSecond(requestsPerSecond.getOrNull()) + + /** + * Sets [Builder.requestsPerSecond] to an arbitrary JSON value. + * + * You should usually call [Builder.requestsPerSecond] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun requestsPerSecond(requestsPerSecond: JsonField<Long>) = apply { + body.requestsPerSecond(requestsPerSecond) + } + + fun runId(runId: String?) = apply { body.runId(runId) } + + /** Alias for calling [Builder.runId] with `runId.orElse(null)`. */ + fun runId(runId: Optional<String>) = runId(runId.getOrNull()) + + /** + * Sets [Builder.runId] to an arbitrary JSON value. + * + * You should usually call [Builder.runId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun runId(runId: JsonField<String>) = apply { body.runId(runId) } + + fun runnerContext(runnerContext: RunnerContextEnum?) = apply { + body.runnerContext(runnerContext) + } + + /** Alias for calling [Builder.runnerContext] with `runnerContext.orElse(null)`. */ + fun runnerContext(runnerContext: Optional<RunnerContextEnum>) = + runnerContext(runnerContext.getOrNull()) + + /** + * Sets [Builder.runnerContext] to an arbitrary JSON value. + * + * You should usually call [Builder.runnerContext] with a well-typed [RunnerContextEnum] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun runnerContext(runnerContext: JsonField<RunnerContextEnum>) = apply { + body.runnerContext(runnerContext) + } + + fun toolChoice(toolChoice: String?) = apply { body.toolChoice(toolChoice) } + + /** Alias for calling [Builder.toolChoice] with `toolChoice.orElse(null)`. */ + fun toolChoice(toolChoice: Optional<String>) = toolChoice(toolChoice.getOrNull()) + + /** + * Sets [Builder.toolChoice] to an arbitrary JSON value. + * + * You should usually call [Builder.toolChoice] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolChoice(toolChoice: JsonField<String>) = apply { body.toolChoice(toolChoice) } + + fun tools(tools: List<JsonValue>?) = apply { body.tools(tools) } + + /** Alias for calling [Builder.tools] with `tools.orElse(null)`. */ + fun tools(tools: Optional<List<JsonValue>>) = tools(tools.getOrNull()) + + /** + * Sets [Builder.tools] to an arbitrary JSON value. + * + * You should usually call [Builder.tools] with a well-typed `List<JsonValue>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tools(tools: JsonField<List<JsonValue>>) = apply { body.tools(tools) } + + /** + * Adds a single [JsonValue] to [tools]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTool(tool: JsonValue) = apply { body.addTool(tool) } + + fun useOrFallbackToWorkspaceSecrets(useOrFallbackToWorkspaceSecrets: Boolean) = apply { + body.useOrFallbackToWorkspaceSecrets(useOrFallbackToWorkspaceSecrets) + } + + /** + * Sets [Builder.useOrFallbackToWorkspaceSecrets] to an arbitrary JSON value. + * + * You should usually call [Builder.useOrFallbackToWorkspaceSecrets] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun useOrFallbackToWorkspaceSecrets(useOrFallbackToWorkspaceSecrets: JsonField<Boolean>) = + apply { + body.useOrFallbackToWorkspaceSecrets(useOrFallbackToWorkspaceSecrets) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [PlaygroundExperimentStreamParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .datasetId() + * .manifest() + * .options() + * .projectName() + * .secrets() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PlaygroundExperimentStreamParams = + PlaygroundExperimentStreamParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val datasetId: JsonField<String>, + private val manifest: JsonValue, + private val options: JsonField<RunnableConfig>, + private val projectName: JsonField<String>, + private val secrets: JsonField<Secrets>, + private val commit: JsonField<String>, + private val datasetSplits: JsonField<List<String>>, + private val evaluatorRules: JsonField<List<String>>, + private val owner: JsonField<String>, + private val parallelToolCalls: JsonField<Boolean>, + private val repetitions: JsonField<Long>, + private val repoHandle: JsonField<String>, + private val repoId: JsonField<String>, + private val requestsPerSecond: JsonField<Long>, + private val runId: JsonField<String>, + private val runnerContext: JsonField<RunnerContextEnum>, + private val toolChoice: JsonField<String>, + private val tools: JsonField<List<JsonValue>>, + private val useOrFallbackToWorkspaceSecrets: JsonField<Boolean>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dataset_id") + @ExcludeMissing + datasetId: JsonField<String> = JsonMissing.of(), + @JsonProperty("manifest") @ExcludeMissing manifest: JsonValue = JsonMissing.of(), + @JsonProperty("options") + @ExcludeMissing + options: JsonField<RunnableConfig> = JsonMissing.of(), + @JsonProperty("project_name") + @ExcludeMissing + projectName: JsonField<String> = JsonMissing.of(), + @JsonProperty("secrets") @ExcludeMissing secrets: JsonField<Secrets> = JsonMissing.of(), + @JsonProperty("commit") @ExcludeMissing commit: JsonField<String> = JsonMissing.of(), + @JsonProperty("dataset_splits") + @ExcludeMissing + datasetSplits: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("evaluator_rules") + @ExcludeMissing + evaluatorRules: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("owner") @ExcludeMissing owner: JsonField<String> = JsonMissing.of(), + @JsonProperty("parallel_tool_calls") + @ExcludeMissing + parallelToolCalls: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("repetitions") + @ExcludeMissing + repetitions: JsonField<Long> = JsonMissing.of(), + @JsonProperty("repo_handle") + @ExcludeMissing + repoHandle: JsonField<String> = JsonMissing.of(), + @JsonProperty("repo_id") @ExcludeMissing repoId: JsonField<String> = JsonMissing.of(), + @JsonProperty("requests_per_second") + @ExcludeMissing + requestsPerSecond: JsonField<Long> = JsonMissing.of(), + @JsonProperty("run_id") @ExcludeMissing runId: JsonField<String> = JsonMissing.of(), + @JsonProperty("runner_context") + @ExcludeMissing + runnerContext: JsonField<RunnerContextEnum> = JsonMissing.of(), + @JsonProperty("tool_choice") + @ExcludeMissing + toolChoice: JsonField<String> = JsonMissing.of(), + @JsonProperty("tools") + @ExcludeMissing + tools: JsonField<List<JsonValue>> = JsonMissing.of(), + @JsonProperty("use_or_fallback_to_workspace_secrets") + @ExcludeMissing + useOrFallbackToWorkspaceSecrets: JsonField<Boolean> = JsonMissing.of(), + ) : this( + datasetId, + manifest, + options, + projectName, + secrets, + commit, + datasetSplits, + evaluatorRules, + owner, + parallelToolCalls, + repetitions, + repoHandle, + repoId, + requestsPerSecond, + runId, + runnerContext, + toolChoice, + tools, + useOrFallbackToWorkspaceSecrets, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun datasetId(): String = datasetId.getRequired("dataset_id") + + @JsonProperty("manifest") @ExcludeMissing fun _manifest(): JsonValue = manifest + + /** + * Configuration for a Runnable. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun options(): RunnableConfig = options.getRequired("options") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun projectName(): String = projectName.getRequired("project_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun secrets(): Secrets = secrets.getRequired("secrets") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun commit(): Optional<String> = commit.getOptional("commit") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun datasetSplits(): Optional<List<String>> = datasetSplits.getOptional("dataset_splits") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun evaluatorRules(): Optional<List<String>> = evaluatorRules.getOptional("evaluator_rules") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun owner(): Optional<String> = owner.getOptional("owner") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun parallelToolCalls(): Optional<Boolean> = + parallelToolCalls.getOptional("parallel_tool_calls") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun repetitions(): Optional<Long> = repetitions.getOptional("repetitions") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun repoHandle(): Optional<String> = repoHandle.getOptional("repo_handle") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun repoId(): Optional<String> = repoId.getOptional("repo_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun requestsPerSecond(): Optional<Long> = + requestsPerSecond.getOptional("requests_per_second") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun runId(): Optional<String> = runId.getOptional("run_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun runnerContext(): Optional<RunnerContextEnum> = + runnerContext.getOptional("runner_context") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun toolChoice(): Optional<String> = toolChoice.getOptional("tool_choice") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun tools(): Optional<List<JsonValue>> = tools.getOptional("tools") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun useOrFallbackToWorkspaceSecrets(): Optional<Boolean> = + useOrFallbackToWorkspaceSecrets.getOptional("use_or_fallback_to_workspace_secrets") + + /** + * Returns the raw JSON value of [datasetId]. + * + * Unlike [datasetId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField<String> = datasetId + + /** + * Returns the raw JSON value of [options]. + * + * Unlike [options], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("options") @ExcludeMissing fun _options(): JsonField<RunnableConfig> = options + + /** + * Returns the raw JSON value of [projectName]. + * + * Unlike [projectName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("project_name") + @ExcludeMissing + fun _projectName(): JsonField<String> = projectName + + /** + * Returns the raw JSON value of [secrets]. + * + * Unlike [secrets], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("secrets") @ExcludeMissing fun _secrets(): JsonField<Secrets> = secrets + + /** + * Returns the raw JSON value of [commit]. + * + * Unlike [commit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("commit") @ExcludeMissing fun _commit(): JsonField<String> = commit + + /** + * Returns the raw JSON value of [datasetSplits]. + * + * Unlike [datasetSplits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dataset_splits") + @ExcludeMissing + fun _datasetSplits(): JsonField<List<String>> = datasetSplits + + /** + * Returns the raw JSON value of [evaluatorRules]. + * + * Unlike [evaluatorRules], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("evaluator_rules") + @ExcludeMissing + fun _evaluatorRules(): JsonField<List<String>> = evaluatorRules + + /** + * Returns the raw JSON value of [owner]. + * + * Unlike [owner], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("owner") @ExcludeMissing fun _owner(): JsonField<String> = owner + + /** + * Returns the raw JSON value of [parallelToolCalls]. + * + * Unlike [parallelToolCalls], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("parallel_tool_calls") + @ExcludeMissing + fun _parallelToolCalls(): JsonField<Boolean> = parallelToolCalls + + /** + * Returns the raw JSON value of [repetitions]. + * + * Unlike [repetitions], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("repetitions") + @ExcludeMissing + fun _repetitions(): JsonField<Long> = repetitions + + /** + * Returns the raw JSON value of [repoHandle]. + * + * Unlike [repoHandle], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("repo_handle") + @ExcludeMissing + fun _repoHandle(): JsonField<String> = repoHandle + + /** + * Returns the raw JSON value of [repoId]. + * + * Unlike [repoId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("repo_id") @ExcludeMissing fun _repoId(): JsonField<String> = repoId + + /** + * Returns the raw JSON value of [requestsPerSecond]. + * + * Unlike [requestsPerSecond], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("requests_per_second") + @ExcludeMissing + fun _requestsPerSecond(): JsonField<Long> = requestsPerSecond + + /** + * Returns the raw JSON value of [runId]. + * + * Unlike [runId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_id") @ExcludeMissing fun _runId(): JsonField<String> = runId + + /** + * Returns the raw JSON value of [runnerContext]. + * + * Unlike [runnerContext], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("runner_context") + @ExcludeMissing + fun _runnerContext(): JsonField<RunnerContextEnum> = runnerContext + + /** + * Returns the raw JSON value of [toolChoice]. + * + * Unlike [toolChoice], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tool_choice") + @ExcludeMissing + fun _toolChoice(): JsonField<String> = toolChoice + + /** + * Returns the raw JSON value of [tools]. + * + * Unlike [tools], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tools") @ExcludeMissing fun _tools(): JsonField<List<JsonValue>> = tools + + /** + * Returns the raw JSON value of [useOrFallbackToWorkspaceSecrets]. + * + * Unlike [useOrFallbackToWorkspaceSecrets], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("use_or_fallback_to_workspace_secrets") + @ExcludeMissing + fun _useOrFallbackToWorkspaceSecrets(): JsonField<Boolean> = useOrFallbackToWorkspaceSecrets + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .datasetId() + * .manifest() + * .options() + * .projectName() + * .secrets() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var datasetId: JsonField<String>? = null + private var manifest: JsonValue? = null + private var options: JsonField<RunnableConfig>? = null + private var projectName: JsonField<String>? = null + private var secrets: JsonField<Secrets>? = null + private var commit: JsonField<String> = JsonMissing.of() + private var datasetSplits: JsonField<MutableList<String>>? = null + private var evaluatorRules: JsonField<MutableList<String>>? = null + private var owner: JsonField<String> = JsonMissing.of() + private var parallelToolCalls: JsonField<Boolean> = JsonMissing.of() + private var repetitions: JsonField<Long> = JsonMissing.of() + private var repoHandle: JsonField<String> = JsonMissing.of() + private var repoId: JsonField<String> = JsonMissing.of() + private var requestsPerSecond: JsonField<Long> = JsonMissing.of() + private var runId: JsonField<String> = JsonMissing.of() + private var runnerContext: JsonField<RunnerContextEnum> = JsonMissing.of() + private var toolChoice: JsonField<String> = JsonMissing.of() + private var tools: JsonField<MutableList<JsonValue>>? = null + private var useOrFallbackToWorkspaceSecrets: JsonField<Boolean> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + datasetId = body.datasetId + manifest = body.manifest + options = body.options + projectName = body.projectName + secrets = body.secrets + commit = body.commit + datasetSplits = body.datasetSplits.map { it.toMutableList() } + evaluatorRules = body.evaluatorRules.map { it.toMutableList() } + owner = body.owner + parallelToolCalls = body.parallelToolCalls + repetitions = body.repetitions + repoHandle = body.repoHandle + repoId = body.repoId + requestsPerSecond = body.requestsPerSecond + runId = body.runId + runnerContext = body.runnerContext + toolChoice = body.toolChoice + tools = body.tools.map { it.toMutableList() } + useOrFallbackToWorkspaceSecrets = body.useOrFallbackToWorkspaceSecrets + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun datasetId(datasetId: String) = datasetId(JsonField.of(datasetId)) + + /** + * Sets [Builder.datasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun datasetId(datasetId: JsonField<String>) = apply { this.datasetId = datasetId } + + fun manifest(manifest: JsonValue) = apply { this.manifest = manifest } + + /** Configuration for a Runnable. */ + fun options(options: RunnableConfig) = options(JsonField.of(options)) + + /** + * Sets [Builder.options] to an arbitrary JSON value. + * + * You should usually call [Builder.options] with a well-typed [RunnableConfig] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun options(options: JsonField<RunnableConfig>) = apply { this.options = options } + + fun projectName(projectName: String) = projectName(JsonField.of(projectName)) + + /** + * Sets [Builder.projectName] to an arbitrary JSON value. + * + * You should usually call [Builder.projectName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun projectName(projectName: JsonField<String>) = apply { + this.projectName = projectName + } + + fun secrets(secrets: Secrets) = secrets(JsonField.of(secrets)) + + /** + * Sets [Builder.secrets] to an arbitrary JSON value. + * + * You should usually call [Builder.secrets] with a well-typed [Secrets] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun secrets(secrets: JsonField<Secrets>) = apply { this.secrets = secrets } + + fun commit(commit: String?) = commit(JsonField.ofNullable(commit)) + + /** Alias for calling [Builder.commit] with `commit.orElse(null)`. */ + fun commit(commit: Optional<String>) = commit(commit.getOrNull()) + + /** + * Sets [Builder.commit] to an arbitrary JSON value. + * + * You should usually call [Builder.commit] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun commit(commit: JsonField<String>) = apply { this.commit = commit } + + fun datasetSplits(datasetSplits: List<String>?) = + datasetSplits(JsonField.ofNullable(datasetSplits)) + + /** Alias for calling [Builder.datasetSplits] with `datasetSplits.orElse(null)`. */ + fun datasetSplits(datasetSplits: Optional<List<String>>) = + datasetSplits(datasetSplits.getOrNull()) + + /** + * Sets [Builder.datasetSplits] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetSplits] with a well-typed `List<String>` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun datasetSplits(datasetSplits: JsonField<List<String>>) = apply { + this.datasetSplits = datasetSplits.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [datasetSplits]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addDatasetSplit(datasetSplit: String) = apply { + datasetSplits = + (datasetSplits ?: JsonField.of(mutableListOf())).also { + checkKnown("datasetSplits", it).add(datasetSplit) + } + } + + fun evaluatorRules(evaluatorRules: List<String>?) = + evaluatorRules(JsonField.ofNullable(evaluatorRules)) + + /** Alias for calling [Builder.evaluatorRules] with `evaluatorRules.orElse(null)`. */ + fun evaluatorRules(evaluatorRules: Optional<List<String>>) = + evaluatorRules(evaluatorRules.getOrNull()) + + /** + * Sets [Builder.evaluatorRules] to an arbitrary JSON value. + * + * You should usually call [Builder.evaluatorRules] with a well-typed `List<String>` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun evaluatorRules(evaluatorRules: JsonField<List<String>>) = apply { + this.evaluatorRules = evaluatorRules.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [evaluatorRules]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvaluatorRule(evaluatorRule: String) = apply { + evaluatorRules = + (evaluatorRules ?: JsonField.of(mutableListOf())).also { + checkKnown("evaluatorRules", it).add(evaluatorRule) + } + } + + fun owner(owner: String?) = owner(JsonField.ofNullable(owner)) + + /** Alias for calling [Builder.owner] with `owner.orElse(null)`. */ + fun owner(owner: Optional<String>) = owner(owner.getOrNull()) + + /** + * Sets [Builder.owner] to an arbitrary JSON value. + * + * You should usually call [Builder.owner] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun owner(owner: JsonField<String>) = apply { this.owner = owner } + + fun parallelToolCalls(parallelToolCalls: Boolean?) = + parallelToolCalls(JsonField.ofNullable(parallelToolCalls)) + + /** + * Alias for [Builder.parallelToolCalls]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun parallelToolCalls(parallelToolCalls: Boolean) = + parallelToolCalls(parallelToolCalls as Boolean?) + + /** + * Alias for calling [Builder.parallelToolCalls] with `parallelToolCalls.orElse(null)`. + */ + fun parallelToolCalls(parallelToolCalls: Optional<Boolean>) = + parallelToolCalls(parallelToolCalls.getOrNull()) + + /** + * Sets [Builder.parallelToolCalls] to an arbitrary JSON value. + * + * You should usually call [Builder.parallelToolCalls] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun parallelToolCalls(parallelToolCalls: JsonField<Boolean>) = apply { + this.parallelToolCalls = parallelToolCalls + } + + fun repetitions(repetitions: Long) = repetitions(JsonField.of(repetitions)) + + /** + * Sets [Builder.repetitions] to an arbitrary JSON value. + * + * You should usually call [Builder.repetitions] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun repetitions(repetitions: JsonField<Long>) = apply { this.repetitions = repetitions } + + fun repoHandle(repoHandle: String?) = repoHandle(JsonField.ofNullable(repoHandle)) + + /** Alias for calling [Builder.repoHandle] with `repoHandle.orElse(null)`. */ + fun repoHandle(repoHandle: Optional<String>) = repoHandle(repoHandle.getOrNull()) + + /** + * Sets [Builder.repoHandle] to an arbitrary JSON value. + * + * You should usually call [Builder.repoHandle] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun repoHandle(repoHandle: JsonField<String>) = apply { this.repoHandle = repoHandle } + + fun repoId(repoId: String?) = repoId(JsonField.ofNullable(repoId)) + + /** Alias for calling [Builder.repoId] with `repoId.orElse(null)`. */ + fun repoId(repoId: Optional<String>) = repoId(repoId.getOrNull()) + + /** + * Sets [Builder.repoId] to an arbitrary JSON value. + * + * You should usually call [Builder.repoId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun repoId(repoId: JsonField<String>) = apply { this.repoId = repoId } + + fun requestsPerSecond(requestsPerSecond: Long?) = + requestsPerSecond(JsonField.ofNullable(requestsPerSecond)) + + /** + * Alias for [Builder.requestsPerSecond]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun requestsPerSecond(requestsPerSecond: Long) = + requestsPerSecond(requestsPerSecond as Long?) + + /** + * Alias for calling [Builder.requestsPerSecond] with `requestsPerSecond.orElse(null)`. + */ + fun requestsPerSecond(requestsPerSecond: Optional<Long>) = + requestsPerSecond(requestsPerSecond.getOrNull()) + + /** + * Sets [Builder.requestsPerSecond] to an arbitrary JSON value. + * + * You should usually call [Builder.requestsPerSecond] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun requestsPerSecond(requestsPerSecond: JsonField<Long>) = apply { + this.requestsPerSecond = requestsPerSecond + } + + fun runId(runId: String?) = runId(JsonField.ofNullable(runId)) + + /** Alias for calling [Builder.runId] with `runId.orElse(null)`. */ + fun runId(runId: Optional<String>) = runId(runId.getOrNull()) + + /** + * Sets [Builder.runId] to an arbitrary JSON value. + * + * You should usually call [Builder.runId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun runId(runId: JsonField<String>) = apply { this.runId = runId } + + fun runnerContext(runnerContext: RunnerContextEnum?) = + runnerContext(JsonField.ofNullable(runnerContext)) + + /** Alias for calling [Builder.runnerContext] with `runnerContext.orElse(null)`. */ + fun runnerContext(runnerContext: Optional<RunnerContextEnum>) = + runnerContext(runnerContext.getOrNull()) + + /** + * Sets [Builder.runnerContext] to an arbitrary JSON value. + * + * You should usually call [Builder.runnerContext] with a well-typed [RunnerContextEnum] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun runnerContext(runnerContext: JsonField<RunnerContextEnum>) = apply { + this.runnerContext = runnerContext + } + + fun toolChoice(toolChoice: String?) = toolChoice(JsonField.ofNullable(toolChoice)) + + /** Alias for calling [Builder.toolChoice] with `toolChoice.orElse(null)`. */ + fun toolChoice(toolChoice: Optional<String>) = toolChoice(toolChoice.getOrNull()) + + /** + * Sets [Builder.toolChoice] to an arbitrary JSON value. + * + * You should usually call [Builder.toolChoice] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun toolChoice(toolChoice: JsonField<String>) = apply { this.toolChoice = toolChoice } + + fun tools(tools: List<JsonValue>?) = tools(JsonField.ofNullable(tools)) + + /** Alias for calling [Builder.tools] with `tools.orElse(null)`. */ + fun tools(tools: Optional<List<JsonValue>>) = tools(tools.getOrNull()) + + /** + * Sets [Builder.tools] to an arbitrary JSON value. + * + * You should usually call [Builder.tools] with a well-typed `List<JsonValue>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tools(tools: JsonField<List<JsonValue>>) = apply { + this.tools = tools.map { it.toMutableList() } + } + + /** + * Adds a single [JsonValue] to [tools]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTool(tool: JsonValue) = apply { + tools = + (tools ?: JsonField.of(mutableListOf())).also { + checkKnown("tools", it).add(tool) + } + } + + fun useOrFallbackToWorkspaceSecrets(useOrFallbackToWorkspaceSecrets: Boolean) = + useOrFallbackToWorkspaceSecrets(JsonField.of(useOrFallbackToWorkspaceSecrets)) + + /** + * Sets [Builder.useOrFallbackToWorkspaceSecrets] to an arbitrary JSON value. + * + * You should usually call [Builder.useOrFallbackToWorkspaceSecrets] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun useOrFallbackToWorkspaceSecrets( + useOrFallbackToWorkspaceSecrets: JsonField<Boolean> + ) = apply { this.useOrFallbackToWorkspaceSecrets = useOrFallbackToWorkspaceSecrets } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .datasetId() + * .manifest() + * .options() + * .projectName() + * .secrets() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("datasetId", datasetId), + checkRequired("manifest", manifest), + checkRequired("options", options), + checkRequired("projectName", projectName), + checkRequired("secrets", secrets), + commit, + (datasetSplits ?: JsonMissing.of()).map { it.toImmutable() }, + (evaluatorRules ?: JsonMissing.of()).map { it.toImmutable() }, + owner, + parallelToolCalls, + repetitions, + repoHandle, + repoId, + requestsPerSecond, + runId, + runnerContext, + toolChoice, + (tools ?: JsonMissing.of()).map { it.toImmutable() }, + useOrFallbackToWorkspaceSecrets, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + datasetId() + options().validate() + projectName() + secrets().validate() + commit() + datasetSplits() + evaluatorRules() + owner() + parallelToolCalls() + repetitions() + repoHandle() + repoId() + requestsPerSecond() + runId() + runnerContext().ifPresent { it.validate() } + toolChoice() + tools() + useOrFallbackToWorkspaceSecrets() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (datasetId.asKnown().isPresent) 1 else 0) + + (options.asKnown().getOrNull()?.validity() ?: 0) + + (if (projectName.asKnown().isPresent) 1 else 0) + + (secrets.asKnown().getOrNull()?.validity() ?: 0) + + (if (commit.asKnown().isPresent) 1 else 0) + + (datasetSplits.asKnown().getOrNull()?.size ?: 0) + + (evaluatorRules.asKnown().getOrNull()?.size ?: 0) + + (if (owner.asKnown().isPresent) 1 else 0) + + (if (parallelToolCalls.asKnown().isPresent) 1 else 0) + + (if (repetitions.asKnown().isPresent) 1 else 0) + + (if (repoHandle.asKnown().isPresent) 1 else 0) + + (if (repoId.asKnown().isPresent) 1 else 0) + + (if (requestsPerSecond.asKnown().isPresent) 1 else 0) + + (if (runId.asKnown().isPresent) 1 else 0) + + (runnerContext.asKnown().getOrNull()?.validity() ?: 0) + + (if (toolChoice.asKnown().isPresent) 1 else 0) + + (tools.asKnown().getOrNull()?.size ?: 0) + + (if (useOrFallbackToWorkspaceSecrets.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + datasetId == other.datasetId && + manifest == other.manifest && + options == other.options && + projectName == other.projectName && + secrets == other.secrets && + commit == other.commit && + datasetSplits == other.datasetSplits && + evaluatorRules == other.evaluatorRules && + owner == other.owner && + parallelToolCalls == other.parallelToolCalls && + repetitions == other.repetitions && + repoHandle == other.repoHandle && + repoId == other.repoId && + requestsPerSecond == other.requestsPerSecond && + runId == other.runId && + runnerContext == other.runnerContext && + toolChoice == other.toolChoice && + tools == other.tools && + useOrFallbackToWorkspaceSecrets == other.useOrFallbackToWorkspaceSecrets && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + datasetId, + manifest, + options, + projectName, + secrets, + commit, + datasetSplits, + evaluatorRules, + owner, + parallelToolCalls, + repetitions, + repoHandle, + repoId, + requestsPerSecond, + runId, + runnerContext, + toolChoice, + tools, + useOrFallbackToWorkspaceSecrets, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{datasetId=$datasetId, manifest=$manifest, options=$options, projectName=$projectName, secrets=$secrets, commit=$commit, datasetSplits=$datasetSplits, evaluatorRules=$evaluatorRules, owner=$owner, parallelToolCalls=$parallelToolCalls, repetitions=$repetitions, repoHandle=$repoHandle, repoId=$repoId, requestsPerSecond=$requestsPerSecond, runId=$runId, runnerContext=$runnerContext, toolChoice=$toolChoice, tools=$tools, useOrFallbackToWorkspaceSecrets=$useOrFallbackToWorkspaceSecrets, additionalProperties=$additionalProperties}" + } + + class Secrets + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Secrets]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Secrets]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(secrets: Secrets) = apply { + additionalProperties = secrets.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Secrets]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Secrets = Secrets(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Secrets = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Secrets && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Secrets{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PlaygroundExperimentStreamParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "PlaygroundExperimentStreamParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/PlaygroundExperimentStreamResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/PlaygroundExperimentStreamResponse.kt new file mode 100644 index 00000000..36a6930d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/PlaygroundExperimentStreamResponse.kt @@ -0,0 +1,121 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.playgroundexperiment + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class PlaygroundExperimentStreamResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PlaygroundExperimentStreamResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PlaygroundExperimentStreamResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(playgroundExperimentStreamResponse: PlaygroundExperimentStreamResponse) = + apply { + additionalProperties = + playgroundExperimentStreamResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PlaygroundExperimentStreamResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PlaygroundExperimentStreamResponse = + PlaygroundExperimentStreamResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): PlaygroundExperimentStreamResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PlaygroundExperimentStreamResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PlaygroundExperimentStreamResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/RunnableConfig.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/RunnableConfig.kt new file mode 100644 index 00000000..674a1847 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/RunnableConfig.kt @@ -0,0 +1,597 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.playgroundexperiment + +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 com.langsmith_api.api.core.BaseDeserializer +import com.langsmith_api.api.core.BaseSerializer +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.allMaxBy +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Configuration for a Runnable. */ +class RunnableConfig +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val callbacks: JsonField<Callbacks>, + private val configurable: JsonValue, + private val maxConcurrency: JsonField<Long>, + private val metadata: JsonValue, + private val recursionLimit: JsonField<Long>, + private val runId: JsonField<String>, + private val runName: JsonField<String>, + private val tags: JsonField<List<String>>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("callbacks") + @ExcludeMissing + callbacks: JsonField<Callbacks> = JsonMissing.of(), + @JsonProperty("configurable") @ExcludeMissing configurable: JsonValue = JsonMissing.of(), + @JsonProperty("max_concurrency") + @ExcludeMissing + maxConcurrency: JsonField<Long> = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("recursion_limit") + @ExcludeMissing + recursionLimit: JsonField<Long> = JsonMissing.of(), + @JsonProperty("run_id") @ExcludeMissing runId: JsonField<String> = JsonMissing.of(), + @JsonProperty("run_name") @ExcludeMissing runName: JsonField<String> = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing tags: JsonField<List<String>> = JsonMissing.of(), + ) : this( + callbacks, + configurable, + maxConcurrency, + metadata, + recursionLimit, + runId, + runName, + tags, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun callbacks(): Optional<Callbacks> = callbacks.getOptional("callbacks") + + @JsonProperty("configurable") @ExcludeMissing fun _configurable(): JsonValue = configurable + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun maxConcurrency(): Optional<Long> = maxConcurrency.getOptional("max_concurrency") + + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun recursionLimit(): Optional<Long> = recursionLimit.getOptional("recursion_limit") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun runId(): Optional<String> = runId.getOptional("run_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun runName(): Optional<String> = runName.getOptional("run_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tags(): Optional<List<String>> = tags.getOptional("tags") + + /** + * Returns the raw JSON value of [callbacks]. + * + * Unlike [callbacks], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("callbacks") @ExcludeMissing fun _callbacks(): JsonField<Callbacks> = callbacks + + /** + * Returns the raw JSON value of [maxConcurrency]. + * + * Unlike [maxConcurrency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("max_concurrency") + @ExcludeMissing + fun _maxConcurrency(): JsonField<Long> = maxConcurrency + + /** + * Returns the raw JSON value of [recursionLimit]. + * + * Unlike [recursionLimit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("recursion_limit") + @ExcludeMissing + fun _recursionLimit(): JsonField<Long> = recursionLimit + + /** + * Returns the raw JSON value of [runId]. + * + * Unlike [runId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_id") @ExcludeMissing fun _runId(): JsonField<String> = runId + + /** + * Returns the raw JSON value of [runName]. + * + * Unlike [runName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_name") @ExcludeMissing fun _runName(): JsonField<String> = runName + + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField<List<String>> = tags + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [RunnableConfig]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunnableConfig]. */ + class Builder internal constructor() { + + private var callbacks: JsonField<Callbacks> = JsonMissing.of() + private var configurable: JsonValue = JsonMissing.of() + private var maxConcurrency: JsonField<Long> = JsonMissing.of() + private var metadata: JsonValue = JsonMissing.of() + private var recursionLimit: JsonField<Long> = JsonMissing.of() + private var runId: JsonField<String> = JsonMissing.of() + private var runName: JsonField<String> = JsonMissing.of() + private var tags: JsonField<MutableList<String>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(runnableConfig: RunnableConfig) = apply { + callbacks = runnableConfig.callbacks + configurable = runnableConfig.configurable + maxConcurrency = runnableConfig.maxConcurrency + metadata = runnableConfig.metadata + recursionLimit = runnableConfig.recursionLimit + runId = runnableConfig.runId + runName = runnableConfig.runName + tags = runnableConfig.tags.map { it.toMutableList() } + additionalProperties = runnableConfig.additionalProperties.toMutableMap() + } + + fun callbacks(callbacks: Callbacks?) = callbacks(JsonField.ofNullable(callbacks)) + + /** Alias for calling [Builder.callbacks] with `callbacks.orElse(null)`. */ + fun callbacks(callbacks: Optional<Callbacks>) = callbacks(callbacks.getOrNull()) + + /** + * Sets [Builder.callbacks] to an arbitrary JSON value. + * + * You should usually call [Builder.callbacks] with a well-typed [Callbacks] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun callbacks(callbacks: JsonField<Callbacks>) = apply { this.callbacks = callbacks } + + /** Alias for calling [callbacks] with `Callbacks.ofJsonValues(jsonValues)`. */ + fun callbacksOfJsonValues(jsonValues: List<JsonValue>) = + callbacks(Callbacks.ofJsonValues(jsonValues)) + + /** Alias for calling [callbacks] with `Callbacks.ofJsonValue(jsonValue)`. */ + fun callbacks(jsonValue: JsonValue) = callbacks(Callbacks.ofJsonValue(jsonValue)) + + fun configurable(configurable: JsonValue) = apply { this.configurable = configurable } + + fun maxConcurrency(maxConcurrency: Long?) = + maxConcurrency(JsonField.ofNullable(maxConcurrency)) + + /** + * Alias for [Builder.maxConcurrency]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun maxConcurrency(maxConcurrency: Long) = maxConcurrency(maxConcurrency as Long?) + + /** Alias for calling [Builder.maxConcurrency] with `maxConcurrency.orElse(null)`. */ + fun maxConcurrency(maxConcurrency: Optional<Long>) = + maxConcurrency(maxConcurrency.getOrNull()) + + /** + * Sets [Builder.maxConcurrency] to an arbitrary JSON value. + * + * You should usually call [Builder.maxConcurrency] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun maxConcurrency(maxConcurrency: JsonField<Long>) = apply { + this.maxConcurrency = maxConcurrency + } + + fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + + fun recursionLimit(recursionLimit: Long) = recursionLimit(JsonField.of(recursionLimit)) + + /** + * Sets [Builder.recursionLimit] to an arbitrary JSON value. + * + * You should usually call [Builder.recursionLimit] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun recursionLimit(recursionLimit: JsonField<Long>) = apply { + this.recursionLimit = recursionLimit + } + + fun runId(runId: String?) = runId(JsonField.ofNullable(runId)) + + /** Alias for calling [Builder.runId] with `runId.orElse(null)`. */ + fun runId(runId: Optional<String>) = runId(runId.getOrNull()) + + /** + * Sets [Builder.runId] to an arbitrary JSON value. + * + * You should usually call [Builder.runId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun runId(runId: JsonField<String>) = apply { this.runId = runId } + + fun runName(runName: String) = runName(JsonField.of(runName)) + + /** + * Sets [Builder.runName] to an arbitrary JSON value. + * + * You should usually call [Builder.runName] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun runName(runName: JsonField<String>) = apply { this.runName = runName } + + fun tags(tags: List<String>) = tags(JsonField.of(tags)) + + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List<String>` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tags(tags: JsonField<List<String>>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RunnableConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RunnableConfig = + RunnableConfig( + callbacks, + configurable, + maxConcurrency, + metadata, + recursionLimit, + runId, + runName, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RunnableConfig = apply { + if (validated) { + return@apply + } + + callbacks().ifPresent { it.validate() } + maxConcurrency() + recursionLimit() + runId() + runName() + tags() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (callbacks.asKnown().getOrNull()?.validity() ?: 0) + + (if (maxConcurrency.asKnown().isPresent) 1 else 0) + + (if (recursionLimit.asKnown().isPresent) 1 else 0) + + (if (runId.asKnown().isPresent) 1 else 0) + + (if (runName.asKnown().isPresent) 1 else 0) + + (tags.asKnown().getOrNull()?.size ?: 0) + + @JsonDeserialize(using = Callbacks.Deserializer::class) + @JsonSerialize(using = Callbacks.Serializer::class) + class Callbacks + private constructor( + private val jsonValues: List<JsonValue>? = null, + private val jsonValue: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun jsonValues(): Optional<List<JsonValue>> = Optional.ofNullable(jsonValues) + + fun jsonValue(): Optional<JsonValue> = Optional.ofNullable(jsonValue) + + fun isJsonValues(): Boolean = jsonValues != null + + fun isJsonValue(): Boolean = jsonValue != null + + fun asJsonValues(): List<JsonValue> = jsonValues.getOrThrow("jsonValues") + + fun asJsonValue(): JsonValue = jsonValue.getOrThrow("jsonValue") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + jsonValues != null -> visitor.visitJsonValues(jsonValues) + jsonValue != null -> visitor.visitJsonValue(jsonValue) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Callbacks = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitJsonValues(jsonValues: List<JsonValue>) {} + + override fun visitJsonValue(jsonValue: JsonValue) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitJsonValues(jsonValues: List<JsonValue>) = jsonValues.size + + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Callbacks && + jsonValues == other.jsonValues && + jsonValue == other.jsonValue + } + + override fun hashCode(): Int = Objects.hash(jsonValues, jsonValue) + + override fun toString(): String = + when { + jsonValues != null -> "Callbacks{jsonValues=$jsonValues}" + jsonValue != null -> "Callbacks{jsonValue=$jsonValue}" + _json != null -> "Callbacks{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Callbacks") + } + + companion object { + + @JvmStatic + fun ofJsonValues(jsonValues: List<JsonValue>) = + Callbacks(jsonValues = jsonValues.toImmutable()) + + @JvmStatic fun ofJsonValue(jsonValue: JsonValue) = Callbacks(jsonValue = jsonValue) + } + + /** + * An interface that defines how to map each variant of [Callbacks] to a value of type [T]. + */ + interface Visitor<out T> { + + fun visitJsonValues(jsonValues: List<JsonValue>): T + + fun visitJsonValue(jsonValue: JsonValue): T + + /** + * Maps an unknown variant of [Callbacks] to a value of type [T]. + * + * An instance of [Callbacks] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Callbacks: $json") + } + } + + internal class Deserializer : BaseDeserializer<Callbacks>(Callbacks::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Callbacks { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<List<JsonValue>>())?.let { + Callbacks(jsonValues = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<JsonValue>())?.let { + Callbacks(jsonValue = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants. + 0 -> Callbacks(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Callbacks>(Callbacks::class) { + + override fun serialize( + value: Callbacks, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.jsonValues != null -> generator.writeObject(value.jsonValues) + value.jsonValue != null -> generator.writeObject(value.jsonValue) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Callbacks") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunnableConfig && + callbacks == other.callbacks && + configurable == other.configurable && + maxConcurrency == other.maxConcurrency && + metadata == other.metadata && + recursionLimit == other.recursionLimit && + runId == other.runId && + runName == other.runName && + tags == other.tags && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + callbacks, + configurable, + maxConcurrency, + metadata, + recursionLimit, + runId, + runName, + tags, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RunnableConfig{callbacks=$callbacks, configurable=$configurable, maxConcurrency=$maxConcurrency, metadata=$metadata, recursionLimit=$recursionLimit, runId=$runId, runName=$runName, tags=$tags, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/RunnerContextEnum.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/RunnerContextEnum.kt new file mode 100644 index 00000000..441d6127 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/RunnerContextEnum.kt @@ -0,0 +1,137 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.playgroundexperiment + +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException + +class RunnerContextEnum @JsonCreator private constructor(private val value: JsonField<String>) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't match + * any known member, and you want to know that value. For example, if the SDK is on an older + * version than the API, then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val LANGSMITH_UI = of("langsmith_ui") + + @JvmField val LANGSMITH_ALIGN_EVALS = of("langsmith_align_evals") + + @JvmStatic fun of(value: String) = RunnerContextEnum(JsonField.of(value)) + } + + /** An enum containing [RunnerContextEnum]'s known values. */ + enum class Known { + LANGSMITH_UI, + LANGSMITH_ALIGN_EVALS, + } + + /** + * An enum containing [RunnerContextEnum]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [RunnerContextEnum] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the SDK + * is on an older version than the API, then the API may respond with new members that the SDK + * is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LANGSMITH_UI, + LANGSMITH_ALIGN_EVALS, + /** + * An enum member indicating that [RunnerContextEnum] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if + * the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want to + * throw for the unknown case. + */ + fun value(): Value = + when (this) { + LANGSMITH_UI -> Value.LANGSMITH_UI + LANGSMITH_ALIGN_EVALS -> Value.LANGSMITH_ALIGN_EVALS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't want + * to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + LANGSMITH_UI -> Known.LANGSMITH_UI + LANGSMITH_ALIGN_EVALS -> Known.LANGSMITH_ALIGN_EVALS + else -> throw LangsmithApiInvalidDataException("Unknown RunnerContextEnum: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): RunnerContextEnum = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunnerContextEnum && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/ExampleWithRuns.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/ExampleWithRuns.kt new file mode 100644 index 00000000..82bfadcb --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/ExampleWithRuns.kt @@ -0,0 +1,483 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.runs + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.runs.RunSchema +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Example schema with list of runs. */ +class ExampleWithRuns +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val datasetId: JsonField<String>, + private val inputs: JsonValue, + private val name: JsonField<String>, + private val runs: JsonField<List<RunSchema>>, + private val attachmentUrls: JsonValue, + private val createdAt: JsonField<OffsetDateTime>, + private val metadata: JsonValue, + private val modifiedAt: JsonField<OffsetDateTime>, + private val outputs: JsonValue, + private val sourceRunId: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("dataset_id") @ExcludeMissing datasetId: JsonField<String> = JsonMissing.of(), + @JsonProperty("inputs") @ExcludeMissing inputs: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("runs") @ExcludeMissing runs: JsonField<List<RunSchema>> = JsonMissing.of(), + @JsonProperty("attachment_urls") + @ExcludeMissing + attachmentUrls: JsonValue = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("modified_at") + @ExcludeMissing + modifiedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("outputs") @ExcludeMissing outputs: JsonValue = JsonMissing.of(), + @JsonProperty("source_run_id") + @ExcludeMissing + sourceRunId: JsonField<String> = JsonMissing.of(), + ) : this( + id, + datasetId, + inputs, + name, + runs, + attachmentUrls, + createdAt, + metadata, + modifiedAt, + outputs, + sourceRunId, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun datasetId(): String = datasetId.getRequired("dataset_id") + + @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonValue = inputs + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun runs(): List<RunSchema> = runs.getRequired("runs") + + @JsonProperty("attachment_urls") + @ExcludeMissing + fun _attachmentUrls(): JsonValue = attachmentUrls + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun createdAt(): Optional<OffsetDateTime> = createdAt.getOptional("created_at") + + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun modifiedAt(): Optional<OffsetDateTime> = modifiedAt.getOptional("modified_at") + + @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonValue = outputs + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun sourceRunId(): Optional<String> = sourceRunId.getOptional("source_run_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [datasetId]. + * + * Unlike [datasetId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField<String> = datasetId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [runs]. + * + * Unlike [runs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("runs") @ExcludeMissing fun _runs(): JsonField<List<RunSchema>> = runs + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [modifiedAt]. + * + * Unlike [modifiedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("modified_at") + @ExcludeMissing + fun _modifiedAt(): JsonField<OffsetDateTime> = modifiedAt + + /** + * Returns the raw JSON value of [sourceRunId]. + * + * Unlike [sourceRunId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("source_run_id") + @ExcludeMissing + fun _sourceRunId(): JsonField<String> = sourceRunId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ExampleWithRuns]. + * + * The following fields are required: + * ```java + * .id() + * .datasetId() + * .inputs() + * .name() + * .runs() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExampleWithRuns]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var datasetId: JsonField<String>? = null + private var inputs: JsonValue? = null + private var name: JsonField<String>? = null + private var runs: JsonField<MutableList<RunSchema>>? = null + private var attachmentUrls: JsonValue = JsonMissing.of() + private var createdAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var metadata: JsonValue = JsonMissing.of() + private var modifiedAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var outputs: JsonValue = JsonMissing.of() + private var sourceRunId: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(exampleWithRuns: ExampleWithRuns) = apply { + id = exampleWithRuns.id + datasetId = exampleWithRuns.datasetId + inputs = exampleWithRuns.inputs + name = exampleWithRuns.name + runs = exampleWithRuns.runs.map { it.toMutableList() } + attachmentUrls = exampleWithRuns.attachmentUrls + createdAt = exampleWithRuns.createdAt + metadata = exampleWithRuns.metadata + modifiedAt = exampleWithRuns.modifiedAt + outputs = exampleWithRuns.outputs + sourceRunId = exampleWithRuns.sourceRunId + additionalProperties = exampleWithRuns.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun datasetId(datasetId: String) = datasetId(JsonField.of(datasetId)) + + /** + * Sets [Builder.datasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun datasetId(datasetId: JsonField<String>) = apply { this.datasetId = datasetId } + + fun inputs(inputs: JsonValue) = apply { this.inputs = inputs } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun runs(runs: List<RunSchema>) = runs(JsonField.of(runs)) + + /** + * Sets [Builder.runs] to an arbitrary JSON value. + * + * You should usually call [Builder.runs] with a well-typed `List<RunSchema>` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun runs(runs: JsonField<List<RunSchema>>) = apply { + this.runs = runs.map { it.toMutableList() } + } + + /** + * Adds a single [RunSchema] to [runs]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRun(run: RunSchema) = apply { + runs = (runs ?: JsonField.of(mutableListOf())).also { checkKnown("runs", it).add(run) } + } + + fun attachmentUrls(attachmentUrls: JsonValue) = apply { + this.attachmentUrls = attachmentUrls + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + + fun modifiedAt(modifiedAt: OffsetDateTime?) = modifiedAt(JsonField.ofNullable(modifiedAt)) + + /** Alias for calling [Builder.modifiedAt] with `modifiedAt.orElse(null)`. */ + fun modifiedAt(modifiedAt: Optional<OffsetDateTime>) = modifiedAt(modifiedAt.getOrNull()) + + /** + * Sets [Builder.modifiedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.modifiedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modifiedAt(modifiedAt: JsonField<OffsetDateTime>) = apply { + this.modifiedAt = modifiedAt + } + + fun outputs(outputs: JsonValue) = apply { this.outputs = outputs } + + fun sourceRunId(sourceRunId: String?) = sourceRunId(JsonField.ofNullable(sourceRunId)) + + /** Alias for calling [Builder.sourceRunId] with `sourceRunId.orElse(null)`. */ + fun sourceRunId(sourceRunId: Optional<String>) = sourceRunId(sourceRunId.getOrNull()) + + /** + * Sets [Builder.sourceRunId] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceRunId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun sourceRunId(sourceRunId: JsonField<String>) = apply { this.sourceRunId = sourceRunId } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ExampleWithRuns]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .datasetId() + * .inputs() + * .name() + * .runs() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ExampleWithRuns = + ExampleWithRuns( + checkRequired("id", id), + checkRequired("datasetId", datasetId), + checkRequired("inputs", inputs), + checkRequired("name", name), + checkRequired("runs", runs).map { it.toImmutable() }, + attachmentUrls, + createdAt, + metadata, + modifiedAt, + outputs, + sourceRunId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ExampleWithRuns = apply { + if (validated) { + return@apply + } + + id() + datasetId() + name() + runs().forEach { it.validate() } + createdAt() + modifiedAt() + sourceRunId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (datasetId.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (runs.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (modifiedAt.asKnown().isPresent) 1 else 0) + + (if (sourceRunId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExampleWithRuns && + id == other.id && + datasetId == other.datasetId && + inputs == other.inputs && + name == other.name && + runs == other.runs && + attachmentUrls == other.attachmentUrls && + createdAt == other.createdAt && + metadata == other.metadata && + modifiedAt == other.modifiedAt && + outputs == other.outputs && + sourceRunId == other.sourceRunId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + datasetId, + inputs, + name, + runs, + attachmentUrls, + createdAt, + metadata, + modifiedAt, + outputs, + sourceRunId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ExampleWithRuns{id=$id, datasetId=$datasetId, inputs=$inputs, name=$name, runs=$runs, attachmentUrls=$attachmentUrls, createdAt=$createdAt, metadata=$metadata, modifiedAt=$modifiedAt, outputs=$outputs, sourceRunId=$sourceRunId, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/ExampleWithRunsCh.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/ExampleWithRunsCh.kt new file mode 100644 index 00000000..5d69646e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/ExampleWithRunsCh.kt @@ -0,0 +1,2068 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.runs + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.runs.RunTypeEnum +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Example schema with list of runs. */ +class ExampleWithRunsCh +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val datasetId: JsonField<String>, + private val inputs: JsonValue, + private val name: JsonField<String>, + private val runs: JsonField<List<Run>>, + private val attachmentUrls: JsonValue, + private val createdAt: JsonField<OffsetDateTime>, + private val metadata: JsonValue, + private val modifiedAt: JsonField<OffsetDateTime>, + private val outputs: JsonValue, + private val sourceRunId: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("dataset_id") @ExcludeMissing datasetId: JsonField<String> = JsonMissing.of(), + @JsonProperty("inputs") @ExcludeMissing inputs: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("runs") @ExcludeMissing runs: JsonField<List<Run>> = JsonMissing.of(), + @JsonProperty("attachment_urls") + @ExcludeMissing + attachmentUrls: JsonValue = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("modified_at") + @ExcludeMissing + modifiedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("outputs") @ExcludeMissing outputs: JsonValue = JsonMissing.of(), + @JsonProperty("source_run_id") + @ExcludeMissing + sourceRunId: JsonField<String> = JsonMissing.of(), + ) : this( + id, + datasetId, + inputs, + name, + runs, + attachmentUrls, + createdAt, + metadata, + modifiedAt, + outputs, + sourceRunId, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun datasetId(): String = datasetId.getRequired("dataset_id") + + @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonValue = inputs + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun runs(): List<Run> = runs.getRequired("runs") + + @JsonProperty("attachment_urls") + @ExcludeMissing + fun _attachmentUrls(): JsonValue = attachmentUrls + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun createdAt(): Optional<OffsetDateTime> = createdAt.getOptional("created_at") + + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun modifiedAt(): Optional<OffsetDateTime> = modifiedAt.getOptional("modified_at") + + @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonValue = outputs + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun sourceRunId(): Optional<String> = sourceRunId.getOptional("source_run_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [datasetId]. + * + * Unlike [datasetId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField<String> = datasetId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [runs]. + * + * Unlike [runs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("runs") @ExcludeMissing fun _runs(): JsonField<List<Run>> = runs + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [modifiedAt]. + * + * Unlike [modifiedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("modified_at") + @ExcludeMissing + fun _modifiedAt(): JsonField<OffsetDateTime> = modifiedAt + + /** + * Returns the raw JSON value of [sourceRunId]. + * + * Unlike [sourceRunId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("source_run_id") + @ExcludeMissing + fun _sourceRunId(): JsonField<String> = sourceRunId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ExampleWithRunsCh]. + * + * The following fields are required: + * ```java + * .id() + * .datasetId() + * .inputs() + * .name() + * .runs() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExampleWithRunsCh]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var datasetId: JsonField<String>? = null + private var inputs: JsonValue? = null + private var name: JsonField<String>? = null + private var runs: JsonField<MutableList<Run>>? = null + private var attachmentUrls: JsonValue = JsonMissing.of() + private var createdAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var metadata: JsonValue = JsonMissing.of() + private var modifiedAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var outputs: JsonValue = JsonMissing.of() + private var sourceRunId: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(exampleWithRunsCh: ExampleWithRunsCh) = apply { + id = exampleWithRunsCh.id + datasetId = exampleWithRunsCh.datasetId + inputs = exampleWithRunsCh.inputs + name = exampleWithRunsCh.name + runs = exampleWithRunsCh.runs.map { it.toMutableList() } + attachmentUrls = exampleWithRunsCh.attachmentUrls + createdAt = exampleWithRunsCh.createdAt + metadata = exampleWithRunsCh.metadata + modifiedAt = exampleWithRunsCh.modifiedAt + outputs = exampleWithRunsCh.outputs + sourceRunId = exampleWithRunsCh.sourceRunId + additionalProperties = exampleWithRunsCh.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun datasetId(datasetId: String) = datasetId(JsonField.of(datasetId)) + + /** + * Sets [Builder.datasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun datasetId(datasetId: JsonField<String>) = apply { this.datasetId = datasetId } + + fun inputs(inputs: JsonValue) = apply { this.inputs = inputs } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun runs(runs: List<Run>) = runs(JsonField.of(runs)) + + /** + * Sets [Builder.runs] to an arbitrary JSON value. + * + * You should usually call [Builder.runs] with a well-typed `List<Run>` value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun runs(runs: JsonField<List<Run>>) = apply { this.runs = runs.map { it.toMutableList() } } + + /** + * Adds a single [Run] to [runs]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRun(run: Run) = apply { + runs = (runs ?: JsonField.of(mutableListOf())).also { checkKnown("runs", it).add(run) } + } + + fun attachmentUrls(attachmentUrls: JsonValue) = apply { + this.attachmentUrls = attachmentUrls + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + + fun modifiedAt(modifiedAt: OffsetDateTime?) = modifiedAt(JsonField.ofNullable(modifiedAt)) + + /** Alias for calling [Builder.modifiedAt] with `modifiedAt.orElse(null)`. */ + fun modifiedAt(modifiedAt: Optional<OffsetDateTime>) = modifiedAt(modifiedAt.getOrNull()) + + /** + * Sets [Builder.modifiedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.modifiedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modifiedAt(modifiedAt: JsonField<OffsetDateTime>) = apply { + this.modifiedAt = modifiedAt + } + + fun outputs(outputs: JsonValue) = apply { this.outputs = outputs } + + fun sourceRunId(sourceRunId: String?) = sourceRunId(JsonField.ofNullable(sourceRunId)) + + /** Alias for calling [Builder.sourceRunId] with `sourceRunId.orElse(null)`. */ + fun sourceRunId(sourceRunId: Optional<String>) = sourceRunId(sourceRunId.getOrNull()) + + /** + * Sets [Builder.sourceRunId] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceRunId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun sourceRunId(sourceRunId: JsonField<String>) = apply { this.sourceRunId = sourceRunId } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ExampleWithRunsCh]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .datasetId() + * .inputs() + * .name() + * .runs() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ExampleWithRunsCh = + ExampleWithRunsCh( + checkRequired("id", id), + checkRequired("datasetId", datasetId), + checkRequired("inputs", inputs), + checkRequired("name", name), + checkRequired("runs", runs).map { it.toImmutable() }, + attachmentUrls, + createdAt, + metadata, + modifiedAt, + outputs, + sourceRunId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ExampleWithRunsCh = apply { + if (validated) { + return@apply + } + + id() + datasetId() + name() + runs().forEach { it.validate() } + createdAt() + modifiedAt() + sourceRunId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (datasetId.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (runs.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (modifiedAt.asKnown().isPresent) 1 else 0) + + (if (sourceRunId.asKnown().isPresent) 1 else 0) + + /** Run schema for comparison view. */ + class Run + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField<String>, + private val name: JsonField<String>, + private val runType: JsonField<RunTypeEnum>, + private val sessionId: JsonField<String>, + private val status: JsonField<String>, + private val traceId: JsonField<String>, + private val appPath: JsonField<String>, + private val completionCost: JsonField<String>, + private val completionTokens: JsonField<Long>, + private val dottedOrder: JsonField<String>, + private val endTime: JsonField<OffsetDateTime>, + private val error: JsonField<String>, + private val events: JsonField<List<JsonValue>>, + private val executionOrder: JsonField<Long>, + private val extra: JsonValue, + private val feedbackStats: JsonField<FeedbackStats>, + private val inputs: JsonValue, + private val inputsPreview: JsonField<String>, + private val inputsS3Urls: JsonValue, + private val manifestId: JsonField<String>, + private val manifestS3Id: JsonField<String>, + private val outputs: JsonValue, + private val outputsPreview: JsonField<String>, + private val outputsS3Urls: JsonValue, + private val parentRunId: JsonField<String>, + private val promptCost: JsonField<String>, + private val promptTokens: JsonField<Long>, + private val referenceExampleId: JsonField<String>, + private val s3Urls: JsonValue, + private val serialized: JsonValue, + private val startTime: JsonField<OffsetDateTime>, + private val tags: JsonField<List<String>>, + private val totalCost: JsonField<String>, + private val totalTokens: JsonField<Long>, + private val traceMaxStartTime: JsonField<OffsetDateTime>, + private val traceMinStartTime: JsonField<OffsetDateTime>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("run_type") + @ExcludeMissing + runType: JsonField<RunTypeEnum> = JsonMissing.of(), + @JsonProperty("session_id") + @ExcludeMissing + sessionId: JsonField<String> = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField<String> = JsonMissing.of(), + @JsonProperty("trace_id") @ExcludeMissing traceId: JsonField<String> = JsonMissing.of(), + @JsonProperty("app_path") @ExcludeMissing appPath: JsonField<String> = JsonMissing.of(), + @JsonProperty("completion_cost") + @ExcludeMissing + completionCost: JsonField<String> = JsonMissing.of(), + @JsonProperty("completion_tokens") + @ExcludeMissing + completionTokens: JsonField<Long> = JsonMissing.of(), + @JsonProperty("dotted_order") + @ExcludeMissing + dottedOrder: JsonField<String> = JsonMissing.of(), + @JsonProperty("end_time") + @ExcludeMissing + endTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("error") @ExcludeMissing error: JsonField<String> = JsonMissing.of(), + @JsonProperty("events") + @ExcludeMissing + events: JsonField<List<JsonValue>> = JsonMissing.of(), + @JsonProperty("execution_order") + @ExcludeMissing + executionOrder: JsonField<Long> = JsonMissing.of(), + @JsonProperty("extra") @ExcludeMissing extra: JsonValue = JsonMissing.of(), + @JsonProperty("feedback_stats") + @ExcludeMissing + feedbackStats: JsonField<FeedbackStats> = JsonMissing.of(), + @JsonProperty("inputs") @ExcludeMissing inputs: JsonValue = JsonMissing.of(), + @JsonProperty("inputs_preview") + @ExcludeMissing + inputsPreview: JsonField<String> = JsonMissing.of(), + @JsonProperty("inputs_s3_urls") + @ExcludeMissing + inputsS3Urls: JsonValue = JsonMissing.of(), + @JsonProperty("manifest_id") + @ExcludeMissing + manifestId: JsonField<String> = JsonMissing.of(), + @JsonProperty("manifest_s3_id") + @ExcludeMissing + manifestS3Id: JsonField<String> = JsonMissing.of(), + @JsonProperty("outputs") @ExcludeMissing outputs: JsonValue = JsonMissing.of(), + @JsonProperty("outputs_preview") + @ExcludeMissing + outputsPreview: JsonField<String> = JsonMissing.of(), + @JsonProperty("outputs_s3_urls") + @ExcludeMissing + outputsS3Urls: JsonValue = JsonMissing.of(), + @JsonProperty("parent_run_id") + @ExcludeMissing + parentRunId: JsonField<String> = JsonMissing.of(), + @JsonProperty("prompt_cost") + @ExcludeMissing + promptCost: JsonField<String> = JsonMissing.of(), + @JsonProperty("prompt_tokens") + @ExcludeMissing + promptTokens: JsonField<Long> = JsonMissing.of(), + @JsonProperty("reference_example_id") + @ExcludeMissing + referenceExampleId: JsonField<String> = JsonMissing.of(), + @JsonProperty("s3_urls") @ExcludeMissing s3Urls: JsonValue = JsonMissing.of(), + @JsonProperty("serialized") @ExcludeMissing serialized: JsonValue = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing tags: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("total_cost") + @ExcludeMissing + totalCost: JsonField<String> = JsonMissing.of(), + @JsonProperty("total_tokens") + @ExcludeMissing + totalTokens: JsonField<Long> = JsonMissing.of(), + @JsonProperty("trace_max_start_time") + @ExcludeMissing + traceMaxStartTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("trace_min_start_time") + @ExcludeMissing + traceMinStartTime: JsonField<OffsetDateTime> = JsonMissing.of(), + ) : this( + id, + name, + runType, + sessionId, + status, + traceId, + appPath, + completionCost, + completionTokens, + dottedOrder, + endTime, + error, + events, + executionOrder, + extra, + feedbackStats, + inputs, + inputsPreview, + inputsS3Urls, + manifestId, + manifestS3Id, + outputs, + outputsPreview, + outputsS3Urls, + parentRunId, + promptCost, + promptTokens, + referenceExampleId, + s3Urls, + serialized, + startTime, + tags, + totalCost, + totalTokens, + traceMaxStartTime, + traceMinStartTime, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Enum for run types. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun runType(): RunTypeEnum = runType.getRequired("run_type") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun sessionId(): String = sessionId.getRequired("session_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): String = status.getRequired("status") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun traceId(): String = traceId.getRequired("trace_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun appPath(): Optional<String> = appPath.getOptional("app_path") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun completionCost(): Optional<String> = completionCost.getOptional("completion_cost") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun completionTokens(): Optional<Long> = completionTokens.getOptional("completion_tokens") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun dottedOrder(): Optional<String> = dottedOrder.getOptional("dotted_order") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun endTime(): Optional<OffsetDateTime> = endTime.getOptional("end_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun error(): Optional<String> = error.getOptional("error") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun events(): Optional<List<JsonValue>> = events.getOptional("events") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun executionOrder(): Optional<Long> = executionOrder.getOptional("execution_order") + + @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonValue = extra + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun feedbackStats(): Optional<FeedbackStats> = feedbackStats.getOptional("feedback_stats") + + @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonValue = inputs + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun inputsPreview(): Optional<String> = inputsPreview.getOptional("inputs_preview") + + @JsonProperty("inputs_s3_urls") + @ExcludeMissing + fun _inputsS3Urls(): JsonValue = inputsS3Urls + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun manifestId(): Optional<String> = manifestId.getOptional("manifest_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun manifestS3Id(): Optional<String> = manifestS3Id.getOptional("manifest_s3_id") + + @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonValue = outputs + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun outputsPreview(): Optional<String> = outputsPreview.getOptional("outputs_preview") + + @JsonProperty("outputs_s3_urls") + @ExcludeMissing + fun _outputsS3Urls(): JsonValue = outputsS3Urls + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun parentRunId(): Optional<String> = parentRunId.getOptional("parent_run_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun promptCost(): Optional<String> = promptCost.getOptional("prompt_cost") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun promptTokens(): Optional<Long> = promptTokens.getOptional("prompt_tokens") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun referenceExampleId(): Optional<String> = + referenceExampleId.getOptional("reference_example_id") + + @JsonProperty("s3_urls") @ExcludeMissing fun _s3Urls(): JsonValue = s3Urls + + @JsonProperty("serialized") @ExcludeMissing fun _serialized(): JsonValue = serialized + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun startTime(): Optional<OffsetDateTime> = startTime.getOptional("start_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun tags(): Optional<List<String>> = tags.getOptional("tags") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun totalCost(): Optional<String> = totalCost.getOptional("total_cost") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun totalTokens(): Optional<Long> = totalTokens.getOptional("total_tokens") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun traceMaxStartTime(): Optional<OffsetDateTime> = + traceMaxStartTime.getOptional("trace_max_start_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun traceMinStartTime(): Optional<OffsetDateTime> = + traceMinStartTime.getOptional("trace_min_start_time") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [runType]. + * + * Unlike [runType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_type") @ExcludeMissing fun _runType(): JsonField<RunTypeEnum> = runType + + /** + * Returns the raw JSON value of [sessionId]. + * + * Unlike [sessionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session_id") @ExcludeMissing fun _sessionId(): JsonField<String> = sessionId + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField<String> = status + + /** + * Returns the raw JSON value of [traceId]. + * + * Unlike [traceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trace_id") @ExcludeMissing fun _traceId(): JsonField<String> = traceId + + /** + * Returns the raw JSON value of [appPath]. + * + * Unlike [appPath], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("app_path") @ExcludeMissing fun _appPath(): JsonField<String> = appPath + + /** + * Returns the raw JSON value of [completionCost]. + * + * Unlike [completionCost], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("completion_cost") + @ExcludeMissing + fun _completionCost(): JsonField<String> = completionCost + + /** + * Returns the raw JSON value of [completionTokens]. + * + * Unlike [completionTokens], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("completion_tokens") + @ExcludeMissing + fun _completionTokens(): JsonField<Long> = completionTokens + + /** + * Returns the raw JSON value of [dottedOrder]. + * + * Unlike [dottedOrder], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dotted_order") + @ExcludeMissing + fun _dottedOrder(): JsonField<String> = dottedOrder + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_time") + @ExcludeMissing + fun _endTime(): JsonField<OffsetDateTime> = endTime + + /** + * Returns the raw JSON value of [error]. + * + * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("error") @ExcludeMissing fun _error(): JsonField<String> = error + + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("events") @ExcludeMissing fun _events(): JsonField<List<JsonValue>> = events + + /** + * Returns the raw JSON value of [executionOrder]. + * + * Unlike [executionOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("execution_order") + @ExcludeMissing + fun _executionOrder(): JsonField<Long> = executionOrder + + /** + * Returns the raw JSON value of [feedbackStats]. + * + * Unlike [feedbackStats], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("feedback_stats") + @ExcludeMissing + fun _feedbackStats(): JsonField<FeedbackStats> = feedbackStats + + /** + * Returns the raw JSON value of [inputsPreview]. + * + * Unlike [inputsPreview], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("inputs_preview") + @ExcludeMissing + fun _inputsPreview(): JsonField<String> = inputsPreview + + /** + * Returns the raw JSON value of [manifestId]. + * + * Unlike [manifestId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("manifest_id") + @ExcludeMissing + fun _manifestId(): JsonField<String> = manifestId + + /** + * Returns the raw JSON value of [manifestS3Id]. + * + * Unlike [manifestS3Id], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("manifest_s3_id") + @ExcludeMissing + fun _manifestS3Id(): JsonField<String> = manifestS3Id + + /** + * Returns the raw JSON value of [outputsPreview]. + * + * Unlike [outputsPreview], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("outputs_preview") + @ExcludeMissing + fun _outputsPreview(): JsonField<String> = outputsPreview + + /** + * Returns the raw JSON value of [parentRunId]. + * + * Unlike [parentRunId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("parent_run_id") + @ExcludeMissing + fun _parentRunId(): JsonField<String> = parentRunId + + /** + * Returns the raw JSON value of [promptCost]. + * + * Unlike [promptCost], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prompt_cost") + @ExcludeMissing + fun _promptCost(): JsonField<String> = promptCost + + /** + * Returns the raw JSON value of [promptTokens]. + * + * Unlike [promptTokens], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("prompt_tokens") + @ExcludeMissing + fun _promptTokens(): JsonField<Long> = promptTokens + + /** + * Returns the raw JSON value of [referenceExampleId]. + * + * Unlike [referenceExampleId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_example_id") + @ExcludeMissing + fun _referenceExampleId(): JsonField<String> = referenceExampleId + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_time") + @ExcludeMissing + fun _startTime(): JsonField<OffsetDateTime> = startTime + + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField<List<String>> = tags + + /** + * Returns the raw JSON value of [totalCost]. + * + * Unlike [totalCost], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total_cost") @ExcludeMissing fun _totalCost(): JsonField<String> = totalCost + + /** + * Returns the raw JSON value of [totalTokens]. + * + * Unlike [totalTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total_tokens") + @ExcludeMissing + fun _totalTokens(): JsonField<Long> = totalTokens + + /** + * Returns the raw JSON value of [traceMaxStartTime]. + * + * Unlike [traceMaxStartTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("trace_max_start_time") + @ExcludeMissing + fun _traceMaxStartTime(): JsonField<OffsetDateTime> = traceMaxStartTime + + /** + * Returns the raw JSON value of [traceMinStartTime]. + * + * Unlike [traceMinStartTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("trace_min_start_time") + @ExcludeMissing + fun _traceMinStartTime(): JsonField<OffsetDateTime> = traceMinStartTime + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Run]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .runType() + * .sessionId() + * .status() + * .traceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Run]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var name: JsonField<String>? = null + private var runType: JsonField<RunTypeEnum>? = null + private var sessionId: JsonField<String>? = null + private var status: JsonField<String>? = null + private var traceId: JsonField<String>? = null + private var appPath: JsonField<String> = JsonMissing.of() + private var completionCost: JsonField<String> = JsonMissing.of() + private var completionTokens: JsonField<Long> = JsonMissing.of() + private var dottedOrder: JsonField<String> = JsonMissing.of() + private var endTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var error: JsonField<String> = JsonMissing.of() + private var events: JsonField<MutableList<JsonValue>>? = null + private var executionOrder: JsonField<Long> = JsonMissing.of() + private var extra: JsonValue = JsonMissing.of() + private var feedbackStats: JsonField<FeedbackStats> = JsonMissing.of() + private var inputs: JsonValue = JsonMissing.of() + private var inputsPreview: JsonField<String> = JsonMissing.of() + private var inputsS3Urls: JsonValue = JsonMissing.of() + private var manifestId: JsonField<String> = JsonMissing.of() + private var manifestS3Id: JsonField<String> = JsonMissing.of() + private var outputs: JsonValue = JsonMissing.of() + private var outputsPreview: JsonField<String> = JsonMissing.of() + private var outputsS3Urls: JsonValue = JsonMissing.of() + private var parentRunId: JsonField<String> = JsonMissing.of() + private var promptCost: JsonField<String> = JsonMissing.of() + private var promptTokens: JsonField<Long> = JsonMissing.of() + private var referenceExampleId: JsonField<String> = JsonMissing.of() + private var s3Urls: JsonValue = JsonMissing.of() + private var serialized: JsonValue = JsonMissing.of() + private var startTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var tags: JsonField<MutableList<String>>? = null + private var totalCost: JsonField<String> = JsonMissing.of() + private var totalTokens: JsonField<Long> = JsonMissing.of() + private var traceMaxStartTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var traceMinStartTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(run: Run) = apply { + id = run.id + name = run.name + runType = run.runType + sessionId = run.sessionId + status = run.status + traceId = run.traceId + appPath = run.appPath + completionCost = run.completionCost + completionTokens = run.completionTokens + dottedOrder = run.dottedOrder + endTime = run.endTime + error = run.error + events = run.events.map { it.toMutableList() } + executionOrder = run.executionOrder + extra = run.extra + feedbackStats = run.feedbackStats + inputs = run.inputs + inputsPreview = run.inputsPreview + inputsS3Urls = run.inputsS3Urls + manifestId = run.manifestId + manifestS3Id = run.manifestS3Id + outputs = run.outputs + outputsPreview = run.outputsPreview + outputsS3Urls = run.outputsS3Urls + parentRunId = run.parentRunId + promptCost = run.promptCost + promptTokens = run.promptTokens + referenceExampleId = run.referenceExampleId + s3Urls = run.s3Urls + serialized = run.serialized + startTime = run.startTime + tags = run.tags.map { it.toMutableList() } + totalCost = run.totalCost + totalTokens = run.totalTokens + traceMaxStartTime = run.traceMaxStartTime + traceMinStartTime = run.traceMinStartTime + additionalProperties = run.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + /** Enum for run types. */ + fun runType(runType: RunTypeEnum) = runType(JsonField.of(runType)) + + /** + * Sets [Builder.runType] to an arbitrary JSON value. + * + * You should usually call [Builder.runType] with a well-typed [RunTypeEnum] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun runType(runType: JsonField<RunTypeEnum>) = apply { this.runType = runType } + + fun sessionId(sessionId: String) = sessionId(JsonField.of(sessionId)) + + /** + * Sets [Builder.sessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sessionId(sessionId: JsonField<String>) = apply { this.sessionId = sessionId } + + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField<String>) = apply { this.status = status } + + fun traceId(traceId: String) = traceId(JsonField.of(traceId)) + + /** + * Sets [Builder.traceId] to an arbitrary JSON value. + * + * You should usually call [Builder.traceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun traceId(traceId: JsonField<String>) = apply { this.traceId = traceId } + + fun appPath(appPath: String?) = appPath(JsonField.ofNullable(appPath)) + + /** Alias for calling [Builder.appPath] with `appPath.orElse(null)`. */ + fun appPath(appPath: Optional<String>) = appPath(appPath.getOrNull()) + + /** + * Sets [Builder.appPath] to an arbitrary JSON value. + * + * You should usually call [Builder.appPath] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun appPath(appPath: JsonField<String>) = apply { this.appPath = appPath } + + fun completionCost(completionCost: String?) = + completionCost(JsonField.ofNullable(completionCost)) + + /** Alias for calling [Builder.completionCost] with `completionCost.orElse(null)`. */ + fun completionCost(completionCost: Optional<String>) = + completionCost(completionCost.getOrNull()) + + /** + * Sets [Builder.completionCost] to an arbitrary JSON value. + * + * You should usually call [Builder.completionCost] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun completionCost(completionCost: JsonField<String>) = apply { + this.completionCost = completionCost + } + + fun completionTokens(completionTokens: Long?) = + completionTokens(JsonField.ofNullable(completionTokens)) + + /** + * Alias for [Builder.completionTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun completionTokens(completionTokens: Long) = + completionTokens(completionTokens as Long?) + + /** + * Alias for calling [Builder.completionTokens] with `completionTokens.orElse(null)`. + */ + fun completionTokens(completionTokens: Optional<Long>) = + completionTokens(completionTokens.getOrNull()) + + /** + * Sets [Builder.completionTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.completionTokens] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun completionTokens(completionTokens: JsonField<Long>) = apply { + this.completionTokens = completionTokens + } + + fun dottedOrder(dottedOrder: String?) = dottedOrder(JsonField.ofNullable(dottedOrder)) + + /** Alias for calling [Builder.dottedOrder] with `dottedOrder.orElse(null)`. */ + fun dottedOrder(dottedOrder: Optional<String>) = dottedOrder(dottedOrder.getOrNull()) + + /** + * Sets [Builder.dottedOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.dottedOrder] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dottedOrder(dottedOrder: JsonField<String>) = apply { + this.dottedOrder = dottedOrder + } + + fun endTime(endTime: OffsetDateTime?) = endTime(JsonField.ofNullable(endTime)) + + /** Alias for calling [Builder.endTime] with `endTime.orElse(null)`. */ + fun endTime(endTime: Optional<OffsetDateTime>) = endTime(endTime.getOrNull()) + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endTime(endTime: JsonField<OffsetDateTime>) = apply { this.endTime = endTime } + + fun error(error: String?) = error(JsonField.ofNullable(error)) + + /** Alias for calling [Builder.error] with `error.orElse(null)`. */ + fun error(error: Optional<String>) = error(error.getOrNull()) + + /** + * Sets [Builder.error] to an arbitrary JSON value. + * + * You should usually call [Builder.error] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun error(error: JsonField<String>) = apply { this.error = error } + + fun events(events: List<JsonValue>?) = events(JsonField.ofNullable(events)) + + /** Alias for calling [Builder.events] with `events.orElse(null)`. */ + fun events(events: Optional<List<JsonValue>>) = events(events.getOrNull()) + + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed `List<JsonValue>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun events(events: JsonField<List<JsonValue>>) = apply { + this.events = events.map { it.toMutableList() } + } + + /** + * Adds a single [JsonValue] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvent(event: JsonValue) = apply { + events = + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) + } + } + + fun executionOrder(executionOrder: Long) = executionOrder(JsonField.of(executionOrder)) + + /** + * Sets [Builder.executionOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.executionOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun executionOrder(executionOrder: JsonField<Long>) = apply { + this.executionOrder = executionOrder + } + + fun extra(extra: JsonValue) = apply { this.extra = extra } + + fun feedbackStats(feedbackStats: FeedbackStats?) = + feedbackStats(JsonField.ofNullable(feedbackStats)) + + /** Alias for calling [Builder.feedbackStats] with `feedbackStats.orElse(null)`. */ + fun feedbackStats(feedbackStats: Optional<FeedbackStats>) = + feedbackStats(feedbackStats.getOrNull()) + + /** + * Sets [Builder.feedbackStats] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackStats] with a well-typed [FeedbackStats] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun feedbackStats(feedbackStats: JsonField<FeedbackStats>) = apply { + this.feedbackStats = feedbackStats + } + + fun inputs(inputs: JsonValue) = apply { this.inputs = inputs } + + fun inputsPreview(inputsPreview: String?) = + inputsPreview(JsonField.ofNullable(inputsPreview)) + + /** Alias for calling [Builder.inputsPreview] with `inputsPreview.orElse(null)`. */ + fun inputsPreview(inputsPreview: Optional<String>) = + inputsPreview(inputsPreview.getOrNull()) + + /** + * Sets [Builder.inputsPreview] to an arbitrary JSON value. + * + * You should usually call [Builder.inputsPreview] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inputsPreview(inputsPreview: JsonField<String>) = apply { + this.inputsPreview = inputsPreview + } + + fun inputsS3Urls(inputsS3Urls: JsonValue) = apply { this.inputsS3Urls = inputsS3Urls } + + fun manifestId(manifestId: String?) = manifestId(JsonField.ofNullable(manifestId)) + + /** Alias for calling [Builder.manifestId] with `manifestId.orElse(null)`. */ + fun manifestId(manifestId: Optional<String>) = manifestId(manifestId.getOrNull()) + + /** + * Sets [Builder.manifestId] to an arbitrary JSON value. + * + * You should usually call [Builder.manifestId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun manifestId(manifestId: JsonField<String>) = apply { this.manifestId = manifestId } + + fun manifestS3Id(manifestS3Id: String?) = + manifestS3Id(JsonField.ofNullable(manifestS3Id)) + + /** Alias for calling [Builder.manifestS3Id] with `manifestS3Id.orElse(null)`. */ + fun manifestS3Id(manifestS3Id: Optional<String>) = + manifestS3Id(manifestS3Id.getOrNull()) + + /** + * Sets [Builder.manifestS3Id] to an arbitrary JSON value. + * + * You should usually call [Builder.manifestS3Id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun manifestS3Id(manifestS3Id: JsonField<String>) = apply { + this.manifestS3Id = manifestS3Id + } + + fun outputs(outputs: JsonValue) = apply { this.outputs = outputs } + + fun outputsPreview(outputsPreview: String?) = + outputsPreview(JsonField.ofNullable(outputsPreview)) + + /** Alias for calling [Builder.outputsPreview] with `outputsPreview.orElse(null)`. */ + fun outputsPreview(outputsPreview: Optional<String>) = + outputsPreview(outputsPreview.getOrNull()) + + /** + * Sets [Builder.outputsPreview] to an arbitrary JSON value. + * + * You should usually call [Builder.outputsPreview] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun outputsPreview(outputsPreview: JsonField<String>) = apply { + this.outputsPreview = outputsPreview + } + + fun outputsS3Urls(outputsS3Urls: JsonValue) = apply { + this.outputsS3Urls = outputsS3Urls + } + + fun parentRunId(parentRunId: String?) = parentRunId(JsonField.ofNullable(parentRunId)) + + /** Alias for calling [Builder.parentRunId] with `parentRunId.orElse(null)`. */ + fun parentRunId(parentRunId: Optional<String>) = parentRunId(parentRunId.getOrNull()) + + /** + * Sets [Builder.parentRunId] to an arbitrary JSON value. + * + * You should usually call [Builder.parentRunId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun parentRunId(parentRunId: JsonField<String>) = apply { + this.parentRunId = parentRunId + } + + fun promptCost(promptCost: String?) = promptCost(JsonField.ofNullable(promptCost)) + + /** Alias for calling [Builder.promptCost] with `promptCost.orElse(null)`. */ + fun promptCost(promptCost: Optional<String>) = promptCost(promptCost.getOrNull()) + + /** + * Sets [Builder.promptCost] to an arbitrary JSON value. + * + * You should usually call [Builder.promptCost] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun promptCost(promptCost: JsonField<String>) = apply { this.promptCost = promptCost } + + fun promptTokens(promptTokens: Long?) = promptTokens(JsonField.ofNullable(promptTokens)) + + /** + * Alias for [Builder.promptTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun promptTokens(promptTokens: Long) = promptTokens(promptTokens as Long?) + + /** Alias for calling [Builder.promptTokens] with `promptTokens.orElse(null)`. */ + fun promptTokens(promptTokens: Optional<Long>) = promptTokens(promptTokens.getOrNull()) + + /** + * Sets [Builder.promptTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.promptTokens] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun promptTokens(promptTokens: JsonField<Long>) = apply { + this.promptTokens = promptTokens + } + + fun referenceExampleId(referenceExampleId: String?) = + referenceExampleId(JsonField.ofNullable(referenceExampleId)) + + /** + * Alias for calling [Builder.referenceExampleId] with + * `referenceExampleId.orElse(null)`. + */ + fun referenceExampleId(referenceExampleId: Optional<String>) = + referenceExampleId(referenceExampleId.getOrNull()) + + /** + * Sets [Builder.referenceExampleId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceExampleId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun referenceExampleId(referenceExampleId: JsonField<String>) = apply { + this.referenceExampleId = referenceExampleId + } + + fun s3Urls(s3Urls: JsonValue) = apply { this.s3Urls = s3Urls } + + fun serialized(serialized: JsonValue) = apply { this.serialized = serialized } + + fun startTime(startTime: OffsetDateTime) = startTime(JsonField.of(startTime)) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField<OffsetDateTime>) = apply { + this.startTime = startTime + } + + fun tags(tags: List<String>?) = tags(JsonField.ofNullable(tags)) + + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ + fun tags(tags: Optional<List<String>>) = tags(tags.getOrNull()) + + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tags(tags: JsonField<List<String>>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { + tags = + (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } + + fun totalCost(totalCost: String?) = totalCost(JsonField.ofNullable(totalCost)) + + /** Alias for calling [Builder.totalCost] with `totalCost.orElse(null)`. */ + fun totalCost(totalCost: Optional<String>) = totalCost(totalCost.getOrNull()) + + /** + * Sets [Builder.totalCost] to an arbitrary JSON value. + * + * You should usually call [Builder.totalCost] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun totalCost(totalCost: JsonField<String>) = apply { this.totalCost = totalCost } + + fun totalTokens(totalTokens: Long?) = totalTokens(JsonField.ofNullable(totalTokens)) + + /** + * Alias for [Builder.totalTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun totalTokens(totalTokens: Long) = totalTokens(totalTokens as Long?) + + /** Alias for calling [Builder.totalTokens] with `totalTokens.orElse(null)`. */ + fun totalTokens(totalTokens: Optional<Long>) = totalTokens(totalTokens.getOrNull()) + + /** + * Sets [Builder.totalTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.totalTokens] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun totalTokens(totalTokens: JsonField<Long>) = apply { this.totalTokens = totalTokens } + + fun traceMaxStartTime(traceMaxStartTime: OffsetDateTime?) = + traceMaxStartTime(JsonField.ofNullable(traceMaxStartTime)) + + /** + * Alias for calling [Builder.traceMaxStartTime] with `traceMaxStartTime.orElse(null)`. + */ + fun traceMaxStartTime(traceMaxStartTime: Optional<OffsetDateTime>) = + traceMaxStartTime(traceMaxStartTime.getOrNull()) + + /** + * Sets [Builder.traceMaxStartTime] to an arbitrary JSON value. + * + * You should usually call [Builder.traceMaxStartTime] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun traceMaxStartTime(traceMaxStartTime: JsonField<OffsetDateTime>) = apply { + this.traceMaxStartTime = traceMaxStartTime + } + + fun traceMinStartTime(traceMinStartTime: OffsetDateTime?) = + traceMinStartTime(JsonField.ofNullable(traceMinStartTime)) + + /** + * Alias for calling [Builder.traceMinStartTime] with `traceMinStartTime.orElse(null)`. + */ + fun traceMinStartTime(traceMinStartTime: Optional<OffsetDateTime>) = + traceMinStartTime(traceMinStartTime.getOrNull()) + + /** + * Sets [Builder.traceMinStartTime] to an arbitrary JSON value. + * + * You should usually call [Builder.traceMinStartTime] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun traceMinStartTime(traceMinStartTime: JsonField<OffsetDateTime>) = apply { + this.traceMinStartTime = traceMinStartTime + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Run]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .runType() + * .sessionId() + * .status() + * .traceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Run = + Run( + checkRequired("id", id), + checkRequired("name", name), + checkRequired("runType", runType), + checkRequired("sessionId", sessionId), + checkRequired("status", status), + checkRequired("traceId", traceId), + appPath, + completionCost, + completionTokens, + dottedOrder, + endTime, + error, + (events ?: JsonMissing.of()).map { it.toImmutable() }, + executionOrder, + extra, + feedbackStats, + inputs, + inputsPreview, + inputsS3Urls, + manifestId, + manifestS3Id, + outputs, + outputsPreview, + outputsS3Urls, + parentRunId, + promptCost, + promptTokens, + referenceExampleId, + s3Urls, + serialized, + startTime, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + totalCost, + totalTokens, + traceMaxStartTime, + traceMinStartTime, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Run = apply { + if (validated) { + return@apply + } + + id() + name() + runType().validate() + sessionId() + status() + traceId() + appPath() + completionCost() + completionTokens() + dottedOrder() + endTime() + error() + events() + executionOrder() + feedbackStats().ifPresent { it.validate() } + inputsPreview() + manifestId() + manifestS3Id() + outputsPreview() + parentRunId() + promptCost() + promptTokens() + referenceExampleId() + startTime() + tags() + totalCost() + totalTokens() + traceMaxStartTime() + traceMinStartTime() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (runType.asKnown().getOrNull()?.validity() ?: 0) + + (if (sessionId.asKnown().isPresent) 1 else 0) + + (if (status.asKnown().isPresent) 1 else 0) + + (if (traceId.asKnown().isPresent) 1 else 0) + + (if (appPath.asKnown().isPresent) 1 else 0) + + (if (completionCost.asKnown().isPresent) 1 else 0) + + (if (completionTokens.asKnown().isPresent) 1 else 0) + + (if (dottedOrder.asKnown().isPresent) 1 else 0) + + (if (endTime.asKnown().isPresent) 1 else 0) + + (if (error.asKnown().isPresent) 1 else 0) + + (events.asKnown().getOrNull()?.size ?: 0) + + (if (executionOrder.asKnown().isPresent) 1 else 0) + + (feedbackStats.asKnown().getOrNull()?.validity() ?: 0) + + (if (inputsPreview.asKnown().isPresent) 1 else 0) + + (if (manifestId.asKnown().isPresent) 1 else 0) + + (if (manifestS3Id.asKnown().isPresent) 1 else 0) + + (if (outputsPreview.asKnown().isPresent) 1 else 0) + + (if (parentRunId.asKnown().isPresent) 1 else 0) + + (if (promptCost.asKnown().isPresent) 1 else 0) + + (if (promptTokens.asKnown().isPresent) 1 else 0) + + (if (referenceExampleId.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + (tags.asKnown().getOrNull()?.size ?: 0) + + (if (totalCost.asKnown().isPresent) 1 else 0) + + (if (totalTokens.asKnown().isPresent) 1 else 0) + + (if (traceMaxStartTime.asKnown().isPresent) 1 else 0) + + (if (traceMinStartTime.asKnown().isPresent) 1 else 0) + + class FeedbackStats + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [FeedbackStats]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackStats]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(feedbackStats: FeedbackStats) = apply { + additionalProperties = feedbackStats.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FeedbackStats]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FeedbackStats = FeedbackStats(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): FeedbackStats = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackStats && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "FeedbackStats{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Run && + id == other.id && + name == other.name && + runType == other.runType && + sessionId == other.sessionId && + status == other.status && + traceId == other.traceId && + appPath == other.appPath && + completionCost == other.completionCost && + completionTokens == other.completionTokens && + dottedOrder == other.dottedOrder && + endTime == other.endTime && + error == other.error && + events == other.events && + executionOrder == other.executionOrder && + extra == other.extra && + feedbackStats == other.feedbackStats && + inputs == other.inputs && + inputsPreview == other.inputsPreview && + inputsS3Urls == other.inputsS3Urls && + manifestId == other.manifestId && + manifestS3Id == other.manifestS3Id && + outputs == other.outputs && + outputsPreview == other.outputsPreview && + outputsS3Urls == other.outputsS3Urls && + parentRunId == other.parentRunId && + promptCost == other.promptCost && + promptTokens == other.promptTokens && + referenceExampleId == other.referenceExampleId && + s3Urls == other.s3Urls && + serialized == other.serialized && + startTime == other.startTime && + tags == other.tags && + totalCost == other.totalCost && + totalTokens == other.totalTokens && + traceMaxStartTime == other.traceMaxStartTime && + traceMinStartTime == other.traceMinStartTime && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + name, + runType, + sessionId, + status, + traceId, + appPath, + completionCost, + completionTokens, + dottedOrder, + endTime, + error, + events, + executionOrder, + extra, + feedbackStats, + inputs, + inputsPreview, + inputsS3Urls, + manifestId, + manifestS3Id, + outputs, + outputsPreview, + outputsS3Urls, + parentRunId, + promptCost, + promptTokens, + referenceExampleId, + s3Urls, + serialized, + startTime, + tags, + totalCost, + totalTokens, + traceMaxStartTime, + traceMinStartTime, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Run{id=$id, name=$name, runType=$runType, sessionId=$sessionId, status=$status, traceId=$traceId, appPath=$appPath, completionCost=$completionCost, completionTokens=$completionTokens, dottedOrder=$dottedOrder, endTime=$endTime, error=$error, events=$events, executionOrder=$executionOrder, extra=$extra, feedbackStats=$feedbackStats, inputs=$inputs, inputsPreview=$inputsPreview, inputsS3Urls=$inputsS3Urls, manifestId=$manifestId, manifestS3Id=$manifestS3Id, outputs=$outputs, outputsPreview=$outputsPreview, outputsS3Urls=$outputsS3Urls, parentRunId=$parentRunId, promptCost=$promptCost, promptTokens=$promptTokens, referenceExampleId=$referenceExampleId, s3Urls=$s3Urls, serialized=$serialized, startTime=$startTime, tags=$tags, totalCost=$totalCost, totalTokens=$totalTokens, traceMaxStartTime=$traceMaxStartTime, traceMinStartTime=$traceMinStartTime, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExampleWithRunsCh && + id == other.id && + datasetId == other.datasetId && + inputs == other.inputs && + name == other.name && + runs == other.runs && + attachmentUrls == other.attachmentUrls && + createdAt == other.createdAt && + metadata == other.metadata && + modifiedAt == other.modifiedAt && + outputs == other.outputs && + sourceRunId == other.sourceRunId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + datasetId, + inputs, + name, + runs, + attachmentUrls, + createdAt, + metadata, + modifiedAt, + outputs, + sourceRunId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ExampleWithRunsCh{id=$id, datasetId=$datasetId, inputs=$inputs, name=$name, runs=$runs, attachmentUrls=$attachmentUrls, createdAt=$createdAt, metadata=$metadata, modifiedAt=$modifiedAt, outputs=$outputs, sourceRunId=$sourceRunId, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/QueryExampleSchemaWithRuns.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/QueryExampleSchemaWithRuns.kt new file mode 100644 index 00000000..5ec0272b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/QueryExampleSchemaWithRuns.kt @@ -0,0 +1,1011 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.runs + +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.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class QueryExampleSchemaWithRuns +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val sessionIds: JsonField<List<String>>, + private val comparativeExperimentId: JsonField<String>, + private val filters: JsonField<Filters>, + private val format: JsonField<Format>, + private val limit: JsonField<Long>, + private val offset: JsonField<Long>, + private val preview: JsonField<Boolean>, + private val sortParams: JsonField<SortParams>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("session_ids") + @ExcludeMissing + sessionIds: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("comparative_experiment_id") + @ExcludeMissing + comparativeExperimentId: JsonField<String> = JsonMissing.of(), + @JsonProperty("filters") @ExcludeMissing filters: JsonField<Filters> = JsonMissing.of(), + @JsonProperty("format") @ExcludeMissing format: JsonField<Format> = JsonMissing.of(), + @JsonProperty("limit") @ExcludeMissing limit: JsonField<Long> = JsonMissing.of(), + @JsonProperty("offset") @ExcludeMissing offset: JsonField<Long> = JsonMissing.of(), + @JsonProperty("preview") @ExcludeMissing preview: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("sort_params") + @ExcludeMissing + sortParams: JsonField<SortParams> = JsonMissing.of(), + ) : this( + sessionIds, + comparativeExperimentId, + filters, + format, + limit, + offset, + preview, + sortParams, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun sessionIds(): List<String> = sessionIds.getRequired("session_ids") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun comparativeExperimentId(): Optional<String> = + comparativeExperimentId.getOptional("comparative_experiment_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun filters(): Optional<Filters> = filters.getOptional("filters") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun format(): Optional<Format> = format.getOptional("format") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun limit(): Optional<Long> = limit.getOptional("limit") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun offset(): Optional<Long> = offset.getOptional("offset") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun preview(): Optional<Boolean> = preview.getOptional("preview") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun sortParams(): Optional<SortParams> = sortParams.getOptional("sort_params") + + /** + * Returns the raw JSON value of [sessionIds]. + * + * Unlike [sessionIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session_ids") + @ExcludeMissing + fun _sessionIds(): JsonField<List<String>> = sessionIds + + /** + * Returns the raw JSON value of [comparativeExperimentId]. + * + * Unlike [comparativeExperimentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("comparative_experiment_id") + @ExcludeMissing + fun _comparativeExperimentId(): JsonField<String> = comparativeExperimentId + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField<Filters> = filters + + /** + * Returns the raw JSON value of [format]. + * + * Unlike [format], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("format") @ExcludeMissing fun _format(): JsonField<Format> = format + + /** + * Returns the raw JSON value of [limit]. + * + * Unlike [limit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("limit") @ExcludeMissing fun _limit(): JsonField<Long> = limit + + /** + * Returns the raw JSON value of [offset]. + * + * Unlike [offset], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("offset") @ExcludeMissing fun _offset(): JsonField<Long> = offset + + /** + * Returns the raw JSON value of [preview]. + * + * Unlike [preview], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("preview") @ExcludeMissing fun _preview(): JsonField<Boolean> = preview + + /** + * Returns the raw JSON value of [sortParams]. + * + * Unlike [sortParams], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sort_params") + @ExcludeMissing + fun _sortParams(): JsonField<SortParams> = sortParams + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [QueryExampleSchemaWithRuns]. + * + * The following fields are required: + * ```java + * .sessionIds() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [QueryExampleSchemaWithRuns]. */ + class Builder internal constructor() { + + private var sessionIds: JsonField<MutableList<String>>? = null + private var comparativeExperimentId: JsonField<String> = JsonMissing.of() + private var filters: JsonField<Filters> = JsonMissing.of() + private var format: JsonField<Format> = JsonMissing.of() + private var limit: JsonField<Long> = JsonMissing.of() + private var offset: JsonField<Long> = JsonMissing.of() + private var preview: JsonField<Boolean> = JsonMissing.of() + private var sortParams: JsonField<SortParams> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(queryExampleSchemaWithRuns: QueryExampleSchemaWithRuns) = apply { + sessionIds = queryExampleSchemaWithRuns.sessionIds.map { it.toMutableList() } + comparativeExperimentId = queryExampleSchemaWithRuns.comparativeExperimentId + filters = queryExampleSchemaWithRuns.filters + format = queryExampleSchemaWithRuns.format + limit = queryExampleSchemaWithRuns.limit + offset = queryExampleSchemaWithRuns.offset + preview = queryExampleSchemaWithRuns.preview + sortParams = queryExampleSchemaWithRuns.sortParams + additionalProperties = queryExampleSchemaWithRuns.additionalProperties.toMutableMap() + } + + fun sessionIds(sessionIds: List<String>) = sessionIds(JsonField.of(sessionIds)) + + /** + * Sets [Builder.sessionIds] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionIds] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sessionIds(sessionIds: JsonField<List<String>>) = apply { + this.sessionIds = sessionIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [sessionIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSessionId(sessionId: String) = apply { + sessionIds = + (sessionIds ?: JsonField.of(mutableListOf())).also { + checkKnown("sessionIds", it).add(sessionId) + } + } + + fun comparativeExperimentId(comparativeExperimentId: String?) = + comparativeExperimentId(JsonField.ofNullable(comparativeExperimentId)) + + /** + * Alias for calling [Builder.comparativeExperimentId] with + * `comparativeExperimentId.orElse(null)`. + */ + fun comparativeExperimentId(comparativeExperimentId: Optional<String>) = + comparativeExperimentId(comparativeExperimentId.getOrNull()) + + /** + * Sets [Builder.comparativeExperimentId] to an arbitrary JSON value. + * + * You should usually call [Builder.comparativeExperimentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun comparativeExperimentId(comparativeExperimentId: JsonField<String>) = apply { + this.comparativeExperimentId = comparativeExperimentId + } + + fun filters(filters: Filters?) = filters(JsonField.ofNullable(filters)) + + /** Alias for calling [Builder.filters] with `filters.orElse(null)`. */ + fun filters(filters: Optional<Filters>) = filters(filters.getOrNull()) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed [Filters] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField<Filters>) = apply { this.filters = filters } + + fun format(format: Format?) = format(JsonField.ofNullable(format)) + + /** Alias for calling [Builder.format] with `format.orElse(null)`. */ + fun format(format: Optional<Format>) = format(format.getOrNull()) + + /** + * Sets [Builder.format] to an arbitrary JSON value. + * + * You should usually call [Builder.format] with a well-typed [Format] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun format(format: JsonField<Format>) = apply { this.format = format } + + fun limit(limit: Long) = limit(JsonField.of(limit)) + + /** + * Sets [Builder.limit] to an arbitrary JSON value. + * + * You should usually call [Builder.limit] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun limit(limit: JsonField<Long>) = apply { this.limit = limit } + + fun offset(offset: Long) = offset(JsonField.of(offset)) + + /** + * Sets [Builder.offset] to an arbitrary JSON value. + * + * You should usually call [Builder.offset] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun offset(offset: JsonField<Long>) = apply { this.offset = offset } + + fun preview(preview: Boolean) = preview(JsonField.of(preview)) + + /** + * Sets [Builder.preview] to an arbitrary JSON value. + * + * You should usually call [Builder.preview] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun preview(preview: JsonField<Boolean>) = apply { this.preview = preview } + + fun sortParams(sortParams: SortParams?) = sortParams(JsonField.ofNullable(sortParams)) + + /** Alias for calling [Builder.sortParams] with `sortParams.orElse(null)`. */ + fun sortParams(sortParams: Optional<SortParams>) = sortParams(sortParams.getOrNull()) + + /** + * Sets [Builder.sortParams] to an arbitrary JSON value. + * + * You should usually call [Builder.sortParams] with a well-typed [SortParams] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sortParams(sortParams: JsonField<SortParams>) = apply { this.sortParams = sortParams } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [QueryExampleSchemaWithRuns]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .sessionIds() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): QueryExampleSchemaWithRuns = + QueryExampleSchemaWithRuns( + checkRequired("sessionIds", sessionIds).map { it.toImmutable() }, + comparativeExperimentId, + filters, + format, + limit, + offset, + preview, + sortParams, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): QueryExampleSchemaWithRuns = apply { + if (validated) { + return@apply + } + + sessionIds() + comparativeExperimentId() + filters().ifPresent { it.validate() } + format().ifPresent { it.validate() } + limit() + offset() + preview() + sortParams().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (sessionIds.asKnown().getOrNull()?.size ?: 0) + + (if (comparativeExperimentId.asKnown().isPresent) 1 else 0) + + (filters.asKnown().getOrNull()?.validity() ?: 0) + + (format.asKnown().getOrNull()?.validity() ?: 0) + + (if (limit.asKnown().isPresent) 1 else 0) + + (if (offset.asKnown().isPresent) 1 else 0) + + (if (preview.asKnown().isPresent) 1 else 0) + + (sortParams.asKnown().getOrNull()?.validity() ?: 0) + + class Filters + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Filters]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Filters]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(filters: Filters) = apply { + additionalProperties = filters.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Filters = Filters(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Filters = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filters && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Filters{additionalProperties=$additionalProperties}" + } + + class Format @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val CSV = of("csv") + + @JvmStatic fun of(value: String) = Format(JsonField.of(value)) + } + + /** An enum containing [Format]'s known values. */ + enum class Known { + CSV + } + + /** + * An enum containing [Format]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Format] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CSV, + /** An enum member indicating that [Format] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CSV -> Value.CSV + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CSV -> Known.CSV + else -> throw LangsmithApiInvalidDataException("Unknown Format: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Format = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Format && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class SortParams + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val sortBy: JsonField<String>, + private val sortOrder: JsonField<SortOrder>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("sort_by") @ExcludeMissing sortBy: JsonField<String> = JsonMissing.of(), + @JsonProperty("sort_order") + @ExcludeMissing + sortOrder: JsonField<SortOrder> = JsonMissing.of(), + ) : this(sortBy, sortOrder, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun sortBy(): String = sortBy.getRequired("sort_by") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun sortOrder(): Optional<SortOrder> = sortOrder.getOptional("sort_order") + + /** + * Returns the raw JSON value of [sortBy]. + * + * Unlike [sortBy], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sort_by") @ExcludeMissing fun _sortBy(): JsonField<String> = sortBy + + /** + * Returns the raw JSON value of [sortOrder]. + * + * Unlike [sortOrder], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sort_order") + @ExcludeMissing + fun _sortOrder(): JsonField<SortOrder> = sortOrder + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SortParams]. + * + * The following fields are required: + * ```java + * .sortBy() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SortParams]. */ + class Builder internal constructor() { + + private var sortBy: JsonField<String>? = null + private var sortOrder: JsonField<SortOrder> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(sortParams: SortParams) = apply { + sortBy = sortParams.sortBy + sortOrder = sortParams.sortOrder + additionalProperties = sortParams.additionalProperties.toMutableMap() + } + + fun sortBy(sortBy: String) = sortBy(JsonField.of(sortBy)) + + /** + * Sets [Builder.sortBy] to an arbitrary JSON value. + * + * You should usually call [Builder.sortBy] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sortBy(sortBy: JsonField<String>) = apply { this.sortBy = sortBy } + + fun sortOrder(sortOrder: SortOrder) = sortOrder(JsonField.of(sortOrder)) + + /** + * Sets [Builder.sortOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.sortOrder] with a well-typed [SortOrder] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sortOrder(sortOrder: JsonField<SortOrder>) = apply { this.sortOrder = sortOrder } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SortParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .sortBy() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SortParams = + SortParams( + checkRequired("sortBy", sortBy), + sortOrder, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SortParams = apply { + if (validated) { + return@apply + } + + sortBy() + sortOrder().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (sortBy.asKnown().isPresent) 1 else 0) + + (sortOrder.asKnown().getOrNull()?.validity() ?: 0) + + class SortOrder @JsonCreator private constructor(private val value: JsonField<String>) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val ASC = of("ASC") + + @JvmField val DESC = of("DESC") + + @JvmStatic fun of(value: String) = SortOrder(JsonField.of(value)) + } + + /** An enum containing [SortOrder]'s known values. */ + enum class Known { + ASC, + DESC, + } + + /** + * An enum containing [SortOrder]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [SortOrder] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ASC, + DESC, + /** + * An enum member indicating that [SortOrder] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ASC -> Value.ASC + DESC -> Value.DESC + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ASC -> Known.ASC + DESC -> Known.DESC + else -> throw LangsmithApiInvalidDataException("Unknown SortOrder: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): SortOrder = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SortOrder && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SortParams && + sortBy == other.sortBy && + sortOrder == other.sortOrder && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(sortBy, sortOrder, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SortParams{sortBy=$sortBy, sortOrder=$sortOrder, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is QueryExampleSchemaWithRuns && + sessionIds == other.sessionIds && + comparativeExperimentId == other.comparativeExperimentId && + filters == other.filters && + format == other.format && + limit == other.limit && + offset == other.offset && + preview == other.preview && + sortParams == other.sortParams && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + sessionIds, + comparativeExperimentId, + filters, + format, + limit, + offset, + preview, + sortParams, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "QueryExampleSchemaWithRuns{sessionIds=$sessionIds, comparativeExperimentId=$comparativeExperimentId, filters=$filters, format=$format, limit=$limit, offset=$offset, preview=$preview, sortParams=$sortParams, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/QueryFeedbackDelta.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/QueryFeedbackDelta.kt new file mode 100644 index 00000000..9c8eeb81 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/QueryFeedbackDelta.kt @@ -0,0 +1,544 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.runs + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class QueryFeedbackDelta +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val baselineSessionId: JsonField<String>, + private val comparisonSessionIds: JsonField<List<String>>, + private val feedbackKey: JsonField<String>, + private val comparativeExperimentId: JsonField<String>, + private val filters: JsonField<Filters>, + private val limit: JsonField<Long>, + private val offset: JsonField<Long>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("baseline_session_id") + @ExcludeMissing + baselineSessionId: JsonField<String> = JsonMissing.of(), + @JsonProperty("comparison_session_ids") + @ExcludeMissing + comparisonSessionIds: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("feedback_key") + @ExcludeMissing + feedbackKey: JsonField<String> = JsonMissing.of(), + @JsonProperty("comparative_experiment_id") + @ExcludeMissing + comparativeExperimentId: JsonField<String> = JsonMissing.of(), + @JsonProperty("filters") @ExcludeMissing filters: JsonField<Filters> = JsonMissing.of(), + @JsonProperty("limit") @ExcludeMissing limit: JsonField<Long> = JsonMissing.of(), + @JsonProperty("offset") @ExcludeMissing offset: JsonField<Long> = JsonMissing.of(), + ) : this( + baselineSessionId, + comparisonSessionIds, + feedbackKey, + comparativeExperimentId, + filters, + limit, + offset, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun baselineSessionId(): String = baselineSessionId.getRequired("baseline_session_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun comparisonSessionIds(): List<String> = + comparisonSessionIds.getRequired("comparison_session_ids") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun feedbackKey(): String = feedbackKey.getRequired("feedback_key") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun comparativeExperimentId(): Optional<String> = + comparativeExperimentId.getOptional("comparative_experiment_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun filters(): Optional<Filters> = filters.getOptional("filters") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun limit(): Optional<Long> = limit.getOptional("limit") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun offset(): Optional<Long> = offset.getOptional("offset") + + /** + * Returns the raw JSON value of [baselineSessionId]. + * + * Unlike [baselineSessionId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("baseline_session_id") + @ExcludeMissing + fun _baselineSessionId(): JsonField<String> = baselineSessionId + + /** + * Returns the raw JSON value of [comparisonSessionIds]. + * + * Unlike [comparisonSessionIds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("comparison_session_ids") + @ExcludeMissing + fun _comparisonSessionIds(): JsonField<List<String>> = comparisonSessionIds + + /** + * Returns the raw JSON value of [feedbackKey]. + * + * Unlike [feedbackKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feedback_key") + @ExcludeMissing + fun _feedbackKey(): JsonField<String> = feedbackKey + + /** + * Returns the raw JSON value of [comparativeExperimentId]. + * + * Unlike [comparativeExperimentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("comparative_experiment_id") + @ExcludeMissing + fun _comparativeExperimentId(): JsonField<String> = comparativeExperimentId + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField<Filters> = filters + + /** + * Returns the raw JSON value of [limit]. + * + * Unlike [limit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("limit") @ExcludeMissing fun _limit(): JsonField<Long> = limit + + /** + * Returns the raw JSON value of [offset]. + * + * Unlike [offset], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("offset") @ExcludeMissing fun _offset(): JsonField<Long> = offset + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [QueryFeedbackDelta]. + * + * The following fields are required: + * ```java + * .baselineSessionId() + * .comparisonSessionIds() + * .feedbackKey() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [QueryFeedbackDelta]. */ + class Builder internal constructor() { + + private var baselineSessionId: JsonField<String>? = null + private var comparisonSessionIds: JsonField<MutableList<String>>? = null + private var feedbackKey: JsonField<String>? = null + private var comparativeExperimentId: JsonField<String> = JsonMissing.of() + private var filters: JsonField<Filters> = JsonMissing.of() + private var limit: JsonField<Long> = JsonMissing.of() + private var offset: JsonField<Long> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(queryFeedbackDelta: QueryFeedbackDelta) = apply { + baselineSessionId = queryFeedbackDelta.baselineSessionId + comparisonSessionIds = + queryFeedbackDelta.comparisonSessionIds.map { it.toMutableList() } + feedbackKey = queryFeedbackDelta.feedbackKey + comparativeExperimentId = queryFeedbackDelta.comparativeExperimentId + filters = queryFeedbackDelta.filters + limit = queryFeedbackDelta.limit + offset = queryFeedbackDelta.offset + additionalProperties = queryFeedbackDelta.additionalProperties.toMutableMap() + } + + fun baselineSessionId(baselineSessionId: String) = + baselineSessionId(JsonField.of(baselineSessionId)) + + /** + * Sets [Builder.baselineSessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.baselineSessionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun baselineSessionId(baselineSessionId: JsonField<String>) = apply { + this.baselineSessionId = baselineSessionId + } + + fun comparisonSessionIds(comparisonSessionIds: List<String>) = + comparisonSessionIds(JsonField.of(comparisonSessionIds)) + + /** + * Sets [Builder.comparisonSessionIds] to an arbitrary JSON value. + * + * You should usually call [Builder.comparisonSessionIds] with a well-typed `List<String>` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun comparisonSessionIds(comparisonSessionIds: JsonField<List<String>>) = apply { + this.comparisonSessionIds = comparisonSessionIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [comparisonSessionIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addComparisonSessionId(comparisonSessionId: String) = apply { + comparisonSessionIds = + (comparisonSessionIds ?: JsonField.of(mutableListOf())).also { + checkKnown("comparisonSessionIds", it).add(comparisonSessionId) + } + } + + fun feedbackKey(feedbackKey: String) = feedbackKey(JsonField.of(feedbackKey)) + + /** + * Sets [Builder.feedbackKey] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun feedbackKey(feedbackKey: JsonField<String>) = apply { this.feedbackKey = feedbackKey } + + fun comparativeExperimentId(comparativeExperimentId: String?) = + comparativeExperimentId(JsonField.ofNullable(comparativeExperimentId)) + + /** + * Alias for calling [Builder.comparativeExperimentId] with + * `comparativeExperimentId.orElse(null)`. + */ + fun comparativeExperimentId(comparativeExperimentId: Optional<String>) = + comparativeExperimentId(comparativeExperimentId.getOrNull()) + + /** + * Sets [Builder.comparativeExperimentId] to an arbitrary JSON value. + * + * You should usually call [Builder.comparativeExperimentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun comparativeExperimentId(comparativeExperimentId: JsonField<String>) = apply { + this.comparativeExperimentId = comparativeExperimentId + } + + fun filters(filters: Filters?) = filters(JsonField.ofNullable(filters)) + + /** Alias for calling [Builder.filters] with `filters.orElse(null)`. */ + fun filters(filters: Optional<Filters>) = filters(filters.getOrNull()) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed [Filters] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField<Filters>) = apply { this.filters = filters } + + fun limit(limit: Long) = limit(JsonField.of(limit)) + + /** + * Sets [Builder.limit] to an arbitrary JSON value. + * + * You should usually call [Builder.limit] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun limit(limit: JsonField<Long>) = apply { this.limit = limit } + + fun offset(offset: Long) = offset(JsonField.of(offset)) + + /** + * Sets [Builder.offset] to an arbitrary JSON value. + * + * You should usually call [Builder.offset] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun offset(offset: JsonField<Long>) = apply { this.offset = offset } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [QueryFeedbackDelta]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .baselineSessionId() + * .comparisonSessionIds() + * .feedbackKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): QueryFeedbackDelta = + QueryFeedbackDelta( + checkRequired("baselineSessionId", baselineSessionId), + checkRequired("comparisonSessionIds", comparisonSessionIds).map { + it.toImmutable() + }, + checkRequired("feedbackKey", feedbackKey), + comparativeExperimentId, + filters, + limit, + offset, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): QueryFeedbackDelta = apply { + if (validated) { + return@apply + } + + baselineSessionId() + comparisonSessionIds() + feedbackKey() + comparativeExperimentId() + filters().ifPresent { it.validate() } + limit() + offset() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (baselineSessionId.asKnown().isPresent) 1 else 0) + + (comparisonSessionIds.asKnown().getOrNull()?.size ?: 0) + + (if (feedbackKey.asKnown().isPresent) 1 else 0) + + (if (comparativeExperimentId.asKnown().isPresent) 1 else 0) + + (filters.asKnown().getOrNull()?.validity() ?: 0) + + (if (limit.asKnown().isPresent) 1 else 0) + + (if (offset.asKnown().isPresent) 1 else 0) + + class Filters + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Filters]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Filters]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(filters: Filters) = apply { + additionalProperties = filters.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Filters = Filters(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Filters = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filters && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Filters{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is QueryFeedbackDelta && + baselineSessionId == other.baselineSessionId && + comparisonSessionIds == other.comparisonSessionIds && + feedbackKey == other.feedbackKey && + comparativeExperimentId == other.comparativeExperimentId && + filters == other.filters && + limit == other.limit && + offset == other.offset && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + baselineSessionId, + comparisonSessionIds, + feedbackKey, + comparativeExperimentId, + filters, + limit, + offset, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "QueryFeedbackDelta{baselineSessionId=$baselineSessionId, comparisonSessionIds=$comparisonSessionIds, feedbackKey=$feedbackKey, comparativeExperimentId=$comparativeExperimentId, filters=$filters, limit=$limit, offset=$offset, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/RunCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/RunCreateParams.kt new file mode 100644 index 00000000..c6681eb2 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/RunCreateParams.kt @@ -0,0 +1,254 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.runs + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Fetch examples for a dataset, and fetch the runs for each example if they are associated with the + * given session_ids. + */ +class RunCreateParams +private constructor( + private val datasetId: String?, + private val queryFormat: String?, + private val queryExampleSchemaWithRuns: QueryExampleSchemaWithRuns, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun datasetId(): Optional<String> = Optional.ofNullable(datasetId) + + /** Response format, e.g., 'csv' */ + fun queryFormat(): Optional<String> = Optional.ofNullable(queryFormat) + + fun queryExampleSchemaWithRuns(): QueryExampleSchemaWithRuns = queryExampleSchemaWithRuns + + fun _additionalBodyProperties(): Map<String, JsonValue> = + queryExampleSchemaWithRuns._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RunCreateParams]. + * + * The following fields are required: + * ```java + * .queryExampleSchemaWithRuns() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunCreateParams]. */ + class Builder internal constructor() { + + private var datasetId: String? = null + private var queryFormat: String? = null + private var queryExampleSchemaWithRuns: QueryExampleSchemaWithRuns? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(runCreateParams: RunCreateParams) = apply { + datasetId = runCreateParams.datasetId + queryFormat = runCreateParams.queryFormat + queryExampleSchemaWithRuns = runCreateParams.queryExampleSchemaWithRuns + additionalHeaders = runCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = runCreateParams.additionalQueryParams.toBuilder() + } + + fun datasetId(datasetId: String?) = apply { this.datasetId = datasetId } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + /** Response format, e.g., 'csv' */ + fun queryFormat(queryFormat: String?) = apply { this.queryFormat = queryFormat } + + /** Alias for calling [Builder.queryFormat] with `queryFormat.orElse(null)`. */ + fun queryFormat(queryFormat: Optional<String>) = queryFormat(queryFormat.getOrNull()) + + fun queryExampleSchemaWithRuns(queryExampleSchemaWithRuns: QueryExampleSchemaWithRuns) = + apply { + this.queryExampleSchemaWithRuns = queryExampleSchemaWithRuns + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RunCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .queryExampleSchemaWithRuns() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RunCreateParams = + RunCreateParams( + datasetId, + queryFormat, + checkRequired("queryExampleSchemaWithRuns", queryExampleSchemaWithRuns), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): QueryExampleSchemaWithRuns = queryExampleSchemaWithRuns + + fun _pathParam(index: Int): String = + when (index) { + 0 -> datasetId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + queryFormat?.let { put("format", it) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunCreateParams && + datasetId == other.datasetId && + queryFormat == other.queryFormat && + queryExampleSchemaWithRuns == other.queryExampleSchemaWithRuns && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + datasetId, + queryFormat, + queryExampleSchemaWithRuns, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "RunCreateParams{datasetId=$datasetId, queryFormat=$queryFormat, queryExampleSchemaWithRuns=$queryExampleSchemaWithRuns, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/RunCreateResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/RunCreateResponse.kt new file mode 100644 index 00000000..a0e2682b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/RunCreateResponse.kt @@ -0,0 +1,207 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.runs + +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 com.langsmith_api.api.core.BaseDeserializer +import com.langsmith_api.api.core.BaseSerializer +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.allMaxBy +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Objects +import java.util.Optional + +@JsonDeserialize(using = RunCreateResponse.Deserializer::class) +@JsonSerialize(using = RunCreateResponse.Serializer::class) +class RunCreateResponse +private constructor( + private val exampleWithRuns: List<ExampleWithRuns>? = null, + private val exampleWithRunsChes: List<ExampleWithRunsCh>? = null, + private val _json: JsonValue? = null, +) { + + fun exampleWithRuns(): Optional<List<ExampleWithRuns>> = Optional.ofNullable(exampleWithRuns) + + fun exampleWithRunsChes(): Optional<List<ExampleWithRunsCh>> = + Optional.ofNullable(exampleWithRunsChes) + + fun isExampleWithRuns(): Boolean = exampleWithRuns != null + + fun isExampleWithRunsChes(): Boolean = exampleWithRunsChes != null + + fun asExampleWithRuns(): List<ExampleWithRuns> = exampleWithRuns.getOrThrow("exampleWithRuns") + + fun asExampleWithRunsChes(): List<ExampleWithRunsCh> = + exampleWithRunsChes.getOrThrow("exampleWithRunsChes") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + exampleWithRuns != null -> visitor.visitExampleWithRuns(exampleWithRuns) + exampleWithRunsChes != null -> visitor.visitExampleWithRunsChes(exampleWithRunsChes) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): RunCreateResponse = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitExampleWithRuns(exampleWithRuns: List<ExampleWithRuns>) { + exampleWithRuns.forEach { it.validate() } + } + + override fun visitExampleWithRunsChes( + exampleWithRunsChes: List<ExampleWithRunsCh> + ) { + exampleWithRunsChes.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitExampleWithRuns(exampleWithRuns: List<ExampleWithRuns>) = + exampleWithRuns.sumOf { it.validity().toInt() } + + override fun visitExampleWithRunsChes( + exampleWithRunsChes: List<ExampleWithRunsCh> + ) = exampleWithRunsChes.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunCreateResponse && + exampleWithRuns == other.exampleWithRuns && + exampleWithRunsChes == other.exampleWithRunsChes + } + + override fun hashCode(): Int = Objects.hash(exampleWithRuns, exampleWithRunsChes) + + override fun toString(): String = + when { + exampleWithRuns != null -> "RunCreateResponse{exampleWithRuns=$exampleWithRuns}" + exampleWithRunsChes != null -> + "RunCreateResponse{exampleWithRunsChes=$exampleWithRunsChes}" + _json != null -> "RunCreateResponse{_unknown=$_json}" + else -> throw IllegalStateException("Invalid RunCreateResponse") + } + + companion object { + + @JvmStatic + fun ofExampleWithRuns(exampleWithRuns: List<ExampleWithRuns>) = + RunCreateResponse(exampleWithRuns = exampleWithRuns.toImmutable()) + + @JvmStatic + fun ofExampleWithRunsChes(exampleWithRunsChes: List<ExampleWithRunsCh>) = + RunCreateResponse(exampleWithRunsChes = exampleWithRunsChes.toImmutable()) + } + + /** + * An interface that defines how to map each variant of [RunCreateResponse] to a value of type + * [T]. + */ + interface Visitor<out T> { + + fun visitExampleWithRuns(exampleWithRuns: List<ExampleWithRuns>): T + + fun visitExampleWithRunsChes(exampleWithRunsChes: List<ExampleWithRunsCh>): T + + /** + * Maps an unknown variant of [RunCreateResponse] to a value of type [T]. + * + * An instance of [RunCreateResponse] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is unaware + * of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown RunCreateResponse: $json") + } + } + + internal class Deserializer : BaseDeserializer<RunCreateResponse>(RunCreateResponse::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): RunCreateResponse { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<List<ExampleWithRuns>>())?.let { + RunCreateResponse(exampleWithRuns = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<List<ExampleWithRunsCh>>())?.let { + RunCreateResponse(exampleWithRunsChes = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with all + // the possible variants (e.g. deserializing from boolean). + 0 -> RunCreateResponse(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<RunCreateResponse>(RunCreateResponse::class) { + + override fun serialize( + value: RunCreateResponse, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.exampleWithRuns != null -> generator.writeObject(value.exampleWithRuns) + value.exampleWithRunsChes != null -> + generator.writeObject(value.exampleWithRunsChes) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid RunCreateResponse") + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/RunDeltaParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/RunDeltaParams.kt new file mode 100644 index 00000000..d78e5deb --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/RunDeltaParams.kt @@ -0,0 +1,227 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.runs + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Fetch the number of regressions/improvements for each example in a dataset, between sessions[0] + * and sessions[1]. + */ +class RunDeltaParams +private constructor( + private val datasetId: String?, + private val queryFeedbackDelta: QueryFeedbackDelta, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun datasetId(): Optional<String> = Optional.ofNullable(datasetId) + + fun queryFeedbackDelta(): QueryFeedbackDelta = queryFeedbackDelta + + fun _additionalBodyProperties(): Map<String, JsonValue> = + queryFeedbackDelta._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RunDeltaParams]. + * + * The following fields are required: + * ```java + * .queryFeedbackDelta() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunDeltaParams]. */ + class Builder internal constructor() { + + private var datasetId: String? = null + private var queryFeedbackDelta: QueryFeedbackDelta? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(runDeltaParams: RunDeltaParams) = apply { + datasetId = runDeltaParams.datasetId + queryFeedbackDelta = runDeltaParams.queryFeedbackDelta + additionalHeaders = runDeltaParams.additionalHeaders.toBuilder() + additionalQueryParams = runDeltaParams.additionalQueryParams.toBuilder() + } + + fun datasetId(datasetId: String?) = apply { this.datasetId = datasetId } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + fun queryFeedbackDelta(queryFeedbackDelta: QueryFeedbackDelta) = apply { + this.queryFeedbackDelta = queryFeedbackDelta + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RunDeltaParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .queryFeedbackDelta() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RunDeltaParams = + RunDeltaParams( + datasetId, + checkRequired("queryFeedbackDelta", queryFeedbackDelta), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): QueryFeedbackDelta = queryFeedbackDelta + + fun _pathParam(index: Int): String = + when (index) { + 0 -> datasetId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunDeltaParams && + datasetId == other.datasetId && + queryFeedbackDelta == other.queryFeedbackDelta && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(datasetId, queryFeedbackDelta, additionalHeaders, additionalQueryParams) + + override fun toString() = + "RunDeltaParams{datasetId=$datasetId, queryFeedbackDelta=$queryFeedbackDelta, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/SessionFeedbackDelta.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/SessionFeedbackDelta.kt new file mode 100644 index 00000000..ef77e340 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/SessionFeedbackDelta.kt @@ -0,0 +1,281 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.runs + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** List of feedback keys with number of improvements and regressions for each. */ +class SessionFeedbackDelta +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val feedbackDeltas: JsonField<FeedbackDeltas>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("feedback_deltas") + @ExcludeMissing + feedbackDeltas: JsonField<FeedbackDeltas> = JsonMissing.of() + ) : this(feedbackDeltas, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun feedbackDeltas(): FeedbackDeltas = feedbackDeltas.getRequired("feedback_deltas") + + /** + * Returns the raw JSON value of [feedbackDeltas]. + * + * Unlike [feedbackDeltas], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feedback_deltas") + @ExcludeMissing + fun _feedbackDeltas(): JsonField<FeedbackDeltas> = feedbackDeltas + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SessionFeedbackDelta]. + * + * The following fields are required: + * ```java + * .feedbackDeltas() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SessionFeedbackDelta]. */ + class Builder internal constructor() { + + private var feedbackDeltas: JsonField<FeedbackDeltas>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(sessionFeedbackDelta: SessionFeedbackDelta) = apply { + feedbackDeltas = sessionFeedbackDelta.feedbackDeltas + additionalProperties = sessionFeedbackDelta.additionalProperties.toMutableMap() + } + + fun feedbackDeltas(feedbackDeltas: FeedbackDeltas) = + feedbackDeltas(JsonField.of(feedbackDeltas)) + + /** + * Sets [Builder.feedbackDeltas] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackDeltas] with a well-typed [FeedbackDeltas] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun feedbackDeltas(feedbackDeltas: JsonField<FeedbackDeltas>) = apply { + this.feedbackDeltas = feedbackDeltas + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SessionFeedbackDelta]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .feedbackDeltas() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SessionFeedbackDelta = + SessionFeedbackDelta( + checkRequired("feedbackDeltas", feedbackDeltas), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SessionFeedbackDelta = apply { + if (validated) { + return@apply + } + + feedbackDeltas().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (feedbackDeltas.asKnown().getOrNull()?.validity() ?: 0) + + class FeedbackDeltas + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [FeedbackDeltas]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackDeltas]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(feedbackDeltas: FeedbackDeltas) = apply { + additionalProperties = feedbackDeltas.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FeedbackDeltas]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FeedbackDeltas = FeedbackDeltas(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): FeedbackDeltas = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackDeltas && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "FeedbackDeltas{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SessionFeedbackDelta && + feedbackDeltas == other.feedbackDeltas && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(feedbackDeltas, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SessionFeedbackDelta{feedbackDeltas=$feedbackDeltas, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/DatasetShareSchema.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/DatasetShareSchema.kt new file mode 100644 index 00000000..cd987abc --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/DatasetShareSchema.kt @@ -0,0 +1,209 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.share + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class DatasetShareSchema +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val datasetId: JsonField<String>, + private val shareToken: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("dataset_id") @ExcludeMissing datasetId: JsonField<String> = JsonMissing.of(), + @JsonProperty("share_token") + @ExcludeMissing + shareToken: JsonField<String> = JsonMissing.of(), + ) : this(datasetId, shareToken, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun datasetId(): String = datasetId.getRequired("dataset_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun shareToken(): String = shareToken.getRequired("share_token") + + /** + * Returns the raw JSON value of [datasetId]. + * + * Unlike [datasetId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField<String> = datasetId + + /** + * Returns the raw JSON value of [shareToken]. + * + * Unlike [shareToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("share_token") @ExcludeMissing fun _shareToken(): JsonField<String> = shareToken + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DatasetShareSchema]. + * + * The following fields are required: + * ```java + * .datasetId() + * .shareToken() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DatasetShareSchema]. */ + class Builder internal constructor() { + + private var datasetId: JsonField<String>? = null + private var shareToken: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(datasetShareSchema: DatasetShareSchema) = apply { + datasetId = datasetShareSchema.datasetId + shareToken = datasetShareSchema.shareToken + additionalProperties = datasetShareSchema.additionalProperties.toMutableMap() + } + + fun datasetId(datasetId: String) = datasetId(JsonField.of(datasetId)) + + /** + * Sets [Builder.datasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun datasetId(datasetId: JsonField<String>) = apply { this.datasetId = datasetId } + + fun shareToken(shareToken: String) = shareToken(JsonField.of(shareToken)) + + /** + * Sets [Builder.shareToken] to an arbitrary JSON value. + * + * You should usually call [Builder.shareToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun shareToken(shareToken: JsonField<String>) = apply { this.shareToken = shareToken } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DatasetShareSchema]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .datasetId() + * .shareToken() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DatasetShareSchema = + DatasetShareSchema( + checkRequired("datasetId", datasetId), + checkRequired("shareToken", shareToken), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DatasetShareSchema = apply { + if (validated) { + return@apply + } + + datasetId() + shareToken() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (datasetId.asKnown().isPresent) 1 else 0) + + (if (shareToken.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetShareSchema && + datasetId == other.datasetId && + shareToken == other.shareToken && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(datasetId, shareToken, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DatasetShareSchema{datasetId=$datasetId, shareToken=$shareToken, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/ShareCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/ShareCreateParams.kt new file mode 100644 index 00000000..93e82852 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/ShareCreateParams.kt @@ -0,0 +1,261 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.share + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Share a dataset. */ +class ShareCreateParams +private constructor( + private val datasetId: String?, + private val shareProjects: Boolean?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun datasetId(): Optional<String> = Optional.ofNullable(datasetId) + + fun shareProjects(): Optional<Boolean> = Optional.ofNullable(shareProjects) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ShareCreateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ShareCreateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ShareCreateParams]. */ + class Builder internal constructor() { + + private var datasetId: String? = null + private var shareProjects: Boolean? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(shareCreateParams: ShareCreateParams) = apply { + datasetId = shareCreateParams.datasetId + shareProjects = shareCreateParams.shareProjects + additionalHeaders = shareCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = shareCreateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = shareCreateParams.additionalBodyProperties.toMutableMap() + } + + fun datasetId(datasetId: String?) = apply { this.datasetId = datasetId } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + fun shareProjects(shareProjects: Boolean?) = apply { this.shareProjects = shareProjects } + + /** + * Alias for [Builder.shareProjects]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun shareProjects(shareProjects: Boolean) = shareProjects(shareProjects as Boolean?) + + /** Alias for calling [Builder.shareProjects] with `shareProjects.orElse(null)`. */ + fun shareProjects(shareProjects: Optional<Boolean>) = + shareProjects(shareProjects.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [ShareCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ShareCreateParams = + ShareCreateParams( + datasetId, + shareProjects, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> datasetId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + shareProjects?.let { put("share_projects", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ShareCreateParams && + datasetId == other.datasetId && + shareProjects == other.shareProjects && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + datasetId, + shareProjects, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "ShareCreateParams{datasetId=$datasetId, shareProjects=$shareProjects, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/ShareDeleteAllParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/ShareDeleteAllParams.kt new file mode 100644 index 00000000..872299df --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/ShareDeleteAllParams.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.share + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Unshare a dataset. */ +class ShareDeleteAllParams +private constructor( + private val datasetId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun datasetId(): Optional<String> = Optional.ofNullable(datasetId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ShareDeleteAllParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ShareDeleteAllParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ShareDeleteAllParams]. */ + class Builder internal constructor() { + + private var datasetId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(shareDeleteAllParams: ShareDeleteAllParams) = apply { + datasetId = shareDeleteAllParams.datasetId + additionalHeaders = shareDeleteAllParams.additionalHeaders.toBuilder() + additionalQueryParams = shareDeleteAllParams.additionalQueryParams.toBuilder() + additionalBodyProperties = shareDeleteAllParams.additionalBodyProperties.toMutableMap() + } + + fun datasetId(datasetId: String?) = apply { this.datasetId = datasetId } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [ShareDeleteAllParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ShareDeleteAllParams = + ShareDeleteAllParams( + datasetId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> datasetId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ShareDeleteAllParams && + datasetId == other.datasetId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(datasetId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "ShareDeleteAllParams{datasetId=$datasetId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/ShareDeleteAllResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/ShareDeleteAllResponse.kt new file mode 100644 index 00000000..0ae22b65 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/ShareDeleteAllResponse.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.share + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class ShareDeleteAllResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ShareDeleteAllResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ShareDeleteAllResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(shareDeleteAllResponse: ShareDeleteAllResponse) = apply { + additionalProperties = shareDeleteAllResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ShareDeleteAllResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ShareDeleteAllResponse = + ShareDeleteAllResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): ShareDeleteAllResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ShareDeleteAllResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "ShareDeleteAllResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/ShareListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/ShareListParams.kt new file mode 100644 index 00000000..ba0004f0 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/ShareListParams.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.share + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get the state of sharing a dataset */ +class ShareListParams +private constructor( + private val datasetId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun datasetId(): Optional<String> = Optional.ofNullable(datasetId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ShareListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ShareListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ShareListParams]. */ + class Builder internal constructor() { + + private var datasetId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(shareListParams: ShareListParams) = apply { + datasetId = shareListParams.datasetId + additionalHeaders = shareListParams.additionalHeaders.toBuilder() + additionalQueryParams = shareListParams.additionalQueryParams.toBuilder() + } + + fun datasetId(datasetId: String?) = apply { this.datasetId = datasetId } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ShareListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ShareListParams = + ShareListParams(datasetId, additionalHeaders.build(), additionalQueryParams.build()) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> datasetId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ShareListParams && + datasetId == other.datasetId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(datasetId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ShareListParams{datasetId=$datasetId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/splits/SplitCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/splits/SplitCreateParams.kt new file mode 100644 index 00000000..e7ada75e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/splits/SplitCreateParams.kt @@ -0,0 +1,584 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.splits + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Update Dataset Splits */ +class SplitCreateParams +private constructor( + private val datasetId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun datasetId(): Optional<String> = Optional.ofNullable(datasetId) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun examples(): List<String> = body.examples() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun splitName(): String = body.splitName() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun remove(): Optional<Boolean> = body.remove() + + /** + * Returns the raw JSON value of [examples]. + * + * Unlike [examples], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _examples(): JsonField<List<String>> = body._examples() + + /** + * Returns the raw JSON value of [splitName]. + * + * Unlike [splitName], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _splitName(): JsonField<String> = body._splitName() + + /** + * Returns the raw JSON value of [remove]. + * + * Unlike [remove], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _remove(): JsonField<Boolean> = body._remove() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SplitCreateParams]. + * + * The following fields are required: + * ```java + * .examples() + * .splitName() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SplitCreateParams]. */ + class Builder internal constructor() { + + private var datasetId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(splitCreateParams: SplitCreateParams) = apply { + datasetId = splitCreateParams.datasetId + body = splitCreateParams.body.toBuilder() + additionalHeaders = splitCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = splitCreateParams.additionalQueryParams.toBuilder() + } + + fun datasetId(datasetId: String?) = apply { this.datasetId = datasetId } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [examples] + * - [splitName] + * - [remove] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun examples(examples: List<String>) = apply { body.examples(examples) } + + /** + * Sets [Builder.examples] to an arbitrary JSON value. + * + * You should usually call [Builder.examples] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun examples(examples: JsonField<List<String>>) = apply { body.examples(examples) } + + /** + * Adds a single [String] to [examples]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExample(example: String) = apply { body.addExample(example) } + + fun splitName(splitName: String) = apply { body.splitName(splitName) } + + /** + * Sets [Builder.splitName] to an arbitrary JSON value. + * + * You should usually call [Builder.splitName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun splitName(splitName: JsonField<String>) = apply { body.splitName(splitName) } + + fun remove(remove: Boolean) = apply { body.remove(remove) } + + /** + * Sets [Builder.remove] to an arbitrary JSON value. + * + * You should usually call [Builder.remove] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun remove(remove: JsonField<Boolean>) = apply { body.remove(remove) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SplitCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .examples() + * .splitName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SplitCreateParams = + SplitCreateParams( + datasetId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> datasetId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val examples: JsonField<List<String>>, + private val splitName: JsonField<String>, + private val remove: JsonField<Boolean>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("examples") + @ExcludeMissing + examples: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("split_name") + @ExcludeMissing + splitName: JsonField<String> = JsonMissing.of(), + @JsonProperty("remove") @ExcludeMissing remove: JsonField<Boolean> = JsonMissing.of(), + ) : this(examples, splitName, remove, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun examples(): List<String> = examples.getRequired("examples") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun splitName(): String = splitName.getRequired("split_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun remove(): Optional<Boolean> = remove.getOptional("remove") + + /** + * Returns the raw JSON value of [examples]. + * + * Unlike [examples], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("examples") + @ExcludeMissing + fun _examples(): JsonField<List<String>> = examples + + /** + * Returns the raw JSON value of [splitName]. + * + * Unlike [splitName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("split_name") @ExcludeMissing fun _splitName(): JsonField<String> = splitName + + /** + * Returns the raw JSON value of [remove]. + * + * Unlike [remove], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("remove") @ExcludeMissing fun _remove(): JsonField<Boolean> = remove + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .examples() + * .splitName() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var examples: JsonField<MutableList<String>>? = null + private var splitName: JsonField<String>? = null + private var remove: JsonField<Boolean> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + examples = body.examples.map { it.toMutableList() } + splitName = body.splitName + remove = body.remove + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun examples(examples: List<String>) = examples(JsonField.of(examples)) + + /** + * Sets [Builder.examples] to an arbitrary JSON value. + * + * You should usually call [Builder.examples] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun examples(examples: JsonField<List<String>>) = apply { + this.examples = examples.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [examples]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExample(example: String) = apply { + examples = + (examples ?: JsonField.of(mutableListOf())).also { + checkKnown("examples", it).add(example) + } + } + + fun splitName(splitName: String) = splitName(JsonField.of(splitName)) + + /** + * Sets [Builder.splitName] to an arbitrary JSON value. + * + * You should usually call [Builder.splitName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun splitName(splitName: JsonField<String>) = apply { this.splitName = splitName } + + fun remove(remove: Boolean) = remove(JsonField.of(remove)) + + /** + * Sets [Builder.remove] to an arbitrary JSON value. + * + * You should usually call [Builder.remove] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun remove(remove: JsonField<Boolean>) = apply { this.remove = remove } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .examples() + * .splitName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("examples", examples).map { it.toImmutable() }, + checkRequired("splitName", splitName), + remove, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + examples() + splitName() + remove() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (examples.asKnown().getOrNull()?.size ?: 0) + + (if (splitName.asKnown().isPresent) 1 else 0) + + (if (remove.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + examples == other.examples && + splitName == other.splitName && + remove == other.remove && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(examples, splitName, remove, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{examples=$examples, splitName=$splitName, remove=$remove, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SplitCreateParams && + datasetId == other.datasetId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(datasetId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "SplitCreateParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/splits/SplitListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/splits/SplitListParams.kt new file mode 100644 index 00000000..c138a221 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/splits/SplitListParams.kt @@ -0,0 +1,306 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.splits + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get Dataset Splits */ +class SplitListParams +private constructor( + private val datasetId: String?, + private val asOf: AsOf?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun datasetId(): Optional<String> = Optional.ofNullable(datasetId) + + /** + * Only modifications made on or before this time are included. If None, the latest version of + * the dataset is used. + */ + fun asOf(): Optional<AsOf> = Optional.ofNullable(asOf) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): SplitListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [SplitListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SplitListParams]. */ + class Builder internal constructor() { + + private var datasetId: String? = null + private var asOf: AsOf? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(splitListParams: SplitListParams) = apply { + datasetId = splitListParams.datasetId + asOf = splitListParams.asOf + additionalHeaders = splitListParams.additionalHeaders.toBuilder() + additionalQueryParams = splitListParams.additionalQueryParams.toBuilder() + } + + fun datasetId(datasetId: String?) = apply { this.datasetId = datasetId } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + /** + * Only modifications made on or before this time are included. If None, the latest version + * of the dataset is used. + */ + fun asOf(asOf: AsOf?) = apply { this.asOf = asOf } + + /** Alias for calling [Builder.asOf] with `asOf.orElse(null)`. */ + fun asOf(asOf: Optional<AsOf>) = asOf(asOf.getOrNull()) + + /** Alias for calling [asOf] with `AsOf.ofOffsetDateTime(offsetDateTime)`. */ + fun asOf(offsetDateTime: OffsetDateTime) = asOf(AsOf.ofOffsetDateTime(offsetDateTime)) + + /** Alias for calling [asOf] with `AsOf.ofString(string)`. */ + fun asOf(string: String) = asOf(AsOf.ofString(string)) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SplitListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SplitListParams = + SplitListParams( + datasetId, + asOf, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> datasetId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + asOf?.accept( + object : AsOf.Visitor<Unit> { + override fun visitOffsetDateTime(offsetDateTime: OffsetDateTime) { + put( + "as_of", + DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(offsetDateTime), + ) + } + + override fun visitString(string: String) { + put("as_of", string) + } + } + ) + putAll(additionalQueryParams) + } + .build() + + /** + * Only modifications made on or before this time are included. If None, the latest version of + * the dataset is used. + */ + class AsOf + private constructor( + private val offsetDateTime: OffsetDateTime? = null, + private val string: String? = null, + ) { + + fun offsetDateTime(): Optional<OffsetDateTime> = Optional.ofNullable(offsetDateTime) + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun isOffsetDateTime(): Boolean = offsetDateTime != null + + fun isString(): Boolean = string != null + + fun asOffsetDateTime(): OffsetDateTime = offsetDateTime.getOrThrow("offsetDateTime") + + fun asString(): String = string.getOrThrow("string") + + fun <T> accept(visitor: Visitor<T>): T = + when { + offsetDateTime != null -> visitor.visitOffsetDateTime(offsetDateTime) + string != null -> visitor.visitString(string) + else -> throw IllegalStateException("Invalid AsOf") + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AsOf && offsetDateTime == other.offsetDateTime && string == other.string + } + + override fun hashCode(): Int = Objects.hash(offsetDateTime, string) + + override fun toString(): String = + when { + offsetDateTime != null -> "AsOf{offsetDateTime=$offsetDateTime}" + string != null -> "AsOf{string=$string}" + else -> throw IllegalStateException("Invalid AsOf") + } + + companion object { + + @JvmStatic + fun ofOffsetDateTime(offsetDateTime: OffsetDateTime) = + AsOf(offsetDateTime = offsetDateTime) + + @JvmStatic fun ofString(string: String) = AsOf(string = string) + } + + /** An interface that defines how to map each variant of [AsOf] to a value of type [T]. */ + interface Visitor<out T> { + + fun visitOffsetDateTime(offsetDateTime: OffsetDateTime): T + + fun visitString(string: String): T + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SplitListParams && + datasetId == other.datasetId && + asOf == other.asOf && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(datasetId, asOf, additionalHeaders, additionalQueryParams) + + override fun toString() = + "SplitListParams{datasetId=$datasetId, asOf=$asOf, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/versions/VersionListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/versions/VersionListParams.kt new file mode 100644 index 00000000..c7e3042e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/versions/VersionListParams.kt @@ -0,0 +1,273 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.versions + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get dataset versions. */ +class VersionListParams +private constructor( + private val datasetId: String?, + private val example: String?, + private val limit: Long?, + private val offset: Long?, + private val search: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun datasetId(): Optional<String> = Optional.ofNullable(datasetId) + + fun example(): Optional<String> = Optional.ofNullable(example) + + fun limit(): Optional<Long> = Optional.ofNullable(limit) + + fun offset(): Optional<Long> = Optional.ofNullable(offset) + + fun search(): Optional<String> = Optional.ofNullable(search) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): VersionListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [VersionListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VersionListParams]. */ + class Builder internal constructor() { + + private var datasetId: String? = null + private var example: String? = null + private var limit: Long? = null + private var offset: Long? = null + private var search: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(versionListParams: VersionListParams) = apply { + datasetId = versionListParams.datasetId + example = versionListParams.example + limit = versionListParams.limit + offset = versionListParams.offset + search = versionListParams.search + additionalHeaders = versionListParams.additionalHeaders.toBuilder() + additionalQueryParams = versionListParams.additionalQueryParams.toBuilder() + } + + fun datasetId(datasetId: String?) = apply { this.datasetId = datasetId } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + fun example(example: String?) = apply { this.example = example } + + /** Alias for calling [Builder.example] with `example.orElse(null)`. */ + fun example(example: Optional<String>) = example(example.getOrNull()) + + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional<Long>) = limit(limit.getOrNull()) + + fun offset(offset: Long?) = apply { this.offset = offset } + + /** + * Alias for [Builder.offset]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun offset(offset: Long) = offset(offset as Long?) + + /** Alias for calling [Builder.offset] with `offset.orElse(null)`. */ + fun offset(offset: Optional<Long>) = offset(offset.getOrNull()) + + fun search(search: String?) = apply { this.search = search } + + /** Alias for calling [Builder.search] with `search.orElse(null)`. */ + fun search(search: Optional<String>) = search(search.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [VersionListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VersionListParams = + VersionListParams( + datasetId, + example, + limit, + offset, + search, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> datasetId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + example?.let { put("example", it) } + limit?.let { put("limit", it.toString()) } + offset?.let { put("offset", it.toString()) } + search?.let { put("search", it) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VersionListParams && + datasetId == other.datasetId && + example == other.example && + limit == other.limit && + offset == other.offset && + search == other.search && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + datasetId, + example, + limit, + offset, + search, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "VersionListParams{datasetId=$datasetId, example=$example, limit=$limit, offset=$offset, search=$search, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/versions/VersionRetrieveDiffParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/versions/VersionRetrieveDiffParams.kt new file mode 100644 index 00000000..71935fe8 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/versions/VersionRetrieveDiffParams.kt @@ -0,0 +1,406 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.versions + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get diff between two dataset versions. */ +class VersionRetrieveDiffParams +private constructor( + private val datasetId: String?, + private val fromVersion: FromVersion, + private val toVersion: ToVersion, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun datasetId(): Optional<String> = Optional.ofNullable(datasetId) + + fun fromVersion(): FromVersion = fromVersion + + fun toVersion(): ToVersion = toVersion + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [VersionRetrieveDiffParams]. + * + * The following fields are required: + * ```java + * .fromVersion() + * .toVersion() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VersionRetrieveDiffParams]. */ + class Builder internal constructor() { + + private var datasetId: String? = null + private var fromVersion: FromVersion? = null + private var toVersion: ToVersion? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(versionRetrieveDiffParams: VersionRetrieveDiffParams) = apply { + datasetId = versionRetrieveDiffParams.datasetId + fromVersion = versionRetrieveDiffParams.fromVersion + toVersion = versionRetrieveDiffParams.toVersion + additionalHeaders = versionRetrieveDiffParams.additionalHeaders.toBuilder() + additionalQueryParams = versionRetrieveDiffParams.additionalQueryParams.toBuilder() + } + + fun datasetId(datasetId: String?) = apply { this.datasetId = datasetId } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + fun fromVersion(fromVersion: FromVersion) = apply { this.fromVersion = fromVersion } + + /** Alias for calling [fromVersion] with `FromVersion.ofOffsetDateTime(offsetDateTime)`. */ + fun fromVersion(offsetDateTime: OffsetDateTime) = + fromVersion(FromVersion.ofOffsetDateTime(offsetDateTime)) + + /** Alias for calling [fromVersion] with `FromVersion.ofString(string)`. */ + fun fromVersion(string: String) = fromVersion(FromVersion.ofString(string)) + + fun toVersion(toVersion: ToVersion) = apply { this.toVersion = toVersion } + + /** Alias for calling [toVersion] with `ToVersion.ofOffsetDateTime(offsetDateTime)`. */ + fun toVersion(offsetDateTime: OffsetDateTime) = + toVersion(ToVersion.ofOffsetDateTime(offsetDateTime)) + + /** Alias for calling [toVersion] with `ToVersion.ofString(string)`. */ + fun toVersion(string: String) = toVersion(ToVersion.ofString(string)) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [VersionRetrieveDiffParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .fromVersion() + * .toVersion() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): VersionRetrieveDiffParams = + VersionRetrieveDiffParams( + datasetId, + checkRequired("fromVersion", fromVersion), + checkRequired("toVersion", toVersion), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> datasetId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + fromVersion.accept( + object : FromVersion.Visitor<Unit> { + override fun visitOffsetDateTime(offsetDateTime: OffsetDateTime) { + put( + "from_version", + DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(offsetDateTime), + ) + } + + override fun visitString(string: String) { + put("from_version", string) + } + } + ) + toVersion.accept( + object : ToVersion.Visitor<Unit> { + override fun visitOffsetDateTime(offsetDateTime: OffsetDateTime) { + put( + "to_version", + DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(offsetDateTime), + ) + } + + override fun visitString(string: String) { + put("to_version", string) + } + } + ) + putAll(additionalQueryParams) + } + .build() + + class FromVersion + private constructor( + private val offsetDateTime: OffsetDateTime? = null, + private val string: String? = null, + ) { + + fun offsetDateTime(): Optional<OffsetDateTime> = Optional.ofNullable(offsetDateTime) + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun isOffsetDateTime(): Boolean = offsetDateTime != null + + fun isString(): Boolean = string != null + + fun asOffsetDateTime(): OffsetDateTime = offsetDateTime.getOrThrow("offsetDateTime") + + fun asString(): String = string.getOrThrow("string") + + fun <T> accept(visitor: Visitor<T>): T = + when { + offsetDateTime != null -> visitor.visitOffsetDateTime(offsetDateTime) + string != null -> visitor.visitString(string) + else -> throw IllegalStateException("Invalid FromVersion") + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FromVersion && + offsetDateTime == other.offsetDateTime && + string == other.string + } + + override fun hashCode(): Int = Objects.hash(offsetDateTime, string) + + override fun toString(): String = + when { + offsetDateTime != null -> "FromVersion{offsetDateTime=$offsetDateTime}" + string != null -> "FromVersion{string=$string}" + else -> throw IllegalStateException("Invalid FromVersion") + } + + companion object { + + @JvmStatic + fun ofOffsetDateTime(offsetDateTime: OffsetDateTime) = + FromVersion(offsetDateTime = offsetDateTime) + + @JvmStatic fun ofString(string: String) = FromVersion(string = string) + } + + /** + * An interface that defines how to map each variant of [FromVersion] to a value of type + * [T]. + */ + interface Visitor<out T> { + + fun visitOffsetDateTime(offsetDateTime: OffsetDateTime): T + + fun visitString(string: String): T + } + } + + class ToVersion + private constructor( + private val offsetDateTime: OffsetDateTime? = null, + private val string: String? = null, + ) { + + fun offsetDateTime(): Optional<OffsetDateTime> = Optional.ofNullable(offsetDateTime) + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun isOffsetDateTime(): Boolean = offsetDateTime != null + + fun isString(): Boolean = string != null + + fun asOffsetDateTime(): OffsetDateTime = offsetDateTime.getOrThrow("offsetDateTime") + + fun asString(): String = string.getOrThrow("string") + + fun <T> accept(visitor: Visitor<T>): T = + when { + offsetDateTime != null -> visitor.visitOffsetDateTime(offsetDateTime) + string != null -> visitor.visitString(string) + else -> throw IllegalStateException("Invalid ToVersion") + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ToVersion && + offsetDateTime == other.offsetDateTime && + string == other.string + } + + override fun hashCode(): Int = Objects.hash(offsetDateTime, string) + + override fun toString(): String = + when { + offsetDateTime != null -> "ToVersion{offsetDateTime=$offsetDateTime}" + string != null -> "ToVersion{string=$string}" + else -> throw IllegalStateException("Invalid ToVersion") + } + + companion object { + + @JvmStatic + fun ofOffsetDateTime(offsetDateTime: OffsetDateTime) = + ToVersion(offsetDateTime = offsetDateTime) + + @JvmStatic fun ofString(string: String) = ToVersion(string = string) + } + + /** + * An interface that defines how to map each variant of [ToVersion] to a value of type [T]. + */ + interface Visitor<out T> { + + fun visitOffsetDateTime(offsetDateTime: OffsetDateTime): T + + fun visitString(string: String): T + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VersionRetrieveDiffParams && + datasetId == other.datasetId && + fromVersion == other.fromVersion && + toVersion == other.toVersion && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(datasetId, fromVersion, toVersion, additionalHeaders, additionalQueryParams) + + override fun toString() = + "VersionRetrieveDiffParams{datasetId=$datasetId, fromVersion=$fromVersion, toVersion=$toVersion, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/versions/VersionRetrieveDiffResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/versions/VersionRetrieveDiffResponse.kt new file mode 100644 index 00000000..f24a4ed0 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/datasets/versions/VersionRetrieveDiffResponse.kt @@ -0,0 +1,305 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.versions + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** Dataset diff schema. */ +class VersionRetrieveDiffResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val examplesAdded: JsonField<List<String>>, + private val examplesModified: JsonField<List<String>>, + private val examplesRemoved: JsonField<List<String>>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("examples_added") + @ExcludeMissing + examplesAdded: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("examples_modified") + @ExcludeMissing + examplesModified: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("examples_removed") + @ExcludeMissing + examplesRemoved: JsonField<List<String>> = JsonMissing.of(), + ) : this(examplesAdded, examplesModified, examplesRemoved, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun examplesAdded(): List<String> = examplesAdded.getRequired("examples_added") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun examplesModified(): List<String> = examplesModified.getRequired("examples_modified") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun examplesRemoved(): List<String> = examplesRemoved.getRequired("examples_removed") + + /** + * Returns the raw JSON value of [examplesAdded]. + * + * Unlike [examplesAdded], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("examples_added") + @ExcludeMissing + fun _examplesAdded(): JsonField<List<String>> = examplesAdded + + /** + * Returns the raw JSON value of [examplesModified]. + * + * Unlike [examplesModified], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("examples_modified") + @ExcludeMissing + fun _examplesModified(): JsonField<List<String>> = examplesModified + + /** + * Returns the raw JSON value of [examplesRemoved]. + * + * Unlike [examplesRemoved], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("examples_removed") + @ExcludeMissing + fun _examplesRemoved(): JsonField<List<String>> = examplesRemoved + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [VersionRetrieveDiffResponse]. + * + * The following fields are required: + * ```java + * .examplesAdded() + * .examplesModified() + * .examplesRemoved() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VersionRetrieveDiffResponse]. */ + class Builder internal constructor() { + + private var examplesAdded: JsonField<MutableList<String>>? = null + private var examplesModified: JsonField<MutableList<String>>? = null + private var examplesRemoved: JsonField<MutableList<String>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(versionRetrieveDiffResponse: VersionRetrieveDiffResponse) = apply { + examplesAdded = versionRetrieveDiffResponse.examplesAdded.map { it.toMutableList() } + examplesModified = + versionRetrieveDiffResponse.examplesModified.map { it.toMutableList() } + examplesRemoved = versionRetrieveDiffResponse.examplesRemoved.map { it.toMutableList() } + additionalProperties = versionRetrieveDiffResponse.additionalProperties.toMutableMap() + } + + fun examplesAdded(examplesAdded: List<String>) = examplesAdded(JsonField.of(examplesAdded)) + + /** + * Sets [Builder.examplesAdded] to an arbitrary JSON value. + * + * You should usually call [Builder.examplesAdded] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun examplesAdded(examplesAdded: JsonField<List<String>>) = apply { + this.examplesAdded = examplesAdded.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.examplesAdded]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExamplesAdded(examplesAdded: String) = apply { + this.examplesAdded = + (this.examplesAdded ?: JsonField.of(mutableListOf())).also { + checkKnown("examplesAdded", it).add(examplesAdded) + } + } + + fun examplesModified(examplesModified: List<String>) = + examplesModified(JsonField.of(examplesModified)) + + /** + * Sets [Builder.examplesModified] to an arbitrary JSON value. + * + * You should usually call [Builder.examplesModified] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun examplesModified(examplesModified: JsonField<List<String>>) = apply { + this.examplesModified = examplesModified.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.examplesModified]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExamplesModified(examplesModified: String) = apply { + this.examplesModified = + (this.examplesModified ?: JsonField.of(mutableListOf())).also { + checkKnown("examplesModified", it).add(examplesModified) + } + } + + fun examplesRemoved(examplesRemoved: List<String>) = + examplesRemoved(JsonField.of(examplesRemoved)) + + /** + * Sets [Builder.examplesRemoved] to an arbitrary JSON value. + * + * You should usually call [Builder.examplesRemoved] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun examplesRemoved(examplesRemoved: JsonField<List<String>>) = apply { + this.examplesRemoved = examplesRemoved.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.examplesRemoved]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExamplesRemoved(examplesRemoved: String) = apply { + this.examplesRemoved = + (this.examplesRemoved ?: JsonField.of(mutableListOf())).also { + checkKnown("examplesRemoved", it).add(examplesRemoved) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [VersionRetrieveDiffResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .examplesAdded() + * .examplesModified() + * .examplesRemoved() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): VersionRetrieveDiffResponse = + VersionRetrieveDiffResponse( + checkRequired("examplesAdded", examplesAdded).map { it.toImmutable() }, + checkRequired("examplesModified", examplesModified).map { it.toImmutable() }, + checkRequired("examplesRemoved", examplesRemoved).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): VersionRetrieveDiffResponse = apply { + if (validated) { + return@apply + } + + examplesAdded() + examplesModified() + examplesRemoved() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (examplesAdded.asKnown().getOrNull()?.size ?: 0) + + (examplesModified.asKnown().getOrNull()?.size ?: 0) + + (examplesRemoved.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VersionRetrieveDiffResponse && + examplesAdded == other.examplesAdded && + examplesModified == other.examplesModified && + examplesRemoved == other.examplesRemoved && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(examplesAdded, examplesModified, examplesRemoved, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "VersionRetrieveDiffResponse{examplesAdded=$examplesAdded, examplesModified=$examplesModified, examplesRemoved=$examplesRemoved, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/AttachmentsOperations.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/AttachmentsOperations.kt new file mode 100644 index 00000000..61252d4f --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/AttachmentsOperations.kt @@ -0,0 +1,312 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.examples + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class AttachmentsOperations +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val rename: JsonField<Rename>, + private val retain: JsonField<List<String>>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("rename") @ExcludeMissing rename: JsonField<Rename> = JsonMissing.of(), + @JsonProperty("retain") @ExcludeMissing retain: JsonField<List<String>> = JsonMissing.of(), + ) : this(rename, retain, mutableMapOf()) + + /** + * Mapping of old attachment names to new names + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun rename(): Optional<Rename> = rename.getOptional("rename") + + /** + * List of attachment names to keep + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun retain(): Optional<List<String>> = retain.getOptional("retain") + + /** + * Returns the raw JSON value of [rename]. + * + * Unlike [rename], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rename") @ExcludeMissing fun _rename(): JsonField<Rename> = rename + + /** + * Returns the raw JSON value of [retain]. + * + * Unlike [retain], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("retain") @ExcludeMissing fun _retain(): JsonField<List<String>> = retain + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [AttachmentsOperations]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AttachmentsOperations]. */ + class Builder internal constructor() { + + private var rename: JsonField<Rename> = JsonMissing.of() + private var retain: JsonField<MutableList<String>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(attachmentsOperations: AttachmentsOperations) = apply { + rename = attachmentsOperations.rename + retain = attachmentsOperations.retain.map { it.toMutableList() } + additionalProperties = attachmentsOperations.additionalProperties.toMutableMap() + } + + /** Mapping of old attachment names to new names */ + fun rename(rename: Rename) = rename(JsonField.of(rename)) + + /** + * Sets [Builder.rename] to an arbitrary JSON value. + * + * You should usually call [Builder.rename] with a well-typed [Rename] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun rename(rename: JsonField<Rename>) = apply { this.rename = rename } + + /** List of attachment names to keep */ + fun retain(retain: List<String>) = retain(JsonField.of(retain)) + + /** + * Sets [Builder.retain] to an arbitrary JSON value. + * + * You should usually call [Builder.retain] with a well-typed `List<String>` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun retain(retain: JsonField<List<String>>) = apply { + this.retain = retain.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.retain]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRetain(retain: String) = apply { + this.retain = + (this.retain ?: JsonField.of(mutableListOf())).also { + checkKnown("retain", it).add(retain) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AttachmentsOperations]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AttachmentsOperations = + AttachmentsOperations( + rename, + (retain ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AttachmentsOperations = apply { + if (validated) { + return@apply + } + + rename().ifPresent { it.validate() } + retain() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (rename.asKnown().getOrNull()?.validity() ?: 0) + (retain.asKnown().getOrNull()?.size ?: 0) + + /** Mapping of old attachment names to new names */ + class Rename + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Rename]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Rename]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(rename: Rename) = apply { + additionalProperties = rename.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Rename]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Rename = Rename(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Rename = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Rename && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Rename{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AttachmentsOperations && + rename == other.rename && + retain == other.retain && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(rename, retain, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AttachmentsOperations{rename=$rename, retain=$retain, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/Example.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/Example.kt new file mode 100644 index 00000000..17a3823e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/Example.kt @@ -0,0 +1,433 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.examples + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Example schema. */ +class Example +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val datasetId: JsonField<String>, + private val inputs: JsonValue, + private val name: JsonField<String>, + private val attachmentUrls: JsonValue, + private val createdAt: JsonField<OffsetDateTime>, + private val metadata: JsonValue, + private val modifiedAt: JsonField<OffsetDateTime>, + private val outputs: JsonValue, + private val sourceRunId: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("dataset_id") @ExcludeMissing datasetId: JsonField<String> = JsonMissing.of(), + @JsonProperty("inputs") @ExcludeMissing inputs: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("attachment_urls") + @ExcludeMissing + attachmentUrls: JsonValue = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("modified_at") + @ExcludeMissing + modifiedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("outputs") @ExcludeMissing outputs: JsonValue = JsonMissing.of(), + @JsonProperty("source_run_id") + @ExcludeMissing + sourceRunId: JsonField<String> = JsonMissing.of(), + ) : this( + id, + datasetId, + inputs, + name, + attachmentUrls, + createdAt, + metadata, + modifiedAt, + outputs, + sourceRunId, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun datasetId(): String = datasetId.getRequired("dataset_id") + + @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonValue = inputs + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + @JsonProperty("attachment_urls") + @ExcludeMissing + fun _attachmentUrls(): JsonValue = attachmentUrls + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun createdAt(): Optional<OffsetDateTime> = createdAt.getOptional("created_at") + + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun modifiedAt(): Optional<OffsetDateTime> = modifiedAt.getOptional("modified_at") + + @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonValue = outputs + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun sourceRunId(): Optional<String> = sourceRunId.getOptional("source_run_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [datasetId]. + * + * Unlike [datasetId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField<String> = datasetId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [modifiedAt]. + * + * Unlike [modifiedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("modified_at") + @ExcludeMissing + fun _modifiedAt(): JsonField<OffsetDateTime> = modifiedAt + + /** + * Returns the raw JSON value of [sourceRunId]. + * + * Unlike [sourceRunId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("source_run_id") + @ExcludeMissing + fun _sourceRunId(): JsonField<String> = sourceRunId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Example]. + * + * The following fields are required: + * ```java + * .id() + * .datasetId() + * .inputs() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Example]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var datasetId: JsonField<String>? = null + private var inputs: JsonValue? = null + private var name: JsonField<String>? = null + private var attachmentUrls: JsonValue = JsonMissing.of() + private var createdAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var metadata: JsonValue = JsonMissing.of() + private var modifiedAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var outputs: JsonValue = JsonMissing.of() + private var sourceRunId: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(example: Example) = apply { + id = example.id + datasetId = example.datasetId + inputs = example.inputs + name = example.name + attachmentUrls = example.attachmentUrls + createdAt = example.createdAt + metadata = example.metadata + modifiedAt = example.modifiedAt + outputs = example.outputs + sourceRunId = example.sourceRunId + additionalProperties = example.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun datasetId(datasetId: String) = datasetId(JsonField.of(datasetId)) + + /** + * Sets [Builder.datasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun datasetId(datasetId: JsonField<String>) = apply { this.datasetId = datasetId } + + fun inputs(inputs: JsonValue) = apply { this.inputs = inputs } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun attachmentUrls(attachmentUrls: JsonValue) = apply { + this.attachmentUrls = attachmentUrls + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + + fun modifiedAt(modifiedAt: OffsetDateTime?) = modifiedAt(JsonField.ofNullable(modifiedAt)) + + /** Alias for calling [Builder.modifiedAt] with `modifiedAt.orElse(null)`. */ + fun modifiedAt(modifiedAt: Optional<OffsetDateTime>) = modifiedAt(modifiedAt.getOrNull()) + + /** + * Sets [Builder.modifiedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.modifiedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modifiedAt(modifiedAt: JsonField<OffsetDateTime>) = apply { + this.modifiedAt = modifiedAt + } + + fun outputs(outputs: JsonValue) = apply { this.outputs = outputs } + + fun sourceRunId(sourceRunId: String?) = sourceRunId(JsonField.ofNullable(sourceRunId)) + + /** Alias for calling [Builder.sourceRunId] with `sourceRunId.orElse(null)`. */ + fun sourceRunId(sourceRunId: Optional<String>) = sourceRunId(sourceRunId.getOrNull()) + + /** + * Sets [Builder.sourceRunId] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceRunId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun sourceRunId(sourceRunId: JsonField<String>) = apply { this.sourceRunId = sourceRunId } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Example]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .datasetId() + * .inputs() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Example = + Example( + checkRequired("id", id), + checkRequired("datasetId", datasetId), + checkRequired("inputs", inputs), + checkRequired("name", name), + attachmentUrls, + createdAt, + metadata, + modifiedAt, + outputs, + sourceRunId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Example = apply { + if (validated) { + return@apply + } + + id() + datasetId() + name() + createdAt() + modifiedAt() + sourceRunId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (datasetId.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (modifiedAt.asKnown().isPresent) 1 else 0) + + (if (sourceRunId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Example && + id == other.id && + datasetId == other.datasetId && + inputs == other.inputs && + name == other.name && + attachmentUrls == other.attachmentUrls && + createdAt == other.createdAt && + metadata == other.metadata && + modifiedAt == other.modifiedAt && + outputs == other.outputs && + sourceRunId == other.sourceRunId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + datasetId, + inputs, + name, + attachmentUrls, + createdAt, + metadata, + modifiedAt, + outputs, + sourceRunId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Example{id=$id, datasetId=$datasetId, inputs=$inputs, name=$name, attachmentUrls=$attachmentUrls, createdAt=$createdAt, metadata=$metadata, modifiedAt=$modifiedAt, outputs=$outputs, sourceRunId=$sourceRunId, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleCreateParams.kt new file mode 100644 index 00000000..143b7dca --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleCreateParams.kt @@ -0,0 +1,210 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.examples + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional + +/** Create a new example. */ +class ExampleCreateParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ExampleCreateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ExampleCreateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExampleCreateParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(exampleCreateParams: ExampleCreateParams) = apply { + additionalHeaders = exampleCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = exampleCreateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = exampleCreateParams.additionalBodyProperties.toMutableMap() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [ExampleCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ExampleCreateParams = + ExampleCreateParams( + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExampleCreateParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "ExampleCreateParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleDeleteAllParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleDeleteAllParams.kt new file mode 100644 index 00000000..067bdeed --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleDeleteAllParams.kt @@ -0,0 +1,250 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.examples + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional + +/** Soft delete examples. Only deletes the examples in the 'latest' version of the dataset. */ +class ExampleDeleteAllParams +private constructor( + private val exampleIds: List<String>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun exampleIds(): List<String> = exampleIds + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ExampleDeleteAllParams]. + * + * The following fields are required: + * ```java + * .exampleIds() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExampleDeleteAllParams]. */ + class Builder internal constructor() { + + private var exampleIds: MutableList<String>? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(exampleDeleteAllParams: ExampleDeleteAllParams) = apply { + exampleIds = exampleDeleteAllParams.exampleIds.toMutableList() + additionalHeaders = exampleDeleteAllParams.additionalHeaders.toBuilder() + additionalQueryParams = exampleDeleteAllParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + exampleDeleteAllParams.additionalBodyProperties.toMutableMap() + } + + fun exampleIds(exampleIds: List<String>) = apply { + this.exampleIds = exampleIds.toMutableList() + } + + /** + * Adds a single [String] to [exampleIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExampleId(exampleId: String) = apply { + exampleIds = (exampleIds ?: mutableListOf()).apply { add(exampleId) } + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [ExampleDeleteAllParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .exampleIds() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ExampleDeleteAllParams = + ExampleDeleteAllParams( + checkRequired("exampleIds", exampleIds).toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("example_ids", exampleIds.joinToString(",")) + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExampleDeleteAllParams && + exampleIds == other.exampleIds && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(exampleIds, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "ExampleDeleteAllParams{exampleIds=$exampleIds, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleDeleteAllResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleDeleteAllResponse.kt new file mode 100644 index 00000000..ae781b13 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleDeleteAllResponse.kt @@ -0,0 +1,115 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.examples + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class ExampleDeleteAllResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ExampleDeleteAllResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExampleDeleteAllResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(exampleDeleteAllResponse: ExampleDeleteAllResponse) = apply { + additionalProperties = exampleDeleteAllResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ExampleDeleteAllResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ExampleDeleteAllResponse = + ExampleDeleteAllResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): ExampleDeleteAllResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExampleDeleteAllResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "ExampleDeleteAllResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleDeleteParams.kt new file mode 100644 index 00000000..e6cb72d0 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleDeleteParams.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.examples + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Soft delete an example. Only deletes the example in the 'latest' version of the dataset. */ +class ExampleDeleteParams +private constructor( + private val exampleId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun exampleId(): Optional<String> = Optional.ofNullable(exampleId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ExampleDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ExampleDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExampleDeleteParams]. */ + class Builder internal constructor() { + + private var exampleId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(exampleDeleteParams: ExampleDeleteParams) = apply { + exampleId = exampleDeleteParams.exampleId + additionalHeaders = exampleDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = exampleDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = exampleDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun exampleId(exampleId: String?) = apply { this.exampleId = exampleId } + + /** Alias for calling [Builder.exampleId] with `exampleId.orElse(null)`. */ + fun exampleId(exampleId: Optional<String>) = exampleId(exampleId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [ExampleDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ExampleDeleteParams = + ExampleDeleteParams( + exampleId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> exampleId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExampleDeleteParams && + exampleId == other.exampleId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(exampleId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "ExampleDeleteParams{exampleId=$exampleId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleDeleteResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleDeleteResponse.kt new file mode 100644 index 00000000..a7080877 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleDeleteResponse.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.examples + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class ExampleDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ExampleDeleteResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExampleDeleteResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(exampleDeleteResponse: ExampleDeleteResponse) = apply { + additionalProperties = exampleDeleteResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ExampleDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ExampleDeleteResponse = + ExampleDeleteResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): ExampleDeleteResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExampleDeleteResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "ExampleDeleteResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleListParams.kt new file mode 100644 index 00000000..278c4ca1 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleListParams.kt @@ -0,0 +1,669 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.examples + +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get all examples by query params */ +class ExampleListParams +private constructor( + private val id: List<String>?, + private val asOf: AsOf?, + private val dataset: String?, + private val descending: Boolean?, + private val filter: String?, + private val fullTextContains: List<String>?, + private val limit: Long?, + private val metadata: String?, + private val offset: Long?, + private val order: Order?, + private val randomSeed: Double?, + private val select: List<ExampleSelect>?, + private val splits: List<String>?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun id(): Optional<List<String>> = Optional.ofNullable(id) + + /** + * Only modifications made on or before this time are included. If None, the latest version of + * the dataset is used. + */ + fun asOf(): Optional<AsOf> = Optional.ofNullable(asOf) + + fun dataset(): Optional<String> = Optional.ofNullable(dataset) + + fun descending(): Optional<Boolean> = Optional.ofNullable(descending) + + fun filter(): Optional<String> = Optional.ofNullable(filter) + + fun fullTextContains(): Optional<List<String>> = Optional.ofNullable(fullTextContains) + + fun limit(): Optional<Long> = Optional.ofNullable(limit) + + fun metadata(): Optional<String> = Optional.ofNullable(metadata) + + fun offset(): Optional<Long> = Optional.ofNullable(offset) + + fun order(): Optional<Order> = Optional.ofNullable(order) + + fun randomSeed(): Optional<Double> = Optional.ofNullable(randomSeed) + + fun select(): Optional<List<ExampleSelect>> = Optional.ofNullable(select) + + fun splits(): Optional<List<String>> = Optional.ofNullable(splits) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ExampleListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ExampleListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExampleListParams]. */ + class Builder internal constructor() { + + private var id: MutableList<String>? = null + private var asOf: AsOf? = null + private var dataset: String? = null + private var descending: Boolean? = null + private var filter: String? = null + private var fullTextContains: MutableList<String>? = null + private var limit: Long? = null + private var metadata: String? = null + private var offset: Long? = null + private var order: Order? = null + private var randomSeed: Double? = null + private var select: MutableList<ExampleSelect>? = null + private var splits: MutableList<String>? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(exampleListParams: ExampleListParams) = apply { + id = exampleListParams.id?.toMutableList() + asOf = exampleListParams.asOf + dataset = exampleListParams.dataset + descending = exampleListParams.descending + filter = exampleListParams.filter + fullTextContains = exampleListParams.fullTextContains?.toMutableList() + limit = exampleListParams.limit + metadata = exampleListParams.metadata + offset = exampleListParams.offset + order = exampleListParams.order + randomSeed = exampleListParams.randomSeed + select = exampleListParams.select?.toMutableList() + splits = exampleListParams.splits?.toMutableList() + additionalHeaders = exampleListParams.additionalHeaders.toBuilder() + additionalQueryParams = exampleListParams.additionalQueryParams.toBuilder() + } + + fun id(id: List<String>?) = apply { this.id = id?.toMutableList() } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<List<String>>) = id(id.getOrNull()) + + /** + * Adds a single [String] to [Builder.id]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addId(id: String) = apply { this.id = (this.id ?: mutableListOf()).apply { add(id) } } + + /** + * Only modifications made on or before this time are included. If None, the latest version + * of the dataset is used. + */ + fun asOf(asOf: AsOf?) = apply { this.asOf = asOf } + + /** Alias for calling [Builder.asOf] with `asOf.orElse(null)`. */ + fun asOf(asOf: Optional<AsOf>) = asOf(asOf.getOrNull()) + + /** Alias for calling [asOf] with `AsOf.ofOffsetDateTime(offsetDateTime)`. */ + fun asOf(offsetDateTime: OffsetDateTime) = asOf(AsOf.ofOffsetDateTime(offsetDateTime)) + + /** Alias for calling [asOf] with `AsOf.ofString(string)`. */ + fun asOf(string: String) = asOf(AsOf.ofString(string)) + + fun dataset(dataset: String?) = apply { this.dataset = dataset } + + /** Alias for calling [Builder.dataset] with `dataset.orElse(null)`. */ + fun dataset(dataset: Optional<String>) = dataset(dataset.getOrNull()) + + fun descending(descending: Boolean?) = apply { this.descending = descending } + + /** + * Alias for [Builder.descending]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun descending(descending: Boolean) = descending(descending as Boolean?) + + /** Alias for calling [Builder.descending] with `descending.orElse(null)`. */ + fun descending(descending: Optional<Boolean>) = descending(descending.getOrNull()) + + fun filter(filter: String?) = apply { this.filter = filter } + + /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ + fun filter(filter: Optional<String>) = filter(filter.getOrNull()) + + fun fullTextContains(fullTextContains: List<String>?) = apply { + this.fullTextContains = fullTextContains?.toMutableList() + } + + /** Alias for calling [Builder.fullTextContains] with `fullTextContains.orElse(null)`. */ + fun fullTextContains(fullTextContains: Optional<List<String>>) = + fullTextContains(fullTextContains.getOrNull()) + + /** + * Adds a single [String] to [fullTextContains]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFullTextContain(fullTextContain: String) = apply { + fullTextContains = (fullTextContains ?: mutableListOf()).apply { add(fullTextContain) } + } + + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional<Long>) = limit(limit.getOrNull()) + + fun metadata(metadata: String?) = apply { this.metadata = metadata } + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional<String>) = metadata(metadata.getOrNull()) + + fun offset(offset: Long?) = apply { this.offset = offset } + + /** + * Alias for [Builder.offset]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun offset(offset: Long) = offset(offset as Long?) + + /** Alias for calling [Builder.offset] with `offset.orElse(null)`. */ + fun offset(offset: Optional<Long>) = offset(offset.getOrNull()) + + fun order(order: Order?) = apply { this.order = order } + + /** Alias for calling [Builder.order] with `order.orElse(null)`. */ + fun order(order: Optional<Order>) = order(order.getOrNull()) + + fun randomSeed(randomSeed: Double?) = apply { this.randomSeed = randomSeed } + + /** + * Alias for [Builder.randomSeed]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun randomSeed(randomSeed: Double) = randomSeed(randomSeed as Double?) + + /** Alias for calling [Builder.randomSeed] with `randomSeed.orElse(null)`. */ + fun randomSeed(randomSeed: Optional<Double>) = randomSeed(randomSeed.getOrNull()) + + fun select(select: List<ExampleSelect>?) = apply { this.select = select?.toMutableList() } + + /** Alias for calling [Builder.select] with `select.orElse(null)`. */ + fun select(select: Optional<List<ExampleSelect>>) = select(select.getOrNull()) + + /** + * Adds a single [ExampleSelect] to [Builder.select]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSelect(select: ExampleSelect) = apply { + this.select = (this.select ?: mutableListOf()).apply { add(select) } + } + + fun splits(splits: List<String>?) = apply { this.splits = splits?.toMutableList() } + + /** Alias for calling [Builder.splits] with `splits.orElse(null)`. */ + fun splits(splits: Optional<List<String>>) = splits(splits.getOrNull()) + + /** + * Adds a single [String] to [splits]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSplit(split: String) = apply { + splits = (splits ?: mutableListOf()).apply { add(split) } + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ExampleListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ExampleListParams = + ExampleListParams( + id?.toImmutable(), + asOf, + dataset, + descending, + filter, + fullTextContains?.toImmutable(), + limit, + metadata, + offset, + order, + randomSeed, + select?.toImmutable(), + splits?.toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + id?.let { put("id", it.joinToString(",")) } + asOf?.accept( + object : AsOf.Visitor<Unit> { + override fun visitOffsetDateTime(offsetDateTime: OffsetDateTime) { + put( + "as_of", + DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(offsetDateTime), + ) + } + + override fun visitString(string: String) { + put("as_of", string) + } + } + ) + dataset?.let { put("dataset", it) } + descending?.let { put("descending", it.toString()) } + filter?.let { put("filter", it) } + fullTextContains?.let { put("full_text_contains", it.joinToString(",")) } + limit?.let { put("limit", it.toString()) } + metadata?.let { put("metadata", it) } + offset?.let { put("offset", it.toString()) } + order?.let { put("order", it.toString()) } + randomSeed?.let { put("random_seed", it.toString()) } + select?.let { put("select", it.joinToString(",") { it.toString() }) } + splits?.let { put("splits", it.joinToString(",")) } + putAll(additionalQueryParams) + } + .build() + + /** + * Only modifications made on or before this time are included. If None, the latest version of + * the dataset is used. + */ + class AsOf + private constructor( + private val offsetDateTime: OffsetDateTime? = null, + private val string: String? = null, + ) { + + fun offsetDateTime(): Optional<OffsetDateTime> = Optional.ofNullable(offsetDateTime) + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun isOffsetDateTime(): Boolean = offsetDateTime != null + + fun isString(): Boolean = string != null + + fun asOffsetDateTime(): OffsetDateTime = offsetDateTime.getOrThrow("offsetDateTime") + + fun asString(): String = string.getOrThrow("string") + + fun <T> accept(visitor: Visitor<T>): T = + when { + offsetDateTime != null -> visitor.visitOffsetDateTime(offsetDateTime) + string != null -> visitor.visitString(string) + else -> throw IllegalStateException("Invalid AsOf") + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AsOf && offsetDateTime == other.offsetDateTime && string == other.string + } + + override fun hashCode(): Int = Objects.hash(offsetDateTime, string) + + override fun toString(): String = + when { + offsetDateTime != null -> "AsOf{offsetDateTime=$offsetDateTime}" + string != null -> "AsOf{string=$string}" + else -> throw IllegalStateException("Invalid AsOf") + } + + companion object { + + @JvmStatic + fun ofOffsetDateTime(offsetDateTime: OffsetDateTime) = + AsOf(offsetDateTime = offsetDateTime) + + @JvmStatic fun ofString(string: String) = AsOf(string = string) + } + + /** An interface that defines how to map each variant of [AsOf] to a value of type [T]. */ + interface Visitor<out T> { + + fun visitOffsetDateTime(offsetDateTime: OffsetDateTime): T + + fun visitString(string: String): T + } + } + + class Order @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val RECENT = of("recent") + + @JvmField val RANDOM = of("random") + + @JvmField val RECENTLY_CREATED = of("recently_created") + + @JvmField val ID = of("id") + + @JvmStatic fun of(value: String) = Order(JsonField.of(value)) + } + + /** An enum containing [Order]'s known values. */ + enum class Known { + RECENT, + RANDOM, + RECENTLY_CREATED, + ID, + } + + /** + * An enum containing [Order]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Order] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + RECENT, + RANDOM, + RECENTLY_CREATED, + ID, + /** An enum member indicating that [Order] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + RECENT -> Value.RECENT + RANDOM -> Value.RANDOM + RECENTLY_CREATED -> Value.RECENTLY_CREATED + ID -> Value.ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + RECENT -> Known.RECENT + RANDOM -> Known.RANDOM + RECENTLY_CREATED -> Known.RECENTLY_CREATED + ID -> Known.ID + else -> throw LangsmithApiInvalidDataException("Unknown Order: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Order = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Order && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExampleListParams && + id == other.id && + asOf == other.asOf && + dataset == other.dataset && + descending == other.descending && + filter == other.filter && + fullTextContains == other.fullTextContains && + limit == other.limit && + metadata == other.metadata && + offset == other.offset && + order == other.order && + randomSeed == other.randomSeed && + select == other.select && + splits == other.splits && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + id, + asOf, + dataset, + descending, + filter, + fullTextContains, + limit, + metadata, + offset, + order, + randomSeed, + select, + splits, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "ExampleListParams{id=$id, asOf=$asOf, dataset=$dataset, descending=$descending, filter=$filter, fullTextContains=$fullTextContains, limit=$limit, metadata=$metadata, offset=$offset, order=$order, randomSeed=$randomSeed, select=$select, splits=$splits, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleRetrieveCountParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleRetrieveCountParams.kt new file mode 100644 index 00000000..f975fd4c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleRetrieveCountParams.kt @@ -0,0 +1,407 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.examples + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Count all examples by query params */ +class ExampleRetrieveCountParams +private constructor( + private val id: List<String>?, + private val asOf: AsOf?, + private val dataset: String?, + private val filter: String?, + private val fullTextContains: List<String>?, + private val metadata: String?, + private val splits: List<String>?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun id(): Optional<List<String>> = Optional.ofNullable(id) + + /** + * Only modifications made on or before this time are included. If None, the latest version of + * the dataset is used. + */ + fun asOf(): Optional<AsOf> = Optional.ofNullable(asOf) + + fun dataset(): Optional<String> = Optional.ofNullable(dataset) + + fun filter(): Optional<String> = Optional.ofNullable(filter) + + fun fullTextContains(): Optional<List<String>> = Optional.ofNullable(fullTextContains) + + fun metadata(): Optional<String> = Optional.ofNullable(metadata) + + fun splits(): Optional<List<String>> = Optional.ofNullable(splits) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ExampleRetrieveCountParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [ExampleRetrieveCountParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExampleRetrieveCountParams]. */ + class Builder internal constructor() { + + private var id: MutableList<String>? = null + private var asOf: AsOf? = null + private var dataset: String? = null + private var filter: String? = null + private var fullTextContains: MutableList<String>? = null + private var metadata: String? = null + private var splits: MutableList<String>? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(exampleRetrieveCountParams: ExampleRetrieveCountParams) = apply { + id = exampleRetrieveCountParams.id?.toMutableList() + asOf = exampleRetrieveCountParams.asOf + dataset = exampleRetrieveCountParams.dataset + filter = exampleRetrieveCountParams.filter + fullTextContains = exampleRetrieveCountParams.fullTextContains?.toMutableList() + metadata = exampleRetrieveCountParams.metadata + splits = exampleRetrieveCountParams.splits?.toMutableList() + additionalHeaders = exampleRetrieveCountParams.additionalHeaders.toBuilder() + additionalQueryParams = exampleRetrieveCountParams.additionalQueryParams.toBuilder() + } + + fun id(id: List<String>?) = apply { this.id = id?.toMutableList() } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<List<String>>) = id(id.getOrNull()) + + /** + * Adds a single [String] to [Builder.id]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addId(id: String) = apply { this.id = (this.id ?: mutableListOf()).apply { add(id) } } + + /** + * Only modifications made on or before this time are included. If None, the latest version + * of the dataset is used. + */ + fun asOf(asOf: AsOf?) = apply { this.asOf = asOf } + + /** Alias for calling [Builder.asOf] with `asOf.orElse(null)`. */ + fun asOf(asOf: Optional<AsOf>) = asOf(asOf.getOrNull()) + + /** Alias for calling [asOf] with `AsOf.ofOffsetDateTime(offsetDateTime)`. */ + fun asOf(offsetDateTime: OffsetDateTime) = asOf(AsOf.ofOffsetDateTime(offsetDateTime)) + + /** Alias for calling [asOf] with `AsOf.ofString(string)`. */ + fun asOf(string: String) = asOf(AsOf.ofString(string)) + + fun dataset(dataset: String?) = apply { this.dataset = dataset } + + /** Alias for calling [Builder.dataset] with `dataset.orElse(null)`. */ + fun dataset(dataset: Optional<String>) = dataset(dataset.getOrNull()) + + fun filter(filter: String?) = apply { this.filter = filter } + + /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ + fun filter(filter: Optional<String>) = filter(filter.getOrNull()) + + fun fullTextContains(fullTextContains: List<String>?) = apply { + this.fullTextContains = fullTextContains?.toMutableList() + } + + /** Alias for calling [Builder.fullTextContains] with `fullTextContains.orElse(null)`. */ + fun fullTextContains(fullTextContains: Optional<List<String>>) = + fullTextContains(fullTextContains.getOrNull()) + + /** + * Adds a single [String] to [fullTextContains]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFullTextContain(fullTextContain: String) = apply { + fullTextContains = (fullTextContains ?: mutableListOf()).apply { add(fullTextContain) } + } + + fun metadata(metadata: String?) = apply { this.metadata = metadata } + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional<String>) = metadata(metadata.getOrNull()) + + fun splits(splits: List<String>?) = apply { this.splits = splits?.toMutableList() } + + /** Alias for calling [Builder.splits] with `splits.orElse(null)`. */ + fun splits(splits: Optional<List<String>>) = splits(splits.getOrNull()) + + /** + * Adds a single [String] to [splits]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSplit(split: String) = apply { + splits = (splits ?: mutableListOf()).apply { add(split) } + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ExampleRetrieveCountParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ExampleRetrieveCountParams = + ExampleRetrieveCountParams( + id?.toImmutable(), + asOf, + dataset, + filter, + fullTextContains?.toImmutable(), + metadata, + splits?.toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + id?.let { put("id", it.joinToString(",")) } + asOf?.accept( + object : AsOf.Visitor<Unit> { + override fun visitOffsetDateTime(offsetDateTime: OffsetDateTime) { + put( + "as_of", + DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(offsetDateTime), + ) + } + + override fun visitString(string: String) { + put("as_of", string) + } + } + ) + dataset?.let { put("dataset", it) } + filter?.let { put("filter", it) } + fullTextContains?.let { put("full_text_contains", it.joinToString(",")) } + metadata?.let { put("metadata", it) } + splits?.let { put("splits", it.joinToString(",")) } + putAll(additionalQueryParams) + } + .build() + + /** + * Only modifications made on or before this time are included. If None, the latest version of + * the dataset is used. + */ + class AsOf + private constructor( + private val offsetDateTime: OffsetDateTime? = null, + private val string: String? = null, + ) { + + fun offsetDateTime(): Optional<OffsetDateTime> = Optional.ofNullable(offsetDateTime) + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun isOffsetDateTime(): Boolean = offsetDateTime != null + + fun isString(): Boolean = string != null + + fun asOffsetDateTime(): OffsetDateTime = offsetDateTime.getOrThrow("offsetDateTime") + + fun asString(): String = string.getOrThrow("string") + + fun <T> accept(visitor: Visitor<T>): T = + when { + offsetDateTime != null -> visitor.visitOffsetDateTime(offsetDateTime) + string != null -> visitor.visitString(string) + else -> throw IllegalStateException("Invalid AsOf") + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AsOf && offsetDateTime == other.offsetDateTime && string == other.string + } + + override fun hashCode(): Int = Objects.hash(offsetDateTime, string) + + override fun toString(): String = + when { + offsetDateTime != null -> "AsOf{offsetDateTime=$offsetDateTime}" + string != null -> "AsOf{string=$string}" + else -> throw IllegalStateException("Invalid AsOf") + } + + companion object { + + @JvmStatic + fun ofOffsetDateTime(offsetDateTime: OffsetDateTime) = + AsOf(offsetDateTime = offsetDateTime) + + @JvmStatic fun ofString(string: String) = AsOf(string = string) + } + + /** An interface that defines how to map each variant of [AsOf] to a value of type [T]. */ + interface Visitor<out T> { + + fun visitOffsetDateTime(offsetDateTime: OffsetDateTime): T + + fun visitString(string: String): T + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExampleRetrieveCountParams && + id == other.id && + asOf == other.asOf && + dataset == other.dataset && + filter == other.filter && + fullTextContains == other.fullTextContains && + metadata == other.metadata && + splits == other.splits && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + id, + asOf, + dataset, + filter, + fullTextContains, + metadata, + splits, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "ExampleRetrieveCountParams{id=$id, asOf=$asOf, dataset=$dataset, filter=$filter, fullTextContains=$fullTextContains, metadata=$metadata, splits=$splits, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleRetrieveParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleRetrieveParams.kt new file mode 100644 index 00000000..320ea680 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleRetrieveParams.kt @@ -0,0 +1,306 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.examples + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get a specific example. */ +class ExampleRetrieveParams +private constructor( + private val exampleId: String?, + private val asOf: AsOf?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun exampleId(): Optional<String> = Optional.ofNullable(exampleId) + + /** + * Only modifications made on or before this time are included. If None, the latest version of + * the dataset is used. + */ + fun asOf(): Optional<AsOf> = Optional.ofNullable(asOf) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ExampleRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ExampleRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExampleRetrieveParams]. */ + class Builder internal constructor() { + + private var exampleId: String? = null + private var asOf: AsOf? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(exampleRetrieveParams: ExampleRetrieveParams) = apply { + exampleId = exampleRetrieveParams.exampleId + asOf = exampleRetrieveParams.asOf + additionalHeaders = exampleRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = exampleRetrieveParams.additionalQueryParams.toBuilder() + } + + fun exampleId(exampleId: String?) = apply { this.exampleId = exampleId } + + /** Alias for calling [Builder.exampleId] with `exampleId.orElse(null)`. */ + fun exampleId(exampleId: Optional<String>) = exampleId(exampleId.getOrNull()) + + /** + * Only modifications made on or before this time are included. If None, the latest version + * of the dataset is used. + */ + fun asOf(asOf: AsOf?) = apply { this.asOf = asOf } + + /** Alias for calling [Builder.asOf] with `asOf.orElse(null)`. */ + fun asOf(asOf: Optional<AsOf>) = asOf(asOf.getOrNull()) + + /** Alias for calling [asOf] with `AsOf.ofOffsetDateTime(offsetDateTime)`. */ + fun asOf(offsetDateTime: OffsetDateTime) = asOf(AsOf.ofOffsetDateTime(offsetDateTime)) + + /** Alias for calling [asOf] with `AsOf.ofString(string)`. */ + fun asOf(string: String) = asOf(AsOf.ofString(string)) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ExampleRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ExampleRetrieveParams = + ExampleRetrieveParams( + exampleId, + asOf, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> exampleId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + asOf?.accept( + object : AsOf.Visitor<Unit> { + override fun visitOffsetDateTime(offsetDateTime: OffsetDateTime) { + put( + "as_of", + DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(offsetDateTime), + ) + } + + override fun visitString(string: String) { + put("as_of", string) + } + } + ) + putAll(additionalQueryParams) + } + .build() + + /** + * Only modifications made on or before this time are included. If None, the latest version of + * the dataset is used. + */ + class AsOf + private constructor( + private val offsetDateTime: OffsetDateTime? = null, + private val string: String? = null, + ) { + + fun offsetDateTime(): Optional<OffsetDateTime> = Optional.ofNullable(offsetDateTime) + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun isOffsetDateTime(): Boolean = offsetDateTime != null + + fun isString(): Boolean = string != null + + fun asOffsetDateTime(): OffsetDateTime = offsetDateTime.getOrThrow("offsetDateTime") + + fun asString(): String = string.getOrThrow("string") + + fun <T> accept(visitor: Visitor<T>): T = + when { + offsetDateTime != null -> visitor.visitOffsetDateTime(offsetDateTime) + string != null -> visitor.visitString(string) + else -> throw IllegalStateException("Invalid AsOf") + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AsOf && offsetDateTime == other.offsetDateTime && string == other.string + } + + override fun hashCode(): Int = Objects.hash(offsetDateTime, string) + + override fun toString(): String = + when { + offsetDateTime != null -> "AsOf{offsetDateTime=$offsetDateTime}" + string != null -> "AsOf{string=$string}" + else -> throw IllegalStateException("Invalid AsOf") + } + + companion object { + + @JvmStatic + fun ofOffsetDateTime(offsetDateTime: OffsetDateTime) = + AsOf(offsetDateTime = offsetDateTime) + + @JvmStatic fun ofString(string: String) = AsOf(string = string) + } + + /** An interface that defines how to map each variant of [AsOf] to a value of type [T]. */ + interface Visitor<out T> { + + fun visitOffsetDateTime(offsetDateTime: OffsetDateTime): T + + fun visitString(string: String): T + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExampleRetrieveParams && + exampleId == other.exampleId && + asOf == other.asOf && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(exampleId, asOf, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ExampleRetrieveParams{exampleId=$exampleId, asOf=$asOf, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleSelect.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleSelect.kt new file mode 100644 index 00000000..553a3cd8 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleSelect.kt @@ -0,0 +1,183 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.examples + +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException + +class ExampleSelect @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't match + * any known member, and you want to know that value. For example, if the SDK is on an older + * version than the API, then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val ID = of("id") + + @JvmField val CREATED_AT = of("created_at") + + @JvmField val MODIFIED_AT = of("modified_at") + + @JvmField val NAME = of("name") + + @JvmField val DATASET_ID = of("dataset_id") + + @JvmField val SOURCE_RUN_ID = of("source_run_id") + + @JvmField val METADATA = of("metadata") + + @JvmField val INPUTS = of("inputs") + + @JvmField val OUTPUTS = of("outputs") + + @JvmField val ATTACHMENT_URLS = of("attachment_urls") + + @JvmStatic fun of(value: String) = ExampleSelect(JsonField.of(value)) + } + + /** An enum containing [ExampleSelect]'s known values. */ + enum class Known { + ID, + CREATED_AT, + MODIFIED_AT, + NAME, + DATASET_ID, + SOURCE_RUN_ID, + METADATA, + INPUTS, + OUTPUTS, + ATTACHMENT_URLS, + } + + /** + * An enum containing [ExampleSelect]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ExampleSelect] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the SDK + * is on an older version than the API, then the API may respond with new members that the SDK + * is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ID, + CREATED_AT, + MODIFIED_AT, + NAME, + DATASET_ID, + SOURCE_RUN_ID, + METADATA, + INPUTS, + OUTPUTS, + ATTACHMENT_URLS, + /** + * An enum member indicating that [ExampleSelect] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if + * the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want to + * throw for the unknown case. + */ + fun value(): Value = + when (this) { + ID -> Value.ID + CREATED_AT -> Value.CREATED_AT + MODIFIED_AT -> Value.MODIFIED_AT + NAME -> Value.NAME + DATASET_ID -> Value.DATASET_ID + SOURCE_RUN_ID -> Value.SOURCE_RUN_ID + METADATA -> Value.METADATA + INPUTS -> Value.INPUTS + OUTPUTS -> Value.OUTPUTS + ATTACHMENT_URLS -> Value.ATTACHMENT_URLS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't want + * to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ID -> Known.ID + CREATED_AT -> Known.CREATED_AT + MODIFIED_AT -> Known.MODIFIED_AT + NAME -> Known.NAME + DATASET_ID -> Known.DATASET_ID + SOURCE_RUN_ID -> Known.SOURCE_RUN_ID + METADATA -> Known.METADATA + INPUTS -> Known.INPUTS + OUTPUTS -> Known.OUTPUTS + ATTACHMENT_URLS -> Known.ATTACHMENT_URLS + else -> throw LangsmithApiInvalidDataException("Unknown ExampleSelect: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ExampleSelect = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExampleSelect && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleUpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleUpdateParams.kt new file mode 100644 index 00000000..426f8a70 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleUpdateParams.kt @@ -0,0 +1,699 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.examples + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.MultipartField +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.io.InputStream +import java.nio.file.Path +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.io.path.inputStream +import kotlin.io.path.name +import kotlin.jvm.optionals.getOrNull + +/** + * Upload examples from a CSV file. + * + * Note: For non-csv upload, please use the POST /v1/platform/datasets/{dataset_id}/examples + * endpoint which provides more efficient upload. + */ +class ExampleUpdateParams +private constructor( + private val datasetId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun datasetId(): Optional<String> = Optional.ofNullable(datasetId) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun file(): InputStream = body.file() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun inputKeys(): List<String> = body.inputKeys() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadataKeys(): Optional<List<String>> = body.metadataKeys() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun outputKeys(): Optional<List<String>> = body.outputKeys() + + /** + * Returns the raw multipart value of [file]. + * + * Unlike [file], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _file(): MultipartField<InputStream> = body._file() + + /** + * Returns the raw multipart value of [inputKeys]. + * + * Unlike [inputKeys], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _inputKeys(): MultipartField<List<String>> = body._inputKeys() + + /** + * Returns the raw multipart value of [metadataKeys]. + * + * Unlike [metadataKeys], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _metadataKeys(): MultipartField<List<String>> = body._metadataKeys() + + /** + * Returns the raw multipart value of [outputKeys]. + * + * Unlike [outputKeys], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _outputKeys(): MultipartField<List<String>> = body._outputKeys() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ExampleUpdateParams]. + * + * The following fields are required: + * ```java + * .file() + * .inputKeys() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExampleUpdateParams]. */ + class Builder internal constructor() { + + private var datasetId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(exampleUpdateParams: ExampleUpdateParams) = apply { + datasetId = exampleUpdateParams.datasetId + body = exampleUpdateParams.body.toBuilder() + additionalHeaders = exampleUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = exampleUpdateParams.additionalQueryParams.toBuilder() + } + + fun datasetId(datasetId: String?) = apply { this.datasetId = datasetId } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [file] + * - [inputKeys] + * - [metadataKeys] + * - [outputKeys] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun file(file: InputStream) = apply { body.file(file) } + + /** + * Sets [Builder.file] to an arbitrary multipart value. + * + * You should usually call [Builder.file] with a well-typed [InputStream] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun file(file: MultipartField<InputStream>) = apply { body.file(file) } + + fun file(file: ByteArray) = apply { body.file(file) } + + fun file(path: Path) = apply { body.file(path) } + + fun inputKeys(inputKeys: List<String>) = apply { body.inputKeys(inputKeys) } + + /** + * Sets [Builder.inputKeys] to an arbitrary multipart value. + * + * You should usually call [Builder.inputKeys] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inputKeys(inputKeys: MultipartField<List<String>>) = apply { body.inputKeys(inputKeys) } + + /** + * Adds a single [String] to [inputKeys]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addInputKey(inputKey: String) = apply { body.addInputKey(inputKey) } + + fun metadataKeys(metadataKeys: List<String>) = apply { body.metadataKeys(metadataKeys) } + + /** + * Sets [Builder.metadataKeys] to an arbitrary multipart value. + * + * You should usually call [Builder.metadataKeys] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadataKeys(metadataKeys: MultipartField<List<String>>) = apply { + body.metadataKeys(metadataKeys) + } + + /** + * Adds a single [String] to [metadataKeys]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMetadataKey(metadataKey: String) = apply { body.addMetadataKey(metadataKey) } + + fun outputKeys(outputKeys: List<String>) = apply { body.outputKeys(outputKeys) } + + /** + * Sets [Builder.outputKeys] to an arbitrary multipart value. + * + * You should usually call [Builder.outputKeys] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun outputKeys(outputKeys: MultipartField<List<String>>) = apply { + body.outputKeys(outputKeys) + } + + /** + * Adds a single [String] to [outputKeys]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addOutputKey(outputKey: String) = apply { body.addOutputKey(outputKey) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ExampleUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .file() + * .inputKeys() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ExampleUpdateParams = + ExampleUpdateParams( + datasetId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Map<String, MultipartField<*>> = + (mapOf( + "file" to _file(), + "input_keys" to _inputKeys(), + "metadata_keys" to _metadataKeys(), + "output_keys" to _outputKeys(), + ) + _additionalBodyProperties().mapValues { (_, value) -> MultipartField.of(value) }) + .toImmutable() + + fun _pathParam(index: Int): String = + when (index) { + 0 -> datasetId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + private constructor( + private val file: MultipartField<InputStream>, + private val inputKeys: MultipartField<List<String>>, + private val metadataKeys: MultipartField<List<String>>, + private val outputKeys: MultipartField<List<String>>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun file(): InputStream = file.value.getRequired("file") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun inputKeys(): List<String> = inputKeys.value.getRequired("input_keys") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun metadataKeys(): Optional<List<String>> = metadataKeys.value.getOptional("metadata_keys") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun outputKeys(): Optional<List<String>> = outputKeys.value.getOptional("output_keys") + + /** + * Returns the raw multipart value of [file]. + * + * Unlike [file], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("file") @ExcludeMissing fun _file(): MultipartField<InputStream> = file + + /** + * Returns the raw multipart value of [inputKeys]. + * + * Unlike [inputKeys], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("input_keys") + @ExcludeMissing + fun _inputKeys(): MultipartField<List<String>> = inputKeys + + /** + * Returns the raw multipart value of [metadataKeys]. + * + * Unlike [metadataKeys], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("metadata_keys") + @ExcludeMissing + fun _metadataKeys(): MultipartField<List<String>> = metadataKeys + + /** + * Returns the raw multipart value of [outputKeys]. + * + * Unlike [outputKeys], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("output_keys") + @ExcludeMissing + fun _outputKeys(): MultipartField<List<String>> = outputKeys + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .file() + * .inputKeys() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var file: MultipartField<InputStream>? = null + private var inputKeys: MultipartField<MutableList<String>>? = null + private var metadataKeys: MultipartField<MutableList<String>>? = null + private var outputKeys: MultipartField<MutableList<String>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + file = body.file + inputKeys = body.inputKeys.map { it.toMutableList() } + metadataKeys = body.metadataKeys.map { it.toMutableList() } + outputKeys = body.outputKeys.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun file(file: InputStream) = file(MultipartField.of(file)) + + /** + * Sets [Builder.file] to an arbitrary multipart value. + * + * You should usually call [Builder.file] with a well-typed [InputStream] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun file(file: MultipartField<InputStream>) = apply { this.file = file } + + fun file(file: ByteArray) = file(file.inputStream()) + + fun file(path: Path) = + file( + MultipartField.builder<InputStream>() + .value(path.inputStream()) + .filename(path.name) + .build() + ) + + fun inputKeys(inputKeys: List<String>) = inputKeys(MultipartField.of(inputKeys)) + + /** + * Sets [Builder.inputKeys] to an arbitrary multipart value. + * + * You should usually call [Builder.inputKeys] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inputKeys(inputKeys: MultipartField<List<String>>) = apply { + this.inputKeys = inputKeys.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [inputKeys]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addInputKey(inputKey: String) = apply { + inputKeys = + (inputKeys ?: MultipartField.of(mutableListOf())).also { + checkKnown("inputKeys", it).add(inputKey) + } + } + + fun metadataKeys(metadataKeys: List<String>) = + metadataKeys(MultipartField.of(metadataKeys)) + + /** + * Sets [Builder.metadataKeys] to an arbitrary multipart value. + * + * You should usually call [Builder.metadataKeys] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadataKeys(metadataKeys: MultipartField<List<String>>) = apply { + this.metadataKeys = metadataKeys.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [metadataKeys]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMetadataKey(metadataKey: String) = apply { + metadataKeys = + (metadataKeys ?: MultipartField.of(mutableListOf())).also { + checkKnown("metadataKeys", it).add(metadataKey) + } + } + + fun outputKeys(outputKeys: List<String>) = outputKeys(MultipartField.of(outputKeys)) + + /** + * Sets [Builder.outputKeys] to an arbitrary multipart value. + * + * You should usually call [Builder.outputKeys] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun outputKeys(outputKeys: MultipartField<List<String>>) = apply { + this.outputKeys = outputKeys.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [outputKeys]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addOutputKey(outputKey: String) = apply { + outputKeys = + (outputKeys ?: MultipartField.of(mutableListOf())).also { + checkKnown("outputKeys", it).add(outputKey) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .file() + * .inputKeys() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("file", file), + checkRequired("inputKeys", inputKeys).map { it.toImmutable() }, + (metadataKeys ?: MultipartField.of(null)).map { it.toImmutable() }, + (outputKeys ?: MultipartField.of(null)).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + file() + inputKeys() + metadataKeys() + outputKeys() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + file == other.file && + inputKeys == other.inputKeys && + metadataKeys == other.metadataKeys && + outputKeys == other.outputKeys && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(file, inputKeys, metadataKeys, outputKeys, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{file=$file, inputKeys=$inputKeys, metadataKeys=$metadataKeys, outputKeys=$outputKeys, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExampleUpdateParams && + datasetId == other.datasetId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(datasetId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ExampleUpdateParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/bulk/BulkCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/bulk/BulkCreateParams.kt new file mode 100644 index 00000000..b509429d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/bulk/BulkCreateParams.kt @@ -0,0 +1,210 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.examples.bulk + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional + +/** Create a new example. */ +class BulkCreateParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): BulkCreateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [BulkCreateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkCreateParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkCreateParams: BulkCreateParams) = apply { + additionalHeaders = bulkCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = bulkCreateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = bulkCreateParams.additionalBodyProperties.toMutableMap() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [BulkCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BulkCreateParams = + BulkCreateParams( + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkCreateParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "BulkCreateParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/bulk/BulkCreateResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/bulk/BulkCreateResponse.kt new file mode 100644 index 00000000..5cff296a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/bulk/BulkCreateResponse.kt @@ -0,0 +1,113 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.examples.bulk + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class BulkCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [BulkCreateResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkCreateResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkCreateResponse: BulkCreateResponse) = apply { + additionalProperties = bulkCreateResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BulkCreateResponse = BulkCreateResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): BulkCreateResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkCreateResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "BulkCreateResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/bulk/BulkPatchAllParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/bulk/BulkPatchAllParams.kt new file mode 100644 index 00000000..70ad5438 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/bulk/BulkPatchAllParams.kt @@ -0,0 +1,776 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.examples.bulk + +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 com.langsmith_api.api.core.BaseDeserializer +import com.langsmith_api.api.core.BaseSerializer +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.allMaxBy +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.examples.AttachmentsOperations +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Legacy update examples in bulk. For update involving attachments, use PATCH + * /v1/platform/datasets/{dataset_id}/examples instead. + */ +class BulkPatchAllParams +private constructor( + private val body: List<Body>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun body(): List<Body> = body + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BulkPatchAllParams]. + * + * The following fields are required: + * ```java + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkPatchAllParams]. */ + class Builder internal constructor() { + + private var body: MutableList<Body>? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(bulkPatchAllParams: BulkPatchAllParams) = apply { + body = bulkPatchAllParams.body.toMutableList() + additionalHeaders = bulkPatchAllParams.additionalHeaders.toBuilder() + additionalQueryParams = bulkPatchAllParams.additionalQueryParams.toBuilder() + } + + fun body(body: List<Body>) = apply { this.body = body.toMutableList() } + + /** + * Adds a single [Body] to [Builder.body]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addBody(body: Body) = apply { + this.body = (this.body ?: mutableListOf()).apply { add(body) } + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [BulkPatchAllParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkPatchAllParams = + BulkPatchAllParams( + checkRequired("body", body).toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): List<Body> = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Bulk update class for Example (includes example id). */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField<String>, + private val attachmentsOperations: JsonField<AttachmentsOperations>, + private val datasetId: JsonField<String>, + private val inputs: JsonValue, + private val metadata: JsonValue, + private val outputs: JsonValue, + private val overwrite: JsonField<Boolean>, + private val split: JsonField<Split>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("attachments_operations") + @ExcludeMissing + attachmentsOperations: JsonField<AttachmentsOperations> = JsonMissing.of(), + @JsonProperty("dataset_id") + @ExcludeMissing + datasetId: JsonField<String> = JsonMissing.of(), + @JsonProperty("inputs") @ExcludeMissing inputs: JsonValue = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("outputs") @ExcludeMissing outputs: JsonValue = JsonMissing.of(), + @JsonProperty("overwrite") + @ExcludeMissing + overwrite: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("split") @ExcludeMissing split: JsonField<Split> = JsonMissing.of(), + ) : this( + id, + attachmentsOperations, + datasetId, + inputs, + metadata, + outputs, + overwrite, + split, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun attachmentsOperations(): Optional<AttachmentsOperations> = + attachmentsOperations.getOptional("attachments_operations") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun datasetId(): Optional<String> = datasetId.getOptional("dataset_id") + + @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonValue = inputs + + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + + @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonValue = outputs + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun overwrite(): Optional<Boolean> = overwrite.getOptional("overwrite") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun split(): Optional<Split> = split.getOptional("split") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [attachmentsOperations]. + * + * Unlike [attachmentsOperations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attachments_operations") + @ExcludeMissing + fun _attachmentsOperations(): JsonField<AttachmentsOperations> = attachmentsOperations + + /** + * Returns the raw JSON value of [datasetId]. + * + * Unlike [datasetId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField<String> = datasetId + + /** + * Returns the raw JSON value of [overwrite]. + * + * Unlike [overwrite], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("overwrite") @ExcludeMissing fun _overwrite(): JsonField<Boolean> = overwrite + + /** + * Returns the raw JSON value of [split]. + * + * Unlike [split], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("split") @ExcludeMissing fun _split(): JsonField<Split> = split + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var attachmentsOperations: JsonField<AttachmentsOperations> = JsonMissing.of() + private var datasetId: JsonField<String> = JsonMissing.of() + private var inputs: JsonValue = JsonMissing.of() + private var metadata: JsonValue = JsonMissing.of() + private var outputs: JsonValue = JsonMissing.of() + private var overwrite: JsonField<Boolean> = JsonMissing.of() + private var split: JsonField<Split> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + id = body.id + attachmentsOperations = body.attachmentsOperations + datasetId = body.datasetId + inputs = body.inputs + metadata = body.metadata + outputs = body.outputs + overwrite = body.overwrite + split = body.split + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun attachmentsOperations(attachmentsOperations: AttachmentsOperations?) = + attachmentsOperations(JsonField.ofNullable(attachmentsOperations)) + + /** + * Alias for calling [Builder.attachmentsOperations] with + * `attachmentsOperations.orElse(null)`. + */ + fun attachmentsOperations(attachmentsOperations: Optional<AttachmentsOperations>) = + attachmentsOperations(attachmentsOperations.getOrNull()) + + /** + * Sets [Builder.attachmentsOperations] to an arbitrary JSON value. + * + * You should usually call [Builder.attachmentsOperations] with a well-typed + * [AttachmentsOperations] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun attachmentsOperations(attachmentsOperations: JsonField<AttachmentsOperations>) = + apply { + this.attachmentsOperations = attachmentsOperations + } + + fun datasetId(datasetId: String?) = datasetId(JsonField.ofNullable(datasetId)) + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + /** + * Sets [Builder.datasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun datasetId(datasetId: JsonField<String>) = apply { this.datasetId = datasetId } + + fun inputs(inputs: JsonValue) = apply { this.inputs = inputs } + + fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + + fun outputs(outputs: JsonValue) = apply { this.outputs = outputs } + + fun overwrite(overwrite: Boolean) = overwrite(JsonField.of(overwrite)) + + /** + * Sets [Builder.overwrite] to an arbitrary JSON value. + * + * You should usually call [Builder.overwrite] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun overwrite(overwrite: JsonField<Boolean>) = apply { this.overwrite = overwrite } + + fun split(split: Split?) = split(JsonField.ofNullable(split)) + + /** Alias for calling [Builder.split] with `split.orElse(null)`. */ + fun split(split: Optional<Split>) = split(split.getOrNull()) + + /** + * Sets [Builder.split] to an arbitrary JSON value. + * + * You should usually call [Builder.split] with a well-typed [Split] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun split(split: JsonField<Split>) = apply { this.split = split } + + /** Alias for calling [split] with `Split.ofStrings(strings)`. */ + fun splitOfStrings(strings: List<String>) = split(Split.ofStrings(strings)) + + /** Alias for calling [split] with `Split.ofString(string)`. */ + fun split(string: String) = split(Split.ofString(string)) + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("id", id), + attachmentsOperations, + datasetId, + inputs, + metadata, + outputs, + overwrite, + split, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + id() + attachmentsOperations().ifPresent { it.validate() } + datasetId() + overwrite() + split().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (attachmentsOperations.asKnown().getOrNull()?.validity() ?: 0) + + (if (datasetId.asKnown().isPresent) 1 else 0) + + (if (overwrite.asKnown().isPresent) 1 else 0) + + (split.asKnown().getOrNull()?.validity() ?: 0) + + @JsonDeserialize(using = Split.Deserializer::class) + @JsonSerialize(using = Split.Serializer::class) + class Split + private constructor( + private val strings: List<String>? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun strings(): Optional<List<String>> = Optional.ofNullable(strings) + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun isStrings(): Boolean = strings != null + + fun isString(): Boolean = string != null + + fun asStrings(): List<String> = strings.getOrThrow("strings") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + strings != null -> visitor.visitStrings(strings) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Split = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitStrings(strings: List<String>) {} + + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitStrings(strings: List<String>) = strings.size + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Split && strings == other.strings && string == other.string + } + + override fun hashCode(): Int = Objects.hash(strings, string) + + override fun toString(): String = + when { + strings != null -> "Split{strings=$strings}" + string != null -> "Split{string=$string}" + _json != null -> "Split{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Split") + } + + companion object { + + @JvmStatic + fun ofStrings(strings: List<String>) = Split(strings = strings.toImmutable()) + + @JvmStatic fun ofString(string: String) = Split(string = string) + } + + /** + * An interface that defines how to map each variant of [Split] to a value of type [T]. + */ + interface Visitor<out T> { + + fun visitStrings(strings: List<String>): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [Split] to a value of type [T]. + * + * An instance of [Split] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Split: $json") + } + } + + internal class Deserializer : BaseDeserializer<Split>(Split::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Split { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<List<String>>())?.let { + Split(strings = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<String>())?.let { + Split(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> Split(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Split>(Split::class) { + + override fun serialize( + value: Split, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.strings != null -> generator.writeObject(value.strings) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Split") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + id == other.id && + attachmentsOperations == other.attachmentsOperations && + datasetId == other.datasetId && + inputs == other.inputs && + metadata == other.metadata && + outputs == other.outputs && + overwrite == other.overwrite && + split == other.split && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + attachmentsOperations, + datasetId, + inputs, + metadata, + outputs, + overwrite, + split, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{id=$id, attachmentsOperations=$attachmentsOperations, datasetId=$datasetId, inputs=$inputs, metadata=$metadata, outputs=$outputs, overwrite=$overwrite, split=$split, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkPatchAllParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "BulkPatchAllParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/bulk/BulkPatchAllResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/bulk/BulkPatchAllResponse.kt new file mode 100644 index 00000000..a41ea15e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/bulk/BulkPatchAllResponse.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.examples.bulk + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class BulkPatchAllResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [BulkPatchAllResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkPatchAllResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkPatchAllResponse: BulkPatchAllResponse) = apply { + additionalProperties = bulkPatchAllResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkPatchAllResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BulkPatchAllResponse = + BulkPatchAllResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): BulkPatchAllResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkPatchAllResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "BulkPatchAllResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/validate/ExampleValidationResult.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/validate/ExampleValidationResult.kt new file mode 100644 index 00000000..a9f3e946 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/validate/ExampleValidationResult.kt @@ -0,0 +1,622 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.examples.validate + +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 com.langsmith_api.api.core.BaseDeserializer +import com.langsmith_api.api.core.BaseSerializer +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.allMaxBy +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Validation result for Example, combining fields from Create/Base/Update schemas. */ +class ExampleValidationResult +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val datasetId: JsonField<String>, + private val inputs: JsonValue, + private val metadata: JsonValue, + private val outputs: JsonValue, + private val overwrite: JsonField<Boolean>, + private val sourceRunId: JsonField<String>, + private val split: JsonField<Split>, + private val useSourceRunIo: JsonField<Boolean>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("dataset_id") @ExcludeMissing datasetId: JsonField<String> = JsonMissing.of(), + @JsonProperty("inputs") @ExcludeMissing inputs: JsonValue = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("outputs") @ExcludeMissing outputs: JsonValue = JsonMissing.of(), + @JsonProperty("overwrite") @ExcludeMissing overwrite: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("source_run_id") + @ExcludeMissing + sourceRunId: JsonField<String> = JsonMissing.of(), + @JsonProperty("split") @ExcludeMissing split: JsonField<Split> = JsonMissing.of(), + @JsonProperty("use_source_run_io") + @ExcludeMissing + useSourceRunIo: JsonField<Boolean> = JsonMissing.of(), + ) : this( + id, + createdAt, + datasetId, + inputs, + metadata, + outputs, + overwrite, + sourceRunId, + split, + useSourceRunIo, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun createdAt(): Optional<OffsetDateTime> = createdAt.getOptional("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun datasetId(): Optional<String> = datasetId.getOptional("dataset_id") + + @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonValue = inputs + + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + + @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonValue = outputs + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun overwrite(): Optional<Boolean> = overwrite.getOptional("overwrite") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun sourceRunId(): Optional<String> = sourceRunId.getOptional("source_run_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun split(): Optional<Split> = split.getOptional("split") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun useSourceRunIo(): Optional<Boolean> = useSourceRunIo.getOptional("use_source_run_io") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [datasetId]. + * + * Unlike [datasetId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField<String> = datasetId + + /** + * Returns the raw JSON value of [overwrite]. + * + * Unlike [overwrite], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("overwrite") @ExcludeMissing fun _overwrite(): JsonField<Boolean> = overwrite + + /** + * Returns the raw JSON value of [sourceRunId]. + * + * Unlike [sourceRunId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("source_run_id") + @ExcludeMissing + fun _sourceRunId(): JsonField<String> = sourceRunId + + /** + * Returns the raw JSON value of [split]. + * + * Unlike [split], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("split") @ExcludeMissing fun _split(): JsonField<Split> = split + + /** + * Returns the raw JSON value of [useSourceRunIo]. + * + * Unlike [useSourceRunIo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("use_source_run_io") + @ExcludeMissing + fun _useSourceRunIo(): JsonField<Boolean> = useSourceRunIo + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ExampleValidationResult]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExampleValidationResult]. */ + class Builder internal constructor() { + + private var id: JsonField<String> = JsonMissing.of() + private var createdAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var datasetId: JsonField<String> = JsonMissing.of() + private var inputs: JsonValue = JsonMissing.of() + private var metadata: JsonValue = JsonMissing.of() + private var outputs: JsonValue = JsonMissing.of() + private var overwrite: JsonField<Boolean> = JsonMissing.of() + private var sourceRunId: JsonField<String> = JsonMissing.of() + private var split: JsonField<Split> = JsonMissing.of() + private var useSourceRunIo: JsonField<Boolean> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(exampleValidationResult: ExampleValidationResult) = apply { + id = exampleValidationResult.id + createdAt = exampleValidationResult.createdAt + datasetId = exampleValidationResult.datasetId + inputs = exampleValidationResult.inputs + metadata = exampleValidationResult.metadata + outputs = exampleValidationResult.outputs + overwrite = exampleValidationResult.overwrite + sourceRunId = exampleValidationResult.sourceRunId + split = exampleValidationResult.split + useSourceRunIo = exampleValidationResult.useSourceRunIo + additionalProperties = exampleValidationResult.additionalProperties.toMutableMap() + } + + fun id(id: String?) = id(JsonField.ofNullable(id)) + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<String>) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun createdAt(createdAt: OffsetDateTime?) = createdAt(JsonField.ofNullable(createdAt)) + + /** Alias for calling [Builder.createdAt] with `createdAt.orElse(null)`. */ + fun createdAt(createdAt: Optional<OffsetDateTime>) = createdAt(createdAt.getOrNull()) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun datasetId(datasetId: String?) = datasetId(JsonField.ofNullable(datasetId)) + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + /** + * Sets [Builder.datasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun datasetId(datasetId: JsonField<String>) = apply { this.datasetId = datasetId } + + fun inputs(inputs: JsonValue) = apply { this.inputs = inputs } + + fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + + fun outputs(outputs: JsonValue) = apply { this.outputs = outputs } + + fun overwrite(overwrite: Boolean) = overwrite(JsonField.of(overwrite)) + + /** + * Sets [Builder.overwrite] to an arbitrary JSON value. + * + * You should usually call [Builder.overwrite] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun overwrite(overwrite: JsonField<Boolean>) = apply { this.overwrite = overwrite } + + fun sourceRunId(sourceRunId: String?) = sourceRunId(JsonField.ofNullable(sourceRunId)) + + /** Alias for calling [Builder.sourceRunId] with `sourceRunId.orElse(null)`. */ + fun sourceRunId(sourceRunId: Optional<String>) = sourceRunId(sourceRunId.getOrNull()) + + /** + * Sets [Builder.sourceRunId] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceRunId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun sourceRunId(sourceRunId: JsonField<String>) = apply { this.sourceRunId = sourceRunId } + + fun split(split: Split?) = split(JsonField.ofNullable(split)) + + /** Alias for calling [Builder.split] with `split.orElse(null)`. */ + fun split(split: Optional<Split>) = split(split.getOrNull()) + + /** + * Sets [Builder.split] to an arbitrary JSON value. + * + * You should usually call [Builder.split] with a well-typed [Split] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun split(split: JsonField<Split>) = apply { this.split = split } + + /** Alias for calling [split] with `Split.ofStrings(strings)`. */ + fun splitOfStrings(strings: List<String>) = split(Split.ofStrings(strings)) + + /** Alias for calling [split] with `Split.ofString(string)`. */ + fun split(string: String) = split(Split.ofString(string)) + + fun useSourceRunIo(useSourceRunIo: Boolean) = useSourceRunIo(JsonField.of(useSourceRunIo)) + + /** + * Sets [Builder.useSourceRunIo] to an arbitrary JSON value. + * + * You should usually call [Builder.useSourceRunIo] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun useSourceRunIo(useSourceRunIo: JsonField<Boolean>) = apply { + this.useSourceRunIo = useSourceRunIo + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ExampleValidationResult]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ExampleValidationResult = + ExampleValidationResult( + id, + createdAt, + datasetId, + inputs, + metadata, + outputs, + overwrite, + sourceRunId, + split, + useSourceRunIo, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ExampleValidationResult = apply { + if (validated) { + return@apply + } + + id() + createdAt() + datasetId() + overwrite() + sourceRunId() + split().ifPresent { it.validate() } + useSourceRunIo() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (datasetId.asKnown().isPresent) 1 else 0) + + (if (overwrite.asKnown().isPresent) 1 else 0) + + (if (sourceRunId.asKnown().isPresent) 1 else 0) + + (split.asKnown().getOrNull()?.validity() ?: 0) + + (if (useSourceRunIo.asKnown().isPresent) 1 else 0) + + @JsonDeserialize(using = Split.Deserializer::class) + @JsonSerialize(using = Split.Serializer::class) + class Split + private constructor( + private val strings: List<String>? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun strings(): Optional<List<String>> = Optional.ofNullable(strings) + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun isStrings(): Boolean = strings != null + + fun isString(): Boolean = string != null + + fun asStrings(): List<String> = strings.getOrThrow("strings") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + strings != null -> visitor.visitStrings(strings) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Split = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitStrings(strings: List<String>) {} + + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitStrings(strings: List<String>) = strings.size + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Split && strings == other.strings && string == other.string + } + + override fun hashCode(): Int = Objects.hash(strings, string) + + override fun toString(): String = + when { + strings != null -> "Split{strings=$strings}" + string != null -> "Split{string=$string}" + _json != null -> "Split{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Split") + } + + companion object { + + @JvmStatic fun ofStrings(strings: List<String>) = Split(strings = strings.toImmutable()) + + @JvmStatic fun ofString(string: String) = Split(string = string) + } + + /** An interface that defines how to map each variant of [Split] to a value of type [T]. */ + interface Visitor<out T> { + + fun visitStrings(strings: List<String>): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [Split] to a value of type [T]. + * + * An instance of [Split] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Split: $json") + } + } + + internal class Deserializer : BaseDeserializer<Split>(Split::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Split { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<List<String>>())?.let { + Split(strings = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<String>())?.let { + Split(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> Split(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Split>(Split::class) { + + override fun serialize( + value: Split, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.strings != null -> generator.writeObject(value.strings) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Split") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExampleValidationResult && + id == other.id && + createdAt == other.createdAt && + datasetId == other.datasetId && + inputs == other.inputs && + metadata == other.metadata && + outputs == other.outputs && + overwrite == other.overwrite && + sourceRunId == other.sourceRunId && + split == other.split && + useSourceRunIo == other.useSourceRunIo && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + createdAt, + datasetId, + inputs, + metadata, + outputs, + overwrite, + sourceRunId, + split, + useSourceRunIo, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ExampleValidationResult{id=$id, createdAt=$createdAt, datasetId=$datasetId, inputs=$inputs, metadata=$metadata, outputs=$outputs, overwrite=$overwrite, sourceRunId=$sourceRunId, split=$split, useSourceRunIo=$useSourceRunIo, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/validate/ValidateBulkParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/validate/ValidateBulkParams.kt new file mode 100644 index 00000000..bf60498d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/validate/ValidateBulkParams.kt @@ -0,0 +1,210 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.examples.validate + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional + +/** Validate an example. */ +class ValidateBulkParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ValidateBulkParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ValidateBulkParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ValidateBulkParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(validateBulkParams: ValidateBulkParams) = apply { + additionalHeaders = validateBulkParams.additionalHeaders.toBuilder() + additionalQueryParams = validateBulkParams.additionalQueryParams.toBuilder() + additionalBodyProperties = validateBulkParams.additionalBodyProperties.toMutableMap() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [ValidateBulkParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ValidateBulkParams = + ValidateBulkParams( + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ValidateBulkParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "ValidateBulkParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/validate/ValidateCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/validate/ValidateCreateParams.kt new file mode 100644 index 00000000..d551c553 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/examples/validate/ValidateCreateParams.kt @@ -0,0 +1,210 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.examples.validate + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional + +/** Validate an example. */ +class ValidateCreateParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ValidateCreateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ValidateCreateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ValidateCreateParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(validateCreateParams: ValidateCreateParams) = apply { + additionalHeaders = validateCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = validateCreateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = validateCreateParams.additionalBodyProperties.toMutableMap() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [ValidateCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ValidateCreateParams = + ValidateCreateParams( + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ValidateCreateParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "ValidateCreateParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/ApiFeedbackSource.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/ApiFeedbackSource.kt new file mode 100644 index 00000000..f858b964 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/ApiFeedbackSource.kt @@ -0,0 +1,163 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional + +/** API feedback source. */ +class ApiFeedbackSource +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val metadata: JsonValue, + private val type: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField<String> = JsonMissing.of(), + ) : this(metadata, type, mutableMapOf()) + + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun type(): Optional<String> = type.getOptional("type") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField<String> = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ApiFeedbackSource]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ApiFeedbackSource]. */ + class Builder internal constructor() { + + private var metadata: JsonValue = JsonMissing.of() + private var type: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(apiFeedbackSource: ApiFeedbackSource) = apply { + metadata = apiFeedbackSource.metadata + type = apiFeedbackSource.type + additionalProperties = apiFeedbackSource.additionalProperties.toMutableMap() + } + + fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + + fun type(type: String) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField<String>) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ApiFeedbackSource]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ApiFeedbackSource = + ApiFeedbackSource(metadata, type, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): ApiFeedbackSource = apply { + if (validated) { + return@apply + } + + type() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (type.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ApiFeedbackSource && + metadata == other.metadata && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(metadata, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ApiFeedbackSource{metadata=$metadata, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/AppFeedbackSource.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/AppFeedbackSource.kt new file mode 100644 index 00000000..04eac5e0 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/AppFeedbackSource.kt @@ -0,0 +1,163 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional + +/** Feedback from the LangChainPlus App. */ +class AppFeedbackSource +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val metadata: JsonValue, + private val type: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField<String> = JsonMissing.of(), + ) : this(metadata, type, mutableMapOf()) + + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun type(): Optional<String> = type.getOptional("type") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField<String> = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [AppFeedbackSource]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AppFeedbackSource]. */ + class Builder internal constructor() { + + private var metadata: JsonValue = JsonMissing.of() + private var type: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(appFeedbackSource: AppFeedbackSource) = apply { + metadata = appFeedbackSource.metadata + type = appFeedbackSource.type + additionalProperties = appFeedbackSource.additionalProperties.toMutableMap() + } + + fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + + fun type(type: String) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField<String>) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AppFeedbackSource]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AppFeedbackSource = + AppFeedbackSource(metadata, type, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): AppFeedbackSource = apply { + if (validated) { + return@apply + } + + type() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (type.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AppFeedbackSource && + metadata == other.metadata && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(metadata, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AppFeedbackSource{metadata=$metadata, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/AutoEvalFeedbackSource.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/AutoEvalFeedbackSource.kt new file mode 100644 index 00000000..8b61487e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/AutoEvalFeedbackSource.kt @@ -0,0 +1,163 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional + +/** Auto eval feedback source. */ +class AutoEvalFeedbackSource +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val metadata: JsonValue, + private val type: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField<String> = JsonMissing.of(), + ) : this(metadata, type, mutableMapOf()) + + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun type(): Optional<String> = type.getOptional("type") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField<String> = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [AutoEvalFeedbackSource]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AutoEvalFeedbackSource]. */ + class Builder internal constructor() { + + private var metadata: JsonValue = JsonMissing.of() + private var type: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(autoEvalFeedbackSource: AutoEvalFeedbackSource) = apply { + metadata = autoEvalFeedbackSource.metadata + type = autoEvalFeedbackSource.type + additionalProperties = autoEvalFeedbackSource.additionalProperties.toMutableMap() + } + + fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + + fun type(type: String) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField<String>) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AutoEvalFeedbackSource]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AutoEvalFeedbackSource = + AutoEvalFeedbackSource(metadata, type, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): AutoEvalFeedbackSource = apply { + if (validated) { + return@apply + } + + type() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (type.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AutoEvalFeedbackSource && + metadata == other.metadata && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(metadata, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AutoEvalFeedbackSource{metadata=$metadata, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackCreateParams.kt new file mode 100644 index 00000000..e32b7c91 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackCreateParams.kt @@ -0,0 +1,206 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** Create a new feedback. */ +class FeedbackCreateParams +private constructor( + private val feedbackCreateSchema: FeedbackCreateSchema, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Schema used for creating feedback. */ + fun feedbackCreateSchema(): FeedbackCreateSchema = feedbackCreateSchema + + fun _additionalBodyProperties(): Map<String, JsonValue> = + feedbackCreateSchema._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [FeedbackCreateParams]. + * + * The following fields are required: + * ```java + * .feedbackCreateSchema() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackCreateParams]. */ + class Builder internal constructor() { + + private var feedbackCreateSchema: FeedbackCreateSchema? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(feedbackCreateParams: FeedbackCreateParams) = apply { + feedbackCreateSchema = feedbackCreateParams.feedbackCreateSchema + additionalHeaders = feedbackCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = feedbackCreateParams.additionalQueryParams.toBuilder() + } + + /** Schema used for creating feedback. */ + fun feedbackCreateSchema(feedbackCreateSchema: FeedbackCreateSchema) = apply { + this.feedbackCreateSchema = feedbackCreateSchema + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [FeedbackCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .feedbackCreateSchema() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FeedbackCreateParams = + FeedbackCreateParams( + checkRequired("feedbackCreateSchema", feedbackCreateSchema), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): FeedbackCreateSchema = feedbackCreateSchema + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackCreateParams && + feedbackCreateSchema == other.feedbackCreateSchema && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(feedbackCreateSchema, additionalHeaders, additionalQueryParams) + + override fun toString() = + "FeedbackCreateParams{feedbackCreateSchema=$feedbackCreateSchema, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackCreateSchema.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackCreateSchema.kt new file mode 100644 index 00000000..3e639adc --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackCreateSchema.kt @@ -0,0 +1,1626 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback + +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 com.langsmith_api.api.core.BaseDeserializer +import com.langsmith_api.api.core.BaseSerializer +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.allMaxBy +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfig +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Schema used for creating feedback. */ +class FeedbackCreateSchema +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val key: JsonField<String>, + private val id: JsonField<String>, + private val comment: JsonField<String>, + private val comparativeExperimentId: JsonField<String>, + private val correction: JsonField<Correction>, + private val createdAt: JsonField<OffsetDateTime>, + private val error: JsonField<Boolean>, + private val feedbackConfig: JsonField<FeedbackConfig>, + private val feedbackGroupId: JsonField<String>, + private val feedbackSource: JsonField<FeedbackSource>, + private val modifiedAt: JsonField<OffsetDateTime>, + private val runId: JsonField<String>, + private val score: JsonField<Score>, + private val sessionId: JsonField<String>, + private val traceId: JsonField<String>, + private val value: JsonField<Value>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("key") @ExcludeMissing key: JsonField<String> = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("comment") @ExcludeMissing comment: JsonField<String> = JsonMissing.of(), + @JsonProperty("comparative_experiment_id") + @ExcludeMissing + comparativeExperimentId: JsonField<String> = JsonMissing.of(), + @JsonProperty("correction") + @ExcludeMissing + correction: JsonField<Correction> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("error") @ExcludeMissing error: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("feedback_config") + @ExcludeMissing + feedbackConfig: JsonField<FeedbackConfig> = JsonMissing.of(), + @JsonProperty("feedback_group_id") + @ExcludeMissing + feedbackGroupId: JsonField<String> = JsonMissing.of(), + @JsonProperty("feedback_source") + @ExcludeMissing + feedbackSource: JsonField<FeedbackSource> = JsonMissing.of(), + @JsonProperty("modified_at") + @ExcludeMissing + modifiedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("run_id") @ExcludeMissing runId: JsonField<String> = JsonMissing.of(), + @JsonProperty("score") @ExcludeMissing score: JsonField<Score> = JsonMissing.of(), + @JsonProperty("session_id") @ExcludeMissing sessionId: JsonField<String> = JsonMissing.of(), + @JsonProperty("trace_id") @ExcludeMissing traceId: JsonField<String> = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField<Value> = JsonMissing.of(), + ) : this( + key, + id, + comment, + comparativeExperimentId, + correction, + createdAt, + error, + feedbackConfig, + feedbackGroupId, + feedbackSource, + modifiedAt, + runId, + score, + sessionId, + traceId, + value, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun key(): String = key.getRequired("key") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun comment(): Optional<String> = comment.getOptional("comment") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun comparativeExperimentId(): Optional<String> = + comparativeExperimentId.getOptional("comparative_experiment_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun correction(): Optional<Correction> = correction.getOptional("correction") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun createdAt(): Optional<OffsetDateTime> = createdAt.getOptional("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun error(): Optional<Boolean> = error.getOptional("error") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun feedbackConfig(): Optional<FeedbackConfig> = feedbackConfig.getOptional("feedback_config") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun feedbackGroupId(): Optional<String> = feedbackGroupId.getOptional("feedback_group_id") + + /** + * Feedback from the LangChainPlus App. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun feedbackSource(): Optional<FeedbackSource> = feedbackSource.getOptional("feedback_source") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun modifiedAt(): Optional<OffsetDateTime> = modifiedAt.getOptional("modified_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun runId(): Optional<String> = runId.getOptional("run_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun score(): Optional<Score> = score.getOptional("score") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun sessionId(): Optional<String> = sessionId.getOptional("session_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun traceId(): Optional<String> = traceId.getOptional("trace_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun value(): Optional<Value> = value.getOptional("value") + + /** + * Returns the raw JSON value of [key]. + * + * Unlike [key], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("key") @ExcludeMissing fun _key(): JsonField<String> = key + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [comment]. + * + * Unlike [comment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("comment") @ExcludeMissing fun _comment(): JsonField<String> = comment + + /** + * Returns the raw JSON value of [comparativeExperimentId]. + * + * Unlike [comparativeExperimentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("comparative_experiment_id") + @ExcludeMissing + fun _comparativeExperimentId(): JsonField<String> = comparativeExperimentId + + /** + * Returns the raw JSON value of [correction]. + * + * Unlike [correction], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("correction") + @ExcludeMissing + fun _correction(): JsonField<Correction> = correction + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [error]. + * + * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("error") @ExcludeMissing fun _error(): JsonField<Boolean> = error + + /** + * Returns the raw JSON value of [feedbackConfig]. + * + * Unlike [feedbackConfig], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feedback_config") + @ExcludeMissing + fun _feedbackConfig(): JsonField<FeedbackConfig> = feedbackConfig + + /** + * Returns the raw JSON value of [feedbackGroupId]. + * + * Unlike [feedbackGroupId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feedback_group_id") + @ExcludeMissing + fun _feedbackGroupId(): JsonField<String> = feedbackGroupId + + /** + * Returns the raw JSON value of [feedbackSource]. + * + * Unlike [feedbackSource], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feedback_source") + @ExcludeMissing + fun _feedbackSource(): JsonField<FeedbackSource> = feedbackSource + + /** + * Returns the raw JSON value of [modifiedAt]. + * + * Unlike [modifiedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("modified_at") + @ExcludeMissing + fun _modifiedAt(): JsonField<OffsetDateTime> = modifiedAt + + /** + * Returns the raw JSON value of [runId]. + * + * Unlike [runId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_id") @ExcludeMissing fun _runId(): JsonField<String> = runId + + /** + * Returns the raw JSON value of [score]. + * + * Unlike [score], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("score") @ExcludeMissing fun _score(): JsonField<Score> = score + + /** + * Returns the raw JSON value of [sessionId]. + * + * Unlike [sessionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session_id") @ExcludeMissing fun _sessionId(): JsonField<String> = sessionId + + /** + * Returns the raw JSON value of [traceId]. + * + * Unlike [traceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trace_id") @ExcludeMissing fun _traceId(): JsonField<String> = traceId + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField<Value> = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [FeedbackCreateSchema]. + * + * The following fields are required: + * ```java + * .key() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackCreateSchema]. */ + class Builder internal constructor() { + + private var key: JsonField<String>? = null + private var id: JsonField<String> = JsonMissing.of() + private var comment: JsonField<String> = JsonMissing.of() + private var comparativeExperimentId: JsonField<String> = JsonMissing.of() + private var correction: JsonField<Correction> = JsonMissing.of() + private var createdAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var error: JsonField<Boolean> = JsonMissing.of() + private var feedbackConfig: JsonField<FeedbackConfig> = JsonMissing.of() + private var feedbackGroupId: JsonField<String> = JsonMissing.of() + private var feedbackSource: JsonField<FeedbackSource> = JsonMissing.of() + private var modifiedAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var runId: JsonField<String> = JsonMissing.of() + private var score: JsonField<Score> = JsonMissing.of() + private var sessionId: JsonField<String> = JsonMissing.of() + private var traceId: JsonField<String> = JsonMissing.of() + private var value: JsonField<Value> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(feedbackCreateSchema: FeedbackCreateSchema) = apply { + key = feedbackCreateSchema.key + id = feedbackCreateSchema.id + comment = feedbackCreateSchema.comment + comparativeExperimentId = feedbackCreateSchema.comparativeExperimentId + correction = feedbackCreateSchema.correction + createdAt = feedbackCreateSchema.createdAt + error = feedbackCreateSchema.error + feedbackConfig = feedbackCreateSchema.feedbackConfig + feedbackGroupId = feedbackCreateSchema.feedbackGroupId + feedbackSource = feedbackCreateSchema.feedbackSource + modifiedAt = feedbackCreateSchema.modifiedAt + runId = feedbackCreateSchema.runId + score = feedbackCreateSchema.score + sessionId = feedbackCreateSchema.sessionId + traceId = feedbackCreateSchema.traceId + value = feedbackCreateSchema.value + additionalProperties = feedbackCreateSchema.additionalProperties.toMutableMap() + } + + fun key(key: String) = key(JsonField.of(key)) + + /** + * Sets [Builder.key] to an arbitrary JSON value. + * + * You should usually call [Builder.key] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun key(key: JsonField<String>) = apply { this.key = key } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun comment(comment: String?) = comment(JsonField.ofNullable(comment)) + + /** Alias for calling [Builder.comment] with `comment.orElse(null)`. */ + fun comment(comment: Optional<String>) = comment(comment.getOrNull()) + + /** + * Sets [Builder.comment] to an arbitrary JSON value. + * + * You should usually call [Builder.comment] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun comment(comment: JsonField<String>) = apply { this.comment = comment } + + fun comparativeExperimentId(comparativeExperimentId: String?) = + comparativeExperimentId(JsonField.ofNullable(comparativeExperimentId)) + + /** + * Alias for calling [Builder.comparativeExperimentId] with + * `comparativeExperimentId.orElse(null)`. + */ + fun comparativeExperimentId(comparativeExperimentId: Optional<String>) = + comparativeExperimentId(comparativeExperimentId.getOrNull()) + + /** + * Sets [Builder.comparativeExperimentId] to an arbitrary JSON value. + * + * You should usually call [Builder.comparativeExperimentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun comparativeExperimentId(comparativeExperimentId: JsonField<String>) = apply { + this.comparativeExperimentId = comparativeExperimentId + } + + fun correction(correction: Correction?) = correction(JsonField.ofNullable(correction)) + + /** Alias for calling [Builder.correction] with `correction.orElse(null)`. */ + fun correction(correction: Optional<Correction>) = correction(correction.getOrNull()) + + /** + * Sets [Builder.correction] to an arbitrary JSON value. + * + * You should usually call [Builder.correction] with a well-typed [Correction] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun correction(correction: JsonField<Correction>) = apply { this.correction = correction } + + /** Alias for calling [correction] with `Correction.ofJsonValue(jsonValue)`. */ + fun correction(jsonValue: JsonValue) = correction(Correction.ofJsonValue(jsonValue)) + + /** Alias for calling [correction] with `Correction.ofString(string)`. */ + fun correction(string: String) = correction(Correction.ofString(string)) + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun error(error: Boolean?) = error(JsonField.ofNullable(error)) + + /** + * Alias for [Builder.error]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun error(error: Boolean) = error(error as Boolean?) + + /** Alias for calling [Builder.error] with `error.orElse(null)`. */ + fun error(error: Optional<Boolean>) = error(error.getOrNull()) + + /** + * Sets [Builder.error] to an arbitrary JSON value. + * + * You should usually call [Builder.error] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun error(error: JsonField<Boolean>) = apply { this.error = error } + + fun feedbackConfig(feedbackConfig: FeedbackConfig?) = + feedbackConfig(JsonField.ofNullable(feedbackConfig)) + + /** Alias for calling [Builder.feedbackConfig] with `feedbackConfig.orElse(null)`. */ + fun feedbackConfig(feedbackConfig: Optional<FeedbackConfig>) = + feedbackConfig(feedbackConfig.getOrNull()) + + /** + * Sets [Builder.feedbackConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackConfig] with a well-typed [FeedbackConfig] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun feedbackConfig(feedbackConfig: JsonField<FeedbackConfig>) = apply { + this.feedbackConfig = feedbackConfig + } + + fun feedbackGroupId(feedbackGroupId: String?) = + feedbackGroupId(JsonField.ofNullable(feedbackGroupId)) + + /** Alias for calling [Builder.feedbackGroupId] with `feedbackGroupId.orElse(null)`. */ + fun feedbackGroupId(feedbackGroupId: Optional<String>) = + feedbackGroupId(feedbackGroupId.getOrNull()) + + /** + * Sets [Builder.feedbackGroupId] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackGroupId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun feedbackGroupId(feedbackGroupId: JsonField<String>) = apply { + this.feedbackGroupId = feedbackGroupId + } + + /** Feedback from the LangChainPlus App. */ + fun feedbackSource(feedbackSource: FeedbackSource?) = + feedbackSource(JsonField.ofNullable(feedbackSource)) + + /** Alias for calling [Builder.feedbackSource] with `feedbackSource.orElse(null)`. */ + fun feedbackSource(feedbackSource: Optional<FeedbackSource>) = + feedbackSource(feedbackSource.getOrNull()) + + /** + * Sets [Builder.feedbackSource] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackSource] with a well-typed [FeedbackSource] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun feedbackSource(feedbackSource: JsonField<FeedbackSource>) = apply { + this.feedbackSource = feedbackSource + } + + /** Alias for calling [feedbackSource] with `FeedbackSource.ofApp(app)`. */ + fun feedbackSource(app: AppFeedbackSource) = feedbackSource(FeedbackSource.ofApp(app)) + + /** Alias for calling [feedbackSource] with `FeedbackSource.ofApi(api)`. */ + fun feedbackSource(api: ApiFeedbackSource) = feedbackSource(FeedbackSource.ofApi(api)) + + /** Alias for calling [feedbackSource] with `FeedbackSource.ofModel(model)`. */ + fun feedbackSource(model: ModelFeedbackSource) = + feedbackSource(FeedbackSource.ofModel(model)) + + /** Alias for calling [feedbackSource] with `FeedbackSource.ofAutoEval(autoEval)`. */ + fun feedbackSource(autoEval: AutoEvalFeedbackSource) = + feedbackSource(FeedbackSource.ofAutoEval(autoEval)) + + fun modifiedAt(modifiedAt: OffsetDateTime) = modifiedAt(JsonField.of(modifiedAt)) + + /** + * Sets [Builder.modifiedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.modifiedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modifiedAt(modifiedAt: JsonField<OffsetDateTime>) = apply { + this.modifiedAt = modifiedAt + } + + fun runId(runId: String?) = runId(JsonField.ofNullable(runId)) + + /** Alias for calling [Builder.runId] with `runId.orElse(null)`. */ + fun runId(runId: Optional<String>) = runId(runId.getOrNull()) + + /** + * Sets [Builder.runId] to an arbitrary JSON value. + * + * You should usually call [Builder.runId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun runId(runId: JsonField<String>) = apply { this.runId = runId } + + fun score(score: Score?) = score(JsonField.ofNullable(score)) + + /** Alias for calling [Builder.score] with `score.orElse(null)`. */ + fun score(score: Optional<Score>) = score(score.getOrNull()) + + /** + * Sets [Builder.score] to an arbitrary JSON value. + * + * You should usually call [Builder.score] with a well-typed [Score] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun score(score: JsonField<Score>) = apply { this.score = score } + + /** Alias for calling [score] with `Score.ofNumber(number)`. */ + fun score(number: Double) = score(Score.ofNumber(number)) + + /** Alias for calling [score] with `Score.ofBool(bool)`. */ + fun score(bool: Boolean) = score(Score.ofBool(bool)) + + fun sessionId(sessionId: String?) = sessionId(JsonField.ofNullable(sessionId)) + + /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ + fun sessionId(sessionId: Optional<String>) = sessionId(sessionId.getOrNull()) + + /** + * Sets [Builder.sessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun sessionId(sessionId: JsonField<String>) = apply { this.sessionId = sessionId } + + fun traceId(traceId: String?) = traceId(JsonField.ofNullable(traceId)) + + /** Alias for calling [Builder.traceId] with `traceId.orElse(null)`. */ + fun traceId(traceId: Optional<String>) = traceId(traceId.getOrNull()) + + /** + * Sets [Builder.traceId] to an arbitrary JSON value. + * + * You should usually call [Builder.traceId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun traceId(traceId: JsonField<String>) = apply { this.traceId = traceId } + + fun value(value: Value?) = value(JsonField.ofNullable(value)) + + /** Alias for calling [Builder.value] with `value.orElse(null)`. */ + fun value(value: Optional<Value>) = value(value.getOrNull()) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Value] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun value(value: JsonField<Value>) = apply { this.value = value } + + /** Alias for calling [value] with `Value.ofNumber(number)`. */ + fun value(number: Double) = value(Value.ofNumber(number)) + + /** Alias for calling [value] with `Value.ofBool(bool)`. */ + fun value(bool: Boolean) = value(Value.ofBool(bool)) + + /** Alias for calling [value] with `Value.ofString(string)`. */ + fun value(string: String) = value(Value.ofString(string)) + + /** Alias for calling [value] with `Value.ofJson(json)`. */ + fun value(json: JsonValue) = value(Value.ofJson(json)) + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FeedbackCreateSchema]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .key() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FeedbackCreateSchema = + FeedbackCreateSchema( + checkRequired("key", key), + id, + comment, + comparativeExperimentId, + correction, + createdAt, + error, + feedbackConfig, + feedbackGroupId, + feedbackSource, + modifiedAt, + runId, + score, + sessionId, + traceId, + value, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): FeedbackCreateSchema = apply { + if (validated) { + return@apply + } + + key() + id() + comment() + comparativeExperimentId() + correction().ifPresent { it.validate() } + createdAt() + error() + feedbackConfig().ifPresent { it.validate() } + feedbackGroupId() + feedbackSource().ifPresent { it.validate() } + modifiedAt() + runId() + score().ifPresent { it.validate() } + sessionId() + traceId() + value().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (key.asKnown().isPresent) 1 else 0) + + (if (id.asKnown().isPresent) 1 else 0) + + (if (comment.asKnown().isPresent) 1 else 0) + + (if (comparativeExperimentId.asKnown().isPresent) 1 else 0) + + (correction.asKnown().getOrNull()?.validity() ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (error.asKnown().isPresent) 1 else 0) + + (feedbackConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (feedbackGroupId.asKnown().isPresent) 1 else 0) + + (feedbackSource.asKnown().getOrNull()?.validity() ?: 0) + + (if (modifiedAt.asKnown().isPresent) 1 else 0) + + (if (runId.asKnown().isPresent) 1 else 0) + + (score.asKnown().getOrNull()?.validity() ?: 0) + + (if (sessionId.asKnown().isPresent) 1 else 0) + + (if (traceId.asKnown().isPresent) 1 else 0) + + (value.asKnown().getOrNull()?.validity() ?: 0) + + @JsonDeserialize(using = Correction.Deserializer::class) + @JsonSerialize(using = Correction.Serializer::class) + class Correction + private constructor( + private val jsonValue: JsonValue? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun jsonValue(): Optional<JsonValue> = Optional.ofNullable(jsonValue) + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun isJsonValue(): Boolean = jsonValue != null + + fun isString(): Boolean = string != null + + fun asJsonValue(): JsonValue = jsonValue.getOrThrow("jsonValue") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + jsonValue != null -> visitor.visitJsonValue(jsonValue) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Correction = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitJsonValue(jsonValue: JsonValue) {} + + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Correction && jsonValue == other.jsonValue && string == other.string + } + + override fun hashCode(): Int = Objects.hash(jsonValue, string) + + override fun toString(): String = + when { + jsonValue != null -> "Correction{jsonValue=$jsonValue}" + string != null -> "Correction{string=$string}" + _json != null -> "Correction{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Correction") + } + + companion object { + + @JvmStatic fun ofJsonValue(jsonValue: JsonValue) = Correction(jsonValue = jsonValue) + + @JvmStatic fun ofString(string: String) = Correction(string = string) + } + + /** + * An interface that defines how to map each variant of [Correction] to a value of type [T]. + */ + interface Visitor<out T> { + + fun visitJsonValue(jsonValue: JsonValue): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [Correction] to a value of type [T]. + * + * An instance of [Correction] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Correction: $json") + } + } + + internal class Deserializer : BaseDeserializer<Correction>(Correction::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Correction { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<String>())?.let { + Correction(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<JsonValue>())?.let { + Correction(jsonValue = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants. + 0 -> Correction(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Correction>(Correction::class) { + + override fun serialize( + value: Correction, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.jsonValue != null -> generator.writeObject(value.jsonValue) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Correction") + } + } + } + } + + /** Feedback from the LangChainPlus App. */ + @JsonDeserialize(using = FeedbackSource.Deserializer::class) + @JsonSerialize(using = FeedbackSource.Serializer::class) + class FeedbackSource + private constructor( + private val app: AppFeedbackSource? = null, + private val api: ApiFeedbackSource? = null, + private val model: ModelFeedbackSource? = null, + private val autoEval: AutoEvalFeedbackSource? = null, + private val _json: JsonValue? = null, + ) { + + /** Feedback from the LangChainPlus App. */ + fun app(): Optional<AppFeedbackSource> = Optional.ofNullable(app) + + /** API feedback source. */ + fun api(): Optional<ApiFeedbackSource> = Optional.ofNullable(api) + + /** Model feedback source. */ + fun model(): Optional<ModelFeedbackSource> = Optional.ofNullable(model) + + /** Auto eval feedback source. */ + fun autoEval(): Optional<AutoEvalFeedbackSource> = Optional.ofNullable(autoEval) + + fun isApp(): Boolean = app != null + + fun isApi(): Boolean = api != null + + fun isModel(): Boolean = model != null + + fun isAutoEval(): Boolean = autoEval != null + + /** Feedback from the LangChainPlus App. */ + fun asApp(): AppFeedbackSource = app.getOrThrow("app") + + /** API feedback source. */ + fun asApi(): ApiFeedbackSource = api.getOrThrow("api") + + /** Model feedback source. */ + fun asModel(): ModelFeedbackSource = model.getOrThrow("model") + + /** Auto eval feedback source. */ + fun asAutoEval(): AutoEvalFeedbackSource = autoEval.getOrThrow("autoEval") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + app != null -> visitor.visitApp(app) + api != null -> visitor.visitApi(api) + model != null -> visitor.visitModel(model) + autoEval != null -> visitor.visitAutoEval(autoEval) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): FeedbackSource = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitApp(app: AppFeedbackSource) { + app.validate() + } + + override fun visitApi(api: ApiFeedbackSource) { + api.validate() + } + + override fun visitModel(model: ModelFeedbackSource) { + model.validate() + } + + override fun visitAutoEval(autoEval: AutoEvalFeedbackSource) { + autoEval.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitApp(app: AppFeedbackSource) = app.validity() + + override fun visitApi(api: ApiFeedbackSource) = api.validity() + + override fun visitModel(model: ModelFeedbackSource) = model.validity() + + override fun visitAutoEval(autoEval: AutoEvalFeedbackSource) = + autoEval.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackSource && + app == other.app && + api == other.api && + model == other.model && + autoEval == other.autoEval + } + + override fun hashCode(): Int = Objects.hash(app, api, model, autoEval) + + override fun toString(): String = + when { + app != null -> "FeedbackSource{app=$app}" + api != null -> "FeedbackSource{api=$api}" + model != null -> "FeedbackSource{model=$model}" + autoEval != null -> "FeedbackSource{autoEval=$autoEval}" + _json != null -> "FeedbackSource{_unknown=$_json}" + else -> throw IllegalStateException("Invalid FeedbackSource") + } + + companion object { + + /** Feedback from the LangChainPlus App. */ + @JvmStatic fun ofApp(app: AppFeedbackSource) = FeedbackSource(app = app) + + /** API feedback source. */ + @JvmStatic fun ofApi(api: ApiFeedbackSource) = FeedbackSource(api = api) + + /** Model feedback source. */ + @JvmStatic fun ofModel(model: ModelFeedbackSource) = FeedbackSource(model = model) + + /** Auto eval feedback source. */ + @JvmStatic + fun ofAutoEval(autoEval: AutoEvalFeedbackSource) = FeedbackSource(autoEval = autoEval) + } + + /** + * An interface that defines how to map each variant of [FeedbackSource] to a value of type + * [T]. + */ + interface Visitor<out T> { + + /** Feedback from the LangChainPlus App. */ + fun visitApp(app: AppFeedbackSource): T + + /** API feedback source. */ + fun visitApi(api: ApiFeedbackSource): T + + /** Model feedback source. */ + fun visitModel(model: ModelFeedbackSource): T + + /** Auto eval feedback source. */ + fun visitAutoEval(autoEval: AutoEvalFeedbackSource): T + + /** + * Maps an unknown variant of [FeedbackSource] to a value of type [T]. + * + * An instance of [FeedbackSource] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown FeedbackSource: $json") + } + } + + internal class Deserializer : BaseDeserializer<FeedbackSource>(FeedbackSource::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): FeedbackSource { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<AppFeedbackSource>())?.let { + FeedbackSource(app = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<ApiFeedbackSource>())?.let { + FeedbackSource(api = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<ModelFeedbackSource>())?.let { + FeedbackSource(model = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<AutoEvalFeedbackSource>())?.let { + FeedbackSource(autoEval = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> FeedbackSource(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<FeedbackSource>(FeedbackSource::class) { + + override fun serialize( + value: FeedbackSource, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.app != null -> generator.writeObject(value.app) + value.api != null -> generator.writeObject(value.api) + value.model != null -> generator.writeObject(value.model) + value.autoEval != null -> generator.writeObject(value.autoEval) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FeedbackSource") + } + } + } + } + + @JsonDeserialize(using = Score.Deserializer::class) + @JsonSerialize(using = Score.Serializer::class) + class Score + private constructor( + private val number: Double? = null, + private val bool: Boolean? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional<Double> = Optional.ofNullable(number) + + fun bool(): Optional<Boolean> = Optional.ofNullable(bool) + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Score = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Score && number == other.number && bool == other.bool + } + + override fun hashCode(): Int = Objects.hash(number, bool) + + override fun toString(): String = + when { + number != null -> "Score{number=$number}" + bool != null -> "Score{bool=$bool}" + _json != null -> "Score{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Score") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Score(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = Score(bool = bool) + } + + /** An interface that defines how to map each variant of [Score] to a value of type [T]. */ + interface Visitor<out T> { + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Maps an unknown variant of [Score] to a value of type [T]. + * + * An instance of [Score] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Score: $json") + } + } + + internal class Deserializer : BaseDeserializer<Score>(Score::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Score { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<Double>())?.let { + Score(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<Boolean>())?.let { + Score(bool = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from string). + 0 -> Score(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Score>(Score::class) { + + override fun serialize( + value: Score, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Score") + } + } + } + } + + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val number: Double? = null, + private val bool: Boolean? = null, + private val string: String? = null, + private val json: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional<Double> = Optional.ofNullable(number) + + fun bool(): Optional<Boolean> = Optional.ofNullable(bool) + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun json(): Optional<JsonValue> = Optional.ofNullable(json) + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun isString(): Boolean = string != null + + fun isJson(): Boolean = json != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun asString(): String = string.getOrThrow("string") + + fun asJson(): JsonValue = json.getOrThrow("json") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + string != null -> visitor.visitString(string) + json != null -> visitor.visitJson(json) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Value = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + + override fun visitString(string: String) {} + + override fun visitJson(json: JsonValue) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun visitString(string: String) = 1 + + override fun visitJson(json: JsonValue) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + number == other.number && + bool == other.bool && + string == other.string && + json == other.json + } + + override fun hashCode(): Int = Objects.hash(number, bool, string, json) + + override fun toString(): String = + when { + number != null -> "Value{number=$number}" + bool != null -> "Value{bool=$bool}" + string != null -> "Value{string=$string}" + json != null -> "Value{json=$json}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Value(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofJson(json: JsonValue) = Value(json = json) + } + + /** An interface that defines how to map each variant of [Value] to a value of type [T]. */ + interface Visitor<out T> { + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + fun visitString(string: String): T + + fun visitJson(json: JsonValue): T + + /** + * Maps an unknown variant of [Value] to a value of type [T]. + * + * An instance of [Value] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Value: $json") + } + } + + internal class Deserializer : BaseDeserializer<Value>(Value::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Value { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<Double>())?.let { + Value(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<Boolean>())?.let { + Value(bool = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<String>())?.let { + Value(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<JsonValue>())?.let { + Value(json = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants. + 0 -> Value(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Value>(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value.string != null -> generator.writeObject(value.string) + value.json != null -> generator.writeObject(value.json) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackCreateSchema && + key == other.key && + id == other.id && + comment == other.comment && + comparativeExperimentId == other.comparativeExperimentId && + correction == other.correction && + createdAt == other.createdAt && + error == other.error && + feedbackConfig == other.feedbackConfig && + feedbackGroupId == other.feedbackGroupId && + feedbackSource == other.feedbackSource && + modifiedAt == other.modifiedAt && + runId == other.runId && + score == other.score && + sessionId == other.sessionId && + traceId == other.traceId && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + key, + id, + comment, + comparativeExperimentId, + correction, + createdAt, + error, + feedbackConfig, + feedbackGroupId, + feedbackSource, + modifiedAt, + runId, + score, + sessionId, + traceId, + value, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FeedbackCreateSchema{key=$key, id=$id, comment=$comment, comparativeExperimentId=$comparativeExperimentId, correction=$correction, createdAt=$createdAt, error=$error, feedbackConfig=$feedbackConfig, feedbackGroupId=$feedbackGroupId, feedbackSource=$feedbackSource, modifiedAt=$modifiedAt, runId=$runId, score=$score, sessionId=$sessionId, traceId=$traceId, value=$value, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackDeleteParams.kt new file mode 100644 index 00000000..760e4362 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackDeleteParams.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete a feedback. */ +class FeedbackDeleteParams +private constructor( + private val feedbackId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun feedbackId(): Optional<String> = Optional.ofNullable(feedbackId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): FeedbackDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [FeedbackDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackDeleteParams]. */ + class Builder internal constructor() { + + private var feedbackId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(feedbackDeleteParams: FeedbackDeleteParams) = apply { + feedbackId = feedbackDeleteParams.feedbackId + additionalHeaders = feedbackDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = feedbackDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = feedbackDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun feedbackId(feedbackId: String?) = apply { this.feedbackId = feedbackId } + + /** Alias for calling [Builder.feedbackId] with `feedbackId.orElse(null)`. */ + fun feedbackId(feedbackId: Optional<String>) = feedbackId(feedbackId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [FeedbackDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FeedbackDeleteParams = + FeedbackDeleteParams( + feedbackId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> feedbackId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackDeleteParams && + feedbackId == other.feedbackId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(feedbackId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "FeedbackDeleteParams{feedbackId=$feedbackId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackDeleteResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackDeleteResponse.kt new file mode 100644 index 00000000..f2a2a670 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackDeleteResponse.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class FeedbackDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [FeedbackDeleteResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackDeleteResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(feedbackDeleteResponse: FeedbackDeleteResponse) = apply { + additionalProperties = feedbackDeleteResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FeedbackDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FeedbackDeleteResponse = + FeedbackDeleteResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): FeedbackDeleteResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackDeleteResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "FeedbackDeleteResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackEagerParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackEagerParams.kt new file mode 100644 index 00000000..dfaf976a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackEagerParams.kt @@ -0,0 +1,211 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** + * Create a new feedback. + * + * This method is invoked under the assumption that the run is already visible in the app, thus + * already present in DB + */ +class FeedbackEagerParams +private constructor( + private val feedbackCreateSchema: FeedbackCreateSchema, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Schema used for creating feedback. */ + fun feedbackCreateSchema(): FeedbackCreateSchema = feedbackCreateSchema + + fun _additionalBodyProperties(): Map<String, JsonValue> = + feedbackCreateSchema._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [FeedbackEagerParams]. + * + * The following fields are required: + * ```java + * .feedbackCreateSchema() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackEagerParams]. */ + class Builder internal constructor() { + + private var feedbackCreateSchema: FeedbackCreateSchema? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(feedbackEagerParams: FeedbackEagerParams) = apply { + feedbackCreateSchema = feedbackEagerParams.feedbackCreateSchema + additionalHeaders = feedbackEagerParams.additionalHeaders.toBuilder() + additionalQueryParams = feedbackEagerParams.additionalQueryParams.toBuilder() + } + + /** Schema used for creating feedback. */ + fun feedbackCreateSchema(feedbackCreateSchema: FeedbackCreateSchema) = apply { + this.feedbackCreateSchema = feedbackCreateSchema + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [FeedbackEagerParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .feedbackCreateSchema() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FeedbackEagerParams = + FeedbackEagerParams( + checkRequired("feedbackCreateSchema", feedbackCreateSchema), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): FeedbackCreateSchema = feedbackCreateSchema + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackEagerParams && + feedbackCreateSchema == other.feedbackCreateSchema && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(feedbackCreateSchema, additionalHeaders, additionalQueryParams) + + override fun toString() = + "FeedbackEagerParams{feedbackCreateSchema=$feedbackCreateSchema, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackLevel.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackLevel.kt new file mode 100644 index 00000000..105e6eca --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackLevel.kt @@ -0,0 +1,136 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback + +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException + +/** Enum for feedback levels. */ +class FeedbackLevel @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't match + * any known member, and you want to know that value. For example, if the SDK is on an older + * version than the API, then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val RUN = of("run") + + @JvmField val SESSION = of("session") + + @JvmStatic fun of(value: String) = FeedbackLevel(JsonField.of(value)) + } + + /** An enum containing [FeedbackLevel]'s known values. */ + enum class Known { + RUN, + SESSION, + } + + /** + * An enum containing [FeedbackLevel]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [FeedbackLevel] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the SDK + * is on an older version than the API, then the API may respond with new members that the SDK + * is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + RUN, + SESSION, + /** + * An enum member indicating that [FeedbackLevel] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if + * the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want to + * throw for the unknown case. + */ + fun value(): Value = + when (this) { + RUN -> Value.RUN + SESSION -> Value.SESSION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't want + * to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + RUN -> Known.RUN + SESSION -> Known.SESSION + else -> throw LangsmithApiInvalidDataException("Unknown FeedbackLevel: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): FeedbackLevel = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackLevel && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackListParams.kt new file mode 100644 index 00000000..f7d6d546 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackListParams.kt @@ -0,0 +1,461 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** List all Feedback by query params. */ +class FeedbackListParams +private constructor( + private val hasComment: Boolean?, + private val hasScore: Boolean?, + private val includeUserNames: Boolean?, + private val key: List<String>?, + private val level: FeedbackLevel?, + private val limit: Long?, + private val maxCreatedAt: OffsetDateTime?, + private val minCreatedAt: OffsetDateTime?, + private val offset: Long?, + private val run: List<String>?, + private val session: List<String>?, + private val source: List<SourceType>?, + private val user: List<String>?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun hasComment(): Optional<Boolean> = Optional.ofNullable(hasComment) + + fun hasScore(): Optional<Boolean> = Optional.ofNullable(hasScore) + + fun includeUserNames(): Optional<Boolean> = Optional.ofNullable(includeUserNames) + + fun key(): Optional<List<String>> = Optional.ofNullable(key) + + /** Enum for feedback levels. */ + fun level(): Optional<FeedbackLevel> = Optional.ofNullable(level) + + fun limit(): Optional<Long> = Optional.ofNullable(limit) + + fun maxCreatedAt(): Optional<OffsetDateTime> = Optional.ofNullable(maxCreatedAt) + + fun minCreatedAt(): Optional<OffsetDateTime> = Optional.ofNullable(minCreatedAt) + + fun offset(): Optional<Long> = Optional.ofNullable(offset) + + fun run(): Optional<List<String>> = Optional.ofNullable(run) + + fun session(): Optional<List<String>> = Optional.ofNullable(session) + + fun source(): Optional<List<SourceType>> = Optional.ofNullable(source) + + fun user(): Optional<List<String>> = Optional.ofNullable(user) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): FeedbackListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [FeedbackListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackListParams]. */ + class Builder internal constructor() { + + private var hasComment: Boolean? = null + private var hasScore: Boolean? = null + private var includeUserNames: Boolean? = null + private var key: MutableList<String>? = null + private var level: FeedbackLevel? = null + private var limit: Long? = null + private var maxCreatedAt: OffsetDateTime? = null + private var minCreatedAt: OffsetDateTime? = null + private var offset: Long? = null + private var run: MutableList<String>? = null + private var session: MutableList<String>? = null + private var source: MutableList<SourceType>? = null + private var user: MutableList<String>? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(feedbackListParams: FeedbackListParams) = apply { + hasComment = feedbackListParams.hasComment + hasScore = feedbackListParams.hasScore + includeUserNames = feedbackListParams.includeUserNames + key = feedbackListParams.key?.toMutableList() + level = feedbackListParams.level + limit = feedbackListParams.limit + maxCreatedAt = feedbackListParams.maxCreatedAt + minCreatedAt = feedbackListParams.minCreatedAt + offset = feedbackListParams.offset + run = feedbackListParams.run?.toMutableList() + session = feedbackListParams.session?.toMutableList() + source = feedbackListParams.source?.toMutableList() + user = feedbackListParams.user?.toMutableList() + additionalHeaders = feedbackListParams.additionalHeaders.toBuilder() + additionalQueryParams = feedbackListParams.additionalQueryParams.toBuilder() + } + + fun hasComment(hasComment: Boolean?) = apply { this.hasComment = hasComment } + + /** + * Alias for [Builder.hasComment]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun hasComment(hasComment: Boolean) = hasComment(hasComment as Boolean?) + + /** Alias for calling [Builder.hasComment] with `hasComment.orElse(null)`. */ + fun hasComment(hasComment: Optional<Boolean>) = hasComment(hasComment.getOrNull()) + + fun hasScore(hasScore: Boolean?) = apply { this.hasScore = hasScore } + + /** + * Alias for [Builder.hasScore]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun hasScore(hasScore: Boolean) = hasScore(hasScore as Boolean?) + + /** Alias for calling [Builder.hasScore] with `hasScore.orElse(null)`. */ + fun hasScore(hasScore: Optional<Boolean>) = hasScore(hasScore.getOrNull()) + + fun includeUserNames(includeUserNames: Boolean?) = apply { + this.includeUserNames = includeUserNames + } + + /** + * Alias for [Builder.includeUserNames]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun includeUserNames(includeUserNames: Boolean) = + includeUserNames(includeUserNames as Boolean?) + + /** Alias for calling [Builder.includeUserNames] with `includeUserNames.orElse(null)`. */ + fun includeUserNames(includeUserNames: Optional<Boolean>) = + includeUserNames(includeUserNames.getOrNull()) + + fun key(key: List<String>?) = apply { this.key = key?.toMutableList() } + + /** Alias for calling [Builder.key] with `key.orElse(null)`. */ + fun key(key: Optional<List<String>>) = key(key.getOrNull()) + + /** + * Adds a single [String] to [Builder.key]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addKey(key: String) = apply { + this.key = (this.key ?: mutableListOf()).apply { add(key) } + } + + /** Enum for feedback levels. */ + fun level(level: FeedbackLevel?) = apply { this.level = level } + + /** Alias for calling [Builder.level] with `level.orElse(null)`. */ + fun level(level: Optional<FeedbackLevel>) = level(level.getOrNull()) + + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional<Long>) = limit(limit.getOrNull()) + + fun maxCreatedAt(maxCreatedAt: OffsetDateTime?) = apply { this.maxCreatedAt = maxCreatedAt } + + /** Alias for calling [Builder.maxCreatedAt] with `maxCreatedAt.orElse(null)`. */ + fun maxCreatedAt(maxCreatedAt: Optional<OffsetDateTime>) = + maxCreatedAt(maxCreatedAt.getOrNull()) + + fun minCreatedAt(minCreatedAt: OffsetDateTime?) = apply { this.minCreatedAt = minCreatedAt } + + /** Alias for calling [Builder.minCreatedAt] with `minCreatedAt.orElse(null)`. */ + fun minCreatedAt(minCreatedAt: Optional<OffsetDateTime>) = + minCreatedAt(minCreatedAt.getOrNull()) + + fun offset(offset: Long?) = apply { this.offset = offset } + + /** + * Alias for [Builder.offset]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun offset(offset: Long) = offset(offset as Long?) + + /** Alias for calling [Builder.offset] with `offset.orElse(null)`. */ + fun offset(offset: Optional<Long>) = offset(offset.getOrNull()) + + fun run(run: List<String>?) = apply { this.run = run?.toMutableList() } + + /** Alias for calling [Builder.run] with `run.orElse(null)`. */ + fun run(run: Optional<List<String>>) = run(run.getOrNull()) + + /** + * Adds a single [String] to [Builder.run]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRun(run: String) = apply { + this.run = (this.run ?: mutableListOf()).apply { add(run) } + } + + fun session(session: List<String>?) = apply { this.session = session?.toMutableList() } + + /** Alias for calling [Builder.session] with `session.orElse(null)`. */ + fun session(session: Optional<List<String>>) = session(session.getOrNull()) + + /** + * Adds a single [String] to [Builder.session]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSession(session: String) = apply { + this.session = (this.session ?: mutableListOf()).apply { add(session) } + } + + fun source(source: List<SourceType>?) = apply { this.source = source?.toMutableList() } + + /** Alias for calling [Builder.source] with `source.orElse(null)`. */ + fun source(source: Optional<List<SourceType>>) = source(source.getOrNull()) + + /** + * Adds a single [SourceType] to [Builder.source]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSource(source: SourceType) = apply { + this.source = (this.source ?: mutableListOf()).apply { add(source) } + } + + fun user(user: List<String>?) = apply { this.user = user?.toMutableList() } + + /** Alias for calling [Builder.user] with `user.orElse(null)`. */ + fun user(user: Optional<List<String>>) = user(user.getOrNull()) + + /** + * Adds a single [String] to [Builder.user]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addUser(user: String) = apply { + this.user = (this.user ?: mutableListOf()).apply { add(user) } + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [FeedbackListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FeedbackListParams = + FeedbackListParams( + hasComment, + hasScore, + includeUserNames, + key?.toImmutable(), + level, + limit, + maxCreatedAt, + minCreatedAt, + offset, + run?.toImmutable(), + session?.toImmutable(), + source?.toImmutable(), + user?.toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + hasComment?.let { put("has_comment", it.toString()) } + hasScore?.let { put("has_score", it.toString()) } + includeUserNames?.let { put("include_user_names", it.toString()) } + key?.let { put("key", it.joinToString(",")) } + level?.let { put("level", it.toString()) } + limit?.let { put("limit", it.toString()) } + maxCreatedAt?.let { + put("max_created_at", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + minCreatedAt?.let { + put("min_created_at", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + offset?.let { put("offset", it.toString()) } + run?.let { put("run", it.joinToString(",")) } + session?.let { put("session", it.joinToString(",")) } + source?.let { put("source", it.joinToString(",") { it.toString() }) } + user?.let { put("user", it.joinToString(",")) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackListParams && + hasComment == other.hasComment && + hasScore == other.hasScore && + includeUserNames == other.includeUserNames && + key == other.key && + level == other.level && + limit == other.limit && + maxCreatedAt == other.maxCreatedAt && + minCreatedAt == other.minCreatedAt && + offset == other.offset && + run == other.run && + session == other.session && + source == other.source && + user == other.user && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + hasComment, + hasScore, + includeUserNames, + key, + level, + limit, + maxCreatedAt, + minCreatedAt, + offset, + run, + session, + source, + user, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "FeedbackListParams{hasComment=$hasComment, hasScore=$hasScore, includeUserNames=$includeUserNames, key=$key, level=$level, limit=$limit, maxCreatedAt=$maxCreatedAt, minCreatedAt=$minCreatedAt, offset=$offset, run=$run, session=$session, source=$source, user=$user, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackRetrieveParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackRetrieveParams.kt new file mode 100644 index 00000000..de84bae6 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackRetrieveParams.kt @@ -0,0 +1,223 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get a specific feedback. */ +class FeedbackRetrieveParams +private constructor( + private val feedbackId: String?, + private val includeUserNames: Boolean?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun feedbackId(): Optional<String> = Optional.ofNullable(feedbackId) + + fun includeUserNames(): Optional<Boolean> = Optional.ofNullable(includeUserNames) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): FeedbackRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [FeedbackRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackRetrieveParams]. */ + class Builder internal constructor() { + + private var feedbackId: String? = null + private var includeUserNames: Boolean? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(feedbackRetrieveParams: FeedbackRetrieveParams) = apply { + feedbackId = feedbackRetrieveParams.feedbackId + includeUserNames = feedbackRetrieveParams.includeUserNames + additionalHeaders = feedbackRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = feedbackRetrieveParams.additionalQueryParams.toBuilder() + } + + fun feedbackId(feedbackId: String?) = apply { this.feedbackId = feedbackId } + + /** Alias for calling [Builder.feedbackId] with `feedbackId.orElse(null)`. */ + fun feedbackId(feedbackId: Optional<String>) = feedbackId(feedbackId.getOrNull()) + + fun includeUserNames(includeUserNames: Boolean?) = apply { + this.includeUserNames = includeUserNames + } + + /** + * Alias for [Builder.includeUserNames]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun includeUserNames(includeUserNames: Boolean) = + includeUserNames(includeUserNames as Boolean?) + + /** Alias for calling [Builder.includeUserNames] with `includeUserNames.orElse(null)`. */ + fun includeUserNames(includeUserNames: Optional<Boolean>) = + includeUserNames(includeUserNames.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [FeedbackRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FeedbackRetrieveParams = + FeedbackRetrieveParams( + feedbackId, + includeUserNames, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> feedbackId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + includeUserNames?.let { put("include_user_names", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackRetrieveParams && + feedbackId == other.feedbackId && + includeUserNames == other.includeUserNames && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(feedbackId, includeUserNames, additionalHeaders, additionalQueryParams) + + override fun toString() = + "FeedbackRetrieveParams{feedbackId=$feedbackId, includeUserNames=$includeUserNames, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackSchema.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackSchema.kt new file mode 100644 index 00000000..767c4360 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackSchema.kt @@ -0,0 +1,1650 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback + +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 com.langsmith_api.api.core.BaseDeserializer +import com.langsmith_api.api.core.BaseSerializer +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.allMaxBy +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Schema for getting feedback. */ +class FeedbackSchema +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val key: JsonField<String>, + private val comment: JsonField<String>, + private val comparativeExperimentId: JsonField<String>, + private val correction: JsonField<Correction>, + private val createdAt: JsonField<OffsetDateTime>, + private val extra: JsonValue, + private val feedbackGroupId: JsonField<String>, + private val feedbackSource: JsonField<FeedbackSource>, + private val feedbackThreadId: JsonField<String>, + private val modifiedAt: JsonField<OffsetDateTime>, + private val runId: JsonField<String>, + private val score: JsonField<Score>, + private val sessionId: JsonField<String>, + private val startTime: JsonField<OffsetDateTime>, + private val traceId: JsonField<String>, + private val value: JsonField<Value>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("key") @ExcludeMissing key: JsonField<String> = JsonMissing.of(), + @JsonProperty("comment") @ExcludeMissing comment: JsonField<String> = JsonMissing.of(), + @JsonProperty("comparative_experiment_id") + @ExcludeMissing + comparativeExperimentId: JsonField<String> = JsonMissing.of(), + @JsonProperty("correction") + @ExcludeMissing + correction: JsonField<Correction> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("extra") @ExcludeMissing extra: JsonValue = JsonMissing.of(), + @JsonProperty("feedback_group_id") + @ExcludeMissing + feedbackGroupId: JsonField<String> = JsonMissing.of(), + @JsonProperty("feedback_source") + @ExcludeMissing + feedbackSource: JsonField<FeedbackSource> = JsonMissing.of(), + @JsonProperty("feedback_thread_id") + @ExcludeMissing + feedbackThreadId: JsonField<String> = JsonMissing.of(), + @JsonProperty("modified_at") + @ExcludeMissing + modifiedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("run_id") @ExcludeMissing runId: JsonField<String> = JsonMissing.of(), + @JsonProperty("score") @ExcludeMissing score: JsonField<Score> = JsonMissing.of(), + @JsonProperty("session_id") @ExcludeMissing sessionId: JsonField<String> = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("trace_id") @ExcludeMissing traceId: JsonField<String> = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField<Value> = JsonMissing.of(), + ) : this( + id, + key, + comment, + comparativeExperimentId, + correction, + createdAt, + extra, + feedbackGroupId, + feedbackSource, + feedbackThreadId, + modifiedAt, + runId, + score, + sessionId, + startTime, + traceId, + value, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun key(): String = key.getRequired("key") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun comment(): Optional<String> = comment.getOptional("comment") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun comparativeExperimentId(): Optional<String> = + comparativeExperimentId.getOptional("comparative_experiment_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun correction(): Optional<Correction> = correction.getOptional("correction") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun createdAt(): Optional<OffsetDateTime> = createdAt.getOptional("created_at") + + @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonValue = extra + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun feedbackGroupId(): Optional<String> = feedbackGroupId.getOptional("feedback_group_id") + + /** + * The feedback source loaded from the database. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun feedbackSource(): Optional<FeedbackSource> = feedbackSource.getOptional("feedback_source") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun feedbackThreadId(): Optional<String> = feedbackThreadId.getOptional("feedback_thread_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun modifiedAt(): Optional<OffsetDateTime> = modifiedAt.getOptional("modified_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun runId(): Optional<String> = runId.getOptional("run_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun score(): Optional<Score> = score.getOptional("score") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun sessionId(): Optional<String> = sessionId.getOptional("session_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun startTime(): Optional<OffsetDateTime> = startTime.getOptional("start_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun traceId(): Optional<String> = traceId.getOptional("trace_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun value(): Optional<Value> = value.getOptional("value") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [key]. + * + * Unlike [key], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("key") @ExcludeMissing fun _key(): JsonField<String> = key + + /** + * Returns the raw JSON value of [comment]. + * + * Unlike [comment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("comment") @ExcludeMissing fun _comment(): JsonField<String> = comment + + /** + * Returns the raw JSON value of [comparativeExperimentId]. + * + * Unlike [comparativeExperimentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("comparative_experiment_id") + @ExcludeMissing + fun _comparativeExperimentId(): JsonField<String> = comparativeExperimentId + + /** + * Returns the raw JSON value of [correction]. + * + * Unlike [correction], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("correction") + @ExcludeMissing + fun _correction(): JsonField<Correction> = correction + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [feedbackGroupId]. + * + * Unlike [feedbackGroupId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feedback_group_id") + @ExcludeMissing + fun _feedbackGroupId(): JsonField<String> = feedbackGroupId + + /** + * Returns the raw JSON value of [feedbackSource]. + * + * Unlike [feedbackSource], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feedback_source") + @ExcludeMissing + fun _feedbackSource(): JsonField<FeedbackSource> = feedbackSource + + /** + * Returns the raw JSON value of [feedbackThreadId]. + * + * Unlike [feedbackThreadId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("feedback_thread_id") + @ExcludeMissing + fun _feedbackThreadId(): JsonField<String> = feedbackThreadId + + /** + * Returns the raw JSON value of [modifiedAt]. + * + * Unlike [modifiedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("modified_at") + @ExcludeMissing + fun _modifiedAt(): JsonField<OffsetDateTime> = modifiedAt + + /** + * Returns the raw JSON value of [runId]. + * + * Unlike [runId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_id") @ExcludeMissing fun _runId(): JsonField<String> = runId + + /** + * Returns the raw JSON value of [score]. + * + * Unlike [score], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("score") @ExcludeMissing fun _score(): JsonField<Score> = score + + /** + * Returns the raw JSON value of [sessionId]. + * + * Unlike [sessionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session_id") @ExcludeMissing fun _sessionId(): JsonField<String> = sessionId + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_time") + @ExcludeMissing + fun _startTime(): JsonField<OffsetDateTime> = startTime + + /** + * Returns the raw JSON value of [traceId]. + * + * Unlike [traceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trace_id") @ExcludeMissing fun _traceId(): JsonField<String> = traceId + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField<Value> = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [FeedbackSchema]. + * + * The following fields are required: + * ```java + * .id() + * .key() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackSchema]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var key: JsonField<String>? = null + private var comment: JsonField<String> = JsonMissing.of() + private var comparativeExperimentId: JsonField<String> = JsonMissing.of() + private var correction: JsonField<Correction> = JsonMissing.of() + private var createdAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var extra: JsonValue = JsonMissing.of() + private var feedbackGroupId: JsonField<String> = JsonMissing.of() + private var feedbackSource: JsonField<FeedbackSource> = JsonMissing.of() + private var feedbackThreadId: JsonField<String> = JsonMissing.of() + private var modifiedAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var runId: JsonField<String> = JsonMissing.of() + private var score: JsonField<Score> = JsonMissing.of() + private var sessionId: JsonField<String> = JsonMissing.of() + private var startTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var traceId: JsonField<String> = JsonMissing.of() + private var value: JsonField<Value> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(feedbackSchema: FeedbackSchema) = apply { + id = feedbackSchema.id + key = feedbackSchema.key + comment = feedbackSchema.comment + comparativeExperimentId = feedbackSchema.comparativeExperimentId + correction = feedbackSchema.correction + createdAt = feedbackSchema.createdAt + extra = feedbackSchema.extra + feedbackGroupId = feedbackSchema.feedbackGroupId + feedbackSource = feedbackSchema.feedbackSource + feedbackThreadId = feedbackSchema.feedbackThreadId + modifiedAt = feedbackSchema.modifiedAt + runId = feedbackSchema.runId + score = feedbackSchema.score + sessionId = feedbackSchema.sessionId + startTime = feedbackSchema.startTime + traceId = feedbackSchema.traceId + value = feedbackSchema.value + additionalProperties = feedbackSchema.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun key(key: String) = key(JsonField.of(key)) + + /** + * Sets [Builder.key] to an arbitrary JSON value. + * + * You should usually call [Builder.key] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun key(key: JsonField<String>) = apply { this.key = key } + + fun comment(comment: String?) = comment(JsonField.ofNullable(comment)) + + /** Alias for calling [Builder.comment] with `comment.orElse(null)`. */ + fun comment(comment: Optional<String>) = comment(comment.getOrNull()) + + /** + * Sets [Builder.comment] to an arbitrary JSON value. + * + * You should usually call [Builder.comment] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun comment(comment: JsonField<String>) = apply { this.comment = comment } + + fun comparativeExperimentId(comparativeExperimentId: String?) = + comparativeExperimentId(JsonField.ofNullable(comparativeExperimentId)) + + /** + * Alias for calling [Builder.comparativeExperimentId] with + * `comparativeExperimentId.orElse(null)`. + */ + fun comparativeExperimentId(comparativeExperimentId: Optional<String>) = + comparativeExperimentId(comparativeExperimentId.getOrNull()) + + /** + * Sets [Builder.comparativeExperimentId] to an arbitrary JSON value. + * + * You should usually call [Builder.comparativeExperimentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun comparativeExperimentId(comparativeExperimentId: JsonField<String>) = apply { + this.comparativeExperimentId = comparativeExperimentId + } + + fun correction(correction: Correction?) = correction(JsonField.ofNullable(correction)) + + /** Alias for calling [Builder.correction] with `correction.orElse(null)`. */ + fun correction(correction: Optional<Correction>) = correction(correction.getOrNull()) + + /** + * Sets [Builder.correction] to an arbitrary JSON value. + * + * You should usually call [Builder.correction] with a well-typed [Correction] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun correction(correction: JsonField<Correction>) = apply { this.correction = correction } + + /** Alias for calling [correction] with `Correction.ofJsonValue(jsonValue)`. */ + fun correction(jsonValue: JsonValue) = correction(Correction.ofJsonValue(jsonValue)) + + /** Alias for calling [correction] with `Correction.ofString(string)`. */ + fun correction(string: String) = correction(Correction.ofString(string)) + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun extra(extra: JsonValue) = apply { this.extra = extra } + + fun feedbackGroupId(feedbackGroupId: String?) = + feedbackGroupId(JsonField.ofNullable(feedbackGroupId)) + + /** Alias for calling [Builder.feedbackGroupId] with `feedbackGroupId.orElse(null)`. */ + fun feedbackGroupId(feedbackGroupId: Optional<String>) = + feedbackGroupId(feedbackGroupId.getOrNull()) + + /** + * Sets [Builder.feedbackGroupId] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackGroupId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun feedbackGroupId(feedbackGroupId: JsonField<String>) = apply { + this.feedbackGroupId = feedbackGroupId + } + + /** The feedback source loaded from the database. */ + fun feedbackSource(feedbackSource: FeedbackSource?) = + feedbackSource(JsonField.ofNullable(feedbackSource)) + + /** Alias for calling [Builder.feedbackSource] with `feedbackSource.orElse(null)`. */ + fun feedbackSource(feedbackSource: Optional<FeedbackSource>) = + feedbackSource(feedbackSource.getOrNull()) + + /** + * Sets [Builder.feedbackSource] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackSource] with a well-typed [FeedbackSource] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun feedbackSource(feedbackSource: JsonField<FeedbackSource>) = apply { + this.feedbackSource = feedbackSource + } + + fun feedbackThreadId(feedbackThreadId: String?) = + feedbackThreadId(JsonField.ofNullable(feedbackThreadId)) + + /** Alias for calling [Builder.feedbackThreadId] with `feedbackThreadId.orElse(null)`. */ + fun feedbackThreadId(feedbackThreadId: Optional<String>) = + feedbackThreadId(feedbackThreadId.getOrNull()) + + /** + * Sets [Builder.feedbackThreadId] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackThreadId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun feedbackThreadId(feedbackThreadId: JsonField<String>) = apply { + this.feedbackThreadId = feedbackThreadId + } + + fun modifiedAt(modifiedAt: OffsetDateTime) = modifiedAt(JsonField.of(modifiedAt)) + + /** + * Sets [Builder.modifiedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.modifiedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modifiedAt(modifiedAt: JsonField<OffsetDateTime>) = apply { + this.modifiedAt = modifiedAt + } + + fun runId(runId: String?) = runId(JsonField.ofNullable(runId)) + + /** Alias for calling [Builder.runId] with `runId.orElse(null)`. */ + fun runId(runId: Optional<String>) = runId(runId.getOrNull()) + + /** + * Sets [Builder.runId] to an arbitrary JSON value. + * + * You should usually call [Builder.runId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun runId(runId: JsonField<String>) = apply { this.runId = runId } + + fun score(score: Score?) = score(JsonField.ofNullable(score)) + + /** Alias for calling [Builder.score] with `score.orElse(null)`. */ + fun score(score: Optional<Score>) = score(score.getOrNull()) + + /** + * Sets [Builder.score] to an arbitrary JSON value. + * + * You should usually call [Builder.score] with a well-typed [Score] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun score(score: JsonField<Score>) = apply { this.score = score } + + /** Alias for calling [score] with `Score.ofNumber(number)`. */ + fun score(number: Double) = score(Score.ofNumber(number)) + + /** Alias for calling [score] with `Score.ofBool(bool)`. */ + fun score(bool: Boolean) = score(Score.ofBool(bool)) + + fun sessionId(sessionId: String?) = sessionId(JsonField.ofNullable(sessionId)) + + /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ + fun sessionId(sessionId: Optional<String>) = sessionId(sessionId.getOrNull()) + + /** + * Sets [Builder.sessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun sessionId(sessionId: JsonField<String>) = apply { this.sessionId = sessionId } + + fun startTime(startTime: OffsetDateTime?) = startTime(JsonField.ofNullable(startTime)) + + /** Alias for calling [Builder.startTime] with `startTime.orElse(null)`. */ + fun startTime(startTime: Optional<OffsetDateTime>) = startTime(startTime.getOrNull()) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField<OffsetDateTime>) = apply { this.startTime = startTime } + + fun traceId(traceId: String?) = traceId(JsonField.ofNullable(traceId)) + + /** Alias for calling [Builder.traceId] with `traceId.orElse(null)`. */ + fun traceId(traceId: Optional<String>) = traceId(traceId.getOrNull()) + + /** + * Sets [Builder.traceId] to an arbitrary JSON value. + * + * You should usually call [Builder.traceId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun traceId(traceId: JsonField<String>) = apply { this.traceId = traceId } + + fun value(value: Value?) = value(JsonField.ofNullable(value)) + + /** Alias for calling [Builder.value] with `value.orElse(null)`. */ + fun value(value: Optional<Value>) = value(value.getOrNull()) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Value] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun value(value: JsonField<Value>) = apply { this.value = value } + + /** Alias for calling [value] with `Value.ofNumber(number)`. */ + fun value(number: Double) = value(Value.ofNumber(number)) + + /** Alias for calling [value] with `Value.ofBool(bool)`. */ + fun value(bool: Boolean) = value(Value.ofBool(bool)) + + /** Alias for calling [value] with `Value.ofString(string)`. */ + fun value(string: String) = value(Value.ofString(string)) + + /** Alias for calling [value] with `Value.ofJson(json)`. */ + fun value(json: JsonValue) = value(Value.ofJson(json)) + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FeedbackSchema]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .key() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FeedbackSchema = + FeedbackSchema( + checkRequired("id", id), + checkRequired("key", key), + comment, + comparativeExperimentId, + correction, + createdAt, + extra, + feedbackGroupId, + feedbackSource, + feedbackThreadId, + modifiedAt, + runId, + score, + sessionId, + startTime, + traceId, + value, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): FeedbackSchema = apply { + if (validated) { + return@apply + } + + id() + key() + comment() + comparativeExperimentId() + correction().ifPresent { it.validate() } + createdAt() + feedbackGroupId() + feedbackSource().ifPresent { it.validate() } + feedbackThreadId() + modifiedAt() + runId() + score().ifPresent { it.validate() } + sessionId() + startTime() + traceId() + value().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (key.asKnown().isPresent) 1 else 0) + + (if (comment.asKnown().isPresent) 1 else 0) + + (if (comparativeExperimentId.asKnown().isPresent) 1 else 0) + + (correction.asKnown().getOrNull()?.validity() ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (feedbackGroupId.asKnown().isPresent) 1 else 0) + + (feedbackSource.asKnown().getOrNull()?.validity() ?: 0) + + (if (feedbackThreadId.asKnown().isPresent) 1 else 0) + + (if (modifiedAt.asKnown().isPresent) 1 else 0) + + (if (runId.asKnown().isPresent) 1 else 0) + + (score.asKnown().getOrNull()?.validity() ?: 0) + + (if (sessionId.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + (if (traceId.asKnown().isPresent) 1 else 0) + + (value.asKnown().getOrNull()?.validity() ?: 0) + + @JsonDeserialize(using = Correction.Deserializer::class) + @JsonSerialize(using = Correction.Serializer::class) + class Correction + private constructor( + private val jsonValue: JsonValue? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun jsonValue(): Optional<JsonValue> = Optional.ofNullable(jsonValue) + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun isJsonValue(): Boolean = jsonValue != null + + fun isString(): Boolean = string != null + + fun asJsonValue(): JsonValue = jsonValue.getOrThrow("jsonValue") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + jsonValue != null -> visitor.visitJsonValue(jsonValue) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Correction = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitJsonValue(jsonValue: JsonValue) {} + + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Correction && jsonValue == other.jsonValue && string == other.string + } + + override fun hashCode(): Int = Objects.hash(jsonValue, string) + + override fun toString(): String = + when { + jsonValue != null -> "Correction{jsonValue=$jsonValue}" + string != null -> "Correction{string=$string}" + _json != null -> "Correction{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Correction") + } + + companion object { + + @JvmStatic fun ofJsonValue(jsonValue: JsonValue) = Correction(jsonValue = jsonValue) + + @JvmStatic fun ofString(string: String) = Correction(string = string) + } + + /** + * An interface that defines how to map each variant of [Correction] to a value of type [T]. + */ + interface Visitor<out T> { + + fun visitJsonValue(jsonValue: JsonValue): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [Correction] to a value of type [T]. + * + * An instance of [Correction] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Correction: $json") + } + } + + internal class Deserializer : BaseDeserializer<Correction>(Correction::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Correction { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<String>())?.let { + Correction(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<JsonValue>())?.let { + Correction(jsonValue = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants. + 0 -> Correction(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Correction>(Correction::class) { + + override fun serialize( + value: Correction, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.jsonValue != null -> generator.writeObject(value.jsonValue) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Correction") + } + } + } + } + + /** The feedback source loaded from the database. */ + class FeedbackSource + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val lsUserId: JsonField<String>, + private val metadata: JsonValue, + private val type: JsonField<String>, + private val userId: JsonField<String>, + private val userName: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("ls_user_id") + @ExcludeMissing + lsUserId: JsonField<String> = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField<String> = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing userId: JsonField<String> = JsonMissing.of(), + @JsonProperty("user_name") + @ExcludeMissing + userName: JsonField<String> = JsonMissing.of(), + ) : this(lsUserId, metadata, type, userId, userName, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun lsUserId(): Optional<String> = lsUserId.getOptional("ls_user_id") + + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun type(): Optional<String> = type.getOptional("type") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun userId(): Optional<String> = userId.getOptional("user_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun userName(): Optional<String> = userName.getOptional("user_name") + + /** + * Returns the raw JSON value of [lsUserId]. + * + * Unlike [lsUserId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ls_user_id") @ExcludeMissing fun _lsUserId(): JsonField<String> = lsUserId + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField<String> = type + + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField<String> = userId + + /** + * Returns the raw JSON value of [userName]. + * + * Unlike [userName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user_name") @ExcludeMissing fun _userName(): JsonField<String> = userName + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [FeedbackSource]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackSource]. */ + class Builder internal constructor() { + + private var lsUserId: JsonField<String> = JsonMissing.of() + private var metadata: JsonValue = JsonMissing.of() + private var type: JsonField<String> = JsonMissing.of() + private var userId: JsonField<String> = JsonMissing.of() + private var userName: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(feedbackSource: FeedbackSource) = apply { + lsUserId = feedbackSource.lsUserId + metadata = feedbackSource.metadata + type = feedbackSource.type + userId = feedbackSource.userId + userName = feedbackSource.userName + additionalProperties = feedbackSource.additionalProperties.toMutableMap() + } + + fun lsUserId(lsUserId: String?) = lsUserId(JsonField.ofNullable(lsUserId)) + + /** Alias for calling [Builder.lsUserId] with `lsUserId.orElse(null)`. */ + fun lsUserId(lsUserId: Optional<String>) = lsUserId(lsUserId.getOrNull()) + + /** + * Sets [Builder.lsUserId] to an arbitrary JSON value. + * + * You should usually call [Builder.lsUserId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lsUserId(lsUserId: JsonField<String>) = apply { this.lsUserId = lsUserId } + + fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + + fun type(type: String?) = type(JsonField.ofNullable(type)) + + /** Alias for calling [Builder.type] with `type.orElse(null)`. */ + fun type(type: Optional<String>) = type(type.getOrNull()) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField<String>) = apply { this.type = type } + + fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) + + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ + fun userId(userId: Optional<String>) = userId(userId.getOrNull()) + + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun userId(userId: JsonField<String>) = apply { this.userId = userId } + + fun userName(userName: String?) = userName(JsonField.ofNullable(userName)) + + /** Alias for calling [Builder.userName] with `userName.orElse(null)`. */ + fun userName(userName: Optional<String>) = userName(userName.getOrNull()) + + /** + * Sets [Builder.userName] to an arbitrary JSON value. + * + * You should usually call [Builder.userName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun userName(userName: JsonField<String>) = apply { this.userName = userName } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FeedbackSource]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FeedbackSource = + FeedbackSource( + lsUserId, + metadata, + type, + userId, + userName, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): FeedbackSource = apply { + if (validated) { + return@apply + } + + lsUserId() + type() + userId() + userName() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (lsUserId.asKnown().isPresent) 1 else 0) + + (if (type.asKnown().isPresent) 1 else 0) + + (if (userId.asKnown().isPresent) 1 else 0) + + (if (userName.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackSource && + lsUserId == other.lsUserId && + metadata == other.metadata && + type == other.type && + userId == other.userId && + userName == other.userName && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(lsUserId, metadata, type, userId, userName, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FeedbackSource{lsUserId=$lsUserId, metadata=$metadata, type=$type, userId=$userId, userName=$userName, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = Score.Deserializer::class) + @JsonSerialize(using = Score.Serializer::class) + class Score + private constructor( + private val number: Double? = null, + private val bool: Boolean? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional<Double> = Optional.ofNullable(number) + + fun bool(): Optional<Boolean> = Optional.ofNullable(bool) + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Score = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Score && number == other.number && bool == other.bool + } + + override fun hashCode(): Int = Objects.hash(number, bool) + + override fun toString(): String = + when { + number != null -> "Score{number=$number}" + bool != null -> "Score{bool=$bool}" + _json != null -> "Score{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Score") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Score(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = Score(bool = bool) + } + + /** An interface that defines how to map each variant of [Score] to a value of type [T]. */ + interface Visitor<out T> { + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Maps an unknown variant of [Score] to a value of type [T]. + * + * An instance of [Score] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Score: $json") + } + } + + internal class Deserializer : BaseDeserializer<Score>(Score::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Score { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<Double>())?.let { + Score(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<Boolean>())?.let { + Score(bool = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from string). + 0 -> Score(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Score>(Score::class) { + + override fun serialize( + value: Score, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Score") + } + } + } + } + + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val number: Double? = null, + private val bool: Boolean? = null, + private val string: String? = null, + private val json: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional<Double> = Optional.ofNullable(number) + + fun bool(): Optional<Boolean> = Optional.ofNullable(bool) + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun json(): Optional<JsonValue> = Optional.ofNullable(json) + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun isString(): Boolean = string != null + + fun isJson(): Boolean = json != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun asString(): String = string.getOrThrow("string") + + fun asJson(): JsonValue = json.getOrThrow("json") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + string != null -> visitor.visitString(string) + json != null -> visitor.visitJson(json) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Value = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + + override fun visitString(string: String) {} + + override fun visitJson(json: JsonValue) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun visitString(string: String) = 1 + + override fun visitJson(json: JsonValue) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + number == other.number && + bool == other.bool && + string == other.string && + json == other.json + } + + override fun hashCode(): Int = Objects.hash(number, bool, string, json) + + override fun toString(): String = + when { + number != null -> "Value{number=$number}" + bool != null -> "Value{bool=$bool}" + string != null -> "Value{string=$string}" + json != null -> "Value{json=$json}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Value(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofJson(json: JsonValue) = Value(json = json) + } + + /** An interface that defines how to map each variant of [Value] to a value of type [T]. */ + interface Visitor<out T> { + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + fun visitString(string: String): T + + fun visitJson(json: JsonValue): T + + /** + * Maps an unknown variant of [Value] to a value of type [T]. + * + * An instance of [Value] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Value: $json") + } + } + + internal class Deserializer : BaseDeserializer<Value>(Value::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Value { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<Double>())?.let { + Value(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<Boolean>())?.let { + Value(bool = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<String>())?.let { + Value(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<JsonValue>())?.let { + Value(json = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants. + 0 -> Value(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Value>(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value.string != null -> generator.writeObject(value.string) + value.json != null -> generator.writeObject(value.json) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackSchema && + id == other.id && + key == other.key && + comment == other.comment && + comparativeExperimentId == other.comparativeExperimentId && + correction == other.correction && + createdAt == other.createdAt && + extra == other.extra && + feedbackGroupId == other.feedbackGroupId && + feedbackSource == other.feedbackSource && + feedbackThreadId == other.feedbackThreadId && + modifiedAt == other.modifiedAt && + runId == other.runId && + score == other.score && + sessionId == other.sessionId && + startTime == other.startTime && + traceId == other.traceId && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + key, + comment, + comparativeExperimentId, + correction, + createdAt, + extra, + feedbackGroupId, + feedbackSource, + feedbackThreadId, + modifiedAt, + runId, + score, + sessionId, + startTime, + traceId, + value, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FeedbackSchema{id=$id, key=$key, comment=$comment, comparativeExperimentId=$comparativeExperimentId, correction=$correction, createdAt=$createdAt, extra=$extra, feedbackGroupId=$feedbackGroupId, feedbackSource=$feedbackSource, feedbackThreadId=$feedbackThreadId, modifiedAt=$modifiedAt, runId=$runId, score=$score, sessionId=$sessionId, startTime=$startTime, traceId=$traceId, value=$value, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackUpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackUpdateParams.kt new file mode 100644 index 00000000..7232b7cb --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackUpdateParams.kt @@ -0,0 +1,1298 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback + +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 com.langsmith_api.api.core.BaseDeserializer +import com.langsmith_api.api.core.BaseSerializer +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.allMaxBy +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfig +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Replace an existing feedback entry with a new, modified entry. */ +class FeedbackUpdateParams +private constructor( + private val feedbackId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun feedbackId(): Optional<String> = Optional.ofNullable(feedbackId) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun comment(): Optional<String> = body.comment() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun correction(): Optional<Correction> = body.correction() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun feedbackConfig(): Optional<FeedbackConfig> = body.feedbackConfig() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun score(): Optional<Score> = body.score() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun value(): Optional<Value> = body.value() + + /** + * Returns the raw JSON value of [comment]. + * + * Unlike [comment], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _comment(): JsonField<String> = body._comment() + + /** + * Returns the raw JSON value of [correction]. + * + * Unlike [correction], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _correction(): JsonField<Correction> = body._correction() + + /** + * Returns the raw JSON value of [feedbackConfig]. + * + * Unlike [feedbackConfig], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _feedbackConfig(): JsonField<FeedbackConfig> = body._feedbackConfig() + + /** + * Returns the raw JSON value of [score]. + * + * Unlike [score], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _score(): JsonField<Score> = body._score() + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _value(): JsonField<Value> = body._value() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): FeedbackUpdateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [FeedbackUpdateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackUpdateParams]. */ + class Builder internal constructor() { + + private var feedbackId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(feedbackUpdateParams: FeedbackUpdateParams) = apply { + feedbackId = feedbackUpdateParams.feedbackId + body = feedbackUpdateParams.body.toBuilder() + additionalHeaders = feedbackUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = feedbackUpdateParams.additionalQueryParams.toBuilder() + } + + fun feedbackId(feedbackId: String?) = apply { this.feedbackId = feedbackId } + + /** Alias for calling [Builder.feedbackId] with `feedbackId.orElse(null)`. */ + fun feedbackId(feedbackId: Optional<String>) = feedbackId(feedbackId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [comment] + * - [correction] + * - [feedbackConfig] + * - [score] + * - [value] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun comment(comment: String?) = apply { body.comment(comment) } + + /** Alias for calling [Builder.comment] with `comment.orElse(null)`. */ + fun comment(comment: Optional<String>) = comment(comment.getOrNull()) + + /** + * Sets [Builder.comment] to an arbitrary JSON value. + * + * You should usually call [Builder.comment] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun comment(comment: JsonField<String>) = apply { body.comment(comment) } + + fun correction(correction: Correction?) = apply { body.correction(correction) } + + /** Alias for calling [Builder.correction] with `correction.orElse(null)`. */ + fun correction(correction: Optional<Correction>) = correction(correction.getOrNull()) + + /** + * Sets [Builder.correction] to an arbitrary JSON value. + * + * You should usually call [Builder.correction] with a well-typed [Correction] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun correction(correction: JsonField<Correction>) = apply { body.correction(correction) } + + /** Alias for calling [correction] with `Correction.ofJsonValue(jsonValue)`. */ + fun correction(jsonValue: JsonValue) = apply { body.correction(jsonValue) } + + /** Alias for calling [correction] with `Correction.ofString(string)`. */ + fun correction(string: String) = apply { body.correction(string) } + + fun feedbackConfig(feedbackConfig: FeedbackConfig?) = apply { + body.feedbackConfig(feedbackConfig) + } + + /** Alias for calling [Builder.feedbackConfig] with `feedbackConfig.orElse(null)`. */ + fun feedbackConfig(feedbackConfig: Optional<FeedbackConfig>) = + feedbackConfig(feedbackConfig.getOrNull()) + + /** + * Sets [Builder.feedbackConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackConfig] with a well-typed [FeedbackConfig] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun feedbackConfig(feedbackConfig: JsonField<FeedbackConfig>) = apply { + body.feedbackConfig(feedbackConfig) + } + + fun score(score: Score?) = apply { body.score(score) } + + /** Alias for calling [Builder.score] with `score.orElse(null)`. */ + fun score(score: Optional<Score>) = score(score.getOrNull()) + + /** + * Sets [Builder.score] to an arbitrary JSON value. + * + * You should usually call [Builder.score] with a well-typed [Score] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun score(score: JsonField<Score>) = apply { body.score(score) } + + /** Alias for calling [score] with `Score.ofNumber(number)`. */ + fun score(number: Double) = apply { body.score(number) } + + /** Alias for calling [score] with `Score.ofBool(bool)`. */ + fun score(bool: Boolean) = apply { body.score(bool) } + + fun value(value: Value?) = apply { body.value(value) } + + /** Alias for calling [Builder.value] with `value.orElse(null)`. */ + fun value(value: Optional<Value>) = value(value.getOrNull()) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Value] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun value(value: JsonField<Value>) = apply { body.value(value) } + + /** Alias for calling [value] with `Value.ofNumber(number)`. */ + fun value(number: Double) = apply { body.value(number) } + + /** Alias for calling [value] with `Value.ofBool(bool)`. */ + fun value(bool: Boolean) = apply { body.value(bool) } + + /** Alias for calling [value] with `Value.ofString(string)`. */ + fun value(string: String) = apply { body.value(string) } + + /** Alias for calling [value] with `Value.ofJson(json)`. */ + fun value(json: JsonValue) = apply { body.value(json) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [FeedbackUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FeedbackUpdateParams = + FeedbackUpdateParams( + feedbackId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> feedbackId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Schema used for updating feedback */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val comment: JsonField<String>, + private val correction: JsonField<Correction>, + private val feedbackConfig: JsonField<FeedbackConfig>, + private val score: JsonField<Score>, + private val value: JsonField<Value>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("comment") @ExcludeMissing comment: JsonField<String> = JsonMissing.of(), + @JsonProperty("correction") + @ExcludeMissing + correction: JsonField<Correction> = JsonMissing.of(), + @JsonProperty("feedback_config") + @ExcludeMissing + feedbackConfig: JsonField<FeedbackConfig> = JsonMissing.of(), + @JsonProperty("score") @ExcludeMissing score: JsonField<Score> = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField<Value> = JsonMissing.of(), + ) : this(comment, correction, feedbackConfig, score, value, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun comment(): Optional<String> = comment.getOptional("comment") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun correction(): Optional<Correction> = correction.getOptional("correction") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun feedbackConfig(): Optional<FeedbackConfig> = + feedbackConfig.getOptional("feedback_config") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun score(): Optional<Score> = score.getOptional("score") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun value(): Optional<Value> = value.getOptional("value") + + /** + * Returns the raw JSON value of [comment]. + * + * Unlike [comment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("comment") @ExcludeMissing fun _comment(): JsonField<String> = comment + + /** + * Returns the raw JSON value of [correction]. + * + * Unlike [correction], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("correction") + @ExcludeMissing + fun _correction(): JsonField<Correction> = correction + + /** + * Returns the raw JSON value of [feedbackConfig]. + * + * Unlike [feedbackConfig], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("feedback_config") + @ExcludeMissing + fun _feedbackConfig(): JsonField<FeedbackConfig> = feedbackConfig + + /** + * Returns the raw JSON value of [score]. + * + * Unlike [score], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("score") @ExcludeMissing fun _score(): JsonField<Score> = score + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField<Value> = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var comment: JsonField<String> = JsonMissing.of() + private var correction: JsonField<Correction> = JsonMissing.of() + private var feedbackConfig: JsonField<FeedbackConfig> = JsonMissing.of() + private var score: JsonField<Score> = JsonMissing.of() + private var value: JsonField<Value> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + comment = body.comment + correction = body.correction + feedbackConfig = body.feedbackConfig + score = body.score + value = body.value + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun comment(comment: String?) = comment(JsonField.ofNullable(comment)) + + /** Alias for calling [Builder.comment] with `comment.orElse(null)`. */ + fun comment(comment: Optional<String>) = comment(comment.getOrNull()) + + /** + * Sets [Builder.comment] to an arbitrary JSON value. + * + * You should usually call [Builder.comment] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun comment(comment: JsonField<String>) = apply { this.comment = comment } + + fun correction(correction: Correction?) = correction(JsonField.ofNullable(correction)) + + /** Alias for calling [Builder.correction] with `correction.orElse(null)`. */ + fun correction(correction: Optional<Correction>) = correction(correction.getOrNull()) + + /** + * Sets [Builder.correction] to an arbitrary JSON value. + * + * You should usually call [Builder.correction] with a well-typed [Correction] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun correction(correction: JsonField<Correction>) = apply { + this.correction = correction + } + + /** Alias for calling [correction] with `Correction.ofJsonValue(jsonValue)`. */ + fun correction(jsonValue: JsonValue) = correction(Correction.ofJsonValue(jsonValue)) + + /** Alias for calling [correction] with `Correction.ofString(string)`. */ + fun correction(string: String) = correction(Correction.ofString(string)) + + fun feedbackConfig(feedbackConfig: FeedbackConfig?) = + feedbackConfig(JsonField.ofNullable(feedbackConfig)) + + /** Alias for calling [Builder.feedbackConfig] with `feedbackConfig.orElse(null)`. */ + fun feedbackConfig(feedbackConfig: Optional<FeedbackConfig>) = + feedbackConfig(feedbackConfig.getOrNull()) + + /** + * Sets [Builder.feedbackConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackConfig] with a well-typed [FeedbackConfig] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun feedbackConfig(feedbackConfig: JsonField<FeedbackConfig>) = apply { + this.feedbackConfig = feedbackConfig + } + + fun score(score: Score?) = score(JsonField.ofNullable(score)) + + /** Alias for calling [Builder.score] with `score.orElse(null)`. */ + fun score(score: Optional<Score>) = score(score.getOrNull()) + + /** + * Sets [Builder.score] to an arbitrary JSON value. + * + * You should usually call [Builder.score] with a well-typed [Score] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun score(score: JsonField<Score>) = apply { this.score = score } + + /** Alias for calling [score] with `Score.ofNumber(number)`. */ + fun score(number: Double) = score(Score.ofNumber(number)) + + /** Alias for calling [score] with `Score.ofBool(bool)`. */ + fun score(bool: Boolean) = score(Score.ofBool(bool)) + + fun value(value: Value?) = value(JsonField.ofNullable(value)) + + /** Alias for calling [Builder.value] with `value.orElse(null)`. */ + fun value(value: Optional<Value>) = value(value.getOrNull()) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Value] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun value(value: JsonField<Value>) = apply { this.value = value } + + /** Alias for calling [value] with `Value.ofNumber(number)`. */ + fun value(number: Double) = value(Value.ofNumber(number)) + + /** Alias for calling [value] with `Value.ofBool(bool)`. */ + fun value(bool: Boolean) = value(Value.ofBool(bool)) + + /** Alias for calling [value] with `Value.ofString(string)`. */ + fun value(string: String) = value(Value.ofString(string)) + + /** Alias for calling [value] with `Value.ofJson(json)`. */ + fun value(json: JsonValue) = value(Value.ofJson(json)) + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = + Body( + comment, + correction, + feedbackConfig, + score, + value, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + comment() + correction().ifPresent { it.validate() } + feedbackConfig().ifPresent { it.validate() } + score().ifPresent { it.validate() } + value().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (comment.asKnown().isPresent) 1 else 0) + + (correction.asKnown().getOrNull()?.validity() ?: 0) + + (feedbackConfig.asKnown().getOrNull()?.validity() ?: 0) + + (score.asKnown().getOrNull()?.validity() ?: 0) + + (value.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + comment == other.comment && + correction == other.correction && + feedbackConfig == other.feedbackConfig && + score == other.score && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(comment, correction, feedbackConfig, score, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{comment=$comment, correction=$correction, feedbackConfig=$feedbackConfig, score=$score, value=$value, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = Correction.Deserializer::class) + @JsonSerialize(using = Correction.Serializer::class) + class Correction + private constructor( + private val jsonValue: JsonValue? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun jsonValue(): Optional<JsonValue> = Optional.ofNullable(jsonValue) + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun isJsonValue(): Boolean = jsonValue != null + + fun isString(): Boolean = string != null + + fun asJsonValue(): JsonValue = jsonValue.getOrThrow("jsonValue") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + jsonValue != null -> visitor.visitJsonValue(jsonValue) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Correction = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitJsonValue(jsonValue: JsonValue) {} + + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Correction && jsonValue == other.jsonValue && string == other.string + } + + override fun hashCode(): Int = Objects.hash(jsonValue, string) + + override fun toString(): String = + when { + jsonValue != null -> "Correction{jsonValue=$jsonValue}" + string != null -> "Correction{string=$string}" + _json != null -> "Correction{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Correction") + } + + companion object { + + @JvmStatic fun ofJsonValue(jsonValue: JsonValue) = Correction(jsonValue = jsonValue) + + @JvmStatic fun ofString(string: String) = Correction(string = string) + } + + /** + * An interface that defines how to map each variant of [Correction] to a value of type [T]. + */ + interface Visitor<out T> { + + fun visitJsonValue(jsonValue: JsonValue): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [Correction] to a value of type [T]. + * + * An instance of [Correction] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Correction: $json") + } + } + + internal class Deserializer : BaseDeserializer<Correction>(Correction::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Correction { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<String>())?.let { + Correction(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<JsonValue>())?.let { + Correction(jsonValue = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants. + 0 -> Correction(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Correction>(Correction::class) { + + override fun serialize( + value: Correction, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.jsonValue != null -> generator.writeObject(value.jsonValue) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Correction") + } + } + } + } + + @JsonDeserialize(using = Score.Deserializer::class) + @JsonSerialize(using = Score.Serializer::class) + class Score + private constructor( + private val number: Double? = null, + private val bool: Boolean? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional<Double> = Optional.ofNullable(number) + + fun bool(): Optional<Boolean> = Optional.ofNullable(bool) + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Score = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Score && number == other.number && bool == other.bool + } + + override fun hashCode(): Int = Objects.hash(number, bool) + + override fun toString(): String = + when { + number != null -> "Score{number=$number}" + bool != null -> "Score{bool=$bool}" + _json != null -> "Score{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Score") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Score(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = Score(bool = bool) + } + + /** An interface that defines how to map each variant of [Score] to a value of type [T]. */ + interface Visitor<out T> { + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Maps an unknown variant of [Score] to a value of type [T]. + * + * An instance of [Score] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Score: $json") + } + } + + internal class Deserializer : BaseDeserializer<Score>(Score::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Score { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<Double>())?.let { + Score(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<Boolean>())?.let { + Score(bool = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from string). + 0 -> Score(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Score>(Score::class) { + + override fun serialize( + value: Score, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Score") + } + } + } + } + + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val number: Double? = null, + private val bool: Boolean? = null, + private val string: String? = null, + private val json: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional<Double> = Optional.ofNullable(number) + + fun bool(): Optional<Boolean> = Optional.ofNullable(bool) + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun json(): Optional<JsonValue> = Optional.ofNullable(json) + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun isString(): Boolean = string != null + + fun isJson(): Boolean = json != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun asString(): String = string.getOrThrow("string") + + fun asJson(): JsonValue = json.getOrThrow("json") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + string != null -> visitor.visitString(string) + json != null -> visitor.visitJson(json) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Value = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + + override fun visitString(string: String) {} + + override fun visitJson(json: JsonValue) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun visitString(string: String) = 1 + + override fun visitJson(json: JsonValue) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + number == other.number && + bool == other.bool && + string == other.string && + json == other.json + } + + override fun hashCode(): Int = Objects.hash(number, bool, string, json) + + override fun toString(): String = + when { + number != null -> "Value{number=$number}" + bool != null -> "Value{bool=$bool}" + string != null -> "Value{string=$string}" + json != null -> "Value{json=$json}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Value(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofJson(json: JsonValue) = Value(json = json) + } + + /** An interface that defines how to map each variant of [Value] to a value of type [T]. */ + interface Visitor<out T> { + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + fun visitString(string: String): T + + fun visitJson(json: JsonValue): T + + /** + * Maps an unknown variant of [Value] to a value of type [T]. + * + * An instance of [Value] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Value: $json") + } + } + + internal class Deserializer : BaseDeserializer<Value>(Value::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Value { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<Double>())?.let { + Value(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<Boolean>())?.let { + Value(bool = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<String>())?.let { + Value(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<JsonValue>())?.let { + Value(json = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants. + 0 -> Value(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Value>(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value.string != null -> generator.writeObject(value.string) + value.json != null -> generator.writeObject(value.json) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackUpdateParams && + feedbackId == other.feedbackId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(feedbackId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "FeedbackUpdateParams{feedbackId=$feedbackId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/ModelFeedbackSource.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/ModelFeedbackSource.kt new file mode 100644 index 00000000..0c737845 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/ModelFeedbackSource.kt @@ -0,0 +1,163 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional + +/** Model feedback source. */ +class ModelFeedbackSource +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val metadata: JsonValue, + private val type: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField<String> = JsonMissing.of(), + ) : this(metadata, type, mutableMapOf()) + + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun type(): Optional<String> = type.getOptional("type") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField<String> = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ModelFeedbackSource]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ModelFeedbackSource]. */ + class Builder internal constructor() { + + private var metadata: JsonValue = JsonMissing.of() + private var type: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(modelFeedbackSource: ModelFeedbackSource) = apply { + metadata = modelFeedbackSource.metadata + type = modelFeedbackSource.type + additionalProperties = modelFeedbackSource.additionalProperties.toMutableMap() + } + + fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + + fun type(type: String) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField<String>) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ModelFeedbackSource]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ModelFeedbackSource = + ModelFeedbackSource(metadata, type, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): ModelFeedbackSource = apply { + if (validated) { + return@apply + } + + type() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (type.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelFeedbackSource && + metadata == other.metadata && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(metadata, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ModelFeedbackSource{metadata=$metadata, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/SourceType.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/SourceType.kt new file mode 100644 index 00000000..5b8dcc1d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/SourceType.kt @@ -0,0 +1,146 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback + +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException + +/** Enum for feedback source types. */ +class SourceType @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't match + * any known member, and you want to know that value. For example, if the SDK is on an older + * version than the API, then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val API = of("api") + + @JvmField val MODEL = of("model") + + @JvmField val APP = of("app") + + @JvmField val AUTO_EVAL = of("auto_eval") + + @JvmStatic fun of(value: String) = SourceType(JsonField.of(value)) + } + + /** An enum containing [SourceType]'s known values. */ + enum class Known { + API, + MODEL, + APP, + AUTO_EVAL, + } + + /** + * An enum containing [SourceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [SourceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the SDK + * is on an older version than the API, then the API may respond with new members that the SDK + * is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + API, + MODEL, + APP, + AUTO_EVAL, + /** An enum member indicating that [SourceType] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if + * the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want to + * throw for the unknown case. + */ + fun value(): Value = + when (this) { + API -> Value.API + MODEL -> Value.MODEL + APP -> Value.APP + AUTO_EVAL -> Value.AUTO_EVAL + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't want + * to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + API -> Known.API + MODEL -> Known.MODEL + APP -> Known.APP + AUTO_EVAL -> Known.AUTO_EVAL + else -> throw LangsmithApiInvalidDataException("Unknown SourceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): SourceType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SourceType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FeedbackFormula.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FeedbackFormula.kt new file mode 100644 index 00000000..71188da4 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FeedbackFormula.kt @@ -0,0 +1,612 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback.formulas + +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.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class FeedbackFormula +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val aggregationType: JsonField<AggregationType>, + private val createdAt: JsonField<OffsetDateTime>, + private val feedbackKey: JsonField<String>, + private val formulaParts: JsonField<List<FeedbackFormulaWeightedVariable>>, + private val modifiedAt: JsonField<OffsetDateTime>, + private val datasetId: JsonField<String>, + private val sessionId: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("aggregation_type") + @ExcludeMissing + aggregationType: JsonField<AggregationType> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("feedback_key") + @ExcludeMissing + feedbackKey: JsonField<String> = JsonMissing.of(), + @JsonProperty("formula_parts") + @ExcludeMissing + formulaParts: JsonField<List<FeedbackFormulaWeightedVariable>> = JsonMissing.of(), + @JsonProperty("modified_at") + @ExcludeMissing + modifiedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("dataset_id") @ExcludeMissing datasetId: JsonField<String> = JsonMissing.of(), + @JsonProperty("session_id") @ExcludeMissing sessionId: JsonField<String> = JsonMissing.of(), + ) : this( + id, + aggregationType, + createdAt, + feedbackKey, + formulaParts, + modifiedAt, + datasetId, + sessionId, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun aggregationType(): AggregationType = aggregationType.getRequired("aggregation_type") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun feedbackKey(): String = feedbackKey.getRequired("feedback_key") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun formulaParts(): List<FeedbackFormulaWeightedVariable> = + formulaParts.getRequired("formula_parts") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun modifiedAt(): OffsetDateTime = modifiedAt.getRequired("modified_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun datasetId(): Optional<String> = datasetId.getOptional("dataset_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun sessionId(): Optional<String> = sessionId.getOptional("session_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [aggregationType]. + * + * Unlike [aggregationType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("aggregation_type") + @ExcludeMissing + fun _aggregationType(): JsonField<AggregationType> = aggregationType + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [feedbackKey]. + * + * Unlike [feedbackKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feedback_key") + @ExcludeMissing + fun _feedbackKey(): JsonField<String> = feedbackKey + + /** + * Returns the raw JSON value of [formulaParts]. + * + * Unlike [formulaParts], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("formula_parts") + @ExcludeMissing + fun _formulaParts(): JsonField<List<FeedbackFormulaWeightedVariable>> = formulaParts + + /** + * Returns the raw JSON value of [modifiedAt]. + * + * Unlike [modifiedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("modified_at") + @ExcludeMissing + fun _modifiedAt(): JsonField<OffsetDateTime> = modifiedAt + + /** + * Returns the raw JSON value of [datasetId]. + * + * Unlike [datasetId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField<String> = datasetId + + /** + * Returns the raw JSON value of [sessionId]. + * + * Unlike [sessionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session_id") @ExcludeMissing fun _sessionId(): JsonField<String> = sessionId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [FeedbackFormula]. + * + * The following fields are required: + * ```java + * .id() + * .aggregationType() + * .createdAt() + * .feedbackKey() + * .formulaParts() + * .modifiedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackFormula]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var aggregationType: JsonField<AggregationType>? = null + private var createdAt: JsonField<OffsetDateTime>? = null + private var feedbackKey: JsonField<String>? = null + private var formulaParts: JsonField<MutableList<FeedbackFormulaWeightedVariable>>? = null + private var modifiedAt: JsonField<OffsetDateTime>? = null + private var datasetId: JsonField<String> = JsonMissing.of() + private var sessionId: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(feedbackFormula: FeedbackFormula) = apply { + id = feedbackFormula.id + aggregationType = feedbackFormula.aggregationType + createdAt = feedbackFormula.createdAt + feedbackKey = feedbackFormula.feedbackKey + formulaParts = feedbackFormula.formulaParts.map { it.toMutableList() } + modifiedAt = feedbackFormula.modifiedAt + datasetId = feedbackFormula.datasetId + sessionId = feedbackFormula.sessionId + additionalProperties = feedbackFormula.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun aggregationType(aggregationType: AggregationType) = + aggregationType(JsonField.of(aggregationType)) + + /** + * Sets [Builder.aggregationType] to an arbitrary JSON value. + * + * You should usually call [Builder.aggregationType] with a well-typed [AggregationType] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun aggregationType(aggregationType: JsonField<AggregationType>) = apply { + this.aggregationType = aggregationType + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun feedbackKey(feedbackKey: String) = feedbackKey(JsonField.of(feedbackKey)) + + /** + * Sets [Builder.feedbackKey] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun feedbackKey(feedbackKey: JsonField<String>) = apply { this.feedbackKey = feedbackKey } + + fun formulaParts(formulaParts: List<FeedbackFormulaWeightedVariable>) = + formulaParts(JsonField.of(formulaParts)) + + /** + * Sets [Builder.formulaParts] to an arbitrary JSON value. + * + * You should usually call [Builder.formulaParts] with a well-typed + * `List<FeedbackFormulaWeightedVariable>` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun formulaParts(formulaParts: JsonField<List<FeedbackFormulaWeightedVariable>>) = apply { + this.formulaParts = formulaParts.map { it.toMutableList() } + } + + /** + * Adds a single [FeedbackFormulaWeightedVariable] to [formulaParts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFormulaPart(formulaPart: FeedbackFormulaWeightedVariable) = apply { + formulaParts = + (formulaParts ?: JsonField.of(mutableListOf())).also { + checkKnown("formulaParts", it).add(formulaPart) + } + } + + fun modifiedAt(modifiedAt: OffsetDateTime) = modifiedAt(JsonField.of(modifiedAt)) + + /** + * Sets [Builder.modifiedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.modifiedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modifiedAt(modifiedAt: JsonField<OffsetDateTime>) = apply { + this.modifiedAt = modifiedAt + } + + fun datasetId(datasetId: String?) = datasetId(JsonField.ofNullable(datasetId)) + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + /** + * Sets [Builder.datasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun datasetId(datasetId: JsonField<String>) = apply { this.datasetId = datasetId } + + fun sessionId(sessionId: String?) = sessionId(JsonField.ofNullable(sessionId)) + + /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ + fun sessionId(sessionId: Optional<String>) = sessionId(sessionId.getOrNull()) + + /** + * Sets [Builder.sessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun sessionId(sessionId: JsonField<String>) = apply { this.sessionId = sessionId } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FeedbackFormula]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .aggregationType() + * .createdAt() + * .feedbackKey() + * .formulaParts() + * .modifiedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FeedbackFormula = + FeedbackFormula( + checkRequired("id", id), + checkRequired("aggregationType", aggregationType), + checkRequired("createdAt", createdAt), + checkRequired("feedbackKey", feedbackKey), + checkRequired("formulaParts", formulaParts).map { it.toImmutable() }, + checkRequired("modifiedAt", modifiedAt), + datasetId, + sessionId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): FeedbackFormula = apply { + if (validated) { + return@apply + } + + id() + aggregationType().validate() + createdAt() + feedbackKey() + formulaParts().forEach { it.validate() } + modifiedAt() + datasetId() + sessionId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (aggregationType.asKnown().getOrNull()?.validity() ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (feedbackKey.asKnown().isPresent) 1 else 0) + + (formulaParts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (modifiedAt.asKnown().isPresent) 1 else 0) + + (if (datasetId.asKnown().isPresent) 1 else 0) + + (if (sessionId.asKnown().isPresent) 1 else 0) + + class AggregationType @JsonCreator private constructor(private val value: JsonField<String>) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val SUM = of("sum") + + @JvmField val AVG = of("avg") + + @JvmStatic fun of(value: String) = AggregationType(JsonField.of(value)) + } + + /** An enum containing [AggregationType]'s known values. */ + enum class Known { + SUM, + AVG, + } + + /** + * An enum containing [AggregationType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AggregationType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SUM, + AVG, + /** + * An enum member indicating that [AggregationType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SUM -> Value.SUM + AVG -> Value.AVG + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SUM -> Known.SUM + AVG -> Known.AVG + else -> throw LangsmithApiInvalidDataException("Unknown AggregationType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AggregationType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AggregationType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackFormula && + id == other.id && + aggregationType == other.aggregationType && + createdAt == other.createdAt && + feedbackKey == other.feedbackKey && + formulaParts == other.formulaParts && + modifiedAt == other.modifiedAt && + datasetId == other.datasetId && + sessionId == other.sessionId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + aggregationType, + createdAt, + feedbackKey, + formulaParts, + modifiedAt, + datasetId, + sessionId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FeedbackFormula{id=$id, aggregationType=$aggregationType, createdAt=$createdAt, feedbackKey=$feedbackKey, formulaParts=$formulaParts, modifiedAt=$modifiedAt, datasetId=$datasetId, sessionId=$sessionId, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FeedbackFormulaWeightedVariable.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FeedbackFormulaWeightedVariable.kt new file mode 100644 index 00000000..25bdc8d9 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FeedbackFormulaWeightedVariable.kt @@ -0,0 +1,245 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback.formulas + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class FeedbackFormulaWeightedVariable +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val key: JsonField<String>, + private val partType: JsonValue, + private val weight: JsonField<Double>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("key") @ExcludeMissing key: JsonField<String> = JsonMissing.of(), + @JsonProperty("part_type") @ExcludeMissing partType: JsonValue = JsonMissing.of(), + @JsonProperty("weight") @ExcludeMissing weight: JsonField<Double> = JsonMissing.of(), + ) : this(key, partType, weight, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun key(): String = key.getRequired("key") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("weighted_key") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("part_type") @ExcludeMissing fun _partType(): JsonValue = partType + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun weight(): Double = weight.getRequired("weight") + + /** + * Returns the raw JSON value of [key]. + * + * Unlike [key], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("key") @ExcludeMissing fun _key(): JsonField<String> = key + + /** + * Returns the raw JSON value of [weight]. + * + * Unlike [weight], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("weight") @ExcludeMissing fun _weight(): JsonField<Double> = weight + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [FeedbackFormulaWeightedVariable]. + * + * The following fields are required: + * ```java + * .key() + * .weight() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackFormulaWeightedVariable]. */ + class Builder internal constructor() { + + private var key: JsonField<String>? = null + private var partType: JsonValue = JsonValue.from("weighted_key") + private var weight: JsonField<Double>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(feedbackFormulaWeightedVariable: FeedbackFormulaWeightedVariable) = + apply { + key = feedbackFormulaWeightedVariable.key + partType = feedbackFormulaWeightedVariable.partType + weight = feedbackFormulaWeightedVariable.weight + additionalProperties = + feedbackFormulaWeightedVariable.additionalProperties.toMutableMap() + } + + fun key(key: String) = key(JsonField.of(key)) + + /** + * Sets [Builder.key] to an arbitrary JSON value. + * + * You should usually call [Builder.key] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun key(key: JsonField<String>) = apply { this.key = key } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("weighted_key") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun partType(partType: JsonValue) = apply { this.partType = partType } + + fun weight(weight: Double) = weight(JsonField.of(weight)) + + /** + * Sets [Builder.weight] to an arbitrary JSON value. + * + * You should usually call [Builder.weight] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun weight(weight: JsonField<Double>) = apply { this.weight = weight } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FeedbackFormulaWeightedVariable]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .key() + * .weight() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FeedbackFormulaWeightedVariable = + FeedbackFormulaWeightedVariable( + checkRequired("key", key), + partType, + checkRequired("weight", weight), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): FeedbackFormulaWeightedVariable = apply { + if (validated) { + return@apply + } + + key() + _partType().let { + if (it != JsonValue.from("weighted_key")) { + throw LangsmithApiInvalidDataException("'partType' is invalid, received $it") + } + } + weight() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (key.asKnown().isPresent) 1 else 0) + + partType.let { if (it == JsonValue.from("weighted_key")) 1 else 0 } + + (if (weight.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackFormulaWeightedVariable && + key == other.key && + partType == other.partType && + weight == other.weight && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(key, partType, weight, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FeedbackFormulaWeightedVariable{key=$key, partType=$partType, weight=$weight, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaCreateParams.kt new file mode 100644 index 00000000..e0deaf5e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaCreateParams.kt @@ -0,0 +1,867 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback.formulas + +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.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create Feedback Formula Ep */ +class FormulaCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun aggregationType(): AggregationType = body.aggregationType() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun feedbackKey(): String = body.feedbackKey() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun formulaParts(): List<FeedbackFormulaWeightedVariable> = body.formulaParts() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun datasetId(): Optional<String> = body.datasetId() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun sessionId(): Optional<String> = body.sessionId() + + /** + * Returns the raw JSON value of [aggregationType]. + * + * Unlike [aggregationType], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _aggregationType(): JsonField<AggregationType> = body._aggregationType() + + /** + * Returns the raw JSON value of [feedbackKey]. + * + * Unlike [feedbackKey], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _feedbackKey(): JsonField<String> = body._feedbackKey() + + /** + * Returns the raw JSON value of [formulaParts]. + * + * Unlike [formulaParts], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _formulaParts(): JsonField<List<FeedbackFormulaWeightedVariable>> = body._formulaParts() + + /** + * Returns the raw JSON value of [datasetId]. + * + * Unlike [datasetId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _datasetId(): JsonField<String> = body._datasetId() + + /** + * Returns the raw JSON value of [sessionId]. + * + * Unlike [sessionId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _sessionId(): JsonField<String> = body._sessionId() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [FormulaCreateParams]. + * + * The following fields are required: + * ```java + * .aggregationType() + * .feedbackKey() + * .formulaParts() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FormulaCreateParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(formulaCreateParams: FormulaCreateParams) = apply { + body = formulaCreateParams.body.toBuilder() + additionalHeaders = formulaCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = formulaCreateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [aggregationType] + * - [feedbackKey] + * - [formulaParts] + * - [datasetId] + * - [sessionId] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun aggregationType(aggregationType: AggregationType) = apply { + body.aggregationType(aggregationType) + } + + /** + * Sets [Builder.aggregationType] to an arbitrary JSON value. + * + * You should usually call [Builder.aggregationType] with a well-typed [AggregationType] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun aggregationType(aggregationType: JsonField<AggregationType>) = apply { + body.aggregationType(aggregationType) + } + + fun feedbackKey(feedbackKey: String) = apply { body.feedbackKey(feedbackKey) } + + /** + * Sets [Builder.feedbackKey] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun feedbackKey(feedbackKey: JsonField<String>) = apply { body.feedbackKey(feedbackKey) } + + fun formulaParts(formulaParts: List<FeedbackFormulaWeightedVariable>) = apply { + body.formulaParts(formulaParts) + } + + /** + * Sets [Builder.formulaParts] to an arbitrary JSON value. + * + * You should usually call [Builder.formulaParts] with a well-typed + * `List<FeedbackFormulaWeightedVariable>` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun formulaParts(formulaParts: JsonField<List<FeedbackFormulaWeightedVariable>>) = apply { + body.formulaParts(formulaParts) + } + + /** + * Adds a single [FeedbackFormulaWeightedVariable] to [formulaParts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFormulaPart(formulaPart: FeedbackFormulaWeightedVariable) = apply { + body.addFormulaPart(formulaPart) + } + + fun datasetId(datasetId: String?) = apply { body.datasetId(datasetId) } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + /** + * Sets [Builder.datasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun datasetId(datasetId: JsonField<String>) = apply { body.datasetId(datasetId) } + + fun sessionId(sessionId: String?) = apply { body.sessionId(sessionId) } + + /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ + fun sessionId(sessionId: Optional<String>) = sessionId(sessionId.getOrNull()) + + /** + * Sets [Builder.sessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun sessionId(sessionId: JsonField<String>) = apply { body.sessionId(sessionId) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [FormulaCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .aggregationType() + * .feedbackKey() + * .formulaParts() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FormulaCreateParams = + FormulaCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val aggregationType: JsonField<AggregationType>, + private val feedbackKey: JsonField<String>, + private val formulaParts: JsonField<List<FeedbackFormulaWeightedVariable>>, + private val datasetId: JsonField<String>, + private val sessionId: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("aggregation_type") + @ExcludeMissing + aggregationType: JsonField<AggregationType> = JsonMissing.of(), + @JsonProperty("feedback_key") + @ExcludeMissing + feedbackKey: JsonField<String> = JsonMissing.of(), + @JsonProperty("formula_parts") + @ExcludeMissing + formulaParts: JsonField<List<FeedbackFormulaWeightedVariable>> = JsonMissing.of(), + @JsonProperty("dataset_id") + @ExcludeMissing + datasetId: JsonField<String> = JsonMissing.of(), + @JsonProperty("session_id") + @ExcludeMissing + sessionId: JsonField<String> = JsonMissing.of(), + ) : this(aggregationType, feedbackKey, formulaParts, datasetId, sessionId, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun aggregationType(): AggregationType = aggregationType.getRequired("aggregation_type") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun feedbackKey(): String = feedbackKey.getRequired("feedback_key") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun formulaParts(): List<FeedbackFormulaWeightedVariable> = + formulaParts.getRequired("formula_parts") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun datasetId(): Optional<String> = datasetId.getOptional("dataset_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun sessionId(): Optional<String> = sessionId.getOptional("session_id") + + /** + * Returns the raw JSON value of [aggregationType]. + * + * Unlike [aggregationType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("aggregation_type") + @ExcludeMissing + fun _aggregationType(): JsonField<AggregationType> = aggregationType + + /** + * Returns the raw JSON value of [feedbackKey]. + * + * Unlike [feedbackKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feedback_key") + @ExcludeMissing + fun _feedbackKey(): JsonField<String> = feedbackKey + + /** + * Returns the raw JSON value of [formulaParts]. + * + * Unlike [formulaParts], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("formula_parts") + @ExcludeMissing + fun _formulaParts(): JsonField<List<FeedbackFormulaWeightedVariable>> = formulaParts + + /** + * Returns the raw JSON value of [datasetId]. + * + * Unlike [datasetId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField<String> = datasetId + + /** + * Returns the raw JSON value of [sessionId]. + * + * Unlike [sessionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session_id") @ExcludeMissing fun _sessionId(): JsonField<String> = sessionId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .aggregationType() + * .feedbackKey() + * .formulaParts() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var aggregationType: JsonField<AggregationType>? = null + private var feedbackKey: JsonField<String>? = null + private var formulaParts: JsonField<MutableList<FeedbackFormulaWeightedVariable>>? = + null + private var datasetId: JsonField<String> = JsonMissing.of() + private var sessionId: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + aggregationType = body.aggregationType + feedbackKey = body.feedbackKey + formulaParts = body.formulaParts.map { it.toMutableList() } + datasetId = body.datasetId + sessionId = body.sessionId + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun aggregationType(aggregationType: AggregationType) = + aggregationType(JsonField.of(aggregationType)) + + /** + * Sets [Builder.aggregationType] to an arbitrary JSON value. + * + * You should usually call [Builder.aggregationType] with a well-typed [AggregationType] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun aggregationType(aggregationType: JsonField<AggregationType>) = apply { + this.aggregationType = aggregationType + } + + fun feedbackKey(feedbackKey: String) = feedbackKey(JsonField.of(feedbackKey)) + + /** + * Sets [Builder.feedbackKey] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun feedbackKey(feedbackKey: JsonField<String>) = apply { + this.feedbackKey = feedbackKey + } + + fun formulaParts(formulaParts: List<FeedbackFormulaWeightedVariable>) = + formulaParts(JsonField.of(formulaParts)) + + /** + * Sets [Builder.formulaParts] to an arbitrary JSON value. + * + * You should usually call [Builder.formulaParts] with a well-typed + * `List<FeedbackFormulaWeightedVariable>` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun formulaParts(formulaParts: JsonField<List<FeedbackFormulaWeightedVariable>>) = + apply { + this.formulaParts = formulaParts.map { it.toMutableList() } + } + + /** + * Adds a single [FeedbackFormulaWeightedVariable] to [formulaParts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFormulaPart(formulaPart: FeedbackFormulaWeightedVariable) = apply { + formulaParts = + (formulaParts ?: JsonField.of(mutableListOf())).also { + checkKnown("formulaParts", it).add(formulaPart) + } + } + + fun datasetId(datasetId: String?) = datasetId(JsonField.ofNullable(datasetId)) + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + /** + * Sets [Builder.datasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun datasetId(datasetId: JsonField<String>) = apply { this.datasetId = datasetId } + + fun sessionId(sessionId: String?) = sessionId(JsonField.ofNullable(sessionId)) + + /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ + fun sessionId(sessionId: Optional<String>) = sessionId(sessionId.getOrNull()) + + /** + * Sets [Builder.sessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sessionId(sessionId: JsonField<String>) = apply { this.sessionId = sessionId } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .aggregationType() + * .feedbackKey() + * .formulaParts() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("aggregationType", aggregationType), + checkRequired("feedbackKey", feedbackKey), + checkRequired("formulaParts", formulaParts).map { it.toImmutable() }, + datasetId, + sessionId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + aggregationType().validate() + feedbackKey() + formulaParts().forEach { it.validate() } + datasetId() + sessionId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (aggregationType.asKnown().getOrNull()?.validity() ?: 0) + + (if (feedbackKey.asKnown().isPresent) 1 else 0) + + (formulaParts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (datasetId.asKnown().isPresent) 1 else 0) + + (if (sessionId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + aggregationType == other.aggregationType && + feedbackKey == other.feedbackKey && + formulaParts == other.formulaParts && + datasetId == other.datasetId && + sessionId == other.sessionId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + aggregationType, + feedbackKey, + formulaParts, + datasetId, + sessionId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{aggregationType=$aggregationType, feedbackKey=$feedbackKey, formulaParts=$formulaParts, datasetId=$datasetId, sessionId=$sessionId, additionalProperties=$additionalProperties}" + } + + class AggregationType @JsonCreator private constructor(private val value: JsonField<String>) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val SUM = of("sum") + + @JvmField val AVG = of("avg") + + @JvmStatic fun of(value: String) = AggregationType(JsonField.of(value)) + } + + /** An enum containing [AggregationType]'s known values. */ + enum class Known { + SUM, + AVG, + } + + /** + * An enum containing [AggregationType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AggregationType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SUM, + AVG, + /** + * An enum member indicating that [AggregationType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SUM -> Value.SUM + AVG -> Value.AVG + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SUM -> Known.SUM + AVG -> Known.AVG + else -> throw LangsmithApiInvalidDataException("Unknown AggregationType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AggregationType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AggregationType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FormulaCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "FormulaCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaDeleteParams.kt new file mode 100644 index 00000000..d8b6271a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaDeleteParams.kt @@ -0,0 +1,237 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback.formulas + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete Feedback Formula Endpoint */ +class FormulaDeleteParams +private constructor( + private val feedbackFormulaId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun feedbackFormulaId(): Optional<String> = Optional.ofNullable(feedbackFormulaId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): FormulaDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [FormulaDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FormulaDeleteParams]. */ + class Builder internal constructor() { + + private var feedbackFormulaId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(formulaDeleteParams: FormulaDeleteParams) = apply { + feedbackFormulaId = formulaDeleteParams.feedbackFormulaId + additionalHeaders = formulaDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = formulaDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = formulaDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun feedbackFormulaId(feedbackFormulaId: String?) = apply { + this.feedbackFormulaId = feedbackFormulaId + } + + /** Alias for calling [Builder.feedbackFormulaId] with `feedbackFormulaId.orElse(null)`. */ + fun feedbackFormulaId(feedbackFormulaId: Optional<String>) = + feedbackFormulaId(feedbackFormulaId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [FormulaDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FormulaDeleteParams = + FormulaDeleteParams( + feedbackFormulaId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> feedbackFormulaId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FormulaDeleteParams && + feedbackFormulaId == other.feedbackFormulaId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + feedbackFormulaId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "FormulaDeleteParams{feedbackFormulaId=$feedbackFormulaId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaDeleteResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaDeleteResponse.kt new file mode 100644 index 00000000..bb633649 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaDeleteResponse.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback.formulas + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class FormulaDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [FormulaDeleteResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FormulaDeleteResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(formulaDeleteResponse: FormulaDeleteResponse) = apply { + additionalProperties = formulaDeleteResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FormulaDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FormulaDeleteResponse = + FormulaDeleteResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): FormulaDeleteResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FormulaDeleteResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "FormulaDeleteResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaListParams.kt new file mode 100644 index 00000000..d0fd5e68 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaListParams.kt @@ -0,0 +1,247 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback.formulas + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** List Feedback Formula Ep */ +class FormulaListParams +private constructor( + private val datasetId: String?, + private val limit: Long?, + private val offset: Long?, + private val sessionId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun datasetId(): Optional<String> = Optional.ofNullable(datasetId) + + fun limit(): Optional<Long> = Optional.ofNullable(limit) + + fun offset(): Optional<Long> = Optional.ofNullable(offset) + + fun sessionId(): Optional<String> = Optional.ofNullable(sessionId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): FormulaListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [FormulaListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FormulaListParams]. */ + class Builder internal constructor() { + + private var datasetId: String? = null + private var limit: Long? = null + private var offset: Long? = null + private var sessionId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(formulaListParams: FormulaListParams) = apply { + datasetId = formulaListParams.datasetId + limit = formulaListParams.limit + offset = formulaListParams.offset + sessionId = formulaListParams.sessionId + additionalHeaders = formulaListParams.additionalHeaders.toBuilder() + additionalQueryParams = formulaListParams.additionalQueryParams.toBuilder() + } + + fun datasetId(datasetId: String?) = apply { this.datasetId = datasetId } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional<Long>) = limit(limit.getOrNull()) + + fun offset(offset: Long?) = apply { this.offset = offset } + + /** + * Alias for [Builder.offset]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun offset(offset: Long) = offset(offset as Long?) + + /** Alias for calling [Builder.offset] with `offset.orElse(null)`. */ + fun offset(offset: Optional<Long>) = offset(offset.getOrNull()) + + fun sessionId(sessionId: String?) = apply { this.sessionId = sessionId } + + /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ + fun sessionId(sessionId: Optional<String>) = sessionId(sessionId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [FormulaListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FormulaListParams = + FormulaListParams( + datasetId, + limit, + offset, + sessionId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + datasetId?.let { put("dataset_id", it) } + limit?.let { put("limit", it.toString()) } + offset?.let { put("offset", it.toString()) } + sessionId?.let { put("session_id", it) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FormulaListParams && + datasetId == other.datasetId && + limit == other.limit && + offset == other.offset && + sessionId == other.sessionId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(datasetId, limit, offset, sessionId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "FormulaListParams{datasetId=$datasetId, limit=$limit, offset=$offset, sessionId=$sessionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaRetrieveParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaRetrieveParams.kt new file mode 100644 index 00000000..c0f7f163 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaRetrieveParams.kt @@ -0,0 +1,197 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback.formulas + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get Feedback Formula Ep */ +class FormulaRetrieveParams +private constructor( + private val feedbackFormulaId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun feedbackFormulaId(): Optional<String> = Optional.ofNullable(feedbackFormulaId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): FormulaRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [FormulaRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FormulaRetrieveParams]. */ + class Builder internal constructor() { + + private var feedbackFormulaId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(formulaRetrieveParams: FormulaRetrieveParams) = apply { + feedbackFormulaId = formulaRetrieveParams.feedbackFormulaId + additionalHeaders = formulaRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = formulaRetrieveParams.additionalQueryParams.toBuilder() + } + + fun feedbackFormulaId(feedbackFormulaId: String?) = apply { + this.feedbackFormulaId = feedbackFormulaId + } + + /** Alias for calling [Builder.feedbackFormulaId] with `feedbackFormulaId.orElse(null)`. */ + fun feedbackFormulaId(feedbackFormulaId: Optional<String>) = + feedbackFormulaId(feedbackFormulaId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [FormulaRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FormulaRetrieveParams = + FormulaRetrieveParams( + feedbackFormulaId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> feedbackFormulaId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FormulaRetrieveParams && + feedbackFormulaId == other.feedbackFormulaId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(feedbackFormulaId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "FormulaRetrieveParams{feedbackFormulaId=$feedbackFormulaId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaUpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaUpdateParams.kt new file mode 100644 index 00000000..05c13803 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaUpdateParams.kt @@ -0,0 +1,751 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback.formulas + +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.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Update Feedback Formula Ep */ +class FormulaUpdateParams +private constructor( + private val feedbackFormulaId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun feedbackFormulaId(): Optional<String> = Optional.ofNullable(feedbackFormulaId) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun aggregationType(): AggregationType = body.aggregationType() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun feedbackKey(): String = body.feedbackKey() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun formulaParts(): List<FeedbackFormulaWeightedVariable> = body.formulaParts() + + /** + * Returns the raw JSON value of [aggregationType]. + * + * Unlike [aggregationType], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _aggregationType(): JsonField<AggregationType> = body._aggregationType() + + /** + * Returns the raw JSON value of [feedbackKey]. + * + * Unlike [feedbackKey], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _feedbackKey(): JsonField<String> = body._feedbackKey() + + /** + * Returns the raw JSON value of [formulaParts]. + * + * Unlike [formulaParts], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _formulaParts(): JsonField<List<FeedbackFormulaWeightedVariable>> = body._formulaParts() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [FormulaUpdateParams]. + * + * The following fields are required: + * ```java + * .aggregationType() + * .feedbackKey() + * .formulaParts() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FormulaUpdateParams]. */ + class Builder internal constructor() { + + private var feedbackFormulaId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(formulaUpdateParams: FormulaUpdateParams) = apply { + feedbackFormulaId = formulaUpdateParams.feedbackFormulaId + body = formulaUpdateParams.body.toBuilder() + additionalHeaders = formulaUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = formulaUpdateParams.additionalQueryParams.toBuilder() + } + + fun feedbackFormulaId(feedbackFormulaId: String?) = apply { + this.feedbackFormulaId = feedbackFormulaId + } + + /** Alias for calling [Builder.feedbackFormulaId] with `feedbackFormulaId.orElse(null)`. */ + fun feedbackFormulaId(feedbackFormulaId: Optional<String>) = + feedbackFormulaId(feedbackFormulaId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [aggregationType] + * - [feedbackKey] + * - [formulaParts] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun aggregationType(aggregationType: AggregationType) = apply { + body.aggregationType(aggregationType) + } + + /** + * Sets [Builder.aggregationType] to an arbitrary JSON value. + * + * You should usually call [Builder.aggregationType] with a well-typed [AggregationType] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun aggregationType(aggregationType: JsonField<AggregationType>) = apply { + body.aggregationType(aggregationType) + } + + fun feedbackKey(feedbackKey: String) = apply { body.feedbackKey(feedbackKey) } + + /** + * Sets [Builder.feedbackKey] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun feedbackKey(feedbackKey: JsonField<String>) = apply { body.feedbackKey(feedbackKey) } + + fun formulaParts(formulaParts: List<FeedbackFormulaWeightedVariable>) = apply { + body.formulaParts(formulaParts) + } + + /** + * Sets [Builder.formulaParts] to an arbitrary JSON value. + * + * You should usually call [Builder.formulaParts] with a well-typed + * `List<FeedbackFormulaWeightedVariable>` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun formulaParts(formulaParts: JsonField<List<FeedbackFormulaWeightedVariable>>) = apply { + body.formulaParts(formulaParts) + } + + /** + * Adds a single [FeedbackFormulaWeightedVariable] to [formulaParts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFormulaPart(formulaPart: FeedbackFormulaWeightedVariable) = apply { + body.addFormulaPart(formulaPart) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [FormulaUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .aggregationType() + * .feedbackKey() + * .formulaParts() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FormulaUpdateParams = + FormulaUpdateParams( + feedbackFormulaId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> feedbackFormulaId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val aggregationType: JsonField<AggregationType>, + private val feedbackKey: JsonField<String>, + private val formulaParts: JsonField<List<FeedbackFormulaWeightedVariable>>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("aggregation_type") + @ExcludeMissing + aggregationType: JsonField<AggregationType> = JsonMissing.of(), + @JsonProperty("feedback_key") + @ExcludeMissing + feedbackKey: JsonField<String> = JsonMissing.of(), + @JsonProperty("formula_parts") + @ExcludeMissing + formulaParts: JsonField<List<FeedbackFormulaWeightedVariable>> = JsonMissing.of(), + ) : this(aggregationType, feedbackKey, formulaParts, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun aggregationType(): AggregationType = aggregationType.getRequired("aggregation_type") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun feedbackKey(): String = feedbackKey.getRequired("feedback_key") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun formulaParts(): List<FeedbackFormulaWeightedVariable> = + formulaParts.getRequired("formula_parts") + + /** + * Returns the raw JSON value of [aggregationType]. + * + * Unlike [aggregationType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("aggregation_type") + @ExcludeMissing + fun _aggregationType(): JsonField<AggregationType> = aggregationType + + /** + * Returns the raw JSON value of [feedbackKey]. + * + * Unlike [feedbackKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feedback_key") + @ExcludeMissing + fun _feedbackKey(): JsonField<String> = feedbackKey + + /** + * Returns the raw JSON value of [formulaParts]. + * + * Unlike [formulaParts], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("formula_parts") + @ExcludeMissing + fun _formulaParts(): JsonField<List<FeedbackFormulaWeightedVariable>> = formulaParts + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .aggregationType() + * .feedbackKey() + * .formulaParts() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var aggregationType: JsonField<AggregationType>? = null + private var feedbackKey: JsonField<String>? = null + private var formulaParts: JsonField<MutableList<FeedbackFormulaWeightedVariable>>? = + null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + aggregationType = body.aggregationType + feedbackKey = body.feedbackKey + formulaParts = body.formulaParts.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun aggregationType(aggregationType: AggregationType) = + aggregationType(JsonField.of(aggregationType)) + + /** + * Sets [Builder.aggregationType] to an arbitrary JSON value. + * + * You should usually call [Builder.aggregationType] with a well-typed [AggregationType] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun aggregationType(aggregationType: JsonField<AggregationType>) = apply { + this.aggregationType = aggregationType + } + + fun feedbackKey(feedbackKey: String) = feedbackKey(JsonField.of(feedbackKey)) + + /** + * Sets [Builder.feedbackKey] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun feedbackKey(feedbackKey: JsonField<String>) = apply { + this.feedbackKey = feedbackKey + } + + fun formulaParts(formulaParts: List<FeedbackFormulaWeightedVariable>) = + formulaParts(JsonField.of(formulaParts)) + + /** + * Sets [Builder.formulaParts] to an arbitrary JSON value. + * + * You should usually call [Builder.formulaParts] with a well-typed + * `List<FeedbackFormulaWeightedVariable>` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun formulaParts(formulaParts: JsonField<List<FeedbackFormulaWeightedVariable>>) = + apply { + this.formulaParts = formulaParts.map { it.toMutableList() } + } + + /** + * Adds a single [FeedbackFormulaWeightedVariable] to [formulaParts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFormulaPart(formulaPart: FeedbackFormulaWeightedVariable) = apply { + formulaParts = + (formulaParts ?: JsonField.of(mutableListOf())).also { + checkKnown("formulaParts", it).add(formulaPart) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .aggregationType() + * .feedbackKey() + * .formulaParts() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("aggregationType", aggregationType), + checkRequired("feedbackKey", feedbackKey), + checkRequired("formulaParts", formulaParts).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + aggregationType().validate() + feedbackKey() + formulaParts().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (aggregationType.asKnown().getOrNull()?.validity() ?: 0) + + (if (feedbackKey.asKnown().isPresent) 1 else 0) + + (formulaParts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + aggregationType == other.aggregationType && + feedbackKey == other.feedbackKey && + formulaParts == other.formulaParts && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(aggregationType, feedbackKey, formulaParts, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{aggregationType=$aggregationType, feedbackKey=$feedbackKey, formulaParts=$formulaParts, additionalProperties=$additionalProperties}" + } + + class AggregationType @JsonCreator private constructor(private val value: JsonField<String>) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val SUM = of("sum") + + @JvmField val AVG = of("avg") + + @JvmStatic fun of(value: String) = AggregationType(JsonField.of(value)) + } + + /** An enum containing [AggregationType]'s known values. */ + enum class Known { + SUM, + AVG, + } + + /** + * An enum containing [AggregationType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AggregationType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SUM, + AVG, + /** + * An enum member indicating that [AggregationType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SUM -> Value.SUM + AVG -> Value.AVG + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SUM -> Known.SUM + AVG -> Known.AVG + else -> throw LangsmithApiInvalidDataException("Unknown AggregationType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AggregationType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AggregationType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FormulaUpdateParams && + feedbackFormulaId == other.feedbackFormulaId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(feedbackFormulaId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "FormulaUpdateParams{feedbackFormulaId=$feedbackFormulaId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/FeedbackIngestTokenCreateSchema.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/FeedbackIngestTokenCreateSchema.kt new file mode 100644 index 00000000..28750be9 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/FeedbackIngestTokenCreateSchema.kt @@ -0,0 +1,345 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback.tokens + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfig +import com.langsmith_api.api.models.api.v1.sessions.TimedeltaInput +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Feedback ingest token create schema. */ +class FeedbackIngestTokenCreateSchema +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val feedbackKey: JsonField<String>, + private val runId: JsonField<String>, + private val expiresAt: JsonField<OffsetDateTime>, + private val expiresIn: JsonField<TimedeltaInput>, + private val feedbackConfig: JsonField<FeedbackConfig>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("feedback_key") + @ExcludeMissing + feedbackKey: JsonField<String> = JsonMissing.of(), + @JsonProperty("run_id") @ExcludeMissing runId: JsonField<String> = JsonMissing.of(), + @JsonProperty("expires_at") + @ExcludeMissing + expiresAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("expires_in") + @ExcludeMissing + expiresIn: JsonField<TimedeltaInput> = JsonMissing.of(), + @JsonProperty("feedback_config") + @ExcludeMissing + feedbackConfig: JsonField<FeedbackConfig> = JsonMissing.of(), + ) : this(feedbackKey, runId, expiresAt, expiresIn, feedbackConfig, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun feedbackKey(): String = feedbackKey.getRequired("feedback_key") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun runId(): String = runId.getRequired("run_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun expiresAt(): Optional<OffsetDateTime> = expiresAt.getOptional("expires_at") + + /** + * Timedelta input. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun expiresIn(): Optional<TimedeltaInput> = expiresIn.getOptional("expires_in") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun feedbackConfig(): Optional<FeedbackConfig> = feedbackConfig.getOptional("feedback_config") + + /** + * Returns the raw JSON value of [feedbackKey]. + * + * Unlike [feedbackKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feedback_key") + @ExcludeMissing + fun _feedbackKey(): JsonField<String> = feedbackKey + + /** + * Returns the raw JSON value of [runId]. + * + * Unlike [runId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_id") @ExcludeMissing fun _runId(): JsonField<String> = runId + + /** + * Returns the raw JSON value of [expiresAt]. + * + * Unlike [expiresAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expires_at") + @ExcludeMissing + fun _expiresAt(): JsonField<OffsetDateTime> = expiresAt + + /** + * Returns the raw JSON value of [expiresIn]. + * + * Unlike [expiresIn], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expires_in") + @ExcludeMissing + fun _expiresIn(): JsonField<TimedeltaInput> = expiresIn + + /** + * Returns the raw JSON value of [feedbackConfig]. + * + * Unlike [feedbackConfig], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feedback_config") + @ExcludeMissing + fun _feedbackConfig(): JsonField<FeedbackConfig> = feedbackConfig + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [FeedbackIngestTokenCreateSchema]. + * + * The following fields are required: + * ```java + * .feedbackKey() + * .runId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackIngestTokenCreateSchema]. */ + class Builder internal constructor() { + + private var feedbackKey: JsonField<String>? = null + private var runId: JsonField<String>? = null + private var expiresAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var expiresIn: JsonField<TimedeltaInput> = JsonMissing.of() + private var feedbackConfig: JsonField<FeedbackConfig> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(feedbackIngestTokenCreateSchema: FeedbackIngestTokenCreateSchema) = + apply { + feedbackKey = feedbackIngestTokenCreateSchema.feedbackKey + runId = feedbackIngestTokenCreateSchema.runId + expiresAt = feedbackIngestTokenCreateSchema.expiresAt + expiresIn = feedbackIngestTokenCreateSchema.expiresIn + feedbackConfig = feedbackIngestTokenCreateSchema.feedbackConfig + additionalProperties = + feedbackIngestTokenCreateSchema.additionalProperties.toMutableMap() + } + + fun feedbackKey(feedbackKey: String) = feedbackKey(JsonField.of(feedbackKey)) + + /** + * Sets [Builder.feedbackKey] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun feedbackKey(feedbackKey: JsonField<String>) = apply { this.feedbackKey = feedbackKey } + + fun runId(runId: String) = runId(JsonField.of(runId)) + + /** + * Sets [Builder.runId] to an arbitrary JSON value. + * + * You should usually call [Builder.runId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun runId(runId: JsonField<String>) = apply { this.runId = runId } + + fun expiresAt(expiresAt: OffsetDateTime?) = expiresAt(JsonField.ofNullable(expiresAt)) + + /** Alias for calling [Builder.expiresAt] with `expiresAt.orElse(null)`. */ + fun expiresAt(expiresAt: Optional<OffsetDateTime>) = expiresAt(expiresAt.getOrNull()) + + /** + * Sets [Builder.expiresAt] to an arbitrary JSON value. + * + * You should usually call [Builder.expiresAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun expiresAt(expiresAt: JsonField<OffsetDateTime>) = apply { this.expiresAt = expiresAt } + + /** Timedelta input. */ + fun expiresIn(expiresIn: TimedeltaInput?) = expiresIn(JsonField.ofNullable(expiresIn)) + + /** Alias for calling [Builder.expiresIn] with `expiresIn.orElse(null)`. */ + fun expiresIn(expiresIn: Optional<TimedeltaInput>) = expiresIn(expiresIn.getOrNull()) + + /** + * Sets [Builder.expiresIn] to an arbitrary JSON value. + * + * You should usually call [Builder.expiresIn] with a well-typed [TimedeltaInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun expiresIn(expiresIn: JsonField<TimedeltaInput>) = apply { this.expiresIn = expiresIn } + + fun feedbackConfig(feedbackConfig: FeedbackConfig?) = + feedbackConfig(JsonField.ofNullable(feedbackConfig)) + + /** Alias for calling [Builder.feedbackConfig] with `feedbackConfig.orElse(null)`. */ + fun feedbackConfig(feedbackConfig: Optional<FeedbackConfig>) = + feedbackConfig(feedbackConfig.getOrNull()) + + /** + * Sets [Builder.feedbackConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackConfig] with a well-typed [FeedbackConfig] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun feedbackConfig(feedbackConfig: JsonField<FeedbackConfig>) = apply { + this.feedbackConfig = feedbackConfig + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FeedbackIngestTokenCreateSchema]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .feedbackKey() + * .runId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FeedbackIngestTokenCreateSchema = + FeedbackIngestTokenCreateSchema( + checkRequired("feedbackKey", feedbackKey), + checkRequired("runId", runId), + expiresAt, + expiresIn, + feedbackConfig, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): FeedbackIngestTokenCreateSchema = apply { + if (validated) { + return@apply + } + + feedbackKey() + runId() + expiresAt() + expiresIn().ifPresent { it.validate() } + feedbackConfig().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (feedbackKey.asKnown().isPresent) 1 else 0) + + (if (runId.asKnown().isPresent) 1 else 0) + + (if (expiresAt.asKnown().isPresent) 1 else 0) + + (expiresIn.asKnown().getOrNull()?.validity() ?: 0) + + (feedbackConfig.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackIngestTokenCreateSchema && + feedbackKey == other.feedbackKey && + runId == other.runId && + expiresAt == other.expiresAt && + expiresIn == other.expiresIn && + feedbackConfig == other.feedbackConfig && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(feedbackKey, runId, expiresAt, expiresIn, feedbackConfig, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FeedbackIngestTokenCreateSchema{feedbackKey=$feedbackKey, runId=$runId, expiresAt=$expiresAt, expiresIn=$expiresIn, feedbackConfig=$feedbackConfig, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/FeedbackIngestTokenSchema.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/FeedbackIngestTokenSchema.kt new file mode 100644 index 00000000..e5d5dd7f --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/FeedbackIngestTokenSchema.kt @@ -0,0 +1,285 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback.tokens + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects + +/** Feedback ingest token schema. */ +class FeedbackIngestTokenSchema +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val expiresAt: JsonField<OffsetDateTime>, + private val feedbackKey: JsonField<String>, + private val url: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("expires_at") + @ExcludeMissing + expiresAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("feedback_key") + @ExcludeMissing + feedbackKey: JsonField<String> = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField<String> = JsonMissing.of(), + ) : this(id, expiresAt, feedbackKey, url, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun expiresAt(): OffsetDateTime = expiresAt.getRequired("expires_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun feedbackKey(): String = feedbackKey.getRequired("feedback_key") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun url(): String = url.getRequired("url") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [expiresAt]. + * + * Unlike [expiresAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expires_at") + @ExcludeMissing + fun _expiresAt(): JsonField<OffsetDateTime> = expiresAt + + /** + * Returns the raw JSON value of [feedbackKey]. + * + * Unlike [feedbackKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feedback_key") + @ExcludeMissing + fun _feedbackKey(): JsonField<String> = feedbackKey + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField<String> = url + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [FeedbackIngestTokenSchema]. + * + * The following fields are required: + * ```java + * .id() + * .expiresAt() + * .feedbackKey() + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackIngestTokenSchema]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var expiresAt: JsonField<OffsetDateTime>? = null + private var feedbackKey: JsonField<String>? = null + private var url: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(feedbackIngestTokenSchema: FeedbackIngestTokenSchema) = apply { + id = feedbackIngestTokenSchema.id + expiresAt = feedbackIngestTokenSchema.expiresAt + feedbackKey = feedbackIngestTokenSchema.feedbackKey + url = feedbackIngestTokenSchema.url + additionalProperties = feedbackIngestTokenSchema.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun expiresAt(expiresAt: OffsetDateTime) = expiresAt(JsonField.of(expiresAt)) + + /** + * Sets [Builder.expiresAt] to an arbitrary JSON value. + * + * You should usually call [Builder.expiresAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun expiresAt(expiresAt: JsonField<OffsetDateTime>) = apply { this.expiresAt = expiresAt } + + fun feedbackKey(feedbackKey: String) = feedbackKey(JsonField.of(feedbackKey)) + + /** + * Sets [Builder.feedbackKey] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun feedbackKey(feedbackKey: JsonField<String>) = apply { this.feedbackKey = feedbackKey } + + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun url(url: JsonField<String>) = apply { this.url = url } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FeedbackIngestTokenSchema]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .expiresAt() + * .feedbackKey() + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FeedbackIngestTokenSchema = + FeedbackIngestTokenSchema( + checkRequired("id", id), + checkRequired("expiresAt", expiresAt), + checkRequired("feedbackKey", feedbackKey), + checkRequired("url", url), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): FeedbackIngestTokenSchema = apply { + if (validated) { + return@apply + } + + id() + expiresAt() + feedbackKey() + url() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (expiresAt.asKnown().isPresent) 1 else 0) + + (if (feedbackKey.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackIngestTokenSchema && + id == other.id && + expiresAt == other.expiresAt && + feedbackKey == other.feedbackKey && + url == other.url && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, expiresAt, feedbackKey, url, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FeedbackIngestTokenSchema{id=$id, expiresAt=$expiresAt, feedbackKey=$feedbackKey, url=$url, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenCreateParams.kt new file mode 100644 index 00000000..bba90bf9 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenCreateParams.kt @@ -0,0 +1,440 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback.tokens + +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 com.langsmith_api.api.core.BaseDeserializer +import com.langsmith_api.api.core.BaseSerializer +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.allMaxBy +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Objects +import java.util.Optional + +/** Create a new feedback ingest token. */ +class TokenCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Feedback ingest token create schema. */ + fun body(): Body = body + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TokenCreateParams]. + * + * The following fields are required: + * ```java + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TokenCreateParams]. */ + class Builder internal constructor() { + + private var body: Body? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(tokenCreateParams: TokenCreateParams) = apply { + body = tokenCreateParams.body + additionalHeaders = tokenCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = tokenCreateParams.additionalQueryParams.toBuilder() + } + + /** Feedback ingest token create schema. */ + fun body(body: Body) = apply { this.body = body } + + /** + * Alias for calling [body] with + * `Body.ofFeedbackIngestTokenCreateSchema(feedbackIngestTokenCreateSchema)`. + */ + fun body(feedbackIngestTokenCreateSchema: FeedbackIngestTokenCreateSchema) = + body(Body.ofFeedbackIngestTokenCreateSchema(feedbackIngestTokenCreateSchema)) + + /** + * Alias for calling [body] with + * `Body.ofFeedbackIngestTokenCreateSchemas(feedbackIngestTokenCreateSchemas)`. + */ + fun bodyOfFeedbackIngestTokenCreateSchemas( + feedbackIngestTokenCreateSchemas: List<FeedbackIngestTokenCreateSchema> + ) = body(Body.ofFeedbackIngestTokenCreateSchemas(feedbackIngestTokenCreateSchemas)) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TokenCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TokenCreateParams = + TokenCreateParams( + checkRequired("body", body), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Feedback ingest token create schema. */ + @JsonDeserialize(using = Body.Deserializer::class) + @JsonSerialize(using = Body.Serializer::class) + class Body + private constructor( + private val feedbackIngestTokenCreateSchema: FeedbackIngestTokenCreateSchema? = null, + private val feedbackIngestTokenCreateSchemas: List<FeedbackIngestTokenCreateSchema>? = null, + private val _json: JsonValue? = null, + ) { + + /** Feedback ingest token create schema. */ + fun feedbackIngestTokenCreateSchema(): Optional<FeedbackIngestTokenCreateSchema> = + Optional.ofNullable(feedbackIngestTokenCreateSchema) + + fun feedbackIngestTokenCreateSchemas(): Optional<List<FeedbackIngestTokenCreateSchema>> = + Optional.ofNullable(feedbackIngestTokenCreateSchemas) + + fun isFeedbackIngestTokenCreateSchema(): Boolean = feedbackIngestTokenCreateSchema != null + + fun isFeedbackIngestTokenCreateSchemas(): Boolean = feedbackIngestTokenCreateSchemas != null + + /** Feedback ingest token create schema. */ + fun asFeedbackIngestTokenCreateSchema(): FeedbackIngestTokenCreateSchema = + feedbackIngestTokenCreateSchema.getOrThrow("feedbackIngestTokenCreateSchema") + + fun asFeedbackIngestTokenCreateSchemas(): List<FeedbackIngestTokenCreateSchema> = + feedbackIngestTokenCreateSchemas.getOrThrow("feedbackIngestTokenCreateSchemas") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + feedbackIngestTokenCreateSchema != null -> + visitor.visitFeedbackIngestTokenCreateSchema(feedbackIngestTokenCreateSchema) + feedbackIngestTokenCreateSchemas != null -> + visitor.visitFeedbackIngestTokenCreateSchemas(feedbackIngestTokenCreateSchemas) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitFeedbackIngestTokenCreateSchema( + feedbackIngestTokenCreateSchema: FeedbackIngestTokenCreateSchema + ) { + feedbackIngestTokenCreateSchema.validate() + } + + override fun visitFeedbackIngestTokenCreateSchemas( + feedbackIngestTokenCreateSchemas: List<FeedbackIngestTokenCreateSchema> + ) { + feedbackIngestTokenCreateSchemas.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitFeedbackIngestTokenCreateSchema( + feedbackIngestTokenCreateSchema: FeedbackIngestTokenCreateSchema + ) = feedbackIngestTokenCreateSchema.validity() + + override fun visitFeedbackIngestTokenCreateSchemas( + feedbackIngestTokenCreateSchemas: List<FeedbackIngestTokenCreateSchema> + ) = feedbackIngestTokenCreateSchemas.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + feedbackIngestTokenCreateSchema == other.feedbackIngestTokenCreateSchema && + feedbackIngestTokenCreateSchemas == other.feedbackIngestTokenCreateSchemas + } + + override fun hashCode(): Int = + Objects.hash(feedbackIngestTokenCreateSchema, feedbackIngestTokenCreateSchemas) + + override fun toString(): String = + when { + feedbackIngestTokenCreateSchema != null -> + "Body{feedbackIngestTokenCreateSchema=$feedbackIngestTokenCreateSchema}" + feedbackIngestTokenCreateSchemas != null -> + "Body{feedbackIngestTokenCreateSchemas=$feedbackIngestTokenCreateSchemas}" + _json != null -> "Body{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Body") + } + + companion object { + + /** Feedback ingest token create schema. */ + @JvmStatic + fun ofFeedbackIngestTokenCreateSchema( + feedbackIngestTokenCreateSchema: FeedbackIngestTokenCreateSchema + ) = Body(feedbackIngestTokenCreateSchema = feedbackIngestTokenCreateSchema) + + @JvmStatic + fun ofFeedbackIngestTokenCreateSchemas( + feedbackIngestTokenCreateSchemas: List<FeedbackIngestTokenCreateSchema> + ) = + Body( + feedbackIngestTokenCreateSchemas = + feedbackIngestTokenCreateSchemas.toImmutable() + ) + } + + /** An interface that defines how to map each variant of [Body] to a value of type [T]. */ + interface Visitor<out T> { + + /** Feedback ingest token create schema. */ + fun visitFeedbackIngestTokenCreateSchema( + feedbackIngestTokenCreateSchema: FeedbackIngestTokenCreateSchema + ): T + + fun visitFeedbackIngestTokenCreateSchemas( + feedbackIngestTokenCreateSchemas: List<FeedbackIngestTokenCreateSchema> + ): T + + /** + * Maps an unknown variant of [Body] to a value of type [T]. + * + * An instance of [Body] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Body: $json") + } + } + + internal class Deserializer : BaseDeserializer<Body>(Body::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Body { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<FeedbackIngestTokenCreateSchema>()) + ?.let { Body(feedbackIngestTokenCreateSchema = it, _json = json) }, + tryDeserialize( + node, + jacksonTypeRef<List<FeedbackIngestTokenCreateSchema>>(), + ) + ?.let { Body(feedbackIngestTokenCreateSchemas = it, _json = json) }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> Body(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Body>(Body::class) { + + override fun serialize( + value: Body, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.feedbackIngestTokenCreateSchema != null -> + generator.writeObject(value.feedbackIngestTokenCreateSchema) + value.feedbackIngestTokenCreateSchemas != null -> + generator.writeObject(value.feedbackIngestTokenCreateSchemas) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Body") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TokenCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TokenCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenCreateResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenCreateResponse.kt new file mode 100644 index 00000000..f0aca9b5 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenCreateResponse.kt @@ -0,0 +1,230 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback.tokens + +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 com.langsmith_api.api.core.BaseDeserializer +import com.langsmith_api.api.core.BaseSerializer +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.allMaxBy +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Objects +import java.util.Optional + +/** Feedback ingest token schema. */ +@JsonDeserialize(using = TokenCreateResponse.Deserializer::class) +@JsonSerialize(using = TokenCreateResponse.Serializer::class) +class TokenCreateResponse +private constructor( + private val feedbackIngestTokenSchema: FeedbackIngestTokenSchema? = null, + private val feedbackIngestTokenSchemas: List<FeedbackIngestTokenSchema>? = null, + private val _json: JsonValue? = null, +) { + + /** Feedback ingest token schema. */ + fun feedbackIngestTokenSchema(): Optional<FeedbackIngestTokenSchema> = + Optional.ofNullable(feedbackIngestTokenSchema) + + fun feedbackIngestTokenSchemas(): Optional<List<FeedbackIngestTokenSchema>> = + Optional.ofNullable(feedbackIngestTokenSchemas) + + fun isFeedbackIngestTokenSchema(): Boolean = feedbackIngestTokenSchema != null + + fun isFeedbackIngestTokenSchemas(): Boolean = feedbackIngestTokenSchemas != null + + /** Feedback ingest token schema. */ + fun asFeedbackIngestTokenSchema(): FeedbackIngestTokenSchema = + feedbackIngestTokenSchema.getOrThrow("feedbackIngestTokenSchema") + + fun asFeedbackIngestTokenSchemas(): List<FeedbackIngestTokenSchema> = + feedbackIngestTokenSchemas.getOrThrow("feedbackIngestTokenSchemas") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + feedbackIngestTokenSchema != null -> + visitor.visitFeedbackIngestTokenSchema(feedbackIngestTokenSchema) + feedbackIngestTokenSchemas != null -> + visitor.visitFeedbackIngestTokenSchemas(feedbackIngestTokenSchemas) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): TokenCreateResponse = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitFeedbackIngestTokenSchema( + feedbackIngestTokenSchema: FeedbackIngestTokenSchema + ) { + feedbackIngestTokenSchema.validate() + } + + override fun visitFeedbackIngestTokenSchemas( + feedbackIngestTokenSchemas: List<FeedbackIngestTokenSchema> + ) { + feedbackIngestTokenSchemas.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitFeedbackIngestTokenSchema( + feedbackIngestTokenSchema: FeedbackIngestTokenSchema + ) = feedbackIngestTokenSchema.validity() + + override fun visitFeedbackIngestTokenSchemas( + feedbackIngestTokenSchemas: List<FeedbackIngestTokenSchema> + ) = feedbackIngestTokenSchemas.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TokenCreateResponse && + feedbackIngestTokenSchema == other.feedbackIngestTokenSchema && + feedbackIngestTokenSchemas == other.feedbackIngestTokenSchemas + } + + override fun hashCode(): Int = + Objects.hash(feedbackIngestTokenSchema, feedbackIngestTokenSchemas) + + override fun toString(): String = + when { + feedbackIngestTokenSchema != null -> + "TokenCreateResponse{feedbackIngestTokenSchema=$feedbackIngestTokenSchema}" + feedbackIngestTokenSchemas != null -> + "TokenCreateResponse{feedbackIngestTokenSchemas=$feedbackIngestTokenSchemas}" + _json != null -> "TokenCreateResponse{_unknown=$_json}" + else -> throw IllegalStateException("Invalid TokenCreateResponse") + } + + companion object { + + /** Feedback ingest token schema. */ + @JvmStatic + fun ofFeedbackIngestTokenSchema(feedbackIngestTokenSchema: FeedbackIngestTokenSchema) = + TokenCreateResponse(feedbackIngestTokenSchema = feedbackIngestTokenSchema) + + @JvmStatic + fun ofFeedbackIngestTokenSchemas( + feedbackIngestTokenSchemas: List<FeedbackIngestTokenSchema> + ) = + TokenCreateResponse( + feedbackIngestTokenSchemas = feedbackIngestTokenSchemas.toImmutable() + ) + } + + /** + * An interface that defines how to map each variant of [TokenCreateResponse] to a value of type + * [T]. + */ + interface Visitor<out T> { + + /** Feedback ingest token schema. */ + fun visitFeedbackIngestTokenSchema(feedbackIngestTokenSchema: FeedbackIngestTokenSchema): T + + fun visitFeedbackIngestTokenSchemas( + feedbackIngestTokenSchemas: List<FeedbackIngestTokenSchema> + ): T + + /** + * Maps an unknown variant of [TokenCreateResponse] to a value of type [T]. + * + * An instance of [TokenCreateResponse] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the SDK is + * on an older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown TokenCreateResponse: $json") + } + } + + internal class Deserializer : + BaseDeserializer<TokenCreateResponse>(TokenCreateResponse::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): TokenCreateResponse { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<FeedbackIngestTokenSchema>())?.let { + TokenCreateResponse(feedbackIngestTokenSchema = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<List<FeedbackIngestTokenSchema>>()) + ?.let { + TokenCreateResponse(feedbackIngestTokenSchemas = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with all + // the possible variants (e.g. deserializing from boolean). + 0 -> TokenCreateResponse(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<TokenCreateResponse>(TokenCreateResponse::class) { + + override fun serialize( + value: TokenCreateResponse, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.feedbackIngestTokenSchema != null -> + generator.writeObject(value.feedbackIngestTokenSchema) + value.feedbackIngestTokenSchemas != null -> + generator.writeObject(value.feedbackIngestTokenSchemas) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid TokenCreateResponse") + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenListParams.kt new file mode 100644 index 00000000..6bac286a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenListParams.kt @@ -0,0 +1,201 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback.tokens + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** List all feedback ingest tokens for a run. */ +class TokenListParams +private constructor( + private val runId: String, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun runId(): String = runId + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TokenListParams]. + * + * The following fields are required: + * ```java + * .runId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TokenListParams]. */ + class Builder internal constructor() { + + private var runId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(tokenListParams: TokenListParams) = apply { + runId = tokenListParams.runId + additionalHeaders = tokenListParams.additionalHeaders.toBuilder() + additionalQueryParams = tokenListParams.additionalQueryParams.toBuilder() + } + + fun runId(runId: String) = apply { this.runId = runId } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TokenListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .runId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TokenListParams = + TokenListParams( + checkRequired("runId", runId), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("run_id", runId) + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TokenListParams && + runId == other.runId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(runId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TokenListParams{runId=$runId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenRetrieveParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenRetrieveParams.kt new file mode 100644 index 00000000..c1097f3a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenRetrieveParams.kt @@ -0,0 +1,428 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback.tokens + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create a new feedback with a token. */ +class TokenRetrieveParams +private constructor( + private val token: String?, + private val comment: String?, + private val correction: String?, + private val score: Score?, + private val value: Value?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun token(): Optional<String> = Optional.ofNullable(token) + + fun comment(): Optional<String> = Optional.ofNullable(comment) + + fun correction(): Optional<String> = Optional.ofNullable(correction) + + fun score(): Optional<Score> = Optional.ofNullable(score) + + fun value(): Optional<Value> = Optional.ofNullable(value) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): TokenRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [TokenRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TokenRetrieveParams]. */ + class Builder internal constructor() { + + private var token: String? = null + private var comment: String? = null + private var correction: String? = null + private var score: Score? = null + private var value: Value? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(tokenRetrieveParams: TokenRetrieveParams) = apply { + token = tokenRetrieveParams.token + comment = tokenRetrieveParams.comment + correction = tokenRetrieveParams.correction + score = tokenRetrieveParams.score + value = tokenRetrieveParams.value + additionalHeaders = tokenRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = tokenRetrieveParams.additionalQueryParams.toBuilder() + } + + fun token(token: String?) = apply { this.token = token } + + /** Alias for calling [Builder.token] with `token.orElse(null)`. */ + fun token(token: Optional<String>) = token(token.getOrNull()) + + fun comment(comment: String?) = apply { this.comment = comment } + + /** Alias for calling [Builder.comment] with `comment.orElse(null)`. */ + fun comment(comment: Optional<String>) = comment(comment.getOrNull()) + + fun correction(correction: String?) = apply { this.correction = correction } + + /** Alias for calling [Builder.correction] with `correction.orElse(null)`. */ + fun correction(correction: Optional<String>) = correction(correction.getOrNull()) + + fun score(score: Score?) = apply { this.score = score } + + /** Alias for calling [Builder.score] with `score.orElse(null)`. */ + fun score(score: Optional<Score>) = score(score.getOrNull()) + + /** Alias for calling [score] with `Score.ofNumber(number)`. */ + fun score(number: Double) = score(Score.ofNumber(number)) + + /** Alias for calling [score] with `Score.ofBool(bool)`. */ + fun score(bool: Boolean) = score(Score.ofBool(bool)) + + fun value(value: Value?) = apply { this.value = value } + + /** Alias for calling [Builder.value] with `value.orElse(null)`. */ + fun value(value: Optional<Value>) = value(value.getOrNull()) + + /** Alias for calling [value] with `Value.ofNumber(number)`. */ + fun value(number: Double) = value(Value.ofNumber(number)) + + /** Alias for calling [value] with `Value.ofBool(bool)`. */ + fun value(bool: Boolean) = value(Value.ofBool(bool)) + + /** Alias for calling [value] with `Value.ofString(string)`. */ + fun value(string: String) = value(Value.ofString(string)) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TokenRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TokenRetrieveParams = + TokenRetrieveParams( + token, + comment, + correction, + score, + value, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> token ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + comment?.let { put("comment", it) } + correction?.let { put("correction", it) } + score?.accept( + object : Score.Visitor<Unit> { + override fun visitNumber(number: Double) { + put("score", number.toString()) + } + + override fun visitBool(bool: Boolean) { + put("score", bool.toString()) + } + } + ) + value?.accept( + object : Value.Visitor<Unit> { + override fun visitNumber(number: Double) { + put("value", number.toString()) + } + + override fun visitBool(bool: Boolean) { + put("value", bool.toString()) + } + + override fun visitString(string: String) { + put("value", string) + } + } + ) + putAll(additionalQueryParams) + } + .build() + + class Score + private constructor(private val number: Double? = null, private val bool: Boolean? = null) { + + fun number(): Optional<Double> = Optional.ofNullable(number) + + fun bool(): Optional<Boolean> = Optional.ofNullable(bool) + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun <T> accept(visitor: Visitor<T>): T = + when { + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + else -> throw IllegalStateException("Invalid Score") + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Score && number == other.number && bool == other.bool + } + + override fun hashCode(): Int = Objects.hash(number, bool) + + override fun toString(): String = + when { + number != null -> "Score{number=$number}" + bool != null -> "Score{bool=$bool}" + else -> throw IllegalStateException("Invalid Score") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Score(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = Score(bool = bool) + } + + /** An interface that defines how to map each variant of [Score] to a value of type [T]. */ + interface Visitor<out T> { + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + } + } + + class Value + private constructor( + private val number: Double? = null, + private val bool: Boolean? = null, + private val string: String? = null, + ) { + + fun number(): Optional<Double> = Optional.ofNullable(number) + + fun bool(): Optional<Boolean> = Optional.ofNullable(bool) + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun asString(): String = string.getOrThrow("string") + + fun <T> accept(visitor: Visitor<T>): T = + when { + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + string != null -> visitor.visitString(string) + else -> throw IllegalStateException("Invalid Value") + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + number == other.number && + bool == other.bool && + string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, bool, string) + + override fun toString(): String = + when { + number != null -> "Value{number=$number}" + bool != null -> "Value{bool=$bool}" + string != null -> "Value{string=$string}" + else -> throw IllegalStateException("Invalid Value") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Value(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) + + @JvmStatic fun ofString(string: String) = Value(string = string) + } + + /** An interface that defines how to map each variant of [Value] to a value of type [T]. */ + interface Visitor<out T> { + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + fun visitString(string: String): T + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TokenRetrieveParams && + token == other.token && + comment == other.comment && + correction == other.correction && + score == other.score && + value == other.value && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + token, + comment, + correction, + score, + value, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "TokenRetrieveParams{token=$token, comment=$comment, correction=$correction, score=$score, value=$value, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenRetrieveResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenRetrieveResponse.kt new file mode 100644 index 00000000..040e458b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenRetrieveResponse.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback.tokens + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class TokenRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [TokenRetrieveResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TokenRetrieveResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(tokenRetrieveResponse: TokenRetrieveResponse) = apply { + additionalProperties = tokenRetrieveResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TokenRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TokenRetrieveResponse = + TokenRetrieveResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): TokenRetrieveResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TokenRetrieveResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "TokenRetrieveResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenUpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenUpdateParams.kt new file mode 100644 index 00000000..12d5c47c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenUpdateParams.kt @@ -0,0 +1,1206 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback.tokens + +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 com.langsmith_api.api.core.BaseDeserializer +import com.langsmith_api.api.core.BaseSerializer +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.allMaxBy +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create a new feedback with a token. */ +class TokenUpdateParams +private constructor( + private val token: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun token(): Optional<String> = Optional.ofNullable(token) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun comment(): Optional<String> = body.comment() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun correction(): Optional<Correction> = body.correction() + + fun _metadata(): JsonValue = body._metadata() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun score(): Optional<Score> = body.score() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun value(): Optional<Value> = body.value() + + /** + * Returns the raw JSON value of [comment]. + * + * Unlike [comment], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _comment(): JsonField<String> = body._comment() + + /** + * Returns the raw JSON value of [correction]. + * + * Unlike [correction], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _correction(): JsonField<Correction> = body._correction() + + /** + * Returns the raw JSON value of [score]. + * + * Unlike [score], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _score(): JsonField<Score> = body._score() + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _value(): JsonField<Value> = body._value() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): TokenUpdateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [TokenUpdateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TokenUpdateParams]. */ + class Builder internal constructor() { + + private var token: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(tokenUpdateParams: TokenUpdateParams) = apply { + token = tokenUpdateParams.token + body = tokenUpdateParams.body.toBuilder() + additionalHeaders = tokenUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = tokenUpdateParams.additionalQueryParams.toBuilder() + } + + fun token(token: String?) = apply { this.token = token } + + /** Alias for calling [Builder.token] with `token.orElse(null)`. */ + fun token(token: Optional<String>) = token(token.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [comment] + * - [correction] + * - [metadata] + * - [score] + * - [value] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun comment(comment: String?) = apply { body.comment(comment) } + + /** Alias for calling [Builder.comment] with `comment.orElse(null)`. */ + fun comment(comment: Optional<String>) = comment(comment.getOrNull()) + + /** + * Sets [Builder.comment] to an arbitrary JSON value. + * + * You should usually call [Builder.comment] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun comment(comment: JsonField<String>) = apply { body.comment(comment) } + + fun correction(correction: Correction?) = apply { body.correction(correction) } + + /** Alias for calling [Builder.correction] with `correction.orElse(null)`. */ + fun correction(correction: Optional<Correction>) = correction(correction.getOrNull()) + + /** + * Sets [Builder.correction] to an arbitrary JSON value. + * + * You should usually call [Builder.correction] with a well-typed [Correction] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun correction(correction: JsonField<Correction>) = apply { body.correction(correction) } + + /** Alias for calling [correction] with `Correction.ofJsonValue(jsonValue)`. */ + fun correction(jsonValue: JsonValue) = apply { body.correction(jsonValue) } + + /** Alias for calling [correction] with `Correction.ofString(string)`. */ + fun correction(string: String) = apply { body.correction(string) } + + fun metadata(metadata: JsonValue) = apply { body.metadata(metadata) } + + fun score(score: Score?) = apply { body.score(score) } + + /** Alias for calling [Builder.score] with `score.orElse(null)`. */ + fun score(score: Optional<Score>) = score(score.getOrNull()) + + /** + * Sets [Builder.score] to an arbitrary JSON value. + * + * You should usually call [Builder.score] with a well-typed [Score] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun score(score: JsonField<Score>) = apply { body.score(score) } + + /** Alias for calling [score] with `Score.ofNumber(number)`. */ + fun score(number: Double) = apply { body.score(number) } + + /** Alias for calling [score] with `Score.ofBool(bool)`. */ + fun score(bool: Boolean) = apply { body.score(bool) } + + fun value(value: Value?) = apply { body.value(value) } + + /** Alias for calling [Builder.value] with `value.orElse(null)`. */ + fun value(value: Optional<Value>) = value(value.getOrNull()) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Value] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun value(value: JsonField<Value>) = apply { body.value(value) } + + /** Alias for calling [value] with `Value.ofNumber(number)`. */ + fun value(number: Double) = apply { body.value(number) } + + /** Alias for calling [value] with `Value.ofBool(bool)`. */ + fun value(bool: Boolean) = apply { body.value(bool) } + + /** Alias for calling [value] with `Value.ofString(string)`. */ + fun value(string: String) = apply { body.value(string) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TokenUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TokenUpdateParams = + TokenUpdateParams( + token, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> token ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Feedback create schema with token. */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val comment: JsonField<String>, + private val correction: JsonField<Correction>, + private val metadata: JsonValue, + private val score: JsonField<Score>, + private val value: JsonField<Value>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("comment") @ExcludeMissing comment: JsonField<String> = JsonMissing.of(), + @JsonProperty("correction") + @ExcludeMissing + correction: JsonField<Correction> = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("score") @ExcludeMissing score: JsonField<Score> = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField<Value> = JsonMissing.of(), + ) : this(comment, correction, metadata, score, value, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun comment(): Optional<String> = comment.getOptional("comment") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun correction(): Optional<Correction> = correction.getOptional("correction") + + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun score(): Optional<Score> = score.getOptional("score") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun value(): Optional<Value> = value.getOptional("value") + + /** + * Returns the raw JSON value of [comment]. + * + * Unlike [comment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("comment") @ExcludeMissing fun _comment(): JsonField<String> = comment + + /** + * Returns the raw JSON value of [correction]. + * + * Unlike [correction], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("correction") + @ExcludeMissing + fun _correction(): JsonField<Correction> = correction + + /** + * Returns the raw JSON value of [score]. + * + * Unlike [score], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("score") @ExcludeMissing fun _score(): JsonField<Score> = score + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField<Value> = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var comment: JsonField<String> = JsonMissing.of() + private var correction: JsonField<Correction> = JsonMissing.of() + private var metadata: JsonValue = JsonMissing.of() + private var score: JsonField<Score> = JsonMissing.of() + private var value: JsonField<Value> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + comment = body.comment + correction = body.correction + metadata = body.metadata + score = body.score + value = body.value + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun comment(comment: String?) = comment(JsonField.ofNullable(comment)) + + /** Alias for calling [Builder.comment] with `comment.orElse(null)`. */ + fun comment(comment: Optional<String>) = comment(comment.getOrNull()) + + /** + * Sets [Builder.comment] to an arbitrary JSON value. + * + * You should usually call [Builder.comment] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun comment(comment: JsonField<String>) = apply { this.comment = comment } + + fun correction(correction: Correction?) = correction(JsonField.ofNullable(correction)) + + /** Alias for calling [Builder.correction] with `correction.orElse(null)`. */ + fun correction(correction: Optional<Correction>) = correction(correction.getOrNull()) + + /** + * Sets [Builder.correction] to an arbitrary JSON value. + * + * You should usually call [Builder.correction] with a well-typed [Correction] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun correction(correction: JsonField<Correction>) = apply { + this.correction = correction + } + + /** Alias for calling [correction] with `Correction.ofJsonValue(jsonValue)`. */ + fun correction(jsonValue: JsonValue) = correction(Correction.ofJsonValue(jsonValue)) + + /** Alias for calling [correction] with `Correction.ofString(string)`. */ + fun correction(string: String) = correction(Correction.ofString(string)) + + fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + + fun score(score: Score?) = score(JsonField.ofNullable(score)) + + /** Alias for calling [Builder.score] with `score.orElse(null)`. */ + fun score(score: Optional<Score>) = score(score.getOrNull()) + + /** + * Sets [Builder.score] to an arbitrary JSON value. + * + * You should usually call [Builder.score] with a well-typed [Score] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun score(score: JsonField<Score>) = apply { this.score = score } + + /** Alias for calling [score] with `Score.ofNumber(number)`. */ + fun score(number: Double) = score(Score.ofNumber(number)) + + /** Alias for calling [score] with `Score.ofBool(bool)`. */ + fun score(bool: Boolean) = score(Score.ofBool(bool)) + + fun value(value: Value?) = value(JsonField.ofNullable(value)) + + /** Alias for calling [Builder.value] with `value.orElse(null)`. */ + fun value(value: Optional<Value>) = value(value.getOrNull()) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Value] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun value(value: JsonField<Value>) = apply { this.value = value } + + /** Alias for calling [value] with `Value.ofNumber(number)`. */ + fun value(number: Double) = value(Value.ofNumber(number)) + + /** Alias for calling [value] with `Value.ofBool(bool)`. */ + fun value(bool: Boolean) = value(Value.ofBool(bool)) + + /** Alias for calling [value] with `Value.ofString(string)`. */ + fun value(string: String) = value(Value.ofString(string)) + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = + Body( + comment, + correction, + metadata, + score, + value, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + comment() + correction().ifPresent { it.validate() } + score().ifPresent { it.validate() } + value().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (comment.asKnown().isPresent) 1 else 0) + + (correction.asKnown().getOrNull()?.validity() ?: 0) + + (score.asKnown().getOrNull()?.validity() ?: 0) + + (value.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + comment == other.comment && + correction == other.correction && + metadata == other.metadata && + score == other.score && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(comment, correction, metadata, score, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{comment=$comment, correction=$correction, metadata=$metadata, score=$score, value=$value, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = Correction.Deserializer::class) + @JsonSerialize(using = Correction.Serializer::class) + class Correction + private constructor( + private val jsonValue: JsonValue? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun jsonValue(): Optional<JsonValue> = Optional.ofNullable(jsonValue) + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun isJsonValue(): Boolean = jsonValue != null + + fun isString(): Boolean = string != null + + fun asJsonValue(): JsonValue = jsonValue.getOrThrow("jsonValue") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + jsonValue != null -> visitor.visitJsonValue(jsonValue) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Correction = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitJsonValue(jsonValue: JsonValue) {} + + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Correction && jsonValue == other.jsonValue && string == other.string + } + + override fun hashCode(): Int = Objects.hash(jsonValue, string) + + override fun toString(): String = + when { + jsonValue != null -> "Correction{jsonValue=$jsonValue}" + string != null -> "Correction{string=$string}" + _json != null -> "Correction{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Correction") + } + + companion object { + + @JvmStatic fun ofJsonValue(jsonValue: JsonValue) = Correction(jsonValue = jsonValue) + + @JvmStatic fun ofString(string: String) = Correction(string = string) + } + + /** + * An interface that defines how to map each variant of [Correction] to a value of type [T]. + */ + interface Visitor<out T> { + + fun visitJsonValue(jsonValue: JsonValue): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [Correction] to a value of type [T]. + * + * An instance of [Correction] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Correction: $json") + } + } + + internal class Deserializer : BaseDeserializer<Correction>(Correction::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Correction { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<String>())?.let { + Correction(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<JsonValue>())?.let { + Correction(jsonValue = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants. + 0 -> Correction(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Correction>(Correction::class) { + + override fun serialize( + value: Correction, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.jsonValue != null -> generator.writeObject(value.jsonValue) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Correction") + } + } + } + } + + @JsonDeserialize(using = Score.Deserializer::class) + @JsonSerialize(using = Score.Serializer::class) + class Score + private constructor( + private val number: Double? = null, + private val bool: Boolean? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional<Double> = Optional.ofNullable(number) + + fun bool(): Optional<Boolean> = Optional.ofNullable(bool) + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Score = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Score && number == other.number && bool == other.bool + } + + override fun hashCode(): Int = Objects.hash(number, bool) + + override fun toString(): String = + when { + number != null -> "Score{number=$number}" + bool != null -> "Score{bool=$bool}" + _json != null -> "Score{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Score") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Score(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = Score(bool = bool) + } + + /** An interface that defines how to map each variant of [Score] to a value of type [T]. */ + interface Visitor<out T> { + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Maps an unknown variant of [Score] to a value of type [T]. + * + * An instance of [Score] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Score: $json") + } + } + + internal class Deserializer : BaseDeserializer<Score>(Score::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Score { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<Double>())?.let { + Score(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<Boolean>())?.let { + Score(bool = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from string). + 0 -> Score(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Score>(Score::class) { + + override fun serialize( + value: Score, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Score") + } + } + } + } + + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val number: Double? = null, + private val bool: Boolean? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional<Double> = Optional.ofNullable(number) + + fun bool(): Optional<Boolean> = Optional.ofNullable(bool) + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Value = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + number == other.number && + bool == other.bool && + string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, bool, string) + + override fun toString(): String = + when { + number != null -> "Value{number=$number}" + bool != null -> "Value{bool=$bool}" + string != null -> "Value{string=$string}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Value(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) + + @JvmStatic fun ofString(string: String) = Value(string = string) + } + + /** An interface that defines how to map each variant of [Value] to a value of type [T]. */ + interface Visitor<out T> { + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [Value] to a value of type [T]. + * + * An instance of [Value] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Value: $json") + } + } + + internal class Deserializer : BaseDeserializer<Value>(Value::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Value { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<Double>())?.let { + Value(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<Boolean>())?.let { + Value(bool = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<String>())?.let { + Value(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> Value(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Value>(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TokenUpdateParams && + token == other.token && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(token, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TokenUpdateParams{token=$token, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenUpdateResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenUpdateResponse.kt new file mode 100644 index 00000000..6eb3e06a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenUpdateResponse.kt @@ -0,0 +1,113 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback.tokens + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class TokenUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [TokenUpdateResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TokenUpdateResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(tokenUpdateResponse: TokenUpdateResponse) = apply { + additionalProperties = tokenUpdateResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TokenUpdateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TokenUpdateResponse = TokenUpdateResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): TokenUpdateResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TokenUpdateResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "TokenUpdateResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfig.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfig.kt new file mode 100644 index 00000000..2a8c8964 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfig.kt @@ -0,0 +1,640 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedbackconfigs + +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.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class FeedbackConfig +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val type: JsonField<Type>, + private val categories: JsonField<List<Category>>, + private val max: JsonField<Double>, + private val min: JsonField<Double>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField<Type> = JsonMissing.of(), + @JsonProperty("categories") + @ExcludeMissing + categories: JsonField<List<Category>> = JsonMissing.of(), + @JsonProperty("max") @ExcludeMissing max: JsonField<Double> = JsonMissing.of(), + @JsonProperty("min") @ExcludeMissing min: JsonField<Double> = JsonMissing.of(), + ) : this(type, categories, max, min, mutableMapOf()) + + /** + * Enum for feedback types. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun categories(): Optional<List<Category>> = categories.getOptional("categories") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun max(): Optional<Double> = max.getOptional("max") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun min(): Optional<Double> = min.getOptional("min") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField<Type> = type + + /** + * Returns the raw JSON value of [categories]. + * + * Unlike [categories], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("categories") + @ExcludeMissing + fun _categories(): JsonField<List<Category>> = categories + + /** + * Returns the raw JSON value of [max]. + * + * Unlike [max], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("max") @ExcludeMissing fun _max(): JsonField<Double> = max + + /** + * Returns the raw JSON value of [min]. + * + * Unlike [min], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("min") @ExcludeMissing fun _min(): JsonField<Double> = min + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [FeedbackConfig]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackConfig]. */ + class Builder internal constructor() { + + private var type: JsonField<Type>? = null + private var categories: JsonField<MutableList<Category>>? = null + private var max: JsonField<Double> = JsonMissing.of() + private var min: JsonField<Double> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(feedbackConfig: FeedbackConfig) = apply { + type = feedbackConfig.type + categories = feedbackConfig.categories.map { it.toMutableList() } + max = feedbackConfig.max + min = feedbackConfig.min + additionalProperties = feedbackConfig.additionalProperties.toMutableMap() + } + + /** Enum for feedback types. */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField<Type>) = apply { this.type = type } + + fun categories(categories: List<Category>?) = categories(JsonField.ofNullable(categories)) + + /** Alias for calling [Builder.categories] with `categories.orElse(null)`. */ + fun categories(categories: Optional<List<Category>>) = categories(categories.getOrNull()) + + /** + * Sets [Builder.categories] to an arbitrary JSON value. + * + * You should usually call [Builder.categories] with a well-typed `List<Category>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun categories(categories: JsonField<List<Category>>) = apply { + this.categories = categories.map { it.toMutableList() } + } + + /** + * Adds a single [Category] to [categories]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCategory(category: Category) = apply { + categories = + (categories ?: JsonField.of(mutableListOf())).also { + checkKnown("categories", it).add(category) + } + } + + fun max(max: Double?) = max(JsonField.ofNullable(max)) + + /** + * Alias for [Builder.max]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun max(max: Double) = max(max as Double?) + + /** Alias for calling [Builder.max] with `max.orElse(null)`. */ + fun max(max: Optional<Double>) = max(max.getOrNull()) + + /** + * Sets [Builder.max] to an arbitrary JSON value. + * + * You should usually call [Builder.max] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun max(max: JsonField<Double>) = apply { this.max = max } + + fun min(min: Double?) = min(JsonField.ofNullable(min)) + + /** + * Alias for [Builder.min]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun min(min: Double) = min(min as Double?) + + /** Alias for calling [Builder.min] with `min.orElse(null)`. */ + fun min(min: Optional<Double>) = min(min.getOrNull()) + + /** + * Sets [Builder.min] to an arbitrary JSON value. + * + * You should usually call [Builder.min] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun min(min: JsonField<Double>) = apply { this.min = min } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FeedbackConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FeedbackConfig = + FeedbackConfig( + checkRequired("type", type), + (categories ?: JsonMissing.of()).map { it.toImmutable() }, + max, + min, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): FeedbackConfig = apply { + if (validated) { + return@apply + } + + type().validate() + categories().ifPresent { it.forEach { it.validate() } } + max() + min() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (type.asKnown().getOrNull()?.validity() ?: 0) + + (categories.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (max.asKnown().isPresent) 1 else 0) + + (if (min.asKnown().isPresent) 1 else 0) + + /** Enum for feedback types. */ + class Type @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val CONTINUOUS = of("continuous") + + @JvmField val CATEGORICAL = of("categorical") + + @JvmField val FREEFORM = of("freeform") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + CONTINUOUS, + CATEGORICAL, + FREEFORM, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CONTINUOUS, + CATEGORICAL, + FREEFORM, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CONTINUOUS -> Value.CONTINUOUS + CATEGORICAL -> Value.CATEGORICAL + FREEFORM -> Value.FREEFORM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CONTINUOUS -> Known.CONTINUOUS + CATEGORICAL -> Known.CATEGORICAL + FREEFORM -> Known.FREEFORM + else -> throw LangsmithApiInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Specific value and label pair for feedback */ + class Category + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val value: JsonField<Double>, + private val label: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("value") @ExcludeMissing value: JsonField<Double> = JsonMissing.of(), + @JsonProperty("label") @ExcludeMissing label: JsonField<String> = JsonMissing.of(), + ) : this(value, label, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun value(): Double = value.getRequired("value") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun label(): Optional<String> = label.getOptional("label") + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField<Double> = value + + /** + * Returns the raw JSON value of [label]. + * + * Unlike [label], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("label") @ExcludeMissing fun _label(): JsonField<String> = label + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Category]. + * + * The following fields are required: + * ```java + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Category]. */ + class Builder internal constructor() { + + private var value: JsonField<Double>? = null + private var label: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(category: Category) = apply { + value = category.value + label = category.label + additionalProperties = category.additionalProperties.toMutableMap() + } + + fun value(value: Double) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun value(value: JsonField<Double>) = apply { this.value = value } + + fun label(label: String?) = label(JsonField.ofNullable(label)) + + /** Alias for calling [Builder.label] with `label.orElse(null)`. */ + fun label(label: Optional<String>) = label(label.getOrNull()) + + /** + * Sets [Builder.label] to an arbitrary JSON value. + * + * You should usually call [Builder.label] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun label(label: JsonField<String>) = apply { this.label = label } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Category]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Category = + Category(checkRequired("value", value), label, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Category = apply { + if (validated) { + return@apply + } + + value() + label() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (value.asKnown().isPresent) 1 else 0) + (if (label.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Category && + value == other.value && + label == other.label && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(value, label, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Category{value=$value, label=$label, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackConfig && + type == other.type && + categories == other.categories && + max == other.max && + min == other.min && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, categories, max, min, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FeedbackConfig{type=$type, categories=$categories, max=$max, min=$min, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfigFeedbackConfigsParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfigFeedbackConfigsParams.kt new file mode 100644 index 00000000..bed0cfbc --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfigFeedbackConfigsParams.kt @@ -0,0 +1,602 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedbackconfigs + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create Feedback Config Endpoint */ +class FeedbackConfigFeedbackConfigsParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun feedbackConfig(): FeedbackConfig = body.feedbackConfig() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun feedbackKey(): String = body.feedbackKey() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun isLowerScoreBetter(): Optional<Boolean> = body.isLowerScoreBetter() + + /** + * Returns the raw JSON value of [feedbackConfig]. + * + * Unlike [feedbackConfig], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _feedbackConfig(): JsonField<FeedbackConfig> = body._feedbackConfig() + + /** + * Returns the raw JSON value of [feedbackKey]. + * + * Unlike [feedbackKey], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _feedbackKey(): JsonField<String> = body._feedbackKey() + + /** + * Returns the raw JSON value of [isLowerScoreBetter]. + * + * Unlike [isLowerScoreBetter], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _isLowerScoreBetter(): JsonField<Boolean> = body._isLowerScoreBetter() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [FeedbackConfigFeedbackConfigsParams]. + * + * The following fields are required: + * ```java + * .feedbackConfig() + * .feedbackKey() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackConfigFeedbackConfigsParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + feedbackConfigFeedbackConfigsParams: FeedbackConfigFeedbackConfigsParams + ) = apply { + body = feedbackConfigFeedbackConfigsParams.body.toBuilder() + additionalHeaders = feedbackConfigFeedbackConfigsParams.additionalHeaders.toBuilder() + additionalQueryParams = + feedbackConfigFeedbackConfigsParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [feedbackConfig] + * - [feedbackKey] + * - [isLowerScoreBetter] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun feedbackConfig(feedbackConfig: FeedbackConfig) = apply { + body.feedbackConfig(feedbackConfig) + } + + /** + * Sets [Builder.feedbackConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackConfig] with a well-typed [FeedbackConfig] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun feedbackConfig(feedbackConfig: JsonField<FeedbackConfig>) = apply { + body.feedbackConfig(feedbackConfig) + } + + fun feedbackKey(feedbackKey: String) = apply { body.feedbackKey(feedbackKey) } + + /** + * Sets [Builder.feedbackKey] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun feedbackKey(feedbackKey: JsonField<String>) = apply { body.feedbackKey(feedbackKey) } + + fun isLowerScoreBetter(isLowerScoreBetter: Boolean?) = apply { + body.isLowerScoreBetter(isLowerScoreBetter) + } + + /** + * Alias for [Builder.isLowerScoreBetter]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun isLowerScoreBetter(isLowerScoreBetter: Boolean) = + isLowerScoreBetter(isLowerScoreBetter as Boolean?) + + /** + * Alias for calling [Builder.isLowerScoreBetter] with `isLowerScoreBetter.orElse(null)`. + */ + fun isLowerScoreBetter(isLowerScoreBetter: Optional<Boolean>) = + isLowerScoreBetter(isLowerScoreBetter.getOrNull()) + + /** + * Sets [Builder.isLowerScoreBetter] to an arbitrary JSON value. + * + * You should usually call [Builder.isLowerScoreBetter] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isLowerScoreBetter(isLowerScoreBetter: JsonField<Boolean>) = apply { + body.isLowerScoreBetter(isLowerScoreBetter) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [FeedbackConfigFeedbackConfigsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .feedbackConfig() + * .feedbackKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FeedbackConfigFeedbackConfigsParams = + FeedbackConfigFeedbackConfigsParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val feedbackConfig: JsonField<FeedbackConfig>, + private val feedbackKey: JsonField<String>, + private val isLowerScoreBetter: JsonField<Boolean>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("feedback_config") + @ExcludeMissing + feedbackConfig: JsonField<FeedbackConfig> = JsonMissing.of(), + @JsonProperty("feedback_key") + @ExcludeMissing + feedbackKey: JsonField<String> = JsonMissing.of(), + @JsonProperty("is_lower_score_better") + @ExcludeMissing + isLowerScoreBetter: JsonField<Boolean> = JsonMissing.of(), + ) : this(feedbackConfig, feedbackKey, isLowerScoreBetter, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun feedbackConfig(): FeedbackConfig = feedbackConfig.getRequired("feedback_config") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun feedbackKey(): String = feedbackKey.getRequired("feedback_key") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun isLowerScoreBetter(): Optional<Boolean> = + isLowerScoreBetter.getOptional("is_lower_score_better") + + /** + * Returns the raw JSON value of [feedbackConfig]. + * + * Unlike [feedbackConfig], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("feedback_config") + @ExcludeMissing + fun _feedbackConfig(): JsonField<FeedbackConfig> = feedbackConfig + + /** + * Returns the raw JSON value of [feedbackKey]. + * + * Unlike [feedbackKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feedback_key") + @ExcludeMissing + fun _feedbackKey(): JsonField<String> = feedbackKey + + /** + * Returns the raw JSON value of [isLowerScoreBetter]. + * + * Unlike [isLowerScoreBetter], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("is_lower_score_better") + @ExcludeMissing + fun _isLowerScoreBetter(): JsonField<Boolean> = isLowerScoreBetter + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .feedbackConfig() + * .feedbackKey() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var feedbackConfig: JsonField<FeedbackConfig>? = null + private var feedbackKey: JsonField<String>? = null + private var isLowerScoreBetter: JsonField<Boolean> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + feedbackConfig = body.feedbackConfig + feedbackKey = body.feedbackKey + isLowerScoreBetter = body.isLowerScoreBetter + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun feedbackConfig(feedbackConfig: FeedbackConfig) = + feedbackConfig(JsonField.of(feedbackConfig)) + + /** + * Sets [Builder.feedbackConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackConfig] with a well-typed [FeedbackConfig] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun feedbackConfig(feedbackConfig: JsonField<FeedbackConfig>) = apply { + this.feedbackConfig = feedbackConfig + } + + fun feedbackKey(feedbackKey: String) = feedbackKey(JsonField.of(feedbackKey)) + + /** + * Sets [Builder.feedbackKey] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun feedbackKey(feedbackKey: JsonField<String>) = apply { + this.feedbackKey = feedbackKey + } + + fun isLowerScoreBetter(isLowerScoreBetter: Boolean?) = + isLowerScoreBetter(JsonField.ofNullable(isLowerScoreBetter)) + + /** + * Alias for [Builder.isLowerScoreBetter]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun isLowerScoreBetter(isLowerScoreBetter: Boolean) = + isLowerScoreBetter(isLowerScoreBetter as Boolean?) + + /** + * Alias for calling [Builder.isLowerScoreBetter] with + * `isLowerScoreBetter.orElse(null)`. + */ + fun isLowerScoreBetter(isLowerScoreBetter: Optional<Boolean>) = + isLowerScoreBetter(isLowerScoreBetter.getOrNull()) + + /** + * Sets [Builder.isLowerScoreBetter] to an arbitrary JSON value. + * + * You should usually call [Builder.isLowerScoreBetter] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun isLowerScoreBetter(isLowerScoreBetter: JsonField<Boolean>) = apply { + this.isLowerScoreBetter = isLowerScoreBetter + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .feedbackConfig() + * .feedbackKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("feedbackConfig", feedbackConfig), + checkRequired("feedbackKey", feedbackKey), + isLowerScoreBetter, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + feedbackConfig().validate() + feedbackKey() + isLowerScoreBetter() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (feedbackConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (feedbackKey.asKnown().isPresent) 1 else 0) + + (if (isLowerScoreBetter.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + feedbackConfig == other.feedbackConfig && + feedbackKey == other.feedbackKey && + isLowerScoreBetter == other.isLowerScoreBetter && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(feedbackConfig, feedbackKey, isLowerScoreBetter, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{feedbackConfig=$feedbackConfig, feedbackKey=$feedbackKey, isLowerScoreBetter=$isLowerScoreBetter, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackConfigFeedbackConfigsParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "FeedbackConfigFeedbackConfigsParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfigRetrieveFeedbackConfigsParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfigRetrieveFeedbackConfigsParams.kt new file mode 100644 index 00000000..3ef11f55 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfigRetrieveFeedbackConfigsParams.kt @@ -0,0 +1,234 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedbackconfigs + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** List Feedback Configs Endpoint */ +class FeedbackConfigRetrieveFeedbackConfigsParams +private constructor( + private val key: List<String>?, + private val readAfterWrite: Boolean?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun key(): Optional<List<String>> = Optional.ofNullable(key) + + fun readAfterWrite(): Optional<Boolean> = Optional.ofNullable(readAfterWrite) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): FeedbackConfigRetrieveFeedbackConfigsParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [FeedbackConfigRetrieveFeedbackConfigsParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackConfigRetrieveFeedbackConfigsParams]. */ + class Builder internal constructor() { + + private var key: MutableList<String>? = null + private var readAfterWrite: Boolean? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + feedbackConfigRetrieveFeedbackConfigsParams: FeedbackConfigRetrieveFeedbackConfigsParams + ) = apply { + key = feedbackConfigRetrieveFeedbackConfigsParams.key?.toMutableList() + readAfterWrite = feedbackConfigRetrieveFeedbackConfigsParams.readAfterWrite + additionalHeaders = + feedbackConfigRetrieveFeedbackConfigsParams.additionalHeaders.toBuilder() + additionalQueryParams = + feedbackConfigRetrieveFeedbackConfigsParams.additionalQueryParams.toBuilder() + } + + fun key(key: List<String>?) = apply { this.key = key?.toMutableList() } + + /** Alias for calling [Builder.key] with `key.orElse(null)`. */ + fun key(key: Optional<List<String>>) = key(key.getOrNull()) + + /** + * Adds a single [String] to [Builder.key]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addKey(key: String) = apply { + this.key = (this.key ?: mutableListOf()).apply { add(key) } + } + + fun readAfterWrite(readAfterWrite: Boolean?) = apply { + this.readAfterWrite = readAfterWrite + } + + /** + * Alias for [Builder.readAfterWrite]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun readAfterWrite(readAfterWrite: Boolean) = readAfterWrite(readAfterWrite as Boolean?) + + /** Alias for calling [Builder.readAfterWrite] with `readAfterWrite.orElse(null)`. */ + fun readAfterWrite(readAfterWrite: Optional<Boolean>) = + readAfterWrite(readAfterWrite.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [FeedbackConfigRetrieveFeedbackConfigsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FeedbackConfigRetrieveFeedbackConfigsParams = + FeedbackConfigRetrieveFeedbackConfigsParams( + key?.toImmutable(), + readAfterWrite, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + key?.let { put("key", it.joinToString(",")) } + readAfterWrite?.let { put("read_after_write", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackConfigRetrieveFeedbackConfigsParams && + key == other.key && + readAfterWrite == other.readAfterWrite && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(key, readAfterWrite, additionalHeaders, additionalQueryParams) + + override fun toString() = + "FeedbackConfigRetrieveFeedbackConfigsParams{key=$key, readAfterWrite=$readAfterWrite, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfigSchema.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfigSchema.kt new file mode 100644 index 00000000..de9a7ebc --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfigSchema.kt @@ -0,0 +1,358 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedbackconfigs + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class FeedbackConfigSchema +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val feedbackConfig: JsonField<FeedbackConfig>, + private val feedbackKey: JsonField<String>, + private val modifiedAt: JsonField<OffsetDateTime>, + private val tenantId: JsonField<String>, + private val isLowerScoreBetter: JsonField<Boolean>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("feedback_config") + @ExcludeMissing + feedbackConfig: JsonField<FeedbackConfig> = JsonMissing.of(), + @JsonProperty("feedback_key") + @ExcludeMissing + feedbackKey: JsonField<String> = JsonMissing.of(), + @JsonProperty("modified_at") + @ExcludeMissing + modifiedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("tenant_id") @ExcludeMissing tenantId: JsonField<String> = JsonMissing.of(), + @JsonProperty("is_lower_score_better") + @ExcludeMissing + isLowerScoreBetter: JsonField<Boolean> = JsonMissing.of(), + ) : this(feedbackConfig, feedbackKey, modifiedAt, tenantId, isLowerScoreBetter, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun feedbackConfig(): FeedbackConfig = feedbackConfig.getRequired("feedback_config") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun feedbackKey(): String = feedbackKey.getRequired("feedback_key") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun modifiedAt(): OffsetDateTime = modifiedAt.getRequired("modified_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tenantId(): String = tenantId.getRequired("tenant_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun isLowerScoreBetter(): Optional<Boolean> = + isLowerScoreBetter.getOptional("is_lower_score_better") + + /** + * Returns the raw JSON value of [feedbackConfig]. + * + * Unlike [feedbackConfig], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feedback_config") + @ExcludeMissing + fun _feedbackConfig(): JsonField<FeedbackConfig> = feedbackConfig + + /** + * Returns the raw JSON value of [feedbackKey]. + * + * Unlike [feedbackKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feedback_key") + @ExcludeMissing + fun _feedbackKey(): JsonField<String> = feedbackKey + + /** + * Returns the raw JSON value of [modifiedAt]. + * + * Unlike [modifiedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("modified_at") + @ExcludeMissing + fun _modifiedAt(): JsonField<OffsetDateTime> = modifiedAt + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_id") @ExcludeMissing fun _tenantId(): JsonField<String> = tenantId + + /** + * Returns the raw JSON value of [isLowerScoreBetter]. + * + * Unlike [isLowerScoreBetter], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("is_lower_score_better") + @ExcludeMissing + fun _isLowerScoreBetter(): JsonField<Boolean> = isLowerScoreBetter + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [FeedbackConfigSchema]. + * + * The following fields are required: + * ```java + * .feedbackConfig() + * .feedbackKey() + * .modifiedAt() + * .tenantId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackConfigSchema]. */ + class Builder internal constructor() { + + private var feedbackConfig: JsonField<FeedbackConfig>? = null + private var feedbackKey: JsonField<String>? = null + private var modifiedAt: JsonField<OffsetDateTime>? = null + private var tenantId: JsonField<String>? = null + private var isLowerScoreBetter: JsonField<Boolean> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(feedbackConfigSchema: FeedbackConfigSchema) = apply { + feedbackConfig = feedbackConfigSchema.feedbackConfig + feedbackKey = feedbackConfigSchema.feedbackKey + modifiedAt = feedbackConfigSchema.modifiedAt + tenantId = feedbackConfigSchema.tenantId + isLowerScoreBetter = feedbackConfigSchema.isLowerScoreBetter + additionalProperties = feedbackConfigSchema.additionalProperties.toMutableMap() + } + + fun feedbackConfig(feedbackConfig: FeedbackConfig) = + feedbackConfig(JsonField.of(feedbackConfig)) + + /** + * Sets [Builder.feedbackConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackConfig] with a well-typed [FeedbackConfig] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun feedbackConfig(feedbackConfig: JsonField<FeedbackConfig>) = apply { + this.feedbackConfig = feedbackConfig + } + + fun feedbackKey(feedbackKey: String) = feedbackKey(JsonField.of(feedbackKey)) + + /** + * Sets [Builder.feedbackKey] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun feedbackKey(feedbackKey: JsonField<String>) = apply { this.feedbackKey = feedbackKey } + + fun modifiedAt(modifiedAt: OffsetDateTime) = modifiedAt(JsonField.of(modifiedAt)) + + /** + * Sets [Builder.modifiedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.modifiedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modifiedAt(modifiedAt: JsonField<OffsetDateTime>) = apply { + this.modifiedAt = modifiedAt + } + + fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tenantId(tenantId: JsonField<String>) = apply { this.tenantId = tenantId } + + fun isLowerScoreBetter(isLowerScoreBetter: Boolean?) = + isLowerScoreBetter(JsonField.ofNullable(isLowerScoreBetter)) + + /** + * Alias for [Builder.isLowerScoreBetter]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun isLowerScoreBetter(isLowerScoreBetter: Boolean) = + isLowerScoreBetter(isLowerScoreBetter as Boolean?) + + /** + * Alias for calling [Builder.isLowerScoreBetter] with `isLowerScoreBetter.orElse(null)`. + */ + fun isLowerScoreBetter(isLowerScoreBetter: Optional<Boolean>) = + isLowerScoreBetter(isLowerScoreBetter.getOrNull()) + + /** + * Sets [Builder.isLowerScoreBetter] to an arbitrary JSON value. + * + * You should usually call [Builder.isLowerScoreBetter] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isLowerScoreBetter(isLowerScoreBetter: JsonField<Boolean>) = apply { + this.isLowerScoreBetter = isLowerScoreBetter + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FeedbackConfigSchema]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .feedbackConfig() + * .feedbackKey() + * .modifiedAt() + * .tenantId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FeedbackConfigSchema = + FeedbackConfigSchema( + checkRequired("feedbackConfig", feedbackConfig), + checkRequired("feedbackKey", feedbackKey), + checkRequired("modifiedAt", modifiedAt), + checkRequired("tenantId", tenantId), + isLowerScoreBetter, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): FeedbackConfigSchema = apply { + if (validated) { + return@apply + } + + feedbackConfig().validate() + feedbackKey() + modifiedAt() + tenantId() + isLowerScoreBetter() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (feedbackConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (feedbackKey.asKnown().isPresent) 1 else 0) + + (if (modifiedAt.asKnown().isPresent) 1 else 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + (if (isLowerScoreBetter.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackConfigSchema && + feedbackConfig == other.feedbackConfig && + feedbackKey == other.feedbackKey && + modifiedAt == other.modifiedAt && + tenantId == other.tenantId && + isLowerScoreBetter == other.isLowerScoreBetter && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + feedbackConfig, + feedbackKey, + modifiedAt, + tenantId, + isLowerScoreBetter, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FeedbackConfigSchema{feedbackConfig=$feedbackConfig, feedbackKey=$feedbackKey, modifiedAt=$modifiedAt, tenantId=$tenantId, isLowerScoreBetter=$isLowerScoreBetter, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfigUpdateFeedbackConfigsParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfigUpdateFeedbackConfigsParams.kt new file mode 100644 index 00000000..0074660e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfigUpdateFeedbackConfigsParams.kt @@ -0,0 +1,608 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedbackconfigs + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Update Feedback Config Endpoint */ +class FeedbackConfigUpdateFeedbackConfigsParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun feedbackKey(): String = body.feedbackKey() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun feedbackConfig(): Optional<FeedbackConfig> = body.feedbackConfig() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun isLowerScoreBetter(): Optional<Boolean> = body.isLowerScoreBetter() + + /** + * Returns the raw JSON value of [feedbackKey]. + * + * Unlike [feedbackKey], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _feedbackKey(): JsonField<String> = body._feedbackKey() + + /** + * Returns the raw JSON value of [feedbackConfig]. + * + * Unlike [feedbackConfig], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _feedbackConfig(): JsonField<FeedbackConfig> = body._feedbackConfig() + + /** + * Returns the raw JSON value of [isLowerScoreBetter]. + * + * Unlike [isLowerScoreBetter], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _isLowerScoreBetter(): JsonField<Boolean> = body._isLowerScoreBetter() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [FeedbackConfigUpdateFeedbackConfigsParams]. + * + * The following fields are required: + * ```java + * .feedbackKey() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackConfigUpdateFeedbackConfigsParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + feedbackConfigUpdateFeedbackConfigsParams: FeedbackConfigUpdateFeedbackConfigsParams + ) = apply { + body = feedbackConfigUpdateFeedbackConfigsParams.body.toBuilder() + additionalHeaders = + feedbackConfigUpdateFeedbackConfigsParams.additionalHeaders.toBuilder() + additionalQueryParams = + feedbackConfigUpdateFeedbackConfigsParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [feedbackKey] + * - [feedbackConfig] + * - [isLowerScoreBetter] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun feedbackKey(feedbackKey: String) = apply { body.feedbackKey(feedbackKey) } + + /** + * Sets [Builder.feedbackKey] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun feedbackKey(feedbackKey: JsonField<String>) = apply { body.feedbackKey(feedbackKey) } + + fun feedbackConfig(feedbackConfig: FeedbackConfig?) = apply { + body.feedbackConfig(feedbackConfig) + } + + /** Alias for calling [Builder.feedbackConfig] with `feedbackConfig.orElse(null)`. */ + fun feedbackConfig(feedbackConfig: Optional<FeedbackConfig>) = + feedbackConfig(feedbackConfig.getOrNull()) + + /** + * Sets [Builder.feedbackConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackConfig] with a well-typed [FeedbackConfig] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun feedbackConfig(feedbackConfig: JsonField<FeedbackConfig>) = apply { + body.feedbackConfig(feedbackConfig) + } + + fun isLowerScoreBetter(isLowerScoreBetter: Boolean?) = apply { + body.isLowerScoreBetter(isLowerScoreBetter) + } + + /** + * Alias for [Builder.isLowerScoreBetter]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun isLowerScoreBetter(isLowerScoreBetter: Boolean) = + isLowerScoreBetter(isLowerScoreBetter as Boolean?) + + /** + * Alias for calling [Builder.isLowerScoreBetter] with `isLowerScoreBetter.orElse(null)`. + */ + fun isLowerScoreBetter(isLowerScoreBetter: Optional<Boolean>) = + isLowerScoreBetter(isLowerScoreBetter.getOrNull()) + + /** + * Sets [Builder.isLowerScoreBetter] to an arbitrary JSON value. + * + * You should usually call [Builder.isLowerScoreBetter] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isLowerScoreBetter(isLowerScoreBetter: JsonField<Boolean>) = apply { + body.isLowerScoreBetter(isLowerScoreBetter) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [FeedbackConfigUpdateFeedbackConfigsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .feedbackKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FeedbackConfigUpdateFeedbackConfigsParams = + FeedbackConfigUpdateFeedbackConfigsParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val feedbackKey: JsonField<String>, + private val feedbackConfig: JsonField<FeedbackConfig>, + private val isLowerScoreBetter: JsonField<Boolean>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("feedback_key") + @ExcludeMissing + feedbackKey: JsonField<String> = JsonMissing.of(), + @JsonProperty("feedback_config") + @ExcludeMissing + feedbackConfig: JsonField<FeedbackConfig> = JsonMissing.of(), + @JsonProperty("is_lower_score_better") + @ExcludeMissing + isLowerScoreBetter: JsonField<Boolean> = JsonMissing.of(), + ) : this(feedbackKey, feedbackConfig, isLowerScoreBetter, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun feedbackKey(): String = feedbackKey.getRequired("feedback_key") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun feedbackConfig(): Optional<FeedbackConfig> = + feedbackConfig.getOptional("feedback_config") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun isLowerScoreBetter(): Optional<Boolean> = + isLowerScoreBetter.getOptional("is_lower_score_better") + + /** + * Returns the raw JSON value of [feedbackKey]. + * + * Unlike [feedbackKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feedback_key") + @ExcludeMissing + fun _feedbackKey(): JsonField<String> = feedbackKey + + /** + * Returns the raw JSON value of [feedbackConfig]. + * + * Unlike [feedbackConfig], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("feedback_config") + @ExcludeMissing + fun _feedbackConfig(): JsonField<FeedbackConfig> = feedbackConfig + + /** + * Returns the raw JSON value of [isLowerScoreBetter]. + * + * Unlike [isLowerScoreBetter], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("is_lower_score_better") + @ExcludeMissing + fun _isLowerScoreBetter(): JsonField<Boolean> = isLowerScoreBetter + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .feedbackKey() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var feedbackKey: JsonField<String>? = null + private var feedbackConfig: JsonField<FeedbackConfig> = JsonMissing.of() + private var isLowerScoreBetter: JsonField<Boolean> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + feedbackKey = body.feedbackKey + feedbackConfig = body.feedbackConfig + isLowerScoreBetter = body.isLowerScoreBetter + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun feedbackKey(feedbackKey: String) = feedbackKey(JsonField.of(feedbackKey)) + + /** + * Sets [Builder.feedbackKey] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun feedbackKey(feedbackKey: JsonField<String>) = apply { + this.feedbackKey = feedbackKey + } + + fun feedbackConfig(feedbackConfig: FeedbackConfig?) = + feedbackConfig(JsonField.ofNullable(feedbackConfig)) + + /** Alias for calling [Builder.feedbackConfig] with `feedbackConfig.orElse(null)`. */ + fun feedbackConfig(feedbackConfig: Optional<FeedbackConfig>) = + feedbackConfig(feedbackConfig.getOrNull()) + + /** + * Sets [Builder.feedbackConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackConfig] with a well-typed [FeedbackConfig] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun feedbackConfig(feedbackConfig: JsonField<FeedbackConfig>) = apply { + this.feedbackConfig = feedbackConfig + } + + fun isLowerScoreBetter(isLowerScoreBetter: Boolean?) = + isLowerScoreBetter(JsonField.ofNullable(isLowerScoreBetter)) + + /** + * Alias for [Builder.isLowerScoreBetter]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun isLowerScoreBetter(isLowerScoreBetter: Boolean) = + isLowerScoreBetter(isLowerScoreBetter as Boolean?) + + /** + * Alias for calling [Builder.isLowerScoreBetter] with + * `isLowerScoreBetter.orElse(null)`. + */ + fun isLowerScoreBetter(isLowerScoreBetter: Optional<Boolean>) = + isLowerScoreBetter(isLowerScoreBetter.getOrNull()) + + /** + * Sets [Builder.isLowerScoreBetter] to an arbitrary JSON value. + * + * You should usually call [Builder.isLowerScoreBetter] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun isLowerScoreBetter(isLowerScoreBetter: JsonField<Boolean>) = apply { + this.isLowerScoreBetter = isLowerScoreBetter + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .feedbackKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("feedbackKey", feedbackKey), + feedbackConfig, + isLowerScoreBetter, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + feedbackKey() + feedbackConfig().ifPresent { it.validate() } + isLowerScoreBetter() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (feedbackKey.asKnown().isPresent) 1 else 0) + + (feedbackConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (isLowerScoreBetter.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + feedbackKey == other.feedbackKey && + feedbackConfig == other.feedbackConfig && + isLowerScoreBetter == other.isLowerScoreBetter && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(feedbackKey, feedbackConfig, isLowerScoreBetter, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{feedbackKey=$feedbackKey, feedbackConfig=$feedbackConfig, isLowerScoreBetter=$isLowerScoreBetter, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackConfigUpdateFeedbackConfigsParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "FeedbackConfigUpdateFeedbackConfigsParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/info/InfoListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/info/InfoListParams.kt new file mode 100644 index 00000000..102e387e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/info/InfoListParams.kt @@ -0,0 +1,170 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.info + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** Get information about the current deployment of LangSmith. */ +class InfoListParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): InfoListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [InfoListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InfoListParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(infoListParams: InfoListParams) = apply { + additionalHeaders = infoListParams.additionalHeaders.toBuilder() + additionalQueryParams = infoListParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [InfoListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InfoListParams = + InfoListParams(additionalHeaders.build(), additionalQueryParams.build()) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InfoListParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "InfoListParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/info/InfoListResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/info/InfoListResponse.kt new file mode 100644 index 00000000..bd15b43e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/info/InfoListResponse.kt @@ -0,0 +1,914 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.info + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** The LangSmith server info. */ +class InfoListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val version: JsonField<String>, + private val batchIngestConfig: JsonField<BatchIngestConfig>, + private val customerInfo: JsonField<CustomerInfo>, + private val instanceFlags: JsonValue, + private val licenseExpirationTime: JsonField<OffsetDateTime>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("version") @ExcludeMissing version: JsonField<String> = JsonMissing.of(), + @JsonProperty("batch_ingest_config") + @ExcludeMissing + batchIngestConfig: JsonField<BatchIngestConfig> = JsonMissing.of(), + @JsonProperty("customer_info") + @ExcludeMissing + customerInfo: JsonField<CustomerInfo> = JsonMissing.of(), + @JsonProperty("instance_flags") @ExcludeMissing instanceFlags: JsonValue = JsonMissing.of(), + @JsonProperty("license_expiration_time") + @ExcludeMissing + licenseExpirationTime: JsonField<OffsetDateTime> = JsonMissing.of(), + ) : this( + version, + batchIngestConfig, + customerInfo, + instanceFlags, + licenseExpirationTime, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): String = version.getRequired("version") + + /** + * Batch ingest config. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun batchIngestConfig(): Optional<BatchIngestConfig> = + batchIngestConfig.getOptional("batch_ingest_config") + + /** + * Customer info. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun customerInfo(): Optional<CustomerInfo> = customerInfo.getOptional("customer_info") + + @JsonProperty("instance_flags") @ExcludeMissing fun _instanceFlags(): JsonValue = instanceFlags + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseExpirationTime(): Optional<OffsetDateTime> = + licenseExpirationTime.getOptional("license_expiration_time") + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField<String> = version + + /** + * Returns the raw JSON value of [batchIngestConfig]. + * + * Unlike [batchIngestConfig], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("batch_ingest_config") + @ExcludeMissing + fun _batchIngestConfig(): JsonField<BatchIngestConfig> = batchIngestConfig + + /** + * Returns the raw JSON value of [customerInfo]. + * + * Unlike [customerInfo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("customer_info") + @ExcludeMissing + fun _customerInfo(): JsonField<CustomerInfo> = customerInfo + + /** + * Returns the raw JSON value of [licenseExpirationTime]. + * + * Unlike [licenseExpirationTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("license_expiration_time") + @ExcludeMissing + fun _licenseExpirationTime(): JsonField<OffsetDateTime> = licenseExpirationTime + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InfoListResponse]. + * + * The following fields are required: + * ```java + * .version() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InfoListResponse]. */ + class Builder internal constructor() { + + private var version: JsonField<String>? = null + private var batchIngestConfig: JsonField<BatchIngestConfig> = JsonMissing.of() + private var customerInfo: JsonField<CustomerInfo> = JsonMissing.of() + private var instanceFlags: JsonValue = JsonMissing.of() + private var licenseExpirationTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(infoListResponse: InfoListResponse) = apply { + version = infoListResponse.version + batchIngestConfig = infoListResponse.batchIngestConfig + customerInfo = infoListResponse.customerInfo + instanceFlags = infoListResponse.instanceFlags + licenseExpirationTime = infoListResponse.licenseExpirationTime + additionalProperties = infoListResponse.additionalProperties.toMutableMap() + } + + fun version(version: String) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun version(version: JsonField<String>) = apply { this.version = version } + + /** Batch ingest config. */ + fun batchIngestConfig(batchIngestConfig: BatchIngestConfig) = + batchIngestConfig(JsonField.of(batchIngestConfig)) + + /** + * Sets [Builder.batchIngestConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.batchIngestConfig] with a well-typed [BatchIngestConfig] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun batchIngestConfig(batchIngestConfig: JsonField<BatchIngestConfig>) = apply { + this.batchIngestConfig = batchIngestConfig + } + + /** Customer info. */ + fun customerInfo(customerInfo: CustomerInfo?) = + customerInfo(JsonField.ofNullable(customerInfo)) + + /** Alias for calling [Builder.customerInfo] with `customerInfo.orElse(null)`. */ + fun customerInfo(customerInfo: Optional<CustomerInfo>) = + customerInfo(customerInfo.getOrNull()) + + /** + * Sets [Builder.customerInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.customerInfo] with a well-typed [CustomerInfo] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customerInfo(customerInfo: JsonField<CustomerInfo>) = apply { + this.customerInfo = customerInfo + } + + fun instanceFlags(instanceFlags: JsonValue) = apply { this.instanceFlags = instanceFlags } + + fun licenseExpirationTime(licenseExpirationTime: OffsetDateTime?) = + licenseExpirationTime(JsonField.ofNullable(licenseExpirationTime)) + + /** + * Alias for calling [Builder.licenseExpirationTime] with + * `licenseExpirationTime.orElse(null)`. + */ + fun licenseExpirationTime(licenseExpirationTime: Optional<OffsetDateTime>) = + licenseExpirationTime(licenseExpirationTime.getOrNull()) + + /** + * Sets [Builder.licenseExpirationTime] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseExpirationTime] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseExpirationTime(licenseExpirationTime: JsonField<OffsetDateTime>) = apply { + this.licenseExpirationTime = licenseExpirationTime + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InfoListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .version() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InfoListResponse = + InfoListResponse( + checkRequired("version", version), + batchIngestConfig, + customerInfo, + instanceFlags, + licenseExpirationTime, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InfoListResponse = apply { + if (validated) { + return@apply + } + + version() + batchIngestConfig().ifPresent { it.validate() } + customerInfo().ifPresent { it.validate() } + licenseExpirationTime() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (version.asKnown().isPresent) 1 else 0) + + (batchIngestConfig.asKnown().getOrNull()?.validity() ?: 0) + + (customerInfo.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseExpirationTime.asKnown().isPresent) 1 else 0) + + /** Batch ingest config. */ + class BatchIngestConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val scaleDownNemptyTrigger: JsonField<Long>, + private val scaleUpNthreadsLimit: JsonField<Long>, + private val scaleUpQsizeTrigger: JsonField<Long>, + private val sizeLimit: JsonField<Long>, + private val sizeLimitBytes: JsonField<Long>, + private val useMultipartEndpoint: JsonField<Boolean>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("scale_down_nempty_trigger") + @ExcludeMissing + scaleDownNemptyTrigger: JsonField<Long> = JsonMissing.of(), + @JsonProperty("scale_up_nthreads_limit") + @ExcludeMissing + scaleUpNthreadsLimit: JsonField<Long> = JsonMissing.of(), + @JsonProperty("scale_up_qsize_trigger") + @ExcludeMissing + scaleUpQsizeTrigger: JsonField<Long> = JsonMissing.of(), + @JsonProperty("size_limit") + @ExcludeMissing + sizeLimit: JsonField<Long> = JsonMissing.of(), + @JsonProperty("size_limit_bytes") + @ExcludeMissing + sizeLimitBytes: JsonField<Long> = JsonMissing.of(), + @JsonProperty("use_multipart_endpoint") + @ExcludeMissing + useMultipartEndpoint: JsonField<Boolean> = JsonMissing.of(), + ) : this( + scaleDownNemptyTrigger, + scaleUpNthreadsLimit, + scaleUpQsizeTrigger, + sizeLimit, + sizeLimitBytes, + useMultipartEndpoint, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun scaleDownNemptyTrigger(): Optional<Long> = + scaleDownNemptyTrigger.getOptional("scale_down_nempty_trigger") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun scaleUpNthreadsLimit(): Optional<Long> = + scaleUpNthreadsLimit.getOptional("scale_up_nthreads_limit") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun scaleUpQsizeTrigger(): Optional<Long> = + scaleUpQsizeTrigger.getOptional("scale_up_qsize_trigger") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun sizeLimit(): Optional<Long> = sizeLimit.getOptional("size_limit") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun sizeLimitBytes(): Optional<Long> = sizeLimitBytes.getOptional("size_limit_bytes") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun useMultipartEndpoint(): Optional<Boolean> = + useMultipartEndpoint.getOptional("use_multipart_endpoint") + + /** + * Returns the raw JSON value of [scaleDownNemptyTrigger]. + * + * Unlike [scaleDownNemptyTrigger], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scale_down_nempty_trigger") + @ExcludeMissing + fun _scaleDownNemptyTrigger(): JsonField<Long> = scaleDownNemptyTrigger + + /** + * Returns the raw JSON value of [scaleUpNthreadsLimit]. + * + * Unlike [scaleUpNthreadsLimit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scale_up_nthreads_limit") + @ExcludeMissing + fun _scaleUpNthreadsLimit(): JsonField<Long> = scaleUpNthreadsLimit + + /** + * Returns the raw JSON value of [scaleUpQsizeTrigger]. + * + * Unlike [scaleUpQsizeTrigger], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scale_up_qsize_trigger") + @ExcludeMissing + fun _scaleUpQsizeTrigger(): JsonField<Long> = scaleUpQsizeTrigger + + /** + * Returns the raw JSON value of [sizeLimit]. + * + * Unlike [sizeLimit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("size_limit") @ExcludeMissing fun _sizeLimit(): JsonField<Long> = sizeLimit + + /** + * Returns the raw JSON value of [sizeLimitBytes]. + * + * Unlike [sizeLimitBytes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("size_limit_bytes") + @ExcludeMissing + fun _sizeLimitBytes(): JsonField<Long> = sizeLimitBytes + + /** + * Returns the raw JSON value of [useMultipartEndpoint]. + * + * Unlike [useMultipartEndpoint], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("use_multipart_endpoint") + @ExcludeMissing + fun _useMultipartEndpoint(): JsonField<Boolean> = useMultipartEndpoint + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [BatchIngestConfig]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BatchIngestConfig]. */ + class Builder internal constructor() { + + private var scaleDownNemptyTrigger: JsonField<Long> = JsonMissing.of() + private var scaleUpNthreadsLimit: JsonField<Long> = JsonMissing.of() + private var scaleUpQsizeTrigger: JsonField<Long> = JsonMissing.of() + private var sizeLimit: JsonField<Long> = JsonMissing.of() + private var sizeLimitBytes: JsonField<Long> = JsonMissing.of() + private var useMultipartEndpoint: JsonField<Boolean> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(batchIngestConfig: BatchIngestConfig) = apply { + scaleDownNemptyTrigger = batchIngestConfig.scaleDownNemptyTrigger + scaleUpNthreadsLimit = batchIngestConfig.scaleUpNthreadsLimit + scaleUpQsizeTrigger = batchIngestConfig.scaleUpQsizeTrigger + sizeLimit = batchIngestConfig.sizeLimit + sizeLimitBytes = batchIngestConfig.sizeLimitBytes + useMultipartEndpoint = batchIngestConfig.useMultipartEndpoint + additionalProperties = batchIngestConfig.additionalProperties.toMutableMap() + } + + fun scaleDownNemptyTrigger(scaleDownNemptyTrigger: Long) = + scaleDownNemptyTrigger(JsonField.of(scaleDownNemptyTrigger)) + + /** + * Sets [Builder.scaleDownNemptyTrigger] to an arbitrary JSON value. + * + * You should usually call [Builder.scaleDownNemptyTrigger] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun scaleDownNemptyTrigger(scaleDownNemptyTrigger: JsonField<Long>) = apply { + this.scaleDownNemptyTrigger = scaleDownNemptyTrigger + } + + fun scaleUpNthreadsLimit(scaleUpNthreadsLimit: Long) = + scaleUpNthreadsLimit(JsonField.of(scaleUpNthreadsLimit)) + + /** + * Sets [Builder.scaleUpNthreadsLimit] to an arbitrary JSON value. + * + * You should usually call [Builder.scaleUpNthreadsLimit] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun scaleUpNthreadsLimit(scaleUpNthreadsLimit: JsonField<Long>) = apply { + this.scaleUpNthreadsLimit = scaleUpNthreadsLimit + } + + fun scaleUpQsizeTrigger(scaleUpQsizeTrigger: Long) = + scaleUpQsizeTrigger(JsonField.of(scaleUpQsizeTrigger)) + + /** + * Sets [Builder.scaleUpQsizeTrigger] to an arbitrary JSON value. + * + * You should usually call [Builder.scaleUpQsizeTrigger] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun scaleUpQsizeTrigger(scaleUpQsizeTrigger: JsonField<Long>) = apply { + this.scaleUpQsizeTrigger = scaleUpQsizeTrigger + } + + fun sizeLimit(sizeLimit: Long) = sizeLimit(JsonField.of(sizeLimit)) + + /** + * Sets [Builder.sizeLimit] to an arbitrary JSON value. + * + * You should usually call [Builder.sizeLimit] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sizeLimit(sizeLimit: JsonField<Long>) = apply { this.sizeLimit = sizeLimit } + + fun sizeLimitBytes(sizeLimitBytes: Long) = sizeLimitBytes(JsonField.of(sizeLimitBytes)) + + /** + * Sets [Builder.sizeLimitBytes] to an arbitrary JSON value. + * + * You should usually call [Builder.sizeLimitBytes] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sizeLimitBytes(sizeLimitBytes: JsonField<Long>) = apply { + this.sizeLimitBytes = sizeLimitBytes + } + + fun useMultipartEndpoint(useMultipartEndpoint: Boolean) = + useMultipartEndpoint(JsonField.of(useMultipartEndpoint)) + + /** + * Sets [Builder.useMultipartEndpoint] to an arbitrary JSON value. + * + * You should usually call [Builder.useMultipartEndpoint] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun useMultipartEndpoint(useMultipartEndpoint: JsonField<Boolean>) = apply { + this.useMultipartEndpoint = useMultipartEndpoint + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BatchIngestConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BatchIngestConfig = + BatchIngestConfig( + scaleDownNemptyTrigger, + scaleUpNthreadsLimit, + scaleUpQsizeTrigger, + sizeLimit, + sizeLimitBytes, + useMultipartEndpoint, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BatchIngestConfig = apply { + if (validated) { + return@apply + } + + scaleDownNemptyTrigger() + scaleUpNthreadsLimit() + scaleUpQsizeTrigger() + sizeLimit() + sizeLimitBytes() + useMultipartEndpoint() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (scaleDownNemptyTrigger.asKnown().isPresent) 1 else 0) + + (if (scaleUpNthreadsLimit.asKnown().isPresent) 1 else 0) + + (if (scaleUpQsizeTrigger.asKnown().isPresent) 1 else 0) + + (if (sizeLimit.asKnown().isPresent) 1 else 0) + + (if (sizeLimitBytes.asKnown().isPresent) 1 else 0) + + (if (useMultipartEndpoint.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BatchIngestConfig && + scaleDownNemptyTrigger == other.scaleDownNemptyTrigger && + scaleUpNthreadsLimit == other.scaleUpNthreadsLimit && + scaleUpQsizeTrigger == other.scaleUpQsizeTrigger && + sizeLimit == other.sizeLimit && + sizeLimitBytes == other.sizeLimitBytes && + useMultipartEndpoint == other.useMultipartEndpoint && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + scaleDownNemptyTrigger, + scaleUpNthreadsLimit, + scaleUpQsizeTrigger, + sizeLimit, + sizeLimitBytes, + useMultipartEndpoint, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BatchIngestConfig{scaleDownNemptyTrigger=$scaleDownNemptyTrigger, scaleUpNthreadsLimit=$scaleUpNthreadsLimit, scaleUpQsizeTrigger=$scaleUpQsizeTrigger, sizeLimit=$sizeLimit, sizeLimitBytes=$sizeLimitBytes, useMultipartEndpoint=$useMultipartEndpoint, additionalProperties=$additionalProperties}" + } + + /** Customer info. */ + class CustomerInfo + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val customerId: JsonField<String>, + private val customerName: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("customer_id") + @ExcludeMissing + customerId: JsonField<String> = JsonMissing.of(), + @JsonProperty("customer_name") + @ExcludeMissing + customerName: JsonField<String> = JsonMissing.of(), + ) : this(customerId, customerName, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun customerId(): String = customerId.getRequired("customer_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun customerName(): String = customerName.getRequired("customer_name") + + /** + * Returns the raw JSON value of [customerId]. + * + * Unlike [customerId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("customer_id") + @ExcludeMissing + fun _customerId(): JsonField<String> = customerId + + /** + * Returns the raw JSON value of [customerName]. + * + * Unlike [customerName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("customer_name") + @ExcludeMissing + fun _customerName(): JsonField<String> = customerName + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CustomerInfo]. + * + * The following fields are required: + * ```java + * .customerId() + * .customerName() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomerInfo]. */ + class Builder internal constructor() { + + private var customerId: JsonField<String>? = null + private var customerName: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(customerInfo: CustomerInfo) = apply { + customerId = customerInfo.customerId + customerName = customerInfo.customerName + additionalProperties = customerInfo.additionalProperties.toMutableMap() + } + + fun customerId(customerId: String) = customerId(JsonField.of(customerId)) + + /** + * Sets [Builder.customerId] to an arbitrary JSON value. + * + * You should usually call [Builder.customerId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customerId(customerId: JsonField<String>) = apply { this.customerId = customerId } + + fun customerName(customerName: String) = customerName(JsonField.of(customerName)) + + /** + * Sets [Builder.customerName] to an arbitrary JSON value. + * + * You should usually call [Builder.customerName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customerName(customerName: JsonField<String>) = apply { + this.customerName = customerName + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomerInfo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .customerId() + * .customerName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomerInfo = + CustomerInfo( + checkRequired("customerId", customerId), + checkRequired("customerName", customerName), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CustomerInfo = apply { + if (validated) { + return@apply + } + + customerId() + customerName() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (customerId.asKnown().isPresent) 1 else 0) + + (if (customerName.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomerInfo && + customerId == other.customerId && + customerName == other.customerName && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(customerId, customerName, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomerInfo{customerId=$customerId, customerName=$customerName, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InfoListResponse && + version == other.version && + batchIngestConfig == other.batchIngestConfig && + customerInfo == other.customerInfo && + instanceFlags == other.instanceFlags && + licenseExpirationTime == other.licenseExpirationTime && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + version, + batchIngestConfig, + customerInfo, + instanceFlags, + licenseExpirationTime, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InfoListResponse{version=$version, batchIngestConfig=$batchIngestConfig, customerInfo=$customerInfo, instanceFlags=$instanceFlags, licenseExpirationTime=$licenseExpirationTime, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/info/InfoRetrieveHealthParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/info/InfoRetrieveHealthParams.kt new file mode 100644 index 00000000..3bbe2d0b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/info/InfoRetrieveHealthParams.kt @@ -0,0 +1,170 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.info + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** Get health information about the current deployment of LangSmith. */ +class InfoRetrieveHealthParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): InfoRetrieveHealthParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [InfoRetrieveHealthParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InfoRetrieveHealthParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(infoRetrieveHealthParams: InfoRetrieveHealthParams) = apply { + additionalHeaders = infoRetrieveHealthParams.additionalHeaders.toBuilder() + additionalQueryParams = infoRetrieveHealthParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [InfoRetrieveHealthParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InfoRetrieveHealthParams = + InfoRetrieveHealthParams(additionalHeaders.build(), additionalQueryParams.build()) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InfoRetrieveHealthParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "InfoRetrieveHealthParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/info/InfoRetrieveHealthResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/info/InfoRetrieveHealthResponse.kt new file mode 100644 index 00000000..aa2b7350 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/info/InfoRetrieveHealthResponse.kt @@ -0,0 +1,182 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.info + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +/** The LangSmith server info. */ +class InfoRetrieveHealthResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val clickhouseDiskFreePct: JsonField<Double>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("clickhouse_disk_free_pct") + @ExcludeMissing + clickhouseDiskFreePct: JsonField<Double> = JsonMissing.of() + ) : this(clickhouseDiskFreePct, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun clickhouseDiskFreePct(): Double = + clickhouseDiskFreePct.getRequired("clickhouse_disk_free_pct") + + /** + * Returns the raw JSON value of [clickhouseDiskFreePct]. + * + * Unlike [clickhouseDiskFreePct], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("clickhouse_disk_free_pct") + @ExcludeMissing + fun _clickhouseDiskFreePct(): JsonField<Double> = clickhouseDiskFreePct + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InfoRetrieveHealthResponse]. + * + * The following fields are required: + * ```java + * .clickhouseDiskFreePct() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InfoRetrieveHealthResponse]. */ + class Builder internal constructor() { + + private var clickhouseDiskFreePct: JsonField<Double>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(infoRetrieveHealthResponse: InfoRetrieveHealthResponse) = apply { + clickhouseDiskFreePct = infoRetrieveHealthResponse.clickhouseDiskFreePct + additionalProperties = infoRetrieveHealthResponse.additionalProperties.toMutableMap() + } + + fun clickhouseDiskFreePct(clickhouseDiskFreePct: Double) = + clickhouseDiskFreePct(JsonField.of(clickhouseDiskFreePct)) + + /** + * Sets [Builder.clickhouseDiskFreePct] to an arbitrary JSON value. + * + * You should usually call [Builder.clickhouseDiskFreePct] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun clickhouseDiskFreePct(clickhouseDiskFreePct: JsonField<Double>) = apply { + this.clickhouseDiskFreePct = clickhouseDiskFreePct + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InfoRetrieveHealthResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .clickhouseDiskFreePct() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InfoRetrieveHealthResponse = + InfoRetrieveHealthResponse( + checkRequired("clickhouseDiskFreePct", clickhouseDiskFreePct), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InfoRetrieveHealthResponse = apply { + if (validated) { + return@apply + } + + clickhouseDiskFreePct() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (clickhouseDiskFreePct.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InfoRetrieveHealthResponse && + clickhouseDiskFreePct == other.clickhouseDiskFreePct && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(clickhouseDiskFreePct, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InfoRetrieveHealthResponse{clickhouseDiskFreePct=$clickhouseDiskFreePct, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/me/MeRetrieveLsUserIdParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/me/MeRetrieveLsUserIdParams.kt new file mode 100644 index 00000000..eeb63444 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/me/MeRetrieveLsUserIdParams.kt @@ -0,0 +1,170 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.me + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** Get the LangSmith user ID for the current user. */ +class MeRetrieveLsUserIdParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): MeRetrieveLsUserIdParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [MeRetrieveLsUserIdParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MeRetrieveLsUserIdParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(meRetrieveLsUserIdParams: MeRetrieveLsUserIdParams) = apply { + additionalHeaders = meRetrieveLsUserIdParams.additionalHeaders.toBuilder() + additionalQueryParams = meRetrieveLsUserIdParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [MeRetrieveLsUserIdParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MeRetrieveLsUserIdParams = + MeRetrieveLsUserIdParams(additionalHeaders.build(), additionalQueryParams.build()) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MeRetrieveLsUserIdParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "MeRetrieveLsUserIdParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/me/onboardingstate/OnboardingStateCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/me/onboardingstate/OnboardingStateCreateParams.kt new file mode 100644 index 00000000..b75a61fe --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/me/onboardingstate/OnboardingStateCreateParams.kt @@ -0,0 +1,213 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.me.onboardingstate + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional + +/** Initialize onboarding state for the current user. */ +class OnboardingStateCreateParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): OnboardingStateCreateParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [OnboardingStateCreateParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OnboardingStateCreateParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(onboardingStateCreateParams: OnboardingStateCreateParams) = apply { + additionalHeaders = onboardingStateCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = onboardingStateCreateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + onboardingStateCreateParams.additionalBodyProperties.toMutableMap() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [OnboardingStateCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OnboardingStateCreateParams = + OnboardingStateCreateParams( + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OnboardingStateCreateParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "OnboardingStateCreateParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/me/onboardingstate/OnboardingStateListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/me/onboardingstate/OnboardingStateListParams.kt new file mode 100644 index 00000000..8f2489ba --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/me/onboardingstate/OnboardingStateListParams.kt @@ -0,0 +1,172 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.me.onboardingstate + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** Get onboarding state for the current user. */ +class OnboardingStateListParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): OnboardingStateListParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [OnboardingStateListParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OnboardingStateListParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(onboardingStateListParams: OnboardingStateListParams) = apply { + additionalHeaders = onboardingStateListParams.additionalHeaders.toBuilder() + additionalQueryParams = onboardingStateListParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [OnboardingStateListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OnboardingStateListParams = + OnboardingStateListParams(additionalHeaders.build(), additionalQueryParams.build()) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OnboardingStateListParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "OnboardingStateListParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/me/onboardingstate/OnboardingStateUpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/me/onboardingstate/OnboardingStateUpdateParams.kt new file mode 100644 index 00000000..e0c9038a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/me/onboardingstate/OnboardingStateUpdateParams.kt @@ -0,0 +1,241 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.me.onboardingstate + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Update a specific onboarding completion field for the current user. + * + * Valid fields: + * - tracing_completed_at + * - lgstudio_completed_at + * - playground_completed_at + * - evaluation_completed_at + * - success_viewed_at + */ +class OnboardingStateUpdateParams +private constructor( + private val field: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun field(): Optional<String> = Optional.ofNullable(field) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): OnboardingStateUpdateParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [OnboardingStateUpdateParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OnboardingStateUpdateParams]. */ + class Builder internal constructor() { + + private var field: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(onboardingStateUpdateParams: OnboardingStateUpdateParams) = apply { + field = onboardingStateUpdateParams.field + additionalHeaders = onboardingStateUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = onboardingStateUpdateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + onboardingStateUpdateParams.additionalBodyProperties.toMutableMap() + } + + fun field(field: String?) = apply { this.field = field } + + /** Alias for calling [Builder.field] with `field.orElse(null)`. */ + fun field(field: Optional<String>) = field(field.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [OnboardingStateUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OnboardingStateUpdateParams = + OnboardingStateUpdateParams( + field, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> field ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OnboardingStateUpdateParams && + field == other.field && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(field, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "OnboardingStateUpdateParams{field=$field, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/me/onboardingstate/UserOnboardingStateResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/me/onboardingstate/UserOnboardingStateResponse.kt new file mode 100644 index 00000000..0e0d21f1 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/me/onboardingstate/UserOnboardingStateResponse.kt @@ -0,0 +1,542 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.me.onboardingstate + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class UserOnboardingStateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val lsUserId: JsonField<String>, + private val updatedAt: JsonField<OffsetDateTime>, + private val evaluationCompletedAt: JsonField<OffsetDateTime>, + private val lgstudioCompletedAt: JsonField<OffsetDateTime>, + private val playgroundCompletedAt: JsonField<OffsetDateTime>, + private val successViewedAt: JsonField<OffsetDateTime>, + private val tracingCompletedAt: JsonField<OffsetDateTime>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("ls_user_id") @ExcludeMissing lsUserId: JsonField<String> = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("evaluation_completed_at") + @ExcludeMissing + evaluationCompletedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("lgstudio_completed_at") + @ExcludeMissing + lgstudioCompletedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("playground_completed_at") + @ExcludeMissing + playgroundCompletedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("success_viewed_at") + @ExcludeMissing + successViewedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("tracing_completed_at") + @ExcludeMissing + tracingCompletedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + ) : this( + id, + createdAt, + lsUserId, + updatedAt, + evaluationCompletedAt, + lgstudioCompletedAt, + playgroundCompletedAt, + successViewedAt, + tracingCompletedAt, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun lsUserId(): String = lsUserId.getRequired("ls_user_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updatedAt(): OffsetDateTime = updatedAt.getRequired("updated_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun evaluationCompletedAt(): Optional<OffsetDateTime> = + evaluationCompletedAt.getOptional("evaluation_completed_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun lgstudioCompletedAt(): Optional<OffsetDateTime> = + lgstudioCompletedAt.getOptional("lgstudio_completed_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun playgroundCompletedAt(): Optional<OffsetDateTime> = + playgroundCompletedAt.getOptional("playground_completed_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun successViewedAt(): Optional<OffsetDateTime> = + successViewedAt.getOptional("success_viewed_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tracingCompletedAt(): Optional<OffsetDateTime> = + tracingCompletedAt.getOptional("tracing_completed_at") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [lsUserId]. + * + * Unlike [lsUserId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ls_user_id") @ExcludeMissing fun _lsUserId(): JsonField<String> = lsUserId + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField<OffsetDateTime> = updatedAt + + /** + * Returns the raw JSON value of [evaluationCompletedAt]. + * + * Unlike [evaluationCompletedAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("evaluation_completed_at") + @ExcludeMissing + fun _evaluationCompletedAt(): JsonField<OffsetDateTime> = evaluationCompletedAt + + /** + * Returns the raw JSON value of [lgstudioCompletedAt]. + * + * Unlike [lgstudioCompletedAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lgstudio_completed_at") + @ExcludeMissing + fun _lgstudioCompletedAt(): JsonField<OffsetDateTime> = lgstudioCompletedAt + + /** + * Returns the raw JSON value of [playgroundCompletedAt]. + * + * Unlike [playgroundCompletedAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("playground_completed_at") + @ExcludeMissing + fun _playgroundCompletedAt(): JsonField<OffsetDateTime> = playgroundCompletedAt + + /** + * Returns the raw JSON value of [successViewedAt]. + * + * Unlike [successViewedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("success_viewed_at") + @ExcludeMissing + fun _successViewedAt(): JsonField<OffsetDateTime> = successViewedAt + + /** + * Returns the raw JSON value of [tracingCompletedAt]. + * + * Unlike [tracingCompletedAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tracing_completed_at") + @ExcludeMissing + fun _tracingCompletedAt(): JsonField<OffsetDateTime> = tracingCompletedAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UserOnboardingStateResponse]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .lsUserId() + * .updatedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UserOnboardingStateResponse]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var createdAt: JsonField<OffsetDateTime>? = null + private var lsUserId: JsonField<String>? = null + private var updatedAt: JsonField<OffsetDateTime>? = null + private var evaluationCompletedAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var lgstudioCompletedAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var playgroundCompletedAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var successViewedAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var tracingCompletedAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(userOnboardingStateResponse: UserOnboardingStateResponse) = apply { + id = userOnboardingStateResponse.id + createdAt = userOnboardingStateResponse.createdAt + lsUserId = userOnboardingStateResponse.lsUserId + updatedAt = userOnboardingStateResponse.updatedAt + evaluationCompletedAt = userOnboardingStateResponse.evaluationCompletedAt + lgstudioCompletedAt = userOnboardingStateResponse.lgstudioCompletedAt + playgroundCompletedAt = userOnboardingStateResponse.playgroundCompletedAt + successViewedAt = userOnboardingStateResponse.successViewedAt + tracingCompletedAt = userOnboardingStateResponse.tracingCompletedAt + additionalProperties = userOnboardingStateResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun lsUserId(lsUserId: String) = lsUserId(JsonField.of(lsUserId)) + + /** + * Sets [Builder.lsUserId] to an arbitrary JSON value. + * + * You should usually call [Builder.lsUserId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun lsUserId(lsUserId: JsonField<String>) = apply { this.lsUserId = lsUserId } + + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField<OffsetDateTime>) = apply { this.updatedAt = updatedAt } + + fun evaluationCompletedAt(evaluationCompletedAt: OffsetDateTime?) = + evaluationCompletedAt(JsonField.ofNullable(evaluationCompletedAt)) + + /** + * Alias for calling [Builder.evaluationCompletedAt] with + * `evaluationCompletedAt.orElse(null)`. + */ + fun evaluationCompletedAt(evaluationCompletedAt: Optional<OffsetDateTime>) = + evaluationCompletedAt(evaluationCompletedAt.getOrNull()) + + /** + * Sets [Builder.evaluationCompletedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.evaluationCompletedAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun evaluationCompletedAt(evaluationCompletedAt: JsonField<OffsetDateTime>) = apply { + this.evaluationCompletedAt = evaluationCompletedAt + } + + fun lgstudioCompletedAt(lgstudioCompletedAt: OffsetDateTime?) = + lgstudioCompletedAt(JsonField.ofNullable(lgstudioCompletedAt)) + + /** + * Alias for calling [Builder.lgstudioCompletedAt] with `lgstudioCompletedAt.orElse(null)`. + */ + fun lgstudioCompletedAt(lgstudioCompletedAt: Optional<OffsetDateTime>) = + lgstudioCompletedAt(lgstudioCompletedAt.getOrNull()) + + /** + * Sets [Builder.lgstudioCompletedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.lgstudioCompletedAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun lgstudioCompletedAt(lgstudioCompletedAt: JsonField<OffsetDateTime>) = apply { + this.lgstudioCompletedAt = lgstudioCompletedAt + } + + fun playgroundCompletedAt(playgroundCompletedAt: OffsetDateTime?) = + playgroundCompletedAt(JsonField.ofNullable(playgroundCompletedAt)) + + /** + * Alias for calling [Builder.playgroundCompletedAt] with + * `playgroundCompletedAt.orElse(null)`. + */ + fun playgroundCompletedAt(playgroundCompletedAt: Optional<OffsetDateTime>) = + playgroundCompletedAt(playgroundCompletedAt.getOrNull()) + + /** + * Sets [Builder.playgroundCompletedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.playgroundCompletedAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun playgroundCompletedAt(playgroundCompletedAt: JsonField<OffsetDateTime>) = apply { + this.playgroundCompletedAt = playgroundCompletedAt + } + + fun successViewedAt(successViewedAt: OffsetDateTime?) = + successViewedAt(JsonField.ofNullable(successViewedAt)) + + /** Alias for calling [Builder.successViewedAt] with `successViewedAt.orElse(null)`. */ + fun successViewedAt(successViewedAt: Optional<OffsetDateTime>) = + successViewedAt(successViewedAt.getOrNull()) + + /** + * Sets [Builder.successViewedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.successViewedAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun successViewedAt(successViewedAt: JsonField<OffsetDateTime>) = apply { + this.successViewedAt = successViewedAt + } + + fun tracingCompletedAt(tracingCompletedAt: OffsetDateTime?) = + tracingCompletedAt(JsonField.ofNullable(tracingCompletedAt)) + + /** + * Alias for calling [Builder.tracingCompletedAt] with `tracingCompletedAt.orElse(null)`. + */ + fun tracingCompletedAt(tracingCompletedAt: Optional<OffsetDateTime>) = + tracingCompletedAt(tracingCompletedAt.getOrNull()) + + /** + * Sets [Builder.tracingCompletedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.tracingCompletedAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tracingCompletedAt(tracingCompletedAt: JsonField<OffsetDateTime>) = apply { + this.tracingCompletedAt = tracingCompletedAt + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UserOnboardingStateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .lsUserId() + * .updatedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UserOnboardingStateResponse = + UserOnboardingStateResponse( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("lsUserId", lsUserId), + checkRequired("updatedAt", updatedAt), + evaluationCompletedAt, + lgstudioCompletedAt, + playgroundCompletedAt, + successViewedAt, + tracingCompletedAt, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UserOnboardingStateResponse = apply { + if (validated) { + return@apply + } + + id() + createdAt() + lsUserId() + updatedAt() + evaluationCompletedAt() + lgstudioCompletedAt() + playgroundCompletedAt() + successViewedAt() + tracingCompletedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (lsUserId.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (if (evaluationCompletedAt.asKnown().isPresent) 1 else 0) + + (if (lgstudioCompletedAt.asKnown().isPresent) 1 else 0) + + (if (playgroundCompletedAt.asKnown().isPresent) 1 else 0) + + (if (successViewedAt.asKnown().isPresent) 1 else 0) + + (if (tracingCompletedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UserOnboardingStateResponse && + id == other.id && + createdAt == other.createdAt && + lsUserId == other.lsUserId && + updatedAt == other.updatedAt && + evaluationCompletedAt == other.evaluationCompletedAt && + lgstudioCompletedAt == other.lgstudioCompletedAt && + playgroundCompletedAt == other.playgroundCompletedAt && + successViewedAt == other.successViewedAt && + tracingCompletedAt == other.tracingCompletedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + createdAt, + lsUserId, + updatedAt, + evaluationCompletedAt, + lgstudioCompletedAt, + playgroundCompletedAt, + successViewedAt, + tracingCompletedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UserOnboardingStateResponse{id=$id, createdAt=$createdAt, lsUserId=$lsUserId, updatedAt=$updatedAt, evaluationCompletedAt=$evaluationCompletedAt, lgstudioCompletedAt=$lgstudioCompletedAt, playgroundCompletedAt=$playgroundCompletedAt, successViewedAt=$successViewedAt, tracingCompletedAt=$tracingCompletedAt, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapDeleteParams.kt new file mode 100644 index 00000000..3568ca2c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapDeleteParams.kt @@ -0,0 +1,232 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.modelpricemap + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete Model Price */ +class ModelPriceMapDeleteParams +private constructor( + private val id: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun id(): Optional<String> = Optional.ofNullable(id) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ModelPriceMapDeleteParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [ModelPriceMapDeleteParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ModelPriceMapDeleteParams]. */ + class Builder internal constructor() { + + private var id: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(modelPriceMapDeleteParams: ModelPriceMapDeleteParams) = apply { + id = modelPriceMapDeleteParams.id + additionalHeaders = modelPriceMapDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = modelPriceMapDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + modelPriceMapDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun id(id: String?) = apply { this.id = id } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<String>) = id(id.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [ModelPriceMapDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ModelPriceMapDeleteParams = + ModelPriceMapDeleteParams( + id, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> id ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelPriceMapDeleteParams && + id == other.id && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(id, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "ModelPriceMapDeleteParams{id=$id, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapDeleteResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapDeleteResponse.kt new file mode 100644 index 00000000..b2855cc1 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapDeleteResponse.kt @@ -0,0 +1,118 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.modelpricemap + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class ModelPriceMapDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ModelPriceMapDeleteResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ModelPriceMapDeleteResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(modelPriceMapDeleteResponse: ModelPriceMapDeleteResponse) = apply { + additionalProperties = modelPriceMapDeleteResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ModelPriceMapDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ModelPriceMapDeleteResponse = + ModelPriceMapDeleteResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): ModelPriceMapDeleteResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelPriceMapDeleteResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ModelPriceMapDeleteResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapModelPriceMapParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapModelPriceMapParams.kt new file mode 100644 index 00000000..9dd785eb --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapModelPriceMapParams.kt @@ -0,0 +1,1613 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.modelpricemap + +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 com.langsmith_api.api.core.BaseDeserializer +import com.langsmith_api.api.core.BaseSerializer +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.allMaxBy +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create New Model Price */ +class ModelPriceMapModelPriceMapParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun completionCost(): CompletionCost = body.completionCost() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun matchPattern(): String = body.matchPattern() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = body.name() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun promptCost(): PromptCost = body.promptCost() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun completionCostDetails(): Optional<CompletionCostDetails> = body.completionCostDetails() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun matchPath(): Optional<List<String>> = body.matchPath() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun promptCostDetails(): Optional<PromptCostDetails> = body.promptCostDetails() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun provider(): Optional<String> = body.provider() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun startTime(): Optional<OffsetDateTime> = body.startTime() + + /** + * Returns the raw JSON value of [completionCost]. + * + * Unlike [completionCost], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _completionCost(): JsonField<CompletionCost> = body._completionCost() + + /** + * Returns the raw JSON value of [matchPattern]. + * + * Unlike [matchPattern], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _matchPattern(): JsonField<String> = body._matchPattern() + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _name(): JsonField<String> = body._name() + + /** + * Returns the raw JSON value of [promptCost]. + * + * Unlike [promptCost], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _promptCost(): JsonField<PromptCost> = body._promptCost() + + /** + * Returns the raw JSON value of [completionCostDetails]. + * + * Unlike [completionCostDetails], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _completionCostDetails(): JsonField<CompletionCostDetails> = body._completionCostDetails() + + /** + * Returns the raw JSON value of [matchPath]. + * + * Unlike [matchPath], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _matchPath(): JsonField<List<String>> = body._matchPath() + + /** + * Returns the raw JSON value of [promptCostDetails]. + * + * Unlike [promptCostDetails], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _promptCostDetails(): JsonField<PromptCostDetails> = body._promptCostDetails() + + /** + * Returns the raw JSON value of [provider]. + * + * Unlike [provider], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _provider(): JsonField<String> = body._provider() + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _startTime(): JsonField<OffsetDateTime> = body._startTime() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ModelPriceMapModelPriceMapParams]. + * + * The following fields are required: + * ```java + * .completionCost() + * .matchPattern() + * .name() + * .promptCost() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ModelPriceMapModelPriceMapParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(modelPriceMapModelPriceMapParams: ModelPriceMapModelPriceMapParams) = + apply { + body = modelPriceMapModelPriceMapParams.body.toBuilder() + additionalHeaders = modelPriceMapModelPriceMapParams.additionalHeaders.toBuilder() + additionalQueryParams = + modelPriceMapModelPriceMapParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [completionCost] + * - [matchPattern] + * - [name] + * - [promptCost] + * - [completionCostDetails] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun completionCost(completionCost: CompletionCost) = apply { + body.completionCost(completionCost) + } + + /** + * Sets [Builder.completionCost] to an arbitrary JSON value. + * + * You should usually call [Builder.completionCost] with a well-typed [CompletionCost] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun completionCost(completionCost: JsonField<CompletionCost>) = apply { + body.completionCost(completionCost) + } + + /** Alias for calling [completionCost] with `CompletionCost.ofNumber(number)`. */ + fun completionCost(number: Double) = apply { body.completionCost(number) } + + /** Alias for calling [completionCost] with `CompletionCost.ofString(string)`. */ + fun completionCost(string: String) = apply { body.completionCost(string) } + + fun matchPattern(matchPattern: String) = apply { body.matchPattern(matchPattern) } + + /** + * Sets [Builder.matchPattern] to an arbitrary JSON value. + * + * You should usually call [Builder.matchPattern] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun matchPattern(matchPattern: JsonField<String>) = apply { + body.matchPattern(matchPattern) + } + + fun name(name: String) = apply { body.name(name) } + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { body.name(name) } + + fun promptCost(promptCost: PromptCost) = apply { body.promptCost(promptCost) } + + /** + * Sets [Builder.promptCost] to an arbitrary JSON value. + * + * You should usually call [Builder.promptCost] with a well-typed [PromptCost] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun promptCost(promptCost: JsonField<PromptCost>) = apply { body.promptCost(promptCost) } + + /** Alias for calling [promptCost] with `PromptCost.ofNumber(number)`. */ + fun promptCost(number: Double) = apply { body.promptCost(number) } + + /** Alias for calling [promptCost] with `PromptCost.ofString(string)`. */ + fun promptCost(string: String) = apply { body.promptCost(string) } + + fun completionCostDetails(completionCostDetails: CompletionCostDetails?) = apply { + body.completionCostDetails(completionCostDetails) + } + + /** + * Alias for calling [Builder.completionCostDetails] with + * `completionCostDetails.orElse(null)`. + */ + fun completionCostDetails(completionCostDetails: Optional<CompletionCostDetails>) = + completionCostDetails(completionCostDetails.getOrNull()) + + /** + * Sets [Builder.completionCostDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.completionCostDetails] with a well-typed + * [CompletionCostDetails] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun completionCostDetails(completionCostDetails: JsonField<CompletionCostDetails>) = apply { + body.completionCostDetails(completionCostDetails) + } + + fun matchPath(matchPath: List<String>) = apply { body.matchPath(matchPath) } + + /** + * Sets [Builder.matchPath] to an arbitrary JSON value. + * + * You should usually call [Builder.matchPath] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun matchPath(matchPath: JsonField<List<String>>) = apply { body.matchPath(matchPath) } + + /** + * Adds a single [String] to [Builder.matchPath]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMatchPath(matchPath: String) = apply { body.addMatchPath(matchPath) } + + fun promptCostDetails(promptCostDetails: PromptCostDetails?) = apply { + body.promptCostDetails(promptCostDetails) + } + + /** Alias for calling [Builder.promptCostDetails] with `promptCostDetails.orElse(null)`. */ + fun promptCostDetails(promptCostDetails: Optional<PromptCostDetails>) = + promptCostDetails(promptCostDetails.getOrNull()) + + /** + * Sets [Builder.promptCostDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.promptCostDetails] with a well-typed [PromptCostDetails] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun promptCostDetails(promptCostDetails: JsonField<PromptCostDetails>) = apply { + body.promptCostDetails(promptCostDetails) + } + + fun provider(provider: String?) = apply { body.provider(provider) } + + /** Alias for calling [Builder.provider] with `provider.orElse(null)`. */ + fun provider(provider: Optional<String>) = provider(provider.getOrNull()) + + /** + * Sets [Builder.provider] to an arbitrary JSON value. + * + * You should usually call [Builder.provider] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun provider(provider: JsonField<String>) = apply { body.provider(provider) } + + fun startTime(startTime: OffsetDateTime?) = apply { body.startTime(startTime) } + + /** Alias for calling [Builder.startTime] with `startTime.orElse(null)`. */ + fun startTime(startTime: Optional<OffsetDateTime>) = startTime(startTime.getOrNull()) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField<OffsetDateTime>) = apply { body.startTime(startTime) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ModelPriceMapModelPriceMapParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .completionCost() + * .matchPattern() + * .name() + * .promptCost() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ModelPriceMapModelPriceMapParams = + ModelPriceMapModelPriceMapParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Model price map create schema. */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val completionCost: JsonField<CompletionCost>, + private val matchPattern: JsonField<String>, + private val name: JsonField<String>, + private val promptCost: JsonField<PromptCost>, + private val completionCostDetails: JsonField<CompletionCostDetails>, + private val matchPath: JsonField<List<String>>, + private val promptCostDetails: JsonField<PromptCostDetails>, + private val provider: JsonField<String>, + private val startTime: JsonField<OffsetDateTime>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("completion_cost") + @ExcludeMissing + completionCost: JsonField<CompletionCost> = JsonMissing.of(), + @JsonProperty("match_pattern") + @ExcludeMissing + matchPattern: JsonField<String> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("prompt_cost") + @ExcludeMissing + promptCost: JsonField<PromptCost> = JsonMissing.of(), + @JsonProperty("completion_cost_details") + @ExcludeMissing + completionCostDetails: JsonField<CompletionCostDetails> = JsonMissing.of(), + @JsonProperty("match_path") + @ExcludeMissing + matchPath: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("prompt_cost_details") + @ExcludeMissing + promptCostDetails: JsonField<PromptCostDetails> = JsonMissing.of(), + @JsonProperty("provider") + @ExcludeMissing + provider: JsonField<String> = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField<OffsetDateTime> = JsonMissing.of(), + ) : this( + completionCost, + matchPattern, + name, + promptCost, + completionCostDetails, + matchPath, + promptCostDetails, + provider, + startTime, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun completionCost(): CompletionCost = completionCost.getRequired("completion_cost") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun matchPattern(): String = matchPattern.getRequired("match_pattern") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun promptCost(): PromptCost = promptCost.getRequired("prompt_cost") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun completionCostDetails(): Optional<CompletionCostDetails> = + completionCostDetails.getOptional("completion_cost_details") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun matchPath(): Optional<List<String>> = matchPath.getOptional("match_path") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun promptCostDetails(): Optional<PromptCostDetails> = + promptCostDetails.getOptional("prompt_cost_details") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun provider(): Optional<String> = provider.getOptional("provider") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun startTime(): Optional<OffsetDateTime> = startTime.getOptional("start_time") + + /** + * Returns the raw JSON value of [completionCost]. + * + * Unlike [completionCost], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("completion_cost") + @ExcludeMissing + fun _completionCost(): JsonField<CompletionCost> = completionCost + + /** + * Returns the raw JSON value of [matchPattern]. + * + * Unlike [matchPattern], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("match_pattern") + @ExcludeMissing + fun _matchPattern(): JsonField<String> = matchPattern + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [promptCost]. + * + * Unlike [promptCost], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prompt_cost") + @ExcludeMissing + fun _promptCost(): JsonField<PromptCost> = promptCost + + /** + * Returns the raw JSON value of [completionCostDetails]. + * + * Unlike [completionCostDetails], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("completion_cost_details") + @ExcludeMissing + fun _completionCostDetails(): JsonField<CompletionCostDetails> = completionCostDetails + + /** + * Returns the raw JSON value of [matchPath]. + * + * Unlike [matchPath], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("match_path") + @ExcludeMissing + fun _matchPath(): JsonField<List<String>> = matchPath + + /** + * Returns the raw JSON value of [promptCostDetails]. + * + * Unlike [promptCostDetails], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("prompt_cost_details") + @ExcludeMissing + fun _promptCostDetails(): JsonField<PromptCostDetails> = promptCostDetails + + /** + * Returns the raw JSON value of [provider]. + * + * Unlike [provider], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("provider") @ExcludeMissing fun _provider(): JsonField<String> = provider + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_time") + @ExcludeMissing + fun _startTime(): JsonField<OffsetDateTime> = startTime + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .completionCost() + * .matchPattern() + * .name() + * .promptCost() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var completionCost: JsonField<CompletionCost>? = null + private var matchPattern: JsonField<String>? = null + private var name: JsonField<String>? = null + private var promptCost: JsonField<PromptCost>? = null + private var completionCostDetails: JsonField<CompletionCostDetails> = JsonMissing.of() + private var matchPath: JsonField<MutableList<String>>? = null + private var promptCostDetails: JsonField<PromptCostDetails> = JsonMissing.of() + private var provider: JsonField<String> = JsonMissing.of() + private var startTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + completionCost = body.completionCost + matchPattern = body.matchPattern + name = body.name + promptCost = body.promptCost + completionCostDetails = body.completionCostDetails + matchPath = body.matchPath.map { it.toMutableList() } + promptCostDetails = body.promptCostDetails + provider = body.provider + startTime = body.startTime + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun completionCost(completionCost: CompletionCost) = + completionCost(JsonField.of(completionCost)) + + /** + * Sets [Builder.completionCost] to an arbitrary JSON value. + * + * You should usually call [Builder.completionCost] with a well-typed [CompletionCost] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun completionCost(completionCost: JsonField<CompletionCost>) = apply { + this.completionCost = completionCost + } + + /** Alias for calling [completionCost] with `CompletionCost.ofNumber(number)`. */ + fun completionCost(number: Double) = completionCost(CompletionCost.ofNumber(number)) + + /** Alias for calling [completionCost] with `CompletionCost.ofString(string)`. */ + fun completionCost(string: String) = completionCost(CompletionCost.ofString(string)) + + fun matchPattern(matchPattern: String) = matchPattern(JsonField.of(matchPattern)) + + /** + * Sets [Builder.matchPattern] to an arbitrary JSON value. + * + * You should usually call [Builder.matchPattern] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun matchPattern(matchPattern: JsonField<String>) = apply { + this.matchPattern = matchPattern + } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun promptCost(promptCost: PromptCost) = promptCost(JsonField.of(promptCost)) + + /** + * Sets [Builder.promptCost] to an arbitrary JSON value. + * + * You should usually call [Builder.promptCost] with a well-typed [PromptCost] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun promptCost(promptCost: JsonField<PromptCost>) = apply { + this.promptCost = promptCost + } + + /** Alias for calling [promptCost] with `PromptCost.ofNumber(number)`. */ + fun promptCost(number: Double) = promptCost(PromptCost.ofNumber(number)) + + /** Alias for calling [promptCost] with `PromptCost.ofString(string)`. */ + fun promptCost(string: String) = promptCost(PromptCost.ofString(string)) + + fun completionCostDetails(completionCostDetails: CompletionCostDetails?) = + completionCostDetails(JsonField.ofNullable(completionCostDetails)) + + /** + * Alias for calling [Builder.completionCostDetails] with + * `completionCostDetails.orElse(null)`. + */ + fun completionCostDetails(completionCostDetails: Optional<CompletionCostDetails>) = + completionCostDetails(completionCostDetails.getOrNull()) + + /** + * Sets [Builder.completionCostDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.completionCostDetails] with a well-typed + * [CompletionCostDetails] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun completionCostDetails(completionCostDetails: JsonField<CompletionCostDetails>) = + apply { + this.completionCostDetails = completionCostDetails + } + + fun matchPath(matchPath: List<String>) = matchPath(JsonField.of(matchPath)) + + /** + * Sets [Builder.matchPath] to an arbitrary JSON value. + * + * You should usually call [Builder.matchPath] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun matchPath(matchPath: JsonField<List<String>>) = apply { + this.matchPath = matchPath.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.matchPath]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMatchPath(matchPath: String) = apply { + this.matchPath = + (this.matchPath ?: JsonField.of(mutableListOf())).also { + checkKnown("matchPath", it).add(matchPath) + } + } + + fun promptCostDetails(promptCostDetails: PromptCostDetails?) = + promptCostDetails(JsonField.ofNullable(promptCostDetails)) + + /** + * Alias for calling [Builder.promptCostDetails] with `promptCostDetails.orElse(null)`. + */ + fun promptCostDetails(promptCostDetails: Optional<PromptCostDetails>) = + promptCostDetails(promptCostDetails.getOrNull()) + + /** + * Sets [Builder.promptCostDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.promptCostDetails] with a well-typed + * [PromptCostDetails] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun promptCostDetails(promptCostDetails: JsonField<PromptCostDetails>) = apply { + this.promptCostDetails = promptCostDetails + } + + fun provider(provider: String?) = provider(JsonField.ofNullable(provider)) + + /** Alias for calling [Builder.provider] with `provider.orElse(null)`. */ + fun provider(provider: Optional<String>) = provider(provider.getOrNull()) + + /** + * Sets [Builder.provider] to an arbitrary JSON value. + * + * You should usually call [Builder.provider] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun provider(provider: JsonField<String>) = apply { this.provider = provider } + + fun startTime(startTime: OffsetDateTime?) = startTime(JsonField.ofNullable(startTime)) + + /** Alias for calling [Builder.startTime] with `startTime.orElse(null)`. */ + fun startTime(startTime: Optional<OffsetDateTime>) = startTime(startTime.getOrNull()) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField<OffsetDateTime>) = apply { + this.startTime = startTime + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .completionCost() + * .matchPattern() + * .name() + * .promptCost() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("completionCost", completionCost), + checkRequired("matchPattern", matchPattern), + checkRequired("name", name), + checkRequired("promptCost", promptCost), + completionCostDetails, + (matchPath ?: JsonMissing.of()).map { it.toImmutable() }, + promptCostDetails, + provider, + startTime, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + completionCost().validate() + matchPattern() + name() + promptCost().validate() + completionCostDetails().ifPresent { it.validate() } + matchPath() + promptCostDetails().ifPresent { it.validate() } + provider() + startTime() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (completionCost.asKnown().getOrNull()?.validity() ?: 0) + + (if (matchPattern.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (promptCost.asKnown().getOrNull()?.validity() ?: 0) + + (completionCostDetails.asKnown().getOrNull()?.validity() ?: 0) + + (matchPath.asKnown().getOrNull()?.size ?: 0) + + (promptCostDetails.asKnown().getOrNull()?.validity() ?: 0) + + (if (provider.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + completionCost == other.completionCost && + matchPattern == other.matchPattern && + name == other.name && + promptCost == other.promptCost && + completionCostDetails == other.completionCostDetails && + matchPath == other.matchPath && + promptCostDetails == other.promptCostDetails && + provider == other.provider && + startTime == other.startTime && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + completionCost, + matchPattern, + name, + promptCost, + completionCostDetails, + matchPath, + promptCostDetails, + provider, + startTime, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{completionCost=$completionCost, matchPattern=$matchPattern, name=$name, promptCost=$promptCost, completionCostDetails=$completionCostDetails, matchPath=$matchPath, promptCostDetails=$promptCostDetails, provider=$provider, startTime=$startTime, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = CompletionCost.Deserializer::class) + @JsonSerialize(using = CompletionCost.Serializer::class) + class CompletionCost + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional<Double> = Optional.ofNullable(number) + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): CompletionCost = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompletionCost && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "CompletionCost{number=$number}" + string != null -> "CompletionCost{string=$string}" + _json != null -> "CompletionCost{_unknown=$_json}" + else -> throw IllegalStateException("Invalid CompletionCost") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = CompletionCost(number = number) + + @JvmStatic fun ofString(string: String) = CompletionCost(string = string) + } + + /** + * An interface that defines how to map each variant of [CompletionCost] to a value of type + * [T]. + */ + interface Visitor<out T> { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [CompletionCost] to a value of type [T]. + * + * An instance of [CompletionCost] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown CompletionCost: $json") + } + } + + internal class Deserializer : BaseDeserializer<CompletionCost>(CompletionCost::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): CompletionCost { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<Double>())?.let { + CompletionCost(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<String>())?.let { + CompletionCost(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> CompletionCost(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<CompletionCost>(CompletionCost::class) { + + override fun serialize( + value: CompletionCost, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid CompletionCost") + } + } + } + } + + @JsonDeserialize(using = PromptCost.Deserializer::class) + @JsonSerialize(using = PromptCost.Serializer::class) + class PromptCost + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional<Double> = Optional.ofNullable(number) + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): PromptCost = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PromptCost && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "PromptCost{number=$number}" + string != null -> "PromptCost{string=$string}" + _json != null -> "PromptCost{_unknown=$_json}" + else -> throw IllegalStateException("Invalid PromptCost") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = PromptCost(number = number) + + @JvmStatic fun ofString(string: String) = PromptCost(string = string) + } + + /** + * An interface that defines how to map each variant of [PromptCost] to a value of type [T]. + */ + interface Visitor<out T> { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [PromptCost] to a value of type [T]. + * + * An instance of [PromptCost] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown PromptCost: $json") + } + } + + internal class Deserializer : BaseDeserializer<PromptCost>(PromptCost::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): PromptCost { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<Double>())?.let { + PromptCost(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<String>())?.let { + PromptCost(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> PromptCost(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<PromptCost>(PromptCost::class) { + + override fun serialize( + value: PromptCost, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid PromptCost") + } + } + } + } + + class CompletionCostDetails + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompletionCostDetails]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CompletionCostDetails]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(completionCostDetails: CompletionCostDetails) = apply { + additionalProperties = completionCostDetails.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompletionCostDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CompletionCostDetails = + CompletionCostDetails(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): CompletionCostDetails = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompletionCostDetails && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompletionCostDetails{additionalProperties=$additionalProperties}" + } + + class PromptCostDetails + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [PromptCostDetails]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PromptCostDetails]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(promptCostDetails: PromptCostDetails) = apply { + additionalProperties = promptCostDetails.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PromptCostDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PromptCostDetails = PromptCostDetails(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): PromptCostDetails = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PromptCostDetails && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "PromptCostDetails{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelPriceMapModelPriceMapParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ModelPriceMapModelPriceMapParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapModelPriceMapResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapModelPriceMapResponse.kt new file mode 100644 index 00000000..ca513638 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapModelPriceMapResponse.kt @@ -0,0 +1,121 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.modelpricemap + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class ModelPriceMapModelPriceMapResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ModelPriceMapModelPriceMapResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ModelPriceMapModelPriceMapResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(modelPriceMapModelPriceMapResponse: ModelPriceMapModelPriceMapResponse) = + apply { + additionalProperties = + modelPriceMapModelPriceMapResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ModelPriceMapModelPriceMapResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ModelPriceMapModelPriceMapResponse = + ModelPriceMapModelPriceMapResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): ModelPriceMapModelPriceMapResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelPriceMapModelPriceMapResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ModelPriceMapModelPriceMapResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapRetrieveModelPriceMapParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapRetrieveModelPriceMapParams.kt new file mode 100644 index 00000000..ac1a9872 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapRetrieveModelPriceMapParams.kt @@ -0,0 +1,180 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.modelpricemap + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** Read Model Price Map */ +class ModelPriceMapRetrieveModelPriceMapParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ModelPriceMapRetrieveModelPriceMapParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [ModelPriceMapRetrieveModelPriceMapParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ModelPriceMapRetrieveModelPriceMapParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + modelPriceMapRetrieveModelPriceMapParams: ModelPriceMapRetrieveModelPriceMapParams + ) = apply { + additionalHeaders = + modelPriceMapRetrieveModelPriceMapParams.additionalHeaders.toBuilder() + additionalQueryParams = + modelPriceMapRetrieveModelPriceMapParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ModelPriceMapRetrieveModelPriceMapParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ModelPriceMapRetrieveModelPriceMapParams = + ModelPriceMapRetrieveModelPriceMapParams( + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelPriceMapRetrieveModelPriceMapParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "ModelPriceMapRetrieveModelPriceMapParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapRetrieveModelPriceMapResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapRetrieveModelPriceMapResponse.kt new file mode 100644 index 00000000..8814bc3a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapRetrieveModelPriceMapResponse.kt @@ -0,0 +1,122 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.modelpricemap + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class ModelPriceMapRetrieveModelPriceMapResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ModelPriceMapRetrieveModelPriceMapResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ModelPriceMapRetrieveModelPriceMapResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from( + modelPriceMapRetrieveModelPriceMapResponse: ModelPriceMapRetrieveModelPriceMapResponse + ) = apply { + additionalProperties = + modelPriceMapRetrieveModelPriceMapResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ModelPriceMapRetrieveModelPriceMapResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ModelPriceMapRetrieveModelPriceMapResponse = + ModelPriceMapRetrieveModelPriceMapResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): ModelPriceMapRetrieveModelPriceMapResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelPriceMapRetrieveModelPriceMapResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ModelPriceMapRetrieveModelPriceMapResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapUpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapUpdateParams.kt new file mode 100644 index 00000000..d6d7b108 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapUpdateParams.kt @@ -0,0 +1,1628 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.modelpricemap + +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 com.langsmith_api.api.core.BaseDeserializer +import com.langsmith_api.api.core.BaseSerializer +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.allMaxBy +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Update Model Price */ +class ModelPriceMapUpdateParams +private constructor( + private val id: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun id(): Optional<String> = Optional.ofNullable(id) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun completionCost(): CompletionCost = body.completionCost() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun matchPattern(): String = body.matchPattern() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = body.name() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun promptCost(): PromptCost = body.promptCost() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun completionCostDetails(): Optional<CompletionCostDetails> = body.completionCostDetails() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun matchPath(): Optional<List<String>> = body.matchPath() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun promptCostDetails(): Optional<PromptCostDetails> = body.promptCostDetails() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun provider(): Optional<String> = body.provider() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun startTime(): Optional<OffsetDateTime> = body.startTime() + + /** + * Returns the raw JSON value of [completionCost]. + * + * Unlike [completionCost], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _completionCost(): JsonField<CompletionCost> = body._completionCost() + + /** + * Returns the raw JSON value of [matchPattern]. + * + * Unlike [matchPattern], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _matchPattern(): JsonField<String> = body._matchPattern() + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _name(): JsonField<String> = body._name() + + /** + * Returns the raw JSON value of [promptCost]. + * + * Unlike [promptCost], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _promptCost(): JsonField<PromptCost> = body._promptCost() + + /** + * Returns the raw JSON value of [completionCostDetails]. + * + * Unlike [completionCostDetails], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _completionCostDetails(): JsonField<CompletionCostDetails> = body._completionCostDetails() + + /** + * Returns the raw JSON value of [matchPath]. + * + * Unlike [matchPath], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _matchPath(): JsonField<List<String>> = body._matchPath() + + /** + * Returns the raw JSON value of [promptCostDetails]. + * + * Unlike [promptCostDetails], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _promptCostDetails(): JsonField<PromptCostDetails> = body._promptCostDetails() + + /** + * Returns the raw JSON value of [provider]. + * + * Unlike [provider], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _provider(): JsonField<String> = body._provider() + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _startTime(): JsonField<OffsetDateTime> = body._startTime() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ModelPriceMapUpdateParams]. + * + * The following fields are required: + * ```java + * .completionCost() + * .matchPattern() + * .name() + * .promptCost() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ModelPriceMapUpdateParams]. */ + class Builder internal constructor() { + + private var id: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(modelPriceMapUpdateParams: ModelPriceMapUpdateParams) = apply { + id = modelPriceMapUpdateParams.id + body = modelPriceMapUpdateParams.body.toBuilder() + additionalHeaders = modelPriceMapUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = modelPriceMapUpdateParams.additionalQueryParams.toBuilder() + } + + fun id(id: String?) = apply { this.id = id } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<String>) = id(id.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [completionCost] + * - [matchPattern] + * - [name] + * - [promptCost] + * - [completionCostDetails] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun completionCost(completionCost: CompletionCost) = apply { + body.completionCost(completionCost) + } + + /** + * Sets [Builder.completionCost] to an arbitrary JSON value. + * + * You should usually call [Builder.completionCost] with a well-typed [CompletionCost] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun completionCost(completionCost: JsonField<CompletionCost>) = apply { + body.completionCost(completionCost) + } + + /** Alias for calling [completionCost] with `CompletionCost.ofNumber(number)`. */ + fun completionCost(number: Double) = apply { body.completionCost(number) } + + /** Alias for calling [completionCost] with `CompletionCost.ofString(string)`. */ + fun completionCost(string: String) = apply { body.completionCost(string) } + + fun matchPattern(matchPattern: String) = apply { body.matchPattern(matchPattern) } + + /** + * Sets [Builder.matchPattern] to an arbitrary JSON value. + * + * You should usually call [Builder.matchPattern] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun matchPattern(matchPattern: JsonField<String>) = apply { + body.matchPattern(matchPattern) + } + + fun name(name: String) = apply { body.name(name) } + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { body.name(name) } + + fun promptCost(promptCost: PromptCost) = apply { body.promptCost(promptCost) } + + /** + * Sets [Builder.promptCost] to an arbitrary JSON value. + * + * You should usually call [Builder.promptCost] with a well-typed [PromptCost] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun promptCost(promptCost: JsonField<PromptCost>) = apply { body.promptCost(promptCost) } + + /** Alias for calling [promptCost] with `PromptCost.ofNumber(number)`. */ + fun promptCost(number: Double) = apply { body.promptCost(number) } + + /** Alias for calling [promptCost] with `PromptCost.ofString(string)`. */ + fun promptCost(string: String) = apply { body.promptCost(string) } + + fun completionCostDetails(completionCostDetails: CompletionCostDetails?) = apply { + body.completionCostDetails(completionCostDetails) + } + + /** + * Alias for calling [Builder.completionCostDetails] with + * `completionCostDetails.orElse(null)`. + */ + fun completionCostDetails(completionCostDetails: Optional<CompletionCostDetails>) = + completionCostDetails(completionCostDetails.getOrNull()) + + /** + * Sets [Builder.completionCostDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.completionCostDetails] with a well-typed + * [CompletionCostDetails] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun completionCostDetails(completionCostDetails: JsonField<CompletionCostDetails>) = apply { + body.completionCostDetails(completionCostDetails) + } + + fun matchPath(matchPath: List<String>) = apply { body.matchPath(matchPath) } + + /** + * Sets [Builder.matchPath] to an arbitrary JSON value. + * + * You should usually call [Builder.matchPath] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun matchPath(matchPath: JsonField<List<String>>) = apply { body.matchPath(matchPath) } + + /** + * Adds a single [String] to [Builder.matchPath]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMatchPath(matchPath: String) = apply { body.addMatchPath(matchPath) } + + fun promptCostDetails(promptCostDetails: PromptCostDetails?) = apply { + body.promptCostDetails(promptCostDetails) + } + + /** Alias for calling [Builder.promptCostDetails] with `promptCostDetails.orElse(null)`. */ + fun promptCostDetails(promptCostDetails: Optional<PromptCostDetails>) = + promptCostDetails(promptCostDetails.getOrNull()) + + /** + * Sets [Builder.promptCostDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.promptCostDetails] with a well-typed [PromptCostDetails] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun promptCostDetails(promptCostDetails: JsonField<PromptCostDetails>) = apply { + body.promptCostDetails(promptCostDetails) + } + + fun provider(provider: String?) = apply { body.provider(provider) } + + /** Alias for calling [Builder.provider] with `provider.orElse(null)`. */ + fun provider(provider: Optional<String>) = provider(provider.getOrNull()) + + /** + * Sets [Builder.provider] to an arbitrary JSON value. + * + * You should usually call [Builder.provider] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun provider(provider: JsonField<String>) = apply { body.provider(provider) } + + fun startTime(startTime: OffsetDateTime?) = apply { body.startTime(startTime) } + + /** Alias for calling [Builder.startTime] with `startTime.orElse(null)`. */ + fun startTime(startTime: Optional<OffsetDateTime>) = startTime(startTime.getOrNull()) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField<OffsetDateTime>) = apply { body.startTime(startTime) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ModelPriceMapUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .completionCost() + * .matchPattern() + * .name() + * .promptCost() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ModelPriceMapUpdateParams = + ModelPriceMapUpdateParams( + id, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> id ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Model price map update schema. */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val completionCost: JsonField<CompletionCost>, + private val matchPattern: JsonField<String>, + private val name: JsonField<String>, + private val promptCost: JsonField<PromptCost>, + private val completionCostDetails: JsonField<CompletionCostDetails>, + private val matchPath: JsonField<List<String>>, + private val promptCostDetails: JsonField<PromptCostDetails>, + private val provider: JsonField<String>, + private val startTime: JsonField<OffsetDateTime>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("completion_cost") + @ExcludeMissing + completionCost: JsonField<CompletionCost> = JsonMissing.of(), + @JsonProperty("match_pattern") + @ExcludeMissing + matchPattern: JsonField<String> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("prompt_cost") + @ExcludeMissing + promptCost: JsonField<PromptCost> = JsonMissing.of(), + @JsonProperty("completion_cost_details") + @ExcludeMissing + completionCostDetails: JsonField<CompletionCostDetails> = JsonMissing.of(), + @JsonProperty("match_path") + @ExcludeMissing + matchPath: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("prompt_cost_details") + @ExcludeMissing + promptCostDetails: JsonField<PromptCostDetails> = JsonMissing.of(), + @JsonProperty("provider") + @ExcludeMissing + provider: JsonField<String> = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField<OffsetDateTime> = JsonMissing.of(), + ) : this( + completionCost, + matchPattern, + name, + promptCost, + completionCostDetails, + matchPath, + promptCostDetails, + provider, + startTime, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun completionCost(): CompletionCost = completionCost.getRequired("completion_cost") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun matchPattern(): String = matchPattern.getRequired("match_pattern") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun promptCost(): PromptCost = promptCost.getRequired("prompt_cost") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun completionCostDetails(): Optional<CompletionCostDetails> = + completionCostDetails.getOptional("completion_cost_details") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun matchPath(): Optional<List<String>> = matchPath.getOptional("match_path") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun promptCostDetails(): Optional<PromptCostDetails> = + promptCostDetails.getOptional("prompt_cost_details") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun provider(): Optional<String> = provider.getOptional("provider") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun startTime(): Optional<OffsetDateTime> = startTime.getOptional("start_time") + + /** + * Returns the raw JSON value of [completionCost]. + * + * Unlike [completionCost], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("completion_cost") + @ExcludeMissing + fun _completionCost(): JsonField<CompletionCost> = completionCost + + /** + * Returns the raw JSON value of [matchPattern]. + * + * Unlike [matchPattern], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("match_pattern") + @ExcludeMissing + fun _matchPattern(): JsonField<String> = matchPattern + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [promptCost]. + * + * Unlike [promptCost], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prompt_cost") + @ExcludeMissing + fun _promptCost(): JsonField<PromptCost> = promptCost + + /** + * Returns the raw JSON value of [completionCostDetails]. + * + * Unlike [completionCostDetails], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("completion_cost_details") + @ExcludeMissing + fun _completionCostDetails(): JsonField<CompletionCostDetails> = completionCostDetails + + /** + * Returns the raw JSON value of [matchPath]. + * + * Unlike [matchPath], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("match_path") + @ExcludeMissing + fun _matchPath(): JsonField<List<String>> = matchPath + + /** + * Returns the raw JSON value of [promptCostDetails]. + * + * Unlike [promptCostDetails], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("prompt_cost_details") + @ExcludeMissing + fun _promptCostDetails(): JsonField<PromptCostDetails> = promptCostDetails + + /** + * Returns the raw JSON value of [provider]. + * + * Unlike [provider], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("provider") @ExcludeMissing fun _provider(): JsonField<String> = provider + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_time") + @ExcludeMissing + fun _startTime(): JsonField<OffsetDateTime> = startTime + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .completionCost() + * .matchPattern() + * .name() + * .promptCost() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var completionCost: JsonField<CompletionCost>? = null + private var matchPattern: JsonField<String>? = null + private var name: JsonField<String>? = null + private var promptCost: JsonField<PromptCost>? = null + private var completionCostDetails: JsonField<CompletionCostDetails> = JsonMissing.of() + private var matchPath: JsonField<MutableList<String>>? = null + private var promptCostDetails: JsonField<PromptCostDetails> = JsonMissing.of() + private var provider: JsonField<String> = JsonMissing.of() + private var startTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + completionCost = body.completionCost + matchPattern = body.matchPattern + name = body.name + promptCost = body.promptCost + completionCostDetails = body.completionCostDetails + matchPath = body.matchPath.map { it.toMutableList() } + promptCostDetails = body.promptCostDetails + provider = body.provider + startTime = body.startTime + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun completionCost(completionCost: CompletionCost) = + completionCost(JsonField.of(completionCost)) + + /** + * Sets [Builder.completionCost] to an arbitrary JSON value. + * + * You should usually call [Builder.completionCost] with a well-typed [CompletionCost] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun completionCost(completionCost: JsonField<CompletionCost>) = apply { + this.completionCost = completionCost + } + + /** Alias for calling [completionCost] with `CompletionCost.ofNumber(number)`. */ + fun completionCost(number: Double) = completionCost(CompletionCost.ofNumber(number)) + + /** Alias for calling [completionCost] with `CompletionCost.ofString(string)`. */ + fun completionCost(string: String) = completionCost(CompletionCost.ofString(string)) + + fun matchPattern(matchPattern: String) = matchPattern(JsonField.of(matchPattern)) + + /** + * Sets [Builder.matchPattern] to an arbitrary JSON value. + * + * You should usually call [Builder.matchPattern] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun matchPattern(matchPattern: JsonField<String>) = apply { + this.matchPattern = matchPattern + } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun promptCost(promptCost: PromptCost) = promptCost(JsonField.of(promptCost)) + + /** + * Sets [Builder.promptCost] to an arbitrary JSON value. + * + * You should usually call [Builder.promptCost] with a well-typed [PromptCost] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun promptCost(promptCost: JsonField<PromptCost>) = apply { + this.promptCost = promptCost + } + + /** Alias for calling [promptCost] with `PromptCost.ofNumber(number)`. */ + fun promptCost(number: Double) = promptCost(PromptCost.ofNumber(number)) + + /** Alias for calling [promptCost] with `PromptCost.ofString(string)`. */ + fun promptCost(string: String) = promptCost(PromptCost.ofString(string)) + + fun completionCostDetails(completionCostDetails: CompletionCostDetails?) = + completionCostDetails(JsonField.ofNullable(completionCostDetails)) + + /** + * Alias for calling [Builder.completionCostDetails] with + * `completionCostDetails.orElse(null)`. + */ + fun completionCostDetails(completionCostDetails: Optional<CompletionCostDetails>) = + completionCostDetails(completionCostDetails.getOrNull()) + + /** + * Sets [Builder.completionCostDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.completionCostDetails] with a well-typed + * [CompletionCostDetails] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun completionCostDetails(completionCostDetails: JsonField<CompletionCostDetails>) = + apply { + this.completionCostDetails = completionCostDetails + } + + fun matchPath(matchPath: List<String>) = matchPath(JsonField.of(matchPath)) + + /** + * Sets [Builder.matchPath] to an arbitrary JSON value. + * + * You should usually call [Builder.matchPath] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun matchPath(matchPath: JsonField<List<String>>) = apply { + this.matchPath = matchPath.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.matchPath]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMatchPath(matchPath: String) = apply { + this.matchPath = + (this.matchPath ?: JsonField.of(mutableListOf())).also { + checkKnown("matchPath", it).add(matchPath) + } + } + + fun promptCostDetails(promptCostDetails: PromptCostDetails?) = + promptCostDetails(JsonField.ofNullable(promptCostDetails)) + + /** + * Alias for calling [Builder.promptCostDetails] with `promptCostDetails.orElse(null)`. + */ + fun promptCostDetails(promptCostDetails: Optional<PromptCostDetails>) = + promptCostDetails(promptCostDetails.getOrNull()) + + /** + * Sets [Builder.promptCostDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.promptCostDetails] with a well-typed + * [PromptCostDetails] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun promptCostDetails(promptCostDetails: JsonField<PromptCostDetails>) = apply { + this.promptCostDetails = promptCostDetails + } + + fun provider(provider: String?) = provider(JsonField.ofNullable(provider)) + + /** Alias for calling [Builder.provider] with `provider.orElse(null)`. */ + fun provider(provider: Optional<String>) = provider(provider.getOrNull()) + + /** + * Sets [Builder.provider] to an arbitrary JSON value. + * + * You should usually call [Builder.provider] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun provider(provider: JsonField<String>) = apply { this.provider = provider } + + fun startTime(startTime: OffsetDateTime?) = startTime(JsonField.ofNullable(startTime)) + + /** Alias for calling [Builder.startTime] with `startTime.orElse(null)`. */ + fun startTime(startTime: Optional<OffsetDateTime>) = startTime(startTime.getOrNull()) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField<OffsetDateTime>) = apply { + this.startTime = startTime + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .completionCost() + * .matchPattern() + * .name() + * .promptCost() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("completionCost", completionCost), + checkRequired("matchPattern", matchPattern), + checkRequired("name", name), + checkRequired("promptCost", promptCost), + completionCostDetails, + (matchPath ?: JsonMissing.of()).map { it.toImmutable() }, + promptCostDetails, + provider, + startTime, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + completionCost().validate() + matchPattern() + name() + promptCost().validate() + completionCostDetails().ifPresent { it.validate() } + matchPath() + promptCostDetails().ifPresent { it.validate() } + provider() + startTime() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (completionCost.asKnown().getOrNull()?.validity() ?: 0) + + (if (matchPattern.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (promptCost.asKnown().getOrNull()?.validity() ?: 0) + + (completionCostDetails.asKnown().getOrNull()?.validity() ?: 0) + + (matchPath.asKnown().getOrNull()?.size ?: 0) + + (promptCostDetails.asKnown().getOrNull()?.validity() ?: 0) + + (if (provider.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + completionCost == other.completionCost && + matchPattern == other.matchPattern && + name == other.name && + promptCost == other.promptCost && + completionCostDetails == other.completionCostDetails && + matchPath == other.matchPath && + promptCostDetails == other.promptCostDetails && + provider == other.provider && + startTime == other.startTime && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + completionCost, + matchPattern, + name, + promptCost, + completionCostDetails, + matchPath, + promptCostDetails, + provider, + startTime, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{completionCost=$completionCost, matchPattern=$matchPattern, name=$name, promptCost=$promptCost, completionCostDetails=$completionCostDetails, matchPath=$matchPath, promptCostDetails=$promptCostDetails, provider=$provider, startTime=$startTime, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = CompletionCost.Deserializer::class) + @JsonSerialize(using = CompletionCost.Serializer::class) + class CompletionCost + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional<Double> = Optional.ofNullable(number) + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): CompletionCost = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompletionCost && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "CompletionCost{number=$number}" + string != null -> "CompletionCost{string=$string}" + _json != null -> "CompletionCost{_unknown=$_json}" + else -> throw IllegalStateException("Invalid CompletionCost") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = CompletionCost(number = number) + + @JvmStatic fun ofString(string: String) = CompletionCost(string = string) + } + + /** + * An interface that defines how to map each variant of [CompletionCost] to a value of type + * [T]. + */ + interface Visitor<out T> { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [CompletionCost] to a value of type [T]. + * + * An instance of [CompletionCost] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown CompletionCost: $json") + } + } + + internal class Deserializer : BaseDeserializer<CompletionCost>(CompletionCost::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): CompletionCost { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<Double>())?.let { + CompletionCost(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<String>())?.let { + CompletionCost(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> CompletionCost(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<CompletionCost>(CompletionCost::class) { + + override fun serialize( + value: CompletionCost, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid CompletionCost") + } + } + } + } + + @JsonDeserialize(using = PromptCost.Deserializer::class) + @JsonSerialize(using = PromptCost.Serializer::class) + class PromptCost + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional<Double> = Optional.ofNullable(number) + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): PromptCost = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PromptCost && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "PromptCost{number=$number}" + string != null -> "PromptCost{string=$string}" + _json != null -> "PromptCost{_unknown=$_json}" + else -> throw IllegalStateException("Invalid PromptCost") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = PromptCost(number = number) + + @JvmStatic fun ofString(string: String) = PromptCost(string = string) + } + + /** + * An interface that defines how to map each variant of [PromptCost] to a value of type [T]. + */ + interface Visitor<out T> { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [PromptCost] to a value of type [T]. + * + * An instance of [PromptCost] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown PromptCost: $json") + } + } + + internal class Deserializer : BaseDeserializer<PromptCost>(PromptCost::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): PromptCost { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<Double>())?.let { + PromptCost(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<String>())?.let { + PromptCost(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> PromptCost(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<PromptCost>(PromptCost::class) { + + override fun serialize( + value: PromptCost, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid PromptCost") + } + } + } + } + + class CompletionCostDetails + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompletionCostDetails]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CompletionCostDetails]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(completionCostDetails: CompletionCostDetails) = apply { + additionalProperties = completionCostDetails.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompletionCostDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CompletionCostDetails = + CompletionCostDetails(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): CompletionCostDetails = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompletionCostDetails && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompletionCostDetails{additionalProperties=$additionalProperties}" + } + + class PromptCostDetails + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [PromptCostDetails]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PromptCostDetails]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(promptCostDetails: PromptCostDetails) = apply { + additionalProperties = promptCostDetails.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PromptCostDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PromptCostDetails = PromptCostDetails(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): PromptCostDetails = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PromptCostDetails && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "PromptCostDetails{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelPriceMapUpdateParams && + id == other.id && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(id, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ModelPriceMapUpdateParams{id=$id, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapUpdateResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapUpdateResponse.kt new file mode 100644 index 00000000..d2e96899 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapUpdateResponse.kt @@ -0,0 +1,118 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.modelpricemap + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class ModelPriceMapUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ModelPriceMapUpdateResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ModelPriceMapUpdateResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(modelPriceMapUpdateResponse: ModelPriceMapUpdateResponse) = apply { + additionalProperties = modelPriceMapUpdateResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ModelPriceMapUpdateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ModelPriceMapUpdateResponse = + ModelPriceMapUpdateResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): ModelPriceMapUpdateResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelPriceMapUpdateResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ModelPriceMapUpdateResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthProvider.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthProvider.kt new file mode 100644 index 00000000..4c6f4a35 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthProvider.kt @@ -0,0 +1,129 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.oauth + +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException + +class OAuthProvider @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't match + * any known member, and you want to know that value. For example, if the SDK is on an older + * version than the API, then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val CUSTOM_OIDC = of("custom-oidc") + + @JvmStatic fun of(value: String) = OAuthProvider(JsonField.of(value)) + } + + /** An enum containing [OAuthProvider]'s known values. */ + enum class Known { + CUSTOM_OIDC + } + + /** + * An enum containing [OAuthProvider]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [OAuthProvider] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the SDK + * is on an older version than the API, then the API may respond with new members that the SDK + * is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CUSTOM_OIDC, + /** + * An enum member indicating that [OAuthProvider] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if + * the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want to + * throw for the unknown case. + */ + fun value(): Value = + when (this) { + CUSTOM_OIDC -> Value.CUSTOM_OIDC + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't want + * to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CUSTOM_OIDC -> Known.CUSTOM_OIDC + else -> throw LangsmithApiInvalidDataException("Unknown OAuthProvider: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): OAuthProvider = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OAuthProvider && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveCallbackParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveCallbackParams.kt new file mode 100644 index 00000000..f3a86796 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveCallbackParams.kt @@ -0,0 +1,195 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.oauth + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Oauth Provider Callback */ +class OAuthRetrieveCallbackParams +private constructor( + private val provider: OAuthProvider?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun provider(): Optional<OAuthProvider> = Optional.ofNullable(provider) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): OAuthRetrieveCallbackParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [OAuthRetrieveCallbackParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OAuthRetrieveCallbackParams]. */ + class Builder internal constructor() { + + private var provider: OAuthProvider? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(oauthRetrieveCallbackParams: OAuthRetrieveCallbackParams) = apply { + provider = oauthRetrieveCallbackParams.provider + additionalHeaders = oauthRetrieveCallbackParams.additionalHeaders.toBuilder() + additionalQueryParams = oauthRetrieveCallbackParams.additionalQueryParams.toBuilder() + } + + fun provider(provider: OAuthProvider?) = apply { this.provider = provider } + + /** Alias for calling [Builder.provider] with `provider.orElse(null)`. */ + fun provider(provider: Optional<OAuthProvider>) = provider(provider.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [OAuthRetrieveCallbackParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OAuthRetrieveCallbackParams = + OAuthRetrieveCallbackParams( + provider, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> provider?.toString() ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OAuthRetrieveCallbackParams && + provider == other.provider && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(provider, additionalHeaders, additionalQueryParams) + + override fun toString() = + "OAuthRetrieveCallbackParams{provider=$provider, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveCallbackResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveCallbackResponse.kt new file mode 100644 index 00000000..624e1006 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveCallbackResponse.kt @@ -0,0 +1,119 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.oauth + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class OAuthRetrieveCallbackResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [OAuthRetrieveCallbackResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OAuthRetrieveCallbackResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(oauthRetrieveCallbackResponse: OAuthRetrieveCallbackResponse) = apply { + additionalProperties = oauthRetrieveCallbackResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OAuthRetrieveCallbackResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OAuthRetrieveCallbackResponse = + OAuthRetrieveCallbackResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): OAuthRetrieveCallbackResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OAuthRetrieveCallbackResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OAuthRetrieveCallbackResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveCurrentUserParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveCurrentUserParams.kt new file mode 100644 index 00000000..cb965567 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveCurrentUserParams.kt @@ -0,0 +1,196 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.oauth + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Oauth Provider Current User */ +class OAuthRetrieveCurrentUserParams +private constructor( + private val provider: OAuthProvider?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun provider(): Optional<OAuthProvider> = Optional.ofNullable(provider) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): OAuthRetrieveCurrentUserParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [OAuthRetrieveCurrentUserParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OAuthRetrieveCurrentUserParams]. */ + class Builder internal constructor() { + + private var provider: OAuthProvider? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(oauthRetrieveCurrentUserParams: OAuthRetrieveCurrentUserParams) = apply { + provider = oauthRetrieveCurrentUserParams.provider + additionalHeaders = oauthRetrieveCurrentUserParams.additionalHeaders.toBuilder() + additionalQueryParams = oauthRetrieveCurrentUserParams.additionalQueryParams.toBuilder() + } + + fun provider(provider: OAuthProvider?) = apply { this.provider = provider } + + /** Alias for calling [Builder.provider] with `provider.orElse(null)`. */ + fun provider(provider: Optional<OAuthProvider>) = provider(provider.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [OAuthRetrieveCurrentUserParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OAuthRetrieveCurrentUserParams = + OAuthRetrieveCurrentUserParams( + provider, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> provider?.toString() ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OAuthRetrieveCurrentUserParams && + provider == other.provider && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(provider, additionalHeaders, additionalQueryParams) + + override fun toString() = + "OAuthRetrieveCurrentUserParams{provider=$provider, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveCurrentUserResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveCurrentUserResponse.kt new file mode 100644 index 00000000..d321bd7e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveCurrentUserResponse.kt @@ -0,0 +1,121 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.oauth + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class OAuthRetrieveCurrentUserResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [OAuthRetrieveCurrentUserResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OAuthRetrieveCurrentUserResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(oauthRetrieveCurrentUserResponse: OAuthRetrieveCurrentUserResponse) = + apply { + additionalProperties = + oauthRetrieveCurrentUserResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OAuthRetrieveCurrentUserResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OAuthRetrieveCurrentUserResponse = + OAuthRetrieveCurrentUserResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): OAuthRetrieveCurrentUserResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OAuthRetrieveCurrentUserResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OAuthRetrieveCurrentUserResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveLogoutParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveLogoutParams.kt new file mode 100644 index 00000000..9808ccb3 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveLogoutParams.kt @@ -0,0 +1,195 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.oauth + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Oauth Provider Logout */ +class OAuthRetrieveLogoutParams +private constructor( + private val provider: OAuthProvider?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun provider(): Optional<OAuthProvider> = Optional.ofNullable(provider) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): OAuthRetrieveLogoutParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [OAuthRetrieveLogoutParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OAuthRetrieveLogoutParams]. */ + class Builder internal constructor() { + + private var provider: OAuthProvider? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(oauthRetrieveLogoutParams: OAuthRetrieveLogoutParams) = apply { + provider = oauthRetrieveLogoutParams.provider + additionalHeaders = oauthRetrieveLogoutParams.additionalHeaders.toBuilder() + additionalQueryParams = oauthRetrieveLogoutParams.additionalQueryParams.toBuilder() + } + + fun provider(provider: OAuthProvider?) = apply { this.provider = provider } + + /** Alias for calling [Builder.provider] with `provider.orElse(null)`. */ + fun provider(provider: Optional<OAuthProvider>) = provider(provider.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [OAuthRetrieveLogoutParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OAuthRetrieveLogoutParams = + OAuthRetrieveLogoutParams( + provider, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> provider?.toString() ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OAuthRetrieveLogoutParams && + provider == other.provider && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(provider, additionalHeaders, additionalQueryParams) + + override fun toString() = + "OAuthRetrieveLogoutParams{provider=$provider, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveLogoutResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveLogoutResponse.kt new file mode 100644 index 00000000..30964a68 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveLogoutResponse.kt @@ -0,0 +1,118 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.oauth + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class OAuthRetrieveLogoutResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [OAuthRetrieveLogoutResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OAuthRetrieveLogoutResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(oauthRetrieveLogoutResponse: OAuthRetrieveLogoutResponse) = apply { + additionalProperties = oauthRetrieveLogoutResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OAuthRetrieveLogoutResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OAuthRetrieveLogoutResponse = + OAuthRetrieveLogoutResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): OAuthRetrieveLogoutResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OAuthRetrieveLogoutResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OAuthRetrieveLogoutResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveParams.kt new file mode 100644 index 00000000..0cc3f9eb --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveParams.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.oauth + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Oauth Provider Auth */ +class OAuthRetrieveParams +private constructor( + private val provider: OAuthProvider?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun provider(): Optional<OAuthProvider> = Optional.ofNullable(provider) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): OAuthRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [OAuthRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OAuthRetrieveParams]. */ + class Builder internal constructor() { + + private var provider: OAuthProvider? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(oauthRetrieveParams: OAuthRetrieveParams) = apply { + provider = oauthRetrieveParams.provider + additionalHeaders = oauthRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = oauthRetrieveParams.additionalQueryParams.toBuilder() + } + + fun provider(provider: OAuthProvider?) = apply { this.provider = provider } + + /** Alias for calling [Builder.provider] with `provider.orElse(null)`. */ + fun provider(provider: Optional<OAuthProvider>) = provider(provider.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [OAuthRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OAuthRetrieveParams = + OAuthRetrieveParams(provider, additionalHeaders.build(), additionalQueryParams.build()) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> provider?.toString() ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OAuthRetrieveParams && + provider == other.provider && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(provider, additionalHeaders, additionalQueryParams) + + override fun toString() = + "OAuthRetrieveParams{provider=$provider, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveResponse.kt new file mode 100644 index 00000000..13a4ab90 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveResponse.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.oauth + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class OAuthRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [OAuthRetrieveResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OAuthRetrieveResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(oauthRetrieveResponse: OAuthRetrieveResponse) = apply { + additionalProperties = oauthRetrieveResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OAuthRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OAuthRetrieveResponse = + OAuthRetrieveResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): OAuthRetrieveResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OAuthRetrieveResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "OAuthRetrieveResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartCreateParams.kt new file mode 100644 index 00000000..a137ba4d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartCreateParams.kt @@ -0,0 +1,205 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgcharts + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.models.api.v1.charts.CustomChartCreate +import java.util.Objects + +/** Create a new chart. */ +class OrgChartCreateParams +private constructor( + private val customChartCreate: CustomChartCreate, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun customChartCreate(): CustomChartCreate = customChartCreate + + fun _additionalBodyProperties(): Map<String, JsonValue> = + customChartCreate._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [OrgChartCreateParams]. + * + * The following fields are required: + * ```java + * .customChartCreate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OrgChartCreateParams]. */ + class Builder internal constructor() { + + private var customChartCreate: CustomChartCreate? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(orgChartCreateParams: OrgChartCreateParams) = apply { + customChartCreate = orgChartCreateParams.customChartCreate + additionalHeaders = orgChartCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = orgChartCreateParams.additionalQueryParams.toBuilder() + } + + fun customChartCreate(customChartCreate: CustomChartCreate) = apply { + this.customChartCreate = customChartCreate + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [OrgChartCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .customChartCreate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): OrgChartCreateParams = + OrgChartCreateParams( + checkRequired("customChartCreate", customChartCreate), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): CustomChartCreate = customChartCreate + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OrgChartCreateParams && + customChartCreate == other.customChartCreate && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(customChartCreate, additionalHeaders, additionalQueryParams) + + override fun toString() = + "OrgChartCreateParams{customChartCreate=$customChartCreate, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartDeleteParams.kt new file mode 100644 index 00000000..7d1e5d5d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartDeleteParams.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgcharts + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete a chart. */ +class OrgChartDeleteParams +private constructor( + private val chartId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun chartId(): Optional<String> = Optional.ofNullable(chartId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): OrgChartDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [OrgChartDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OrgChartDeleteParams]. */ + class Builder internal constructor() { + + private var chartId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(orgChartDeleteParams: OrgChartDeleteParams) = apply { + chartId = orgChartDeleteParams.chartId + additionalHeaders = orgChartDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = orgChartDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = orgChartDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun chartId(chartId: String?) = apply { this.chartId = chartId } + + /** Alias for calling [Builder.chartId] with `chartId.orElse(null)`. */ + fun chartId(chartId: Optional<String>) = chartId(chartId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [OrgChartDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OrgChartDeleteParams = + OrgChartDeleteParams( + chartId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> chartId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OrgChartDeleteParams && + chartId == other.chartId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(chartId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "OrgChartDeleteParams{chartId=$chartId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartDeleteResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartDeleteResponse.kt new file mode 100644 index 00000000..0ff33ecc --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartDeleteResponse.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgcharts + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class OrgChartDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [OrgChartDeleteResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OrgChartDeleteResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(orgChartDeleteResponse: OrgChartDeleteResponse) = apply { + additionalProperties = orgChartDeleteResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OrgChartDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OrgChartDeleteResponse = + OrgChartDeleteResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): OrgChartDeleteResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OrgChartDeleteResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "OrgChartDeleteResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartOrgChartsParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartOrgChartsParams.kt new file mode 100644 index 00000000..1725f67e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartOrgChartsParams.kt @@ -0,0 +1,205 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgcharts + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.models.api.v1.charts.CustomChartsRequest +import java.util.Objects + +/** Get all charts for the tenant. */ +class OrgChartOrgChartsParams +private constructor( + private val customChartsRequest: CustomChartsRequest, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun customChartsRequest(): CustomChartsRequest = customChartsRequest + + fun _additionalBodyProperties(): Map<String, JsonValue> = + customChartsRequest._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [OrgChartOrgChartsParams]. + * + * The following fields are required: + * ```java + * .customChartsRequest() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OrgChartOrgChartsParams]. */ + class Builder internal constructor() { + + private var customChartsRequest: CustomChartsRequest? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(orgChartOrgChartsParams: OrgChartOrgChartsParams) = apply { + customChartsRequest = orgChartOrgChartsParams.customChartsRequest + additionalHeaders = orgChartOrgChartsParams.additionalHeaders.toBuilder() + additionalQueryParams = orgChartOrgChartsParams.additionalQueryParams.toBuilder() + } + + fun customChartsRequest(customChartsRequest: CustomChartsRequest) = apply { + this.customChartsRequest = customChartsRequest + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [OrgChartOrgChartsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .customChartsRequest() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): OrgChartOrgChartsParams = + OrgChartOrgChartsParams( + checkRequired("customChartsRequest", customChartsRequest), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): CustomChartsRequest = customChartsRequest + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OrgChartOrgChartsParams && + customChartsRequest == other.customChartsRequest && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(customChartsRequest, additionalHeaders, additionalQueryParams) + + override fun toString() = + "OrgChartOrgChartsParams{customChartsRequest=$customChartsRequest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartPreviewParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartPreviewParams.kt new file mode 100644 index 00000000..c20605b1 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartPreviewParams.kt @@ -0,0 +1,206 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgcharts + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.models.api.v1.charts.CustomChartPreviewRequest +import java.util.Objects + +/** Get a preview for a chart without actually creating it. */ +class OrgChartPreviewParams +private constructor( + private val customChartPreviewRequest: CustomChartPreviewRequest, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun customChartPreviewRequest(): CustomChartPreviewRequest = customChartPreviewRequest + + fun _additionalBodyProperties(): Map<String, JsonValue> = + customChartPreviewRequest._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [OrgChartPreviewParams]. + * + * The following fields are required: + * ```java + * .customChartPreviewRequest() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OrgChartPreviewParams]. */ + class Builder internal constructor() { + + private var customChartPreviewRequest: CustomChartPreviewRequest? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(orgChartPreviewParams: OrgChartPreviewParams) = apply { + customChartPreviewRequest = orgChartPreviewParams.customChartPreviewRequest + additionalHeaders = orgChartPreviewParams.additionalHeaders.toBuilder() + additionalQueryParams = orgChartPreviewParams.additionalQueryParams.toBuilder() + } + + fun customChartPreviewRequest(customChartPreviewRequest: CustomChartPreviewRequest) = + apply { + this.customChartPreviewRequest = customChartPreviewRequest + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [OrgChartPreviewParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .customChartPreviewRequest() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): OrgChartPreviewParams = + OrgChartPreviewParams( + checkRequired("customChartPreviewRequest", customChartPreviewRequest), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): CustomChartPreviewRequest = customChartPreviewRequest + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OrgChartPreviewParams && + customChartPreviewRequest == other.customChartPreviewRequest && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(customChartPreviewRequest, additionalHeaders, additionalQueryParams) + + override fun toString() = + "OrgChartPreviewParams{customChartPreviewRequest=$customChartPreviewRequest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartUpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartUpdateParams.kt new file mode 100644 index 00000000..44b843c9 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartUpdateParams.kt @@ -0,0 +1,225 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgcharts + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.models.api.v1.charts.CustomChartUpdate +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Update a chart. */ +class OrgChartUpdateParams +private constructor( + private val chartId: String?, + private val customChartUpdate: CustomChartUpdate, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun chartId(): Optional<String> = Optional.ofNullable(chartId) + + fun customChartUpdate(): CustomChartUpdate = customChartUpdate + + fun _additionalBodyProperties(): Map<String, JsonValue> = + customChartUpdate._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [OrgChartUpdateParams]. + * + * The following fields are required: + * ```java + * .customChartUpdate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OrgChartUpdateParams]. */ + class Builder internal constructor() { + + private var chartId: String? = null + private var customChartUpdate: CustomChartUpdate? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(orgChartUpdateParams: OrgChartUpdateParams) = apply { + chartId = orgChartUpdateParams.chartId + customChartUpdate = orgChartUpdateParams.customChartUpdate + additionalHeaders = orgChartUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = orgChartUpdateParams.additionalQueryParams.toBuilder() + } + + fun chartId(chartId: String?) = apply { this.chartId = chartId } + + /** Alias for calling [Builder.chartId] with `chartId.orElse(null)`. */ + fun chartId(chartId: Optional<String>) = chartId(chartId.getOrNull()) + + fun customChartUpdate(customChartUpdate: CustomChartUpdate) = apply { + this.customChartUpdate = customChartUpdate + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [OrgChartUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .customChartUpdate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): OrgChartUpdateParams = + OrgChartUpdateParams( + chartId, + checkRequired("customChartUpdate", customChartUpdate), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): CustomChartUpdate = customChartUpdate + + fun _pathParam(index: Int): String = + when (index) { + 0 -> chartId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OrgChartUpdateParams && + chartId == other.chartId && + customChartUpdate == other.customChartUpdate && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(chartId, customChartUpdate, additionalHeaders, additionalQueryParams) + + override fun toString() = + "OrgChartUpdateParams{chartId=$chartId, customChartUpdate=$customChartUpdate, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/CustomChartsRequestBase.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/CustomChartsRequestBase.kt new file mode 100644 index 00000000..72f2f0bd --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/CustomChartsRequestBase.kt @@ -0,0 +1,308 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgcharts.section + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.sessions.TimedeltaInput +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class CustomChartsRequestBase +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val endTime: JsonField<OffsetDateTime>, + private val omitData: JsonField<Boolean>, + private val startTime: JsonField<OffsetDateTime>, + private val stride: JsonField<TimedeltaInput>, + private val timezone: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("end_time") + @ExcludeMissing + endTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("omit_data") @ExcludeMissing omitData: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("stride") + @ExcludeMissing + stride: JsonField<TimedeltaInput> = JsonMissing.of(), + @JsonProperty("timezone") @ExcludeMissing timezone: JsonField<String> = JsonMissing.of(), + ) : this(endTime, omitData, startTime, stride, timezone, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endTime(): Optional<OffsetDateTime> = endTime.getOptional("end_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun omitData(): Optional<Boolean> = omitData.getOptional("omit_data") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun startTime(): Optional<OffsetDateTime> = startTime.getOptional("start_time") + + /** + * Timedelta input. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun stride(): Optional<TimedeltaInput> = stride.getOptional("stride") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun timezone(): Optional<String> = timezone.getOptional("timezone") + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_time") @ExcludeMissing fun _endTime(): JsonField<OffsetDateTime> = endTime + + /** + * Returns the raw JSON value of [omitData]. + * + * Unlike [omitData], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("omit_data") @ExcludeMissing fun _omitData(): JsonField<Boolean> = omitData + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_time") + @ExcludeMissing + fun _startTime(): JsonField<OffsetDateTime> = startTime + + /** + * Returns the raw JSON value of [stride]. + * + * Unlike [stride], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("stride") @ExcludeMissing fun _stride(): JsonField<TimedeltaInput> = stride + + /** + * Returns the raw JSON value of [timezone]. + * + * Unlike [timezone], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("timezone") @ExcludeMissing fun _timezone(): JsonField<String> = timezone + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [CustomChartsRequestBase]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomChartsRequestBase]. */ + class Builder internal constructor() { + + private var endTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var omitData: JsonField<Boolean> = JsonMissing.of() + private var startTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var stride: JsonField<TimedeltaInput> = JsonMissing.of() + private var timezone: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(customChartsRequestBase: CustomChartsRequestBase) = apply { + endTime = customChartsRequestBase.endTime + omitData = customChartsRequestBase.omitData + startTime = customChartsRequestBase.startTime + stride = customChartsRequestBase.stride + timezone = customChartsRequestBase.timezone + additionalProperties = customChartsRequestBase.additionalProperties.toMutableMap() + } + + fun endTime(endTime: OffsetDateTime?) = endTime(JsonField.ofNullable(endTime)) + + /** Alias for calling [Builder.endTime] with `endTime.orElse(null)`. */ + fun endTime(endTime: Optional<OffsetDateTime>) = endTime(endTime.getOrNull()) + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endTime(endTime: JsonField<OffsetDateTime>) = apply { this.endTime = endTime } + + fun omitData(omitData: Boolean) = omitData(JsonField.of(omitData)) + + /** + * Sets [Builder.omitData] to an arbitrary JSON value. + * + * You should usually call [Builder.omitData] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun omitData(omitData: JsonField<Boolean>) = apply { this.omitData = omitData } + + fun startTime(startTime: OffsetDateTime?) = startTime(JsonField.ofNullable(startTime)) + + /** Alias for calling [Builder.startTime] with `startTime.orElse(null)`. */ + fun startTime(startTime: Optional<OffsetDateTime>) = startTime(startTime.getOrNull()) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField<OffsetDateTime>) = apply { this.startTime = startTime } + + /** Timedelta input. */ + fun stride(stride: TimedeltaInput) = stride(JsonField.of(stride)) + + /** + * Sets [Builder.stride] to an arbitrary JSON value. + * + * You should usually call [Builder.stride] with a well-typed [TimedeltaInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun stride(stride: JsonField<TimedeltaInput>) = apply { this.stride = stride } + + fun timezone(timezone: String) = timezone(JsonField.of(timezone)) + + /** + * Sets [Builder.timezone] to an arbitrary JSON value. + * + * You should usually call [Builder.timezone] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun timezone(timezone: JsonField<String>) = apply { this.timezone = timezone } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomChartsRequestBase]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CustomChartsRequestBase = + CustomChartsRequestBase( + endTime, + omitData, + startTime, + stride, + timezone, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CustomChartsRequestBase = apply { + if (validated) { + return@apply + } + + endTime() + omitData() + startTime() + stride().ifPresent { it.validate() } + timezone() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (endTime.asKnown().isPresent) 1 else 0) + + (if (omitData.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + (stride.asKnown().getOrNull()?.validity() ?: 0) + + (if (timezone.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomChartsRequestBase && + endTime == other.endTime && + omitData == other.omitData && + startTime == other.startTime && + stride == other.stride && + timezone == other.timezone && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(endTime, omitData, startTime, stride, timezone, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomChartsRequestBase{endTime=$endTime, omitData=$omitData, startTime=$startTime, stride=$stride, timezone=$timezone, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionCreateParams.kt new file mode 100644 index 00000000..a43ef8d5 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionCreateParams.kt @@ -0,0 +1,206 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgcharts.section + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.models.api.v1.charts.section.CustomChartsSectionCreate +import java.util.Objects + +/** Create a new section. */ +class SectionCreateParams +private constructor( + private val customChartsSectionCreate: CustomChartsSectionCreate, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun customChartsSectionCreate(): CustomChartsSectionCreate = customChartsSectionCreate + + fun _additionalBodyProperties(): Map<String, JsonValue> = + customChartsSectionCreate._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SectionCreateParams]. + * + * The following fields are required: + * ```java + * .customChartsSectionCreate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SectionCreateParams]. */ + class Builder internal constructor() { + + private var customChartsSectionCreate: CustomChartsSectionCreate? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(sectionCreateParams: SectionCreateParams) = apply { + customChartsSectionCreate = sectionCreateParams.customChartsSectionCreate + additionalHeaders = sectionCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = sectionCreateParams.additionalQueryParams.toBuilder() + } + + fun customChartsSectionCreate(customChartsSectionCreate: CustomChartsSectionCreate) = + apply { + this.customChartsSectionCreate = customChartsSectionCreate + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SectionCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .customChartsSectionCreate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SectionCreateParams = + SectionCreateParams( + checkRequired("customChartsSectionCreate", customChartsSectionCreate), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): CustomChartsSectionCreate = customChartsSectionCreate + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SectionCreateParams && + customChartsSectionCreate == other.customChartsSectionCreate && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(customChartsSectionCreate, additionalHeaders, additionalQueryParams) + + override fun toString() = + "SectionCreateParams{customChartsSectionCreate=$customChartsSectionCreate, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionDeleteParams.kt new file mode 100644 index 00000000..6dbb5d50 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionDeleteParams.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgcharts.section + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete a section. */ +class SectionDeleteParams +private constructor( + private val sectionId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun sectionId(): Optional<String> = Optional.ofNullable(sectionId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): SectionDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [SectionDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SectionDeleteParams]. */ + class Builder internal constructor() { + + private var sectionId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(sectionDeleteParams: SectionDeleteParams) = apply { + sectionId = sectionDeleteParams.sectionId + additionalHeaders = sectionDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = sectionDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = sectionDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun sectionId(sectionId: String?) = apply { this.sectionId = sectionId } + + /** Alias for calling [Builder.sectionId] with `sectionId.orElse(null)`. */ + fun sectionId(sectionId: Optional<String>) = sectionId(sectionId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [SectionDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SectionDeleteParams = + SectionDeleteParams( + sectionId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> sectionId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SectionDeleteParams && + sectionId == other.sectionId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(sectionId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "SectionDeleteParams{sectionId=$sectionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionDeleteResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionDeleteResponse.kt new file mode 100644 index 00000000..24326357 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionDeleteResponse.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgcharts.section + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class SectionDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [SectionDeleteResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SectionDeleteResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(sectionDeleteResponse: SectionDeleteResponse) = apply { + additionalProperties = sectionDeleteResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SectionDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SectionDeleteResponse = + SectionDeleteResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): SectionDeleteResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SectionDeleteResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "SectionDeleteResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionListParams.kt new file mode 100644 index 00000000..c493f2f9 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionListParams.kt @@ -0,0 +1,323 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgcharts.section + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get all sections for the tenant. */ +class SectionListParams +private constructor( + private val ids: List<String>?, + private val limit: Long?, + private val offset: Long?, + private val sortBy: String?, + private val sortByDesc: Boolean?, + private val tagValueId: List<String>?, + private val titleContains: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun ids(): Optional<List<String>> = Optional.ofNullable(ids) + + fun limit(): Optional<Long> = Optional.ofNullable(limit) + + fun offset(): Optional<Long> = Optional.ofNullable(offset) + + fun sortBy(): Optional<String> = Optional.ofNullable(sortBy) + + fun sortByDesc(): Optional<Boolean> = Optional.ofNullable(sortByDesc) + + fun tagValueId(): Optional<List<String>> = Optional.ofNullable(tagValueId) + + fun titleContains(): Optional<String> = Optional.ofNullable(titleContains) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): SectionListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [SectionListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SectionListParams]. */ + class Builder internal constructor() { + + private var ids: MutableList<String>? = null + private var limit: Long? = null + private var offset: Long? = null + private var sortBy: String? = null + private var sortByDesc: Boolean? = null + private var tagValueId: MutableList<String>? = null + private var titleContains: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(sectionListParams: SectionListParams) = apply { + ids = sectionListParams.ids?.toMutableList() + limit = sectionListParams.limit + offset = sectionListParams.offset + sortBy = sectionListParams.sortBy + sortByDesc = sectionListParams.sortByDesc + tagValueId = sectionListParams.tagValueId?.toMutableList() + titleContains = sectionListParams.titleContains + additionalHeaders = sectionListParams.additionalHeaders.toBuilder() + additionalQueryParams = sectionListParams.additionalQueryParams.toBuilder() + } + + fun ids(ids: List<String>?) = apply { this.ids = ids?.toMutableList() } + + /** Alias for calling [Builder.ids] with `ids.orElse(null)`. */ + fun ids(ids: Optional<List<String>>) = ids(ids.getOrNull()) + + /** + * Adds a single [String] to [ids]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addId(id: String) = apply { ids = (ids ?: mutableListOf()).apply { add(id) } } + + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional<Long>) = limit(limit.getOrNull()) + + fun offset(offset: Long?) = apply { this.offset = offset } + + /** + * Alias for [Builder.offset]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun offset(offset: Long) = offset(offset as Long?) + + /** Alias for calling [Builder.offset] with `offset.orElse(null)`. */ + fun offset(offset: Optional<Long>) = offset(offset.getOrNull()) + + fun sortBy(sortBy: String?) = apply { this.sortBy = sortBy } + + /** Alias for calling [Builder.sortBy] with `sortBy.orElse(null)`. */ + fun sortBy(sortBy: Optional<String>) = sortBy(sortBy.getOrNull()) + + fun sortByDesc(sortByDesc: Boolean?) = apply { this.sortByDesc = sortByDesc } + + /** + * Alias for [Builder.sortByDesc]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun sortByDesc(sortByDesc: Boolean) = sortByDesc(sortByDesc as Boolean?) + + /** Alias for calling [Builder.sortByDesc] with `sortByDesc.orElse(null)`. */ + fun sortByDesc(sortByDesc: Optional<Boolean>) = sortByDesc(sortByDesc.getOrNull()) + + fun tagValueId(tagValueId: List<String>?) = apply { + this.tagValueId = tagValueId?.toMutableList() + } + + /** Alias for calling [Builder.tagValueId] with `tagValueId.orElse(null)`. */ + fun tagValueId(tagValueId: Optional<List<String>>) = tagValueId(tagValueId.getOrNull()) + + /** + * Adds a single [String] to [Builder.tagValueId]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTagValueId(tagValueId: String) = apply { + this.tagValueId = (this.tagValueId ?: mutableListOf()).apply { add(tagValueId) } + } + + fun titleContains(titleContains: String?) = apply { this.titleContains = titleContains } + + /** Alias for calling [Builder.titleContains] with `titleContains.orElse(null)`. */ + fun titleContains(titleContains: Optional<String>) = + titleContains(titleContains.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SectionListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SectionListParams = + SectionListParams( + ids?.toImmutable(), + limit, + offset, + sortBy, + sortByDesc, + tagValueId?.toImmutable(), + titleContains, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + ids?.let { put("ids", it.joinToString(",")) } + limit?.let { put("limit", it.toString()) } + offset?.let { put("offset", it.toString()) } + sortBy?.let { put("sort_by", it) } + sortByDesc?.let { put("sort_by_desc", it.toString()) } + tagValueId?.let { put("tag_value_id", it.joinToString(",")) } + titleContains?.let { put("title_contains", it) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SectionListParams && + ids == other.ids && + limit == other.limit && + offset == other.offset && + sortBy == other.sortBy && + sortByDesc == other.sortByDesc && + tagValueId == other.tagValueId && + titleContains == other.titleContains && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + ids, + limit, + offset, + sortBy, + sortByDesc, + tagValueId, + titleContains, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "SectionListParams{ids=$ids, limit=$limit, offset=$offset, sortBy=$sortBy, sortByDesc=$sortByDesc, tagValueId=$tagValueId, titleContains=$titleContains, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionUpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionUpdateParams.kt new file mode 100644 index 00000000..220def06 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionUpdateParams.kt @@ -0,0 +1,226 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgcharts.section + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.models.api.v1.charts.section.CustomChartsSectionUpdate +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Update a section. */ +class SectionUpdateParams +private constructor( + private val sectionId: String?, + private val customChartsSectionUpdate: CustomChartsSectionUpdate, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun sectionId(): Optional<String> = Optional.ofNullable(sectionId) + + fun customChartsSectionUpdate(): CustomChartsSectionUpdate = customChartsSectionUpdate + + fun _additionalBodyProperties(): Map<String, JsonValue> = + customChartsSectionUpdate._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SectionUpdateParams]. + * + * The following fields are required: + * ```java + * .customChartsSectionUpdate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SectionUpdateParams]. */ + class Builder internal constructor() { + + private var sectionId: String? = null + private var customChartsSectionUpdate: CustomChartsSectionUpdate? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(sectionUpdateParams: SectionUpdateParams) = apply { + sectionId = sectionUpdateParams.sectionId + customChartsSectionUpdate = sectionUpdateParams.customChartsSectionUpdate + additionalHeaders = sectionUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = sectionUpdateParams.additionalQueryParams.toBuilder() + } + + fun sectionId(sectionId: String?) = apply { this.sectionId = sectionId } + + /** Alias for calling [Builder.sectionId] with `sectionId.orElse(null)`. */ + fun sectionId(sectionId: Optional<String>) = sectionId(sectionId.getOrNull()) + + fun customChartsSectionUpdate(customChartsSectionUpdate: CustomChartsSectionUpdate) = + apply { + this.customChartsSectionUpdate = customChartsSectionUpdate + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SectionUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .customChartsSectionUpdate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SectionUpdateParams = + SectionUpdateParams( + sectionId, + checkRequired("customChartsSectionUpdate", customChartsSectionUpdate), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): CustomChartsSectionUpdate = customChartsSectionUpdate + + fun _pathParam(index: Int): String = + when (index) { + 0 -> sectionId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SectionUpdateParams && + sectionId == other.sectionId && + customChartsSectionUpdate == other.customChartsSectionUpdate && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(sectionId, customChartsSectionUpdate, additionalHeaders, additionalQueryParams) + + override fun toString() = + "SectionUpdateParams{sectionId=$sectionId, customChartsSectionUpdate=$customChartsSectionUpdate, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrgCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrgCreateParams.kt new file mode 100644 index 00000000..1694ba4c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrgCreateParams.kt @@ -0,0 +1,485 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +/** Create Organization */ +class OrgCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun displayName(): String = body.displayName() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun isPersonal(): Boolean = body.isPersonal() + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _displayName(): JsonField<String> = body._displayName() + + /** + * Returns the raw JSON value of [isPersonal]. + * + * Unlike [isPersonal], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _isPersonal(): JsonField<Boolean> = body._isPersonal() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [OrgCreateParams]. + * + * The following fields are required: + * ```java + * .displayName() + * .isPersonal() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OrgCreateParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(orgCreateParams: OrgCreateParams) = apply { + body = orgCreateParams.body.toBuilder() + additionalHeaders = orgCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = orgCreateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [displayName] + * - [isPersonal] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun displayName(displayName: String) = apply { body.displayName(displayName) } + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun displayName(displayName: JsonField<String>) = apply { body.displayName(displayName) } + + fun isPersonal(isPersonal: Boolean) = apply { body.isPersonal(isPersonal) } + + /** + * Sets [Builder.isPersonal] to an arbitrary JSON value. + * + * You should usually call [Builder.isPersonal] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isPersonal(isPersonal: JsonField<Boolean>) = apply { body.isPersonal(isPersonal) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [OrgCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .displayName() + * .isPersonal() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): OrgCreateParams = + OrgCreateParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Create organization schema. */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val displayName: JsonField<String>, + private val isPersonal: JsonField<Boolean>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField<String> = JsonMissing.of(), + @JsonProperty("is_personal") + @ExcludeMissing + isPersonal: JsonField<Boolean> = JsonMissing.of(), + ) : this(displayName, isPersonal, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun displayName(): String = displayName.getRequired("display_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun isPersonal(): Boolean = isPersonal.getRequired("is_personal") + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField<String> = displayName + + /** + * Returns the raw JSON value of [isPersonal]. + * + * Unlike [isPersonal], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_personal") + @ExcludeMissing + fun _isPersonal(): JsonField<Boolean> = isPersonal + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .displayName() + * .isPersonal() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var displayName: JsonField<String>? = null + private var isPersonal: JsonField<Boolean>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + displayName = body.displayName + isPersonal = body.isPersonal + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun displayName(displayName: String) = displayName(JsonField.of(displayName)) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun displayName(displayName: JsonField<String>) = apply { + this.displayName = displayName + } + + fun isPersonal(isPersonal: Boolean) = isPersonal(JsonField.of(isPersonal)) + + /** + * Sets [Builder.isPersonal] to an arbitrary JSON value. + * + * You should usually call [Builder.isPersonal] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isPersonal(isPersonal: JsonField<Boolean>) = apply { this.isPersonal = isPersonal } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .displayName() + * .isPersonal() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("displayName", displayName), + checkRequired("isPersonal", isPersonal), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + displayName() + isPersonal() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (displayName.asKnown().isPresent) 1 else 0) + + (if (isPersonal.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + displayName == other.displayName && + isPersonal == other.isPersonal && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(displayName, isPersonal, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{displayName=$displayName, isPersonal=$isPersonal, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OrgCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "OrgCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrgListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrgListParams.kt new file mode 100644 index 00000000..64e32427 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrgListParams.kt @@ -0,0 +1,221 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get all orgs visible to this auth */ +class OrgListParams +private constructor( + private val includeTier: Boolean?, + private val skipCreate: Boolean?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun includeTier(): Optional<Boolean> = Optional.ofNullable(includeTier) + + fun skipCreate(): Optional<Boolean> = Optional.ofNullable(skipCreate) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): OrgListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [OrgListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OrgListParams]. */ + class Builder internal constructor() { + + private var includeTier: Boolean? = null + private var skipCreate: Boolean? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(orgListParams: OrgListParams) = apply { + includeTier = orgListParams.includeTier + skipCreate = orgListParams.skipCreate + additionalHeaders = orgListParams.additionalHeaders.toBuilder() + additionalQueryParams = orgListParams.additionalQueryParams.toBuilder() + } + + fun includeTier(includeTier: Boolean?) = apply { this.includeTier = includeTier } + + /** + * Alias for [Builder.includeTier]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun includeTier(includeTier: Boolean) = includeTier(includeTier as Boolean?) + + /** Alias for calling [Builder.includeTier] with `includeTier.orElse(null)`. */ + fun includeTier(includeTier: Optional<Boolean>) = includeTier(includeTier.getOrNull()) + + fun skipCreate(skipCreate: Boolean?) = apply { this.skipCreate = skipCreate } + + /** + * Alias for [Builder.skipCreate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun skipCreate(skipCreate: Boolean) = skipCreate(skipCreate as Boolean?) + + /** Alias for calling [Builder.skipCreate] with `skipCreate.orElse(null)`. */ + fun skipCreate(skipCreate: Optional<Boolean>) = skipCreate(skipCreate.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [OrgListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OrgListParams = + OrgListParams( + includeTier, + skipCreate, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + includeTier?.let { put("include_tier", it.toString()) } + skipCreate?.let { put("skip_create", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OrgListParams && + includeTier == other.includeTier && + skipCreate == other.skipCreate && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(includeTier, skipCreate, additionalHeaders, additionalQueryParams) + + override fun toString() = + "OrgListParams{includeTier=$includeTier, skipCreate=$skipCreate, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrgRetrievePermissionsParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrgRetrievePermissionsParams.kt new file mode 100644 index 00000000..ba8a80bc --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrgRetrievePermissionsParams.kt @@ -0,0 +1,172 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** List Permissions */ +class OrgRetrievePermissionsParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): OrgRetrievePermissionsParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [OrgRetrievePermissionsParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OrgRetrievePermissionsParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(orgRetrievePermissionsParams: OrgRetrievePermissionsParams) = apply { + additionalHeaders = orgRetrievePermissionsParams.additionalHeaders.toBuilder() + additionalQueryParams = orgRetrievePermissionsParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [OrgRetrievePermissionsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OrgRetrievePermissionsParams = + OrgRetrievePermissionsParams(additionalHeaders.build(), additionalQueryParams.build()) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OrgRetrievePermissionsParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "OrgRetrievePermissionsParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrgRetrievePermissionsResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrgRetrievePermissionsResponse.kt new file mode 100644 index 00000000..d5d084d6 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrgRetrievePermissionsResponse.kt @@ -0,0 +1,254 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.orgs.current.members.AccessScope +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class OrgRetrievePermissionsResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val accessScope: JsonField<AccessScope>, + private val description: JsonField<String>, + private val name: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("access_scope") + @ExcludeMissing + accessScope: JsonField<AccessScope> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + ) : this(accessScope, description, name, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun accessScope(): AccessScope = accessScope.getRequired("access_scope") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun description(): String = description.getRequired("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [accessScope]. + * + * Unlike [accessScope], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("access_scope") + @ExcludeMissing + fun _accessScope(): JsonField<AccessScope> = accessScope + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [OrgRetrievePermissionsResponse]. + * + * The following fields are required: + * ```java + * .accessScope() + * .description() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OrgRetrievePermissionsResponse]. */ + class Builder internal constructor() { + + private var accessScope: JsonField<AccessScope>? = null + private var description: JsonField<String>? = null + private var name: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(orgRetrievePermissionsResponse: OrgRetrievePermissionsResponse) = apply { + accessScope = orgRetrievePermissionsResponse.accessScope + description = orgRetrievePermissionsResponse.description + name = orgRetrievePermissionsResponse.name + additionalProperties = + orgRetrievePermissionsResponse.additionalProperties.toMutableMap() + } + + fun accessScope(accessScope: AccessScope) = accessScope(JsonField.of(accessScope)) + + /** + * Sets [Builder.accessScope] to an arbitrary JSON value. + * + * You should usually call [Builder.accessScope] with a well-typed [AccessScope] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun accessScope(accessScope: JsonField<AccessScope>) = apply { + this.accessScope = accessScope + } + + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { this.description = description } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OrgRetrievePermissionsResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accessScope() + * .description() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): OrgRetrievePermissionsResponse = + OrgRetrievePermissionsResponse( + checkRequired("accessScope", accessScope), + checkRequired("description", description), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OrgRetrievePermissionsResponse = apply { + if (validated) { + return@apply + } + + accessScope().validate() + description() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (accessScope.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OrgRetrievePermissionsResponse && + accessScope == other.accessScope && + description == other.description && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(accessScope, description, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OrgRetrievePermissionsResponse{accessScope=$accessScope, description=$description, name=$name, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrganizationPgSchemaSlim.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrganizationPgSchemaSlim.kt new file mode 100644 index 00000000..38112b49 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrganizationPgSchemaSlim.kt @@ -0,0 +1,802 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Schema for an organization in postgres for list views. */ +class OrganizationPgSchemaSlim +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val disabled: JsonField<Boolean>, + private val displayName: JsonField<String>, + private val isPersonal: JsonField<Boolean>, + private val createdAt: JsonField<OffsetDateTime>, + private val createdByLsUserId: JsonField<String>, + private val createdByUserId: JsonField<String>, + private val defaultSsoProvision: JsonField<Boolean>, + private val jitProvisioningEnabled: JsonField<Boolean>, + private val modifiedAt: JsonField<OffsetDateTime>, + private val patCreationDisabled: JsonField<Boolean>, + private val publicSharingDisabled: JsonField<Boolean>, + private val ssoLoginSlug: JsonField<String>, + private val ssoOnly: JsonField<Boolean>, + private val tier: JsonField<PaymentPlanTier>, + private val workspaceAdminCanInviteToOrg: JsonField<Boolean>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("disabled") @ExcludeMissing disabled: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField<String> = JsonMissing.of(), + @JsonProperty("is_personal") + @ExcludeMissing + isPersonal: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("created_by_ls_user_id") + @ExcludeMissing + createdByLsUserId: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_by_user_id") + @ExcludeMissing + createdByUserId: JsonField<String> = JsonMissing.of(), + @JsonProperty("default_sso_provision") + @ExcludeMissing + defaultSsoProvision: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("jit_provisioning_enabled") + @ExcludeMissing + jitProvisioningEnabled: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("modified_at") + @ExcludeMissing + modifiedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("pat_creation_disabled") + @ExcludeMissing + patCreationDisabled: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("public_sharing_disabled") + @ExcludeMissing + publicSharingDisabled: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("sso_login_slug") + @ExcludeMissing + ssoLoginSlug: JsonField<String> = JsonMissing.of(), + @JsonProperty("sso_only") @ExcludeMissing ssoOnly: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("tier") @ExcludeMissing tier: JsonField<PaymentPlanTier> = JsonMissing.of(), + @JsonProperty("workspace_admin_can_invite_to_org") + @ExcludeMissing + workspaceAdminCanInviteToOrg: JsonField<Boolean> = JsonMissing.of(), + ) : this( + id, + disabled, + displayName, + isPersonal, + createdAt, + createdByLsUserId, + createdByUserId, + defaultSsoProvision, + jitProvisioningEnabled, + modifiedAt, + patCreationDisabled, + publicSharingDisabled, + ssoLoginSlug, + ssoOnly, + tier, + workspaceAdminCanInviteToOrg, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun disabled(): Boolean = disabled.getRequired("disabled") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun displayName(): String = displayName.getRequired("display_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun isPersonal(): Boolean = isPersonal.getRequired("is_personal") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun createdAt(): Optional<OffsetDateTime> = createdAt.getOptional("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun createdByLsUserId(): Optional<String> = + createdByLsUserId.getOptional("created_by_ls_user_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun createdByUserId(): Optional<String> = createdByUserId.getOptional("created_by_user_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun defaultSsoProvision(): Optional<Boolean> = + defaultSsoProvision.getOptional("default_sso_provision") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun jitProvisioningEnabled(): Optional<Boolean> = + jitProvisioningEnabled.getOptional("jit_provisioning_enabled") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun modifiedAt(): Optional<OffsetDateTime> = modifiedAt.getOptional("modified_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun patCreationDisabled(): Optional<Boolean> = + patCreationDisabled.getOptional("pat_creation_disabled") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun publicSharingDisabled(): Optional<Boolean> = + publicSharingDisabled.getOptional("public_sharing_disabled") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun ssoLoginSlug(): Optional<String> = ssoLoginSlug.getOptional("sso_login_slug") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun ssoOnly(): Optional<Boolean> = ssoOnly.getOptional("sso_only") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tier(): Optional<PaymentPlanTier> = tier.getOptional("tier") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun workspaceAdminCanInviteToOrg(): Optional<Boolean> = + workspaceAdminCanInviteToOrg.getOptional("workspace_admin_can_invite_to_org") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [disabled]. + * + * Unlike [disabled], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("disabled") @ExcludeMissing fun _disabled(): JsonField<Boolean> = disabled + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField<String> = displayName + + /** + * Returns the raw JSON value of [isPersonal]. + * + * Unlike [isPersonal], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_personal") @ExcludeMissing fun _isPersonal(): JsonField<Boolean> = isPersonal + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [createdByLsUserId]. + * + * Unlike [createdByLsUserId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("created_by_ls_user_id") + @ExcludeMissing + fun _createdByLsUserId(): JsonField<String> = createdByLsUserId + + /** + * Returns the raw JSON value of [createdByUserId]. + * + * Unlike [createdByUserId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_by_user_id") + @ExcludeMissing + fun _createdByUserId(): JsonField<String> = createdByUserId + + /** + * Returns the raw JSON value of [defaultSsoProvision]. + * + * Unlike [defaultSsoProvision], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("default_sso_provision") + @ExcludeMissing + fun _defaultSsoProvision(): JsonField<Boolean> = defaultSsoProvision + + /** + * Returns the raw JSON value of [jitProvisioningEnabled]. + * + * Unlike [jitProvisioningEnabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("jit_provisioning_enabled") + @ExcludeMissing + fun _jitProvisioningEnabled(): JsonField<Boolean> = jitProvisioningEnabled + + /** + * Returns the raw JSON value of [modifiedAt]. + * + * Unlike [modifiedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("modified_at") + @ExcludeMissing + fun _modifiedAt(): JsonField<OffsetDateTime> = modifiedAt + + /** + * Returns the raw JSON value of [patCreationDisabled]. + * + * Unlike [patCreationDisabled], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("pat_creation_disabled") + @ExcludeMissing + fun _patCreationDisabled(): JsonField<Boolean> = patCreationDisabled + + /** + * Returns the raw JSON value of [publicSharingDisabled]. + * + * Unlike [publicSharingDisabled], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("public_sharing_disabled") + @ExcludeMissing + fun _publicSharingDisabled(): JsonField<Boolean> = publicSharingDisabled + + /** + * Returns the raw JSON value of [ssoLoginSlug]. + * + * Unlike [ssoLoginSlug], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sso_login_slug") + @ExcludeMissing + fun _ssoLoginSlug(): JsonField<String> = ssoLoginSlug + + /** + * Returns the raw JSON value of [ssoOnly]. + * + * Unlike [ssoOnly], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sso_only") @ExcludeMissing fun _ssoOnly(): JsonField<Boolean> = ssoOnly + + /** + * Returns the raw JSON value of [tier]. + * + * Unlike [tier], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tier") @ExcludeMissing fun _tier(): JsonField<PaymentPlanTier> = tier + + /** + * Returns the raw JSON value of [workspaceAdminCanInviteToOrg]. + * + * Unlike [workspaceAdminCanInviteToOrg], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("workspace_admin_can_invite_to_org") + @ExcludeMissing + fun _workspaceAdminCanInviteToOrg(): JsonField<Boolean> = workspaceAdminCanInviteToOrg + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [OrganizationPgSchemaSlim]. + * + * The following fields are required: + * ```java + * .id() + * .disabled() + * .displayName() + * .isPersonal() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OrganizationPgSchemaSlim]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var disabled: JsonField<Boolean>? = null + private var displayName: JsonField<String>? = null + private var isPersonal: JsonField<Boolean>? = null + private var createdAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var createdByLsUserId: JsonField<String> = JsonMissing.of() + private var createdByUserId: JsonField<String> = JsonMissing.of() + private var defaultSsoProvision: JsonField<Boolean> = JsonMissing.of() + private var jitProvisioningEnabled: JsonField<Boolean> = JsonMissing.of() + private var modifiedAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var patCreationDisabled: JsonField<Boolean> = JsonMissing.of() + private var publicSharingDisabled: JsonField<Boolean> = JsonMissing.of() + private var ssoLoginSlug: JsonField<String> = JsonMissing.of() + private var ssoOnly: JsonField<Boolean> = JsonMissing.of() + private var tier: JsonField<PaymentPlanTier> = JsonMissing.of() + private var workspaceAdminCanInviteToOrg: JsonField<Boolean> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(organizationPgSchemaSlim: OrganizationPgSchemaSlim) = apply { + id = organizationPgSchemaSlim.id + disabled = organizationPgSchemaSlim.disabled + displayName = organizationPgSchemaSlim.displayName + isPersonal = organizationPgSchemaSlim.isPersonal + createdAt = organizationPgSchemaSlim.createdAt + createdByLsUserId = organizationPgSchemaSlim.createdByLsUserId + createdByUserId = organizationPgSchemaSlim.createdByUserId + defaultSsoProvision = organizationPgSchemaSlim.defaultSsoProvision + jitProvisioningEnabled = organizationPgSchemaSlim.jitProvisioningEnabled + modifiedAt = organizationPgSchemaSlim.modifiedAt + patCreationDisabled = organizationPgSchemaSlim.patCreationDisabled + publicSharingDisabled = organizationPgSchemaSlim.publicSharingDisabled + ssoLoginSlug = organizationPgSchemaSlim.ssoLoginSlug + ssoOnly = organizationPgSchemaSlim.ssoOnly + tier = organizationPgSchemaSlim.tier + workspaceAdminCanInviteToOrg = organizationPgSchemaSlim.workspaceAdminCanInviteToOrg + additionalProperties = organizationPgSchemaSlim.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun disabled(disabled: Boolean) = disabled(JsonField.of(disabled)) + + /** + * Sets [Builder.disabled] to an arbitrary JSON value. + * + * You should usually call [Builder.disabled] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun disabled(disabled: JsonField<Boolean>) = apply { this.disabled = disabled } + + fun displayName(displayName: String) = displayName(JsonField.of(displayName)) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun displayName(displayName: JsonField<String>) = apply { this.displayName = displayName } + + fun isPersonal(isPersonal: Boolean) = isPersonal(JsonField.of(isPersonal)) + + /** + * Sets [Builder.isPersonal] to an arbitrary JSON value. + * + * You should usually call [Builder.isPersonal] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isPersonal(isPersonal: JsonField<Boolean>) = apply { this.isPersonal = isPersonal } + + fun createdAt(createdAt: OffsetDateTime?) = createdAt(JsonField.ofNullable(createdAt)) + + /** Alias for calling [Builder.createdAt] with `createdAt.orElse(null)`. */ + fun createdAt(createdAt: Optional<OffsetDateTime>) = createdAt(createdAt.getOrNull()) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun createdByLsUserId(createdByLsUserId: String?) = + createdByLsUserId(JsonField.ofNullable(createdByLsUserId)) + + /** Alias for calling [Builder.createdByLsUserId] with `createdByLsUserId.orElse(null)`. */ + fun createdByLsUserId(createdByLsUserId: Optional<String>) = + createdByLsUserId(createdByLsUserId.getOrNull()) + + /** + * Sets [Builder.createdByLsUserId] to an arbitrary JSON value. + * + * You should usually call [Builder.createdByLsUserId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdByLsUserId(createdByLsUserId: JsonField<String>) = apply { + this.createdByLsUserId = createdByLsUserId + } + + fun createdByUserId(createdByUserId: String?) = + createdByUserId(JsonField.ofNullable(createdByUserId)) + + /** Alias for calling [Builder.createdByUserId] with `createdByUserId.orElse(null)`. */ + fun createdByUserId(createdByUserId: Optional<String>) = + createdByUserId(createdByUserId.getOrNull()) + + /** + * Sets [Builder.createdByUserId] to an arbitrary JSON value. + * + * You should usually call [Builder.createdByUserId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdByUserId(createdByUserId: JsonField<String>) = apply { + this.createdByUserId = createdByUserId + } + + fun defaultSsoProvision(defaultSsoProvision: Boolean) = + defaultSsoProvision(JsonField.of(defaultSsoProvision)) + + /** + * Sets [Builder.defaultSsoProvision] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultSsoProvision] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun defaultSsoProvision(defaultSsoProvision: JsonField<Boolean>) = apply { + this.defaultSsoProvision = defaultSsoProvision + } + + fun jitProvisioningEnabled(jitProvisioningEnabled: Boolean) = + jitProvisioningEnabled(JsonField.of(jitProvisioningEnabled)) + + /** + * Sets [Builder.jitProvisioningEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.jitProvisioningEnabled] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun jitProvisioningEnabled(jitProvisioningEnabled: JsonField<Boolean>) = apply { + this.jitProvisioningEnabled = jitProvisioningEnabled + } + + fun modifiedAt(modifiedAt: OffsetDateTime?) = modifiedAt(JsonField.ofNullable(modifiedAt)) + + /** Alias for calling [Builder.modifiedAt] with `modifiedAt.orElse(null)`. */ + fun modifiedAt(modifiedAt: Optional<OffsetDateTime>) = modifiedAt(modifiedAt.getOrNull()) + + /** + * Sets [Builder.modifiedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.modifiedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modifiedAt(modifiedAt: JsonField<OffsetDateTime>) = apply { + this.modifiedAt = modifiedAt + } + + fun patCreationDisabled(patCreationDisabled: Boolean) = + patCreationDisabled(JsonField.of(patCreationDisabled)) + + /** + * Sets [Builder.patCreationDisabled] to an arbitrary JSON value. + * + * You should usually call [Builder.patCreationDisabled] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun patCreationDisabled(patCreationDisabled: JsonField<Boolean>) = apply { + this.patCreationDisabled = patCreationDisabled + } + + fun publicSharingDisabled(publicSharingDisabled: Boolean) = + publicSharingDisabled(JsonField.of(publicSharingDisabled)) + + /** + * Sets [Builder.publicSharingDisabled] to an arbitrary JSON value. + * + * You should usually call [Builder.publicSharingDisabled] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun publicSharingDisabled(publicSharingDisabled: JsonField<Boolean>) = apply { + this.publicSharingDisabled = publicSharingDisabled + } + + fun ssoLoginSlug(ssoLoginSlug: String?) = ssoLoginSlug(JsonField.ofNullable(ssoLoginSlug)) + + /** Alias for calling [Builder.ssoLoginSlug] with `ssoLoginSlug.orElse(null)`. */ + fun ssoLoginSlug(ssoLoginSlug: Optional<String>) = ssoLoginSlug(ssoLoginSlug.getOrNull()) + + /** + * Sets [Builder.ssoLoginSlug] to an arbitrary JSON value. + * + * You should usually call [Builder.ssoLoginSlug] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ssoLoginSlug(ssoLoginSlug: JsonField<String>) = apply { + this.ssoLoginSlug = ssoLoginSlug + } + + fun ssoOnly(ssoOnly: Boolean) = ssoOnly(JsonField.of(ssoOnly)) + + /** + * Sets [Builder.ssoOnly] to an arbitrary JSON value. + * + * You should usually call [Builder.ssoOnly] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun ssoOnly(ssoOnly: JsonField<Boolean>) = apply { this.ssoOnly = ssoOnly } + + fun tier(tier: PaymentPlanTier?) = tier(JsonField.ofNullable(tier)) + + /** Alias for calling [Builder.tier] with `tier.orElse(null)`. */ + fun tier(tier: Optional<PaymentPlanTier>) = tier(tier.getOrNull()) + + /** + * Sets [Builder.tier] to an arbitrary JSON value. + * + * You should usually call [Builder.tier] with a well-typed [PaymentPlanTier] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tier(tier: JsonField<PaymentPlanTier>) = apply { this.tier = tier } + + fun workspaceAdminCanInviteToOrg(workspaceAdminCanInviteToOrg: Boolean) = + workspaceAdminCanInviteToOrg(JsonField.of(workspaceAdminCanInviteToOrg)) + + /** + * Sets [Builder.workspaceAdminCanInviteToOrg] to an arbitrary JSON value. + * + * You should usually call [Builder.workspaceAdminCanInviteToOrg] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun workspaceAdminCanInviteToOrg(workspaceAdminCanInviteToOrg: JsonField<Boolean>) = apply { + this.workspaceAdminCanInviteToOrg = workspaceAdminCanInviteToOrg + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OrganizationPgSchemaSlim]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .disabled() + * .displayName() + * .isPersonal() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): OrganizationPgSchemaSlim = + OrganizationPgSchemaSlim( + checkRequired("id", id), + checkRequired("disabled", disabled), + checkRequired("displayName", displayName), + checkRequired("isPersonal", isPersonal), + createdAt, + createdByLsUserId, + createdByUserId, + defaultSsoProvision, + jitProvisioningEnabled, + modifiedAt, + patCreationDisabled, + publicSharingDisabled, + ssoLoginSlug, + ssoOnly, + tier, + workspaceAdminCanInviteToOrg, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OrganizationPgSchemaSlim = apply { + if (validated) { + return@apply + } + + id() + disabled() + displayName() + isPersonal() + createdAt() + createdByLsUserId() + createdByUserId() + defaultSsoProvision() + jitProvisioningEnabled() + modifiedAt() + patCreationDisabled() + publicSharingDisabled() + ssoLoginSlug() + ssoOnly() + tier().ifPresent { it.validate() } + workspaceAdminCanInviteToOrg() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (disabled.asKnown().isPresent) 1 else 0) + + (if (displayName.asKnown().isPresent) 1 else 0) + + (if (isPersonal.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (createdByLsUserId.asKnown().isPresent) 1 else 0) + + (if (createdByUserId.asKnown().isPresent) 1 else 0) + + (if (defaultSsoProvision.asKnown().isPresent) 1 else 0) + + (if (jitProvisioningEnabled.asKnown().isPresent) 1 else 0) + + (if (modifiedAt.asKnown().isPresent) 1 else 0) + + (if (patCreationDisabled.asKnown().isPresent) 1 else 0) + + (if (publicSharingDisabled.asKnown().isPresent) 1 else 0) + + (if (ssoLoginSlug.asKnown().isPresent) 1 else 0) + + (if (ssoOnly.asKnown().isPresent) 1 else 0) + + (tier.asKnown().getOrNull()?.validity() ?: 0) + + (if (workspaceAdminCanInviteToOrg.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OrganizationPgSchemaSlim && + id == other.id && + disabled == other.disabled && + displayName == other.displayName && + isPersonal == other.isPersonal && + createdAt == other.createdAt && + createdByLsUserId == other.createdByLsUserId && + createdByUserId == other.createdByUserId && + defaultSsoProvision == other.defaultSsoProvision && + jitProvisioningEnabled == other.jitProvisioningEnabled && + modifiedAt == other.modifiedAt && + patCreationDisabled == other.patCreationDisabled && + publicSharingDisabled == other.publicSharingDisabled && + ssoLoginSlug == other.ssoLoginSlug && + ssoOnly == other.ssoOnly && + tier == other.tier && + workspaceAdminCanInviteToOrg == other.workspaceAdminCanInviteToOrg && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + disabled, + displayName, + isPersonal, + createdAt, + createdByLsUserId, + createdByUserId, + defaultSsoProvision, + jitProvisioningEnabled, + modifiedAt, + patCreationDisabled, + publicSharingDisabled, + ssoLoginSlug, + ssoOnly, + tier, + workspaceAdminCanInviteToOrg, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OrganizationPgSchemaSlim{id=$id, disabled=$disabled, displayName=$displayName, isPersonal=$isPersonal, createdAt=$createdAt, createdByLsUserId=$createdByLsUserId, createdByUserId=$createdByUserId, defaultSsoProvision=$defaultSsoProvision, jitProvisioningEnabled=$jitProvisioningEnabled, modifiedAt=$modifiedAt, patCreationDisabled=$patCreationDisabled, publicSharingDisabled=$publicSharingDisabled, ssoLoginSlug=$ssoLoginSlug, ssoOnly=$ssoOnly, tier=$tier, workspaceAdminCanInviteToOrg=$workspaceAdminCanInviteToOrg, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/PaymentPlanTier.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/PaymentPlanTier.kt new file mode 100644 index 00000000..931093ac --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/PaymentPlanTier.kt @@ -0,0 +1,196 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs + +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException + +class PaymentPlanTier @JsonCreator private constructor(private val value: JsonField<String>) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't match + * any known member, and you want to know that value. For example, if the SDK is on an older + * version than the API, then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val NO_PLAN = of("no_plan") + + @JvmField val DEVELOPER = of("developer") + + @JvmField val PLUS = of("plus") + + @JvmField val ENTERPRISE = of("enterprise") + + @JvmField val DEVELOPER_LEGACY = of("developer_legacy") + + @JvmField val PLUS_LEGACY = of("plus_legacy") + + @JvmField val FREE = of("free") + + @JvmField val ENTERPRISE_LEGACY = of("enterprise_legacy") + + @JvmField val STARTUP = of("startup") + + @JvmField val STARTUP_V0 = of("startup_v0") + + @JvmField val PARTNER = of("partner") + + @JvmField val PREMIER = of("premier") + + @JvmStatic fun of(value: String) = PaymentPlanTier(JsonField.of(value)) + } + + /** An enum containing [PaymentPlanTier]'s known values. */ + enum class Known { + NO_PLAN, + DEVELOPER, + PLUS, + ENTERPRISE, + DEVELOPER_LEGACY, + PLUS_LEGACY, + FREE, + ENTERPRISE_LEGACY, + STARTUP, + STARTUP_V0, + PARTNER, + PREMIER, + } + + /** + * An enum containing [PaymentPlanTier]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PaymentPlanTier] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the SDK + * is on an older version than the API, then the API may respond with new members that the SDK + * is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + NO_PLAN, + DEVELOPER, + PLUS, + ENTERPRISE, + DEVELOPER_LEGACY, + PLUS_LEGACY, + FREE, + ENTERPRISE_LEGACY, + STARTUP, + STARTUP_V0, + PARTNER, + PREMIER, + /** + * An enum member indicating that [PaymentPlanTier] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if + * the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want to + * throw for the unknown case. + */ + fun value(): Value = + when (this) { + NO_PLAN -> Value.NO_PLAN + DEVELOPER -> Value.DEVELOPER + PLUS -> Value.PLUS + ENTERPRISE -> Value.ENTERPRISE + DEVELOPER_LEGACY -> Value.DEVELOPER_LEGACY + PLUS_LEGACY -> Value.PLUS_LEGACY + FREE -> Value.FREE + ENTERPRISE_LEGACY -> Value.ENTERPRISE_LEGACY + STARTUP -> Value.STARTUP + STARTUP_V0 -> Value.STARTUP_V0 + PARTNER -> Value.PARTNER + PREMIER -> Value.PREMIER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't want + * to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + NO_PLAN -> Known.NO_PLAN + DEVELOPER -> Known.DEVELOPER + PLUS -> Known.PLUS + ENTERPRISE -> Known.ENTERPRISE + DEVELOPER_LEGACY -> Known.DEVELOPER_LEGACY + PLUS_LEGACY -> Known.PLUS_LEGACY + FREE -> Known.FREE + ENTERPRISE_LEGACY -> Known.ENTERPRISE_LEGACY + STARTUP -> Known.STARTUP + STARTUP_V0 -> Known.STARTUP_V0 + PARTNER -> Known.PARTNER + PREMIER -> Known.PREMIER + else -> throw LangsmithApiInvalidDataException("Unknown PaymentPlanTier: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): PaymentPlanTier = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PaymentPlanTier && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentConfirmCheckoutSessionCompletionParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentConfirmCheckoutSessionCompletionParams.kt new file mode 100644 index 00000000..7df8c85c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentConfirmCheckoutSessionCompletionParams.kt @@ -0,0 +1,432 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +/** Complete a Stripe checkout session flow. */ +class CurrentConfirmCheckoutSessionCompletionParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun stripeSessionId(): String = body.stripeSessionId() + + /** + * Returns the raw JSON value of [stripeSessionId]. + * + * Unlike [stripeSessionId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _stripeSessionId(): JsonField<String> = body._stripeSessionId() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CurrentConfirmCheckoutSessionCompletionParams]. + * + * The following fields are required: + * ```java + * .stripeSessionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CurrentConfirmCheckoutSessionCompletionParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + currentConfirmCheckoutSessionCompletionParams: + CurrentConfirmCheckoutSessionCompletionParams + ) = apply { + body = currentConfirmCheckoutSessionCompletionParams.body.toBuilder() + additionalHeaders = + currentConfirmCheckoutSessionCompletionParams.additionalHeaders.toBuilder() + additionalQueryParams = + currentConfirmCheckoutSessionCompletionParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [stripeSessionId] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun stripeSessionId(stripeSessionId: String) = apply { + body.stripeSessionId(stripeSessionId) + } + + /** + * Sets [Builder.stripeSessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.stripeSessionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun stripeSessionId(stripeSessionId: JsonField<String>) = apply { + body.stripeSessionId(stripeSessionId) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [CurrentConfirmCheckoutSessionCompletionParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .stripeSessionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CurrentConfirmCheckoutSessionCompletionParams = + CurrentConfirmCheckoutSessionCompletionParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val stripeSessionId: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("stripe_session_id") + @ExcludeMissing + stripeSessionId: JsonField<String> = JsonMissing.of() + ) : this(stripeSessionId, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun stripeSessionId(): String = stripeSessionId.getRequired("stripe_session_id") + + /** + * Returns the raw JSON value of [stripeSessionId]. + * + * Unlike [stripeSessionId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("stripe_session_id") + @ExcludeMissing + fun _stripeSessionId(): JsonField<String> = stripeSessionId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .stripeSessionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var stripeSessionId: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + stripeSessionId = body.stripeSessionId + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun stripeSessionId(stripeSessionId: String) = + stripeSessionId(JsonField.of(stripeSessionId)) + + /** + * Sets [Builder.stripeSessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.stripeSessionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun stripeSessionId(stripeSessionId: JsonField<String>) = apply { + this.stripeSessionId = stripeSessionId + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .stripeSessionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("stripeSessionId", stripeSessionId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + stripeSessionId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (stripeSessionId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + stripeSessionId == other.stripeSessionId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(stripeSessionId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{stripeSessionId=$stripeSessionId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CurrentConfirmCheckoutSessionCompletionParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "CurrentConfirmCheckoutSessionCompletionParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentConfirmCheckoutSessionCompletionResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentConfirmCheckoutSessionCompletionResponse.kt new file mode 100644 index 00000000..1f94a086 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentConfirmCheckoutSessionCompletionResponse.kt @@ -0,0 +1,123 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class CurrentConfirmCheckoutSessionCompletionResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CurrentConfirmCheckoutSessionCompletionResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CurrentConfirmCheckoutSessionCompletionResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from( + currentConfirmCheckoutSessionCompletionResponse: + CurrentConfirmCheckoutSessionCompletionResponse + ) = apply { + additionalProperties = + currentConfirmCheckoutSessionCompletionResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CurrentConfirmCheckoutSessionCompletionResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CurrentConfirmCheckoutSessionCompletionResponse = + CurrentConfirmCheckoutSessionCompletionResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): CurrentConfirmCheckoutSessionCompletionResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CurrentConfirmCheckoutSessionCompletionResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CurrentConfirmCheckoutSessionCompletionResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentListParams.kt new file mode 100644 index 00000000..237c40aa --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentListParams.kt @@ -0,0 +1,170 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** Get Organization Info */ +class CurrentListParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): CurrentListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [CurrentListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CurrentListParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(currentListParams: CurrentListParams) = apply { + additionalHeaders = currentListParams.additionalHeaders.toBuilder() + additionalQueryParams = currentListParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [CurrentListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CurrentListParams = + CurrentListParams(additionalHeaders.build(), additionalQueryParams.build()) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CurrentListParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "CurrentListParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentListResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentListResponse.kt new file mode 100644 index 00000000..ba4f3db4 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentListResponse.kt @@ -0,0 +1,891 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.orgs.PaymentPlanTier +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Information about an organization. */ +class CurrentListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val config: JsonField<OrganizationConfig>, + private val connectedToMetronome: JsonField<Boolean>, + private val connectedToStripe: JsonField<Boolean>, + private val hasCancelled: JsonField<Boolean>, + private val isPersonal: JsonField<Boolean>, + private val id: JsonField<String>, + private val currentPlan: JsonField<CustomerVisiblePlanInfo>, + private val defaultSsoProvision: JsonField<Boolean>, + private val displayName: JsonField<String>, + private val endOfBillingPeriod: JsonField<OffsetDateTime>, + private val marketplacePayoutsEnabled: JsonField<Boolean>, + private val paymentMethod: JsonField<StripePaymentMethodInfo>, + private val permissions: JsonField<List<String>>, + private val reachedMaxWorkspaces: JsonField<Boolean>, + private val tier: JsonField<PaymentPlanTier>, + private val upcomingPlan: JsonField<CustomerVisiblePlanInfo>, + private val wallet: JsonField<Wallet>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("config") + @ExcludeMissing + config: JsonField<OrganizationConfig> = JsonMissing.of(), + @JsonProperty("connected_to_metronome") + @ExcludeMissing + connectedToMetronome: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("connected_to_stripe") + @ExcludeMissing + connectedToStripe: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("has_cancelled") + @ExcludeMissing + hasCancelled: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("is_personal") + @ExcludeMissing + isPersonal: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("current_plan") + @ExcludeMissing + currentPlan: JsonField<CustomerVisiblePlanInfo> = JsonMissing.of(), + @JsonProperty("default_sso_provision") + @ExcludeMissing + defaultSsoProvision: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField<String> = JsonMissing.of(), + @JsonProperty("end_of_billing_period") + @ExcludeMissing + endOfBillingPeriod: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("marketplace_payouts_enabled") + @ExcludeMissing + marketplacePayoutsEnabled: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("payment_method") + @ExcludeMissing + paymentMethod: JsonField<StripePaymentMethodInfo> = JsonMissing.of(), + @JsonProperty("permissions") + @ExcludeMissing + permissions: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("reached_max_workspaces") + @ExcludeMissing + reachedMaxWorkspaces: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("tier") @ExcludeMissing tier: JsonField<PaymentPlanTier> = JsonMissing.of(), + @JsonProperty("upcoming_plan") + @ExcludeMissing + upcomingPlan: JsonField<CustomerVisiblePlanInfo> = JsonMissing.of(), + @JsonProperty("wallet") @ExcludeMissing wallet: JsonField<Wallet> = JsonMissing.of(), + ) : this( + config, + connectedToMetronome, + connectedToStripe, + hasCancelled, + isPersonal, + id, + currentPlan, + defaultSsoProvision, + displayName, + endOfBillingPeriod, + marketplacePayoutsEnabled, + paymentMethod, + permissions, + reachedMaxWorkspaces, + tier, + upcomingPlan, + wallet, + mutableMapOf(), + ) + + /** + * Organization level configuration. May include any field that exists in tenant config and + * additional fields. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun config(): OrganizationConfig = config.getRequired("config") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun connectedToMetronome(): Boolean = connectedToMetronome.getRequired("connected_to_metronome") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun connectedToStripe(): Boolean = connectedToStripe.getRequired("connected_to_stripe") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun hasCancelled(): Boolean = hasCancelled.getRequired("has_cancelled") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun isPersonal(): Boolean = isPersonal.getRequired("is_personal") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + /** + * Customer visible plan information. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currentPlan(): Optional<CustomerVisiblePlanInfo> = currentPlan.getOptional("current_plan") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun defaultSsoProvision(): Optional<Boolean> = + defaultSsoProvision.getOptional("default_sso_provision") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun displayName(): Optional<String> = displayName.getOptional("display_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endOfBillingPeriod(): Optional<OffsetDateTime> = + endOfBillingPeriod.getOptional("end_of_billing_period") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun marketplacePayoutsEnabled(): Optional<Boolean> = + marketplacePayoutsEnabled.getOptional("marketplace_payouts_enabled") + + /** + * Stripe customer billing info. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun paymentMethod(): Optional<StripePaymentMethodInfo> = + paymentMethod.getOptional("payment_method") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun permissions(): Optional<List<String>> = permissions.getOptional("permissions") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun reachedMaxWorkspaces(): Optional<Boolean> = + reachedMaxWorkspaces.getOptional("reached_max_workspaces") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tier(): Optional<PaymentPlanTier> = tier.getOptional("tier") + + /** + * Customer visible plan information. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun upcomingPlan(): Optional<CustomerVisiblePlanInfo> = + upcomingPlan.getOptional("upcoming_plan") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun wallet(): Optional<Wallet> = wallet.getOptional("wallet") + + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("config") @ExcludeMissing fun _config(): JsonField<OrganizationConfig> = config + + /** + * Returns the raw JSON value of [connectedToMetronome]. + * + * Unlike [connectedToMetronome], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("connected_to_metronome") + @ExcludeMissing + fun _connectedToMetronome(): JsonField<Boolean> = connectedToMetronome + + /** + * Returns the raw JSON value of [connectedToStripe]. + * + * Unlike [connectedToStripe], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("connected_to_stripe") + @ExcludeMissing + fun _connectedToStripe(): JsonField<Boolean> = connectedToStripe + + /** + * Returns the raw JSON value of [hasCancelled]. + * + * Unlike [hasCancelled], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("has_cancelled") + @ExcludeMissing + fun _hasCancelled(): JsonField<Boolean> = hasCancelled + + /** + * Returns the raw JSON value of [isPersonal]. + * + * Unlike [isPersonal], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_personal") @ExcludeMissing fun _isPersonal(): JsonField<Boolean> = isPersonal + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [currentPlan]. + * + * Unlike [currentPlan], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("current_plan") + @ExcludeMissing + fun _currentPlan(): JsonField<CustomerVisiblePlanInfo> = currentPlan + + /** + * Returns the raw JSON value of [defaultSsoProvision]. + * + * Unlike [defaultSsoProvision], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("default_sso_provision") + @ExcludeMissing + fun _defaultSsoProvision(): JsonField<Boolean> = defaultSsoProvision + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField<String> = displayName + + /** + * Returns the raw JSON value of [endOfBillingPeriod]. + * + * Unlike [endOfBillingPeriod], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("end_of_billing_period") + @ExcludeMissing + fun _endOfBillingPeriod(): JsonField<OffsetDateTime> = endOfBillingPeriod + + /** + * Returns the raw JSON value of [marketplacePayoutsEnabled]. + * + * Unlike [marketplacePayoutsEnabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("marketplace_payouts_enabled") + @ExcludeMissing + fun _marketplacePayoutsEnabled(): JsonField<Boolean> = marketplacePayoutsEnabled + + /** + * Returns the raw JSON value of [paymentMethod]. + * + * Unlike [paymentMethod], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("payment_method") + @ExcludeMissing + fun _paymentMethod(): JsonField<StripePaymentMethodInfo> = paymentMethod + + /** + * Returns the raw JSON value of [permissions]. + * + * Unlike [permissions], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("permissions") + @ExcludeMissing + fun _permissions(): JsonField<List<String>> = permissions + + /** + * Returns the raw JSON value of [reachedMaxWorkspaces]. + * + * Unlike [reachedMaxWorkspaces], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reached_max_workspaces") + @ExcludeMissing + fun _reachedMaxWorkspaces(): JsonField<Boolean> = reachedMaxWorkspaces + + /** + * Returns the raw JSON value of [tier]. + * + * Unlike [tier], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tier") @ExcludeMissing fun _tier(): JsonField<PaymentPlanTier> = tier + + /** + * Returns the raw JSON value of [upcomingPlan]. + * + * Unlike [upcomingPlan], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("upcoming_plan") + @ExcludeMissing + fun _upcomingPlan(): JsonField<CustomerVisiblePlanInfo> = upcomingPlan + + /** + * Returns the raw JSON value of [wallet]. + * + * Unlike [wallet], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("wallet") @ExcludeMissing fun _wallet(): JsonField<Wallet> = wallet + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CurrentListResponse]. + * + * The following fields are required: + * ```java + * .config() + * .connectedToMetronome() + * .connectedToStripe() + * .hasCancelled() + * .isPersonal() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CurrentListResponse]. */ + class Builder internal constructor() { + + private var config: JsonField<OrganizationConfig>? = null + private var connectedToMetronome: JsonField<Boolean>? = null + private var connectedToStripe: JsonField<Boolean>? = null + private var hasCancelled: JsonField<Boolean>? = null + private var isPersonal: JsonField<Boolean>? = null + private var id: JsonField<String> = JsonMissing.of() + private var currentPlan: JsonField<CustomerVisiblePlanInfo> = JsonMissing.of() + private var defaultSsoProvision: JsonField<Boolean> = JsonMissing.of() + private var displayName: JsonField<String> = JsonMissing.of() + private var endOfBillingPeriod: JsonField<OffsetDateTime> = JsonMissing.of() + private var marketplacePayoutsEnabled: JsonField<Boolean> = JsonMissing.of() + private var paymentMethod: JsonField<StripePaymentMethodInfo> = JsonMissing.of() + private var permissions: JsonField<MutableList<String>>? = null + private var reachedMaxWorkspaces: JsonField<Boolean> = JsonMissing.of() + private var tier: JsonField<PaymentPlanTier> = JsonMissing.of() + private var upcomingPlan: JsonField<CustomerVisiblePlanInfo> = JsonMissing.of() + private var wallet: JsonField<Wallet> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(currentListResponse: CurrentListResponse) = apply { + config = currentListResponse.config + connectedToMetronome = currentListResponse.connectedToMetronome + connectedToStripe = currentListResponse.connectedToStripe + hasCancelled = currentListResponse.hasCancelled + isPersonal = currentListResponse.isPersonal + id = currentListResponse.id + currentPlan = currentListResponse.currentPlan + defaultSsoProvision = currentListResponse.defaultSsoProvision + displayName = currentListResponse.displayName + endOfBillingPeriod = currentListResponse.endOfBillingPeriod + marketplacePayoutsEnabled = currentListResponse.marketplacePayoutsEnabled + paymentMethod = currentListResponse.paymentMethod + permissions = currentListResponse.permissions.map { it.toMutableList() } + reachedMaxWorkspaces = currentListResponse.reachedMaxWorkspaces + tier = currentListResponse.tier + upcomingPlan = currentListResponse.upcomingPlan + wallet = currentListResponse.wallet + additionalProperties = currentListResponse.additionalProperties.toMutableMap() + } + + /** + * Organization level configuration. May include any field that exists in tenant config and + * additional fields. + */ + fun config(config: OrganizationConfig) = config(JsonField.of(config)) + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed [OrganizationConfig] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun config(config: JsonField<OrganizationConfig>) = apply { this.config = config } + + fun connectedToMetronome(connectedToMetronome: Boolean) = + connectedToMetronome(JsonField.of(connectedToMetronome)) + + /** + * Sets [Builder.connectedToMetronome] to an arbitrary JSON value. + * + * You should usually call [Builder.connectedToMetronome] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun connectedToMetronome(connectedToMetronome: JsonField<Boolean>) = apply { + this.connectedToMetronome = connectedToMetronome + } + + fun connectedToStripe(connectedToStripe: Boolean) = + connectedToStripe(JsonField.of(connectedToStripe)) + + /** + * Sets [Builder.connectedToStripe] to an arbitrary JSON value. + * + * You should usually call [Builder.connectedToStripe] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun connectedToStripe(connectedToStripe: JsonField<Boolean>) = apply { + this.connectedToStripe = connectedToStripe + } + + fun hasCancelled(hasCancelled: Boolean) = hasCancelled(JsonField.of(hasCancelled)) + + /** + * Sets [Builder.hasCancelled] to an arbitrary JSON value. + * + * You should usually call [Builder.hasCancelled] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun hasCancelled(hasCancelled: JsonField<Boolean>) = apply { + this.hasCancelled = hasCancelled + } + + fun isPersonal(isPersonal: Boolean) = isPersonal(JsonField.of(isPersonal)) + + /** + * Sets [Builder.isPersonal] to an arbitrary JSON value. + * + * You should usually call [Builder.isPersonal] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isPersonal(isPersonal: JsonField<Boolean>) = apply { this.isPersonal = isPersonal } + + fun id(id: String?) = id(JsonField.ofNullable(id)) + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<String>) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + /** Customer visible plan information. */ + fun currentPlan(currentPlan: CustomerVisiblePlanInfo?) = + currentPlan(JsonField.ofNullable(currentPlan)) + + /** Alias for calling [Builder.currentPlan] with `currentPlan.orElse(null)`. */ + fun currentPlan(currentPlan: Optional<CustomerVisiblePlanInfo>) = + currentPlan(currentPlan.getOrNull()) + + /** + * Sets [Builder.currentPlan] to an arbitrary JSON value. + * + * You should usually call [Builder.currentPlan] with a well-typed [CustomerVisiblePlanInfo] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun currentPlan(currentPlan: JsonField<CustomerVisiblePlanInfo>) = apply { + this.currentPlan = currentPlan + } + + fun defaultSsoProvision(defaultSsoProvision: Boolean) = + defaultSsoProvision(JsonField.of(defaultSsoProvision)) + + /** + * Sets [Builder.defaultSsoProvision] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultSsoProvision] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun defaultSsoProvision(defaultSsoProvision: JsonField<Boolean>) = apply { + this.defaultSsoProvision = defaultSsoProvision + } + + fun displayName(displayName: String?) = displayName(JsonField.ofNullable(displayName)) + + /** Alias for calling [Builder.displayName] with `displayName.orElse(null)`. */ + fun displayName(displayName: Optional<String>) = displayName(displayName.getOrNull()) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun displayName(displayName: JsonField<String>) = apply { this.displayName = displayName } + + fun endOfBillingPeriod(endOfBillingPeriod: OffsetDateTime?) = + endOfBillingPeriod(JsonField.ofNullable(endOfBillingPeriod)) + + /** + * Alias for calling [Builder.endOfBillingPeriod] with `endOfBillingPeriod.orElse(null)`. + */ + fun endOfBillingPeriod(endOfBillingPeriod: Optional<OffsetDateTime>) = + endOfBillingPeriod(endOfBillingPeriod.getOrNull()) + + /** + * Sets [Builder.endOfBillingPeriod] to an arbitrary JSON value. + * + * You should usually call [Builder.endOfBillingPeriod] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun endOfBillingPeriod(endOfBillingPeriod: JsonField<OffsetDateTime>) = apply { + this.endOfBillingPeriod = endOfBillingPeriod + } + + fun marketplacePayoutsEnabled(marketplacePayoutsEnabled: Boolean) = + marketplacePayoutsEnabled(JsonField.of(marketplacePayoutsEnabled)) + + /** + * Sets [Builder.marketplacePayoutsEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.marketplacePayoutsEnabled] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun marketplacePayoutsEnabled(marketplacePayoutsEnabled: JsonField<Boolean>) = apply { + this.marketplacePayoutsEnabled = marketplacePayoutsEnabled + } + + /** Stripe customer billing info. */ + fun paymentMethod(paymentMethod: StripePaymentMethodInfo?) = + paymentMethod(JsonField.ofNullable(paymentMethod)) + + /** Alias for calling [Builder.paymentMethod] with `paymentMethod.orElse(null)`. */ + fun paymentMethod(paymentMethod: Optional<StripePaymentMethodInfo>) = + paymentMethod(paymentMethod.getOrNull()) + + /** + * Sets [Builder.paymentMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentMethod] with a well-typed + * [StripePaymentMethodInfo] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun paymentMethod(paymentMethod: JsonField<StripePaymentMethodInfo>) = apply { + this.paymentMethod = paymentMethod + } + + fun permissions(permissions: List<String>) = permissions(JsonField.of(permissions)) + + /** + * Sets [Builder.permissions] to an arbitrary JSON value. + * + * You should usually call [Builder.permissions] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun permissions(permissions: JsonField<List<String>>) = apply { + this.permissions = permissions.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [permissions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPermission(permission: String) = apply { + permissions = + (permissions ?: JsonField.of(mutableListOf())).also { + checkKnown("permissions", it).add(permission) + } + } + + fun reachedMaxWorkspaces(reachedMaxWorkspaces: Boolean) = + reachedMaxWorkspaces(JsonField.of(reachedMaxWorkspaces)) + + /** + * Sets [Builder.reachedMaxWorkspaces] to an arbitrary JSON value. + * + * You should usually call [Builder.reachedMaxWorkspaces] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun reachedMaxWorkspaces(reachedMaxWorkspaces: JsonField<Boolean>) = apply { + this.reachedMaxWorkspaces = reachedMaxWorkspaces + } + + fun tier(tier: PaymentPlanTier?) = tier(JsonField.ofNullable(tier)) + + /** Alias for calling [Builder.tier] with `tier.orElse(null)`. */ + fun tier(tier: Optional<PaymentPlanTier>) = tier(tier.getOrNull()) + + /** + * Sets [Builder.tier] to an arbitrary JSON value. + * + * You should usually call [Builder.tier] with a well-typed [PaymentPlanTier] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tier(tier: JsonField<PaymentPlanTier>) = apply { this.tier = tier } + + /** Customer visible plan information. */ + fun upcomingPlan(upcomingPlan: CustomerVisiblePlanInfo?) = + upcomingPlan(JsonField.ofNullable(upcomingPlan)) + + /** Alias for calling [Builder.upcomingPlan] with `upcomingPlan.orElse(null)`. */ + fun upcomingPlan(upcomingPlan: Optional<CustomerVisiblePlanInfo>) = + upcomingPlan(upcomingPlan.getOrNull()) + + /** + * Sets [Builder.upcomingPlan] to an arbitrary JSON value. + * + * You should usually call [Builder.upcomingPlan] with a well-typed + * [CustomerVisiblePlanInfo] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun upcomingPlan(upcomingPlan: JsonField<CustomerVisiblePlanInfo>) = apply { + this.upcomingPlan = upcomingPlan + } + + fun wallet(wallet: Wallet?) = wallet(JsonField.ofNullable(wallet)) + + /** Alias for calling [Builder.wallet] with `wallet.orElse(null)`. */ + fun wallet(wallet: Optional<Wallet>) = wallet(wallet.getOrNull()) + + /** + * Sets [Builder.wallet] to an arbitrary JSON value. + * + * You should usually call [Builder.wallet] with a well-typed [Wallet] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun wallet(wallet: JsonField<Wallet>) = apply { this.wallet = wallet } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CurrentListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .config() + * .connectedToMetronome() + * .connectedToStripe() + * .hasCancelled() + * .isPersonal() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CurrentListResponse = + CurrentListResponse( + checkRequired("config", config), + checkRequired("connectedToMetronome", connectedToMetronome), + checkRequired("connectedToStripe", connectedToStripe), + checkRequired("hasCancelled", hasCancelled), + checkRequired("isPersonal", isPersonal), + id, + currentPlan, + defaultSsoProvision, + displayName, + endOfBillingPeriod, + marketplacePayoutsEnabled, + paymentMethod, + (permissions ?: JsonMissing.of()).map { it.toImmutable() }, + reachedMaxWorkspaces, + tier, + upcomingPlan, + wallet, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CurrentListResponse = apply { + if (validated) { + return@apply + } + + config().validate() + connectedToMetronome() + connectedToStripe() + hasCancelled() + isPersonal() + id() + currentPlan().ifPresent { it.validate() } + defaultSsoProvision() + displayName() + endOfBillingPeriod() + marketplacePayoutsEnabled() + paymentMethod().ifPresent { it.validate() } + permissions() + reachedMaxWorkspaces() + tier().ifPresent { it.validate() } + upcomingPlan().ifPresent { it.validate() } + wallet().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (config.asKnown().getOrNull()?.validity() ?: 0) + + (if (connectedToMetronome.asKnown().isPresent) 1 else 0) + + (if (connectedToStripe.asKnown().isPresent) 1 else 0) + + (if (hasCancelled.asKnown().isPresent) 1 else 0) + + (if (isPersonal.asKnown().isPresent) 1 else 0) + + (if (id.asKnown().isPresent) 1 else 0) + + (currentPlan.asKnown().getOrNull()?.validity() ?: 0) + + (if (defaultSsoProvision.asKnown().isPresent) 1 else 0) + + (if (displayName.asKnown().isPresent) 1 else 0) + + (if (endOfBillingPeriod.asKnown().isPresent) 1 else 0) + + (if (marketplacePayoutsEnabled.asKnown().isPresent) 1 else 0) + + (paymentMethod.asKnown().getOrNull()?.validity() ?: 0) + + (permissions.asKnown().getOrNull()?.size ?: 0) + + (if (reachedMaxWorkspaces.asKnown().isPresent) 1 else 0) + + (tier.asKnown().getOrNull()?.validity() ?: 0) + + (upcomingPlan.asKnown().getOrNull()?.validity() ?: 0) + + (wallet.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CurrentListResponse && + config == other.config && + connectedToMetronome == other.connectedToMetronome && + connectedToStripe == other.connectedToStripe && + hasCancelled == other.hasCancelled && + isPersonal == other.isPersonal && + id == other.id && + currentPlan == other.currentPlan && + defaultSsoProvision == other.defaultSsoProvision && + displayName == other.displayName && + endOfBillingPeriod == other.endOfBillingPeriod && + marketplacePayoutsEnabled == other.marketplacePayoutsEnabled && + paymentMethod == other.paymentMethod && + permissions == other.permissions && + reachedMaxWorkspaces == other.reachedMaxWorkspaces && + tier == other.tier && + upcomingPlan == other.upcomingPlan && + wallet == other.wallet && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + config, + connectedToMetronome, + connectedToStripe, + hasCancelled, + isPersonal, + id, + currentPlan, + defaultSsoProvision, + displayName, + endOfBillingPeriod, + marketplacePayoutsEnabled, + paymentMethod, + permissions, + reachedMaxWorkspaces, + tier, + upcomingPlan, + wallet, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CurrentListResponse{config=$config, connectedToMetronome=$connectedToMetronome, connectedToStripe=$connectedToStripe, hasCancelled=$hasCancelled, isPersonal=$isPersonal, id=$id, currentPlan=$currentPlan, defaultSsoProvision=$defaultSsoProvision, displayName=$displayName, endOfBillingPeriod=$endOfBillingPeriod, marketplacePayoutsEnabled=$marketplacePayoutsEnabled, paymentMethod=$paymentMethod, permissions=$permissions, reachedMaxWorkspaces=$reachedMaxWorkspaces, tier=$tier, upcomingPlan=$upcomingPlan, wallet=$wallet, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentPaymentMethodParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentPaymentMethodParams.kt new file mode 100644 index 00000000..21cbb856 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentPaymentMethodParams.kt @@ -0,0 +1,702 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** On Payment Method Created */ +class CurrentPaymentMethodParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Stripe customer billing information. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingInfo(): BillingInfo = body.billingInfo() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun setupIntent(): String = body.setupIntent() + + /** + * Returns the raw JSON value of [billingInfo]. + * + * Unlike [billingInfo], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _billingInfo(): JsonField<BillingInfo> = body._billingInfo() + + /** + * Returns the raw JSON value of [setupIntent]. + * + * Unlike [setupIntent], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _setupIntent(): JsonField<String> = body._setupIntent() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CurrentPaymentMethodParams]. + * + * The following fields are required: + * ```java + * .billingInfo() + * .setupIntent() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CurrentPaymentMethodParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(currentPaymentMethodParams: CurrentPaymentMethodParams) = apply { + body = currentPaymentMethodParams.body.toBuilder() + additionalHeaders = currentPaymentMethodParams.additionalHeaders.toBuilder() + additionalQueryParams = currentPaymentMethodParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [billingInfo] + * - [setupIntent] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** Stripe customer billing information. */ + fun billingInfo(billingInfo: BillingInfo) = apply { body.billingInfo(billingInfo) } + + /** + * Sets [Builder.billingInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.billingInfo] with a well-typed [BillingInfo] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingInfo(billingInfo: JsonField<BillingInfo>) = apply { + body.billingInfo(billingInfo) + } + + fun setupIntent(setupIntent: String) = apply { body.setupIntent(setupIntent) } + + /** + * Sets [Builder.setupIntent] to an arbitrary JSON value. + * + * You should usually call [Builder.setupIntent] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun setupIntent(setupIntent: JsonField<String>) = apply { body.setupIntent(setupIntent) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [CurrentPaymentMethodParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .billingInfo() + * .setupIntent() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CurrentPaymentMethodParams = + CurrentPaymentMethodParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Stripe payment information. */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val billingInfo: JsonField<BillingInfo>, + private val setupIntent: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("billing_info") + @ExcludeMissing + billingInfo: JsonField<BillingInfo> = JsonMissing.of(), + @JsonProperty("setup_intent") + @ExcludeMissing + setupIntent: JsonField<String> = JsonMissing.of(), + ) : this(billingInfo, setupIntent, mutableMapOf()) + + /** + * Stripe customer billing information. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingInfo(): BillingInfo = billingInfo.getRequired("billing_info") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun setupIntent(): String = setupIntent.getRequired("setup_intent") + + /** + * Returns the raw JSON value of [billingInfo]. + * + * Unlike [billingInfo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_info") + @ExcludeMissing + fun _billingInfo(): JsonField<BillingInfo> = billingInfo + + /** + * Returns the raw JSON value of [setupIntent]. + * + * Unlike [setupIntent], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("setup_intent") + @ExcludeMissing + fun _setupIntent(): JsonField<String> = setupIntent + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .billingInfo() + * .setupIntent() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var billingInfo: JsonField<BillingInfo>? = null + private var setupIntent: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + billingInfo = body.billingInfo + setupIntent = body.setupIntent + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** Stripe customer billing information. */ + fun billingInfo(billingInfo: BillingInfo) = billingInfo(JsonField.of(billingInfo)) + + /** + * Sets [Builder.billingInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.billingInfo] with a well-typed [BillingInfo] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingInfo(billingInfo: JsonField<BillingInfo>) = apply { + this.billingInfo = billingInfo + } + + fun setupIntent(setupIntent: String) = setupIntent(JsonField.of(setupIntent)) + + /** + * Sets [Builder.setupIntent] to an arbitrary JSON value. + * + * You should usually call [Builder.setupIntent] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun setupIntent(setupIntent: JsonField<String>) = apply { + this.setupIntent = setupIntent + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .billingInfo() + * .setupIntent() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("billingInfo", billingInfo), + checkRequired("setupIntent", setupIntent), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + billingInfo().validate() + setupIntent() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (billingInfo.asKnown().getOrNull()?.validity() ?: 0) + + (if (setupIntent.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + billingInfo == other.billingInfo && + setupIntent == other.setupIntent && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(billingInfo, setupIntent, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{billingInfo=$billingInfo, setupIntent=$setupIntent, additionalProperties=$additionalProperties}" + } + + /** Stripe customer billing information. */ + class BillingInfo + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val address: JsonField<StripeCustomerAddress>, + private val name: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("address") + @ExcludeMissing + address: JsonField<StripeCustomerAddress> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + ) : this(address, name, mutableMapOf()) + + /** + * Stripe customer address. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun address(): StripeCustomerAddress = address.getRequired("address") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [address]. + * + * Unlike [address], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("address") + @ExcludeMissing + fun _address(): JsonField<StripeCustomerAddress> = address + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BillingInfo]. + * + * The following fields are required: + * ```java + * .address() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BillingInfo]. */ + class Builder internal constructor() { + + private var address: JsonField<StripeCustomerAddress>? = null + private var name: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(billingInfo: BillingInfo) = apply { + address = billingInfo.address + name = billingInfo.name + additionalProperties = billingInfo.additionalProperties.toMutableMap() + } + + /** Stripe customer address. */ + fun address(address: StripeCustomerAddress) = address(JsonField.of(address)) + + /** + * Sets [Builder.address] to an arbitrary JSON value. + * + * You should usually call [Builder.address] with a well-typed [StripeCustomerAddress] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun address(address: JsonField<StripeCustomerAddress>) = apply { + this.address = address + } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BillingInfo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .address() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BillingInfo = + BillingInfo( + checkRequired("address", address), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BillingInfo = apply { + if (validated) { + return@apply + } + + address().validate() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (address.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingInfo && + address == other.address && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(address, name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BillingInfo{address=$address, name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CurrentPaymentMethodParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "CurrentPaymentMethodParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentPaymentMethodResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentPaymentMethodResponse.kt new file mode 100644 index 00000000..e59e2f91 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentPaymentMethodResponse.kt @@ -0,0 +1,118 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class CurrentPaymentMethodResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CurrentPaymentMethodResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CurrentPaymentMethodResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(currentPaymentMethodResponse: CurrentPaymentMethodResponse) = apply { + additionalProperties = currentPaymentMethodResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CurrentPaymentMethodResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CurrentPaymentMethodResponse = + CurrentPaymentMethodResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): CurrentPaymentMethodResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CurrentPaymentMethodResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CurrentPaymentMethodResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentPlanParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentPlanParams.kt new file mode 100644 index 00000000..22512ceb --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentPlanParams.kt @@ -0,0 +1,592 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +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.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** Change Payment Plan */ +class CurrentPlanParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Enum for payment plans that the user can change to. Developer plans are permanent and + * enterprise plans will be changed manually. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tier(): Tier = body.tier() + + /** + * Returns the raw JSON value of [tier]. + * + * Unlike [tier], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _tier(): JsonField<Tier> = body._tier() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CurrentPlanParams]. + * + * The following fields are required: + * ```java + * .tier() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CurrentPlanParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(currentPlanParams: CurrentPlanParams) = apply { + body = currentPlanParams.body.toBuilder() + additionalHeaders = currentPlanParams.additionalHeaders.toBuilder() + additionalQueryParams = currentPlanParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [tier] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * Enum for payment plans that the user can change to. Developer plans are permanent and + * enterprise plans will be changed manually. + */ + fun tier(tier: Tier) = apply { body.tier(tier) } + + /** + * Sets [Builder.tier] to an arbitrary JSON value. + * + * You should usually call [Builder.tier] with a well-typed [Tier] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tier(tier: JsonField<Tier>) = apply { body.tier(tier) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [CurrentPlanParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tier() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CurrentPlanParams = + CurrentPlanParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Change payment plan schema. */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tier: JsonField<Tier>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier") @ExcludeMissing tier: JsonField<Tier> = JsonMissing.of() + ) : this(tier, mutableMapOf()) + + /** + * Enum for payment plans that the user can change to. Developer plans are permanent and + * enterprise plans will be changed manually. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tier(): Tier = tier.getRequired("tier") + + /** + * Returns the raw JSON value of [tier]. + * + * Unlike [tier], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tier") @ExcludeMissing fun _tier(): JsonField<Tier> = tier + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .tier() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var tier: JsonField<Tier>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + tier = body.tier + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * Enum for payment plans that the user can change to. Developer plans are permanent and + * enterprise plans will be changed manually. + */ + fun tier(tier: Tier) = tier(JsonField.of(tier)) + + /** + * Sets [Builder.tier] to an arbitrary JSON value. + * + * You should usually call [Builder.tier] with a well-typed [Tier] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tier(tier: JsonField<Tier>) = apply { this.tier = tier } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tier() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body(checkRequired("tier", tier), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + tier().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (tier.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + tier == other.tier && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tier, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Body{tier=$tier, additionalProperties=$additionalProperties}" + } + + /** + * Enum for payment plans that the user can change to. Developer plans are permanent and + * enterprise plans will be changed manually. + */ + class Tier @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val DISABLED = of("disabled") + + @JvmField val DEVELOPER = of("developer") + + @JvmField val PLUS = of("plus") + + @JvmField val STARTUP = of("startup") + + @JvmField val STARTUP_V0 = of("startup_v0") + + @JvmField val PARTNER = of("partner") + + @JvmField val PREMIER = of("premier") + + @JvmField val FREE = of("free") + + @JvmStatic fun of(value: String) = Tier(JsonField.of(value)) + } + + /** An enum containing [Tier]'s known values. */ + enum class Known { + DISABLED, + DEVELOPER, + PLUS, + STARTUP, + STARTUP_V0, + PARTNER, + PREMIER, + FREE, + } + + /** + * An enum containing [Tier]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Tier] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + DISABLED, + DEVELOPER, + PLUS, + STARTUP, + STARTUP_V0, + PARTNER, + PREMIER, + FREE, + /** An enum member indicating that [Tier] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + DISABLED -> Value.DISABLED + DEVELOPER -> Value.DEVELOPER + PLUS -> Value.PLUS + STARTUP -> Value.STARTUP + STARTUP_V0 -> Value.STARTUP_V0 + PARTNER -> Value.PARTNER + PREMIER -> Value.PREMIER + FREE -> Value.FREE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + DISABLED -> Known.DISABLED + DEVELOPER -> Known.DEVELOPER + PLUS -> Known.PLUS + STARTUP -> Known.STARTUP + STARTUP_V0 -> Known.STARTUP_V0 + PARTNER -> Known.PARTNER + PREMIER -> Known.PREMIER + FREE -> Known.FREE + else -> throw LangsmithApiInvalidDataException("Unknown Tier: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CurrentPlanParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "CurrentPlanParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentPlanResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentPlanResponse.kt new file mode 100644 index 00000000..d2be6936 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentPlanResponse.kt @@ -0,0 +1,113 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class CurrentPlanResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [CurrentPlanResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CurrentPlanResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(currentPlanResponse: CurrentPlanResponse) = apply { + additionalProperties = currentPlanResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CurrentPlanResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CurrentPlanResponse = CurrentPlanResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): CurrentPlanResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CurrentPlanResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "CurrentPlanResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentRetrieveDashboardParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentRetrieveDashboardParams.kt new file mode 100644 index 00000000..c830d3b3 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentRetrieveDashboardParams.kt @@ -0,0 +1,491 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get Dashboard */ +class CurrentRetrieveDashboardParams +private constructor( + private val colorScheme: ColorScheme?, + private val type: Type, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Enum for acceptable color schemes of dashboards. */ + fun colorScheme(): Optional<ColorScheme> = Optional.ofNullable(colorScheme) + + /** Enum for acceptable types of dashboards. */ + fun type(): Type = type + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CurrentRetrieveDashboardParams]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CurrentRetrieveDashboardParams]. */ + class Builder internal constructor() { + + private var colorScheme: ColorScheme? = null + private var type: Type? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(currentRetrieveDashboardParams: CurrentRetrieveDashboardParams) = apply { + colorScheme = currentRetrieveDashboardParams.colorScheme + type = currentRetrieveDashboardParams.type + additionalHeaders = currentRetrieveDashboardParams.additionalHeaders.toBuilder() + additionalQueryParams = currentRetrieveDashboardParams.additionalQueryParams.toBuilder() + } + + /** Enum for acceptable color schemes of dashboards. */ + fun colorScheme(colorScheme: ColorScheme?) = apply { this.colorScheme = colorScheme } + + /** Alias for calling [Builder.colorScheme] with `colorScheme.orElse(null)`. */ + fun colorScheme(colorScheme: Optional<ColorScheme>) = colorScheme(colorScheme.getOrNull()) + + /** Enum for acceptable types of dashboards. */ + fun type(type: Type) = apply { this.type = type } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [CurrentRetrieveDashboardParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CurrentRetrieveDashboardParams = + CurrentRetrieveDashboardParams( + colorScheme, + checkRequired("type", type), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + colorScheme?.let { put("color_scheme", it.toString()) } + put("type", type.toString()) + putAll(additionalQueryParams) + } + .build() + + /** Enum for acceptable color schemes of dashboards. */ + class ColorScheme @JsonCreator private constructor(private val value: JsonField<String>) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val LIGHT = of("light") + + @JvmField val DARK = of("dark") + + @JvmStatic fun of(value: String) = ColorScheme(JsonField.of(value)) + } + + /** An enum containing [ColorScheme]'s known values. */ + enum class Known { + LIGHT, + DARK, + } + + /** + * An enum containing [ColorScheme]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ColorScheme] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LIGHT, + DARK, + /** + * An enum member indicating that [ColorScheme] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LIGHT -> Value.LIGHT + DARK -> Value.DARK + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + LIGHT -> Known.LIGHT + DARK -> Known.DARK + else -> throw LangsmithApiInvalidDataException("Unknown ColorScheme: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ColorScheme = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ColorScheme && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Enum for acceptable types of dashboards. */ + class Type @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val INVOICES = of("invoices") + + @JvmField val USAGE = of("usage") + + @JvmField val CREDITS = of("credits") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + INVOICES, + USAGE, + CREDITS, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INVOICES, + USAGE, + CREDITS, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INVOICES -> Value.INVOICES + USAGE -> Value.USAGE + CREDITS -> Value.CREDITS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INVOICES -> Known.INVOICES + USAGE -> Known.USAGE + CREDITS -> Known.CREDITS + else -> throw LangsmithApiInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CurrentRetrieveDashboardParams && + colorScheme == other.colorScheme && + type == other.type && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(colorScheme, type, additionalHeaders, additionalQueryParams) + + override fun toString() = + "CurrentRetrieveDashboardParams{colorScheme=$colorScheme, type=$type, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentRetrieveDashboardResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentRetrieveDashboardResponse.kt new file mode 100644 index 00000000..835bcd54 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentRetrieveDashboardResponse.kt @@ -0,0 +1,181 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +/** Organization dashboard for usage or invoices. */ +class CurrentRetrieveDashboardResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val embeddableUrl: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("embeddable_url") + @ExcludeMissing + embeddableUrl: JsonField<String> = JsonMissing.of() + ) : this(embeddableUrl, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun embeddableUrl(): String = embeddableUrl.getRequired("embeddable_url") + + /** + * Returns the raw JSON value of [embeddableUrl]. + * + * Unlike [embeddableUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("embeddable_url") + @ExcludeMissing + fun _embeddableUrl(): JsonField<String> = embeddableUrl + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CurrentRetrieveDashboardResponse]. + * + * The following fields are required: + * ```java + * .embeddableUrl() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CurrentRetrieveDashboardResponse]. */ + class Builder internal constructor() { + + private var embeddableUrl: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(currentRetrieveDashboardResponse: CurrentRetrieveDashboardResponse) = + apply { + embeddableUrl = currentRetrieveDashboardResponse.embeddableUrl + additionalProperties = + currentRetrieveDashboardResponse.additionalProperties.toMutableMap() + } + + fun embeddableUrl(embeddableUrl: String) = embeddableUrl(JsonField.of(embeddableUrl)) + + /** + * Sets [Builder.embeddableUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.embeddableUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun embeddableUrl(embeddableUrl: JsonField<String>) = apply { + this.embeddableUrl = embeddableUrl + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CurrentRetrieveDashboardResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .embeddableUrl() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CurrentRetrieveDashboardResponse = + CurrentRetrieveDashboardResponse( + checkRequired("embeddableUrl", embeddableUrl), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CurrentRetrieveDashboardResponse = apply { + if (validated) { + return@apply + } + + embeddableUrl() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (embeddableUrl.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CurrentRetrieveDashboardResponse && + embeddableUrl == other.embeddableUrl && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(embeddableUrl, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CurrentRetrieveDashboardResponse{embeddableUrl=$embeddableUrl, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentSetDefaultSsoProvisionParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentSetDefaultSsoProvisionParams.kt new file mode 100644 index 00000000..0b9c3800 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentSetDefaultSsoProvisionParams.kt @@ -0,0 +1,217 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional + +/** Set the current organization as the default for SSO provisioning in self-hosted environments. */ +class CurrentSetDefaultSsoProvisionParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): CurrentSetDefaultSsoProvisionParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [CurrentSetDefaultSsoProvisionParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CurrentSetDefaultSsoProvisionParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from( + currentSetDefaultSsoProvisionParams: CurrentSetDefaultSsoProvisionParams + ) = apply { + additionalHeaders = currentSetDefaultSsoProvisionParams.additionalHeaders.toBuilder() + additionalQueryParams = + currentSetDefaultSsoProvisionParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + currentSetDefaultSsoProvisionParams.additionalBodyProperties.toMutableMap() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [CurrentSetDefaultSsoProvisionParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CurrentSetDefaultSsoProvisionParams = + CurrentSetDefaultSsoProvisionParams( + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CurrentSetDefaultSsoProvisionParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "CurrentSetDefaultSsoProvisionParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentSetDefaultSsoProvisionResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentSetDefaultSsoProvisionResponse.kt new file mode 100644 index 00000000..0aa69072 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentSetDefaultSsoProvisionResponse.kt @@ -0,0 +1,122 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class CurrentSetDefaultSsoProvisionResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CurrentSetDefaultSsoProvisionResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CurrentSetDefaultSsoProvisionResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from( + currentSetDefaultSsoProvisionResponse: CurrentSetDefaultSsoProvisionResponse + ) = apply { + additionalProperties = + currentSetDefaultSsoProvisionResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CurrentSetDefaultSsoProvisionResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CurrentSetDefaultSsoProvisionResponse = + CurrentSetDefaultSsoProvisionResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): CurrentSetDefaultSsoProvisionResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CurrentSetDefaultSsoProvisionResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CurrentSetDefaultSsoProvisionResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentSetupParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentSetupParams.kt new file mode 100644 index 00000000..a1a78a44 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentSetupParams.kt @@ -0,0 +1,210 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional + +/** Create Customers And Get Stripe Setup Intent */ +class CurrentSetupParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): CurrentSetupParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [CurrentSetupParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CurrentSetupParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(currentSetupParams: CurrentSetupParams) = apply { + additionalHeaders = currentSetupParams.additionalHeaders.toBuilder() + additionalQueryParams = currentSetupParams.additionalQueryParams.toBuilder() + additionalBodyProperties = currentSetupParams.additionalBodyProperties.toMutableMap() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [CurrentSetupParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CurrentSetupParams = + CurrentSetupParams( + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CurrentSetupParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "CurrentSetupParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentSetupResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentSetupResponse.kt new file mode 100644 index 00000000..b96f1507 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentSetupResponse.kt @@ -0,0 +1,178 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +/** Stripe setup intent response. */ +class CurrentSetupResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val clientSecret: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("client_secret") + @ExcludeMissing + clientSecret: JsonField<String> = JsonMissing.of() + ) : this(clientSecret, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun clientSecret(): String = clientSecret.getRequired("client_secret") + + /** + * Returns the raw JSON value of [clientSecret]. + * + * Unlike [clientSecret], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("client_secret") + @ExcludeMissing + fun _clientSecret(): JsonField<String> = clientSecret + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CurrentSetupResponse]. + * + * The following fields are required: + * ```java + * .clientSecret() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CurrentSetupResponse]. */ + class Builder internal constructor() { + + private var clientSecret: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(currentSetupResponse: CurrentSetupResponse) = apply { + clientSecret = currentSetupResponse.clientSecret + additionalProperties = currentSetupResponse.additionalProperties.toMutableMap() + } + + fun clientSecret(clientSecret: String) = clientSecret(JsonField.of(clientSecret)) + + /** + * Sets [Builder.clientSecret] to an arbitrary JSON value. + * + * You should usually call [Builder.clientSecret] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun clientSecret(clientSecret: JsonField<String>) = apply { + this.clientSecret = clientSecret + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CurrentSetupResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .clientSecret() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CurrentSetupResponse = + CurrentSetupResponse( + checkRequired("clientSecret", clientSecret), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CurrentSetupResponse = apply { + if (validated) { + return@apply + } + + clientSecret() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (clientSecret.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CurrentSetupResponse && + clientSecret == other.clientSecret && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(clientSecret, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CurrentSetupResponse{clientSecret=$clientSecret, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentStripeAccountLinksParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentStripeAccountLinksParams.kt new file mode 100644 index 00000000..574e54af --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentStripeAccountLinksParams.kt @@ -0,0 +1,419 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +/** Kick off a Stripe account link flow. */ +class CurrentStripeAccountLinksParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun successPath(): String = body.successPath() + + /** + * Returns the raw JSON value of [successPath]. + * + * Unlike [successPath], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _successPath(): JsonField<String> = body._successPath() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CurrentStripeAccountLinksParams]. + * + * The following fields are required: + * ```java + * .successPath() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CurrentStripeAccountLinksParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(currentStripeAccountLinksParams: CurrentStripeAccountLinksParams) = + apply { + body = currentStripeAccountLinksParams.body.toBuilder() + additionalHeaders = currentStripeAccountLinksParams.additionalHeaders.toBuilder() + additionalQueryParams = + currentStripeAccountLinksParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [successPath] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun successPath(successPath: String) = apply { body.successPath(successPath) } + + /** + * Sets [Builder.successPath] to an arbitrary JSON value. + * + * You should usually call [Builder.successPath] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun successPath(successPath: JsonField<String>) = apply { body.successPath(successPath) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [CurrentStripeAccountLinksParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .successPath() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CurrentStripeAccountLinksParams = + CurrentStripeAccountLinksParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val successPath: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("success_path") + @ExcludeMissing + successPath: JsonField<String> = JsonMissing.of() + ) : this(successPath, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun successPath(): String = successPath.getRequired("success_path") + + /** + * Returns the raw JSON value of [successPath]. + * + * Unlike [successPath], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("success_path") + @ExcludeMissing + fun _successPath(): JsonField<String> = successPath + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .successPath() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var successPath: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + successPath = body.successPath + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun successPath(successPath: String) = successPath(JsonField.of(successPath)) + + /** + * Sets [Builder.successPath] to an arbitrary JSON value. + * + * You should usually call [Builder.successPath] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun successPath(successPath: JsonField<String>) = apply { + this.successPath = successPath + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .successPath() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body(checkRequired("successPath", successPath), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + successPath() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (successPath.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + successPath == other.successPath && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(successPath, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{successPath=$successPath, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CurrentStripeAccountLinksParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "CurrentStripeAccountLinksParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentStripeAccountLinksResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentStripeAccountLinksResponse.kt new file mode 100644 index 00000000..cd98fc52 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentStripeAccountLinksResponse.kt @@ -0,0 +1,121 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class CurrentStripeAccountLinksResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CurrentStripeAccountLinksResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CurrentStripeAccountLinksResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(currentStripeAccountLinksResponse: CurrentStripeAccountLinksResponse) = + apply { + additionalProperties = + currentStripeAccountLinksResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CurrentStripeAccountLinksResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CurrentStripeAccountLinksResponse = + CurrentStripeAccountLinksResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): CurrentStripeAccountLinksResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CurrentStripeAccountLinksResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CurrentStripeAccountLinksResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentStripeCheckoutSessionParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentStripeCheckoutSessionParams.kt new file mode 100644 index 00000000..5df984fa --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentStripeCheckoutSessionParams.kt @@ -0,0 +1,491 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +/** Kick off a Stripe checkout session flow. */ +class CurrentStripeCheckoutSessionParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun amountCents(): Long = body.amountCents() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun successPath(): String = body.successPath() + + /** + * Returns the raw JSON value of [amountCents]. + * + * Unlike [amountCents], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _amountCents(): JsonField<Long> = body._amountCents() + + /** + * Returns the raw JSON value of [successPath]. + * + * Unlike [successPath], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _successPath(): JsonField<String> = body._successPath() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CurrentStripeCheckoutSessionParams]. + * + * The following fields are required: + * ```java + * .amountCents() + * .successPath() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CurrentStripeCheckoutSessionParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(currentStripeCheckoutSessionParams: CurrentStripeCheckoutSessionParams) = + apply { + body = currentStripeCheckoutSessionParams.body.toBuilder() + additionalHeaders = currentStripeCheckoutSessionParams.additionalHeaders.toBuilder() + additionalQueryParams = + currentStripeCheckoutSessionParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [amountCents] + * - [successPath] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun amountCents(amountCents: Long) = apply { body.amountCents(amountCents) } + + /** + * Sets [Builder.amountCents] to an arbitrary JSON value. + * + * You should usually call [Builder.amountCents] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun amountCents(amountCents: JsonField<Long>) = apply { body.amountCents(amountCents) } + + fun successPath(successPath: String) = apply { body.successPath(successPath) } + + /** + * Sets [Builder.successPath] to an arbitrary JSON value. + * + * You should usually call [Builder.successPath] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun successPath(successPath: JsonField<String>) = apply { body.successPath(successPath) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [CurrentStripeCheckoutSessionParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amountCents() + * .successPath() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CurrentStripeCheckoutSessionParams = + CurrentStripeCheckoutSessionParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amountCents: JsonField<Long>, + private val successPath: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount_cents") + @ExcludeMissing + amountCents: JsonField<Long> = JsonMissing.of(), + @JsonProperty("success_path") + @ExcludeMissing + successPath: JsonField<String> = JsonMissing.of(), + ) : this(amountCents, successPath, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun amountCents(): Long = amountCents.getRequired("amount_cents") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun successPath(): String = successPath.getRequired("success_path") + + /** + * Returns the raw JSON value of [amountCents]. + * + * Unlike [amountCents], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount_cents") + @ExcludeMissing + fun _amountCents(): JsonField<Long> = amountCents + + /** + * Returns the raw JSON value of [successPath]. + * + * Unlike [successPath], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("success_path") + @ExcludeMissing + fun _successPath(): JsonField<String> = successPath + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .amountCents() + * .successPath() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var amountCents: JsonField<Long>? = null + private var successPath: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + amountCents = body.amountCents + successPath = body.successPath + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun amountCents(amountCents: Long) = amountCents(JsonField.of(amountCents)) + + /** + * Sets [Builder.amountCents] to an arbitrary JSON value. + * + * You should usually call [Builder.amountCents] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun amountCents(amountCents: JsonField<Long>) = apply { this.amountCents = amountCents } + + fun successPath(successPath: String) = successPath(JsonField.of(successPath)) + + /** + * Sets [Builder.successPath] to an arbitrary JSON value. + * + * You should usually call [Builder.successPath] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun successPath(successPath: JsonField<String>) = apply { + this.successPath = successPath + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amountCents() + * .successPath() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("amountCents", amountCents), + checkRequired("successPath", successPath), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + amountCents() + successPath() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amountCents.asKnown().isPresent) 1 else 0) + + (if (successPath.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + amountCents == other.amountCents && + successPath == other.successPath && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amountCents, successPath, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{amountCents=$amountCents, successPath=$successPath, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CurrentStripeCheckoutSessionParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "CurrentStripeCheckoutSessionParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentStripeCheckoutSessionResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentStripeCheckoutSessionResponse.kt new file mode 100644 index 00000000..0d8345bb --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentStripeCheckoutSessionResponse.kt @@ -0,0 +1,122 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class CurrentStripeCheckoutSessionResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CurrentStripeCheckoutSessionResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CurrentStripeCheckoutSessionResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from( + currentStripeCheckoutSessionResponse: CurrentStripeCheckoutSessionResponse + ) = apply { + additionalProperties = + currentStripeCheckoutSessionResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CurrentStripeCheckoutSessionResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CurrentStripeCheckoutSessionResponse = + CurrentStripeCheckoutSessionResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): CurrentStripeCheckoutSessionResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CurrentStripeCheckoutSessionResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CurrentStripeCheckoutSessionResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentUpdateLoginMethodsParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentUpdateLoginMethodsParams.kt new file mode 100644 index 00000000..761bddd4 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentUpdateLoginMethodsParams.kt @@ -0,0 +1,412 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +/** Update allowed login methods for the current organization. */ +class CurrentUpdateLoginMethodsParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun ssoOnly(): Boolean = body.ssoOnly() + + /** + * Returns the raw JSON value of [ssoOnly]. + * + * Unlike [ssoOnly], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _ssoOnly(): JsonField<Boolean> = body._ssoOnly() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CurrentUpdateLoginMethodsParams]. + * + * The following fields are required: + * ```java + * .ssoOnly() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CurrentUpdateLoginMethodsParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(currentUpdateLoginMethodsParams: CurrentUpdateLoginMethodsParams) = + apply { + body = currentUpdateLoginMethodsParams.body.toBuilder() + additionalHeaders = currentUpdateLoginMethodsParams.additionalHeaders.toBuilder() + additionalQueryParams = + currentUpdateLoginMethodsParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [ssoOnly] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun ssoOnly(ssoOnly: Boolean) = apply { body.ssoOnly(ssoOnly) } + + /** + * Sets [Builder.ssoOnly] to an arbitrary JSON value. + * + * You should usually call [Builder.ssoOnly] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun ssoOnly(ssoOnly: JsonField<Boolean>) = apply { body.ssoOnly(ssoOnly) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [CurrentUpdateLoginMethodsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .ssoOnly() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CurrentUpdateLoginMethodsParams = + CurrentUpdateLoginMethodsParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val ssoOnly: JsonField<Boolean>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("sso_only") @ExcludeMissing ssoOnly: JsonField<Boolean> = JsonMissing.of() + ) : this(ssoOnly, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun ssoOnly(): Boolean = ssoOnly.getRequired("sso_only") + + /** + * Returns the raw JSON value of [ssoOnly]. + * + * Unlike [ssoOnly], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sso_only") @ExcludeMissing fun _ssoOnly(): JsonField<Boolean> = ssoOnly + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .ssoOnly() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var ssoOnly: JsonField<Boolean>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + ssoOnly = body.ssoOnly + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun ssoOnly(ssoOnly: Boolean) = ssoOnly(JsonField.of(ssoOnly)) + + /** + * Sets [Builder.ssoOnly] to an arbitrary JSON value. + * + * You should usually call [Builder.ssoOnly] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun ssoOnly(ssoOnly: JsonField<Boolean>) = apply { this.ssoOnly = ssoOnly } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .ssoOnly() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body(checkRequired("ssoOnly", ssoOnly), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + ssoOnly() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (ssoOnly.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + ssoOnly == other.ssoOnly && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(ssoOnly, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{ssoOnly=$ssoOnly, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CurrentUpdateLoginMethodsParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "CurrentUpdateLoginMethodsParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentUpdateLoginMethodsResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentUpdateLoginMethodsResponse.kt new file mode 100644 index 00000000..22930a8f --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentUpdateLoginMethodsResponse.kt @@ -0,0 +1,121 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class CurrentUpdateLoginMethodsResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CurrentUpdateLoginMethodsResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CurrentUpdateLoginMethodsResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(currentUpdateLoginMethodsResponse: CurrentUpdateLoginMethodsResponse) = + apply { + additionalProperties = + currentUpdateLoginMethodsResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CurrentUpdateLoginMethodsResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CurrentUpdateLoginMethodsResponse = + CurrentUpdateLoginMethodsResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): CurrentUpdateLoginMethodsResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CurrentUpdateLoginMethodsResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CurrentUpdateLoginMethodsResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CustomerVisiblePlanInfo.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CustomerVisiblePlanInfo.kt new file mode 100644 index 00000000..1bcbb563 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CustomerVisiblePlanInfo.kt @@ -0,0 +1,255 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.orgs.PaymentPlanTier +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Customer visible plan information. */ +class CustomerVisiblePlanInfo +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val startedOn: JsonField<OffsetDateTime>, + private val tier: JsonField<PaymentPlanTier>, + private val endsOn: JsonField<OffsetDateTime>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("started_on") + @ExcludeMissing + startedOn: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("tier") @ExcludeMissing tier: JsonField<PaymentPlanTier> = JsonMissing.of(), + @JsonProperty("ends_on") + @ExcludeMissing + endsOn: JsonField<OffsetDateTime> = JsonMissing.of(), + ) : this(startedOn, tier, endsOn, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun startedOn(): OffsetDateTime = startedOn.getRequired("started_on") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tier(): PaymentPlanTier = tier.getRequired("tier") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endsOn(): Optional<OffsetDateTime> = endsOn.getOptional("ends_on") + + /** + * Returns the raw JSON value of [startedOn]. + * + * Unlike [startedOn], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("started_on") + @ExcludeMissing + fun _startedOn(): JsonField<OffsetDateTime> = startedOn + + /** + * Returns the raw JSON value of [tier]. + * + * Unlike [tier], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tier") @ExcludeMissing fun _tier(): JsonField<PaymentPlanTier> = tier + + /** + * Returns the raw JSON value of [endsOn]. + * + * Unlike [endsOn], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ends_on") @ExcludeMissing fun _endsOn(): JsonField<OffsetDateTime> = endsOn + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CustomerVisiblePlanInfo]. + * + * The following fields are required: + * ```java + * .startedOn() + * .tier() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomerVisiblePlanInfo]. */ + class Builder internal constructor() { + + private var startedOn: JsonField<OffsetDateTime>? = null + private var tier: JsonField<PaymentPlanTier>? = null + private var endsOn: JsonField<OffsetDateTime> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(customerVisiblePlanInfo: CustomerVisiblePlanInfo) = apply { + startedOn = customerVisiblePlanInfo.startedOn + tier = customerVisiblePlanInfo.tier + endsOn = customerVisiblePlanInfo.endsOn + additionalProperties = customerVisiblePlanInfo.additionalProperties.toMutableMap() + } + + fun startedOn(startedOn: OffsetDateTime) = startedOn(JsonField.of(startedOn)) + + /** + * Sets [Builder.startedOn] to an arbitrary JSON value. + * + * You should usually call [Builder.startedOn] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startedOn(startedOn: JsonField<OffsetDateTime>) = apply { this.startedOn = startedOn } + + fun tier(tier: PaymentPlanTier) = tier(JsonField.of(tier)) + + /** + * Sets [Builder.tier] to an arbitrary JSON value. + * + * You should usually call [Builder.tier] with a well-typed [PaymentPlanTier] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tier(tier: JsonField<PaymentPlanTier>) = apply { this.tier = tier } + + fun endsOn(endsOn: OffsetDateTime?) = endsOn(JsonField.ofNullable(endsOn)) + + /** Alias for calling [Builder.endsOn] with `endsOn.orElse(null)`. */ + fun endsOn(endsOn: Optional<OffsetDateTime>) = endsOn(endsOn.getOrNull()) + + /** + * Sets [Builder.endsOn] to an arbitrary JSON value. + * + * You should usually call [Builder.endsOn] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endsOn(endsOn: JsonField<OffsetDateTime>) = apply { this.endsOn = endsOn } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomerVisiblePlanInfo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .startedOn() + * .tier() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomerVisiblePlanInfo = + CustomerVisiblePlanInfo( + checkRequired("startedOn", startedOn), + checkRequired("tier", tier), + endsOn, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CustomerVisiblePlanInfo = apply { + if (validated) { + return@apply + } + + startedOn() + tier().validate() + endsOn() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (startedOn.asKnown().isPresent) 1 else 0) + + (tier.asKnown().getOrNull()?.validity() ?: 0) + + (if (endsOn.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomerVisiblePlanInfo && + startedOn == other.startedOn && + tier == other.tier && + endsOn == other.endsOn && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(startedOn, tier, endsOn, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomerVisiblePlanInfo{startedOn=$startedOn, tier=$tier, endsOn=$endsOn, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/OrganizationConfig.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/OrganizationConfig.kt new file mode 100644 index 00000000..6bda3322 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/OrganizationConfig.kt @@ -0,0 +1,2417 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Organization level configuration. May include any field that exists in tenant config and + * additional fields. + */ +class OrganizationConfig +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val allowCustomIframes: JsonField<Boolean>, + private val canAddSeats: JsonField<Boolean>, + private val canDisablePublicSharing: JsonField<Boolean>, + private val canServeDatasets: JsonField<Boolean>, + private val canUseAbac: JsonField<Boolean>, + private val canUseAgentBuilder: JsonField<Boolean>, + private val canUseBulkExport: JsonField<Boolean>, + private val canUseLanggraphCloud: JsonField<Boolean>, + private val canUseRbac: JsonField<Boolean>, + private val canUseSamlSso: JsonField<Boolean>, + private val clioEnabled: JsonField<Boolean>, + private val datadogRumSessionSampleRate: JsonField<Long>, + private val demoLgpNewGraphEnabled: JsonField<Boolean>, + private val enableAlignEvaluators: JsonField<Boolean>, + private val enableIncludeExtendedStats: JsonField<Boolean>, + private val enableLanggraphPricing: JsonField<Boolean>, + private val enableLgpListenersPage: JsonField<Boolean>, + private val enableMarkdownInTracing: JsonField<Boolean>, + private val enableMonthlyUsageCharts: JsonField<Boolean>, + private val enableOrgUsageCharts: JsonField<Boolean>, + private val enablePricingRedesign: JsonField<Boolean>, + private val enableQueryingV2Endpoints: JsonField<Boolean>, + private val enableRunTreeStreaming: JsonField<Boolean>, + private val enableThreadViewPlayground: JsonField<Boolean>, + private val enableThreadsImprovements: JsonField<Boolean>, + private val kvDatasetMessageSupport: JsonField<Boolean>, + private val langgraphDeployOwnCloudEnabled: JsonField<Boolean>, + private val langgraphEnterpriseEnabled: JsonField<Boolean>, + private val langgraphRemoteReconcilerEnabled: JsonField<Boolean>, + private val langsmithAlertsLegacyPocEnabled: JsonField<Boolean>, + private val langsmithAlertsPocEnabled: JsonField<Boolean>, + private val langsmithExperimentalSearchEnabled: JsonField<Boolean>, + private val lgpTemplatesEnabled: JsonField<Boolean>, + private val maxFreeLanggraphCloudDeployments: JsonField<Long>, + private val maxIdentities: JsonField<Long>, + private val maxLanggraphCloudDeployments: JsonField<Long>, + private val maxPromptWebhooks: JsonField<Long>, + private val maxThreadEvaluatorsPerTenant: JsonField<Long>, + private val maxWorkspaces: JsonField<Long>, + private val newRuleEvaluatorCreationVersion: JsonField<Long>, + private val partnerPlanApprovalDate: JsonField<String>, + private val playgroundEvaluatorStrategy: JsonField<String>, + private val premierPlanApprovalDate: JsonField<String>, + private val promptOptimizationJobsEnabled: JsonField<Boolean>, + private val requireCodeEvaluatorLanguageField: JsonField<Boolean>, + private val showPlaygroundPromptCanvas: JsonField<Boolean>, + private val showUpdatedResourceTags: JsonField<Boolean>, + private val showUpdatedSidenav: JsonField<Boolean>, + private val startupPlanApprovalDate: JsonField<String>, + private val tenantSkipTopkFacets: JsonField<Boolean>, + private val threadEvaluatorsEnabled: JsonField<Boolean>, + private val useExactSearchForPrompts: JsonField<Boolean>, + private val usePythonPlaygroundService: JsonField<Boolean>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("allow_custom_iframes") + @ExcludeMissing + allowCustomIframes: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("can_add_seats") + @ExcludeMissing + canAddSeats: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("can_disable_public_sharing") + @ExcludeMissing + canDisablePublicSharing: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("can_serve_datasets") + @ExcludeMissing + canServeDatasets: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("can_use_abac") + @ExcludeMissing + canUseAbac: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("can_use_agent_builder") + @ExcludeMissing + canUseAgentBuilder: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("can_use_bulk_export") + @ExcludeMissing + canUseBulkExport: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("can_use_langgraph_cloud") + @ExcludeMissing + canUseLanggraphCloud: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("can_use_rbac") + @ExcludeMissing + canUseRbac: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("can_use_saml_sso") + @ExcludeMissing + canUseSamlSso: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("clio_enabled") + @ExcludeMissing + clioEnabled: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("datadog_rum_session_sample_rate") + @ExcludeMissing + datadogRumSessionSampleRate: JsonField<Long> = JsonMissing.of(), + @JsonProperty("demo_lgp_new_graph_enabled") + @ExcludeMissing + demoLgpNewGraphEnabled: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("enable_align_evaluators") + @ExcludeMissing + enableAlignEvaluators: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("enable_include_extended_stats") + @ExcludeMissing + enableIncludeExtendedStats: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("enable_langgraph_pricing") + @ExcludeMissing + enableLanggraphPricing: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("enable_lgp_listeners_page") + @ExcludeMissing + enableLgpListenersPage: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("enable_markdown_in_tracing") + @ExcludeMissing + enableMarkdownInTracing: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("enable_monthly_usage_charts") + @ExcludeMissing + enableMonthlyUsageCharts: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("enable_org_usage_charts") + @ExcludeMissing + enableOrgUsageCharts: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("enable_pricing_redesign") + @ExcludeMissing + enablePricingRedesign: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("enable_querying_v2_endpoints") + @ExcludeMissing + enableQueryingV2Endpoints: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("enable_run_tree_streaming") + @ExcludeMissing + enableRunTreeStreaming: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("enable_thread_view_playground") + @ExcludeMissing + enableThreadViewPlayground: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("enable_threads_improvements") + @ExcludeMissing + enableThreadsImprovements: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("kv_dataset_message_support") + @ExcludeMissing + kvDatasetMessageSupport: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("langgraph_deploy_own_cloud_enabled") + @ExcludeMissing + langgraphDeployOwnCloudEnabled: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("langgraph_enterprise_enabled") + @ExcludeMissing + langgraphEnterpriseEnabled: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("langgraph_remote_reconciler_enabled") + @ExcludeMissing + langgraphRemoteReconcilerEnabled: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("langsmith_alerts_legacy_poc_enabled") + @ExcludeMissing + langsmithAlertsLegacyPocEnabled: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("langsmith_alerts_poc_enabled") + @ExcludeMissing + langsmithAlertsPocEnabled: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("langsmith_experimental_search_enabled") + @ExcludeMissing + langsmithExperimentalSearchEnabled: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("lgp_templates_enabled") + @ExcludeMissing + lgpTemplatesEnabled: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("max_free_langgraph_cloud_deployments") + @ExcludeMissing + maxFreeLanggraphCloudDeployments: JsonField<Long> = JsonMissing.of(), + @JsonProperty("max_identities") + @ExcludeMissing + maxIdentities: JsonField<Long> = JsonMissing.of(), + @JsonProperty("max_langgraph_cloud_deployments") + @ExcludeMissing + maxLanggraphCloudDeployments: JsonField<Long> = JsonMissing.of(), + @JsonProperty("max_prompt_webhooks") + @ExcludeMissing + maxPromptWebhooks: JsonField<Long> = JsonMissing.of(), + @JsonProperty("max_thread_evaluators_per_tenant") + @ExcludeMissing + maxThreadEvaluatorsPerTenant: JsonField<Long> = JsonMissing.of(), + @JsonProperty("max_workspaces") + @ExcludeMissing + maxWorkspaces: JsonField<Long> = JsonMissing.of(), + @JsonProperty("new_rule_evaluator_creation_version") + @ExcludeMissing + newRuleEvaluatorCreationVersion: JsonField<Long> = JsonMissing.of(), + @JsonProperty("partner_plan_approval_date") + @ExcludeMissing + partnerPlanApprovalDate: JsonField<String> = JsonMissing.of(), + @JsonProperty("playground_evaluator_strategy") + @ExcludeMissing + playgroundEvaluatorStrategy: JsonField<String> = JsonMissing.of(), + @JsonProperty("premier_plan_approval_date") + @ExcludeMissing + premierPlanApprovalDate: JsonField<String> = JsonMissing.of(), + @JsonProperty("prompt_optimization_jobs_enabled") + @ExcludeMissing + promptOptimizationJobsEnabled: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("require_code_evaluator_language_field") + @ExcludeMissing + requireCodeEvaluatorLanguageField: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("show_playground_prompt_canvas") + @ExcludeMissing + showPlaygroundPromptCanvas: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("show_updated_resource_tags") + @ExcludeMissing + showUpdatedResourceTags: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("show_updated_sidenav") + @ExcludeMissing + showUpdatedSidenav: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("startup_plan_approval_date") + @ExcludeMissing + startupPlanApprovalDate: JsonField<String> = JsonMissing.of(), + @JsonProperty("tenant_skip_topk_facets") + @ExcludeMissing + tenantSkipTopkFacets: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("thread_evaluators_enabled") + @ExcludeMissing + threadEvaluatorsEnabled: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("use_exact_search_for_prompts") + @ExcludeMissing + useExactSearchForPrompts: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("use_python_playground_service") + @ExcludeMissing + usePythonPlaygroundService: JsonField<Boolean> = JsonMissing.of(), + ) : this( + allowCustomIframes, + canAddSeats, + canDisablePublicSharing, + canServeDatasets, + canUseAbac, + canUseAgentBuilder, + canUseBulkExport, + canUseLanggraphCloud, + canUseRbac, + canUseSamlSso, + clioEnabled, + datadogRumSessionSampleRate, + demoLgpNewGraphEnabled, + enableAlignEvaluators, + enableIncludeExtendedStats, + enableLanggraphPricing, + enableLgpListenersPage, + enableMarkdownInTracing, + enableMonthlyUsageCharts, + enableOrgUsageCharts, + enablePricingRedesign, + enableQueryingV2Endpoints, + enableRunTreeStreaming, + enableThreadViewPlayground, + enableThreadsImprovements, + kvDatasetMessageSupport, + langgraphDeployOwnCloudEnabled, + langgraphEnterpriseEnabled, + langgraphRemoteReconcilerEnabled, + langsmithAlertsLegacyPocEnabled, + langsmithAlertsPocEnabled, + langsmithExperimentalSearchEnabled, + lgpTemplatesEnabled, + maxFreeLanggraphCloudDeployments, + maxIdentities, + maxLanggraphCloudDeployments, + maxPromptWebhooks, + maxThreadEvaluatorsPerTenant, + maxWorkspaces, + newRuleEvaluatorCreationVersion, + partnerPlanApprovalDate, + playgroundEvaluatorStrategy, + premierPlanApprovalDate, + promptOptimizationJobsEnabled, + requireCodeEvaluatorLanguageField, + showPlaygroundPromptCanvas, + showUpdatedResourceTags, + showUpdatedSidenav, + startupPlanApprovalDate, + tenantSkipTopkFacets, + threadEvaluatorsEnabled, + useExactSearchForPrompts, + usePythonPlaygroundService, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun allowCustomIframes(): Optional<Boolean> = + allowCustomIframes.getOptional("allow_custom_iframes") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun canAddSeats(): Optional<Boolean> = canAddSeats.getOptional("can_add_seats") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun canDisablePublicSharing(): Optional<Boolean> = + canDisablePublicSharing.getOptional("can_disable_public_sharing") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun canServeDatasets(): Optional<Boolean> = canServeDatasets.getOptional("can_serve_datasets") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun canUseAbac(): Optional<Boolean> = canUseAbac.getOptional("can_use_abac") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun canUseAgentBuilder(): Optional<Boolean> = + canUseAgentBuilder.getOptional("can_use_agent_builder") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun canUseBulkExport(): Optional<Boolean> = canUseBulkExport.getOptional("can_use_bulk_export") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun canUseLanggraphCloud(): Optional<Boolean> = + canUseLanggraphCloud.getOptional("can_use_langgraph_cloud") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun canUseRbac(): Optional<Boolean> = canUseRbac.getOptional("can_use_rbac") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun canUseSamlSso(): Optional<Boolean> = canUseSamlSso.getOptional("can_use_saml_sso") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun clioEnabled(): Optional<Boolean> = clioEnabled.getOptional("clio_enabled") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun datadogRumSessionSampleRate(): Optional<Long> = + datadogRumSessionSampleRate.getOptional("datadog_rum_session_sample_rate") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun demoLgpNewGraphEnabled(): Optional<Boolean> = + demoLgpNewGraphEnabled.getOptional("demo_lgp_new_graph_enabled") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun enableAlignEvaluators(): Optional<Boolean> = + enableAlignEvaluators.getOptional("enable_align_evaluators") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun enableIncludeExtendedStats(): Optional<Boolean> = + enableIncludeExtendedStats.getOptional("enable_include_extended_stats") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun enableLanggraphPricing(): Optional<Boolean> = + enableLanggraphPricing.getOptional("enable_langgraph_pricing") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun enableLgpListenersPage(): Optional<Boolean> = + enableLgpListenersPage.getOptional("enable_lgp_listeners_page") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun enableMarkdownInTracing(): Optional<Boolean> = + enableMarkdownInTracing.getOptional("enable_markdown_in_tracing") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun enableMonthlyUsageCharts(): Optional<Boolean> = + enableMonthlyUsageCharts.getOptional("enable_monthly_usage_charts") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun enableOrgUsageCharts(): Optional<Boolean> = + enableOrgUsageCharts.getOptional("enable_org_usage_charts") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun enablePricingRedesign(): Optional<Boolean> = + enablePricingRedesign.getOptional("enable_pricing_redesign") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun enableQueryingV2Endpoints(): Optional<Boolean> = + enableQueryingV2Endpoints.getOptional("enable_querying_v2_endpoints") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun enableRunTreeStreaming(): Optional<Boolean> = + enableRunTreeStreaming.getOptional("enable_run_tree_streaming") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun enableThreadViewPlayground(): Optional<Boolean> = + enableThreadViewPlayground.getOptional("enable_thread_view_playground") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun enableThreadsImprovements(): Optional<Boolean> = + enableThreadsImprovements.getOptional("enable_threads_improvements") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun kvDatasetMessageSupport(): Optional<Boolean> = + kvDatasetMessageSupport.getOptional("kv_dataset_message_support") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun langgraphDeployOwnCloudEnabled(): Optional<Boolean> = + langgraphDeployOwnCloudEnabled.getOptional("langgraph_deploy_own_cloud_enabled") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun langgraphEnterpriseEnabled(): Optional<Boolean> = + langgraphEnterpriseEnabled.getOptional("langgraph_enterprise_enabled") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun langgraphRemoteReconcilerEnabled(): Optional<Boolean> = + langgraphRemoteReconcilerEnabled.getOptional("langgraph_remote_reconciler_enabled") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun langsmithAlertsLegacyPocEnabled(): Optional<Boolean> = + langsmithAlertsLegacyPocEnabled.getOptional("langsmith_alerts_legacy_poc_enabled") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun langsmithAlertsPocEnabled(): Optional<Boolean> = + langsmithAlertsPocEnabled.getOptional("langsmith_alerts_poc_enabled") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun langsmithExperimentalSearchEnabled(): Optional<Boolean> = + langsmithExperimentalSearchEnabled.getOptional("langsmith_experimental_search_enabled") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun lgpTemplatesEnabled(): Optional<Boolean> = + lgpTemplatesEnabled.getOptional("lgp_templates_enabled") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun maxFreeLanggraphCloudDeployments(): Optional<Long> = + maxFreeLanggraphCloudDeployments.getOptional("max_free_langgraph_cloud_deployments") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun maxIdentities(): Optional<Long> = maxIdentities.getOptional("max_identities") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun maxLanggraphCloudDeployments(): Optional<Long> = + maxLanggraphCloudDeployments.getOptional("max_langgraph_cloud_deployments") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun maxPromptWebhooks(): Optional<Long> = maxPromptWebhooks.getOptional("max_prompt_webhooks") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun maxThreadEvaluatorsPerTenant(): Optional<Long> = + maxThreadEvaluatorsPerTenant.getOptional("max_thread_evaluators_per_tenant") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun maxWorkspaces(): Optional<Long> = maxWorkspaces.getOptional("max_workspaces") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun newRuleEvaluatorCreationVersion(): Optional<Long> = + newRuleEvaluatorCreationVersion.getOptional("new_rule_evaluator_creation_version") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun partnerPlanApprovalDate(): Optional<String> = + partnerPlanApprovalDate.getOptional("partner_plan_approval_date") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun playgroundEvaluatorStrategy(): Optional<String> = + playgroundEvaluatorStrategy.getOptional("playground_evaluator_strategy") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun premierPlanApprovalDate(): Optional<String> = + premierPlanApprovalDate.getOptional("premier_plan_approval_date") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun promptOptimizationJobsEnabled(): Optional<Boolean> = + promptOptimizationJobsEnabled.getOptional("prompt_optimization_jobs_enabled") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun requireCodeEvaluatorLanguageField(): Optional<Boolean> = + requireCodeEvaluatorLanguageField.getOptional("require_code_evaluator_language_field") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun showPlaygroundPromptCanvas(): Optional<Boolean> = + showPlaygroundPromptCanvas.getOptional("show_playground_prompt_canvas") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun showUpdatedResourceTags(): Optional<Boolean> = + showUpdatedResourceTags.getOptional("show_updated_resource_tags") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun showUpdatedSidenav(): Optional<Boolean> = + showUpdatedSidenav.getOptional("show_updated_sidenav") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun startupPlanApprovalDate(): Optional<String> = + startupPlanApprovalDate.getOptional("startup_plan_approval_date") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tenantSkipTopkFacets(): Optional<Boolean> = + tenantSkipTopkFacets.getOptional("tenant_skip_topk_facets") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun threadEvaluatorsEnabled(): Optional<Boolean> = + threadEvaluatorsEnabled.getOptional("thread_evaluators_enabled") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun useExactSearchForPrompts(): Optional<Boolean> = + useExactSearchForPrompts.getOptional("use_exact_search_for_prompts") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun usePythonPlaygroundService(): Optional<Boolean> = + usePythonPlaygroundService.getOptional("use_python_playground_service") + + /** + * Returns the raw JSON value of [allowCustomIframes]. + * + * Unlike [allowCustomIframes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allow_custom_iframes") + @ExcludeMissing + fun _allowCustomIframes(): JsonField<Boolean> = allowCustomIframes + + /** + * Returns the raw JSON value of [canAddSeats]. + * + * Unlike [canAddSeats], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("can_add_seats") + @ExcludeMissing + fun _canAddSeats(): JsonField<Boolean> = canAddSeats + + /** + * Returns the raw JSON value of [canDisablePublicSharing]. + * + * Unlike [canDisablePublicSharing], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("can_disable_public_sharing") + @ExcludeMissing + fun _canDisablePublicSharing(): JsonField<Boolean> = canDisablePublicSharing + + /** + * Returns the raw JSON value of [canServeDatasets]. + * + * Unlike [canServeDatasets], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("can_serve_datasets") + @ExcludeMissing + fun _canServeDatasets(): JsonField<Boolean> = canServeDatasets + + /** + * Returns the raw JSON value of [canUseAbac]. + * + * Unlike [canUseAbac], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("can_use_abac") @ExcludeMissing fun _canUseAbac(): JsonField<Boolean> = canUseAbac + + /** + * Returns the raw JSON value of [canUseAgentBuilder]. + * + * Unlike [canUseAgentBuilder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("can_use_agent_builder") + @ExcludeMissing + fun _canUseAgentBuilder(): JsonField<Boolean> = canUseAgentBuilder + + /** + * Returns the raw JSON value of [canUseBulkExport]. + * + * Unlike [canUseBulkExport], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("can_use_bulk_export") + @ExcludeMissing + fun _canUseBulkExport(): JsonField<Boolean> = canUseBulkExport + + /** + * Returns the raw JSON value of [canUseLanggraphCloud]. + * + * Unlike [canUseLanggraphCloud], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("can_use_langgraph_cloud") + @ExcludeMissing + fun _canUseLanggraphCloud(): JsonField<Boolean> = canUseLanggraphCloud + + /** + * Returns the raw JSON value of [canUseRbac]. + * + * Unlike [canUseRbac], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("can_use_rbac") @ExcludeMissing fun _canUseRbac(): JsonField<Boolean> = canUseRbac + + /** + * Returns the raw JSON value of [canUseSamlSso]. + * + * Unlike [canUseSamlSso], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("can_use_saml_sso") + @ExcludeMissing + fun _canUseSamlSso(): JsonField<Boolean> = canUseSamlSso + + /** + * Returns the raw JSON value of [clioEnabled]. + * + * Unlike [clioEnabled], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("clio_enabled") + @ExcludeMissing + fun _clioEnabled(): JsonField<Boolean> = clioEnabled + + /** + * Returns the raw JSON value of [datadogRumSessionSampleRate]. + * + * Unlike [datadogRumSessionSampleRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("datadog_rum_session_sample_rate") + @ExcludeMissing + fun _datadogRumSessionSampleRate(): JsonField<Long> = datadogRumSessionSampleRate + + /** + * Returns the raw JSON value of [demoLgpNewGraphEnabled]. + * + * Unlike [demoLgpNewGraphEnabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("demo_lgp_new_graph_enabled") + @ExcludeMissing + fun _demoLgpNewGraphEnabled(): JsonField<Boolean> = demoLgpNewGraphEnabled + + /** + * Returns the raw JSON value of [enableAlignEvaluators]. + * + * Unlike [enableAlignEvaluators], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("enable_align_evaluators") + @ExcludeMissing + fun _enableAlignEvaluators(): JsonField<Boolean> = enableAlignEvaluators + + /** + * Returns the raw JSON value of [enableIncludeExtendedStats]. + * + * Unlike [enableIncludeExtendedStats], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("enable_include_extended_stats") + @ExcludeMissing + fun _enableIncludeExtendedStats(): JsonField<Boolean> = enableIncludeExtendedStats + + /** + * Returns the raw JSON value of [enableLanggraphPricing]. + * + * Unlike [enableLanggraphPricing], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("enable_langgraph_pricing") + @ExcludeMissing + fun _enableLanggraphPricing(): JsonField<Boolean> = enableLanggraphPricing + + /** + * Returns the raw JSON value of [enableLgpListenersPage]. + * + * Unlike [enableLgpListenersPage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("enable_lgp_listeners_page") + @ExcludeMissing + fun _enableLgpListenersPage(): JsonField<Boolean> = enableLgpListenersPage + + /** + * Returns the raw JSON value of [enableMarkdownInTracing]. + * + * Unlike [enableMarkdownInTracing], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("enable_markdown_in_tracing") + @ExcludeMissing + fun _enableMarkdownInTracing(): JsonField<Boolean> = enableMarkdownInTracing + + /** + * Returns the raw JSON value of [enableMonthlyUsageCharts]. + * + * Unlike [enableMonthlyUsageCharts], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("enable_monthly_usage_charts") + @ExcludeMissing + fun _enableMonthlyUsageCharts(): JsonField<Boolean> = enableMonthlyUsageCharts + + /** + * Returns the raw JSON value of [enableOrgUsageCharts]. + * + * Unlike [enableOrgUsageCharts], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("enable_org_usage_charts") + @ExcludeMissing + fun _enableOrgUsageCharts(): JsonField<Boolean> = enableOrgUsageCharts + + /** + * Returns the raw JSON value of [enablePricingRedesign]. + * + * Unlike [enablePricingRedesign], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("enable_pricing_redesign") + @ExcludeMissing + fun _enablePricingRedesign(): JsonField<Boolean> = enablePricingRedesign + + /** + * Returns the raw JSON value of [enableQueryingV2Endpoints]. + * + * Unlike [enableQueryingV2Endpoints], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("enable_querying_v2_endpoints") + @ExcludeMissing + fun _enableQueryingV2Endpoints(): JsonField<Boolean> = enableQueryingV2Endpoints + + /** + * Returns the raw JSON value of [enableRunTreeStreaming]. + * + * Unlike [enableRunTreeStreaming], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("enable_run_tree_streaming") + @ExcludeMissing + fun _enableRunTreeStreaming(): JsonField<Boolean> = enableRunTreeStreaming + + /** + * Returns the raw JSON value of [enableThreadViewPlayground]. + * + * Unlike [enableThreadViewPlayground], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("enable_thread_view_playground") + @ExcludeMissing + fun _enableThreadViewPlayground(): JsonField<Boolean> = enableThreadViewPlayground + + /** + * Returns the raw JSON value of [enableThreadsImprovements]. + * + * Unlike [enableThreadsImprovements], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("enable_threads_improvements") + @ExcludeMissing + fun _enableThreadsImprovements(): JsonField<Boolean> = enableThreadsImprovements + + /** + * Returns the raw JSON value of [kvDatasetMessageSupport]. + * + * Unlike [kvDatasetMessageSupport], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("kv_dataset_message_support") + @ExcludeMissing + fun _kvDatasetMessageSupport(): JsonField<Boolean> = kvDatasetMessageSupport + + /** + * Returns the raw JSON value of [langgraphDeployOwnCloudEnabled]. + * + * Unlike [langgraphDeployOwnCloudEnabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("langgraph_deploy_own_cloud_enabled") + @ExcludeMissing + fun _langgraphDeployOwnCloudEnabled(): JsonField<Boolean> = langgraphDeployOwnCloudEnabled + + /** + * Returns the raw JSON value of [langgraphEnterpriseEnabled]. + * + * Unlike [langgraphEnterpriseEnabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("langgraph_enterprise_enabled") + @ExcludeMissing + fun _langgraphEnterpriseEnabled(): JsonField<Boolean> = langgraphEnterpriseEnabled + + /** + * Returns the raw JSON value of [langgraphRemoteReconcilerEnabled]. + * + * Unlike [langgraphRemoteReconcilerEnabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("langgraph_remote_reconciler_enabled") + @ExcludeMissing + fun _langgraphRemoteReconcilerEnabled(): JsonField<Boolean> = langgraphRemoteReconcilerEnabled + + /** + * Returns the raw JSON value of [langsmithAlertsLegacyPocEnabled]. + * + * Unlike [langsmithAlertsLegacyPocEnabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("langsmith_alerts_legacy_poc_enabled") + @ExcludeMissing + fun _langsmithAlertsLegacyPocEnabled(): JsonField<Boolean> = langsmithAlertsLegacyPocEnabled + + /** + * Returns the raw JSON value of [langsmithAlertsPocEnabled]. + * + * Unlike [langsmithAlertsPocEnabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("langsmith_alerts_poc_enabled") + @ExcludeMissing + fun _langsmithAlertsPocEnabled(): JsonField<Boolean> = langsmithAlertsPocEnabled + + /** + * Returns the raw JSON value of [langsmithExperimentalSearchEnabled]. + * + * Unlike [langsmithExperimentalSearchEnabled], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("langsmith_experimental_search_enabled") + @ExcludeMissing + fun _langsmithExperimentalSearchEnabled(): JsonField<Boolean> = + langsmithExperimentalSearchEnabled + + /** + * Returns the raw JSON value of [lgpTemplatesEnabled]. + * + * Unlike [lgpTemplatesEnabled], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lgp_templates_enabled") + @ExcludeMissing + fun _lgpTemplatesEnabled(): JsonField<Boolean> = lgpTemplatesEnabled + + /** + * Returns the raw JSON value of [maxFreeLanggraphCloudDeployments]. + * + * Unlike [maxFreeLanggraphCloudDeployments], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("max_free_langgraph_cloud_deployments") + @ExcludeMissing + fun _maxFreeLanggraphCloudDeployments(): JsonField<Long> = maxFreeLanggraphCloudDeployments + + /** + * Returns the raw JSON value of [maxIdentities]. + * + * Unlike [maxIdentities], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("max_identities") + @ExcludeMissing + fun _maxIdentities(): JsonField<Long> = maxIdentities + + /** + * Returns the raw JSON value of [maxLanggraphCloudDeployments]. + * + * Unlike [maxLanggraphCloudDeployments], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("max_langgraph_cloud_deployments") + @ExcludeMissing + fun _maxLanggraphCloudDeployments(): JsonField<Long> = maxLanggraphCloudDeployments + + /** + * Returns the raw JSON value of [maxPromptWebhooks]. + * + * Unlike [maxPromptWebhooks], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("max_prompt_webhooks") + @ExcludeMissing + fun _maxPromptWebhooks(): JsonField<Long> = maxPromptWebhooks + + /** + * Returns the raw JSON value of [maxThreadEvaluatorsPerTenant]. + * + * Unlike [maxThreadEvaluatorsPerTenant], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("max_thread_evaluators_per_tenant") + @ExcludeMissing + fun _maxThreadEvaluatorsPerTenant(): JsonField<Long> = maxThreadEvaluatorsPerTenant + + /** + * Returns the raw JSON value of [maxWorkspaces]. + * + * Unlike [maxWorkspaces], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("max_workspaces") + @ExcludeMissing + fun _maxWorkspaces(): JsonField<Long> = maxWorkspaces + + /** + * Returns the raw JSON value of [newRuleEvaluatorCreationVersion]. + * + * Unlike [newRuleEvaluatorCreationVersion], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("new_rule_evaluator_creation_version") + @ExcludeMissing + fun _newRuleEvaluatorCreationVersion(): JsonField<Long> = newRuleEvaluatorCreationVersion + + /** + * Returns the raw JSON value of [partnerPlanApprovalDate]. + * + * Unlike [partnerPlanApprovalDate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("partner_plan_approval_date") + @ExcludeMissing + fun _partnerPlanApprovalDate(): JsonField<String> = partnerPlanApprovalDate + + /** + * Returns the raw JSON value of [playgroundEvaluatorStrategy]. + * + * Unlike [playgroundEvaluatorStrategy], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("playground_evaluator_strategy") + @ExcludeMissing + fun _playgroundEvaluatorStrategy(): JsonField<String> = playgroundEvaluatorStrategy + + /** + * Returns the raw JSON value of [premierPlanApprovalDate]. + * + * Unlike [premierPlanApprovalDate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("premier_plan_approval_date") + @ExcludeMissing + fun _premierPlanApprovalDate(): JsonField<String> = premierPlanApprovalDate + + /** + * Returns the raw JSON value of [promptOptimizationJobsEnabled]. + * + * Unlike [promptOptimizationJobsEnabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prompt_optimization_jobs_enabled") + @ExcludeMissing + fun _promptOptimizationJobsEnabled(): JsonField<Boolean> = promptOptimizationJobsEnabled + + /** + * Returns the raw JSON value of [requireCodeEvaluatorLanguageField]. + * + * Unlike [requireCodeEvaluatorLanguageField], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("require_code_evaluator_language_field") + @ExcludeMissing + fun _requireCodeEvaluatorLanguageField(): JsonField<Boolean> = requireCodeEvaluatorLanguageField + + /** + * Returns the raw JSON value of [showPlaygroundPromptCanvas]. + * + * Unlike [showPlaygroundPromptCanvas], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("show_playground_prompt_canvas") + @ExcludeMissing + fun _showPlaygroundPromptCanvas(): JsonField<Boolean> = showPlaygroundPromptCanvas + + /** + * Returns the raw JSON value of [showUpdatedResourceTags]. + * + * Unlike [showUpdatedResourceTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("show_updated_resource_tags") + @ExcludeMissing + fun _showUpdatedResourceTags(): JsonField<Boolean> = showUpdatedResourceTags + + /** + * Returns the raw JSON value of [showUpdatedSidenav]. + * + * Unlike [showUpdatedSidenav], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("show_updated_sidenav") + @ExcludeMissing + fun _showUpdatedSidenav(): JsonField<Boolean> = showUpdatedSidenav + + /** + * Returns the raw JSON value of [startupPlanApprovalDate]. + * + * Unlike [startupPlanApprovalDate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("startup_plan_approval_date") + @ExcludeMissing + fun _startupPlanApprovalDate(): JsonField<String> = startupPlanApprovalDate + + /** + * Returns the raw JSON value of [tenantSkipTopkFacets]. + * + * Unlike [tenantSkipTopkFacets], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tenant_skip_topk_facets") + @ExcludeMissing + fun _tenantSkipTopkFacets(): JsonField<Boolean> = tenantSkipTopkFacets + + /** + * Returns the raw JSON value of [threadEvaluatorsEnabled]. + * + * Unlike [threadEvaluatorsEnabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("thread_evaluators_enabled") + @ExcludeMissing + fun _threadEvaluatorsEnabled(): JsonField<Boolean> = threadEvaluatorsEnabled + + /** + * Returns the raw JSON value of [useExactSearchForPrompts]. + * + * Unlike [useExactSearchForPrompts], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("use_exact_search_for_prompts") + @ExcludeMissing + fun _useExactSearchForPrompts(): JsonField<Boolean> = useExactSearchForPrompts + + /** + * Returns the raw JSON value of [usePythonPlaygroundService]. + * + * Unlike [usePythonPlaygroundService], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("use_python_playground_service") + @ExcludeMissing + fun _usePythonPlaygroundService(): JsonField<Boolean> = usePythonPlaygroundService + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [OrganizationConfig]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OrganizationConfig]. */ + class Builder internal constructor() { + + private var allowCustomIframes: JsonField<Boolean> = JsonMissing.of() + private var canAddSeats: JsonField<Boolean> = JsonMissing.of() + private var canDisablePublicSharing: JsonField<Boolean> = JsonMissing.of() + private var canServeDatasets: JsonField<Boolean> = JsonMissing.of() + private var canUseAbac: JsonField<Boolean> = JsonMissing.of() + private var canUseAgentBuilder: JsonField<Boolean> = JsonMissing.of() + private var canUseBulkExport: JsonField<Boolean> = JsonMissing.of() + private var canUseLanggraphCloud: JsonField<Boolean> = JsonMissing.of() + private var canUseRbac: JsonField<Boolean> = JsonMissing.of() + private var canUseSamlSso: JsonField<Boolean> = JsonMissing.of() + private var clioEnabled: JsonField<Boolean> = JsonMissing.of() + private var datadogRumSessionSampleRate: JsonField<Long> = JsonMissing.of() + private var demoLgpNewGraphEnabled: JsonField<Boolean> = JsonMissing.of() + private var enableAlignEvaluators: JsonField<Boolean> = JsonMissing.of() + private var enableIncludeExtendedStats: JsonField<Boolean> = JsonMissing.of() + private var enableLanggraphPricing: JsonField<Boolean> = JsonMissing.of() + private var enableLgpListenersPage: JsonField<Boolean> = JsonMissing.of() + private var enableMarkdownInTracing: JsonField<Boolean> = JsonMissing.of() + private var enableMonthlyUsageCharts: JsonField<Boolean> = JsonMissing.of() + private var enableOrgUsageCharts: JsonField<Boolean> = JsonMissing.of() + private var enablePricingRedesign: JsonField<Boolean> = JsonMissing.of() + private var enableQueryingV2Endpoints: JsonField<Boolean> = JsonMissing.of() + private var enableRunTreeStreaming: JsonField<Boolean> = JsonMissing.of() + private var enableThreadViewPlayground: JsonField<Boolean> = JsonMissing.of() + private var enableThreadsImprovements: JsonField<Boolean> = JsonMissing.of() + private var kvDatasetMessageSupport: JsonField<Boolean> = JsonMissing.of() + private var langgraphDeployOwnCloudEnabled: JsonField<Boolean> = JsonMissing.of() + private var langgraphEnterpriseEnabled: JsonField<Boolean> = JsonMissing.of() + private var langgraphRemoteReconcilerEnabled: JsonField<Boolean> = JsonMissing.of() + private var langsmithAlertsLegacyPocEnabled: JsonField<Boolean> = JsonMissing.of() + private var langsmithAlertsPocEnabled: JsonField<Boolean> = JsonMissing.of() + private var langsmithExperimentalSearchEnabled: JsonField<Boolean> = JsonMissing.of() + private var lgpTemplatesEnabled: JsonField<Boolean> = JsonMissing.of() + private var maxFreeLanggraphCloudDeployments: JsonField<Long> = JsonMissing.of() + private var maxIdentities: JsonField<Long> = JsonMissing.of() + private var maxLanggraphCloudDeployments: JsonField<Long> = JsonMissing.of() + private var maxPromptWebhooks: JsonField<Long> = JsonMissing.of() + private var maxThreadEvaluatorsPerTenant: JsonField<Long> = JsonMissing.of() + private var maxWorkspaces: JsonField<Long> = JsonMissing.of() + private var newRuleEvaluatorCreationVersion: JsonField<Long> = JsonMissing.of() + private var partnerPlanApprovalDate: JsonField<String> = JsonMissing.of() + private var playgroundEvaluatorStrategy: JsonField<String> = JsonMissing.of() + private var premierPlanApprovalDate: JsonField<String> = JsonMissing.of() + private var promptOptimizationJobsEnabled: JsonField<Boolean> = JsonMissing.of() + private var requireCodeEvaluatorLanguageField: JsonField<Boolean> = JsonMissing.of() + private var showPlaygroundPromptCanvas: JsonField<Boolean> = JsonMissing.of() + private var showUpdatedResourceTags: JsonField<Boolean> = JsonMissing.of() + private var showUpdatedSidenav: JsonField<Boolean> = JsonMissing.of() + private var startupPlanApprovalDate: JsonField<String> = JsonMissing.of() + private var tenantSkipTopkFacets: JsonField<Boolean> = JsonMissing.of() + private var threadEvaluatorsEnabled: JsonField<Boolean> = JsonMissing.of() + private var useExactSearchForPrompts: JsonField<Boolean> = JsonMissing.of() + private var usePythonPlaygroundService: JsonField<Boolean> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(organizationConfig: OrganizationConfig) = apply { + allowCustomIframes = organizationConfig.allowCustomIframes + canAddSeats = organizationConfig.canAddSeats + canDisablePublicSharing = organizationConfig.canDisablePublicSharing + canServeDatasets = organizationConfig.canServeDatasets + canUseAbac = organizationConfig.canUseAbac + canUseAgentBuilder = organizationConfig.canUseAgentBuilder + canUseBulkExport = organizationConfig.canUseBulkExport + canUseLanggraphCloud = organizationConfig.canUseLanggraphCloud + canUseRbac = organizationConfig.canUseRbac + canUseSamlSso = organizationConfig.canUseSamlSso + clioEnabled = organizationConfig.clioEnabled + datadogRumSessionSampleRate = organizationConfig.datadogRumSessionSampleRate + demoLgpNewGraphEnabled = organizationConfig.demoLgpNewGraphEnabled + enableAlignEvaluators = organizationConfig.enableAlignEvaluators + enableIncludeExtendedStats = organizationConfig.enableIncludeExtendedStats + enableLanggraphPricing = organizationConfig.enableLanggraphPricing + enableLgpListenersPage = organizationConfig.enableLgpListenersPage + enableMarkdownInTracing = organizationConfig.enableMarkdownInTracing + enableMonthlyUsageCharts = organizationConfig.enableMonthlyUsageCharts + enableOrgUsageCharts = organizationConfig.enableOrgUsageCharts + enablePricingRedesign = organizationConfig.enablePricingRedesign + enableQueryingV2Endpoints = organizationConfig.enableQueryingV2Endpoints + enableRunTreeStreaming = organizationConfig.enableRunTreeStreaming + enableThreadViewPlayground = organizationConfig.enableThreadViewPlayground + enableThreadsImprovements = organizationConfig.enableThreadsImprovements + kvDatasetMessageSupport = organizationConfig.kvDatasetMessageSupport + langgraphDeployOwnCloudEnabled = organizationConfig.langgraphDeployOwnCloudEnabled + langgraphEnterpriseEnabled = organizationConfig.langgraphEnterpriseEnabled + langgraphRemoteReconcilerEnabled = organizationConfig.langgraphRemoteReconcilerEnabled + langsmithAlertsLegacyPocEnabled = organizationConfig.langsmithAlertsLegacyPocEnabled + langsmithAlertsPocEnabled = organizationConfig.langsmithAlertsPocEnabled + langsmithExperimentalSearchEnabled = + organizationConfig.langsmithExperimentalSearchEnabled + lgpTemplatesEnabled = organizationConfig.lgpTemplatesEnabled + maxFreeLanggraphCloudDeployments = organizationConfig.maxFreeLanggraphCloudDeployments + maxIdentities = organizationConfig.maxIdentities + maxLanggraphCloudDeployments = organizationConfig.maxLanggraphCloudDeployments + maxPromptWebhooks = organizationConfig.maxPromptWebhooks + maxThreadEvaluatorsPerTenant = organizationConfig.maxThreadEvaluatorsPerTenant + maxWorkspaces = organizationConfig.maxWorkspaces + newRuleEvaluatorCreationVersion = organizationConfig.newRuleEvaluatorCreationVersion + partnerPlanApprovalDate = organizationConfig.partnerPlanApprovalDate + playgroundEvaluatorStrategy = organizationConfig.playgroundEvaluatorStrategy + premierPlanApprovalDate = organizationConfig.premierPlanApprovalDate + promptOptimizationJobsEnabled = organizationConfig.promptOptimizationJobsEnabled + requireCodeEvaluatorLanguageField = organizationConfig.requireCodeEvaluatorLanguageField + showPlaygroundPromptCanvas = organizationConfig.showPlaygroundPromptCanvas + showUpdatedResourceTags = organizationConfig.showUpdatedResourceTags + showUpdatedSidenav = organizationConfig.showUpdatedSidenav + startupPlanApprovalDate = organizationConfig.startupPlanApprovalDate + tenantSkipTopkFacets = organizationConfig.tenantSkipTopkFacets + threadEvaluatorsEnabled = organizationConfig.threadEvaluatorsEnabled + useExactSearchForPrompts = organizationConfig.useExactSearchForPrompts + usePythonPlaygroundService = organizationConfig.usePythonPlaygroundService + additionalProperties = organizationConfig.additionalProperties.toMutableMap() + } + + fun allowCustomIframes(allowCustomIframes: Boolean) = + allowCustomIframes(JsonField.of(allowCustomIframes)) + + /** + * Sets [Builder.allowCustomIframes] to an arbitrary JSON value. + * + * You should usually call [Builder.allowCustomIframes] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun allowCustomIframes(allowCustomIframes: JsonField<Boolean>) = apply { + this.allowCustomIframes = allowCustomIframes + } + + fun canAddSeats(canAddSeats: Boolean) = canAddSeats(JsonField.of(canAddSeats)) + + /** + * Sets [Builder.canAddSeats] to an arbitrary JSON value. + * + * You should usually call [Builder.canAddSeats] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun canAddSeats(canAddSeats: JsonField<Boolean>) = apply { this.canAddSeats = canAddSeats } + + fun canDisablePublicSharing(canDisablePublicSharing: Boolean) = + canDisablePublicSharing(JsonField.of(canDisablePublicSharing)) + + /** + * Sets [Builder.canDisablePublicSharing] to an arbitrary JSON value. + * + * You should usually call [Builder.canDisablePublicSharing] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun canDisablePublicSharing(canDisablePublicSharing: JsonField<Boolean>) = apply { + this.canDisablePublicSharing = canDisablePublicSharing + } + + fun canServeDatasets(canServeDatasets: Boolean) = + canServeDatasets(JsonField.of(canServeDatasets)) + + /** + * Sets [Builder.canServeDatasets] to an arbitrary JSON value. + * + * You should usually call [Builder.canServeDatasets] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun canServeDatasets(canServeDatasets: JsonField<Boolean>) = apply { + this.canServeDatasets = canServeDatasets + } + + fun canUseAbac(canUseAbac: Boolean) = canUseAbac(JsonField.of(canUseAbac)) + + /** + * Sets [Builder.canUseAbac] to an arbitrary JSON value. + * + * You should usually call [Builder.canUseAbac] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun canUseAbac(canUseAbac: JsonField<Boolean>) = apply { this.canUseAbac = canUseAbac } + + fun canUseAgentBuilder(canUseAgentBuilder: Boolean) = + canUseAgentBuilder(JsonField.of(canUseAgentBuilder)) + + /** + * Sets [Builder.canUseAgentBuilder] to an arbitrary JSON value. + * + * You should usually call [Builder.canUseAgentBuilder] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun canUseAgentBuilder(canUseAgentBuilder: JsonField<Boolean>) = apply { + this.canUseAgentBuilder = canUseAgentBuilder + } + + fun canUseBulkExport(canUseBulkExport: Boolean) = + canUseBulkExport(JsonField.of(canUseBulkExport)) + + /** + * Sets [Builder.canUseBulkExport] to an arbitrary JSON value. + * + * You should usually call [Builder.canUseBulkExport] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun canUseBulkExport(canUseBulkExport: JsonField<Boolean>) = apply { + this.canUseBulkExport = canUseBulkExport + } + + fun canUseLanggraphCloud(canUseLanggraphCloud: Boolean) = + canUseLanggraphCloud(JsonField.of(canUseLanggraphCloud)) + + /** + * Sets [Builder.canUseLanggraphCloud] to an arbitrary JSON value. + * + * You should usually call [Builder.canUseLanggraphCloud] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun canUseLanggraphCloud(canUseLanggraphCloud: JsonField<Boolean>) = apply { + this.canUseLanggraphCloud = canUseLanggraphCloud + } + + fun canUseRbac(canUseRbac: Boolean) = canUseRbac(JsonField.of(canUseRbac)) + + /** + * Sets [Builder.canUseRbac] to an arbitrary JSON value. + * + * You should usually call [Builder.canUseRbac] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun canUseRbac(canUseRbac: JsonField<Boolean>) = apply { this.canUseRbac = canUseRbac } + + fun canUseSamlSso(canUseSamlSso: Boolean) = canUseSamlSso(JsonField.of(canUseSamlSso)) + + /** + * Sets [Builder.canUseSamlSso] to an arbitrary JSON value. + * + * You should usually call [Builder.canUseSamlSso] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun canUseSamlSso(canUseSamlSso: JsonField<Boolean>) = apply { + this.canUseSamlSso = canUseSamlSso + } + + fun clioEnabled(clioEnabled: Boolean) = clioEnabled(JsonField.of(clioEnabled)) + + /** + * Sets [Builder.clioEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.clioEnabled] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun clioEnabled(clioEnabled: JsonField<Boolean>) = apply { this.clioEnabled = clioEnabled } + + fun datadogRumSessionSampleRate(datadogRumSessionSampleRate: Long) = + datadogRumSessionSampleRate(JsonField.of(datadogRumSessionSampleRate)) + + /** + * Sets [Builder.datadogRumSessionSampleRate] to an arbitrary JSON value. + * + * You should usually call [Builder.datadogRumSessionSampleRate] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun datadogRumSessionSampleRate(datadogRumSessionSampleRate: JsonField<Long>) = apply { + this.datadogRumSessionSampleRate = datadogRumSessionSampleRate + } + + fun demoLgpNewGraphEnabled(demoLgpNewGraphEnabled: Boolean) = + demoLgpNewGraphEnabled(JsonField.of(demoLgpNewGraphEnabled)) + + /** + * Sets [Builder.demoLgpNewGraphEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.demoLgpNewGraphEnabled] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun demoLgpNewGraphEnabled(demoLgpNewGraphEnabled: JsonField<Boolean>) = apply { + this.demoLgpNewGraphEnabled = demoLgpNewGraphEnabled + } + + fun enableAlignEvaluators(enableAlignEvaluators: Boolean) = + enableAlignEvaluators(JsonField.of(enableAlignEvaluators)) + + /** + * Sets [Builder.enableAlignEvaluators] to an arbitrary JSON value. + * + * You should usually call [Builder.enableAlignEvaluators] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun enableAlignEvaluators(enableAlignEvaluators: JsonField<Boolean>) = apply { + this.enableAlignEvaluators = enableAlignEvaluators + } + + fun enableIncludeExtendedStats(enableIncludeExtendedStats: Boolean) = + enableIncludeExtendedStats(JsonField.of(enableIncludeExtendedStats)) + + /** + * Sets [Builder.enableIncludeExtendedStats] to an arbitrary JSON value. + * + * You should usually call [Builder.enableIncludeExtendedStats] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun enableIncludeExtendedStats(enableIncludeExtendedStats: JsonField<Boolean>) = apply { + this.enableIncludeExtendedStats = enableIncludeExtendedStats + } + + fun enableLanggraphPricing(enableLanggraphPricing: Boolean) = + enableLanggraphPricing(JsonField.of(enableLanggraphPricing)) + + /** + * Sets [Builder.enableLanggraphPricing] to an arbitrary JSON value. + * + * You should usually call [Builder.enableLanggraphPricing] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun enableLanggraphPricing(enableLanggraphPricing: JsonField<Boolean>) = apply { + this.enableLanggraphPricing = enableLanggraphPricing + } + + fun enableLgpListenersPage(enableLgpListenersPage: Boolean) = + enableLgpListenersPage(JsonField.of(enableLgpListenersPage)) + + /** + * Sets [Builder.enableLgpListenersPage] to an arbitrary JSON value. + * + * You should usually call [Builder.enableLgpListenersPage] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun enableLgpListenersPage(enableLgpListenersPage: JsonField<Boolean>) = apply { + this.enableLgpListenersPage = enableLgpListenersPage + } + + fun enableMarkdownInTracing(enableMarkdownInTracing: Boolean) = + enableMarkdownInTracing(JsonField.of(enableMarkdownInTracing)) + + /** + * Sets [Builder.enableMarkdownInTracing] to an arbitrary JSON value. + * + * You should usually call [Builder.enableMarkdownInTracing] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun enableMarkdownInTracing(enableMarkdownInTracing: JsonField<Boolean>) = apply { + this.enableMarkdownInTracing = enableMarkdownInTracing + } + + fun enableMonthlyUsageCharts(enableMonthlyUsageCharts: Boolean) = + enableMonthlyUsageCharts(JsonField.of(enableMonthlyUsageCharts)) + + /** + * Sets [Builder.enableMonthlyUsageCharts] to an arbitrary JSON value. + * + * You should usually call [Builder.enableMonthlyUsageCharts] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun enableMonthlyUsageCharts(enableMonthlyUsageCharts: JsonField<Boolean>) = apply { + this.enableMonthlyUsageCharts = enableMonthlyUsageCharts + } + + fun enableOrgUsageCharts(enableOrgUsageCharts: Boolean) = + enableOrgUsageCharts(JsonField.of(enableOrgUsageCharts)) + + /** + * Sets [Builder.enableOrgUsageCharts] to an arbitrary JSON value. + * + * You should usually call [Builder.enableOrgUsageCharts] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun enableOrgUsageCharts(enableOrgUsageCharts: JsonField<Boolean>) = apply { + this.enableOrgUsageCharts = enableOrgUsageCharts + } + + fun enablePricingRedesign(enablePricingRedesign: Boolean) = + enablePricingRedesign(JsonField.of(enablePricingRedesign)) + + /** + * Sets [Builder.enablePricingRedesign] to an arbitrary JSON value. + * + * You should usually call [Builder.enablePricingRedesign] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun enablePricingRedesign(enablePricingRedesign: JsonField<Boolean>) = apply { + this.enablePricingRedesign = enablePricingRedesign + } + + fun enableQueryingV2Endpoints(enableQueryingV2Endpoints: Boolean) = + enableQueryingV2Endpoints(JsonField.of(enableQueryingV2Endpoints)) + + /** + * Sets [Builder.enableQueryingV2Endpoints] to an arbitrary JSON value. + * + * You should usually call [Builder.enableQueryingV2Endpoints] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun enableQueryingV2Endpoints(enableQueryingV2Endpoints: JsonField<Boolean>) = apply { + this.enableQueryingV2Endpoints = enableQueryingV2Endpoints + } + + fun enableRunTreeStreaming(enableRunTreeStreaming: Boolean) = + enableRunTreeStreaming(JsonField.of(enableRunTreeStreaming)) + + /** + * Sets [Builder.enableRunTreeStreaming] to an arbitrary JSON value. + * + * You should usually call [Builder.enableRunTreeStreaming] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun enableRunTreeStreaming(enableRunTreeStreaming: JsonField<Boolean>) = apply { + this.enableRunTreeStreaming = enableRunTreeStreaming + } + + fun enableThreadViewPlayground(enableThreadViewPlayground: Boolean) = + enableThreadViewPlayground(JsonField.of(enableThreadViewPlayground)) + + /** + * Sets [Builder.enableThreadViewPlayground] to an arbitrary JSON value. + * + * You should usually call [Builder.enableThreadViewPlayground] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun enableThreadViewPlayground(enableThreadViewPlayground: JsonField<Boolean>) = apply { + this.enableThreadViewPlayground = enableThreadViewPlayground + } + + fun enableThreadsImprovements(enableThreadsImprovements: Boolean) = + enableThreadsImprovements(JsonField.of(enableThreadsImprovements)) + + /** + * Sets [Builder.enableThreadsImprovements] to an arbitrary JSON value. + * + * You should usually call [Builder.enableThreadsImprovements] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun enableThreadsImprovements(enableThreadsImprovements: JsonField<Boolean>) = apply { + this.enableThreadsImprovements = enableThreadsImprovements + } + + fun kvDatasetMessageSupport(kvDatasetMessageSupport: Boolean) = + kvDatasetMessageSupport(JsonField.of(kvDatasetMessageSupport)) + + /** + * Sets [Builder.kvDatasetMessageSupport] to an arbitrary JSON value. + * + * You should usually call [Builder.kvDatasetMessageSupport] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun kvDatasetMessageSupport(kvDatasetMessageSupport: JsonField<Boolean>) = apply { + this.kvDatasetMessageSupport = kvDatasetMessageSupport + } + + fun langgraphDeployOwnCloudEnabled(langgraphDeployOwnCloudEnabled: Boolean) = + langgraphDeployOwnCloudEnabled(JsonField.of(langgraphDeployOwnCloudEnabled)) + + /** + * Sets [Builder.langgraphDeployOwnCloudEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.langgraphDeployOwnCloudEnabled] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun langgraphDeployOwnCloudEnabled(langgraphDeployOwnCloudEnabled: JsonField<Boolean>) = + apply { + this.langgraphDeployOwnCloudEnabled = langgraphDeployOwnCloudEnabled + } + + fun langgraphEnterpriseEnabled(langgraphEnterpriseEnabled: Boolean) = + langgraphEnterpriseEnabled(JsonField.of(langgraphEnterpriseEnabled)) + + /** + * Sets [Builder.langgraphEnterpriseEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.langgraphEnterpriseEnabled] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun langgraphEnterpriseEnabled(langgraphEnterpriseEnabled: JsonField<Boolean>) = apply { + this.langgraphEnterpriseEnabled = langgraphEnterpriseEnabled + } + + fun langgraphRemoteReconcilerEnabled(langgraphRemoteReconcilerEnabled: Boolean) = + langgraphRemoteReconcilerEnabled(JsonField.of(langgraphRemoteReconcilerEnabled)) + + /** + * Sets [Builder.langgraphRemoteReconcilerEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.langgraphRemoteReconcilerEnabled] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun langgraphRemoteReconcilerEnabled(langgraphRemoteReconcilerEnabled: JsonField<Boolean>) = + apply { + this.langgraphRemoteReconcilerEnabled = langgraphRemoteReconcilerEnabled + } + + fun langsmithAlertsLegacyPocEnabled(langsmithAlertsLegacyPocEnabled: Boolean) = + langsmithAlertsLegacyPocEnabled(JsonField.of(langsmithAlertsLegacyPocEnabled)) + + /** + * Sets [Builder.langsmithAlertsLegacyPocEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.langsmithAlertsLegacyPocEnabled] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun langsmithAlertsLegacyPocEnabled(langsmithAlertsLegacyPocEnabled: JsonField<Boolean>) = + apply { + this.langsmithAlertsLegacyPocEnabled = langsmithAlertsLegacyPocEnabled + } + + fun langsmithAlertsPocEnabled(langsmithAlertsPocEnabled: Boolean) = + langsmithAlertsPocEnabled(JsonField.of(langsmithAlertsPocEnabled)) + + /** + * Sets [Builder.langsmithAlertsPocEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.langsmithAlertsPocEnabled] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun langsmithAlertsPocEnabled(langsmithAlertsPocEnabled: JsonField<Boolean>) = apply { + this.langsmithAlertsPocEnabled = langsmithAlertsPocEnabled + } + + fun langsmithExperimentalSearchEnabled(langsmithExperimentalSearchEnabled: Boolean) = + langsmithExperimentalSearchEnabled(JsonField.of(langsmithExperimentalSearchEnabled)) + + /** + * Sets [Builder.langsmithExperimentalSearchEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.langsmithExperimentalSearchEnabled] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun langsmithExperimentalSearchEnabled( + langsmithExperimentalSearchEnabled: JsonField<Boolean> + ) = apply { this.langsmithExperimentalSearchEnabled = langsmithExperimentalSearchEnabled } + + fun lgpTemplatesEnabled(lgpTemplatesEnabled: Boolean) = + lgpTemplatesEnabled(JsonField.of(lgpTemplatesEnabled)) + + /** + * Sets [Builder.lgpTemplatesEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.lgpTemplatesEnabled] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lgpTemplatesEnabled(lgpTemplatesEnabled: JsonField<Boolean>) = apply { + this.lgpTemplatesEnabled = lgpTemplatesEnabled + } + + fun maxFreeLanggraphCloudDeployments(maxFreeLanggraphCloudDeployments: Long) = + maxFreeLanggraphCloudDeployments(JsonField.of(maxFreeLanggraphCloudDeployments)) + + /** + * Sets [Builder.maxFreeLanggraphCloudDeployments] to an arbitrary JSON value. + * + * You should usually call [Builder.maxFreeLanggraphCloudDeployments] with a well-typed + * [Long] value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun maxFreeLanggraphCloudDeployments(maxFreeLanggraphCloudDeployments: JsonField<Long>) = + apply { + this.maxFreeLanggraphCloudDeployments = maxFreeLanggraphCloudDeployments + } + + fun maxIdentities(maxIdentities: Long) = maxIdentities(JsonField.of(maxIdentities)) + + /** + * Sets [Builder.maxIdentities] to an arbitrary JSON value. + * + * You should usually call [Builder.maxIdentities] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun maxIdentities(maxIdentities: JsonField<Long>) = apply { + this.maxIdentities = maxIdentities + } + + fun maxLanggraphCloudDeployments(maxLanggraphCloudDeployments: Long) = + maxLanggraphCloudDeployments(JsonField.of(maxLanggraphCloudDeployments)) + + /** + * Sets [Builder.maxLanggraphCloudDeployments] to an arbitrary JSON value. + * + * You should usually call [Builder.maxLanggraphCloudDeployments] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun maxLanggraphCloudDeployments(maxLanggraphCloudDeployments: JsonField<Long>) = apply { + this.maxLanggraphCloudDeployments = maxLanggraphCloudDeployments + } + + fun maxPromptWebhooks(maxPromptWebhooks: Long) = + maxPromptWebhooks(JsonField.of(maxPromptWebhooks)) + + /** + * Sets [Builder.maxPromptWebhooks] to an arbitrary JSON value. + * + * You should usually call [Builder.maxPromptWebhooks] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun maxPromptWebhooks(maxPromptWebhooks: JsonField<Long>) = apply { + this.maxPromptWebhooks = maxPromptWebhooks + } + + fun maxThreadEvaluatorsPerTenant(maxThreadEvaluatorsPerTenant: Long) = + maxThreadEvaluatorsPerTenant(JsonField.of(maxThreadEvaluatorsPerTenant)) + + /** + * Sets [Builder.maxThreadEvaluatorsPerTenant] to an arbitrary JSON value. + * + * You should usually call [Builder.maxThreadEvaluatorsPerTenant] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun maxThreadEvaluatorsPerTenant(maxThreadEvaluatorsPerTenant: JsonField<Long>) = apply { + this.maxThreadEvaluatorsPerTenant = maxThreadEvaluatorsPerTenant + } + + fun maxWorkspaces(maxWorkspaces: Long) = maxWorkspaces(JsonField.of(maxWorkspaces)) + + /** + * Sets [Builder.maxWorkspaces] to an arbitrary JSON value. + * + * You should usually call [Builder.maxWorkspaces] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun maxWorkspaces(maxWorkspaces: JsonField<Long>) = apply { + this.maxWorkspaces = maxWorkspaces + } + + fun newRuleEvaluatorCreationVersion(newRuleEvaluatorCreationVersion: Long) = + newRuleEvaluatorCreationVersion(JsonField.of(newRuleEvaluatorCreationVersion)) + + /** + * Sets [Builder.newRuleEvaluatorCreationVersion] to an arbitrary JSON value. + * + * You should usually call [Builder.newRuleEvaluatorCreationVersion] with a well-typed + * [Long] value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun newRuleEvaluatorCreationVersion(newRuleEvaluatorCreationVersion: JsonField<Long>) = + apply { + this.newRuleEvaluatorCreationVersion = newRuleEvaluatorCreationVersion + } + + fun partnerPlanApprovalDate(partnerPlanApprovalDate: String?) = + partnerPlanApprovalDate(JsonField.ofNullable(partnerPlanApprovalDate)) + + /** + * Alias for calling [Builder.partnerPlanApprovalDate] with + * `partnerPlanApprovalDate.orElse(null)`. + */ + fun partnerPlanApprovalDate(partnerPlanApprovalDate: Optional<String>) = + partnerPlanApprovalDate(partnerPlanApprovalDate.getOrNull()) + + /** + * Sets [Builder.partnerPlanApprovalDate] to an arbitrary JSON value. + * + * You should usually call [Builder.partnerPlanApprovalDate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun partnerPlanApprovalDate(partnerPlanApprovalDate: JsonField<String>) = apply { + this.partnerPlanApprovalDate = partnerPlanApprovalDate + } + + fun playgroundEvaluatorStrategy(playgroundEvaluatorStrategy: String?) = + playgroundEvaluatorStrategy(JsonField.ofNullable(playgroundEvaluatorStrategy)) + + /** + * Alias for calling [Builder.playgroundEvaluatorStrategy] with + * `playgroundEvaluatorStrategy.orElse(null)`. + */ + fun playgroundEvaluatorStrategy(playgroundEvaluatorStrategy: Optional<String>) = + playgroundEvaluatorStrategy(playgroundEvaluatorStrategy.getOrNull()) + + /** + * Sets [Builder.playgroundEvaluatorStrategy] to an arbitrary JSON value. + * + * You should usually call [Builder.playgroundEvaluatorStrategy] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun playgroundEvaluatorStrategy(playgroundEvaluatorStrategy: JsonField<String>) = apply { + this.playgroundEvaluatorStrategy = playgroundEvaluatorStrategy + } + + fun premierPlanApprovalDate(premierPlanApprovalDate: String?) = + premierPlanApprovalDate(JsonField.ofNullable(premierPlanApprovalDate)) + + /** + * Alias for calling [Builder.premierPlanApprovalDate] with + * `premierPlanApprovalDate.orElse(null)`. + */ + fun premierPlanApprovalDate(premierPlanApprovalDate: Optional<String>) = + premierPlanApprovalDate(premierPlanApprovalDate.getOrNull()) + + /** + * Sets [Builder.premierPlanApprovalDate] to an arbitrary JSON value. + * + * You should usually call [Builder.premierPlanApprovalDate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun premierPlanApprovalDate(premierPlanApprovalDate: JsonField<String>) = apply { + this.premierPlanApprovalDate = premierPlanApprovalDate + } + + fun promptOptimizationJobsEnabled(promptOptimizationJobsEnabled: Boolean) = + promptOptimizationJobsEnabled(JsonField.of(promptOptimizationJobsEnabled)) + + /** + * Sets [Builder.promptOptimizationJobsEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.promptOptimizationJobsEnabled] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun promptOptimizationJobsEnabled(promptOptimizationJobsEnabled: JsonField<Boolean>) = + apply { + this.promptOptimizationJobsEnabled = promptOptimizationJobsEnabled + } + + fun requireCodeEvaluatorLanguageField(requireCodeEvaluatorLanguageField: Boolean) = + requireCodeEvaluatorLanguageField(JsonField.of(requireCodeEvaluatorLanguageField)) + + /** + * Sets [Builder.requireCodeEvaluatorLanguageField] to an arbitrary JSON value. + * + * You should usually call [Builder.requireCodeEvaluatorLanguageField] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun requireCodeEvaluatorLanguageField( + requireCodeEvaluatorLanguageField: JsonField<Boolean> + ) = apply { this.requireCodeEvaluatorLanguageField = requireCodeEvaluatorLanguageField } + + fun showPlaygroundPromptCanvas(showPlaygroundPromptCanvas: Boolean) = + showPlaygroundPromptCanvas(JsonField.of(showPlaygroundPromptCanvas)) + + /** + * Sets [Builder.showPlaygroundPromptCanvas] to an arbitrary JSON value. + * + * You should usually call [Builder.showPlaygroundPromptCanvas] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun showPlaygroundPromptCanvas(showPlaygroundPromptCanvas: JsonField<Boolean>) = apply { + this.showPlaygroundPromptCanvas = showPlaygroundPromptCanvas + } + + fun showUpdatedResourceTags(showUpdatedResourceTags: Boolean) = + showUpdatedResourceTags(JsonField.of(showUpdatedResourceTags)) + + /** + * Sets [Builder.showUpdatedResourceTags] to an arbitrary JSON value. + * + * You should usually call [Builder.showUpdatedResourceTags] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun showUpdatedResourceTags(showUpdatedResourceTags: JsonField<Boolean>) = apply { + this.showUpdatedResourceTags = showUpdatedResourceTags + } + + fun showUpdatedSidenav(showUpdatedSidenav: Boolean) = + showUpdatedSidenav(JsonField.of(showUpdatedSidenav)) + + /** + * Sets [Builder.showUpdatedSidenav] to an arbitrary JSON value. + * + * You should usually call [Builder.showUpdatedSidenav] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun showUpdatedSidenav(showUpdatedSidenav: JsonField<Boolean>) = apply { + this.showUpdatedSidenav = showUpdatedSidenav + } + + fun startupPlanApprovalDate(startupPlanApprovalDate: String?) = + startupPlanApprovalDate(JsonField.ofNullable(startupPlanApprovalDate)) + + /** + * Alias for calling [Builder.startupPlanApprovalDate] with + * `startupPlanApprovalDate.orElse(null)`. + */ + fun startupPlanApprovalDate(startupPlanApprovalDate: Optional<String>) = + startupPlanApprovalDate(startupPlanApprovalDate.getOrNull()) + + /** + * Sets [Builder.startupPlanApprovalDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startupPlanApprovalDate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun startupPlanApprovalDate(startupPlanApprovalDate: JsonField<String>) = apply { + this.startupPlanApprovalDate = startupPlanApprovalDate + } + + fun tenantSkipTopkFacets(tenantSkipTopkFacets: Boolean) = + tenantSkipTopkFacets(JsonField.of(tenantSkipTopkFacets)) + + /** + * Sets [Builder.tenantSkipTopkFacets] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantSkipTopkFacets] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tenantSkipTopkFacets(tenantSkipTopkFacets: JsonField<Boolean>) = apply { + this.tenantSkipTopkFacets = tenantSkipTopkFacets + } + + fun threadEvaluatorsEnabled(threadEvaluatorsEnabled: Boolean) = + threadEvaluatorsEnabled(JsonField.of(threadEvaluatorsEnabled)) + + /** + * Sets [Builder.threadEvaluatorsEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.threadEvaluatorsEnabled] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun threadEvaluatorsEnabled(threadEvaluatorsEnabled: JsonField<Boolean>) = apply { + this.threadEvaluatorsEnabled = threadEvaluatorsEnabled + } + + fun useExactSearchForPrompts(useExactSearchForPrompts: Boolean) = + useExactSearchForPrompts(JsonField.of(useExactSearchForPrompts)) + + /** + * Sets [Builder.useExactSearchForPrompts] to an arbitrary JSON value. + * + * You should usually call [Builder.useExactSearchForPrompts] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun useExactSearchForPrompts(useExactSearchForPrompts: JsonField<Boolean>) = apply { + this.useExactSearchForPrompts = useExactSearchForPrompts + } + + fun usePythonPlaygroundService(usePythonPlaygroundService: Boolean) = + usePythonPlaygroundService(JsonField.of(usePythonPlaygroundService)) + + /** + * Sets [Builder.usePythonPlaygroundService] to an arbitrary JSON value. + * + * You should usually call [Builder.usePythonPlaygroundService] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun usePythonPlaygroundService(usePythonPlaygroundService: JsonField<Boolean>) = apply { + this.usePythonPlaygroundService = usePythonPlaygroundService + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OrganizationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OrganizationConfig = + OrganizationConfig( + allowCustomIframes, + canAddSeats, + canDisablePublicSharing, + canServeDatasets, + canUseAbac, + canUseAgentBuilder, + canUseBulkExport, + canUseLanggraphCloud, + canUseRbac, + canUseSamlSso, + clioEnabled, + datadogRumSessionSampleRate, + demoLgpNewGraphEnabled, + enableAlignEvaluators, + enableIncludeExtendedStats, + enableLanggraphPricing, + enableLgpListenersPage, + enableMarkdownInTracing, + enableMonthlyUsageCharts, + enableOrgUsageCharts, + enablePricingRedesign, + enableQueryingV2Endpoints, + enableRunTreeStreaming, + enableThreadViewPlayground, + enableThreadsImprovements, + kvDatasetMessageSupport, + langgraphDeployOwnCloudEnabled, + langgraphEnterpriseEnabled, + langgraphRemoteReconcilerEnabled, + langsmithAlertsLegacyPocEnabled, + langsmithAlertsPocEnabled, + langsmithExperimentalSearchEnabled, + lgpTemplatesEnabled, + maxFreeLanggraphCloudDeployments, + maxIdentities, + maxLanggraphCloudDeployments, + maxPromptWebhooks, + maxThreadEvaluatorsPerTenant, + maxWorkspaces, + newRuleEvaluatorCreationVersion, + partnerPlanApprovalDate, + playgroundEvaluatorStrategy, + premierPlanApprovalDate, + promptOptimizationJobsEnabled, + requireCodeEvaluatorLanguageField, + showPlaygroundPromptCanvas, + showUpdatedResourceTags, + showUpdatedSidenav, + startupPlanApprovalDate, + tenantSkipTopkFacets, + threadEvaluatorsEnabled, + useExactSearchForPrompts, + usePythonPlaygroundService, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OrganizationConfig = apply { + if (validated) { + return@apply + } + + allowCustomIframes() + canAddSeats() + canDisablePublicSharing() + canServeDatasets() + canUseAbac() + canUseAgentBuilder() + canUseBulkExport() + canUseLanggraphCloud() + canUseRbac() + canUseSamlSso() + clioEnabled() + datadogRumSessionSampleRate() + demoLgpNewGraphEnabled() + enableAlignEvaluators() + enableIncludeExtendedStats() + enableLanggraphPricing() + enableLgpListenersPage() + enableMarkdownInTracing() + enableMonthlyUsageCharts() + enableOrgUsageCharts() + enablePricingRedesign() + enableQueryingV2Endpoints() + enableRunTreeStreaming() + enableThreadViewPlayground() + enableThreadsImprovements() + kvDatasetMessageSupport() + langgraphDeployOwnCloudEnabled() + langgraphEnterpriseEnabled() + langgraphRemoteReconcilerEnabled() + langsmithAlertsLegacyPocEnabled() + langsmithAlertsPocEnabled() + langsmithExperimentalSearchEnabled() + lgpTemplatesEnabled() + maxFreeLanggraphCloudDeployments() + maxIdentities() + maxLanggraphCloudDeployments() + maxPromptWebhooks() + maxThreadEvaluatorsPerTenant() + maxWorkspaces() + newRuleEvaluatorCreationVersion() + partnerPlanApprovalDate() + playgroundEvaluatorStrategy() + premierPlanApprovalDate() + promptOptimizationJobsEnabled() + requireCodeEvaluatorLanguageField() + showPlaygroundPromptCanvas() + showUpdatedResourceTags() + showUpdatedSidenav() + startupPlanApprovalDate() + tenantSkipTopkFacets() + threadEvaluatorsEnabled() + useExactSearchForPrompts() + usePythonPlaygroundService() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allowCustomIframes.asKnown().isPresent) 1 else 0) + + (if (canAddSeats.asKnown().isPresent) 1 else 0) + + (if (canDisablePublicSharing.asKnown().isPresent) 1 else 0) + + (if (canServeDatasets.asKnown().isPresent) 1 else 0) + + (if (canUseAbac.asKnown().isPresent) 1 else 0) + + (if (canUseAgentBuilder.asKnown().isPresent) 1 else 0) + + (if (canUseBulkExport.asKnown().isPresent) 1 else 0) + + (if (canUseLanggraphCloud.asKnown().isPresent) 1 else 0) + + (if (canUseRbac.asKnown().isPresent) 1 else 0) + + (if (canUseSamlSso.asKnown().isPresent) 1 else 0) + + (if (clioEnabled.asKnown().isPresent) 1 else 0) + + (if (datadogRumSessionSampleRate.asKnown().isPresent) 1 else 0) + + (if (demoLgpNewGraphEnabled.asKnown().isPresent) 1 else 0) + + (if (enableAlignEvaluators.asKnown().isPresent) 1 else 0) + + (if (enableIncludeExtendedStats.asKnown().isPresent) 1 else 0) + + (if (enableLanggraphPricing.asKnown().isPresent) 1 else 0) + + (if (enableLgpListenersPage.asKnown().isPresent) 1 else 0) + + (if (enableMarkdownInTracing.asKnown().isPresent) 1 else 0) + + (if (enableMonthlyUsageCharts.asKnown().isPresent) 1 else 0) + + (if (enableOrgUsageCharts.asKnown().isPresent) 1 else 0) + + (if (enablePricingRedesign.asKnown().isPresent) 1 else 0) + + (if (enableQueryingV2Endpoints.asKnown().isPresent) 1 else 0) + + (if (enableRunTreeStreaming.asKnown().isPresent) 1 else 0) + + (if (enableThreadViewPlayground.asKnown().isPresent) 1 else 0) + + (if (enableThreadsImprovements.asKnown().isPresent) 1 else 0) + + (if (kvDatasetMessageSupport.asKnown().isPresent) 1 else 0) + + (if (langgraphDeployOwnCloudEnabled.asKnown().isPresent) 1 else 0) + + (if (langgraphEnterpriseEnabled.asKnown().isPresent) 1 else 0) + + (if (langgraphRemoteReconcilerEnabled.asKnown().isPresent) 1 else 0) + + (if (langsmithAlertsLegacyPocEnabled.asKnown().isPresent) 1 else 0) + + (if (langsmithAlertsPocEnabled.asKnown().isPresent) 1 else 0) + + (if (langsmithExperimentalSearchEnabled.asKnown().isPresent) 1 else 0) + + (if (lgpTemplatesEnabled.asKnown().isPresent) 1 else 0) + + (if (maxFreeLanggraphCloudDeployments.asKnown().isPresent) 1 else 0) + + (if (maxIdentities.asKnown().isPresent) 1 else 0) + + (if (maxLanggraphCloudDeployments.asKnown().isPresent) 1 else 0) + + (if (maxPromptWebhooks.asKnown().isPresent) 1 else 0) + + (if (maxThreadEvaluatorsPerTenant.asKnown().isPresent) 1 else 0) + + (if (maxWorkspaces.asKnown().isPresent) 1 else 0) + + (if (newRuleEvaluatorCreationVersion.asKnown().isPresent) 1 else 0) + + (if (partnerPlanApprovalDate.asKnown().isPresent) 1 else 0) + + (if (playgroundEvaluatorStrategy.asKnown().isPresent) 1 else 0) + + (if (premierPlanApprovalDate.asKnown().isPresent) 1 else 0) + + (if (promptOptimizationJobsEnabled.asKnown().isPresent) 1 else 0) + + (if (requireCodeEvaluatorLanguageField.asKnown().isPresent) 1 else 0) + + (if (showPlaygroundPromptCanvas.asKnown().isPresent) 1 else 0) + + (if (showUpdatedResourceTags.asKnown().isPresent) 1 else 0) + + (if (showUpdatedSidenav.asKnown().isPresent) 1 else 0) + + (if (startupPlanApprovalDate.asKnown().isPresent) 1 else 0) + + (if (tenantSkipTopkFacets.asKnown().isPresent) 1 else 0) + + (if (threadEvaluatorsEnabled.asKnown().isPresent) 1 else 0) + + (if (useExactSearchForPrompts.asKnown().isPresent) 1 else 0) + + (if (usePythonPlaygroundService.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OrganizationConfig && + allowCustomIframes == other.allowCustomIframes && + canAddSeats == other.canAddSeats && + canDisablePublicSharing == other.canDisablePublicSharing && + canServeDatasets == other.canServeDatasets && + canUseAbac == other.canUseAbac && + canUseAgentBuilder == other.canUseAgentBuilder && + canUseBulkExport == other.canUseBulkExport && + canUseLanggraphCloud == other.canUseLanggraphCloud && + canUseRbac == other.canUseRbac && + canUseSamlSso == other.canUseSamlSso && + clioEnabled == other.clioEnabled && + datadogRumSessionSampleRate == other.datadogRumSessionSampleRate && + demoLgpNewGraphEnabled == other.demoLgpNewGraphEnabled && + enableAlignEvaluators == other.enableAlignEvaluators && + enableIncludeExtendedStats == other.enableIncludeExtendedStats && + enableLanggraphPricing == other.enableLanggraphPricing && + enableLgpListenersPage == other.enableLgpListenersPage && + enableMarkdownInTracing == other.enableMarkdownInTracing && + enableMonthlyUsageCharts == other.enableMonthlyUsageCharts && + enableOrgUsageCharts == other.enableOrgUsageCharts && + enablePricingRedesign == other.enablePricingRedesign && + enableQueryingV2Endpoints == other.enableQueryingV2Endpoints && + enableRunTreeStreaming == other.enableRunTreeStreaming && + enableThreadViewPlayground == other.enableThreadViewPlayground && + enableThreadsImprovements == other.enableThreadsImprovements && + kvDatasetMessageSupport == other.kvDatasetMessageSupport && + langgraphDeployOwnCloudEnabled == other.langgraphDeployOwnCloudEnabled && + langgraphEnterpriseEnabled == other.langgraphEnterpriseEnabled && + langgraphRemoteReconcilerEnabled == other.langgraphRemoteReconcilerEnabled && + langsmithAlertsLegacyPocEnabled == other.langsmithAlertsLegacyPocEnabled && + langsmithAlertsPocEnabled == other.langsmithAlertsPocEnabled && + langsmithExperimentalSearchEnabled == other.langsmithExperimentalSearchEnabled && + lgpTemplatesEnabled == other.lgpTemplatesEnabled && + maxFreeLanggraphCloudDeployments == other.maxFreeLanggraphCloudDeployments && + maxIdentities == other.maxIdentities && + maxLanggraphCloudDeployments == other.maxLanggraphCloudDeployments && + maxPromptWebhooks == other.maxPromptWebhooks && + maxThreadEvaluatorsPerTenant == other.maxThreadEvaluatorsPerTenant && + maxWorkspaces == other.maxWorkspaces && + newRuleEvaluatorCreationVersion == other.newRuleEvaluatorCreationVersion && + partnerPlanApprovalDate == other.partnerPlanApprovalDate && + playgroundEvaluatorStrategy == other.playgroundEvaluatorStrategy && + premierPlanApprovalDate == other.premierPlanApprovalDate && + promptOptimizationJobsEnabled == other.promptOptimizationJobsEnabled && + requireCodeEvaluatorLanguageField == other.requireCodeEvaluatorLanguageField && + showPlaygroundPromptCanvas == other.showPlaygroundPromptCanvas && + showUpdatedResourceTags == other.showUpdatedResourceTags && + showUpdatedSidenav == other.showUpdatedSidenav && + startupPlanApprovalDate == other.startupPlanApprovalDate && + tenantSkipTopkFacets == other.tenantSkipTopkFacets && + threadEvaluatorsEnabled == other.threadEvaluatorsEnabled && + useExactSearchForPrompts == other.useExactSearchForPrompts && + usePythonPlaygroundService == other.usePythonPlaygroundService && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + allowCustomIframes, + canAddSeats, + canDisablePublicSharing, + canServeDatasets, + canUseAbac, + canUseAgentBuilder, + canUseBulkExport, + canUseLanggraphCloud, + canUseRbac, + canUseSamlSso, + clioEnabled, + datadogRumSessionSampleRate, + demoLgpNewGraphEnabled, + enableAlignEvaluators, + enableIncludeExtendedStats, + enableLanggraphPricing, + enableLgpListenersPage, + enableMarkdownInTracing, + enableMonthlyUsageCharts, + enableOrgUsageCharts, + enablePricingRedesign, + enableQueryingV2Endpoints, + enableRunTreeStreaming, + enableThreadViewPlayground, + enableThreadsImprovements, + kvDatasetMessageSupport, + langgraphDeployOwnCloudEnabled, + langgraphEnterpriseEnabled, + langgraphRemoteReconcilerEnabled, + langsmithAlertsLegacyPocEnabled, + langsmithAlertsPocEnabled, + langsmithExperimentalSearchEnabled, + lgpTemplatesEnabled, + maxFreeLanggraphCloudDeployments, + maxIdentities, + maxLanggraphCloudDeployments, + maxPromptWebhooks, + maxThreadEvaluatorsPerTenant, + maxWorkspaces, + newRuleEvaluatorCreationVersion, + partnerPlanApprovalDate, + playgroundEvaluatorStrategy, + premierPlanApprovalDate, + promptOptimizationJobsEnabled, + requireCodeEvaluatorLanguageField, + showPlaygroundPromptCanvas, + showUpdatedResourceTags, + showUpdatedSidenav, + startupPlanApprovalDate, + tenantSkipTopkFacets, + threadEvaluatorsEnabled, + useExactSearchForPrompts, + usePythonPlaygroundService, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OrganizationConfig{allowCustomIframes=$allowCustomIframes, canAddSeats=$canAddSeats, canDisablePublicSharing=$canDisablePublicSharing, canServeDatasets=$canServeDatasets, canUseAbac=$canUseAbac, canUseAgentBuilder=$canUseAgentBuilder, canUseBulkExport=$canUseBulkExport, canUseLanggraphCloud=$canUseLanggraphCloud, canUseRbac=$canUseRbac, canUseSamlSso=$canUseSamlSso, clioEnabled=$clioEnabled, datadogRumSessionSampleRate=$datadogRumSessionSampleRate, demoLgpNewGraphEnabled=$demoLgpNewGraphEnabled, enableAlignEvaluators=$enableAlignEvaluators, enableIncludeExtendedStats=$enableIncludeExtendedStats, enableLanggraphPricing=$enableLanggraphPricing, enableLgpListenersPage=$enableLgpListenersPage, enableMarkdownInTracing=$enableMarkdownInTracing, enableMonthlyUsageCharts=$enableMonthlyUsageCharts, enableOrgUsageCharts=$enableOrgUsageCharts, enablePricingRedesign=$enablePricingRedesign, enableQueryingV2Endpoints=$enableQueryingV2Endpoints, enableRunTreeStreaming=$enableRunTreeStreaming, enableThreadViewPlayground=$enableThreadViewPlayground, enableThreadsImprovements=$enableThreadsImprovements, kvDatasetMessageSupport=$kvDatasetMessageSupport, langgraphDeployOwnCloudEnabled=$langgraphDeployOwnCloudEnabled, langgraphEnterpriseEnabled=$langgraphEnterpriseEnabled, langgraphRemoteReconcilerEnabled=$langgraphRemoteReconcilerEnabled, langsmithAlertsLegacyPocEnabled=$langsmithAlertsLegacyPocEnabled, langsmithAlertsPocEnabled=$langsmithAlertsPocEnabled, langsmithExperimentalSearchEnabled=$langsmithExperimentalSearchEnabled, lgpTemplatesEnabled=$lgpTemplatesEnabled, maxFreeLanggraphCloudDeployments=$maxFreeLanggraphCloudDeployments, maxIdentities=$maxIdentities, maxLanggraphCloudDeployments=$maxLanggraphCloudDeployments, maxPromptWebhooks=$maxPromptWebhooks, maxThreadEvaluatorsPerTenant=$maxThreadEvaluatorsPerTenant, maxWorkspaces=$maxWorkspaces, newRuleEvaluatorCreationVersion=$newRuleEvaluatorCreationVersion, partnerPlanApprovalDate=$partnerPlanApprovalDate, playgroundEvaluatorStrategy=$playgroundEvaluatorStrategy, premierPlanApprovalDate=$premierPlanApprovalDate, promptOptimizationJobsEnabled=$promptOptimizationJobsEnabled, requireCodeEvaluatorLanguageField=$requireCodeEvaluatorLanguageField, showPlaygroundPromptCanvas=$showPlaygroundPromptCanvas, showUpdatedResourceTags=$showUpdatedResourceTags, showUpdatedSidenav=$showUpdatedSidenav, startupPlanApprovalDate=$startupPlanApprovalDate, tenantSkipTopkFacets=$tenantSkipTopkFacets, threadEvaluatorsEnabled=$threadEvaluatorsEnabled, useExactSearchForPrompts=$useExactSearchForPrompts, usePythonPlaygroundService=$usePythonPlaygroundService, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/StripeCustomerAddress.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/StripeCustomerAddress.kt new file mode 100644 index 00000000..bc900c3c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/StripeCustomerAddress.kt @@ -0,0 +1,347 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Stripe customer address. */ +class StripeCustomerAddress +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val city: JsonField<String>, + private val country: JsonField<String>, + private val line1: JsonField<String>, + private val postalCode: JsonField<String>, + private val line2: JsonField<String>, + private val state: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("city") @ExcludeMissing city: JsonField<String> = JsonMissing.of(), + @JsonProperty("country") @ExcludeMissing country: JsonField<String> = JsonMissing.of(), + @JsonProperty("line1") @ExcludeMissing line1: JsonField<String> = JsonMissing.of(), + @JsonProperty("postal_code") + @ExcludeMissing + postalCode: JsonField<String> = JsonMissing.of(), + @JsonProperty("line2") @ExcludeMissing line2: JsonField<String> = JsonMissing.of(), + @JsonProperty("state") @ExcludeMissing state: JsonField<String> = JsonMissing.of(), + ) : this(city, country, line1, postalCode, line2, state, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun city(): String = city.getRequired("city") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun country(): String = country.getRequired("country") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun line1(): String = line1.getRequired("line1") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun postalCode(): String = postalCode.getRequired("postal_code") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun line2(): Optional<String> = line2.getOptional("line2") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun state(): Optional<String> = state.getOptional("state") + + /** + * Returns the raw JSON value of [city]. + * + * Unlike [city], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("city") @ExcludeMissing fun _city(): JsonField<String> = city + + /** + * Returns the raw JSON value of [country]. + * + * Unlike [country], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField<String> = country + + /** + * Returns the raw JSON value of [line1]. + * + * Unlike [line1], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField<String> = line1 + + /** + * Returns the raw JSON value of [postalCode]. + * + * Unlike [postalCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("postal_code") @ExcludeMissing fun _postalCode(): JsonField<String> = postalCode + + /** + * Returns the raw JSON value of [line2]. + * + * Unlike [line2], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField<String> = line2 + + /** + * Returns the raw JSON value of [state]. + * + * Unlike [state], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField<String> = state + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [StripeCustomerAddress]. + * + * The following fields are required: + * ```java + * .city() + * .country() + * .line1() + * .postalCode() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StripeCustomerAddress]. */ + class Builder internal constructor() { + + private var city: JsonField<String>? = null + private var country: JsonField<String>? = null + private var line1: JsonField<String>? = null + private var postalCode: JsonField<String>? = null + private var line2: JsonField<String> = JsonMissing.of() + private var state: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(stripeCustomerAddress: StripeCustomerAddress) = apply { + city = stripeCustomerAddress.city + country = stripeCustomerAddress.country + line1 = stripeCustomerAddress.line1 + postalCode = stripeCustomerAddress.postalCode + line2 = stripeCustomerAddress.line2 + state = stripeCustomerAddress.state + additionalProperties = stripeCustomerAddress.additionalProperties.toMutableMap() + } + + fun city(city: String) = city(JsonField.of(city)) + + /** + * Sets [Builder.city] to an arbitrary JSON value. + * + * You should usually call [Builder.city] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun city(city: JsonField<String>) = apply { this.city = city } + + fun country(country: String) = country(JsonField.of(country)) + + /** + * Sets [Builder.country] to an arbitrary JSON value. + * + * You should usually call [Builder.country] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun country(country: JsonField<String>) = apply { this.country = country } + + fun line1(line1: String) = line1(JsonField.of(line1)) + + /** + * Sets [Builder.line1] to an arbitrary JSON value. + * + * You should usually call [Builder.line1] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun line1(line1: JsonField<String>) = apply { this.line1 = line1 } + + fun postalCode(postalCode: String) = postalCode(JsonField.of(postalCode)) + + /** + * Sets [Builder.postalCode] to an arbitrary JSON value. + * + * You should usually call [Builder.postalCode] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun postalCode(postalCode: JsonField<String>) = apply { this.postalCode = postalCode } + + fun line2(line2: String?) = line2(JsonField.ofNullable(line2)) + + /** Alias for calling [Builder.line2] with `line2.orElse(null)`. */ + fun line2(line2: Optional<String>) = line2(line2.getOrNull()) + + /** + * Sets [Builder.line2] to an arbitrary JSON value. + * + * You should usually call [Builder.line2] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun line2(line2: JsonField<String>) = apply { this.line2 = line2 } + + fun state(state: String?) = state(JsonField.ofNullable(state)) + + /** Alias for calling [Builder.state] with `state.orElse(null)`. */ + fun state(state: Optional<String>) = state(state.getOrNull()) + + /** + * Sets [Builder.state] to an arbitrary JSON value. + * + * You should usually call [Builder.state] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun state(state: JsonField<String>) = apply { this.state = state } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [StripeCustomerAddress]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .city() + * .country() + * .line1() + * .postalCode() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): StripeCustomerAddress = + StripeCustomerAddress( + checkRequired("city", city), + checkRequired("country", country), + checkRequired("line1", line1), + checkRequired("postalCode", postalCode), + line2, + state, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): StripeCustomerAddress = apply { + if (validated) { + return@apply + } + + city() + country() + line1() + postalCode() + line2() + state() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (city.asKnown().isPresent) 1 else 0) + + (if (country.asKnown().isPresent) 1 else 0) + + (if (line1.asKnown().isPresent) 1 else 0) + + (if (postalCode.asKnown().isPresent) 1 else 0) + + (if (line2.asKnown().isPresent) 1 else 0) + + (if (state.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is StripeCustomerAddress && + city == other.city && + country == other.country && + line1 == other.line1 && + postalCode == other.postalCode && + line2 == other.line2 && + state == other.state && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(city, country, line1, postalCode, line2, state, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StripeCustomerAddress{city=$city, country=$country, line1=$line1, postalCode=$postalCode, line2=$line2, state=$state, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/StripePaymentMethodInfo.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/StripePaymentMethodInfo.kt new file mode 100644 index 00000000..f5e13cc0 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/StripePaymentMethodInfo.kt @@ -0,0 +1,315 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Stripe customer billing info. */ +class StripePaymentMethodInfo +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val brand: JsonField<String>, + private val email: JsonField<String>, + private val expMonth: JsonField<Long>, + private val expYear: JsonField<Long>, + private val last4: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("brand") @ExcludeMissing brand: JsonField<String> = JsonMissing.of(), + @JsonProperty("email") @ExcludeMissing email: JsonField<String> = JsonMissing.of(), + @JsonProperty("exp_month") @ExcludeMissing expMonth: JsonField<Long> = JsonMissing.of(), + @JsonProperty("exp_year") @ExcludeMissing expYear: JsonField<Long> = JsonMissing.of(), + @JsonProperty("last4") @ExcludeMissing last4: JsonField<String> = JsonMissing.of(), + ) : this(brand, email, expMonth, expYear, last4, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun brand(): Optional<String> = brand.getOptional("brand") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun email(): Optional<String> = email.getOptional("email") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun expMonth(): Optional<Long> = expMonth.getOptional("exp_month") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun expYear(): Optional<Long> = expYear.getOptional("exp_year") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun last4(): Optional<String> = last4.getOptional("last4") + + /** + * Returns the raw JSON value of [brand]. + * + * Unlike [brand], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("brand") @ExcludeMissing fun _brand(): JsonField<String> = brand + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField<String> = email + + /** + * Returns the raw JSON value of [expMonth]. + * + * Unlike [expMonth], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("exp_month") @ExcludeMissing fun _expMonth(): JsonField<Long> = expMonth + + /** + * Returns the raw JSON value of [expYear]. + * + * Unlike [expYear], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("exp_year") @ExcludeMissing fun _expYear(): JsonField<Long> = expYear + + /** + * Returns the raw JSON value of [last4]. + * + * Unlike [last4], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("last4") @ExcludeMissing fun _last4(): JsonField<String> = last4 + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [StripePaymentMethodInfo]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StripePaymentMethodInfo]. */ + class Builder internal constructor() { + + private var brand: JsonField<String> = JsonMissing.of() + private var email: JsonField<String> = JsonMissing.of() + private var expMonth: JsonField<Long> = JsonMissing.of() + private var expYear: JsonField<Long> = JsonMissing.of() + private var last4: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(stripePaymentMethodInfo: StripePaymentMethodInfo) = apply { + brand = stripePaymentMethodInfo.brand + email = stripePaymentMethodInfo.email + expMonth = stripePaymentMethodInfo.expMonth + expYear = stripePaymentMethodInfo.expYear + last4 = stripePaymentMethodInfo.last4 + additionalProperties = stripePaymentMethodInfo.additionalProperties.toMutableMap() + } + + fun brand(brand: String?) = brand(JsonField.ofNullable(brand)) + + /** Alias for calling [Builder.brand] with `brand.orElse(null)`. */ + fun brand(brand: Optional<String>) = brand(brand.getOrNull()) + + /** + * Sets [Builder.brand] to an arbitrary JSON value. + * + * You should usually call [Builder.brand] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun brand(brand: JsonField<String>) = apply { this.brand = brand } + + fun email(email: String?) = email(JsonField.ofNullable(email)) + + /** Alias for calling [Builder.email] with `email.orElse(null)`. */ + fun email(email: Optional<String>) = email(email.getOrNull()) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun email(email: JsonField<String>) = apply { this.email = email } + + fun expMonth(expMonth: Long?) = expMonth(JsonField.ofNullable(expMonth)) + + /** + * Alias for [Builder.expMonth]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun expMonth(expMonth: Long) = expMonth(expMonth as Long?) + + /** Alias for calling [Builder.expMonth] with `expMonth.orElse(null)`. */ + fun expMonth(expMonth: Optional<Long>) = expMonth(expMonth.getOrNull()) + + /** + * Sets [Builder.expMonth] to an arbitrary JSON value. + * + * You should usually call [Builder.expMonth] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun expMonth(expMonth: JsonField<Long>) = apply { this.expMonth = expMonth } + + fun expYear(expYear: Long?) = expYear(JsonField.ofNullable(expYear)) + + /** + * Alias for [Builder.expYear]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun expYear(expYear: Long) = expYear(expYear as Long?) + + /** Alias for calling [Builder.expYear] with `expYear.orElse(null)`. */ + fun expYear(expYear: Optional<Long>) = expYear(expYear.getOrNull()) + + /** + * Sets [Builder.expYear] to an arbitrary JSON value. + * + * You should usually call [Builder.expYear] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun expYear(expYear: JsonField<Long>) = apply { this.expYear = expYear } + + fun last4(last4: String?) = last4(JsonField.ofNullable(last4)) + + /** Alias for calling [Builder.last4] with `last4.orElse(null)`. */ + fun last4(last4: Optional<String>) = last4(last4.getOrNull()) + + /** + * Sets [Builder.last4] to an arbitrary JSON value. + * + * You should usually call [Builder.last4] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun last4(last4: JsonField<String>) = apply { this.last4 = last4 } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [StripePaymentMethodInfo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): StripePaymentMethodInfo = + StripePaymentMethodInfo( + brand, + email, + expMonth, + expYear, + last4, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): StripePaymentMethodInfo = apply { + if (validated) { + return@apply + } + + brand() + email() + expMonth() + expYear() + last4() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (brand.asKnown().isPresent) 1 else 0) + + (if (email.asKnown().isPresent) 1 else 0) + + (if (expMonth.asKnown().isPresent) 1 else 0) + + (if (expYear.asKnown().isPresent) 1 else 0) + + (if (last4.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is StripePaymentMethodInfo && + brand == other.brand && + email == other.email && + expMonth == other.expMonth && + expYear == other.expYear && + last4 == other.last4 && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(brand, email, expMonth, expYear, last4, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StripePaymentMethodInfo{brand=$brand, email=$email, expMonth=$expMonth, expYear=$expYear, last4=$last4, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/Wallet.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/Wallet.kt new file mode 100644 index 00000000..5e67fa15 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/Wallet.kt @@ -0,0 +1,225 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class Wallet +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val creditBalanceMicros: JsonField<Long>, + private val inflightBalanceMicros: JsonField<Long>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("credit_balance_micros") + @ExcludeMissing + creditBalanceMicros: JsonField<Long> = JsonMissing.of(), + @JsonProperty("inflight_balance_micros") + @ExcludeMissing + inflightBalanceMicros: JsonField<Long> = JsonMissing.of(), + ) : this(creditBalanceMicros, inflightBalanceMicros, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun creditBalanceMicros(): Long = creditBalanceMicros.getRequired("credit_balance_micros") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun inflightBalanceMicros(): Long = inflightBalanceMicros.getRequired("inflight_balance_micros") + + /** + * Returns the raw JSON value of [creditBalanceMicros]. + * + * Unlike [creditBalanceMicros], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("credit_balance_micros") + @ExcludeMissing + fun _creditBalanceMicros(): JsonField<Long> = creditBalanceMicros + + /** + * Returns the raw JSON value of [inflightBalanceMicros]. + * + * Unlike [inflightBalanceMicros], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("inflight_balance_micros") + @ExcludeMissing + fun _inflightBalanceMicros(): JsonField<Long> = inflightBalanceMicros + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Wallet]. + * + * The following fields are required: + * ```java + * .creditBalanceMicros() + * .inflightBalanceMicros() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Wallet]. */ + class Builder internal constructor() { + + private var creditBalanceMicros: JsonField<Long>? = null + private var inflightBalanceMicros: JsonField<Long>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(wallet: Wallet) = apply { + creditBalanceMicros = wallet.creditBalanceMicros + inflightBalanceMicros = wallet.inflightBalanceMicros + additionalProperties = wallet.additionalProperties.toMutableMap() + } + + fun creditBalanceMicros(creditBalanceMicros: Long) = + creditBalanceMicros(JsonField.of(creditBalanceMicros)) + + /** + * Sets [Builder.creditBalanceMicros] to an arbitrary JSON value. + * + * You should usually call [Builder.creditBalanceMicros] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creditBalanceMicros(creditBalanceMicros: JsonField<Long>) = apply { + this.creditBalanceMicros = creditBalanceMicros + } + + fun inflightBalanceMicros(inflightBalanceMicros: Long) = + inflightBalanceMicros(JsonField.of(inflightBalanceMicros)) + + /** + * Sets [Builder.inflightBalanceMicros] to an arbitrary JSON value. + * + * You should usually call [Builder.inflightBalanceMicros] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inflightBalanceMicros(inflightBalanceMicros: JsonField<Long>) = apply { + this.inflightBalanceMicros = inflightBalanceMicros + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Wallet]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .creditBalanceMicros() + * .inflightBalanceMicros() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Wallet = + Wallet( + checkRequired("creditBalanceMicros", creditBalanceMicros), + checkRequired("inflightBalanceMicros", inflightBalanceMicros), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Wallet = apply { + if (validated) { + return@apply + } + + creditBalanceMicros() + inflightBalanceMicros() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (creditBalanceMicros.asKnown().isPresent) 1 else 0) + + (if (inflightBalanceMicros.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Wallet && + creditBalanceMicros == other.creditBalanceMicros && + inflightBalanceMicros == other.inflightBalanceMicros && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(creditBalanceMicros, inflightBalanceMicros, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Wallet{creditBalanceMicros=$creditBalanceMicros, inflightBalanceMicros=$inflightBalanceMicros, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/billing/BillingListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/billing/BillingListParams.kt new file mode 100644 index 00000000..3065416a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/billing/BillingListParams.kt @@ -0,0 +1,170 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.billing + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** Get Organization Billing Info */ +class BillingListParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): BillingListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [BillingListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BillingListParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(billingListParams: BillingListParams) = apply { + additionalHeaders = billingListParams.additionalHeaders.toBuilder() + additionalQueryParams = billingListParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [BillingListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BillingListParams = + BillingListParams(additionalHeaders.build(), additionalQueryParams.build()) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingListParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "BillingListParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/billing/BillingListResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/billing/BillingListResponse.kt new file mode 100644 index 00000000..3132c74c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/billing/BillingListResponse.kt @@ -0,0 +1,752 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.billing + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.orgs.PaymentPlanTier +import com.langsmith_api.api.models.api.v1.orgs.current.CustomerVisiblePlanInfo +import com.langsmith_api.api.models.api.v1.orgs.current.OrganizationConfig +import com.langsmith_api.api.models.api.v1.orgs.current.StripePaymentMethodInfo +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Information about an organization's billing configuration. */ +class BillingListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val config: JsonField<OrganizationConfig>, + private val connectedToMetronome: JsonField<Boolean>, + private val connectedToStripe: JsonField<Boolean>, + private val displayName: JsonField<String>, + private val isPersonal: JsonField<Boolean>, + private val id: JsonField<String>, + private val currentPlan: JsonField<CustomerVisiblePlanInfo>, + private val defaultSsoProvision: JsonField<Boolean>, + private val disabled: JsonField<Boolean>, + private val endOfBillingPeriod: JsonField<OffsetDateTime>, + private val paymentMethod: JsonField<StripePaymentMethodInfo>, + private val reachedMaxWorkspaces: JsonField<Boolean>, + private val tier: JsonField<PaymentPlanTier>, + private val upcomingPlan: JsonField<CustomerVisiblePlanInfo>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("config") + @ExcludeMissing + config: JsonField<OrganizationConfig> = JsonMissing.of(), + @JsonProperty("connected_to_metronome") + @ExcludeMissing + connectedToMetronome: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("connected_to_stripe") + @ExcludeMissing + connectedToStripe: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField<String> = JsonMissing.of(), + @JsonProperty("is_personal") + @ExcludeMissing + isPersonal: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("current_plan") + @ExcludeMissing + currentPlan: JsonField<CustomerVisiblePlanInfo> = JsonMissing.of(), + @JsonProperty("default_sso_provision") + @ExcludeMissing + defaultSsoProvision: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("disabled") @ExcludeMissing disabled: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("end_of_billing_period") + @ExcludeMissing + endOfBillingPeriod: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("payment_method") + @ExcludeMissing + paymentMethod: JsonField<StripePaymentMethodInfo> = JsonMissing.of(), + @JsonProperty("reached_max_workspaces") + @ExcludeMissing + reachedMaxWorkspaces: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("tier") @ExcludeMissing tier: JsonField<PaymentPlanTier> = JsonMissing.of(), + @JsonProperty("upcoming_plan") + @ExcludeMissing + upcomingPlan: JsonField<CustomerVisiblePlanInfo> = JsonMissing.of(), + ) : this( + config, + connectedToMetronome, + connectedToStripe, + displayName, + isPersonal, + id, + currentPlan, + defaultSsoProvision, + disabled, + endOfBillingPeriod, + paymentMethod, + reachedMaxWorkspaces, + tier, + upcomingPlan, + mutableMapOf(), + ) + + /** + * Organization level configuration. May include any field that exists in tenant config and + * additional fields. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun config(): OrganizationConfig = config.getRequired("config") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun connectedToMetronome(): Boolean = connectedToMetronome.getRequired("connected_to_metronome") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun connectedToStripe(): Boolean = connectedToStripe.getRequired("connected_to_stripe") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun displayName(): String = displayName.getRequired("display_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun isPersonal(): Boolean = isPersonal.getRequired("is_personal") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + /** + * Customer visible plan information. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currentPlan(): Optional<CustomerVisiblePlanInfo> = currentPlan.getOptional("current_plan") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun defaultSsoProvision(): Optional<Boolean> = + defaultSsoProvision.getOptional("default_sso_provision") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun disabled(): Optional<Boolean> = disabled.getOptional("disabled") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endOfBillingPeriod(): Optional<OffsetDateTime> = + endOfBillingPeriod.getOptional("end_of_billing_period") + + /** + * Stripe customer billing info. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun paymentMethod(): Optional<StripePaymentMethodInfo> = + paymentMethod.getOptional("payment_method") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun reachedMaxWorkspaces(): Optional<Boolean> = + reachedMaxWorkspaces.getOptional("reached_max_workspaces") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tier(): Optional<PaymentPlanTier> = tier.getOptional("tier") + + /** + * Customer visible plan information. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun upcomingPlan(): Optional<CustomerVisiblePlanInfo> = + upcomingPlan.getOptional("upcoming_plan") + + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("config") @ExcludeMissing fun _config(): JsonField<OrganizationConfig> = config + + /** + * Returns the raw JSON value of [connectedToMetronome]. + * + * Unlike [connectedToMetronome], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("connected_to_metronome") + @ExcludeMissing + fun _connectedToMetronome(): JsonField<Boolean> = connectedToMetronome + + /** + * Returns the raw JSON value of [connectedToStripe]. + * + * Unlike [connectedToStripe], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("connected_to_stripe") + @ExcludeMissing + fun _connectedToStripe(): JsonField<Boolean> = connectedToStripe + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField<String> = displayName + + /** + * Returns the raw JSON value of [isPersonal]. + * + * Unlike [isPersonal], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_personal") @ExcludeMissing fun _isPersonal(): JsonField<Boolean> = isPersonal + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [currentPlan]. + * + * Unlike [currentPlan], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("current_plan") + @ExcludeMissing + fun _currentPlan(): JsonField<CustomerVisiblePlanInfo> = currentPlan + + /** + * Returns the raw JSON value of [defaultSsoProvision]. + * + * Unlike [defaultSsoProvision], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("default_sso_provision") + @ExcludeMissing + fun _defaultSsoProvision(): JsonField<Boolean> = defaultSsoProvision + + /** + * Returns the raw JSON value of [disabled]. + * + * Unlike [disabled], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("disabled") @ExcludeMissing fun _disabled(): JsonField<Boolean> = disabled + + /** + * Returns the raw JSON value of [endOfBillingPeriod]. + * + * Unlike [endOfBillingPeriod], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("end_of_billing_period") + @ExcludeMissing + fun _endOfBillingPeriod(): JsonField<OffsetDateTime> = endOfBillingPeriod + + /** + * Returns the raw JSON value of [paymentMethod]. + * + * Unlike [paymentMethod], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("payment_method") + @ExcludeMissing + fun _paymentMethod(): JsonField<StripePaymentMethodInfo> = paymentMethod + + /** + * Returns the raw JSON value of [reachedMaxWorkspaces]. + * + * Unlike [reachedMaxWorkspaces], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reached_max_workspaces") + @ExcludeMissing + fun _reachedMaxWorkspaces(): JsonField<Boolean> = reachedMaxWorkspaces + + /** + * Returns the raw JSON value of [tier]. + * + * Unlike [tier], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tier") @ExcludeMissing fun _tier(): JsonField<PaymentPlanTier> = tier + + /** + * Returns the raw JSON value of [upcomingPlan]. + * + * Unlike [upcomingPlan], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("upcoming_plan") + @ExcludeMissing + fun _upcomingPlan(): JsonField<CustomerVisiblePlanInfo> = upcomingPlan + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BillingListResponse]. + * + * The following fields are required: + * ```java + * .config() + * .connectedToMetronome() + * .connectedToStripe() + * .displayName() + * .isPersonal() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BillingListResponse]. */ + class Builder internal constructor() { + + private var config: JsonField<OrganizationConfig>? = null + private var connectedToMetronome: JsonField<Boolean>? = null + private var connectedToStripe: JsonField<Boolean>? = null + private var displayName: JsonField<String>? = null + private var isPersonal: JsonField<Boolean>? = null + private var id: JsonField<String> = JsonMissing.of() + private var currentPlan: JsonField<CustomerVisiblePlanInfo> = JsonMissing.of() + private var defaultSsoProvision: JsonField<Boolean> = JsonMissing.of() + private var disabled: JsonField<Boolean> = JsonMissing.of() + private var endOfBillingPeriod: JsonField<OffsetDateTime> = JsonMissing.of() + private var paymentMethod: JsonField<StripePaymentMethodInfo> = JsonMissing.of() + private var reachedMaxWorkspaces: JsonField<Boolean> = JsonMissing.of() + private var tier: JsonField<PaymentPlanTier> = JsonMissing.of() + private var upcomingPlan: JsonField<CustomerVisiblePlanInfo> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(billingListResponse: BillingListResponse) = apply { + config = billingListResponse.config + connectedToMetronome = billingListResponse.connectedToMetronome + connectedToStripe = billingListResponse.connectedToStripe + displayName = billingListResponse.displayName + isPersonal = billingListResponse.isPersonal + id = billingListResponse.id + currentPlan = billingListResponse.currentPlan + defaultSsoProvision = billingListResponse.defaultSsoProvision + disabled = billingListResponse.disabled + endOfBillingPeriod = billingListResponse.endOfBillingPeriod + paymentMethod = billingListResponse.paymentMethod + reachedMaxWorkspaces = billingListResponse.reachedMaxWorkspaces + tier = billingListResponse.tier + upcomingPlan = billingListResponse.upcomingPlan + additionalProperties = billingListResponse.additionalProperties.toMutableMap() + } + + /** + * Organization level configuration. May include any field that exists in tenant config and + * additional fields. + */ + fun config(config: OrganizationConfig) = config(JsonField.of(config)) + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed [OrganizationConfig] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun config(config: JsonField<OrganizationConfig>) = apply { this.config = config } + + fun connectedToMetronome(connectedToMetronome: Boolean) = + connectedToMetronome(JsonField.of(connectedToMetronome)) + + /** + * Sets [Builder.connectedToMetronome] to an arbitrary JSON value. + * + * You should usually call [Builder.connectedToMetronome] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun connectedToMetronome(connectedToMetronome: JsonField<Boolean>) = apply { + this.connectedToMetronome = connectedToMetronome + } + + fun connectedToStripe(connectedToStripe: Boolean) = + connectedToStripe(JsonField.of(connectedToStripe)) + + /** + * Sets [Builder.connectedToStripe] to an arbitrary JSON value. + * + * You should usually call [Builder.connectedToStripe] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun connectedToStripe(connectedToStripe: JsonField<Boolean>) = apply { + this.connectedToStripe = connectedToStripe + } + + fun displayName(displayName: String) = displayName(JsonField.of(displayName)) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun displayName(displayName: JsonField<String>) = apply { this.displayName = displayName } + + fun isPersonal(isPersonal: Boolean) = isPersonal(JsonField.of(isPersonal)) + + /** + * Sets [Builder.isPersonal] to an arbitrary JSON value. + * + * You should usually call [Builder.isPersonal] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isPersonal(isPersonal: JsonField<Boolean>) = apply { this.isPersonal = isPersonal } + + fun id(id: String?) = id(JsonField.ofNullable(id)) + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<String>) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + /** Customer visible plan information. */ + fun currentPlan(currentPlan: CustomerVisiblePlanInfo?) = + currentPlan(JsonField.ofNullable(currentPlan)) + + /** Alias for calling [Builder.currentPlan] with `currentPlan.orElse(null)`. */ + fun currentPlan(currentPlan: Optional<CustomerVisiblePlanInfo>) = + currentPlan(currentPlan.getOrNull()) + + /** + * Sets [Builder.currentPlan] to an arbitrary JSON value. + * + * You should usually call [Builder.currentPlan] with a well-typed [CustomerVisiblePlanInfo] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun currentPlan(currentPlan: JsonField<CustomerVisiblePlanInfo>) = apply { + this.currentPlan = currentPlan + } + + fun defaultSsoProvision(defaultSsoProvision: Boolean) = + defaultSsoProvision(JsonField.of(defaultSsoProvision)) + + /** + * Sets [Builder.defaultSsoProvision] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultSsoProvision] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun defaultSsoProvision(defaultSsoProvision: JsonField<Boolean>) = apply { + this.defaultSsoProvision = defaultSsoProvision + } + + fun disabled(disabled: Boolean) = disabled(JsonField.of(disabled)) + + /** + * Sets [Builder.disabled] to an arbitrary JSON value. + * + * You should usually call [Builder.disabled] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun disabled(disabled: JsonField<Boolean>) = apply { this.disabled = disabled } + + fun endOfBillingPeriod(endOfBillingPeriod: OffsetDateTime?) = + endOfBillingPeriod(JsonField.ofNullable(endOfBillingPeriod)) + + /** + * Alias for calling [Builder.endOfBillingPeriod] with `endOfBillingPeriod.orElse(null)`. + */ + fun endOfBillingPeriod(endOfBillingPeriod: Optional<OffsetDateTime>) = + endOfBillingPeriod(endOfBillingPeriod.getOrNull()) + + /** + * Sets [Builder.endOfBillingPeriod] to an arbitrary JSON value. + * + * You should usually call [Builder.endOfBillingPeriod] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun endOfBillingPeriod(endOfBillingPeriod: JsonField<OffsetDateTime>) = apply { + this.endOfBillingPeriod = endOfBillingPeriod + } + + /** Stripe customer billing info. */ + fun paymentMethod(paymentMethod: StripePaymentMethodInfo?) = + paymentMethod(JsonField.ofNullable(paymentMethod)) + + /** Alias for calling [Builder.paymentMethod] with `paymentMethod.orElse(null)`. */ + fun paymentMethod(paymentMethod: Optional<StripePaymentMethodInfo>) = + paymentMethod(paymentMethod.getOrNull()) + + /** + * Sets [Builder.paymentMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentMethod] with a well-typed + * [StripePaymentMethodInfo] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun paymentMethod(paymentMethod: JsonField<StripePaymentMethodInfo>) = apply { + this.paymentMethod = paymentMethod + } + + fun reachedMaxWorkspaces(reachedMaxWorkspaces: Boolean) = + reachedMaxWorkspaces(JsonField.of(reachedMaxWorkspaces)) + + /** + * Sets [Builder.reachedMaxWorkspaces] to an arbitrary JSON value. + * + * You should usually call [Builder.reachedMaxWorkspaces] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun reachedMaxWorkspaces(reachedMaxWorkspaces: JsonField<Boolean>) = apply { + this.reachedMaxWorkspaces = reachedMaxWorkspaces + } + + fun tier(tier: PaymentPlanTier?) = tier(JsonField.ofNullable(tier)) + + /** Alias for calling [Builder.tier] with `tier.orElse(null)`. */ + fun tier(tier: Optional<PaymentPlanTier>) = tier(tier.getOrNull()) + + /** + * Sets [Builder.tier] to an arbitrary JSON value. + * + * You should usually call [Builder.tier] with a well-typed [PaymentPlanTier] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tier(tier: JsonField<PaymentPlanTier>) = apply { this.tier = tier } + + /** Customer visible plan information. */ + fun upcomingPlan(upcomingPlan: CustomerVisiblePlanInfo?) = + upcomingPlan(JsonField.ofNullable(upcomingPlan)) + + /** Alias for calling [Builder.upcomingPlan] with `upcomingPlan.orElse(null)`. */ + fun upcomingPlan(upcomingPlan: Optional<CustomerVisiblePlanInfo>) = + upcomingPlan(upcomingPlan.getOrNull()) + + /** + * Sets [Builder.upcomingPlan] to an arbitrary JSON value. + * + * You should usually call [Builder.upcomingPlan] with a well-typed + * [CustomerVisiblePlanInfo] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun upcomingPlan(upcomingPlan: JsonField<CustomerVisiblePlanInfo>) = apply { + this.upcomingPlan = upcomingPlan + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BillingListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .config() + * .connectedToMetronome() + * .connectedToStripe() + * .displayName() + * .isPersonal() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BillingListResponse = + BillingListResponse( + checkRequired("config", config), + checkRequired("connectedToMetronome", connectedToMetronome), + checkRequired("connectedToStripe", connectedToStripe), + checkRequired("displayName", displayName), + checkRequired("isPersonal", isPersonal), + id, + currentPlan, + defaultSsoProvision, + disabled, + endOfBillingPeriod, + paymentMethod, + reachedMaxWorkspaces, + tier, + upcomingPlan, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BillingListResponse = apply { + if (validated) { + return@apply + } + + config().validate() + connectedToMetronome() + connectedToStripe() + displayName() + isPersonal() + id() + currentPlan().ifPresent { it.validate() } + defaultSsoProvision() + disabled() + endOfBillingPeriod() + paymentMethod().ifPresent { it.validate() } + reachedMaxWorkspaces() + tier().ifPresent { it.validate() } + upcomingPlan().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (config.asKnown().getOrNull()?.validity() ?: 0) + + (if (connectedToMetronome.asKnown().isPresent) 1 else 0) + + (if (connectedToStripe.asKnown().isPresent) 1 else 0) + + (if (displayName.asKnown().isPresent) 1 else 0) + + (if (isPersonal.asKnown().isPresent) 1 else 0) + + (if (id.asKnown().isPresent) 1 else 0) + + (currentPlan.asKnown().getOrNull()?.validity() ?: 0) + + (if (defaultSsoProvision.asKnown().isPresent) 1 else 0) + + (if (disabled.asKnown().isPresent) 1 else 0) + + (if (endOfBillingPeriod.asKnown().isPresent) 1 else 0) + + (paymentMethod.asKnown().getOrNull()?.validity() ?: 0) + + (if (reachedMaxWorkspaces.asKnown().isPresent) 1 else 0) + + (tier.asKnown().getOrNull()?.validity() ?: 0) + + (upcomingPlan.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingListResponse && + config == other.config && + connectedToMetronome == other.connectedToMetronome && + connectedToStripe == other.connectedToStripe && + displayName == other.displayName && + isPersonal == other.isPersonal && + id == other.id && + currentPlan == other.currentPlan && + defaultSsoProvision == other.defaultSsoProvision && + disabled == other.disabled && + endOfBillingPeriod == other.endOfBillingPeriod && + paymentMethod == other.paymentMethod && + reachedMaxWorkspaces == other.reachedMaxWorkspaces && + tier == other.tier && + upcomingPlan == other.upcomingPlan && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + config, + connectedToMetronome, + connectedToStripe, + displayName, + isPersonal, + id, + currentPlan, + defaultSsoProvision, + disabled, + endOfBillingPeriod, + paymentMethod, + reachedMaxWorkspaces, + tier, + upcomingPlan, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BillingListResponse{config=$config, connectedToMetronome=$connectedToMetronome, connectedToStripe=$connectedToStripe, displayName=$displayName, isPersonal=$isPersonal, id=$id, currentPlan=$currentPlan, defaultSsoProvision=$defaultSsoProvision, disabled=$disabled, endOfBillingPeriod=$endOfBillingPeriod, paymentMethod=$paymentMethod, reachedMaxWorkspaces=$reachedMaxWorkspaces, tier=$tier, upcomingPlan=$upcomingPlan, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/billing/BillingRetrieveUsageParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/billing/BillingRetrieveUsageParams.kt new file mode 100644 index 00000000..80b5d8d4 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/billing/BillingRetrieveUsageParams.kt @@ -0,0 +1,245 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.billing + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get Org Usage */ +class BillingRetrieveUsageParams +private constructor( + private val endingBefore: OffsetDateTime, + private val startingOn: OffsetDateTime, + private val onCurrentPlan: Boolean?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun endingBefore(): OffsetDateTime = endingBefore + + fun startingOn(): OffsetDateTime = startingOn + + fun onCurrentPlan(): Optional<Boolean> = Optional.ofNullable(onCurrentPlan) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BillingRetrieveUsageParams]. + * + * The following fields are required: + * ```java + * .endingBefore() + * .startingOn() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BillingRetrieveUsageParams]. */ + class Builder internal constructor() { + + private var endingBefore: OffsetDateTime? = null + private var startingOn: OffsetDateTime? = null + private var onCurrentPlan: Boolean? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(billingRetrieveUsageParams: BillingRetrieveUsageParams) = apply { + endingBefore = billingRetrieveUsageParams.endingBefore + startingOn = billingRetrieveUsageParams.startingOn + onCurrentPlan = billingRetrieveUsageParams.onCurrentPlan + additionalHeaders = billingRetrieveUsageParams.additionalHeaders.toBuilder() + additionalQueryParams = billingRetrieveUsageParams.additionalQueryParams.toBuilder() + } + + fun endingBefore(endingBefore: OffsetDateTime) = apply { this.endingBefore = endingBefore } + + fun startingOn(startingOn: OffsetDateTime) = apply { this.startingOn = startingOn } + + fun onCurrentPlan(onCurrentPlan: Boolean?) = apply { this.onCurrentPlan = onCurrentPlan } + + /** + * Alias for [Builder.onCurrentPlan]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun onCurrentPlan(onCurrentPlan: Boolean) = onCurrentPlan(onCurrentPlan as Boolean?) + + /** Alias for calling [Builder.onCurrentPlan] with `onCurrentPlan.orElse(null)`. */ + fun onCurrentPlan(onCurrentPlan: Optional<Boolean>) = + onCurrentPlan(onCurrentPlan.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [BillingRetrieveUsageParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .endingBefore() + * .startingOn() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BillingRetrieveUsageParams = + BillingRetrieveUsageParams( + checkRequired("endingBefore", endingBefore), + checkRequired("startingOn", startingOn), + onCurrentPlan, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("ending_before", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(endingBefore)) + put("starting_on", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(startingOn)) + onCurrentPlan?.let { put("on_current_plan", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingRetrieveUsageParams && + endingBefore == other.endingBefore && + startingOn == other.startingOn && + onCurrentPlan == other.onCurrentPlan && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + endingBefore, + startingOn, + onCurrentPlan, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "BillingRetrieveUsageParams{endingBefore=$endingBefore, startingOn=$startingOn, onCurrentPlan=$onCurrentPlan, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/billing/BillingRetrieveUsageResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/billing/BillingRetrieveUsageResponse.kt new file mode 100644 index 00000000..ee6dfc6c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/billing/BillingRetrieveUsageResponse.kt @@ -0,0 +1,540 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.billing + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BillingRetrieveUsageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val billableMetricId: JsonField<String>, + private val billableMetricName: JsonField<String>, + private val customerId: JsonField<String>, + private val endTimestamp: JsonField<String>, + private val groups: JsonField<Groups>, + private val startTimestamp: JsonField<String>, + private val value: JsonField<Double>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField<String> = JsonMissing.of(), + @JsonProperty("billable_metric_name") + @ExcludeMissing + billableMetricName: JsonField<String> = JsonMissing.of(), + @JsonProperty("customer_id") + @ExcludeMissing + customerId: JsonField<String> = JsonMissing.of(), + @JsonProperty("end_timestamp") + @ExcludeMissing + endTimestamp: JsonField<String> = JsonMissing.of(), + @JsonProperty("groups") @ExcludeMissing groups: JsonField<Groups> = JsonMissing.of(), + @JsonProperty("start_timestamp") + @ExcludeMissing + startTimestamp: JsonField<String> = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField<Double> = JsonMissing.of(), + ) : this( + billableMetricId, + billableMetricName, + customerId, + endTimestamp, + groups, + startTimestamp, + value, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billableMetricId(): String = billableMetricId.getRequired("billable_metric_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billableMetricName(): String = billableMetricName.getRequired("billable_metric_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun customerId(): String = customerId.getRequired("customer_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun endTimestamp(): String = endTimestamp.getRequired("end_timestamp") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun groups(): Optional<Groups> = groups.getOptional("groups") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun startTimestamp(): String = startTimestamp.getRequired("start_timestamp") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun value(): Optional<Double> = value.getOptional("value") + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField<String> = billableMetricId + + /** + * Returns the raw JSON value of [billableMetricName]. + * + * Unlike [billableMetricName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("billable_metric_name") + @ExcludeMissing + fun _billableMetricName(): JsonField<String> = billableMetricName + + /** + * Returns the raw JSON value of [customerId]. + * + * Unlike [customerId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("customer_id") @ExcludeMissing fun _customerId(): JsonField<String> = customerId + + /** + * Returns the raw JSON value of [endTimestamp]. + * + * Unlike [endTimestamp], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_timestamp") + @ExcludeMissing + fun _endTimestamp(): JsonField<String> = endTimestamp + + /** + * Returns the raw JSON value of [groups]. + * + * Unlike [groups], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("groups") @ExcludeMissing fun _groups(): JsonField<Groups> = groups + + /** + * Returns the raw JSON value of [startTimestamp]. + * + * Unlike [startTimestamp], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_timestamp") + @ExcludeMissing + fun _startTimestamp(): JsonField<String> = startTimestamp + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField<Double> = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BillingRetrieveUsageResponse]. + * + * The following fields are required: + * ```java + * .billableMetricId() + * .billableMetricName() + * .customerId() + * .endTimestamp() + * .groups() + * .startTimestamp() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BillingRetrieveUsageResponse]. */ + class Builder internal constructor() { + + private var billableMetricId: JsonField<String>? = null + private var billableMetricName: JsonField<String>? = null + private var customerId: JsonField<String>? = null + private var endTimestamp: JsonField<String>? = null + private var groups: JsonField<Groups>? = null + private var startTimestamp: JsonField<String>? = null + private var value: JsonField<Double>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(billingRetrieveUsageResponse: BillingRetrieveUsageResponse) = apply { + billableMetricId = billingRetrieveUsageResponse.billableMetricId + billableMetricName = billingRetrieveUsageResponse.billableMetricName + customerId = billingRetrieveUsageResponse.customerId + endTimestamp = billingRetrieveUsageResponse.endTimestamp + groups = billingRetrieveUsageResponse.groups + startTimestamp = billingRetrieveUsageResponse.startTimestamp + value = billingRetrieveUsageResponse.value + additionalProperties = billingRetrieveUsageResponse.additionalProperties.toMutableMap() + } + + fun billableMetricId(billableMetricId: String) = + billableMetricId(JsonField.of(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billableMetricId(billableMetricId: JsonField<String>) = apply { + this.billableMetricId = billableMetricId + } + + fun billableMetricName(billableMetricName: String) = + billableMetricName(JsonField.of(billableMetricName)) + + /** + * Sets [Builder.billableMetricName] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billableMetricName(billableMetricName: JsonField<String>) = apply { + this.billableMetricName = billableMetricName + } + + fun customerId(customerId: String) = customerId(JsonField.of(customerId)) + + /** + * Sets [Builder.customerId] to an arbitrary JSON value. + * + * You should usually call [Builder.customerId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun customerId(customerId: JsonField<String>) = apply { this.customerId = customerId } + + fun endTimestamp(endTimestamp: String) = endTimestamp(JsonField.of(endTimestamp)) + + /** + * Sets [Builder.endTimestamp] to an arbitrary JSON value. + * + * You should usually call [Builder.endTimestamp] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun endTimestamp(endTimestamp: JsonField<String>) = apply { + this.endTimestamp = endTimestamp + } + + fun groups(groups: Groups?) = groups(JsonField.ofNullable(groups)) + + /** Alias for calling [Builder.groups] with `groups.orElse(null)`. */ + fun groups(groups: Optional<Groups>) = groups(groups.getOrNull()) + + /** + * Sets [Builder.groups] to an arbitrary JSON value. + * + * You should usually call [Builder.groups] with a well-typed [Groups] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun groups(groups: JsonField<Groups>) = apply { this.groups = groups } + + fun startTimestamp(startTimestamp: String) = startTimestamp(JsonField.of(startTimestamp)) + + /** + * Sets [Builder.startTimestamp] to an arbitrary JSON value. + * + * You should usually call [Builder.startTimestamp] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTimestamp(startTimestamp: JsonField<String>) = apply { + this.startTimestamp = startTimestamp + } + + fun value(value: Double?) = value(JsonField.ofNullable(value)) + + /** + * Alias for [Builder.value]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun value(value: Double) = value(value as Double?) + + /** Alias for calling [Builder.value] with `value.orElse(null)`. */ + fun value(value: Optional<Double>) = value(value.getOrNull()) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun value(value: JsonField<Double>) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BillingRetrieveUsageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .billableMetricId() + * .billableMetricName() + * .customerId() + * .endTimestamp() + * .groups() + * .startTimestamp() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BillingRetrieveUsageResponse = + BillingRetrieveUsageResponse( + checkRequired("billableMetricId", billableMetricId), + checkRequired("billableMetricName", billableMetricName), + checkRequired("customerId", customerId), + checkRequired("endTimestamp", endTimestamp), + checkRequired("groups", groups), + checkRequired("startTimestamp", startTimestamp), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BillingRetrieveUsageResponse = apply { + if (validated) { + return@apply + } + + billableMetricId() + billableMetricName() + customerId() + endTimestamp() + groups().ifPresent { it.validate() } + startTimestamp() + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billableMetricName.asKnown().isPresent) 1 else 0) + + (if (customerId.asKnown().isPresent) 1 else 0) + + (if (endTimestamp.asKnown().isPresent) 1 else 0) + + (groups.asKnown().getOrNull()?.validity() ?: 0) + + (if (startTimestamp.asKnown().isPresent) 1 else 0) + + (if (value.asKnown().isPresent) 1 else 0) + + class Groups + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Groups]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Groups]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(groups: Groups) = apply { + additionalProperties = groups.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Groups]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Groups = Groups(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Groups = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Groups && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Groups{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingRetrieveUsageResponse && + billableMetricId == other.billableMetricId && + billableMetricName == other.billableMetricName && + customerId == other.customerId && + endTimestamp == other.endTimestamp && + groups == other.groups && + startTimestamp == other.startTimestamp && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + billableMetricId, + billableMetricName, + customerId, + endTimestamp, + groups, + startTimestamp, + value, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BillingRetrieveUsageResponse{billableMetricId=$billableMetricId, billableMetricName=$billableMetricName, customerId=$customerId, endTimestamp=$endTimestamp, groups=$groups, startTimestamp=$startTimestamp, value=$value, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/BusinessInfoBusinessInfoParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/BusinessInfoBusinessInfoParams.kt new file mode 100644 index 00000000..1936e4d4 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/BusinessInfoBusinessInfoParams.kt @@ -0,0 +1,625 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.businessinfo + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Set Company Info */ +class BusinessInfoBusinessInfoParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Stripe customer billing information. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun companyInfo(): Optional<StripeBusinessBillingInfo> = body.companyInfo() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceEmail(): Optional<String> = body.invoiceEmail() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun isBusiness(): Optional<Boolean> = body.isBusiness() + + /** + * Stripe tax ID. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun taxId(): Optional<StripeTaxId> = body.taxId() + + /** + * Returns the raw JSON value of [companyInfo]. + * + * Unlike [companyInfo], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _companyInfo(): JsonField<StripeBusinessBillingInfo> = body._companyInfo() + + /** + * Returns the raw JSON value of [invoiceEmail]. + * + * Unlike [invoiceEmail], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _invoiceEmail(): JsonField<String> = body._invoiceEmail() + + /** + * Returns the raw JSON value of [isBusiness]. + * + * Unlike [isBusiness], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _isBusiness(): JsonField<Boolean> = body._isBusiness() + + /** + * Returns the raw JSON value of [taxId]. + * + * Unlike [taxId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _taxId(): JsonField<StripeTaxId> = body._taxId() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): BusinessInfoBusinessInfoParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [BusinessInfoBusinessInfoParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BusinessInfoBusinessInfoParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(businessInfoBusinessInfoParams: BusinessInfoBusinessInfoParams) = apply { + body = businessInfoBusinessInfoParams.body.toBuilder() + additionalHeaders = businessInfoBusinessInfoParams.additionalHeaders.toBuilder() + additionalQueryParams = businessInfoBusinessInfoParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [companyInfo] + * - [invoiceEmail] + * - [isBusiness] + * - [taxId] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** Stripe customer billing information. */ + fun companyInfo(companyInfo: StripeBusinessBillingInfo?) = apply { + body.companyInfo(companyInfo) + } + + /** Alias for calling [Builder.companyInfo] with `companyInfo.orElse(null)`. */ + fun companyInfo(companyInfo: Optional<StripeBusinessBillingInfo>) = + companyInfo(companyInfo.getOrNull()) + + /** + * Sets [Builder.companyInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.companyInfo] with a well-typed + * [StripeBusinessBillingInfo] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun companyInfo(companyInfo: JsonField<StripeBusinessBillingInfo>) = apply { + body.companyInfo(companyInfo) + } + + fun invoiceEmail(invoiceEmail: String?) = apply { body.invoiceEmail(invoiceEmail) } + + /** Alias for calling [Builder.invoiceEmail] with `invoiceEmail.orElse(null)`. */ + fun invoiceEmail(invoiceEmail: Optional<String>) = invoiceEmail(invoiceEmail.getOrNull()) + + /** + * Sets [Builder.invoiceEmail] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceEmail] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoiceEmail(invoiceEmail: JsonField<String>) = apply { + body.invoiceEmail(invoiceEmail) + } + + fun isBusiness(isBusiness: Boolean) = apply { body.isBusiness(isBusiness) } + + /** + * Sets [Builder.isBusiness] to an arbitrary JSON value. + * + * You should usually call [Builder.isBusiness] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isBusiness(isBusiness: JsonField<Boolean>) = apply { body.isBusiness(isBusiness) } + + /** Stripe tax ID. */ + fun taxId(taxId: StripeTaxId?) = apply { body.taxId(taxId) } + + /** Alias for calling [Builder.taxId] with `taxId.orElse(null)`. */ + fun taxId(taxId: Optional<StripeTaxId>) = taxId(taxId.getOrNull()) + + /** + * Sets [Builder.taxId] to an arbitrary JSON value. + * + * You should usually call [Builder.taxId] with a well-typed [StripeTaxId] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun taxId(taxId: JsonField<StripeTaxId>) = apply { body.taxId(taxId) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [BusinessInfoBusinessInfoParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BusinessInfoBusinessInfoParams = + BusinessInfoBusinessInfoParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val companyInfo: JsonField<StripeBusinessBillingInfo>, + private val invoiceEmail: JsonField<String>, + private val isBusiness: JsonField<Boolean>, + private val taxId: JsonField<StripeTaxId>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("company_info") + @ExcludeMissing + companyInfo: JsonField<StripeBusinessBillingInfo> = JsonMissing.of(), + @JsonProperty("invoice_email") + @ExcludeMissing + invoiceEmail: JsonField<String> = JsonMissing.of(), + @JsonProperty("is_business") + @ExcludeMissing + isBusiness: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("tax_id") @ExcludeMissing taxId: JsonField<StripeTaxId> = JsonMissing.of(), + ) : this(companyInfo, invoiceEmail, isBusiness, taxId, mutableMapOf()) + + /** + * Stripe customer billing information. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun companyInfo(): Optional<StripeBusinessBillingInfo> = + companyInfo.getOptional("company_info") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun invoiceEmail(): Optional<String> = invoiceEmail.getOptional("invoice_email") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun isBusiness(): Optional<Boolean> = isBusiness.getOptional("is_business") + + /** + * Stripe tax ID. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun taxId(): Optional<StripeTaxId> = taxId.getOptional("tax_id") + + /** + * Returns the raw JSON value of [companyInfo]. + * + * Unlike [companyInfo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("company_info") + @ExcludeMissing + fun _companyInfo(): JsonField<StripeBusinessBillingInfo> = companyInfo + + /** + * Returns the raw JSON value of [invoiceEmail]. + * + * Unlike [invoiceEmail], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("invoice_email") + @ExcludeMissing + fun _invoiceEmail(): JsonField<String> = invoiceEmail + + /** + * Returns the raw JSON value of [isBusiness]. + * + * Unlike [isBusiness], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_business") + @ExcludeMissing + fun _isBusiness(): JsonField<Boolean> = isBusiness + + /** + * Returns the raw JSON value of [taxId]. + * + * Unlike [taxId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tax_id") @ExcludeMissing fun _taxId(): JsonField<StripeTaxId> = taxId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var companyInfo: JsonField<StripeBusinessBillingInfo> = JsonMissing.of() + private var invoiceEmail: JsonField<String> = JsonMissing.of() + private var isBusiness: JsonField<Boolean> = JsonMissing.of() + private var taxId: JsonField<StripeTaxId> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + companyInfo = body.companyInfo + invoiceEmail = body.invoiceEmail + isBusiness = body.isBusiness + taxId = body.taxId + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** Stripe customer billing information. */ + fun companyInfo(companyInfo: StripeBusinessBillingInfo?) = + companyInfo(JsonField.ofNullable(companyInfo)) + + /** Alias for calling [Builder.companyInfo] with `companyInfo.orElse(null)`. */ + fun companyInfo(companyInfo: Optional<StripeBusinessBillingInfo>) = + companyInfo(companyInfo.getOrNull()) + + /** + * Sets [Builder.companyInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.companyInfo] with a well-typed + * [StripeBusinessBillingInfo] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun companyInfo(companyInfo: JsonField<StripeBusinessBillingInfo>) = apply { + this.companyInfo = companyInfo + } + + fun invoiceEmail(invoiceEmail: String?) = + invoiceEmail(JsonField.ofNullable(invoiceEmail)) + + /** Alias for calling [Builder.invoiceEmail] with `invoiceEmail.orElse(null)`. */ + fun invoiceEmail(invoiceEmail: Optional<String>) = + invoiceEmail(invoiceEmail.getOrNull()) + + /** + * Sets [Builder.invoiceEmail] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceEmail] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceEmail(invoiceEmail: JsonField<String>) = apply { + this.invoiceEmail = invoiceEmail + } + + fun isBusiness(isBusiness: Boolean) = isBusiness(JsonField.of(isBusiness)) + + /** + * Sets [Builder.isBusiness] to an arbitrary JSON value. + * + * You should usually call [Builder.isBusiness] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isBusiness(isBusiness: JsonField<Boolean>) = apply { this.isBusiness = isBusiness } + + /** Stripe tax ID. */ + fun taxId(taxId: StripeTaxId?) = taxId(JsonField.ofNullable(taxId)) + + /** Alias for calling [Builder.taxId] with `taxId.orElse(null)`. */ + fun taxId(taxId: Optional<StripeTaxId>) = taxId(taxId.getOrNull()) + + /** + * Sets [Builder.taxId] to an arbitrary JSON value. + * + * You should usually call [Builder.taxId] with a well-typed [StripeTaxId] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun taxId(taxId: JsonField<StripeTaxId>) = apply { this.taxId = taxId } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = + Body( + companyInfo, + invoiceEmail, + isBusiness, + taxId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + companyInfo().ifPresent { it.validate() } + invoiceEmail() + isBusiness() + taxId().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (companyInfo.asKnown().getOrNull()?.validity() ?: 0) + + (if (invoiceEmail.asKnown().isPresent) 1 else 0) + + (if (isBusiness.asKnown().isPresent) 1 else 0) + + (taxId.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + companyInfo == other.companyInfo && + invoiceEmail == other.invoiceEmail && + isBusiness == other.isBusiness && + taxId == other.taxId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(companyInfo, invoiceEmail, isBusiness, taxId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{companyInfo=$companyInfo, invoiceEmail=$invoiceEmail, isBusiness=$isBusiness, taxId=$taxId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BusinessInfoBusinessInfoParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "BusinessInfoBusinessInfoParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/BusinessInfoBusinessInfoResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/BusinessInfoBusinessInfoResponse.kt new file mode 100644 index 00000000..e3864b14 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/BusinessInfoBusinessInfoResponse.kt @@ -0,0 +1,121 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.businessinfo + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class BusinessInfoBusinessInfoResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BusinessInfoBusinessInfoResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BusinessInfoBusinessInfoResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(businessInfoBusinessInfoResponse: BusinessInfoBusinessInfoResponse) = + apply { + additionalProperties = + businessInfoBusinessInfoResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BusinessInfoBusinessInfoResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BusinessInfoBusinessInfoResponse = + BusinessInfoBusinessInfoResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): BusinessInfoBusinessInfoResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BusinessInfoBusinessInfoResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BusinessInfoBusinessInfoResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/BusinessInfoRetrieveBusinessInfoParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/BusinessInfoRetrieveBusinessInfoParams.kt new file mode 100644 index 00000000..bc276c72 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/BusinessInfoRetrieveBusinessInfoParams.kt @@ -0,0 +1,179 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.businessinfo + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** Get Company Info */ +class BusinessInfoRetrieveBusinessInfoParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): BusinessInfoRetrieveBusinessInfoParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [BusinessInfoRetrieveBusinessInfoParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BusinessInfoRetrieveBusinessInfoParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + businessInfoRetrieveBusinessInfoParams: BusinessInfoRetrieveBusinessInfoParams + ) = apply { + additionalHeaders = businessInfoRetrieveBusinessInfoParams.additionalHeaders.toBuilder() + additionalQueryParams = + businessInfoRetrieveBusinessInfoParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [BusinessInfoRetrieveBusinessInfoParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BusinessInfoRetrieveBusinessInfoParams = + BusinessInfoRetrieveBusinessInfoParams( + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BusinessInfoRetrieveBusinessInfoParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "BusinessInfoRetrieveBusinessInfoParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/BusinessInfoRetrieveBusinessInfoResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/BusinessInfoRetrieveBusinessInfoResponse.kt new file mode 100644 index 00000000..e5f6698e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/BusinessInfoRetrieveBusinessInfoResponse.kt @@ -0,0 +1,295 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.businessinfo + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BusinessInfoRetrieveBusinessInfoResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val companyInfo: JsonField<StripeBusinessBillingInfo>, + private val invoiceEmail: JsonField<String>, + private val isBusiness: JsonField<Boolean>, + private val taxId: JsonField<StripeTaxId>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("company_info") + @ExcludeMissing + companyInfo: JsonField<StripeBusinessBillingInfo> = JsonMissing.of(), + @JsonProperty("invoice_email") + @ExcludeMissing + invoiceEmail: JsonField<String> = JsonMissing.of(), + @JsonProperty("is_business") + @ExcludeMissing + isBusiness: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("tax_id") @ExcludeMissing taxId: JsonField<StripeTaxId> = JsonMissing.of(), + ) : this(companyInfo, invoiceEmail, isBusiness, taxId, mutableMapOf()) + + /** + * Stripe customer billing information. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun companyInfo(): Optional<StripeBusinessBillingInfo> = companyInfo.getOptional("company_info") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceEmail(): Optional<String> = invoiceEmail.getOptional("invoice_email") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun isBusiness(): Optional<Boolean> = isBusiness.getOptional("is_business") + + /** + * Stripe tax ID. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun taxId(): Optional<StripeTaxId> = taxId.getOptional("tax_id") + + /** + * Returns the raw JSON value of [companyInfo]. + * + * Unlike [companyInfo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("company_info") + @ExcludeMissing + fun _companyInfo(): JsonField<StripeBusinessBillingInfo> = companyInfo + + /** + * Returns the raw JSON value of [invoiceEmail]. + * + * Unlike [invoiceEmail], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("invoice_email") + @ExcludeMissing + fun _invoiceEmail(): JsonField<String> = invoiceEmail + + /** + * Returns the raw JSON value of [isBusiness]. + * + * Unlike [isBusiness], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_business") @ExcludeMissing fun _isBusiness(): JsonField<Boolean> = isBusiness + + /** + * Returns the raw JSON value of [taxId]. + * + * Unlike [taxId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tax_id") @ExcludeMissing fun _taxId(): JsonField<StripeTaxId> = taxId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BusinessInfoRetrieveBusinessInfoResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BusinessInfoRetrieveBusinessInfoResponse]. */ + class Builder internal constructor() { + + private var companyInfo: JsonField<StripeBusinessBillingInfo> = JsonMissing.of() + private var invoiceEmail: JsonField<String> = JsonMissing.of() + private var isBusiness: JsonField<Boolean> = JsonMissing.of() + private var taxId: JsonField<StripeTaxId> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from( + businessInfoRetrieveBusinessInfoResponse: BusinessInfoRetrieveBusinessInfoResponse + ) = apply { + companyInfo = businessInfoRetrieveBusinessInfoResponse.companyInfo + invoiceEmail = businessInfoRetrieveBusinessInfoResponse.invoiceEmail + isBusiness = businessInfoRetrieveBusinessInfoResponse.isBusiness + taxId = businessInfoRetrieveBusinessInfoResponse.taxId + additionalProperties = + businessInfoRetrieveBusinessInfoResponse.additionalProperties.toMutableMap() + } + + /** Stripe customer billing information. */ + fun companyInfo(companyInfo: StripeBusinessBillingInfo?) = + companyInfo(JsonField.ofNullable(companyInfo)) + + /** Alias for calling [Builder.companyInfo] with `companyInfo.orElse(null)`. */ + fun companyInfo(companyInfo: Optional<StripeBusinessBillingInfo>) = + companyInfo(companyInfo.getOrNull()) + + /** + * Sets [Builder.companyInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.companyInfo] with a well-typed + * [StripeBusinessBillingInfo] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun companyInfo(companyInfo: JsonField<StripeBusinessBillingInfo>) = apply { + this.companyInfo = companyInfo + } + + fun invoiceEmail(invoiceEmail: String?) = invoiceEmail(JsonField.ofNullable(invoiceEmail)) + + /** Alias for calling [Builder.invoiceEmail] with `invoiceEmail.orElse(null)`. */ + fun invoiceEmail(invoiceEmail: Optional<String>) = invoiceEmail(invoiceEmail.getOrNull()) + + /** + * Sets [Builder.invoiceEmail] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceEmail] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoiceEmail(invoiceEmail: JsonField<String>) = apply { + this.invoiceEmail = invoiceEmail + } + + fun isBusiness(isBusiness: Boolean) = isBusiness(JsonField.of(isBusiness)) + + /** + * Sets [Builder.isBusiness] to an arbitrary JSON value. + * + * You should usually call [Builder.isBusiness] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isBusiness(isBusiness: JsonField<Boolean>) = apply { this.isBusiness = isBusiness } + + /** Stripe tax ID. */ + fun taxId(taxId: StripeTaxId?) = taxId(JsonField.ofNullable(taxId)) + + /** Alias for calling [Builder.taxId] with `taxId.orElse(null)`. */ + fun taxId(taxId: Optional<StripeTaxId>) = taxId(taxId.getOrNull()) + + /** + * Sets [Builder.taxId] to an arbitrary JSON value. + * + * You should usually call [Builder.taxId] with a well-typed [StripeTaxId] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun taxId(taxId: JsonField<StripeTaxId>) = apply { this.taxId = taxId } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BusinessInfoRetrieveBusinessInfoResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BusinessInfoRetrieveBusinessInfoResponse = + BusinessInfoRetrieveBusinessInfoResponse( + companyInfo, + invoiceEmail, + isBusiness, + taxId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BusinessInfoRetrieveBusinessInfoResponse = apply { + if (validated) { + return@apply + } + + companyInfo().ifPresent { it.validate() } + invoiceEmail() + isBusiness() + taxId().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (companyInfo.asKnown().getOrNull()?.validity() ?: 0) + + (if (invoiceEmail.asKnown().isPresent) 1 else 0) + + (if (isBusiness.asKnown().isPresent) 1 else 0) + + (taxId.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BusinessInfoRetrieveBusinessInfoResponse && + companyInfo == other.companyInfo && + invoiceEmail == other.invoiceEmail && + isBusiness == other.isBusiness && + taxId == other.taxId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(companyInfo, invoiceEmail, isBusiness, taxId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BusinessInfoRetrieveBusinessInfoResponse{companyInfo=$companyInfo, invoiceEmail=$invoiceEmail, isBusiness=$isBusiness, taxId=$taxId, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/StripeBusinessBillingInfo.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/StripeBusinessBillingInfo.kt new file mode 100644 index 00000000..c127d142 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/StripeBusinessBillingInfo.kt @@ -0,0 +1,217 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.businessinfo + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.orgs.current.StripeCustomerAddress +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Stripe customer billing information. */ +class StripeBusinessBillingInfo +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val name: JsonField<String>, + private val address: JsonField<StripeCustomerAddress>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("address") + @ExcludeMissing + address: JsonField<StripeCustomerAddress> = JsonMissing.of(), + ) : this(name, address, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Stripe customer address. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun address(): Optional<StripeCustomerAddress> = address.getOptional("address") + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [address]. + * + * Unlike [address], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("address") + @ExcludeMissing + fun _address(): JsonField<StripeCustomerAddress> = address + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [StripeBusinessBillingInfo]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StripeBusinessBillingInfo]. */ + class Builder internal constructor() { + + private var name: JsonField<String>? = null + private var address: JsonField<StripeCustomerAddress> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(stripeBusinessBillingInfo: StripeBusinessBillingInfo) = apply { + name = stripeBusinessBillingInfo.name + address = stripeBusinessBillingInfo.address + additionalProperties = stripeBusinessBillingInfo.additionalProperties.toMutableMap() + } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + /** Stripe customer address. */ + fun address(address: StripeCustomerAddress?) = address(JsonField.ofNullable(address)) + + /** Alias for calling [Builder.address] with `address.orElse(null)`. */ + fun address(address: Optional<StripeCustomerAddress>) = address(address.getOrNull()) + + /** + * Sets [Builder.address] to an arbitrary JSON value. + * + * You should usually call [Builder.address] with a well-typed [StripeCustomerAddress] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun address(address: JsonField<StripeCustomerAddress>) = apply { this.address = address } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [StripeBusinessBillingInfo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): StripeBusinessBillingInfo = + StripeBusinessBillingInfo( + checkRequired("name", name), + address, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): StripeBusinessBillingInfo = apply { + if (validated) { + return@apply + } + + name() + address().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (name.asKnown().isPresent) 1 else 0) + (address.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is StripeBusinessBillingInfo && + name == other.name && + address == other.address && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(name, address, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StripeBusinessBillingInfo{name=$name, address=$address, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/StripeTaxId.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/StripeTaxId.kt new file mode 100644 index 00000000..12769701 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/StripeTaxId.kt @@ -0,0 +1,205 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.businessinfo + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +/** Stripe tax ID. */ +class StripeTaxId +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val type: JsonField<String>, + private val value: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField<String> = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField<String> = JsonMissing.of(), + ) : this(type, value, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): String = type.getRequired("type") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun value(): String = value.getRequired("value") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField<String> = type + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField<String> = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [StripeTaxId]. + * + * The following fields are required: + * ```java + * .type() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StripeTaxId]. */ + class Builder internal constructor() { + + private var type: JsonField<String>? = null + private var value: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(stripeTaxId: StripeTaxId) = apply { + type = stripeTaxId.type + value = stripeTaxId.value + additionalProperties = stripeTaxId.additionalProperties.toMutableMap() + } + + fun type(type: String) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField<String>) = apply { this.type = type } + + fun value(value: String) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun value(value: JsonField<String>) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [StripeTaxId]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): StripeTaxId = + StripeTaxId( + checkRequired("type", type), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): StripeTaxId = apply { + if (validated) { + return@apply + } + + type() + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (type.asKnown().isPresent) 1 else 0) + (if (value.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is StripeTaxId && + type == other.type && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, value, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StripeTaxId{type=$type, value=$value, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/info/InfoListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/info/InfoListParams.kt new file mode 100644 index 00000000..4c2064c3 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/info/InfoListParams.kt @@ -0,0 +1,170 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.info + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** Get Current Organization Info */ +class InfoListParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): InfoListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [InfoListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InfoListParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(infoListParams: InfoListParams) = apply { + additionalHeaders = infoListParams.additionalHeaders.toBuilder() + additionalQueryParams = infoListParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [InfoListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InfoListParams = + InfoListParams(additionalHeaders.build(), additionalQueryParams.build()) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InfoListParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "InfoListParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/info/InfoPatchAllParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/info/InfoPatchAllParams.kt new file mode 100644 index 00000000..f94fb326 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/info/InfoPatchAllParams.kt @@ -0,0 +1,900 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.info + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Update Current Organization Info */ +class InfoPatchAllParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun displayName(): Optional<String> = body.displayName() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun jitProvisioningEnabled(): Optional<Boolean> = body.jitProvisioningEnabled() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun patCreationDisabled(): Optional<Boolean> = body.patCreationDisabled() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun publicSharingDisabled(): Optional<Boolean> = body.publicSharingDisabled() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun unshareAll(): Optional<Boolean> = body.unshareAll() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun workspaceAdminCanInviteToOrg(): Optional<Boolean> = body.workspaceAdminCanInviteToOrg() + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _displayName(): JsonField<String> = body._displayName() + + /** + * Returns the raw JSON value of [jitProvisioningEnabled]. + * + * Unlike [jitProvisioningEnabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _jitProvisioningEnabled(): JsonField<Boolean> = body._jitProvisioningEnabled() + + /** + * Returns the raw JSON value of [patCreationDisabled]. + * + * Unlike [patCreationDisabled], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _patCreationDisabled(): JsonField<Boolean> = body._patCreationDisabled() + + /** + * Returns the raw JSON value of [publicSharingDisabled]. + * + * Unlike [publicSharingDisabled], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _publicSharingDisabled(): JsonField<Boolean> = body._publicSharingDisabled() + + /** + * Returns the raw JSON value of [unshareAll]. + * + * Unlike [unshareAll], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _unshareAll(): JsonField<Boolean> = body._unshareAll() + + /** + * Returns the raw JSON value of [workspaceAdminCanInviteToOrg]. + * + * Unlike [workspaceAdminCanInviteToOrg], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _workspaceAdminCanInviteToOrg(): JsonField<Boolean> = body._workspaceAdminCanInviteToOrg() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): InfoPatchAllParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [InfoPatchAllParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InfoPatchAllParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(infoPatchAllParams: InfoPatchAllParams) = apply { + body = infoPatchAllParams.body.toBuilder() + additionalHeaders = infoPatchAllParams.additionalHeaders.toBuilder() + additionalQueryParams = infoPatchAllParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [displayName] + * - [jitProvisioningEnabled] + * - [patCreationDisabled] + * - [publicSharingDisabled] + * - [unshareAll] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun displayName(displayName: String) = apply { body.displayName(displayName) } + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun displayName(displayName: JsonField<String>) = apply { body.displayName(displayName) } + + fun jitProvisioningEnabled(jitProvisioningEnabled: Boolean?) = apply { + body.jitProvisioningEnabled(jitProvisioningEnabled) + } + + /** + * Alias for [Builder.jitProvisioningEnabled]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun jitProvisioningEnabled(jitProvisioningEnabled: Boolean) = + jitProvisioningEnabled(jitProvisioningEnabled as Boolean?) + + /** + * Alias for calling [Builder.jitProvisioningEnabled] with + * `jitProvisioningEnabled.orElse(null)`. + */ + fun jitProvisioningEnabled(jitProvisioningEnabled: Optional<Boolean>) = + jitProvisioningEnabled(jitProvisioningEnabled.getOrNull()) + + /** + * Sets [Builder.jitProvisioningEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.jitProvisioningEnabled] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun jitProvisioningEnabled(jitProvisioningEnabled: JsonField<Boolean>) = apply { + body.jitProvisioningEnabled(jitProvisioningEnabled) + } + + fun patCreationDisabled(patCreationDisabled: Boolean?) = apply { + body.patCreationDisabled(patCreationDisabled) + } + + /** + * Alias for [Builder.patCreationDisabled]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun patCreationDisabled(patCreationDisabled: Boolean) = + patCreationDisabled(patCreationDisabled as Boolean?) + + /** + * Alias for calling [Builder.patCreationDisabled] with `patCreationDisabled.orElse(null)`. + */ + fun patCreationDisabled(patCreationDisabled: Optional<Boolean>) = + patCreationDisabled(patCreationDisabled.getOrNull()) + + /** + * Sets [Builder.patCreationDisabled] to an arbitrary JSON value. + * + * You should usually call [Builder.patCreationDisabled] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun patCreationDisabled(patCreationDisabled: JsonField<Boolean>) = apply { + body.patCreationDisabled(patCreationDisabled) + } + + fun publicSharingDisabled(publicSharingDisabled: Boolean?) = apply { + body.publicSharingDisabled(publicSharingDisabled) + } + + /** + * Alias for [Builder.publicSharingDisabled]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun publicSharingDisabled(publicSharingDisabled: Boolean) = + publicSharingDisabled(publicSharingDisabled as Boolean?) + + /** + * Alias for calling [Builder.publicSharingDisabled] with + * `publicSharingDisabled.orElse(null)`. + */ + fun publicSharingDisabled(publicSharingDisabled: Optional<Boolean>) = + publicSharingDisabled(publicSharingDisabled.getOrNull()) + + /** + * Sets [Builder.publicSharingDisabled] to an arbitrary JSON value. + * + * You should usually call [Builder.publicSharingDisabled] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun publicSharingDisabled(publicSharingDisabled: JsonField<Boolean>) = apply { + body.publicSharingDisabled(publicSharingDisabled) + } + + fun unshareAll(unshareAll: Boolean?) = apply { body.unshareAll(unshareAll) } + + /** + * Alias for [Builder.unshareAll]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun unshareAll(unshareAll: Boolean) = unshareAll(unshareAll as Boolean?) + + /** Alias for calling [Builder.unshareAll] with `unshareAll.orElse(null)`. */ + fun unshareAll(unshareAll: Optional<Boolean>) = unshareAll(unshareAll.getOrNull()) + + /** + * Sets [Builder.unshareAll] to an arbitrary JSON value. + * + * You should usually call [Builder.unshareAll] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun unshareAll(unshareAll: JsonField<Boolean>) = apply { body.unshareAll(unshareAll) } + + fun workspaceAdminCanInviteToOrg(workspaceAdminCanInviteToOrg: Boolean?) = apply { + body.workspaceAdminCanInviteToOrg(workspaceAdminCanInviteToOrg) + } + + /** + * Alias for [Builder.workspaceAdminCanInviteToOrg]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun workspaceAdminCanInviteToOrg(workspaceAdminCanInviteToOrg: Boolean) = + workspaceAdminCanInviteToOrg(workspaceAdminCanInviteToOrg as Boolean?) + + /** + * Alias for calling [Builder.workspaceAdminCanInviteToOrg] with + * `workspaceAdminCanInviteToOrg.orElse(null)`. + */ + fun workspaceAdminCanInviteToOrg(workspaceAdminCanInviteToOrg: Optional<Boolean>) = + workspaceAdminCanInviteToOrg(workspaceAdminCanInviteToOrg.getOrNull()) + + /** + * Sets [Builder.workspaceAdminCanInviteToOrg] to an arbitrary JSON value. + * + * You should usually call [Builder.workspaceAdminCanInviteToOrg] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun workspaceAdminCanInviteToOrg(workspaceAdminCanInviteToOrg: JsonField<Boolean>) = apply { + body.workspaceAdminCanInviteToOrg(workspaceAdminCanInviteToOrg) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [InfoPatchAllParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InfoPatchAllParams = + InfoPatchAllParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Update organization schema. */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val displayName: JsonField<String>, + private val jitProvisioningEnabled: JsonField<Boolean>, + private val patCreationDisabled: JsonField<Boolean>, + private val publicSharingDisabled: JsonField<Boolean>, + private val unshareAll: JsonField<Boolean>, + private val workspaceAdminCanInviteToOrg: JsonField<Boolean>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField<String> = JsonMissing.of(), + @JsonProperty("jit_provisioning_enabled") + @ExcludeMissing + jitProvisioningEnabled: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("pat_creation_disabled") + @ExcludeMissing + patCreationDisabled: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("public_sharing_disabled") + @ExcludeMissing + publicSharingDisabled: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("unshare_all") + @ExcludeMissing + unshareAll: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("workspace_admin_can_invite_to_org") + @ExcludeMissing + workspaceAdminCanInviteToOrg: JsonField<Boolean> = JsonMissing.of(), + ) : this( + displayName, + jitProvisioningEnabled, + patCreationDisabled, + publicSharingDisabled, + unshareAll, + workspaceAdminCanInviteToOrg, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun displayName(): Optional<String> = displayName.getOptional("display_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun jitProvisioningEnabled(): Optional<Boolean> = + jitProvisioningEnabled.getOptional("jit_provisioning_enabled") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun patCreationDisabled(): Optional<Boolean> = + patCreationDisabled.getOptional("pat_creation_disabled") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun publicSharingDisabled(): Optional<Boolean> = + publicSharingDisabled.getOptional("public_sharing_disabled") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun unshareAll(): Optional<Boolean> = unshareAll.getOptional("unshare_all") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun workspaceAdminCanInviteToOrg(): Optional<Boolean> = + workspaceAdminCanInviteToOrg.getOptional("workspace_admin_can_invite_to_org") + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField<String> = displayName + + /** + * Returns the raw JSON value of [jitProvisioningEnabled]. + * + * Unlike [jitProvisioningEnabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("jit_provisioning_enabled") + @ExcludeMissing + fun _jitProvisioningEnabled(): JsonField<Boolean> = jitProvisioningEnabled + + /** + * Returns the raw JSON value of [patCreationDisabled]. + * + * Unlike [patCreationDisabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pat_creation_disabled") + @ExcludeMissing + fun _patCreationDisabled(): JsonField<Boolean> = patCreationDisabled + + /** + * Returns the raw JSON value of [publicSharingDisabled]. + * + * Unlike [publicSharingDisabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("public_sharing_disabled") + @ExcludeMissing + fun _publicSharingDisabled(): JsonField<Boolean> = publicSharingDisabled + + /** + * Returns the raw JSON value of [unshareAll]. + * + * Unlike [unshareAll], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("unshare_all") + @ExcludeMissing + fun _unshareAll(): JsonField<Boolean> = unshareAll + + /** + * Returns the raw JSON value of [workspaceAdminCanInviteToOrg]. + * + * Unlike [workspaceAdminCanInviteToOrg], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("workspace_admin_can_invite_to_org") + @ExcludeMissing + fun _workspaceAdminCanInviteToOrg(): JsonField<Boolean> = workspaceAdminCanInviteToOrg + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var displayName: JsonField<String> = JsonMissing.of() + private var jitProvisioningEnabled: JsonField<Boolean> = JsonMissing.of() + private var patCreationDisabled: JsonField<Boolean> = JsonMissing.of() + private var publicSharingDisabled: JsonField<Boolean> = JsonMissing.of() + private var unshareAll: JsonField<Boolean> = JsonMissing.of() + private var workspaceAdminCanInviteToOrg: JsonField<Boolean> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + displayName = body.displayName + jitProvisioningEnabled = body.jitProvisioningEnabled + patCreationDisabled = body.patCreationDisabled + publicSharingDisabled = body.publicSharingDisabled + unshareAll = body.unshareAll + workspaceAdminCanInviteToOrg = body.workspaceAdminCanInviteToOrg + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun displayName(displayName: String) = displayName(JsonField.of(displayName)) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun displayName(displayName: JsonField<String>) = apply { + this.displayName = displayName + } + + fun jitProvisioningEnabled(jitProvisioningEnabled: Boolean?) = + jitProvisioningEnabled(JsonField.ofNullable(jitProvisioningEnabled)) + + /** + * Alias for [Builder.jitProvisioningEnabled]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun jitProvisioningEnabled(jitProvisioningEnabled: Boolean) = + jitProvisioningEnabled(jitProvisioningEnabled as Boolean?) + + /** + * Alias for calling [Builder.jitProvisioningEnabled] with + * `jitProvisioningEnabled.orElse(null)`. + */ + fun jitProvisioningEnabled(jitProvisioningEnabled: Optional<Boolean>) = + jitProvisioningEnabled(jitProvisioningEnabled.getOrNull()) + + /** + * Sets [Builder.jitProvisioningEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.jitProvisioningEnabled] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun jitProvisioningEnabled(jitProvisioningEnabled: JsonField<Boolean>) = apply { + this.jitProvisioningEnabled = jitProvisioningEnabled + } + + fun patCreationDisabled(patCreationDisabled: Boolean?) = + patCreationDisabled(JsonField.ofNullable(patCreationDisabled)) + + /** + * Alias for [Builder.patCreationDisabled]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun patCreationDisabled(patCreationDisabled: Boolean) = + patCreationDisabled(patCreationDisabled as Boolean?) + + /** + * Alias for calling [Builder.patCreationDisabled] with + * `patCreationDisabled.orElse(null)`. + */ + fun patCreationDisabled(patCreationDisabled: Optional<Boolean>) = + patCreationDisabled(patCreationDisabled.getOrNull()) + + /** + * Sets [Builder.patCreationDisabled] to an arbitrary JSON value. + * + * You should usually call [Builder.patCreationDisabled] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun patCreationDisabled(patCreationDisabled: JsonField<Boolean>) = apply { + this.patCreationDisabled = patCreationDisabled + } + + fun publicSharingDisabled(publicSharingDisabled: Boolean?) = + publicSharingDisabled(JsonField.ofNullable(publicSharingDisabled)) + + /** + * Alias for [Builder.publicSharingDisabled]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun publicSharingDisabled(publicSharingDisabled: Boolean) = + publicSharingDisabled(publicSharingDisabled as Boolean?) + + /** + * Alias for calling [Builder.publicSharingDisabled] with + * `publicSharingDisabled.orElse(null)`. + */ + fun publicSharingDisabled(publicSharingDisabled: Optional<Boolean>) = + publicSharingDisabled(publicSharingDisabled.getOrNull()) + + /** + * Sets [Builder.publicSharingDisabled] to an arbitrary JSON value. + * + * You should usually call [Builder.publicSharingDisabled] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun publicSharingDisabled(publicSharingDisabled: JsonField<Boolean>) = apply { + this.publicSharingDisabled = publicSharingDisabled + } + + fun unshareAll(unshareAll: Boolean?) = unshareAll(JsonField.ofNullable(unshareAll)) + + /** + * Alias for [Builder.unshareAll]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun unshareAll(unshareAll: Boolean) = unshareAll(unshareAll as Boolean?) + + /** Alias for calling [Builder.unshareAll] with `unshareAll.orElse(null)`. */ + fun unshareAll(unshareAll: Optional<Boolean>) = unshareAll(unshareAll.getOrNull()) + + /** + * Sets [Builder.unshareAll] to an arbitrary JSON value. + * + * You should usually call [Builder.unshareAll] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun unshareAll(unshareAll: JsonField<Boolean>) = apply { this.unshareAll = unshareAll } + + fun workspaceAdminCanInviteToOrg(workspaceAdminCanInviteToOrg: Boolean?) = + workspaceAdminCanInviteToOrg(JsonField.ofNullable(workspaceAdminCanInviteToOrg)) + + /** + * Alias for [Builder.workspaceAdminCanInviteToOrg]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun workspaceAdminCanInviteToOrg(workspaceAdminCanInviteToOrg: Boolean) = + workspaceAdminCanInviteToOrg(workspaceAdminCanInviteToOrg as Boolean?) + + /** + * Alias for calling [Builder.workspaceAdminCanInviteToOrg] with + * `workspaceAdminCanInviteToOrg.orElse(null)`. + */ + fun workspaceAdminCanInviteToOrg(workspaceAdminCanInviteToOrg: Optional<Boolean>) = + workspaceAdminCanInviteToOrg(workspaceAdminCanInviteToOrg.getOrNull()) + + /** + * Sets [Builder.workspaceAdminCanInviteToOrg] to an arbitrary JSON value. + * + * You should usually call [Builder.workspaceAdminCanInviteToOrg] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun workspaceAdminCanInviteToOrg(workspaceAdminCanInviteToOrg: JsonField<Boolean>) = + apply { + this.workspaceAdminCanInviteToOrg = workspaceAdminCanInviteToOrg + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = + Body( + displayName, + jitProvisioningEnabled, + patCreationDisabled, + publicSharingDisabled, + unshareAll, + workspaceAdminCanInviteToOrg, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + displayName() + jitProvisioningEnabled() + patCreationDisabled() + publicSharingDisabled() + unshareAll() + workspaceAdminCanInviteToOrg() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (displayName.asKnown().isPresent) 1 else 0) + + (if (jitProvisioningEnabled.asKnown().isPresent) 1 else 0) + + (if (patCreationDisabled.asKnown().isPresent) 1 else 0) + + (if (publicSharingDisabled.asKnown().isPresent) 1 else 0) + + (if (unshareAll.asKnown().isPresent) 1 else 0) + + (if (workspaceAdminCanInviteToOrg.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + displayName == other.displayName && + jitProvisioningEnabled == other.jitProvisioningEnabled && + patCreationDisabled == other.patCreationDisabled && + publicSharingDisabled == other.publicSharingDisabled && + unshareAll == other.unshareAll && + workspaceAdminCanInviteToOrg == other.workspaceAdminCanInviteToOrg && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + displayName, + jitProvisioningEnabled, + patCreationDisabled, + publicSharingDisabled, + unshareAll, + workspaceAdminCanInviteToOrg, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{displayName=$displayName, jitProvisioningEnabled=$jitProvisioningEnabled, patCreationDisabled=$patCreationDisabled, publicSharingDisabled=$publicSharingDisabled, unshareAll=$unshareAll, workspaceAdminCanInviteToOrg=$workspaceAdminCanInviteToOrg, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InfoPatchAllParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "InfoPatchAllParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/info/OrganizationInfo.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/info/OrganizationInfo.kt new file mode 100644 index 00000000..3fe07959 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/info/OrganizationInfo.kt @@ -0,0 +1,849 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.info + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.orgs.PaymentPlanTier +import com.langsmith_api.api.models.api.v1.orgs.current.OrganizationConfig +import com.langsmith_api.api.models.api.v1.orgs.current.Wallet +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Information about an organization. */ +class OrganizationInfo +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val config: JsonField<OrganizationConfig>, + private val isPersonal: JsonField<Boolean>, + private val id: JsonField<String>, + private val defaultSsoProvision: JsonField<Boolean>, + private val disabled: JsonField<Boolean>, + private val displayName: JsonField<String>, + private val jitProvisioningEnabled: JsonField<Boolean>, + private val marketplacePayoutsEnabled: JsonField<Boolean>, + private val patCreationDisabled: JsonField<Boolean>, + private val permissions: JsonField<List<String>>, + private val publicSharingDisabled: JsonField<Boolean>, + private val reachedMaxWorkspaces: JsonField<Boolean>, + private val ssoLoginSlug: JsonField<String>, + private val ssoOnly: JsonField<Boolean>, + private val tier: JsonField<PaymentPlanTier>, + private val wallet: JsonField<Wallet>, + private val workspaceAdminCanInviteToOrg: JsonField<Boolean>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("config") + @ExcludeMissing + config: JsonField<OrganizationConfig> = JsonMissing.of(), + @JsonProperty("is_personal") + @ExcludeMissing + isPersonal: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("default_sso_provision") + @ExcludeMissing + defaultSsoProvision: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("disabled") @ExcludeMissing disabled: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField<String> = JsonMissing.of(), + @JsonProperty("jit_provisioning_enabled") + @ExcludeMissing + jitProvisioningEnabled: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("marketplace_payouts_enabled") + @ExcludeMissing + marketplacePayoutsEnabled: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("pat_creation_disabled") + @ExcludeMissing + patCreationDisabled: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("permissions") + @ExcludeMissing + permissions: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("public_sharing_disabled") + @ExcludeMissing + publicSharingDisabled: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("reached_max_workspaces") + @ExcludeMissing + reachedMaxWorkspaces: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("sso_login_slug") + @ExcludeMissing + ssoLoginSlug: JsonField<String> = JsonMissing.of(), + @JsonProperty("sso_only") @ExcludeMissing ssoOnly: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("tier") @ExcludeMissing tier: JsonField<PaymentPlanTier> = JsonMissing.of(), + @JsonProperty("wallet") @ExcludeMissing wallet: JsonField<Wallet> = JsonMissing.of(), + @JsonProperty("workspace_admin_can_invite_to_org") + @ExcludeMissing + workspaceAdminCanInviteToOrg: JsonField<Boolean> = JsonMissing.of(), + ) : this( + config, + isPersonal, + id, + defaultSsoProvision, + disabled, + displayName, + jitProvisioningEnabled, + marketplacePayoutsEnabled, + patCreationDisabled, + permissions, + publicSharingDisabled, + reachedMaxWorkspaces, + ssoLoginSlug, + ssoOnly, + tier, + wallet, + workspaceAdminCanInviteToOrg, + mutableMapOf(), + ) + + /** + * Organization level configuration. May include any field that exists in tenant config and + * additional fields. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun config(): OrganizationConfig = config.getRequired("config") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun isPersonal(): Boolean = isPersonal.getRequired("is_personal") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun defaultSsoProvision(): Optional<Boolean> = + defaultSsoProvision.getOptional("default_sso_provision") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun disabled(): Optional<Boolean> = disabled.getOptional("disabled") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun displayName(): Optional<String> = displayName.getOptional("display_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun jitProvisioningEnabled(): Optional<Boolean> = + jitProvisioningEnabled.getOptional("jit_provisioning_enabled") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun marketplacePayoutsEnabled(): Optional<Boolean> = + marketplacePayoutsEnabled.getOptional("marketplace_payouts_enabled") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun patCreationDisabled(): Optional<Boolean> = + patCreationDisabled.getOptional("pat_creation_disabled") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun permissions(): Optional<List<String>> = permissions.getOptional("permissions") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun publicSharingDisabled(): Optional<Boolean> = + publicSharingDisabled.getOptional("public_sharing_disabled") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun reachedMaxWorkspaces(): Optional<Boolean> = + reachedMaxWorkspaces.getOptional("reached_max_workspaces") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun ssoLoginSlug(): Optional<String> = ssoLoginSlug.getOptional("sso_login_slug") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun ssoOnly(): Optional<Boolean> = ssoOnly.getOptional("sso_only") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tier(): Optional<PaymentPlanTier> = tier.getOptional("tier") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun wallet(): Optional<Wallet> = wallet.getOptional("wallet") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun workspaceAdminCanInviteToOrg(): Optional<Boolean> = + workspaceAdminCanInviteToOrg.getOptional("workspace_admin_can_invite_to_org") + + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("config") @ExcludeMissing fun _config(): JsonField<OrganizationConfig> = config + + /** + * Returns the raw JSON value of [isPersonal]. + * + * Unlike [isPersonal], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_personal") @ExcludeMissing fun _isPersonal(): JsonField<Boolean> = isPersonal + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [defaultSsoProvision]. + * + * Unlike [defaultSsoProvision], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("default_sso_provision") + @ExcludeMissing + fun _defaultSsoProvision(): JsonField<Boolean> = defaultSsoProvision + + /** + * Returns the raw JSON value of [disabled]. + * + * Unlike [disabled], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("disabled") @ExcludeMissing fun _disabled(): JsonField<Boolean> = disabled + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField<String> = displayName + + /** + * Returns the raw JSON value of [jitProvisioningEnabled]. + * + * Unlike [jitProvisioningEnabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("jit_provisioning_enabled") + @ExcludeMissing + fun _jitProvisioningEnabled(): JsonField<Boolean> = jitProvisioningEnabled + + /** + * Returns the raw JSON value of [marketplacePayoutsEnabled]. + * + * Unlike [marketplacePayoutsEnabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("marketplace_payouts_enabled") + @ExcludeMissing + fun _marketplacePayoutsEnabled(): JsonField<Boolean> = marketplacePayoutsEnabled + + /** + * Returns the raw JSON value of [patCreationDisabled]. + * + * Unlike [patCreationDisabled], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("pat_creation_disabled") + @ExcludeMissing + fun _patCreationDisabled(): JsonField<Boolean> = patCreationDisabled + + /** + * Returns the raw JSON value of [permissions]. + * + * Unlike [permissions], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("permissions") + @ExcludeMissing + fun _permissions(): JsonField<List<String>> = permissions + + /** + * Returns the raw JSON value of [publicSharingDisabled]. + * + * Unlike [publicSharingDisabled], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("public_sharing_disabled") + @ExcludeMissing + fun _publicSharingDisabled(): JsonField<Boolean> = publicSharingDisabled + + /** + * Returns the raw JSON value of [reachedMaxWorkspaces]. + * + * Unlike [reachedMaxWorkspaces], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reached_max_workspaces") + @ExcludeMissing + fun _reachedMaxWorkspaces(): JsonField<Boolean> = reachedMaxWorkspaces + + /** + * Returns the raw JSON value of [ssoLoginSlug]. + * + * Unlike [ssoLoginSlug], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sso_login_slug") + @ExcludeMissing + fun _ssoLoginSlug(): JsonField<String> = ssoLoginSlug + + /** + * Returns the raw JSON value of [ssoOnly]. + * + * Unlike [ssoOnly], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sso_only") @ExcludeMissing fun _ssoOnly(): JsonField<Boolean> = ssoOnly + + /** + * Returns the raw JSON value of [tier]. + * + * Unlike [tier], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tier") @ExcludeMissing fun _tier(): JsonField<PaymentPlanTier> = tier + + /** + * Returns the raw JSON value of [wallet]. + * + * Unlike [wallet], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("wallet") @ExcludeMissing fun _wallet(): JsonField<Wallet> = wallet + + /** + * Returns the raw JSON value of [workspaceAdminCanInviteToOrg]. + * + * Unlike [workspaceAdminCanInviteToOrg], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("workspace_admin_can_invite_to_org") + @ExcludeMissing + fun _workspaceAdminCanInviteToOrg(): JsonField<Boolean> = workspaceAdminCanInviteToOrg + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [OrganizationInfo]. + * + * The following fields are required: + * ```java + * .config() + * .isPersonal() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OrganizationInfo]. */ + class Builder internal constructor() { + + private var config: JsonField<OrganizationConfig>? = null + private var isPersonal: JsonField<Boolean>? = null + private var id: JsonField<String> = JsonMissing.of() + private var defaultSsoProvision: JsonField<Boolean> = JsonMissing.of() + private var disabled: JsonField<Boolean> = JsonMissing.of() + private var displayName: JsonField<String> = JsonMissing.of() + private var jitProvisioningEnabled: JsonField<Boolean> = JsonMissing.of() + private var marketplacePayoutsEnabled: JsonField<Boolean> = JsonMissing.of() + private var patCreationDisabled: JsonField<Boolean> = JsonMissing.of() + private var permissions: JsonField<MutableList<String>>? = null + private var publicSharingDisabled: JsonField<Boolean> = JsonMissing.of() + private var reachedMaxWorkspaces: JsonField<Boolean> = JsonMissing.of() + private var ssoLoginSlug: JsonField<String> = JsonMissing.of() + private var ssoOnly: JsonField<Boolean> = JsonMissing.of() + private var tier: JsonField<PaymentPlanTier> = JsonMissing.of() + private var wallet: JsonField<Wallet> = JsonMissing.of() + private var workspaceAdminCanInviteToOrg: JsonField<Boolean> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(organizationInfo: OrganizationInfo) = apply { + config = organizationInfo.config + isPersonal = organizationInfo.isPersonal + id = organizationInfo.id + defaultSsoProvision = organizationInfo.defaultSsoProvision + disabled = organizationInfo.disabled + displayName = organizationInfo.displayName + jitProvisioningEnabled = organizationInfo.jitProvisioningEnabled + marketplacePayoutsEnabled = organizationInfo.marketplacePayoutsEnabled + patCreationDisabled = organizationInfo.patCreationDisabled + permissions = organizationInfo.permissions.map { it.toMutableList() } + publicSharingDisabled = organizationInfo.publicSharingDisabled + reachedMaxWorkspaces = organizationInfo.reachedMaxWorkspaces + ssoLoginSlug = organizationInfo.ssoLoginSlug + ssoOnly = organizationInfo.ssoOnly + tier = organizationInfo.tier + wallet = organizationInfo.wallet + workspaceAdminCanInviteToOrg = organizationInfo.workspaceAdminCanInviteToOrg + additionalProperties = organizationInfo.additionalProperties.toMutableMap() + } + + /** + * Organization level configuration. May include any field that exists in tenant config and + * additional fields. + */ + fun config(config: OrganizationConfig) = config(JsonField.of(config)) + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed [OrganizationConfig] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun config(config: JsonField<OrganizationConfig>) = apply { this.config = config } + + fun isPersonal(isPersonal: Boolean) = isPersonal(JsonField.of(isPersonal)) + + /** + * Sets [Builder.isPersonal] to an arbitrary JSON value. + * + * You should usually call [Builder.isPersonal] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isPersonal(isPersonal: JsonField<Boolean>) = apply { this.isPersonal = isPersonal } + + fun id(id: String?) = id(JsonField.ofNullable(id)) + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<String>) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun defaultSsoProvision(defaultSsoProvision: Boolean) = + defaultSsoProvision(JsonField.of(defaultSsoProvision)) + + /** + * Sets [Builder.defaultSsoProvision] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultSsoProvision] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun defaultSsoProvision(defaultSsoProvision: JsonField<Boolean>) = apply { + this.defaultSsoProvision = defaultSsoProvision + } + + fun disabled(disabled: Boolean) = disabled(JsonField.of(disabled)) + + /** + * Sets [Builder.disabled] to an arbitrary JSON value. + * + * You should usually call [Builder.disabled] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun disabled(disabled: JsonField<Boolean>) = apply { this.disabled = disabled } + + fun displayName(displayName: String?) = displayName(JsonField.ofNullable(displayName)) + + /** Alias for calling [Builder.displayName] with `displayName.orElse(null)`. */ + fun displayName(displayName: Optional<String>) = displayName(displayName.getOrNull()) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun displayName(displayName: JsonField<String>) = apply { this.displayName = displayName } + + fun jitProvisioningEnabled(jitProvisioningEnabled: Boolean) = + jitProvisioningEnabled(JsonField.of(jitProvisioningEnabled)) + + /** + * Sets [Builder.jitProvisioningEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.jitProvisioningEnabled] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun jitProvisioningEnabled(jitProvisioningEnabled: JsonField<Boolean>) = apply { + this.jitProvisioningEnabled = jitProvisioningEnabled + } + + fun marketplacePayoutsEnabled(marketplacePayoutsEnabled: Boolean) = + marketplacePayoutsEnabled(JsonField.of(marketplacePayoutsEnabled)) + + /** + * Sets [Builder.marketplacePayoutsEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.marketplacePayoutsEnabled] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun marketplacePayoutsEnabled(marketplacePayoutsEnabled: JsonField<Boolean>) = apply { + this.marketplacePayoutsEnabled = marketplacePayoutsEnabled + } + + fun patCreationDisabled(patCreationDisabled: Boolean) = + patCreationDisabled(JsonField.of(patCreationDisabled)) + + /** + * Sets [Builder.patCreationDisabled] to an arbitrary JSON value. + * + * You should usually call [Builder.patCreationDisabled] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun patCreationDisabled(patCreationDisabled: JsonField<Boolean>) = apply { + this.patCreationDisabled = patCreationDisabled + } + + fun permissions(permissions: List<String>) = permissions(JsonField.of(permissions)) + + /** + * Sets [Builder.permissions] to an arbitrary JSON value. + * + * You should usually call [Builder.permissions] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun permissions(permissions: JsonField<List<String>>) = apply { + this.permissions = permissions.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [permissions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPermission(permission: String) = apply { + permissions = + (permissions ?: JsonField.of(mutableListOf())).also { + checkKnown("permissions", it).add(permission) + } + } + + fun publicSharingDisabled(publicSharingDisabled: Boolean) = + publicSharingDisabled(JsonField.of(publicSharingDisabled)) + + /** + * Sets [Builder.publicSharingDisabled] to an arbitrary JSON value. + * + * You should usually call [Builder.publicSharingDisabled] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun publicSharingDisabled(publicSharingDisabled: JsonField<Boolean>) = apply { + this.publicSharingDisabled = publicSharingDisabled + } + + fun reachedMaxWorkspaces(reachedMaxWorkspaces: Boolean) = + reachedMaxWorkspaces(JsonField.of(reachedMaxWorkspaces)) + + /** + * Sets [Builder.reachedMaxWorkspaces] to an arbitrary JSON value. + * + * You should usually call [Builder.reachedMaxWorkspaces] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun reachedMaxWorkspaces(reachedMaxWorkspaces: JsonField<Boolean>) = apply { + this.reachedMaxWorkspaces = reachedMaxWorkspaces + } + + fun ssoLoginSlug(ssoLoginSlug: String?) = ssoLoginSlug(JsonField.ofNullable(ssoLoginSlug)) + + /** Alias for calling [Builder.ssoLoginSlug] with `ssoLoginSlug.orElse(null)`. */ + fun ssoLoginSlug(ssoLoginSlug: Optional<String>) = ssoLoginSlug(ssoLoginSlug.getOrNull()) + + /** + * Sets [Builder.ssoLoginSlug] to an arbitrary JSON value. + * + * You should usually call [Builder.ssoLoginSlug] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ssoLoginSlug(ssoLoginSlug: JsonField<String>) = apply { + this.ssoLoginSlug = ssoLoginSlug + } + + fun ssoOnly(ssoOnly: Boolean) = ssoOnly(JsonField.of(ssoOnly)) + + /** + * Sets [Builder.ssoOnly] to an arbitrary JSON value. + * + * You should usually call [Builder.ssoOnly] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun ssoOnly(ssoOnly: JsonField<Boolean>) = apply { this.ssoOnly = ssoOnly } + + fun tier(tier: PaymentPlanTier?) = tier(JsonField.ofNullable(tier)) + + /** Alias for calling [Builder.tier] with `tier.orElse(null)`. */ + fun tier(tier: Optional<PaymentPlanTier>) = tier(tier.getOrNull()) + + /** + * Sets [Builder.tier] to an arbitrary JSON value. + * + * You should usually call [Builder.tier] with a well-typed [PaymentPlanTier] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tier(tier: JsonField<PaymentPlanTier>) = apply { this.tier = tier } + + fun wallet(wallet: Wallet?) = wallet(JsonField.ofNullable(wallet)) + + /** Alias for calling [Builder.wallet] with `wallet.orElse(null)`. */ + fun wallet(wallet: Optional<Wallet>) = wallet(wallet.getOrNull()) + + /** + * Sets [Builder.wallet] to an arbitrary JSON value. + * + * You should usually call [Builder.wallet] with a well-typed [Wallet] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun wallet(wallet: JsonField<Wallet>) = apply { this.wallet = wallet } + + fun workspaceAdminCanInviteToOrg(workspaceAdminCanInviteToOrg: Boolean) = + workspaceAdminCanInviteToOrg(JsonField.of(workspaceAdminCanInviteToOrg)) + + /** + * Sets [Builder.workspaceAdminCanInviteToOrg] to an arbitrary JSON value. + * + * You should usually call [Builder.workspaceAdminCanInviteToOrg] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun workspaceAdminCanInviteToOrg(workspaceAdminCanInviteToOrg: JsonField<Boolean>) = apply { + this.workspaceAdminCanInviteToOrg = workspaceAdminCanInviteToOrg + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OrganizationInfo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .config() + * .isPersonal() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): OrganizationInfo = + OrganizationInfo( + checkRequired("config", config), + checkRequired("isPersonal", isPersonal), + id, + defaultSsoProvision, + disabled, + displayName, + jitProvisioningEnabled, + marketplacePayoutsEnabled, + patCreationDisabled, + (permissions ?: JsonMissing.of()).map { it.toImmutable() }, + publicSharingDisabled, + reachedMaxWorkspaces, + ssoLoginSlug, + ssoOnly, + tier, + wallet, + workspaceAdminCanInviteToOrg, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OrganizationInfo = apply { + if (validated) { + return@apply + } + + config().validate() + isPersonal() + id() + defaultSsoProvision() + disabled() + displayName() + jitProvisioningEnabled() + marketplacePayoutsEnabled() + patCreationDisabled() + permissions() + publicSharingDisabled() + reachedMaxWorkspaces() + ssoLoginSlug() + ssoOnly() + tier().ifPresent { it.validate() } + wallet().ifPresent { it.validate() } + workspaceAdminCanInviteToOrg() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (config.asKnown().getOrNull()?.validity() ?: 0) + + (if (isPersonal.asKnown().isPresent) 1 else 0) + + (if (id.asKnown().isPresent) 1 else 0) + + (if (defaultSsoProvision.asKnown().isPresent) 1 else 0) + + (if (disabled.asKnown().isPresent) 1 else 0) + + (if (displayName.asKnown().isPresent) 1 else 0) + + (if (jitProvisioningEnabled.asKnown().isPresent) 1 else 0) + + (if (marketplacePayoutsEnabled.asKnown().isPresent) 1 else 0) + + (if (patCreationDisabled.asKnown().isPresent) 1 else 0) + + (permissions.asKnown().getOrNull()?.size ?: 0) + + (if (publicSharingDisabled.asKnown().isPresent) 1 else 0) + + (if (reachedMaxWorkspaces.asKnown().isPresent) 1 else 0) + + (if (ssoLoginSlug.asKnown().isPresent) 1 else 0) + + (if (ssoOnly.asKnown().isPresent) 1 else 0) + + (tier.asKnown().getOrNull()?.validity() ?: 0) + + (wallet.asKnown().getOrNull()?.validity() ?: 0) + + (if (workspaceAdminCanInviteToOrg.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OrganizationInfo && + config == other.config && + isPersonal == other.isPersonal && + id == other.id && + defaultSsoProvision == other.defaultSsoProvision && + disabled == other.disabled && + displayName == other.displayName && + jitProvisioningEnabled == other.jitProvisioningEnabled && + marketplacePayoutsEnabled == other.marketplacePayoutsEnabled && + patCreationDisabled == other.patCreationDisabled && + permissions == other.permissions && + publicSharingDisabled == other.publicSharingDisabled && + reachedMaxWorkspaces == other.reachedMaxWorkspaces && + ssoLoginSlug == other.ssoLoginSlug && + ssoOnly == other.ssoOnly && + tier == other.tier && + wallet == other.wallet && + workspaceAdminCanInviteToOrg == other.workspaceAdminCanInviteToOrg && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + config, + isPersonal, + id, + defaultSsoProvision, + disabled, + displayName, + jitProvisioningEnabled, + marketplacePayoutsEnabled, + patCreationDisabled, + permissions, + publicSharingDisabled, + reachedMaxWorkspaces, + ssoLoginSlug, + ssoOnly, + tier, + wallet, + workspaceAdminCanInviteToOrg, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OrganizationInfo{config=$config, isPersonal=$isPersonal, id=$id, defaultSsoProvision=$defaultSsoProvision, disabled=$disabled, displayName=$displayName, jitProvisioningEnabled=$jitProvisioningEnabled, marketplacePayoutsEnabled=$marketplacePayoutsEnabled, patCreationDisabled=$patCreationDisabled, permissions=$permissions, publicSharingDisabled=$publicSharingDisabled, reachedMaxWorkspaces=$reachedMaxWorkspaces, ssoLoginSlug=$ssoLoginSlug, ssoOnly=$ssoOnly, tier=$tier, wallet=$wallet, workspaceAdminCanInviteToOrg=$workspaceAdminCanInviteToOrg, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/AccessScope.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/AccessScope.kt new file mode 100644 index 00000000..55affc24 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/AccessScope.kt @@ -0,0 +1,133 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.members + +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException + +class AccessScope @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't match + * any known member, and you want to know that value. For example, if the SDK is on an older + * version than the API, then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val ORGANIZATION = of("organization") + + @JvmField val WORKSPACE = of("workspace") + + @JvmStatic fun of(value: String) = AccessScope(JsonField.of(value)) + } + + /** An enum containing [AccessScope]'s known values. */ + enum class Known { + ORGANIZATION, + WORKSPACE, + } + + /** + * An enum containing [AccessScope]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AccessScope] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the SDK + * is on an older version than the API, then the API may respond with new members that the SDK + * is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ORGANIZATION, + WORKSPACE, + /** An enum member indicating that [AccessScope] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if + * the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want to + * throw for the unknown case. + */ + fun value(): Value = + when (this) { + ORGANIZATION -> Value.ORGANIZATION + WORKSPACE -> Value.WORKSPACE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't want + * to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ORGANIZATION -> Known.ORGANIZATION + WORKSPACE -> Known.WORKSPACE + else -> throw LangsmithApiInvalidDataException("Unknown AccessScope: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AccessScope = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AccessScope && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberBatchParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberBatchParams.kt new file mode 100644 index 00000000..347b3e91 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberBatchParams.kt @@ -0,0 +1,207 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.members + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects + +/** Batch invite up to 500 users to the current org. */ +class MemberBatchParams +private constructor( + private val body: List<PendingIdentityCreate>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun body(): List<PendingIdentityCreate> = body + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MemberBatchParams]. + * + * The following fields are required: + * ```java + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MemberBatchParams]. */ + class Builder internal constructor() { + + private var body: MutableList<PendingIdentityCreate>? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(memberBatchParams: MemberBatchParams) = apply { + body = memberBatchParams.body.toMutableList() + additionalHeaders = memberBatchParams.additionalHeaders.toBuilder() + additionalQueryParams = memberBatchParams.additionalQueryParams.toBuilder() + } + + fun body(body: List<PendingIdentityCreate>) = apply { this.body = body.toMutableList() } + + /** + * Adds a single [PendingIdentityCreate] to [Builder.body]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addBody(body: PendingIdentityCreate) = apply { + this.body = (this.body ?: mutableListOf()).apply { add(body) } + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [MemberBatchParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MemberBatchParams = + MemberBatchParams( + checkRequired("body", body).toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): List<PendingIdentityCreate> = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MemberBatchParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "MemberBatchParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberCreateParams.kt new file mode 100644 index 00000000..fa1f0297 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberCreateParams.kt @@ -0,0 +1,204 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.members + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** Add Member To Current Org */ +class MemberCreateParams +private constructor( + private val pendingIdentityCreate: PendingIdentityCreate, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun pendingIdentityCreate(): PendingIdentityCreate = pendingIdentityCreate + + fun _additionalBodyProperties(): Map<String, JsonValue> = + pendingIdentityCreate._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MemberCreateParams]. + * + * The following fields are required: + * ```java + * .pendingIdentityCreate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MemberCreateParams]. */ + class Builder internal constructor() { + + private var pendingIdentityCreate: PendingIdentityCreate? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(memberCreateParams: MemberCreateParams) = apply { + pendingIdentityCreate = memberCreateParams.pendingIdentityCreate + additionalHeaders = memberCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = memberCreateParams.additionalQueryParams.toBuilder() + } + + fun pendingIdentityCreate(pendingIdentityCreate: PendingIdentityCreate) = apply { + this.pendingIdentityCreate = pendingIdentityCreate + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [MemberCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .pendingIdentityCreate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MemberCreateParams = + MemberCreateParams( + checkRequired("pendingIdentityCreate", pendingIdentityCreate), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): PendingIdentityCreate = pendingIdentityCreate + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MemberCreateParams && + pendingIdentityCreate == other.pendingIdentityCreate && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(pendingIdentityCreate, additionalHeaders, additionalQueryParams) + + override fun toString() = + "MemberCreateParams{pendingIdentityCreate=$pendingIdentityCreate, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberDeleteParams.kt new file mode 100644 index 00000000..42677fdc --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberDeleteParams.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.members + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Remove a user from the current organization. */ +class MemberDeleteParams +private constructor( + private val identityId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun identityId(): Optional<String> = Optional.ofNullable(identityId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): MemberDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [MemberDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MemberDeleteParams]. */ + class Builder internal constructor() { + + private var identityId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(memberDeleteParams: MemberDeleteParams) = apply { + identityId = memberDeleteParams.identityId + additionalHeaders = memberDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = memberDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = memberDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun identityId(identityId: String?) = apply { this.identityId = identityId } + + /** Alias for calling [Builder.identityId] with `identityId.orElse(null)`. */ + fun identityId(identityId: Optional<String>) = identityId(identityId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [MemberDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MemberDeleteParams = + MemberDeleteParams( + identityId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> identityId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MemberDeleteParams && + identityId == other.identityId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(identityId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "MemberDeleteParams{identityId=$identityId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberDeleteResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberDeleteResponse.kt new file mode 100644 index 00000000..2aa8574b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberDeleteResponse.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.members + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class MemberDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [MemberDeleteResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MemberDeleteResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(memberDeleteResponse: MemberDeleteResponse) = apply { + additionalProperties = memberDeleteResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MemberDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MemberDeleteResponse = + MemberDeleteResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): MemberDeleteResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MemberDeleteResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "MemberDeleteResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberListParams.kt new file mode 100644 index 00000000..b4066fa6 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberListParams.kt @@ -0,0 +1,170 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.members + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** Get Current Org Members */ +class MemberListParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): MemberListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [MemberListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MemberListParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(memberListParams: MemberListParams) = apply { + additionalHeaders = memberListParams.additionalHeaders.toBuilder() + additionalQueryParams = memberListParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [MemberListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MemberListParams = + MemberListParams(additionalHeaders.build(), additionalQueryParams.build()) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MemberListParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "MemberListParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberListResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberListResponse.kt new file mode 100644 index 00000000..4f63ac8b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberListResponse.kt @@ -0,0 +1,290 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.members + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.orgs.current.members.pending.OrgPendingIdentity +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** Organization members schema. */ +class MemberListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val members: JsonField<List<OrgMemberIdentity>>, + private val organizationId: JsonField<String>, + private val pending: JsonField<List<OrgPendingIdentity>>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("members") + @ExcludeMissing + members: JsonField<List<OrgMemberIdentity>> = JsonMissing.of(), + @JsonProperty("organization_id") + @ExcludeMissing + organizationId: JsonField<String> = JsonMissing.of(), + @JsonProperty("pending") + @ExcludeMissing + pending: JsonField<List<OrgPendingIdentity>> = JsonMissing.of(), + ) : this(members, organizationId, pending, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun members(): List<OrgMemberIdentity> = members.getRequired("members") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun organizationId(): String = organizationId.getRequired("organization_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun pending(): List<OrgPendingIdentity> = pending.getRequired("pending") + + /** + * Returns the raw JSON value of [members]. + * + * Unlike [members], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("members") + @ExcludeMissing + fun _members(): JsonField<List<OrgMemberIdentity>> = members + + /** + * Returns the raw JSON value of [organizationId]. + * + * Unlike [organizationId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("organization_id") + @ExcludeMissing + fun _organizationId(): JsonField<String> = organizationId + + /** + * Returns the raw JSON value of [pending]. + * + * Unlike [pending], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pending") + @ExcludeMissing + fun _pending(): JsonField<List<OrgPendingIdentity>> = pending + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MemberListResponse]. + * + * The following fields are required: + * ```java + * .members() + * .organizationId() + * .pending() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MemberListResponse]. */ + class Builder internal constructor() { + + private var members: JsonField<MutableList<OrgMemberIdentity>>? = null + private var organizationId: JsonField<String>? = null + private var pending: JsonField<MutableList<OrgPendingIdentity>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(memberListResponse: MemberListResponse) = apply { + members = memberListResponse.members.map { it.toMutableList() } + organizationId = memberListResponse.organizationId + pending = memberListResponse.pending.map { it.toMutableList() } + additionalProperties = memberListResponse.additionalProperties.toMutableMap() + } + + fun members(members: List<OrgMemberIdentity>) = members(JsonField.of(members)) + + /** + * Sets [Builder.members] to an arbitrary JSON value. + * + * You should usually call [Builder.members] with a well-typed `List<OrgMemberIdentity>` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun members(members: JsonField<List<OrgMemberIdentity>>) = apply { + this.members = members.map { it.toMutableList() } + } + + /** + * Adds a single [OrgMemberIdentity] to [members]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMember(member: OrgMemberIdentity) = apply { + members = + (members ?: JsonField.of(mutableListOf())).also { + checkKnown("members", it).add(member) + } + } + + fun organizationId(organizationId: String) = organizationId(JsonField.of(organizationId)) + + /** + * Sets [Builder.organizationId] to an arbitrary JSON value. + * + * You should usually call [Builder.organizationId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun organizationId(organizationId: JsonField<String>) = apply { + this.organizationId = organizationId + } + + fun pending(pending: List<OrgPendingIdentity>) = pending(JsonField.of(pending)) + + /** + * Sets [Builder.pending] to an arbitrary JSON value. + * + * You should usually call [Builder.pending] with a well-typed `List<OrgPendingIdentity>` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun pending(pending: JsonField<List<OrgPendingIdentity>>) = apply { + this.pending = pending.map { it.toMutableList() } + } + + /** + * Adds a single [OrgPendingIdentity] to [Builder.pending]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPending(pending: OrgPendingIdentity) = apply { + this.pending = + (this.pending ?: JsonField.of(mutableListOf())).also { + checkKnown("pending", it).add(pending) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MemberListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .members() + * .organizationId() + * .pending() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MemberListResponse = + MemberListResponse( + checkRequired("members", members).map { it.toImmutable() }, + checkRequired("organizationId", organizationId), + checkRequired("pending", pending).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MemberListResponse = apply { + if (validated) { + return@apply + } + + members().forEach { it.validate() } + organizationId() + pending().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (members.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (organizationId.asKnown().isPresent) 1 else 0) + + (pending.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MemberListResponse && + members == other.members && + organizationId == other.organizationId && + pending == other.pending && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(members, organizationId, pending, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MemberListResponse{members=$members, organizationId=$organizationId, pending=$pending, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberRetrieveActiveParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberRetrieveActiveParams.kt new file mode 100644 index 00000000..0dd62f5b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberRetrieveActiveParams.kt @@ -0,0 +1,303 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.members + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get Current Active Org Members */ +class MemberRetrieveActiveParams +private constructor( + private val emails: List<String>?, + private val limit: Long?, + private val lsUserIds: List<String>?, + private val offset: Long?, + private val userIds: List<String>?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun emails(): Optional<List<String>> = Optional.ofNullable(emails) + + fun limit(): Optional<Long> = Optional.ofNullable(limit) + + fun lsUserIds(): Optional<List<String>> = Optional.ofNullable(lsUserIds) + + fun offset(): Optional<Long> = Optional.ofNullable(offset) + + @Deprecated("deprecated") fun userIds(): Optional<List<String>> = Optional.ofNullable(userIds) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): MemberRetrieveActiveParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [MemberRetrieveActiveParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MemberRetrieveActiveParams]. */ + class Builder internal constructor() { + + private var emails: MutableList<String>? = null + private var limit: Long? = null + private var lsUserIds: MutableList<String>? = null + private var offset: Long? = null + private var userIds: MutableList<String>? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(memberRetrieveActiveParams: MemberRetrieveActiveParams) = apply { + emails = memberRetrieveActiveParams.emails?.toMutableList() + limit = memberRetrieveActiveParams.limit + lsUserIds = memberRetrieveActiveParams.lsUserIds?.toMutableList() + offset = memberRetrieveActiveParams.offset + userIds = memberRetrieveActiveParams.userIds?.toMutableList() + additionalHeaders = memberRetrieveActiveParams.additionalHeaders.toBuilder() + additionalQueryParams = memberRetrieveActiveParams.additionalQueryParams.toBuilder() + } + + fun emails(emails: List<String>?) = apply { this.emails = emails?.toMutableList() } + + /** Alias for calling [Builder.emails] with `emails.orElse(null)`. */ + fun emails(emails: Optional<List<String>>) = emails(emails.getOrNull()) + + /** + * Adds a single [String] to [emails]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEmail(email: String) = apply { + emails = (emails ?: mutableListOf()).apply { add(email) } + } + + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional<Long>) = limit(limit.getOrNull()) + + fun lsUserIds(lsUserIds: List<String>?) = apply { + this.lsUserIds = lsUserIds?.toMutableList() + } + + /** Alias for calling [Builder.lsUserIds] with `lsUserIds.orElse(null)`. */ + fun lsUserIds(lsUserIds: Optional<List<String>>) = lsUserIds(lsUserIds.getOrNull()) + + /** + * Adds a single [String] to [lsUserIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLsUserId(lsUserId: String) = apply { + lsUserIds = (lsUserIds ?: mutableListOf()).apply { add(lsUserId) } + } + + fun offset(offset: Long?) = apply { this.offset = offset } + + /** + * Alias for [Builder.offset]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun offset(offset: Long) = offset(offset as Long?) + + /** Alias for calling [Builder.offset] with `offset.orElse(null)`. */ + fun offset(offset: Optional<Long>) = offset(offset.getOrNull()) + + @Deprecated("deprecated") + fun userIds(userIds: List<String>?) = apply { this.userIds = userIds?.toMutableList() } + + /** Alias for calling [Builder.userIds] with `userIds.orElse(null)`. */ + @Deprecated("deprecated") + fun userIds(userIds: Optional<List<String>>) = userIds(userIds.getOrNull()) + + /** + * Adds a single [String] to [userIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + @Deprecated("deprecated") + fun addUserId(userId: String) = apply { + userIds = (userIds ?: mutableListOf()).apply { add(userId) } + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [MemberRetrieveActiveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MemberRetrieveActiveParams = + MemberRetrieveActiveParams( + emails?.toImmutable(), + limit, + lsUserIds?.toImmutable(), + offset, + userIds?.toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + emails?.let { put("emails", it.joinToString(",")) } + limit?.let { put("limit", it.toString()) } + lsUserIds?.let { put("ls_user_ids", it.joinToString(",")) } + offset?.let { put("offset", it.toString()) } + userIds?.let { put("user_ids", it.joinToString(",")) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MemberRetrieveActiveParams && + emails == other.emails && + limit == other.limit && + lsUserIds == other.lsUserIds && + offset == other.offset && + userIds == other.userIds && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + emails, + limit, + lsUserIds, + offset, + userIds, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "MemberRetrieveActiveParams{emails=$emails, limit=$limit, lsUserIds=$lsUserIds, offset=$offset, userIds=$userIds, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberUpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberUpdateParams.kt new file mode 100644 index 00000000..3b1c3948 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberUpdateParams.kt @@ -0,0 +1,539 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.members + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** This is used for updating a user's role (all auth modes) or full_name/password (basic auth) */ +class MemberUpdateParams +private constructor( + private val identityId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun identityId(): Optional<String> = Optional.ofNullable(identityId) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fullName(): Optional<String> = body.fullName() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun password(): Optional<String> = body.password() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun roleId(): Optional<String> = body.roleId() + + /** + * Returns the raw JSON value of [fullName]. + * + * Unlike [fullName], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _fullName(): JsonField<String> = body._fullName() + + /** + * Returns the raw JSON value of [password]. + * + * Unlike [password], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _password(): JsonField<String> = body._password() + + /** + * Returns the raw JSON value of [roleId]. + * + * Unlike [roleId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _roleId(): JsonField<String> = body._roleId() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): MemberUpdateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [MemberUpdateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MemberUpdateParams]. */ + class Builder internal constructor() { + + private var identityId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(memberUpdateParams: MemberUpdateParams) = apply { + identityId = memberUpdateParams.identityId + body = memberUpdateParams.body.toBuilder() + additionalHeaders = memberUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = memberUpdateParams.additionalQueryParams.toBuilder() + } + + fun identityId(identityId: String?) = apply { this.identityId = identityId } + + /** Alias for calling [Builder.identityId] with `identityId.orElse(null)`. */ + fun identityId(identityId: Optional<String>) = identityId(identityId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [fullName] + * - [password] + * - [roleId] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun fullName(fullName: String?) = apply { body.fullName(fullName) } + + /** Alias for calling [Builder.fullName] with `fullName.orElse(null)`. */ + fun fullName(fullName: Optional<String>) = fullName(fullName.getOrNull()) + + /** + * Sets [Builder.fullName] to an arbitrary JSON value. + * + * You should usually call [Builder.fullName] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun fullName(fullName: JsonField<String>) = apply { body.fullName(fullName) } + + fun password(password: String?) = apply { body.password(password) } + + /** Alias for calling [Builder.password] with `password.orElse(null)`. */ + fun password(password: Optional<String>) = password(password.getOrNull()) + + /** + * Sets [Builder.password] to an arbitrary JSON value. + * + * You should usually call [Builder.password] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun password(password: JsonField<String>) = apply { body.password(password) } + + fun roleId(roleId: String?) = apply { body.roleId(roleId) } + + /** Alias for calling [Builder.roleId] with `roleId.orElse(null)`. */ + fun roleId(roleId: Optional<String>) = roleId(roleId.getOrNull()) + + /** + * Sets [Builder.roleId] to an arbitrary JSON value. + * + * You should usually call [Builder.roleId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun roleId(roleId: JsonField<String>) = apply { body.roleId(roleId) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [MemberUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MemberUpdateParams = + MemberUpdateParams( + identityId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> identityId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val fullName: JsonField<String>, + private val password: JsonField<String>, + private val roleId: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("full_name") + @ExcludeMissing + fullName: JsonField<String> = JsonMissing.of(), + @JsonProperty("password") + @ExcludeMissing + password: JsonField<String> = JsonMissing.of(), + @JsonProperty("role_id") @ExcludeMissing roleId: JsonField<String> = JsonMissing.of(), + ) : this(fullName, password, roleId, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun fullName(): Optional<String> = fullName.getOptional("full_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun password(): Optional<String> = password.getOptional("password") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun roleId(): Optional<String> = roleId.getOptional("role_id") + + /** + * Returns the raw JSON value of [fullName]. + * + * Unlike [fullName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("full_name") @ExcludeMissing fun _fullName(): JsonField<String> = fullName + + /** + * Returns the raw JSON value of [password]. + * + * Unlike [password], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("password") @ExcludeMissing fun _password(): JsonField<String> = password + + /** + * Returns the raw JSON value of [roleId]. + * + * Unlike [roleId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("role_id") @ExcludeMissing fun _roleId(): JsonField<String> = roleId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var fullName: JsonField<String> = JsonMissing.of() + private var password: JsonField<String> = JsonMissing.of() + private var roleId: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + fullName = body.fullName + password = body.password + roleId = body.roleId + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun fullName(fullName: String?) = fullName(JsonField.ofNullable(fullName)) + + /** Alias for calling [Builder.fullName] with `fullName.orElse(null)`. */ + fun fullName(fullName: Optional<String>) = fullName(fullName.getOrNull()) + + /** + * Sets [Builder.fullName] to an arbitrary JSON value. + * + * You should usually call [Builder.fullName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fullName(fullName: JsonField<String>) = apply { this.fullName = fullName } + + fun password(password: String?) = password(JsonField.ofNullable(password)) + + /** Alias for calling [Builder.password] with `password.orElse(null)`. */ + fun password(password: Optional<String>) = password(password.getOrNull()) + + /** + * Sets [Builder.password] to an arbitrary JSON value. + * + * You should usually call [Builder.password] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun password(password: JsonField<String>) = apply { this.password = password } + + fun roleId(roleId: String?) = roleId(JsonField.ofNullable(roleId)) + + /** Alias for calling [Builder.roleId] with `roleId.orElse(null)`. */ + fun roleId(roleId: Optional<String>) = roleId(roleId.getOrNull()) + + /** + * Sets [Builder.roleId] to an arbitrary JSON value. + * + * You should usually call [Builder.roleId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun roleId(roleId: JsonField<String>) = apply { this.roleId = roleId } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = + Body(fullName, password, roleId, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + fullName() + password() + roleId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (fullName.asKnown().isPresent) 1 else 0) + + (if (password.asKnown().isPresent) 1 else 0) + + (if (roleId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + fullName == other.fullName && + password == other.password && + roleId == other.roleId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(fullName, password, roleId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{fullName=$fullName, password=$password, roleId=$roleId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MemberUpdateParams && + identityId == other.identityId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(identityId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "MemberUpdateParams{identityId=$identityId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberUpdateResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberUpdateResponse.kt new file mode 100644 index 00000000..a4d3ef55 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberUpdateResponse.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.members + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class MemberUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [MemberUpdateResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MemberUpdateResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(memberUpdateResponse: MemberUpdateResponse) = apply { + additionalProperties = memberUpdateResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MemberUpdateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MemberUpdateResponse = + MemberUpdateResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): MemberUpdateResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MemberUpdateResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "MemberUpdateResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/OrgMemberIdentity.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/OrgMemberIdentity.kt new file mode 100644 index 00000000..75f54f19 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/OrgMemberIdentity.kt @@ -0,0 +1,818 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.members + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.orgs.current.user.ProviderUserSlim +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class OrgMemberIdentity +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val lsUserId: JsonField<String>, + private val organizationId: JsonField<String>, + private val readOnly: JsonField<Boolean>, + private val userId: JsonField<String>, + private val accessScope: JsonField<AccessScope>, + private val avatarUrl: JsonField<String>, + private val email: JsonField<String>, + private val fullName: JsonField<String>, + private val linkedLoginMethods: JsonField<List<ProviderUserSlim>>, + private val orgRoleId: JsonField<String>, + private val orgRoleName: JsonField<String>, + private val roleId: JsonField<String>, + private val roleName: JsonField<String>, + private val tenantId: JsonField<String>, + private val tenantIds: JsonField<List<String>>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("ls_user_id") @ExcludeMissing lsUserId: JsonField<String> = JsonMissing.of(), + @JsonProperty("organization_id") + @ExcludeMissing + organizationId: JsonField<String> = JsonMissing.of(), + @JsonProperty("read_only") @ExcludeMissing readOnly: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing userId: JsonField<String> = JsonMissing.of(), + @JsonProperty("access_scope") + @ExcludeMissing + accessScope: JsonField<AccessScope> = JsonMissing.of(), + @JsonProperty("avatar_url") @ExcludeMissing avatarUrl: JsonField<String> = JsonMissing.of(), + @JsonProperty("email") @ExcludeMissing email: JsonField<String> = JsonMissing.of(), + @JsonProperty("full_name") @ExcludeMissing fullName: JsonField<String> = JsonMissing.of(), + @JsonProperty("linked_login_methods") + @ExcludeMissing + linkedLoginMethods: JsonField<List<ProviderUserSlim>> = JsonMissing.of(), + @JsonProperty("org_role_id") + @ExcludeMissing + orgRoleId: JsonField<String> = JsonMissing.of(), + @JsonProperty("org_role_name") + @ExcludeMissing + orgRoleName: JsonField<String> = JsonMissing.of(), + @JsonProperty("role_id") @ExcludeMissing roleId: JsonField<String> = JsonMissing.of(), + @JsonProperty("role_name") @ExcludeMissing roleName: JsonField<String> = JsonMissing.of(), + @JsonProperty("tenant_id") @ExcludeMissing tenantId: JsonField<String> = JsonMissing.of(), + @JsonProperty("tenant_ids") + @ExcludeMissing + tenantIds: JsonField<List<String>> = JsonMissing.of(), + ) : this( + id, + createdAt, + lsUserId, + organizationId, + readOnly, + userId, + accessScope, + avatarUrl, + email, + fullName, + linkedLoginMethods, + orgRoleId, + orgRoleName, + roleId, + roleName, + tenantId, + tenantIds, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun lsUserId(): String = lsUserId.getRequired("ls_user_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun organizationId(): String = organizationId.getRequired("organization_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun readOnly(): Boolean = readOnly.getRequired("read_only") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun userId(): String = userId.getRequired("user_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun accessScope(): Optional<AccessScope> = accessScope.getOptional("access_scope") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun avatarUrl(): Optional<String> = avatarUrl.getOptional("avatar_url") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun email(): Optional<String> = email.getOptional("email") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fullName(): Optional<String> = fullName.getOptional("full_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun linkedLoginMethods(): Optional<List<ProviderUserSlim>> = + linkedLoginMethods.getOptional("linked_login_methods") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun orgRoleId(): Optional<String> = orgRoleId.getOptional("org_role_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun orgRoleName(): Optional<String> = orgRoleName.getOptional("org_role_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun roleId(): Optional<String> = roleId.getOptional("role_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun roleName(): Optional<String> = roleName.getOptional("role_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tenantId(): Optional<String> = tenantId.getOptional("tenant_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tenantIds(): Optional<List<String>> = tenantIds.getOptional("tenant_ids") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [lsUserId]. + * + * Unlike [lsUserId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ls_user_id") @ExcludeMissing fun _lsUserId(): JsonField<String> = lsUserId + + /** + * Returns the raw JSON value of [organizationId]. + * + * Unlike [organizationId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("organization_id") + @ExcludeMissing + fun _organizationId(): JsonField<String> = organizationId + + /** + * Returns the raw JSON value of [readOnly]. + * + * Unlike [readOnly], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("read_only") @ExcludeMissing fun _readOnly(): JsonField<Boolean> = readOnly + + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField<String> = userId + + /** + * Returns the raw JSON value of [accessScope]. + * + * Unlike [accessScope], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("access_scope") + @ExcludeMissing + fun _accessScope(): JsonField<AccessScope> = accessScope + + /** + * Returns the raw JSON value of [avatarUrl]. + * + * Unlike [avatarUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("avatar_url") @ExcludeMissing fun _avatarUrl(): JsonField<String> = avatarUrl + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField<String> = email + + /** + * Returns the raw JSON value of [fullName]. + * + * Unlike [fullName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("full_name") @ExcludeMissing fun _fullName(): JsonField<String> = fullName + + /** + * Returns the raw JSON value of [linkedLoginMethods]. + * + * Unlike [linkedLoginMethods], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("linked_login_methods") + @ExcludeMissing + fun _linkedLoginMethods(): JsonField<List<ProviderUserSlim>> = linkedLoginMethods + + /** + * Returns the raw JSON value of [orgRoleId]. + * + * Unlike [orgRoleId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("org_role_id") @ExcludeMissing fun _orgRoleId(): JsonField<String> = orgRoleId + + /** + * Returns the raw JSON value of [orgRoleName]. + * + * Unlike [orgRoleName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("org_role_name") + @ExcludeMissing + fun _orgRoleName(): JsonField<String> = orgRoleName + + /** + * Returns the raw JSON value of [roleId]. + * + * Unlike [roleId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("role_id") @ExcludeMissing fun _roleId(): JsonField<String> = roleId + + /** + * Returns the raw JSON value of [roleName]. + * + * Unlike [roleName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("role_name") @ExcludeMissing fun _roleName(): JsonField<String> = roleName + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_id") @ExcludeMissing fun _tenantId(): JsonField<String> = tenantId + + /** + * Returns the raw JSON value of [tenantIds]. + * + * Unlike [tenantIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_ids") + @ExcludeMissing + fun _tenantIds(): JsonField<List<String>> = tenantIds + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [OrgMemberIdentity]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .lsUserId() + * .organizationId() + * .readOnly() + * .userId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OrgMemberIdentity]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var createdAt: JsonField<OffsetDateTime>? = null + private var lsUserId: JsonField<String>? = null + private var organizationId: JsonField<String>? = null + private var readOnly: JsonField<Boolean>? = null + private var userId: JsonField<String>? = null + private var accessScope: JsonField<AccessScope> = JsonMissing.of() + private var avatarUrl: JsonField<String> = JsonMissing.of() + private var email: JsonField<String> = JsonMissing.of() + private var fullName: JsonField<String> = JsonMissing.of() + private var linkedLoginMethods: JsonField<MutableList<ProviderUserSlim>>? = null + private var orgRoleId: JsonField<String> = JsonMissing.of() + private var orgRoleName: JsonField<String> = JsonMissing.of() + private var roleId: JsonField<String> = JsonMissing.of() + private var roleName: JsonField<String> = JsonMissing.of() + private var tenantId: JsonField<String> = JsonMissing.of() + private var tenantIds: JsonField<MutableList<String>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(orgMemberIdentity: OrgMemberIdentity) = apply { + id = orgMemberIdentity.id + createdAt = orgMemberIdentity.createdAt + lsUserId = orgMemberIdentity.lsUserId + organizationId = orgMemberIdentity.organizationId + readOnly = orgMemberIdentity.readOnly + userId = orgMemberIdentity.userId + accessScope = orgMemberIdentity.accessScope + avatarUrl = orgMemberIdentity.avatarUrl + email = orgMemberIdentity.email + fullName = orgMemberIdentity.fullName + linkedLoginMethods = orgMemberIdentity.linkedLoginMethods.map { it.toMutableList() } + orgRoleId = orgMemberIdentity.orgRoleId + orgRoleName = orgMemberIdentity.orgRoleName + roleId = orgMemberIdentity.roleId + roleName = orgMemberIdentity.roleName + tenantId = orgMemberIdentity.tenantId + tenantIds = orgMemberIdentity.tenantIds.map { it.toMutableList() } + additionalProperties = orgMemberIdentity.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun lsUserId(lsUserId: String) = lsUserId(JsonField.of(lsUserId)) + + /** + * Sets [Builder.lsUserId] to an arbitrary JSON value. + * + * You should usually call [Builder.lsUserId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun lsUserId(lsUserId: JsonField<String>) = apply { this.lsUserId = lsUserId } + + fun organizationId(organizationId: String) = organizationId(JsonField.of(organizationId)) + + /** + * Sets [Builder.organizationId] to an arbitrary JSON value. + * + * You should usually call [Builder.organizationId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun organizationId(organizationId: JsonField<String>) = apply { + this.organizationId = organizationId + } + + fun readOnly(readOnly: Boolean) = readOnly(JsonField.of(readOnly)) + + /** + * Sets [Builder.readOnly] to an arbitrary JSON value. + * + * You should usually call [Builder.readOnly] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun readOnly(readOnly: JsonField<Boolean>) = apply { this.readOnly = readOnly } + + fun userId(userId: String) = userId(JsonField.of(userId)) + + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun userId(userId: JsonField<String>) = apply { this.userId = userId } + + fun accessScope(accessScope: AccessScope) = accessScope(JsonField.of(accessScope)) + + /** + * Sets [Builder.accessScope] to an arbitrary JSON value. + * + * You should usually call [Builder.accessScope] with a well-typed [AccessScope] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun accessScope(accessScope: JsonField<AccessScope>) = apply { + this.accessScope = accessScope + } + + fun avatarUrl(avatarUrl: String?) = avatarUrl(JsonField.ofNullable(avatarUrl)) + + /** Alias for calling [Builder.avatarUrl] with `avatarUrl.orElse(null)`. */ + fun avatarUrl(avatarUrl: Optional<String>) = avatarUrl(avatarUrl.getOrNull()) + + /** + * Sets [Builder.avatarUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.avatarUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun avatarUrl(avatarUrl: JsonField<String>) = apply { this.avatarUrl = avatarUrl } + + fun email(email: String?) = email(JsonField.ofNullable(email)) + + /** Alias for calling [Builder.email] with `email.orElse(null)`. */ + fun email(email: Optional<String>) = email(email.getOrNull()) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun email(email: JsonField<String>) = apply { this.email = email } + + fun fullName(fullName: String?) = fullName(JsonField.ofNullable(fullName)) + + /** Alias for calling [Builder.fullName] with `fullName.orElse(null)`. */ + fun fullName(fullName: Optional<String>) = fullName(fullName.getOrNull()) + + /** + * Sets [Builder.fullName] to an arbitrary JSON value. + * + * You should usually call [Builder.fullName] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun fullName(fullName: JsonField<String>) = apply { this.fullName = fullName } + + fun linkedLoginMethods(linkedLoginMethods: List<ProviderUserSlim>) = + linkedLoginMethods(JsonField.of(linkedLoginMethods)) + + /** + * Sets [Builder.linkedLoginMethods] to an arbitrary JSON value. + * + * You should usually call [Builder.linkedLoginMethods] with a well-typed + * `List<ProviderUserSlim>` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun linkedLoginMethods(linkedLoginMethods: JsonField<List<ProviderUserSlim>>) = apply { + this.linkedLoginMethods = linkedLoginMethods.map { it.toMutableList() } + } + + /** + * Adds a single [ProviderUserSlim] to [linkedLoginMethods]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLinkedLoginMethod(linkedLoginMethod: ProviderUserSlim) = apply { + linkedLoginMethods = + (linkedLoginMethods ?: JsonField.of(mutableListOf())).also { + checkKnown("linkedLoginMethods", it).add(linkedLoginMethod) + } + } + + fun orgRoleId(orgRoleId: String?) = orgRoleId(JsonField.ofNullable(orgRoleId)) + + /** Alias for calling [Builder.orgRoleId] with `orgRoleId.orElse(null)`. */ + fun orgRoleId(orgRoleId: Optional<String>) = orgRoleId(orgRoleId.getOrNull()) + + /** + * Sets [Builder.orgRoleId] to an arbitrary JSON value. + * + * You should usually call [Builder.orgRoleId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun orgRoleId(orgRoleId: JsonField<String>) = apply { this.orgRoleId = orgRoleId } + + fun orgRoleName(orgRoleName: String?) = orgRoleName(JsonField.ofNullable(orgRoleName)) + + /** Alias for calling [Builder.orgRoleName] with `orgRoleName.orElse(null)`. */ + fun orgRoleName(orgRoleName: Optional<String>) = orgRoleName(orgRoleName.getOrNull()) + + /** + * Sets [Builder.orgRoleName] to an arbitrary JSON value. + * + * You should usually call [Builder.orgRoleName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun orgRoleName(orgRoleName: JsonField<String>) = apply { this.orgRoleName = orgRoleName } + + fun roleId(roleId: String?) = roleId(JsonField.ofNullable(roleId)) + + /** Alias for calling [Builder.roleId] with `roleId.orElse(null)`. */ + fun roleId(roleId: Optional<String>) = roleId(roleId.getOrNull()) + + /** + * Sets [Builder.roleId] to an arbitrary JSON value. + * + * You should usually call [Builder.roleId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun roleId(roleId: JsonField<String>) = apply { this.roleId = roleId } + + fun roleName(roleName: String?) = roleName(JsonField.ofNullable(roleName)) + + /** Alias for calling [Builder.roleName] with `roleName.orElse(null)`. */ + fun roleName(roleName: Optional<String>) = roleName(roleName.getOrNull()) + + /** + * Sets [Builder.roleName] to an arbitrary JSON value. + * + * You should usually call [Builder.roleName] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun roleName(roleName: JsonField<String>) = apply { this.roleName = roleName } + + fun tenantId(tenantId: String?) = tenantId(JsonField.ofNullable(tenantId)) + + /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ + fun tenantId(tenantId: Optional<String>) = tenantId(tenantId.getOrNull()) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tenantId(tenantId: JsonField<String>) = apply { this.tenantId = tenantId } + + fun tenantIds(tenantIds: List<String>) = tenantIds(JsonField.of(tenantIds)) + + /** + * Sets [Builder.tenantIds] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantIds] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tenantIds(tenantIds: JsonField<List<String>>) = apply { + this.tenantIds = tenantIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [tenantIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTenantId(tenantId: String) = apply { + tenantIds = + (tenantIds ?: JsonField.of(mutableListOf())).also { + checkKnown("tenantIds", it).add(tenantId) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OrgMemberIdentity]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .lsUserId() + * .organizationId() + * .readOnly() + * .userId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): OrgMemberIdentity = + OrgMemberIdentity( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("lsUserId", lsUserId), + checkRequired("organizationId", organizationId), + checkRequired("readOnly", readOnly), + checkRequired("userId", userId), + accessScope, + avatarUrl, + email, + fullName, + (linkedLoginMethods ?: JsonMissing.of()).map { it.toImmutable() }, + orgRoleId, + orgRoleName, + roleId, + roleName, + tenantId, + (tenantIds ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OrgMemberIdentity = apply { + if (validated) { + return@apply + } + + id() + createdAt() + lsUserId() + organizationId() + readOnly() + userId() + accessScope().ifPresent { it.validate() } + avatarUrl() + email() + fullName() + linkedLoginMethods().ifPresent { it.forEach { it.validate() } } + orgRoleId() + orgRoleName() + roleId() + roleName() + tenantId() + tenantIds() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (lsUserId.asKnown().isPresent) 1 else 0) + + (if (organizationId.asKnown().isPresent) 1 else 0) + + (if (readOnly.asKnown().isPresent) 1 else 0) + + (if (userId.asKnown().isPresent) 1 else 0) + + (accessScope.asKnown().getOrNull()?.validity() ?: 0) + + (if (avatarUrl.asKnown().isPresent) 1 else 0) + + (if (email.asKnown().isPresent) 1 else 0) + + (if (fullName.asKnown().isPresent) 1 else 0) + + (linkedLoginMethods.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (orgRoleId.asKnown().isPresent) 1 else 0) + + (if (orgRoleName.asKnown().isPresent) 1 else 0) + + (if (roleId.asKnown().isPresent) 1 else 0) + + (if (roleName.asKnown().isPresent) 1 else 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + (tenantIds.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OrgMemberIdentity && + id == other.id && + createdAt == other.createdAt && + lsUserId == other.lsUserId && + organizationId == other.organizationId && + readOnly == other.readOnly && + userId == other.userId && + accessScope == other.accessScope && + avatarUrl == other.avatarUrl && + email == other.email && + fullName == other.fullName && + linkedLoginMethods == other.linkedLoginMethods && + orgRoleId == other.orgRoleId && + orgRoleName == other.orgRoleName && + roleId == other.roleId && + roleName == other.roleName && + tenantId == other.tenantId && + tenantIds == other.tenantIds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + createdAt, + lsUserId, + organizationId, + readOnly, + userId, + accessScope, + avatarUrl, + email, + fullName, + linkedLoginMethods, + orgRoleId, + orgRoleName, + roleId, + roleName, + tenantId, + tenantIds, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OrgMemberIdentity{id=$id, createdAt=$createdAt, lsUserId=$lsUserId, organizationId=$organizationId, readOnly=$readOnly, userId=$userId, accessScope=$accessScope, avatarUrl=$avatarUrl, email=$email, fullName=$fullName, linkedLoginMethods=$linkedLoginMethods, orgRoleId=$orgRoleId, orgRoleName=$orgRoleName, roleId=$roleId, roleName=$roleName, tenantId=$tenantId, tenantIds=$tenantIds, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/PendingIdentity.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/PendingIdentity.kt new file mode 100644 index 00000000..29550624 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/PendingIdentity.kt @@ -0,0 +1,777 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.members + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class PendingIdentity +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val email: JsonField<String>, + private val accessScope: JsonField<AccessScope>, + private val fullName: JsonField<String>, + private val orgRoleId: JsonField<String>, + private val orgRoleName: JsonField<String>, + private val organizationId: JsonField<String>, + private val password: JsonField<String>, + private val readOnly: JsonField<Boolean>, + private val roleId: JsonField<String>, + private val roleName: JsonField<String>, + private val tenantId: JsonField<String>, + private val userId: JsonField<String>, + private val workspaceIds: JsonField<List<String>>, + private val workspaceRoleId: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("email") @ExcludeMissing email: JsonField<String> = JsonMissing.of(), + @JsonProperty("access_scope") + @ExcludeMissing + accessScope: JsonField<AccessScope> = JsonMissing.of(), + @JsonProperty("full_name") @ExcludeMissing fullName: JsonField<String> = JsonMissing.of(), + @JsonProperty("org_role_id") + @ExcludeMissing + orgRoleId: JsonField<String> = JsonMissing.of(), + @JsonProperty("org_role_name") + @ExcludeMissing + orgRoleName: JsonField<String> = JsonMissing.of(), + @JsonProperty("organization_id") + @ExcludeMissing + organizationId: JsonField<String> = JsonMissing.of(), + @JsonProperty("password") @ExcludeMissing password: JsonField<String> = JsonMissing.of(), + @JsonProperty("read_only") @ExcludeMissing readOnly: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("role_id") @ExcludeMissing roleId: JsonField<String> = JsonMissing.of(), + @JsonProperty("role_name") @ExcludeMissing roleName: JsonField<String> = JsonMissing.of(), + @JsonProperty("tenant_id") @ExcludeMissing tenantId: JsonField<String> = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing userId: JsonField<String> = JsonMissing.of(), + @JsonProperty("workspace_ids") + @ExcludeMissing + workspaceIds: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("workspace_role_id") + @ExcludeMissing + workspaceRoleId: JsonField<String> = JsonMissing.of(), + ) : this( + id, + createdAt, + email, + accessScope, + fullName, + orgRoleId, + orgRoleName, + organizationId, + password, + readOnly, + roleId, + roleName, + tenantId, + userId, + workspaceIds, + workspaceRoleId, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun email(): String = email.getRequired("email") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun accessScope(): Optional<AccessScope> = accessScope.getOptional("access_scope") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fullName(): Optional<String> = fullName.getOptional("full_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun orgRoleId(): Optional<String> = orgRoleId.getOptional("org_role_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun orgRoleName(): Optional<String> = orgRoleName.getOptional("org_role_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun organizationId(): Optional<String> = organizationId.getOptional("organization_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun password(): Optional<String> = password.getOptional("password") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun readOnly(): Optional<Boolean> = readOnly.getOptional("read_only") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun roleId(): Optional<String> = roleId.getOptional("role_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun roleName(): Optional<String> = roleName.getOptional("role_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tenantId(): Optional<String> = tenantId.getOptional("tenant_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun userId(): Optional<String> = userId.getOptional("user_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun workspaceIds(): Optional<List<String>> = workspaceIds.getOptional("workspace_ids") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun workspaceRoleId(): Optional<String> = workspaceRoleId.getOptional("workspace_role_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField<String> = email + + /** + * Returns the raw JSON value of [accessScope]. + * + * Unlike [accessScope], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("access_scope") + @ExcludeMissing + fun _accessScope(): JsonField<AccessScope> = accessScope + + /** + * Returns the raw JSON value of [fullName]. + * + * Unlike [fullName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("full_name") @ExcludeMissing fun _fullName(): JsonField<String> = fullName + + /** + * Returns the raw JSON value of [orgRoleId]. + * + * Unlike [orgRoleId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("org_role_id") @ExcludeMissing fun _orgRoleId(): JsonField<String> = orgRoleId + + /** + * Returns the raw JSON value of [orgRoleName]. + * + * Unlike [orgRoleName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("org_role_name") + @ExcludeMissing + fun _orgRoleName(): JsonField<String> = orgRoleName + + /** + * Returns the raw JSON value of [organizationId]. + * + * Unlike [organizationId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("organization_id") + @ExcludeMissing + fun _organizationId(): JsonField<String> = organizationId + + /** + * Returns the raw JSON value of [password]. + * + * Unlike [password], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("password") @ExcludeMissing fun _password(): JsonField<String> = password + + /** + * Returns the raw JSON value of [readOnly]. + * + * Unlike [readOnly], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("read_only") @ExcludeMissing fun _readOnly(): JsonField<Boolean> = readOnly + + /** + * Returns the raw JSON value of [roleId]. + * + * Unlike [roleId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("role_id") @ExcludeMissing fun _roleId(): JsonField<String> = roleId + + /** + * Returns the raw JSON value of [roleName]. + * + * Unlike [roleName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("role_name") @ExcludeMissing fun _roleName(): JsonField<String> = roleName + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_id") @ExcludeMissing fun _tenantId(): JsonField<String> = tenantId + + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField<String> = userId + + /** + * Returns the raw JSON value of [workspaceIds]. + * + * Unlike [workspaceIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("workspace_ids") + @ExcludeMissing + fun _workspaceIds(): JsonField<List<String>> = workspaceIds + + /** + * Returns the raw JSON value of [workspaceRoleId]. + * + * Unlike [workspaceRoleId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("workspace_role_id") + @ExcludeMissing + fun _workspaceRoleId(): JsonField<String> = workspaceRoleId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PendingIdentity]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .email() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PendingIdentity]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var createdAt: JsonField<OffsetDateTime>? = null + private var email: JsonField<String>? = null + private var accessScope: JsonField<AccessScope> = JsonMissing.of() + private var fullName: JsonField<String> = JsonMissing.of() + private var orgRoleId: JsonField<String> = JsonMissing.of() + private var orgRoleName: JsonField<String> = JsonMissing.of() + private var organizationId: JsonField<String> = JsonMissing.of() + private var password: JsonField<String> = JsonMissing.of() + private var readOnly: JsonField<Boolean> = JsonMissing.of() + private var roleId: JsonField<String> = JsonMissing.of() + private var roleName: JsonField<String> = JsonMissing.of() + private var tenantId: JsonField<String> = JsonMissing.of() + private var userId: JsonField<String> = JsonMissing.of() + private var workspaceIds: JsonField<MutableList<String>>? = null + private var workspaceRoleId: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(pendingIdentity: PendingIdentity) = apply { + id = pendingIdentity.id + createdAt = pendingIdentity.createdAt + email = pendingIdentity.email + accessScope = pendingIdentity.accessScope + fullName = pendingIdentity.fullName + orgRoleId = pendingIdentity.orgRoleId + orgRoleName = pendingIdentity.orgRoleName + organizationId = pendingIdentity.organizationId + password = pendingIdentity.password + readOnly = pendingIdentity.readOnly + roleId = pendingIdentity.roleId + roleName = pendingIdentity.roleName + tenantId = pendingIdentity.tenantId + userId = pendingIdentity.userId + workspaceIds = pendingIdentity.workspaceIds.map { it.toMutableList() } + workspaceRoleId = pendingIdentity.workspaceRoleId + additionalProperties = pendingIdentity.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun email(email: String) = email(JsonField.of(email)) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun email(email: JsonField<String>) = apply { this.email = email } + + fun accessScope(accessScope: AccessScope) = accessScope(JsonField.of(accessScope)) + + /** + * Sets [Builder.accessScope] to an arbitrary JSON value. + * + * You should usually call [Builder.accessScope] with a well-typed [AccessScope] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun accessScope(accessScope: JsonField<AccessScope>) = apply { + this.accessScope = accessScope + } + + fun fullName(fullName: String?) = fullName(JsonField.ofNullable(fullName)) + + /** Alias for calling [Builder.fullName] with `fullName.orElse(null)`. */ + fun fullName(fullName: Optional<String>) = fullName(fullName.getOrNull()) + + /** + * Sets [Builder.fullName] to an arbitrary JSON value. + * + * You should usually call [Builder.fullName] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun fullName(fullName: JsonField<String>) = apply { this.fullName = fullName } + + fun orgRoleId(orgRoleId: String?) = orgRoleId(JsonField.ofNullable(orgRoleId)) + + /** Alias for calling [Builder.orgRoleId] with `orgRoleId.orElse(null)`. */ + fun orgRoleId(orgRoleId: Optional<String>) = orgRoleId(orgRoleId.getOrNull()) + + /** + * Sets [Builder.orgRoleId] to an arbitrary JSON value. + * + * You should usually call [Builder.orgRoleId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun orgRoleId(orgRoleId: JsonField<String>) = apply { this.orgRoleId = orgRoleId } + + fun orgRoleName(orgRoleName: String?) = orgRoleName(JsonField.ofNullable(orgRoleName)) + + /** Alias for calling [Builder.orgRoleName] with `orgRoleName.orElse(null)`. */ + fun orgRoleName(orgRoleName: Optional<String>) = orgRoleName(orgRoleName.getOrNull()) + + /** + * Sets [Builder.orgRoleName] to an arbitrary JSON value. + * + * You should usually call [Builder.orgRoleName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun orgRoleName(orgRoleName: JsonField<String>) = apply { this.orgRoleName = orgRoleName } + + fun organizationId(organizationId: String?) = + organizationId(JsonField.ofNullable(organizationId)) + + /** Alias for calling [Builder.organizationId] with `organizationId.orElse(null)`. */ + fun organizationId(organizationId: Optional<String>) = + organizationId(organizationId.getOrNull()) + + /** + * Sets [Builder.organizationId] to an arbitrary JSON value. + * + * You should usually call [Builder.organizationId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun organizationId(organizationId: JsonField<String>) = apply { + this.organizationId = organizationId + } + + fun password(password: String?) = password(JsonField.ofNullable(password)) + + /** Alias for calling [Builder.password] with `password.orElse(null)`. */ + fun password(password: Optional<String>) = password(password.getOrNull()) + + /** + * Sets [Builder.password] to an arbitrary JSON value. + * + * You should usually call [Builder.password] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun password(password: JsonField<String>) = apply { this.password = password } + + fun readOnly(readOnly: Boolean) = readOnly(JsonField.of(readOnly)) + + /** + * Sets [Builder.readOnly] to an arbitrary JSON value. + * + * You should usually call [Builder.readOnly] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun readOnly(readOnly: JsonField<Boolean>) = apply { this.readOnly = readOnly } + + fun roleId(roleId: String?) = roleId(JsonField.ofNullable(roleId)) + + /** Alias for calling [Builder.roleId] with `roleId.orElse(null)`. */ + fun roleId(roleId: Optional<String>) = roleId(roleId.getOrNull()) + + /** + * Sets [Builder.roleId] to an arbitrary JSON value. + * + * You should usually call [Builder.roleId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun roleId(roleId: JsonField<String>) = apply { this.roleId = roleId } + + fun roleName(roleName: String?) = roleName(JsonField.ofNullable(roleName)) + + /** Alias for calling [Builder.roleName] with `roleName.orElse(null)`. */ + fun roleName(roleName: Optional<String>) = roleName(roleName.getOrNull()) + + /** + * Sets [Builder.roleName] to an arbitrary JSON value. + * + * You should usually call [Builder.roleName] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun roleName(roleName: JsonField<String>) = apply { this.roleName = roleName } + + fun tenantId(tenantId: String?) = tenantId(JsonField.ofNullable(tenantId)) + + /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ + fun tenantId(tenantId: Optional<String>) = tenantId(tenantId.getOrNull()) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tenantId(tenantId: JsonField<String>) = apply { this.tenantId = tenantId } + + fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) + + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ + fun userId(userId: Optional<String>) = userId(userId.getOrNull()) + + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun userId(userId: JsonField<String>) = apply { this.userId = userId } + + fun workspaceIds(workspaceIds: List<String>?) = + workspaceIds(JsonField.ofNullable(workspaceIds)) + + /** Alias for calling [Builder.workspaceIds] with `workspaceIds.orElse(null)`. */ + fun workspaceIds(workspaceIds: Optional<List<String>>) = + workspaceIds(workspaceIds.getOrNull()) + + /** + * Sets [Builder.workspaceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.workspaceIds] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun workspaceIds(workspaceIds: JsonField<List<String>>) = apply { + this.workspaceIds = workspaceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [workspaceIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWorkspaceId(workspaceId: String) = apply { + workspaceIds = + (workspaceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("workspaceIds", it).add(workspaceId) + } + } + + fun workspaceRoleId(workspaceRoleId: String?) = + workspaceRoleId(JsonField.ofNullable(workspaceRoleId)) + + /** Alias for calling [Builder.workspaceRoleId] with `workspaceRoleId.orElse(null)`. */ + fun workspaceRoleId(workspaceRoleId: Optional<String>) = + workspaceRoleId(workspaceRoleId.getOrNull()) + + /** + * Sets [Builder.workspaceRoleId] to an arbitrary JSON value. + * + * You should usually call [Builder.workspaceRoleId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun workspaceRoleId(workspaceRoleId: JsonField<String>) = apply { + this.workspaceRoleId = workspaceRoleId + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PendingIdentity]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .email() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PendingIdentity = + PendingIdentity( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("email", email), + accessScope, + fullName, + orgRoleId, + orgRoleName, + organizationId, + password, + readOnly, + roleId, + roleName, + tenantId, + userId, + (workspaceIds ?: JsonMissing.of()).map { it.toImmutable() }, + workspaceRoleId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PendingIdentity = apply { + if (validated) { + return@apply + } + + id() + createdAt() + email() + accessScope().ifPresent { it.validate() } + fullName() + orgRoleId() + orgRoleName() + organizationId() + password() + readOnly() + roleId() + roleName() + tenantId() + userId() + workspaceIds() + workspaceRoleId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (email.asKnown().isPresent) 1 else 0) + + (accessScope.asKnown().getOrNull()?.validity() ?: 0) + + (if (fullName.asKnown().isPresent) 1 else 0) + + (if (orgRoleId.asKnown().isPresent) 1 else 0) + + (if (orgRoleName.asKnown().isPresent) 1 else 0) + + (if (organizationId.asKnown().isPresent) 1 else 0) + + (if (password.asKnown().isPresent) 1 else 0) + + (if (readOnly.asKnown().isPresent) 1 else 0) + + (if (roleId.asKnown().isPresent) 1 else 0) + + (if (roleName.asKnown().isPresent) 1 else 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + (if (userId.asKnown().isPresent) 1 else 0) + + (workspaceIds.asKnown().getOrNull()?.size ?: 0) + + (if (workspaceRoleId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PendingIdentity && + id == other.id && + createdAt == other.createdAt && + email == other.email && + accessScope == other.accessScope && + fullName == other.fullName && + orgRoleId == other.orgRoleId && + orgRoleName == other.orgRoleName && + organizationId == other.organizationId && + password == other.password && + readOnly == other.readOnly && + roleId == other.roleId && + roleName == other.roleName && + tenantId == other.tenantId && + userId == other.userId && + workspaceIds == other.workspaceIds && + workspaceRoleId == other.workspaceRoleId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + createdAt, + email, + accessScope, + fullName, + orgRoleId, + orgRoleName, + organizationId, + password, + readOnly, + roleId, + roleName, + tenantId, + userId, + workspaceIds, + workspaceRoleId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PendingIdentity{id=$id, createdAt=$createdAt, email=$email, accessScope=$accessScope, fullName=$fullName, orgRoleId=$orgRoleId, orgRoleName=$orgRoleName, organizationId=$organizationId, password=$password, readOnly=$readOnly, roleId=$roleId, roleName=$roleName, tenantId=$tenantId, userId=$userId, workspaceIds=$workspaceIds, workspaceRoleId=$workspaceRoleId, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/PendingIdentityCreate.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/PendingIdentityCreate.kt new file mode 100644 index 00000000..b20f461c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/PendingIdentityCreate.kt @@ -0,0 +1,428 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.members + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class PendingIdentityCreate +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val email: JsonField<String>, + private val fullName: JsonField<String>, + private val password: JsonField<String>, + private val readOnly: JsonField<Boolean>, + private val roleId: JsonField<String>, + private val workspaceIds: JsonField<List<String>>, + private val workspaceRoleId: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("email") @ExcludeMissing email: JsonField<String> = JsonMissing.of(), + @JsonProperty("full_name") @ExcludeMissing fullName: JsonField<String> = JsonMissing.of(), + @JsonProperty("password") @ExcludeMissing password: JsonField<String> = JsonMissing.of(), + @JsonProperty("read_only") @ExcludeMissing readOnly: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("role_id") @ExcludeMissing roleId: JsonField<String> = JsonMissing.of(), + @JsonProperty("workspace_ids") + @ExcludeMissing + workspaceIds: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("workspace_role_id") + @ExcludeMissing + workspaceRoleId: JsonField<String> = JsonMissing.of(), + ) : this( + email, + fullName, + password, + readOnly, + roleId, + workspaceIds, + workspaceRoleId, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun email(): String = email.getRequired("email") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fullName(): Optional<String> = fullName.getOptional("full_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun password(): Optional<String> = password.getOptional("password") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun readOnly(): Optional<Boolean> = readOnly.getOptional("read_only") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun roleId(): Optional<String> = roleId.getOptional("role_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun workspaceIds(): Optional<List<String>> = workspaceIds.getOptional("workspace_ids") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun workspaceRoleId(): Optional<String> = workspaceRoleId.getOptional("workspace_role_id") + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField<String> = email + + /** + * Returns the raw JSON value of [fullName]. + * + * Unlike [fullName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("full_name") @ExcludeMissing fun _fullName(): JsonField<String> = fullName + + /** + * Returns the raw JSON value of [password]. + * + * Unlike [password], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("password") @ExcludeMissing fun _password(): JsonField<String> = password + + /** + * Returns the raw JSON value of [readOnly]. + * + * Unlike [readOnly], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("read_only") @ExcludeMissing fun _readOnly(): JsonField<Boolean> = readOnly + + /** + * Returns the raw JSON value of [roleId]. + * + * Unlike [roleId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("role_id") @ExcludeMissing fun _roleId(): JsonField<String> = roleId + + /** + * Returns the raw JSON value of [workspaceIds]. + * + * Unlike [workspaceIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("workspace_ids") + @ExcludeMissing + fun _workspaceIds(): JsonField<List<String>> = workspaceIds + + /** + * Returns the raw JSON value of [workspaceRoleId]. + * + * Unlike [workspaceRoleId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("workspace_role_id") + @ExcludeMissing + fun _workspaceRoleId(): JsonField<String> = workspaceRoleId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PendingIdentityCreate]. + * + * The following fields are required: + * ```java + * .email() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PendingIdentityCreate]. */ + class Builder internal constructor() { + + private var email: JsonField<String>? = null + private var fullName: JsonField<String> = JsonMissing.of() + private var password: JsonField<String> = JsonMissing.of() + private var readOnly: JsonField<Boolean> = JsonMissing.of() + private var roleId: JsonField<String> = JsonMissing.of() + private var workspaceIds: JsonField<MutableList<String>>? = null + private var workspaceRoleId: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(pendingIdentityCreate: PendingIdentityCreate) = apply { + email = pendingIdentityCreate.email + fullName = pendingIdentityCreate.fullName + password = pendingIdentityCreate.password + readOnly = pendingIdentityCreate.readOnly + roleId = pendingIdentityCreate.roleId + workspaceIds = pendingIdentityCreate.workspaceIds.map { it.toMutableList() } + workspaceRoleId = pendingIdentityCreate.workspaceRoleId + additionalProperties = pendingIdentityCreate.additionalProperties.toMutableMap() + } + + fun email(email: String) = email(JsonField.of(email)) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun email(email: JsonField<String>) = apply { this.email = email } + + fun fullName(fullName: String?) = fullName(JsonField.ofNullable(fullName)) + + /** Alias for calling [Builder.fullName] with `fullName.orElse(null)`. */ + fun fullName(fullName: Optional<String>) = fullName(fullName.getOrNull()) + + /** + * Sets [Builder.fullName] to an arbitrary JSON value. + * + * You should usually call [Builder.fullName] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun fullName(fullName: JsonField<String>) = apply { this.fullName = fullName } + + fun password(password: String?) = password(JsonField.ofNullable(password)) + + /** Alias for calling [Builder.password] with `password.orElse(null)`. */ + fun password(password: Optional<String>) = password(password.getOrNull()) + + /** + * Sets [Builder.password] to an arbitrary JSON value. + * + * You should usually call [Builder.password] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun password(password: JsonField<String>) = apply { this.password = password } + + fun readOnly(readOnly: Boolean) = readOnly(JsonField.of(readOnly)) + + /** + * Sets [Builder.readOnly] to an arbitrary JSON value. + * + * You should usually call [Builder.readOnly] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun readOnly(readOnly: JsonField<Boolean>) = apply { this.readOnly = readOnly } + + fun roleId(roleId: String?) = roleId(JsonField.ofNullable(roleId)) + + /** Alias for calling [Builder.roleId] with `roleId.orElse(null)`. */ + fun roleId(roleId: Optional<String>) = roleId(roleId.getOrNull()) + + /** + * Sets [Builder.roleId] to an arbitrary JSON value. + * + * You should usually call [Builder.roleId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun roleId(roleId: JsonField<String>) = apply { this.roleId = roleId } + + fun workspaceIds(workspaceIds: List<String>?) = + workspaceIds(JsonField.ofNullable(workspaceIds)) + + /** Alias for calling [Builder.workspaceIds] with `workspaceIds.orElse(null)`. */ + fun workspaceIds(workspaceIds: Optional<List<String>>) = + workspaceIds(workspaceIds.getOrNull()) + + /** + * Sets [Builder.workspaceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.workspaceIds] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun workspaceIds(workspaceIds: JsonField<List<String>>) = apply { + this.workspaceIds = workspaceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [workspaceIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWorkspaceId(workspaceId: String) = apply { + workspaceIds = + (workspaceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("workspaceIds", it).add(workspaceId) + } + } + + fun workspaceRoleId(workspaceRoleId: String?) = + workspaceRoleId(JsonField.ofNullable(workspaceRoleId)) + + /** Alias for calling [Builder.workspaceRoleId] with `workspaceRoleId.orElse(null)`. */ + fun workspaceRoleId(workspaceRoleId: Optional<String>) = + workspaceRoleId(workspaceRoleId.getOrNull()) + + /** + * Sets [Builder.workspaceRoleId] to an arbitrary JSON value. + * + * You should usually call [Builder.workspaceRoleId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun workspaceRoleId(workspaceRoleId: JsonField<String>) = apply { + this.workspaceRoleId = workspaceRoleId + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PendingIdentityCreate]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .email() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PendingIdentityCreate = + PendingIdentityCreate( + checkRequired("email", email), + fullName, + password, + readOnly, + roleId, + (workspaceIds ?: JsonMissing.of()).map { it.toImmutable() }, + workspaceRoleId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PendingIdentityCreate = apply { + if (validated) { + return@apply + } + + email() + fullName() + password() + readOnly() + roleId() + workspaceIds() + workspaceRoleId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (email.asKnown().isPresent) 1 else 0) + + (if (fullName.asKnown().isPresent) 1 else 0) + + (if (password.asKnown().isPresent) 1 else 0) + + (if (readOnly.asKnown().isPresent) 1 else 0) + + (if (roleId.asKnown().isPresent) 1 else 0) + + (workspaceIds.asKnown().getOrNull()?.size ?: 0) + + (if (workspaceRoleId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PendingIdentityCreate && + email == other.email && + fullName == other.fullName && + password == other.password && + readOnly == other.readOnly && + roleId == other.roleId && + workspaceIds == other.workspaceIds && + workspaceRoleId == other.workspaceRoleId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + email, + fullName, + password, + readOnly, + roleId, + workspaceIds, + workspaceRoleId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PendingIdentityCreate{email=$email, fullName=$fullName, password=$password, readOnly=$readOnly, roleId=$roleId, workspaceIds=$workspaceIds, workspaceRoleId=$workspaceRoleId, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/basic/BasicBatchParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/basic/BasicBatchParams.kt new file mode 100644 index 00000000..3bae895c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/basic/BasicBatchParams.kt @@ -0,0 +1,727 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.members.basic + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Batch add up to 500 users to the org and specified workspaces in basic auth mode. */ +class BasicBatchParams +private constructor( + private val body: List<Body>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun body(): List<Body> = body + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BasicBatchParams]. + * + * The following fields are required: + * ```java + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BasicBatchParams]. */ + class Builder internal constructor() { + + private var body: MutableList<Body>? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(basicBatchParams: BasicBatchParams) = apply { + body = basicBatchParams.body.toMutableList() + additionalHeaders = basicBatchParams.additionalHeaders.toBuilder() + additionalQueryParams = basicBatchParams.additionalQueryParams.toBuilder() + } + + fun body(body: List<Body>) = apply { this.body = body.toMutableList() } + + /** + * Adds a single [Body] to [Builder.body]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addBody(body: Body) = apply { + this.body = (this.body ?: mutableListOf()).apply { add(body) } + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [BasicBatchParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BasicBatchParams = + BasicBatchParams( + checkRequired("body", body).toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): List<Body> = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val email: JsonField<String>, + private val fullName: JsonField<String>, + private val lsUserId: JsonField<String>, + private val password: JsonField<String>, + private val readOnly: JsonField<Boolean>, + private val roleId: JsonField<String>, + private val userId: JsonField<String>, + private val workspaceIds: JsonField<List<String>>, + private val workspaceRoleId: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("email") @ExcludeMissing email: JsonField<String> = JsonMissing.of(), + @JsonProperty("full_name") + @ExcludeMissing + fullName: JsonField<String> = JsonMissing.of(), + @JsonProperty("ls_user_id") + @ExcludeMissing + lsUserId: JsonField<String> = JsonMissing.of(), + @JsonProperty("password") + @ExcludeMissing + password: JsonField<String> = JsonMissing.of(), + @JsonProperty("read_only") + @ExcludeMissing + readOnly: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("role_id") @ExcludeMissing roleId: JsonField<String> = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing userId: JsonField<String> = JsonMissing.of(), + @JsonProperty("workspace_ids") + @ExcludeMissing + workspaceIds: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("workspace_role_id") + @ExcludeMissing + workspaceRoleId: JsonField<String> = JsonMissing.of(), + ) : this( + email, + fullName, + lsUserId, + password, + readOnly, + roleId, + userId, + workspaceIds, + workspaceRoleId, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun email(): String = email.getRequired("email") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun fullName(): Optional<String> = fullName.getOptional("full_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun lsUserId(): Optional<String> = lsUserId.getOptional("ls_user_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun password(): Optional<String> = password.getOptional("password") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun readOnly(): Optional<Boolean> = readOnly.getOptional("read_only") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun roleId(): Optional<String> = roleId.getOptional("role_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun userId(): Optional<String> = userId.getOptional("user_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun workspaceIds(): Optional<List<String>> = workspaceIds.getOptional("workspace_ids") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun workspaceRoleId(): Optional<String> = workspaceRoleId.getOptional("workspace_role_id") + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField<String> = email + + /** + * Returns the raw JSON value of [fullName]. + * + * Unlike [fullName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("full_name") @ExcludeMissing fun _fullName(): JsonField<String> = fullName + + /** + * Returns the raw JSON value of [lsUserId]. + * + * Unlike [lsUserId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ls_user_id") @ExcludeMissing fun _lsUserId(): JsonField<String> = lsUserId + + /** + * Returns the raw JSON value of [password]. + * + * Unlike [password], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("password") @ExcludeMissing fun _password(): JsonField<String> = password + + /** + * Returns the raw JSON value of [readOnly]. + * + * Unlike [readOnly], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("read_only") @ExcludeMissing fun _readOnly(): JsonField<Boolean> = readOnly + + /** + * Returns the raw JSON value of [roleId]. + * + * Unlike [roleId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("role_id") @ExcludeMissing fun _roleId(): JsonField<String> = roleId + + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField<String> = userId + + /** + * Returns the raw JSON value of [workspaceIds]. + * + * Unlike [workspaceIds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("workspace_ids") + @ExcludeMissing + fun _workspaceIds(): JsonField<List<String>> = workspaceIds + + /** + * Returns the raw JSON value of [workspaceRoleId]. + * + * Unlike [workspaceRoleId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("workspace_role_id") + @ExcludeMissing + fun _workspaceRoleId(): JsonField<String> = workspaceRoleId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .email() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var email: JsonField<String>? = null + private var fullName: JsonField<String> = JsonMissing.of() + private var lsUserId: JsonField<String> = JsonMissing.of() + private var password: JsonField<String> = JsonMissing.of() + private var readOnly: JsonField<Boolean> = JsonMissing.of() + private var roleId: JsonField<String> = JsonMissing.of() + private var userId: JsonField<String> = JsonMissing.of() + private var workspaceIds: JsonField<MutableList<String>>? = null + private var workspaceRoleId: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + email = body.email + fullName = body.fullName + lsUserId = body.lsUserId + password = body.password + readOnly = body.readOnly + roleId = body.roleId + userId = body.userId + workspaceIds = body.workspaceIds.map { it.toMutableList() } + workspaceRoleId = body.workspaceRoleId + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun email(email: String) = email(JsonField.of(email)) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun email(email: JsonField<String>) = apply { this.email = email } + + fun fullName(fullName: String?) = fullName(JsonField.ofNullable(fullName)) + + /** Alias for calling [Builder.fullName] with `fullName.orElse(null)`. */ + fun fullName(fullName: Optional<String>) = fullName(fullName.getOrNull()) + + /** + * Sets [Builder.fullName] to an arbitrary JSON value. + * + * You should usually call [Builder.fullName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fullName(fullName: JsonField<String>) = apply { this.fullName = fullName } + + fun lsUserId(lsUserId: String?) = lsUserId(JsonField.ofNullable(lsUserId)) + + /** Alias for calling [Builder.lsUserId] with `lsUserId.orElse(null)`. */ + fun lsUserId(lsUserId: Optional<String>) = lsUserId(lsUserId.getOrNull()) + + /** + * Sets [Builder.lsUserId] to an arbitrary JSON value. + * + * You should usually call [Builder.lsUserId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lsUserId(lsUserId: JsonField<String>) = apply { this.lsUserId = lsUserId } + + fun password(password: String?) = password(JsonField.ofNullable(password)) + + /** Alias for calling [Builder.password] with `password.orElse(null)`. */ + fun password(password: Optional<String>) = password(password.getOrNull()) + + /** + * Sets [Builder.password] to an arbitrary JSON value. + * + * You should usually call [Builder.password] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun password(password: JsonField<String>) = apply { this.password = password } + + fun readOnly(readOnly: Boolean?) = readOnly(JsonField.ofNullable(readOnly)) + + /** + * Alias for [Builder.readOnly]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun readOnly(readOnly: Boolean) = readOnly(readOnly as Boolean?) + + /** Alias for calling [Builder.readOnly] with `readOnly.orElse(null)`. */ + fun readOnly(readOnly: Optional<Boolean>) = readOnly(readOnly.getOrNull()) + + /** + * Sets [Builder.readOnly] to an arbitrary JSON value. + * + * You should usually call [Builder.readOnly] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun readOnly(readOnly: JsonField<Boolean>) = apply { this.readOnly = readOnly } + + fun roleId(roleId: String?) = roleId(JsonField.ofNullable(roleId)) + + /** Alias for calling [Builder.roleId] with `roleId.orElse(null)`. */ + fun roleId(roleId: Optional<String>) = roleId(roleId.getOrNull()) + + /** + * Sets [Builder.roleId] to an arbitrary JSON value. + * + * You should usually call [Builder.roleId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun roleId(roleId: JsonField<String>) = apply { this.roleId = roleId } + + fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) + + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ + fun userId(userId: Optional<String>) = userId(userId.getOrNull()) + + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun userId(userId: JsonField<String>) = apply { this.userId = userId } + + fun workspaceIds(workspaceIds: List<String>?) = + workspaceIds(JsonField.ofNullable(workspaceIds)) + + /** Alias for calling [Builder.workspaceIds] with `workspaceIds.orElse(null)`. */ + fun workspaceIds(workspaceIds: Optional<List<String>>) = + workspaceIds(workspaceIds.getOrNull()) + + /** + * Sets [Builder.workspaceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.workspaceIds] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun workspaceIds(workspaceIds: JsonField<List<String>>) = apply { + this.workspaceIds = workspaceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [workspaceIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWorkspaceId(workspaceId: String) = apply { + workspaceIds = + (workspaceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("workspaceIds", it).add(workspaceId) + } + } + + fun workspaceRoleId(workspaceRoleId: String?) = + workspaceRoleId(JsonField.ofNullable(workspaceRoleId)) + + /** Alias for calling [Builder.workspaceRoleId] with `workspaceRoleId.orElse(null)`. */ + fun workspaceRoleId(workspaceRoleId: Optional<String>) = + workspaceRoleId(workspaceRoleId.getOrNull()) + + /** + * Sets [Builder.workspaceRoleId] to an arbitrary JSON value. + * + * You should usually call [Builder.workspaceRoleId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun workspaceRoleId(workspaceRoleId: JsonField<String>) = apply { + this.workspaceRoleId = workspaceRoleId + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .email() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("email", email), + fullName, + lsUserId, + password, + readOnly, + roleId, + userId, + (workspaceIds ?: JsonMissing.of()).map { it.toImmutable() }, + workspaceRoleId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + email() + fullName() + lsUserId() + password() + readOnly() + roleId() + userId() + workspaceIds() + workspaceRoleId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (email.asKnown().isPresent) 1 else 0) + + (if (fullName.asKnown().isPresent) 1 else 0) + + (if (lsUserId.asKnown().isPresent) 1 else 0) + + (if (password.asKnown().isPresent) 1 else 0) + + (if (readOnly.asKnown().isPresent) 1 else 0) + + (if (roleId.asKnown().isPresent) 1 else 0) + + (if (userId.asKnown().isPresent) 1 else 0) + + (workspaceIds.asKnown().getOrNull()?.size ?: 0) + + (if (workspaceRoleId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + email == other.email && + fullName == other.fullName && + lsUserId == other.lsUserId && + password == other.password && + readOnly == other.readOnly && + roleId == other.roleId && + userId == other.userId && + workspaceIds == other.workspaceIds && + workspaceRoleId == other.workspaceRoleId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + email, + fullName, + lsUserId, + password, + readOnly, + roleId, + userId, + workspaceIds, + workspaceRoleId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{email=$email, fullName=$fullName, lsUserId=$lsUserId, password=$password, readOnly=$readOnly, roleId=$roleId, userId=$userId, workspaceIds=$workspaceIds, workspaceRoleId=$workspaceRoleId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BasicBatchParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "BasicBatchParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/basic/BasicBatchResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/basic/BasicBatchResponse.kt new file mode 100644 index 00000000..cdcc70f4 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/basic/BasicBatchResponse.kt @@ -0,0 +1,442 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.members.basic + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BasicBatchResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val email: JsonField<String>, + private val lsUserId: JsonField<String>, + private val updatedAt: JsonField<OffsetDateTime>, + private val avatarUrl: JsonField<String>, + private val fullName: JsonField<String>, + private val password: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("email") @ExcludeMissing email: JsonField<String> = JsonMissing.of(), + @JsonProperty("ls_user_id") @ExcludeMissing lsUserId: JsonField<String> = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("avatar_url") @ExcludeMissing avatarUrl: JsonField<String> = JsonMissing.of(), + @JsonProperty("full_name") @ExcludeMissing fullName: JsonField<String> = JsonMissing.of(), + @JsonProperty("password") @ExcludeMissing password: JsonField<String> = JsonMissing.of(), + ) : this( + id, + createdAt, + email, + lsUserId, + updatedAt, + avatarUrl, + fullName, + password, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun email(): String = email.getRequired("email") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun lsUserId(): String = lsUserId.getRequired("ls_user_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updatedAt(): OffsetDateTime = updatedAt.getRequired("updated_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun avatarUrl(): Optional<String> = avatarUrl.getOptional("avatar_url") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fullName(): Optional<String> = fullName.getOptional("full_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun password(): Optional<String> = password.getOptional("password") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField<String> = email + + /** + * Returns the raw JSON value of [lsUserId]. + * + * Unlike [lsUserId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ls_user_id") @ExcludeMissing fun _lsUserId(): JsonField<String> = lsUserId + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField<OffsetDateTime> = updatedAt + + /** + * Returns the raw JSON value of [avatarUrl]. + * + * Unlike [avatarUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("avatar_url") @ExcludeMissing fun _avatarUrl(): JsonField<String> = avatarUrl + + /** + * Returns the raw JSON value of [fullName]. + * + * Unlike [fullName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("full_name") @ExcludeMissing fun _fullName(): JsonField<String> = fullName + + /** + * Returns the raw JSON value of [password]. + * + * Unlike [password], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("password") @ExcludeMissing fun _password(): JsonField<String> = password + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BasicBatchResponse]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .email() + * .lsUserId() + * .updatedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BasicBatchResponse]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var createdAt: JsonField<OffsetDateTime>? = null + private var email: JsonField<String>? = null + private var lsUserId: JsonField<String>? = null + private var updatedAt: JsonField<OffsetDateTime>? = null + private var avatarUrl: JsonField<String> = JsonMissing.of() + private var fullName: JsonField<String> = JsonMissing.of() + private var password: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(basicBatchResponse: BasicBatchResponse) = apply { + id = basicBatchResponse.id + createdAt = basicBatchResponse.createdAt + email = basicBatchResponse.email + lsUserId = basicBatchResponse.lsUserId + updatedAt = basicBatchResponse.updatedAt + avatarUrl = basicBatchResponse.avatarUrl + fullName = basicBatchResponse.fullName + password = basicBatchResponse.password + additionalProperties = basicBatchResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun email(email: String) = email(JsonField.of(email)) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun email(email: JsonField<String>) = apply { this.email = email } + + fun lsUserId(lsUserId: String) = lsUserId(JsonField.of(lsUserId)) + + /** + * Sets [Builder.lsUserId] to an arbitrary JSON value. + * + * You should usually call [Builder.lsUserId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun lsUserId(lsUserId: JsonField<String>) = apply { this.lsUserId = lsUserId } + + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField<OffsetDateTime>) = apply { this.updatedAt = updatedAt } + + fun avatarUrl(avatarUrl: String?) = avatarUrl(JsonField.ofNullable(avatarUrl)) + + /** Alias for calling [Builder.avatarUrl] with `avatarUrl.orElse(null)`. */ + fun avatarUrl(avatarUrl: Optional<String>) = avatarUrl(avatarUrl.getOrNull()) + + /** + * Sets [Builder.avatarUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.avatarUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun avatarUrl(avatarUrl: JsonField<String>) = apply { this.avatarUrl = avatarUrl } + + fun fullName(fullName: String?) = fullName(JsonField.ofNullable(fullName)) + + /** Alias for calling [Builder.fullName] with `fullName.orElse(null)`. */ + fun fullName(fullName: Optional<String>) = fullName(fullName.getOrNull()) + + /** + * Sets [Builder.fullName] to an arbitrary JSON value. + * + * You should usually call [Builder.fullName] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun fullName(fullName: JsonField<String>) = apply { this.fullName = fullName } + + fun password(password: String?) = password(JsonField.ofNullable(password)) + + /** Alias for calling [Builder.password] with `password.orElse(null)`. */ + fun password(password: Optional<String>) = password(password.getOrNull()) + + /** + * Sets [Builder.password] to an arbitrary JSON value. + * + * You should usually call [Builder.password] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun password(password: JsonField<String>) = apply { this.password = password } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BasicBatchResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .email() + * .lsUserId() + * .updatedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BasicBatchResponse = + BasicBatchResponse( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("email", email), + checkRequired("lsUserId", lsUserId), + checkRequired("updatedAt", updatedAt), + avatarUrl, + fullName, + password, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BasicBatchResponse = apply { + if (validated) { + return@apply + } + + id() + createdAt() + email() + lsUserId() + updatedAt() + avatarUrl() + fullName() + password() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (email.asKnown().isPresent) 1 else 0) + + (if (lsUserId.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (if (avatarUrl.asKnown().isPresent) 1 else 0) + + (if (fullName.asKnown().isPresent) 1 else 0) + + (if (password.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BasicBatchResponse && + id == other.id && + createdAt == other.createdAt && + email == other.email && + lsUserId == other.lsUserId && + updatedAt == other.updatedAt && + avatarUrl == other.avatarUrl && + fullName == other.fullName && + password == other.password && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + createdAt, + email, + lsUserId, + updatedAt, + avatarUrl, + fullName, + password, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BasicBatchResponse{id=$id, createdAt=$createdAt, email=$email, lsUserId=$lsUserId, updatedAt=$updatedAt, avatarUrl=$avatarUrl, fullName=$fullName, password=$password, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/pending/OrgPendingIdentity.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/pending/OrgPendingIdentity.kt new file mode 100644 index 00000000..5674384c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/pending/OrgPendingIdentity.kt @@ -0,0 +1,830 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.members.pending + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.orgs.current.members.AccessScope +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class OrgPendingIdentity +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val email: JsonField<String>, + private val accessScope: JsonField<AccessScope>, + private val fullName: JsonField<String>, + private val orgRoleId: JsonField<String>, + private val orgRoleName: JsonField<String>, + private val organizationId: JsonField<String>, + private val password: JsonField<String>, + private val readOnly: JsonField<Boolean>, + private val roleId: JsonField<String>, + private val roleName: JsonField<String>, + private val tenantId: JsonField<String>, + private val tenantIds: JsonField<List<String>>, + private val userId: JsonField<String>, + private val workspaceIds: JsonField<List<String>>, + private val workspaceRoleId: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("email") @ExcludeMissing email: JsonField<String> = JsonMissing.of(), + @JsonProperty("access_scope") + @ExcludeMissing + accessScope: JsonField<AccessScope> = JsonMissing.of(), + @JsonProperty("full_name") @ExcludeMissing fullName: JsonField<String> = JsonMissing.of(), + @JsonProperty("org_role_id") + @ExcludeMissing + orgRoleId: JsonField<String> = JsonMissing.of(), + @JsonProperty("org_role_name") + @ExcludeMissing + orgRoleName: JsonField<String> = JsonMissing.of(), + @JsonProperty("organization_id") + @ExcludeMissing + organizationId: JsonField<String> = JsonMissing.of(), + @JsonProperty("password") @ExcludeMissing password: JsonField<String> = JsonMissing.of(), + @JsonProperty("read_only") @ExcludeMissing readOnly: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("role_id") @ExcludeMissing roleId: JsonField<String> = JsonMissing.of(), + @JsonProperty("role_name") @ExcludeMissing roleName: JsonField<String> = JsonMissing.of(), + @JsonProperty("tenant_id") @ExcludeMissing tenantId: JsonField<String> = JsonMissing.of(), + @JsonProperty("tenant_ids") + @ExcludeMissing + tenantIds: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing userId: JsonField<String> = JsonMissing.of(), + @JsonProperty("workspace_ids") + @ExcludeMissing + workspaceIds: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("workspace_role_id") + @ExcludeMissing + workspaceRoleId: JsonField<String> = JsonMissing.of(), + ) : this( + id, + createdAt, + email, + accessScope, + fullName, + orgRoleId, + orgRoleName, + organizationId, + password, + readOnly, + roleId, + roleName, + tenantId, + tenantIds, + userId, + workspaceIds, + workspaceRoleId, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun email(): String = email.getRequired("email") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun accessScope(): Optional<AccessScope> = accessScope.getOptional("access_scope") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fullName(): Optional<String> = fullName.getOptional("full_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun orgRoleId(): Optional<String> = orgRoleId.getOptional("org_role_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun orgRoleName(): Optional<String> = orgRoleName.getOptional("org_role_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun organizationId(): Optional<String> = organizationId.getOptional("organization_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun password(): Optional<String> = password.getOptional("password") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun readOnly(): Optional<Boolean> = readOnly.getOptional("read_only") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun roleId(): Optional<String> = roleId.getOptional("role_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun roleName(): Optional<String> = roleName.getOptional("role_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tenantId(): Optional<String> = tenantId.getOptional("tenant_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tenantIds(): Optional<List<String>> = tenantIds.getOptional("tenant_ids") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun userId(): Optional<String> = userId.getOptional("user_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun workspaceIds(): Optional<List<String>> = workspaceIds.getOptional("workspace_ids") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun workspaceRoleId(): Optional<String> = workspaceRoleId.getOptional("workspace_role_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField<String> = email + + /** + * Returns the raw JSON value of [accessScope]. + * + * Unlike [accessScope], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("access_scope") + @ExcludeMissing + fun _accessScope(): JsonField<AccessScope> = accessScope + + /** + * Returns the raw JSON value of [fullName]. + * + * Unlike [fullName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("full_name") @ExcludeMissing fun _fullName(): JsonField<String> = fullName + + /** + * Returns the raw JSON value of [orgRoleId]. + * + * Unlike [orgRoleId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("org_role_id") @ExcludeMissing fun _orgRoleId(): JsonField<String> = orgRoleId + + /** + * Returns the raw JSON value of [orgRoleName]. + * + * Unlike [orgRoleName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("org_role_name") + @ExcludeMissing + fun _orgRoleName(): JsonField<String> = orgRoleName + + /** + * Returns the raw JSON value of [organizationId]. + * + * Unlike [organizationId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("organization_id") + @ExcludeMissing + fun _organizationId(): JsonField<String> = organizationId + + /** + * Returns the raw JSON value of [password]. + * + * Unlike [password], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("password") @ExcludeMissing fun _password(): JsonField<String> = password + + /** + * Returns the raw JSON value of [readOnly]. + * + * Unlike [readOnly], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("read_only") @ExcludeMissing fun _readOnly(): JsonField<Boolean> = readOnly + + /** + * Returns the raw JSON value of [roleId]. + * + * Unlike [roleId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("role_id") @ExcludeMissing fun _roleId(): JsonField<String> = roleId + + /** + * Returns the raw JSON value of [roleName]. + * + * Unlike [roleName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("role_name") @ExcludeMissing fun _roleName(): JsonField<String> = roleName + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_id") @ExcludeMissing fun _tenantId(): JsonField<String> = tenantId + + /** + * Returns the raw JSON value of [tenantIds]. + * + * Unlike [tenantIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_ids") + @ExcludeMissing + fun _tenantIds(): JsonField<List<String>> = tenantIds + + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField<String> = userId + + /** + * Returns the raw JSON value of [workspaceIds]. + * + * Unlike [workspaceIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("workspace_ids") + @ExcludeMissing + fun _workspaceIds(): JsonField<List<String>> = workspaceIds + + /** + * Returns the raw JSON value of [workspaceRoleId]. + * + * Unlike [workspaceRoleId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("workspace_role_id") + @ExcludeMissing + fun _workspaceRoleId(): JsonField<String> = workspaceRoleId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [OrgPendingIdentity]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .email() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OrgPendingIdentity]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var createdAt: JsonField<OffsetDateTime>? = null + private var email: JsonField<String>? = null + private var accessScope: JsonField<AccessScope> = JsonMissing.of() + private var fullName: JsonField<String> = JsonMissing.of() + private var orgRoleId: JsonField<String> = JsonMissing.of() + private var orgRoleName: JsonField<String> = JsonMissing.of() + private var organizationId: JsonField<String> = JsonMissing.of() + private var password: JsonField<String> = JsonMissing.of() + private var readOnly: JsonField<Boolean> = JsonMissing.of() + private var roleId: JsonField<String> = JsonMissing.of() + private var roleName: JsonField<String> = JsonMissing.of() + private var tenantId: JsonField<String> = JsonMissing.of() + private var tenantIds: JsonField<MutableList<String>>? = null + private var userId: JsonField<String> = JsonMissing.of() + private var workspaceIds: JsonField<MutableList<String>>? = null + private var workspaceRoleId: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(orgPendingIdentity: OrgPendingIdentity) = apply { + id = orgPendingIdentity.id + createdAt = orgPendingIdentity.createdAt + email = orgPendingIdentity.email + accessScope = orgPendingIdentity.accessScope + fullName = orgPendingIdentity.fullName + orgRoleId = orgPendingIdentity.orgRoleId + orgRoleName = orgPendingIdentity.orgRoleName + organizationId = orgPendingIdentity.organizationId + password = orgPendingIdentity.password + readOnly = orgPendingIdentity.readOnly + roleId = orgPendingIdentity.roleId + roleName = orgPendingIdentity.roleName + tenantId = orgPendingIdentity.tenantId + tenantIds = orgPendingIdentity.tenantIds.map { it.toMutableList() } + userId = orgPendingIdentity.userId + workspaceIds = orgPendingIdentity.workspaceIds.map { it.toMutableList() } + workspaceRoleId = orgPendingIdentity.workspaceRoleId + additionalProperties = orgPendingIdentity.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun email(email: String) = email(JsonField.of(email)) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun email(email: JsonField<String>) = apply { this.email = email } + + fun accessScope(accessScope: AccessScope) = accessScope(JsonField.of(accessScope)) + + /** + * Sets [Builder.accessScope] to an arbitrary JSON value. + * + * You should usually call [Builder.accessScope] with a well-typed [AccessScope] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun accessScope(accessScope: JsonField<AccessScope>) = apply { + this.accessScope = accessScope + } + + fun fullName(fullName: String?) = fullName(JsonField.ofNullable(fullName)) + + /** Alias for calling [Builder.fullName] with `fullName.orElse(null)`. */ + fun fullName(fullName: Optional<String>) = fullName(fullName.getOrNull()) + + /** + * Sets [Builder.fullName] to an arbitrary JSON value. + * + * You should usually call [Builder.fullName] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun fullName(fullName: JsonField<String>) = apply { this.fullName = fullName } + + fun orgRoleId(orgRoleId: String?) = orgRoleId(JsonField.ofNullable(orgRoleId)) + + /** Alias for calling [Builder.orgRoleId] with `orgRoleId.orElse(null)`. */ + fun orgRoleId(orgRoleId: Optional<String>) = orgRoleId(orgRoleId.getOrNull()) + + /** + * Sets [Builder.orgRoleId] to an arbitrary JSON value. + * + * You should usually call [Builder.orgRoleId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun orgRoleId(orgRoleId: JsonField<String>) = apply { this.orgRoleId = orgRoleId } + + fun orgRoleName(orgRoleName: String?) = orgRoleName(JsonField.ofNullable(orgRoleName)) + + /** Alias for calling [Builder.orgRoleName] with `orgRoleName.orElse(null)`. */ + fun orgRoleName(orgRoleName: Optional<String>) = orgRoleName(orgRoleName.getOrNull()) + + /** + * Sets [Builder.orgRoleName] to an arbitrary JSON value. + * + * You should usually call [Builder.orgRoleName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun orgRoleName(orgRoleName: JsonField<String>) = apply { this.orgRoleName = orgRoleName } + + fun organizationId(organizationId: String?) = + organizationId(JsonField.ofNullable(organizationId)) + + /** Alias for calling [Builder.organizationId] with `organizationId.orElse(null)`. */ + fun organizationId(organizationId: Optional<String>) = + organizationId(organizationId.getOrNull()) + + /** + * Sets [Builder.organizationId] to an arbitrary JSON value. + * + * You should usually call [Builder.organizationId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun organizationId(organizationId: JsonField<String>) = apply { + this.organizationId = organizationId + } + + fun password(password: String?) = password(JsonField.ofNullable(password)) + + /** Alias for calling [Builder.password] with `password.orElse(null)`. */ + fun password(password: Optional<String>) = password(password.getOrNull()) + + /** + * Sets [Builder.password] to an arbitrary JSON value. + * + * You should usually call [Builder.password] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun password(password: JsonField<String>) = apply { this.password = password } + + fun readOnly(readOnly: Boolean) = readOnly(JsonField.of(readOnly)) + + /** + * Sets [Builder.readOnly] to an arbitrary JSON value. + * + * You should usually call [Builder.readOnly] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun readOnly(readOnly: JsonField<Boolean>) = apply { this.readOnly = readOnly } + + fun roleId(roleId: String?) = roleId(JsonField.ofNullable(roleId)) + + /** Alias for calling [Builder.roleId] with `roleId.orElse(null)`. */ + fun roleId(roleId: Optional<String>) = roleId(roleId.getOrNull()) + + /** + * Sets [Builder.roleId] to an arbitrary JSON value. + * + * You should usually call [Builder.roleId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun roleId(roleId: JsonField<String>) = apply { this.roleId = roleId } + + fun roleName(roleName: String?) = roleName(JsonField.ofNullable(roleName)) + + /** Alias for calling [Builder.roleName] with `roleName.orElse(null)`. */ + fun roleName(roleName: Optional<String>) = roleName(roleName.getOrNull()) + + /** + * Sets [Builder.roleName] to an arbitrary JSON value. + * + * You should usually call [Builder.roleName] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun roleName(roleName: JsonField<String>) = apply { this.roleName = roleName } + + fun tenantId(tenantId: String?) = tenantId(JsonField.ofNullable(tenantId)) + + /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ + fun tenantId(tenantId: Optional<String>) = tenantId(tenantId.getOrNull()) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tenantId(tenantId: JsonField<String>) = apply { this.tenantId = tenantId } + + fun tenantIds(tenantIds: List<String>) = tenantIds(JsonField.of(tenantIds)) + + /** + * Sets [Builder.tenantIds] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantIds] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tenantIds(tenantIds: JsonField<List<String>>) = apply { + this.tenantIds = tenantIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [tenantIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTenantId(tenantId: String) = apply { + tenantIds = + (tenantIds ?: JsonField.of(mutableListOf())).also { + checkKnown("tenantIds", it).add(tenantId) + } + } + + fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) + + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ + fun userId(userId: Optional<String>) = userId(userId.getOrNull()) + + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun userId(userId: JsonField<String>) = apply { this.userId = userId } + + fun workspaceIds(workspaceIds: List<String>?) = + workspaceIds(JsonField.ofNullable(workspaceIds)) + + /** Alias for calling [Builder.workspaceIds] with `workspaceIds.orElse(null)`. */ + fun workspaceIds(workspaceIds: Optional<List<String>>) = + workspaceIds(workspaceIds.getOrNull()) + + /** + * Sets [Builder.workspaceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.workspaceIds] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun workspaceIds(workspaceIds: JsonField<List<String>>) = apply { + this.workspaceIds = workspaceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [workspaceIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWorkspaceId(workspaceId: String) = apply { + workspaceIds = + (workspaceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("workspaceIds", it).add(workspaceId) + } + } + + fun workspaceRoleId(workspaceRoleId: String?) = + workspaceRoleId(JsonField.ofNullable(workspaceRoleId)) + + /** Alias for calling [Builder.workspaceRoleId] with `workspaceRoleId.orElse(null)`. */ + fun workspaceRoleId(workspaceRoleId: Optional<String>) = + workspaceRoleId(workspaceRoleId.getOrNull()) + + /** + * Sets [Builder.workspaceRoleId] to an arbitrary JSON value. + * + * You should usually call [Builder.workspaceRoleId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun workspaceRoleId(workspaceRoleId: JsonField<String>) = apply { + this.workspaceRoleId = workspaceRoleId + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OrgPendingIdentity]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .email() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): OrgPendingIdentity = + OrgPendingIdentity( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("email", email), + accessScope, + fullName, + orgRoleId, + orgRoleName, + organizationId, + password, + readOnly, + roleId, + roleName, + tenantId, + (tenantIds ?: JsonMissing.of()).map { it.toImmutable() }, + userId, + (workspaceIds ?: JsonMissing.of()).map { it.toImmutable() }, + workspaceRoleId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OrgPendingIdentity = apply { + if (validated) { + return@apply + } + + id() + createdAt() + email() + accessScope().ifPresent { it.validate() } + fullName() + orgRoleId() + orgRoleName() + organizationId() + password() + readOnly() + roleId() + roleName() + tenantId() + tenantIds() + userId() + workspaceIds() + workspaceRoleId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (email.asKnown().isPresent) 1 else 0) + + (accessScope.asKnown().getOrNull()?.validity() ?: 0) + + (if (fullName.asKnown().isPresent) 1 else 0) + + (if (orgRoleId.asKnown().isPresent) 1 else 0) + + (if (orgRoleName.asKnown().isPresent) 1 else 0) + + (if (organizationId.asKnown().isPresent) 1 else 0) + + (if (password.asKnown().isPresent) 1 else 0) + + (if (readOnly.asKnown().isPresent) 1 else 0) + + (if (roleId.asKnown().isPresent) 1 else 0) + + (if (roleName.asKnown().isPresent) 1 else 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + (tenantIds.asKnown().getOrNull()?.size ?: 0) + + (if (userId.asKnown().isPresent) 1 else 0) + + (workspaceIds.asKnown().getOrNull()?.size ?: 0) + + (if (workspaceRoleId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OrgPendingIdentity && + id == other.id && + createdAt == other.createdAt && + email == other.email && + accessScope == other.accessScope && + fullName == other.fullName && + orgRoleId == other.orgRoleId && + orgRoleName == other.orgRoleName && + organizationId == other.organizationId && + password == other.password && + readOnly == other.readOnly && + roleId == other.roleId && + roleName == other.roleName && + tenantId == other.tenantId && + tenantIds == other.tenantIds && + userId == other.userId && + workspaceIds == other.workspaceIds && + workspaceRoleId == other.workspaceRoleId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + createdAt, + email, + accessScope, + fullName, + orgRoleId, + orgRoleName, + organizationId, + password, + readOnly, + roleId, + roleName, + tenantId, + tenantIds, + userId, + workspaceIds, + workspaceRoleId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OrgPendingIdentity{id=$id, createdAt=$createdAt, email=$email, accessScope=$accessScope, fullName=$fullName, orgRoleId=$orgRoleId, orgRoleName=$orgRoleName, organizationId=$organizationId, password=$password, readOnly=$readOnly, roleId=$roleId, roleName=$roleName, tenantId=$tenantId, tenantIds=$tenantIds, userId=$userId, workspaceIds=$workspaceIds, workspaceRoleId=$workspaceRoleId, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/pending/PendingDeleteAllParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/pending/PendingDeleteAllParams.kt new file mode 100644 index 00000000..461bb75c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/pending/PendingDeleteAllParams.kt @@ -0,0 +1,230 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.members.pending + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** When an admin deletes a pending member invite. */ +class PendingDeleteAllParams +private constructor( + private val identityId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun identityId(): Optional<String> = Optional.ofNullable(identityId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): PendingDeleteAllParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [PendingDeleteAllParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PendingDeleteAllParams]. */ + class Builder internal constructor() { + + private var identityId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(pendingDeleteAllParams: PendingDeleteAllParams) = apply { + identityId = pendingDeleteAllParams.identityId + additionalHeaders = pendingDeleteAllParams.additionalHeaders.toBuilder() + additionalQueryParams = pendingDeleteAllParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + pendingDeleteAllParams.additionalBodyProperties.toMutableMap() + } + + fun identityId(identityId: String?) = apply { this.identityId = identityId } + + /** Alias for calling [Builder.identityId] with `identityId.orElse(null)`. */ + fun identityId(identityId: Optional<String>) = identityId(identityId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [PendingDeleteAllParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PendingDeleteAllParams = + PendingDeleteAllParams( + identityId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> identityId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PendingDeleteAllParams && + identityId == other.identityId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(identityId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "PendingDeleteAllParams{identityId=$identityId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/pending/PendingDeleteAllResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/pending/PendingDeleteAllResponse.kt new file mode 100644 index 00000000..2bc978c8 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/pending/PendingDeleteAllResponse.kt @@ -0,0 +1,115 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.members.pending + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class PendingDeleteAllResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [PendingDeleteAllResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PendingDeleteAllResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(pendingDeleteAllResponse: PendingDeleteAllResponse) = apply { + additionalProperties = pendingDeleteAllResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PendingDeleteAllResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PendingDeleteAllResponse = + PendingDeleteAllResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): PendingDeleteAllResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PendingDeleteAllResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "PendingDeleteAllResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/pending/PendingListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/pending/PendingListParams.kt new file mode 100644 index 00000000..9708cd9a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/pending/PendingListParams.kt @@ -0,0 +1,244 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.members.pending + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get Current Pending Org Members */ +class PendingListParams +private constructor( + private val emails: List<String>?, + private val limit: Long?, + private val offset: Long?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun emails(): Optional<List<String>> = Optional.ofNullable(emails) + + fun limit(): Optional<Long> = Optional.ofNullable(limit) + + fun offset(): Optional<Long> = Optional.ofNullable(offset) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): PendingListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [PendingListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PendingListParams]. */ + class Builder internal constructor() { + + private var emails: MutableList<String>? = null + private var limit: Long? = null + private var offset: Long? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(pendingListParams: PendingListParams) = apply { + emails = pendingListParams.emails?.toMutableList() + limit = pendingListParams.limit + offset = pendingListParams.offset + additionalHeaders = pendingListParams.additionalHeaders.toBuilder() + additionalQueryParams = pendingListParams.additionalQueryParams.toBuilder() + } + + fun emails(emails: List<String>?) = apply { this.emails = emails?.toMutableList() } + + /** Alias for calling [Builder.emails] with `emails.orElse(null)`. */ + fun emails(emails: Optional<List<String>>) = emails(emails.getOrNull()) + + /** + * Adds a single [String] to [emails]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEmail(email: String) = apply { + emails = (emails ?: mutableListOf()).apply { add(email) } + } + + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional<Long>) = limit(limit.getOrNull()) + + fun offset(offset: Long?) = apply { this.offset = offset } + + /** + * Alias for [Builder.offset]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun offset(offset: Long) = offset(offset as Long?) + + /** Alias for calling [Builder.offset] with `offset.orElse(null)`. */ + fun offset(offset: Optional<Long>) = offset(offset.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [PendingListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PendingListParams = + PendingListParams( + emails?.toImmutable(), + limit, + offset, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + emails?.let { put("emails", it.joinToString(",")) } + limit?.let { put("limit", it.toString()) } + offset?.let { put("offset", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PendingListParams && + emails == other.emails && + limit == other.limit && + offset == other.offset && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(emails, limit, offset, additionalHeaders, additionalQueryParams) + + override fun toString() = + "PendingListParams{emails=$emails, limit=$limit, offset=$offset, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/personalaccesstokens/PersonalAccessTokenDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/personalaccesstokens/PersonalAccessTokenDeleteParams.kt new file mode 100644 index 00000000..fa4d2df3 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/personalaccesstokens/PersonalAccessTokenDeleteParams.kt @@ -0,0 +1,235 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.personalaccesstokens + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete Org Personal Access Token */ +class PersonalAccessTokenDeleteParams +private constructor( + private val patId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun patId(): Optional<String> = Optional.ofNullable(patId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): PersonalAccessTokenDeleteParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [PersonalAccessTokenDeleteParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PersonalAccessTokenDeleteParams]. */ + class Builder internal constructor() { + + private var patId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(personalAccessTokenDeleteParams: PersonalAccessTokenDeleteParams) = + apply { + patId = personalAccessTokenDeleteParams.patId + additionalHeaders = personalAccessTokenDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = + personalAccessTokenDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + personalAccessTokenDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun patId(patId: String?) = apply { this.patId = patId } + + /** Alias for calling [Builder.patId] with `patId.orElse(null)`. */ + fun patId(patId: Optional<String>) = patId(patId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [PersonalAccessTokenDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PersonalAccessTokenDeleteParams = + PersonalAccessTokenDeleteParams( + patId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> patId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PersonalAccessTokenDeleteParams && + patId == other.patId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(patId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "PersonalAccessTokenDeleteParams{patId=$patId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/personalaccesstokens/PersonalAccessTokenPersonalAccessTokensParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/personalaccesstokens/PersonalAccessTokenPersonalAccessTokensParams.kt new file mode 100644 index 00000000..52afd290 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/personalaccesstokens/PersonalAccessTokenPersonalAccessTokensParams.kt @@ -0,0 +1,234 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.personalaccesstokens + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyCreateRequest +import java.util.Objects + +/** Create Org Personal Access Token */ +class PersonalAccessTokenPersonalAccessTokensParams +private constructor( + private val apiKeyCreateRequest: ApiKeyCreateRequest, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * API key POST schema. + * + * expires_at: Optional datetime when the API key will expire. workspaces: List of workspace + * UUIDs this key can access (feature-flagged). role_id: Optional UUID of the role to assign to + * API key. If not provided, uses default role based on read_only flag: + * - WORKSPACE_ADMIN if read_only is False + * - WORKSPACE_READER if read_only is True org_role_id: UUID of a org role for org-scoped keys + * If not provided, defaults to ORG_USER default_workspace_id: UUID of the default workspace + * for PATs. If not provided, uses the current logic (first available workspace). + */ + fun apiKeyCreateRequest(): ApiKeyCreateRequest = apiKeyCreateRequest + + fun _additionalBodyProperties(): Map<String, JsonValue> = + apiKeyCreateRequest._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PersonalAccessTokenPersonalAccessTokensParams]. + * + * The following fields are required: + * ```java + * .apiKeyCreateRequest() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PersonalAccessTokenPersonalAccessTokensParams]. */ + class Builder internal constructor() { + + private var apiKeyCreateRequest: ApiKeyCreateRequest? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + personalAccessTokenPersonalAccessTokensParams: + PersonalAccessTokenPersonalAccessTokensParams + ) = apply { + apiKeyCreateRequest = personalAccessTokenPersonalAccessTokensParams.apiKeyCreateRequest + additionalHeaders = + personalAccessTokenPersonalAccessTokensParams.additionalHeaders.toBuilder() + additionalQueryParams = + personalAccessTokenPersonalAccessTokensParams.additionalQueryParams.toBuilder() + } + + /** + * API key POST schema. + * + * expires_at: Optional datetime when the API key will expire. workspaces: List of workspace + * UUIDs this key can access (feature-flagged). role_id: Optional UUID of the role to assign + * to API key. If not provided, uses default role based on read_only flag: + * - WORKSPACE_ADMIN if read_only is False + * - WORKSPACE_READER if read_only is True org_role_id: UUID of a org role for org-scoped + * keys If not provided, defaults to ORG_USER default_workspace_id: UUID of the default + * workspace for PATs. If not provided, uses the current logic (first available + * workspace). + */ + fun apiKeyCreateRequest(apiKeyCreateRequest: ApiKeyCreateRequest) = apply { + this.apiKeyCreateRequest = apiKeyCreateRequest + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [PersonalAccessTokenPersonalAccessTokensParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .apiKeyCreateRequest() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PersonalAccessTokenPersonalAccessTokensParams = + PersonalAccessTokenPersonalAccessTokensParams( + checkRequired("apiKeyCreateRequest", apiKeyCreateRequest), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): ApiKeyCreateRequest = apiKeyCreateRequest + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PersonalAccessTokenPersonalAccessTokensParams && + apiKeyCreateRequest == other.apiKeyCreateRequest && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(apiKeyCreateRequest, additionalHeaders, additionalQueryParams) + + override fun toString() = + "PersonalAccessTokenPersonalAccessTokensParams{apiKeyCreateRequest=$apiKeyCreateRequest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/personalaccesstokens/PersonalAccessTokenRetrievePersonalAccessTokensParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/personalaccesstokens/PersonalAccessTokenRetrievePersonalAccessTokensParams.kt new file mode 100644 index 00000000..255a469d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/personalaccesstokens/PersonalAccessTokenRetrievePersonalAccessTokensParams.kt @@ -0,0 +1,183 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.personalaccesstokens + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** List Org Personal Access Tokens */ +class PersonalAccessTokenRetrievePersonalAccessTokensParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic + fun none(): PersonalAccessTokenRetrievePersonalAccessTokensParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [PersonalAccessTokenRetrievePersonalAccessTokensParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PersonalAccessTokenRetrievePersonalAccessTokensParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + personalAccessTokenRetrievePersonalAccessTokensParams: + PersonalAccessTokenRetrievePersonalAccessTokensParams + ) = apply { + additionalHeaders = + personalAccessTokenRetrievePersonalAccessTokensParams.additionalHeaders.toBuilder() + additionalQueryParams = + personalAccessTokenRetrievePersonalAccessTokensParams.additionalQueryParams + .toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [PersonalAccessTokenRetrievePersonalAccessTokensParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PersonalAccessTokenRetrievePersonalAccessTokensParams = + PersonalAccessTokenRetrievePersonalAccessTokensParams( + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PersonalAccessTokenRetrievePersonalAccessTokensParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "PersonalAccessTokenRetrievePersonalAccessTokensParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/Role.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/Role.kt new file mode 100644 index 00000000..a7d0f41e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/Role.kt @@ -0,0 +1,440 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.roles + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.orgs.current.members.AccessScope +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class Role +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val description: JsonField<String>, + private val displayName: JsonField<String>, + private val name: JsonField<String>, + private val permissions: JsonField<List<String>>, + private val accessScope: JsonField<AccessScope>, + private val organizationId: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField<String> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("permissions") + @ExcludeMissing + permissions: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("access_scope") + @ExcludeMissing + accessScope: JsonField<AccessScope> = JsonMissing.of(), + @JsonProperty("organization_id") + @ExcludeMissing + organizationId: JsonField<String> = JsonMissing.of(), + ) : this( + id, + description, + displayName, + name, + permissions, + accessScope, + organizationId, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun description(): String = description.getRequired("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun displayName(): String = displayName.getRequired("display_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun permissions(): List<String> = permissions.getRequired("permissions") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun accessScope(): Optional<AccessScope> = accessScope.getOptional("access_scope") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun organizationId(): Optional<String> = organizationId.getOptional("organization_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField<String> = displayName + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [permissions]. + * + * Unlike [permissions], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("permissions") + @ExcludeMissing + fun _permissions(): JsonField<List<String>> = permissions + + /** + * Returns the raw JSON value of [accessScope]. + * + * Unlike [accessScope], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("access_scope") + @ExcludeMissing + fun _accessScope(): JsonField<AccessScope> = accessScope + + /** + * Returns the raw JSON value of [organizationId]. + * + * Unlike [organizationId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("organization_id") + @ExcludeMissing + fun _organizationId(): JsonField<String> = organizationId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Role]. + * + * The following fields are required: + * ```java + * .id() + * .description() + * .displayName() + * .name() + * .permissions() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Role]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var description: JsonField<String>? = null + private var displayName: JsonField<String>? = null + private var name: JsonField<String>? = null + private var permissions: JsonField<MutableList<String>>? = null + private var accessScope: JsonField<AccessScope> = JsonMissing.of() + private var organizationId: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(role: Role) = apply { + id = role.id + description = role.description + displayName = role.displayName + name = role.name + permissions = role.permissions.map { it.toMutableList() } + accessScope = role.accessScope + organizationId = role.organizationId + additionalProperties = role.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { this.description = description } + + fun displayName(displayName: String) = displayName(JsonField.of(displayName)) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun displayName(displayName: JsonField<String>) = apply { this.displayName = displayName } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun permissions(permissions: List<String>) = permissions(JsonField.of(permissions)) + + /** + * Sets [Builder.permissions] to an arbitrary JSON value. + * + * You should usually call [Builder.permissions] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun permissions(permissions: JsonField<List<String>>) = apply { + this.permissions = permissions.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [permissions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPermission(permission: String) = apply { + permissions = + (permissions ?: JsonField.of(mutableListOf())).also { + checkKnown("permissions", it).add(permission) + } + } + + fun accessScope(accessScope: AccessScope?) = accessScope(JsonField.ofNullable(accessScope)) + + /** Alias for calling [Builder.accessScope] with `accessScope.orElse(null)`. */ + fun accessScope(accessScope: Optional<AccessScope>) = accessScope(accessScope.getOrNull()) + + /** + * Sets [Builder.accessScope] to an arbitrary JSON value. + * + * You should usually call [Builder.accessScope] with a well-typed [AccessScope] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun accessScope(accessScope: JsonField<AccessScope>) = apply { + this.accessScope = accessScope + } + + fun organizationId(organizationId: String?) = + organizationId(JsonField.ofNullable(organizationId)) + + /** Alias for calling [Builder.organizationId] with `organizationId.orElse(null)`. */ + fun organizationId(organizationId: Optional<String>) = + organizationId(organizationId.getOrNull()) + + /** + * Sets [Builder.organizationId] to an arbitrary JSON value. + * + * You should usually call [Builder.organizationId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun organizationId(organizationId: JsonField<String>) = apply { + this.organizationId = organizationId + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Role]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .description() + * .displayName() + * .name() + * .permissions() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Role = + Role( + checkRequired("id", id), + checkRequired("description", description), + checkRequired("displayName", displayName), + checkRequired("name", name), + checkRequired("permissions", permissions).map { it.toImmutable() }, + accessScope, + organizationId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Role = apply { + if (validated) { + return@apply + } + + id() + description() + displayName() + name() + permissions() + accessScope().ifPresent { it.validate() } + organizationId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (displayName.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (permissions.asKnown().getOrNull()?.size ?: 0) + + (accessScope.asKnown().getOrNull()?.validity() ?: 0) + + (if (organizationId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Role && + id == other.id && + description == other.description && + displayName == other.displayName && + name == other.name && + permissions == other.permissions && + accessScope == other.accessScope && + organizationId == other.organizationId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + description, + displayName, + name, + permissions, + accessScope, + organizationId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Role{id=$id, description=$description, displayName=$displayName, name=$name, permissions=$permissions, accessScope=$accessScope, organizationId=$organizationId, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/RoleCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/RoleCreateParams.kt new file mode 100644 index 00000000..5ab63694 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/RoleCreateParams.kt @@ -0,0 +1,577 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.roles + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** Create Organization Roles */ +class RoleCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun description(): String = body.description() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun displayName(): String = body.displayName() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun permissions(): List<String> = body.permissions() + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _description(): JsonField<String> = body._description() + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _displayName(): JsonField<String> = body._displayName() + + /** + * Returns the raw JSON value of [permissions]. + * + * Unlike [permissions], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _permissions(): JsonField<List<String>> = body._permissions() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RoleCreateParams]. + * + * The following fields are required: + * ```java + * .description() + * .displayName() + * .permissions() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RoleCreateParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(roleCreateParams: RoleCreateParams) = apply { + body = roleCreateParams.body.toBuilder() + additionalHeaders = roleCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = roleCreateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [description] + * - [displayName] + * - [permissions] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun description(description: String) = apply { body.description(description) } + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { body.description(description) } + + fun displayName(displayName: String) = apply { body.displayName(displayName) } + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun displayName(displayName: JsonField<String>) = apply { body.displayName(displayName) } + + fun permissions(permissions: List<String>) = apply { body.permissions(permissions) } + + /** + * Sets [Builder.permissions] to an arbitrary JSON value. + * + * You should usually call [Builder.permissions] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun permissions(permissions: JsonField<List<String>>) = apply { + body.permissions(permissions) + } + + /** + * Adds a single [String] to [permissions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPermission(permission: String) = apply { body.addPermission(permission) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RoleCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .description() + * .displayName() + * .permissions() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RoleCreateParams = + RoleCreateParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val description: JsonField<String>, + private val displayName: JsonField<String>, + private val permissions: JsonField<List<String>>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField<String> = JsonMissing.of(), + @JsonProperty("permissions") + @ExcludeMissing + permissions: JsonField<List<String>> = JsonMissing.of(), + ) : this(description, displayName, permissions, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun description(): String = description.getRequired("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun displayName(): String = displayName.getRequired("display_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun permissions(): List<String> = permissions.getRequired("permissions") + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField<String> = displayName + + /** + * Returns the raw JSON value of [permissions]. + * + * Unlike [permissions], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("permissions") + @ExcludeMissing + fun _permissions(): JsonField<List<String>> = permissions + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .description() + * .displayName() + * .permissions() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var description: JsonField<String>? = null + private var displayName: JsonField<String>? = null + private var permissions: JsonField<MutableList<String>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + description = body.description + displayName = body.displayName + permissions = body.permissions.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField<String>) = apply { + this.description = description + } + + fun displayName(displayName: String) = displayName(JsonField.of(displayName)) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun displayName(displayName: JsonField<String>) = apply { + this.displayName = displayName + } + + fun permissions(permissions: List<String>) = permissions(JsonField.of(permissions)) + + /** + * Sets [Builder.permissions] to an arbitrary JSON value. + * + * You should usually call [Builder.permissions] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun permissions(permissions: JsonField<List<String>>) = apply { + this.permissions = permissions.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [permissions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPermission(permission: String) = apply { + permissions = + (permissions ?: JsonField.of(mutableListOf())).also { + checkKnown("permissions", it).add(permission) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .description() + * .displayName() + * .permissions() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("description", description), + checkRequired("displayName", displayName), + checkRequired("permissions", permissions).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + description() + displayName() + permissions() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (description.asKnown().isPresent) 1 else 0) + + (if (displayName.asKnown().isPresent) 1 else 0) + + (permissions.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + description == other.description && + displayName == other.displayName && + permissions == other.permissions && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(description, displayName, permissions, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{description=$description, displayName=$displayName, permissions=$permissions, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoleCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "RoleCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/RoleDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/RoleDeleteParams.kt new file mode 100644 index 00000000..57321ed9 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/RoleDeleteParams.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.roles + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete Organization Roles */ +class RoleDeleteParams +private constructor( + private val roleId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun roleId(): Optional<String> = Optional.ofNullable(roleId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): RoleDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [RoleDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RoleDeleteParams]. */ + class Builder internal constructor() { + + private var roleId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(roleDeleteParams: RoleDeleteParams) = apply { + roleId = roleDeleteParams.roleId + additionalHeaders = roleDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = roleDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = roleDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun roleId(roleId: String?) = apply { this.roleId = roleId } + + /** Alias for calling [Builder.roleId] with `roleId.orElse(null)`. */ + fun roleId(roleId: Optional<String>) = roleId(roleId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [RoleDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RoleDeleteParams = + RoleDeleteParams( + roleId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> roleId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoleDeleteParams && + roleId == other.roleId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(roleId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "RoleDeleteParams{roleId=$roleId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/RoleListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/RoleListParams.kt new file mode 100644 index 00000000..e9ec3fc2 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/RoleListParams.kt @@ -0,0 +1,170 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.roles + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** List Organization Roles */ +class RoleListParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): RoleListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [RoleListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RoleListParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(roleListParams: RoleListParams) = apply { + additionalHeaders = roleListParams.additionalHeaders.toBuilder() + additionalQueryParams = roleListParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RoleListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RoleListParams = + RoleListParams(additionalHeaders.build(), additionalQueryParams.build()) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoleListParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "RoleListParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/RoleUpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/RoleUpdateParams.kt new file mode 100644 index 00000000..6de938df --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/RoleUpdateParams.kt @@ -0,0 +1,601 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.roles + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Update Organization Roles */ +class RoleUpdateParams +private constructor( + private val roleId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun roleId(): Optional<String> = Optional.ofNullable(roleId) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun description(): String = body.description() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun displayName(): String = body.displayName() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun permissions(): List<String> = body.permissions() + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _description(): JsonField<String> = body._description() + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _displayName(): JsonField<String> = body._displayName() + + /** + * Returns the raw JSON value of [permissions]. + * + * Unlike [permissions], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _permissions(): JsonField<List<String>> = body._permissions() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RoleUpdateParams]. + * + * The following fields are required: + * ```java + * .description() + * .displayName() + * .permissions() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RoleUpdateParams]. */ + class Builder internal constructor() { + + private var roleId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(roleUpdateParams: RoleUpdateParams) = apply { + roleId = roleUpdateParams.roleId + body = roleUpdateParams.body.toBuilder() + additionalHeaders = roleUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = roleUpdateParams.additionalQueryParams.toBuilder() + } + + fun roleId(roleId: String?) = apply { this.roleId = roleId } + + /** Alias for calling [Builder.roleId] with `roleId.orElse(null)`. */ + fun roleId(roleId: Optional<String>) = roleId(roleId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [description] + * - [displayName] + * - [permissions] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun description(description: String) = apply { body.description(description) } + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { body.description(description) } + + fun displayName(displayName: String) = apply { body.displayName(displayName) } + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun displayName(displayName: JsonField<String>) = apply { body.displayName(displayName) } + + fun permissions(permissions: List<String>) = apply { body.permissions(permissions) } + + /** + * Sets [Builder.permissions] to an arbitrary JSON value. + * + * You should usually call [Builder.permissions] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun permissions(permissions: JsonField<List<String>>) = apply { + body.permissions(permissions) + } + + /** + * Adds a single [String] to [permissions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPermission(permission: String) = apply { body.addPermission(permission) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RoleUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .description() + * .displayName() + * .permissions() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RoleUpdateParams = + RoleUpdateParams( + roleId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> roleId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val description: JsonField<String>, + private val displayName: JsonField<String>, + private val permissions: JsonField<List<String>>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField<String> = JsonMissing.of(), + @JsonProperty("permissions") + @ExcludeMissing + permissions: JsonField<List<String>> = JsonMissing.of(), + ) : this(description, displayName, permissions, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun description(): String = description.getRequired("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun displayName(): String = displayName.getRequired("display_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun permissions(): List<String> = permissions.getRequired("permissions") + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField<String> = displayName + + /** + * Returns the raw JSON value of [permissions]. + * + * Unlike [permissions], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("permissions") + @ExcludeMissing + fun _permissions(): JsonField<List<String>> = permissions + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .description() + * .displayName() + * .permissions() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var description: JsonField<String>? = null + private var displayName: JsonField<String>? = null + private var permissions: JsonField<MutableList<String>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + description = body.description + displayName = body.displayName + permissions = body.permissions.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField<String>) = apply { + this.description = description + } + + fun displayName(displayName: String) = displayName(JsonField.of(displayName)) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun displayName(displayName: JsonField<String>) = apply { + this.displayName = displayName + } + + fun permissions(permissions: List<String>) = permissions(JsonField.of(permissions)) + + /** + * Sets [Builder.permissions] to an arbitrary JSON value. + * + * You should usually call [Builder.permissions] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun permissions(permissions: JsonField<List<String>>) = apply { + this.permissions = permissions.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [permissions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPermission(permission: String) = apply { + permissions = + (permissions ?: JsonField.of(mutableListOf())).also { + checkKnown("permissions", it).add(permission) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .description() + * .displayName() + * .permissions() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("description", description), + checkRequired("displayName", displayName), + checkRequired("permissions", permissions).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + description() + displayName() + permissions() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (description.asKnown().isPresent) 1 else 0) + + (if (displayName.asKnown().isPresent) 1 else 0) + + (permissions.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + description == other.description && + displayName == other.displayName && + permissions == other.permissions && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(description, displayName, permissions, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{description=$description, displayName=$displayName, permissions=$permissions, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoleUpdateParams && + roleId == other.roleId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(roleId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "RoleUpdateParams{roleId=$roleId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ApiKeyCreateRequest.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ApiKeyCreateRequest.kt new file mode 100644 index 00000000..339d65dd --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ApiKeyCreateRequest.kt @@ -0,0 +1,438 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.servicekeys + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * API key POST schema. + * + * expires_at: Optional datetime when the API key will expire. workspaces: List of workspace UUIDs + * this key can access (feature-flagged). role_id: Optional UUID of the role to assign to API key. + * If not provided, uses default role based on read_only flag: + * - WORKSPACE_ADMIN if read_only is False + * - WORKSPACE_READER if read_only is True org_role_id: UUID of a org role for org-scoped keys If + * not provided, defaults to ORG_USER default_workspace_id: UUID of the default workspace for + * PATs. If not provided, uses the current logic (first available workspace). + */ +class ApiKeyCreateRequest +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val defaultWorkspaceId: JsonField<String>, + private val description: JsonField<String>, + private val expiresAt: JsonField<OffsetDateTime>, + private val orgRoleId: JsonField<String>, + private val readOnly: JsonField<Boolean>, + private val roleId: JsonField<String>, + private val workspaces: JsonField<List<String>>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("default_workspace_id") + @ExcludeMissing + defaultWorkspaceId: JsonField<String> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("expires_at") + @ExcludeMissing + expiresAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("org_role_id") + @ExcludeMissing + orgRoleId: JsonField<String> = JsonMissing.of(), + @JsonProperty("read_only") @ExcludeMissing readOnly: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("role_id") @ExcludeMissing roleId: JsonField<String> = JsonMissing.of(), + @JsonProperty("workspaces") + @ExcludeMissing + workspaces: JsonField<List<String>> = JsonMissing.of(), + ) : this( + defaultWorkspaceId, + description, + expiresAt, + orgRoleId, + readOnly, + roleId, + workspaces, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun defaultWorkspaceId(): Optional<String> = + defaultWorkspaceId.getOptional("default_workspace_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun expiresAt(): Optional<OffsetDateTime> = expiresAt.getOptional("expires_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun orgRoleId(): Optional<String> = orgRoleId.getOptional("org_role_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun readOnly(): Optional<Boolean> = readOnly.getOptional("read_only") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun roleId(): Optional<String> = roleId.getOptional("role_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun workspaces(): Optional<List<String>> = workspaces.getOptional("workspaces") + + /** + * Returns the raw JSON value of [defaultWorkspaceId]. + * + * Unlike [defaultWorkspaceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("default_workspace_id") + @ExcludeMissing + fun _defaultWorkspaceId(): JsonField<String> = defaultWorkspaceId + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [expiresAt]. + * + * Unlike [expiresAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expires_at") + @ExcludeMissing + fun _expiresAt(): JsonField<OffsetDateTime> = expiresAt + + /** + * Returns the raw JSON value of [orgRoleId]. + * + * Unlike [orgRoleId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("org_role_id") @ExcludeMissing fun _orgRoleId(): JsonField<String> = orgRoleId + + /** + * Returns the raw JSON value of [readOnly]. + * + * Unlike [readOnly], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("read_only") @ExcludeMissing fun _readOnly(): JsonField<Boolean> = readOnly + + /** + * Returns the raw JSON value of [roleId]. + * + * Unlike [roleId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("role_id") @ExcludeMissing fun _roleId(): JsonField<String> = roleId + + /** + * Returns the raw JSON value of [workspaces]. + * + * Unlike [workspaces], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("workspaces") + @ExcludeMissing + fun _workspaces(): JsonField<List<String>> = workspaces + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ApiKeyCreateRequest]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ApiKeyCreateRequest]. */ + class Builder internal constructor() { + + private var defaultWorkspaceId: JsonField<String> = JsonMissing.of() + private var description: JsonField<String> = JsonMissing.of() + private var expiresAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var orgRoleId: JsonField<String> = JsonMissing.of() + private var readOnly: JsonField<Boolean> = JsonMissing.of() + private var roleId: JsonField<String> = JsonMissing.of() + private var workspaces: JsonField<MutableList<String>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(apiKeyCreateRequest: ApiKeyCreateRequest) = apply { + defaultWorkspaceId = apiKeyCreateRequest.defaultWorkspaceId + description = apiKeyCreateRequest.description + expiresAt = apiKeyCreateRequest.expiresAt + orgRoleId = apiKeyCreateRequest.orgRoleId + readOnly = apiKeyCreateRequest.readOnly + roleId = apiKeyCreateRequest.roleId + workspaces = apiKeyCreateRequest.workspaces.map { it.toMutableList() } + additionalProperties = apiKeyCreateRequest.additionalProperties.toMutableMap() + } + + fun defaultWorkspaceId(defaultWorkspaceId: String?) = + defaultWorkspaceId(JsonField.ofNullable(defaultWorkspaceId)) + + /** + * Alias for calling [Builder.defaultWorkspaceId] with `defaultWorkspaceId.orElse(null)`. + */ + fun defaultWorkspaceId(defaultWorkspaceId: Optional<String>) = + defaultWorkspaceId(defaultWorkspaceId.getOrNull()) + + /** + * Sets [Builder.defaultWorkspaceId] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultWorkspaceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun defaultWorkspaceId(defaultWorkspaceId: JsonField<String>) = apply { + this.defaultWorkspaceId = defaultWorkspaceId + } + + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { this.description = description } + + fun expiresAt(expiresAt: OffsetDateTime?) = expiresAt(JsonField.ofNullable(expiresAt)) + + /** Alias for calling [Builder.expiresAt] with `expiresAt.orElse(null)`. */ + fun expiresAt(expiresAt: Optional<OffsetDateTime>) = expiresAt(expiresAt.getOrNull()) + + /** + * Sets [Builder.expiresAt] to an arbitrary JSON value. + * + * You should usually call [Builder.expiresAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun expiresAt(expiresAt: JsonField<OffsetDateTime>) = apply { this.expiresAt = expiresAt } + + fun orgRoleId(orgRoleId: String?) = orgRoleId(JsonField.ofNullable(orgRoleId)) + + /** Alias for calling [Builder.orgRoleId] with `orgRoleId.orElse(null)`. */ + fun orgRoleId(orgRoleId: Optional<String>) = orgRoleId(orgRoleId.getOrNull()) + + /** + * Sets [Builder.orgRoleId] to an arbitrary JSON value. + * + * You should usually call [Builder.orgRoleId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun orgRoleId(orgRoleId: JsonField<String>) = apply { this.orgRoleId = orgRoleId } + + fun readOnly(readOnly: Boolean) = readOnly(JsonField.of(readOnly)) + + /** + * Sets [Builder.readOnly] to an arbitrary JSON value. + * + * You should usually call [Builder.readOnly] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun readOnly(readOnly: JsonField<Boolean>) = apply { this.readOnly = readOnly } + + fun roleId(roleId: String?) = roleId(JsonField.ofNullable(roleId)) + + /** Alias for calling [Builder.roleId] with `roleId.orElse(null)`. */ + fun roleId(roleId: Optional<String>) = roleId(roleId.getOrNull()) + + /** + * Sets [Builder.roleId] to an arbitrary JSON value. + * + * You should usually call [Builder.roleId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun roleId(roleId: JsonField<String>) = apply { this.roleId = roleId } + + fun workspaces(workspaces: List<String>?) = workspaces(JsonField.ofNullable(workspaces)) + + /** Alias for calling [Builder.workspaces] with `workspaces.orElse(null)`. */ + fun workspaces(workspaces: Optional<List<String>>) = workspaces(workspaces.getOrNull()) + + /** + * Sets [Builder.workspaces] to an arbitrary JSON value. + * + * You should usually call [Builder.workspaces] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun workspaces(workspaces: JsonField<List<String>>) = apply { + this.workspaces = workspaces.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [workspaces]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWorkspace(workspace: String) = apply { + workspaces = + (workspaces ?: JsonField.of(mutableListOf())).also { + checkKnown("workspaces", it).add(workspace) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ApiKeyCreateRequest]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ApiKeyCreateRequest = + ApiKeyCreateRequest( + defaultWorkspaceId, + description, + expiresAt, + orgRoleId, + readOnly, + roleId, + (workspaces ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ApiKeyCreateRequest = apply { + if (validated) { + return@apply + } + + defaultWorkspaceId() + description() + expiresAt() + orgRoleId() + readOnly() + roleId() + workspaces() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (defaultWorkspaceId.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (expiresAt.asKnown().isPresent) 1 else 0) + + (if (orgRoleId.asKnown().isPresent) 1 else 0) + + (if (readOnly.asKnown().isPresent) 1 else 0) + + (if (roleId.asKnown().isPresent) 1 else 0) + + (workspaces.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ApiKeyCreateRequest && + defaultWorkspaceId == other.defaultWorkspaceId && + description == other.description && + expiresAt == other.expiresAt && + orgRoleId == other.orgRoleId && + readOnly == other.readOnly && + roleId == other.roleId && + workspaces == other.workspaces && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + defaultWorkspaceId, + description, + expiresAt, + orgRoleId, + readOnly, + roleId, + workspaces, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ApiKeyCreateRequest{defaultWorkspaceId=$defaultWorkspaceId, description=$description, expiresAt=$expiresAt, orgRoleId=$orgRoleId, readOnly=$readOnly, roleId=$roleId, workspaces=$workspaces, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ApiKeyCreateResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ApiKeyCreateResponse.kt new file mode 100644 index 00000000..0496e56e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ApiKeyCreateResponse.kt @@ -0,0 +1,510 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.servicekeys + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** API key POST schema. */ +class ApiKeyCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val description: JsonField<String>, + private val key: JsonField<String>, + private val shortKey: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val expiresAt: JsonField<OffsetDateTime>, + private val lastUsedAt: JsonField<OffsetDateTime>, + private val readOnly: JsonField<Boolean>, + private val workspaceNames: JsonField<List<String>>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("key") @ExcludeMissing key: JsonField<String> = JsonMissing.of(), + @JsonProperty("short_key") @ExcludeMissing shortKey: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("expires_at") + @ExcludeMissing + expiresAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("last_used_at") + @ExcludeMissing + lastUsedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("read_only") @ExcludeMissing readOnly: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("workspace_names") + @ExcludeMissing + workspaceNames: JsonField<List<String>> = JsonMissing.of(), + ) : this( + id, + description, + key, + shortKey, + createdAt, + expiresAt, + lastUsedAt, + readOnly, + workspaceNames, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun description(): String = description.getRequired("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun key(): String = key.getRequired("key") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun shortKey(): String = shortKey.getRequired("short_key") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun createdAt(): Optional<OffsetDateTime> = createdAt.getOptional("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun expiresAt(): Optional<OffsetDateTime> = expiresAt.getOptional("expires_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun lastUsedAt(): Optional<OffsetDateTime> = lastUsedAt.getOptional("last_used_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun readOnly(): Optional<Boolean> = readOnly.getOptional("read_only") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun workspaceNames(): Optional<List<String>> = workspaceNames.getOptional("workspace_names") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [key]. + * + * Unlike [key], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("key") @ExcludeMissing fun _key(): JsonField<String> = key + + /** + * Returns the raw JSON value of [shortKey]. + * + * Unlike [shortKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("short_key") @ExcludeMissing fun _shortKey(): JsonField<String> = shortKey + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [expiresAt]. + * + * Unlike [expiresAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expires_at") + @ExcludeMissing + fun _expiresAt(): JsonField<OffsetDateTime> = expiresAt + + /** + * Returns the raw JSON value of [lastUsedAt]. + * + * Unlike [lastUsedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("last_used_at") + @ExcludeMissing + fun _lastUsedAt(): JsonField<OffsetDateTime> = lastUsedAt + + /** + * Returns the raw JSON value of [readOnly]. + * + * Unlike [readOnly], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("read_only") @ExcludeMissing fun _readOnly(): JsonField<Boolean> = readOnly + + /** + * Returns the raw JSON value of [workspaceNames]. + * + * Unlike [workspaceNames], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("workspace_names") + @ExcludeMissing + fun _workspaceNames(): JsonField<List<String>> = workspaceNames + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ApiKeyCreateResponse]. + * + * The following fields are required: + * ```java + * .id() + * .description() + * .key() + * .shortKey() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ApiKeyCreateResponse]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var description: JsonField<String>? = null + private var key: JsonField<String>? = null + private var shortKey: JsonField<String>? = null + private var createdAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var expiresAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var lastUsedAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var readOnly: JsonField<Boolean> = JsonMissing.of() + private var workspaceNames: JsonField<MutableList<String>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(apiKeyCreateResponse: ApiKeyCreateResponse) = apply { + id = apiKeyCreateResponse.id + description = apiKeyCreateResponse.description + key = apiKeyCreateResponse.key + shortKey = apiKeyCreateResponse.shortKey + createdAt = apiKeyCreateResponse.createdAt + expiresAt = apiKeyCreateResponse.expiresAt + lastUsedAt = apiKeyCreateResponse.lastUsedAt + readOnly = apiKeyCreateResponse.readOnly + workspaceNames = apiKeyCreateResponse.workspaceNames.map { it.toMutableList() } + additionalProperties = apiKeyCreateResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { this.description = description } + + fun key(key: String) = key(JsonField.of(key)) + + /** + * Sets [Builder.key] to an arbitrary JSON value. + * + * You should usually call [Builder.key] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun key(key: JsonField<String>) = apply { this.key = key } + + fun shortKey(shortKey: String) = shortKey(JsonField.of(shortKey)) + + /** + * Sets [Builder.shortKey] to an arbitrary JSON value. + * + * You should usually call [Builder.shortKey] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun shortKey(shortKey: JsonField<String>) = apply { this.shortKey = shortKey } + + fun createdAt(createdAt: OffsetDateTime?) = createdAt(JsonField.ofNullable(createdAt)) + + /** Alias for calling [Builder.createdAt] with `createdAt.orElse(null)`. */ + fun createdAt(createdAt: Optional<OffsetDateTime>) = createdAt(createdAt.getOrNull()) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun expiresAt(expiresAt: OffsetDateTime?) = expiresAt(JsonField.ofNullable(expiresAt)) + + /** Alias for calling [Builder.expiresAt] with `expiresAt.orElse(null)`. */ + fun expiresAt(expiresAt: Optional<OffsetDateTime>) = expiresAt(expiresAt.getOrNull()) + + /** + * Sets [Builder.expiresAt] to an arbitrary JSON value. + * + * You should usually call [Builder.expiresAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun expiresAt(expiresAt: JsonField<OffsetDateTime>) = apply { this.expiresAt = expiresAt } + + fun lastUsedAt(lastUsedAt: OffsetDateTime?) = lastUsedAt(JsonField.ofNullable(lastUsedAt)) + + /** Alias for calling [Builder.lastUsedAt] with `lastUsedAt.orElse(null)`. */ + fun lastUsedAt(lastUsedAt: Optional<OffsetDateTime>) = lastUsedAt(lastUsedAt.getOrNull()) + + /** + * Sets [Builder.lastUsedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.lastUsedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lastUsedAt(lastUsedAt: JsonField<OffsetDateTime>) = apply { + this.lastUsedAt = lastUsedAt + } + + fun readOnly(readOnly: Boolean) = readOnly(JsonField.of(readOnly)) + + /** + * Sets [Builder.readOnly] to an arbitrary JSON value. + * + * You should usually call [Builder.readOnly] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun readOnly(readOnly: JsonField<Boolean>) = apply { this.readOnly = readOnly } + + fun workspaceNames(workspaceNames: List<String>?) = + workspaceNames(JsonField.ofNullable(workspaceNames)) + + /** Alias for calling [Builder.workspaceNames] with `workspaceNames.orElse(null)`. */ + fun workspaceNames(workspaceNames: Optional<List<String>>) = + workspaceNames(workspaceNames.getOrNull()) + + /** + * Sets [Builder.workspaceNames] to an arbitrary JSON value. + * + * You should usually call [Builder.workspaceNames] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun workspaceNames(workspaceNames: JsonField<List<String>>) = apply { + this.workspaceNames = workspaceNames.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [workspaceNames]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWorkspaceName(workspaceName: String) = apply { + workspaceNames = + (workspaceNames ?: JsonField.of(mutableListOf())).also { + checkKnown("workspaceNames", it).add(workspaceName) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ApiKeyCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .description() + * .key() + * .shortKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ApiKeyCreateResponse = + ApiKeyCreateResponse( + checkRequired("id", id), + checkRequired("description", description), + checkRequired("key", key), + checkRequired("shortKey", shortKey), + createdAt, + expiresAt, + lastUsedAt, + readOnly, + (workspaceNames ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ApiKeyCreateResponse = apply { + if (validated) { + return@apply + } + + id() + description() + key() + shortKey() + createdAt() + expiresAt() + lastUsedAt() + readOnly() + workspaceNames() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (key.asKnown().isPresent) 1 else 0) + + (if (shortKey.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (expiresAt.asKnown().isPresent) 1 else 0) + + (if (lastUsedAt.asKnown().isPresent) 1 else 0) + + (if (readOnly.asKnown().isPresent) 1 else 0) + + (workspaceNames.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ApiKeyCreateResponse && + id == other.id && + description == other.description && + key == other.key && + shortKey == other.shortKey && + createdAt == other.createdAt && + expiresAt == other.expiresAt && + lastUsedAt == other.lastUsedAt && + readOnly == other.readOnly && + workspaceNames == other.workspaceNames && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + description, + key, + shortKey, + createdAt, + expiresAt, + lastUsedAt, + readOnly, + workspaceNames, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ApiKeyCreateResponse{id=$id, description=$description, key=$key, shortKey=$shortKey, createdAt=$createdAt, expiresAt=$expiresAt, lastUsedAt=$lastUsedAt, readOnly=$readOnly, workspaceNames=$workspaceNames, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ApiKeyGetResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ApiKeyGetResponse.kt new file mode 100644 index 00000000..4b07f4a4 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ApiKeyGetResponse.kt @@ -0,0 +1,475 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.servicekeys + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** API key GET schema. */ +class ApiKeyGetResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val description: JsonField<String>, + private val shortKey: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val expiresAt: JsonField<OffsetDateTime>, + private val lastUsedAt: JsonField<OffsetDateTime>, + private val readOnly: JsonField<Boolean>, + private val workspaceNames: JsonField<List<String>>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("short_key") @ExcludeMissing shortKey: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("expires_at") + @ExcludeMissing + expiresAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("last_used_at") + @ExcludeMissing + lastUsedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("read_only") @ExcludeMissing readOnly: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("workspace_names") + @ExcludeMissing + workspaceNames: JsonField<List<String>> = JsonMissing.of(), + ) : this( + id, + description, + shortKey, + createdAt, + expiresAt, + lastUsedAt, + readOnly, + workspaceNames, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun description(): String = description.getRequired("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun shortKey(): String = shortKey.getRequired("short_key") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun createdAt(): Optional<OffsetDateTime> = createdAt.getOptional("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun expiresAt(): Optional<OffsetDateTime> = expiresAt.getOptional("expires_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun lastUsedAt(): Optional<OffsetDateTime> = lastUsedAt.getOptional("last_used_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun readOnly(): Optional<Boolean> = readOnly.getOptional("read_only") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun workspaceNames(): Optional<List<String>> = workspaceNames.getOptional("workspace_names") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [shortKey]. + * + * Unlike [shortKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("short_key") @ExcludeMissing fun _shortKey(): JsonField<String> = shortKey + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [expiresAt]. + * + * Unlike [expiresAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expires_at") + @ExcludeMissing + fun _expiresAt(): JsonField<OffsetDateTime> = expiresAt + + /** + * Returns the raw JSON value of [lastUsedAt]. + * + * Unlike [lastUsedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("last_used_at") + @ExcludeMissing + fun _lastUsedAt(): JsonField<OffsetDateTime> = lastUsedAt + + /** + * Returns the raw JSON value of [readOnly]. + * + * Unlike [readOnly], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("read_only") @ExcludeMissing fun _readOnly(): JsonField<Boolean> = readOnly + + /** + * Returns the raw JSON value of [workspaceNames]. + * + * Unlike [workspaceNames], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("workspace_names") + @ExcludeMissing + fun _workspaceNames(): JsonField<List<String>> = workspaceNames + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ApiKeyGetResponse]. + * + * The following fields are required: + * ```java + * .id() + * .description() + * .shortKey() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ApiKeyGetResponse]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var description: JsonField<String>? = null + private var shortKey: JsonField<String>? = null + private var createdAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var expiresAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var lastUsedAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var readOnly: JsonField<Boolean> = JsonMissing.of() + private var workspaceNames: JsonField<MutableList<String>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(apiKeyGetResponse: ApiKeyGetResponse) = apply { + id = apiKeyGetResponse.id + description = apiKeyGetResponse.description + shortKey = apiKeyGetResponse.shortKey + createdAt = apiKeyGetResponse.createdAt + expiresAt = apiKeyGetResponse.expiresAt + lastUsedAt = apiKeyGetResponse.lastUsedAt + readOnly = apiKeyGetResponse.readOnly + workspaceNames = apiKeyGetResponse.workspaceNames.map { it.toMutableList() } + additionalProperties = apiKeyGetResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { this.description = description } + + fun shortKey(shortKey: String) = shortKey(JsonField.of(shortKey)) + + /** + * Sets [Builder.shortKey] to an arbitrary JSON value. + * + * You should usually call [Builder.shortKey] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun shortKey(shortKey: JsonField<String>) = apply { this.shortKey = shortKey } + + fun createdAt(createdAt: OffsetDateTime?) = createdAt(JsonField.ofNullable(createdAt)) + + /** Alias for calling [Builder.createdAt] with `createdAt.orElse(null)`. */ + fun createdAt(createdAt: Optional<OffsetDateTime>) = createdAt(createdAt.getOrNull()) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun expiresAt(expiresAt: OffsetDateTime?) = expiresAt(JsonField.ofNullable(expiresAt)) + + /** Alias for calling [Builder.expiresAt] with `expiresAt.orElse(null)`. */ + fun expiresAt(expiresAt: Optional<OffsetDateTime>) = expiresAt(expiresAt.getOrNull()) + + /** + * Sets [Builder.expiresAt] to an arbitrary JSON value. + * + * You should usually call [Builder.expiresAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun expiresAt(expiresAt: JsonField<OffsetDateTime>) = apply { this.expiresAt = expiresAt } + + fun lastUsedAt(lastUsedAt: OffsetDateTime?) = lastUsedAt(JsonField.ofNullable(lastUsedAt)) + + /** Alias for calling [Builder.lastUsedAt] with `lastUsedAt.orElse(null)`. */ + fun lastUsedAt(lastUsedAt: Optional<OffsetDateTime>) = lastUsedAt(lastUsedAt.getOrNull()) + + /** + * Sets [Builder.lastUsedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.lastUsedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lastUsedAt(lastUsedAt: JsonField<OffsetDateTime>) = apply { + this.lastUsedAt = lastUsedAt + } + + fun readOnly(readOnly: Boolean) = readOnly(JsonField.of(readOnly)) + + /** + * Sets [Builder.readOnly] to an arbitrary JSON value. + * + * You should usually call [Builder.readOnly] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun readOnly(readOnly: JsonField<Boolean>) = apply { this.readOnly = readOnly } + + fun workspaceNames(workspaceNames: List<String>?) = + workspaceNames(JsonField.ofNullable(workspaceNames)) + + /** Alias for calling [Builder.workspaceNames] with `workspaceNames.orElse(null)`. */ + fun workspaceNames(workspaceNames: Optional<List<String>>) = + workspaceNames(workspaceNames.getOrNull()) + + /** + * Sets [Builder.workspaceNames] to an arbitrary JSON value. + * + * You should usually call [Builder.workspaceNames] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun workspaceNames(workspaceNames: JsonField<List<String>>) = apply { + this.workspaceNames = workspaceNames.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [workspaceNames]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWorkspaceName(workspaceName: String) = apply { + workspaceNames = + (workspaceNames ?: JsonField.of(mutableListOf())).also { + checkKnown("workspaceNames", it).add(workspaceName) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ApiKeyGetResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .description() + * .shortKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ApiKeyGetResponse = + ApiKeyGetResponse( + checkRequired("id", id), + checkRequired("description", description), + checkRequired("shortKey", shortKey), + createdAt, + expiresAt, + lastUsedAt, + readOnly, + (workspaceNames ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ApiKeyGetResponse = apply { + if (validated) { + return@apply + } + + id() + description() + shortKey() + createdAt() + expiresAt() + lastUsedAt() + readOnly() + workspaceNames() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (shortKey.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (expiresAt.asKnown().isPresent) 1 else 0) + + (if (lastUsedAt.asKnown().isPresent) 1 else 0) + + (if (readOnly.asKnown().isPresent) 1 else 0) + + (workspaceNames.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ApiKeyGetResponse && + id == other.id && + description == other.description && + shortKey == other.shortKey && + createdAt == other.createdAt && + expiresAt == other.expiresAt && + lastUsedAt == other.lastUsedAt && + readOnly == other.readOnly && + workspaceNames == other.workspaceNames && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + description, + shortKey, + createdAt, + expiresAt, + lastUsedAt, + readOnly, + workspaceNames, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ApiKeyGetResponse{id=$id, description=$description, shortKey=$shortKey, createdAt=$createdAt, expiresAt=$expiresAt, lastUsedAt=$lastUsedAt, readOnly=$readOnly, workspaceNames=$workspaceNames, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ServiceKeyDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ServiceKeyDeleteParams.kt new file mode 100644 index 00000000..7a4b68f7 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ServiceKeyDeleteParams.kt @@ -0,0 +1,230 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.servicekeys + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete Org Service Key */ +class ServiceKeyDeleteParams +private constructor( + private val apiKeyId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun apiKeyId(): Optional<String> = Optional.ofNullable(apiKeyId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ServiceKeyDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ServiceKeyDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ServiceKeyDeleteParams]. */ + class Builder internal constructor() { + + private var apiKeyId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(serviceKeyDeleteParams: ServiceKeyDeleteParams) = apply { + apiKeyId = serviceKeyDeleteParams.apiKeyId + additionalHeaders = serviceKeyDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = serviceKeyDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + serviceKeyDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun apiKeyId(apiKeyId: String?) = apply { this.apiKeyId = apiKeyId } + + /** Alias for calling [Builder.apiKeyId] with `apiKeyId.orElse(null)`. */ + fun apiKeyId(apiKeyId: Optional<String>) = apiKeyId(apiKeyId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [ServiceKeyDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ServiceKeyDeleteParams = + ServiceKeyDeleteParams( + apiKeyId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> apiKeyId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ServiceKeyDeleteParams && + apiKeyId == other.apiKeyId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(apiKeyId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "ServiceKeyDeleteParams{apiKeyId=$apiKeyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ServiceKeyRetrieveServiceKeysParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ServiceKeyRetrieveServiceKeysParams.kt new file mode 100644 index 00000000..3e15988c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ServiceKeyRetrieveServiceKeysParams.kt @@ -0,0 +1,179 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.servicekeys + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** List Org Service Keys */ +class ServiceKeyRetrieveServiceKeysParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ServiceKeyRetrieveServiceKeysParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [ServiceKeyRetrieveServiceKeysParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ServiceKeyRetrieveServiceKeysParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + serviceKeyRetrieveServiceKeysParams: ServiceKeyRetrieveServiceKeysParams + ) = apply { + additionalHeaders = serviceKeyRetrieveServiceKeysParams.additionalHeaders.toBuilder() + additionalQueryParams = + serviceKeyRetrieveServiceKeysParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ServiceKeyRetrieveServiceKeysParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ServiceKeyRetrieveServiceKeysParams = + ServiceKeyRetrieveServiceKeysParams( + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ServiceKeyRetrieveServiceKeysParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "ServiceKeyRetrieveServiceKeysParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ServiceKeyServiceKeysParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ServiceKeyServiceKeysParams.kt new file mode 100644 index 00000000..33328298 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ServiceKeyServiceKeysParams.kt @@ -0,0 +1,227 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.servicekeys + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** Create org-scoped service key. If workspaces is None, key is org-wide. */ +class ServiceKeyServiceKeysParams +private constructor( + private val apiKeyCreateRequest: ApiKeyCreateRequest, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * API key POST schema. + * + * expires_at: Optional datetime when the API key will expire. workspaces: List of workspace + * UUIDs this key can access (feature-flagged). role_id: Optional UUID of the role to assign to + * API key. If not provided, uses default role based on read_only flag: + * - WORKSPACE_ADMIN if read_only is False + * - WORKSPACE_READER if read_only is True org_role_id: UUID of a org role for org-scoped keys + * If not provided, defaults to ORG_USER default_workspace_id: UUID of the default workspace + * for PATs. If not provided, uses the current logic (first available workspace). + */ + fun apiKeyCreateRequest(): ApiKeyCreateRequest = apiKeyCreateRequest + + fun _additionalBodyProperties(): Map<String, JsonValue> = + apiKeyCreateRequest._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ServiceKeyServiceKeysParams]. + * + * The following fields are required: + * ```java + * .apiKeyCreateRequest() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ServiceKeyServiceKeysParams]. */ + class Builder internal constructor() { + + private var apiKeyCreateRequest: ApiKeyCreateRequest? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(serviceKeyServiceKeysParams: ServiceKeyServiceKeysParams) = apply { + apiKeyCreateRequest = serviceKeyServiceKeysParams.apiKeyCreateRequest + additionalHeaders = serviceKeyServiceKeysParams.additionalHeaders.toBuilder() + additionalQueryParams = serviceKeyServiceKeysParams.additionalQueryParams.toBuilder() + } + + /** + * API key POST schema. + * + * expires_at: Optional datetime when the API key will expire. workspaces: List of workspace + * UUIDs this key can access (feature-flagged). role_id: Optional UUID of the role to assign + * to API key. If not provided, uses default role based on read_only flag: + * - WORKSPACE_ADMIN if read_only is False + * - WORKSPACE_READER if read_only is True org_role_id: UUID of a org role for org-scoped + * keys If not provided, defaults to ORG_USER default_workspace_id: UUID of the default + * workspace for PATs. If not provided, uses the current logic (first available + * workspace). + */ + fun apiKeyCreateRequest(apiKeyCreateRequest: ApiKeyCreateRequest) = apply { + this.apiKeyCreateRequest = apiKeyCreateRequest + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ServiceKeyServiceKeysParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .apiKeyCreateRequest() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ServiceKeyServiceKeysParams = + ServiceKeyServiceKeysParams( + checkRequired("apiKeyCreateRequest", apiKeyCreateRequest), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): ApiKeyCreateRequest = apiKeyCreateRequest + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ServiceKeyServiceKeysParams && + apiKeyCreateRequest == other.apiKeyCreateRequest && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(apiKeyCreateRequest, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ServiceKeyServiceKeysParams{apiKeyCreateRequest=$apiKeyCreateRequest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoProvider.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoProvider.kt new file mode 100644 index 00000000..7d34cc5e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoProvider.kt @@ -0,0 +1,448 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.ssosettings + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class SsoProvider +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val defaultWorkspaceIds: JsonField<List<String>>, + private val defaultWorkspaceRoleId: JsonField<String>, + private val organizationId: JsonField<String>, + private val providerId: JsonField<String>, + private val metadataUrl: JsonField<String>, + private val metadataXml: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("default_workspace_ids") + @ExcludeMissing + defaultWorkspaceIds: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("default_workspace_role_id") + @ExcludeMissing + defaultWorkspaceRoleId: JsonField<String> = JsonMissing.of(), + @JsonProperty("organization_id") + @ExcludeMissing + organizationId: JsonField<String> = JsonMissing.of(), + @JsonProperty("provider_id") + @ExcludeMissing + providerId: JsonField<String> = JsonMissing.of(), + @JsonProperty("metadata_url") + @ExcludeMissing + metadataUrl: JsonField<String> = JsonMissing.of(), + @JsonProperty("metadata_xml") + @ExcludeMissing + metadataXml: JsonField<String> = JsonMissing.of(), + ) : this( + id, + defaultWorkspaceIds, + defaultWorkspaceRoleId, + organizationId, + providerId, + metadataUrl, + metadataXml, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun defaultWorkspaceIds(): List<String> = + defaultWorkspaceIds.getRequired("default_workspace_ids") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun defaultWorkspaceRoleId(): String = + defaultWorkspaceRoleId.getRequired("default_workspace_role_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun organizationId(): String = organizationId.getRequired("organization_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun providerId(): String = providerId.getRequired("provider_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadataUrl(): Optional<String> = metadataUrl.getOptional("metadata_url") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadataXml(): Optional<String> = metadataXml.getOptional("metadata_xml") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [defaultWorkspaceIds]. + * + * Unlike [defaultWorkspaceIds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("default_workspace_ids") + @ExcludeMissing + fun _defaultWorkspaceIds(): JsonField<List<String>> = defaultWorkspaceIds + + /** + * Returns the raw JSON value of [defaultWorkspaceRoleId]. + * + * Unlike [defaultWorkspaceRoleId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_workspace_role_id") + @ExcludeMissing + fun _defaultWorkspaceRoleId(): JsonField<String> = defaultWorkspaceRoleId + + /** + * Returns the raw JSON value of [organizationId]. + * + * Unlike [organizationId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("organization_id") + @ExcludeMissing + fun _organizationId(): JsonField<String> = organizationId + + /** + * Returns the raw JSON value of [providerId]. + * + * Unlike [providerId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("provider_id") @ExcludeMissing fun _providerId(): JsonField<String> = providerId + + /** + * Returns the raw JSON value of [metadataUrl]. + * + * Unlike [metadataUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata_url") + @ExcludeMissing + fun _metadataUrl(): JsonField<String> = metadataUrl + + /** + * Returns the raw JSON value of [metadataXml]. + * + * Unlike [metadataXml], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata_xml") + @ExcludeMissing + fun _metadataXml(): JsonField<String> = metadataXml + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SsoProvider]. + * + * The following fields are required: + * ```java + * .id() + * .defaultWorkspaceIds() + * .defaultWorkspaceRoleId() + * .organizationId() + * .providerId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SsoProvider]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var defaultWorkspaceIds: JsonField<MutableList<String>>? = null + private var defaultWorkspaceRoleId: JsonField<String>? = null + private var organizationId: JsonField<String>? = null + private var providerId: JsonField<String>? = null + private var metadataUrl: JsonField<String> = JsonMissing.of() + private var metadataXml: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(ssoProvider: SsoProvider) = apply { + id = ssoProvider.id + defaultWorkspaceIds = ssoProvider.defaultWorkspaceIds.map { it.toMutableList() } + defaultWorkspaceRoleId = ssoProvider.defaultWorkspaceRoleId + organizationId = ssoProvider.organizationId + providerId = ssoProvider.providerId + metadataUrl = ssoProvider.metadataUrl + metadataXml = ssoProvider.metadataXml + additionalProperties = ssoProvider.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun defaultWorkspaceIds(defaultWorkspaceIds: List<String>) = + defaultWorkspaceIds(JsonField.of(defaultWorkspaceIds)) + + /** + * Sets [Builder.defaultWorkspaceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultWorkspaceIds] with a well-typed `List<String>` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun defaultWorkspaceIds(defaultWorkspaceIds: JsonField<List<String>>) = apply { + this.defaultWorkspaceIds = defaultWorkspaceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [defaultWorkspaceIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addDefaultWorkspaceId(defaultWorkspaceId: String) = apply { + defaultWorkspaceIds = + (defaultWorkspaceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("defaultWorkspaceIds", it).add(defaultWorkspaceId) + } + } + + fun defaultWorkspaceRoleId(defaultWorkspaceRoleId: String) = + defaultWorkspaceRoleId(JsonField.of(defaultWorkspaceRoleId)) + + /** + * Sets [Builder.defaultWorkspaceRoleId] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultWorkspaceRoleId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun defaultWorkspaceRoleId(defaultWorkspaceRoleId: JsonField<String>) = apply { + this.defaultWorkspaceRoleId = defaultWorkspaceRoleId + } + + fun organizationId(organizationId: String) = organizationId(JsonField.of(organizationId)) + + /** + * Sets [Builder.organizationId] to an arbitrary JSON value. + * + * You should usually call [Builder.organizationId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun organizationId(organizationId: JsonField<String>) = apply { + this.organizationId = organizationId + } + + fun providerId(providerId: String) = providerId(JsonField.of(providerId)) + + /** + * Sets [Builder.providerId] to an arbitrary JSON value. + * + * You should usually call [Builder.providerId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun providerId(providerId: JsonField<String>) = apply { this.providerId = providerId } + + fun metadataUrl(metadataUrl: String?) = metadataUrl(JsonField.ofNullable(metadataUrl)) + + /** Alias for calling [Builder.metadataUrl] with `metadataUrl.orElse(null)`. */ + fun metadataUrl(metadataUrl: Optional<String>) = metadataUrl(metadataUrl.getOrNull()) + + /** + * Sets [Builder.metadataUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.metadataUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadataUrl(metadataUrl: JsonField<String>) = apply { this.metadataUrl = metadataUrl } + + fun metadataXml(metadataXml: String?) = metadataXml(JsonField.ofNullable(metadataXml)) + + /** Alias for calling [Builder.metadataXml] with `metadataXml.orElse(null)`. */ + fun metadataXml(metadataXml: Optional<String>) = metadataXml(metadataXml.getOrNull()) + + /** + * Sets [Builder.metadataXml] to an arbitrary JSON value. + * + * You should usually call [Builder.metadataXml] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadataXml(metadataXml: JsonField<String>) = apply { this.metadataXml = metadataXml } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SsoProvider]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .defaultWorkspaceIds() + * .defaultWorkspaceRoleId() + * .organizationId() + * .providerId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SsoProvider = + SsoProvider( + checkRequired("id", id), + checkRequired("defaultWorkspaceIds", defaultWorkspaceIds).map { it.toImmutable() }, + checkRequired("defaultWorkspaceRoleId", defaultWorkspaceRoleId), + checkRequired("organizationId", organizationId), + checkRequired("providerId", providerId), + metadataUrl, + metadataXml, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SsoProvider = apply { + if (validated) { + return@apply + } + + id() + defaultWorkspaceIds() + defaultWorkspaceRoleId() + organizationId() + providerId() + metadataUrl() + metadataXml() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (defaultWorkspaceIds.asKnown().getOrNull()?.size ?: 0) + + (if (defaultWorkspaceRoleId.asKnown().isPresent) 1 else 0) + + (if (organizationId.asKnown().isPresent) 1 else 0) + + (if (providerId.asKnown().isPresent) 1 else 0) + + (if (metadataUrl.asKnown().isPresent) 1 else 0) + + (if (metadataXml.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SsoProvider && + id == other.id && + defaultWorkspaceIds == other.defaultWorkspaceIds && + defaultWorkspaceRoleId == other.defaultWorkspaceRoleId && + organizationId == other.organizationId && + providerId == other.providerId && + metadataUrl == other.metadataUrl && + metadataXml == other.metadataXml && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + defaultWorkspaceIds, + defaultWorkspaceRoleId, + organizationId, + providerId, + metadataUrl, + metadataXml, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SsoProvider{id=$id, defaultWorkspaceIds=$defaultWorkspaceIds, defaultWorkspaceRoleId=$defaultWorkspaceRoleId, organizationId=$organizationId, providerId=$providerId, metadataUrl=$metadataUrl, metadataXml=$metadataXml, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoSettingDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoSettingDeleteParams.kt new file mode 100644 index 00000000..abef6c79 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoSettingDeleteParams.kt @@ -0,0 +1,230 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.ssosettings + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete SSO provider settings for the current organization. */ +class SsoSettingDeleteParams +private constructor( + private val id: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun id(): Optional<String> = Optional.ofNullable(id) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): SsoSettingDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [SsoSettingDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SsoSettingDeleteParams]. */ + class Builder internal constructor() { + + private var id: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(ssoSettingDeleteParams: SsoSettingDeleteParams) = apply { + id = ssoSettingDeleteParams.id + additionalHeaders = ssoSettingDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = ssoSettingDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + ssoSettingDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun id(id: String?) = apply { this.id = id } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<String>) = id(id.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [SsoSettingDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SsoSettingDeleteParams = + SsoSettingDeleteParams( + id, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> id ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SsoSettingDeleteParams && + id == other.id && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(id, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "SsoSettingDeleteParams{id=$id, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoSettingRetrieveSsoSettingsParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoSettingRetrieveSsoSettingsParams.kt new file mode 100644 index 00000000..4461365a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoSettingRetrieveSsoSettingsParams.kt @@ -0,0 +1,179 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.ssosettings + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** Get SSO provider settings for the current organization. */ +class SsoSettingRetrieveSsoSettingsParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): SsoSettingRetrieveSsoSettingsParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [SsoSettingRetrieveSsoSettingsParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SsoSettingRetrieveSsoSettingsParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + ssoSettingRetrieveSsoSettingsParams: SsoSettingRetrieveSsoSettingsParams + ) = apply { + additionalHeaders = ssoSettingRetrieveSsoSettingsParams.additionalHeaders.toBuilder() + additionalQueryParams = + ssoSettingRetrieveSsoSettingsParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SsoSettingRetrieveSsoSettingsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SsoSettingRetrieveSsoSettingsParams = + SsoSettingRetrieveSsoSettingsParams( + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SsoSettingRetrieveSsoSettingsParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "SsoSettingRetrieveSsoSettingsParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoSettingSsoSettingsParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoSettingSsoSettingsParams.kt new file mode 100644 index 00000000..ae0f7b93 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoSettingSsoSettingsParams.kt @@ -0,0 +1,856 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.ssosettings + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create SSO provider settings for the current organization. */ +class SsoSettingSsoSettingsParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun defaultWorkspaceIds(): List<String> = body.defaultWorkspaceIds() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun defaultWorkspaceRoleId(): String = body.defaultWorkspaceRoleId() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun attributeMapping(): Optional<AttributeMapping> = body.attributeMapping() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadataUrl(): Optional<String> = body.metadataUrl() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadataXml(): Optional<String> = body.metadataXml() + + /** + * Returns the raw JSON value of [defaultWorkspaceIds]. + * + * Unlike [defaultWorkspaceIds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _defaultWorkspaceIds(): JsonField<List<String>> = body._defaultWorkspaceIds() + + /** + * Returns the raw JSON value of [defaultWorkspaceRoleId]. + * + * Unlike [defaultWorkspaceRoleId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _defaultWorkspaceRoleId(): JsonField<String> = body._defaultWorkspaceRoleId() + + /** + * Returns the raw JSON value of [attributeMapping]. + * + * Unlike [attributeMapping], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _attributeMapping(): JsonField<AttributeMapping> = body._attributeMapping() + + /** + * Returns the raw JSON value of [metadataUrl]. + * + * Unlike [metadataUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _metadataUrl(): JsonField<String> = body._metadataUrl() + + /** + * Returns the raw JSON value of [metadataXml]. + * + * Unlike [metadataXml], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _metadataXml(): JsonField<String> = body._metadataXml() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SsoSettingSsoSettingsParams]. + * + * The following fields are required: + * ```java + * .defaultWorkspaceIds() + * .defaultWorkspaceRoleId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SsoSettingSsoSettingsParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(ssoSettingSsoSettingsParams: SsoSettingSsoSettingsParams) = apply { + body = ssoSettingSsoSettingsParams.body.toBuilder() + additionalHeaders = ssoSettingSsoSettingsParams.additionalHeaders.toBuilder() + additionalQueryParams = ssoSettingSsoSettingsParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [defaultWorkspaceIds] + * - [defaultWorkspaceRoleId] + * - [attributeMapping] + * - [metadataUrl] + * - [metadataXml] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun defaultWorkspaceIds(defaultWorkspaceIds: List<String>) = apply { + body.defaultWorkspaceIds(defaultWorkspaceIds) + } + + /** + * Sets [Builder.defaultWorkspaceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultWorkspaceIds] with a well-typed `List<String>` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun defaultWorkspaceIds(defaultWorkspaceIds: JsonField<List<String>>) = apply { + body.defaultWorkspaceIds(defaultWorkspaceIds) + } + + /** + * Adds a single [String] to [defaultWorkspaceIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addDefaultWorkspaceId(defaultWorkspaceId: String) = apply { + body.addDefaultWorkspaceId(defaultWorkspaceId) + } + + fun defaultWorkspaceRoleId(defaultWorkspaceRoleId: String) = apply { + body.defaultWorkspaceRoleId(defaultWorkspaceRoleId) + } + + /** + * Sets [Builder.defaultWorkspaceRoleId] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultWorkspaceRoleId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun defaultWorkspaceRoleId(defaultWorkspaceRoleId: JsonField<String>) = apply { + body.defaultWorkspaceRoleId(defaultWorkspaceRoleId) + } + + fun attributeMapping(attributeMapping: AttributeMapping) = apply { + body.attributeMapping(attributeMapping) + } + + /** + * Sets [Builder.attributeMapping] to an arbitrary JSON value. + * + * You should usually call [Builder.attributeMapping] with a well-typed [AttributeMapping] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun attributeMapping(attributeMapping: JsonField<AttributeMapping>) = apply { + body.attributeMapping(attributeMapping) + } + + fun metadataUrl(metadataUrl: String?) = apply { body.metadataUrl(metadataUrl) } + + /** Alias for calling [Builder.metadataUrl] with `metadataUrl.orElse(null)`. */ + fun metadataUrl(metadataUrl: Optional<String>) = metadataUrl(metadataUrl.getOrNull()) + + /** + * Sets [Builder.metadataUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.metadataUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadataUrl(metadataUrl: JsonField<String>) = apply { body.metadataUrl(metadataUrl) } + + fun metadataXml(metadataXml: String?) = apply { body.metadataXml(metadataXml) } + + /** Alias for calling [Builder.metadataXml] with `metadataXml.orElse(null)`. */ + fun metadataXml(metadataXml: Optional<String>) = metadataXml(metadataXml.getOrNull()) + + /** + * Sets [Builder.metadataXml] to an arbitrary JSON value. + * + * You should usually call [Builder.metadataXml] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadataXml(metadataXml: JsonField<String>) = apply { body.metadataXml(metadataXml) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SsoSettingSsoSettingsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .defaultWorkspaceIds() + * .defaultWorkspaceRoleId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SsoSettingSsoSettingsParams = + SsoSettingSsoSettingsParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val defaultWorkspaceIds: JsonField<List<String>>, + private val defaultWorkspaceRoleId: JsonField<String>, + private val attributeMapping: JsonField<AttributeMapping>, + private val metadataUrl: JsonField<String>, + private val metadataXml: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("default_workspace_ids") + @ExcludeMissing + defaultWorkspaceIds: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("default_workspace_role_id") + @ExcludeMissing + defaultWorkspaceRoleId: JsonField<String> = JsonMissing.of(), + @JsonProperty("attribute_mapping") + @ExcludeMissing + attributeMapping: JsonField<AttributeMapping> = JsonMissing.of(), + @JsonProperty("metadata_url") + @ExcludeMissing + metadataUrl: JsonField<String> = JsonMissing.of(), + @JsonProperty("metadata_xml") + @ExcludeMissing + metadataXml: JsonField<String> = JsonMissing.of(), + ) : this( + defaultWorkspaceIds, + defaultWorkspaceRoleId, + attributeMapping, + metadataUrl, + metadataXml, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun defaultWorkspaceIds(): List<String> = + defaultWorkspaceIds.getRequired("default_workspace_ids") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun defaultWorkspaceRoleId(): String = + defaultWorkspaceRoleId.getRequired("default_workspace_role_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun attributeMapping(): Optional<AttributeMapping> = + attributeMapping.getOptional("attribute_mapping") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun metadataUrl(): Optional<String> = metadataUrl.getOptional("metadata_url") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun metadataXml(): Optional<String> = metadataXml.getOptional("metadata_xml") + + /** + * Returns the raw JSON value of [defaultWorkspaceIds]. + * + * Unlike [defaultWorkspaceIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_workspace_ids") + @ExcludeMissing + fun _defaultWorkspaceIds(): JsonField<List<String>> = defaultWorkspaceIds + + /** + * Returns the raw JSON value of [defaultWorkspaceRoleId]. + * + * Unlike [defaultWorkspaceRoleId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_workspace_role_id") + @ExcludeMissing + fun _defaultWorkspaceRoleId(): JsonField<String> = defaultWorkspaceRoleId + + /** + * Returns the raw JSON value of [attributeMapping]. + * + * Unlike [attributeMapping], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("attribute_mapping") + @ExcludeMissing + fun _attributeMapping(): JsonField<AttributeMapping> = attributeMapping + + /** + * Returns the raw JSON value of [metadataUrl]. + * + * Unlike [metadataUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata_url") + @ExcludeMissing + fun _metadataUrl(): JsonField<String> = metadataUrl + + /** + * Returns the raw JSON value of [metadataXml]. + * + * Unlike [metadataXml], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata_xml") + @ExcludeMissing + fun _metadataXml(): JsonField<String> = metadataXml + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .defaultWorkspaceIds() + * .defaultWorkspaceRoleId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var defaultWorkspaceIds: JsonField<MutableList<String>>? = null + private var defaultWorkspaceRoleId: JsonField<String>? = null + private var attributeMapping: JsonField<AttributeMapping> = JsonMissing.of() + private var metadataUrl: JsonField<String> = JsonMissing.of() + private var metadataXml: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + defaultWorkspaceIds = body.defaultWorkspaceIds.map { it.toMutableList() } + defaultWorkspaceRoleId = body.defaultWorkspaceRoleId + attributeMapping = body.attributeMapping + metadataUrl = body.metadataUrl + metadataXml = body.metadataXml + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun defaultWorkspaceIds(defaultWorkspaceIds: List<String>) = + defaultWorkspaceIds(JsonField.of(defaultWorkspaceIds)) + + /** + * Sets [Builder.defaultWorkspaceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultWorkspaceIds] with a well-typed + * `List<String>` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun defaultWorkspaceIds(defaultWorkspaceIds: JsonField<List<String>>) = apply { + this.defaultWorkspaceIds = defaultWorkspaceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [defaultWorkspaceIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addDefaultWorkspaceId(defaultWorkspaceId: String) = apply { + defaultWorkspaceIds = + (defaultWorkspaceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("defaultWorkspaceIds", it).add(defaultWorkspaceId) + } + } + + fun defaultWorkspaceRoleId(defaultWorkspaceRoleId: String) = + defaultWorkspaceRoleId(JsonField.of(defaultWorkspaceRoleId)) + + /** + * Sets [Builder.defaultWorkspaceRoleId] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultWorkspaceRoleId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun defaultWorkspaceRoleId(defaultWorkspaceRoleId: JsonField<String>) = apply { + this.defaultWorkspaceRoleId = defaultWorkspaceRoleId + } + + fun attributeMapping(attributeMapping: AttributeMapping) = + attributeMapping(JsonField.of(attributeMapping)) + + /** + * Sets [Builder.attributeMapping] to an arbitrary JSON value. + * + * You should usually call [Builder.attributeMapping] with a well-typed + * [AttributeMapping] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun attributeMapping(attributeMapping: JsonField<AttributeMapping>) = apply { + this.attributeMapping = attributeMapping + } + + fun metadataUrl(metadataUrl: String?) = metadataUrl(JsonField.ofNullable(metadataUrl)) + + /** Alias for calling [Builder.metadataUrl] with `metadataUrl.orElse(null)`. */ + fun metadataUrl(metadataUrl: Optional<String>) = metadataUrl(metadataUrl.getOrNull()) + + /** + * Sets [Builder.metadataUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.metadataUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadataUrl(metadataUrl: JsonField<String>) = apply { + this.metadataUrl = metadataUrl + } + + fun metadataXml(metadataXml: String?) = metadataXml(JsonField.ofNullable(metadataXml)) + + /** Alias for calling [Builder.metadataXml] with `metadataXml.orElse(null)`. */ + fun metadataXml(metadataXml: Optional<String>) = metadataXml(metadataXml.getOrNull()) + + /** + * Sets [Builder.metadataXml] to an arbitrary JSON value. + * + * You should usually call [Builder.metadataXml] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadataXml(metadataXml: JsonField<String>) = apply { + this.metadataXml = metadataXml + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .defaultWorkspaceIds() + * .defaultWorkspaceRoleId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("defaultWorkspaceIds", defaultWorkspaceIds).map { + it.toImmutable() + }, + checkRequired("defaultWorkspaceRoleId", defaultWorkspaceRoleId), + attributeMapping, + metadataUrl, + metadataXml, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + defaultWorkspaceIds() + defaultWorkspaceRoleId() + attributeMapping().ifPresent { it.validate() } + metadataUrl() + metadataXml() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (defaultWorkspaceIds.asKnown().getOrNull()?.size ?: 0) + + (if (defaultWorkspaceRoleId.asKnown().isPresent) 1 else 0) + + (attributeMapping.asKnown().getOrNull()?.validity() ?: 0) + + (if (metadataUrl.asKnown().isPresent) 1 else 0) + + (if (metadataXml.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + defaultWorkspaceIds == other.defaultWorkspaceIds && + defaultWorkspaceRoleId == other.defaultWorkspaceRoleId && + attributeMapping == other.attributeMapping && + metadataUrl == other.metadataUrl && + metadataXml == other.metadataXml && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + defaultWorkspaceIds, + defaultWorkspaceRoleId, + attributeMapping, + metadataUrl, + metadataXml, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{defaultWorkspaceIds=$defaultWorkspaceIds, defaultWorkspaceRoleId=$defaultWorkspaceRoleId, attributeMapping=$attributeMapping, metadataUrl=$metadataUrl, metadataXml=$metadataXml, additionalProperties=$additionalProperties}" + } + + class AttributeMapping + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [AttributeMapping]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AttributeMapping]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(attributeMapping: AttributeMapping) = apply { + additionalProperties = attributeMapping.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AttributeMapping]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AttributeMapping = AttributeMapping(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): AttributeMapping = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AttributeMapping && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "AttributeMapping{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SsoSettingSsoSettingsParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "SsoSettingSsoSettingsParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoSettingUpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoSettingUpdateParams.kt new file mode 100644 index 00000000..a74f9749 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoSettingUpdateParams.kt @@ -0,0 +1,695 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.ssosettings + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Update SSO provider settings defaults for the current organization. */ +class SsoSettingUpdateParams +private constructor( + private val id: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun id(): Optional<String> = Optional.ofNullable(id) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun defaultWorkspaceIds(): Optional<List<String>> = body.defaultWorkspaceIds() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun defaultWorkspaceRoleId(): Optional<String> = body.defaultWorkspaceRoleId() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadataUrl(): Optional<String> = body.metadataUrl() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadataXml(): Optional<String> = body.metadataXml() + + /** + * Returns the raw JSON value of [defaultWorkspaceIds]. + * + * Unlike [defaultWorkspaceIds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _defaultWorkspaceIds(): JsonField<List<String>> = body._defaultWorkspaceIds() + + /** + * Returns the raw JSON value of [defaultWorkspaceRoleId]. + * + * Unlike [defaultWorkspaceRoleId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _defaultWorkspaceRoleId(): JsonField<String> = body._defaultWorkspaceRoleId() + + /** + * Returns the raw JSON value of [metadataUrl]. + * + * Unlike [metadataUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _metadataUrl(): JsonField<String> = body._metadataUrl() + + /** + * Returns the raw JSON value of [metadataXml]. + * + * Unlike [metadataXml], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _metadataXml(): JsonField<String> = body._metadataXml() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): SsoSettingUpdateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [SsoSettingUpdateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SsoSettingUpdateParams]. */ + class Builder internal constructor() { + + private var id: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(ssoSettingUpdateParams: SsoSettingUpdateParams) = apply { + id = ssoSettingUpdateParams.id + body = ssoSettingUpdateParams.body.toBuilder() + additionalHeaders = ssoSettingUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = ssoSettingUpdateParams.additionalQueryParams.toBuilder() + } + + fun id(id: String?) = apply { this.id = id } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<String>) = id(id.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [defaultWorkspaceIds] + * - [defaultWorkspaceRoleId] + * - [metadataUrl] + * - [metadataXml] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun defaultWorkspaceIds(defaultWorkspaceIds: List<String>?) = apply { + body.defaultWorkspaceIds(defaultWorkspaceIds) + } + + /** + * Alias for calling [Builder.defaultWorkspaceIds] with `defaultWorkspaceIds.orElse(null)`. + */ + fun defaultWorkspaceIds(defaultWorkspaceIds: Optional<List<String>>) = + defaultWorkspaceIds(defaultWorkspaceIds.getOrNull()) + + /** + * Sets [Builder.defaultWorkspaceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultWorkspaceIds] with a well-typed `List<String>` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun defaultWorkspaceIds(defaultWorkspaceIds: JsonField<List<String>>) = apply { + body.defaultWorkspaceIds(defaultWorkspaceIds) + } + + /** + * Adds a single [String] to [defaultWorkspaceIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addDefaultWorkspaceId(defaultWorkspaceId: String) = apply { + body.addDefaultWorkspaceId(defaultWorkspaceId) + } + + fun defaultWorkspaceRoleId(defaultWorkspaceRoleId: String?) = apply { + body.defaultWorkspaceRoleId(defaultWorkspaceRoleId) + } + + /** + * Alias for calling [Builder.defaultWorkspaceRoleId] with + * `defaultWorkspaceRoleId.orElse(null)`. + */ + fun defaultWorkspaceRoleId(defaultWorkspaceRoleId: Optional<String>) = + defaultWorkspaceRoleId(defaultWorkspaceRoleId.getOrNull()) + + /** + * Sets [Builder.defaultWorkspaceRoleId] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultWorkspaceRoleId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun defaultWorkspaceRoleId(defaultWorkspaceRoleId: JsonField<String>) = apply { + body.defaultWorkspaceRoleId(defaultWorkspaceRoleId) + } + + fun metadataUrl(metadataUrl: String?) = apply { body.metadataUrl(metadataUrl) } + + /** Alias for calling [Builder.metadataUrl] with `metadataUrl.orElse(null)`. */ + fun metadataUrl(metadataUrl: Optional<String>) = metadataUrl(metadataUrl.getOrNull()) + + /** + * Sets [Builder.metadataUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.metadataUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadataUrl(metadataUrl: JsonField<String>) = apply { body.metadataUrl(metadataUrl) } + + fun metadataXml(metadataXml: String?) = apply { body.metadataXml(metadataXml) } + + /** Alias for calling [Builder.metadataXml] with `metadataXml.orElse(null)`. */ + fun metadataXml(metadataXml: Optional<String>) = metadataXml(metadataXml.getOrNull()) + + /** + * Sets [Builder.metadataXml] to an arbitrary JSON value. + * + * You should usually call [Builder.metadataXml] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadataXml(metadataXml: JsonField<String>) = apply { body.metadataXml(metadataXml) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SsoSettingUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SsoSettingUpdateParams = + SsoSettingUpdateParams( + id, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> id ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val defaultWorkspaceIds: JsonField<List<String>>, + private val defaultWorkspaceRoleId: JsonField<String>, + private val metadataUrl: JsonField<String>, + private val metadataXml: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("default_workspace_ids") + @ExcludeMissing + defaultWorkspaceIds: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("default_workspace_role_id") + @ExcludeMissing + defaultWorkspaceRoleId: JsonField<String> = JsonMissing.of(), + @JsonProperty("metadata_url") + @ExcludeMissing + metadataUrl: JsonField<String> = JsonMissing.of(), + @JsonProperty("metadata_xml") + @ExcludeMissing + metadataXml: JsonField<String> = JsonMissing.of(), + ) : this( + defaultWorkspaceIds, + defaultWorkspaceRoleId, + metadataUrl, + metadataXml, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun defaultWorkspaceIds(): Optional<List<String>> = + defaultWorkspaceIds.getOptional("default_workspace_ids") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun defaultWorkspaceRoleId(): Optional<String> = + defaultWorkspaceRoleId.getOptional("default_workspace_role_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun metadataUrl(): Optional<String> = metadataUrl.getOptional("metadata_url") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun metadataXml(): Optional<String> = metadataXml.getOptional("metadata_xml") + + /** + * Returns the raw JSON value of [defaultWorkspaceIds]. + * + * Unlike [defaultWorkspaceIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_workspace_ids") + @ExcludeMissing + fun _defaultWorkspaceIds(): JsonField<List<String>> = defaultWorkspaceIds + + /** + * Returns the raw JSON value of [defaultWorkspaceRoleId]. + * + * Unlike [defaultWorkspaceRoleId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_workspace_role_id") + @ExcludeMissing + fun _defaultWorkspaceRoleId(): JsonField<String> = defaultWorkspaceRoleId + + /** + * Returns the raw JSON value of [metadataUrl]. + * + * Unlike [metadataUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata_url") + @ExcludeMissing + fun _metadataUrl(): JsonField<String> = metadataUrl + + /** + * Returns the raw JSON value of [metadataXml]. + * + * Unlike [metadataXml], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata_xml") + @ExcludeMissing + fun _metadataXml(): JsonField<String> = metadataXml + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var defaultWorkspaceIds: JsonField<MutableList<String>>? = null + private var defaultWorkspaceRoleId: JsonField<String> = JsonMissing.of() + private var metadataUrl: JsonField<String> = JsonMissing.of() + private var metadataXml: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + defaultWorkspaceIds = body.defaultWorkspaceIds.map { it.toMutableList() } + defaultWorkspaceRoleId = body.defaultWorkspaceRoleId + metadataUrl = body.metadataUrl + metadataXml = body.metadataXml + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun defaultWorkspaceIds(defaultWorkspaceIds: List<String>?) = + defaultWorkspaceIds(JsonField.ofNullable(defaultWorkspaceIds)) + + /** + * Alias for calling [Builder.defaultWorkspaceIds] with + * `defaultWorkspaceIds.orElse(null)`. + */ + fun defaultWorkspaceIds(defaultWorkspaceIds: Optional<List<String>>) = + defaultWorkspaceIds(defaultWorkspaceIds.getOrNull()) + + /** + * Sets [Builder.defaultWorkspaceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultWorkspaceIds] with a well-typed + * `List<String>` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun defaultWorkspaceIds(defaultWorkspaceIds: JsonField<List<String>>) = apply { + this.defaultWorkspaceIds = defaultWorkspaceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [defaultWorkspaceIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addDefaultWorkspaceId(defaultWorkspaceId: String) = apply { + defaultWorkspaceIds = + (defaultWorkspaceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("defaultWorkspaceIds", it).add(defaultWorkspaceId) + } + } + + fun defaultWorkspaceRoleId(defaultWorkspaceRoleId: String?) = + defaultWorkspaceRoleId(JsonField.ofNullable(defaultWorkspaceRoleId)) + + /** + * Alias for calling [Builder.defaultWorkspaceRoleId] with + * `defaultWorkspaceRoleId.orElse(null)`. + */ + fun defaultWorkspaceRoleId(defaultWorkspaceRoleId: Optional<String>) = + defaultWorkspaceRoleId(defaultWorkspaceRoleId.getOrNull()) + + /** + * Sets [Builder.defaultWorkspaceRoleId] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultWorkspaceRoleId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun defaultWorkspaceRoleId(defaultWorkspaceRoleId: JsonField<String>) = apply { + this.defaultWorkspaceRoleId = defaultWorkspaceRoleId + } + + fun metadataUrl(metadataUrl: String?) = metadataUrl(JsonField.ofNullable(metadataUrl)) + + /** Alias for calling [Builder.metadataUrl] with `metadataUrl.orElse(null)`. */ + fun metadataUrl(metadataUrl: Optional<String>) = metadataUrl(metadataUrl.getOrNull()) + + /** + * Sets [Builder.metadataUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.metadataUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadataUrl(metadataUrl: JsonField<String>) = apply { + this.metadataUrl = metadataUrl + } + + fun metadataXml(metadataXml: String?) = metadataXml(JsonField.ofNullable(metadataXml)) + + /** Alias for calling [Builder.metadataXml] with `metadataXml.orElse(null)`. */ + fun metadataXml(metadataXml: Optional<String>) = metadataXml(metadataXml.getOrNull()) + + /** + * Sets [Builder.metadataXml] to an arbitrary JSON value. + * + * You should usually call [Builder.metadataXml] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadataXml(metadataXml: JsonField<String>) = apply { + this.metadataXml = metadataXml + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = + Body( + (defaultWorkspaceIds ?: JsonMissing.of()).map { it.toImmutable() }, + defaultWorkspaceRoleId, + metadataUrl, + metadataXml, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + defaultWorkspaceIds() + defaultWorkspaceRoleId() + metadataUrl() + metadataXml() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (defaultWorkspaceIds.asKnown().getOrNull()?.size ?: 0) + + (if (defaultWorkspaceRoleId.asKnown().isPresent) 1 else 0) + + (if (metadataUrl.asKnown().isPresent) 1 else 0) + + (if (metadataXml.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + defaultWorkspaceIds == other.defaultWorkspaceIds && + defaultWorkspaceRoleId == other.defaultWorkspaceRoleId && + metadataUrl == other.metadataUrl && + metadataXml == other.metadataXml && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + defaultWorkspaceIds, + defaultWorkspaceRoleId, + metadataUrl, + metadataXml, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{defaultWorkspaceIds=$defaultWorkspaceIds, defaultWorkspaceRoleId=$defaultWorkspaceRoleId, metadataUrl=$metadataUrl, metadataXml=$metadataXml, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SsoSettingUpdateParams && + id == other.id && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(id, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "SsoSettingUpdateParams{id=$id, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/user/ProviderUserSlim.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/user/ProviderUserSlim.kt new file mode 100644 index 00000000..d9f4700b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/user/ProviderUserSlim.kt @@ -0,0 +1,1032 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.user + +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.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ProviderUserSlim +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val lsUserId: JsonField<String>, + private val updatedAt: JsonField<OffsetDateTime>, + private val email: JsonField<String>, + private val emailConfirmedAt: JsonField<OffsetDateTime>, + private val firstName: JsonField<String>, + private val fullName: JsonField<String>, + private val isDisabled: JsonField<Boolean>, + private val lastName: JsonField<String>, + private val provider: JsonField<Provider>, + private val providerUserId: JsonField<String>, + private val provisioningMethod: JsonField<ProvisioningMethod>, + private val samlProviderId: JsonField<String>, + private val username: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("ls_user_id") @ExcludeMissing lsUserId: JsonField<String> = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("email") @ExcludeMissing email: JsonField<String> = JsonMissing.of(), + @JsonProperty("email_confirmed_at") + @ExcludeMissing + emailConfirmedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("first_name") @ExcludeMissing firstName: JsonField<String> = JsonMissing.of(), + @JsonProperty("full_name") @ExcludeMissing fullName: JsonField<String> = JsonMissing.of(), + @JsonProperty("is_disabled") + @ExcludeMissing + isDisabled: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("last_name") @ExcludeMissing lastName: JsonField<String> = JsonMissing.of(), + @JsonProperty("provider") @ExcludeMissing provider: JsonField<Provider> = JsonMissing.of(), + @JsonProperty("provider_user_id") + @ExcludeMissing + providerUserId: JsonField<String> = JsonMissing.of(), + @JsonProperty("provisioning_method") + @ExcludeMissing + provisioningMethod: JsonField<ProvisioningMethod> = JsonMissing.of(), + @JsonProperty("saml_provider_id") + @ExcludeMissing + samlProviderId: JsonField<String> = JsonMissing.of(), + @JsonProperty("username") @ExcludeMissing username: JsonField<String> = JsonMissing.of(), + ) : this( + id, + createdAt, + lsUserId, + updatedAt, + email, + emailConfirmedAt, + firstName, + fullName, + isDisabled, + lastName, + provider, + providerUserId, + provisioningMethod, + samlProviderId, + username, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun lsUserId(): String = lsUserId.getRequired("ls_user_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updatedAt(): OffsetDateTime = updatedAt.getRequired("updated_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun email(): Optional<String> = email.getOptional("email") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun emailConfirmedAt(): Optional<OffsetDateTime> = + emailConfirmedAt.getOptional("email_confirmed_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun firstName(): Optional<String> = firstName.getOptional("first_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fullName(): Optional<String> = fullName.getOptional("full_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun isDisabled(): Optional<Boolean> = isDisabled.getOptional("is_disabled") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun lastName(): Optional<String> = lastName.getOptional("last_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun provider(): Optional<Provider> = provider.getOptional("provider") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun providerUserId(): Optional<String> = providerUserId.getOptional("provider_user_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun provisioningMethod(): Optional<ProvisioningMethod> = + provisioningMethod.getOptional("provisioning_method") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun samlProviderId(): Optional<String> = samlProviderId.getOptional("saml_provider_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun username(): Optional<String> = username.getOptional("username") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [lsUserId]. + * + * Unlike [lsUserId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ls_user_id") @ExcludeMissing fun _lsUserId(): JsonField<String> = lsUserId + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField<OffsetDateTime> = updatedAt + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField<String> = email + + /** + * Returns the raw JSON value of [emailConfirmedAt]. + * + * Unlike [emailConfirmedAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("email_confirmed_at") + @ExcludeMissing + fun _emailConfirmedAt(): JsonField<OffsetDateTime> = emailConfirmedAt + + /** + * Returns the raw JSON value of [firstName]. + * + * Unlike [firstName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("first_name") @ExcludeMissing fun _firstName(): JsonField<String> = firstName + + /** + * Returns the raw JSON value of [fullName]. + * + * Unlike [fullName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("full_name") @ExcludeMissing fun _fullName(): JsonField<String> = fullName + + /** + * Returns the raw JSON value of [isDisabled]. + * + * Unlike [isDisabled], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_disabled") @ExcludeMissing fun _isDisabled(): JsonField<Boolean> = isDisabled + + /** + * Returns the raw JSON value of [lastName]. + * + * Unlike [lastName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("last_name") @ExcludeMissing fun _lastName(): JsonField<String> = lastName + + /** + * Returns the raw JSON value of [provider]. + * + * Unlike [provider], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("provider") @ExcludeMissing fun _provider(): JsonField<Provider> = provider + + /** + * Returns the raw JSON value of [providerUserId]. + * + * Unlike [providerUserId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("provider_user_id") + @ExcludeMissing + fun _providerUserId(): JsonField<String> = providerUserId + + /** + * Returns the raw JSON value of [provisioningMethod]. + * + * Unlike [provisioningMethod], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("provisioning_method") + @ExcludeMissing + fun _provisioningMethod(): JsonField<ProvisioningMethod> = provisioningMethod + + /** + * Returns the raw JSON value of [samlProviderId]. + * + * Unlike [samlProviderId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("saml_provider_id") + @ExcludeMissing + fun _samlProviderId(): JsonField<String> = samlProviderId + + /** + * Returns the raw JSON value of [username]. + * + * Unlike [username], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("username") @ExcludeMissing fun _username(): JsonField<String> = username + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ProviderUserSlim]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .lsUserId() + * .updatedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ProviderUserSlim]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var createdAt: JsonField<OffsetDateTime>? = null + private var lsUserId: JsonField<String>? = null + private var updatedAt: JsonField<OffsetDateTime>? = null + private var email: JsonField<String> = JsonMissing.of() + private var emailConfirmedAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var firstName: JsonField<String> = JsonMissing.of() + private var fullName: JsonField<String> = JsonMissing.of() + private var isDisabled: JsonField<Boolean> = JsonMissing.of() + private var lastName: JsonField<String> = JsonMissing.of() + private var provider: JsonField<Provider> = JsonMissing.of() + private var providerUserId: JsonField<String> = JsonMissing.of() + private var provisioningMethod: JsonField<ProvisioningMethod> = JsonMissing.of() + private var samlProviderId: JsonField<String> = JsonMissing.of() + private var username: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(providerUserSlim: ProviderUserSlim) = apply { + id = providerUserSlim.id + createdAt = providerUserSlim.createdAt + lsUserId = providerUserSlim.lsUserId + updatedAt = providerUserSlim.updatedAt + email = providerUserSlim.email + emailConfirmedAt = providerUserSlim.emailConfirmedAt + firstName = providerUserSlim.firstName + fullName = providerUserSlim.fullName + isDisabled = providerUserSlim.isDisabled + lastName = providerUserSlim.lastName + provider = providerUserSlim.provider + providerUserId = providerUserSlim.providerUserId + provisioningMethod = providerUserSlim.provisioningMethod + samlProviderId = providerUserSlim.samlProviderId + username = providerUserSlim.username + additionalProperties = providerUserSlim.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun lsUserId(lsUserId: String) = lsUserId(JsonField.of(lsUserId)) + + /** + * Sets [Builder.lsUserId] to an arbitrary JSON value. + * + * You should usually call [Builder.lsUserId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun lsUserId(lsUserId: JsonField<String>) = apply { this.lsUserId = lsUserId } + + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField<OffsetDateTime>) = apply { this.updatedAt = updatedAt } + + fun email(email: String?) = email(JsonField.ofNullable(email)) + + /** Alias for calling [Builder.email] with `email.orElse(null)`. */ + fun email(email: Optional<String>) = email(email.getOrNull()) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun email(email: JsonField<String>) = apply { this.email = email } + + fun emailConfirmedAt(emailConfirmedAt: OffsetDateTime?) = + emailConfirmedAt(JsonField.ofNullable(emailConfirmedAt)) + + /** Alias for calling [Builder.emailConfirmedAt] with `emailConfirmedAt.orElse(null)`. */ + fun emailConfirmedAt(emailConfirmedAt: Optional<OffsetDateTime>) = + emailConfirmedAt(emailConfirmedAt.getOrNull()) + + /** + * Sets [Builder.emailConfirmedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.emailConfirmedAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun emailConfirmedAt(emailConfirmedAt: JsonField<OffsetDateTime>) = apply { + this.emailConfirmedAt = emailConfirmedAt + } + + fun firstName(firstName: String?) = firstName(JsonField.ofNullable(firstName)) + + /** Alias for calling [Builder.firstName] with `firstName.orElse(null)`. */ + fun firstName(firstName: Optional<String>) = firstName(firstName.getOrNull()) + + /** + * Sets [Builder.firstName] to an arbitrary JSON value. + * + * You should usually call [Builder.firstName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun firstName(firstName: JsonField<String>) = apply { this.firstName = firstName } + + fun fullName(fullName: String?) = fullName(JsonField.ofNullable(fullName)) + + /** Alias for calling [Builder.fullName] with `fullName.orElse(null)`. */ + fun fullName(fullName: Optional<String>) = fullName(fullName.getOrNull()) + + /** + * Sets [Builder.fullName] to an arbitrary JSON value. + * + * You should usually call [Builder.fullName] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun fullName(fullName: JsonField<String>) = apply { this.fullName = fullName } + + fun isDisabled(isDisabled: Boolean?) = isDisabled(JsonField.ofNullable(isDisabled)) + + /** + * Alias for [Builder.isDisabled]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun isDisabled(isDisabled: Boolean) = isDisabled(isDisabled as Boolean?) + + /** Alias for calling [Builder.isDisabled] with `isDisabled.orElse(null)`. */ + fun isDisabled(isDisabled: Optional<Boolean>) = isDisabled(isDisabled.getOrNull()) + + /** + * Sets [Builder.isDisabled] to an arbitrary JSON value. + * + * You should usually call [Builder.isDisabled] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isDisabled(isDisabled: JsonField<Boolean>) = apply { this.isDisabled = isDisabled } + + fun lastName(lastName: String?) = lastName(JsonField.ofNullable(lastName)) + + /** Alias for calling [Builder.lastName] with `lastName.orElse(null)`. */ + fun lastName(lastName: Optional<String>) = lastName(lastName.getOrNull()) + + /** + * Sets [Builder.lastName] to an arbitrary JSON value. + * + * You should usually call [Builder.lastName] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun lastName(lastName: JsonField<String>) = apply { this.lastName = lastName } + + fun provider(provider: Provider?) = provider(JsonField.ofNullable(provider)) + + /** Alias for calling [Builder.provider] with `provider.orElse(null)`. */ + fun provider(provider: Optional<Provider>) = provider(provider.getOrNull()) + + /** + * Sets [Builder.provider] to an arbitrary JSON value. + * + * You should usually call [Builder.provider] with a well-typed [Provider] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun provider(provider: JsonField<Provider>) = apply { this.provider = provider } + + fun providerUserId(providerUserId: String?) = + providerUserId(JsonField.ofNullable(providerUserId)) + + /** Alias for calling [Builder.providerUserId] with `providerUserId.orElse(null)`. */ + fun providerUserId(providerUserId: Optional<String>) = + providerUserId(providerUserId.getOrNull()) + + /** + * Sets [Builder.providerUserId] to an arbitrary JSON value. + * + * You should usually call [Builder.providerUserId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun providerUserId(providerUserId: JsonField<String>) = apply { + this.providerUserId = providerUserId + } + + fun provisioningMethod(provisioningMethod: ProvisioningMethod?) = + provisioningMethod(JsonField.ofNullable(provisioningMethod)) + + /** + * Alias for calling [Builder.provisioningMethod] with `provisioningMethod.orElse(null)`. + */ + fun provisioningMethod(provisioningMethod: Optional<ProvisioningMethod>) = + provisioningMethod(provisioningMethod.getOrNull()) + + /** + * Sets [Builder.provisioningMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.provisioningMethod] with a well-typed + * [ProvisioningMethod] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun provisioningMethod(provisioningMethod: JsonField<ProvisioningMethod>) = apply { + this.provisioningMethod = provisioningMethod + } + + fun samlProviderId(samlProviderId: String?) = + samlProviderId(JsonField.ofNullable(samlProviderId)) + + /** Alias for calling [Builder.samlProviderId] with `samlProviderId.orElse(null)`. */ + fun samlProviderId(samlProviderId: Optional<String>) = + samlProviderId(samlProviderId.getOrNull()) + + /** + * Sets [Builder.samlProviderId] to an arbitrary JSON value. + * + * You should usually call [Builder.samlProviderId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun samlProviderId(samlProviderId: JsonField<String>) = apply { + this.samlProviderId = samlProviderId + } + + fun username(username: String?) = username(JsonField.ofNullable(username)) + + /** Alias for calling [Builder.username] with `username.orElse(null)`. */ + fun username(username: Optional<String>) = username(username.getOrNull()) + + /** + * Sets [Builder.username] to an arbitrary JSON value. + * + * You should usually call [Builder.username] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun username(username: JsonField<String>) = apply { this.username = username } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ProviderUserSlim]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .lsUserId() + * .updatedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ProviderUserSlim = + ProviderUserSlim( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("lsUserId", lsUserId), + checkRequired("updatedAt", updatedAt), + email, + emailConfirmedAt, + firstName, + fullName, + isDisabled, + lastName, + provider, + providerUserId, + provisioningMethod, + samlProviderId, + username, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ProviderUserSlim = apply { + if (validated) { + return@apply + } + + id() + createdAt() + lsUserId() + updatedAt() + email() + emailConfirmedAt() + firstName() + fullName() + isDisabled() + lastName() + provider().ifPresent { it.validate() } + providerUserId() + provisioningMethod().ifPresent { it.validate() } + samlProviderId() + username() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (lsUserId.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (if (email.asKnown().isPresent) 1 else 0) + + (if (emailConfirmedAt.asKnown().isPresent) 1 else 0) + + (if (firstName.asKnown().isPresent) 1 else 0) + + (if (fullName.asKnown().isPresent) 1 else 0) + + (if (isDisabled.asKnown().isPresent) 1 else 0) + + (if (lastName.asKnown().isPresent) 1 else 0) + + (provider.asKnown().getOrNull()?.validity() ?: 0) + + (if (providerUserId.asKnown().isPresent) 1 else 0) + + (provisioningMethod.asKnown().getOrNull()?.validity() ?: 0) + + (if (samlProviderId.asKnown().isPresent) 1 else 0) + + (if (username.asKnown().isPresent) 1 else 0) + + class Provider @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val EMAIL = of("email") + + @JvmField val SUPABASE_NON_SSO = of("supabase:non-sso") + + @JvmField val SUPABASE_SSO = of("supabase:sso") + + @JvmField val OIDC = of("oidc") + + @JvmField val CUSTOM_OIDC = of("custom-oidc") + + @JvmStatic fun of(value: String) = Provider(JsonField.of(value)) + } + + /** An enum containing [Provider]'s known values. */ + enum class Known { + EMAIL, + SUPABASE_NON_SSO, + SUPABASE_SSO, + OIDC, + CUSTOM_OIDC, + } + + /** + * An enum containing [Provider]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Provider] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + EMAIL, + SUPABASE_NON_SSO, + SUPABASE_SSO, + OIDC, + CUSTOM_OIDC, + /** An enum member indicating that [Provider] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + EMAIL -> Value.EMAIL + SUPABASE_NON_SSO -> Value.SUPABASE_NON_SSO + SUPABASE_SSO -> Value.SUPABASE_SSO + OIDC -> Value.OIDC + CUSTOM_OIDC -> Value.CUSTOM_OIDC + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + EMAIL -> Known.EMAIL + SUPABASE_NON_SSO -> Known.SUPABASE_NON_SSO + SUPABASE_SSO -> Known.SUPABASE_SSO + OIDC -> Known.OIDC + CUSTOM_OIDC -> Known.CUSTOM_OIDC + else -> throw LangsmithApiInvalidDataException("Unknown Provider: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Provider = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Provider && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ProvisioningMethod + @JsonCreator + private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val SCIM = of("scim") + + @JvmField val SAML_JIT = of("saml:jit") + + @JvmField val BOOTSTRAP = of("bootstrap") + + @JvmStatic fun of(value: String) = ProvisioningMethod(JsonField.of(value)) + } + + /** An enum containing [ProvisioningMethod]'s known values. */ + enum class Known { + SCIM, + SAML_JIT, + BOOTSTRAP, + } + + /** + * An enum containing [ProvisioningMethod]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ProvisioningMethod] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SCIM, + SAML_JIT, + BOOTSTRAP, + /** + * An enum member indicating that [ProvisioningMethod] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SCIM -> Value.SCIM + SAML_JIT -> Value.SAML_JIT + BOOTSTRAP -> Value.BOOTSTRAP + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SCIM -> Known.SCIM + SAML_JIT -> Known.SAML_JIT + BOOTSTRAP -> Known.BOOTSTRAP + else -> throw LangsmithApiInvalidDataException("Unknown ProvisioningMethod: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ProvisioningMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProvisioningMethod && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProviderUserSlim && + id == other.id && + createdAt == other.createdAt && + lsUserId == other.lsUserId && + updatedAt == other.updatedAt && + email == other.email && + emailConfirmedAt == other.emailConfirmedAt && + firstName == other.firstName && + fullName == other.fullName && + isDisabled == other.isDisabled && + lastName == other.lastName && + provider == other.provider && + providerUserId == other.providerUserId && + provisioningMethod == other.provisioningMethod && + samlProviderId == other.samlProviderId && + username == other.username && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + createdAt, + lsUserId, + updatedAt, + email, + emailConfirmedAt, + firstName, + fullName, + isDisabled, + lastName, + provider, + providerUserId, + provisioningMethod, + samlProviderId, + username, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ProviderUserSlim{id=$id, createdAt=$createdAt, lsUserId=$lsUserId, updatedAt=$updatedAt, email=$email, emailConfirmedAt=$emailConfirmedAt, firstName=$firstName, fullName=$fullName, isDisabled=$isDisabled, lastName=$lastName, provider=$provider, providerUserId=$providerUserId, provisioningMethod=$provisioningMethod, samlProviderId=$samlProviderId, username=$username, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/user/UserRetrieveLoginMethodsParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/user/UserRetrieveLoginMethodsParams.kt new file mode 100644 index 00000000..3897803b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/user/UserRetrieveLoginMethodsParams.kt @@ -0,0 +1,173 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.user + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** Get login methods for the current user. */ +class UserRetrieveLoginMethodsParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): UserRetrieveLoginMethodsParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [UserRetrieveLoginMethodsParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UserRetrieveLoginMethodsParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(userRetrieveLoginMethodsParams: UserRetrieveLoginMethodsParams) = apply { + additionalHeaders = userRetrieveLoginMethodsParams.additionalHeaders.toBuilder() + additionalQueryParams = userRetrieveLoginMethodsParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [UserRetrieveLoginMethodsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UserRetrieveLoginMethodsParams = + UserRetrieveLoginMethodsParams(additionalHeaders.build(), additionalQueryParams.build()) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UserRetrieveLoginMethodsParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "UserRetrieveLoginMethodsParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/members/MemberUpdateBasicParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/members/MemberUpdateBasicParams.kt new file mode 100644 index 00000000..02403cfe --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/members/MemberUpdateBasicParams.kt @@ -0,0 +1,454 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.members + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Update a user's full_name/password (basic auth only) */ +class MemberUpdateBasicParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fullName(): Optional<String> = body.fullName() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun password(): Optional<String> = body.password() + + /** + * Returns the raw JSON value of [fullName]. + * + * Unlike [fullName], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _fullName(): JsonField<String> = body._fullName() + + /** + * Returns the raw JSON value of [password]. + * + * Unlike [password], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _password(): JsonField<String> = body._password() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): MemberUpdateBasicParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [MemberUpdateBasicParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MemberUpdateBasicParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(memberUpdateBasicParams: MemberUpdateBasicParams) = apply { + body = memberUpdateBasicParams.body.toBuilder() + additionalHeaders = memberUpdateBasicParams.additionalHeaders.toBuilder() + additionalQueryParams = memberUpdateBasicParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [fullName] + * - [password] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun fullName(fullName: String?) = apply { body.fullName(fullName) } + + /** Alias for calling [Builder.fullName] with `fullName.orElse(null)`. */ + fun fullName(fullName: Optional<String>) = fullName(fullName.getOrNull()) + + /** + * Sets [Builder.fullName] to an arbitrary JSON value. + * + * You should usually call [Builder.fullName] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun fullName(fullName: JsonField<String>) = apply { body.fullName(fullName) } + + fun password(password: String?) = apply { body.password(password) } + + /** Alias for calling [Builder.password] with `password.orElse(null)`. */ + fun password(password: Optional<String>) = password(password.getOrNull()) + + /** + * Sets [Builder.password] to an arbitrary JSON value. + * + * You should usually call [Builder.password] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun password(password: JsonField<String>) = apply { body.password(password) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [MemberUpdateBasicParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MemberUpdateBasicParams = + MemberUpdateBasicParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val fullName: JsonField<String>, + private val password: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("full_name") + @ExcludeMissing + fullName: JsonField<String> = JsonMissing.of(), + @JsonProperty("password") @ExcludeMissing password: JsonField<String> = JsonMissing.of(), + ) : this(fullName, password, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun fullName(): Optional<String> = fullName.getOptional("full_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun password(): Optional<String> = password.getOptional("password") + + /** + * Returns the raw JSON value of [fullName]. + * + * Unlike [fullName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("full_name") @ExcludeMissing fun _fullName(): JsonField<String> = fullName + + /** + * Returns the raw JSON value of [password]. + * + * Unlike [password], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("password") @ExcludeMissing fun _password(): JsonField<String> = password + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var fullName: JsonField<String> = JsonMissing.of() + private var password: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + fullName = body.fullName + password = body.password + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun fullName(fullName: String?) = fullName(JsonField.ofNullable(fullName)) + + /** Alias for calling [Builder.fullName] with `fullName.orElse(null)`. */ + fun fullName(fullName: Optional<String>) = fullName(fullName.getOrNull()) + + /** + * Sets [Builder.fullName] to an arbitrary JSON value. + * + * You should usually call [Builder.fullName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fullName(fullName: JsonField<String>) = apply { this.fullName = fullName } + + fun password(password: String?) = password(JsonField.ofNullable(password)) + + /** Alias for calling [Builder.password] with `password.orElse(null)`. */ + fun password(password: Optional<String>) = password(password.getOrNull()) + + /** + * Sets [Builder.password] to an arbitrary JSON value. + * + * You should usually call [Builder.password] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun password(password: JsonField<String>) = apply { this.password = password } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = Body(fullName, password, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + fullName() + password() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (fullName.asKnown().isPresent) 1 else 0) + + (if (password.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + fullName == other.fullName && + password == other.password && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(fullName, password, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{fullName=$fullName, password=$password, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MemberUpdateBasicParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "MemberUpdateBasicParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/members/MemberUpdateBasicResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/members/MemberUpdateBasicResponse.kt new file mode 100644 index 00000000..559d2df1 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/members/MemberUpdateBasicResponse.kt @@ -0,0 +1,118 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.members + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class MemberUpdateBasicResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MemberUpdateBasicResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MemberUpdateBasicResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(memberUpdateBasicResponse: MemberUpdateBasicResponse) = apply { + additionalProperties = memberUpdateBasicResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MemberUpdateBasicResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MemberUpdateBasicResponse = + MemberUpdateBasicResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): MemberUpdateBasicResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MemberUpdateBasicResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MemberUpdateBasicResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/Identity.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/Identity.kt new file mode 100644 index 00000000..e1bd9c15 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/Identity.kt @@ -0,0 +1,520 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.pending + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.orgs.current.members.AccessScope +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class Identity +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val lsUserId: JsonField<String>, + private val organizationId: JsonField<String>, + private val readOnly: JsonField<Boolean>, + private val userId: JsonField<String>, + private val accessScope: JsonField<AccessScope>, + private val roleId: JsonField<String>, + private val roleName: JsonField<String>, + private val tenantId: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("ls_user_id") @ExcludeMissing lsUserId: JsonField<String> = JsonMissing.of(), + @JsonProperty("organization_id") + @ExcludeMissing + organizationId: JsonField<String> = JsonMissing.of(), + @JsonProperty("read_only") @ExcludeMissing readOnly: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing userId: JsonField<String> = JsonMissing.of(), + @JsonProperty("access_scope") + @ExcludeMissing + accessScope: JsonField<AccessScope> = JsonMissing.of(), + @JsonProperty("role_id") @ExcludeMissing roleId: JsonField<String> = JsonMissing.of(), + @JsonProperty("role_name") @ExcludeMissing roleName: JsonField<String> = JsonMissing.of(), + @JsonProperty("tenant_id") @ExcludeMissing tenantId: JsonField<String> = JsonMissing.of(), + ) : this( + id, + createdAt, + lsUserId, + organizationId, + readOnly, + userId, + accessScope, + roleId, + roleName, + tenantId, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun lsUserId(): String = lsUserId.getRequired("ls_user_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun organizationId(): String = organizationId.getRequired("organization_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun readOnly(): Boolean = readOnly.getRequired("read_only") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun userId(): String = userId.getRequired("user_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun accessScope(): Optional<AccessScope> = accessScope.getOptional("access_scope") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun roleId(): Optional<String> = roleId.getOptional("role_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun roleName(): Optional<String> = roleName.getOptional("role_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tenantId(): Optional<String> = tenantId.getOptional("tenant_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [lsUserId]. + * + * Unlike [lsUserId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ls_user_id") @ExcludeMissing fun _lsUserId(): JsonField<String> = lsUserId + + /** + * Returns the raw JSON value of [organizationId]. + * + * Unlike [organizationId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("organization_id") + @ExcludeMissing + fun _organizationId(): JsonField<String> = organizationId + + /** + * Returns the raw JSON value of [readOnly]. + * + * Unlike [readOnly], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("read_only") @ExcludeMissing fun _readOnly(): JsonField<Boolean> = readOnly + + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField<String> = userId + + /** + * Returns the raw JSON value of [accessScope]. + * + * Unlike [accessScope], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("access_scope") + @ExcludeMissing + fun _accessScope(): JsonField<AccessScope> = accessScope + + /** + * Returns the raw JSON value of [roleId]. + * + * Unlike [roleId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("role_id") @ExcludeMissing fun _roleId(): JsonField<String> = roleId + + /** + * Returns the raw JSON value of [roleName]. + * + * Unlike [roleName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("role_name") @ExcludeMissing fun _roleName(): JsonField<String> = roleName + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_id") @ExcludeMissing fun _tenantId(): JsonField<String> = tenantId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Identity]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .lsUserId() + * .organizationId() + * .readOnly() + * .userId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Identity]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var createdAt: JsonField<OffsetDateTime>? = null + private var lsUserId: JsonField<String>? = null + private var organizationId: JsonField<String>? = null + private var readOnly: JsonField<Boolean>? = null + private var userId: JsonField<String>? = null + private var accessScope: JsonField<AccessScope> = JsonMissing.of() + private var roleId: JsonField<String> = JsonMissing.of() + private var roleName: JsonField<String> = JsonMissing.of() + private var tenantId: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(identity: Identity) = apply { + id = identity.id + createdAt = identity.createdAt + lsUserId = identity.lsUserId + organizationId = identity.organizationId + readOnly = identity.readOnly + userId = identity.userId + accessScope = identity.accessScope + roleId = identity.roleId + roleName = identity.roleName + tenantId = identity.tenantId + additionalProperties = identity.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun lsUserId(lsUserId: String) = lsUserId(JsonField.of(lsUserId)) + + /** + * Sets [Builder.lsUserId] to an arbitrary JSON value. + * + * You should usually call [Builder.lsUserId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun lsUserId(lsUserId: JsonField<String>) = apply { this.lsUserId = lsUserId } + + fun organizationId(organizationId: String) = organizationId(JsonField.of(organizationId)) + + /** + * Sets [Builder.organizationId] to an arbitrary JSON value. + * + * You should usually call [Builder.organizationId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun organizationId(organizationId: JsonField<String>) = apply { + this.organizationId = organizationId + } + + fun readOnly(readOnly: Boolean) = readOnly(JsonField.of(readOnly)) + + /** + * Sets [Builder.readOnly] to an arbitrary JSON value. + * + * You should usually call [Builder.readOnly] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun readOnly(readOnly: JsonField<Boolean>) = apply { this.readOnly = readOnly } + + fun userId(userId: String) = userId(JsonField.of(userId)) + + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun userId(userId: JsonField<String>) = apply { this.userId = userId } + + fun accessScope(accessScope: AccessScope) = accessScope(JsonField.of(accessScope)) + + /** + * Sets [Builder.accessScope] to an arbitrary JSON value. + * + * You should usually call [Builder.accessScope] with a well-typed [AccessScope] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun accessScope(accessScope: JsonField<AccessScope>) = apply { + this.accessScope = accessScope + } + + fun roleId(roleId: String?) = roleId(JsonField.ofNullable(roleId)) + + /** Alias for calling [Builder.roleId] with `roleId.orElse(null)`. */ + fun roleId(roleId: Optional<String>) = roleId(roleId.getOrNull()) + + /** + * Sets [Builder.roleId] to an arbitrary JSON value. + * + * You should usually call [Builder.roleId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun roleId(roleId: JsonField<String>) = apply { this.roleId = roleId } + + fun roleName(roleName: String?) = roleName(JsonField.ofNullable(roleName)) + + /** Alias for calling [Builder.roleName] with `roleName.orElse(null)`. */ + fun roleName(roleName: Optional<String>) = roleName(roleName.getOrNull()) + + /** + * Sets [Builder.roleName] to an arbitrary JSON value. + * + * You should usually call [Builder.roleName] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun roleName(roleName: JsonField<String>) = apply { this.roleName = roleName } + + fun tenantId(tenantId: String?) = tenantId(JsonField.ofNullable(tenantId)) + + /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ + fun tenantId(tenantId: Optional<String>) = tenantId(tenantId.getOrNull()) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tenantId(tenantId: JsonField<String>) = apply { this.tenantId = tenantId } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Identity]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .lsUserId() + * .organizationId() + * .readOnly() + * .userId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Identity = + Identity( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("lsUserId", lsUserId), + checkRequired("organizationId", organizationId), + checkRequired("readOnly", readOnly), + checkRequired("userId", userId), + accessScope, + roleId, + roleName, + tenantId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Identity = apply { + if (validated) { + return@apply + } + + id() + createdAt() + lsUserId() + organizationId() + readOnly() + userId() + accessScope().ifPresent { it.validate() } + roleId() + roleName() + tenantId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (lsUserId.asKnown().isPresent) 1 else 0) + + (if (organizationId.asKnown().isPresent) 1 else 0) + + (if (readOnly.asKnown().isPresent) 1 else 0) + + (if (userId.asKnown().isPresent) 1 else 0) + + (accessScope.asKnown().getOrNull()?.validity() ?: 0) + + (if (roleId.asKnown().isPresent) 1 else 0) + + (if (roleName.asKnown().isPresent) 1 else 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Identity && + id == other.id && + createdAt == other.createdAt && + lsUserId == other.lsUserId && + organizationId == other.organizationId && + readOnly == other.readOnly && + userId == other.userId && + accessScope == other.accessScope && + roleId == other.roleId && + roleName == other.roleName && + tenantId == other.tenantId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + createdAt, + lsUserId, + organizationId, + readOnly, + userId, + accessScope, + roleId, + roleName, + tenantId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Identity{id=$id, createdAt=$createdAt, lsUserId=$lsUserId, organizationId=$organizationId, readOnly=$readOnly, userId=$userId, accessScope=$accessScope, roleId=$roleId, roleName=$roleName, tenantId=$tenantId, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/PendingClaimParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/PendingClaimParams.kt new file mode 100644 index 00000000..a7aba05c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/PendingClaimParams.kt @@ -0,0 +1,235 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.pending + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Claim Pending Organization Invite */ +class PendingClaimParams +private constructor( + private val organizationId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun organizationId(): Optional<String> = Optional.ofNullable(organizationId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): PendingClaimParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [PendingClaimParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PendingClaimParams]. */ + class Builder internal constructor() { + + private var organizationId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(pendingClaimParams: PendingClaimParams) = apply { + organizationId = pendingClaimParams.organizationId + additionalHeaders = pendingClaimParams.additionalHeaders.toBuilder() + additionalQueryParams = pendingClaimParams.additionalQueryParams.toBuilder() + additionalBodyProperties = pendingClaimParams.additionalBodyProperties.toMutableMap() + } + + fun organizationId(organizationId: String?) = apply { this.organizationId = organizationId } + + /** Alias for calling [Builder.organizationId] with `organizationId.orElse(null)`. */ + fun organizationId(organizationId: Optional<String>) = + organizationId(organizationId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [PendingClaimParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PendingClaimParams = + PendingClaimParams( + organizationId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> organizationId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PendingClaimParams && + organizationId == other.organizationId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + organizationId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "PendingClaimParams{organizationId=$organizationId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/PendingDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/PendingDeleteParams.kt new file mode 100644 index 00000000..29bef32e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/PendingDeleteParams.kt @@ -0,0 +1,235 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.pending + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete Pending Organization Invite */ +class PendingDeleteParams +private constructor( + private val organizationId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun organizationId(): Optional<String> = Optional.ofNullable(organizationId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): PendingDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [PendingDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PendingDeleteParams]. */ + class Builder internal constructor() { + + private var organizationId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(pendingDeleteParams: PendingDeleteParams) = apply { + organizationId = pendingDeleteParams.organizationId + additionalHeaders = pendingDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = pendingDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = pendingDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun organizationId(organizationId: String?) = apply { this.organizationId = organizationId } + + /** Alias for calling [Builder.organizationId] with `organizationId.orElse(null)`. */ + fun organizationId(organizationId: Optional<String>) = + organizationId(organizationId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [PendingDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PendingDeleteParams = + PendingDeleteParams( + organizationId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> organizationId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PendingDeleteParams && + organizationId == other.organizationId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + organizationId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "PendingDeleteParams{organizationId=$organizationId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/PendingDeleteResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/PendingDeleteResponse.kt new file mode 100644 index 00000000..f1e9b2d4 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/PendingDeleteResponse.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.pending + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class PendingDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [PendingDeleteResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PendingDeleteResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(pendingDeleteResponse: PendingDeleteResponse) = apply { + additionalProperties = pendingDeleteResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PendingDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PendingDeleteResponse = + PendingDeleteResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): PendingDeleteResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PendingDeleteResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "PendingDeleteResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/PendingListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/PendingListParams.kt new file mode 100644 index 00000000..e5af7ab6 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/PendingListParams.kt @@ -0,0 +1,170 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.pending + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** Get all pending orgs visible to this auth */ +class PendingListParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): PendingListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [PendingListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PendingListParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(pendingListParams: PendingListParams) = apply { + additionalHeaders = pendingListParams.additionalHeaders.toBuilder() + additionalQueryParams = pendingListParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [PendingListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PendingListParams = + PendingListParams(additionalHeaders.build(), additionalQueryParams.build()) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PendingListParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "PendingListParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/ttlsettings/TraceTier.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/ttlsettings/TraceTier.kt new file mode 100644 index 00000000..2ad14a6e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/ttlsettings/TraceTier.kt @@ -0,0 +1,133 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.ttlsettings + +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException + +class TraceTier @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't match + * any known member, and you want to know that value. For example, if the SDK is on an older + * version than the API, then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val LONGLIVED = of("longlived") + + @JvmField val SHORTLIVED = of("shortlived") + + @JvmStatic fun of(value: String) = TraceTier(JsonField.of(value)) + } + + /** An enum containing [TraceTier]'s known values. */ + enum class Known { + LONGLIVED, + SHORTLIVED, + } + + /** + * An enum containing [TraceTier]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TraceTier] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the SDK + * is on an older version than the API, then the API may respond with new members that the SDK + * is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LONGLIVED, + SHORTLIVED, + /** An enum member indicating that [TraceTier] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if + * the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want to + * throw for the unknown case. + */ + fun value(): Value = + when (this) { + LONGLIVED -> Value.LONGLIVED + SHORTLIVED -> Value.SHORTLIVED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't want + * to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + LONGLIVED -> Known.LONGLIVED + SHORTLIVED -> Known.SHORTLIVED + else -> throw LangsmithApiInvalidDataException("Unknown TraceTier: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TraceTier = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TraceTier && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/ttlsettings/TtlSettingRetrieveTtlSettingsParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/ttlsettings/TtlSettingRetrieveTtlSettingsParams.kt new file mode 100644 index 00000000..3fd5c7d9 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/ttlsettings/TtlSettingRetrieveTtlSettingsParams.kt @@ -0,0 +1,179 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.ttlsettings + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** List out the configured TTL settings for a given org (org-level and tenant-level). */ +class TtlSettingRetrieveTtlSettingsParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): TtlSettingRetrieveTtlSettingsParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [TtlSettingRetrieveTtlSettingsParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TtlSettingRetrieveTtlSettingsParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + ttlSettingRetrieveTtlSettingsParams: TtlSettingRetrieveTtlSettingsParams + ) = apply { + additionalHeaders = ttlSettingRetrieveTtlSettingsParams.additionalHeaders.toBuilder() + additionalQueryParams = + ttlSettingRetrieveTtlSettingsParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TtlSettingRetrieveTtlSettingsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TtlSettingRetrieveTtlSettingsParams = + TtlSettingRetrieveTtlSettingsParams( + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TtlSettingRetrieveTtlSettingsParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "TtlSettingRetrieveTtlSettingsParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/ttlsettings/TtlSettingUpdateTtlSettingsParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/ttlsettings/TtlSettingUpdateTtlSettingsParams.kt new file mode 100644 index 00000000..ea060773 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/ttlsettings/TtlSettingUpdateTtlSettingsParams.kt @@ -0,0 +1,210 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.ttlsettings + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** Upsert Ttl Settings */ +class TtlSettingUpdateTtlSettingsParams +private constructor( + private val upsertTtlSettingsRequest: UpsertTtlSettingsRequest, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Base TTL settings model. */ + fun upsertTtlSettingsRequest(): UpsertTtlSettingsRequest = upsertTtlSettingsRequest + + fun _additionalBodyProperties(): Map<String, JsonValue> = + upsertTtlSettingsRequest._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TtlSettingUpdateTtlSettingsParams]. + * + * The following fields are required: + * ```java + * .upsertTtlSettingsRequest() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TtlSettingUpdateTtlSettingsParams]. */ + class Builder internal constructor() { + + private var upsertTtlSettingsRequest: UpsertTtlSettingsRequest? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(ttlSettingUpdateTtlSettingsParams: TtlSettingUpdateTtlSettingsParams) = + apply { + upsertTtlSettingsRequest = + ttlSettingUpdateTtlSettingsParams.upsertTtlSettingsRequest + additionalHeaders = ttlSettingUpdateTtlSettingsParams.additionalHeaders.toBuilder() + additionalQueryParams = + ttlSettingUpdateTtlSettingsParams.additionalQueryParams.toBuilder() + } + + /** Base TTL settings model. */ + fun upsertTtlSettingsRequest(upsertTtlSettingsRequest: UpsertTtlSettingsRequest) = apply { + this.upsertTtlSettingsRequest = upsertTtlSettingsRequest + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TtlSettingUpdateTtlSettingsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .upsertTtlSettingsRequest() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TtlSettingUpdateTtlSettingsParams = + TtlSettingUpdateTtlSettingsParams( + checkRequired("upsertTtlSettingsRequest", upsertTtlSettingsRequest), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): UpsertTtlSettingsRequest = upsertTtlSettingsRequest + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TtlSettingUpdateTtlSettingsParams && + upsertTtlSettingsRequest == other.upsertTtlSettingsRequest && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(upsertTtlSettingsRequest, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TtlSettingUpdateTtlSettingsParams{upsertTtlSettingsRequest=$upsertTtlSettingsRequest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/ttlsettings/TtlSettings.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/ttlsettings/TtlSettings.kt new file mode 100644 index 00000000..d37fbc90 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/ttlsettings/TtlSettings.kt @@ -0,0 +1,602 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.ttlsettings + +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.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** TTL settings model. */ +class TtlSettings +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val configuredBy: JsonField<ConfiguredBy>, + private val createdAt: JsonField<OffsetDateTime>, + private val defaultTraceTier: JsonField<TraceTier>, + private val organizationId: JsonField<String>, + private val updatedAt: JsonField<OffsetDateTime>, + private val applyToAllProjects: JsonField<Boolean>, + private val tenantId: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("configured_by") + @ExcludeMissing + configuredBy: JsonField<ConfiguredBy> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("default_trace_tier") + @ExcludeMissing + defaultTraceTier: JsonField<TraceTier> = JsonMissing.of(), + @JsonProperty("organization_id") + @ExcludeMissing + organizationId: JsonField<String> = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("apply_to_all_projects") + @ExcludeMissing + applyToAllProjects: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("tenant_id") @ExcludeMissing tenantId: JsonField<String> = JsonMissing.of(), + ) : this( + id, + configuredBy, + createdAt, + defaultTraceTier, + organizationId, + updatedAt, + applyToAllProjects, + tenantId, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun configuredBy(): ConfiguredBy = configuredBy.getRequired("configured_by") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun defaultTraceTier(): TraceTier = defaultTraceTier.getRequired("default_trace_tier") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun organizationId(): String = organizationId.getRequired("organization_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updatedAt(): OffsetDateTime = updatedAt.getRequired("updated_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun applyToAllProjects(): Optional<Boolean> = + applyToAllProjects.getOptional("apply_to_all_projects") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tenantId(): Optional<String> = tenantId.getOptional("tenant_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [configuredBy]. + * + * Unlike [configuredBy], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("configured_by") + @ExcludeMissing + fun _configuredBy(): JsonField<ConfiguredBy> = configuredBy + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [defaultTraceTier]. + * + * Unlike [defaultTraceTier], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("default_trace_tier") + @ExcludeMissing + fun _defaultTraceTier(): JsonField<TraceTier> = defaultTraceTier + + /** + * Returns the raw JSON value of [organizationId]. + * + * Unlike [organizationId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("organization_id") + @ExcludeMissing + fun _organizationId(): JsonField<String> = organizationId + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField<OffsetDateTime> = updatedAt + + /** + * Returns the raw JSON value of [applyToAllProjects]. + * + * Unlike [applyToAllProjects], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("apply_to_all_projects") + @ExcludeMissing + fun _applyToAllProjects(): JsonField<Boolean> = applyToAllProjects + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_id") @ExcludeMissing fun _tenantId(): JsonField<String> = tenantId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TtlSettings]. + * + * The following fields are required: + * ```java + * .id() + * .configuredBy() + * .createdAt() + * .defaultTraceTier() + * .organizationId() + * .updatedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TtlSettings]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var configuredBy: JsonField<ConfiguredBy>? = null + private var createdAt: JsonField<OffsetDateTime>? = null + private var defaultTraceTier: JsonField<TraceTier>? = null + private var organizationId: JsonField<String>? = null + private var updatedAt: JsonField<OffsetDateTime>? = null + private var applyToAllProjects: JsonField<Boolean> = JsonMissing.of() + private var tenantId: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(ttlSettings: TtlSettings) = apply { + id = ttlSettings.id + configuredBy = ttlSettings.configuredBy + createdAt = ttlSettings.createdAt + defaultTraceTier = ttlSettings.defaultTraceTier + organizationId = ttlSettings.organizationId + updatedAt = ttlSettings.updatedAt + applyToAllProjects = ttlSettings.applyToAllProjects + tenantId = ttlSettings.tenantId + additionalProperties = ttlSettings.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun configuredBy(configuredBy: ConfiguredBy) = configuredBy(JsonField.of(configuredBy)) + + /** + * Sets [Builder.configuredBy] to an arbitrary JSON value. + * + * You should usually call [Builder.configuredBy] with a well-typed [ConfiguredBy] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun configuredBy(configuredBy: JsonField<ConfiguredBy>) = apply { + this.configuredBy = configuredBy + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun defaultTraceTier(defaultTraceTier: TraceTier) = + defaultTraceTier(JsonField.of(defaultTraceTier)) + + /** + * Sets [Builder.defaultTraceTier] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultTraceTier] with a well-typed [TraceTier] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun defaultTraceTier(defaultTraceTier: JsonField<TraceTier>) = apply { + this.defaultTraceTier = defaultTraceTier + } + + fun organizationId(organizationId: String) = organizationId(JsonField.of(organizationId)) + + /** + * Sets [Builder.organizationId] to an arbitrary JSON value. + * + * You should usually call [Builder.organizationId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun organizationId(organizationId: JsonField<String>) = apply { + this.organizationId = organizationId + } + + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField<OffsetDateTime>) = apply { this.updatedAt = updatedAt } + + fun applyToAllProjects(applyToAllProjects: Boolean) = + applyToAllProjects(JsonField.of(applyToAllProjects)) + + /** + * Sets [Builder.applyToAllProjects] to an arbitrary JSON value. + * + * You should usually call [Builder.applyToAllProjects] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun applyToAllProjects(applyToAllProjects: JsonField<Boolean>) = apply { + this.applyToAllProjects = applyToAllProjects + } + + fun tenantId(tenantId: String?) = tenantId(JsonField.ofNullable(tenantId)) + + /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ + fun tenantId(tenantId: Optional<String>) = tenantId(tenantId.getOrNull()) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tenantId(tenantId: JsonField<String>) = apply { this.tenantId = tenantId } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TtlSettings]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .configuredBy() + * .createdAt() + * .defaultTraceTier() + * .organizationId() + * .updatedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TtlSettings = + TtlSettings( + checkRequired("id", id), + checkRequired("configuredBy", configuredBy), + checkRequired("createdAt", createdAt), + checkRequired("defaultTraceTier", defaultTraceTier), + checkRequired("organizationId", organizationId), + checkRequired("updatedAt", updatedAt), + applyToAllProjects, + tenantId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TtlSettings = apply { + if (validated) { + return@apply + } + + id() + configuredBy().validate() + createdAt() + defaultTraceTier().validate() + organizationId() + updatedAt() + applyToAllProjects() + tenantId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (configuredBy.asKnown().getOrNull()?.validity() ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (defaultTraceTier.asKnown().getOrNull()?.validity() ?: 0) + + (if (organizationId.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (if (applyToAllProjects.asKnown().isPresent) 1 else 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + class ConfiguredBy @JsonCreator private constructor(private val value: JsonField<String>) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val SYSTEM = of("system") + + @JvmField val USER = of("user") + + @JvmStatic fun of(value: String) = ConfiguredBy(JsonField.of(value)) + } + + /** An enum containing [ConfiguredBy]'s known values. */ + enum class Known { + SYSTEM, + USER, + } + + /** + * An enum containing [ConfiguredBy]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ConfiguredBy] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SYSTEM, + USER, + /** + * An enum member indicating that [ConfiguredBy] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SYSTEM -> Value.SYSTEM + USER -> Value.USER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SYSTEM -> Known.SYSTEM + USER -> Known.USER + else -> throw LangsmithApiInvalidDataException("Unknown ConfiguredBy: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ConfiguredBy = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConfiguredBy && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TtlSettings && + id == other.id && + configuredBy == other.configuredBy && + createdAt == other.createdAt && + defaultTraceTier == other.defaultTraceTier && + organizationId == other.organizationId && + updatedAt == other.updatedAt && + applyToAllProjects == other.applyToAllProjects && + tenantId == other.tenantId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + configuredBy, + createdAt, + defaultTraceTier, + organizationId, + updatedAt, + applyToAllProjects, + tenantId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TtlSettings{id=$id, configuredBy=$configuredBy, createdAt=$createdAt, defaultTraceTier=$defaultTraceTier, organizationId=$organizationId, updatedAt=$updatedAt, applyToAllProjects=$applyToAllProjects, tenantId=$tenantId, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/ttlsettings/UpsertTtlSettingsRequest.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/ttlsettings/UpsertTtlSettingsRequest.kt new file mode 100644 index 00000000..00ae403d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/orgs/ttlsettings/UpsertTtlSettingsRequest.kt @@ -0,0 +1,261 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.ttlsettings + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Base TTL settings model. */ +class UpsertTtlSettingsRequest +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val defaultTraceTier: JsonField<TraceTier>, + private val applyToAllProjects: JsonField<Boolean>, + private val tenantId: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("default_trace_tier") + @ExcludeMissing + defaultTraceTier: JsonField<TraceTier> = JsonMissing.of(), + @JsonProperty("apply_to_all_projects") + @ExcludeMissing + applyToAllProjects: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("tenant_id") @ExcludeMissing tenantId: JsonField<String> = JsonMissing.of(), + ) : this(defaultTraceTier, applyToAllProjects, tenantId, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun defaultTraceTier(): TraceTier = defaultTraceTier.getRequired("default_trace_tier") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun applyToAllProjects(): Optional<Boolean> = + applyToAllProjects.getOptional("apply_to_all_projects") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tenantId(): Optional<String> = tenantId.getOptional("tenant_id") + + /** + * Returns the raw JSON value of [defaultTraceTier]. + * + * Unlike [defaultTraceTier], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("default_trace_tier") + @ExcludeMissing + fun _defaultTraceTier(): JsonField<TraceTier> = defaultTraceTier + + /** + * Returns the raw JSON value of [applyToAllProjects]. + * + * Unlike [applyToAllProjects], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("apply_to_all_projects") + @ExcludeMissing + fun _applyToAllProjects(): JsonField<Boolean> = applyToAllProjects + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_id") @ExcludeMissing fun _tenantId(): JsonField<String> = tenantId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UpsertTtlSettingsRequest]. + * + * The following fields are required: + * ```java + * .defaultTraceTier() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UpsertTtlSettingsRequest]. */ + class Builder internal constructor() { + + private var defaultTraceTier: JsonField<TraceTier>? = null + private var applyToAllProjects: JsonField<Boolean> = JsonMissing.of() + private var tenantId: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(upsertTtlSettingsRequest: UpsertTtlSettingsRequest) = apply { + defaultTraceTier = upsertTtlSettingsRequest.defaultTraceTier + applyToAllProjects = upsertTtlSettingsRequest.applyToAllProjects + tenantId = upsertTtlSettingsRequest.tenantId + additionalProperties = upsertTtlSettingsRequest.additionalProperties.toMutableMap() + } + + fun defaultTraceTier(defaultTraceTier: TraceTier) = + defaultTraceTier(JsonField.of(defaultTraceTier)) + + /** + * Sets [Builder.defaultTraceTier] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultTraceTier] with a well-typed [TraceTier] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun defaultTraceTier(defaultTraceTier: JsonField<TraceTier>) = apply { + this.defaultTraceTier = defaultTraceTier + } + + fun applyToAllProjects(applyToAllProjects: Boolean) = + applyToAllProjects(JsonField.of(applyToAllProjects)) + + /** + * Sets [Builder.applyToAllProjects] to an arbitrary JSON value. + * + * You should usually call [Builder.applyToAllProjects] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun applyToAllProjects(applyToAllProjects: JsonField<Boolean>) = apply { + this.applyToAllProjects = applyToAllProjects + } + + fun tenantId(tenantId: String?) = tenantId(JsonField.ofNullable(tenantId)) + + /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ + fun tenantId(tenantId: Optional<String>) = tenantId(tenantId.getOrNull()) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tenantId(tenantId: JsonField<String>) = apply { this.tenantId = tenantId } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UpsertTtlSettingsRequest]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .defaultTraceTier() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UpsertTtlSettingsRequest = + UpsertTtlSettingsRequest( + checkRequired("defaultTraceTier", defaultTraceTier), + applyToAllProjects, + tenantId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UpsertTtlSettingsRequest = apply { + if (validated) { + return@apply + } + + defaultTraceTier().validate() + applyToAllProjects() + tenantId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (defaultTraceTier.asKnown().getOrNull()?.validity() ?: 0) + + (if (applyToAllProjects.asKnown().isPresent) 1 else 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UpsertTtlSettingsRequest && + defaultTraceTier == other.defaultTraceTier && + applyToAllProjects == other.applyToAllProjects && + tenantId == other.tenantId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(defaultTraceTier, applyToAllProjects, tenantId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UpsertTtlSettingsRequest{defaultTraceTier=$defaultTraceTier, applyToAllProjects=$applyToAllProjects, tenantId=$tenantId, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSavedOptions.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSavedOptions.kt new file mode 100644 index 00000000..b7f0ba74 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSavedOptions.kt @@ -0,0 +1,176 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.playgroundsettings + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class PlaygroundSavedOptions +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val requestsPerSecond: JsonField<Long>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("requests_per_second") + @ExcludeMissing + requestsPerSecond: JsonField<Long> = JsonMissing.of() + ) : this(requestsPerSecond, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun requestsPerSecond(): Optional<Long> = requestsPerSecond.getOptional("requests_per_second") + + /** + * Returns the raw JSON value of [requestsPerSecond]. + * + * Unlike [requestsPerSecond], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("requests_per_second") + @ExcludeMissing + fun _requestsPerSecond(): JsonField<Long> = requestsPerSecond + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [PlaygroundSavedOptions]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PlaygroundSavedOptions]. */ + class Builder internal constructor() { + + private var requestsPerSecond: JsonField<Long> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(playgroundSavedOptions: PlaygroundSavedOptions) = apply { + requestsPerSecond = playgroundSavedOptions.requestsPerSecond + additionalProperties = playgroundSavedOptions.additionalProperties.toMutableMap() + } + + fun requestsPerSecond(requestsPerSecond: Long?) = + requestsPerSecond(JsonField.ofNullable(requestsPerSecond)) + + /** + * Alias for [Builder.requestsPerSecond]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun requestsPerSecond(requestsPerSecond: Long) = + requestsPerSecond(requestsPerSecond as Long?) + + /** Alias for calling [Builder.requestsPerSecond] with `requestsPerSecond.orElse(null)`. */ + fun requestsPerSecond(requestsPerSecond: Optional<Long>) = + requestsPerSecond(requestsPerSecond.getOrNull()) + + /** + * Sets [Builder.requestsPerSecond] to an arbitrary JSON value. + * + * You should usually call [Builder.requestsPerSecond] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun requestsPerSecond(requestsPerSecond: JsonField<Long>) = apply { + this.requestsPerSecond = requestsPerSecond + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PlaygroundSavedOptions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PlaygroundSavedOptions = + PlaygroundSavedOptions(requestsPerSecond, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): PlaygroundSavedOptions = apply { + if (validated) { + return@apply + } + + requestsPerSecond() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (requestsPerSecond.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PlaygroundSavedOptions && + requestsPerSecond == other.requestsPerSecond && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(requestsPerSecond, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PlaygroundSavedOptions{requestsPerSecond=$requestsPerSecond, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingDeleteParams.kt new file mode 100644 index 00000000..652c647e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingDeleteParams.kt @@ -0,0 +1,244 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.playgroundsettings + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete playground settings. */ +class PlaygroundSettingDeleteParams +private constructor( + private val playgroundSettingsId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun playgroundSettingsId(): Optional<String> = Optional.ofNullable(playgroundSettingsId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): PlaygroundSettingDeleteParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [PlaygroundSettingDeleteParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PlaygroundSettingDeleteParams]. */ + class Builder internal constructor() { + + private var playgroundSettingsId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(playgroundSettingDeleteParams: PlaygroundSettingDeleteParams) = apply { + playgroundSettingsId = playgroundSettingDeleteParams.playgroundSettingsId + additionalHeaders = playgroundSettingDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = playgroundSettingDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + playgroundSettingDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun playgroundSettingsId(playgroundSettingsId: String?) = apply { + this.playgroundSettingsId = playgroundSettingsId + } + + /** + * Alias for calling [Builder.playgroundSettingsId] with + * `playgroundSettingsId.orElse(null)`. + */ + fun playgroundSettingsId(playgroundSettingsId: Optional<String>) = + playgroundSettingsId(playgroundSettingsId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [PlaygroundSettingDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PlaygroundSettingDeleteParams = + PlaygroundSettingDeleteParams( + playgroundSettingsId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> playgroundSettingsId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PlaygroundSettingDeleteParams && + playgroundSettingsId == other.playgroundSettingsId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + playgroundSettingsId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "PlaygroundSettingDeleteParams{playgroundSettingsId=$playgroundSettingsId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingDeleteResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingDeleteResponse.kt new file mode 100644 index 00000000..d167a3e5 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingDeleteResponse.kt @@ -0,0 +1,121 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.playgroundsettings + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class PlaygroundSettingDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PlaygroundSettingDeleteResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PlaygroundSettingDeleteResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(playgroundSettingDeleteResponse: PlaygroundSettingDeleteResponse) = + apply { + additionalProperties = + playgroundSettingDeleteResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PlaygroundSettingDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PlaygroundSettingDeleteResponse = + PlaygroundSettingDeleteResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): PlaygroundSettingDeleteResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PlaygroundSettingDeleteResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PlaygroundSettingDeleteResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingPlaygroundSettingsParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingPlaygroundSettingsParams.kt new file mode 100644 index 00000000..6444d356 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingPlaygroundSettingsParams.kt @@ -0,0 +1,582 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.playgroundsettings + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create playground settings. */ +class PlaygroundSettingPlaygroundSettingsParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun _settings(): JsonValue = body._settings() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = body.description() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional<String> = body.name() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun options(): Optional<PlaygroundSavedOptions> = body.options() + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _description(): JsonField<String> = body._description() + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _name(): JsonField<String> = body._name() + + /** + * Returns the raw JSON value of [options]. + * + * Unlike [options], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _options(): JsonField<PlaygroundSavedOptions> = body._options() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PlaygroundSettingPlaygroundSettingsParams]. + * + * The following fields are required: + * ```java + * .settings() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PlaygroundSettingPlaygroundSettingsParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + playgroundSettingPlaygroundSettingsParams: PlaygroundSettingPlaygroundSettingsParams + ) = apply { + body = playgroundSettingPlaygroundSettingsParams.body.toBuilder() + additionalHeaders = + playgroundSettingPlaygroundSettingsParams.additionalHeaders.toBuilder() + additionalQueryParams = + playgroundSettingPlaygroundSettingsParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [settings] + * - [description] + * - [name] + * - [options] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun settings(settings: JsonValue) = apply { body.settings(settings) } + + fun description(description: String?) = apply { body.description(description) } + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { body.description(description) } + + fun name(name: String?) = apply { body.name(name) } + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional<String>) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { body.name(name) } + + fun options(options: PlaygroundSavedOptions?) = apply { body.options(options) } + + /** Alias for calling [Builder.options] with `options.orElse(null)`. */ + fun options(options: Optional<PlaygroundSavedOptions>) = options(options.getOrNull()) + + /** + * Sets [Builder.options] to an arbitrary JSON value. + * + * You should usually call [Builder.options] with a well-typed [PlaygroundSavedOptions] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun options(options: JsonField<PlaygroundSavedOptions>) = apply { body.options(options) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [PlaygroundSettingPlaygroundSettingsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .settings() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PlaygroundSettingPlaygroundSettingsParams = + PlaygroundSettingPlaygroundSettingsParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val settings: JsonValue, + private val description: JsonField<String>, + private val name: JsonField<String>, + private val options: JsonField<PlaygroundSavedOptions>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("settings") @ExcludeMissing settings: JsonValue = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("options") + @ExcludeMissing + options: JsonField<PlaygroundSavedOptions> = JsonMissing.of(), + ) : this(settings, description, name, options, mutableMapOf()) + + @JsonProperty("settings") @ExcludeMissing fun _settings(): JsonValue = settings + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun name(): Optional<String> = name.getOptional("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun options(): Optional<PlaygroundSavedOptions> = options.getOptional("options") + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [options]. + * + * Unlike [options], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("options") + @ExcludeMissing + fun _options(): JsonField<PlaygroundSavedOptions> = options + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .settings() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var settings: JsonValue? = null + private var description: JsonField<String> = JsonMissing.of() + private var name: JsonField<String> = JsonMissing.of() + private var options: JsonField<PlaygroundSavedOptions> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + settings = body.settings + description = body.description + name = body.name + options = body.options + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun settings(settings: JsonValue) = apply { this.settings = settings } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField<String>) = apply { + this.description = description + } + + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional<String>) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun options(options: PlaygroundSavedOptions?) = options(JsonField.ofNullable(options)) + + /** Alias for calling [Builder.options] with `options.orElse(null)`. */ + fun options(options: Optional<PlaygroundSavedOptions>) = options(options.getOrNull()) + + /** + * Sets [Builder.options] to an arbitrary JSON value. + * + * You should usually call [Builder.options] with a well-typed [PlaygroundSavedOptions] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun options(options: JsonField<PlaygroundSavedOptions>) = apply { + this.options = options + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .settings() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("settings", settings), + description, + name, + options, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + description() + name() + options().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (description.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (options.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + settings == other.settings && + description == other.description && + name == other.name && + options == other.options && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(settings, description, name, options, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{settings=$settings, description=$description, name=$name, options=$options, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PlaygroundSettingPlaygroundSettingsParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "PlaygroundSettingPlaygroundSettingsParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingRetrievePlaygroundSettingsParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingRetrievePlaygroundSettingsParams.kt new file mode 100644 index 00000000..d624830d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingRetrievePlaygroundSettingsParams.kt @@ -0,0 +1,181 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.playgroundsettings + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** Get all playground settings for this tenant id. */ +class PlaygroundSettingRetrievePlaygroundSettingsParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): PlaygroundSettingRetrievePlaygroundSettingsParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [PlaygroundSettingRetrievePlaygroundSettingsParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PlaygroundSettingRetrievePlaygroundSettingsParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + playgroundSettingRetrievePlaygroundSettingsParams: + PlaygroundSettingRetrievePlaygroundSettingsParams + ) = apply { + additionalHeaders = + playgroundSettingRetrievePlaygroundSettingsParams.additionalHeaders.toBuilder() + additionalQueryParams = + playgroundSettingRetrievePlaygroundSettingsParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [PlaygroundSettingRetrievePlaygroundSettingsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PlaygroundSettingRetrievePlaygroundSettingsParams = + PlaygroundSettingRetrievePlaygroundSettingsParams( + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PlaygroundSettingRetrievePlaygroundSettingsParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "PlaygroundSettingRetrievePlaygroundSettingsParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingUpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingUpdateParams.kt new file mode 100644 index 00000000..8b39a1a4 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingUpdateParams.kt @@ -0,0 +1,572 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.playgroundsettings + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Update playground settings. */ +class PlaygroundSettingUpdateParams +private constructor( + private val playgroundSettingsId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun playgroundSettingsId(): Optional<String> = Optional.ofNullable(playgroundSettingsId) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = body.description() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional<String> = body.name() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun options(): Optional<PlaygroundSavedOptions> = body.options() + + fun _settings(): JsonValue = body._settings() + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _description(): JsonField<String> = body._description() + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _name(): JsonField<String> = body._name() + + /** + * Returns the raw JSON value of [options]. + * + * Unlike [options], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _options(): JsonField<PlaygroundSavedOptions> = body._options() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): PlaygroundSettingUpdateParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [PlaygroundSettingUpdateParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PlaygroundSettingUpdateParams]. */ + class Builder internal constructor() { + + private var playgroundSettingsId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(playgroundSettingUpdateParams: PlaygroundSettingUpdateParams) = apply { + playgroundSettingsId = playgroundSettingUpdateParams.playgroundSettingsId + body = playgroundSettingUpdateParams.body.toBuilder() + additionalHeaders = playgroundSettingUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = playgroundSettingUpdateParams.additionalQueryParams.toBuilder() + } + + fun playgroundSettingsId(playgroundSettingsId: String?) = apply { + this.playgroundSettingsId = playgroundSettingsId + } + + /** + * Alias for calling [Builder.playgroundSettingsId] with + * `playgroundSettingsId.orElse(null)`. + */ + fun playgroundSettingsId(playgroundSettingsId: Optional<String>) = + playgroundSettingsId(playgroundSettingsId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [description] + * - [name] + * - [options] + * - [settings] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun description(description: String?) = apply { body.description(description) } + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { body.description(description) } + + fun name(name: String?) = apply { body.name(name) } + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional<String>) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { body.name(name) } + + fun options(options: PlaygroundSavedOptions?) = apply { body.options(options) } + + /** Alias for calling [Builder.options] with `options.orElse(null)`. */ + fun options(options: Optional<PlaygroundSavedOptions>) = options(options.getOrNull()) + + /** + * Sets [Builder.options] to an arbitrary JSON value. + * + * You should usually call [Builder.options] with a well-typed [PlaygroundSavedOptions] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun options(options: JsonField<PlaygroundSavedOptions>) = apply { body.options(options) } + + fun settings(settings: JsonValue) = apply { body.settings(settings) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [PlaygroundSettingUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PlaygroundSettingUpdateParams = + PlaygroundSettingUpdateParams( + playgroundSettingsId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> playgroundSettingsId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val description: JsonField<String>, + private val name: JsonField<String>, + private val options: JsonField<PlaygroundSavedOptions>, + private val settings: JsonValue, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("options") + @ExcludeMissing + options: JsonField<PlaygroundSavedOptions> = JsonMissing.of(), + @JsonProperty("settings") @ExcludeMissing settings: JsonValue = JsonMissing.of(), + ) : this(description, name, options, settings, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun name(): Optional<String> = name.getOptional("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun options(): Optional<PlaygroundSavedOptions> = options.getOptional("options") + + @JsonProperty("settings") @ExcludeMissing fun _settings(): JsonValue = settings + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [options]. + * + * Unlike [options], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("options") + @ExcludeMissing + fun _options(): JsonField<PlaygroundSavedOptions> = options + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var description: JsonField<String> = JsonMissing.of() + private var name: JsonField<String> = JsonMissing.of() + private var options: JsonField<PlaygroundSavedOptions> = JsonMissing.of() + private var settings: JsonValue = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + description = body.description + name = body.name + options = body.options + settings = body.settings + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField<String>) = apply { + this.description = description + } + + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional<String>) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun options(options: PlaygroundSavedOptions?) = options(JsonField.ofNullable(options)) + + /** Alias for calling [Builder.options] with `options.orElse(null)`. */ + fun options(options: Optional<PlaygroundSavedOptions>) = options(options.getOrNull()) + + /** + * Sets [Builder.options] to an arbitrary JSON value. + * + * You should usually call [Builder.options] with a well-typed [PlaygroundSavedOptions] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun options(options: JsonField<PlaygroundSavedOptions>) = apply { + this.options = options + } + + fun settings(settings: JsonValue) = apply { this.settings = settings } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = + Body(description, name, options, settings, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + description() + name() + options().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (description.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (options.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + description == other.description && + name == other.name && + options == other.options && + settings == other.settings && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(description, name, options, settings, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{description=$description, name=$name, options=$options, settings=$settings, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PlaygroundSettingUpdateParams && + playgroundSettingsId == other.playgroundSettingsId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(playgroundSettingsId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "PlaygroundSettingUpdateParams{playgroundSettingsId=$playgroundSettingsId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingsResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingsResponse.kt new file mode 100644 index 00000000..181e54d0 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingsResponse.kt @@ -0,0 +1,384 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.playgroundsettings + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class PlaygroundSettingsResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val settings: JsonValue, + private val updatedAt: JsonField<OffsetDateTime>, + private val description: JsonField<String>, + private val name: JsonField<String>, + private val options: JsonField<PlaygroundSavedOptions>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("settings") @ExcludeMissing settings: JsonValue = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("options") + @ExcludeMissing + options: JsonField<PlaygroundSavedOptions> = JsonMissing.of(), + ) : this(id, createdAt, settings, updatedAt, description, name, options, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + @JsonProperty("settings") @ExcludeMissing fun _settings(): JsonValue = settings + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updatedAt(): OffsetDateTime = updatedAt.getRequired("updated_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional<String> = name.getOptional("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun options(): Optional<PlaygroundSavedOptions> = options.getOptional("options") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField<OffsetDateTime> = updatedAt + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [options]. + * + * Unlike [options], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("options") + @ExcludeMissing + fun _options(): JsonField<PlaygroundSavedOptions> = options + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PlaygroundSettingsResponse]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .settings() + * .updatedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PlaygroundSettingsResponse]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var createdAt: JsonField<OffsetDateTime>? = null + private var settings: JsonValue? = null + private var updatedAt: JsonField<OffsetDateTime>? = null + private var description: JsonField<String> = JsonMissing.of() + private var name: JsonField<String> = JsonMissing.of() + private var options: JsonField<PlaygroundSavedOptions> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(playgroundSettingsResponse: PlaygroundSettingsResponse) = apply { + id = playgroundSettingsResponse.id + createdAt = playgroundSettingsResponse.createdAt + settings = playgroundSettingsResponse.settings + updatedAt = playgroundSettingsResponse.updatedAt + description = playgroundSettingsResponse.description + name = playgroundSettingsResponse.name + options = playgroundSettingsResponse.options + additionalProperties = playgroundSettingsResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun settings(settings: JsonValue) = apply { this.settings = settings } + + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField<OffsetDateTime>) = apply { this.updatedAt = updatedAt } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { this.description = description } + + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional<String>) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun options(options: PlaygroundSavedOptions?) = options(JsonField.ofNullable(options)) + + /** Alias for calling [Builder.options] with `options.orElse(null)`. */ + fun options(options: Optional<PlaygroundSavedOptions>) = options(options.getOrNull()) + + /** + * Sets [Builder.options] to an arbitrary JSON value. + * + * You should usually call [Builder.options] with a well-typed [PlaygroundSavedOptions] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun options(options: JsonField<PlaygroundSavedOptions>) = apply { this.options = options } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PlaygroundSettingsResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .settings() + * .updatedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PlaygroundSettingsResponse = + PlaygroundSettingsResponse( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("settings", settings), + checkRequired("updatedAt", updatedAt), + description, + name, + options, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PlaygroundSettingsResponse = apply { + if (validated) { + return@apply + } + + id() + createdAt() + updatedAt() + description() + name() + options().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (options.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PlaygroundSettingsResponse && + id == other.id && + createdAt == other.createdAt && + settings == other.settings && + updatedAt == other.updatedAt && + description == other.description && + name == other.name && + options == other.options && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + createdAt, + settings, + updatedAt, + description, + name, + options, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PlaygroundSettingsResponse{id=$id, createdAt=$createdAt, settings=$settings, updatedAt=$updatedAt, description=$description, name=$name, options=$options, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/prompts/InvalidToolCall.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/prompts/InvalidToolCall.kt new file mode 100644 index 00000000..3ff9e3a7 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/prompts/InvalidToolCall.kt @@ -0,0 +1,555 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.prompts + +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 com.langsmith_api.api.core.BaseDeserializer +import com.langsmith_api.api.core.BaseSerializer +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.allMaxBy +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Allowance for errors made by LLM. + * + * Here we add an `error` key to surface errors made during generation (e.g., invalid JSON + * arguments.) + */ +class InvalidToolCall +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val args: JsonField<String>, + private val error: JsonField<String>, + private val name: JsonField<String>, + private val type: JsonValue, + private val extras: JsonValue, + private val index: JsonField<Index>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("args") @ExcludeMissing args: JsonField<String> = JsonMissing.of(), + @JsonProperty("error") @ExcludeMissing error: JsonField<String> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("extras") @ExcludeMissing extras: JsonValue = JsonMissing.of(), + @JsonProperty("index") @ExcludeMissing index: JsonField<Index> = JsonMissing.of(), + ) : this(id, args, error, name, type, extras, index, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun args(): Optional<String> = args.getOptional("args") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun error(): Optional<String> = error.getOptional("error") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional<String> = name.getOptional("name") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("invalid_tool_call") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + @JsonProperty("extras") @ExcludeMissing fun _extras(): JsonValue = extras + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun index(): Optional<Index> = index.getOptional("index") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [args]. + * + * Unlike [args], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("args") @ExcludeMissing fun _args(): JsonField<String> = args + + /** + * Returns the raw JSON value of [error]. + * + * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("error") @ExcludeMissing fun _error(): JsonField<String> = error + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [index]. + * + * Unlike [index], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("index") @ExcludeMissing fun _index(): JsonField<Index> = index + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InvalidToolCall]. + * + * The following fields are required: + * ```java + * .id() + * .args() + * .error() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InvalidToolCall]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var args: JsonField<String>? = null + private var error: JsonField<String>? = null + private var name: JsonField<String>? = null + private var type: JsonValue = JsonValue.from("invalid_tool_call") + private var extras: JsonValue = JsonMissing.of() + private var index: JsonField<Index> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(invalidToolCall: InvalidToolCall) = apply { + id = invalidToolCall.id + args = invalidToolCall.args + error = invalidToolCall.error + name = invalidToolCall.name + type = invalidToolCall.type + extras = invalidToolCall.extras + index = invalidToolCall.index + additionalProperties = invalidToolCall.additionalProperties.toMutableMap() + } + + fun id(id: String?) = id(JsonField.ofNullable(id)) + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<String>) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun args(args: String?) = args(JsonField.ofNullable(args)) + + /** Alias for calling [Builder.args] with `args.orElse(null)`. */ + fun args(args: Optional<String>) = args(args.getOrNull()) + + /** + * Sets [Builder.args] to an arbitrary JSON value. + * + * You should usually call [Builder.args] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun args(args: JsonField<String>) = apply { this.args = args } + + fun error(error: String?) = error(JsonField.ofNullable(error)) + + /** Alias for calling [Builder.error] with `error.orElse(null)`. */ + fun error(error: Optional<String>) = error(error.getOrNull()) + + /** + * Sets [Builder.error] to an arbitrary JSON value. + * + * You should usually call [Builder.error] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun error(error: JsonField<String>) = apply { this.error = error } + + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional<String>) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("invalid_tool_call") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun extras(extras: JsonValue) = apply { this.extras = extras } + + fun index(index: Index) = index(JsonField.of(index)) + + /** + * Sets [Builder.index] to an arbitrary JSON value. + * + * You should usually call [Builder.index] with a well-typed [Index] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun index(index: JsonField<Index>) = apply { this.index = index } + + /** Alias for calling [index] with `Index.ofInteger(integer)`. */ + fun index(integer: Long) = index(Index.ofInteger(integer)) + + /** Alias for calling [index] with `Index.ofString(string)`. */ + fun index(string: String) = index(Index.ofString(string)) + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InvalidToolCall]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .args() + * .error() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InvalidToolCall = + InvalidToolCall( + checkRequired("id", id), + checkRequired("args", args), + checkRequired("error", error), + checkRequired("name", name), + type, + extras, + index, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InvalidToolCall = apply { + if (validated) { + return@apply + } + + id() + args() + error() + name() + _type().let { + if (it != JsonValue.from("invalid_tool_call")) { + throw LangsmithApiInvalidDataException("'type' is invalid, received $it") + } + } + index().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (args.asKnown().isPresent) 1 else 0) + + (if (error.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("invalid_tool_call")) 1 else 0 } + + (index.asKnown().getOrNull()?.validity() ?: 0) + + @JsonDeserialize(using = Index.Deserializer::class) + @JsonSerialize(using = Index.Serializer::class) + class Index + private constructor( + private val integer: Long? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun integer(): Optional<Long> = Optional.ofNullable(integer) + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun isInteger(): Boolean = integer != null + + fun isString(): Boolean = string != null + + fun asInteger(): Long = integer.getOrThrow("integer") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + integer != null -> visitor.visitInteger(integer) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Index = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitInteger(integer: Long) {} + + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitInteger(integer: Long) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Index && integer == other.integer && string == other.string + } + + override fun hashCode(): Int = Objects.hash(integer, string) + + override fun toString(): String = + when { + integer != null -> "Index{integer=$integer}" + string != null -> "Index{string=$string}" + _json != null -> "Index{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Index") + } + + companion object { + + @JvmStatic fun ofInteger(integer: Long) = Index(integer = integer) + + @JvmStatic fun ofString(string: String) = Index(string = string) + } + + /** An interface that defines how to map each variant of [Index] to a value of type [T]. */ + interface Visitor<out T> { + + fun visitInteger(integer: Long): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [Index] to a value of type [T]. + * + * An instance of [Index] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Index: $json") + } + } + + internal class Deserializer : BaseDeserializer<Index>(Index::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Index { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<Long>())?.let { + Index(integer = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<String>())?.let { + Index(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> Index(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Index>(Index::class) { + + override fun serialize( + value: Index, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.integer != null -> generator.writeObject(value.integer) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Index") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InvalidToolCall && + id == other.id && + args == other.args && + error == other.error && + name == other.name && + type == other.type && + extras == other.extras && + index == other.index && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, args, error, name, type, extras, index, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InvalidToolCall{id=$id, args=$args, error=$error, name=$name, type=$type, extras=$extras, index=$index, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/prompts/PromptCanvasParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/prompts/PromptCanvasParams.kt new file mode 100644 index 00000000..568586c1 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/prompts/PromptCanvasParams.kt @@ -0,0 +1,15204 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.prompts + +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 com.langsmith_api.api.core.BaseDeserializer +import com.langsmith_api.api.core.BaseSerializer +import com.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.allMaxBy +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Prompt Canvas */ +class PromptCanvasParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun messages(): List<Message> = body.messages() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun secrets(): Secrets = body.secrets() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun templateFormat(): TemplateFormat = body.templateFormat() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun artifact(): Optional<Artifact> = body.artifact() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun artifactLength(): Optional<ArtifactLength> = body.artifactLength() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun customAction(): Optional<String> = body.customAction() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun highlighted(): Optional<Highlighted> = body.highlighted() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun readingLevel(): Optional<ReadingLevel> = body.readingLevel() + + /** + * Returns the raw JSON value of [messages]. + * + * Unlike [messages], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _messages(): JsonField<List<Message>> = body._messages() + + /** + * Returns the raw JSON value of [secrets]. + * + * Unlike [secrets], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _secrets(): JsonField<Secrets> = body._secrets() + + /** + * Returns the raw JSON value of [templateFormat]. + * + * Unlike [templateFormat], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _templateFormat(): JsonField<TemplateFormat> = body._templateFormat() + + /** + * Returns the raw JSON value of [artifact]. + * + * Unlike [artifact], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _artifact(): JsonField<Artifact> = body._artifact() + + /** + * Returns the raw JSON value of [artifactLength]. + * + * Unlike [artifactLength], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _artifactLength(): JsonField<ArtifactLength> = body._artifactLength() + + /** + * Returns the raw JSON value of [customAction]. + * + * Unlike [customAction], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _customAction(): JsonField<String> = body._customAction() + + /** + * Returns the raw JSON value of [highlighted]. + * + * Unlike [highlighted], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _highlighted(): JsonField<Highlighted> = body._highlighted() + + /** + * Returns the raw JSON value of [readingLevel]. + * + * Unlike [readingLevel], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _readingLevel(): JsonField<ReadingLevel> = body._readingLevel() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PromptCanvasParams]. + * + * The following fields are required: + * ```java + * .messages() + * .secrets() + * .templateFormat() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PromptCanvasParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(promptCanvasParams: PromptCanvasParams) = apply { + body = promptCanvasParams.body.toBuilder() + additionalHeaders = promptCanvasParams.additionalHeaders.toBuilder() + additionalQueryParams = promptCanvasParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [messages] + * - [secrets] + * - [templateFormat] + * - [artifact] + * - [artifactLength] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun messages(messages: List<Message>) = apply { body.messages(messages) } + + /** + * Sets [Builder.messages] to an arbitrary JSON value. + * + * You should usually call [Builder.messages] with a well-typed `List<Message>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun messages(messages: JsonField<List<Message>>) = apply { body.messages(messages) } + + /** + * Adds a single [Message] to [messages]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMessage(message: Message) = apply { body.addMessage(message) } + + /** Alias for calling [addMessage] with `Message.ofAi(ai)`. */ + fun addMessage(ai: Message.AiMessage) = apply { body.addMessage(ai) } + + /** Alias for calling [addMessage] with `Message.ofHuman(human)`. */ + fun addMessage(human: Message.HumanMessage) = apply { body.addMessage(human) } + + /** Alias for calling [addMessage] with `Message.ofChat(chat)`. */ + fun addMessage(chat: Message.ChatMessage) = apply { body.addMessage(chat) } + + /** Alias for calling [addMessage] with `Message.ofSystem(system)`. */ + fun addMessage(system: Message.SystemMessage) = apply { body.addMessage(system) } + + /** Alias for calling [addMessage] with `Message.ofFunction(function)`. */ + fun addMessage(function: Message.FunctionMessage) = apply { body.addMessage(function) } + + /** Alias for calling [addMessage] with `Message.ofTool(tool)`. */ + fun addMessage(tool: Message.ToolMessage) = apply { body.addMessage(tool) } + + /** Alias for calling [addMessage] with `Message.ofAiMessageChunk(aiMessageChunk)`. */ + fun addMessage(aiMessageChunk: Message.AiMessageChunk) = apply { + body.addMessage(aiMessageChunk) + } + + /** Alias for calling [addMessage] with `Message.ofHumanMessageChunk(humanMessageChunk)`. */ + fun addMessage(humanMessageChunk: Message.HumanMessageChunk) = apply { + body.addMessage(humanMessageChunk) + } + + /** Alias for calling [addMessage] with `Message.ofChatMessageChunk(chatMessageChunk)`. */ + fun addMessage(chatMessageChunk: Message.ChatMessageChunk) = apply { + body.addMessage(chatMessageChunk) + } + + /** + * Alias for calling [addMessage] with `Message.ofSystemMessageChunk(systemMessageChunk)`. + */ + fun addMessage(systemMessageChunk: Message.SystemMessageChunk) = apply { + body.addMessage(systemMessageChunk) + } + + /** + * Alias for calling [addMessage] with + * `Message.ofFunctionMessageChunk(functionMessageChunk)`. + */ + fun addMessage(functionMessageChunk: Message.FunctionMessageChunk) = apply { + body.addMessage(functionMessageChunk) + } + + /** Alias for calling [addMessage] with `Message.ofToolMessageChunk(toolMessageChunk)`. */ + fun addMessage(toolMessageChunk: Message.ToolMessageChunk) = apply { + body.addMessage(toolMessageChunk) + } + + fun secrets(secrets: Secrets) = apply { body.secrets(secrets) } + + /** + * Sets [Builder.secrets] to an arbitrary JSON value. + * + * You should usually call [Builder.secrets] with a well-typed [Secrets] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun secrets(secrets: JsonField<Secrets>) = apply { body.secrets(secrets) } + + fun templateFormat(templateFormat: TemplateFormat) = apply { + body.templateFormat(templateFormat) + } + + /** + * Sets [Builder.templateFormat] to an arbitrary JSON value. + * + * You should usually call [Builder.templateFormat] with a well-typed [TemplateFormat] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun templateFormat(templateFormat: JsonField<TemplateFormat>) = apply { + body.templateFormat(templateFormat) + } + + fun artifact(artifact: Artifact?) = apply { body.artifact(artifact) } + + /** Alias for calling [Builder.artifact] with `artifact.orElse(null)`. */ + fun artifact(artifact: Optional<Artifact>) = artifact(artifact.getOrNull()) + + /** + * Sets [Builder.artifact] to an arbitrary JSON value. + * + * You should usually call [Builder.artifact] with a well-typed [Artifact] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun artifact(artifact: JsonField<Artifact>) = apply { body.artifact(artifact) } + + fun artifactLength(artifactLength: ArtifactLength?) = apply { + body.artifactLength(artifactLength) + } + + /** Alias for calling [Builder.artifactLength] with `artifactLength.orElse(null)`. */ + fun artifactLength(artifactLength: Optional<ArtifactLength>) = + artifactLength(artifactLength.getOrNull()) + + /** + * Sets [Builder.artifactLength] to an arbitrary JSON value. + * + * You should usually call [Builder.artifactLength] with a well-typed [ArtifactLength] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun artifactLength(artifactLength: JsonField<ArtifactLength>) = apply { + body.artifactLength(artifactLength) + } + + fun customAction(customAction: String?) = apply { body.customAction(customAction) } + + /** Alias for calling [Builder.customAction] with `customAction.orElse(null)`. */ + fun customAction(customAction: Optional<String>) = customAction(customAction.getOrNull()) + + /** + * Sets [Builder.customAction] to an arbitrary JSON value. + * + * You should usually call [Builder.customAction] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun customAction(customAction: JsonField<String>) = apply { + body.customAction(customAction) + } + + fun highlighted(highlighted: Highlighted?) = apply { body.highlighted(highlighted) } + + /** Alias for calling [Builder.highlighted] with `highlighted.orElse(null)`. */ + fun highlighted(highlighted: Optional<Highlighted>) = highlighted(highlighted.getOrNull()) + + /** + * Sets [Builder.highlighted] to an arbitrary JSON value. + * + * You should usually call [Builder.highlighted] with a well-typed [Highlighted] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun highlighted(highlighted: JsonField<Highlighted>) = apply { + body.highlighted(highlighted) + } + + fun readingLevel(readingLevel: ReadingLevel?) = apply { body.readingLevel(readingLevel) } + + /** Alias for calling [Builder.readingLevel] with `readingLevel.orElse(null)`. */ + fun readingLevel(readingLevel: Optional<ReadingLevel>) = + readingLevel(readingLevel.getOrNull()) + + /** + * Sets [Builder.readingLevel] to an arbitrary JSON value. + * + * You should usually call [Builder.readingLevel] with a well-typed [ReadingLevel] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun readingLevel(readingLevel: JsonField<ReadingLevel>) = apply { + body.readingLevel(readingLevel) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [PromptCanvasParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .messages() + * .secrets() + * .templateFormat() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PromptCanvasParams = + PromptCanvasParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val messages: JsonField<List<Message>>, + private val secrets: JsonField<Secrets>, + private val templateFormat: JsonField<TemplateFormat>, + private val artifact: JsonField<Artifact>, + private val artifactLength: JsonField<ArtifactLength>, + private val customAction: JsonField<String>, + private val highlighted: JsonField<Highlighted>, + private val readingLevel: JsonField<ReadingLevel>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("messages") + @ExcludeMissing + messages: JsonField<List<Message>> = JsonMissing.of(), + @JsonProperty("secrets") @ExcludeMissing secrets: JsonField<Secrets> = JsonMissing.of(), + @JsonProperty("template_format") + @ExcludeMissing + templateFormat: JsonField<TemplateFormat> = JsonMissing.of(), + @JsonProperty("artifact") + @ExcludeMissing + artifact: JsonField<Artifact> = JsonMissing.of(), + @JsonProperty("artifact_length") + @ExcludeMissing + artifactLength: JsonField<ArtifactLength> = JsonMissing.of(), + @JsonProperty("custom_action") + @ExcludeMissing + customAction: JsonField<String> = JsonMissing.of(), + @JsonProperty("highlighted") + @ExcludeMissing + highlighted: JsonField<Highlighted> = JsonMissing.of(), + @JsonProperty("reading_level") + @ExcludeMissing + readingLevel: JsonField<ReadingLevel> = JsonMissing.of(), + ) : this( + messages, + secrets, + templateFormat, + artifact, + artifactLength, + customAction, + highlighted, + readingLevel, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun messages(): List<Message> = messages.getRequired("messages") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun secrets(): Secrets = secrets.getRequired("secrets") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun templateFormat(): TemplateFormat = templateFormat.getRequired("template_format") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun artifact(): Optional<Artifact> = artifact.getOptional("artifact") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun artifactLength(): Optional<ArtifactLength> = + artifactLength.getOptional("artifact_length") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun customAction(): Optional<String> = customAction.getOptional("custom_action") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun highlighted(): Optional<Highlighted> = highlighted.getOptional("highlighted") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun readingLevel(): Optional<ReadingLevel> = readingLevel.getOptional("reading_level") + + /** + * Returns the raw JSON value of [messages]. + * + * Unlike [messages], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("messages") + @ExcludeMissing + fun _messages(): JsonField<List<Message>> = messages + + /** + * Returns the raw JSON value of [secrets]. + * + * Unlike [secrets], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("secrets") @ExcludeMissing fun _secrets(): JsonField<Secrets> = secrets + + /** + * Returns the raw JSON value of [templateFormat]. + * + * Unlike [templateFormat], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("template_format") + @ExcludeMissing + fun _templateFormat(): JsonField<TemplateFormat> = templateFormat + + /** + * Returns the raw JSON value of [artifact]. + * + * Unlike [artifact], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("artifact") @ExcludeMissing fun _artifact(): JsonField<Artifact> = artifact + + /** + * Returns the raw JSON value of [artifactLength]. + * + * Unlike [artifactLength], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("artifact_length") + @ExcludeMissing + fun _artifactLength(): JsonField<ArtifactLength> = artifactLength + + /** + * Returns the raw JSON value of [customAction]. + * + * Unlike [customAction], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("custom_action") + @ExcludeMissing + fun _customAction(): JsonField<String> = customAction + + /** + * Returns the raw JSON value of [highlighted]. + * + * Unlike [highlighted], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("highlighted") + @ExcludeMissing + fun _highlighted(): JsonField<Highlighted> = highlighted + + /** + * Returns the raw JSON value of [readingLevel]. + * + * Unlike [readingLevel], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reading_level") + @ExcludeMissing + fun _readingLevel(): JsonField<ReadingLevel> = readingLevel + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .messages() + * .secrets() + * .templateFormat() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var messages: JsonField<MutableList<Message>>? = null + private var secrets: JsonField<Secrets>? = null + private var templateFormat: JsonField<TemplateFormat>? = null + private var artifact: JsonField<Artifact> = JsonMissing.of() + private var artifactLength: JsonField<ArtifactLength> = JsonMissing.of() + private var customAction: JsonField<String> = JsonMissing.of() + private var highlighted: JsonField<Highlighted> = JsonMissing.of() + private var readingLevel: JsonField<ReadingLevel> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + messages = body.messages.map { it.toMutableList() } + secrets = body.secrets + templateFormat = body.templateFormat + artifact = body.artifact + artifactLength = body.artifactLength + customAction = body.customAction + highlighted = body.highlighted + readingLevel = body.readingLevel + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun messages(messages: List<Message>) = messages(JsonField.of(messages)) + + /** + * Sets [Builder.messages] to an arbitrary JSON value. + * + * You should usually call [Builder.messages] with a well-typed `List<Message>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun messages(messages: JsonField<List<Message>>) = apply { + this.messages = messages.map { it.toMutableList() } + } + + /** + * Adds a single [Message] to [messages]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMessage(message: Message) = apply { + messages = + (messages ?: JsonField.of(mutableListOf())).also { + checkKnown("messages", it).add(message) + } + } + + /** Alias for calling [addMessage] with `Message.ofAi(ai)`. */ + fun addMessage(ai: Message.AiMessage) = addMessage(Message.ofAi(ai)) + + /** Alias for calling [addMessage] with `Message.ofHuman(human)`. */ + fun addMessage(human: Message.HumanMessage) = addMessage(Message.ofHuman(human)) + + /** Alias for calling [addMessage] with `Message.ofChat(chat)`. */ + fun addMessage(chat: Message.ChatMessage) = addMessage(Message.ofChat(chat)) + + /** Alias for calling [addMessage] with `Message.ofSystem(system)`. */ + fun addMessage(system: Message.SystemMessage) = addMessage(Message.ofSystem(system)) + + /** Alias for calling [addMessage] with `Message.ofFunction(function)`. */ + fun addMessage(function: Message.FunctionMessage) = + addMessage(Message.ofFunction(function)) + + /** Alias for calling [addMessage] with `Message.ofTool(tool)`. */ + fun addMessage(tool: Message.ToolMessage) = addMessage(Message.ofTool(tool)) + + /** Alias for calling [addMessage] with `Message.ofAiMessageChunk(aiMessageChunk)`. */ + fun addMessage(aiMessageChunk: Message.AiMessageChunk) = + addMessage(Message.ofAiMessageChunk(aiMessageChunk)) + + /** + * Alias for calling [addMessage] with `Message.ofHumanMessageChunk(humanMessageChunk)`. + */ + fun addMessage(humanMessageChunk: Message.HumanMessageChunk) = + addMessage(Message.ofHumanMessageChunk(humanMessageChunk)) + + /** + * Alias for calling [addMessage] with `Message.ofChatMessageChunk(chatMessageChunk)`. + */ + fun addMessage(chatMessageChunk: Message.ChatMessageChunk) = + addMessage(Message.ofChatMessageChunk(chatMessageChunk)) + + /** + * Alias for calling [addMessage] with + * `Message.ofSystemMessageChunk(systemMessageChunk)`. + */ + fun addMessage(systemMessageChunk: Message.SystemMessageChunk) = + addMessage(Message.ofSystemMessageChunk(systemMessageChunk)) + + /** + * Alias for calling [addMessage] with + * `Message.ofFunctionMessageChunk(functionMessageChunk)`. + */ + fun addMessage(functionMessageChunk: Message.FunctionMessageChunk) = + addMessage(Message.ofFunctionMessageChunk(functionMessageChunk)) + + /** + * Alias for calling [addMessage] with `Message.ofToolMessageChunk(toolMessageChunk)`. + */ + fun addMessage(toolMessageChunk: Message.ToolMessageChunk) = + addMessage(Message.ofToolMessageChunk(toolMessageChunk)) + + fun secrets(secrets: Secrets) = secrets(JsonField.of(secrets)) + + /** + * Sets [Builder.secrets] to an arbitrary JSON value. + * + * You should usually call [Builder.secrets] with a well-typed [Secrets] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun secrets(secrets: JsonField<Secrets>) = apply { this.secrets = secrets } + + fun templateFormat(templateFormat: TemplateFormat) = + templateFormat(JsonField.of(templateFormat)) + + /** + * Sets [Builder.templateFormat] to an arbitrary JSON value. + * + * You should usually call [Builder.templateFormat] with a well-typed [TemplateFormat] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun templateFormat(templateFormat: JsonField<TemplateFormat>) = apply { + this.templateFormat = templateFormat + } + + fun artifact(artifact: Artifact?) = artifact(JsonField.ofNullable(artifact)) + + /** Alias for calling [Builder.artifact] with `artifact.orElse(null)`. */ + fun artifact(artifact: Optional<Artifact>) = artifact(artifact.getOrNull()) + + /** + * Sets [Builder.artifact] to an arbitrary JSON value. + * + * You should usually call [Builder.artifact] with a well-typed [Artifact] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun artifact(artifact: JsonField<Artifact>) = apply { this.artifact = artifact } + + fun artifactLength(artifactLength: ArtifactLength?) = + artifactLength(JsonField.ofNullable(artifactLength)) + + /** Alias for calling [Builder.artifactLength] with `artifactLength.orElse(null)`. */ + fun artifactLength(artifactLength: Optional<ArtifactLength>) = + artifactLength(artifactLength.getOrNull()) + + /** + * Sets [Builder.artifactLength] to an arbitrary JSON value. + * + * You should usually call [Builder.artifactLength] with a well-typed [ArtifactLength] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun artifactLength(artifactLength: JsonField<ArtifactLength>) = apply { + this.artifactLength = artifactLength + } + + fun customAction(customAction: String?) = + customAction(JsonField.ofNullable(customAction)) + + /** Alias for calling [Builder.customAction] with `customAction.orElse(null)`. */ + fun customAction(customAction: Optional<String>) = + customAction(customAction.getOrNull()) + + /** + * Sets [Builder.customAction] to an arbitrary JSON value. + * + * You should usually call [Builder.customAction] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customAction(customAction: JsonField<String>) = apply { + this.customAction = customAction + } + + fun highlighted(highlighted: Highlighted?) = + highlighted(JsonField.ofNullable(highlighted)) + + /** Alias for calling [Builder.highlighted] with `highlighted.orElse(null)`. */ + fun highlighted(highlighted: Optional<Highlighted>) = + highlighted(highlighted.getOrNull()) + + /** + * Sets [Builder.highlighted] to an arbitrary JSON value. + * + * You should usually call [Builder.highlighted] with a well-typed [Highlighted] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun highlighted(highlighted: JsonField<Highlighted>) = apply { + this.highlighted = highlighted + } + + fun readingLevel(readingLevel: ReadingLevel?) = + readingLevel(JsonField.ofNullable(readingLevel)) + + /** Alias for calling [Builder.readingLevel] with `readingLevel.orElse(null)`. */ + fun readingLevel(readingLevel: Optional<ReadingLevel>) = + readingLevel(readingLevel.getOrNull()) + + /** + * Sets [Builder.readingLevel] to an arbitrary JSON value. + * + * You should usually call [Builder.readingLevel] with a well-typed [ReadingLevel] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun readingLevel(readingLevel: JsonField<ReadingLevel>) = apply { + this.readingLevel = readingLevel + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .messages() + * .secrets() + * .templateFormat() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("messages", messages).map { it.toImmutable() }, + checkRequired("secrets", secrets), + checkRequired("templateFormat", templateFormat), + artifact, + artifactLength, + customAction, + highlighted, + readingLevel, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + messages().forEach { it.validate() } + secrets().validate() + templateFormat().validate() + artifact().ifPresent { it.validate() } + artifactLength().ifPresent { it.validate() } + customAction() + highlighted().ifPresent { it.validate() } + readingLevel().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (messages.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (secrets.asKnown().getOrNull()?.validity() ?: 0) + + (templateFormat.asKnown().getOrNull()?.validity() ?: 0) + + (artifact.asKnown().getOrNull()?.validity() ?: 0) + + (artifactLength.asKnown().getOrNull()?.validity() ?: 0) + + (if (customAction.asKnown().isPresent) 1 else 0) + + (highlighted.asKnown().getOrNull()?.validity() ?: 0) + + (readingLevel.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + messages == other.messages && + secrets == other.secrets && + templateFormat == other.templateFormat && + artifact == other.artifact && + artifactLength == other.artifactLength && + customAction == other.customAction && + highlighted == other.highlighted && + readingLevel == other.readingLevel && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + messages, + secrets, + templateFormat, + artifact, + artifactLength, + customAction, + highlighted, + readingLevel, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{messages=$messages, secrets=$secrets, templateFormat=$templateFormat, artifact=$artifact, artifactLength=$artifactLength, customAction=$customAction, highlighted=$highlighted, readingLevel=$readingLevel, additionalProperties=$additionalProperties}" + } + + /** + * Message from an AI. + * + * An `AIMessage` is returned from a chat model as a response to a prompt. + * + * This message represents the output of the model and consists of both the raw output as + * returned by the model and standardized fields (e.g., tool calls, usage metadata) added by the + * LangChain framework. + */ + @JsonDeserialize(using = Message.Deserializer::class) + @JsonSerialize(using = Message.Serializer::class) + class Message + private constructor( + private val ai: AiMessage? = null, + private val human: HumanMessage? = null, + private val chat: ChatMessage? = null, + private val system: SystemMessage? = null, + private val function: FunctionMessage? = null, + private val tool: ToolMessage? = null, + private val aiMessageChunk: AiMessageChunk? = null, + private val humanMessageChunk: HumanMessageChunk? = null, + private val chatMessageChunk: ChatMessageChunk? = null, + private val systemMessageChunk: SystemMessageChunk? = null, + private val functionMessageChunk: FunctionMessageChunk? = null, + private val toolMessageChunk: ToolMessageChunk? = null, + private val _json: JsonValue? = null, + ) { + + /** + * Message from an AI. + * + * An `AIMessage` is returned from a chat model as a response to a prompt. + * + * This message represents the output of the model and consists of both the raw output as + * returned by the model and standardized fields (e.g., tool calls, usage metadata) added by + * the LangChain framework. + */ + fun ai(): Optional<AiMessage> = Optional.ofNullable(ai) + + /** + * Message from the user. + * + * A `HumanMessage` is a message that is passed in from a user to the model. + * + * Example: + * + * ```python + * from langchain_core.messages import HumanMessage, SystemMessage + * + * messages = [ + * SystemMessage(content="You are a helpful assistant! Your name is Bob."), + * HumanMessage(content="What is your name?"), + * ] + * + * # Instantiate a chat model and invoke it with the messages + * model = ... + * print(model.invoke(messages)) + * ``` + */ + fun human(): Optional<HumanMessage> = Optional.ofNullable(human) + + /** Message that can be assigned an arbitrary speaker (i.e. role). */ + fun chat(): Optional<ChatMessage> = Optional.ofNullable(chat) + + /** + * Message for priming AI behavior. + * + * The system message is usually passed in as the first of a sequence of input messages. + * + * Example: + * + * ```python + * from langchain_core.messages import HumanMessage, SystemMessage + * + * messages = [ + * SystemMessage(content="You are a helpful assistant! Your name is Bob."), + * HumanMessage(content="What is your name?"), + * ] + * + * # Define a chat model and invoke it with the messages + * print(model.invoke(messages)) + * ``` + */ + fun system(): Optional<SystemMessage> = Optional.ofNullable(system) + + /** + * Message for passing the result of executing a tool back to a model. + * + * `FunctionMessage` are an older version of the `ToolMessage` schema, and do not contain + * the `tool_call_id` field. + * + * The `tool_call_id` field is used to associate the tool call request with the tool call + * response. Useful in situations where a chat model is able to request multiple tool calls + * in parallel. + */ + fun function(): Optional<FunctionMessage> = Optional.ofNullable(function) + + /** + * Message for passing the result of executing a tool back to a model. + * + * `ToolMessage` objects contain the result of a tool invocation. Typically, the result is + * encoded inside the `content` field. + * + * Example: A `ToolMessage` representing a result of `42` from a tool call with id + * + * ```python + * from langchain_core.messages import ToolMessage + * + * ToolMessage(content="42", tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL") + * ``` + * + * Example: A `ToolMessage` where only part of the tool output is sent to the model and the + * full output is passed in to artifact. + * + * ```python + * from langchain_core.messages import ToolMessage + * + * tool_output = { + * "stdout": "From the graph we can see that the correlation between " + * "x and y is ...", + * "stderr": None, + * "artifacts": {"type": "image", "base64_data": "/9j/4gIcSU..."}, + * } + * + * ToolMessage( + * content=tool_output["stdout"], + * artifact=tool_output, + * tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL", + * ) + * ``` + * + * The `tool_call_id` field is used to associate the tool call request with the tool call + * response. Useful in situations where a chat model is able to request multiple tool calls + * in parallel. + */ + fun tool(): Optional<ToolMessage> = Optional.ofNullable(tool) + + /** Message chunk from an AI (yielded when streaming). */ + fun aiMessageChunk(): Optional<AiMessageChunk> = Optional.ofNullable(aiMessageChunk) + + /** Human Message chunk. */ + fun humanMessageChunk(): Optional<HumanMessageChunk> = + Optional.ofNullable(humanMessageChunk) + + /** Chat Message chunk. */ + fun chatMessageChunk(): Optional<ChatMessageChunk> = Optional.ofNullable(chatMessageChunk) + + /** System Message chunk. */ + fun systemMessageChunk(): Optional<SystemMessageChunk> = + Optional.ofNullable(systemMessageChunk) + + /** Function Message chunk. */ + fun functionMessageChunk(): Optional<FunctionMessageChunk> = + Optional.ofNullable(functionMessageChunk) + + /** Tool Message chunk. */ + fun toolMessageChunk(): Optional<ToolMessageChunk> = Optional.ofNullable(toolMessageChunk) + + fun isAi(): Boolean = ai != null + + fun isHuman(): Boolean = human != null + + fun isChat(): Boolean = chat != null + + fun isSystem(): Boolean = system != null + + fun isFunction(): Boolean = function != null + + fun isTool(): Boolean = tool != null + + fun isAiMessageChunk(): Boolean = aiMessageChunk != null + + fun isHumanMessageChunk(): Boolean = humanMessageChunk != null + + fun isChatMessageChunk(): Boolean = chatMessageChunk != null + + fun isSystemMessageChunk(): Boolean = systemMessageChunk != null + + fun isFunctionMessageChunk(): Boolean = functionMessageChunk != null + + fun isToolMessageChunk(): Boolean = toolMessageChunk != null + + /** + * Message from an AI. + * + * An `AIMessage` is returned from a chat model as a response to a prompt. + * + * This message represents the output of the model and consists of both the raw output as + * returned by the model and standardized fields (e.g., tool calls, usage metadata) added by + * the LangChain framework. + */ + fun asAi(): AiMessage = ai.getOrThrow("ai") + + /** + * Message from the user. + * + * A `HumanMessage` is a message that is passed in from a user to the model. + * + * Example: + * + * ```python + * from langchain_core.messages import HumanMessage, SystemMessage + * + * messages = [ + * SystemMessage(content="You are a helpful assistant! Your name is Bob."), + * HumanMessage(content="What is your name?"), + * ] + * + * # Instantiate a chat model and invoke it with the messages + * model = ... + * print(model.invoke(messages)) + * ``` + */ + fun asHuman(): HumanMessage = human.getOrThrow("human") + + /** Message that can be assigned an arbitrary speaker (i.e. role). */ + fun asChat(): ChatMessage = chat.getOrThrow("chat") + + /** + * Message for priming AI behavior. + * + * The system message is usually passed in as the first of a sequence of input messages. + * + * Example: + * + * ```python + * from langchain_core.messages import HumanMessage, SystemMessage + * + * messages = [ + * SystemMessage(content="You are a helpful assistant! Your name is Bob."), + * HumanMessage(content="What is your name?"), + * ] + * + * # Define a chat model and invoke it with the messages + * print(model.invoke(messages)) + * ``` + */ + fun asSystem(): SystemMessage = system.getOrThrow("system") + + /** + * Message for passing the result of executing a tool back to a model. + * + * `FunctionMessage` are an older version of the `ToolMessage` schema, and do not contain + * the `tool_call_id` field. + * + * The `tool_call_id` field is used to associate the tool call request with the tool call + * response. Useful in situations where a chat model is able to request multiple tool calls + * in parallel. + */ + fun asFunction(): FunctionMessage = function.getOrThrow("function") + + /** + * Message for passing the result of executing a tool back to a model. + * + * `ToolMessage` objects contain the result of a tool invocation. Typically, the result is + * encoded inside the `content` field. + * + * Example: A `ToolMessage` representing a result of `42` from a tool call with id + * + * ```python + * from langchain_core.messages import ToolMessage + * + * ToolMessage(content="42", tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL") + * ``` + * + * Example: A `ToolMessage` where only part of the tool output is sent to the model and the + * full output is passed in to artifact. + * + * ```python + * from langchain_core.messages import ToolMessage + * + * tool_output = { + * "stdout": "From the graph we can see that the correlation between " + * "x and y is ...", + * "stderr": None, + * "artifacts": {"type": "image", "base64_data": "/9j/4gIcSU..."}, + * } + * + * ToolMessage( + * content=tool_output["stdout"], + * artifact=tool_output, + * tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL", + * ) + * ``` + * + * The `tool_call_id` field is used to associate the tool call request with the tool call + * response. Useful in situations where a chat model is able to request multiple tool calls + * in parallel. + */ + fun asTool(): ToolMessage = tool.getOrThrow("tool") + + /** Message chunk from an AI (yielded when streaming). */ + fun asAiMessageChunk(): AiMessageChunk = aiMessageChunk.getOrThrow("aiMessageChunk") + + /** Human Message chunk. */ + fun asHumanMessageChunk(): HumanMessageChunk = + humanMessageChunk.getOrThrow("humanMessageChunk") + + /** Chat Message chunk. */ + fun asChatMessageChunk(): ChatMessageChunk = chatMessageChunk.getOrThrow("chatMessageChunk") + + /** System Message chunk. */ + fun asSystemMessageChunk(): SystemMessageChunk = + systemMessageChunk.getOrThrow("systemMessageChunk") + + /** Function Message chunk. */ + fun asFunctionMessageChunk(): FunctionMessageChunk = + functionMessageChunk.getOrThrow("functionMessageChunk") + + /** Tool Message chunk. */ + fun asToolMessageChunk(): ToolMessageChunk = toolMessageChunk.getOrThrow("toolMessageChunk") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + ai != null -> visitor.visitAi(ai) + human != null -> visitor.visitHuman(human) + chat != null -> visitor.visitChat(chat) + system != null -> visitor.visitSystem(system) + function != null -> visitor.visitFunction(function) + tool != null -> visitor.visitTool(tool) + aiMessageChunk != null -> visitor.visitAiMessageChunk(aiMessageChunk) + humanMessageChunk != null -> visitor.visitHumanMessageChunk(humanMessageChunk) + chatMessageChunk != null -> visitor.visitChatMessageChunk(chatMessageChunk) + systemMessageChunk != null -> visitor.visitSystemMessageChunk(systemMessageChunk) + functionMessageChunk != null -> + visitor.visitFunctionMessageChunk(functionMessageChunk) + toolMessageChunk != null -> visitor.visitToolMessageChunk(toolMessageChunk) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Message = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitAi(ai: AiMessage) { + ai.validate() + } + + override fun visitHuman(human: HumanMessage) { + human.validate() + } + + override fun visitChat(chat: ChatMessage) { + chat.validate() + } + + override fun visitSystem(system: SystemMessage) { + system.validate() + } + + override fun visitFunction(function: FunctionMessage) { + function.validate() + } + + override fun visitTool(tool: ToolMessage) { + tool.validate() + } + + override fun visitAiMessageChunk(aiMessageChunk: AiMessageChunk) { + aiMessageChunk.validate() + } + + override fun visitHumanMessageChunk(humanMessageChunk: HumanMessageChunk) { + humanMessageChunk.validate() + } + + override fun visitChatMessageChunk(chatMessageChunk: ChatMessageChunk) { + chatMessageChunk.validate() + } + + override fun visitSystemMessageChunk(systemMessageChunk: SystemMessageChunk) { + systemMessageChunk.validate() + } + + override fun visitFunctionMessageChunk( + functionMessageChunk: FunctionMessageChunk + ) { + functionMessageChunk.validate() + } + + override fun visitToolMessageChunk(toolMessageChunk: ToolMessageChunk) { + toolMessageChunk.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitAi(ai: AiMessage) = ai.validity() + + override fun visitHuman(human: HumanMessage) = human.validity() + + override fun visitChat(chat: ChatMessage) = chat.validity() + + override fun visitSystem(system: SystemMessage) = system.validity() + + override fun visitFunction(function: FunctionMessage) = function.validity() + + override fun visitTool(tool: ToolMessage) = tool.validity() + + override fun visitAiMessageChunk(aiMessageChunk: AiMessageChunk) = + aiMessageChunk.validity() + + override fun visitHumanMessageChunk(humanMessageChunk: HumanMessageChunk) = + humanMessageChunk.validity() + + override fun visitChatMessageChunk(chatMessageChunk: ChatMessageChunk) = + chatMessageChunk.validity() + + override fun visitSystemMessageChunk(systemMessageChunk: SystemMessageChunk) = + systemMessageChunk.validity() + + override fun visitFunctionMessageChunk( + functionMessageChunk: FunctionMessageChunk + ) = functionMessageChunk.validity() + + override fun visitToolMessageChunk(toolMessageChunk: ToolMessageChunk) = + toolMessageChunk.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Message && + ai == other.ai && + human == other.human && + chat == other.chat && + system == other.system && + function == other.function && + tool == other.tool && + aiMessageChunk == other.aiMessageChunk && + humanMessageChunk == other.humanMessageChunk && + chatMessageChunk == other.chatMessageChunk && + systemMessageChunk == other.systemMessageChunk && + functionMessageChunk == other.functionMessageChunk && + toolMessageChunk == other.toolMessageChunk + } + + override fun hashCode(): Int = + Objects.hash( + ai, + human, + chat, + system, + function, + tool, + aiMessageChunk, + humanMessageChunk, + chatMessageChunk, + systemMessageChunk, + functionMessageChunk, + toolMessageChunk, + ) + + override fun toString(): String = + when { + ai != null -> "Message{ai=$ai}" + human != null -> "Message{human=$human}" + chat != null -> "Message{chat=$chat}" + system != null -> "Message{system=$system}" + function != null -> "Message{function=$function}" + tool != null -> "Message{tool=$tool}" + aiMessageChunk != null -> "Message{aiMessageChunk=$aiMessageChunk}" + humanMessageChunk != null -> "Message{humanMessageChunk=$humanMessageChunk}" + chatMessageChunk != null -> "Message{chatMessageChunk=$chatMessageChunk}" + systemMessageChunk != null -> "Message{systemMessageChunk=$systemMessageChunk}" + functionMessageChunk != null -> + "Message{functionMessageChunk=$functionMessageChunk}" + toolMessageChunk != null -> "Message{toolMessageChunk=$toolMessageChunk}" + _json != null -> "Message{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Message") + } + + companion object { + + /** + * Message from an AI. + * + * An `AIMessage` is returned from a chat model as a response to a prompt. + * + * This message represents the output of the model and consists of both the raw output + * as returned by the model and standardized fields (e.g., tool calls, usage metadata) + * added by the LangChain framework. + */ + @JvmStatic fun ofAi(ai: AiMessage) = Message(ai = ai) + + /** + * Message from the user. + * + * A `HumanMessage` is a message that is passed in from a user to the model. + * + * Example: + * + * ```python + * from langchain_core.messages import HumanMessage, SystemMessage + * + * messages = [ + * SystemMessage(content="You are a helpful assistant! Your name is Bob."), + * HumanMessage(content="What is your name?"), + * ] + * + * # Instantiate a chat model and invoke it with the messages + * model = ... + * print(model.invoke(messages)) + * ``` + */ + @JvmStatic fun ofHuman(human: HumanMessage) = Message(human = human) + + /** Message that can be assigned an arbitrary speaker (i.e. role). */ + @JvmStatic fun ofChat(chat: ChatMessage) = Message(chat = chat) + + /** + * Message for priming AI behavior. + * + * The system message is usually passed in as the first of a sequence of input messages. + * + * Example: + * + * ```python + * from langchain_core.messages import HumanMessage, SystemMessage + * + * messages = [ + * SystemMessage(content="You are a helpful assistant! Your name is Bob."), + * HumanMessage(content="What is your name?"), + * ] + * + * # Define a chat model and invoke it with the messages + * print(model.invoke(messages)) + * ``` + */ + @JvmStatic fun ofSystem(system: SystemMessage) = Message(system = system) + + /** + * Message for passing the result of executing a tool back to a model. + * + * `FunctionMessage` are an older version of the `ToolMessage` schema, and do not + * contain the `tool_call_id` field. + * + * The `tool_call_id` field is used to associate the tool call request with the tool + * call response. Useful in situations where a chat model is able to request multiple + * tool calls in parallel. + */ + @JvmStatic fun ofFunction(function: FunctionMessage) = Message(function = function) + + /** + * Message for passing the result of executing a tool back to a model. + * + * `ToolMessage` objects contain the result of a tool invocation. Typically, the result + * is encoded inside the `content` field. + * + * Example: A `ToolMessage` representing a result of `42` from a tool call with id + * + * ```python + * from langchain_core.messages import ToolMessage + * + * ToolMessage(content="42", tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL") + * ``` + * + * Example: A `ToolMessage` where only part of the tool output is sent to the model and + * the full output is passed in to artifact. + * + * ```python + * from langchain_core.messages import ToolMessage + * + * tool_output = { + * "stdout": "From the graph we can see that the correlation between " + * "x and y is ...", + * "stderr": None, + * "artifacts": {"type": "image", "base64_data": "/9j/4gIcSU..."}, + * } + * + * ToolMessage( + * content=tool_output["stdout"], + * artifact=tool_output, + * tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL", + * ) + * ``` + * + * The `tool_call_id` field is used to associate the tool call request with the tool + * call response. Useful in situations where a chat model is able to request multiple + * tool calls in parallel. + */ + @JvmStatic fun ofTool(tool: ToolMessage) = Message(tool = tool) + + /** Message chunk from an AI (yielded when streaming). */ + @JvmStatic + fun ofAiMessageChunk(aiMessageChunk: AiMessageChunk) = + Message(aiMessageChunk = aiMessageChunk) + + /** Human Message chunk. */ + @JvmStatic + fun ofHumanMessageChunk(humanMessageChunk: HumanMessageChunk) = + Message(humanMessageChunk = humanMessageChunk) + + /** Chat Message chunk. */ + @JvmStatic + fun ofChatMessageChunk(chatMessageChunk: ChatMessageChunk) = + Message(chatMessageChunk = chatMessageChunk) + + /** System Message chunk. */ + @JvmStatic + fun ofSystemMessageChunk(systemMessageChunk: SystemMessageChunk) = + Message(systemMessageChunk = systemMessageChunk) + + /** Function Message chunk. */ + @JvmStatic + fun ofFunctionMessageChunk(functionMessageChunk: FunctionMessageChunk) = + Message(functionMessageChunk = functionMessageChunk) + + /** Tool Message chunk. */ + @JvmStatic + fun ofToolMessageChunk(toolMessageChunk: ToolMessageChunk) = + Message(toolMessageChunk = toolMessageChunk) + } + + /** + * An interface that defines how to map each variant of [Message] to a value of type [T]. + */ + interface Visitor<out T> { + + /** + * Message from an AI. + * + * An `AIMessage` is returned from a chat model as a response to a prompt. + * + * This message represents the output of the model and consists of both the raw output + * as returned by the model and standardized fields (e.g., tool calls, usage metadata) + * added by the LangChain framework. + */ + fun visitAi(ai: AiMessage): T + + /** + * Message from the user. + * + * A `HumanMessage` is a message that is passed in from a user to the model. + * + * Example: + * + * ```python + * from langchain_core.messages import HumanMessage, SystemMessage + * + * messages = [ + * SystemMessage(content="You are a helpful assistant! Your name is Bob."), + * HumanMessage(content="What is your name?"), + * ] + * + * # Instantiate a chat model and invoke it with the messages + * model = ... + * print(model.invoke(messages)) + * ``` + */ + fun visitHuman(human: HumanMessage): T + + /** Message that can be assigned an arbitrary speaker (i.e. role). */ + fun visitChat(chat: ChatMessage): T + + /** + * Message for priming AI behavior. + * + * The system message is usually passed in as the first of a sequence of input messages. + * + * Example: + * + * ```python + * from langchain_core.messages import HumanMessage, SystemMessage + * + * messages = [ + * SystemMessage(content="You are a helpful assistant! Your name is Bob."), + * HumanMessage(content="What is your name?"), + * ] + * + * # Define a chat model and invoke it with the messages + * print(model.invoke(messages)) + * ``` + */ + fun visitSystem(system: SystemMessage): T + + /** + * Message for passing the result of executing a tool back to a model. + * + * `FunctionMessage` are an older version of the `ToolMessage` schema, and do not + * contain the `tool_call_id` field. + * + * The `tool_call_id` field is used to associate the tool call request with the tool + * call response. Useful in situations where a chat model is able to request multiple + * tool calls in parallel. + */ + fun visitFunction(function: FunctionMessage): T + + /** + * Message for passing the result of executing a tool back to a model. + * + * `ToolMessage` objects contain the result of a tool invocation. Typically, the result + * is encoded inside the `content` field. + * + * Example: A `ToolMessage` representing a result of `42` from a tool call with id + * + * ```python + * from langchain_core.messages import ToolMessage + * + * ToolMessage(content="42", tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL") + * ``` + * + * Example: A `ToolMessage` where only part of the tool output is sent to the model and + * the full output is passed in to artifact. + * + * ```python + * from langchain_core.messages import ToolMessage + * + * tool_output = { + * "stdout": "From the graph we can see that the correlation between " + * "x and y is ...", + * "stderr": None, + * "artifacts": {"type": "image", "base64_data": "/9j/4gIcSU..."}, + * } + * + * ToolMessage( + * content=tool_output["stdout"], + * artifact=tool_output, + * tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL", + * ) + * ``` + * + * The `tool_call_id` field is used to associate the tool call request with the tool + * call response. Useful in situations where a chat model is able to request multiple + * tool calls in parallel. + */ + fun visitTool(tool: ToolMessage): T + + /** Message chunk from an AI (yielded when streaming). */ + fun visitAiMessageChunk(aiMessageChunk: AiMessageChunk): T + + /** Human Message chunk. */ + fun visitHumanMessageChunk(humanMessageChunk: HumanMessageChunk): T + + /** Chat Message chunk. */ + fun visitChatMessageChunk(chatMessageChunk: ChatMessageChunk): T + + /** System Message chunk. */ + fun visitSystemMessageChunk(systemMessageChunk: SystemMessageChunk): T + + /** Function Message chunk. */ + fun visitFunctionMessageChunk(functionMessageChunk: FunctionMessageChunk): T + + /** Tool Message chunk. */ + fun visitToolMessageChunk(toolMessageChunk: ToolMessageChunk): T + + /** + * Maps an unknown variant of [Message] to a value of type [T]. + * + * An instance of [Message] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Message: $json") + } + } + + internal class Deserializer : BaseDeserializer<Message>(Message::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Message { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<AiMessage>())?.let { + Message(ai = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<HumanMessage>())?.let { + Message(human = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<ChatMessage>())?.let { + Message(chat = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<SystemMessage>())?.let { + Message(system = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<FunctionMessage>())?.let { + Message(function = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<ToolMessage>())?.let { + Message(tool = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<AiMessageChunk>())?.let { + Message(aiMessageChunk = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<HumanMessageChunk>())?.let { + Message(humanMessageChunk = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<ChatMessageChunk>())?.let { + Message(chatMessageChunk = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<SystemMessageChunk>())?.let { + Message(systemMessageChunk = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<FunctionMessageChunk>())?.let { + Message(functionMessageChunk = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<ToolMessageChunk>())?.let { + Message(toolMessageChunk = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> Message(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Message>(Message::class) { + + override fun serialize( + value: Message, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.ai != null -> generator.writeObject(value.ai) + value.human != null -> generator.writeObject(value.human) + value.chat != null -> generator.writeObject(value.chat) + value.system != null -> generator.writeObject(value.system) + value.function != null -> generator.writeObject(value.function) + value.tool != null -> generator.writeObject(value.tool) + value.aiMessageChunk != null -> generator.writeObject(value.aiMessageChunk) + value.humanMessageChunk != null -> + generator.writeObject(value.humanMessageChunk) + value.chatMessageChunk != null -> generator.writeObject(value.chatMessageChunk) + value.systemMessageChunk != null -> + generator.writeObject(value.systemMessageChunk) + value.functionMessageChunk != null -> + generator.writeObject(value.functionMessageChunk) + value.toolMessageChunk != null -> generator.writeObject(value.toolMessageChunk) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Message") + } + } + } + + /** + * Message from an AI. + * + * An `AIMessage` is returned from a chat model as a response to a prompt. + * + * This message represents the output of the model and consists of both the raw output as + * returned by the model and standardized fields (e.g., tool calls, usage metadata) added by + * the LangChain framework. + */ + class AiMessage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val content: JsonField<Content>, + private val id: JsonField<String>, + private val additionalKwargs: JsonValue, + private val invalidToolCalls: JsonField<List<InvalidToolCall>>, + private val name: JsonField<String>, + private val responseMetadata: JsonValue, + private val toolCalls: JsonField<List<ToolCall>>, + private val type: JsonField<Type>, + private val usageMetadata: JsonField<UsageMetadata>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("content") + @ExcludeMissing + content: JsonField<Content> = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("additional_kwargs") + @ExcludeMissing + additionalKwargs: JsonValue = JsonMissing.of(), + @JsonProperty("invalid_tool_calls") + @ExcludeMissing + invalidToolCalls: JsonField<List<InvalidToolCall>> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("response_metadata") + @ExcludeMissing + responseMetadata: JsonValue = JsonMissing.of(), + @JsonProperty("tool_calls") + @ExcludeMissing + toolCalls: JsonField<List<ToolCall>> = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField<Type> = JsonMissing.of(), + @JsonProperty("usage_metadata") + @ExcludeMissing + usageMetadata: JsonField<UsageMetadata> = JsonMissing.of(), + ) : this( + content, + id, + additionalKwargs, + invalidToolCalls, + name, + responseMetadata, + toolCalls, + type, + usageMetadata, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun content(): Content = content.getRequired("content") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + @JsonProperty("additional_kwargs") + @ExcludeMissing + fun _additionalKwargs(): JsonValue = additionalKwargs + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun invalidToolCalls(): Optional<List<InvalidToolCall>> = + invalidToolCalls.getOptional("invalid_tool_calls") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun name(): Optional<String> = name.getOptional("name") + + @JsonProperty("response_metadata") + @ExcludeMissing + fun _responseMetadata(): JsonValue = responseMetadata + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun toolCalls(): Optional<List<ToolCall>> = toolCalls.getOptional("tool_calls") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun type(): Optional<Type> = type.getOptional("type") + + /** + * Usage metadata for a message, such as token counts. + * + * This is a standard representation of token usage that is consistent across models. + * + * Example: + * + * ```python + * { + * "input_tokens": 350, + * "output_tokens": 240, + * "total_tokens": 590, + * "input_token_details": { + * "audio": 10, + * "cache_creation": 200, + * "cache_read": 100, + * }, + * "output_token_details": { + * "audio": 10, + * "reasoning": 200, + * }, + * } + * ``` + * + * !!! warning "Behavior changed in 0.3.9" Added `input_token_details` and + * `output_token_details`. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun usageMetadata(): Optional<UsageMetadata> = + usageMetadata.getOptional("usage_metadata") + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField<Content> = content + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [invalidToolCalls]. + * + * Unlike [invalidToolCalls], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invalid_tool_calls") + @ExcludeMissing + fun _invalidToolCalls(): JsonField<List<InvalidToolCall>> = invalidToolCalls + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [toolCalls]. + * + * Unlike [toolCalls], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tool_calls") + @ExcludeMissing + fun _toolCalls(): JsonField<List<ToolCall>> = toolCalls + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField<Type> = type + + /** + * Returns the raw JSON value of [usageMetadata]. + * + * Unlike [usageMetadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("usage_metadata") + @ExcludeMissing + fun _usageMetadata(): JsonField<UsageMetadata> = usageMetadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AiMessage]. + * + * The following fields are required: + * ```java + * .content() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AiMessage]. */ + class Builder internal constructor() { + + private var content: JsonField<Content>? = null + private var id: JsonField<String> = JsonMissing.of() + private var additionalKwargs: JsonValue = JsonMissing.of() + private var invalidToolCalls: JsonField<MutableList<InvalidToolCall>>? = null + private var name: JsonField<String> = JsonMissing.of() + private var responseMetadata: JsonValue = JsonMissing.of() + private var toolCalls: JsonField<MutableList<ToolCall>>? = null + private var type: JsonField<Type> = JsonMissing.of() + private var usageMetadata: JsonField<UsageMetadata> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(aiMessage: AiMessage) = apply { + content = aiMessage.content + id = aiMessage.id + additionalKwargs = aiMessage.additionalKwargs + invalidToolCalls = aiMessage.invalidToolCalls.map { it.toMutableList() } + name = aiMessage.name + responseMetadata = aiMessage.responseMetadata + toolCalls = aiMessage.toolCalls.map { it.toMutableList() } + type = aiMessage.type + usageMetadata = aiMessage.usageMetadata + additionalProperties = aiMessage.additionalProperties.toMutableMap() + } + + fun content(content: Content) = content(JsonField.of(content)) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [Content] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun content(content: JsonField<Content>) = apply { this.content = content } + + /** Alias for calling [content] with `Content.ofString(string)`. */ + fun content(string: String) = content(Content.ofString(string)) + + /** + * Alias for calling [content] with + * `Content.ofUnnamedSchemaWithArrayParent0s(unnamedSchemaWithArrayParent0s)`. + */ + fun contentOfUnnamedSchemaWithArrayParent0s( + unnamedSchemaWithArrayParent0s: List<Content.UnnamedSchemaWithArrayParent0> + ) = + content( + Content.ofUnnamedSchemaWithArrayParent0s(unnamedSchemaWithArrayParent0s) + ) + + fun id(id: String?) = id(JsonField.ofNullable(id)) + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<String>) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun additionalKwargs(additionalKwargs: JsonValue) = apply { + this.additionalKwargs = additionalKwargs + } + + fun invalidToolCalls(invalidToolCalls: List<InvalidToolCall>) = + invalidToolCalls(JsonField.of(invalidToolCalls)) + + /** + * Sets [Builder.invalidToolCalls] to an arbitrary JSON value. + * + * You should usually call [Builder.invalidToolCalls] with a well-typed + * `List<InvalidToolCall>` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun invalidToolCalls(invalidToolCalls: JsonField<List<InvalidToolCall>>) = apply { + this.invalidToolCalls = invalidToolCalls.map { it.toMutableList() } + } + + /** + * Adds a single [InvalidToolCall] to [invalidToolCalls]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addInvalidToolCall(invalidToolCall: InvalidToolCall) = apply { + invalidToolCalls = + (invalidToolCalls ?: JsonField.of(mutableListOf())).also { + checkKnown("invalidToolCalls", it).add(invalidToolCall) + } + } + + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional<String>) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun responseMetadata(responseMetadata: JsonValue) = apply { + this.responseMetadata = responseMetadata + } + + fun toolCalls(toolCalls: List<ToolCall>) = toolCalls(JsonField.of(toolCalls)) + + /** + * Sets [Builder.toolCalls] to an arbitrary JSON value. + * + * You should usually call [Builder.toolCalls] with a well-typed `List<ToolCall>` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun toolCalls(toolCalls: JsonField<List<ToolCall>>) = apply { + this.toolCalls = toolCalls.map { it.toMutableList() } + } + + /** + * Adds a single [ToolCall] to [toolCalls]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addToolCall(toolCall: ToolCall) = apply { + toolCalls = + (toolCalls ?: JsonField.of(mutableListOf())).also { + checkKnown("toolCalls", it).add(toolCall) + } + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField<Type>) = apply { this.type = type } + + /** + * Usage metadata for a message, such as token counts. + * + * This is a standard representation of token usage that is consistent across + * models. + * + * Example: + * + * ```python + * { + * "input_tokens": 350, + * "output_tokens": 240, + * "total_tokens": 590, + * "input_token_details": { + * "audio": 10, + * "cache_creation": 200, + * "cache_read": 100, + * }, + * "output_token_details": { + * "audio": 10, + * "reasoning": 200, + * }, + * } + * ``` + * + * !!! warning "Behavior changed in 0.3.9" Added `input_token_details` and + * `output_token_details`. + */ + fun usageMetadata(usageMetadata: UsageMetadata?) = + usageMetadata(JsonField.ofNullable(usageMetadata)) + + /** Alias for calling [Builder.usageMetadata] with `usageMetadata.orElse(null)`. */ + fun usageMetadata(usageMetadata: Optional<UsageMetadata>) = + usageMetadata(usageMetadata.getOrNull()) + + /** + * Sets [Builder.usageMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.usageMetadata] with a well-typed [UsageMetadata] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun usageMetadata(usageMetadata: JsonField<UsageMetadata>) = apply { + this.usageMetadata = usageMetadata + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AiMessage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .content() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AiMessage = + AiMessage( + checkRequired("content", content), + id, + additionalKwargs, + (invalidToolCalls ?: JsonMissing.of()).map { it.toImmutable() }, + name, + responseMetadata, + (toolCalls ?: JsonMissing.of()).map { it.toImmutable() }, + type, + usageMetadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AiMessage = apply { + if (validated) { + return@apply + } + + content().validate() + id() + invalidToolCalls().ifPresent { it.forEach { it.validate() } } + name() + toolCalls().ifPresent { it.forEach { it.validate() } } + type().ifPresent { it.validate() } + usageMetadata().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (content.asKnown().getOrNull()?.validity() ?: 0) + + (if (id.asKnown().isPresent) 1 else 0) + + (invalidToolCalls.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (toolCalls.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (usageMetadata.asKnown().getOrNull()?.validity() ?: 0) + + @JsonDeserialize(using = Content.Deserializer::class) + @JsonSerialize(using = Content.Serializer::class) + class Content + private constructor( + private val string: String? = null, + private val unnamedSchemaWithArrayParent0s: List<UnnamedSchemaWithArrayParent0>? = + null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun unnamedSchemaWithArrayParent0s(): + Optional<List<UnnamedSchemaWithArrayParent0>> = + Optional.ofNullable(unnamedSchemaWithArrayParent0s) + + fun isString(): Boolean = string != null + + fun isUnnamedSchemaWithArrayParent0s(): Boolean = + unnamedSchemaWithArrayParent0s != null + + fun asString(): String = string.getOrThrow("string") + + fun asUnnamedSchemaWithArrayParent0s(): List<UnnamedSchemaWithArrayParent0> = + unnamedSchemaWithArrayParent0s.getOrThrow("unnamedSchemaWithArrayParent0s") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + string != null -> visitor.visitString(string) + unnamedSchemaWithArrayParent0s != null -> + visitor.visitUnnamedSchemaWithArrayParent0s( + unnamedSchemaWithArrayParent0s + ) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Content = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitString(string: String) {} + + override fun visitUnnamedSchemaWithArrayParent0s( + unnamedSchemaWithArrayParent0s: List<UnnamedSchemaWithArrayParent0> + ) { + unnamedSchemaWithArrayParent0s.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitString(string: String) = 1 + + override fun visitUnnamedSchemaWithArrayParent0s( + unnamedSchemaWithArrayParent0s: List<UnnamedSchemaWithArrayParent0> + ) = unnamedSchemaWithArrayParent0s.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Content && + string == other.string && + unnamedSchemaWithArrayParent0s == other.unnamedSchemaWithArrayParent0s + } + + override fun hashCode(): Int = Objects.hash(string, unnamedSchemaWithArrayParent0s) + + override fun toString(): String = + when { + string != null -> "Content{string=$string}" + unnamedSchemaWithArrayParent0s != null -> + "Content{unnamedSchemaWithArrayParent0s=$unnamedSchemaWithArrayParent0s}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Content(string = string) + + @JvmStatic + fun ofUnnamedSchemaWithArrayParent0s( + unnamedSchemaWithArrayParent0s: List<UnnamedSchemaWithArrayParent0> + ) = + Content( + unnamedSchemaWithArrayParent0s = + unnamedSchemaWithArrayParent0s.toImmutable() + ) + } + + /** + * An interface that defines how to map each variant of [Content] to a value of type + * [T]. + */ + interface Visitor<out T> { + + fun visitString(string: String): T + + fun visitUnnamedSchemaWithArrayParent0s( + unnamedSchemaWithArrayParent0s: List<UnnamedSchemaWithArrayParent0> + ): T + + /** + * Maps an unknown variant of [Content] to a value of type [T]. + * + * An instance of [Content] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Content: $json") + } + } + + internal class Deserializer : BaseDeserializer<Content>(Content::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Content { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<String>())?.let { + Content(string = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef<List<UnnamedSchemaWithArrayParent0>>(), + ) + ?.let { + Content( + unnamedSchemaWithArrayParent0s = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // object). + 0 -> Content(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Content>(Content::class) { + + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.unnamedSchemaWithArrayParent0s != null -> + generator.writeObject(value.unnamedSchemaWithArrayParent0s) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } + } + } + + @JsonDeserialize(using = UnnamedSchemaWithArrayParent0.Deserializer::class) + @JsonSerialize(using = UnnamedSchemaWithArrayParent0.Serializer::class) + class UnnamedSchemaWithArrayParent0 + private constructor( + private val string: String? = null, + private val jsonValue: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun jsonValue(): Optional<JsonValue> = Optional.ofNullable(jsonValue) + + fun isString(): Boolean = string != null + + fun isJsonValue(): Boolean = jsonValue != null + + fun asString(): String = string.getOrThrow("string") + + fun asJsonValue(): JsonValue = jsonValue.getOrThrow("jsonValue") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + string != null -> visitor.visitString(string) + jsonValue != null -> visitor.visitJsonValue(jsonValue) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent0 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitString(string: String) {} + + override fun visitJsonValue(jsonValue: JsonValue) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitString(string: String) = 1 + + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent0 && + string == other.string && + jsonValue == other.jsonValue + } + + override fun hashCode(): Int = Objects.hash(string, jsonValue) + + override fun toString(): String = + when { + string != null -> "UnnamedSchemaWithArrayParent0{string=$string}" + jsonValue != null -> + "UnnamedSchemaWithArrayParent0{jsonValue=$jsonValue}" + _json != null -> "UnnamedSchemaWithArrayParent0{_unknown=$_json}" + else -> + throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent0") + } + + companion object { + + @JvmStatic + fun ofString(string: String) = + UnnamedSchemaWithArrayParent0(string = string) + + @JvmStatic + fun ofJsonValue(jsonValue: JsonValue) = + UnnamedSchemaWithArrayParent0(jsonValue = jsonValue) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent0] to a value of type [T]. + */ + interface Visitor<out T> { + + fun visitString(string: String): T + + fun visitJsonValue(jsonValue: JsonValue): T + + /** + * Maps an unknown variant of [UnnamedSchemaWithArrayParent0] to a value of + * type [T]. + * + * An instance of [UnnamedSchemaWithArrayParent0] can contain an unknown + * variant if it was deserialized from data that doesn't match any known + * variant. For example, if the SDK is on an older version than the API, + * then the API may respond with new variants that the SDK is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent0: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer<UnnamedSchemaWithArrayParent0>( + UnnamedSchemaWithArrayParent0::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent0 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<String>())?.let { + UnnamedSchemaWithArrayParent0(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<JsonValue>())?.let { + UnnamedSchemaWithArrayParent0( + jsonValue = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants. + 0 -> UnnamedSchemaWithArrayParent0(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then + // use the first completely valid match, or simply the first match + // if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer<UnnamedSchemaWithArrayParent0>( + UnnamedSchemaWithArrayParent0::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent0, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.jsonValue != null -> generator.writeObject(value.jsonValue) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent0" + ) + } + } + } + } + } + + class Type @JsonCreator private constructor(private val value: JsonField<String>) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val AI = of("ai") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + AI + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AI, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AI -> Value.AI + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + AI -> Known.AI + else -> throw LangsmithApiInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AiMessage && + content == other.content && + id == other.id && + additionalKwargs == other.additionalKwargs && + invalidToolCalls == other.invalidToolCalls && + name == other.name && + responseMetadata == other.responseMetadata && + toolCalls == other.toolCalls && + type == other.type && + usageMetadata == other.usageMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + content, + id, + additionalKwargs, + invalidToolCalls, + name, + responseMetadata, + toolCalls, + type, + usageMetadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AiMessage{content=$content, id=$id, additionalKwargs=$additionalKwargs, invalidToolCalls=$invalidToolCalls, name=$name, responseMetadata=$responseMetadata, toolCalls=$toolCalls, type=$type, usageMetadata=$usageMetadata, additionalProperties=$additionalProperties}" + } + + /** + * Message from the user. + * + * A `HumanMessage` is a message that is passed in from a user to the model. + * + * Example: + * + * ```python + * from langchain_core.messages import HumanMessage, SystemMessage + * + * messages = [ + * SystemMessage(content="You are a helpful assistant! Your name is Bob."), + * HumanMessage(content="What is your name?"), + * ] + * + * # Instantiate a chat model and invoke it with the messages + * model = ... + * print(model.invoke(messages)) + * ``` + */ + class HumanMessage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val content: JsonField<Content>, + private val id: JsonField<String>, + private val additionalKwargs: JsonValue, + private val name: JsonField<String>, + private val responseMetadata: JsonValue, + private val type: JsonField<Type>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("content") + @ExcludeMissing + content: JsonField<Content> = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("additional_kwargs") + @ExcludeMissing + additionalKwargs: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("response_metadata") + @ExcludeMissing + responseMetadata: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField<Type> = JsonMissing.of(), + ) : this(content, id, additionalKwargs, name, responseMetadata, type, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun content(): Content = content.getRequired("content") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + @JsonProperty("additional_kwargs") + @ExcludeMissing + fun _additionalKwargs(): JsonValue = additionalKwargs + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun name(): Optional<String> = name.getOptional("name") + + @JsonProperty("response_metadata") + @ExcludeMissing + fun _responseMetadata(): JsonValue = responseMetadata + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun type(): Optional<Type> = type.getOptional("type") + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField<Content> = content + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField<Type> = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [HumanMessage]. + * + * The following fields are required: + * ```java + * .content() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [HumanMessage]. */ + class Builder internal constructor() { + + private var content: JsonField<Content>? = null + private var id: JsonField<String> = JsonMissing.of() + private var additionalKwargs: JsonValue = JsonMissing.of() + private var name: JsonField<String> = JsonMissing.of() + private var responseMetadata: JsonValue = JsonMissing.of() + private var type: JsonField<Type> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(humanMessage: HumanMessage) = apply { + content = humanMessage.content + id = humanMessage.id + additionalKwargs = humanMessage.additionalKwargs + name = humanMessage.name + responseMetadata = humanMessage.responseMetadata + type = humanMessage.type + additionalProperties = humanMessage.additionalProperties.toMutableMap() + } + + fun content(content: Content) = content(JsonField.of(content)) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [Content] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun content(content: JsonField<Content>) = apply { this.content = content } + + /** Alias for calling [content] with `Content.ofString(string)`. */ + fun content(string: String) = content(Content.ofString(string)) + + /** + * Alias for calling [content] with + * `Content.ofUnnamedSchemaWithArrayParent1s(unnamedSchemaWithArrayParent1s)`. + */ + fun contentOfUnnamedSchemaWithArrayParent1s( + unnamedSchemaWithArrayParent1s: List<Content.UnnamedSchemaWithArrayParent1> + ) = + content( + Content.ofUnnamedSchemaWithArrayParent1s(unnamedSchemaWithArrayParent1s) + ) + + fun id(id: String?) = id(JsonField.ofNullable(id)) + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<String>) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun additionalKwargs(additionalKwargs: JsonValue) = apply { + this.additionalKwargs = additionalKwargs + } + + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional<String>) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun responseMetadata(responseMetadata: JsonValue) = apply { + this.responseMetadata = responseMetadata + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField<Type>) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [HumanMessage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .content() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): HumanMessage = + HumanMessage( + checkRequired("content", content), + id, + additionalKwargs, + name, + responseMetadata, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): HumanMessage = apply { + if (validated) { + return@apply + } + + content().validate() + id() + name() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (content.asKnown().getOrNull()?.validity() ?: 0) + + (if (id.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + @JsonDeserialize(using = Content.Deserializer::class) + @JsonSerialize(using = Content.Serializer::class) + class Content + private constructor( + private val string: String? = null, + private val unnamedSchemaWithArrayParent1s: List<UnnamedSchemaWithArrayParent1>? = + null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun unnamedSchemaWithArrayParent1s(): + Optional<List<UnnamedSchemaWithArrayParent1>> = + Optional.ofNullable(unnamedSchemaWithArrayParent1s) + + fun isString(): Boolean = string != null + + fun isUnnamedSchemaWithArrayParent1s(): Boolean = + unnamedSchemaWithArrayParent1s != null + + fun asString(): String = string.getOrThrow("string") + + fun asUnnamedSchemaWithArrayParent1s(): List<UnnamedSchemaWithArrayParent1> = + unnamedSchemaWithArrayParent1s.getOrThrow("unnamedSchemaWithArrayParent1s") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + string != null -> visitor.visitString(string) + unnamedSchemaWithArrayParent1s != null -> + visitor.visitUnnamedSchemaWithArrayParent1s( + unnamedSchemaWithArrayParent1s + ) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Content = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitString(string: String) {} + + override fun visitUnnamedSchemaWithArrayParent1s( + unnamedSchemaWithArrayParent1s: List<UnnamedSchemaWithArrayParent1> + ) { + unnamedSchemaWithArrayParent1s.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitString(string: String) = 1 + + override fun visitUnnamedSchemaWithArrayParent1s( + unnamedSchemaWithArrayParent1s: List<UnnamedSchemaWithArrayParent1> + ) = unnamedSchemaWithArrayParent1s.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Content && + string == other.string && + unnamedSchemaWithArrayParent1s == other.unnamedSchemaWithArrayParent1s + } + + override fun hashCode(): Int = Objects.hash(string, unnamedSchemaWithArrayParent1s) + + override fun toString(): String = + when { + string != null -> "Content{string=$string}" + unnamedSchemaWithArrayParent1s != null -> + "Content{unnamedSchemaWithArrayParent1s=$unnamedSchemaWithArrayParent1s}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Content(string = string) + + @JvmStatic + fun ofUnnamedSchemaWithArrayParent1s( + unnamedSchemaWithArrayParent1s: List<UnnamedSchemaWithArrayParent1> + ) = + Content( + unnamedSchemaWithArrayParent1s = + unnamedSchemaWithArrayParent1s.toImmutable() + ) + } + + /** + * An interface that defines how to map each variant of [Content] to a value of type + * [T]. + */ + interface Visitor<out T> { + + fun visitString(string: String): T + + fun visitUnnamedSchemaWithArrayParent1s( + unnamedSchemaWithArrayParent1s: List<UnnamedSchemaWithArrayParent1> + ): T + + /** + * Maps an unknown variant of [Content] to a value of type [T]. + * + * An instance of [Content] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Content: $json") + } + } + + internal class Deserializer : BaseDeserializer<Content>(Content::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Content { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<String>())?.let { + Content(string = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef<List<UnnamedSchemaWithArrayParent1>>(), + ) + ?.let { + Content( + unnamedSchemaWithArrayParent1s = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // object). + 0 -> Content(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Content>(Content::class) { + + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.unnamedSchemaWithArrayParent1s != null -> + generator.writeObject(value.unnamedSchemaWithArrayParent1s) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } + } + } + + @JsonDeserialize(using = UnnamedSchemaWithArrayParent1.Deserializer::class) + @JsonSerialize(using = UnnamedSchemaWithArrayParent1.Serializer::class) + class UnnamedSchemaWithArrayParent1 + private constructor( + private val string: String? = null, + private val jsonValue: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun jsonValue(): Optional<JsonValue> = Optional.ofNullable(jsonValue) + + fun isString(): Boolean = string != null + + fun isJsonValue(): Boolean = jsonValue != null + + fun asString(): String = string.getOrThrow("string") + + fun asJsonValue(): JsonValue = jsonValue.getOrThrow("jsonValue") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + string != null -> visitor.visitString(string) + jsonValue != null -> visitor.visitJsonValue(jsonValue) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent1 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitString(string: String) {} + + override fun visitJsonValue(jsonValue: JsonValue) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitString(string: String) = 1 + + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent1 && + string == other.string && + jsonValue == other.jsonValue + } + + override fun hashCode(): Int = Objects.hash(string, jsonValue) + + override fun toString(): String = + when { + string != null -> "UnnamedSchemaWithArrayParent1{string=$string}" + jsonValue != null -> + "UnnamedSchemaWithArrayParent1{jsonValue=$jsonValue}" + _json != null -> "UnnamedSchemaWithArrayParent1{_unknown=$_json}" + else -> + throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent1") + } + + companion object { + + @JvmStatic + fun ofString(string: String) = + UnnamedSchemaWithArrayParent1(string = string) + + @JvmStatic + fun ofJsonValue(jsonValue: JsonValue) = + UnnamedSchemaWithArrayParent1(jsonValue = jsonValue) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent1] to a value of type [T]. + */ + interface Visitor<out T> { + + fun visitString(string: String): T + + fun visitJsonValue(jsonValue: JsonValue): T + + /** + * Maps an unknown variant of [UnnamedSchemaWithArrayParent1] to a value of + * type [T]. + * + * An instance of [UnnamedSchemaWithArrayParent1] can contain an unknown + * variant if it was deserialized from data that doesn't match any known + * variant. For example, if the SDK is on an older version than the API, + * then the API may respond with new variants that the SDK is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent1: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer<UnnamedSchemaWithArrayParent1>( + UnnamedSchemaWithArrayParent1::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent1 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<String>())?.let { + UnnamedSchemaWithArrayParent1(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<JsonValue>())?.let { + UnnamedSchemaWithArrayParent1( + jsonValue = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants. + 0 -> UnnamedSchemaWithArrayParent1(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then + // use the first completely valid match, or simply the first match + // if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer<UnnamedSchemaWithArrayParent1>( + UnnamedSchemaWithArrayParent1::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent1, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.jsonValue != null -> generator.writeObject(value.jsonValue) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent1" + ) + } + } + } + } + } + + class Type @JsonCreator private constructor(private val value: JsonField<String>) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val HUMAN = of("human") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + HUMAN + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HUMAN, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HUMAN -> Value.HUMAN + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + HUMAN -> Known.HUMAN + else -> throw LangsmithApiInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is HumanMessage && + content == other.content && + id == other.id && + additionalKwargs == other.additionalKwargs && + name == other.name && + responseMetadata == other.responseMetadata && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + content, + id, + additionalKwargs, + name, + responseMetadata, + type, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "HumanMessage{content=$content, id=$id, additionalKwargs=$additionalKwargs, name=$name, responseMetadata=$responseMetadata, type=$type, additionalProperties=$additionalProperties}" + } + + /** Message that can be assigned an arbitrary speaker (i.e. role). */ + class ChatMessage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val content: JsonField<Content>, + private val role: JsonField<String>, + private val id: JsonField<String>, + private val additionalKwargs: JsonValue, + private val name: JsonField<String>, + private val responseMetadata: JsonValue, + private val type: JsonField<Type>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("content") + @ExcludeMissing + content: JsonField<Content> = JsonMissing.of(), + @JsonProperty("role") @ExcludeMissing role: JsonField<String> = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("additional_kwargs") + @ExcludeMissing + additionalKwargs: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("response_metadata") + @ExcludeMissing + responseMetadata: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField<Type> = JsonMissing.of(), + ) : this( + content, + role, + id, + additionalKwargs, + name, + responseMetadata, + type, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun content(): Content = content.getRequired("content") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun role(): String = role.getRequired("role") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + @JsonProperty("additional_kwargs") + @ExcludeMissing + fun _additionalKwargs(): JsonValue = additionalKwargs + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun name(): Optional<String> = name.getOptional("name") + + @JsonProperty("response_metadata") + @ExcludeMissing + fun _responseMetadata(): JsonValue = responseMetadata + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun type(): Optional<Type> = type.getOptional("type") + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField<Content> = content + + /** + * Returns the raw JSON value of [role]. + * + * Unlike [role], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("role") @ExcludeMissing fun _role(): JsonField<String> = role + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField<Type> = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ChatMessage]. + * + * The following fields are required: + * ```java + * .content() + * .role() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatMessage]. */ + class Builder internal constructor() { + + private var content: JsonField<Content>? = null + private var role: JsonField<String>? = null + private var id: JsonField<String> = JsonMissing.of() + private var additionalKwargs: JsonValue = JsonMissing.of() + private var name: JsonField<String> = JsonMissing.of() + private var responseMetadata: JsonValue = JsonMissing.of() + private var type: JsonField<Type> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(chatMessage: ChatMessage) = apply { + content = chatMessage.content + role = chatMessage.role + id = chatMessage.id + additionalKwargs = chatMessage.additionalKwargs + name = chatMessage.name + responseMetadata = chatMessage.responseMetadata + type = chatMessage.type + additionalProperties = chatMessage.additionalProperties.toMutableMap() + } + + fun content(content: Content) = content(JsonField.of(content)) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [Content] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun content(content: JsonField<Content>) = apply { this.content = content } + + /** Alias for calling [content] with `Content.ofString(string)`. */ + fun content(string: String) = content(Content.ofString(string)) + + /** + * Alias for calling [content] with + * `Content.ofUnnamedSchemaWithArrayParent2s(unnamedSchemaWithArrayParent2s)`. + */ + fun contentOfUnnamedSchemaWithArrayParent2s( + unnamedSchemaWithArrayParent2s: List<Content.UnnamedSchemaWithArrayParent2> + ) = + content( + Content.ofUnnamedSchemaWithArrayParent2s(unnamedSchemaWithArrayParent2s) + ) + + fun role(role: String) = role(JsonField.of(role)) + + /** + * Sets [Builder.role] to an arbitrary JSON value. + * + * You should usually call [Builder.role] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun role(role: JsonField<String>) = apply { this.role = role } + + fun id(id: String?) = id(JsonField.ofNullable(id)) + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<String>) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun additionalKwargs(additionalKwargs: JsonValue) = apply { + this.additionalKwargs = additionalKwargs + } + + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional<String>) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun responseMetadata(responseMetadata: JsonValue) = apply { + this.responseMetadata = responseMetadata + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField<Type>) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChatMessage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .content() + * .role() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChatMessage = + ChatMessage( + checkRequired("content", content), + checkRequired("role", role), + id, + additionalKwargs, + name, + responseMetadata, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatMessage = apply { + if (validated) { + return@apply + } + + content().validate() + role() + id() + name() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (content.asKnown().getOrNull()?.validity() ?: 0) + + (if (role.asKnown().isPresent) 1 else 0) + + (if (id.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + @JsonDeserialize(using = Content.Deserializer::class) + @JsonSerialize(using = Content.Serializer::class) + class Content + private constructor( + private val string: String? = null, + private val unnamedSchemaWithArrayParent2s: List<UnnamedSchemaWithArrayParent2>? = + null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun unnamedSchemaWithArrayParent2s(): + Optional<List<UnnamedSchemaWithArrayParent2>> = + Optional.ofNullable(unnamedSchemaWithArrayParent2s) + + fun isString(): Boolean = string != null + + fun isUnnamedSchemaWithArrayParent2s(): Boolean = + unnamedSchemaWithArrayParent2s != null + + fun asString(): String = string.getOrThrow("string") + + fun asUnnamedSchemaWithArrayParent2s(): List<UnnamedSchemaWithArrayParent2> = + unnamedSchemaWithArrayParent2s.getOrThrow("unnamedSchemaWithArrayParent2s") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + string != null -> visitor.visitString(string) + unnamedSchemaWithArrayParent2s != null -> + visitor.visitUnnamedSchemaWithArrayParent2s( + unnamedSchemaWithArrayParent2s + ) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Content = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitString(string: String) {} + + override fun visitUnnamedSchemaWithArrayParent2s( + unnamedSchemaWithArrayParent2s: List<UnnamedSchemaWithArrayParent2> + ) { + unnamedSchemaWithArrayParent2s.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitString(string: String) = 1 + + override fun visitUnnamedSchemaWithArrayParent2s( + unnamedSchemaWithArrayParent2s: List<UnnamedSchemaWithArrayParent2> + ) = unnamedSchemaWithArrayParent2s.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Content && + string == other.string && + unnamedSchemaWithArrayParent2s == other.unnamedSchemaWithArrayParent2s + } + + override fun hashCode(): Int = Objects.hash(string, unnamedSchemaWithArrayParent2s) + + override fun toString(): String = + when { + string != null -> "Content{string=$string}" + unnamedSchemaWithArrayParent2s != null -> + "Content{unnamedSchemaWithArrayParent2s=$unnamedSchemaWithArrayParent2s}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Content(string = string) + + @JvmStatic + fun ofUnnamedSchemaWithArrayParent2s( + unnamedSchemaWithArrayParent2s: List<UnnamedSchemaWithArrayParent2> + ) = + Content( + unnamedSchemaWithArrayParent2s = + unnamedSchemaWithArrayParent2s.toImmutable() + ) + } + + /** + * An interface that defines how to map each variant of [Content] to a value of type + * [T]. + */ + interface Visitor<out T> { + + fun visitString(string: String): T + + fun visitUnnamedSchemaWithArrayParent2s( + unnamedSchemaWithArrayParent2s: List<UnnamedSchemaWithArrayParent2> + ): T + + /** + * Maps an unknown variant of [Content] to a value of type [T]. + * + * An instance of [Content] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Content: $json") + } + } + + internal class Deserializer : BaseDeserializer<Content>(Content::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Content { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<String>())?.let { + Content(string = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef<List<UnnamedSchemaWithArrayParent2>>(), + ) + ?.let { + Content( + unnamedSchemaWithArrayParent2s = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // object). + 0 -> Content(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Content>(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") + } + } + } + + @JsonDeserialize(using = UnnamedSchemaWithArrayParent2.Deserializer::class) + @JsonSerialize(using = UnnamedSchemaWithArrayParent2.Serializer::class) + class UnnamedSchemaWithArrayParent2 + private constructor( + private val string: String? = null, + private val jsonValue: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun jsonValue(): Optional<JsonValue> = Optional.ofNullable(jsonValue) + + fun isString(): Boolean = string != null + + fun isJsonValue(): Boolean = jsonValue != null + + fun asString(): String = string.getOrThrow("string") + + fun asJsonValue(): JsonValue = jsonValue.getOrThrow("jsonValue") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + string != null -> visitor.visitString(string) + jsonValue != null -> visitor.visitJsonValue(jsonValue) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent2 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitString(string: String) {} + + override fun visitJsonValue(jsonValue: JsonValue) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitString(string: String) = 1 + + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent2 && + string == other.string && + jsonValue == other.jsonValue + } + + override fun hashCode(): Int = Objects.hash(string, jsonValue) + + override fun toString(): String = + when { + string != null -> "UnnamedSchemaWithArrayParent2{string=$string}" + jsonValue != null -> + "UnnamedSchemaWithArrayParent2{jsonValue=$jsonValue}" + _json != null -> "UnnamedSchemaWithArrayParent2{_unknown=$_json}" + else -> + throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent2") + } + + companion object { + + @JvmStatic + fun ofString(string: String) = + UnnamedSchemaWithArrayParent2(string = string) + + @JvmStatic + fun ofJsonValue(jsonValue: JsonValue) = + UnnamedSchemaWithArrayParent2(jsonValue = jsonValue) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent2] to a value of type [T]. + */ + interface Visitor<out T> { + + fun visitString(string: String): T + + fun visitJsonValue(jsonValue: JsonValue): T + + /** + * Maps an unknown variant of [UnnamedSchemaWithArrayParent2] to a value of + * type [T]. + * + * An instance of [UnnamedSchemaWithArrayParent2] can contain an unknown + * variant if it was deserialized from data that doesn't match any known + * variant. For example, if the SDK is on an older version than the API, + * then the API may respond with new variants that the SDK is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent2: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer<UnnamedSchemaWithArrayParent2>( + UnnamedSchemaWithArrayParent2::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent2 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<String>())?.let { + UnnamedSchemaWithArrayParent2(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<JsonValue>())?.let { + UnnamedSchemaWithArrayParent2( + jsonValue = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants. + 0 -> UnnamedSchemaWithArrayParent2(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then + // use the first completely valid match, or simply the first match + // if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer<UnnamedSchemaWithArrayParent2>( + UnnamedSchemaWithArrayParent2::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent2, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.jsonValue != null -> generator.writeObject(value.jsonValue) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent2" + ) + } + } + } + } + } + + class Type @JsonCreator private constructor(private val value: JsonField<String>) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val CHAT = of("chat") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + CHAT + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CHAT, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CHAT -> Value.CHAT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + CHAT -> Known.CHAT + else -> throw LangsmithApiInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatMessage && + content == other.content && + role == other.role && + id == other.id && + additionalKwargs == other.additionalKwargs && + name == other.name && + responseMetadata == other.responseMetadata && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + content, + role, + id, + additionalKwargs, + name, + responseMetadata, + type, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatMessage{content=$content, role=$role, id=$id, additionalKwargs=$additionalKwargs, name=$name, responseMetadata=$responseMetadata, type=$type, additionalProperties=$additionalProperties}" + } + + /** + * Message for priming AI behavior. + * + * The system message is usually passed in as the first of a sequence of input messages. + * + * Example: + * + * ```python + * from langchain_core.messages import HumanMessage, SystemMessage + * + * messages = [ + * SystemMessage(content="You are a helpful assistant! Your name is Bob."), + * HumanMessage(content="What is your name?"), + * ] + * + * # Define a chat model and invoke it with the messages + * print(model.invoke(messages)) + * ``` + */ + class SystemMessage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val content: JsonField<Content>, + private val id: JsonField<String>, + private val additionalKwargs: JsonValue, + private val name: JsonField<String>, + private val responseMetadata: JsonValue, + private val type: JsonField<Type>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("content") + @ExcludeMissing + content: JsonField<Content> = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("additional_kwargs") + @ExcludeMissing + additionalKwargs: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("response_metadata") + @ExcludeMissing + responseMetadata: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField<Type> = JsonMissing.of(), + ) : this(content, id, additionalKwargs, name, responseMetadata, type, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun content(): Content = content.getRequired("content") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + @JsonProperty("additional_kwargs") + @ExcludeMissing + fun _additionalKwargs(): JsonValue = additionalKwargs + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun name(): Optional<String> = name.getOptional("name") + + @JsonProperty("response_metadata") + @ExcludeMissing + fun _responseMetadata(): JsonValue = responseMetadata + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun type(): Optional<Type> = type.getOptional("type") + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField<Content> = content + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField<Type> = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SystemMessage]. + * + * The following fields are required: + * ```java + * .content() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SystemMessage]. */ + class Builder internal constructor() { + + private var content: JsonField<Content>? = null + private var id: JsonField<String> = JsonMissing.of() + private var additionalKwargs: JsonValue = JsonMissing.of() + private var name: JsonField<String> = JsonMissing.of() + private var responseMetadata: JsonValue = JsonMissing.of() + private var type: JsonField<Type> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(systemMessage: SystemMessage) = apply { + content = systemMessage.content + id = systemMessage.id + additionalKwargs = systemMessage.additionalKwargs + name = systemMessage.name + responseMetadata = systemMessage.responseMetadata + type = systemMessage.type + additionalProperties = systemMessage.additionalProperties.toMutableMap() + } + + fun content(content: Content) = content(JsonField.of(content)) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [Content] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun content(content: JsonField<Content>) = apply { this.content = content } + + /** Alias for calling [content] with `Content.ofString(string)`. */ + fun content(string: String) = content(Content.ofString(string)) + + /** + * Alias for calling [content] with + * `Content.ofUnnamedSchemaWithArrayParent3s(unnamedSchemaWithArrayParent3s)`. + */ + fun contentOfUnnamedSchemaWithArrayParent3s( + unnamedSchemaWithArrayParent3s: List<Content.UnnamedSchemaWithArrayParent3> + ) = + content( + Content.ofUnnamedSchemaWithArrayParent3s(unnamedSchemaWithArrayParent3s) + ) + + fun id(id: String?) = id(JsonField.ofNullable(id)) + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<String>) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun additionalKwargs(additionalKwargs: JsonValue) = apply { + this.additionalKwargs = additionalKwargs + } + + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional<String>) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun responseMetadata(responseMetadata: JsonValue) = apply { + this.responseMetadata = responseMetadata + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField<Type>) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SystemMessage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .content() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SystemMessage = + SystemMessage( + checkRequired("content", content), + id, + additionalKwargs, + name, + responseMetadata, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SystemMessage = apply { + if (validated) { + return@apply + } + + content().validate() + id() + name() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (content.asKnown().getOrNull()?.validity() ?: 0) + + (if (id.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + @JsonDeserialize(using = Content.Deserializer::class) + @JsonSerialize(using = Content.Serializer::class) + class Content + private constructor( + private val string: String? = null, + private val unnamedSchemaWithArrayParent3s: List<UnnamedSchemaWithArrayParent3>? = + null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun unnamedSchemaWithArrayParent3s(): + Optional<List<UnnamedSchemaWithArrayParent3>> = + Optional.ofNullable(unnamedSchemaWithArrayParent3s) + + fun isString(): Boolean = string != null + + fun isUnnamedSchemaWithArrayParent3s(): Boolean = + unnamedSchemaWithArrayParent3s != null + + fun asString(): String = string.getOrThrow("string") + + fun asUnnamedSchemaWithArrayParent3s(): List<UnnamedSchemaWithArrayParent3> = + unnamedSchemaWithArrayParent3s.getOrThrow("unnamedSchemaWithArrayParent3s") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + string != null -> visitor.visitString(string) + unnamedSchemaWithArrayParent3s != null -> + visitor.visitUnnamedSchemaWithArrayParent3s( + unnamedSchemaWithArrayParent3s + ) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Content = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitString(string: String) {} + + override fun visitUnnamedSchemaWithArrayParent3s( + unnamedSchemaWithArrayParent3s: List<UnnamedSchemaWithArrayParent3> + ) { + unnamedSchemaWithArrayParent3s.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitString(string: String) = 1 + + override fun visitUnnamedSchemaWithArrayParent3s( + unnamedSchemaWithArrayParent3s: List<UnnamedSchemaWithArrayParent3> + ) = unnamedSchemaWithArrayParent3s.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Content && + string == other.string && + unnamedSchemaWithArrayParent3s == other.unnamedSchemaWithArrayParent3s + } + + override fun hashCode(): Int = Objects.hash(string, unnamedSchemaWithArrayParent3s) + + override fun toString(): String = + when { + string != null -> "Content{string=$string}" + unnamedSchemaWithArrayParent3s != null -> + "Content{unnamedSchemaWithArrayParent3s=$unnamedSchemaWithArrayParent3s}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Content(string = string) + + @JvmStatic + fun ofUnnamedSchemaWithArrayParent3s( + unnamedSchemaWithArrayParent3s: List<UnnamedSchemaWithArrayParent3> + ) = + Content( + unnamedSchemaWithArrayParent3s = + unnamedSchemaWithArrayParent3s.toImmutable() + ) + } + + /** + * An interface that defines how to map each variant of [Content] to a value of type + * [T]. + */ + interface Visitor<out T> { + + fun visitString(string: String): T + + fun visitUnnamedSchemaWithArrayParent3s( + unnamedSchemaWithArrayParent3s: List<UnnamedSchemaWithArrayParent3> + ): T + + /** + * Maps an unknown variant of [Content] to a value of type [T]. + * + * An instance of [Content] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Content: $json") + } + } + + internal class Deserializer : BaseDeserializer<Content>(Content::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Content { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<String>())?.let { + Content(string = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef<List<UnnamedSchemaWithArrayParent3>>(), + ) + ?.let { + Content( + unnamedSchemaWithArrayParent3s = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // object). + 0 -> Content(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Content>(Content::class) { + + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.unnamedSchemaWithArrayParent3s != null -> + generator.writeObject(value.unnamedSchemaWithArrayParent3s) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } + } + } + + @JsonDeserialize(using = UnnamedSchemaWithArrayParent3.Deserializer::class) + @JsonSerialize(using = UnnamedSchemaWithArrayParent3.Serializer::class) + class UnnamedSchemaWithArrayParent3 + private constructor( + private val string: String? = null, + private val jsonValue: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun jsonValue(): Optional<JsonValue> = Optional.ofNullable(jsonValue) + + fun isString(): Boolean = string != null + + fun isJsonValue(): Boolean = jsonValue != null + + fun asString(): String = string.getOrThrow("string") + + fun asJsonValue(): JsonValue = jsonValue.getOrThrow("jsonValue") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + string != null -> visitor.visitString(string) + jsonValue != null -> visitor.visitJsonValue(jsonValue) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent3 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitString(string: String) {} + + override fun visitJsonValue(jsonValue: JsonValue) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitString(string: String) = 1 + + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent3 && + string == other.string && + jsonValue == other.jsonValue + } + + override fun hashCode(): Int = Objects.hash(string, jsonValue) + + override fun toString(): String = + when { + string != null -> "UnnamedSchemaWithArrayParent3{string=$string}" + jsonValue != null -> + "UnnamedSchemaWithArrayParent3{jsonValue=$jsonValue}" + _json != null -> "UnnamedSchemaWithArrayParent3{_unknown=$_json}" + else -> + throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent3") + } + + companion object { + + @JvmStatic + fun ofString(string: String) = + UnnamedSchemaWithArrayParent3(string = string) + + @JvmStatic + fun ofJsonValue(jsonValue: JsonValue) = + UnnamedSchemaWithArrayParent3(jsonValue = jsonValue) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent3] to a value of type [T]. + */ + interface Visitor<out T> { + + fun visitString(string: String): T + + fun visitJsonValue(jsonValue: JsonValue): T + + /** + * Maps an unknown variant of [UnnamedSchemaWithArrayParent3] to a value of + * type [T]. + * + * An instance of [UnnamedSchemaWithArrayParent3] can contain an unknown + * variant if it was deserialized from data that doesn't match any known + * variant. For example, if the SDK is on an older version than the API, + * then the API may respond with new variants that the SDK is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent3: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer<UnnamedSchemaWithArrayParent3>( + UnnamedSchemaWithArrayParent3::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent3 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<String>())?.let { + UnnamedSchemaWithArrayParent3(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<JsonValue>())?.let { + UnnamedSchemaWithArrayParent3( + jsonValue = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants. + 0 -> UnnamedSchemaWithArrayParent3(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then + // use the first completely valid match, or simply the first match + // if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer<UnnamedSchemaWithArrayParent3>( + UnnamedSchemaWithArrayParent3::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent3, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.jsonValue != null -> generator.writeObject(value.jsonValue) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent3" + ) + } + } + } + } + } + + class Type @JsonCreator private constructor(private val value: JsonField<String>) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val SYSTEM = of("system") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + SYSTEM + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SYSTEM, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SYSTEM -> Value.SYSTEM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + SYSTEM -> Known.SYSTEM + else -> throw LangsmithApiInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SystemMessage && + content == other.content && + id == other.id && + additionalKwargs == other.additionalKwargs && + name == other.name && + responseMetadata == other.responseMetadata && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + content, + id, + additionalKwargs, + name, + responseMetadata, + type, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SystemMessage{content=$content, id=$id, additionalKwargs=$additionalKwargs, name=$name, responseMetadata=$responseMetadata, type=$type, additionalProperties=$additionalProperties}" + } + + /** + * Message for passing the result of executing a tool back to a model. + * + * `FunctionMessage` are an older version of the `ToolMessage` schema, and do not contain + * the `tool_call_id` field. + * + * The `tool_call_id` field is used to associate the tool call request with the tool call + * response. Useful in situations where a chat model is able to request multiple tool calls + * in parallel. + */ + class FunctionMessage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val content: JsonField<Content>, + private val name: JsonField<String>, + private val id: JsonField<String>, + private val additionalKwargs: JsonValue, + private val responseMetadata: JsonValue, + private val type: JsonField<Type>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("content") + @ExcludeMissing + content: JsonField<Content> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("additional_kwargs") + @ExcludeMissing + additionalKwargs: JsonValue = JsonMissing.of(), + @JsonProperty("response_metadata") + @ExcludeMissing + responseMetadata: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField<Type> = JsonMissing.of(), + ) : this(content, name, id, additionalKwargs, responseMetadata, type, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun content(): Content = content.getRequired("content") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + @JsonProperty("additional_kwargs") + @ExcludeMissing + fun _additionalKwargs(): JsonValue = additionalKwargs + + @JsonProperty("response_metadata") + @ExcludeMissing + fun _responseMetadata(): JsonValue = responseMetadata + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun type(): Optional<Type> = type.getOptional("type") + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField<Content> = content + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField<Type> = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [FunctionMessage]. + * + * The following fields are required: + * ```java + * .content() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FunctionMessage]. */ + class Builder internal constructor() { + + private var content: JsonField<Content>? = null + private var name: JsonField<String>? = null + private var id: JsonField<String> = JsonMissing.of() + private var additionalKwargs: JsonValue = JsonMissing.of() + private var responseMetadata: JsonValue = JsonMissing.of() + private var type: JsonField<Type> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(functionMessage: FunctionMessage) = apply { + content = functionMessage.content + name = functionMessage.name + id = functionMessage.id + additionalKwargs = functionMessage.additionalKwargs + responseMetadata = functionMessage.responseMetadata + type = functionMessage.type + additionalProperties = functionMessage.additionalProperties.toMutableMap() + } + + fun content(content: Content) = content(JsonField.of(content)) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [Content] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun content(content: JsonField<Content>) = apply { this.content = content } + + /** Alias for calling [content] with `Content.ofString(string)`. */ + fun content(string: String) = content(Content.ofString(string)) + + /** + * Alias for calling [content] with + * `Content.ofUnnamedSchemaWithArrayParent4s(unnamedSchemaWithArrayParent4s)`. + */ + fun contentOfUnnamedSchemaWithArrayParent4s( + unnamedSchemaWithArrayParent4s: List<Content.UnnamedSchemaWithArrayParent4> + ) = + content( + Content.ofUnnamedSchemaWithArrayParent4s(unnamedSchemaWithArrayParent4s) + ) + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun id(id: String?) = id(JsonField.ofNullable(id)) + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<String>) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun additionalKwargs(additionalKwargs: JsonValue) = apply { + this.additionalKwargs = additionalKwargs + } + + fun responseMetadata(responseMetadata: JsonValue) = apply { + this.responseMetadata = responseMetadata + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField<Type>) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FunctionMessage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .content() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FunctionMessage = + FunctionMessage( + checkRequired("content", content), + checkRequired("name", name), + id, + additionalKwargs, + responseMetadata, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): FunctionMessage = apply { + if (validated) { + return@apply + } + + content().validate() + name() + id() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (content.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (id.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + @JsonDeserialize(using = Content.Deserializer::class) + @JsonSerialize(using = Content.Serializer::class) + class Content + private constructor( + private val string: String? = null, + private val unnamedSchemaWithArrayParent4s: List<UnnamedSchemaWithArrayParent4>? = + null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun unnamedSchemaWithArrayParent4s(): + Optional<List<UnnamedSchemaWithArrayParent4>> = + Optional.ofNullable(unnamedSchemaWithArrayParent4s) + + fun isString(): Boolean = string != null + + fun isUnnamedSchemaWithArrayParent4s(): Boolean = + unnamedSchemaWithArrayParent4s != null + + fun asString(): String = string.getOrThrow("string") + + fun asUnnamedSchemaWithArrayParent4s(): List<UnnamedSchemaWithArrayParent4> = + unnamedSchemaWithArrayParent4s.getOrThrow("unnamedSchemaWithArrayParent4s") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + string != null -> visitor.visitString(string) + unnamedSchemaWithArrayParent4s != null -> + visitor.visitUnnamedSchemaWithArrayParent4s( + unnamedSchemaWithArrayParent4s + ) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Content = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitString(string: String) {} + + override fun visitUnnamedSchemaWithArrayParent4s( + unnamedSchemaWithArrayParent4s: List<UnnamedSchemaWithArrayParent4> + ) { + unnamedSchemaWithArrayParent4s.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitString(string: String) = 1 + + override fun visitUnnamedSchemaWithArrayParent4s( + unnamedSchemaWithArrayParent4s: List<UnnamedSchemaWithArrayParent4> + ) = unnamedSchemaWithArrayParent4s.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Content && + string == other.string && + unnamedSchemaWithArrayParent4s == other.unnamedSchemaWithArrayParent4s + } + + override fun hashCode(): Int = Objects.hash(string, unnamedSchemaWithArrayParent4s) + + override fun toString(): String = + when { + string != null -> "Content{string=$string}" + unnamedSchemaWithArrayParent4s != null -> + "Content{unnamedSchemaWithArrayParent4s=$unnamedSchemaWithArrayParent4s}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Content(string = string) + + @JvmStatic + fun ofUnnamedSchemaWithArrayParent4s( + unnamedSchemaWithArrayParent4s: List<UnnamedSchemaWithArrayParent4> + ) = + Content( + unnamedSchemaWithArrayParent4s = + unnamedSchemaWithArrayParent4s.toImmutable() + ) + } + + /** + * An interface that defines how to map each variant of [Content] to a value of type + * [T]. + */ + interface Visitor<out T> { + + fun visitString(string: String): T + + fun visitUnnamedSchemaWithArrayParent4s( + unnamedSchemaWithArrayParent4s: List<UnnamedSchemaWithArrayParent4> + ): T + + /** + * Maps an unknown variant of [Content] to a value of type [T]. + * + * An instance of [Content] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Content: $json") + } + } + + internal class Deserializer : BaseDeserializer<Content>(Content::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Content { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<String>())?.let { + Content(string = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef<List<UnnamedSchemaWithArrayParent4>>(), + ) + ?.let { + Content( + unnamedSchemaWithArrayParent4s = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // object). + 0 -> Content(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Content>(Content::class) { + + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.unnamedSchemaWithArrayParent4s != null -> + generator.writeObject(value.unnamedSchemaWithArrayParent4s) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } + } + } + + @JsonDeserialize(using = UnnamedSchemaWithArrayParent4.Deserializer::class) + @JsonSerialize(using = UnnamedSchemaWithArrayParent4.Serializer::class) + class UnnamedSchemaWithArrayParent4 + private constructor( + private val string: String? = null, + private val jsonValue: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun jsonValue(): Optional<JsonValue> = Optional.ofNullable(jsonValue) + + fun isString(): Boolean = string != null + + fun isJsonValue(): Boolean = jsonValue != null + + fun asString(): String = string.getOrThrow("string") + + fun asJsonValue(): JsonValue = jsonValue.getOrThrow("jsonValue") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + string != null -> visitor.visitString(string) + jsonValue != null -> visitor.visitJsonValue(jsonValue) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent4 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitString(string: String) {} + + override fun visitJsonValue(jsonValue: JsonValue) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitString(string: String) = 1 + + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent4 && + string == other.string && + jsonValue == other.jsonValue + } + + override fun hashCode(): Int = Objects.hash(string, jsonValue) + + override fun toString(): String = + when { + string != null -> "UnnamedSchemaWithArrayParent4{string=$string}" + jsonValue != null -> + "UnnamedSchemaWithArrayParent4{jsonValue=$jsonValue}" + _json != null -> "UnnamedSchemaWithArrayParent4{_unknown=$_json}" + else -> + throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent4") + } + + companion object { + + @JvmStatic + fun ofString(string: String) = + UnnamedSchemaWithArrayParent4(string = string) + + @JvmStatic + fun ofJsonValue(jsonValue: JsonValue) = + UnnamedSchemaWithArrayParent4(jsonValue = jsonValue) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent4] to a value of type [T]. + */ + interface Visitor<out T> { + + fun visitString(string: String): T + + fun visitJsonValue(jsonValue: JsonValue): T + + /** + * Maps an unknown variant of [UnnamedSchemaWithArrayParent4] to a value of + * type [T]. + * + * An instance of [UnnamedSchemaWithArrayParent4] can contain an unknown + * variant if it was deserialized from data that doesn't match any known + * variant. For example, if the SDK is on an older version than the API, + * then the API may respond with new variants that the SDK is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent4: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer<UnnamedSchemaWithArrayParent4>( + UnnamedSchemaWithArrayParent4::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent4 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<String>())?.let { + UnnamedSchemaWithArrayParent4(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<JsonValue>())?.let { + UnnamedSchemaWithArrayParent4( + jsonValue = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants. + 0 -> UnnamedSchemaWithArrayParent4(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then + // use the first completely valid match, or simply the first match + // if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer<UnnamedSchemaWithArrayParent4>( + UnnamedSchemaWithArrayParent4::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent4, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.jsonValue != null -> generator.writeObject(value.jsonValue) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent4" + ) + } + } + } + } + } + + class Type @JsonCreator private constructor(private val value: JsonField<String>) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val FUNCTION = of("function") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + FUNCTION + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + FUNCTION, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + FUNCTION -> Value.FUNCTION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + FUNCTION -> Known.FUNCTION + else -> throw LangsmithApiInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FunctionMessage && + content == other.content && + name == other.name && + id == other.id && + additionalKwargs == other.additionalKwargs && + responseMetadata == other.responseMetadata && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + content, + name, + id, + additionalKwargs, + responseMetadata, + type, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FunctionMessage{content=$content, name=$name, id=$id, additionalKwargs=$additionalKwargs, responseMetadata=$responseMetadata, type=$type, additionalProperties=$additionalProperties}" + } + + /** + * Message for passing the result of executing a tool back to a model. + * + * `ToolMessage` objects contain the result of a tool invocation. Typically, the result is + * encoded inside the `content` field. + * + * Example: A `ToolMessage` representing a result of `42` from a tool call with id + * + * ```python + * from langchain_core.messages import ToolMessage + * + * ToolMessage(content="42", tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL") + * ``` + * + * Example: A `ToolMessage` where only part of the tool output is sent to the model and the + * full output is passed in to artifact. + * + * ```python + * from langchain_core.messages import ToolMessage + * + * tool_output = { + * "stdout": "From the graph we can see that the correlation between " + * "x and y is ...", + * "stderr": None, + * "artifacts": {"type": "image", "base64_data": "/9j/4gIcSU..."}, + * } + * + * ToolMessage( + * content=tool_output["stdout"], + * artifact=tool_output, + * tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL", + * ) + * ``` + * + * The `tool_call_id` field is used to associate the tool call request with the tool call + * response. Useful in situations where a chat model is able to request multiple tool calls + * in parallel. + */ + class ToolMessage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val content: JsonField<Content>, + private val toolCallId: JsonField<String>, + private val id: JsonField<String>, + private val additionalKwargs: JsonValue, + private val artifact: JsonValue, + private val name: JsonField<String>, + private val responseMetadata: JsonValue, + private val status: JsonField<Status>, + private val type: JsonField<Type>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("content") + @ExcludeMissing + content: JsonField<Content> = JsonMissing.of(), + @JsonProperty("tool_call_id") + @ExcludeMissing + toolCallId: JsonField<String> = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("additional_kwargs") + @ExcludeMissing + additionalKwargs: JsonValue = JsonMissing.of(), + @JsonProperty("artifact") @ExcludeMissing artifact: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("response_metadata") + @ExcludeMissing + responseMetadata: JsonValue = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField<Status> = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField<Type> = JsonMissing.of(), + ) : this( + content, + toolCallId, + id, + additionalKwargs, + artifact, + name, + responseMetadata, + status, + type, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun content(): Content = content.getRequired("content") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun toolCallId(): String = toolCallId.getRequired("tool_call_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + @JsonProperty("additional_kwargs") + @ExcludeMissing + fun _additionalKwargs(): JsonValue = additionalKwargs + + @JsonProperty("artifact") @ExcludeMissing fun _artifact(): JsonValue = artifact + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun name(): Optional<String> = name.getOptional("name") + + @JsonProperty("response_metadata") + @ExcludeMissing + fun _responseMetadata(): JsonValue = responseMetadata + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun status(): Optional<Status> = status.getOptional("status") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun type(): Optional<Type> = type.getOptional("type") + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField<Content> = content + + /** + * Returns the raw JSON value of [toolCallId]. + * + * Unlike [toolCallId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tool_call_id") + @ExcludeMissing + fun _toolCallId(): JsonField<String> = toolCallId + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField<Status> = status + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField<Type> = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ToolMessage]. + * + * The following fields are required: + * ```java + * .content() + * .toolCallId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ToolMessage]. */ + class Builder internal constructor() { + + private var content: JsonField<Content>? = null + private var toolCallId: JsonField<String>? = null + private var id: JsonField<String> = JsonMissing.of() + private var additionalKwargs: JsonValue = JsonMissing.of() + private var artifact: JsonValue = JsonMissing.of() + private var name: JsonField<String> = JsonMissing.of() + private var responseMetadata: JsonValue = JsonMissing.of() + private var status: JsonField<Status> = JsonMissing.of() + private var type: JsonField<Type> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(toolMessage: ToolMessage) = apply { + content = toolMessage.content + toolCallId = toolMessage.toolCallId + id = toolMessage.id + additionalKwargs = toolMessage.additionalKwargs + artifact = toolMessage.artifact + name = toolMessage.name + responseMetadata = toolMessage.responseMetadata + status = toolMessage.status + type = toolMessage.type + additionalProperties = toolMessage.additionalProperties.toMutableMap() + } + + fun content(content: Content) = content(JsonField.of(content)) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [Content] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun content(content: JsonField<Content>) = apply { this.content = content } + + /** Alias for calling [content] with `Content.ofString(string)`. */ + fun content(string: String) = content(Content.ofString(string)) + + /** + * Alias for calling [content] with + * `Content.ofUnnamedSchemaWithArrayParent5s(unnamedSchemaWithArrayParent5s)`. + */ + fun contentOfUnnamedSchemaWithArrayParent5s( + unnamedSchemaWithArrayParent5s: List<Content.UnnamedSchemaWithArrayParent5> + ) = + content( + Content.ofUnnamedSchemaWithArrayParent5s(unnamedSchemaWithArrayParent5s) + ) + + fun toolCallId(toolCallId: String) = toolCallId(JsonField.of(toolCallId)) + + /** + * Sets [Builder.toolCallId] to an arbitrary JSON value. + * + * You should usually call [Builder.toolCallId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun toolCallId(toolCallId: JsonField<String>) = apply { + this.toolCallId = toolCallId + } + + fun id(id: String?) = id(JsonField.ofNullable(id)) + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<String>) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun additionalKwargs(additionalKwargs: JsonValue) = apply { + this.additionalKwargs = additionalKwargs + } + + fun artifact(artifact: JsonValue) = apply { this.artifact = artifact } + + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional<String>) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun responseMetadata(responseMetadata: JsonValue) = apply { + this.responseMetadata = responseMetadata + } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun status(status: JsonField<Status>) = apply { this.status = status } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField<Type>) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ToolMessage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .content() + * .toolCallId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ToolMessage = + ToolMessage( + checkRequired("content", content), + checkRequired("toolCallId", toolCallId), + id, + additionalKwargs, + artifact, + name, + responseMetadata, + status, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ToolMessage = apply { + if (validated) { + return@apply + } + + content().validate() + toolCallId() + id() + name() + status().ifPresent { it.validate() } + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (content.asKnown().getOrNull()?.validity() ?: 0) + + (if (toolCallId.asKnown().isPresent) 1 else 0) + + (if (id.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + @JsonDeserialize(using = Content.Deserializer::class) + @JsonSerialize(using = Content.Serializer::class) + class Content + private constructor( + private val string: String? = null, + private val unnamedSchemaWithArrayParent5s: List<UnnamedSchemaWithArrayParent5>? = + null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun unnamedSchemaWithArrayParent5s(): + Optional<List<UnnamedSchemaWithArrayParent5>> = + Optional.ofNullable(unnamedSchemaWithArrayParent5s) + + fun isString(): Boolean = string != null + + fun isUnnamedSchemaWithArrayParent5s(): Boolean = + unnamedSchemaWithArrayParent5s != null + + fun asString(): String = string.getOrThrow("string") + + fun asUnnamedSchemaWithArrayParent5s(): List<UnnamedSchemaWithArrayParent5> = + unnamedSchemaWithArrayParent5s.getOrThrow("unnamedSchemaWithArrayParent5s") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + string != null -> visitor.visitString(string) + unnamedSchemaWithArrayParent5s != null -> + visitor.visitUnnamedSchemaWithArrayParent5s( + unnamedSchemaWithArrayParent5s + ) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Content = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitString(string: String) {} + + override fun visitUnnamedSchemaWithArrayParent5s( + unnamedSchemaWithArrayParent5s: List<UnnamedSchemaWithArrayParent5> + ) { + unnamedSchemaWithArrayParent5s.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitString(string: String) = 1 + + override fun visitUnnamedSchemaWithArrayParent5s( + unnamedSchemaWithArrayParent5s: List<UnnamedSchemaWithArrayParent5> + ) = unnamedSchemaWithArrayParent5s.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Content && + string == other.string && + unnamedSchemaWithArrayParent5s == other.unnamedSchemaWithArrayParent5s + } + + override fun hashCode(): Int = Objects.hash(string, unnamedSchemaWithArrayParent5s) + + override fun toString(): String = + when { + string != null -> "Content{string=$string}" + unnamedSchemaWithArrayParent5s != null -> + "Content{unnamedSchemaWithArrayParent5s=$unnamedSchemaWithArrayParent5s}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Content(string = string) + + @JvmStatic + fun ofUnnamedSchemaWithArrayParent5s( + unnamedSchemaWithArrayParent5s: List<UnnamedSchemaWithArrayParent5> + ) = + Content( + unnamedSchemaWithArrayParent5s = + unnamedSchemaWithArrayParent5s.toImmutable() + ) + } + + /** + * An interface that defines how to map each variant of [Content] to a value of type + * [T]. + */ + interface Visitor<out T> { + + fun visitString(string: String): T + + fun visitUnnamedSchemaWithArrayParent5s( + unnamedSchemaWithArrayParent5s: List<UnnamedSchemaWithArrayParent5> + ): T + + /** + * Maps an unknown variant of [Content] to a value of type [T]. + * + * An instance of [Content] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Content: $json") + } + } + + internal class Deserializer : BaseDeserializer<Content>(Content::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Content { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<String>())?.let { + Content(string = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef<List<UnnamedSchemaWithArrayParent5>>(), + ) + ?.let { + Content( + unnamedSchemaWithArrayParent5s = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // object). + 0 -> Content(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Content>(Content::class) { + + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.unnamedSchemaWithArrayParent5s != null -> + generator.writeObject(value.unnamedSchemaWithArrayParent5s) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } + } + } + + @JsonDeserialize(using = UnnamedSchemaWithArrayParent5.Deserializer::class) + @JsonSerialize(using = UnnamedSchemaWithArrayParent5.Serializer::class) + class UnnamedSchemaWithArrayParent5 + private constructor( + private val string: String? = null, + private val jsonValue: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun jsonValue(): Optional<JsonValue> = Optional.ofNullable(jsonValue) + + fun isString(): Boolean = string != null + + fun isJsonValue(): Boolean = jsonValue != null + + fun asString(): String = string.getOrThrow("string") + + fun asJsonValue(): JsonValue = jsonValue.getOrThrow("jsonValue") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + string != null -> visitor.visitString(string) + jsonValue != null -> visitor.visitJsonValue(jsonValue) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent5 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitString(string: String) {} + + override fun visitJsonValue(jsonValue: JsonValue) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitString(string: String) = 1 + + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent5 && + string == other.string && + jsonValue == other.jsonValue + } + + override fun hashCode(): Int = Objects.hash(string, jsonValue) + + override fun toString(): String = + when { + string != null -> "UnnamedSchemaWithArrayParent5{string=$string}" + jsonValue != null -> + "UnnamedSchemaWithArrayParent5{jsonValue=$jsonValue}" + _json != null -> "UnnamedSchemaWithArrayParent5{_unknown=$_json}" + else -> + throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent5") + } + + companion object { + + @JvmStatic + fun ofString(string: String) = + UnnamedSchemaWithArrayParent5(string = string) + + @JvmStatic + fun ofJsonValue(jsonValue: JsonValue) = + UnnamedSchemaWithArrayParent5(jsonValue = jsonValue) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent5] to a value of type [T]. + */ + interface Visitor<out T> { + + fun visitString(string: String): T + + fun visitJsonValue(jsonValue: JsonValue): T + + /** + * Maps an unknown variant of [UnnamedSchemaWithArrayParent5] to a value of + * type [T]. + * + * An instance of [UnnamedSchemaWithArrayParent5] can contain an unknown + * variant if it was deserialized from data that doesn't match any known + * variant. For example, if the SDK is on an older version than the API, + * then the API may respond with new variants that the SDK is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent5: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer<UnnamedSchemaWithArrayParent5>( + UnnamedSchemaWithArrayParent5::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent5 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<String>())?.let { + UnnamedSchemaWithArrayParent5(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<JsonValue>())?.let { + UnnamedSchemaWithArrayParent5( + jsonValue = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants. + 0 -> UnnamedSchemaWithArrayParent5(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then + // use the first completely valid match, or simply the first match + // if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer<UnnamedSchemaWithArrayParent5>( + UnnamedSchemaWithArrayParent5::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent5, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.jsonValue != null -> generator.writeObject(value.jsonValue) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent5" + ) + } + } + } + } + } + + class Status @JsonCreator private constructor(private val value: JsonField<String>) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val SUCCESS = of("success") + + @JvmField val ERROR = of("error") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + SUCCESS, + ERROR, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SUCCESS, + ERROR, + /** + * An enum member indicating that [Status] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SUCCESS -> Value.SUCCESS + ERROR -> Value.ERROR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + SUCCESS -> Known.SUCCESS + ERROR -> Known.ERROR + else -> throw LangsmithApiInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Type @JsonCreator private constructor(private val value: JsonField<String>) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val TOOL = of("tool") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + TOOL + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TOOL, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TOOL -> Value.TOOL + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + TOOL -> Known.TOOL + else -> throw LangsmithApiInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ToolMessage && + content == other.content && + toolCallId == other.toolCallId && + id == other.id && + additionalKwargs == other.additionalKwargs && + artifact == other.artifact && + name == other.name && + responseMetadata == other.responseMetadata && + status == other.status && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + content, + toolCallId, + id, + additionalKwargs, + artifact, + name, + responseMetadata, + status, + type, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ToolMessage{content=$content, toolCallId=$toolCallId, id=$id, additionalKwargs=$additionalKwargs, artifact=$artifact, name=$name, responseMetadata=$responseMetadata, status=$status, type=$type, additionalProperties=$additionalProperties}" + } + + /** Message chunk from an AI (yielded when streaming). */ + class AiMessageChunk + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val content: JsonField<Content>, + private val id: JsonField<String>, + private val additionalKwargs: JsonValue, + private val chunkPosition: JsonField<ChunkPosition>, + private val invalidToolCalls: JsonField<List<InvalidToolCall>>, + private val name: JsonField<String>, + private val responseMetadata: JsonValue, + private val toolCallChunks: JsonField<List<ToolCallChunk>>, + private val toolCalls: JsonField<List<ToolCall>>, + private val type: JsonField<Type>, + private val usageMetadata: JsonField<UsageMetadata>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("content") + @ExcludeMissing + content: JsonField<Content> = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("additional_kwargs") + @ExcludeMissing + additionalKwargs: JsonValue = JsonMissing.of(), + @JsonProperty("chunk_position") + @ExcludeMissing + chunkPosition: JsonField<ChunkPosition> = JsonMissing.of(), + @JsonProperty("invalid_tool_calls") + @ExcludeMissing + invalidToolCalls: JsonField<List<InvalidToolCall>> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("response_metadata") + @ExcludeMissing + responseMetadata: JsonValue = JsonMissing.of(), + @JsonProperty("tool_call_chunks") + @ExcludeMissing + toolCallChunks: JsonField<List<ToolCallChunk>> = JsonMissing.of(), + @JsonProperty("tool_calls") + @ExcludeMissing + toolCalls: JsonField<List<ToolCall>> = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField<Type> = JsonMissing.of(), + @JsonProperty("usage_metadata") + @ExcludeMissing + usageMetadata: JsonField<UsageMetadata> = JsonMissing.of(), + ) : this( + content, + id, + additionalKwargs, + chunkPosition, + invalidToolCalls, + name, + responseMetadata, + toolCallChunks, + toolCalls, + type, + usageMetadata, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun content(): Content = content.getRequired("content") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + @JsonProperty("additional_kwargs") + @ExcludeMissing + fun _additionalKwargs(): JsonValue = additionalKwargs + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun chunkPosition(): Optional<ChunkPosition> = + chunkPosition.getOptional("chunk_position") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun invalidToolCalls(): Optional<List<InvalidToolCall>> = + invalidToolCalls.getOptional("invalid_tool_calls") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun name(): Optional<String> = name.getOptional("name") + + @JsonProperty("response_metadata") + @ExcludeMissing + fun _responseMetadata(): JsonValue = responseMetadata + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun toolCallChunks(): Optional<List<ToolCallChunk>> = + toolCallChunks.getOptional("tool_call_chunks") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun toolCalls(): Optional<List<ToolCall>> = toolCalls.getOptional("tool_calls") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun type(): Optional<Type> = type.getOptional("type") + + /** + * Usage metadata for a message, such as token counts. + * + * This is a standard representation of token usage that is consistent across models. + * + * Example: + * + * ```python + * { + * "input_tokens": 350, + * "output_tokens": 240, + * "total_tokens": 590, + * "input_token_details": { + * "audio": 10, + * "cache_creation": 200, + * "cache_read": 100, + * }, + * "output_token_details": { + * "audio": 10, + * "reasoning": 200, + * }, + * } + * ``` + * + * !!! warning "Behavior changed in 0.3.9" Added `input_token_details` and + * `output_token_details`. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun usageMetadata(): Optional<UsageMetadata> = + usageMetadata.getOptional("usage_metadata") + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField<Content> = content + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [chunkPosition]. + * + * Unlike [chunkPosition], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("chunk_position") + @ExcludeMissing + fun _chunkPosition(): JsonField<ChunkPosition> = chunkPosition + + /** + * Returns the raw JSON value of [invalidToolCalls]. + * + * Unlike [invalidToolCalls], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invalid_tool_calls") + @ExcludeMissing + fun _invalidToolCalls(): JsonField<List<InvalidToolCall>> = invalidToolCalls + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [toolCallChunks]. + * + * Unlike [toolCallChunks], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tool_call_chunks") + @ExcludeMissing + fun _toolCallChunks(): JsonField<List<ToolCallChunk>> = toolCallChunks + + /** + * Returns the raw JSON value of [toolCalls]. + * + * Unlike [toolCalls], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tool_calls") + @ExcludeMissing + fun _toolCalls(): JsonField<List<ToolCall>> = toolCalls + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField<Type> = type + + /** + * Returns the raw JSON value of [usageMetadata]. + * + * Unlike [usageMetadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("usage_metadata") + @ExcludeMissing + fun _usageMetadata(): JsonField<UsageMetadata> = usageMetadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AiMessageChunk]. + * + * The following fields are required: + * ```java + * .content() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AiMessageChunk]. */ + class Builder internal constructor() { + + private var content: JsonField<Content>? = null + private var id: JsonField<String> = JsonMissing.of() + private var additionalKwargs: JsonValue = JsonMissing.of() + private var chunkPosition: JsonField<ChunkPosition> = JsonMissing.of() + private var invalidToolCalls: JsonField<MutableList<InvalidToolCall>>? = null + private var name: JsonField<String> = JsonMissing.of() + private var responseMetadata: JsonValue = JsonMissing.of() + private var toolCallChunks: JsonField<MutableList<ToolCallChunk>>? = null + private var toolCalls: JsonField<MutableList<ToolCall>>? = null + private var type: JsonField<Type> = JsonMissing.of() + private var usageMetadata: JsonField<UsageMetadata> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(aiMessageChunk: AiMessageChunk) = apply { + content = aiMessageChunk.content + id = aiMessageChunk.id + additionalKwargs = aiMessageChunk.additionalKwargs + chunkPosition = aiMessageChunk.chunkPosition + invalidToolCalls = aiMessageChunk.invalidToolCalls.map { it.toMutableList() } + name = aiMessageChunk.name + responseMetadata = aiMessageChunk.responseMetadata + toolCallChunks = aiMessageChunk.toolCallChunks.map { it.toMutableList() } + toolCalls = aiMessageChunk.toolCalls.map { it.toMutableList() } + type = aiMessageChunk.type + usageMetadata = aiMessageChunk.usageMetadata + additionalProperties = aiMessageChunk.additionalProperties.toMutableMap() + } + + fun content(content: Content) = content(JsonField.of(content)) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [Content] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun content(content: JsonField<Content>) = apply { this.content = content } + + /** Alias for calling [content] with `Content.ofString(string)`. */ + fun content(string: String) = content(Content.ofString(string)) + + /** + * Alias for calling [content] with + * `Content.ofUnnamedSchemaWithArrayParent6s(unnamedSchemaWithArrayParent6s)`. + */ + fun contentOfUnnamedSchemaWithArrayParent6s( + unnamedSchemaWithArrayParent6s: List<Content.UnnamedSchemaWithArrayParent6> + ) = + content( + Content.ofUnnamedSchemaWithArrayParent6s(unnamedSchemaWithArrayParent6s) + ) + + fun id(id: String?) = id(JsonField.ofNullable(id)) + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<String>) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun additionalKwargs(additionalKwargs: JsonValue) = apply { + this.additionalKwargs = additionalKwargs + } + + fun chunkPosition(chunkPosition: ChunkPosition?) = + chunkPosition(JsonField.ofNullable(chunkPosition)) + + /** Alias for calling [Builder.chunkPosition] with `chunkPosition.orElse(null)`. */ + fun chunkPosition(chunkPosition: Optional<ChunkPosition>) = + chunkPosition(chunkPosition.getOrNull()) + + /** + * Sets [Builder.chunkPosition] to an arbitrary JSON value. + * + * You should usually call [Builder.chunkPosition] with a well-typed [ChunkPosition] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun chunkPosition(chunkPosition: JsonField<ChunkPosition>) = apply { + this.chunkPosition = chunkPosition + } + + fun invalidToolCalls(invalidToolCalls: List<InvalidToolCall>) = + invalidToolCalls(JsonField.of(invalidToolCalls)) + + /** + * Sets [Builder.invalidToolCalls] to an arbitrary JSON value. + * + * You should usually call [Builder.invalidToolCalls] with a well-typed + * `List<InvalidToolCall>` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun invalidToolCalls(invalidToolCalls: JsonField<List<InvalidToolCall>>) = apply { + this.invalidToolCalls = invalidToolCalls.map { it.toMutableList() } + } + + /** + * Adds a single [InvalidToolCall] to [invalidToolCalls]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addInvalidToolCall(invalidToolCall: InvalidToolCall) = apply { + invalidToolCalls = + (invalidToolCalls ?: JsonField.of(mutableListOf())).also { + checkKnown("invalidToolCalls", it).add(invalidToolCall) + } + } + + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional<String>) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun responseMetadata(responseMetadata: JsonValue) = apply { + this.responseMetadata = responseMetadata + } + + fun toolCallChunks(toolCallChunks: List<ToolCallChunk>) = + toolCallChunks(JsonField.of(toolCallChunks)) + + /** + * Sets [Builder.toolCallChunks] to an arbitrary JSON value. + * + * You should usually call [Builder.toolCallChunks] with a well-typed + * `List<ToolCallChunk>` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun toolCallChunks(toolCallChunks: JsonField<List<ToolCallChunk>>) = apply { + this.toolCallChunks = toolCallChunks.map { it.toMutableList() } + } + + /** + * Adds a single [ToolCallChunk] to [toolCallChunks]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addToolCallChunk(toolCallChunk: ToolCallChunk) = apply { + toolCallChunks = + (toolCallChunks ?: JsonField.of(mutableListOf())).also { + checkKnown("toolCallChunks", it).add(toolCallChunk) + } + } + + fun toolCalls(toolCalls: List<ToolCall>) = toolCalls(JsonField.of(toolCalls)) + + /** + * Sets [Builder.toolCalls] to an arbitrary JSON value. + * + * You should usually call [Builder.toolCalls] with a well-typed `List<ToolCall>` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun toolCalls(toolCalls: JsonField<List<ToolCall>>) = apply { + this.toolCalls = toolCalls.map { it.toMutableList() } + } + + /** + * Adds a single [ToolCall] to [toolCalls]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addToolCall(toolCall: ToolCall) = apply { + toolCalls = + (toolCalls ?: JsonField.of(mutableListOf())).also { + checkKnown("toolCalls", it).add(toolCall) + } + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField<Type>) = apply { this.type = type } + + /** + * Usage metadata for a message, such as token counts. + * + * This is a standard representation of token usage that is consistent across + * models. + * + * Example: + * + * ```python + * { + * "input_tokens": 350, + * "output_tokens": 240, + * "total_tokens": 590, + * "input_token_details": { + * "audio": 10, + * "cache_creation": 200, + * "cache_read": 100, + * }, + * "output_token_details": { + * "audio": 10, + * "reasoning": 200, + * }, + * } + * ``` + * + * !!! warning "Behavior changed in 0.3.9" Added `input_token_details` and + * `output_token_details`. + */ + fun usageMetadata(usageMetadata: UsageMetadata?) = + usageMetadata(JsonField.ofNullable(usageMetadata)) + + /** Alias for calling [Builder.usageMetadata] with `usageMetadata.orElse(null)`. */ + fun usageMetadata(usageMetadata: Optional<UsageMetadata>) = + usageMetadata(usageMetadata.getOrNull()) + + /** + * Sets [Builder.usageMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.usageMetadata] with a well-typed [UsageMetadata] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun usageMetadata(usageMetadata: JsonField<UsageMetadata>) = apply { + this.usageMetadata = usageMetadata + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AiMessageChunk]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .content() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AiMessageChunk = + AiMessageChunk( + checkRequired("content", content), + id, + additionalKwargs, + chunkPosition, + (invalidToolCalls ?: JsonMissing.of()).map { it.toImmutable() }, + name, + responseMetadata, + (toolCallChunks ?: JsonMissing.of()).map { it.toImmutable() }, + (toolCalls ?: JsonMissing.of()).map { it.toImmutable() }, + type, + usageMetadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AiMessageChunk = apply { + if (validated) { + return@apply + } + + content().validate() + id() + chunkPosition().ifPresent { it.validate() } + invalidToolCalls().ifPresent { it.forEach { it.validate() } } + name() + toolCallChunks().ifPresent { it.forEach { it.validate() } } + toolCalls().ifPresent { it.forEach { it.validate() } } + type().ifPresent { it.validate() } + usageMetadata().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (content.asKnown().getOrNull()?.validity() ?: 0) + + (if (id.asKnown().isPresent) 1 else 0) + + (chunkPosition.asKnown().getOrNull()?.validity() ?: 0) + + (invalidToolCalls.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (toolCallChunks.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (toolCalls.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (usageMetadata.asKnown().getOrNull()?.validity() ?: 0) + + @JsonDeserialize(using = Content.Deserializer::class) + @JsonSerialize(using = Content.Serializer::class) + class Content + private constructor( + private val string: String? = null, + private val unnamedSchemaWithArrayParent6s: List<UnnamedSchemaWithArrayParent6>? = + null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun unnamedSchemaWithArrayParent6s(): + Optional<List<UnnamedSchemaWithArrayParent6>> = + Optional.ofNullable(unnamedSchemaWithArrayParent6s) + + fun isString(): Boolean = string != null + + fun isUnnamedSchemaWithArrayParent6s(): Boolean = + unnamedSchemaWithArrayParent6s != null + + fun asString(): String = string.getOrThrow("string") + + fun asUnnamedSchemaWithArrayParent6s(): List<UnnamedSchemaWithArrayParent6> = + unnamedSchemaWithArrayParent6s.getOrThrow("unnamedSchemaWithArrayParent6s") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + string != null -> visitor.visitString(string) + unnamedSchemaWithArrayParent6s != null -> + visitor.visitUnnamedSchemaWithArrayParent6s( + unnamedSchemaWithArrayParent6s + ) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Content = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitString(string: String) {} + + override fun visitUnnamedSchemaWithArrayParent6s( + unnamedSchemaWithArrayParent6s: List<UnnamedSchemaWithArrayParent6> + ) { + unnamedSchemaWithArrayParent6s.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitString(string: String) = 1 + + override fun visitUnnamedSchemaWithArrayParent6s( + unnamedSchemaWithArrayParent6s: List<UnnamedSchemaWithArrayParent6> + ) = unnamedSchemaWithArrayParent6s.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Content && + string == other.string && + unnamedSchemaWithArrayParent6s == other.unnamedSchemaWithArrayParent6s + } + + override fun hashCode(): Int = Objects.hash(string, unnamedSchemaWithArrayParent6s) + + override fun toString(): String = + when { + string != null -> "Content{string=$string}" + unnamedSchemaWithArrayParent6s != null -> + "Content{unnamedSchemaWithArrayParent6s=$unnamedSchemaWithArrayParent6s}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Content(string = string) + + @JvmStatic + fun ofUnnamedSchemaWithArrayParent6s( + unnamedSchemaWithArrayParent6s: List<UnnamedSchemaWithArrayParent6> + ) = + Content( + unnamedSchemaWithArrayParent6s = + unnamedSchemaWithArrayParent6s.toImmutable() + ) + } + + /** + * An interface that defines how to map each variant of [Content] to a value of type + * [T]. + */ + interface Visitor<out T> { + + fun visitString(string: String): T + + fun visitUnnamedSchemaWithArrayParent6s( + unnamedSchemaWithArrayParent6s: List<UnnamedSchemaWithArrayParent6> + ): T + + /** + * Maps an unknown variant of [Content] to a value of type [T]. + * + * An instance of [Content] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Content: $json") + } + } + + internal class Deserializer : BaseDeserializer<Content>(Content::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Content { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<String>())?.let { + Content(string = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef<List<UnnamedSchemaWithArrayParent6>>(), + ) + ?.let { + Content( + unnamedSchemaWithArrayParent6s = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // object). + 0 -> Content(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Content>(Content::class) { + + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.unnamedSchemaWithArrayParent6s != null -> + generator.writeObject(value.unnamedSchemaWithArrayParent6s) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } + } + } + + @JsonDeserialize(using = UnnamedSchemaWithArrayParent6.Deserializer::class) + @JsonSerialize(using = UnnamedSchemaWithArrayParent6.Serializer::class) + class UnnamedSchemaWithArrayParent6 + private constructor( + private val string: String? = null, + private val jsonValue: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun jsonValue(): Optional<JsonValue> = Optional.ofNullable(jsonValue) + + fun isString(): Boolean = string != null + + fun isJsonValue(): Boolean = jsonValue != null + + fun asString(): String = string.getOrThrow("string") + + fun asJsonValue(): JsonValue = jsonValue.getOrThrow("jsonValue") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + string != null -> visitor.visitString(string) + jsonValue != null -> visitor.visitJsonValue(jsonValue) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent6 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitString(string: String) {} + + override fun visitJsonValue(jsonValue: JsonValue) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitString(string: String) = 1 + + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent6 && + string == other.string && + jsonValue == other.jsonValue + } + + override fun hashCode(): Int = Objects.hash(string, jsonValue) + + override fun toString(): String = + when { + string != null -> "UnnamedSchemaWithArrayParent6{string=$string}" + jsonValue != null -> + "UnnamedSchemaWithArrayParent6{jsonValue=$jsonValue}" + _json != null -> "UnnamedSchemaWithArrayParent6{_unknown=$_json}" + else -> + throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent6") + } + + companion object { + + @JvmStatic + fun ofString(string: String) = + UnnamedSchemaWithArrayParent6(string = string) + + @JvmStatic + fun ofJsonValue(jsonValue: JsonValue) = + UnnamedSchemaWithArrayParent6(jsonValue = jsonValue) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent6] to a value of type [T]. + */ + interface Visitor<out T> { + + fun visitString(string: String): T + + fun visitJsonValue(jsonValue: JsonValue): T + + /** + * Maps an unknown variant of [UnnamedSchemaWithArrayParent6] to a value of + * type [T]. + * + * An instance of [UnnamedSchemaWithArrayParent6] can contain an unknown + * variant if it was deserialized from data that doesn't match any known + * variant. For example, if the SDK is on an older version than the API, + * then the API may respond with new variants that the SDK is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent6: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer<UnnamedSchemaWithArrayParent6>( + UnnamedSchemaWithArrayParent6::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent6 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<String>())?.let { + UnnamedSchemaWithArrayParent6(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<JsonValue>())?.let { + UnnamedSchemaWithArrayParent6( + jsonValue = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants. + 0 -> UnnamedSchemaWithArrayParent6(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then + // use the first completely valid match, or simply the first match + // if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer<UnnamedSchemaWithArrayParent6>( + UnnamedSchemaWithArrayParent6::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent6, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.jsonValue != null -> generator.writeObject(value.jsonValue) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent6" + ) + } + } + } + } + } + + class ChunkPosition + @JsonCreator + private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val LAST = of("last") + + @JvmStatic fun of(value: String) = ChunkPosition(JsonField.of(value)) + } + + /** An enum containing [ChunkPosition]'s known values. */ + enum class Known { + LAST + } + + /** + * An enum containing [ChunkPosition]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [ChunkPosition] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LAST, + /** + * An enum member indicating that [ChunkPosition] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LAST -> Value.LAST + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + LAST -> Known.LAST + else -> + throw LangsmithApiInvalidDataException("Unknown ChunkPosition: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ChunkPosition = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChunkPosition && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * A chunk of a tool call (yielded when streaming). + * + * When merging `ToolCallChunk`s (e.g., via `AIMessageChunk.__add__`), all string + * attributes are concatenated. Chunks are only merged if their values of `index` are + * equal and not None. + * + * Example: + * ```python + * left_chunks = [ToolCallChunk(name="foo", args='{"a":', index=0)] + * right_chunks = [ToolCallChunk(name=None, args="1}", index=0)] + * + * ( + * AIMessageChunk(content="", tool_call_chunks=left_chunks) + * + AIMessageChunk(content="", tool_call_chunks=right_chunks) + * ).tool_call_chunks == [ToolCallChunk(name="foo", args='{"a":1}', index=0)] + * ``` + */ + class ToolCallChunk + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField<String>, + private val args: JsonField<String>, + private val index: JsonField<Long>, + private val name: JsonField<String>, + private val type: JsonField<Type>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("args") + @ExcludeMissing + args: JsonField<String> = JsonMissing.of(), + @JsonProperty("index") + @ExcludeMissing + index: JsonField<Long> = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField<String> = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField<Type> = JsonMissing.of(), + ) : this(id, args, index, name, type, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun args(): Optional<String> = args.getOptional("args") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun index(): Optional<Long> = index.getOptional("index") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun name(): Optional<String> = name.getOptional("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun type(): Optional<Type> = type.getOptional("type") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [args]. + * + * Unlike [args], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("args") @ExcludeMissing fun _args(): JsonField<String> = args + + /** + * Returns the raw JSON value of [index]. + * + * Unlike [index], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("index") @ExcludeMissing fun _index(): JsonField<Long> = index + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField<Type> = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ToolCallChunk]. + * + * The following fields are required: + * ```java + * .id() + * .args() + * .index() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ToolCallChunk]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var args: JsonField<String>? = null + private var index: JsonField<Long>? = null + private var name: JsonField<String>? = null + private var type: JsonField<Type> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(toolCallChunk: ToolCallChunk) = apply { + id = toolCallChunk.id + args = toolCallChunk.args + index = toolCallChunk.index + name = toolCallChunk.name + type = toolCallChunk.type + additionalProperties = toolCallChunk.additionalProperties.toMutableMap() + } + + fun id(id: String?) = id(JsonField.ofNullable(id)) + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<String>) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun args(args: String?) = args(JsonField.ofNullable(args)) + + /** Alias for calling [Builder.args] with `args.orElse(null)`. */ + fun args(args: Optional<String>) = args(args.getOrNull()) + + /** + * Sets [Builder.args] to an arbitrary JSON value. + * + * You should usually call [Builder.args] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun args(args: JsonField<String>) = apply { this.args = args } + + fun index(index: Long?) = index(JsonField.ofNullable(index)) + + /** + * Alias for [Builder.index]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun index(index: Long) = index(index as Long?) + + /** Alias for calling [Builder.index] with `index.orElse(null)`. */ + fun index(index: Optional<Long>) = index(index.getOrNull()) + + /** + * Sets [Builder.index] to an arbitrary JSON value. + * + * You should usually call [Builder.index] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun index(index: JsonField<Long>) = apply { this.index = index } + + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional<String>) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonField<Type>) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ToolCallChunk]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .args() + * .index() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ToolCallChunk = + ToolCallChunk( + checkRequired("id", id), + checkRequired("args", args), + checkRequired("index", index), + checkRequired("name", name), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ToolCallChunk = apply { + if (validated) { + return@apply + } + + id() + args() + index() + name() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (args.asKnown().isPresent) 1 else 0) + + (if (index.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField<String>) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField<String> = value + + companion object { + + @JvmField val TOOL_CALL_CHUNK = of("tool_call_chunk") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + TOOL_CALL_CHUNK + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TOOL_CALL_CHUNK, + /** + * An enum member indicating that [Type] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TOOL_CALL_CHUNK -> Value.TOOL_CALL_CHUNK + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + TOOL_CALL_CHUNK -> Known.TOOL_CALL_CHUNK + else -> throw LangsmithApiInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ToolCallChunk && + id == other.id && + args == other.args && + index == other.index && + name == other.name && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, args, index, name, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ToolCallChunk{id=$id, args=$args, index=$index, name=$name, type=$type, additionalProperties=$additionalProperties}" + } + + class Type @JsonCreator private constructor(private val value: JsonField<String>) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val AI_MESSAGE_CHUNK = of("AIMessageChunk") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + AI_MESSAGE_CHUNK + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AI_MESSAGE_CHUNK, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AI_MESSAGE_CHUNK -> Value.AI_MESSAGE_CHUNK + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + AI_MESSAGE_CHUNK -> Known.AI_MESSAGE_CHUNK + else -> throw LangsmithApiInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AiMessageChunk && + content == other.content && + id == other.id && + additionalKwargs == other.additionalKwargs && + chunkPosition == other.chunkPosition && + invalidToolCalls == other.invalidToolCalls && + name == other.name && + responseMetadata == other.responseMetadata && + toolCallChunks == other.toolCallChunks && + toolCalls == other.toolCalls && + type == other.type && + usageMetadata == other.usageMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + content, + id, + additionalKwargs, + chunkPosition, + invalidToolCalls, + name, + responseMetadata, + toolCallChunks, + toolCalls, + type, + usageMetadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AiMessageChunk{content=$content, id=$id, additionalKwargs=$additionalKwargs, chunkPosition=$chunkPosition, invalidToolCalls=$invalidToolCalls, name=$name, responseMetadata=$responseMetadata, toolCallChunks=$toolCallChunks, toolCalls=$toolCalls, type=$type, usageMetadata=$usageMetadata, additionalProperties=$additionalProperties}" + } + + /** Human Message chunk. */ + class HumanMessageChunk + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val content: JsonField<Content>, + private val id: JsonField<String>, + private val additionalKwargs: JsonValue, + private val name: JsonField<String>, + private val responseMetadata: JsonValue, + private val type: JsonField<Type>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("content") + @ExcludeMissing + content: JsonField<Content> = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("additional_kwargs") + @ExcludeMissing + additionalKwargs: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("response_metadata") + @ExcludeMissing + responseMetadata: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField<Type> = JsonMissing.of(), + ) : this(content, id, additionalKwargs, name, responseMetadata, type, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun content(): Content = content.getRequired("content") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + @JsonProperty("additional_kwargs") + @ExcludeMissing + fun _additionalKwargs(): JsonValue = additionalKwargs + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun name(): Optional<String> = name.getOptional("name") + + @JsonProperty("response_metadata") + @ExcludeMissing + fun _responseMetadata(): JsonValue = responseMetadata + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun type(): Optional<Type> = type.getOptional("type") + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField<Content> = content + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField<Type> = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [HumanMessageChunk]. + * + * The following fields are required: + * ```java + * .content() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [HumanMessageChunk]. */ + class Builder internal constructor() { + + private var content: JsonField<Content>? = null + private var id: JsonField<String> = JsonMissing.of() + private var additionalKwargs: JsonValue = JsonMissing.of() + private var name: JsonField<String> = JsonMissing.of() + private var responseMetadata: JsonValue = JsonMissing.of() + private var type: JsonField<Type> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(humanMessageChunk: HumanMessageChunk) = apply { + content = humanMessageChunk.content + id = humanMessageChunk.id + additionalKwargs = humanMessageChunk.additionalKwargs + name = humanMessageChunk.name + responseMetadata = humanMessageChunk.responseMetadata + type = humanMessageChunk.type + additionalProperties = humanMessageChunk.additionalProperties.toMutableMap() + } + + fun content(content: Content) = content(JsonField.of(content)) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [Content] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun content(content: JsonField<Content>) = apply { this.content = content } + + /** Alias for calling [content] with `Content.ofString(string)`. */ + fun content(string: String) = content(Content.ofString(string)) + + /** + * Alias for calling [content] with + * `Content.ofUnnamedSchemaWithArrayParent7s(unnamedSchemaWithArrayParent7s)`. + */ + fun contentOfUnnamedSchemaWithArrayParent7s( + unnamedSchemaWithArrayParent7s: List<Content.UnnamedSchemaWithArrayParent7> + ) = + content( + Content.ofUnnamedSchemaWithArrayParent7s(unnamedSchemaWithArrayParent7s) + ) + + fun id(id: String?) = id(JsonField.ofNullable(id)) + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<String>) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun additionalKwargs(additionalKwargs: JsonValue) = apply { + this.additionalKwargs = additionalKwargs + } + + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional<String>) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun responseMetadata(responseMetadata: JsonValue) = apply { + this.responseMetadata = responseMetadata + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField<Type>) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [HumanMessageChunk]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .content() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): HumanMessageChunk = + HumanMessageChunk( + checkRequired("content", content), + id, + additionalKwargs, + name, + responseMetadata, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): HumanMessageChunk = apply { + if (validated) { + return@apply + } + + content().validate() + id() + name() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (content.asKnown().getOrNull()?.validity() ?: 0) + + (if (id.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + @JsonDeserialize(using = Content.Deserializer::class) + @JsonSerialize(using = Content.Serializer::class) + class Content + private constructor( + private val string: String? = null, + private val unnamedSchemaWithArrayParent7s: List<UnnamedSchemaWithArrayParent7>? = + null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun unnamedSchemaWithArrayParent7s(): + Optional<List<UnnamedSchemaWithArrayParent7>> = + Optional.ofNullable(unnamedSchemaWithArrayParent7s) + + fun isString(): Boolean = string != null + + fun isUnnamedSchemaWithArrayParent7s(): Boolean = + unnamedSchemaWithArrayParent7s != null + + fun asString(): String = string.getOrThrow("string") + + fun asUnnamedSchemaWithArrayParent7s(): List<UnnamedSchemaWithArrayParent7> = + unnamedSchemaWithArrayParent7s.getOrThrow("unnamedSchemaWithArrayParent7s") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + string != null -> visitor.visitString(string) + unnamedSchemaWithArrayParent7s != null -> + visitor.visitUnnamedSchemaWithArrayParent7s( + unnamedSchemaWithArrayParent7s + ) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Content = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitString(string: String) {} + + override fun visitUnnamedSchemaWithArrayParent7s( + unnamedSchemaWithArrayParent7s: List<UnnamedSchemaWithArrayParent7> + ) { + unnamedSchemaWithArrayParent7s.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitString(string: String) = 1 + + override fun visitUnnamedSchemaWithArrayParent7s( + unnamedSchemaWithArrayParent7s: List<UnnamedSchemaWithArrayParent7> + ) = unnamedSchemaWithArrayParent7s.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Content && + string == other.string && + unnamedSchemaWithArrayParent7s == other.unnamedSchemaWithArrayParent7s + } + + override fun hashCode(): Int = Objects.hash(string, unnamedSchemaWithArrayParent7s) + + override fun toString(): String = + when { + string != null -> "Content{string=$string}" + unnamedSchemaWithArrayParent7s != null -> + "Content{unnamedSchemaWithArrayParent7s=$unnamedSchemaWithArrayParent7s}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Content(string = string) + + @JvmStatic + fun ofUnnamedSchemaWithArrayParent7s( + unnamedSchemaWithArrayParent7s: List<UnnamedSchemaWithArrayParent7> + ) = + Content( + unnamedSchemaWithArrayParent7s = + unnamedSchemaWithArrayParent7s.toImmutable() + ) + } + + /** + * An interface that defines how to map each variant of [Content] to a value of type + * [T]. + */ + interface Visitor<out T> { + + fun visitString(string: String): T + + fun visitUnnamedSchemaWithArrayParent7s( + unnamedSchemaWithArrayParent7s: List<UnnamedSchemaWithArrayParent7> + ): T + + /** + * Maps an unknown variant of [Content] to a value of type [T]. + * + * An instance of [Content] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Content: $json") + } + } + + internal class Deserializer : BaseDeserializer<Content>(Content::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Content { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<String>())?.let { + Content(string = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef<List<UnnamedSchemaWithArrayParent7>>(), + ) + ?.let { + Content( + unnamedSchemaWithArrayParent7s = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // object). + 0 -> Content(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Content>(Content::class) { + + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.unnamedSchemaWithArrayParent7s != null -> + generator.writeObject(value.unnamedSchemaWithArrayParent7s) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } + } + } + + @JsonDeserialize(using = UnnamedSchemaWithArrayParent7.Deserializer::class) + @JsonSerialize(using = UnnamedSchemaWithArrayParent7.Serializer::class) + class UnnamedSchemaWithArrayParent7 + private constructor( + private val string: String? = null, + private val jsonValue: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun jsonValue(): Optional<JsonValue> = Optional.ofNullable(jsonValue) + + fun isString(): Boolean = string != null + + fun isJsonValue(): Boolean = jsonValue != null + + fun asString(): String = string.getOrThrow("string") + + fun asJsonValue(): JsonValue = jsonValue.getOrThrow("jsonValue") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + string != null -> visitor.visitString(string) + jsonValue != null -> visitor.visitJsonValue(jsonValue) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent7 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitString(string: String) {} + + override fun visitJsonValue(jsonValue: JsonValue) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitString(string: String) = 1 + + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent7 && + string == other.string && + jsonValue == other.jsonValue + } + + override fun hashCode(): Int = Objects.hash(string, jsonValue) + + override fun toString(): String = + when { + string != null -> "UnnamedSchemaWithArrayParent7{string=$string}" + jsonValue != null -> + "UnnamedSchemaWithArrayParent7{jsonValue=$jsonValue}" + _json != null -> "UnnamedSchemaWithArrayParent7{_unknown=$_json}" + else -> + throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent7") + } + + companion object { + + @JvmStatic + fun ofString(string: String) = + UnnamedSchemaWithArrayParent7(string = string) + + @JvmStatic + fun ofJsonValue(jsonValue: JsonValue) = + UnnamedSchemaWithArrayParent7(jsonValue = jsonValue) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent7] to a value of type [T]. + */ + interface Visitor<out T> { + + fun visitString(string: String): T + + fun visitJsonValue(jsonValue: JsonValue): T + + /** + * Maps an unknown variant of [UnnamedSchemaWithArrayParent7] to a value of + * type [T]. + * + * An instance of [UnnamedSchemaWithArrayParent7] can contain an unknown + * variant if it was deserialized from data that doesn't match any known + * variant. For example, if the SDK is on an older version than the API, + * then the API may respond with new variants that the SDK is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent7: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer<UnnamedSchemaWithArrayParent7>( + UnnamedSchemaWithArrayParent7::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent7 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<String>())?.let { + UnnamedSchemaWithArrayParent7(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<JsonValue>())?.let { + UnnamedSchemaWithArrayParent7( + jsonValue = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants. + 0 -> UnnamedSchemaWithArrayParent7(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then + // use the first completely valid match, or simply the first match + // if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer<UnnamedSchemaWithArrayParent7>( + UnnamedSchemaWithArrayParent7::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent7, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.jsonValue != null -> generator.writeObject(value.jsonValue) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent7" + ) + } + } + } + } + } + + class Type @JsonCreator private constructor(private val value: JsonField<String>) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val HUMAN_MESSAGE_CHUNK = of("HumanMessageChunk") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + HUMAN_MESSAGE_CHUNK + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HUMAN_MESSAGE_CHUNK, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HUMAN_MESSAGE_CHUNK -> Value.HUMAN_MESSAGE_CHUNK + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + HUMAN_MESSAGE_CHUNK -> Known.HUMAN_MESSAGE_CHUNK + else -> throw LangsmithApiInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is HumanMessageChunk && + content == other.content && + id == other.id && + additionalKwargs == other.additionalKwargs && + name == other.name && + responseMetadata == other.responseMetadata && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + content, + id, + additionalKwargs, + name, + responseMetadata, + type, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "HumanMessageChunk{content=$content, id=$id, additionalKwargs=$additionalKwargs, name=$name, responseMetadata=$responseMetadata, type=$type, additionalProperties=$additionalProperties}" + } + + /** Chat Message chunk. */ + class ChatMessageChunk + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val content: JsonField<Content>, + private val role: JsonField<String>, + private val id: JsonField<String>, + private val additionalKwargs: JsonValue, + private val name: JsonField<String>, + private val responseMetadata: JsonValue, + private val type: JsonField<Type>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("content") + @ExcludeMissing + content: JsonField<Content> = JsonMissing.of(), + @JsonProperty("role") @ExcludeMissing role: JsonField<String> = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("additional_kwargs") + @ExcludeMissing + additionalKwargs: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("response_metadata") + @ExcludeMissing + responseMetadata: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField<Type> = JsonMissing.of(), + ) : this( + content, + role, + id, + additionalKwargs, + name, + responseMetadata, + type, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun content(): Content = content.getRequired("content") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun role(): String = role.getRequired("role") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + @JsonProperty("additional_kwargs") + @ExcludeMissing + fun _additionalKwargs(): JsonValue = additionalKwargs + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun name(): Optional<String> = name.getOptional("name") + + @JsonProperty("response_metadata") + @ExcludeMissing + fun _responseMetadata(): JsonValue = responseMetadata + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun type(): Optional<Type> = type.getOptional("type") + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField<Content> = content + + /** + * Returns the raw JSON value of [role]. + * + * Unlike [role], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("role") @ExcludeMissing fun _role(): JsonField<String> = role + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField<Type> = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ChatMessageChunk]. + * + * The following fields are required: + * ```java + * .content() + * .role() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChatMessageChunk]. */ + class Builder internal constructor() { + + private var content: JsonField<Content>? = null + private var role: JsonField<String>? = null + private var id: JsonField<String> = JsonMissing.of() + private var additionalKwargs: JsonValue = JsonMissing.of() + private var name: JsonField<String> = JsonMissing.of() + private var responseMetadata: JsonValue = JsonMissing.of() + private var type: JsonField<Type> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(chatMessageChunk: ChatMessageChunk) = apply { + content = chatMessageChunk.content + role = chatMessageChunk.role + id = chatMessageChunk.id + additionalKwargs = chatMessageChunk.additionalKwargs + name = chatMessageChunk.name + responseMetadata = chatMessageChunk.responseMetadata + type = chatMessageChunk.type + additionalProperties = chatMessageChunk.additionalProperties.toMutableMap() + } + + fun content(content: Content) = content(JsonField.of(content)) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [Content] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun content(content: JsonField<Content>) = apply { this.content = content } + + /** Alias for calling [content] with `Content.ofString(string)`. */ + fun content(string: String) = content(Content.ofString(string)) + + /** + * Alias for calling [content] with + * `Content.ofUnnamedSchemaWithArrayParent8s(unnamedSchemaWithArrayParent8s)`. + */ + fun contentOfUnnamedSchemaWithArrayParent8s( + unnamedSchemaWithArrayParent8s: List<Content.UnnamedSchemaWithArrayParent8> + ) = + content( + Content.ofUnnamedSchemaWithArrayParent8s(unnamedSchemaWithArrayParent8s) + ) + + fun role(role: String) = role(JsonField.of(role)) + + /** + * Sets [Builder.role] to an arbitrary JSON value. + * + * You should usually call [Builder.role] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun role(role: JsonField<String>) = apply { this.role = role } + + fun id(id: String?) = id(JsonField.ofNullable(id)) + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<String>) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun additionalKwargs(additionalKwargs: JsonValue) = apply { + this.additionalKwargs = additionalKwargs + } + + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional<String>) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun responseMetadata(responseMetadata: JsonValue) = apply { + this.responseMetadata = responseMetadata + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField<Type>) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChatMessageChunk]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .content() + * .role() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChatMessageChunk = + ChatMessageChunk( + checkRequired("content", content), + checkRequired("role", role), + id, + additionalKwargs, + name, + responseMetadata, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChatMessageChunk = apply { + if (validated) { + return@apply + } + + content().validate() + role() + id() + name() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (content.asKnown().getOrNull()?.validity() ?: 0) + + (if (role.asKnown().isPresent) 1 else 0) + + (if (id.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + @JsonDeserialize(using = Content.Deserializer::class) + @JsonSerialize(using = Content.Serializer::class) + class Content + private constructor( + private val string: String? = null, + private val unnamedSchemaWithArrayParent8s: List<UnnamedSchemaWithArrayParent8>? = + null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun unnamedSchemaWithArrayParent8s(): + Optional<List<UnnamedSchemaWithArrayParent8>> = + Optional.ofNullable(unnamedSchemaWithArrayParent8s) + + fun isString(): Boolean = string != null + + fun isUnnamedSchemaWithArrayParent8s(): Boolean = + unnamedSchemaWithArrayParent8s != null + + fun asString(): String = string.getOrThrow("string") + + fun asUnnamedSchemaWithArrayParent8s(): List<UnnamedSchemaWithArrayParent8> = + unnamedSchemaWithArrayParent8s.getOrThrow("unnamedSchemaWithArrayParent8s") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + string != null -> visitor.visitString(string) + unnamedSchemaWithArrayParent8s != null -> + visitor.visitUnnamedSchemaWithArrayParent8s( + unnamedSchemaWithArrayParent8s + ) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Content = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitString(string: String) {} + + override fun visitUnnamedSchemaWithArrayParent8s( + unnamedSchemaWithArrayParent8s: List<UnnamedSchemaWithArrayParent8> + ) { + unnamedSchemaWithArrayParent8s.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitString(string: String) = 1 + + override fun visitUnnamedSchemaWithArrayParent8s( + unnamedSchemaWithArrayParent8s: List<UnnamedSchemaWithArrayParent8> + ) = unnamedSchemaWithArrayParent8s.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Content && + string == other.string && + unnamedSchemaWithArrayParent8s == other.unnamedSchemaWithArrayParent8s + } + + override fun hashCode(): Int = Objects.hash(string, unnamedSchemaWithArrayParent8s) + + override fun toString(): String = + when { + string != null -> "Content{string=$string}" + unnamedSchemaWithArrayParent8s != null -> + "Content{unnamedSchemaWithArrayParent8s=$unnamedSchemaWithArrayParent8s}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Content(string = string) + + @JvmStatic + fun ofUnnamedSchemaWithArrayParent8s( + unnamedSchemaWithArrayParent8s: List<UnnamedSchemaWithArrayParent8> + ) = + Content( + unnamedSchemaWithArrayParent8s = + unnamedSchemaWithArrayParent8s.toImmutable() + ) + } + + /** + * An interface that defines how to map each variant of [Content] to a value of type + * [T]. + */ + interface Visitor<out T> { + + fun visitString(string: String): T + + fun visitUnnamedSchemaWithArrayParent8s( + unnamedSchemaWithArrayParent8s: List<UnnamedSchemaWithArrayParent8> + ): T + + /** + * Maps an unknown variant of [Content] to a value of type [T]. + * + * An instance of [Content] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Content: $json") + } + } + + internal class Deserializer : BaseDeserializer<Content>(Content::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Content { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<String>())?.let { + Content(string = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef<List<UnnamedSchemaWithArrayParent8>>(), + ) + ?.let { + Content( + unnamedSchemaWithArrayParent8s = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // object). + 0 -> Content(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Content>(Content::class) { + + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.unnamedSchemaWithArrayParent8s != null -> + generator.writeObject(value.unnamedSchemaWithArrayParent8s) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } + } + } + + @JsonDeserialize(using = UnnamedSchemaWithArrayParent8.Deserializer::class) + @JsonSerialize(using = UnnamedSchemaWithArrayParent8.Serializer::class) + class UnnamedSchemaWithArrayParent8 + private constructor( + private val string: String? = null, + private val jsonValue: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun jsonValue(): Optional<JsonValue> = Optional.ofNullable(jsonValue) + + fun isString(): Boolean = string != null + + fun isJsonValue(): Boolean = jsonValue != null + + fun asString(): String = string.getOrThrow("string") + + fun asJsonValue(): JsonValue = jsonValue.getOrThrow("jsonValue") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + string != null -> visitor.visitString(string) + jsonValue != null -> visitor.visitJsonValue(jsonValue) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent8 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitString(string: String) {} + + override fun visitJsonValue(jsonValue: JsonValue) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitString(string: String) = 1 + + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent8 && + string == other.string && + jsonValue == other.jsonValue + } + + override fun hashCode(): Int = Objects.hash(string, jsonValue) + + override fun toString(): String = + when { + string != null -> "UnnamedSchemaWithArrayParent8{string=$string}" + jsonValue != null -> + "UnnamedSchemaWithArrayParent8{jsonValue=$jsonValue}" + _json != null -> "UnnamedSchemaWithArrayParent8{_unknown=$_json}" + else -> + throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent8") + } + + companion object { + + @JvmStatic + fun ofString(string: String) = + UnnamedSchemaWithArrayParent8(string = string) + + @JvmStatic + fun ofJsonValue(jsonValue: JsonValue) = + UnnamedSchemaWithArrayParent8(jsonValue = jsonValue) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent8] to a value of type [T]. + */ + interface Visitor<out T> { + + fun visitString(string: String): T + + fun visitJsonValue(jsonValue: JsonValue): T + + /** + * Maps an unknown variant of [UnnamedSchemaWithArrayParent8] to a value of + * type [T]. + * + * An instance of [UnnamedSchemaWithArrayParent8] can contain an unknown + * variant if it was deserialized from data that doesn't match any known + * variant. For example, if the SDK is on an older version than the API, + * then the API may respond with new variants that the SDK is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent8: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer<UnnamedSchemaWithArrayParent8>( + UnnamedSchemaWithArrayParent8::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent8 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<String>())?.let { + UnnamedSchemaWithArrayParent8(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<JsonValue>())?.let { + UnnamedSchemaWithArrayParent8( + jsonValue = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants. + 0 -> UnnamedSchemaWithArrayParent8(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then + // use the first completely valid match, or simply the first match + // if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer<UnnamedSchemaWithArrayParent8>( + UnnamedSchemaWithArrayParent8::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent8, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.jsonValue != null -> generator.writeObject(value.jsonValue) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent8" + ) + } + } + } + } + } + + class Type @JsonCreator private constructor(private val value: JsonField<String>) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val CHAT_MESSAGE_CHUNK = of("ChatMessageChunk") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + CHAT_MESSAGE_CHUNK + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CHAT_MESSAGE_CHUNK, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CHAT_MESSAGE_CHUNK -> Value.CHAT_MESSAGE_CHUNK + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + CHAT_MESSAGE_CHUNK -> Known.CHAT_MESSAGE_CHUNK + else -> throw LangsmithApiInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatMessageChunk && + content == other.content && + role == other.role && + id == other.id && + additionalKwargs == other.additionalKwargs && + name == other.name && + responseMetadata == other.responseMetadata && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + content, + role, + id, + additionalKwargs, + name, + responseMetadata, + type, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChatMessageChunk{content=$content, role=$role, id=$id, additionalKwargs=$additionalKwargs, name=$name, responseMetadata=$responseMetadata, type=$type, additionalProperties=$additionalProperties}" + } + + /** System Message chunk. */ + class SystemMessageChunk + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val content: JsonField<Content>, + private val id: JsonField<String>, + private val additionalKwargs: JsonValue, + private val name: JsonField<String>, + private val responseMetadata: JsonValue, + private val type: JsonField<Type>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("content") + @ExcludeMissing + content: JsonField<Content> = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("additional_kwargs") + @ExcludeMissing + additionalKwargs: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("response_metadata") + @ExcludeMissing + responseMetadata: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField<Type> = JsonMissing.of(), + ) : this(content, id, additionalKwargs, name, responseMetadata, type, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun content(): Content = content.getRequired("content") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + @JsonProperty("additional_kwargs") + @ExcludeMissing + fun _additionalKwargs(): JsonValue = additionalKwargs + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun name(): Optional<String> = name.getOptional("name") + + @JsonProperty("response_metadata") + @ExcludeMissing + fun _responseMetadata(): JsonValue = responseMetadata + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun type(): Optional<Type> = type.getOptional("type") + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField<Content> = content + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField<Type> = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SystemMessageChunk]. + * + * The following fields are required: + * ```java + * .content() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SystemMessageChunk]. */ + class Builder internal constructor() { + + private var content: JsonField<Content>? = null + private var id: JsonField<String> = JsonMissing.of() + private var additionalKwargs: JsonValue = JsonMissing.of() + private var name: JsonField<String> = JsonMissing.of() + private var responseMetadata: JsonValue = JsonMissing.of() + private var type: JsonField<Type> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(systemMessageChunk: SystemMessageChunk) = apply { + content = systemMessageChunk.content + id = systemMessageChunk.id + additionalKwargs = systemMessageChunk.additionalKwargs + name = systemMessageChunk.name + responseMetadata = systemMessageChunk.responseMetadata + type = systemMessageChunk.type + additionalProperties = systemMessageChunk.additionalProperties.toMutableMap() + } + + fun content(content: Content) = content(JsonField.of(content)) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [Content] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun content(content: JsonField<Content>) = apply { this.content = content } + + /** Alias for calling [content] with `Content.ofString(string)`. */ + fun content(string: String) = content(Content.ofString(string)) + + /** + * Alias for calling [content] with + * `Content.ofUnnamedSchemaWithArrayParent9s(unnamedSchemaWithArrayParent9s)`. + */ + fun contentOfUnnamedSchemaWithArrayParent9s( + unnamedSchemaWithArrayParent9s: List<Content.UnnamedSchemaWithArrayParent9> + ) = + content( + Content.ofUnnamedSchemaWithArrayParent9s(unnamedSchemaWithArrayParent9s) + ) + + fun id(id: String?) = id(JsonField.ofNullable(id)) + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<String>) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun additionalKwargs(additionalKwargs: JsonValue) = apply { + this.additionalKwargs = additionalKwargs + } + + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional<String>) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun responseMetadata(responseMetadata: JsonValue) = apply { + this.responseMetadata = responseMetadata + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField<Type>) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SystemMessageChunk]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .content() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SystemMessageChunk = + SystemMessageChunk( + checkRequired("content", content), + id, + additionalKwargs, + name, + responseMetadata, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SystemMessageChunk = apply { + if (validated) { + return@apply + } + + content().validate() + id() + name() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (content.asKnown().getOrNull()?.validity() ?: 0) + + (if (id.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + @JsonDeserialize(using = Content.Deserializer::class) + @JsonSerialize(using = Content.Serializer::class) + class Content + private constructor( + private val string: String? = null, + private val unnamedSchemaWithArrayParent9s: List<UnnamedSchemaWithArrayParent9>? = + null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun unnamedSchemaWithArrayParent9s(): + Optional<List<UnnamedSchemaWithArrayParent9>> = + Optional.ofNullable(unnamedSchemaWithArrayParent9s) + + fun isString(): Boolean = string != null + + fun isUnnamedSchemaWithArrayParent9s(): Boolean = + unnamedSchemaWithArrayParent9s != null + + fun asString(): String = string.getOrThrow("string") + + fun asUnnamedSchemaWithArrayParent9s(): List<UnnamedSchemaWithArrayParent9> = + unnamedSchemaWithArrayParent9s.getOrThrow("unnamedSchemaWithArrayParent9s") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + string != null -> visitor.visitString(string) + unnamedSchemaWithArrayParent9s != null -> + visitor.visitUnnamedSchemaWithArrayParent9s( + unnamedSchemaWithArrayParent9s + ) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Content = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitString(string: String) {} + + override fun visitUnnamedSchemaWithArrayParent9s( + unnamedSchemaWithArrayParent9s: List<UnnamedSchemaWithArrayParent9> + ) { + unnamedSchemaWithArrayParent9s.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitString(string: String) = 1 + + override fun visitUnnamedSchemaWithArrayParent9s( + unnamedSchemaWithArrayParent9s: List<UnnamedSchemaWithArrayParent9> + ) = unnamedSchemaWithArrayParent9s.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Content && + string == other.string && + unnamedSchemaWithArrayParent9s == other.unnamedSchemaWithArrayParent9s + } + + override fun hashCode(): Int = Objects.hash(string, unnamedSchemaWithArrayParent9s) + + override fun toString(): String = + when { + string != null -> "Content{string=$string}" + unnamedSchemaWithArrayParent9s != null -> + "Content{unnamedSchemaWithArrayParent9s=$unnamedSchemaWithArrayParent9s}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Content(string = string) + + @JvmStatic + fun ofUnnamedSchemaWithArrayParent9s( + unnamedSchemaWithArrayParent9s: List<UnnamedSchemaWithArrayParent9> + ) = + Content( + unnamedSchemaWithArrayParent9s = + unnamedSchemaWithArrayParent9s.toImmutable() + ) + } + + /** + * An interface that defines how to map each variant of [Content] to a value of type + * [T]. + */ + interface Visitor<out T> { + + fun visitString(string: String): T + + fun visitUnnamedSchemaWithArrayParent9s( + unnamedSchemaWithArrayParent9s: List<UnnamedSchemaWithArrayParent9> + ): T + + /** + * Maps an unknown variant of [Content] to a value of type [T]. + * + * An instance of [Content] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Content: $json") + } + } + + internal class Deserializer : BaseDeserializer<Content>(Content::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Content { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<String>())?.let { + Content(string = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef<List<UnnamedSchemaWithArrayParent9>>(), + ) + ?.let { + Content( + unnamedSchemaWithArrayParent9s = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // object). + 0 -> Content(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Content>(Content::class) { + + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.unnamedSchemaWithArrayParent9s != null -> + generator.writeObject(value.unnamedSchemaWithArrayParent9s) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } + } + } + + @JsonDeserialize(using = UnnamedSchemaWithArrayParent9.Deserializer::class) + @JsonSerialize(using = UnnamedSchemaWithArrayParent9.Serializer::class) + class UnnamedSchemaWithArrayParent9 + private constructor( + private val string: String? = null, + private val jsonValue: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun jsonValue(): Optional<JsonValue> = Optional.ofNullable(jsonValue) + + fun isString(): Boolean = string != null + + fun isJsonValue(): Boolean = jsonValue != null + + fun asString(): String = string.getOrThrow("string") + + fun asJsonValue(): JsonValue = jsonValue.getOrThrow("jsonValue") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + string != null -> visitor.visitString(string) + jsonValue != null -> visitor.visitJsonValue(jsonValue) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent9 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitString(string: String) {} + + override fun visitJsonValue(jsonValue: JsonValue) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitString(string: String) = 1 + + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent9 && + string == other.string && + jsonValue == other.jsonValue + } + + override fun hashCode(): Int = Objects.hash(string, jsonValue) + + override fun toString(): String = + when { + string != null -> "UnnamedSchemaWithArrayParent9{string=$string}" + jsonValue != null -> + "UnnamedSchemaWithArrayParent9{jsonValue=$jsonValue}" + _json != null -> "UnnamedSchemaWithArrayParent9{_unknown=$_json}" + else -> + throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent9") + } + + companion object { + + @JvmStatic + fun ofString(string: String) = + UnnamedSchemaWithArrayParent9(string = string) + + @JvmStatic + fun ofJsonValue(jsonValue: JsonValue) = + UnnamedSchemaWithArrayParent9(jsonValue = jsonValue) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent9] to a value of type [T]. + */ + interface Visitor<out T> { + + fun visitString(string: String): T + + fun visitJsonValue(jsonValue: JsonValue): T + + /** + * Maps an unknown variant of [UnnamedSchemaWithArrayParent9] to a value of + * type [T]. + * + * An instance of [UnnamedSchemaWithArrayParent9] can contain an unknown + * variant if it was deserialized from data that doesn't match any known + * variant. For example, if the SDK is on an older version than the API, + * then the API may respond with new variants that the SDK is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent9: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer<UnnamedSchemaWithArrayParent9>( + UnnamedSchemaWithArrayParent9::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent9 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<String>())?.let { + UnnamedSchemaWithArrayParent9(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<JsonValue>())?.let { + UnnamedSchemaWithArrayParent9( + jsonValue = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants. + 0 -> UnnamedSchemaWithArrayParent9(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then + // use the first completely valid match, or simply the first match + // if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer<UnnamedSchemaWithArrayParent9>( + UnnamedSchemaWithArrayParent9::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent9, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.jsonValue != null -> generator.writeObject(value.jsonValue) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent9" + ) + } + } + } + } + } + + class Type @JsonCreator private constructor(private val value: JsonField<String>) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val SYSTEM_MESSAGE_CHUNK = of("SystemMessageChunk") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + SYSTEM_MESSAGE_CHUNK + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SYSTEM_MESSAGE_CHUNK, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SYSTEM_MESSAGE_CHUNK -> Value.SYSTEM_MESSAGE_CHUNK + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + SYSTEM_MESSAGE_CHUNK -> Known.SYSTEM_MESSAGE_CHUNK + else -> throw LangsmithApiInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SystemMessageChunk && + content == other.content && + id == other.id && + additionalKwargs == other.additionalKwargs && + name == other.name && + responseMetadata == other.responseMetadata && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + content, + id, + additionalKwargs, + name, + responseMetadata, + type, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SystemMessageChunk{content=$content, id=$id, additionalKwargs=$additionalKwargs, name=$name, responseMetadata=$responseMetadata, type=$type, additionalProperties=$additionalProperties}" + } + + /** Function Message chunk. */ + class FunctionMessageChunk + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val content: JsonField<Content>, + private val name: JsonField<String>, + private val id: JsonField<String>, + private val additionalKwargs: JsonValue, + private val responseMetadata: JsonValue, + private val type: JsonField<Type>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("content") + @ExcludeMissing + content: JsonField<Content> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("additional_kwargs") + @ExcludeMissing + additionalKwargs: JsonValue = JsonMissing.of(), + @JsonProperty("response_metadata") + @ExcludeMissing + responseMetadata: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField<Type> = JsonMissing.of(), + ) : this(content, name, id, additionalKwargs, responseMetadata, type, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun content(): Content = content.getRequired("content") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + @JsonProperty("additional_kwargs") + @ExcludeMissing + fun _additionalKwargs(): JsonValue = additionalKwargs + + @JsonProperty("response_metadata") + @ExcludeMissing + fun _responseMetadata(): JsonValue = responseMetadata + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun type(): Optional<Type> = type.getOptional("type") + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField<Content> = content + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField<Type> = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [FunctionMessageChunk]. + * + * The following fields are required: + * ```java + * .content() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FunctionMessageChunk]. */ + class Builder internal constructor() { + + private var content: JsonField<Content>? = null + private var name: JsonField<String>? = null + private var id: JsonField<String> = JsonMissing.of() + private var additionalKwargs: JsonValue = JsonMissing.of() + private var responseMetadata: JsonValue = JsonMissing.of() + private var type: JsonField<Type> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(functionMessageChunk: FunctionMessageChunk) = apply { + content = functionMessageChunk.content + name = functionMessageChunk.name + id = functionMessageChunk.id + additionalKwargs = functionMessageChunk.additionalKwargs + responseMetadata = functionMessageChunk.responseMetadata + type = functionMessageChunk.type + additionalProperties = functionMessageChunk.additionalProperties.toMutableMap() + } + + fun content(content: Content) = content(JsonField.of(content)) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [Content] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun content(content: JsonField<Content>) = apply { this.content = content } + + /** Alias for calling [content] with `Content.ofString(string)`. */ + fun content(string: String) = content(Content.ofString(string)) + + /** + * Alias for calling [content] with + * `Content.ofUnnamedSchemaWithArrayParent10s(unnamedSchemaWithArrayParent10s)`. + */ + fun contentOfUnnamedSchemaWithArrayParent10s( + unnamedSchemaWithArrayParent10s: List<Content.UnnamedSchemaWithArrayParent10> + ) = + content( + Content.ofUnnamedSchemaWithArrayParent10s(unnamedSchemaWithArrayParent10s) + ) + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun id(id: String?) = id(JsonField.ofNullable(id)) + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<String>) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun additionalKwargs(additionalKwargs: JsonValue) = apply { + this.additionalKwargs = additionalKwargs + } + + fun responseMetadata(responseMetadata: JsonValue) = apply { + this.responseMetadata = responseMetadata + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField<Type>) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FunctionMessageChunk]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .content() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FunctionMessageChunk = + FunctionMessageChunk( + checkRequired("content", content), + checkRequired("name", name), + id, + additionalKwargs, + responseMetadata, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): FunctionMessageChunk = apply { + if (validated) { + return@apply + } + + content().validate() + name() + id() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (content.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (id.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + @JsonDeserialize(using = Content.Deserializer::class) + @JsonSerialize(using = Content.Serializer::class) + class Content + private constructor( + private val string: String? = null, + private val unnamedSchemaWithArrayParent10s: List<UnnamedSchemaWithArrayParent10>? = + null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun unnamedSchemaWithArrayParent10s(): + Optional<List<UnnamedSchemaWithArrayParent10>> = + Optional.ofNullable(unnamedSchemaWithArrayParent10s) + + fun isString(): Boolean = string != null + + fun isUnnamedSchemaWithArrayParent10s(): Boolean = + unnamedSchemaWithArrayParent10s != null + + fun asString(): String = string.getOrThrow("string") + + fun asUnnamedSchemaWithArrayParent10s(): List<UnnamedSchemaWithArrayParent10> = + unnamedSchemaWithArrayParent10s.getOrThrow("unnamedSchemaWithArrayParent10s") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + string != null -> visitor.visitString(string) + unnamedSchemaWithArrayParent10s != null -> + visitor.visitUnnamedSchemaWithArrayParent10s( + unnamedSchemaWithArrayParent10s + ) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Content = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitString(string: String) {} + + override fun visitUnnamedSchemaWithArrayParent10s( + unnamedSchemaWithArrayParent10s: + List<UnnamedSchemaWithArrayParent10> + ) { + unnamedSchemaWithArrayParent10s.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitString(string: String) = 1 + + override fun visitUnnamedSchemaWithArrayParent10s( + unnamedSchemaWithArrayParent10s: + List<UnnamedSchemaWithArrayParent10> + ) = unnamedSchemaWithArrayParent10s.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Content && + string == other.string && + unnamedSchemaWithArrayParent10s == other.unnamedSchemaWithArrayParent10s + } + + override fun hashCode(): Int = Objects.hash(string, unnamedSchemaWithArrayParent10s) + + override fun toString(): String = + when { + string != null -> "Content{string=$string}" + unnamedSchemaWithArrayParent10s != null -> + "Content{unnamedSchemaWithArrayParent10s=$unnamedSchemaWithArrayParent10s}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Content(string = string) + + @JvmStatic + fun ofUnnamedSchemaWithArrayParent10s( + unnamedSchemaWithArrayParent10s: List<UnnamedSchemaWithArrayParent10> + ) = + Content( + unnamedSchemaWithArrayParent10s = + unnamedSchemaWithArrayParent10s.toImmutable() + ) + } + + /** + * An interface that defines how to map each variant of [Content] to a value of type + * [T]. + */ + interface Visitor<out T> { + + fun visitString(string: String): T + + fun visitUnnamedSchemaWithArrayParent10s( + unnamedSchemaWithArrayParent10s: List<UnnamedSchemaWithArrayParent10> + ): T + + /** + * Maps an unknown variant of [Content] to a value of type [T]. + * + * An instance of [Content] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Content: $json") + } + } + + internal class Deserializer : BaseDeserializer<Content>(Content::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Content { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<String>())?.let { + Content(string = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef<List<UnnamedSchemaWithArrayParent10>>(), + ) + ?.let { + Content( + unnamedSchemaWithArrayParent10s = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // object). + 0 -> Content(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Content>(Content::class) { + + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.unnamedSchemaWithArrayParent10s != null -> + generator.writeObject(value.unnamedSchemaWithArrayParent10s) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } + } + } + + @JsonDeserialize(using = UnnamedSchemaWithArrayParent10.Deserializer::class) + @JsonSerialize(using = UnnamedSchemaWithArrayParent10.Serializer::class) + class UnnamedSchemaWithArrayParent10 + private constructor( + private val string: String? = null, + private val jsonValue: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun jsonValue(): Optional<JsonValue> = Optional.ofNullable(jsonValue) + + fun isString(): Boolean = string != null + + fun isJsonValue(): Boolean = jsonValue != null + + fun asString(): String = string.getOrThrow("string") + + fun asJsonValue(): JsonValue = jsonValue.getOrThrow("jsonValue") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + string != null -> visitor.visitString(string) + jsonValue != null -> visitor.visitJsonValue(jsonValue) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent10 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitString(string: String) {} + + override fun visitJsonValue(jsonValue: JsonValue) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitString(string: String) = 1 + + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent10 && + string == other.string && + jsonValue == other.jsonValue + } + + override fun hashCode(): Int = Objects.hash(string, jsonValue) + + override fun toString(): String = + when { + string != null -> "UnnamedSchemaWithArrayParent10{string=$string}" + jsonValue != null -> + "UnnamedSchemaWithArrayParent10{jsonValue=$jsonValue}" + _json != null -> "UnnamedSchemaWithArrayParent10{_unknown=$_json}" + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent10" + ) + } + + companion object { + + @JvmStatic + fun ofString(string: String) = + UnnamedSchemaWithArrayParent10(string = string) + + @JvmStatic + fun ofJsonValue(jsonValue: JsonValue) = + UnnamedSchemaWithArrayParent10(jsonValue = jsonValue) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent10] to a value of type [T]. + */ + interface Visitor<out T> { + + fun visitString(string: String): T + + fun visitJsonValue(jsonValue: JsonValue): T + + /** + * Maps an unknown variant of [UnnamedSchemaWithArrayParent10] to a value of + * type [T]. + * + * An instance of [UnnamedSchemaWithArrayParent10] can contain an unknown + * variant if it was deserialized from data that doesn't match any known + * variant. For example, if the SDK is on an older version than the API, + * then the API may respond with new variants that the SDK is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent10: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer<UnnamedSchemaWithArrayParent10>( + UnnamedSchemaWithArrayParent10::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent10 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<String>())?.let { + UnnamedSchemaWithArrayParent10( + string = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef<JsonValue>())?.let { + UnnamedSchemaWithArrayParent10( + jsonValue = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants. + 0 -> UnnamedSchemaWithArrayParent10(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then + // use the first completely valid match, or simply the first match + // if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer<UnnamedSchemaWithArrayParent10>( + UnnamedSchemaWithArrayParent10::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent10, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.jsonValue != null -> generator.writeObject(value.jsonValue) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent10" + ) + } + } + } + } + } + + class Type @JsonCreator private constructor(private val value: JsonField<String>) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val FUNCTION_MESSAGE_CHUNK = of("FunctionMessageChunk") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + FUNCTION_MESSAGE_CHUNK + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + FUNCTION_MESSAGE_CHUNK, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + FUNCTION_MESSAGE_CHUNK -> Value.FUNCTION_MESSAGE_CHUNK + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + FUNCTION_MESSAGE_CHUNK -> Known.FUNCTION_MESSAGE_CHUNK + else -> throw LangsmithApiInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FunctionMessageChunk && + content == other.content && + name == other.name && + id == other.id && + additionalKwargs == other.additionalKwargs && + responseMetadata == other.responseMetadata && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + content, + name, + id, + additionalKwargs, + responseMetadata, + type, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FunctionMessageChunk{content=$content, name=$name, id=$id, additionalKwargs=$additionalKwargs, responseMetadata=$responseMetadata, type=$type, additionalProperties=$additionalProperties}" + } + + /** Tool Message chunk. */ + class ToolMessageChunk + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val content: JsonField<Content>, + private val toolCallId: JsonField<String>, + private val id: JsonField<String>, + private val additionalKwargs: JsonValue, + private val artifact: JsonValue, + private val name: JsonField<String>, + private val responseMetadata: JsonValue, + private val status: JsonField<Status>, + private val type: JsonField<Type>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("content") + @ExcludeMissing + content: JsonField<Content> = JsonMissing.of(), + @JsonProperty("tool_call_id") + @ExcludeMissing + toolCallId: JsonField<String> = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("additional_kwargs") + @ExcludeMissing + additionalKwargs: JsonValue = JsonMissing.of(), + @JsonProperty("artifact") @ExcludeMissing artifact: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("response_metadata") + @ExcludeMissing + responseMetadata: JsonValue = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField<Status> = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField<Type> = JsonMissing.of(), + ) : this( + content, + toolCallId, + id, + additionalKwargs, + artifact, + name, + responseMetadata, + status, + type, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun content(): Content = content.getRequired("content") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun toolCallId(): String = toolCallId.getRequired("tool_call_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + @JsonProperty("additional_kwargs") + @ExcludeMissing + fun _additionalKwargs(): JsonValue = additionalKwargs + + @JsonProperty("artifact") @ExcludeMissing fun _artifact(): JsonValue = artifact + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun name(): Optional<String> = name.getOptional("name") + + @JsonProperty("response_metadata") + @ExcludeMissing + fun _responseMetadata(): JsonValue = responseMetadata + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun status(): Optional<Status> = status.getOptional("status") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun type(): Optional<Type> = type.getOptional("type") + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField<Content> = content + + /** + * Returns the raw JSON value of [toolCallId]. + * + * Unlike [toolCallId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tool_call_id") + @ExcludeMissing + fun _toolCallId(): JsonField<String> = toolCallId + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField<Status> = status + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField<Type> = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ToolMessageChunk]. + * + * The following fields are required: + * ```java + * .content() + * .toolCallId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ToolMessageChunk]. */ + class Builder internal constructor() { + + private var content: JsonField<Content>? = null + private var toolCallId: JsonField<String>? = null + private var id: JsonField<String> = JsonMissing.of() + private var additionalKwargs: JsonValue = JsonMissing.of() + private var artifact: JsonValue = JsonMissing.of() + private var name: JsonField<String> = JsonMissing.of() + private var responseMetadata: JsonValue = JsonMissing.of() + private var status: JsonField<Status> = JsonMissing.of() + private var type: JsonField<Type> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(toolMessageChunk: ToolMessageChunk) = apply { + content = toolMessageChunk.content + toolCallId = toolMessageChunk.toolCallId + id = toolMessageChunk.id + additionalKwargs = toolMessageChunk.additionalKwargs + artifact = toolMessageChunk.artifact + name = toolMessageChunk.name + responseMetadata = toolMessageChunk.responseMetadata + status = toolMessageChunk.status + type = toolMessageChunk.type + additionalProperties = toolMessageChunk.additionalProperties.toMutableMap() + } + + fun content(content: Content) = content(JsonField.of(content)) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [Content] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun content(content: JsonField<Content>) = apply { this.content = content } + + /** Alias for calling [content] with `Content.ofString(string)`. */ + fun content(string: String) = content(Content.ofString(string)) + + /** + * Alias for calling [content] with + * `Content.ofUnnamedSchemaWithArrayParent11s(unnamedSchemaWithArrayParent11s)`. + */ + fun contentOfUnnamedSchemaWithArrayParent11s( + unnamedSchemaWithArrayParent11s: List<Content.UnnamedSchemaWithArrayParent11> + ) = + content( + Content.ofUnnamedSchemaWithArrayParent11s(unnamedSchemaWithArrayParent11s) + ) + + fun toolCallId(toolCallId: String) = toolCallId(JsonField.of(toolCallId)) + + /** + * Sets [Builder.toolCallId] to an arbitrary JSON value. + * + * You should usually call [Builder.toolCallId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun toolCallId(toolCallId: JsonField<String>) = apply { + this.toolCallId = toolCallId + } + + fun id(id: String?) = id(JsonField.ofNullable(id)) + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<String>) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun additionalKwargs(additionalKwargs: JsonValue) = apply { + this.additionalKwargs = additionalKwargs + } + + fun artifact(artifact: JsonValue) = apply { this.artifact = artifact } + + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional<String>) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun responseMetadata(responseMetadata: JsonValue) = apply { + this.responseMetadata = responseMetadata + } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun status(status: JsonField<Status>) = apply { this.status = status } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField<Type>) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ToolMessageChunk]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .content() + * .toolCallId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ToolMessageChunk = + ToolMessageChunk( + checkRequired("content", content), + checkRequired("toolCallId", toolCallId), + id, + additionalKwargs, + artifact, + name, + responseMetadata, + status, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ToolMessageChunk = apply { + if (validated) { + return@apply + } + + content().validate() + toolCallId() + id() + name() + status().ifPresent { it.validate() } + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (content.asKnown().getOrNull()?.validity() ?: 0) + + (if (toolCallId.asKnown().isPresent) 1 else 0) + + (if (id.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + @JsonDeserialize(using = Content.Deserializer::class) + @JsonSerialize(using = Content.Serializer::class) + class Content + private constructor( + private val string: String? = null, + private val unnamedSchemaWithArrayParent11s: List<UnnamedSchemaWithArrayParent11>? = + null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun unnamedSchemaWithArrayParent11s(): + Optional<List<UnnamedSchemaWithArrayParent11>> = + Optional.ofNullable(unnamedSchemaWithArrayParent11s) + + fun isString(): Boolean = string != null + + fun isUnnamedSchemaWithArrayParent11s(): Boolean = + unnamedSchemaWithArrayParent11s != null + + fun asString(): String = string.getOrThrow("string") + + fun asUnnamedSchemaWithArrayParent11s(): List<UnnamedSchemaWithArrayParent11> = + unnamedSchemaWithArrayParent11s.getOrThrow("unnamedSchemaWithArrayParent11s") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + string != null -> visitor.visitString(string) + unnamedSchemaWithArrayParent11s != null -> + visitor.visitUnnamedSchemaWithArrayParent11s( + unnamedSchemaWithArrayParent11s + ) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Content = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitString(string: String) {} + + override fun visitUnnamedSchemaWithArrayParent11s( + unnamedSchemaWithArrayParent11s: + List<UnnamedSchemaWithArrayParent11> + ) { + unnamedSchemaWithArrayParent11s.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitString(string: String) = 1 + + override fun visitUnnamedSchemaWithArrayParent11s( + unnamedSchemaWithArrayParent11s: + List<UnnamedSchemaWithArrayParent11> + ) = unnamedSchemaWithArrayParent11s.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Content && + string == other.string && + unnamedSchemaWithArrayParent11s == other.unnamedSchemaWithArrayParent11s + } + + override fun hashCode(): Int = Objects.hash(string, unnamedSchemaWithArrayParent11s) + + override fun toString(): String = + when { + string != null -> "Content{string=$string}" + unnamedSchemaWithArrayParent11s != null -> + "Content{unnamedSchemaWithArrayParent11s=$unnamedSchemaWithArrayParent11s}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Content(string = string) + + @JvmStatic + fun ofUnnamedSchemaWithArrayParent11s( + unnamedSchemaWithArrayParent11s: List<UnnamedSchemaWithArrayParent11> + ) = + Content( + unnamedSchemaWithArrayParent11s = + unnamedSchemaWithArrayParent11s.toImmutable() + ) + } + + /** + * An interface that defines how to map each variant of [Content] to a value of type + * [T]. + */ + interface Visitor<out T> { + + fun visitString(string: String): T + + fun visitUnnamedSchemaWithArrayParent11s( + unnamedSchemaWithArrayParent11s: List<UnnamedSchemaWithArrayParent11> + ): T + + /** + * Maps an unknown variant of [Content] to a value of type [T]. + * + * An instance of [Content] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Content: $json") + } + } + + internal class Deserializer : BaseDeserializer<Content>(Content::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Content { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<String>())?.let { + Content(string = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef<List<UnnamedSchemaWithArrayParent11>>(), + ) + ?.let { + Content( + unnamedSchemaWithArrayParent11s = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // object). + 0 -> Content(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Content>(Content::class) { + + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.unnamedSchemaWithArrayParent11s != null -> + generator.writeObject(value.unnamedSchemaWithArrayParent11s) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } + } + } + + @JsonDeserialize(using = UnnamedSchemaWithArrayParent11.Deserializer::class) + @JsonSerialize(using = UnnamedSchemaWithArrayParent11.Serializer::class) + class UnnamedSchemaWithArrayParent11 + private constructor( + private val string: String? = null, + private val jsonValue: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun jsonValue(): Optional<JsonValue> = Optional.ofNullable(jsonValue) + + fun isString(): Boolean = string != null + + fun isJsonValue(): Boolean = jsonValue != null + + fun asString(): String = string.getOrThrow("string") + + fun asJsonValue(): JsonValue = jsonValue.getOrThrow("jsonValue") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + string != null -> visitor.visitString(string) + jsonValue != null -> visitor.visitJsonValue(jsonValue) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent11 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitString(string: String) {} + + override fun visitJsonValue(jsonValue: JsonValue) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitString(string: String) = 1 + + override fun visitJsonValue(jsonValue: JsonValue) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent11 && + string == other.string && + jsonValue == other.jsonValue + } + + override fun hashCode(): Int = Objects.hash(string, jsonValue) + + override fun toString(): String = + when { + string != null -> "UnnamedSchemaWithArrayParent11{string=$string}" + jsonValue != null -> + "UnnamedSchemaWithArrayParent11{jsonValue=$jsonValue}" + _json != null -> "UnnamedSchemaWithArrayParent11{_unknown=$_json}" + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent11" + ) + } + + companion object { + + @JvmStatic + fun ofString(string: String) = + UnnamedSchemaWithArrayParent11(string = string) + + @JvmStatic + fun ofJsonValue(jsonValue: JsonValue) = + UnnamedSchemaWithArrayParent11(jsonValue = jsonValue) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent11] to a value of type [T]. + */ + interface Visitor<out T> { + + fun visitString(string: String): T + + fun visitJsonValue(jsonValue: JsonValue): T + + /** + * Maps an unknown variant of [UnnamedSchemaWithArrayParent11] to a value of + * type [T]. + * + * An instance of [UnnamedSchemaWithArrayParent11] can contain an unknown + * variant if it was deserialized from data that doesn't match any known + * variant. For example, if the SDK is on an older version than the API, + * then the API may respond with new variants that the SDK is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent11: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer<UnnamedSchemaWithArrayParent11>( + UnnamedSchemaWithArrayParent11::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent11 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<String>())?.let { + UnnamedSchemaWithArrayParent11( + string = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef<JsonValue>())?.let { + UnnamedSchemaWithArrayParent11( + jsonValue = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants. + 0 -> UnnamedSchemaWithArrayParent11(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then + // use the first completely valid match, or simply the first match + // if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer<UnnamedSchemaWithArrayParent11>( + UnnamedSchemaWithArrayParent11::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent11, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.jsonValue != null -> generator.writeObject(value.jsonValue) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent11" + ) + } + } + } + } + } + + class Status @JsonCreator private constructor(private val value: JsonField<String>) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val SUCCESS = of("success") + + @JvmField val ERROR = of("error") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + SUCCESS, + ERROR, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SUCCESS, + ERROR, + /** + * An enum member indicating that [Status] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SUCCESS -> Value.SUCCESS + ERROR -> Value.ERROR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + SUCCESS -> Known.SUCCESS + ERROR -> Known.ERROR + else -> throw LangsmithApiInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Type @JsonCreator private constructor(private val value: JsonField<String>) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val TOOL_MESSAGE_CHUNK = of("ToolMessageChunk") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + TOOL_MESSAGE_CHUNK + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TOOL_MESSAGE_CHUNK, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TOOL_MESSAGE_CHUNK -> Value.TOOL_MESSAGE_CHUNK + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + TOOL_MESSAGE_CHUNK -> Known.TOOL_MESSAGE_CHUNK + else -> throw LangsmithApiInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ToolMessageChunk && + content == other.content && + toolCallId == other.toolCallId && + id == other.id && + additionalKwargs == other.additionalKwargs && + artifact == other.artifact && + name == other.name && + responseMetadata == other.responseMetadata && + status == other.status && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + content, + toolCallId, + id, + additionalKwargs, + artifact, + name, + responseMetadata, + status, + type, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ToolMessageChunk{content=$content, toolCallId=$toolCallId, id=$id, additionalKwargs=$additionalKwargs, artifact=$artifact, name=$name, responseMetadata=$responseMetadata, status=$status, type=$type, additionalProperties=$additionalProperties}" + } + } + + class Secrets + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Secrets]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Secrets]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(secrets: Secrets) = apply { + additionalProperties = secrets.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Secrets]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Secrets = Secrets(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Secrets = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Secrets && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Secrets{additionalProperties=$additionalProperties}" + } + + class TemplateFormat @JsonCreator private constructor(private val value: JsonField<String>) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val F_STRING = of("f-string") + + @JvmField val MUSTACHE = of("mustache") + + @JvmStatic fun of(value: String) = TemplateFormat(JsonField.of(value)) + } + + /** An enum containing [TemplateFormat]'s known values. */ + enum class Known { + F_STRING, + MUSTACHE, + } + + /** + * An enum containing [TemplateFormat]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TemplateFormat] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + F_STRING, + MUSTACHE, + /** + * An enum member indicating that [TemplateFormat] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + F_STRING -> Value.F_STRING + MUSTACHE -> Value.MUSTACHE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + F_STRING -> Known.F_STRING + MUSTACHE -> Known.MUSTACHE + else -> throw LangsmithApiInvalidDataException("Unknown TemplateFormat: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TemplateFormat = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TemplateFormat && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Artifact + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField<String>, + private val contents: JsonField<List<Content>>, + private val currentContentIndex: JsonField<Long>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("contents") + @ExcludeMissing + contents: JsonField<List<Content>> = JsonMissing.of(), + @JsonProperty("current_content_index") + @ExcludeMissing + currentContentIndex: JsonField<Long> = JsonMissing.of(), + ) : this(id, contents, currentContentIndex, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun contents(): List<Content> = contents.getRequired("contents") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currentContentIndex(): Long = currentContentIndex.getRequired("current_content_index") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [contents]. + * + * Unlike [contents], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("contents") + @ExcludeMissing + fun _contents(): JsonField<List<Content>> = contents + + /** + * Returns the raw JSON value of [currentContentIndex]. + * + * Unlike [currentContentIndex], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("current_content_index") + @ExcludeMissing + fun _currentContentIndex(): JsonField<Long> = currentContentIndex + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Artifact]. + * + * The following fields are required: + * ```java + * .id() + * .contents() + * .currentContentIndex() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Artifact]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var contents: JsonField<MutableList<Content>>? = null + private var currentContentIndex: JsonField<Long>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(artifact: Artifact) = apply { + id = artifact.id + contents = artifact.contents.map { it.toMutableList() } + currentContentIndex = artifact.currentContentIndex + additionalProperties = artifact.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun contents(contents: List<Content>) = contents(JsonField.of(contents)) + + /** + * Sets [Builder.contents] to an arbitrary JSON value. + * + * You should usually call [Builder.contents] with a well-typed `List<Content>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun contents(contents: JsonField<List<Content>>) = apply { + this.contents = contents.map { it.toMutableList() } + } + + /** + * Adds a single [Content] to [contents]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addContent(content: Content) = apply { + contents = + (contents ?: JsonField.of(mutableListOf())).also { + checkKnown("contents", it).add(content) + } + } + + fun currentContentIndex(currentContentIndex: Long) = + currentContentIndex(JsonField.of(currentContentIndex)) + + /** + * Sets [Builder.currentContentIndex] to an arbitrary JSON value. + * + * You should usually call [Builder.currentContentIndex] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun currentContentIndex(currentContentIndex: JsonField<Long>) = apply { + this.currentContentIndex = currentContentIndex + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Artifact]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .contents() + * .currentContentIndex() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Artifact = + Artifact( + checkRequired("id", id), + checkRequired("contents", contents).map { it.toImmutable() }, + checkRequired("currentContentIndex", currentContentIndex), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Artifact = apply { + if (validated) { + return@apply + } + + id() + contents().forEach { it.validate() } + currentContentIndex() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (contents.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (currentContentIndex.asKnown().isPresent) 1 else 0) + + class Content + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val content: JsonField<String>, + private val index: JsonField<Long>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("content") + @ExcludeMissing + content: JsonField<String> = JsonMissing.of(), + @JsonProperty("index") @ExcludeMissing index: JsonField<Long> = JsonMissing.of(), + ) : this(content, index, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun content(): String = content.getRequired("content") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun index(): Long = index.getRequired("index") + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField<String> = content + + /** + * Returns the raw JSON value of [index]. + * + * Unlike [index], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("index") @ExcludeMissing fun _index(): JsonField<Long> = index + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Content]. + * + * The following fields are required: + * ```java + * .content() + * .index() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Content]. */ + class Builder internal constructor() { + + private var content: JsonField<String>? = null + private var index: JsonField<Long>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(content: Content) = apply { + this.content = content.content + index = content.index + additionalProperties = content.additionalProperties.toMutableMap() + } + + fun content(content: String) = content(JsonField.of(content)) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun content(content: JsonField<String>) = apply { this.content = content } + + fun index(index: Long) = index(JsonField.of(index)) + + /** + * Sets [Builder.index] to an arbitrary JSON value. + * + * You should usually call [Builder.index] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun index(index: JsonField<Long>) = apply { this.index = index } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Content]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .content() + * .index() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Content = + Content( + checkRequired("content", content), + checkRequired("index", index), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Content = apply { + if (validated) { + return@apply + } + + content() + index() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (content.asKnown().isPresent) 1 else 0) + + (if (index.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Content && + content == other.content && + index == other.index && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(content, index, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Content{content=$content, index=$index, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Artifact && + id == other.id && + contents == other.contents && + currentContentIndex == other.currentContentIndex && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, contents, currentContentIndex, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Artifact{id=$id, contents=$contents, currentContentIndex=$currentContentIndex, additionalProperties=$additionalProperties}" + } + + class ArtifactLength @JsonCreator private constructor(private val value: JsonField<String>) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val SHORTEST = of("shortest") + + @JvmField val SHORT = of("short") + + @JvmField val LONG = of("long") + + @JvmField val LONGEST = of("longest") + + @JvmStatic fun of(value: String) = ArtifactLength(JsonField.of(value)) + } + + /** An enum containing [ArtifactLength]'s known values. */ + enum class Known { + SHORTEST, + SHORT, + LONG, + LONGEST, + } + + /** + * An enum containing [ArtifactLength]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ArtifactLength] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SHORTEST, + SHORT, + LONG, + LONGEST, + /** + * An enum member indicating that [ArtifactLength] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SHORTEST -> Value.SHORTEST + SHORT -> Value.SHORT + LONG -> Value.LONG + LONGEST -> Value.LONGEST + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SHORTEST -> Known.SHORTEST + SHORT -> Known.SHORT + LONG -> Known.LONG + LONGEST -> Known.LONGEST + else -> throw LangsmithApiInvalidDataException("Unknown ArtifactLength: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ArtifactLength = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ArtifactLength && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Highlighted + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val highlightText: JsonField<String>, + private val promptChunk: JsonField<String>, + private val promptChunkEndIndex: JsonField<Long>, + private val promptChunkStartIndex: JsonField<Long>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("highlight_text") + @ExcludeMissing + highlightText: JsonField<String> = JsonMissing.of(), + @JsonProperty("prompt_chunk") + @ExcludeMissing + promptChunk: JsonField<String> = JsonMissing.of(), + @JsonProperty("prompt_chunk_end_index") + @ExcludeMissing + promptChunkEndIndex: JsonField<Long> = JsonMissing.of(), + @JsonProperty("prompt_chunk_start_index") + @ExcludeMissing + promptChunkStartIndex: JsonField<Long> = JsonMissing.of(), + ) : this( + highlightText, + promptChunk, + promptChunkEndIndex, + promptChunkStartIndex, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun highlightText(): String = highlightText.getRequired("highlight_text") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun promptChunk(): String = promptChunk.getRequired("prompt_chunk") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun promptChunkEndIndex(): Long = promptChunkEndIndex.getRequired("prompt_chunk_end_index") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun promptChunkStartIndex(): Long = + promptChunkStartIndex.getRequired("prompt_chunk_start_index") + + /** + * Returns the raw JSON value of [highlightText]. + * + * Unlike [highlightText], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("highlight_text") + @ExcludeMissing + fun _highlightText(): JsonField<String> = highlightText + + /** + * Returns the raw JSON value of [promptChunk]. + * + * Unlike [promptChunk], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prompt_chunk") + @ExcludeMissing + fun _promptChunk(): JsonField<String> = promptChunk + + /** + * Returns the raw JSON value of [promptChunkEndIndex]. + * + * Unlike [promptChunkEndIndex], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prompt_chunk_end_index") + @ExcludeMissing + fun _promptChunkEndIndex(): JsonField<Long> = promptChunkEndIndex + + /** + * Returns the raw JSON value of [promptChunkStartIndex]. + * + * Unlike [promptChunkStartIndex], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prompt_chunk_start_index") + @ExcludeMissing + fun _promptChunkStartIndex(): JsonField<Long> = promptChunkStartIndex + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Highlighted]. + * + * The following fields are required: + * ```java + * .highlightText() + * .promptChunk() + * .promptChunkEndIndex() + * .promptChunkStartIndex() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Highlighted]. */ + class Builder internal constructor() { + + private var highlightText: JsonField<String>? = null + private var promptChunk: JsonField<String>? = null + private var promptChunkEndIndex: JsonField<Long>? = null + private var promptChunkStartIndex: JsonField<Long>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(highlighted: Highlighted) = apply { + highlightText = highlighted.highlightText + promptChunk = highlighted.promptChunk + promptChunkEndIndex = highlighted.promptChunkEndIndex + promptChunkStartIndex = highlighted.promptChunkStartIndex + additionalProperties = highlighted.additionalProperties.toMutableMap() + } + + fun highlightText(highlightText: String) = highlightText(JsonField.of(highlightText)) + + /** + * Sets [Builder.highlightText] to an arbitrary JSON value. + * + * You should usually call [Builder.highlightText] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun highlightText(highlightText: JsonField<String>) = apply { + this.highlightText = highlightText + } + + fun promptChunk(promptChunk: String) = promptChunk(JsonField.of(promptChunk)) + + /** + * Sets [Builder.promptChunk] to an arbitrary JSON value. + * + * You should usually call [Builder.promptChunk] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun promptChunk(promptChunk: JsonField<String>) = apply { + this.promptChunk = promptChunk + } + + fun promptChunkEndIndex(promptChunkEndIndex: Long) = + promptChunkEndIndex(JsonField.of(promptChunkEndIndex)) + + /** + * Sets [Builder.promptChunkEndIndex] to an arbitrary JSON value. + * + * You should usually call [Builder.promptChunkEndIndex] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun promptChunkEndIndex(promptChunkEndIndex: JsonField<Long>) = apply { + this.promptChunkEndIndex = promptChunkEndIndex + } + + fun promptChunkStartIndex(promptChunkStartIndex: Long) = + promptChunkStartIndex(JsonField.of(promptChunkStartIndex)) + + /** + * Sets [Builder.promptChunkStartIndex] to an arbitrary JSON value. + * + * You should usually call [Builder.promptChunkStartIndex] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun promptChunkStartIndex(promptChunkStartIndex: JsonField<Long>) = apply { + this.promptChunkStartIndex = promptChunkStartIndex + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Highlighted]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .highlightText() + * .promptChunk() + * .promptChunkEndIndex() + * .promptChunkStartIndex() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Highlighted = + Highlighted( + checkRequired("highlightText", highlightText), + checkRequired("promptChunk", promptChunk), + checkRequired("promptChunkEndIndex", promptChunkEndIndex), + checkRequired("promptChunkStartIndex", promptChunkStartIndex), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Highlighted = apply { + if (validated) { + return@apply + } + + highlightText() + promptChunk() + promptChunkEndIndex() + promptChunkStartIndex() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (highlightText.asKnown().isPresent) 1 else 0) + + (if (promptChunk.asKnown().isPresent) 1 else 0) + + (if (promptChunkEndIndex.asKnown().isPresent) 1 else 0) + + (if (promptChunkStartIndex.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Highlighted && + highlightText == other.highlightText && + promptChunk == other.promptChunk && + promptChunkEndIndex == other.promptChunkEndIndex && + promptChunkStartIndex == other.promptChunkStartIndex && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + highlightText, + promptChunk, + promptChunkEndIndex, + promptChunkStartIndex, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Highlighted{highlightText=$highlightText, promptChunk=$promptChunk, promptChunkEndIndex=$promptChunkEndIndex, promptChunkStartIndex=$promptChunkStartIndex, additionalProperties=$additionalProperties}" + } + + class ReadingLevel @JsonCreator private constructor(private val value: JsonField<String>) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val CHILD = of("child") + + @JvmField val TEENAGER = of("teenager") + + @JvmField val COLLEGE = of("college") + + @JvmField val PHD = of("phd") + + @JvmStatic fun of(value: String) = ReadingLevel(JsonField.of(value)) + } + + /** An enum containing [ReadingLevel]'s known values. */ + enum class Known { + CHILD, + TEENAGER, + COLLEGE, + PHD, + } + + /** + * An enum containing [ReadingLevel]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ReadingLevel] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CHILD, + TEENAGER, + COLLEGE, + PHD, + /** + * An enum member indicating that [ReadingLevel] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CHILD -> Value.CHILD + TEENAGER -> Value.TEENAGER + COLLEGE -> Value.COLLEGE + PHD -> Value.PHD + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CHILD -> Known.CHILD + TEENAGER -> Known.TEENAGER + COLLEGE -> Known.COLLEGE + PHD -> Known.PHD + else -> throw LangsmithApiInvalidDataException("Unknown ReadingLevel: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReadingLevel = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReadingLevel && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PromptCanvasParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "PromptCanvasParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/prompts/PromptCanvasResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/prompts/PromptCanvasResponse.kt new file mode 100644 index 00000000..71213499 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/prompts/PromptCanvasResponse.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.prompts + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class PromptCanvasResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [PromptCanvasResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PromptCanvasResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(promptCanvasResponse: PromptCanvasResponse) = apply { + additionalProperties = promptCanvasResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PromptCanvasResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PromptCanvasResponse = + PromptCanvasResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): PromptCanvasResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PromptCanvasResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "PromptCanvasResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/prompts/PromptInvokePromptParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/prompts/PromptInvokePromptParams.kt new file mode 100644 index 00000000..26c9a6d4 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/prompts/PromptInvokePromptParams.kt @@ -0,0 +1,535 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.prompts + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** Invoke Prompt */ +class PromptInvokePromptParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun _inputs(): JsonValue = body._inputs() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun messages(): List<List<JsonValue>> = body.messages() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun templateFormat(): String = body.templateFormat() + + /** + * Returns the raw JSON value of [messages]. + * + * Unlike [messages], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _messages(): JsonField<List<List<JsonValue>>> = body._messages() + + /** + * Returns the raw JSON value of [templateFormat]. + * + * Unlike [templateFormat], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _templateFormat(): JsonField<String> = body._templateFormat() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PromptInvokePromptParams]. + * + * The following fields are required: + * ```java + * .inputs() + * .messages() + * .templateFormat() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PromptInvokePromptParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(promptInvokePromptParams: PromptInvokePromptParams) = apply { + body = promptInvokePromptParams.body.toBuilder() + additionalHeaders = promptInvokePromptParams.additionalHeaders.toBuilder() + additionalQueryParams = promptInvokePromptParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [inputs] + * - [messages] + * - [templateFormat] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun inputs(inputs: JsonValue) = apply { body.inputs(inputs) } + + fun messages(messages: List<List<JsonValue>>) = apply { body.messages(messages) } + + /** + * Sets [Builder.messages] to an arbitrary JSON value. + * + * You should usually call [Builder.messages] with a well-typed `List<List<JsonValue>>` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun messages(messages: JsonField<List<List<JsonValue>>>) = apply { body.messages(messages) } + + /** + * Adds a single [List<JsonValue>] to [messages]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMessage(message: List<JsonValue>) = apply { body.addMessage(message) } + + fun templateFormat(templateFormat: String) = apply { body.templateFormat(templateFormat) } + + /** + * Sets [Builder.templateFormat] to an arbitrary JSON value. + * + * You should usually call [Builder.templateFormat] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun templateFormat(templateFormat: JsonField<String>) = apply { + body.templateFormat(templateFormat) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [PromptInvokePromptParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .inputs() + * .messages() + * .templateFormat() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PromptInvokePromptParams = + PromptInvokePromptParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val inputs: JsonValue, + private val messages: JsonField<List<List<JsonValue>>>, + private val templateFormat: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("inputs") @ExcludeMissing inputs: JsonValue = JsonMissing.of(), + @JsonProperty("messages") + @ExcludeMissing + messages: JsonField<List<List<JsonValue>>> = JsonMissing.of(), + @JsonProperty("template_format") + @ExcludeMissing + templateFormat: JsonField<String> = JsonMissing.of(), + ) : this(inputs, messages, templateFormat, mutableMapOf()) + + @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonValue = inputs + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun messages(): List<List<JsonValue>> = messages.getRequired("messages") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun templateFormat(): String = templateFormat.getRequired("template_format") + + /** + * Returns the raw JSON value of [messages]. + * + * Unlike [messages], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("messages") + @ExcludeMissing + fun _messages(): JsonField<List<List<JsonValue>>> = messages + + /** + * Returns the raw JSON value of [templateFormat]. + * + * Unlike [templateFormat], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("template_format") + @ExcludeMissing + fun _templateFormat(): JsonField<String> = templateFormat + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .inputs() + * .messages() + * .templateFormat() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var inputs: JsonValue? = null + private var messages: JsonField<MutableList<List<JsonValue>>>? = null + private var templateFormat: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + inputs = body.inputs + messages = body.messages.map { it.toMutableList() } + templateFormat = body.templateFormat + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun inputs(inputs: JsonValue) = apply { this.inputs = inputs } + + fun messages(messages: List<List<JsonValue>>) = messages(JsonField.of(messages)) + + /** + * Sets [Builder.messages] to an arbitrary JSON value. + * + * You should usually call [Builder.messages] with a well-typed `List<List<JsonValue>>` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun messages(messages: JsonField<List<List<JsonValue>>>) = apply { + this.messages = messages.map { it.toMutableList() } + } + + /** + * Adds a single [List<JsonValue>] to [messages]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMessage(message: List<JsonValue>) = apply { + messages = + (messages ?: JsonField.of(mutableListOf())).also { + checkKnown("messages", it).add(message) + } + } + + fun templateFormat(templateFormat: String) = + templateFormat(JsonField.of(templateFormat)) + + /** + * Sets [Builder.templateFormat] to an arbitrary JSON value. + * + * You should usually call [Builder.templateFormat] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun templateFormat(templateFormat: JsonField<String>) = apply { + this.templateFormat = templateFormat + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .inputs() + * .messages() + * .templateFormat() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("inputs", inputs), + checkRequired("messages", messages).map { it.toImmutable() }, + checkRequired("templateFormat", templateFormat), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + messages() + templateFormat() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (messages.asKnown().getOrNull()?.sumOf { it.size.toInt() } ?: 0) + + (if (templateFormat.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + inputs == other.inputs && + messages == other.messages && + templateFormat == other.templateFormat && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(inputs, messages, templateFormat, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{inputs=$inputs, messages=$messages, templateFormat=$templateFormat, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PromptInvokePromptParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "PromptInvokePromptParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/prompts/PromptInvokePromptResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/prompts/PromptInvokePromptResponse.kt new file mode 100644 index 00000000..9ba1e308 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/prompts/PromptInvokePromptResponse.kt @@ -0,0 +1,118 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.prompts + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class PromptInvokePromptResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PromptInvokePromptResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PromptInvokePromptResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(promptInvokePromptResponse: PromptInvokePromptResponse) = apply { + additionalProperties = promptInvokePromptResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PromptInvokePromptResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PromptInvokePromptResponse = + PromptInvokePromptResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): PromptInvokePromptResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PromptInvokePromptResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PromptInvokePromptResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/prompts/ToolCall.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/prompts/ToolCall.kt new file mode 100644 index 00000000..7e51d5db --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/prompts/ToolCall.kt @@ -0,0 +1,386 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.prompts + +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.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Represents an AI's request to call a tool. + * + * Example: + * + * ```python + * {"name": "foo", "args": {"a": 1}, "id": "123"} + * ``` + * This represents a request to call the tool named `'foo'` with arguments + * `{"a": 1}` and an identifier of `'123'`. + */ +class ToolCall +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val args: JsonValue, + private val name: JsonField<String>, + private val type: JsonField<Type>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("args") @ExcludeMissing args: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField<Type> = JsonMissing.of(), + ) : this(id, args, name, type, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + @JsonProperty("args") @ExcludeMissing fun _args(): JsonValue = args + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun type(): Optional<Type> = type.getOptional("type") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField<Type> = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ToolCall]. + * + * The following fields are required: + * ```java + * .id() + * .args() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ToolCall]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var args: JsonValue? = null + private var name: JsonField<String>? = null + private var type: JsonField<Type> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(toolCall: ToolCall) = apply { + id = toolCall.id + args = toolCall.args + name = toolCall.name + type = toolCall.type + additionalProperties = toolCall.additionalProperties.toMutableMap() + } + + fun id(id: String?) = id(JsonField.ofNullable(id)) + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<String>) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun args(args: JsonValue) = apply { this.args = args } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField<Type>) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ToolCall]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .args() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ToolCall = + ToolCall( + checkRequired("id", id), + checkRequired("args", args), + checkRequired("name", name), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ToolCall = apply { + if (validated) { + return@apply + } + + id() + name() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val TOOL_CALL = of("tool_call") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + TOOL_CALL + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TOOL_CALL, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TOOL_CALL -> Value.TOOL_CALL + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TOOL_CALL -> Known.TOOL_CALL + else -> throw LangsmithApiInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ToolCall && + id == other.id && + args == other.args && + name == other.name && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, args, name, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ToolCall{id=$id, args=$args, name=$name, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/prompts/UsageMetadata.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/prompts/UsageMetadata.kt new file mode 100644 index 00000000..c9de7ee2 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/prompts/UsageMetadata.kt @@ -0,0 +1,869 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.prompts + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Usage metadata for a message, such as token counts. + * + * This is a standard representation of token usage that is consistent across models. + * + * Example: + * + * ```python + * { + * "input_tokens": 350, + * "output_tokens": 240, + * "total_tokens": 590, + * "input_token_details": { + * "audio": 10, + * "cache_creation": 200, + * "cache_read": 100, + * }, + * "output_token_details": { + * "audio": 10, + * "reasoning": 200, + * }, + * } + * ``` + * + * !!! warning "Behavior changed in 0.3.9" Added `input_token_details` and `output_token_details`. + */ +class UsageMetadata +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val inputTokens: JsonField<Long>, + private val outputTokens: JsonField<Long>, + private val totalTokens: JsonField<Long>, + private val inputTokenDetails: JsonField<InputTokenDetails>, + private val outputTokenDetails: JsonField<OutputTokenDetails>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("input_tokens") + @ExcludeMissing + inputTokens: JsonField<Long> = JsonMissing.of(), + @JsonProperty("output_tokens") + @ExcludeMissing + outputTokens: JsonField<Long> = JsonMissing.of(), + @JsonProperty("total_tokens") + @ExcludeMissing + totalTokens: JsonField<Long> = JsonMissing.of(), + @JsonProperty("input_token_details") + @ExcludeMissing + inputTokenDetails: JsonField<InputTokenDetails> = JsonMissing.of(), + @JsonProperty("output_token_details") + @ExcludeMissing + outputTokenDetails: JsonField<OutputTokenDetails> = JsonMissing.of(), + ) : this( + inputTokens, + outputTokens, + totalTokens, + inputTokenDetails, + outputTokenDetails, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun inputTokens(): Long = inputTokens.getRequired("input_tokens") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun outputTokens(): Long = outputTokens.getRequired("output_tokens") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun totalTokens(): Long = totalTokens.getRequired("total_tokens") + + /** + * Breakdown of input token counts. + * + * Does *not* need to sum to full input token count. Does *not* need to have all keys. + * + * Example: + * + * ```python + * { + * "audio": 10, + * "cache_creation": 200, + * "cache_read": 100, + * } + * ``` + * + * !!! version-added "Added in version 0.3.9" + * + * May also hold extra provider-specific keys. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun inputTokenDetails(): Optional<InputTokenDetails> = + inputTokenDetails.getOptional("input_token_details") + + /** + * Breakdown of output token counts. + * + * Does *not* need to sum to full output token count. Does *not* need to have all keys. + * + * Example: + * + * ```python + * { + * "audio": 10, + * "reasoning": 200, + * } + * ``` + * + * !!! version-added "Added in version 0.3.9" + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun outputTokenDetails(): Optional<OutputTokenDetails> = + outputTokenDetails.getOptional("output_token_details") + + /** + * Returns the raw JSON value of [inputTokens]. + * + * Unlike [inputTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input_tokens") @ExcludeMissing fun _inputTokens(): JsonField<Long> = inputTokens + + /** + * Returns the raw JSON value of [outputTokens]. + * + * Unlike [outputTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("output_tokens") + @ExcludeMissing + fun _outputTokens(): JsonField<Long> = outputTokens + + /** + * Returns the raw JSON value of [totalTokens]. + * + * Unlike [totalTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total_tokens") @ExcludeMissing fun _totalTokens(): JsonField<Long> = totalTokens + + /** + * Returns the raw JSON value of [inputTokenDetails]. + * + * Unlike [inputTokenDetails], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("input_token_details") + @ExcludeMissing + fun _inputTokenDetails(): JsonField<InputTokenDetails> = inputTokenDetails + + /** + * Returns the raw JSON value of [outputTokenDetails]. + * + * Unlike [outputTokenDetails], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("output_token_details") + @ExcludeMissing + fun _outputTokenDetails(): JsonField<OutputTokenDetails> = outputTokenDetails + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UsageMetadata]. + * + * The following fields are required: + * ```java + * .inputTokens() + * .outputTokens() + * .totalTokens() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UsageMetadata]. */ + class Builder internal constructor() { + + private var inputTokens: JsonField<Long>? = null + private var outputTokens: JsonField<Long>? = null + private var totalTokens: JsonField<Long>? = null + private var inputTokenDetails: JsonField<InputTokenDetails> = JsonMissing.of() + private var outputTokenDetails: JsonField<OutputTokenDetails> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(usageMetadata: UsageMetadata) = apply { + inputTokens = usageMetadata.inputTokens + outputTokens = usageMetadata.outputTokens + totalTokens = usageMetadata.totalTokens + inputTokenDetails = usageMetadata.inputTokenDetails + outputTokenDetails = usageMetadata.outputTokenDetails + additionalProperties = usageMetadata.additionalProperties.toMutableMap() + } + + fun inputTokens(inputTokens: Long) = inputTokens(JsonField.of(inputTokens)) + + /** + * Sets [Builder.inputTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.inputTokens] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun inputTokens(inputTokens: JsonField<Long>) = apply { this.inputTokens = inputTokens } + + fun outputTokens(outputTokens: Long) = outputTokens(JsonField.of(outputTokens)) + + /** + * Sets [Builder.outputTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.outputTokens] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun outputTokens(outputTokens: JsonField<Long>) = apply { this.outputTokens = outputTokens } + + fun totalTokens(totalTokens: Long) = totalTokens(JsonField.of(totalTokens)) + + /** + * Sets [Builder.totalTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.totalTokens] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun totalTokens(totalTokens: JsonField<Long>) = apply { this.totalTokens = totalTokens } + + /** + * Breakdown of input token counts. + * + * Does *not* need to sum to full input token count. Does *not* need to have all keys. + * + * Example: + * + * ```python + * { + * "audio": 10, + * "cache_creation": 200, + * "cache_read": 100, + * } + * ``` + * + * !!! version-added "Added in version 0.3.9" + * + * May also hold extra provider-specific keys. + */ + fun inputTokenDetails(inputTokenDetails: InputTokenDetails) = + inputTokenDetails(JsonField.of(inputTokenDetails)) + + /** + * Sets [Builder.inputTokenDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.inputTokenDetails] with a well-typed [InputTokenDetails] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun inputTokenDetails(inputTokenDetails: JsonField<InputTokenDetails>) = apply { + this.inputTokenDetails = inputTokenDetails + } + + /** + * Breakdown of output token counts. + * + * Does *not* need to sum to full output token count. Does *not* need to have all keys. + * + * Example: + * + * ```python + * { + * "audio": 10, + * "reasoning": 200, + * } + * ``` + * + * !!! version-added "Added in version 0.3.9" + */ + fun outputTokenDetails(outputTokenDetails: OutputTokenDetails) = + outputTokenDetails(JsonField.of(outputTokenDetails)) + + /** + * Sets [Builder.outputTokenDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.outputTokenDetails] with a well-typed + * [OutputTokenDetails] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun outputTokenDetails(outputTokenDetails: JsonField<OutputTokenDetails>) = apply { + this.outputTokenDetails = outputTokenDetails + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UsageMetadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .inputTokens() + * .outputTokens() + * .totalTokens() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UsageMetadata = + UsageMetadata( + checkRequired("inputTokens", inputTokens), + checkRequired("outputTokens", outputTokens), + checkRequired("totalTokens", totalTokens), + inputTokenDetails, + outputTokenDetails, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UsageMetadata = apply { + if (validated) { + return@apply + } + + inputTokens() + outputTokens() + totalTokens() + inputTokenDetails().ifPresent { it.validate() } + outputTokenDetails().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (inputTokens.asKnown().isPresent) 1 else 0) + + (if (outputTokens.asKnown().isPresent) 1 else 0) + + (if (totalTokens.asKnown().isPresent) 1 else 0) + + (inputTokenDetails.asKnown().getOrNull()?.validity() ?: 0) + + (outputTokenDetails.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Breakdown of input token counts. + * + * Does *not* need to sum to full input token count. Does *not* need to have all keys. + * + * Example: + * + * ```python + * { + * "audio": 10, + * "cache_creation": 200, + * "cache_read": 100, + * } + * ``` + * + * !!! version-added "Added in version 0.3.9" + * + * May also hold extra provider-specific keys. + */ + class InputTokenDetails + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val audio: JsonField<Long>, + private val cacheCreation: JsonField<Long>, + private val cacheRead: JsonField<Long>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("audio") @ExcludeMissing audio: JsonField<Long> = JsonMissing.of(), + @JsonProperty("cache_creation") + @ExcludeMissing + cacheCreation: JsonField<Long> = JsonMissing.of(), + @JsonProperty("cache_read") + @ExcludeMissing + cacheRead: JsonField<Long> = JsonMissing.of(), + ) : this(audio, cacheCreation, cacheRead, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun audio(): Optional<Long> = audio.getOptional("audio") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun cacheCreation(): Optional<Long> = cacheCreation.getOptional("cache_creation") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun cacheRead(): Optional<Long> = cacheRead.getOptional("cache_read") + + /** + * Returns the raw JSON value of [audio]. + * + * Unlike [audio], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("audio") @ExcludeMissing fun _audio(): JsonField<Long> = audio + + /** + * Returns the raw JSON value of [cacheCreation]. + * + * Unlike [cacheCreation], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cache_creation") + @ExcludeMissing + fun _cacheCreation(): JsonField<Long> = cacheCreation + + /** + * Returns the raw JSON value of [cacheRead]. + * + * Unlike [cacheRead], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cache_read") @ExcludeMissing fun _cacheRead(): JsonField<Long> = cacheRead + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [InputTokenDetails]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InputTokenDetails]. */ + class Builder internal constructor() { + + private var audio: JsonField<Long> = JsonMissing.of() + private var cacheCreation: JsonField<Long> = JsonMissing.of() + private var cacheRead: JsonField<Long> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(inputTokenDetails: InputTokenDetails) = apply { + audio = inputTokenDetails.audio + cacheCreation = inputTokenDetails.cacheCreation + cacheRead = inputTokenDetails.cacheRead + additionalProperties = inputTokenDetails.additionalProperties.toMutableMap() + } + + fun audio(audio: Long) = audio(JsonField.of(audio)) + + /** + * Sets [Builder.audio] to an arbitrary JSON value. + * + * You should usually call [Builder.audio] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun audio(audio: JsonField<Long>) = apply { this.audio = audio } + + fun cacheCreation(cacheCreation: Long) = cacheCreation(JsonField.of(cacheCreation)) + + /** + * Sets [Builder.cacheCreation] to an arbitrary JSON value. + * + * You should usually call [Builder.cacheCreation] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cacheCreation(cacheCreation: JsonField<Long>) = apply { + this.cacheCreation = cacheCreation + } + + fun cacheRead(cacheRead: Long) = cacheRead(JsonField.of(cacheRead)) + + /** + * Sets [Builder.cacheRead] to an arbitrary JSON value. + * + * You should usually call [Builder.cacheRead] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cacheRead(cacheRead: JsonField<Long>) = apply { this.cacheRead = cacheRead } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InputTokenDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InputTokenDetails = + InputTokenDetails( + audio, + cacheCreation, + cacheRead, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InputTokenDetails = apply { + if (validated) { + return@apply + } + + audio() + cacheCreation() + cacheRead() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (audio.asKnown().isPresent) 1 else 0) + + (if (cacheCreation.asKnown().isPresent) 1 else 0) + + (if (cacheRead.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InputTokenDetails && + audio == other.audio && + cacheCreation == other.cacheCreation && + cacheRead == other.cacheRead && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(audio, cacheCreation, cacheRead, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InputTokenDetails{audio=$audio, cacheCreation=$cacheCreation, cacheRead=$cacheRead, additionalProperties=$additionalProperties}" + } + + /** + * Breakdown of output token counts. + * + * Does *not* need to sum to full output token count. Does *not* need to have all keys. + * + * Example: + * + * ```python + * { + * "audio": 10, + * "reasoning": 200, + * } + * ``` + * + * !!! version-added "Added in version 0.3.9" + */ + class OutputTokenDetails + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val audio: JsonField<Long>, + private val reasoning: JsonField<Long>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("audio") @ExcludeMissing audio: JsonField<Long> = JsonMissing.of(), + @JsonProperty("reasoning") @ExcludeMissing reasoning: JsonField<Long> = JsonMissing.of(), + ) : this(audio, reasoning, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun audio(): Optional<Long> = audio.getOptional("audio") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun reasoning(): Optional<Long> = reasoning.getOptional("reasoning") + + /** + * Returns the raw JSON value of [audio]. + * + * Unlike [audio], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("audio") @ExcludeMissing fun _audio(): JsonField<Long> = audio + + /** + * Returns the raw JSON value of [reasoning]. + * + * Unlike [reasoning], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("reasoning") @ExcludeMissing fun _reasoning(): JsonField<Long> = reasoning + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [OutputTokenDetails]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OutputTokenDetails]. */ + class Builder internal constructor() { + + private var audio: JsonField<Long> = JsonMissing.of() + private var reasoning: JsonField<Long> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(outputTokenDetails: OutputTokenDetails) = apply { + audio = outputTokenDetails.audio + reasoning = outputTokenDetails.reasoning + additionalProperties = outputTokenDetails.additionalProperties.toMutableMap() + } + + fun audio(audio: Long) = audio(JsonField.of(audio)) + + /** + * Sets [Builder.audio] to an arbitrary JSON value. + * + * You should usually call [Builder.audio] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun audio(audio: JsonField<Long>) = apply { this.audio = audio } + + fun reasoning(reasoning: Long) = reasoning(JsonField.of(reasoning)) + + /** + * Sets [Builder.reasoning] to an arbitrary JSON value. + * + * You should usually call [Builder.reasoning] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun reasoning(reasoning: JsonField<Long>) = apply { this.reasoning = reasoning } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OutputTokenDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OutputTokenDetails = + OutputTokenDetails(audio, reasoning, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): OutputTokenDetails = apply { + if (validated) { + return@apply + } + + audio() + reasoning() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (audio.asKnown().isPresent) 1 else 0) + + (if (reasoning.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OutputTokenDetails && + audio == other.audio && + reasoning == other.reasoning && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(audio, reasoning, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OutputTokenDetails{audio=$audio, reasoning=$reasoning, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UsageMetadata && + inputTokens == other.inputTokens && + outputTokens == other.outputTokens && + totalTokens == other.totalTokens && + inputTokenDetails == other.inputTokenDetails && + outputTokenDetails == other.outputTokenDetails && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + inputTokens, + outputTokens, + totalTokens, + inputTokenDetails, + outputTokenDetails, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UsageMetadata{inputTokens=$inputTokens, outputTokens=$outputTokens, totalTokens=$totalTokens, inputTokenDetails=$inputTokenDetails, outputTokenDetails=$outputTokenDetails, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/EPromptWebhookTrigger.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/EPromptWebhookTrigger.kt new file mode 100644 index 00000000..b6520399 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/EPromptWebhookTrigger.kt @@ -0,0 +1,144 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.promptwebhooks + +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException + +/** Valid trigger types for prompt webhooks. */ +class EPromptWebhookTrigger @JsonCreator private constructor(private val value: JsonField<String>) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't match + * any known member, and you want to know that value. For example, if the SDK is on an older + * version than the API, then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val COMMIT = of("commit") + + @JvmField val TAG_CREATE = of("tag:create") + + @JvmField val TAG_UPDATE = of("tag:update") + + @JvmStatic fun of(value: String) = EPromptWebhookTrigger(JsonField.of(value)) + } + + /** An enum containing [EPromptWebhookTrigger]'s known values. */ + enum class Known { + COMMIT, + TAG_CREATE, + TAG_UPDATE, + } + + /** + * An enum containing [EPromptWebhookTrigger]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [EPromptWebhookTrigger] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the SDK + * is on an older version than the API, then the API may respond with new members that the SDK + * is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + COMMIT, + TAG_CREATE, + TAG_UPDATE, + /** + * An enum member indicating that [EPromptWebhookTrigger] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if + * the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want to + * throw for the unknown case. + */ + fun value(): Value = + when (this) { + COMMIT -> Value.COMMIT + TAG_CREATE -> Value.TAG_CREATE + TAG_UPDATE -> Value.TAG_UPDATE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't want + * to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + COMMIT -> Known.COMMIT + TAG_CREATE -> Known.TAG_CREATE + TAG_UPDATE -> Known.TAG_UPDATE + else -> throw LangsmithApiInvalidDataException("Unknown EPromptWebhookTrigger: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): EPromptWebhookTrigger = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EPromptWebhookTrigger && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhook.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhook.kt new file mode 100644 index 00000000..89267a85 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhook.kt @@ -0,0 +1,514 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.promptwebhooks + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Schema for a prompt webhook. */ +class PromptWebhook +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val tenantId: JsonField<String>, + private val updatedAt: JsonField<OffsetDateTime>, + private val url: JsonField<String>, + private val excludePrompts: JsonField<List<String>>, + private val headers: JsonValue, + private val includePrompts: JsonField<List<String>>, + private val triggers: JsonField<List<EPromptWebhookTrigger>>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("tenant_id") @ExcludeMissing tenantId: JsonField<String> = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField<String> = JsonMissing.of(), + @JsonProperty("exclude_prompts") + @ExcludeMissing + excludePrompts: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("headers") @ExcludeMissing headers: JsonValue = JsonMissing.of(), + @JsonProperty("include_prompts") + @ExcludeMissing + includePrompts: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("triggers") + @ExcludeMissing + triggers: JsonField<List<EPromptWebhookTrigger>> = JsonMissing.of(), + ) : this( + id, + createdAt, + tenantId, + updatedAt, + url, + excludePrompts, + headers, + includePrompts, + triggers, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tenantId(): String = tenantId.getRequired("tenant_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updatedAt(): OffsetDateTime = updatedAt.getRequired("updated_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun url(): String = url.getRequired("url") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun excludePrompts(): Optional<List<String>> = excludePrompts.getOptional("exclude_prompts") + + @JsonProperty("headers") @ExcludeMissing fun _headers(): JsonValue = headers + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun includePrompts(): Optional<List<String>> = includePrompts.getOptional("include_prompts") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun triggers(): Optional<List<EPromptWebhookTrigger>> = triggers.getOptional("triggers") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_id") @ExcludeMissing fun _tenantId(): JsonField<String> = tenantId + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField<OffsetDateTime> = updatedAt + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField<String> = url + + /** + * Returns the raw JSON value of [excludePrompts]. + * + * Unlike [excludePrompts], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("exclude_prompts") + @ExcludeMissing + fun _excludePrompts(): JsonField<List<String>> = excludePrompts + + /** + * Returns the raw JSON value of [includePrompts]. + * + * Unlike [includePrompts], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("include_prompts") + @ExcludeMissing + fun _includePrompts(): JsonField<List<String>> = includePrompts + + /** + * Returns the raw JSON value of [triggers]. + * + * Unlike [triggers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("triggers") + @ExcludeMissing + fun _triggers(): JsonField<List<EPromptWebhookTrigger>> = triggers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PromptWebhook]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .tenantId() + * .updatedAt() + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PromptWebhook]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var createdAt: JsonField<OffsetDateTime>? = null + private var tenantId: JsonField<String>? = null + private var updatedAt: JsonField<OffsetDateTime>? = null + private var url: JsonField<String>? = null + private var excludePrompts: JsonField<MutableList<String>>? = null + private var headers: JsonValue = JsonMissing.of() + private var includePrompts: JsonField<MutableList<String>>? = null + private var triggers: JsonField<MutableList<EPromptWebhookTrigger>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(promptWebhook: PromptWebhook) = apply { + id = promptWebhook.id + createdAt = promptWebhook.createdAt + tenantId = promptWebhook.tenantId + updatedAt = promptWebhook.updatedAt + url = promptWebhook.url + excludePrompts = promptWebhook.excludePrompts.map { it.toMutableList() } + headers = promptWebhook.headers + includePrompts = promptWebhook.includePrompts.map { it.toMutableList() } + triggers = promptWebhook.triggers.map { it.toMutableList() } + additionalProperties = promptWebhook.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tenantId(tenantId: JsonField<String>) = apply { this.tenantId = tenantId } + + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField<OffsetDateTime>) = apply { this.updatedAt = updatedAt } + + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun url(url: JsonField<String>) = apply { this.url = url } + + fun excludePrompts(excludePrompts: List<String>?) = + excludePrompts(JsonField.ofNullable(excludePrompts)) + + /** Alias for calling [Builder.excludePrompts] with `excludePrompts.orElse(null)`. */ + fun excludePrompts(excludePrompts: Optional<List<String>>) = + excludePrompts(excludePrompts.getOrNull()) + + /** + * Sets [Builder.excludePrompts] to an arbitrary JSON value. + * + * You should usually call [Builder.excludePrompts] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun excludePrompts(excludePrompts: JsonField<List<String>>) = apply { + this.excludePrompts = excludePrompts.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [excludePrompts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExcludePrompt(excludePrompt: String) = apply { + excludePrompts = + (excludePrompts ?: JsonField.of(mutableListOf())).also { + checkKnown("excludePrompts", it).add(excludePrompt) + } + } + + fun headers(headers: JsonValue) = apply { this.headers = headers } + + fun includePrompts(includePrompts: List<String>?) = + includePrompts(JsonField.ofNullable(includePrompts)) + + /** Alias for calling [Builder.includePrompts] with `includePrompts.orElse(null)`. */ + fun includePrompts(includePrompts: Optional<List<String>>) = + includePrompts(includePrompts.getOrNull()) + + /** + * Sets [Builder.includePrompts] to an arbitrary JSON value. + * + * You should usually call [Builder.includePrompts] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun includePrompts(includePrompts: JsonField<List<String>>) = apply { + this.includePrompts = includePrompts.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [includePrompts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addIncludePrompt(includePrompt: String) = apply { + includePrompts = + (includePrompts ?: JsonField.of(mutableListOf())).also { + checkKnown("includePrompts", it).add(includePrompt) + } + } + + fun triggers(triggers: List<EPromptWebhookTrigger>) = triggers(JsonField.of(triggers)) + + /** + * Sets [Builder.triggers] to an arbitrary JSON value. + * + * You should usually call [Builder.triggers] with a well-typed + * `List<EPromptWebhookTrigger>` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun triggers(triggers: JsonField<List<EPromptWebhookTrigger>>) = apply { + this.triggers = triggers.map { it.toMutableList() } + } + + /** + * Adds a single [EPromptWebhookTrigger] to [triggers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTrigger(trigger: EPromptWebhookTrigger) = apply { + triggers = + (triggers ?: JsonField.of(mutableListOf())).also { + checkKnown("triggers", it).add(trigger) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PromptWebhook]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .tenantId() + * .updatedAt() + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PromptWebhook = + PromptWebhook( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("tenantId", tenantId), + checkRequired("updatedAt", updatedAt), + checkRequired("url", url), + (excludePrompts ?: JsonMissing.of()).map { it.toImmutable() }, + headers, + (includePrompts ?: JsonMissing.of()).map { it.toImmutable() }, + (triggers ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PromptWebhook = apply { + if (validated) { + return@apply + } + + id() + createdAt() + tenantId() + updatedAt() + url() + excludePrompts() + includePrompts() + triggers().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + (excludePrompts.asKnown().getOrNull()?.size ?: 0) + + (includePrompts.asKnown().getOrNull()?.size ?: 0) + + (triggers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PromptWebhook && + id == other.id && + createdAt == other.createdAt && + tenantId == other.tenantId && + updatedAt == other.updatedAt && + url == other.url && + excludePrompts == other.excludePrompts && + headers == other.headers && + includePrompts == other.includePrompts && + triggers == other.triggers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + createdAt, + tenantId, + updatedAt, + url, + excludePrompts, + headers, + includePrompts, + triggers, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PromptWebhook{id=$id, createdAt=$createdAt, tenantId=$tenantId, updatedAt=$updatedAt, url=$url, excludePrompts=$excludePrompts, headers=$headers, includePrompts=$includePrompts, triggers=$triggers, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookDeleteParams.kt new file mode 100644 index 00000000..275d6cff --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookDeleteParams.kt @@ -0,0 +1,232 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.promptwebhooks + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete a specific prompt webhook. */ +class PromptWebhookDeleteParams +private constructor( + private val webhookId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun webhookId(): Optional<String> = Optional.ofNullable(webhookId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): PromptWebhookDeleteParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [PromptWebhookDeleteParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PromptWebhookDeleteParams]. */ + class Builder internal constructor() { + + private var webhookId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(promptWebhookDeleteParams: PromptWebhookDeleteParams) = apply { + webhookId = promptWebhookDeleteParams.webhookId + additionalHeaders = promptWebhookDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = promptWebhookDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + promptWebhookDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun webhookId(webhookId: String?) = apply { this.webhookId = webhookId } + + /** Alias for calling [Builder.webhookId] with `webhookId.orElse(null)`. */ + fun webhookId(webhookId: Optional<String>) = webhookId(webhookId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [PromptWebhookDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PromptWebhookDeleteParams = + PromptWebhookDeleteParams( + webhookId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> webhookId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PromptWebhookDeleteParams && + webhookId == other.webhookId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(webhookId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "PromptWebhookDeleteParams{webhookId=$webhookId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookDeleteResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookDeleteResponse.kt new file mode 100644 index 00000000..b979c56a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookDeleteResponse.kt @@ -0,0 +1,118 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.promptwebhooks + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class PromptWebhookDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PromptWebhookDeleteResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PromptWebhookDeleteResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(promptWebhookDeleteResponse: PromptWebhookDeleteResponse) = apply { + additionalProperties = promptWebhookDeleteResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PromptWebhookDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PromptWebhookDeleteResponse = + PromptWebhookDeleteResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): PromptWebhookDeleteResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PromptWebhookDeleteResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PromptWebhookDeleteResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookPromptWebhooksParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookPromptWebhooksParams.kt new file mode 100644 index 00000000..5dcead80 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookPromptWebhooksParams.kt @@ -0,0 +1,785 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.promptwebhooks + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create a new prompt webhook. */ +class PromptWebhookPromptWebhooksParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun url(): String = body.url() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional<String> = body.id() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun excludePrompts(): Optional<List<String>> = body.excludePrompts() + + fun _headers_(): JsonValue = body._headers_() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun includePrompts(): Optional<List<String>> = body.includePrompts() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun triggers(): Optional<List<EPromptWebhookTrigger>> = body.triggers() + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _url(): JsonField<String> = body._url() + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _id(): JsonField<String> = body._id() + + /** + * Returns the raw JSON value of [excludePrompts]. + * + * Unlike [excludePrompts], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _excludePrompts(): JsonField<List<String>> = body._excludePrompts() + + /** + * Returns the raw JSON value of [includePrompts]. + * + * Unlike [includePrompts], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _includePrompts(): JsonField<List<String>> = body._includePrompts() + + /** + * Returns the raw JSON value of [triggers]. + * + * Unlike [triggers], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _triggers(): JsonField<List<EPromptWebhookTrigger>> = body._triggers() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PromptWebhookPromptWebhooksParams]. + * + * The following fields are required: + * ```java + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PromptWebhookPromptWebhooksParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(promptWebhookPromptWebhooksParams: PromptWebhookPromptWebhooksParams) = + apply { + body = promptWebhookPromptWebhooksParams.body.toBuilder() + additionalHeaders = promptWebhookPromptWebhooksParams.additionalHeaders.toBuilder() + additionalQueryParams = + promptWebhookPromptWebhooksParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [url] + * - [id] + * - [excludePrompts] + * - [headers] + * - [includePrompts] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun url(url: String) = apply { body.url(url) } + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun url(url: JsonField<String>) = apply { body.url(url) } + + fun id(id: String?) = apply { body.id(id) } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<String>) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { body.id(id) } + + fun excludePrompts(excludePrompts: List<String>?) = apply { + body.excludePrompts(excludePrompts) + } + + /** Alias for calling [Builder.excludePrompts] with `excludePrompts.orElse(null)`. */ + fun excludePrompts(excludePrompts: Optional<List<String>>) = + excludePrompts(excludePrompts.getOrNull()) + + /** + * Sets [Builder.excludePrompts] to an arbitrary JSON value. + * + * You should usually call [Builder.excludePrompts] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun excludePrompts(excludePrompts: JsonField<List<String>>) = apply { + body.excludePrompts(excludePrompts) + } + + /** + * Adds a single [String] to [excludePrompts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExcludePrompt(excludePrompt: String) = apply { body.addExcludePrompt(excludePrompt) } + + fun headers(headers: JsonValue) = apply { body.headers(headers) } + + fun includePrompts(includePrompts: List<String>?) = apply { + body.includePrompts(includePrompts) + } + + /** Alias for calling [Builder.includePrompts] with `includePrompts.orElse(null)`. */ + fun includePrompts(includePrompts: Optional<List<String>>) = + includePrompts(includePrompts.getOrNull()) + + /** + * Sets [Builder.includePrompts] to an arbitrary JSON value. + * + * You should usually call [Builder.includePrompts] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun includePrompts(includePrompts: JsonField<List<String>>) = apply { + body.includePrompts(includePrompts) + } + + /** + * Adds a single [String] to [includePrompts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addIncludePrompt(includePrompt: String) = apply { body.addIncludePrompt(includePrompt) } + + fun triggers(triggers: List<EPromptWebhookTrigger>) = apply { body.triggers(triggers) } + + /** + * Sets [Builder.triggers] to an arbitrary JSON value. + * + * You should usually call [Builder.triggers] with a well-typed + * `List<EPromptWebhookTrigger>` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun triggers(triggers: JsonField<List<EPromptWebhookTrigger>>) = apply { + body.triggers(triggers) + } + + /** + * Adds a single [EPromptWebhookTrigger] to [triggers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTrigger(trigger: EPromptWebhookTrigger) = apply { body.addTrigger(trigger) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [PromptWebhookPromptWebhooksParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PromptWebhookPromptWebhooksParams = + PromptWebhookPromptWebhooksParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Schema for creating a prompt webhook. */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val url: JsonField<String>, + private val id: JsonField<String>, + private val excludePrompts: JsonField<List<String>>, + private val headers: JsonValue, + private val includePrompts: JsonField<List<String>>, + private val triggers: JsonField<List<EPromptWebhookTrigger>>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("url") @ExcludeMissing url: JsonField<String> = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("exclude_prompts") + @ExcludeMissing + excludePrompts: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("headers") @ExcludeMissing headers: JsonValue = JsonMissing.of(), + @JsonProperty("include_prompts") + @ExcludeMissing + includePrompts: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("triggers") + @ExcludeMissing + triggers: JsonField<List<EPromptWebhookTrigger>> = JsonMissing.of(), + ) : this(url, id, excludePrompts, headers, includePrompts, triggers, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun url(): String = url.getRequired("url") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun excludePrompts(): Optional<List<String>> = excludePrompts.getOptional("exclude_prompts") + + @JsonProperty("headers") @ExcludeMissing fun _headers_(): JsonValue = headers + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun includePrompts(): Optional<List<String>> = includePrompts.getOptional("include_prompts") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun triggers(): Optional<List<EPromptWebhookTrigger>> = triggers.getOptional("triggers") + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField<String> = url + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [excludePrompts]. + * + * Unlike [excludePrompts], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("exclude_prompts") + @ExcludeMissing + fun _excludePrompts(): JsonField<List<String>> = excludePrompts + + /** + * Returns the raw JSON value of [includePrompts]. + * + * Unlike [includePrompts], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("include_prompts") + @ExcludeMissing + fun _includePrompts(): JsonField<List<String>> = includePrompts + + /** + * Returns the raw JSON value of [triggers]. + * + * Unlike [triggers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("triggers") + @ExcludeMissing + fun _triggers(): JsonField<List<EPromptWebhookTrigger>> = triggers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var url: JsonField<String>? = null + private var id: JsonField<String> = JsonMissing.of() + private var excludePrompts: JsonField<MutableList<String>>? = null + private var headers: JsonValue = JsonMissing.of() + private var includePrompts: JsonField<MutableList<String>>? = null + private var triggers: JsonField<MutableList<EPromptWebhookTrigger>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + url = body.url + id = body.id + excludePrompts = body.excludePrompts.map { it.toMutableList() } + headers = body.headers + includePrompts = body.includePrompts.map { it.toMutableList() } + triggers = body.triggers.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun url(url: JsonField<String>) = apply { this.url = url } + + fun id(id: String?) = id(JsonField.ofNullable(id)) + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<String>) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun excludePrompts(excludePrompts: List<String>?) = + excludePrompts(JsonField.ofNullable(excludePrompts)) + + /** Alias for calling [Builder.excludePrompts] with `excludePrompts.orElse(null)`. */ + fun excludePrompts(excludePrompts: Optional<List<String>>) = + excludePrompts(excludePrompts.getOrNull()) + + /** + * Sets [Builder.excludePrompts] to an arbitrary JSON value. + * + * You should usually call [Builder.excludePrompts] with a well-typed `List<String>` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun excludePrompts(excludePrompts: JsonField<List<String>>) = apply { + this.excludePrompts = excludePrompts.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [excludePrompts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExcludePrompt(excludePrompt: String) = apply { + excludePrompts = + (excludePrompts ?: JsonField.of(mutableListOf())).also { + checkKnown("excludePrompts", it).add(excludePrompt) + } + } + + fun headers(headers: JsonValue) = apply { this.headers = headers } + + fun includePrompts(includePrompts: List<String>?) = + includePrompts(JsonField.ofNullable(includePrompts)) + + /** Alias for calling [Builder.includePrompts] with `includePrompts.orElse(null)`. */ + fun includePrompts(includePrompts: Optional<List<String>>) = + includePrompts(includePrompts.getOrNull()) + + /** + * Sets [Builder.includePrompts] to an arbitrary JSON value. + * + * You should usually call [Builder.includePrompts] with a well-typed `List<String>` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun includePrompts(includePrompts: JsonField<List<String>>) = apply { + this.includePrompts = includePrompts.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [includePrompts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addIncludePrompt(includePrompt: String) = apply { + includePrompts = + (includePrompts ?: JsonField.of(mutableListOf())).also { + checkKnown("includePrompts", it).add(includePrompt) + } + } + + fun triggers(triggers: List<EPromptWebhookTrigger>) = triggers(JsonField.of(triggers)) + + /** + * Sets [Builder.triggers] to an arbitrary JSON value. + * + * You should usually call [Builder.triggers] with a well-typed + * `List<EPromptWebhookTrigger>` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun triggers(triggers: JsonField<List<EPromptWebhookTrigger>>) = apply { + this.triggers = triggers.map { it.toMutableList() } + } + + /** + * Adds a single [EPromptWebhookTrigger] to [triggers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTrigger(trigger: EPromptWebhookTrigger) = apply { + triggers = + (triggers ?: JsonField.of(mutableListOf())).also { + checkKnown("triggers", it).add(trigger) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("url", url), + id, + (excludePrompts ?: JsonMissing.of()).map { it.toImmutable() }, + headers, + (includePrompts ?: JsonMissing.of()).map { it.toImmutable() }, + (triggers ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + url() + id() + excludePrompts() + includePrompts() + triggers().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (url.asKnown().isPresent) 1 else 0) + + (if (id.asKnown().isPresent) 1 else 0) + + (excludePrompts.asKnown().getOrNull()?.size ?: 0) + + (includePrompts.asKnown().getOrNull()?.size ?: 0) + + (triggers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + url == other.url && + id == other.id && + excludePrompts == other.excludePrompts && + headers == other.headers && + includePrompts == other.includePrompts && + triggers == other.triggers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + url, + id, + excludePrompts, + headers, + includePrompts, + triggers, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{url=$url, id=$id, excludePrompts=$excludePrompts, headers=$headers, includePrompts=$includePrompts, triggers=$triggers, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PromptWebhookPromptWebhooksParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "PromptWebhookPromptWebhooksParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookRetrieveParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookRetrieveParams.kt new file mode 100644 index 00000000..4c4bd128 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookRetrieveParams.kt @@ -0,0 +1,195 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.promptwebhooks + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get a specific prompt webhook. */ +class PromptWebhookRetrieveParams +private constructor( + private val webhookId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun webhookId(): Optional<String> = Optional.ofNullable(webhookId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): PromptWebhookRetrieveParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [PromptWebhookRetrieveParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PromptWebhookRetrieveParams]. */ + class Builder internal constructor() { + + private var webhookId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(promptWebhookRetrieveParams: PromptWebhookRetrieveParams) = apply { + webhookId = promptWebhookRetrieveParams.webhookId + additionalHeaders = promptWebhookRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = promptWebhookRetrieveParams.additionalQueryParams.toBuilder() + } + + fun webhookId(webhookId: String?) = apply { this.webhookId = webhookId } + + /** Alias for calling [Builder.webhookId] with `webhookId.orElse(null)`. */ + fun webhookId(webhookId: Optional<String>) = webhookId(webhookId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [PromptWebhookRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PromptWebhookRetrieveParams = + PromptWebhookRetrieveParams( + webhookId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> webhookId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PromptWebhookRetrieveParams && + webhookId == other.webhookId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(webhookId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "PromptWebhookRetrieveParams{webhookId=$webhookId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookRetrievePromptWebhooksParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookRetrievePromptWebhooksParams.kt new file mode 100644 index 00000000..9fa45d15 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookRetrievePromptWebhooksParams.kt @@ -0,0 +1,180 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.promptwebhooks + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** List all prompt webhooks for the current tenant. */ +class PromptWebhookRetrievePromptWebhooksParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): PromptWebhookRetrievePromptWebhooksParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [PromptWebhookRetrievePromptWebhooksParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PromptWebhookRetrievePromptWebhooksParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + promptWebhookRetrievePromptWebhooksParams: PromptWebhookRetrievePromptWebhooksParams + ) = apply { + additionalHeaders = + promptWebhookRetrievePromptWebhooksParams.additionalHeaders.toBuilder() + additionalQueryParams = + promptWebhookRetrievePromptWebhooksParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [PromptWebhookRetrievePromptWebhooksParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PromptWebhookRetrievePromptWebhooksParams = + PromptWebhookRetrievePromptWebhooksParams( + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PromptWebhookRetrievePromptWebhooksParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "PromptWebhookRetrievePromptWebhooksParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookTestParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookTestParams.kt new file mode 100644 index 00000000..805c7939 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookTestParams.kt @@ -0,0 +1,1243 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.promptwebhooks + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Test a specific prompt webhook. */ +class PromptWebhookTestParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun payload(): Payload = body.payload() + + /** + * Base schema for prompt webhooks. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun webhook(): Webhook = body.webhook() + + /** + * Returns the raw JSON value of [payload]. + * + * Unlike [payload], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _payload(): JsonField<Payload> = body._payload() + + /** + * Returns the raw JSON value of [webhook]. + * + * Unlike [webhook], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _webhook(): JsonField<Webhook> = body._webhook() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PromptWebhookTestParams]. + * + * The following fields are required: + * ```java + * .payload() + * .webhook() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PromptWebhookTestParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(promptWebhookTestParams: PromptWebhookTestParams) = apply { + body = promptWebhookTestParams.body.toBuilder() + additionalHeaders = promptWebhookTestParams.additionalHeaders.toBuilder() + additionalQueryParams = promptWebhookTestParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [payload] + * - [webhook] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun payload(payload: Payload) = apply { body.payload(payload) } + + /** + * Sets [Builder.payload] to an arbitrary JSON value. + * + * You should usually call [Builder.payload] with a well-typed [Payload] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun payload(payload: JsonField<Payload>) = apply { body.payload(payload) } + + /** Base schema for prompt webhooks. */ + fun webhook(webhook: Webhook) = apply { body.webhook(webhook) } + + /** + * Sets [Builder.webhook] to an arbitrary JSON value. + * + * You should usually call [Builder.webhook] with a well-typed [Webhook] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun webhook(webhook: JsonField<Webhook>) = apply { body.webhook(webhook) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [PromptWebhookTestParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .payload() + * .webhook() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PromptWebhookTestParams = + PromptWebhookTestParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Schema for testing a prompt webhook. */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val payload: JsonField<Payload>, + private val webhook: JsonField<Webhook>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("payload") @ExcludeMissing payload: JsonField<Payload> = JsonMissing.of(), + @JsonProperty("webhook") @ExcludeMissing webhook: JsonField<Webhook> = JsonMissing.of(), + ) : this(payload, webhook, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun payload(): Payload = payload.getRequired("payload") + + /** + * Base schema for prompt webhooks. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun webhook(): Webhook = webhook.getRequired("webhook") + + /** + * Returns the raw JSON value of [payload]. + * + * Unlike [payload], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("payload") @ExcludeMissing fun _payload(): JsonField<Payload> = payload + + /** + * Returns the raw JSON value of [webhook]. + * + * Unlike [webhook], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("webhook") @ExcludeMissing fun _webhook(): JsonField<Webhook> = webhook + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .payload() + * .webhook() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var payload: JsonField<Payload>? = null + private var webhook: JsonField<Webhook>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + payload = body.payload + webhook = body.webhook + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun payload(payload: Payload) = payload(JsonField.of(payload)) + + /** + * Sets [Builder.payload] to an arbitrary JSON value. + * + * You should usually call [Builder.payload] with a well-typed [Payload] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun payload(payload: JsonField<Payload>) = apply { this.payload = payload } + + /** Base schema for prompt webhooks. */ + fun webhook(webhook: Webhook) = webhook(JsonField.of(webhook)) + + /** + * Sets [Builder.webhook] to an arbitrary JSON value. + * + * You should usually call [Builder.webhook] with a well-typed [Webhook] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun webhook(webhook: JsonField<Webhook>) = apply { this.webhook = webhook } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .payload() + * .webhook() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("payload", payload), + checkRequired("webhook", webhook), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + payload().validate() + webhook().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (payload.asKnown().getOrNull()?.validity() ?: 0) + + (webhook.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + payload == other.payload && + webhook == other.webhook && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(payload, webhook, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{payload=$payload, webhook=$webhook, additionalProperties=$additionalProperties}" + } + + class Payload + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val commitHash: JsonField<String>, + private val createdAt: JsonField<String>, + private val createdBy: JsonField<String>, + private val event: JsonField<EPromptWebhookTrigger>, + private val manifest: JsonValue, + private val promptId: JsonField<String>, + private val promptName: JsonField<String>, + private val tagName: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("commit_hash") + @ExcludeMissing + commitHash: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_by") + @ExcludeMissing + createdBy: JsonField<String> = JsonMissing.of(), + @JsonProperty("event") + @ExcludeMissing + event: JsonField<EPromptWebhookTrigger> = JsonMissing.of(), + @JsonProperty("manifest") @ExcludeMissing manifest: JsonValue = JsonMissing.of(), + @JsonProperty("prompt_id") + @ExcludeMissing + promptId: JsonField<String> = JsonMissing.of(), + @JsonProperty("prompt_name") + @ExcludeMissing + promptName: JsonField<String> = JsonMissing.of(), + @JsonProperty("tag_name") @ExcludeMissing tagName: JsonField<String> = JsonMissing.of(), + ) : this( + commitHash, + createdAt, + createdBy, + event, + manifest, + promptId, + promptName, + tagName, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun commitHash(): String = commitHash.getRequired("commit_hash") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): String = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdBy(): String = createdBy.getRequired("created_by") + + /** + * Valid trigger types for prompt webhooks. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun event(): EPromptWebhookTrigger = event.getRequired("event") + + @JsonProperty("manifest") @ExcludeMissing fun _manifest(): JsonValue = manifest + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun promptId(): String = promptId.getRequired("prompt_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun promptName(): String = promptName.getRequired("prompt_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun tagName(): Optional<String> = tagName.getOptional("tag_name") + + /** + * Returns the raw JSON value of [commitHash]. + * + * Unlike [commitHash], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("commit_hash") + @ExcludeMissing + fun _commitHash(): JsonField<String> = commitHash + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") @ExcludeMissing fun _createdAt(): JsonField<String> = createdAt + + /** + * Returns the raw JSON value of [createdBy]. + * + * Unlike [createdBy], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_by") @ExcludeMissing fun _createdBy(): JsonField<String> = createdBy + + /** + * Returns the raw JSON value of [event]. + * + * Unlike [event], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("event") + @ExcludeMissing + fun _event(): JsonField<EPromptWebhookTrigger> = event + + /** + * Returns the raw JSON value of [promptId]. + * + * Unlike [promptId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prompt_id") @ExcludeMissing fun _promptId(): JsonField<String> = promptId + + /** + * Returns the raw JSON value of [promptName]. + * + * Unlike [promptName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prompt_name") + @ExcludeMissing + fun _promptName(): JsonField<String> = promptName + + /** + * Returns the raw JSON value of [tagName]. + * + * Unlike [tagName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tag_name") @ExcludeMissing fun _tagName(): JsonField<String> = tagName + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Payload]. + * + * The following fields are required: + * ```java + * .commitHash() + * .createdAt() + * .createdBy() + * .event() + * .manifest() + * .promptId() + * .promptName() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Payload]. */ + class Builder internal constructor() { + + private var commitHash: JsonField<String>? = null + private var createdAt: JsonField<String>? = null + private var createdBy: JsonField<String>? = null + private var event: JsonField<EPromptWebhookTrigger>? = null + private var manifest: JsonValue? = null + private var promptId: JsonField<String>? = null + private var promptName: JsonField<String>? = null + private var tagName: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(payload: Payload) = apply { + commitHash = payload.commitHash + createdAt = payload.createdAt + createdBy = payload.createdBy + event = payload.event + manifest = payload.manifest + promptId = payload.promptId + promptName = payload.promptName + tagName = payload.tagName + additionalProperties = payload.additionalProperties.toMutableMap() + } + + fun commitHash(commitHash: String) = commitHash(JsonField.of(commitHash)) + + /** + * Sets [Builder.commitHash] to an arbitrary JSON value. + * + * You should usually call [Builder.commitHash] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun commitHash(commitHash: JsonField<String>) = apply { this.commitHash = commitHash } + + fun createdAt(createdAt: String) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<String>) = apply { this.createdAt = createdAt } + + fun createdBy(createdBy: String) = createdBy(JsonField.of(createdBy)) + + /** + * Sets [Builder.createdBy] to an arbitrary JSON value. + * + * You should usually call [Builder.createdBy] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdBy(createdBy: JsonField<String>) = apply { this.createdBy = createdBy } + + /** Valid trigger types for prompt webhooks. */ + fun event(event: EPromptWebhookTrigger) = event(JsonField.of(event)) + + /** + * Sets [Builder.event] to an arbitrary JSON value. + * + * You should usually call [Builder.event] with a well-typed [EPromptWebhookTrigger] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun event(event: JsonField<EPromptWebhookTrigger>) = apply { this.event = event } + + fun manifest(manifest: JsonValue) = apply { this.manifest = manifest } + + fun promptId(promptId: String) = promptId(JsonField.of(promptId)) + + /** + * Sets [Builder.promptId] to an arbitrary JSON value. + * + * You should usually call [Builder.promptId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun promptId(promptId: JsonField<String>) = apply { this.promptId = promptId } + + fun promptName(promptName: String) = promptName(JsonField.of(promptName)) + + /** + * Sets [Builder.promptName] to an arbitrary JSON value. + * + * You should usually call [Builder.promptName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun promptName(promptName: JsonField<String>) = apply { this.promptName = promptName } + + fun tagName(tagName: String?) = tagName(JsonField.ofNullable(tagName)) + + /** Alias for calling [Builder.tagName] with `tagName.orElse(null)`. */ + fun tagName(tagName: Optional<String>) = tagName(tagName.getOrNull()) + + /** + * Sets [Builder.tagName] to an arbitrary JSON value. + * + * You should usually call [Builder.tagName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tagName(tagName: JsonField<String>) = apply { this.tagName = tagName } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Payload]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .commitHash() + * .createdAt() + * .createdBy() + * .event() + * .manifest() + * .promptId() + * .promptName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Payload = + Payload( + checkRequired("commitHash", commitHash), + checkRequired("createdAt", createdAt), + checkRequired("createdBy", createdBy), + checkRequired("event", event), + checkRequired("manifest", manifest), + checkRequired("promptId", promptId), + checkRequired("promptName", promptName), + tagName, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Payload = apply { + if (validated) { + return@apply + } + + commitHash() + createdAt() + createdBy() + event().validate() + promptId() + promptName() + tagName() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (commitHash.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (createdBy.asKnown().isPresent) 1 else 0) + + (event.asKnown().getOrNull()?.validity() ?: 0) + + (if (promptId.asKnown().isPresent) 1 else 0) + + (if (promptName.asKnown().isPresent) 1 else 0) + + (if (tagName.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Payload && + commitHash == other.commitHash && + createdAt == other.createdAt && + createdBy == other.createdBy && + event == other.event && + manifest == other.manifest && + promptId == other.promptId && + promptName == other.promptName && + tagName == other.tagName && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + commitHash, + createdAt, + createdBy, + event, + manifest, + promptId, + promptName, + tagName, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Payload{commitHash=$commitHash, createdAt=$createdAt, createdBy=$createdBy, event=$event, manifest=$manifest, promptId=$promptId, promptName=$promptName, tagName=$tagName, additionalProperties=$additionalProperties}" + } + + /** Base schema for prompt webhooks. */ + class Webhook + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val url: JsonField<String>, + private val excludePrompts: JsonField<List<String>>, + private val headers: JsonValue, + private val includePrompts: JsonField<List<String>>, + private val triggers: JsonField<List<EPromptWebhookTrigger>>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("url") @ExcludeMissing url: JsonField<String> = JsonMissing.of(), + @JsonProperty("exclude_prompts") + @ExcludeMissing + excludePrompts: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("headers") @ExcludeMissing headers: JsonValue = JsonMissing.of(), + @JsonProperty("include_prompts") + @ExcludeMissing + includePrompts: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("triggers") + @ExcludeMissing + triggers: JsonField<List<EPromptWebhookTrigger>> = JsonMissing.of(), + ) : this(url, excludePrompts, headers, includePrompts, triggers, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun url(): String = url.getRequired("url") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun excludePrompts(): Optional<List<String>> = excludePrompts.getOptional("exclude_prompts") + + @JsonProperty("headers") @ExcludeMissing fun _headers(): JsonValue = headers + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun includePrompts(): Optional<List<String>> = includePrompts.getOptional("include_prompts") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun triggers(): Optional<List<EPromptWebhookTrigger>> = triggers.getOptional("triggers") + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField<String> = url + + /** + * Returns the raw JSON value of [excludePrompts]. + * + * Unlike [excludePrompts], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("exclude_prompts") + @ExcludeMissing + fun _excludePrompts(): JsonField<List<String>> = excludePrompts + + /** + * Returns the raw JSON value of [includePrompts]. + * + * Unlike [includePrompts], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("include_prompts") + @ExcludeMissing + fun _includePrompts(): JsonField<List<String>> = includePrompts + + /** + * Returns the raw JSON value of [triggers]. + * + * Unlike [triggers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("triggers") + @ExcludeMissing + fun _triggers(): JsonField<List<EPromptWebhookTrigger>> = triggers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Webhook]. + * + * The following fields are required: + * ```java + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Webhook]. */ + class Builder internal constructor() { + + private var url: JsonField<String>? = null + private var excludePrompts: JsonField<MutableList<String>>? = null + private var headers: JsonValue = JsonMissing.of() + private var includePrompts: JsonField<MutableList<String>>? = null + private var triggers: JsonField<MutableList<EPromptWebhookTrigger>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(webhook: Webhook) = apply { + url = webhook.url + excludePrompts = webhook.excludePrompts.map { it.toMutableList() } + headers = webhook.headers + includePrompts = webhook.includePrompts.map { it.toMutableList() } + triggers = webhook.triggers.map { it.toMutableList() } + additionalProperties = webhook.additionalProperties.toMutableMap() + } + + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun url(url: JsonField<String>) = apply { this.url = url } + + fun excludePrompts(excludePrompts: List<String>?) = + excludePrompts(JsonField.ofNullable(excludePrompts)) + + /** Alias for calling [Builder.excludePrompts] with `excludePrompts.orElse(null)`. */ + fun excludePrompts(excludePrompts: Optional<List<String>>) = + excludePrompts(excludePrompts.getOrNull()) + + /** + * Sets [Builder.excludePrompts] to an arbitrary JSON value. + * + * You should usually call [Builder.excludePrompts] with a well-typed `List<String>` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun excludePrompts(excludePrompts: JsonField<List<String>>) = apply { + this.excludePrompts = excludePrompts.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [excludePrompts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExcludePrompt(excludePrompt: String) = apply { + excludePrompts = + (excludePrompts ?: JsonField.of(mutableListOf())).also { + checkKnown("excludePrompts", it).add(excludePrompt) + } + } + + fun headers(headers: JsonValue) = apply { this.headers = headers } + + fun includePrompts(includePrompts: List<String>?) = + includePrompts(JsonField.ofNullable(includePrompts)) + + /** Alias for calling [Builder.includePrompts] with `includePrompts.orElse(null)`. */ + fun includePrompts(includePrompts: Optional<List<String>>) = + includePrompts(includePrompts.getOrNull()) + + /** + * Sets [Builder.includePrompts] to an arbitrary JSON value. + * + * You should usually call [Builder.includePrompts] with a well-typed `List<String>` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun includePrompts(includePrompts: JsonField<List<String>>) = apply { + this.includePrompts = includePrompts.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [includePrompts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addIncludePrompt(includePrompt: String) = apply { + includePrompts = + (includePrompts ?: JsonField.of(mutableListOf())).also { + checkKnown("includePrompts", it).add(includePrompt) + } + } + + fun triggers(triggers: List<EPromptWebhookTrigger>) = triggers(JsonField.of(triggers)) + + /** + * Sets [Builder.triggers] to an arbitrary JSON value. + * + * You should usually call [Builder.triggers] with a well-typed + * `List<EPromptWebhookTrigger>` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun triggers(triggers: JsonField<List<EPromptWebhookTrigger>>) = apply { + this.triggers = triggers.map { it.toMutableList() } + } + + /** + * Adds a single [EPromptWebhookTrigger] to [triggers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTrigger(trigger: EPromptWebhookTrigger) = apply { + triggers = + (triggers ?: JsonField.of(mutableListOf())).also { + checkKnown("triggers", it).add(trigger) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Webhook]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Webhook = + Webhook( + checkRequired("url", url), + (excludePrompts ?: JsonMissing.of()).map { it.toImmutable() }, + headers, + (includePrompts ?: JsonMissing.of()).map { it.toImmutable() }, + (triggers ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Webhook = apply { + if (validated) { + return@apply + } + + url() + excludePrompts() + includePrompts() + triggers().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (url.asKnown().isPresent) 1 else 0) + + (excludePrompts.asKnown().getOrNull()?.size ?: 0) + + (includePrompts.asKnown().getOrNull()?.size ?: 0) + + (triggers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Webhook && + url == other.url && + excludePrompts == other.excludePrompts && + headers == other.headers && + includePrompts == other.includePrompts && + triggers == other.triggers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + url, + excludePrompts, + headers, + includePrompts, + triggers, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Webhook{url=$url, excludePrompts=$excludePrompts, headers=$headers, includePrompts=$includePrompts, triggers=$triggers, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PromptWebhookTestParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "PromptWebhookTestParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookTestResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookTestResponse.kt new file mode 100644 index 00000000..86b3801f --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookTestResponse.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.promptwebhooks + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Objects + +class PromptWebhookTestResponse +@JsonCreator +private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> +) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PromptWebhookTestResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PromptWebhookTestResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(promptWebhookTestResponse: PromptWebhookTestResponse) = apply { + additionalProperties = promptWebhookTestResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PromptWebhookTestResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PromptWebhookTestResponse = + PromptWebhookTestResponse(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): PromptWebhookTestResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PromptWebhookTestResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PromptWebhookTestResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookUpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookUpdateParams.kt new file mode 100644 index 00000000..738cbd79 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookUpdateParams.kt @@ -0,0 +1,729 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.promptwebhooks + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Update a specific prompt webhook. */ +class PromptWebhookUpdateParams +private constructor( + private val webhookId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun webhookId(): Optional<String> = Optional.ofNullable(webhookId) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun excludePrompts(): Optional<List<String>> = body.excludePrompts() + + fun _headers_(): JsonValue = body._headers_() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun includePrompts(): Optional<List<String>> = body.includePrompts() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun triggers(): Optional<List<EPromptWebhookTrigger>> = body.triggers() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun url(): Optional<String> = body.url() + + /** + * Returns the raw JSON value of [excludePrompts]. + * + * Unlike [excludePrompts], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _excludePrompts(): JsonField<List<String>> = body._excludePrompts() + + /** + * Returns the raw JSON value of [includePrompts]. + * + * Unlike [includePrompts], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _includePrompts(): JsonField<List<String>> = body._includePrompts() + + /** + * Returns the raw JSON value of [triggers]. + * + * Unlike [triggers], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _triggers(): JsonField<List<EPromptWebhookTrigger>> = body._triggers() + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _url(): JsonField<String> = body._url() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): PromptWebhookUpdateParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [PromptWebhookUpdateParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PromptWebhookUpdateParams]. */ + class Builder internal constructor() { + + private var webhookId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(promptWebhookUpdateParams: PromptWebhookUpdateParams) = apply { + webhookId = promptWebhookUpdateParams.webhookId + body = promptWebhookUpdateParams.body.toBuilder() + additionalHeaders = promptWebhookUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = promptWebhookUpdateParams.additionalQueryParams.toBuilder() + } + + fun webhookId(webhookId: String?) = apply { this.webhookId = webhookId } + + /** Alias for calling [Builder.webhookId] with `webhookId.orElse(null)`. */ + fun webhookId(webhookId: Optional<String>) = webhookId(webhookId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [excludePrompts] + * - [headers] + * - [includePrompts] + * - [triggers] + * - [url] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun excludePrompts(excludePrompts: List<String>?) = apply { + body.excludePrompts(excludePrompts) + } + + /** Alias for calling [Builder.excludePrompts] with `excludePrompts.orElse(null)`. */ + fun excludePrompts(excludePrompts: Optional<List<String>>) = + excludePrompts(excludePrompts.getOrNull()) + + /** + * Sets [Builder.excludePrompts] to an arbitrary JSON value. + * + * You should usually call [Builder.excludePrompts] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun excludePrompts(excludePrompts: JsonField<List<String>>) = apply { + body.excludePrompts(excludePrompts) + } + + /** + * Adds a single [String] to [excludePrompts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExcludePrompt(excludePrompt: String) = apply { body.addExcludePrompt(excludePrompt) } + + fun headers(headers: JsonValue) = apply { body.headers(headers) } + + fun includePrompts(includePrompts: List<String>?) = apply { + body.includePrompts(includePrompts) + } + + /** Alias for calling [Builder.includePrompts] with `includePrompts.orElse(null)`. */ + fun includePrompts(includePrompts: Optional<List<String>>) = + includePrompts(includePrompts.getOrNull()) + + /** + * Sets [Builder.includePrompts] to an arbitrary JSON value. + * + * You should usually call [Builder.includePrompts] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun includePrompts(includePrompts: JsonField<List<String>>) = apply { + body.includePrompts(includePrompts) + } + + /** + * Adds a single [String] to [includePrompts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addIncludePrompt(includePrompt: String) = apply { body.addIncludePrompt(includePrompt) } + + fun triggers(triggers: List<EPromptWebhookTrigger>?) = apply { body.triggers(triggers) } + + /** Alias for calling [Builder.triggers] with `triggers.orElse(null)`. */ + fun triggers(triggers: Optional<List<EPromptWebhookTrigger>>) = + triggers(triggers.getOrNull()) + + /** + * Sets [Builder.triggers] to an arbitrary JSON value. + * + * You should usually call [Builder.triggers] with a well-typed + * `List<EPromptWebhookTrigger>` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun triggers(triggers: JsonField<List<EPromptWebhookTrigger>>) = apply { + body.triggers(triggers) + } + + /** + * Adds a single [EPromptWebhookTrigger] to [triggers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTrigger(trigger: EPromptWebhookTrigger) = apply { body.addTrigger(trigger) } + + fun url(url: String?) = apply { body.url(url) } + + /** Alias for calling [Builder.url] with `url.orElse(null)`. */ + fun url(url: Optional<String>) = url(url.getOrNull()) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun url(url: JsonField<String>) = apply { body.url(url) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [PromptWebhookUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PromptWebhookUpdateParams = + PromptWebhookUpdateParams( + webhookId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> webhookId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Schema for updating a prompt webhook. */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val excludePrompts: JsonField<List<String>>, + private val headers: JsonValue, + private val includePrompts: JsonField<List<String>>, + private val triggers: JsonField<List<EPromptWebhookTrigger>>, + private val url: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("exclude_prompts") + @ExcludeMissing + excludePrompts: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("headers") @ExcludeMissing headers: JsonValue = JsonMissing.of(), + @JsonProperty("include_prompts") + @ExcludeMissing + includePrompts: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("triggers") + @ExcludeMissing + triggers: JsonField<List<EPromptWebhookTrigger>> = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField<String> = JsonMissing.of(), + ) : this(excludePrompts, headers, includePrompts, triggers, url, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun excludePrompts(): Optional<List<String>> = excludePrompts.getOptional("exclude_prompts") + + @JsonProperty("headers") @ExcludeMissing fun _headers_(): JsonValue = headers + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun includePrompts(): Optional<List<String>> = includePrompts.getOptional("include_prompts") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun triggers(): Optional<List<EPromptWebhookTrigger>> = triggers.getOptional("triggers") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun url(): Optional<String> = url.getOptional("url") + + /** + * Returns the raw JSON value of [excludePrompts]. + * + * Unlike [excludePrompts], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("exclude_prompts") + @ExcludeMissing + fun _excludePrompts(): JsonField<List<String>> = excludePrompts + + /** + * Returns the raw JSON value of [includePrompts]. + * + * Unlike [includePrompts], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("include_prompts") + @ExcludeMissing + fun _includePrompts(): JsonField<List<String>> = includePrompts + + /** + * Returns the raw JSON value of [triggers]. + * + * Unlike [triggers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("triggers") + @ExcludeMissing + fun _triggers(): JsonField<List<EPromptWebhookTrigger>> = triggers + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField<String> = url + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var excludePrompts: JsonField<MutableList<String>>? = null + private var headers: JsonValue = JsonMissing.of() + private var includePrompts: JsonField<MutableList<String>>? = null + private var triggers: JsonField<MutableList<EPromptWebhookTrigger>>? = null + private var url: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + excludePrompts = body.excludePrompts.map { it.toMutableList() } + headers = body.headers + includePrompts = body.includePrompts.map { it.toMutableList() } + triggers = body.triggers.map { it.toMutableList() } + url = body.url + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun excludePrompts(excludePrompts: List<String>?) = + excludePrompts(JsonField.ofNullable(excludePrompts)) + + /** Alias for calling [Builder.excludePrompts] with `excludePrompts.orElse(null)`. */ + fun excludePrompts(excludePrompts: Optional<List<String>>) = + excludePrompts(excludePrompts.getOrNull()) + + /** + * Sets [Builder.excludePrompts] to an arbitrary JSON value. + * + * You should usually call [Builder.excludePrompts] with a well-typed `List<String>` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun excludePrompts(excludePrompts: JsonField<List<String>>) = apply { + this.excludePrompts = excludePrompts.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [excludePrompts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExcludePrompt(excludePrompt: String) = apply { + excludePrompts = + (excludePrompts ?: JsonField.of(mutableListOf())).also { + checkKnown("excludePrompts", it).add(excludePrompt) + } + } + + fun headers(headers: JsonValue) = apply { this.headers = headers } + + fun includePrompts(includePrompts: List<String>?) = + includePrompts(JsonField.ofNullable(includePrompts)) + + /** Alias for calling [Builder.includePrompts] with `includePrompts.orElse(null)`. */ + fun includePrompts(includePrompts: Optional<List<String>>) = + includePrompts(includePrompts.getOrNull()) + + /** + * Sets [Builder.includePrompts] to an arbitrary JSON value. + * + * You should usually call [Builder.includePrompts] with a well-typed `List<String>` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun includePrompts(includePrompts: JsonField<List<String>>) = apply { + this.includePrompts = includePrompts.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [includePrompts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addIncludePrompt(includePrompt: String) = apply { + includePrompts = + (includePrompts ?: JsonField.of(mutableListOf())).also { + checkKnown("includePrompts", it).add(includePrompt) + } + } + + fun triggers(triggers: List<EPromptWebhookTrigger>?) = + triggers(JsonField.ofNullable(triggers)) + + /** Alias for calling [Builder.triggers] with `triggers.orElse(null)`. */ + fun triggers(triggers: Optional<List<EPromptWebhookTrigger>>) = + triggers(triggers.getOrNull()) + + /** + * Sets [Builder.triggers] to an arbitrary JSON value. + * + * You should usually call [Builder.triggers] with a well-typed + * `List<EPromptWebhookTrigger>` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun triggers(triggers: JsonField<List<EPromptWebhookTrigger>>) = apply { + this.triggers = triggers.map { it.toMutableList() } + } + + /** + * Adds a single [EPromptWebhookTrigger] to [triggers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTrigger(trigger: EPromptWebhookTrigger) = apply { + triggers = + (triggers ?: JsonField.of(mutableListOf())).also { + checkKnown("triggers", it).add(trigger) + } + } + + fun url(url: String?) = url(JsonField.ofNullable(url)) + + /** Alias for calling [Builder.url] with `url.orElse(null)`. */ + fun url(url: Optional<String>) = url(url.getOrNull()) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun url(url: JsonField<String>) = apply { this.url = url } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = + Body( + (excludePrompts ?: JsonMissing.of()).map { it.toImmutable() }, + headers, + (includePrompts ?: JsonMissing.of()).map { it.toImmutable() }, + (triggers ?: JsonMissing.of()).map { it.toImmutable() }, + url, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + excludePrompts() + includePrompts() + triggers().ifPresent { it.forEach { it.validate() } } + url() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (excludePrompts.asKnown().getOrNull()?.size ?: 0) + + (includePrompts.asKnown().getOrNull()?.size ?: 0) + + (triggers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (url.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + excludePrompts == other.excludePrompts && + headers == other.headers && + includePrompts == other.includePrompts && + triggers == other.triggers && + url == other.url && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + excludePrompts, + headers, + includePrompts, + triggers, + url, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{excludePrompts=$excludePrompts, headers=$headers, includePrompts=$includePrompts, triggers=$triggers, url=$url, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PromptWebhookUpdateParams && + webhookId == other.webhookId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(webhookId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "PromptWebhookUpdateParams{webhookId=$webhookId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/PublicRetrieveFeedbacksParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/PublicRetrieveFeedbacksParams.kt new file mode 100644 index 00000000..4407de8d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/PublicRetrieveFeedbacksParams.kt @@ -0,0 +1,424 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_ + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.models.api.v1.feedback.FeedbackLevel +import com.langsmith_api.api.models.api.v1.feedback.SourceType +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Read Shared Feedbacks */ +class PublicRetrieveFeedbacksParams +private constructor( + private val shareToken: String?, + private val hasComment: Boolean?, + private val hasScore: Boolean?, + private val key: List<String>?, + private val level: FeedbackLevel?, + private val limit: Long?, + private val offset: Long?, + private val run: List<String>?, + private val session: List<String>?, + private val source: List<SourceType>?, + private val user: List<String>?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun shareToken(): Optional<String> = Optional.ofNullable(shareToken) + + fun hasComment(): Optional<Boolean> = Optional.ofNullable(hasComment) + + fun hasScore(): Optional<Boolean> = Optional.ofNullable(hasScore) + + fun key(): Optional<List<String>> = Optional.ofNullable(key) + + /** Enum for feedback levels. */ + fun level(): Optional<FeedbackLevel> = Optional.ofNullable(level) + + fun limit(): Optional<Long> = Optional.ofNullable(limit) + + fun offset(): Optional<Long> = Optional.ofNullable(offset) + + fun run(): Optional<List<String>> = Optional.ofNullable(run) + + fun session(): Optional<List<String>> = Optional.ofNullable(session) + + fun source(): Optional<List<SourceType>> = Optional.ofNullable(source) + + fun user(): Optional<List<String>> = Optional.ofNullable(user) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): PublicRetrieveFeedbacksParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [PublicRetrieveFeedbacksParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PublicRetrieveFeedbacksParams]. */ + class Builder internal constructor() { + + private var shareToken: String? = null + private var hasComment: Boolean? = null + private var hasScore: Boolean? = null + private var key: MutableList<String>? = null + private var level: FeedbackLevel? = null + private var limit: Long? = null + private var offset: Long? = null + private var run: MutableList<String>? = null + private var session: MutableList<String>? = null + private var source: MutableList<SourceType>? = null + private var user: MutableList<String>? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(publicRetrieveFeedbacksParams: PublicRetrieveFeedbacksParams) = apply { + shareToken = publicRetrieveFeedbacksParams.shareToken + hasComment = publicRetrieveFeedbacksParams.hasComment + hasScore = publicRetrieveFeedbacksParams.hasScore + key = publicRetrieveFeedbacksParams.key?.toMutableList() + level = publicRetrieveFeedbacksParams.level + limit = publicRetrieveFeedbacksParams.limit + offset = publicRetrieveFeedbacksParams.offset + run = publicRetrieveFeedbacksParams.run?.toMutableList() + session = publicRetrieveFeedbacksParams.session?.toMutableList() + source = publicRetrieveFeedbacksParams.source?.toMutableList() + user = publicRetrieveFeedbacksParams.user?.toMutableList() + additionalHeaders = publicRetrieveFeedbacksParams.additionalHeaders.toBuilder() + additionalQueryParams = publicRetrieveFeedbacksParams.additionalQueryParams.toBuilder() + } + + fun shareToken(shareToken: String?) = apply { this.shareToken = shareToken } + + /** Alias for calling [Builder.shareToken] with `shareToken.orElse(null)`. */ + fun shareToken(shareToken: Optional<String>) = shareToken(shareToken.getOrNull()) + + fun hasComment(hasComment: Boolean?) = apply { this.hasComment = hasComment } + + /** + * Alias for [Builder.hasComment]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun hasComment(hasComment: Boolean) = hasComment(hasComment as Boolean?) + + /** Alias for calling [Builder.hasComment] with `hasComment.orElse(null)`. */ + fun hasComment(hasComment: Optional<Boolean>) = hasComment(hasComment.getOrNull()) + + fun hasScore(hasScore: Boolean?) = apply { this.hasScore = hasScore } + + /** + * Alias for [Builder.hasScore]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun hasScore(hasScore: Boolean) = hasScore(hasScore as Boolean?) + + /** Alias for calling [Builder.hasScore] with `hasScore.orElse(null)`. */ + fun hasScore(hasScore: Optional<Boolean>) = hasScore(hasScore.getOrNull()) + + fun key(key: List<String>?) = apply { this.key = key?.toMutableList() } + + /** Alias for calling [Builder.key] with `key.orElse(null)`. */ + fun key(key: Optional<List<String>>) = key(key.getOrNull()) + + /** + * Adds a single [String] to [Builder.key]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addKey(key: String) = apply { + this.key = (this.key ?: mutableListOf()).apply { add(key) } + } + + /** Enum for feedback levels. */ + fun level(level: FeedbackLevel?) = apply { this.level = level } + + /** Alias for calling [Builder.level] with `level.orElse(null)`. */ + fun level(level: Optional<FeedbackLevel>) = level(level.getOrNull()) + + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional<Long>) = limit(limit.getOrNull()) + + fun offset(offset: Long?) = apply { this.offset = offset } + + /** + * Alias for [Builder.offset]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun offset(offset: Long) = offset(offset as Long?) + + /** Alias for calling [Builder.offset] with `offset.orElse(null)`. */ + fun offset(offset: Optional<Long>) = offset(offset.getOrNull()) + + fun run(run: List<String>?) = apply { this.run = run?.toMutableList() } + + /** Alias for calling [Builder.run] with `run.orElse(null)`. */ + fun run(run: Optional<List<String>>) = run(run.getOrNull()) + + /** + * Adds a single [String] to [Builder.run]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRun(run: String) = apply { + this.run = (this.run ?: mutableListOf()).apply { add(run) } + } + + fun session(session: List<String>?) = apply { this.session = session?.toMutableList() } + + /** Alias for calling [Builder.session] with `session.orElse(null)`. */ + fun session(session: Optional<List<String>>) = session(session.getOrNull()) + + /** + * Adds a single [String] to [Builder.session]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSession(session: String) = apply { + this.session = (this.session ?: mutableListOf()).apply { add(session) } + } + + fun source(source: List<SourceType>?) = apply { this.source = source?.toMutableList() } + + /** Alias for calling [Builder.source] with `source.orElse(null)`. */ + fun source(source: Optional<List<SourceType>>) = source(source.getOrNull()) + + /** + * Adds a single [SourceType] to [Builder.source]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSource(source: SourceType) = apply { + this.source = (this.source ?: mutableListOf()).apply { add(source) } + } + + fun user(user: List<String>?) = apply { this.user = user?.toMutableList() } + + /** Alias for calling [Builder.user] with `user.orElse(null)`. */ + fun user(user: Optional<List<String>>) = user(user.getOrNull()) + + /** + * Adds a single [String] to [Builder.user]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addUser(user: String) = apply { + this.user = (this.user ?: mutableListOf()).apply { add(user) } + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [PublicRetrieveFeedbacksParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PublicRetrieveFeedbacksParams = + PublicRetrieveFeedbacksParams( + shareToken, + hasComment, + hasScore, + key?.toImmutable(), + level, + limit, + offset, + run?.toImmutable(), + session?.toImmutable(), + source?.toImmutable(), + user?.toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> shareToken ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + hasComment?.let { put("has_comment", it.toString()) } + hasScore?.let { put("has_score", it.toString()) } + key?.let { put("key", it.joinToString(",")) } + level?.let { put("level", it.toString()) } + limit?.let { put("limit", it.toString()) } + offset?.let { put("offset", it.toString()) } + run?.let { put("run", it.joinToString(",")) } + session?.let { put("session", it.joinToString(",")) } + source?.let { put("source", it.joinToString(",") { it.toString() }) } + user?.let { put("user", it.joinToString(",")) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PublicRetrieveFeedbacksParams && + shareToken == other.shareToken && + hasComment == other.hasComment && + hasScore == other.hasScore && + key == other.key && + level == other.level && + limit == other.limit && + offset == other.offset && + run == other.run && + session == other.session && + source == other.source && + user == other.user && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + shareToken, + hasComment, + hasScore, + key, + level, + limit, + offset, + run, + session, + source, + user, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "PublicRetrieveFeedbacksParams{shareToken=$shareToken, hasComment=$hasComment, hasScore=$hasScore, key=$key, level=$level, limit=$limit, offset=$offset, run=$run, session=$session, source=$source, user=$user, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetListParams.kt new file mode 100644 index 00000000..3ecb49fc --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetListParams.kt @@ -0,0 +1,283 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.datasets + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.models.api.v1.datasets.SortByDatasetColumn +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get dataset by ids or the shared dataset if not specifed. */ +class DatasetListParams +private constructor( + private val shareToken: String?, + private val limit: Long?, + private val offset: Long?, + private val sortBy: SortByDatasetColumn?, + private val sortByDesc: Boolean?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun shareToken(): Optional<String> = Optional.ofNullable(shareToken) + + fun limit(): Optional<Long> = Optional.ofNullable(limit) + + fun offset(): Optional<Long> = Optional.ofNullable(offset) + + /** Enum for available dataset columns to sort by. */ + fun sortBy(): Optional<SortByDatasetColumn> = Optional.ofNullable(sortBy) + + fun sortByDesc(): Optional<Boolean> = Optional.ofNullable(sortByDesc) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): DatasetListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [DatasetListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DatasetListParams]. */ + class Builder internal constructor() { + + private var shareToken: String? = null + private var limit: Long? = null + private var offset: Long? = null + private var sortBy: SortByDatasetColumn? = null + private var sortByDesc: Boolean? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(datasetListParams: DatasetListParams) = apply { + shareToken = datasetListParams.shareToken + limit = datasetListParams.limit + offset = datasetListParams.offset + sortBy = datasetListParams.sortBy + sortByDesc = datasetListParams.sortByDesc + additionalHeaders = datasetListParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetListParams.additionalQueryParams.toBuilder() + } + + fun shareToken(shareToken: String?) = apply { this.shareToken = shareToken } + + /** Alias for calling [Builder.shareToken] with `shareToken.orElse(null)`. */ + fun shareToken(shareToken: Optional<String>) = shareToken(shareToken.getOrNull()) + + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional<Long>) = limit(limit.getOrNull()) + + fun offset(offset: Long?) = apply { this.offset = offset } + + /** + * Alias for [Builder.offset]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun offset(offset: Long) = offset(offset as Long?) + + /** Alias for calling [Builder.offset] with `offset.orElse(null)`. */ + fun offset(offset: Optional<Long>) = offset(offset.getOrNull()) + + /** Enum for available dataset columns to sort by. */ + fun sortBy(sortBy: SortByDatasetColumn?) = apply { this.sortBy = sortBy } + + /** Alias for calling [Builder.sortBy] with `sortBy.orElse(null)`. */ + fun sortBy(sortBy: Optional<SortByDatasetColumn>) = sortBy(sortBy.getOrNull()) + + fun sortByDesc(sortByDesc: Boolean?) = apply { this.sortByDesc = sortByDesc } + + /** + * Alias for [Builder.sortByDesc]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun sortByDesc(sortByDesc: Boolean) = sortByDesc(sortByDesc as Boolean?) + + /** Alias for calling [Builder.sortByDesc] with `sortByDesc.orElse(null)`. */ + fun sortByDesc(sortByDesc: Optional<Boolean>) = sortByDesc(sortByDesc.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [DatasetListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DatasetListParams = + DatasetListParams( + shareToken, + limit, + offset, + sortBy, + sortByDesc, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> shareToken ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + limit?.let { put("limit", it.toString()) } + offset?.let { put("offset", it.toString()) } + sortBy?.let { put("sort_by", it.toString()) } + sortByDesc?.let { put("sort_by_desc", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetListParams && + shareToken == other.shareToken && + limit == other.limit && + offset == other.offset && + sortBy == other.sortBy && + sortByDesc == other.sortByDesc && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + shareToken, + limit, + offset, + sortBy, + sortByDesc, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "DatasetListParams{shareToken=$shareToken, limit=$limit, offset=$offset, sortBy=$sortBy, sortByDesc=$sortByDesc, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetListResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetListResponse.kt new file mode 100644 index 00000000..ae2fa34b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetListResponse.kt @@ -0,0 +1,533 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.datasets + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.datasets.DataType +import com.langsmith_api.api.models.api.v1.datasets.DatasetTransformation +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Public schema for datasets. + * + * Doesn't currently include session counts/stats since public test project sharing is not yet + * shipped + */ +class DatasetListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val exampleCount: JsonField<Long>, + private val name: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val dataType: JsonField<DataType>, + private val description: JsonField<String>, + private val externallyManaged: JsonField<Boolean>, + private val inputsSchemaDefinition: JsonValue, + private val outputsSchemaDefinition: JsonValue, + private val transformations: JsonField<List<DatasetTransformation>>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("example_count") + @ExcludeMissing + exampleCount: JsonField<Long> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("data_type") @ExcludeMissing dataType: JsonField<DataType> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("externally_managed") + @ExcludeMissing + externallyManaged: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("inputs_schema_definition") + @ExcludeMissing + inputsSchemaDefinition: JsonValue = JsonMissing.of(), + @JsonProperty("outputs_schema_definition") + @ExcludeMissing + outputsSchemaDefinition: JsonValue = JsonMissing.of(), + @JsonProperty("transformations") + @ExcludeMissing + transformations: JsonField<List<DatasetTransformation>> = JsonMissing.of(), + ) : this( + id, + exampleCount, + name, + createdAt, + dataType, + description, + externallyManaged, + inputsSchemaDefinition, + outputsSchemaDefinition, + transformations, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun exampleCount(): Long = exampleCount.getRequired("example_count") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun createdAt(): Optional<OffsetDateTime> = createdAt.getOptional("created_at") + + /** + * Enum for dataset data types. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dataType(): Optional<DataType> = dataType.getOptional("data_type") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externallyManaged(): Optional<Boolean> = externallyManaged.getOptional("externally_managed") + + @JsonProperty("inputs_schema_definition") + @ExcludeMissing + fun _inputsSchemaDefinition(): JsonValue = inputsSchemaDefinition + + @JsonProperty("outputs_schema_definition") + @ExcludeMissing + fun _outputsSchemaDefinition(): JsonValue = outputsSchemaDefinition + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun transformations(): Optional<List<DatasetTransformation>> = + transformations.getOptional("transformations") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [exampleCount]. + * + * Unlike [exampleCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("example_count") + @ExcludeMissing + fun _exampleCount(): JsonField<Long> = exampleCount + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [dataType]. + * + * Unlike [dataType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data_type") @ExcludeMissing fun _dataType(): JsonField<DataType> = dataType + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [externallyManaged]. + * + * Unlike [externallyManaged], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("externally_managed") + @ExcludeMissing + fun _externallyManaged(): JsonField<Boolean> = externallyManaged + + /** + * Returns the raw JSON value of [transformations]. + * + * Unlike [transformations], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("transformations") + @ExcludeMissing + fun _transformations(): JsonField<List<DatasetTransformation>> = transformations + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DatasetListResponse]. + * + * The following fields are required: + * ```java + * .id() + * .exampleCount() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DatasetListResponse]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var exampleCount: JsonField<Long>? = null + private var name: JsonField<String>? = null + private var createdAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var dataType: JsonField<DataType> = JsonMissing.of() + private var description: JsonField<String> = JsonMissing.of() + private var externallyManaged: JsonField<Boolean> = JsonMissing.of() + private var inputsSchemaDefinition: JsonValue = JsonMissing.of() + private var outputsSchemaDefinition: JsonValue = JsonMissing.of() + private var transformations: JsonField<MutableList<DatasetTransformation>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(datasetListResponse: DatasetListResponse) = apply { + id = datasetListResponse.id + exampleCount = datasetListResponse.exampleCount + name = datasetListResponse.name + createdAt = datasetListResponse.createdAt + dataType = datasetListResponse.dataType + description = datasetListResponse.description + externallyManaged = datasetListResponse.externallyManaged + inputsSchemaDefinition = datasetListResponse.inputsSchemaDefinition + outputsSchemaDefinition = datasetListResponse.outputsSchemaDefinition + transformations = datasetListResponse.transformations.map { it.toMutableList() } + additionalProperties = datasetListResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun exampleCount(exampleCount: Long) = exampleCount(JsonField.of(exampleCount)) + + /** + * Sets [Builder.exampleCount] to an arbitrary JSON value. + * + * You should usually call [Builder.exampleCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun exampleCount(exampleCount: JsonField<Long>) = apply { this.exampleCount = exampleCount } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + /** Enum for dataset data types. */ + fun dataType(dataType: DataType?) = dataType(JsonField.ofNullable(dataType)) + + /** Alias for calling [Builder.dataType] with `dataType.orElse(null)`. */ + fun dataType(dataType: Optional<DataType>) = dataType(dataType.getOrNull()) + + /** + * Sets [Builder.dataType] to an arbitrary JSON value. + * + * You should usually call [Builder.dataType] with a well-typed [DataType] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dataType(dataType: JsonField<DataType>) = apply { this.dataType = dataType } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { this.description = description } + + fun externallyManaged(externallyManaged: Boolean?) = + externallyManaged(JsonField.ofNullable(externallyManaged)) + + /** + * Alias for [Builder.externallyManaged]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun externallyManaged(externallyManaged: Boolean) = + externallyManaged(externallyManaged as Boolean?) + + /** Alias for calling [Builder.externallyManaged] with `externallyManaged.orElse(null)`. */ + fun externallyManaged(externallyManaged: Optional<Boolean>) = + externallyManaged(externallyManaged.getOrNull()) + + /** + * Sets [Builder.externallyManaged] to an arbitrary JSON value. + * + * You should usually call [Builder.externallyManaged] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externallyManaged(externallyManaged: JsonField<Boolean>) = apply { + this.externallyManaged = externallyManaged + } + + fun inputsSchemaDefinition(inputsSchemaDefinition: JsonValue) = apply { + this.inputsSchemaDefinition = inputsSchemaDefinition + } + + fun outputsSchemaDefinition(outputsSchemaDefinition: JsonValue) = apply { + this.outputsSchemaDefinition = outputsSchemaDefinition + } + + fun transformations(transformations: List<DatasetTransformation>?) = + transformations(JsonField.ofNullable(transformations)) + + /** Alias for calling [Builder.transformations] with `transformations.orElse(null)`. */ + fun transformations(transformations: Optional<List<DatasetTransformation>>) = + transformations(transformations.getOrNull()) + + /** + * Sets [Builder.transformations] to an arbitrary JSON value. + * + * You should usually call [Builder.transformations] with a well-typed + * `List<DatasetTransformation>` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun transformations(transformations: JsonField<List<DatasetTransformation>>) = apply { + this.transformations = transformations.map { it.toMutableList() } + } + + /** + * Adds a single [DatasetTransformation] to [transformations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTransformation(transformation: DatasetTransformation) = apply { + transformations = + (transformations ?: JsonField.of(mutableListOf())).also { + checkKnown("transformations", it).add(transformation) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DatasetListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .exampleCount() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DatasetListResponse = + DatasetListResponse( + checkRequired("id", id), + checkRequired("exampleCount", exampleCount), + checkRequired("name", name), + createdAt, + dataType, + description, + externallyManaged, + inputsSchemaDefinition, + outputsSchemaDefinition, + (transformations ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DatasetListResponse = apply { + if (validated) { + return@apply + } + + id() + exampleCount() + name() + createdAt() + dataType().ifPresent { it.validate() } + description() + externallyManaged() + transformations().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (exampleCount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (dataType.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (externallyManaged.asKnown().isPresent) 1 else 0) + + (transformations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetListResponse && + id == other.id && + exampleCount == other.exampleCount && + name == other.name && + createdAt == other.createdAt && + dataType == other.dataType && + description == other.description && + externallyManaged == other.externallyManaged && + inputsSchemaDefinition == other.inputsSchemaDefinition && + outputsSchemaDefinition == other.outputsSchemaDefinition && + transformations == other.transformations && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + exampleCount, + name, + createdAt, + dataType, + description, + externallyManaged, + inputsSchemaDefinition, + outputsSchemaDefinition, + transformations, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DatasetListResponse{id=$id, exampleCount=$exampleCount, name=$name, createdAt=$createdAt, dataType=$dataType, description=$description, externallyManaged=$externallyManaged, inputsSchemaDefinition=$inputsSchemaDefinition, outputsSchemaDefinition=$outputsSchemaDefinition, transformations=$transformations, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveComparativeParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveComparativeParams.kt new file mode 100644 index 00000000..e73bd81e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveComparativeParams.kt @@ -0,0 +1,316 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.datasets + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.models.api.v1.datasets.comparative.SortByComparativeExperimentColumn +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get all comparative experiments for a given dataset. */ +class DatasetRetrieveComparativeParams +private constructor( + private val shareToken: String?, + private val limit: Long?, + private val name: String?, + private val nameContains: String?, + private val offset: Long?, + private val sortBy: SortByComparativeExperimentColumn?, + private val sortByDesc: Boolean?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun shareToken(): Optional<String> = Optional.ofNullable(shareToken) + + fun limit(): Optional<Long> = Optional.ofNullable(limit) + + fun name(): Optional<String> = Optional.ofNullable(name) + + fun nameContains(): Optional<String> = Optional.ofNullable(nameContains) + + fun offset(): Optional<Long> = Optional.ofNullable(offset) + + /** Enum for available comparative experiment columns to sort by. */ + fun sortBy(): Optional<SortByComparativeExperimentColumn> = Optional.ofNullable(sortBy) + + fun sortByDesc(): Optional<Boolean> = Optional.ofNullable(sortByDesc) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): DatasetRetrieveComparativeParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [DatasetRetrieveComparativeParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DatasetRetrieveComparativeParams]. */ + class Builder internal constructor() { + + private var shareToken: String? = null + private var limit: Long? = null + private var name: String? = null + private var nameContains: String? = null + private var offset: Long? = null + private var sortBy: SortByComparativeExperimentColumn? = null + private var sortByDesc: Boolean? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(datasetRetrieveComparativeParams: DatasetRetrieveComparativeParams) = + apply { + shareToken = datasetRetrieveComparativeParams.shareToken + limit = datasetRetrieveComparativeParams.limit + name = datasetRetrieveComparativeParams.name + nameContains = datasetRetrieveComparativeParams.nameContains + offset = datasetRetrieveComparativeParams.offset + sortBy = datasetRetrieveComparativeParams.sortBy + sortByDesc = datasetRetrieveComparativeParams.sortByDesc + additionalHeaders = datasetRetrieveComparativeParams.additionalHeaders.toBuilder() + additionalQueryParams = + datasetRetrieveComparativeParams.additionalQueryParams.toBuilder() + } + + fun shareToken(shareToken: String?) = apply { this.shareToken = shareToken } + + /** Alias for calling [Builder.shareToken] with `shareToken.orElse(null)`. */ + fun shareToken(shareToken: Optional<String>) = shareToken(shareToken.getOrNull()) + + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional<Long>) = limit(limit.getOrNull()) + + fun name(name: String?) = apply { this.name = name } + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional<String>) = name(name.getOrNull()) + + fun nameContains(nameContains: String?) = apply { this.nameContains = nameContains } + + /** Alias for calling [Builder.nameContains] with `nameContains.orElse(null)`. */ + fun nameContains(nameContains: Optional<String>) = nameContains(nameContains.getOrNull()) + + fun offset(offset: Long?) = apply { this.offset = offset } + + /** + * Alias for [Builder.offset]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun offset(offset: Long) = offset(offset as Long?) + + /** Alias for calling [Builder.offset] with `offset.orElse(null)`. */ + fun offset(offset: Optional<Long>) = offset(offset.getOrNull()) + + /** Enum for available comparative experiment columns to sort by. */ + fun sortBy(sortBy: SortByComparativeExperimentColumn?) = apply { this.sortBy = sortBy } + + /** Alias for calling [Builder.sortBy] with `sortBy.orElse(null)`. */ + fun sortBy(sortBy: Optional<SortByComparativeExperimentColumn>) = sortBy(sortBy.getOrNull()) + + fun sortByDesc(sortByDesc: Boolean?) = apply { this.sortByDesc = sortByDesc } + + /** + * Alias for [Builder.sortByDesc]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun sortByDesc(sortByDesc: Boolean) = sortByDesc(sortByDesc as Boolean?) + + /** Alias for calling [Builder.sortByDesc] with `sortByDesc.orElse(null)`. */ + fun sortByDesc(sortByDesc: Optional<Boolean>) = sortByDesc(sortByDesc.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [DatasetRetrieveComparativeParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DatasetRetrieveComparativeParams = + DatasetRetrieveComparativeParams( + shareToken, + limit, + name, + nameContains, + offset, + sortBy, + sortByDesc, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> shareToken ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + limit?.let { put("limit", it.toString()) } + name?.let { put("name", it) } + nameContains?.let { put("name_contains", it) } + offset?.let { put("offset", it.toString()) } + sortBy?.let { put("sort_by", it.toString()) } + sortByDesc?.let { put("sort_by_desc", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetRetrieveComparativeParams && + shareToken == other.shareToken && + limit == other.limit && + name == other.name && + nameContains == other.nameContains && + offset == other.offset && + sortBy == other.sortBy && + sortByDesc == other.sortByDesc && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + shareToken, + limit, + name, + nameContains, + offset, + sortBy, + sortByDesc, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "DatasetRetrieveComparativeParams{shareToken=$shareToken, limit=$limit, name=$name, nameContains=$nameContains, offset=$offset, sortBy=$sortBy, sortByDesc=$sortByDesc, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveComparativeResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveComparativeResponse.kt new file mode 100644 index 00000000..74fcfc6d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveComparativeResponse.kt @@ -0,0 +1,428 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.datasets + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.datasets.comparative.SimpleExperimentInfo +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Publicly-shared ComparativeExperiment schema. */ +class DatasetRetrieveComparativeResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val experimentsInfo: JsonField<List<SimpleExperimentInfo>>, + private val modifiedAt: JsonField<OffsetDateTime>, + private val description: JsonField<String>, + private val extra: JsonValue, + private val feedbackStats: JsonValue, + private val name: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("experiments_info") + @ExcludeMissing + experimentsInfo: JsonField<List<SimpleExperimentInfo>> = JsonMissing.of(), + @JsonProperty("modified_at") + @ExcludeMissing + modifiedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("extra") @ExcludeMissing extra: JsonValue = JsonMissing.of(), + @JsonProperty("feedback_stats") @ExcludeMissing feedbackStats: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + ) : this( + id, + createdAt, + experimentsInfo, + modifiedAt, + description, + extra, + feedbackStats, + name, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun experimentsInfo(): List<SimpleExperimentInfo> = + experimentsInfo.getRequired("experiments_info") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun modifiedAt(): OffsetDateTime = modifiedAt.getRequired("modified_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonValue = extra + + @JsonProperty("feedback_stats") @ExcludeMissing fun _feedbackStats(): JsonValue = feedbackStats + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional<String> = name.getOptional("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [experimentsInfo]. + * + * Unlike [experimentsInfo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("experiments_info") + @ExcludeMissing + fun _experimentsInfo(): JsonField<List<SimpleExperimentInfo>> = experimentsInfo + + /** + * Returns the raw JSON value of [modifiedAt]. + * + * Unlike [modifiedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("modified_at") + @ExcludeMissing + fun _modifiedAt(): JsonField<OffsetDateTime> = modifiedAt + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [DatasetRetrieveComparativeResponse]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .experimentsInfo() + * .modifiedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DatasetRetrieveComparativeResponse]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var createdAt: JsonField<OffsetDateTime>? = null + private var experimentsInfo: JsonField<MutableList<SimpleExperimentInfo>>? = null + private var modifiedAt: JsonField<OffsetDateTime>? = null + private var description: JsonField<String> = JsonMissing.of() + private var extra: JsonValue = JsonMissing.of() + private var feedbackStats: JsonValue = JsonMissing.of() + private var name: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(datasetRetrieveComparativeResponse: DatasetRetrieveComparativeResponse) = + apply { + id = datasetRetrieveComparativeResponse.id + createdAt = datasetRetrieveComparativeResponse.createdAt + experimentsInfo = + datasetRetrieveComparativeResponse.experimentsInfo.map { it.toMutableList() } + modifiedAt = datasetRetrieveComparativeResponse.modifiedAt + description = datasetRetrieveComparativeResponse.description + extra = datasetRetrieveComparativeResponse.extra + feedbackStats = datasetRetrieveComparativeResponse.feedbackStats + name = datasetRetrieveComparativeResponse.name + additionalProperties = + datasetRetrieveComparativeResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun experimentsInfo(experimentsInfo: List<SimpleExperimentInfo>) = + experimentsInfo(JsonField.of(experimentsInfo)) + + /** + * Sets [Builder.experimentsInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.experimentsInfo] with a well-typed + * `List<SimpleExperimentInfo>` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun experimentsInfo(experimentsInfo: JsonField<List<SimpleExperimentInfo>>) = apply { + this.experimentsInfo = experimentsInfo.map { it.toMutableList() } + } + + /** + * Adds a single [SimpleExperimentInfo] to [Builder.experimentsInfo]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExperimentsInfo(experimentsInfo: SimpleExperimentInfo) = apply { + this.experimentsInfo = + (this.experimentsInfo ?: JsonField.of(mutableListOf())).also { + checkKnown("experimentsInfo", it).add(experimentsInfo) + } + } + + fun modifiedAt(modifiedAt: OffsetDateTime) = modifiedAt(JsonField.of(modifiedAt)) + + /** + * Sets [Builder.modifiedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.modifiedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modifiedAt(modifiedAt: JsonField<OffsetDateTime>) = apply { + this.modifiedAt = modifiedAt + } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { this.description = description } + + fun extra(extra: JsonValue) = apply { this.extra = extra } + + fun feedbackStats(feedbackStats: JsonValue) = apply { this.feedbackStats = feedbackStats } + + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional<String>) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DatasetRetrieveComparativeResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .experimentsInfo() + * .modifiedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DatasetRetrieveComparativeResponse = + DatasetRetrieveComparativeResponse( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("experimentsInfo", experimentsInfo).map { it.toImmutable() }, + checkRequired("modifiedAt", modifiedAt), + description, + extra, + feedbackStats, + name, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DatasetRetrieveComparativeResponse = apply { + if (validated) { + return@apply + } + + id() + createdAt() + experimentsInfo().forEach { it.validate() } + modifiedAt() + description() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (experimentsInfo.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (modifiedAt.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetRetrieveComparativeResponse && + id == other.id && + createdAt == other.createdAt && + experimentsInfo == other.experimentsInfo && + modifiedAt == other.modifiedAt && + description == other.description && + extra == other.extra && + feedbackStats == other.feedbackStats && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + createdAt, + experimentsInfo, + modifiedAt, + description, + extra, + feedbackStats, + name, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DatasetRetrieveComparativeResponse{id=$id, createdAt=$createdAt, experimentsInfo=$experimentsInfo, modifiedAt=$modifiedAt, description=$description, extra=$extra, feedbackStats=$feedbackStats, name=$name, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveFeedbackParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveFeedbackParams.kt new file mode 100644 index 00000000..8692c6a5 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveFeedbackParams.kt @@ -0,0 +1,424 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.datasets + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.models.api.v1.feedback.FeedbackLevel +import com.langsmith_api.api.models.api.v1.feedback.SourceType +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get feedback for runs in projects run over a dataset that has been shared. */ +class DatasetRetrieveFeedbackParams +private constructor( + private val shareToken: String?, + private val hasComment: Boolean?, + private val hasScore: Boolean?, + private val key: List<String>?, + private val level: FeedbackLevel?, + private val limit: Long?, + private val offset: Long?, + private val run: List<String>?, + private val session: List<String>?, + private val source: List<SourceType>?, + private val user: List<String>?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun shareToken(): Optional<String> = Optional.ofNullable(shareToken) + + fun hasComment(): Optional<Boolean> = Optional.ofNullable(hasComment) + + fun hasScore(): Optional<Boolean> = Optional.ofNullable(hasScore) + + fun key(): Optional<List<String>> = Optional.ofNullable(key) + + /** Enum for feedback levels. */ + fun level(): Optional<FeedbackLevel> = Optional.ofNullable(level) + + fun limit(): Optional<Long> = Optional.ofNullable(limit) + + fun offset(): Optional<Long> = Optional.ofNullable(offset) + + fun run(): Optional<List<String>> = Optional.ofNullable(run) + + fun session(): Optional<List<String>> = Optional.ofNullable(session) + + fun source(): Optional<List<SourceType>> = Optional.ofNullable(source) + + fun user(): Optional<List<String>> = Optional.ofNullable(user) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): DatasetRetrieveFeedbackParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [DatasetRetrieveFeedbackParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DatasetRetrieveFeedbackParams]. */ + class Builder internal constructor() { + + private var shareToken: String? = null + private var hasComment: Boolean? = null + private var hasScore: Boolean? = null + private var key: MutableList<String>? = null + private var level: FeedbackLevel? = null + private var limit: Long? = null + private var offset: Long? = null + private var run: MutableList<String>? = null + private var session: MutableList<String>? = null + private var source: MutableList<SourceType>? = null + private var user: MutableList<String>? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(datasetRetrieveFeedbackParams: DatasetRetrieveFeedbackParams) = apply { + shareToken = datasetRetrieveFeedbackParams.shareToken + hasComment = datasetRetrieveFeedbackParams.hasComment + hasScore = datasetRetrieveFeedbackParams.hasScore + key = datasetRetrieveFeedbackParams.key?.toMutableList() + level = datasetRetrieveFeedbackParams.level + limit = datasetRetrieveFeedbackParams.limit + offset = datasetRetrieveFeedbackParams.offset + run = datasetRetrieveFeedbackParams.run?.toMutableList() + session = datasetRetrieveFeedbackParams.session?.toMutableList() + source = datasetRetrieveFeedbackParams.source?.toMutableList() + user = datasetRetrieveFeedbackParams.user?.toMutableList() + additionalHeaders = datasetRetrieveFeedbackParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetRetrieveFeedbackParams.additionalQueryParams.toBuilder() + } + + fun shareToken(shareToken: String?) = apply { this.shareToken = shareToken } + + /** Alias for calling [Builder.shareToken] with `shareToken.orElse(null)`. */ + fun shareToken(shareToken: Optional<String>) = shareToken(shareToken.getOrNull()) + + fun hasComment(hasComment: Boolean?) = apply { this.hasComment = hasComment } + + /** + * Alias for [Builder.hasComment]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun hasComment(hasComment: Boolean) = hasComment(hasComment as Boolean?) + + /** Alias for calling [Builder.hasComment] with `hasComment.orElse(null)`. */ + fun hasComment(hasComment: Optional<Boolean>) = hasComment(hasComment.getOrNull()) + + fun hasScore(hasScore: Boolean?) = apply { this.hasScore = hasScore } + + /** + * Alias for [Builder.hasScore]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun hasScore(hasScore: Boolean) = hasScore(hasScore as Boolean?) + + /** Alias for calling [Builder.hasScore] with `hasScore.orElse(null)`. */ + fun hasScore(hasScore: Optional<Boolean>) = hasScore(hasScore.getOrNull()) + + fun key(key: List<String>?) = apply { this.key = key?.toMutableList() } + + /** Alias for calling [Builder.key] with `key.orElse(null)`. */ + fun key(key: Optional<List<String>>) = key(key.getOrNull()) + + /** + * Adds a single [String] to [Builder.key]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addKey(key: String) = apply { + this.key = (this.key ?: mutableListOf()).apply { add(key) } + } + + /** Enum for feedback levels. */ + fun level(level: FeedbackLevel?) = apply { this.level = level } + + /** Alias for calling [Builder.level] with `level.orElse(null)`. */ + fun level(level: Optional<FeedbackLevel>) = level(level.getOrNull()) + + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional<Long>) = limit(limit.getOrNull()) + + fun offset(offset: Long?) = apply { this.offset = offset } + + /** + * Alias for [Builder.offset]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun offset(offset: Long) = offset(offset as Long?) + + /** Alias for calling [Builder.offset] with `offset.orElse(null)`. */ + fun offset(offset: Optional<Long>) = offset(offset.getOrNull()) + + fun run(run: List<String>?) = apply { this.run = run?.toMutableList() } + + /** Alias for calling [Builder.run] with `run.orElse(null)`. */ + fun run(run: Optional<List<String>>) = run(run.getOrNull()) + + /** + * Adds a single [String] to [Builder.run]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRun(run: String) = apply { + this.run = (this.run ?: mutableListOf()).apply { add(run) } + } + + fun session(session: List<String>?) = apply { this.session = session?.toMutableList() } + + /** Alias for calling [Builder.session] with `session.orElse(null)`. */ + fun session(session: Optional<List<String>>) = session(session.getOrNull()) + + /** + * Adds a single [String] to [Builder.session]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSession(session: String) = apply { + this.session = (this.session ?: mutableListOf()).apply { add(session) } + } + + fun source(source: List<SourceType>?) = apply { this.source = source?.toMutableList() } + + /** Alias for calling [Builder.source] with `source.orElse(null)`. */ + fun source(source: Optional<List<SourceType>>) = source(source.getOrNull()) + + /** + * Adds a single [SourceType] to [Builder.source]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSource(source: SourceType) = apply { + this.source = (this.source ?: mutableListOf()).apply { add(source) } + } + + fun user(user: List<String>?) = apply { this.user = user?.toMutableList() } + + /** Alias for calling [Builder.user] with `user.orElse(null)`. */ + fun user(user: Optional<List<String>>) = user(user.getOrNull()) + + /** + * Adds a single [String] to [Builder.user]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addUser(user: String) = apply { + this.user = (this.user ?: mutableListOf()).apply { add(user) } + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [DatasetRetrieveFeedbackParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DatasetRetrieveFeedbackParams = + DatasetRetrieveFeedbackParams( + shareToken, + hasComment, + hasScore, + key?.toImmutable(), + level, + limit, + offset, + run?.toImmutable(), + session?.toImmutable(), + source?.toImmutable(), + user?.toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> shareToken ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + hasComment?.let { put("has_comment", it.toString()) } + hasScore?.let { put("has_score", it.toString()) } + key?.let { put("key", it.joinToString(",")) } + level?.let { put("level", it.toString()) } + limit?.let { put("limit", it.toString()) } + offset?.let { put("offset", it.toString()) } + run?.let { put("run", it.joinToString(",")) } + session?.let { put("session", it.joinToString(",")) } + source?.let { put("source", it.joinToString(",") { it.toString() }) } + user?.let { put("user", it.joinToString(",")) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetRetrieveFeedbackParams && + shareToken == other.shareToken && + hasComment == other.hasComment && + hasScore == other.hasScore && + key == other.key && + level == other.level && + limit == other.limit && + offset == other.offset && + run == other.run && + session == other.session && + source == other.source && + user == other.user && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + shareToken, + hasComment, + hasScore, + key, + level, + limit, + offset, + run, + session, + source, + user, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "DatasetRetrieveFeedbackParams{shareToken=$shareToken, hasComment=$hasComment, hasScore=$hasScore, key=$key, level=$level, limit=$limit, offset=$offset, run=$run, session=$session, source=$source, user=$user, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveSessionsBulkParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveSessionsBulkParams.kt new file mode 100644 index 00000000..26532950 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveSessionsBulkParams.kt @@ -0,0 +1,217 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.datasets + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects + +/** Get sessions from multiple datasets using share tokens. */ +class DatasetRetrieveSessionsBulkParams +private constructor( + private val shareTokens: List<String>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun shareTokens(): List<String> = shareTokens + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [DatasetRetrieveSessionsBulkParams]. + * + * The following fields are required: + * ```java + * .shareTokens() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DatasetRetrieveSessionsBulkParams]. */ + class Builder internal constructor() { + + private var shareTokens: MutableList<String>? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(datasetRetrieveSessionsBulkParams: DatasetRetrieveSessionsBulkParams) = + apply { + shareTokens = datasetRetrieveSessionsBulkParams.shareTokens.toMutableList() + additionalHeaders = datasetRetrieveSessionsBulkParams.additionalHeaders.toBuilder() + additionalQueryParams = + datasetRetrieveSessionsBulkParams.additionalQueryParams.toBuilder() + } + + fun shareTokens(shareTokens: List<String>) = apply { + this.shareTokens = shareTokens.toMutableList() + } + + /** + * Adds a single [String] to [shareTokens]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addShareToken(shareToken: String) = apply { + shareTokens = (shareTokens ?: mutableListOf()).apply { add(shareToken) } + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [DatasetRetrieveSessionsBulkParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .shareTokens() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DatasetRetrieveSessionsBulkParams = + DatasetRetrieveSessionsBulkParams( + checkRequired("shareTokens", shareTokens).toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("share_tokens", shareTokens.joinToString(",")) + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetRetrieveSessionsBulkParams && + shareTokens == other.shareTokens && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(shareTokens, additionalHeaders, additionalQueryParams) + + override fun toString() = + "DatasetRetrieveSessionsBulkParams{shareTokens=$shareTokens, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveSessionsParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveSessionsParams.kt new file mode 100644 index 00000000..c2cd4bd4 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveSessionsParams.kt @@ -0,0 +1,406 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.datasets + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.models.api.v1.sessions.SessionSortableColumns +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get projects run on a dataset that has been shared. */ +class DatasetRetrieveSessionsParams +private constructor( + private val shareToken: String?, + private val id: List<String>?, + private val datasetVersion: String?, + private val facets: Boolean?, + private val limit: Long?, + private val name: String?, + private val nameContains: String?, + private val offset: Long?, + private val sortBy: SessionSortableColumns?, + private val sortByDesc: Boolean?, + private val sortByFeedbackKey: String?, + private val accept: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun shareToken(): Optional<String> = Optional.ofNullable(shareToken) + + fun id(): Optional<List<String>> = Optional.ofNullable(id) + + fun datasetVersion(): Optional<String> = Optional.ofNullable(datasetVersion) + + fun facets(): Optional<Boolean> = Optional.ofNullable(facets) + + fun limit(): Optional<Long> = Optional.ofNullable(limit) + + fun name(): Optional<String> = Optional.ofNullable(name) + + fun nameContains(): Optional<String> = Optional.ofNullable(nameContains) + + fun offset(): Optional<Long> = Optional.ofNullable(offset) + + fun sortBy(): Optional<SessionSortableColumns> = Optional.ofNullable(sortBy) + + fun sortByDesc(): Optional<Boolean> = Optional.ofNullable(sortByDesc) + + fun sortByFeedbackKey(): Optional<String> = Optional.ofNullable(sortByFeedbackKey) + + fun accept(): Optional<String> = Optional.ofNullable(accept) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): DatasetRetrieveSessionsParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [DatasetRetrieveSessionsParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DatasetRetrieveSessionsParams]. */ + class Builder internal constructor() { + + private var shareToken: String? = null + private var id: MutableList<String>? = null + private var datasetVersion: String? = null + private var facets: Boolean? = null + private var limit: Long? = null + private var name: String? = null + private var nameContains: String? = null + private var offset: Long? = null + private var sortBy: SessionSortableColumns? = null + private var sortByDesc: Boolean? = null + private var sortByFeedbackKey: String? = null + private var accept: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(datasetRetrieveSessionsParams: DatasetRetrieveSessionsParams) = apply { + shareToken = datasetRetrieveSessionsParams.shareToken + id = datasetRetrieveSessionsParams.id?.toMutableList() + datasetVersion = datasetRetrieveSessionsParams.datasetVersion + facets = datasetRetrieveSessionsParams.facets + limit = datasetRetrieveSessionsParams.limit + name = datasetRetrieveSessionsParams.name + nameContains = datasetRetrieveSessionsParams.nameContains + offset = datasetRetrieveSessionsParams.offset + sortBy = datasetRetrieveSessionsParams.sortBy + sortByDesc = datasetRetrieveSessionsParams.sortByDesc + sortByFeedbackKey = datasetRetrieveSessionsParams.sortByFeedbackKey + accept = datasetRetrieveSessionsParams.accept + additionalHeaders = datasetRetrieveSessionsParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetRetrieveSessionsParams.additionalQueryParams.toBuilder() + } + + fun shareToken(shareToken: String?) = apply { this.shareToken = shareToken } + + /** Alias for calling [Builder.shareToken] with `shareToken.orElse(null)`. */ + fun shareToken(shareToken: Optional<String>) = shareToken(shareToken.getOrNull()) + + fun id(id: List<String>?) = apply { this.id = id?.toMutableList() } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<List<String>>) = id(id.getOrNull()) + + /** + * Adds a single [String] to [Builder.id]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addId(id: String) = apply { this.id = (this.id ?: mutableListOf()).apply { add(id) } } + + fun datasetVersion(datasetVersion: String?) = apply { this.datasetVersion = datasetVersion } + + /** Alias for calling [Builder.datasetVersion] with `datasetVersion.orElse(null)`. */ + fun datasetVersion(datasetVersion: Optional<String>) = + datasetVersion(datasetVersion.getOrNull()) + + fun facets(facets: Boolean?) = apply { this.facets = facets } + + /** + * Alias for [Builder.facets]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun facets(facets: Boolean) = facets(facets as Boolean?) + + /** Alias for calling [Builder.facets] with `facets.orElse(null)`. */ + fun facets(facets: Optional<Boolean>) = facets(facets.getOrNull()) + + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional<Long>) = limit(limit.getOrNull()) + + fun name(name: String?) = apply { this.name = name } + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional<String>) = name(name.getOrNull()) + + fun nameContains(nameContains: String?) = apply { this.nameContains = nameContains } + + /** Alias for calling [Builder.nameContains] with `nameContains.orElse(null)`. */ + fun nameContains(nameContains: Optional<String>) = nameContains(nameContains.getOrNull()) + + fun offset(offset: Long?) = apply { this.offset = offset } + + /** + * Alias for [Builder.offset]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun offset(offset: Long) = offset(offset as Long?) + + /** Alias for calling [Builder.offset] with `offset.orElse(null)`. */ + fun offset(offset: Optional<Long>) = offset(offset.getOrNull()) + + fun sortBy(sortBy: SessionSortableColumns?) = apply { this.sortBy = sortBy } + + /** Alias for calling [Builder.sortBy] with `sortBy.orElse(null)`. */ + fun sortBy(sortBy: Optional<SessionSortableColumns>) = sortBy(sortBy.getOrNull()) + + fun sortByDesc(sortByDesc: Boolean?) = apply { this.sortByDesc = sortByDesc } + + /** + * Alias for [Builder.sortByDesc]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun sortByDesc(sortByDesc: Boolean) = sortByDesc(sortByDesc as Boolean?) + + /** Alias for calling [Builder.sortByDesc] with `sortByDesc.orElse(null)`. */ + fun sortByDesc(sortByDesc: Optional<Boolean>) = sortByDesc(sortByDesc.getOrNull()) + + fun sortByFeedbackKey(sortByFeedbackKey: String?) = apply { + this.sortByFeedbackKey = sortByFeedbackKey + } + + /** Alias for calling [Builder.sortByFeedbackKey] with `sortByFeedbackKey.orElse(null)`. */ + fun sortByFeedbackKey(sortByFeedbackKey: Optional<String>) = + sortByFeedbackKey(sortByFeedbackKey.getOrNull()) + + fun accept(accept: String?) = apply { this.accept = accept } + + /** Alias for calling [Builder.accept] with `accept.orElse(null)`. */ + fun accept(accept: Optional<String>) = accept(accept.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [DatasetRetrieveSessionsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DatasetRetrieveSessionsParams = + DatasetRetrieveSessionsParams( + shareToken, + id?.toImmutable(), + datasetVersion, + facets, + limit, + name, + nameContains, + offset, + sortBy, + sortByDesc, + sortByFeedbackKey, + accept, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> shareToken ?: "" + else -> "" + } + + override fun _headers(): Headers = + Headers.builder() + .apply { + accept?.let { put("accept", it) } + putAll(additionalHeaders) + } + .build() + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + id?.let { put("id", it.joinToString(",")) } + datasetVersion?.let { put("dataset_version", it) } + facets?.let { put("facets", it.toString()) } + limit?.let { put("limit", it.toString()) } + name?.let { put("name", it) } + nameContains?.let { put("name_contains", it) } + offset?.let { put("offset", it.toString()) } + sortBy?.let { put("sort_by", it.toString()) } + sortByDesc?.let { put("sort_by_desc", it.toString()) } + sortByFeedbackKey?.let { put("sort_by_feedback_key", it) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DatasetRetrieveSessionsParams && + shareToken == other.shareToken && + id == other.id && + datasetVersion == other.datasetVersion && + facets == other.facets && + limit == other.limit && + name == other.name && + nameContains == other.nameContains && + offset == other.offset && + sortBy == other.sortBy && + sortByDesc == other.sortByDesc && + sortByFeedbackKey == other.sortByFeedbackKey && + accept == other.accept && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + shareToken, + id, + datasetVersion, + facets, + limit, + name, + nameContains, + offset, + sortBy, + sortByDesc, + sortByFeedbackKey, + accept, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "DatasetRetrieveSessionsParams{shareToken=$shareToken, id=$id, datasetVersion=$datasetVersion, facets=$facets, limit=$limit, name=$name, nameContains=$nameContains, offset=$offset, sortBy=$sortBy, sortByDesc=$sortByDesc, sortByFeedbackKey=$sortByFeedbackKey, accept=$accept, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunDeltaParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunDeltaParams.kt new file mode 100644 index 00000000..0e607f45 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunDeltaParams.kt @@ -0,0 +1,228 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.datasets.runs + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.models.api.v1.datasets.runs.QueryFeedbackDelta +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Fetch the number of regressions/improvements for each example in a dataset, between sessions[0] + * and sessions[1]. + */ +class RunDeltaParams +private constructor( + private val shareToken: String?, + private val queryFeedbackDelta: QueryFeedbackDelta, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun shareToken(): Optional<String> = Optional.ofNullable(shareToken) + + fun queryFeedbackDelta(): QueryFeedbackDelta = queryFeedbackDelta + + fun _additionalBodyProperties(): Map<String, JsonValue> = + queryFeedbackDelta._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RunDeltaParams]. + * + * The following fields are required: + * ```java + * .queryFeedbackDelta() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunDeltaParams]. */ + class Builder internal constructor() { + + private var shareToken: String? = null + private var queryFeedbackDelta: QueryFeedbackDelta? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(runDeltaParams: RunDeltaParams) = apply { + shareToken = runDeltaParams.shareToken + queryFeedbackDelta = runDeltaParams.queryFeedbackDelta + additionalHeaders = runDeltaParams.additionalHeaders.toBuilder() + additionalQueryParams = runDeltaParams.additionalQueryParams.toBuilder() + } + + fun shareToken(shareToken: String?) = apply { this.shareToken = shareToken } + + /** Alias for calling [Builder.shareToken] with `shareToken.orElse(null)`. */ + fun shareToken(shareToken: Optional<String>) = shareToken(shareToken.getOrNull()) + + fun queryFeedbackDelta(queryFeedbackDelta: QueryFeedbackDelta) = apply { + this.queryFeedbackDelta = queryFeedbackDelta + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RunDeltaParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .queryFeedbackDelta() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RunDeltaParams = + RunDeltaParams( + shareToken, + checkRequired("queryFeedbackDelta", queryFeedbackDelta), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): QueryFeedbackDelta = queryFeedbackDelta + + fun _pathParam(index: Int): String = + when (index) { + 0 -> shareToken ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunDeltaParams && + shareToken == other.shareToken && + queryFeedbackDelta == other.queryFeedbackDelta && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(shareToken, queryFeedbackDelta, additionalHeaders, additionalQueryParams) + + override fun toString() = + "RunDeltaParams{shareToken=$shareToken, queryFeedbackDelta=$queryFeedbackDelta, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunGenerateQueryParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunGenerateQueryParams.kt new file mode 100644 index 00000000..206c7b31 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunGenerateQueryParams.kt @@ -0,0 +1,231 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.datasets.runs + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.models.api.v1.runs.RequestBodyForRunsGenerateQuery +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get runs in projects run over a dataset that has been shared. */ +class RunGenerateQueryParams +private constructor( + private val shareToken: String?, + private val requestBodyForRunsGenerateQuery: RequestBodyForRunsGenerateQuery, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun shareToken(): Optional<String> = Optional.ofNullable(shareToken) + + fun requestBodyForRunsGenerateQuery(): RequestBodyForRunsGenerateQuery = + requestBodyForRunsGenerateQuery + + fun _additionalBodyProperties(): Map<String, JsonValue> = + requestBodyForRunsGenerateQuery._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RunGenerateQueryParams]. + * + * The following fields are required: + * ```java + * .requestBodyForRunsGenerateQuery() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunGenerateQueryParams]. */ + class Builder internal constructor() { + + private var shareToken: String? = null + private var requestBodyForRunsGenerateQuery: RequestBodyForRunsGenerateQuery? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(runGenerateQueryParams: RunGenerateQueryParams) = apply { + shareToken = runGenerateQueryParams.shareToken + requestBodyForRunsGenerateQuery = runGenerateQueryParams.requestBodyForRunsGenerateQuery + additionalHeaders = runGenerateQueryParams.additionalHeaders.toBuilder() + additionalQueryParams = runGenerateQueryParams.additionalQueryParams.toBuilder() + } + + fun shareToken(shareToken: String?) = apply { this.shareToken = shareToken } + + /** Alias for calling [Builder.shareToken] with `shareToken.orElse(null)`. */ + fun shareToken(shareToken: Optional<String>) = shareToken(shareToken.getOrNull()) + + fun requestBodyForRunsGenerateQuery( + requestBodyForRunsGenerateQuery: RequestBodyForRunsGenerateQuery + ) = apply { this.requestBodyForRunsGenerateQuery = requestBodyForRunsGenerateQuery } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RunGenerateQueryParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .requestBodyForRunsGenerateQuery() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RunGenerateQueryParams = + RunGenerateQueryParams( + shareToken, + checkRequired("requestBodyForRunsGenerateQuery", requestBodyForRunsGenerateQuery), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): RequestBodyForRunsGenerateQuery = requestBodyForRunsGenerateQuery + + fun _pathParam(index: Int): String = + when (index) { + 0 -> shareToken ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunGenerateQueryParams && + shareToken == other.shareToken && + requestBodyForRunsGenerateQuery == other.requestBodyForRunsGenerateQuery && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + shareToken, + requestBodyForRunsGenerateQuery, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "RunGenerateQueryParams{shareToken=$shareToken, requestBodyForRunsGenerateQuery=$requestBodyForRunsGenerateQuery, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunPublicDatasetSchema.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunPublicDatasetSchema.kt new file mode 100644 index 00000000..4a2859e7 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunPublicDatasetSchema.kt @@ -0,0 +1,2348 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.datasets.runs + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.runs.RunTypeEnum +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Schema for a run in a publicly-shared dataset. */ +class RunPublicDatasetSchema +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val dottedOrder: JsonField<String>, + private val name: JsonField<String>, + private val runType: JsonField<RunTypeEnum>, + private val sessionId: JsonField<String>, + private val status: JsonField<String>, + private val traceId: JsonField<String>, + private val childRunIds: JsonField<List<String>>, + private val completionCost: JsonField<String>, + private val completionCostDetails: JsonField<CompletionCostDetails>, + private val completionTokenDetails: JsonField<CompletionTokenDetails>, + private val completionTokens: JsonField<Long>, + private val directChildRunIds: JsonField<List<String>>, + private val endTime: JsonField<OffsetDateTime>, + private val error: JsonField<String>, + private val events: JsonField<List<JsonValue>>, + private val executionOrder: JsonField<Long>, + private val extra: JsonValue, + private val feedbackStats: JsonField<FeedbackStats>, + private val firstTokenTime: JsonField<OffsetDateTime>, + private val inputs: JsonValue, + private val inputsPreview: JsonField<String>, + private val inputsS3Urls: JsonValue, + private val manifestId: JsonField<String>, + private val manifestS3Id: JsonField<String>, + private val outputs: JsonValue, + private val outputsPreview: JsonField<String>, + private val outputsS3Urls: JsonValue, + private val parentRunId: JsonField<String>, + private val parentRunIds: JsonField<List<String>>, + private val priceModelId: JsonField<String>, + private val promptCost: JsonField<String>, + private val promptCostDetails: JsonField<PromptCostDetails>, + private val promptTokenDetails: JsonField<PromptTokenDetails>, + private val promptTokens: JsonField<Long>, + private val referenceExampleId: JsonField<String>, + private val s3Urls: JsonValue, + private val serialized: JsonValue, + private val startTime: JsonField<OffsetDateTime>, + private val tags: JsonField<List<String>>, + private val totalCost: JsonField<String>, + private val totalTokens: JsonField<Long>, + private val traceMaxStartTime: JsonField<OffsetDateTime>, + private val traceMinStartTime: JsonField<OffsetDateTime>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("dotted_order") + @ExcludeMissing + dottedOrder: JsonField<String> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("run_type") + @ExcludeMissing + runType: JsonField<RunTypeEnum> = JsonMissing.of(), + @JsonProperty("session_id") @ExcludeMissing sessionId: JsonField<String> = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField<String> = JsonMissing.of(), + @JsonProperty("trace_id") @ExcludeMissing traceId: JsonField<String> = JsonMissing.of(), + @JsonProperty("child_run_ids") + @ExcludeMissing + childRunIds: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("completion_cost") + @ExcludeMissing + completionCost: JsonField<String> = JsonMissing.of(), + @JsonProperty("completion_cost_details") + @ExcludeMissing + completionCostDetails: JsonField<CompletionCostDetails> = JsonMissing.of(), + @JsonProperty("completion_token_details") + @ExcludeMissing + completionTokenDetails: JsonField<CompletionTokenDetails> = JsonMissing.of(), + @JsonProperty("completion_tokens") + @ExcludeMissing + completionTokens: JsonField<Long> = JsonMissing.of(), + @JsonProperty("direct_child_run_ids") + @ExcludeMissing + directChildRunIds: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("end_time") + @ExcludeMissing + endTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("error") @ExcludeMissing error: JsonField<String> = JsonMissing.of(), + @JsonProperty("events") + @ExcludeMissing + events: JsonField<List<JsonValue>> = JsonMissing.of(), + @JsonProperty("execution_order") + @ExcludeMissing + executionOrder: JsonField<Long> = JsonMissing.of(), + @JsonProperty("extra") @ExcludeMissing extra: JsonValue = JsonMissing.of(), + @JsonProperty("feedback_stats") + @ExcludeMissing + feedbackStats: JsonField<FeedbackStats> = JsonMissing.of(), + @JsonProperty("first_token_time") + @ExcludeMissing + firstTokenTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("inputs") @ExcludeMissing inputs: JsonValue = JsonMissing.of(), + @JsonProperty("inputs_preview") + @ExcludeMissing + inputsPreview: JsonField<String> = JsonMissing.of(), + @JsonProperty("inputs_s3_urls") @ExcludeMissing inputsS3Urls: JsonValue = JsonMissing.of(), + @JsonProperty("manifest_id") + @ExcludeMissing + manifestId: JsonField<String> = JsonMissing.of(), + @JsonProperty("manifest_s3_id") + @ExcludeMissing + manifestS3Id: JsonField<String> = JsonMissing.of(), + @JsonProperty("outputs") @ExcludeMissing outputs: JsonValue = JsonMissing.of(), + @JsonProperty("outputs_preview") + @ExcludeMissing + outputsPreview: JsonField<String> = JsonMissing.of(), + @JsonProperty("outputs_s3_urls") + @ExcludeMissing + outputsS3Urls: JsonValue = JsonMissing.of(), + @JsonProperty("parent_run_id") + @ExcludeMissing + parentRunId: JsonField<String> = JsonMissing.of(), + @JsonProperty("parent_run_ids") + @ExcludeMissing + parentRunIds: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("price_model_id") + @ExcludeMissing + priceModelId: JsonField<String> = JsonMissing.of(), + @JsonProperty("prompt_cost") + @ExcludeMissing + promptCost: JsonField<String> = JsonMissing.of(), + @JsonProperty("prompt_cost_details") + @ExcludeMissing + promptCostDetails: JsonField<PromptCostDetails> = JsonMissing.of(), + @JsonProperty("prompt_token_details") + @ExcludeMissing + promptTokenDetails: JsonField<PromptTokenDetails> = JsonMissing.of(), + @JsonProperty("prompt_tokens") + @ExcludeMissing + promptTokens: JsonField<Long> = JsonMissing.of(), + @JsonProperty("reference_example_id") + @ExcludeMissing + referenceExampleId: JsonField<String> = JsonMissing.of(), + @JsonProperty("s3_urls") @ExcludeMissing s3Urls: JsonValue = JsonMissing.of(), + @JsonProperty("serialized") @ExcludeMissing serialized: JsonValue = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing tags: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("total_cost") @ExcludeMissing totalCost: JsonField<String> = JsonMissing.of(), + @JsonProperty("total_tokens") + @ExcludeMissing + totalTokens: JsonField<Long> = JsonMissing.of(), + @JsonProperty("trace_max_start_time") + @ExcludeMissing + traceMaxStartTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("trace_min_start_time") + @ExcludeMissing + traceMinStartTime: JsonField<OffsetDateTime> = JsonMissing.of(), + ) : this( + id, + dottedOrder, + name, + runType, + sessionId, + status, + traceId, + childRunIds, + completionCost, + completionCostDetails, + completionTokenDetails, + completionTokens, + directChildRunIds, + endTime, + error, + events, + executionOrder, + extra, + feedbackStats, + firstTokenTime, + inputs, + inputsPreview, + inputsS3Urls, + manifestId, + manifestS3Id, + outputs, + outputsPreview, + outputsS3Urls, + parentRunId, + parentRunIds, + priceModelId, + promptCost, + promptCostDetails, + promptTokenDetails, + promptTokens, + referenceExampleId, + s3Urls, + serialized, + startTime, + tags, + totalCost, + totalTokens, + traceMaxStartTime, + traceMinStartTime, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun dottedOrder(): String = dottedOrder.getRequired("dotted_order") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Enum for run types. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun runType(): RunTypeEnum = runType.getRequired("run_type") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun sessionId(): String = sessionId.getRequired("session_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): String = status.getRequired("status") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun traceId(): String = traceId.getRequired("trace_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun childRunIds(): Optional<List<String>> = childRunIds.getOptional("child_run_ids") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun completionCost(): Optional<String> = completionCost.getOptional("completion_cost") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun completionCostDetails(): Optional<CompletionCostDetails> = + completionCostDetails.getOptional("completion_cost_details") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun completionTokenDetails(): Optional<CompletionTokenDetails> = + completionTokenDetails.getOptional("completion_token_details") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun completionTokens(): Optional<Long> = completionTokens.getOptional("completion_tokens") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun directChildRunIds(): Optional<List<String>> = + directChildRunIds.getOptional("direct_child_run_ids") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endTime(): Optional<OffsetDateTime> = endTime.getOptional("end_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun error(): Optional<String> = error.getOptional("error") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun events(): Optional<List<JsonValue>> = events.getOptional("events") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun executionOrder(): Optional<Long> = executionOrder.getOptional("execution_order") + + @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonValue = extra + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun feedbackStats(): Optional<FeedbackStats> = feedbackStats.getOptional("feedback_stats") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun firstTokenTime(): Optional<OffsetDateTime> = firstTokenTime.getOptional("first_token_time") + + @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonValue = inputs + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun inputsPreview(): Optional<String> = inputsPreview.getOptional("inputs_preview") + + @JsonProperty("inputs_s3_urls") @ExcludeMissing fun _inputsS3Urls(): JsonValue = inputsS3Urls + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun manifestId(): Optional<String> = manifestId.getOptional("manifest_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun manifestS3Id(): Optional<String> = manifestS3Id.getOptional("manifest_s3_id") + + @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonValue = outputs + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun outputsPreview(): Optional<String> = outputsPreview.getOptional("outputs_preview") + + @JsonProperty("outputs_s3_urls") @ExcludeMissing fun _outputsS3Urls(): JsonValue = outputsS3Urls + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun parentRunId(): Optional<String> = parentRunId.getOptional("parent_run_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun parentRunIds(): Optional<List<String>> = parentRunIds.getOptional("parent_run_ids") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun priceModelId(): Optional<String> = priceModelId.getOptional("price_model_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun promptCost(): Optional<String> = promptCost.getOptional("prompt_cost") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun promptCostDetails(): Optional<PromptCostDetails> = + promptCostDetails.getOptional("prompt_cost_details") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun promptTokenDetails(): Optional<PromptTokenDetails> = + promptTokenDetails.getOptional("prompt_token_details") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun promptTokens(): Optional<Long> = promptTokens.getOptional("prompt_tokens") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceExampleId(): Optional<String> = + referenceExampleId.getOptional("reference_example_id") + + @JsonProperty("s3_urls") @ExcludeMissing fun _s3Urls(): JsonValue = s3Urls + + @JsonProperty("serialized") @ExcludeMissing fun _serialized(): JsonValue = serialized + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun startTime(): Optional<OffsetDateTime> = startTime.getOptional("start_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tags(): Optional<List<String>> = tags.getOptional("tags") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun totalCost(): Optional<String> = totalCost.getOptional("total_cost") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun totalTokens(): Optional<Long> = totalTokens.getOptional("total_tokens") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun traceMaxStartTime(): Optional<OffsetDateTime> = + traceMaxStartTime.getOptional("trace_max_start_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun traceMinStartTime(): Optional<OffsetDateTime> = + traceMinStartTime.getOptional("trace_min_start_time") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [dottedOrder]. + * + * Unlike [dottedOrder], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dotted_order") + @ExcludeMissing + fun _dottedOrder(): JsonField<String> = dottedOrder + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [runType]. + * + * Unlike [runType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_type") @ExcludeMissing fun _runType(): JsonField<RunTypeEnum> = runType + + /** + * Returns the raw JSON value of [sessionId]. + * + * Unlike [sessionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session_id") @ExcludeMissing fun _sessionId(): JsonField<String> = sessionId + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField<String> = status + + /** + * Returns the raw JSON value of [traceId]. + * + * Unlike [traceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trace_id") @ExcludeMissing fun _traceId(): JsonField<String> = traceId + + /** + * Returns the raw JSON value of [childRunIds]. + * + * Unlike [childRunIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("child_run_ids") + @ExcludeMissing + fun _childRunIds(): JsonField<List<String>> = childRunIds + + /** + * Returns the raw JSON value of [completionCost]. + * + * Unlike [completionCost], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("completion_cost") + @ExcludeMissing + fun _completionCost(): JsonField<String> = completionCost + + /** + * Returns the raw JSON value of [completionCostDetails]. + * + * Unlike [completionCostDetails], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("completion_cost_details") + @ExcludeMissing + fun _completionCostDetails(): JsonField<CompletionCostDetails> = completionCostDetails + + /** + * Returns the raw JSON value of [completionTokenDetails]. + * + * Unlike [completionTokenDetails], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("completion_token_details") + @ExcludeMissing + fun _completionTokenDetails(): JsonField<CompletionTokenDetails> = completionTokenDetails + + /** + * Returns the raw JSON value of [completionTokens]. + * + * Unlike [completionTokens], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("completion_tokens") + @ExcludeMissing + fun _completionTokens(): JsonField<Long> = completionTokens + + /** + * Returns the raw JSON value of [directChildRunIds]. + * + * Unlike [directChildRunIds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("direct_child_run_ids") + @ExcludeMissing + fun _directChildRunIds(): JsonField<List<String>> = directChildRunIds + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_time") @ExcludeMissing fun _endTime(): JsonField<OffsetDateTime> = endTime + + /** + * Returns the raw JSON value of [error]. + * + * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("error") @ExcludeMissing fun _error(): JsonField<String> = error + + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("events") @ExcludeMissing fun _events(): JsonField<List<JsonValue>> = events + + /** + * Returns the raw JSON value of [executionOrder]. + * + * Unlike [executionOrder], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("execution_order") + @ExcludeMissing + fun _executionOrder(): JsonField<Long> = executionOrder + + /** + * Returns the raw JSON value of [feedbackStats]. + * + * Unlike [feedbackStats], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feedback_stats") + @ExcludeMissing + fun _feedbackStats(): JsonField<FeedbackStats> = feedbackStats + + /** + * Returns the raw JSON value of [firstTokenTime]. + * + * Unlike [firstTokenTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("first_token_time") + @ExcludeMissing + fun _firstTokenTime(): JsonField<OffsetDateTime> = firstTokenTime + + /** + * Returns the raw JSON value of [inputsPreview]. + * + * Unlike [inputsPreview], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inputs_preview") + @ExcludeMissing + fun _inputsPreview(): JsonField<String> = inputsPreview + + /** + * Returns the raw JSON value of [manifestId]. + * + * Unlike [manifestId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("manifest_id") @ExcludeMissing fun _manifestId(): JsonField<String> = manifestId + + /** + * Returns the raw JSON value of [manifestS3Id]. + * + * Unlike [manifestS3Id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("manifest_s3_id") + @ExcludeMissing + fun _manifestS3Id(): JsonField<String> = manifestS3Id + + /** + * Returns the raw JSON value of [outputsPreview]. + * + * Unlike [outputsPreview], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outputs_preview") + @ExcludeMissing + fun _outputsPreview(): JsonField<String> = outputsPreview + + /** + * Returns the raw JSON value of [parentRunId]. + * + * Unlike [parentRunId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("parent_run_id") + @ExcludeMissing + fun _parentRunId(): JsonField<String> = parentRunId + + /** + * Returns the raw JSON value of [parentRunIds]. + * + * Unlike [parentRunIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("parent_run_ids") + @ExcludeMissing + fun _parentRunIds(): JsonField<List<String>> = parentRunIds + + /** + * Returns the raw JSON value of [priceModelId]. + * + * Unlike [priceModelId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_model_id") + @ExcludeMissing + fun _priceModelId(): JsonField<String> = priceModelId + + /** + * Returns the raw JSON value of [promptCost]. + * + * Unlike [promptCost], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prompt_cost") @ExcludeMissing fun _promptCost(): JsonField<String> = promptCost + + /** + * Returns the raw JSON value of [promptCostDetails]. + * + * Unlike [promptCostDetails], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("prompt_cost_details") + @ExcludeMissing + fun _promptCostDetails(): JsonField<PromptCostDetails> = promptCostDetails + + /** + * Returns the raw JSON value of [promptTokenDetails]. + * + * Unlike [promptTokenDetails], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("prompt_token_details") + @ExcludeMissing + fun _promptTokenDetails(): JsonField<PromptTokenDetails> = promptTokenDetails + + /** + * Returns the raw JSON value of [promptTokens]. + * + * Unlike [promptTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prompt_tokens") + @ExcludeMissing + fun _promptTokens(): JsonField<Long> = promptTokens + + /** + * Returns the raw JSON value of [referenceExampleId]. + * + * Unlike [referenceExampleId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reference_example_id") + @ExcludeMissing + fun _referenceExampleId(): JsonField<String> = referenceExampleId + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_time") + @ExcludeMissing + fun _startTime(): JsonField<OffsetDateTime> = startTime + + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField<List<String>> = tags + + /** + * Returns the raw JSON value of [totalCost]. + * + * Unlike [totalCost], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total_cost") @ExcludeMissing fun _totalCost(): JsonField<String> = totalCost + + /** + * Returns the raw JSON value of [totalTokens]. + * + * Unlike [totalTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total_tokens") @ExcludeMissing fun _totalTokens(): JsonField<Long> = totalTokens + + /** + * Returns the raw JSON value of [traceMaxStartTime]. + * + * Unlike [traceMaxStartTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("trace_max_start_time") + @ExcludeMissing + fun _traceMaxStartTime(): JsonField<OffsetDateTime> = traceMaxStartTime + + /** + * Returns the raw JSON value of [traceMinStartTime]. + * + * Unlike [traceMinStartTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("trace_min_start_time") + @ExcludeMissing + fun _traceMinStartTime(): JsonField<OffsetDateTime> = traceMinStartTime + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RunPublicDatasetSchema]. + * + * The following fields are required: + * ```java + * .id() + * .dottedOrder() + * .name() + * .runType() + * .sessionId() + * .status() + * .traceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunPublicDatasetSchema]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var dottedOrder: JsonField<String>? = null + private var name: JsonField<String>? = null + private var runType: JsonField<RunTypeEnum>? = null + private var sessionId: JsonField<String>? = null + private var status: JsonField<String>? = null + private var traceId: JsonField<String>? = null + private var childRunIds: JsonField<MutableList<String>>? = null + private var completionCost: JsonField<String> = JsonMissing.of() + private var completionCostDetails: JsonField<CompletionCostDetails> = JsonMissing.of() + private var completionTokenDetails: JsonField<CompletionTokenDetails> = JsonMissing.of() + private var completionTokens: JsonField<Long> = JsonMissing.of() + private var directChildRunIds: JsonField<MutableList<String>>? = null + private var endTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var error: JsonField<String> = JsonMissing.of() + private var events: JsonField<MutableList<JsonValue>>? = null + private var executionOrder: JsonField<Long> = JsonMissing.of() + private var extra: JsonValue = JsonMissing.of() + private var feedbackStats: JsonField<FeedbackStats> = JsonMissing.of() + private var firstTokenTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var inputs: JsonValue = JsonMissing.of() + private var inputsPreview: JsonField<String> = JsonMissing.of() + private var inputsS3Urls: JsonValue = JsonMissing.of() + private var manifestId: JsonField<String> = JsonMissing.of() + private var manifestS3Id: JsonField<String> = JsonMissing.of() + private var outputs: JsonValue = JsonMissing.of() + private var outputsPreview: JsonField<String> = JsonMissing.of() + private var outputsS3Urls: JsonValue = JsonMissing.of() + private var parentRunId: JsonField<String> = JsonMissing.of() + private var parentRunIds: JsonField<MutableList<String>>? = null + private var priceModelId: JsonField<String> = JsonMissing.of() + private var promptCost: JsonField<String> = JsonMissing.of() + private var promptCostDetails: JsonField<PromptCostDetails> = JsonMissing.of() + private var promptTokenDetails: JsonField<PromptTokenDetails> = JsonMissing.of() + private var promptTokens: JsonField<Long> = JsonMissing.of() + private var referenceExampleId: JsonField<String> = JsonMissing.of() + private var s3Urls: JsonValue = JsonMissing.of() + private var serialized: JsonValue = JsonMissing.of() + private var startTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var tags: JsonField<MutableList<String>>? = null + private var totalCost: JsonField<String> = JsonMissing.of() + private var totalTokens: JsonField<Long> = JsonMissing.of() + private var traceMaxStartTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var traceMinStartTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(runPublicDatasetSchema: RunPublicDatasetSchema) = apply { + id = runPublicDatasetSchema.id + dottedOrder = runPublicDatasetSchema.dottedOrder + name = runPublicDatasetSchema.name + runType = runPublicDatasetSchema.runType + sessionId = runPublicDatasetSchema.sessionId + status = runPublicDatasetSchema.status + traceId = runPublicDatasetSchema.traceId + childRunIds = runPublicDatasetSchema.childRunIds.map { it.toMutableList() } + completionCost = runPublicDatasetSchema.completionCost + completionCostDetails = runPublicDatasetSchema.completionCostDetails + completionTokenDetails = runPublicDatasetSchema.completionTokenDetails + completionTokens = runPublicDatasetSchema.completionTokens + directChildRunIds = runPublicDatasetSchema.directChildRunIds.map { it.toMutableList() } + endTime = runPublicDatasetSchema.endTime + error = runPublicDatasetSchema.error + events = runPublicDatasetSchema.events.map { it.toMutableList() } + executionOrder = runPublicDatasetSchema.executionOrder + extra = runPublicDatasetSchema.extra + feedbackStats = runPublicDatasetSchema.feedbackStats + firstTokenTime = runPublicDatasetSchema.firstTokenTime + inputs = runPublicDatasetSchema.inputs + inputsPreview = runPublicDatasetSchema.inputsPreview + inputsS3Urls = runPublicDatasetSchema.inputsS3Urls + manifestId = runPublicDatasetSchema.manifestId + manifestS3Id = runPublicDatasetSchema.manifestS3Id + outputs = runPublicDatasetSchema.outputs + outputsPreview = runPublicDatasetSchema.outputsPreview + outputsS3Urls = runPublicDatasetSchema.outputsS3Urls + parentRunId = runPublicDatasetSchema.parentRunId + parentRunIds = runPublicDatasetSchema.parentRunIds.map { it.toMutableList() } + priceModelId = runPublicDatasetSchema.priceModelId + promptCost = runPublicDatasetSchema.promptCost + promptCostDetails = runPublicDatasetSchema.promptCostDetails + promptTokenDetails = runPublicDatasetSchema.promptTokenDetails + promptTokens = runPublicDatasetSchema.promptTokens + referenceExampleId = runPublicDatasetSchema.referenceExampleId + s3Urls = runPublicDatasetSchema.s3Urls + serialized = runPublicDatasetSchema.serialized + startTime = runPublicDatasetSchema.startTime + tags = runPublicDatasetSchema.tags.map { it.toMutableList() } + totalCost = runPublicDatasetSchema.totalCost + totalTokens = runPublicDatasetSchema.totalTokens + traceMaxStartTime = runPublicDatasetSchema.traceMaxStartTime + traceMinStartTime = runPublicDatasetSchema.traceMinStartTime + additionalProperties = runPublicDatasetSchema.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun dottedOrder(dottedOrder: String) = dottedOrder(JsonField.of(dottedOrder)) + + /** + * Sets [Builder.dottedOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.dottedOrder] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dottedOrder(dottedOrder: JsonField<String>) = apply { this.dottedOrder = dottedOrder } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + /** Enum for run types. */ + fun runType(runType: RunTypeEnum) = runType(JsonField.of(runType)) + + /** + * Sets [Builder.runType] to an arbitrary JSON value. + * + * You should usually call [Builder.runType] with a well-typed [RunTypeEnum] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun runType(runType: JsonField<RunTypeEnum>) = apply { this.runType = runType } + + fun sessionId(sessionId: String) = sessionId(JsonField.of(sessionId)) + + /** + * Sets [Builder.sessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun sessionId(sessionId: JsonField<String>) = apply { this.sessionId = sessionId } + + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField<String>) = apply { this.status = status } + + fun traceId(traceId: String) = traceId(JsonField.of(traceId)) + + /** + * Sets [Builder.traceId] to an arbitrary JSON value. + * + * You should usually call [Builder.traceId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun traceId(traceId: JsonField<String>) = apply { this.traceId = traceId } + + fun childRunIds(childRunIds: List<String>?) = childRunIds(JsonField.ofNullable(childRunIds)) + + /** Alias for calling [Builder.childRunIds] with `childRunIds.orElse(null)`. */ + fun childRunIds(childRunIds: Optional<List<String>>) = childRunIds(childRunIds.getOrNull()) + + /** + * Sets [Builder.childRunIds] to an arbitrary JSON value. + * + * You should usually call [Builder.childRunIds] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun childRunIds(childRunIds: JsonField<List<String>>) = apply { + this.childRunIds = childRunIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [childRunIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChildRunId(childRunId: String) = apply { + childRunIds = + (childRunIds ?: JsonField.of(mutableListOf())).also { + checkKnown("childRunIds", it).add(childRunId) + } + } + + fun completionCost(completionCost: String?) = + completionCost(JsonField.ofNullable(completionCost)) + + /** Alias for calling [Builder.completionCost] with `completionCost.orElse(null)`. */ + fun completionCost(completionCost: Optional<String>) = + completionCost(completionCost.getOrNull()) + + /** + * Sets [Builder.completionCost] to an arbitrary JSON value. + * + * You should usually call [Builder.completionCost] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun completionCost(completionCost: JsonField<String>) = apply { + this.completionCost = completionCost + } + + fun completionCostDetails(completionCostDetails: CompletionCostDetails?) = + completionCostDetails(JsonField.ofNullable(completionCostDetails)) + + /** + * Alias for calling [Builder.completionCostDetails] with + * `completionCostDetails.orElse(null)`. + */ + fun completionCostDetails(completionCostDetails: Optional<CompletionCostDetails>) = + completionCostDetails(completionCostDetails.getOrNull()) + + /** + * Sets [Builder.completionCostDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.completionCostDetails] with a well-typed + * [CompletionCostDetails] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun completionCostDetails(completionCostDetails: JsonField<CompletionCostDetails>) = apply { + this.completionCostDetails = completionCostDetails + } + + fun completionTokenDetails(completionTokenDetails: CompletionTokenDetails?) = + completionTokenDetails(JsonField.ofNullable(completionTokenDetails)) + + /** + * Alias for calling [Builder.completionTokenDetails] with + * `completionTokenDetails.orElse(null)`. + */ + fun completionTokenDetails(completionTokenDetails: Optional<CompletionTokenDetails>) = + completionTokenDetails(completionTokenDetails.getOrNull()) + + /** + * Sets [Builder.completionTokenDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.completionTokenDetails] with a well-typed + * [CompletionTokenDetails] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun completionTokenDetails(completionTokenDetails: JsonField<CompletionTokenDetails>) = + apply { + this.completionTokenDetails = completionTokenDetails + } + + fun completionTokens(completionTokens: Long) = + completionTokens(JsonField.of(completionTokens)) + + /** + * Sets [Builder.completionTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.completionTokens] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun completionTokens(completionTokens: JsonField<Long>) = apply { + this.completionTokens = completionTokens + } + + fun directChildRunIds(directChildRunIds: List<String>?) = + directChildRunIds(JsonField.ofNullable(directChildRunIds)) + + /** Alias for calling [Builder.directChildRunIds] with `directChildRunIds.orElse(null)`. */ + fun directChildRunIds(directChildRunIds: Optional<List<String>>) = + directChildRunIds(directChildRunIds.getOrNull()) + + /** + * Sets [Builder.directChildRunIds] to an arbitrary JSON value. + * + * You should usually call [Builder.directChildRunIds] with a well-typed `List<String>` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun directChildRunIds(directChildRunIds: JsonField<List<String>>) = apply { + this.directChildRunIds = directChildRunIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [directChildRunIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addDirectChildRunId(directChildRunId: String) = apply { + directChildRunIds = + (directChildRunIds ?: JsonField.of(mutableListOf())).also { + checkKnown("directChildRunIds", it).add(directChildRunId) + } + } + + fun endTime(endTime: OffsetDateTime?) = endTime(JsonField.ofNullable(endTime)) + + /** Alias for calling [Builder.endTime] with `endTime.orElse(null)`. */ + fun endTime(endTime: Optional<OffsetDateTime>) = endTime(endTime.getOrNull()) + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endTime(endTime: JsonField<OffsetDateTime>) = apply { this.endTime = endTime } + + fun error(error: String?) = error(JsonField.ofNullable(error)) + + /** Alias for calling [Builder.error] with `error.orElse(null)`. */ + fun error(error: Optional<String>) = error(error.getOrNull()) + + /** + * Sets [Builder.error] to an arbitrary JSON value. + * + * You should usually call [Builder.error] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun error(error: JsonField<String>) = apply { this.error = error } + + fun events(events: List<JsonValue>?) = events(JsonField.ofNullable(events)) + + /** Alias for calling [Builder.events] with `events.orElse(null)`. */ + fun events(events: Optional<List<JsonValue>>) = events(events.getOrNull()) + + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed `List<JsonValue>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun events(events: JsonField<List<JsonValue>>) = apply { + this.events = events.map { it.toMutableList() } + } + + /** + * Adds a single [JsonValue] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvent(event: JsonValue) = apply { + events = + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) + } + } + + fun executionOrder(executionOrder: Long) = executionOrder(JsonField.of(executionOrder)) + + /** + * Sets [Builder.executionOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.executionOrder] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun executionOrder(executionOrder: JsonField<Long>) = apply { + this.executionOrder = executionOrder + } + + fun extra(extra: JsonValue) = apply { this.extra = extra } + + fun feedbackStats(feedbackStats: FeedbackStats?) = + feedbackStats(JsonField.ofNullable(feedbackStats)) + + /** Alias for calling [Builder.feedbackStats] with `feedbackStats.orElse(null)`. */ + fun feedbackStats(feedbackStats: Optional<FeedbackStats>) = + feedbackStats(feedbackStats.getOrNull()) + + /** + * Sets [Builder.feedbackStats] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackStats] with a well-typed [FeedbackStats] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun feedbackStats(feedbackStats: JsonField<FeedbackStats>) = apply { + this.feedbackStats = feedbackStats + } + + fun firstTokenTime(firstTokenTime: OffsetDateTime?) = + firstTokenTime(JsonField.ofNullable(firstTokenTime)) + + /** Alias for calling [Builder.firstTokenTime] with `firstTokenTime.orElse(null)`. */ + fun firstTokenTime(firstTokenTime: Optional<OffsetDateTime>) = + firstTokenTime(firstTokenTime.getOrNull()) + + /** + * Sets [Builder.firstTokenTime] to an arbitrary JSON value. + * + * You should usually call [Builder.firstTokenTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun firstTokenTime(firstTokenTime: JsonField<OffsetDateTime>) = apply { + this.firstTokenTime = firstTokenTime + } + + fun inputs(inputs: JsonValue) = apply { this.inputs = inputs } + + fun inputsPreview(inputsPreview: String?) = + inputsPreview(JsonField.ofNullable(inputsPreview)) + + /** Alias for calling [Builder.inputsPreview] with `inputsPreview.orElse(null)`. */ + fun inputsPreview(inputsPreview: Optional<String>) = + inputsPreview(inputsPreview.getOrNull()) + + /** + * Sets [Builder.inputsPreview] to an arbitrary JSON value. + * + * You should usually call [Builder.inputsPreview] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun inputsPreview(inputsPreview: JsonField<String>) = apply { + this.inputsPreview = inputsPreview + } + + fun inputsS3Urls(inputsS3Urls: JsonValue) = apply { this.inputsS3Urls = inputsS3Urls } + + fun manifestId(manifestId: String?) = manifestId(JsonField.ofNullable(manifestId)) + + /** Alias for calling [Builder.manifestId] with `manifestId.orElse(null)`. */ + fun manifestId(manifestId: Optional<String>) = manifestId(manifestId.getOrNull()) + + /** + * Sets [Builder.manifestId] to an arbitrary JSON value. + * + * You should usually call [Builder.manifestId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun manifestId(manifestId: JsonField<String>) = apply { this.manifestId = manifestId } + + fun manifestS3Id(manifestS3Id: String?) = manifestS3Id(JsonField.ofNullable(manifestS3Id)) + + /** Alias for calling [Builder.manifestS3Id] with `manifestS3Id.orElse(null)`. */ + fun manifestS3Id(manifestS3Id: Optional<String>) = manifestS3Id(manifestS3Id.getOrNull()) + + /** + * Sets [Builder.manifestS3Id] to an arbitrary JSON value. + * + * You should usually call [Builder.manifestS3Id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun manifestS3Id(manifestS3Id: JsonField<String>) = apply { + this.manifestS3Id = manifestS3Id + } + + fun outputs(outputs: JsonValue) = apply { this.outputs = outputs } + + fun outputsPreview(outputsPreview: String?) = + outputsPreview(JsonField.ofNullable(outputsPreview)) + + /** Alias for calling [Builder.outputsPreview] with `outputsPreview.orElse(null)`. */ + fun outputsPreview(outputsPreview: Optional<String>) = + outputsPreview(outputsPreview.getOrNull()) + + /** + * Sets [Builder.outputsPreview] to an arbitrary JSON value. + * + * You should usually call [Builder.outputsPreview] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun outputsPreview(outputsPreview: JsonField<String>) = apply { + this.outputsPreview = outputsPreview + } + + fun outputsS3Urls(outputsS3Urls: JsonValue) = apply { this.outputsS3Urls = outputsS3Urls } + + fun parentRunId(parentRunId: String?) = parentRunId(JsonField.ofNullable(parentRunId)) + + /** Alias for calling [Builder.parentRunId] with `parentRunId.orElse(null)`. */ + fun parentRunId(parentRunId: Optional<String>) = parentRunId(parentRunId.getOrNull()) + + /** + * Sets [Builder.parentRunId] to an arbitrary JSON value. + * + * You should usually call [Builder.parentRunId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun parentRunId(parentRunId: JsonField<String>) = apply { this.parentRunId = parentRunId } + + fun parentRunIds(parentRunIds: List<String>?) = + parentRunIds(JsonField.ofNullable(parentRunIds)) + + /** Alias for calling [Builder.parentRunIds] with `parentRunIds.orElse(null)`. */ + fun parentRunIds(parentRunIds: Optional<List<String>>) = + parentRunIds(parentRunIds.getOrNull()) + + /** + * Sets [Builder.parentRunIds] to an arbitrary JSON value. + * + * You should usually call [Builder.parentRunIds] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun parentRunIds(parentRunIds: JsonField<List<String>>) = apply { + this.parentRunIds = parentRunIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [parentRunIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addParentRunId(parentRunId: String) = apply { + parentRunIds = + (parentRunIds ?: JsonField.of(mutableListOf())).also { + checkKnown("parentRunIds", it).add(parentRunId) + } + } + + fun priceModelId(priceModelId: String?) = priceModelId(JsonField.ofNullable(priceModelId)) + + /** Alias for calling [Builder.priceModelId] with `priceModelId.orElse(null)`. */ + fun priceModelId(priceModelId: Optional<String>) = priceModelId(priceModelId.getOrNull()) + + /** + * Sets [Builder.priceModelId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceModelId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun priceModelId(priceModelId: JsonField<String>) = apply { + this.priceModelId = priceModelId + } + + fun promptCost(promptCost: String?) = promptCost(JsonField.ofNullable(promptCost)) + + /** Alias for calling [Builder.promptCost] with `promptCost.orElse(null)`. */ + fun promptCost(promptCost: Optional<String>) = promptCost(promptCost.getOrNull()) + + /** + * Sets [Builder.promptCost] to an arbitrary JSON value. + * + * You should usually call [Builder.promptCost] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun promptCost(promptCost: JsonField<String>) = apply { this.promptCost = promptCost } + + fun promptCostDetails(promptCostDetails: PromptCostDetails?) = + promptCostDetails(JsonField.ofNullable(promptCostDetails)) + + /** Alias for calling [Builder.promptCostDetails] with `promptCostDetails.orElse(null)`. */ + fun promptCostDetails(promptCostDetails: Optional<PromptCostDetails>) = + promptCostDetails(promptCostDetails.getOrNull()) + + /** + * Sets [Builder.promptCostDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.promptCostDetails] with a well-typed [PromptCostDetails] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun promptCostDetails(promptCostDetails: JsonField<PromptCostDetails>) = apply { + this.promptCostDetails = promptCostDetails + } + + fun promptTokenDetails(promptTokenDetails: PromptTokenDetails?) = + promptTokenDetails(JsonField.ofNullable(promptTokenDetails)) + + /** + * Alias for calling [Builder.promptTokenDetails] with `promptTokenDetails.orElse(null)`. + */ + fun promptTokenDetails(promptTokenDetails: Optional<PromptTokenDetails>) = + promptTokenDetails(promptTokenDetails.getOrNull()) + + /** + * Sets [Builder.promptTokenDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.promptTokenDetails] with a well-typed + * [PromptTokenDetails] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun promptTokenDetails(promptTokenDetails: JsonField<PromptTokenDetails>) = apply { + this.promptTokenDetails = promptTokenDetails + } + + fun promptTokens(promptTokens: Long) = promptTokens(JsonField.of(promptTokens)) + + /** + * Sets [Builder.promptTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.promptTokens] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun promptTokens(promptTokens: JsonField<Long>) = apply { this.promptTokens = promptTokens } + + fun referenceExampleId(referenceExampleId: String?) = + referenceExampleId(JsonField.ofNullable(referenceExampleId)) + + /** + * Alias for calling [Builder.referenceExampleId] with `referenceExampleId.orElse(null)`. + */ + fun referenceExampleId(referenceExampleId: Optional<String>) = + referenceExampleId(referenceExampleId.getOrNull()) + + /** + * Sets [Builder.referenceExampleId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceExampleId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun referenceExampleId(referenceExampleId: JsonField<String>) = apply { + this.referenceExampleId = referenceExampleId + } + + fun s3Urls(s3Urls: JsonValue) = apply { this.s3Urls = s3Urls } + + fun serialized(serialized: JsonValue) = apply { this.serialized = serialized } + + fun startTime(startTime: OffsetDateTime) = startTime(JsonField.of(startTime)) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField<OffsetDateTime>) = apply { this.startTime = startTime } + + fun tags(tags: List<String>?) = tags(JsonField.ofNullable(tags)) + + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ + fun tags(tags: Optional<List<String>>) = tags(tags.getOrNull()) + + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List<String>` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tags(tags: JsonField<List<String>>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } + + fun totalCost(totalCost: String?) = totalCost(JsonField.ofNullable(totalCost)) + + /** Alias for calling [Builder.totalCost] with `totalCost.orElse(null)`. */ + fun totalCost(totalCost: Optional<String>) = totalCost(totalCost.getOrNull()) + + /** + * Sets [Builder.totalCost] to an arbitrary JSON value. + * + * You should usually call [Builder.totalCost] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun totalCost(totalCost: JsonField<String>) = apply { this.totalCost = totalCost } + + fun totalTokens(totalTokens: Long) = totalTokens(JsonField.of(totalTokens)) + + /** + * Sets [Builder.totalTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.totalTokens] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun totalTokens(totalTokens: JsonField<Long>) = apply { this.totalTokens = totalTokens } + + fun traceMaxStartTime(traceMaxStartTime: OffsetDateTime?) = + traceMaxStartTime(JsonField.ofNullable(traceMaxStartTime)) + + /** Alias for calling [Builder.traceMaxStartTime] with `traceMaxStartTime.orElse(null)`. */ + fun traceMaxStartTime(traceMaxStartTime: Optional<OffsetDateTime>) = + traceMaxStartTime(traceMaxStartTime.getOrNull()) + + /** + * Sets [Builder.traceMaxStartTime] to an arbitrary JSON value. + * + * You should usually call [Builder.traceMaxStartTime] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun traceMaxStartTime(traceMaxStartTime: JsonField<OffsetDateTime>) = apply { + this.traceMaxStartTime = traceMaxStartTime + } + + fun traceMinStartTime(traceMinStartTime: OffsetDateTime?) = + traceMinStartTime(JsonField.ofNullable(traceMinStartTime)) + + /** Alias for calling [Builder.traceMinStartTime] with `traceMinStartTime.orElse(null)`. */ + fun traceMinStartTime(traceMinStartTime: Optional<OffsetDateTime>) = + traceMinStartTime(traceMinStartTime.getOrNull()) + + /** + * Sets [Builder.traceMinStartTime] to an arbitrary JSON value. + * + * You should usually call [Builder.traceMinStartTime] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun traceMinStartTime(traceMinStartTime: JsonField<OffsetDateTime>) = apply { + this.traceMinStartTime = traceMinStartTime + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RunPublicDatasetSchema]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .dottedOrder() + * .name() + * .runType() + * .sessionId() + * .status() + * .traceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RunPublicDatasetSchema = + RunPublicDatasetSchema( + checkRequired("id", id), + checkRequired("dottedOrder", dottedOrder), + checkRequired("name", name), + checkRequired("runType", runType), + checkRequired("sessionId", sessionId), + checkRequired("status", status), + checkRequired("traceId", traceId), + (childRunIds ?: JsonMissing.of()).map { it.toImmutable() }, + completionCost, + completionCostDetails, + completionTokenDetails, + completionTokens, + (directChildRunIds ?: JsonMissing.of()).map { it.toImmutable() }, + endTime, + error, + (events ?: JsonMissing.of()).map { it.toImmutable() }, + executionOrder, + extra, + feedbackStats, + firstTokenTime, + inputs, + inputsPreview, + inputsS3Urls, + manifestId, + manifestS3Id, + outputs, + outputsPreview, + outputsS3Urls, + parentRunId, + (parentRunIds ?: JsonMissing.of()).map { it.toImmutable() }, + priceModelId, + promptCost, + promptCostDetails, + promptTokenDetails, + promptTokens, + referenceExampleId, + s3Urls, + serialized, + startTime, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + totalCost, + totalTokens, + traceMaxStartTime, + traceMinStartTime, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RunPublicDatasetSchema = apply { + if (validated) { + return@apply + } + + id() + dottedOrder() + name() + runType().validate() + sessionId() + status() + traceId() + childRunIds() + completionCost() + completionCostDetails().ifPresent { it.validate() } + completionTokenDetails().ifPresent { it.validate() } + completionTokens() + directChildRunIds() + endTime() + error() + events() + executionOrder() + feedbackStats().ifPresent { it.validate() } + firstTokenTime() + inputsPreview() + manifestId() + manifestS3Id() + outputsPreview() + parentRunId() + parentRunIds() + priceModelId() + promptCost() + promptCostDetails().ifPresent { it.validate() } + promptTokenDetails().ifPresent { it.validate() } + promptTokens() + referenceExampleId() + startTime() + tags() + totalCost() + totalTokens() + traceMaxStartTime() + traceMinStartTime() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (dottedOrder.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (runType.asKnown().getOrNull()?.validity() ?: 0) + + (if (sessionId.asKnown().isPresent) 1 else 0) + + (if (status.asKnown().isPresent) 1 else 0) + + (if (traceId.asKnown().isPresent) 1 else 0) + + (childRunIds.asKnown().getOrNull()?.size ?: 0) + + (if (completionCost.asKnown().isPresent) 1 else 0) + + (completionCostDetails.asKnown().getOrNull()?.validity() ?: 0) + + (completionTokenDetails.asKnown().getOrNull()?.validity() ?: 0) + + (if (completionTokens.asKnown().isPresent) 1 else 0) + + (directChildRunIds.asKnown().getOrNull()?.size ?: 0) + + (if (endTime.asKnown().isPresent) 1 else 0) + + (if (error.asKnown().isPresent) 1 else 0) + + (events.asKnown().getOrNull()?.size ?: 0) + + (if (executionOrder.asKnown().isPresent) 1 else 0) + + (feedbackStats.asKnown().getOrNull()?.validity() ?: 0) + + (if (firstTokenTime.asKnown().isPresent) 1 else 0) + + (if (inputsPreview.asKnown().isPresent) 1 else 0) + + (if (manifestId.asKnown().isPresent) 1 else 0) + + (if (manifestS3Id.asKnown().isPresent) 1 else 0) + + (if (outputsPreview.asKnown().isPresent) 1 else 0) + + (if (parentRunId.asKnown().isPresent) 1 else 0) + + (parentRunIds.asKnown().getOrNull()?.size ?: 0) + + (if (priceModelId.asKnown().isPresent) 1 else 0) + + (if (promptCost.asKnown().isPresent) 1 else 0) + + (promptCostDetails.asKnown().getOrNull()?.validity() ?: 0) + + (promptTokenDetails.asKnown().getOrNull()?.validity() ?: 0) + + (if (promptTokens.asKnown().isPresent) 1 else 0) + + (if (referenceExampleId.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + (tags.asKnown().getOrNull()?.size ?: 0) + + (if (totalCost.asKnown().isPresent) 1 else 0) + + (if (totalTokens.asKnown().isPresent) 1 else 0) + + (if (traceMaxStartTime.asKnown().isPresent) 1 else 0) + + (if (traceMinStartTime.asKnown().isPresent) 1 else 0) + + class CompletionCostDetails + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompletionCostDetails]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CompletionCostDetails]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(completionCostDetails: CompletionCostDetails) = apply { + additionalProperties = completionCostDetails.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompletionCostDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CompletionCostDetails = + CompletionCostDetails(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): CompletionCostDetails = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompletionCostDetails && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompletionCostDetails{additionalProperties=$additionalProperties}" + } + + class CompletionTokenDetails + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompletionTokenDetails]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CompletionTokenDetails]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(completionTokenDetails: CompletionTokenDetails) = apply { + additionalProperties = completionTokenDetails.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompletionTokenDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CompletionTokenDetails = + CompletionTokenDetails(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): CompletionTokenDetails = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompletionTokenDetails && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompletionTokenDetails{additionalProperties=$additionalProperties}" + } + + class FeedbackStats + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [FeedbackStats]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackStats]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(feedbackStats: FeedbackStats) = apply { + additionalProperties = feedbackStats.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FeedbackStats]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FeedbackStats = FeedbackStats(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): FeedbackStats = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackStats && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "FeedbackStats{additionalProperties=$additionalProperties}" + } + + class PromptCostDetails + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [PromptCostDetails]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PromptCostDetails]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(promptCostDetails: PromptCostDetails) = apply { + additionalProperties = promptCostDetails.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PromptCostDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PromptCostDetails = PromptCostDetails(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): PromptCostDetails = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PromptCostDetails && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "PromptCostDetails{additionalProperties=$additionalProperties}" + } + + class PromptTokenDetails + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [PromptTokenDetails]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PromptTokenDetails]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(promptTokenDetails: PromptTokenDetails) = apply { + additionalProperties = promptTokenDetails.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PromptTokenDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PromptTokenDetails = PromptTokenDetails(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): PromptTokenDetails = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PromptTokenDetails && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "PromptTokenDetails{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunPublicDatasetSchema && + id == other.id && + dottedOrder == other.dottedOrder && + name == other.name && + runType == other.runType && + sessionId == other.sessionId && + status == other.status && + traceId == other.traceId && + childRunIds == other.childRunIds && + completionCost == other.completionCost && + completionCostDetails == other.completionCostDetails && + completionTokenDetails == other.completionTokenDetails && + completionTokens == other.completionTokens && + directChildRunIds == other.directChildRunIds && + endTime == other.endTime && + error == other.error && + events == other.events && + executionOrder == other.executionOrder && + extra == other.extra && + feedbackStats == other.feedbackStats && + firstTokenTime == other.firstTokenTime && + inputs == other.inputs && + inputsPreview == other.inputsPreview && + inputsS3Urls == other.inputsS3Urls && + manifestId == other.manifestId && + manifestS3Id == other.manifestS3Id && + outputs == other.outputs && + outputsPreview == other.outputsPreview && + outputsS3Urls == other.outputsS3Urls && + parentRunId == other.parentRunId && + parentRunIds == other.parentRunIds && + priceModelId == other.priceModelId && + promptCost == other.promptCost && + promptCostDetails == other.promptCostDetails && + promptTokenDetails == other.promptTokenDetails && + promptTokens == other.promptTokens && + referenceExampleId == other.referenceExampleId && + s3Urls == other.s3Urls && + serialized == other.serialized && + startTime == other.startTime && + tags == other.tags && + totalCost == other.totalCost && + totalTokens == other.totalTokens && + traceMaxStartTime == other.traceMaxStartTime && + traceMinStartTime == other.traceMinStartTime && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + dottedOrder, + name, + runType, + sessionId, + status, + traceId, + childRunIds, + completionCost, + completionCostDetails, + completionTokenDetails, + completionTokens, + directChildRunIds, + endTime, + error, + events, + executionOrder, + extra, + feedbackStats, + firstTokenTime, + inputs, + inputsPreview, + inputsS3Urls, + manifestId, + manifestS3Id, + outputs, + outputsPreview, + outputsS3Urls, + parentRunId, + parentRunIds, + priceModelId, + promptCost, + promptCostDetails, + promptTokenDetails, + promptTokens, + referenceExampleId, + s3Urls, + serialized, + startTime, + tags, + totalCost, + totalTokens, + traceMaxStartTime, + traceMinStartTime, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RunPublicDatasetSchema{id=$id, dottedOrder=$dottedOrder, name=$name, runType=$runType, sessionId=$sessionId, status=$status, traceId=$traceId, childRunIds=$childRunIds, completionCost=$completionCost, completionCostDetails=$completionCostDetails, completionTokenDetails=$completionTokenDetails, completionTokens=$completionTokens, directChildRunIds=$directChildRunIds, endTime=$endTime, error=$error, events=$events, executionOrder=$executionOrder, extra=$extra, feedbackStats=$feedbackStats, firstTokenTime=$firstTokenTime, inputs=$inputs, inputsPreview=$inputsPreview, inputsS3Urls=$inputsS3Urls, manifestId=$manifestId, manifestS3Id=$manifestS3Id, outputs=$outputs, outputsPreview=$outputsPreview, outputsS3Urls=$outputsS3Urls, parentRunId=$parentRunId, parentRunIds=$parentRunIds, priceModelId=$priceModelId, promptCost=$promptCost, promptCostDetails=$promptCostDetails, promptTokenDetails=$promptTokenDetails, promptTokens=$promptTokens, referenceExampleId=$referenceExampleId, s3Urls=$s3Urls, serialized=$serialized, startTime=$startTime, tags=$tags, totalCost=$totalCost, totalTokens=$totalTokens, traceMaxStartTime=$traceMaxStartTime, traceMinStartTime=$traceMinStartTime, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunQueryParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunQueryParams.kt new file mode 100644 index 00000000..ded52fa9 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunQueryParams.kt @@ -0,0 +1,227 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.datasets.runs + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.models.api.v1.runs.BodyParamsForRunSchema +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get runs in projects run over a dataset that has been shared. */ +class RunQueryParams +private constructor( + private val shareToken: String?, + private val bodyParamsForRunSchema: BodyParamsForRunSchema, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun shareToken(): Optional<String> = Optional.ofNullable(shareToken) + + /** Query params for run endpoints. */ + fun bodyParamsForRunSchema(): BodyParamsForRunSchema = bodyParamsForRunSchema + + fun _additionalBodyProperties(): Map<String, JsonValue> = + bodyParamsForRunSchema._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RunQueryParams]. + * + * The following fields are required: + * ```java + * .bodyParamsForRunSchema() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunQueryParams]. */ + class Builder internal constructor() { + + private var shareToken: String? = null + private var bodyParamsForRunSchema: BodyParamsForRunSchema? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(runQueryParams: RunQueryParams) = apply { + shareToken = runQueryParams.shareToken + bodyParamsForRunSchema = runQueryParams.bodyParamsForRunSchema + additionalHeaders = runQueryParams.additionalHeaders.toBuilder() + additionalQueryParams = runQueryParams.additionalQueryParams.toBuilder() + } + + fun shareToken(shareToken: String?) = apply { this.shareToken = shareToken } + + /** Alias for calling [Builder.shareToken] with `shareToken.orElse(null)`. */ + fun shareToken(shareToken: Optional<String>) = shareToken(shareToken.getOrNull()) + + /** Query params for run endpoints. */ + fun bodyParamsForRunSchema(bodyParamsForRunSchema: BodyParamsForRunSchema) = apply { + this.bodyParamsForRunSchema = bodyParamsForRunSchema + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RunQueryParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bodyParamsForRunSchema() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RunQueryParams = + RunQueryParams( + shareToken, + checkRequired("bodyParamsForRunSchema", bodyParamsForRunSchema), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): BodyParamsForRunSchema = bodyParamsForRunSchema + + fun _pathParam(index: Int): String = + when (index) { + 0 -> shareToken ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunQueryParams && + shareToken == other.shareToken && + bodyParamsForRunSchema == other.bodyParamsForRunSchema && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(shareToken, bodyParamsForRunSchema, additionalHeaders, additionalQueryParams) + + override fun toString() = + "RunQueryParams{shareToken=$shareToken, bodyParamsForRunSchema=$bodyParamsForRunSchema, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunQueryResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunQueryResponse.kt new file mode 100644 index 00000000..8225a4f9 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunQueryResponse.kt @@ -0,0 +1,365 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.datasets.runs + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class RunQueryResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val cursors: JsonField<Cursors>, + private val runs: JsonField<List<RunPublicDatasetSchema>>, + private val parsedQuery: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("cursors") @ExcludeMissing cursors: JsonField<Cursors> = JsonMissing.of(), + @JsonProperty("runs") + @ExcludeMissing + runs: JsonField<List<RunPublicDatasetSchema>> = JsonMissing.of(), + @JsonProperty("parsed_query") + @ExcludeMissing + parsedQuery: JsonField<String> = JsonMissing.of(), + ) : this(cursors, runs, parsedQuery, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cursors(): Cursors = cursors.getRequired("cursors") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun runs(): List<RunPublicDatasetSchema> = runs.getRequired("runs") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun parsedQuery(): Optional<String> = parsedQuery.getOptional("parsed_query") + + /** + * Returns the raw JSON value of [cursors]. + * + * Unlike [cursors], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cursors") @ExcludeMissing fun _cursors(): JsonField<Cursors> = cursors + + /** + * Returns the raw JSON value of [runs]. + * + * Unlike [runs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("runs") + @ExcludeMissing + fun _runs(): JsonField<List<RunPublicDatasetSchema>> = runs + + /** + * Returns the raw JSON value of [parsedQuery]. + * + * Unlike [parsedQuery], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("parsed_query") + @ExcludeMissing + fun _parsedQuery(): JsonField<String> = parsedQuery + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RunQueryResponse]. + * + * The following fields are required: + * ```java + * .cursors() + * .runs() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunQueryResponse]. */ + class Builder internal constructor() { + + private var cursors: JsonField<Cursors>? = null + private var runs: JsonField<MutableList<RunPublicDatasetSchema>>? = null + private var parsedQuery: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(runQueryResponse: RunQueryResponse) = apply { + cursors = runQueryResponse.cursors + runs = runQueryResponse.runs.map { it.toMutableList() } + parsedQuery = runQueryResponse.parsedQuery + additionalProperties = runQueryResponse.additionalProperties.toMutableMap() + } + + fun cursors(cursors: Cursors) = cursors(JsonField.of(cursors)) + + /** + * Sets [Builder.cursors] to an arbitrary JSON value. + * + * You should usually call [Builder.cursors] with a well-typed [Cursors] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun cursors(cursors: JsonField<Cursors>) = apply { this.cursors = cursors } + + fun runs(runs: List<RunPublicDatasetSchema>) = runs(JsonField.of(runs)) + + /** + * Sets [Builder.runs] to an arbitrary JSON value. + * + * You should usually call [Builder.runs] with a well-typed `List<RunPublicDatasetSchema>` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun runs(runs: JsonField<List<RunPublicDatasetSchema>>) = apply { + this.runs = runs.map { it.toMutableList() } + } + + /** + * Adds a single [RunPublicDatasetSchema] to [runs]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRun(run: RunPublicDatasetSchema) = apply { + runs = (runs ?: JsonField.of(mutableListOf())).also { checkKnown("runs", it).add(run) } + } + + fun parsedQuery(parsedQuery: String?) = parsedQuery(JsonField.ofNullable(parsedQuery)) + + /** Alias for calling [Builder.parsedQuery] with `parsedQuery.orElse(null)`. */ + fun parsedQuery(parsedQuery: Optional<String>) = parsedQuery(parsedQuery.getOrNull()) + + /** + * Sets [Builder.parsedQuery] to an arbitrary JSON value. + * + * You should usually call [Builder.parsedQuery] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun parsedQuery(parsedQuery: JsonField<String>) = apply { this.parsedQuery = parsedQuery } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RunQueryResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cursors() + * .runs() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RunQueryResponse = + RunQueryResponse( + checkRequired("cursors", cursors), + checkRequired("runs", runs).map { it.toImmutable() }, + parsedQuery, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RunQueryResponse = apply { + if (validated) { + return@apply + } + + cursors().validate() + runs().forEach { it.validate() } + parsedQuery() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cursors.asKnown().getOrNull()?.validity() ?: 0) + + (runs.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (parsedQuery.asKnown().isPresent) 1 else 0) + + class Cursors + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Cursors]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Cursors]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(cursors: Cursors) = apply { + additionalProperties = cursors.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Cursors]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Cursors = Cursors(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Cursors = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cursors && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Cursors{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunQueryResponse && + cursors == other.cursors && + runs == other.runs && + parsedQuery == other.parsedQuery && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(cursors, runs, parsedQuery, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RunQueryResponse{cursors=$cursors, runs=$runs, parsedQuery=$parsedQuery, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunRetrieveParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunRetrieveParams.kt new file mode 100644 index 00000000..616de682 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunRetrieveParams.kt @@ -0,0 +1,258 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.datasets.runs + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get runs in projects run over a dataset that has been shared. */ +class RunRetrieveParams +private constructor( + private val shareToken: String, + private val runId: String?, + private val excludeS3StoredAttributes: Boolean?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun shareToken(): String = shareToken + + fun runId(): Optional<String> = Optional.ofNullable(runId) + + fun excludeS3StoredAttributes(): Optional<Boolean> = + Optional.ofNullable(excludeS3StoredAttributes) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RunRetrieveParams]. + * + * The following fields are required: + * ```java + * .shareToken() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunRetrieveParams]. */ + class Builder internal constructor() { + + private var shareToken: String? = null + private var runId: String? = null + private var excludeS3StoredAttributes: Boolean? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(runRetrieveParams: RunRetrieveParams) = apply { + shareToken = runRetrieveParams.shareToken + runId = runRetrieveParams.runId + excludeS3StoredAttributes = runRetrieveParams.excludeS3StoredAttributes + additionalHeaders = runRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = runRetrieveParams.additionalQueryParams.toBuilder() + } + + fun shareToken(shareToken: String) = apply { this.shareToken = shareToken } + + fun runId(runId: String?) = apply { this.runId = runId } + + /** Alias for calling [Builder.runId] with `runId.orElse(null)`. */ + fun runId(runId: Optional<String>) = runId(runId.getOrNull()) + + fun excludeS3StoredAttributes(excludeS3StoredAttributes: Boolean?) = apply { + this.excludeS3StoredAttributes = excludeS3StoredAttributes + } + + /** + * Alias for [Builder.excludeS3StoredAttributes]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun excludeS3StoredAttributes(excludeS3StoredAttributes: Boolean) = + excludeS3StoredAttributes(excludeS3StoredAttributes as Boolean?) + + /** + * Alias for calling [Builder.excludeS3StoredAttributes] with + * `excludeS3StoredAttributes.orElse(null)`. + */ + fun excludeS3StoredAttributes(excludeS3StoredAttributes: Optional<Boolean>) = + excludeS3StoredAttributes(excludeS3StoredAttributes.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RunRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .shareToken() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RunRetrieveParams = + RunRetrieveParams( + checkRequired("shareToken", shareToken), + runId, + excludeS3StoredAttributes, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> shareToken + 1 -> runId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + excludeS3StoredAttributes?.let { + put("exclude_s3_stored_attributes", it.toString()) + } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunRetrieveParams && + shareToken == other.shareToken && + runId == other.runId && + excludeS3StoredAttributes == other.excludeS3StoredAttributes && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + shareToken, + runId, + excludeS3StoredAttributes, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "RunRetrieveParams{shareToken=$shareToken, runId=$runId, excludeS3StoredAttributes=$excludeS3StoredAttributes, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunStats.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunStats.kt new file mode 100644 index 00000000..37315e55 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunStats.kt @@ -0,0 +1,1307 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.datasets.runs + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class RunStats +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val completionCost: JsonField<String>, + private val completionCostDetails: JsonValue, + private val completionTokenDetails: JsonValue, + private val completionTokens: JsonField<Long>, + private val completionTokensP50: JsonField<Long>, + private val completionTokensP99: JsonField<Long>, + private val costP50: JsonField<String>, + private val costP99: JsonField<String>, + private val errorRate: JsonField<Double>, + private val feedbackStats: JsonValue, + private val firstTokenP50: JsonField<Double>, + private val firstTokenP99: JsonField<Double>, + private val lastRunStartTime: JsonField<OffsetDateTime>, + private val latencyP50: JsonField<Double>, + private val latencyP99: JsonField<Double>, + private val medianTokens: JsonField<Long>, + private val promptCost: JsonField<String>, + private val promptCostDetails: JsonValue, + private val promptTokenDetails: JsonValue, + private val promptTokens: JsonField<Long>, + private val promptTokensP50: JsonField<Long>, + private val promptTokensP99: JsonField<Long>, + private val runCount: JsonField<Long>, + private val runFacets: JsonField<List<JsonValue>>, + private val streamingRate: JsonField<Double>, + private val tokensP99: JsonField<Long>, + private val totalCost: JsonField<String>, + private val totalTokens: JsonField<Long>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("completion_cost") + @ExcludeMissing + completionCost: JsonField<String> = JsonMissing.of(), + @JsonProperty("completion_cost_details") + @ExcludeMissing + completionCostDetails: JsonValue = JsonMissing.of(), + @JsonProperty("completion_token_details") + @ExcludeMissing + completionTokenDetails: JsonValue = JsonMissing.of(), + @JsonProperty("completion_tokens") + @ExcludeMissing + completionTokens: JsonField<Long> = JsonMissing.of(), + @JsonProperty("completion_tokens_p50") + @ExcludeMissing + completionTokensP50: JsonField<Long> = JsonMissing.of(), + @JsonProperty("completion_tokens_p99") + @ExcludeMissing + completionTokensP99: JsonField<Long> = JsonMissing.of(), + @JsonProperty("cost_p50") @ExcludeMissing costP50: JsonField<String> = JsonMissing.of(), + @JsonProperty("cost_p99") @ExcludeMissing costP99: JsonField<String> = JsonMissing.of(), + @JsonProperty("error_rate") @ExcludeMissing errorRate: JsonField<Double> = JsonMissing.of(), + @JsonProperty("feedback_stats") @ExcludeMissing feedbackStats: JsonValue = JsonMissing.of(), + @JsonProperty("first_token_p50") + @ExcludeMissing + firstTokenP50: JsonField<Double> = JsonMissing.of(), + @JsonProperty("first_token_p99") + @ExcludeMissing + firstTokenP99: JsonField<Double> = JsonMissing.of(), + @JsonProperty("last_run_start_time") + @ExcludeMissing + lastRunStartTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("latency_p50") + @ExcludeMissing + latencyP50: JsonField<Double> = JsonMissing.of(), + @JsonProperty("latency_p99") + @ExcludeMissing + latencyP99: JsonField<Double> = JsonMissing.of(), + @JsonProperty("median_tokens") + @ExcludeMissing + medianTokens: JsonField<Long> = JsonMissing.of(), + @JsonProperty("prompt_cost") + @ExcludeMissing + promptCost: JsonField<String> = JsonMissing.of(), + @JsonProperty("prompt_cost_details") + @ExcludeMissing + promptCostDetails: JsonValue = JsonMissing.of(), + @JsonProperty("prompt_token_details") + @ExcludeMissing + promptTokenDetails: JsonValue = JsonMissing.of(), + @JsonProperty("prompt_tokens") + @ExcludeMissing + promptTokens: JsonField<Long> = JsonMissing.of(), + @JsonProperty("prompt_tokens_p50") + @ExcludeMissing + promptTokensP50: JsonField<Long> = JsonMissing.of(), + @JsonProperty("prompt_tokens_p99") + @ExcludeMissing + promptTokensP99: JsonField<Long> = JsonMissing.of(), + @JsonProperty("run_count") @ExcludeMissing runCount: JsonField<Long> = JsonMissing.of(), + @JsonProperty("run_facets") + @ExcludeMissing + runFacets: JsonField<List<JsonValue>> = JsonMissing.of(), + @JsonProperty("streaming_rate") + @ExcludeMissing + streamingRate: JsonField<Double> = JsonMissing.of(), + @JsonProperty("tokens_p99") @ExcludeMissing tokensP99: JsonField<Long> = JsonMissing.of(), + @JsonProperty("total_cost") @ExcludeMissing totalCost: JsonField<String> = JsonMissing.of(), + @JsonProperty("total_tokens") + @ExcludeMissing + totalTokens: JsonField<Long> = JsonMissing.of(), + ) : this( + completionCost, + completionCostDetails, + completionTokenDetails, + completionTokens, + completionTokensP50, + completionTokensP99, + costP50, + costP99, + errorRate, + feedbackStats, + firstTokenP50, + firstTokenP99, + lastRunStartTime, + latencyP50, + latencyP99, + medianTokens, + promptCost, + promptCostDetails, + promptTokenDetails, + promptTokens, + promptTokensP50, + promptTokensP99, + runCount, + runFacets, + streamingRate, + tokensP99, + totalCost, + totalTokens, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun completionCost(): Optional<String> = completionCost.getOptional("completion_cost") + + @JsonProperty("completion_cost_details") + @ExcludeMissing + fun _completionCostDetails(): JsonValue = completionCostDetails + + @JsonProperty("completion_token_details") + @ExcludeMissing + fun _completionTokenDetails(): JsonValue = completionTokenDetails + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun completionTokens(): Optional<Long> = completionTokens.getOptional("completion_tokens") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun completionTokensP50(): Optional<Long> = + completionTokensP50.getOptional("completion_tokens_p50") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun completionTokensP99(): Optional<Long> = + completionTokensP99.getOptional("completion_tokens_p99") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun costP50(): Optional<String> = costP50.getOptional("cost_p50") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun costP99(): Optional<String> = costP99.getOptional("cost_p99") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun errorRate(): Optional<Double> = errorRate.getOptional("error_rate") + + @JsonProperty("feedback_stats") @ExcludeMissing fun _feedbackStats(): JsonValue = feedbackStats + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun firstTokenP50(): Optional<Double> = firstTokenP50.getOptional("first_token_p50") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun firstTokenP99(): Optional<Double> = firstTokenP99.getOptional("first_token_p99") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun lastRunStartTime(): Optional<OffsetDateTime> = + lastRunStartTime.getOptional("last_run_start_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun latencyP50(): Optional<Double> = latencyP50.getOptional("latency_p50") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun latencyP99(): Optional<Double> = latencyP99.getOptional("latency_p99") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun medianTokens(): Optional<Long> = medianTokens.getOptional("median_tokens") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun promptCost(): Optional<String> = promptCost.getOptional("prompt_cost") + + @JsonProperty("prompt_cost_details") + @ExcludeMissing + fun _promptCostDetails(): JsonValue = promptCostDetails + + @JsonProperty("prompt_token_details") + @ExcludeMissing + fun _promptTokenDetails(): JsonValue = promptTokenDetails + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun promptTokens(): Optional<Long> = promptTokens.getOptional("prompt_tokens") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun promptTokensP50(): Optional<Long> = promptTokensP50.getOptional("prompt_tokens_p50") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun promptTokensP99(): Optional<Long> = promptTokensP99.getOptional("prompt_tokens_p99") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun runCount(): Optional<Long> = runCount.getOptional("run_count") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun runFacets(): Optional<List<JsonValue>> = runFacets.getOptional("run_facets") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun streamingRate(): Optional<Double> = streamingRate.getOptional("streaming_rate") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tokensP99(): Optional<Long> = tokensP99.getOptional("tokens_p99") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun totalCost(): Optional<String> = totalCost.getOptional("total_cost") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun totalTokens(): Optional<Long> = totalTokens.getOptional("total_tokens") + + /** + * Returns the raw JSON value of [completionCost]. + * + * Unlike [completionCost], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("completion_cost") + @ExcludeMissing + fun _completionCost(): JsonField<String> = completionCost + + /** + * Returns the raw JSON value of [completionTokens]. + * + * Unlike [completionTokens], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("completion_tokens") + @ExcludeMissing + fun _completionTokens(): JsonField<Long> = completionTokens + + /** + * Returns the raw JSON value of [completionTokensP50]. + * + * Unlike [completionTokensP50], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("completion_tokens_p50") + @ExcludeMissing + fun _completionTokensP50(): JsonField<Long> = completionTokensP50 + + /** + * Returns the raw JSON value of [completionTokensP99]. + * + * Unlike [completionTokensP99], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("completion_tokens_p99") + @ExcludeMissing + fun _completionTokensP99(): JsonField<Long> = completionTokensP99 + + /** + * Returns the raw JSON value of [costP50]. + * + * Unlike [costP50], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cost_p50") @ExcludeMissing fun _costP50(): JsonField<String> = costP50 + + /** + * Returns the raw JSON value of [costP99]. + * + * Unlike [costP99], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cost_p99") @ExcludeMissing fun _costP99(): JsonField<String> = costP99 + + /** + * Returns the raw JSON value of [errorRate]. + * + * Unlike [errorRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("error_rate") @ExcludeMissing fun _errorRate(): JsonField<Double> = errorRate + + /** + * Returns the raw JSON value of [firstTokenP50]. + * + * Unlike [firstTokenP50], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("first_token_p50") + @ExcludeMissing + fun _firstTokenP50(): JsonField<Double> = firstTokenP50 + + /** + * Returns the raw JSON value of [firstTokenP99]. + * + * Unlike [firstTokenP99], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("first_token_p99") + @ExcludeMissing + fun _firstTokenP99(): JsonField<Double> = firstTokenP99 + + /** + * Returns the raw JSON value of [lastRunStartTime]. + * + * Unlike [lastRunStartTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("last_run_start_time") + @ExcludeMissing + fun _lastRunStartTime(): JsonField<OffsetDateTime> = lastRunStartTime + + /** + * Returns the raw JSON value of [latencyP50]. + * + * Unlike [latencyP50], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("latency_p50") @ExcludeMissing fun _latencyP50(): JsonField<Double> = latencyP50 + + /** + * Returns the raw JSON value of [latencyP99]. + * + * Unlike [latencyP99], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("latency_p99") @ExcludeMissing fun _latencyP99(): JsonField<Double> = latencyP99 + + /** + * Returns the raw JSON value of [medianTokens]. + * + * Unlike [medianTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("median_tokens") + @ExcludeMissing + fun _medianTokens(): JsonField<Long> = medianTokens + + /** + * Returns the raw JSON value of [promptCost]. + * + * Unlike [promptCost], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prompt_cost") @ExcludeMissing fun _promptCost(): JsonField<String> = promptCost + + /** + * Returns the raw JSON value of [promptTokens]. + * + * Unlike [promptTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prompt_tokens") + @ExcludeMissing + fun _promptTokens(): JsonField<Long> = promptTokens + + /** + * Returns the raw JSON value of [promptTokensP50]. + * + * Unlike [promptTokensP50], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prompt_tokens_p50") + @ExcludeMissing + fun _promptTokensP50(): JsonField<Long> = promptTokensP50 + + /** + * Returns the raw JSON value of [promptTokensP99]. + * + * Unlike [promptTokensP99], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prompt_tokens_p99") + @ExcludeMissing + fun _promptTokensP99(): JsonField<Long> = promptTokensP99 + + /** + * Returns the raw JSON value of [runCount]. + * + * Unlike [runCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_count") @ExcludeMissing fun _runCount(): JsonField<Long> = runCount + + /** + * Returns the raw JSON value of [runFacets]. + * + * Unlike [runFacets], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_facets") + @ExcludeMissing + fun _runFacets(): JsonField<List<JsonValue>> = runFacets + + /** + * Returns the raw JSON value of [streamingRate]. + * + * Unlike [streamingRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("streaming_rate") + @ExcludeMissing + fun _streamingRate(): JsonField<Double> = streamingRate + + /** + * Returns the raw JSON value of [tokensP99]. + * + * Unlike [tokensP99], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tokens_p99") @ExcludeMissing fun _tokensP99(): JsonField<Long> = tokensP99 + + /** + * Returns the raw JSON value of [totalCost]. + * + * Unlike [totalCost], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total_cost") @ExcludeMissing fun _totalCost(): JsonField<String> = totalCost + + /** + * Returns the raw JSON value of [totalTokens]. + * + * Unlike [totalTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total_tokens") @ExcludeMissing fun _totalTokens(): JsonField<Long> = totalTokens + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [RunStats]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunStats]. */ + class Builder internal constructor() { + + private var completionCost: JsonField<String> = JsonMissing.of() + private var completionCostDetails: JsonValue = JsonMissing.of() + private var completionTokenDetails: JsonValue = JsonMissing.of() + private var completionTokens: JsonField<Long> = JsonMissing.of() + private var completionTokensP50: JsonField<Long> = JsonMissing.of() + private var completionTokensP99: JsonField<Long> = JsonMissing.of() + private var costP50: JsonField<String> = JsonMissing.of() + private var costP99: JsonField<String> = JsonMissing.of() + private var errorRate: JsonField<Double> = JsonMissing.of() + private var feedbackStats: JsonValue = JsonMissing.of() + private var firstTokenP50: JsonField<Double> = JsonMissing.of() + private var firstTokenP99: JsonField<Double> = JsonMissing.of() + private var lastRunStartTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var latencyP50: JsonField<Double> = JsonMissing.of() + private var latencyP99: JsonField<Double> = JsonMissing.of() + private var medianTokens: JsonField<Long> = JsonMissing.of() + private var promptCost: JsonField<String> = JsonMissing.of() + private var promptCostDetails: JsonValue = JsonMissing.of() + private var promptTokenDetails: JsonValue = JsonMissing.of() + private var promptTokens: JsonField<Long> = JsonMissing.of() + private var promptTokensP50: JsonField<Long> = JsonMissing.of() + private var promptTokensP99: JsonField<Long> = JsonMissing.of() + private var runCount: JsonField<Long> = JsonMissing.of() + private var runFacets: JsonField<MutableList<JsonValue>>? = null + private var streamingRate: JsonField<Double> = JsonMissing.of() + private var tokensP99: JsonField<Long> = JsonMissing.of() + private var totalCost: JsonField<String> = JsonMissing.of() + private var totalTokens: JsonField<Long> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(runStats: RunStats) = apply { + completionCost = runStats.completionCost + completionCostDetails = runStats.completionCostDetails + completionTokenDetails = runStats.completionTokenDetails + completionTokens = runStats.completionTokens + completionTokensP50 = runStats.completionTokensP50 + completionTokensP99 = runStats.completionTokensP99 + costP50 = runStats.costP50 + costP99 = runStats.costP99 + errorRate = runStats.errorRate + feedbackStats = runStats.feedbackStats + firstTokenP50 = runStats.firstTokenP50 + firstTokenP99 = runStats.firstTokenP99 + lastRunStartTime = runStats.lastRunStartTime + latencyP50 = runStats.latencyP50 + latencyP99 = runStats.latencyP99 + medianTokens = runStats.medianTokens + promptCost = runStats.promptCost + promptCostDetails = runStats.promptCostDetails + promptTokenDetails = runStats.promptTokenDetails + promptTokens = runStats.promptTokens + promptTokensP50 = runStats.promptTokensP50 + promptTokensP99 = runStats.promptTokensP99 + runCount = runStats.runCount + runFacets = runStats.runFacets.map { it.toMutableList() } + streamingRate = runStats.streamingRate + tokensP99 = runStats.tokensP99 + totalCost = runStats.totalCost + totalTokens = runStats.totalTokens + additionalProperties = runStats.additionalProperties.toMutableMap() + } + + fun completionCost(completionCost: String?) = + completionCost(JsonField.ofNullable(completionCost)) + + /** Alias for calling [Builder.completionCost] with `completionCost.orElse(null)`. */ + fun completionCost(completionCost: Optional<String>) = + completionCost(completionCost.getOrNull()) + + /** + * Sets [Builder.completionCost] to an arbitrary JSON value. + * + * You should usually call [Builder.completionCost] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun completionCost(completionCost: JsonField<String>) = apply { + this.completionCost = completionCost + } + + fun completionCostDetails(completionCostDetails: JsonValue) = apply { + this.completionCostDetails = completionCostDetails + } + + fun completionTokenDetails(completionTokenDetails: JsonValue) = apply { + this.completionTokenDetails = completionTokenDetails + } + + fun completionTokens(completionTokens: Long?) = + completionTokens(JsonField.ofNullable(completionTokens)) + + /** + * Alias for [Builder.completionTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun completionTokens(completionTokens: Long) = completionTokens(completionTokens as Long?) + + /** Alias for calling [Builder.completionTokens] with `completionTokens.orElse(null)`. */ + fun completionTokens(completionTokens: Optional<Long>) = + completionTokens(completionTokens.getOrNull()) + + /** + * Sets [Builder.completionTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.completionTokens] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun completionTokens(completionTokens: JsonField<Long>) = apply { + this.completionTokens = completionTokens + } + + fun completionTokensP50(completionTokensP50: Long?) = + completionTokensP50(JsonField.ofNullable(completionTokensP50)) + + /** + * Alias for [Builder.completionTokensP50]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun completionTokensP50(completionTokensP50: Long) = + completionTokensP50(completionTokensP50 as Long?) + + /** + * Alias for calling [Builder.completionTokensP50] with `completionTokensP50.orElse(null)`. + */ + fun completionTokensP50(completionTokensP50: Optional<Long>) = + completionTokensP50(completionTokensP50.getOrNull()) + + /** + * Sets [Builder.completionTokensP50] to an arbitrary JSON value. + * + * You should usually call [Builder.completionTokensP50] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun completionTokensP50(completionTokensP50: JsonField<Long>) = apply { + this.completionTokensP50 = completionTokensP50 + } + + fun completionTokensP99(completionTokensP99: Long?) = + completionTokensP99(JsonField.ofNullable(completionTokensP99)) + + /** + * Alias for [Builder.completionTokensP99]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun completionTokensP99(completionTokensP99: Long) = + completionTokensP99(completionTokensP99 as Long?) + + /** + * Alias for calling [Builder.completionTokensP99] with `completionTokensP99.orElse(null)`. + */ + fun completionTokensP99(completionTokensP99: Optional<Long>) = + completionTokensP99(completionTokensP99.getOrNull()) + + /** + * Sets [Builder.completionTokensP99] to an arbitrary JSON value. + * + * You should usually call [Builder.completionTokensP99] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun completionTokensP99(completionTokensP99: JsonField<Long>) = apply { + this.completionTokensP99 = completionTokensP99 + } + + fun costP50(costP50: String?) = costP50(JsonField.ofNullable(costP50)) + + /** Alias for calling [Builder.costP50] with `costP50.orElse(null)`. */ + fun costP50(costP50: Optional<String>) = costP50(costP50.getOrNull()) + + /** + * Sets [Builder.costP50] to an arbitrary JSON value. + * + * You should usually call [Builder.costP50] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun costP50(costP50: JsonField<String>) = apply { this.costP50 = costP50 } + + fun costP99(costP99: String?) = costP99(JsonField.ofNullable(costP99)) + + /** Alias for calling [Builder.costP99] with `costP99.orElse(null)`. */ + fun costP99(costP99: Optional<String>) = costP99(costP99.getOrNull()) + + /** + * Sets [Builder.costP99] to an arbitrary JSON value. + * + * You should usually call [Builder.costP99] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun costP99(costP99: JsonField<String>) = apply { this.costP99 = costP99 } + + fun errorRate(errorRate: Double?) = errorRate(JsonField.ofNullable(errorRate)) + + /** + * Alias for [Builder.errorRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun errorRate(errorRate: Double) = errorRate(errorRate as Double?) + + /** Alias for calling [Builder.errorRate] with `errorRate.orElse(null)`. */ + fun errorRate(errorRate: Optional<Double>) = errorRate(errorRate.getOrNull()) + + /** + * Sets [Builder.errorRate] to an arbitrary JSON value. + * + * You should usually call [Builder.errorRate] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun errorRate(errorRate: JsonField<Double>) = apply { this.errorRate = errorRate } + + fun feedbackStats(feedbackStats: JsonValue) = apply { this.feedbackStats = feedbackStats } + + fun firstTokenP50(firstTokenP50: Double?) = + firstTokenP50(JsonField.ofNullable(firstTokenP50)) + + /** + * Alias for [Builder.firstTokenP50]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun firstTokenP50(firstTokenP50: Double) = firstTokenP50(firstTokenP50 as Double?) + + /** Alias for calling [Builder.firstTokenP50] with `firstTokenP50.orElse(null)`. */ + fun firstTokenP50(firstTokenP50: Optional<Double>) = + firstTokenP50(firstTokenP50.getOrNull()) + + /** + * Sets [Builder.firstTokenP50] to an arbitrary JSON value. + * + * You should usually call [Builder.firstTokenP50] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun firstTokenP50(firstTokenP50: JsonField<Double>) = apply { + this.firstTokenP50 = firstTokenP50 + } + + fun firstTokenP99(firstTokenP99: Double?) = + firstTokenP99(JsonField.ofNullable(firstTokenP99)) + + /** + * Alias for [Builder.firstTokenP99]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun firstTokenP99(firstTokenP99: Double) = firstTokenP99(firstTokenP99 as Double?) + + /** Alias for calling [Builder.firstTokenP99] with `firstTokenP99.orElse(null)`. */ + fun firstTokenP99(firstTokenP99: Optional<Double>) = + firstTokenP99(firstTokenP99.getOrNull()) + + /** + * Sets [Builder.firstTokenP99] to an arbitrary JSON value. + * + * You should usually call [Builder.firstTokenP99] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun firstTokenP99(firstTokenP99: JsonField<Double>) = apply { + this.firstTokenP99 = firstTokenP99 + } + + fun lastRunStartTime(lastRunStartTime: OffsetDateTime?) = + lastRunStartTime(JsonField.ofNullable(lastRunStartTime)) + + /** Alias for calling [Builder.lastRunStartTime] with `lastRunStartTime.orElse(null)`. */ + fun lastRunStartTime(lastRunStartTime: Optional<OffsetDateTime>) = + lastRunStartTime(lastRunStartTime.getOrNull()) + + /** + * Sets [Builder.lastRunStartTime] to an arbitrary JSON value. + * + * You should usually call [Builder.lastRunStartTime] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun lastRunStartTime(lastRunStartTime: JsonField<OffsetDateTime>) = apply { + this.lastRunStartTime = lastRunStartTime + } + + fun latencyP50(latencyP50: Double?) = latencyP50(JsonField.ofNullable(latencyP50)) + + /** + * Alias for [Builder.latencyP50]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun latencyP50(latencyP50: Double) = latencyP50(latencyP50 as Double?) + + /** Alias for calling [Builder.latencyP50] with `latencyP50.orElse(null)`. */ + fun latencyP50(latencyP50: Optional<Double>) = latencyP50(latencyP50.getOrNull()) + + /** + * Sets [Builder.latencyP50] to an arbitrary JSON value. + * + * You should usually call [Builder.latencyP50] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun latencyP50(latencyP50: JsonField<Double>) = apply { this.latencyP50 = latencyP50 } + + fun latencyP99(latencyP99: Double?) = latencyP99(JsonField.ofNullable(latencyP99)) + + /** + * Alias for [Builder.latencyP99]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun latencyP99(latencyP99: Double) = latencyP99(latencyP99 as Double?) + + /** Alias for calling [Builder.latencyP99] with `latencyP99.orElse(null)`. */ + fun latencyP99(latencyP99: Optional<Double>) = latencyP99(latencyP99.getOrNull()) + + /** + * Sets [Builder.latencyP99] to an arbitrary JSON value. + * + * You should usually call [Builder.latencyP99] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun latencyP99(latencyP99: JsonField<Double>) = apply { this.latencyP99 = latencyP99 } + + fun medianTokens(medianTokens: Long?) = medianTokens(JsonField.ofNullable(medianTokens)) + + /** + * Alias for [Builder.medianTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun medianTokens(medianTokens: Long) = medianTokens(medianTokens as Long?) + + /** Alias for calling [Builder.medianTokens] with `medianTokens.orElse(null)`. */ + fun medianTokens(medianTokens: Optional<Long>) = medianTokens(medianTokens.getOrNull()) + + /** + * Sets [Builder.medianTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.medianTokens] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun medianTokens(medianTokens: JsonField<Long>) = apply { this.medianTokens = medianTokens } + + fun promptCost(promptCost: String?) = promptCost(JsonField.ofNullable(promptCost)) + + /** Alias for calling [Builder.promptCost] with `promptCost.orElse(null)`. */ + fun promptCost(promptCost: Optional<String>) = promptCost(promptCost.getOrNull()) + + /** + * Sets [Builder.promptCost] to an arbitrary JSON value. + * + * You should usually call [Builder.promptCost] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun promptCost(promptCost: JsonField<String>) = apply { this.promptCost = promptCost } + + fun promptCostDetails(promptCostDetails: JsonValue) = apply { + this.promptCostDetails = promptCostDetails + } + + fun promptTokenDetails(promptTokenDetails: JsonValue) = apply { + this.promptTokenDetails = promptTokenDetails + } + + fun promptTokens(promptTokens: Long?) = promptTokens(JsonField.ofNullable(promptTokens)) + + /** + * Alias for [Builder.promptTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun promptTokens(promptTokens: Long) = promptTokens(promptTokens as Long?) + + /** Alias for calling [Builder.promptTokens] with `promptTokens.orElse(null)`. */ + fun promptTokens(promptTokens: Optional<Long>) = promptTokens(promptTokens.getOrNull()) + + /** + * Sets [Builder.promptTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.promptTokens] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun promptTokens(promptTokens: JsonField<Long>) = apply { this.promptTokens = promptTokens } + + fun promptTokensP50(promptTokensP50: Long?) = + promptTokensP50(JsonField.ofNullable(promptTokensP50)) + + /** + * Alias for [Builder.promptTokensP50]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun promptTokensP50(promptTokensP50: Long) = promptTokensP50(promptTokensP50 as Long?) + + /** Alias for calling [Builder.promptTokensP50] with `promptTokensP50.orElse(null)`. */ + fun promptTokensP50(promptTokensP50: Optional<Long>) = + promptTokensP50(promptTokensP50.getOrNull()) + + /** + * Sets [Builder.promptTokensP50] to an arbitrary JSON value. + * + * You should usually call [Builder.promptTokensP50] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun promptTokensP50(promptTokensP50: JsonField<Long>) = apply { + this.promptTokensP50 = promptTokensP50 + } + + fun promptTokensP99(promptTokensP99: Long?) = + promptTokensP99(JsonField.ofNullable(promptTokensP99)) + + /** + * Alias for [Builder.promptTokensP99]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun promptTokensP99(promptTokensP99: Long) = promptTokensP99(promptTokensP99 as Long?) + + /** Alias for calling [Builder.promptTokensP99] with `promptTokensP99.orElse(null)`. */ + fun promptTokensP99(promptTokensP99: Optional<Long>) = + promptTokensP99(promptTokensP99.getOrNull()) + + /** + * Sets [Builder.promptTokensP99] to an arbitrary JSON value. + * + * You should usually call [Builder.promptTokensP99] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun promptTokensP99(promptTokensP99: JsonField<Long>) = apply { + this.promptTokensP99 = promptTokensP99 + } + + fun runCount(runCount: Long?) = runCount(JsonField.ofNullable(runCount)) + + /** + * Alias for [Builder.runCount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun runCount(runCount: Long) = runCount(runCount as Long?) + + /** Alias for calling [Builder.runCount] with `runCount.orElse(null)`. */ + fun runCount(runCount: Optional<Long>) = runCount(runCount.getOrNull()) + + /** + * Sets [Builder.runCount] to an arbitrary JSON value. + * + * You should usually call [Builder.runCount] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun runCount(runCount: JsonField<Long>) = apply { this.runCount = runCount } + + fun runFacets(runFacets: List<JsonValue>?) = runFacets(JsonField.ofNullable(runFacets)) + + /** Alias for calling [Builder.runFacets] with `runFacets.orElse(null)`. */ + fun runFacets(runFacets: Optional<List<JsonValue>>) = runFacets(runFacets.getOrNull()) + + /** + * Sets [Builder.runFacets] to an arbitrary JSON value. + * + * You should usually call [Builder.runFacets] with a well-typed `List<JsonValue>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun runFacets(runFacets: JsonField<List<JsonValue>>) = apply { + this.runFacets = runFacets.map { it.toMutableList() } + } + + /** + * Adds a single [JsonValue] to [runFacets]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRunFacet(runFacet: JsonValue) = apply { + runFacets = + (runFacets ?: JsonField.of(mutableListOf())).also { + checkKnown("runFacets", it).add(runFacet) + } + } + + fun streamingRate(streamingRate: Double?) = + streamingRate(JsonField.ofNullable(streamingRate)) + + /** + * Alias for [Builder.streamingRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun streamingRate(streamingRate: Double) = streamingRate(streamingRate as Double?) + + /** Alias for calling [Builder.streamingRate] with `streamingRate.orElse(null)`. */ + fun streamingRate(streamingRate: Optional<Double>) = + streamingRate(streamingRate.getOrNull()) + + /** + * Sets [Builder.streamingRate] to an arbitrary JSON value. + * + * You should usually call [Builder.streamingRate] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun streamingRate(streamingRate: JsonField<Double>) = apply { + this.streamingRate = streamingRate + } + + fun tokensP99(tokensP99: Long?) = tokensP99(JsonField.ofNullable(tokensP99)) + + /** + * Alias for [Builder.tokensP99]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun tokensP99(tokensP99: Long) = tokensP99(tokensP99 as Long?) + + /** Alias for calling [Builder.tokensP99] with `tokensP99.orElse(null)`. */ + fun tokensP99(tokensP99: Optional<Long>) = tokensP99(tokensP99.getOrNull()) + + /** + * Sets [Builder.tokensP99] to an arbitrary JSON value. + * + * You should usually call [Builder.tokensP99] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tokensP99(tokensP99: JsonField<Long>) = apply { this.tokensP99 = tokensP99 } + + fun totalCost(totalCost: String?) = totalCost(JsonField.ofNullable(totalCost)) + + /** Alias for calling [Builder.totalCost] with `totalCost.orElse(null)`. */ + fun totalCost(totalCost: Optional<String>) = totalCost(totalCost.getOrNull()) + + /** + * Sets [Builder.totalCost] to an arbitrary JSON value. + * + * You should usually call [Builder.totalCost] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun totalCost(totalCost: JsonField<String>) = apply { this.totalCost = totalCost } + + fun totalTokens(totalTokens: Long?) = totalTokens(JsonField.ofNullable(totalTokens)) + + /** + * Alias for [Builder.totalTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun totalTokens(totalTokens: Long) = totalTokens(totalTokens as Long?) + + /** Alias for calling [Builder.totalTokens] with `totalTokens.orElse(null)`. */ + fun totalTokens(totalTokens: Optional<Long>) = totalTokens(totalTokens.getOrNull()) + + /** + * Sets [Builder.totalTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.totalTokens] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun totalTokens(totalTokens: JsonField<Long>) = apply { this.totalTokens = totalTokens } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RunStats]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RunStats = + RunStats( + completionCost, + completionCostDetails, + completionTokenDetails, + completionTokens, + completionTokensP50, + completionTokensP99, + costP50, + costP99, + errorRate, + feedbackStats, + firstTokenP50, + firstTokenP99, + lastRunStartTime, + latencyP50, + latencyP99, + medianTokens, + promptCost, + promptCostDetails, + promptTokenDetails, + promptTokens, + promptTokensP50, + promptTokensP99, + runCount, + (runFacets ?: JsonMissing.of()).map { it.toImmutable() }, + streamingRate, + tokensP99, + totalCost, + totalTokens, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RunStats = apply { + if (validated) { + return@apply + } + + completionCost() + completionTokens() + completionTokensP50() + completionTokensP99() + costP50() + costP99() + errorRate() + firstTokenP50() + firstTokenP99() + lastRunStartTime() + latencyP50() + latencyP99() + medianTokens() + promptCost() + promptTokens() + promptTokensP50() + promptTokensP99() + runCount() + runFacets() + streamingRate() + tokensP99() + totalCost() + totalTokens() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (completionCost.asKnown().isPresent) 1 else 0) + + (if (completionTokens.asKnown().isPresent) 1 else 0) + + (if (completionTokensP50.asKnown().isPresent) 1 else 0) + + (if (completionTokensP99.asKnown().isPresent) 1 else 0) + + (if (costP50.asKnown().isPresent) 1 else 0) + + (if (costP99.asKnown().isPresent) 1 else 0) + + (if (errorRate.asKnown().isPresent) 1 else 0) + + (if (firstTokenP50.asKnown().isPresent) 1 else 0) + + (if (firstTokenP99.asKnown().isPresent) 1 else 0) + + (if (lastRunStartTime.asKnown().isPresent) 1 else 0) + + (if (latencyP50.asKnown().isPresent) 1 else 0) + + (if (latencyP99.asKnown().isPresent) 1 else 0) + + (if (medianTokens.asKnown().isPresent) 1 else 0) + + (if (promptCost.asKnown().isPresent) 1 else 0) + + (if (promptTokens.asKnown().isPresent) 1 else 0) + + (if (promptTokensP50.asKnown().isPresent) 1 else 0) + + (if (promptTokensP99.asKnown().isPresent) 1 else 0) + + (if (runCount.asKnown().isPresent) 1 else 0) + + (runFacets.asKnown().getOrNull()?.size ?: 0) + + (if (streamingRate.asKnown().isPresent) 1 else 0) + + (if (tokensP99.asKnown().isPresent) 1 else 0) + + (if (totalCost.asKnown().isPresent) 1 else 0) + + (if (totalTokens.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunStats && + completionCost == other.completionCost && + completionCostDetails == other.completionCostDetails && + completionTokenDetails == other.completionTokenDetails && + completionTokens == other.completionTokens && + completionTokensP50 == other.completionTokensP50 && + completionTokensP99 == other.completionTokensP99 && + costP50 == other.costP50 && + costP99 == other.costP99 && + errorRate == other.errorRate && + feedbackStats == other.feedbackStats && + firstTokenP50 == other.firstTokenP50 && + firstTokenP99 == other.firstTokenP99 && + lastRunStartTime == other.lastRunStartTime && + latencyP50 == other.latencyP50 && + latencyP99 == other.latencyP99 && + medianTokens == other.medianTokens && + promptCost == other.promptCost && + promptCostDetails == other.promptCostDetails && + promptTokenDetails == other.promptTokenDetails && + promptTokens == other.promptTokens && + promptTokensP50 == other.promptTokensP50 && + promptTokensP99 == other.promptTokensP99 && + runCount == other.runCount && + runFacets == other.runFacets && + streamingRate == other.streamingRate && + tokensP99 == other.tokensP99 && + totalCost == other.totalCost && + totalTokens == other.totalTokens && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + completionCost, + completionCostDetails, + completionTokenDetails, + completionTokens, + completionTokensP50, + completionTokensP99, + costP50, + costP99, + errorRate, + feedbackStats, + firstTokenP50, + firstTokenP99, + lastRunStartTime, + latencyP50, + latencyP99, + medianTokens, + promptCost, + promptCostDetails, + promptTokenDetails, + promptTokens, + promptTokensP50, + promptTokensP99, + runCount, + runFacets, + streamingRate, + tokensP99, + totalCost, + totalTokens, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RunStats{completionCost=$completionCost, completionCostDetails=$completionCostDetails, completionTokenDetails=$completionTokenDetails, completionTokens=$completionTokens, completionTokensP50=$completionTokensP50, completionTokensP99=$completionTokensP99, costP50=$costP50, costP99=$costP99, errorRate=$errorRate, feedbackStats=$feedbackStats, firstTokenP50=$firstTokenP50, firstTokenP99=$firstTokenP99, lastRunStartTime=$lastRunStartTime, latencyP50=$latencyP50, latencyP99=$latencyP99, medianTokens=$medianTokens, promptCost=$promptCost, promptCostDetails=$promptCostDetails, promptTokenDetails=$promptTokenDetails, promptTokens=$promptTokens, promptTokensP50=$promptTokensP50, promptTokensP99=$promptTokensP99, runCount=$runCount, runFacets=$runFacets, streamingRate=$streamingRate, tokensP99=$tokensP99, totalCost=$totalCost, totalTokens=$totalTokens, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunStatsParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunStatsParams.kt new file mode 100644 index 00000000..8f1c7e52 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunStatsParams.kt @@ -0,0 +1,227 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.datasets.runs + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.models.api.v1.runs.RunStatsQueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get run stats in projects run over a dataset that has been shared. */ +class RunStatsParams +private constructor( + private val shareToken: String?, + private val runStatsQueryParams: RunStatsQueryParams, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun shareToken(): Optional<String> = Optional.ofNullable(shareToken) + + /** Query params for run stats. */ + fun runStatsQueryParams(): RunStatsQueryParams = runStatsQueryParams + + fun _additionalBodyProperties(): Map<String, JsonValue> = + runStatsQueryParams._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RunStatsParams]. + * + * The following fields are required: + * ```java + * .runStatsQueryParams() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunStatsParams]. */ + class Builder internal constructor() { + + private var shareToken: String? = null + private var runStatsQueryParams: RunStatsQueryParams? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(runStatsParams: RunStatsParams) = apply { + shareToken = runStatsParams.shareToken + runStatsQueryParams = runStatsParams.runStatsQueryParams + additionalHeaders = runStatsParams.additionalHeaders.toBuilder() + additionalQueryParams = runStatsParams.additionalQueryParams.toBuilder() + } + + fun shareToken(shareToken: String?) = apply { this.shareToken = shareToken } + + /** Alias for calling [Builder.shareToken] with `shareToken.orElse(null)`. */ + fun shareToken(shareToken: Optional<String>) = shareToken(shareToken.getOrNull()) + + /** Query params for run stats. */ + fun runStatsQueryParams(runStatsQueryParams: RunStatsQueryParams) = apply { + this.runStatsQueryParams = runStatsQueryParams + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RunStatsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .runStatsQueryParams() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RunStatsParams = + RunStatsParams( + shareToken, + checkRequired("runStatsQueryParams", runStatsQueryParams), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): RunStatsQueryParams = runStatsQueryParams + + fun _pathParam(index: Int): String = + when (index) { + 0 -> shareToken ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunStatsParams && + shareToken == other.shareToken && + runStatsQueryParams == other.runStatsQueryParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(shareToken, runStatsQueryParams, additionalHeaders, additionalQueryParams) + + override fun toString() = + "RunStatsParams{shareToken=$shareToken, runStatsQueryParams=$runStatsQueryParams, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/examples/ExampleListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/examples/ExampleListParams.kt new file mode 100644 index 00000000..f749797a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/examples/ExampleListParams.kt @@ -0,0 +1,427 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.examples + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.models.api.v1.examples.ExampleSelect +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get example by ids or the shared example if not specifed. */ +class ExampleListParams +private constructor( + private val shareToken: String?, + private val id: List<String>?, + private val asOf: AsOf?, + private val filter: String?, + private val limit: Long?, + private val metadata: String?, + private val offset: Long?, + private val select: List<ExampleSelect>?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun shareToken(): Optional<String> = Optional.ofNullable(shareToken) + + fun id(): Optional<List<String>> = Optional.ofNullable(id) + + /** + * Only modifications made on or before this time are included. If None, the latest version of + * the dataset is used. + */ + fun asOf(): Optional<AsOf> = Optional.ofNullable(asOf) + + fun filter(): Optional<String> = Optional.ofNullable(filter) + + fun limit(): Optional<Long> = Optional.ofNullable(limit) + + fun metadata(): Optional<String> = Optional.ofNullable(metadata) + + fun offset(): Optional<Long> = Optional.ofNullable(offset) + + fun select(): Optional<List<ExampleSelect>> = Optional.ofNullable(select) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ExampleListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ExampleListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExampleListParams]. */ + class Builder internal constructor() { + + private var shareToken: String? = null + private var id: MutableList<String>? = null + private var asOf: AsOf? = null + private var filter: String? = null + private var limit: Long? = null + private var metadata: String? = null + private var offset: Long? = null + private var select: MutableList<ExampleSelect>? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(exampleListParams: ExampleListParams) = apply { + shareToken = exampleListParams.shareToken + id = exampleListParams.id?.toMutableList() + asOf = exampleListParams.asOf + filter = exampleListParams.filter + limit = exampleListParams.limit + metadata = exampleListParams.metadata + offset = exampleListParams.offset + select = exampleListParams.select?.toMutableList() + additionalHeaders = exampleListParams.additionalHeaders.toBuilder() + additionalQueryParams = exampleListParams.additionalQueryParams.toBuilder() + } + + fun shareToken(shareToken: String?) = apply { this.shareToken = shareToken } + + /** Alias for calling [Builder.shareToken] with `shareToken.orElse(null)`. */ + fun shareToken(shareToken: Optional<String>) = shareToken(shareToken.getOrNull()) + + fun id(id: List<String>?) = apply { this.id = id?.toMutableList() } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<List<String>>) = id(id.getOrNull()) + + /** + * Adds a single [String] to [Builder.id]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addId(id: String) = apply { this.id = (this.id ?: mutableListOf()).apply { add(id) } } + + /** + * Only modifications made on or before this time are included. If None, the latest version + * of the dataset is used. + */ + fun asOf(asOf: AsOf?) = apply { this.asOf = asOf } + + /** Alias for calling [Builder.asOf] with `asOf.orElse(null)`. */ + fun asOf(asOf: Optional<AsOf>) = asOf(asOf.getOrNull()) + + /** Alias for calling [asOf] with `AsOf.ofOffsetDateTime(offsetDateTime)`. */ + fun asOf(offsetDateTime: OffsetDateTime) = asOf(AsOf.ofOffsetDateTime(offsetDateTime)) + + /** Alias for calling [asOf] with `AsOf.ofString(string)`. */ + fun asOf(string: String) = asOf(AsOf.ofString(string)) + + fun filter(filter: String?) = apply { this.filter = filter } + + /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ + fun filter(filter: Optional<String>) = filter(filter.getOrNull()) + + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional<Long>) = limit(limit.getOrNull()) + + fun metadata(metadata: String?) = apply { this.metadata = metadata } + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional<String>) = metadata(metadata.getOrNull()) + + fun offset(offset: Long?) = apply { this.offset = offset } + + /** + * Alias for [Builder.offset]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun offset(offset: Long) = offset(offset as Long?) + + /** Alias for calling [Builder.offset] with `offset.orElse(null)`. */ + fun offset(offset: Optional<Long>) = offset(offset.getOrNull()) + + fun select(select: List<ExampleSelect>?) = apply { this.select = select?.toMutableList() } + + /** Alias for calling [Builder.select] with `select.orElse(null)`. */ + fun select(select: Optional<List<ExampleSelect>>) = select(select.getOrNull()) + + /** + * Adds a single [ExampleSelect] to [Builder.select]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSelect(select: ExampleSelect) = apply { + this.select = (this.select ?: mutableListOf()).apply { add(select) } + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ExampleListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ExampleListParams = + ExampleListParams( + shareToken, + id?.toImmutable(), + asOf, + filter, + limit, + metadata, + offset, + select?.toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> shareToken ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + id?.let { put("id", it.joinToString(",")) } + asOf?.accept( + object : AsOf.Visitor<Unit> { + override fun visitOffsetDateTime(offsetDateTime: OffsetDateTime) { + put( + "as_of", + DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(offsetDateTime), + ) + } + + override fun visitString(string: String) { + put("as_of", string) + } + } + ) + filter?.let { put("filter", it) } + limit?.let { put("limit", it.toString()) } + metadata?.let { put("metadata", it) } + offset?.let { put("offset", it.toString()) } + select?.let { put("select", it.joinToString(",") { it.toString() }) } + putAll(additionalQueryParams) + } + .build() + + /** + * Only modifications made on or before this time are included. If None, the latest version of + * the dataset is used. + */ + class AsOf + private constructor( + private val offsetDateTime: OffsetDateTime? = null, + private val string: String? = null, + ) { + + fun offsetDateTime(): Optional<OffsetDateTime> = Optional.ofNullable(offsetDateTime) + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun isOffsetDateTime(): Boolean = offsetDateTime != null + + fun isString(): Boolean = string != null + + fun asOffsetDateTime(): OffsetDateTime = offsetDateTime.getOrThrow("offsetDateTime") + + fun asString(): String = string.getOrThrow("string") + + fun <T> accept(visitor: Visitor<T>): T = + when { + offsetDateTime != null -> visitor.visitOffsetDateTime(offsetDateTime) + string != null -> visitor.visitString(string) + else -> throw IllegalStateException("Invalid AsOf") + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AsOf && offsetDateTime == other.offsetDateTime && string == other.string + } + + override fun hashCode(): Int = Objects.hash(offsetDateTime, string) + + override fun toString(): String = + when { + offsetDateTime != null -> "AsOf{offsetDateTime=$offsetDateTime}" + string != null -> "AsOf{string=$string}" + else -> throw IllegalStateException("Invalid AsOf") + } + + companion object { + + @JvmStatic + fun ofOffsetDateTime(offsetDateTime: OffsetDateTime) = + AsOf(offsetDateTime = offsetDateTime) + + @JvmStatic fun ofString(string: String) = AsOf(string = string) + } + + /** An interface that defines how to map each variant of [AsOf] to a value of type [T]. */ + interface Visitor<out T> { + + fun visitOffsetDateTime(offsetDateTime: OffsetDateTime): T + + fun visitString(string: String): T + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExampleListParams && + shareToken == other.shareToken && + id == other.id && + asOf == other.asOf && + filter == other.filter && + limit == other.limit && + metadata == other.metadata && + offset == other.offset && + select == other.select && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + shareToken, + id, + asOf, + filter, + limit, + metadata, + offset, + select, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "ExampleListParams{shareToken=$shareToken, id=$id, asOf=$asOf, filter=$filter, limit=$limit, metadata=$metadata, offset=$offset, select=$select, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/examples/ExampleRetrieveCountParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/examples/ExampleRetrieveCountParams.kt new file mode 100644 index 00000000..f4b55c6d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/examples/ExampleRetrieveCountParams.kt @@ -0,0 +1,363 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.examples + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Count all examples by query params */ +class ExampleRetrieveCountParams +private constructor( + private val shareToken: String?, + private val id: List<String>?, + private val asOf: AsOf?, + private val filter: String?, + private val metadata: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun shareToken(): Optional<String> = Optional.ofNullable(shareToken) + + fun id(): Optional<List<String>> = Optional.ofNullable(id) + + /** + * Only modifications made on or before this time are included. If None, the latest version of + * the dataset is used. + */ + fun asOf(): Optional<AsOf> = Optional.ofNullable(asOf) + + fun filter(): Optional<String> = Optional.ofNullable(filter) + + fun metadata(): Optional<String> = Optional.ofNullable(metadata) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ExampleRetrieveCountParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [ExampleRetrieveCountParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExampleRetrieveCountParams]. */ + class Builder internal constructor() { + + private var shareToken: String? = null + private var id: MutableList<String>? = null + private var asOf: AsOf? = null + private var filter: String? = null + private var metadata: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(exampleRetrieveCountParams: ExampleRetrieveCountParams) = apply { + shareToken = exampleRetrieveCountParams.shareToken + id = exampleRetrieveCountParams.id?.toMutableList() + asOf = exampleRetrieveCountParams.asOf + filter = exampleRetrieveCountParams.filter + metadata = exampleRetrieveCountParams.metadata + additionalHeaders = exampleRetrieveCountParams.additionalHeaders.toBuilder() + additionalQueryParams = exampleRetrieveCountParams.additionalQueryParams.toBuilder() + } + + fun shareToken(shareToken: String?) = apply { this.shareToken = shareToken } + + /** Alias for calling [Builder.shareToken] with `shareToken.orElse(null)`. */ + fun shareToken(shareToken: Optional<String>) = shareToken(shareToken.getOrNull()) + + fun id(id: List<String>?) = apply { this.id = id?.toMutableList() } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<List<String>>) = id(id.getOrNull()) + + /** + * Adds a single [String] to [Builder.id]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addId(id: String) = apply { this.id = (this.id ?: mutableListOf()).apply { add(id) } } + + /** + * Only modifications made on or before this time are included. If None, the latest version + * of the dataset is used. + */ + fun asOf(asOf: AsOf?) = apply { this.asOf = asOf } + + /** Alias for calling [Builder.asOf] with `asOf.orElse(null)`. */ + fun asOf(asOf: Optional<AsOf>) = asOf(asOf.getOrNull()) + + /** Alias for calling [asOf] with `AsOf.ofOffsetDateTime(offsetDateTime)`. */ + fun asOf(offsetDateTime: OffsetDateTime) = asOf(AsOf.ofOffsetDateTime(offsetDateTime)) + + /** Alias for calling [asOf] with `AsOf.ofString(string)`. */ + fun asOf(string: String) = asOf(AsOf.ofString(string)) + + fun filter(filter: String?) = apply { this.filter = filter } + + /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ + fun filter(filter: Optional<String>) = filter(filter.getOrNull()) + + fun metadata(metadata: String?) = apply { this.metadata = metadata } + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional<String>) = metadata(metadata.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ExampleRetrieveCountParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ExampleRetrieveCountParams = + ExampleRetrieveCountParams( + shareToken, + id?.toImmutable(), + asOf, + filter, + metadata, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> shareToken ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + id?.let { put("id", it.joinToString(",")) } + asOf?.accept( + object : AsOf.Visitor<Unit> { + override fun visitOffsetDateTime(offsetDateTime: OffsetDateTime) { + put( + "as_of", + DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(offsetDateTime), + ) + } + + override fun visitString(string: String) { + put("as_of", string) + } + } + ) + filter?.let { put("filter", it) } + metadata?.let { put("metadata", it) } + putAll(additionalQueryParams) + } + .build() + + /** + * Only modifications made on or before this time are included. If None, the latest version of + * the dataset is used. + */ + class AsOf + private constructor( + private val offsetDateTime: OffsetDateTime? = null, + private val string: String? = null, + ) { + + fun offsetDateTime(): Optional<OffsetDateTime> = Optional.ofNullable(offsetDateTime) + + fun string(): Optional<String> = Optional.ofNullable(string) + + fun isOffsetDateTime(): Boolean = offsetDateTime != null + + fun isString(): Boolean = string != null + + fun asOffsetDateTime(): OffsetDateTime = offsetDateTime.getOrThrow("offsetDateTime") + + fun asString(): String = string.getOrThrow("string") + + fun <T> accept(visitor: Visitor<T>): T = + when { + offsetDateTime != null -> visitor.visitOffsetDateTime(offsetDateTime) + string != null -> visitor.visitString(string) + else -> throw IllegalStateException("Invalid AsOf") + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AsOf && offsetDateTime == other.offsetDateTime && string == other.string + } + + override fun hashCode(): Int = Objects.hash(offsetDateTime, string) + + override fun toString(): String = + when { + offsetDateTime != null -> "AsOf{offsetDateTime=$offsetDateTime}" + string != null -> "AsOf{string=$string}" + else -> throw IllegalStateException("Invalid AsOf") + } + + companion object { + + @JvmStatic + fun ofOffsetDateTime(offsetDateTime: OffsetDateTime) = + AsOf(offsetDateTime = offsetDateTime) + + @JvmStatic fun ofString(string: String) = AsOf(string = string) + } + + /** An interface that defines how to map each variant of [AsOf] to a value of type [T]. */ + interface Visitor<out T> { + + fun visitOffsetDateTime(offsetDateTime: OffsetDateTime): T + + fun visitString(string: String): T + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExampleRetrieveCountParams && + shareToken == other.shareToken && + id == other.id && + asOf == other.asOf && + filter == other.filter && + metadata == other.metadata && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + shareToken, + id, + asOf, + filter, + metadata, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "ExampleRetrieveCountParams{shareToken=$shareToken, id=$id, asOf=$asOf, filter=$filter, metadata=$metadata, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/examples/ExampleRunsParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/examples/ExampleRunsParams.kt new file mode 100644 index 00000000..cf39559d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/examples/ExampleRunsParams.kt @@ -0,0 +1,231 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.examples + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.models.api.v1.datasets.runs.QueryExampleSchemaWithRuns +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get examples with associated runs from sessions in a dataset that has been shared. */ +class ExampleRunsParams +private constructor( + private val shareToken: String?, + private val queryExampleSchemaWithRuns: QueryExampleSchemaWithRuns, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun shareToken(): Optional<String> = Optional.ofNullable(shareToken) + + fun queryExampleSchemaWithRuns(): QueryExampleSchemaWithRuns = queryExampleSchemaWithRuns + + fun _additionalBodyProperties(): Map<String, JsonValue> = + queryExampleSchemaWithRuns._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ExampleRunsParams]. + * + * The following fields are required: + * ```java + * .queryExampleSchemaWithRuns() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExampleRunsParams]. */ + class Builder internal constructor() { + + private var shareToken: String? = null + private var queryExampleSchemaWithRuns: QueryExampleSchemaWithRuns? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(exampleRunsParams: ExampleRunsParams) = apply { + shareToken = exampleRunsParams.shareToken + queryExampleSchemaWithRuns = exampleRunsParams.queryExampleSchemaWithRuns + additionalHeaders = exampleRunsParams.additionalHeaders.toBuilder() + additionalQueryParams = exampleRunsParams.additionalQueryParams.toBuilder() + } + + fun shareToken(shareToken: String?) = apply { this.shareToken = shareToken } + + /** Alias for calling [Builder.shareToken] with `shareToken.orElse(null)`. */ + fun shareToken(shareToken: Optional<String>) = shareToken(shareToken.getOrNull()) + + fun queryExampleSchemaWithRuns(queryExampleSchemaWithRuns: QueryExampleSchemaWithRuns) = + apply { + this.queryExampleSchemaWithRuns = queryExampleSchemaWithRuns + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ExampleRunsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .queryExampleSchemaWithRuns() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ExampleRunsParams = + ExampleRunsParams( + shareToken, + checkRequired("queryExampleSchemaWithRuns", queryExampleSchemaWithRuns), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): QueryExampleSchemaWithRuns = queryExampleSchemaWithRuns + + fun _pathParam(index: Int): String = + when (index) { + 0 -> shareToken ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExampleRunsParams && + shareToken == other.shareToken && + queryExampleSchemaWithRuns == other.queryExampleSchemaWithRuns && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + shareToken, + queryExampleSchemaWithRuns, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "ExampleRunsParams{shareToken=$shareToken, queryExampleSchemaWithRuns=$queryExampleSchemaWithRuns, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/examples/ExampleRunsResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/examples/ExampleRunsResponse.kt new file mode 100644 index 00000000..ff9a8fb6 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/examples/ExampleRunsResponse.kt @@ -0,0 +1,700 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.examples + +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 com.langsmith_api.api.core.BaseDeserializer +import com.langsmith_api.api.core.BaseSerializer +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.allMaxBy +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.datasets.runs.ExampleWithRunsCh +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunPublicDatasetSchema +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +@JsonDeserialize(using = ExampleRunsResponse.Deserializer::class) +@JsonSerialize(using = ExampleRunsResponse.Serializer::class) +class ExampleRunsResponse +private constructor( + private val publicExampleWithRuns: List<PublicExampleWithRun>? = null, + private val withRunsChes: List<ExampleWithRunsCh>? = null, + private val _json: JsonValue? = null, +) { + + fun publicExampleWithRuns(): Optional<List<PublicExampleWithRun>> = + Optional.ofNullable(publicExampleWithRuns) + + fun withRunsChes(): Optional<List<ExampleWithRunsCh>> = Optional.ofNullable(withRunsChes) + + fun isPublicExampleWithRuns(): Boolean = publicExampleWithRuns != null + + fun isWithRunsChes(): Boolean = withRunsChes != null + + fun asPublicExampleWithRuns(): List<PublicExampleWithRun> = + publicExampleWithRuns.getOrThrow("publicExampleWithRuns") + + fun asWithRunsChes(): List<ExampleWithRunsCh> = withRunsChes.getOrThrow("withRunsChes") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + publicExampleWithRuns != null -> + visitor.visitPublicExampleWithRuns(publicExampleWithRuns) + withRunsChes != null -> visitor.visitWithRunsChes(withRunsChes) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): ExampleRunsResponse = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitPublicExampleWithRuns( + publicExampleWithRuns: List<PublicExampleWithRun> + ) { + publicExampleWithRuns.forEach { it.validate() } + } + + override fun visitWithRunsChes(withRunsChes: List<ExampleWithRunsCh>) { + withRunsChes.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitPublicExampleWithRuns( + publicExampleWithRuns: List<PublicExampleWithRun> + ) = publicExampleWithRuns.sumOf { it.validity().toInt() } + + override fun visitWithRunsChes(withRunsChes: List<ExampleWithRunsCh>) = + withRunsChes.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExampleRunsResponse && + publicExampleWithRuns == other.publicExampleWithRuns && + withRunsChes == other.withRunsChes + } + + override fun hashCode(): Int = Objects.hash(publicExampleWithRuns, withRunsChes) + + override fun toString(): String = + when { + publicExampleWithRuns != null -> + "ExampleRunsResponse{publicExampleWithRuns=$publicExampleWithRuns}" + withRunsChes != null -> "ExampleRunsResponse{withRunsChes=$withRunsChes}" + _json != null -> "ExampleRunsResponse{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ExampleRunsResponse") + } + + companion object { + + @JvmStatic + fun ofPublicExampleWithRuns(publicExampleWithRuns: List<PublicExampleWithRun>) = + ExampleRunsResponse(publicExampleWithRuns = publicExampleWithRuns.toImmutable()) + + @JvmStatic + fun ofWithRunsChes(withRunsChes: List<ExampleWithRunsCh>) = + ExampleRunsResponse(withRunsChes = withRunsChes.toImmutable()) + } + + /** + * An interface that defines how to map each variant of [ExampleRunsResponse] to a value of type + * [T]. + */ + interface Visitor<out T> { + + fun visitPublicExampleWithRuns(publicExampleWithRuns: List<PublicExampleWithRun>): T + + fun visitWithRunsChes(withRunsChes: List<ExampleWithRunsCh>): T + + /** + * Maps an unknown variant of [ExampleRunsResponse] to a value of type [T]. + * + * An instance of [ExampleRunsResponse] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the SDK is + * on an older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown ExampleRunsResponse: $json") + } + } + + internal class Deserializer : + BaseDeserializer<ExampleRunsResponse>(ExampleRunsResponse::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ExampleRunsResponse { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<List<PublicExampleWithRun>>())?.let { + ExampleRunsResponse(publicExampleWithRuns = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<List<ExampleWithRunsCh>>())?.let { + ExampleRunsResponse(withRunsChes = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with all + // the possible variants (e.g. deserializing from boolean). + 0 -> ExampleRunsResponse(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<ExampleRunsResponse>(ExampleRunsResponse::class) { + + override fun serialize( + value: ExampleRunsResponse, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.publicExampleWithRuns != null -> + generator.writeObject(value.publicExampleWithRuns) + value.withRunsChes != null -> generator.writeObject(value.withRunsChes) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ExampleRunsResponse") + } + } + } + + /** Schema for an example in a publicly-shared dataset with list of runs. */ + class PublicExampleWithRun + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField<String>, + private val datasetId: JsonField<String>, + private val inputs: JsonValue, + private val name: JsonField<String>, + private val runs: JsonField<List<RunPublicDatasetSchema>>, + private val attachmentUrls: JsonValue, + private val createdAt: JsonField<OffsetDateTime>, + private val metadata: JsonValue, + private val modifiedAt: JsonField<OffsetDateTime>, + private val outputs: JsonValue, + private val sourceRunId: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("dataset_id") + @ExcludeMissing + datasetId: JsonField<String> = JsonMissing.of(), + @JsonProperty("inputs") @ExcludeMissing inputs: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("runs") + @ExcludeMissing + runs: JsonField<List<RunPublicDatasetSchema>> = JsonMissing.of(), + @JsonProperty("attachment_urls") + @ExcludeMissing + attachmentUrls: JsonValue = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("modified_at") + @ExcludeMissing + modifiedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("outputs") @ExcludeMissing outputs: JsonValue = JsonMissing.of(), + @JsonProperty("source_run_id") + @ExcludeMissing + sourceRunId: JsonField<String> = JsonMissing.of(), + ) : this( + id, + datasetId, + inputs, + name, + runs, + attachmentUrls, + createdAt, + metadata, + modifiedAt, + outputs, + sourceRunId, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun datasetId(): String = datasetId.getRequired("dataset_id") + + @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonValue = inputs + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun runs(): List<RunPublicDatasetSchema> = runs.getRequired("runs") + + @JsonProperty("attachment_urls") + @ExcludeMissing + fun _attachmentUrls(): JsonValue = attachmentUrls + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun createdAt(): Optional<OffsetDateTime> = createdAt.getOptional("created_at") + + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun modifiedAt(): Optional<OffsetDateTime> = modifiedAt.getOptional("modified_at") + + @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonValue = outputs + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun sourceRunId(): Optional<String> = sourceRunId.getOptional("source_run_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [datasetId]. + * + * Unlike [datasetId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField<String> = datasetId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [runs]. + * + * Unlike [runs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("runs") + @ExcludeMissing + fun _runs(): JsonField<List<RunPublicDatasetSchema>> = runs + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [modifiedAt]. + * + * Unlike [modifiedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("modified_at") + @ExcludeMissing + fun _modifiedAt(): JsonField<OffsetDateTime> = modifiedAt + + /** + * Returns the raw JSON value of [sourceRunId]. + * + * Unlike [sourceRunId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("source_run_id") + @ExcludeMissing + fun _sourceRunId(): JsonField<String> = sourceRunId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PublicExampleWithRun]. + * + * The following fields are required: + * ```java + * .id() + * .datasetId() + * .inputs() + * .name() + * .runs() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PublicExampleWithRun]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var datasetId: JsonField<String>? = null + private var inputs: JsonValue? = null + private var name: JsonField<String>? = null + private var runs: JsonField<MutableList<RunPublicDatasetSchema>>? = null + private var attachmentUrls: JsonValue = JsonMissing.of() + private var createdAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var metadata: JsonValue = JsonMissing.of() + private var modifiedAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var outputs: JsonValue = JsonMissing.of() + private var sourceRunId: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(publicExampleWithRun: PublicExampleWithRun) = apply { + id = publicExampleWithRun.id + datasetId = publicExampleWithRun.datasetId + inputs = publicExampleWithRun.inputs + name = publicExampleWithRun.name + runs = publicExampleWithRun.runs.map { it.toMutableList() } + attachmentUrls = publicExampleWithRun.attachmentUrls + createdAt = publicExampleWithRun.createdAt + metadata = publicExampleWithRun.metadata + modifiedAt = publicExampleWithRun.modifiedAt + outputs = publicExampleWithRun.outputs + sourceRunId = publicExampleWithRun.sourceRunId + additionalProperties = publicExampleWithRun.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun datasetId(datasetId: String) = datasetId(JsonField.of(datasetId)) + + /** + * Sets [Builder.datasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun datasetId(datasetId: JsonField<String>) = apply { this.datasetId = datasetId } + + fun inputs(inputs: JsonValue) = apply { this.inputs = inputs } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun runs(runs: List<RunPublicDatasetSchema>) = runs(JsonField.of(runs)) + + /** + * Sets [Builder.runs] to an arbitrary JSON value. + * + * You should usually call [Builder.runs] with a well-typed + * `List<RunPublicDatasetSchema>` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun runs(runs: JsonField<List<RunPublicDatasetSchema>>) = apply { + this.runs = runs.map { it.toMutableList() } + } + + /** + * Adds a single [RunPublicDatasetSchema] to [runs]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRun(run: RunPublicDatasetSchema) = apply { + runs = + (runs ?: JsonField.of(mutableListOf())).also { checkKnown("runs", it).add(run) } + } + + fun attachmentUrls(attachmentUrls: JsonValue) = apply { + this.attachmentUrls = attachmentUrls + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { + this.createdAt = createdAt + } + + fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + + fun modifiedAt(modifiedAt: OffsetDateTime?) = + modifiedAt(JsonField.ofNullable(modifiedAt)) + + /** Alias for calling [Builder.modifiedAt] with `modifiedAt.orElse(null)`. */ + fun modifiedAt(modifiedAt: Optional<OffsetDateTime>) = + modifiedAt(modifiedAt.getOrNull()) + + /** + * Sets [Builder.modifiedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.modifiedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modifiedAt(modifiedAt: JsonField<OffsetDateTime>) = apply { + this.modifiedAt = modifiedAt + } + + fun outputs(outputs: JsonValue) = apply { this.outputs = outputs } + + fun sourceRunId(sourceRunId: String?) = sourceRunId(JsonField.ofNullable(sourceRunId)) + + /** Alias for calling [Builder.sourceRunId] with `sourceRunId.orElse(null)`. */ + fun sourceRunId(sourceRunId: Optional<String>) = sourceRunId(sourceRunId.getOrNull()) + + /** + * Sets [Builder.sourceRunId] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceRunId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sourceRunId(sourceRunId: JsonField<String>) = apply { + this.sourceRunId = sourceRunId + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PublicExampleWithRun]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .datasetId() + * .inputs() + * .name() + * .runs() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PublicExampleWithRun = + PublicExampleWithRun( + checkRequired("id", id), + checkRequired("datasetId", datasetId), + checkRequired("inputs", inputs), + checkRequired("name", name), + checkRequired("runs", runs).map { it.toImmutable() }, + attachmentUrls, + createdAt, + metadata, + modifiedAt, + outputs, + sourceRunId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PublicExampleWithRun = apply { + if (validated) { + return@apply + } + + id() + datasetId() + name() + runs().forEach { it.validate() } + createdAt() + modifiedAt() + sourceRunId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (datasetId.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (runs.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (modifiedAt.asKnown().isPresent) 1 else 0) + + (if (sourceRunId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PublicExampleWithRun && + id == other.id && + datasetId == other.datasetId && + inputs == other.inputs && + name == other.name && + runs == other.runs && + attachmentUrls == other.attachmentUrls && + createdAt == other.createdAt && + metadata == other.metadata && + modifiedAt == other.modifiedAt && + outputs == other.outputs && + sourceRunId == other.sourceRunId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + datasetId, + inputs, + name, + runs, + attachmentUrls, + createdAt, + metadata, + modifiedAt, + outputs, + sourceRunId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PublicExampleWithRun{id=$id, datasetId=$datasetId, inputs=$inputs, name=$name, runs=$runs, attachmentUrls=$attachmentUrls, createdAt=$createdAt, metadata=$metadata, modifiedAt=$modifiedAt, outputs=$outputs, sourceRunId=$sourceRunId, additionalProperties=$additionalProperties}" + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunListParams.kt new file mode 100644 index 00000000..d55caa47 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunListParams.kt @@ -0,0 +1,234 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.runs + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get the shared run. */ +class RunListParams +private constructor( + private val shareToken: String?, + private val excludeS3StoredAttributes: Boolean?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun shareToken(): Optional<String> = Optional.ofNullable(shareToken) + + fun excludeS3StoredAttributes(): Optional<Boolean> = + Optional.ofNullable(excludeS3StoredAttributes) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): RunListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [RunListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunListParams]. */ + class Builder internal constructor() { + + private var shareToken: String? = null + private var excludeS3StoredAttributes: Boolean? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(runListParams: RunListParams) = apply { + shareToken = runListParams.shareToken + excludeS3StoredAttributes = runListParams.excludeS3StoredAttributes + additionalHeaders = runListParams.additionalHeaders.toBuilder() + additionalQueryParams = runListParams.additionalQueryParams.toBuilder() + } + + fun shareToken(shareToken: String?) = apply { this.shareToken = shareToken } + + /** Alias for calling [Builder.shareToken] with `shareToken.orElse(null)`. */ + fun shareToken(shareToken: Optional<String>) = shareToken(shareToken.getOrNull()) + + fun excludeS3StoredAttributes(excludeS3StoredAttributes: Boolean?) = apply { + this.excludeS3StoredAttributes = excludeS3StoredAttributes + } + + /** + * Alias for [Builder.excludeS3StoredAttributes]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun excludeS3StoredAttributes(excludeS3StoredAttributes: Boolean) = + excludeS3StoredAttributes(excludeS3StoredAttributes as Boolean?) + + /** + * Alias for calling [Builder.excludeS3StoredAttributes] with + * `excludeS3StoredAttributes.orElse(null)`. + */ + fun excludeS3StoredAttributes(excludeS3StoredAttributes: Optional<Boolean>) = + excludeS3StoredAttributes(excludeS3StoredAttributes.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RunListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RunListParams = + RunListParams( + shareToken, + excludeS3StoredAttributes, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> shareToken ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + excludeS3StoredAttributes?.let { + put("exclude_s3_stored_attributes", it.toString()) + } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunListParams && + shareToken == other.shareToken && + excludeS3StoredAttributes == other.excludeS3StoredAttributes && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + shareToken, + excludeS3StoredAttributes, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "RunListParams{shareToken=$shareToken, excludeS3StoredAttributes=$excludeS3StoredAttributes, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunPublicSchema.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunPublicSchema.kt new file mode 100644 index 00000000..2ddfc48c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunPublicSchema.kt @@ -0,0 +1,2311 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.runs + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.runs.RunTypeEnum +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class RunPublicSchema +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val dottedOrder: JsonField<String>, + private val name: JsonField<String>, + private val runType: JsonField<RunTypeEnum>, + private val status: JsonField<String>, + private val traceId: JsonField<String>, + private val childRunIds: JsonField<List<String>>, + private val completionCost: JsonField<String>, + private val completionCostDetails: JsonField<CompletionCostDetails>, + private val completionTokenDetails: JsonField<CompletionTokenDetails>, + private val completionTokens: JsonField<Long>, + private val directChildRunIds: JsonField<List<String>>, + private val endTime: JsonField<OffsetDateTime>, + private val error: JsonField<String>, + private val events: JsonField<List<JsonValue>>, + private val executionOrder: JsonField<Long>, + private val extra: JsonValue, + private val feedbackStats: JsonField<FeedbackStats>, + private val firstTokenTime: JsonField<OffsetDateTime>, + private val inputs: JsonValue, + private val inputsPreview: JsonField<String>, + private val inputsS3Urls: JsonValue, + private val manifestId: JsonField<String>, + private val manifestS3Id: JsonField<String>, + private val outputs: JsonValue, + private val outputsPreview: JsonField<String>, + private val outputsS3Urls: JsonValue, + private val parentRunId: JsonField<String>, + private val parentRunIds: JsonField<List<String>>, + private val priceModelId: JsonField<String>, + private val promptCost: JsonField<String>, + private val promptCostDetails: JsonField<PromptCostDetails>, + private val promptTokenDetails: JsonField<PromptTokenDetails>, + private val promptTokens: JsonField<Long>, + private val referenceExampleId: JsonField<String>, + private val s3Urls: JsonValue, + private val serialized: JsonValue, + private val startTime: JsonField<OffsetDateTime>, + private val tags: JsonField<List<String>>, + private val totalCost: JsonField<String>, + private val totalTokens: JsonField<Long>, + private val traceMaxStartTime: JsonField<OffsetDateTime>, + private val traceMinStartTime: JsonField<OffsetDateTime>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("dotted_order") + @ExcludeMissing + dottedOrder: JsonField<String> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("run_type") + @ExcludeMissing + runType: JsonField<RunTypeEnum> = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField<String> = JsonMissing.of(), + @JsonProperty("trace_id") @ExcludeMissing traceId: JsonField<String> = JsonMissing.of(), + @JsonProperty("child_run_ids") + @ExcludeMissing + childRunIds: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("completion_cost") + @ExcludeMissing + completionCost: JsonField<String> = JsonMissing.of(), + @JsonProperty("completion_cost_details") + @ExcludeMissing + completionCostDetails: JsonField<CompletionCostDetails> = JsonMissing.of(), + @JsonProperty("completion_token_details") + @ExcludeMissing + completionTokenDetails: JsonField<CompletionTokenDetails> = JsonMissing.of(), + @JsonProperty("completion_tokens") + @ExcludeMissing + completionTokens: JsonField<Long> = JsonMissing.of(), + @JsonProperty("direct_child_run_ids") + @ExcludeMissing + directChildRunIds: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("end_time") + @ExcludeMissing + endTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("error") @ExcludeMissing error: JsonField<String> = JsonMissing.of(), + @JsonProperty("events") + @ExcludeMissing + events: JsonField<List<JsonValue>> = JsonMissing.of(), + @JsonProperty("execution_order") + @ExcludeMissing + executionOrder: JsonField<Long> = JsonMissing.of(), + @JsonProperty("extra") @ExcludeMissing extra: JsonValue = JsonMissing.of(), + @JsonProperty("feedback_stats") + @ExcludeMissing + feedbackStats: JsonField<FeedbackStats> = JsonMissing.of(), + @JsonProperty("first_token_time") + @ExcludeMissing + firstTokenTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("inputs") @ExcludeMissing inputs: JsonValue = JsonMissing.of(), + @JsonProperty("inputs_preview") + @ExcludeMissing + inputsPreview: JsonField<String> = JsonMissing.of(), + @JsonProperty("inputs_s3_urls") @ExcludeMissing inputsS3Urls: JsonValue = JsonMissing.of(), + @JsonProperty("manifest_id") + @ExcludeMissing + manifestId: JsonField<String> = JsonMissing.of(), + @JsonProperty("manifest_s3_id") + @ExcludeMissing + manifestS3Id: JsonField<String> = JsonMissing.of(), + @JsonProperty("outputs") @ExcludeMissing outputs: JsonValue = JsonMissing.of(), + @JsonProperty("outputs_preview") + @ExcludeMissing + outputsPreview: JsonField<String> = JsonMissing.of(), + @JsonProperty("outputs_s3_urls") + @ExcludeMissing + outputsS3Urls: JsonValue = JsonMissing.of(), + @JsonProperty("parent_run_id") + @ExcludeMissing + parentRunId: JsonField<String> = JsonMissing.of(), + @JsonProperty("parent_run_ids") + @ExcludeMissing + parentRunIds: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("price_model_id") + @ExcludeMissing + priceModelId: JsonField<String> = JsonMissing.of(), + @JsonProperty("prompt_cost") + @ExcludeMissing + promptCost: JsonField<String> = JsonMissing.of(), + @JsonProperty("prompt_cost_details") + @ExcludeMissing + promptCostDetails: JsonField<PromptCostDetails> = JsonMissing.of(), + @JsonProperty("prompt_token_details") + @ExcludeMissing + promptTokenDetails: JsonField<PromptTokenDetails> = JsonMissing.of(), + @JsonProperty("prompt_tokens") + @ExcludeMissing + promptTokens: JsonField<Long> = JsonMissing.of(), + @JsonProperty("reference_example_id") + @ExcludeMissing + referenceExampleId: JsonField<String> = JsonMissing.of(), + @JsonProperty("s3_urls") @ExcludeMissing s3Urls: JsonValue = JsonMissing.of(), + @JsonProperty("serialized") @ExcludeMissing serialized: JsonValue = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing tags: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("total_cost") @ExcludeMissing totalCost: JsonField<String> = JsonMissing.of(), + @JsonProperty("total_tokens") + @ExcludeMissing + totalTokens: JsonField<Long> = JsonMissing.of(), + @JsonProperty("trace_max_start_time") + @ExcludeMissing + traceMaxStartTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("trace_min_start_time") + @ExcludeMissing + traceMinStartTime: JsonField<OffsetDateTime> = JsonMissing.of(), + ) : this( + id, + dottedOrder, + name, + runType, + status, + traceId, + childRunIds, + completionCost, + completionCostDetails, + completionTokenDetails, + completionTokens, + directChildRunIds, + endTime, + error, + events, + executionOrder, + extra, + feedbackStats, + firstTokenTime, + inputs, + inputsPreview, + inputsS3Urls, + manifestId, + manifestS3Id, + outputs, + outputsPreview, + outputsS3Urls, + parentRunId, + parentRunIds, + priceModelId, + promptCost, + promptCostDetails, + promptTokenDetails, + promptTokens, + referenceExampleId, + s3Urls, + serialized, + startTime, + tags, + totalCost, + totalTokens, + traceMaxStartTime, + traceMinStartTime, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun dottedOrder(): String = dottedOrder.getRequired("dotted_order") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Enum for run types. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun runType(): RunTypeEnum = runType.getRequired("run_type") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): String = status.getRequired("status") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun traceId(): String = traceId.getRequired("trace_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun childRunIds(): Optional<List<String>> = childRunIds.getOptional("child_run_ids") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun completionCost(): Optional<String> = completionCost.getOptional("completion_cost") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun completionCostDetails(): Optional<CompletionCostDetails> = + completionCostDetails.getOptional("completion_cost_details") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun completionTokenDetails(): Optional<CompletionTokenDetails> = + completionTokenDetails.getOptional("completion_token_details") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun completionTokens(): Optional<Long> = completionTokens.getOptional("completion_tokens") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun directChildRunIds(): Optional<List<String>> = + directChildRunIds.getOptional("direct_child_run_ids") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endTime(): Optional<OffsetDateTime> = endTime.getOptional("end_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun error(): Optional<String> = error.getOptional("error") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun events(): Optional<List<JsonValue>> = events.getOptional("events") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun executionOrder(): Optional<Long> = executionOrder.getOptional("execution_order") + + @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonValue = extra + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun feedbackStats(): Optional<FeedbackStats> = feedbackStats.getOptional("feedback_stats") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun firstTokenTime(): Optional<OffsetDateTime> = firstTokenTime.getOptional("first_token_time") + + @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonValue = inputs + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun inputsPreview(): Optional<String> = inputsPreview.getOptional("inputs_preview") + + @JsonProperty("inputs_s3_urls") @ExcludeMissing fun _inputsS3Urls(): JsonValue = inputsS3Urls + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun manifestId(): Optional<String> = manifestId.getOptional("manifest_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun manifestS3Id(): Optional<String> = manifestS3Id.getOptional("manifest_s3_id") + + @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonValue = outputs + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun outputsPreview(): Optional<String> = outputsPreview.getOptional("outputs_preview") + + @JsonProperty("outputs_s3_urls") @ExcludeMissing fun _outputsS3Urls(): JsonValue = outputsS3Urls + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun parentRunId(): Optional<String> = parentRunId.getOptional("parent_run_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun parentRunIds(): Optional<List<String>> = parentRunIds.getOptional("parent_run_ids") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun priceModelId(): Optional<String> = priceModelId.getOptional("price_model_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun promptCost(): Optional<String> = promptCost.getOptional("prompt_cost") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun promptCostDetails(): Optional<PromptCostDetails> = + promptCostDetails.getOptional("prompt_cost_details") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun promptTokenDetails(): Optional<PromptTokenDetails> = + promptTokenDetails.getOptional("prompt_token_details") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun promptTokens(): Optional<Long> = promptTokens.getOptional("prompt_tokens") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceExampleId(): Optional<String> = + referenceExampleId.getOptional("reference_example_id") + + @JsonProperty("s3_urls") @ExcludeMissing fun _s3Urls(): JsonValue = s3Urls + + @JsonProperty("serialized") @ExcludeMissing fun _serialized(): JsonValue = serialized + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun startTime(): Optional<OffsetDateTime> = startTime.getOptional("start_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tags(): Optional<List<String>> = tags.getOptional("tags") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun totalCost(): Optional<String> = totalCost.getOptional("total_cost") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun totalTokens(): Optional<Long> = totalTokens.getOptional("total_tokens") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun traceMaxStartTime(): Optional<OffsetDateTime> = + traceMaxStartTime.getOptional("trace_max_start_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun traceMinStartTime(): Optional<OffsetDateTime> = + traceMinStartTime.getOptional("trace_min_start_time") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [dottedOrder]. + * + * Unlike [dottedOrder], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dotted_order") + @ExcludeMissing + fun _dottedOrder(): JsonField<String> = dottedOrder + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [runType]. + * + * Unlike [runType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_type") @ExcludeMissing fun _runType(): JsonField<RunTypeEnum> = runType + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField<String> = status + + /** + * Returns the raw JSON value of [traceId]. + * + * Unlike [traceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trace_id") @ExcludeMissing fun _traceId(): JsonField<String> = traceId + + /** + * Returns the raw JSON value of [childRunIds]. + * + * Unlike [childRunIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("child_run_ids") + @ExcludeMissing + fun _childRunIds(): JsonField<List<String>> = childRunIds + + /** + * Returns the raw JSON value of [completionCost]. + * + * Unlike [completionCost], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("completion_cost") + @ExcludeMissing + fun _completionCost(): JsonField<String> = completionCost + + /** + * Returns the raw JSON value of [completionCostDetails]. + * + * Unlike [completionCostDetails], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("completion_cost_details") + @ExcludeMissing + fun _completionCostDetails(): JsonField<CompletionCostDetails> = completionCostDetails + + /** + * Returns the raw JSON value of [completionTokenDetails]. + * + * Unlike [completionTokenDetails], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("completion_token_details") + @ExcludeMissing + fun _completionTokenDetails(): JsonField<CompletionTokenDetails> = completionTokenDetails + + /** + * Returns the raw JSON value of [completionTokens]. + * + * Unlike [completionTokens], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("completion_tokens") + @ExcludeMissing + fun _completionTokens(): JsonField<Long> = completionTokens + + /** + * Returns the raw JSON value of [directChildRunIds]. + * + * Unlike [directChildRunIds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("direct_child_run_ids") + @ExcludeMissing + fun _directChildRunIds(): JsonField<List<String>> = directChildRunIds + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_time") @ExcludeMissing fun _endTime(): JsonField<OffsetDateTime> = endTime + + /** + * Returns the raw JSON value of [error]. + * + * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("error") @ExcludeMissing fun _error(): JsonField<String> = error + + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("events") @ExcludeMissing fun _events(): JsonField<List<JsonValue>> = events + + /** + * Returns the raw JSON value of [executionOrder]. + * + * Unlike [executionOrder], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("execution_order") + @ExcludeMissing + fun _executionOrder(): JsonField<Long> = executionOrder + + /** + * Returns the raw JSON value of [feedbackStats]. + * + * Unlike [feedbackStats], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feedback_stats") + @ExcludeMissing + fun _feedbackStats(): JsonField<FeedbackStats> = feedbackStats + + /** + * Returns the raw JSON value of [firstTokenTime]. + * + * Unlike [firstTokenTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("first_token_time") + @ExcludeMissing + fun _firstTokenTime(): JsonField<OffsetDateTime> = firstTokenTime + + /** + * Returns the raw JSON value of [inputsPreview]. + * + * Unlike [inputsPreview], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inputs_preview") + @ExcludeMissing + fun _inputsPreview(): JsonField<String> = inputsPreview + + /** + * Returns the raw JSON value of [manifestId]. + * + * Unlike [manifestId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("manifest_id") @ExcludeMissing fun _manifestId(): JsonField<String> = manifestId + + /** + * Returns the raw JSON value of [manifestS3Id]. + * + * Unlike [manifestS3Id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("manifest_s3_id") + @ExcludeMissing + fun _manifestS3Id(): JsonField<String> = manifestS3Id + + /** + * Returns the raw JSON value of [outputsPreview]. + * + * Unlike [outputsPreview], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outputs_preview") + @ExcludeMissing + fun _outputsPreview(): JsonField<String> = outputsPreview + + /** + * Returns the raw JSON value of [parentRunId]. + * + * Unlike [parentRunId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("parent_run_id") + @ExcludeMissing + fun _parentRunId(): JsonField<String> = parentRunId + + /** + * Returns the raw JSON value of [parentRunIds]. + * + * Unlike [parentRunIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("parent_run_ids") + @ExcludeMissing + fun _parentRunIds(): JsonField<List<String>> = parentRunIds + + /** + * Returns the raw JSON value of [priceModelId]. + * + * Unlike [priceModelId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_model_id") + @ExcludeMissing + fun _priceModelId(): JsonField<String> = priceModelId + + /** + * Returns the raw JSON value of [promptCost]. + * + * Unlike [promptCost], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prompt_cost") @ExcludeMissing fun _promptCost(): JsonField<String> = promptCost + + /** + * Returns the raw JSON value of [promptCostDetails]. + * + * Unlike [promptCostDetails], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("prompt_cost_details") + @ExcludeMissing + fun _promptCostDetails(): JsonField<PromptCostDetails> = promptCostDetails + + /** + * Returns the raw JSON value of [promptTokenDetails]. + * + * Unlike [promptTokenDetails], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("prompt_token_details") + @ExcludeMissing + fun _promptTokenDetails(): JsonField<PromptTokenDetails> = promptTokenDetails + + /** + * Returns the raw JSON value of [promptTokens]. + * + * Unlike [promptTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prompt_tokens") + @ExcludeMissing + fun _promptTokens(): JsonField<Long> = promptTokens + + /** + * Returns the raw JSON value of [referenceExampleId]. + * + * Unlike [referenceExampleId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reference_example_id") + @ExcludeMissing + fun _referenceExampleId(): JsonField<String> = referenceExampleId + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_time") + @ExcludeMissing + fun _startTime(): JsonField<OffsetDateTime> = startTime + + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField<List<String>> = tags + + /** + * Returns the raw JSON value of [totalCost]. + * + * Unlike [totalCost], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total_cost") @ExcludeMissing fun _totalCost(): JsonField<String> = totalCost + + /** + * Returns the raw JSON value of [totalTokens]. + * + * Unlike [totalTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total_tokens") @ExcludeMissing fun _totalTokens(): JsonField<Long> = totalTokens + + /** + * Returns the raw JSON value of [traceMaxStartTime]. + * + * Unlike [traceMaxStartTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("trace_max_start_time") + @ExcludeMissing + fun _traceMaxStartTime(): JsonField<OffsetDateTime> = traceMaxStartTime + + /** + * Returns the raw JSON value of [traceMinStartTime]. + * + * Unlike [traceMinStartTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("trace_min_start_time") + @ExcludeMissing + fun _traceMinStartTime(): JsonField<OffsetDateTime> = traceMinStartTime + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RunPublicSchema]. + * + * The following fields are required: + * ```java + * .id() + * .dottedOrder() + * .name() + * .runType() + * .status() + * .traceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunPublicSchema]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var dottedOrder: JsonField<String>? = null + private var name: JsonField<String>? = null + private var runType: JsonField<RunTypeEnum>? = null + private var status: JsonField<String>? = null + private var traceId: JsonField<String>? = null + private var childRunIds: JsonField<MutableList<String>>? = null + private var completionCost: JsonField<String> = JsonMissing.of() + private var completionCostDetails: JsonField<CompletionCostDetails> = JsonMissing.of() + private var completionTokenDetails: JsonField<CompletionTokenDetails> = JsonMissing.of() + private var completionTokens: JsonField<Long> = JsonMissing.of() + private var directChildRunIds: JsonField<MutableList<String>>? = null + private var endTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var error: JsonField<String> = JsonMissing.of() + private var events: JsonField<MutableList<JsonValue>>? = null + private var executionOrder: JsonField<Long> = JsonMissing.of() + private var extra: JsonValue = JsonMissing.of() + private var feedbackStats: JsonField<FeedbackStats> = JsonMissing.of() + private var firstTokenTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var inputs: JsonValue = JsonMissing.of() + private var inputsPreview: JsonField<String> = JsonMissing.of() + private var inputsS3Urls: JsonValue = JsonMissing.of() + private var manifestId: JsonField<String> = JsonMissing.of() + private var manifestS3Id: JsonField<String> = JsonMissing.of() + private var outputs: JsonValue = JsonMissing.of() + private var outputsPreview: JsonField<String> = JsonMissing.of() + private var outputsS3Urls: JsonValue = JsonMissing.of() + private var parentRunId: JsonField<String> = JsonMissing.of() + private var parentRunIds: JsonField<MutableList<String>>? = null + private var priceModelId: JsonField<String> = JsonMissing.of() + private var promptCost: JsonField<String> = JsonMissing.of() + private var promptCostDetails: JsonField<PromptCostDetails> = JsonMissing.of() + private var promptTokenDetails: JsonField<PromptTokenDetails> = JsonMissing.of() + private var promptTokens: JsonField<Long> = JsonMissing.of() + private var referenceExampleId: JsonField<String> = JsonMissing.of() + private var s3Urls: JsonValue = JsonMissing.of() + private var serialized: JsonValue = JsonMissing.of() + private var startTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var tags: JsonField<MutableList<String>>? = null + private var totalCost: JsonField<String> = JsonMissing.of() + private var totalTokens: JsonField<Long> = JsonMissing.of() + private var traceMaxStartTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var traceMinStartTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(runPublicSchema: RunPublicSchema) = apply { + id = runPublicSchema.id + dottedOrder = runPublicSchema.dottedOrder + name = runPublicSchema.name + runType = runPublicSchema.runType + status = runPublicSchema.status + traceId = runPublicSchema.traceId + childRunIds = runPublicSchema.childRunIds.map { it.toMutableList() } + completionCost = runPublicSchema.completionCost + completionCostDetails = runPublicSchema.completionCostDetails + completionTokenDetails = runPublicSchema.completionTokenDetails + completionTokens = runPublicSchema.completionTokens + directChildRunIds = runPublicSchema.directChildRunIds.map { it.toMutableList() } + endTime = runPublicSchema.endTime + error = runPublicSchema.error + events = runPublicSchema.events.map { it.toMutableList() } + executionOrder = runPublicSchema.executionOrder + extra = runPublicSchema.extra + feedbackStats = runPublicSchema.feedbackStats + firstTokenTime = runPublicSchema.firstTokenTime + inputs = runPublicSchema.inputs + inputsPreview = runPublicSchema.inputsPreview + inputsS3Urls = runPublicSchema.inputsS3Urls + manifestId = runPublicSchema.manifestId + manifestS3Id = runPublicSchema.manifestS3Id + outputs = runPublicSchema.outputs + outputsPreview = runPublicSchema.outputsPreview + outputsS3Urls = runPublicSchema.outputsS3Urls + parentRunId = runPublicSchema.parentRunId + parentRunIds = runPublicSchema.parentRunIds.map { it.toMutableList() } + priceModelId = runPublicSchema.priceModelId + promptCost = runPublicSchema.promptCost + promptCostDetails = runPublicSchema.promptCostDetails + promptTokenDetails = runPublicSchema.promptTokenDetails + promptTokens = runPublicSchema.promptTokens + referenceExampleId = runPublicSchema.referenceExampleId + s3Urls = runPublicSchema.s3Urls + serialized = runPublicSchema.serialized + startTime = runPublicSchema.startTime + tags = runPublicSchema.tags.map { it.toMutableList() } + totalCost = runPublicSchema.totalCost + totalTokens = runPublicSchema.totalTokens + traceMaxStartTime = runPublicSchema.traceMaxStartTime + traceMinStartTime = runPublicSchema.traceMinStartTime + additionalProperties = runPublicSchema.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun dottedOrder(dottedOrder: String) = dottedOrder(JsonField.of(dottedOrder)) + + /** + * Sets [Builder.dottedOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.dottedOrder] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dottedOrder(dottedOrder: JsonField<String>) = apply { this.dottedOrder = dottedOrder } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + /** Enum for run types. */ + fun runType(runType: RunTypeEnum) = runType(JsonField.of(runType)) + + /** + * Sets [Builder.runType] to an arbitrary JSON value. + * + * You should usually call [Builder.runType] with a well-typed [RunTypeEnum] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun runType(runType: JsonField<RunTypeEnum>) = apply { this.runType = runType } + + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField<String>) = apply { this.status = status } + + fun traceId(traceId: String) = traceId(JsonField.of(traceId)) + + /** + * Sets [Builder.traceId] to an arbitrary JSON value. + * + * You should usually call [Builder.traceId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun traceId(traceId: JsonField<String>) = apply { this.traceId = traceId } + + fun childRunIds(childRunIds: List<String>?) = childRunIds(JsonField.ofNullable(childRunIds)) + + /** Alias for calling [Builder.childRunIds] with `childRunIds.orElse(null)`. */ + fun childRunIds(childRunIds: Optional<List<String>>) = childRunIds(childRunIds.getOrNull()) + + /** + * Sets [Builder.childRunIds] to an arbitrary JSON value. + * + * You should usually call [Builder.childRunIds] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun childRunIds(childRunIds: JsonField<List<String>>) = apply { + this.childRunIds = childRunIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [childRunIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChildRunId(childRunId: String) = apply { + childRunIds = + (childRunIds ?: JsonField.of(mutableListOf())).also { + checkKnown("childRunIds", it).add(childRunId) + } + } + + fun completionCost(completionCost: String?) = + completionCost(JsonField.ofNullable(completionCost)) + + /** Alias for calling [Builder.completionCost] with `completionCost.orElse(null)`. */ + fun completionCost(completionCost: Optional<String>) = + completionCost(completionCost.getOrNull()) + + /** + * Sets [Builder.completionCost] to an arbitrary JSON value. + * + * You should usually call [Builder.completionCost] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun completionCost(completionCost: JsonField<String>) = apply { + this.completionCost = completionCost + } + + fun completionCostDetails(completionCostDetails: CompletionCostDetails?) = + completionCostDetails(JsonField.ofNullable(completionCostDetails)) + + /** + * Alias for calling [Builder.completionCostDetails] with + * `completionCostDetails.orElse(null)`. + */ + fun completionCostDetails(completionCostDetails: Optional<CompletionCostDetails>) = + completionCostDetails(completionCostDetails.getOrNull()) + + /** + * Sets [Builder.completionCostDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.completionCostDetails] with a well-typed + * [CompletionCostDetails] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun completionCostDetails(completionCostDetails: JsonField<CompletionCostDetails>) = apply { + this.completionCostDetails = completionCostDetails + } + + fun completionTokenDetails(completionTokenDetails: CompletionTokenDetails?) = + completionTokenDetails(JsonField.ofNullable(completionTokenDetails)) + + /** + * Alias for calling [Builder.completionTokenDetails] with + * `completionTokenDetails.orElse(null)`. + */ + fun completionTokenDetails(completionTokenDetails: Optional<CompletionTokenDetails>) = + completionTokenDetails(completionTokenDetails.getOrNull()) + + /** + * Sets [Builder.completionTokenDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.completionTokenDetails] with a well-typed + * [CompletionTokenDetails] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun completionTokenDetails(completionTokenDetails: JsonField<CompletionTokenDetails>) = + apply { + this.completionTokenDetails = completionTokenDetails + } + + fun completionTokens(completionTokens: Long) = + completionTokens(JsonField.of(completionTokens)) + + /** + * Sets [Builder.completionTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.completionTokens] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun completionTokens(completionTokens: JsonField<Long>) = apply { + this.completionTokens = completionTokens + } + + fun directChildRunIds(directChildRunIds: List<String>?) = + directChildRunIds(JsonField.ofNullable(directChildRunIds)) + + /** Alias for calling [Builder.directChildRunIds] with `directChildRunIds.orElse(null)`. */ + fun directChildRunIds(directChildRunIds: Optional<List<String>>) = + directChildRunIds(directChildRunIds.getOrNull()) + + /** + * Sets [Builder.directChildRunIds] to an arbitrary JSON value. + * + * You should usually call [Builder.directChildRunIds] with a well-typed `List<String>` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun directChildRunIds(directChildRunIds: JsonField<List<String>>) = apply { + this.directChildRunIds = directChildRunIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [directChildRunIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addDirectChildRunId(directChildRunId: String) = apply { + directChildRunIds = + (directChildRunIds ?: JsonField.of(mutableListOf())).also { + checkKnown("directChildRunIds", it).add(directChildRunId) + } + } + + fun endTime(endTime: OffsetDateTime?) = endTime(JsonField.ofNullable(endTime)) + + /** Alias for calling [Builder.endTime] with `endTime.orElse(null)`. */ + fun endTime(endTime: Optional<OffsetDateTime>) = endTime(endTime.getOrNull()) + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endTime(endTime: JsonField<OffsetDateTime>) = apply { this.endTime = endTime } + + fun error(error: String?) = error(JsonField.ofNullable(error)) + + /** Alias for calling [Builder.error] with `error.orElse(null)`. */ + fun error(error: Optional<String>) = error(error.getOrNull()) + + /** + * Sets [Builder.error] to an arbitrary JSON value. + * + * You should usually call [Builder.error] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun error(error: JsonField<String>) = apply { this.error = error } + + fun events(events: List<JsonValue>?) = events(JsonField.ofNullable(events)) + + /** Alias for calling [Builder.events] with `events.orElse(null)`. */ + fun events(events: Optional<List<JsonValue>>) = events(events.getOrNull()) + + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed `List<JsonValue>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun events(events: JsonField<List<JsonValue>>) = apply { + this.events = events.map { it.toMutableList() } + } + + /** + * Adds a single [JsonValue] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvent(event: JsonValue) = apply { + events = + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) + } + } + + fun executionOrder(executionOrder: Long) = executionOrder(JsonField.of(executionOrder)) + + /** + * Sets [Builder.executionOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.executionOrder] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun executionOrder(executionOrder: JsonField<Long>) = apply { + this.executionOrder = executionOrder + } + + fun extra(extra: JsonValue) = apply { this.extra = extra } + + fun feedbackStats(feedbackStats: FeedbackStats?) = + feedbackStats(JsonField.ofNullable(feedbackStats)) + + /** Alias for calling [Builder.feedbackStats] with `feedbackStats.orElse(null)`. */ + fun feedbackStats(feedbackStats: Optional<FeedbackStats>) = + feedbackStats(feedbackStats.getOrNull()) + + /** + * Sets [Builder.feedbackStats] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackStats] with a well-typed [FeedbackStats] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun feedbackStats(feedbackStats: JsonField<FeedbackStats>) = apply { + this.feedbackStats = feedbackStats + } + + fun firstTokenTime(firstTokenTime: OffsetDateTime?) = + firstTokenTime(JsonField.ofNullable(firstTokenTime)) + + /** Alias for calling [Builder.firstTokenTime] with `firstTokenTime.orElse(null)`. */ + fun firstTokenTime(firstTokenTime: Optional<OffsetDateTime>) = + firstTokenTime(firstTokenTime.getOrNull()) + + /** + * Sets [Builder.firstTokenTime] to an arbitrary JSON value. + * + * You should usually call [Builder.firstTokenTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun firstTokenTime(firstTokenTime: JsonField<OffsetDateTime>) = apply { + this.firstTokenTime = firstTokenTime + } + + fun inputs(inputs: JsonValue) = apply { this.inputs = inputs } + + fun inputsPreview(inputsPreview: String?) = + inputsPreview(JsonField.ofNullable(inputsPreview)) + + /** Alias for calling [Builder.inputsPreview] with `inputsPreview.orElse(null)`. */ + fun inputsPreview(inputsPreview: Optional<String>) = + inputsPreview(inputsPreview.getOrNull()) + + /** + * Sets [Builder.inputsPreview] to an arbitrary JSON value. + * + * You should usually call [Builder.inputsPreview] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun inputsPreview(inputsPreview: JsonField<String>) = apply { + this.inputsPreview = inputsPreview + } + + fun inputsS3Urls(inputsS3Urls: JsonValue) = apply { this.inputsS3Urls = inputsS3Urls } + + fun manifestId(manifestId: String?) = manifestId(JsonField.ofNullable(manifestId)) + + /** Alias for calling [Builder.manifestId] with `manifestId.orElse(null)`. */ + fun manifestId(manifestId: Optional<String>) = manifestId(manifestId.getOrNull()) + + /** + * Sets [Builder.manifestId] to an arbitrary JSON value. + * + * You should usually call [Builder.manifestId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun manifestId(manifestId: JsonField<String>) = apply { this.manifestId = manifestId } + + fun manifestS3Id(manifestS3Id: String?) = manifestS3Id(JsonField.ofNullable(manifestS3Id)) + + /** Alias for calling [Builder.manifestS3Id] with `manifestS3Id.orElse(null)`. */ + fun manifestS3Id(manifestS3Id: Optional<String>) = manifestS3Id(manifestS3Id.getOrNull()) + + /** + * Sets [Builder.manifestS3Id] to an arbitrary JSON value. + * + * You should usually call [Builder.manifestS3Id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun manifestS3Id(manifestS3Id: JsonField<String>) = apply { + this.manifestS3Id = manifestS3Id + } + + fun outputs(outputs: JsonValue) = apply { this.outputs = outputs } + + fun outputsPreview(outputsPreview: String?) = + outputsPreview(JsonField.ofNullable(outputsPreview)) + + /** Alias for calling [Builder.outputsPreview] with `outputsPreview.orElse(null)`. */ + fun outputsPreview(outputsPreview: Optional<String>) = + outputsPreview(outputsPreview.getOrNull()) + + /** + * Sets [Builder.outputsPreview] to an arbitrary JSON value. + * + * You should usually call [Builder.outputsPreview] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun outputsPreview(outputsPreview: JsonField<String>) = apply { + this.outputsPreview = outputsPreview + } + + fun outputsS3Urls(outputsS3Urls: JsonValue) = apply { this.outputsS3Urls = outputsS3Urls } + + fun parentRunId(parentRunId: String?) = parentRunId(JsonField.ofNullable(parentRunId)) + + /** Alias for calling [Builder.parentRunId] with `parentRunId.orElse(null)`. */ + fun parentRunId(parentRunId: Optional<String>) = parentRunId(parentRunId.getOrNull()) + + /** + * Sets [Builder.parentRunId] to an arbitrary JSON value. + * + * You should usually call [Builder.parentRunId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun parentRunId(parentRunId: JsonField<String>) = apply { this.parentRunId = parentRunId } + + fun parentRunIds(parentRunIds: List<String>?) = + parentRunIds(JsonField.ofNullable(parentRunIds)) + + /** Alias for calling [Builder.parentRunIds] with `parentRunIds.orElse(null)`. */ + fun parentRunIds(parentRunIds: Optional<List<String>>) = + parentRunIds(parentRunIds.getOrNull()) + + /** + * Sets [Builder.parentRunIds] to an arbitrary JSON value. + * + * You should usually call [Builder.parentRunIds] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun parentRunIds(parentRunIds: JsonField<List<String>>) = apply { + this.parentRunIds = parentRunIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [parentRunIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addParentRunId(parentRunId: String) = apply { + parentRunIds = + (parentRunIds ?: JsonField.of(mutableListOf())).also { + checkKnown("parentRunIds", it).add(parentRunId) + } + } + + fun priceModelId(priceModelId: String?) = priceModelId(JsonField.ofNullable(priceModelId)) + + /** Alias for calling [Builder.priceModelId] with `priceModelId.orElse(null)`. */ + fun priceModelId(priceModelId: Optional<String>) = priceModelId(priceModelId.getOrNull()) + + /** + * Sets [Builder.priceModelId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceModelId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun priceModelId(priceModelId: JsonField<String>) = apply { + this.priceModelId = priceModelId + } + + fun promptCost(promptCost: String?) = promptCost(JsonField.ofNullable(promptCost)) + + /** Alias for calling [Builder.promptCost] with `promptCost.orElse(null)`. */ + fun promptCost(promptCost: Optional<String>) = promptCost(promptCost.getOrNull()) + + /** + * Sets [Builder.promptCost] to an arbitrary JSON value. + * + * You should usually call [Builder.promptCost] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun promptCost(promptCost: JsonField<String>) = apply { this.promptCost = promptCost } + + fun promptCostDetails(promptCostDetails: PromptCostDetails?) = + promptCostDetails(JsonField.ofNullable(promptCostDetails)) + + /** Alias for calling [Builder.promptCostDetails] with `promptCostDetails.orElse(null)`. */ + fun promptCostDetails(promptCostDetails: Optional<PromptCostDetails>) = + promptCostDetails(promptCostDetails.getOrNull()) + + /** + * Sets [Builder.promptCostDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.promptCostDetails] with a well-typed [PromptCostDetails] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun promptCostDetails(promptCostDetails: JsonField<PromptCostDetails>) = apply { + this.promptCostDetails = promptCostDetails + } + + fun promptTokenDetails(promptTokenDetails: PromptTokenDetails?) = + promptTokenDetails(JsonField.ofNullable(promptTokenDetails)) + + /** + * Alias for calling [Builder.promptTokenDetails] with `promptTokenDetails.orElse(null)`. + */ + fun promptTokenDetails(promptTokenDetails: Optional<PromptTokenDetails>) = + promptTokenDetails(promptTokenDetails.getOrNull()) + + /** + * Sets [Builder.promptTokenDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.promptTokenDetails] with a well-typed + * [PromptTokenDetails] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun promptTokenDetails(promptTokenDetails: JsonField<PromptTokenDetails>) = apply { + this.promptTokenDetails = promptTokenDetails + } + + fun promptTokens(promptTokens: Long) = promptTokens(JsonField.of(promptTokens)) + + /** + * Sets [Builder.promptTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.promptTokens] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun promptTokens(promptTokens: JsonField<Long>) = apply { this.promptTokens = promptTokens } + + fun referenceExampleId(referenceExampleId: String?) = + referenceExampleId(JsonField.ofNullable(referenceExampleId)) + + /** + * Alias for calling [Builder.referenceExampleId] with `referenceExampleId.orElse(null)`. + */ + fun referenceExampleId(referenceExampleId: Optional<String>) = + referenceExampleId(referenceExampleId.getOrNull()) + + /** + * Sets [Builder.referenceExampleId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceExampleId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun referenceExampleId(referenceExampleId: JsonField<String>) = apply { + this.referenceExampleId = referenceExampleId + } + + fun s3Urls(s3Urls: JsonValue) = apply { this.s3Urls = s3Urls } + + fun serialized(serialized: JsonValue) = apply { this.serialized = serialized } + + fun startTime(startTime: OffsetDateTime) = startTime(JsonField.of(startTime)) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField<OffsetDateTime>) = apply { this.startTime = startTime } + + fun tags(tags: List<String>?) = tags(JsonField.ofNullable(tags)) + + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ + fun tags(tags: Optional<List<String>>) = tags(tags.getOrNull()) + + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List<String>` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tags(tags: JsonField<List<String>>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } + + fun totalCost(totalCost: String?) = totalCost(JsonField.ofNullable(totalCost)) + + /** Alias for calling [Builder.totalCost] with `totalCost.orElse(null)`. */ + fun totalCost(totalCost: Optional<String>) = totalCost(totalCost.getOrNull()) + + /** + * Sets [Builder.totalCost] to an arbitrary JSON value. + * + * You should usually call [Builder.totalCost] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun totalCost(totalCost: JsonField<String>) = apply { this.totalCost = totalCost } + + fun totalTokens(totalTokens: Long) = totalTokens(JsonField.of(totalTokens)) + + /** + * Sets [Builder.totalTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.totalTokens] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun totalTokens(totalTokens: JsonField<Long>) = apply { this.totalTokens = totalTokens } + + fun traceMaxStartTime(traceMaxStartTime: OffsetDateTime?) = + traceMaxStartTime(JsonField.ofNullable(traceMaxStartTime)) + + /** Alias for calling [Builder.traceMaxStartTime] with `traceMaxStartTime.orElse(null)`. */ + fun traceMaxStartTime(traceMaxStartTime: Optional<OffsetDateTime>) = + traceMaxStartTime(traceMaxStartTime.getOrNull()) + + /** + * Sets [Builder.traceMaxStartTime] to an arbitrary JSON value. + * + * You should usually call [Builder.traceMaxStartTime] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun traceMaxStartTime(traceMaxStartTime: JsonField<OffsetDateTime>) = apply { + this.traceMaxStartTime = traceMaxStartTime + } + + fun traceMinStartTime(traceMinStartTime: OffsetDateTime?) = + traceMinStartTime(JsonField.ofNullable(traceMinStartTime)) + + /** Alias for calling [Builder.traceMinStartTime] with `traceMinStartTime.orElse(null)`. */ + fun traceMinStartTime(traceMinStartTime: Optional<OffsetDateTime>) = + traceMinStartTime(traceMinStartTime.getOrNull()) + + /** + * Sets [Builder.traceMinStartTime] to an arbitrary JSON value. + * + * You should usually call [Builder.traceMinStartTime] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun traceMinStartTime(traceMinStartTime: JsonField<OffsetDateTime>) = apply { + this.traceMinStartTime = traceMinStartTime + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RunPublicSchema]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .dottedOrder() + * .name() + * .runType() + * .status() + * .traceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RunPublicSchema = + RunPublicSchema( + checkRequired("id", id), + checkRequired("dottedOrder", dottedOrder), + checkRequired("name", name), + checkRequired("runType", runType), + checkRequired("status", status), + checkRequired("traceId", traceId), + (childRunIds ?: JsonMissing.of()).map { it.toImmutable() }, + completionCost, + completionCostDetails, + completionTokenDetails, + completionTokens, + (directChildRunIds ?: JsonMissing.of()).map { it.toImmutable() }, + endTime, + error, + (events ?: JsonMissing.of()).map { it.toImmutable() }, + executionOrder, + extra, + feedbackStats, + firstTokenTime, + inputs, + inputsPreview, + inputsS3Urls, + manifestId, + manifestS3Id, + outputs, + outputsPreview, + outputsS3Urls, + parentRunId, + (parentRunIds ?: JsonMissing.of()).map { it.toImmutable() }, + priceModelId, + promptCost, + promptCostDetails, + promptTokenDetails, + promptTokens, + referenceExampleId, + s3Urls, + serialized, + startTime, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + totalCost, + totalTokens, + traceMaxStartTime, + traceMinStartTime, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RunPublicSchema = apply { + if (validated) { + return@apply + } + + id() + dottedOrder() + name() + runType().validate() + status() + traceId() + childRunIds() + completionCost() + completionCostDetails().ifPresent { it.validate() } + completionTokenDetails().ifPresent { it.validate() } + completionTokens() + directChildRunIds() + endTime() + error() + events() + executionOrder() + feedbackStats().ifPresent { it.validate() } + firstTokenTime() + inputsPreview() + manifestId() + manifestS3Id() + outputsPreview() + parentRunId() + parentRunIds() + priceModelId() + promptCost() + promptCostDetails().ifPresent { it.validate() } + promptTokenDetails().ifPresent { it.validate() } + promptTokens() + referenceExampleId() + startTime() + tags() + totalCost() + totalTokens() + traceMaxStartTime() + traceMinStartTime() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (dottedOrder.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (runType.asKnown().getOrNull()?.validity() ?: 0) + + (if (status.asKnown().isPresent) 1 else 0) + + (if (traceId.asKnown().isPresent) 1 else 0) + + (childRunIds.asKnown().getOrNull()?.size ?: 0) + + (if (completionCost.asKnown().isPresent) 1 else 0) + + (completionCostDetails.asKnown().getOrNull()?.validity() ?: 0) + + (completionTokenDetails.asKnown().getOrNull()?.validity() ?: 0) + + (if (completionTokens.asKnown().isPresent) 1 else 0) + + (directChildRunIds.asKnown().getOrNull()?.size ?: 0) + + (if (endTime.asKnown().isPresent) 1 else 0) + + (if (error.asKnown().isPresent) 1 else 0) + + (events.asKnown().getOrNull()?.size ?: 0) + + (if (executionOrder.asKnown().isPresent) 1 else 0) + + (feedbackStats.asKnown().getOrNull()?.validity() ?: 0) + + (if (firstTokenTime.asKnown().isPresent) 1 else 0) + + (if (inputsPreview.asKnown().isPresent) 1 else 0) + + (if (manifestId.asKnown().isPresent) 1 else 0) + + (if (manifestS3Id.asKnown().isPresent) 1 else 0) + + (if (outputsPreview.asKnown().isPresent) 1 else 0) + + (if (parentRunId.asKnown().isPresent) 1 else 0) + + (parentRunIds.asKnown().getOrNull()?.size ?: 0) + + (if (priceModelId.asKnown().isPresent) 1 else 0) + + (if (promptCost.asKnown().isPresent) 1 else 0) + + (promptCostDetails.asKnown().getOrNull()?.validity() ?: 0) + + (promptTokenDetails.asKnown().getOrNull()?.validity() ?: 0) + + (if (promptTokens.asKnown().isPresent) 1 else 0) + + (if (referenceExampleId.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + (tags.asKnown().getOrNull()?.size ?: 0) + + (if (totalCost.asKnown().isPresent) 1 else 0) + + (if (totalTokens.asKnown().isPresent) 1 else 0) + + (if (traceMaxStartTime.asKnown().isPresent) 1 else 0) + + (if (traceMinStartTime.asKnown().isPresent) 1 else 0) + + class CompletionCostDetails + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompletionCostDetails]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CompletionCostDetails]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(completionCostDetails: CompletionCostDetails) = apply { + additionalProperties = completionCostDetails.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompletionCostDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CompletionCostDetails = + CompletionCostDetails(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): CompletionCostDetails = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompletionCostDetails && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompletionCostDetails{additionalProperties=$additionalProperties}" + } + + class CompletionTokenDetails + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompletionTokenDetails]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CompletionTokenDetails]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(completionTokenDetails: CompletionTokenDetails) = apply { + additionalProperties = completionTokenDetails.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompletionTokenDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CompletionTokenDetails = + CompletionTokenDetails(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): CompletionTokenDetails = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompletionTokenDetails && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompletionTokenDetails{additionalProperties=$additionalProperties}" + } + + class FeedbackStats + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [FeedbackStats]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackStats]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(feedbackStats: FeedbackStats) = apply { + additionalProperties = feedbackStats.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FeedbackStats]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FeedbackStats = FeedbackStats(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): FeedbackStats = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackStats && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "FeedbackStats{additionalProperties=$additionalProperties}" + } + + class PromptCostDetails + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [PromptCostDetails]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PromptCostDetails]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(promptCostDetails: PromptCostDetails) = apply { + additionalProperties = promptCostDetails.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PromptCostDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PromptCostDetails = PromptCostDetails(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): PromptCostDetails = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PromptCostDetails && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "PromptCostDetails{additionalProperties=$additionalProperties}" + } + + class PromptTokenDetails + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [PromptTokenDetails]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PromptTokenDetails]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(promptTokenDetails: PromptTokenDetails) = apply { + additionalProperties = promptTokenDetails.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PromptTokenDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PromptTokenDetails = PromptTokenDetails(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): PromptTokenDetails = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PromptTokenDetails && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "PromptTokenDetails{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunPublicSchema && + id == other.id && + dottedOrder == other.dottedOrder && + name == other.name && + runType == other.runType && + status == other.status && + traceId == other.traceId && + childRunIds == other.childRunIds && + completionCost == other.completionCost && + completionCostDetails == other.completionCostDetails && + completionTokenDetails == other.completionTokenDetails && + completionTokens == other.completionTokens && + directChildRunIds == other.directChildRunIds && + endTime == other.endTime && + error == other.error && + events == other.events && + executionOrder == other.executionOrder && + extra == other.extra && + feedbackStats == other.feedbackStats && + firstTokenTime == other.firstTokenTime && + inputs == other.inputs && + inputsPreview == other.inputsPreview && + inputsS3Urls == other.inputsS3Urls && + manifestId == other.manifestId && + manifestS3Id == other.manifestS3Id && + outputs == other.outputs && + outputsPreview == other.outputsPreview && + outputsS3Urls == other.outputsS3Urls && + parentRunId == other.parentRunId && + parentRunIds == other.parentRunIds && + priceModelId == other.priceModelId && + promptCost == other.promptCost && + promptCostDetails == other.promptCostDetails && + promptTokenDetails == other.promptTokenDetails && + promptTokens == other.promptTokens && + referenceExampleId == other.referenceExampleId && + s3Urls == other.s3Urls && + serialized == other.serialized && + startTime == other.startTime && + tags == other.tags && + totalCost == other.totalCost && + totalTokens == other.totalTokens && + traceMaxStartTime == other.traceMaxStartTime && + traceMinStartTime == other.traceMinStartTime && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + dottedOrder, + name, + runType, + status, + traceId, + childRunIds, + completionCost, + completionCostDetails, + completionTokenDetails, + completionTokens, + directChildRunIds, + endTime, + error, + events, + executionOrder, + extra, + feedbackStats, + firstTokenTime, + inputs, + inputsPreview, + inputsS3Urls, + manifestId, + manifestS3Id, + outputs, + outputsPreview, + outputsS3Urls, + parentRunId, + parentRunIds, + priceModelId, + promptCost, + promptCostDetails, + promptTokenDetails, + promptTokens, + referenceExampleId, + s3Urls, + serialized, + startTime, + tags, + totalCost, + totalTokens, + traceMaxStartTime, + traceMinStartTime, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RunPublicSchema{id=$id, dottedOrder=$dottedOrder, name=$name, runType=$runType, status=$status, traceId=$traceId, childRunIds=$childRunIds, completionCost=$completionCost, completionCostDetails=$completionCostDetails, completionTokenDetails=$completionTokenDetails, completionTokens=$completionTokens, directChildRunIds=$directChildRunIds, endTime=$endTime, error=$error, events=$events, executionOrder=$executionOrder, extra=$extra, feedbackStats=$feedbackStats, firstTokenTime=$firstTokenTime, inputs=$inputs, inputsPreview=$inputsPreview, inputsS3Urls=$inputsS3Urls, manifestId=$manifestId, manifestS3Id=$manifestS3Id, outputs=$outputs, outputsPreview=$outputsPreview, outputsS3Urls=$outputsS3Urls, parentRunId=$parentRunId, parentRunIds=$parentRunIds, priceModelId=$priceModelId, promptCost=$promptCost, promptCostDetails=$promptCostDetails, promptTokenDetails=$promptTokenDetails, promptTokens=$promptTokens, referenceExampleId=$referenceExampleId, s3Urls=$s3Urls, serialized=$serialized, startTime=$startTime, tags=$tags, totalCost=$totalCost, totalTokens=$totalTokens, traceMaxStartTime=$traceMaxStartTime, traceMinStartTime=$traceMinStartTime, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunQueryParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunQueryParams.kt new file mode 100644 index 00000000..4b0577df --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunQueryParams.kt @@ -0,0 +1,431 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.runs + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get run by ids or the shared run if not specifed. */ +class RunQueryParams +private constructor( + private val shareToken: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun shareToken(): Optional<String> = Optional.ofNullable(shareToken) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional<List<String>> = body.id() + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _id(): JsonField<List<String>> = body._id() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): RunQueryParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [RunQueryParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunQueryParams]. */ + class Builder internal constructor() { + + private var shareToken: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(runQueryParams: RunQueryParams) = apply { + shareToken = runQueryParams.shareToken + body = runQueryParams.body.toBuilder() + additionalHeaders = runQueryParams.additionalHeaders.toBuilder() + additionalQueryParams = runQueryParams.additionalQueryParams.toBuilder() + } + + fun shareToken(shareToken: String?) = apply { this.shareToken = shareToken } + + /** Alias for calling [Builder.shareToken] with `shareToken.orElse(null)`. */ + fun shareToken(shareToken: Optional<String>) = shareToken(shareToken.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [id] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun id(id: List<String>?) = apply { body.id(id) } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<List<String>>) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed `List<String>` value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<List<String>>) = apply { body.id(id) } + + /** + * Adds a single [String] to [Builder.id]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addId(id: String) = apply { body.addId(id) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RunQueryParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RunQueryParams = + RunQueryParams( + shareToken, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> shareToken ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Query params for public run endpoints. */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField<List<String>>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<List<String>> = JsonMissing.of() + ) : this(id, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun id(): Optional<List<String>> = id.getOptional("id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<List<String>> = id + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var id: JsonField<MutableList<String>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + id = body.id.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun id(id: List<String>?) = id(JsonField.ofNullable(id)) + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<List<String>>) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed `List<String>` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField<List<String>>) = apply { this.id = id.map { it.toMutableList() } } + + /** + * Adds a single [String] to [Builder.id]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addId(id: String) = apply { + this.id = + (this.id ?: JsonField.of(mutableListOf())).also { checkKnown("id", it).add(id) } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = + Body( + (id ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + id() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (id.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + id == other.id && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Body{id=$id, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunQueryParams && + shareToken == other.shareToken && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(shareToken, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "RunQueryParams{shareToken=$shareToken, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunQueryResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunQueryResponse.kt new file mode 100644 index 00000000..0935f159 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunQueryResponse.kt @@ -0,0 +1,363 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.runs + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class RunQueryResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val cursors: JsonField<Cursors>, + private val runs: JsonField<List<RunPublicSchema>>, + private val parsedQuery: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("cursors") @ExcludeMissing cursors: JsonField<Cursors> = JsonMissing.of(), + @JsonProperty("runs") + @ExcludeMissing + runs: JsonField<List<RunPublicSchema>> = JsonMissing.of(), + @JsonProperty("parsed_query") + @ExcludeMissing + parsedQuery: JsonField<String> = JsonMissing.of(), + ) : this(cursors, runs, parsedQuery, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cursors(): Cursors = cursors.getRequired("cursors") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun runs(): List<RunPublicSchema> = runs.getRequired("runs") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun parsedQuery(): Optional<String> = parsedQuery.getOptional("parsed_query") + + /** + * Returns the raw JSON value of [cursors]. + * + * Unlike [cursors], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cursors") @ExcludeMissing fun _cursors(): JsonField<Cursors> = cursors + + /** + * Returns the raw JSON value of [runs]. + * + * Unlike [runs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("runs") @ExcludeMissing fun _runs(): JsonField<List<RunPublicSchema>> = runs + + /** + * Returns the raw JSON value of [parsedQuery]. + * + * Unlike [parsedQuery], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("parsed_query") + @ExcludeMissing + fun _parsedQuery(): JsonField<String> = parsedQuery + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RunQueryResponse]. + * + * The following fields are required: + * ```java + * .cursors() + * .runs() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunQueryResponse]. */ + class Builder internal constructor() { + + private var cursors: JsonField<Cursors>? = null + private var runs: JsonField<MutableList<RunPublicSchema>>? = null + private var parsedQuery: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(runQueryResponse: RunQueryResponse) = apply { + cursors = runQueryResponse.cursors + runs = runQueryResponse.runs.map { it.toMutableList() } + parsedQuery = runQueryResponse.parsedQuery + additionalProperties = runQueryResponse.additionalProperties.toMutableMap() + } + + fun cursors(cursors: Cursors) = cursors(JsonField.of(cursors)) + + /** + * Sets [Builder.cursors] to an arbitrary JSON value. + * + * You should usually call [Builder.cursors] with a well-typed [Cursors] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun cursors(cursors: JsonField<Cursors>) = apply { this.cursors = cursors } + + fun runs(runs: List<RunPublicSchema>) = runs(JsonField.of(runs)) + + /** + * Sets [Builder.runs] to an arbitrary JSON value. + * + * You should usually call [Builder.runs] with a well-typed `List<RunPublicSchema>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun runs(runs: JsonField<List<RunPublicSchema>>) = apply { + this.runs = runs.map { it.toMutableList() } + } + + /** + * Adds a single [RunPublicSchema] to [runs]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRun(run: RunPublicSchema) = apply { + runs = (runs ?: JsonField.of(mutableListOf())).also { checkKnown("runs", it).add(run) } + } + + fun parsedQuery(parsedQuery: String?) = parsedQuery(JsonField.ofNullable(parsedQuery)) + + /** Alias for calling [Builder.parsedQuery] with `parsedQuery.orElse(null)`. */ + fun parsedQuery(parsedQuery: Optional<String>) = parsedQuery(parsedQuery.getOrNull()) + + /** + * Sets [Builder.parsedQuery] to an arbitrary JSON value. + * + * You should usually call [Builder.parsedQuery] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun parsedQuery(parsedQuery: JsonField<String>) = apply { this.parsedQuery = parsedQuery } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RunQueryResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cursors() + * .runs() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RunQueryResponse = + RunQueryResponse( + checkRequired("cursors", cursors), + checkRequired("runs", runs).map { it.toImmutable() }, + parsedQuery, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RunQueryResponse = apply { + if (validated) { + return@apply + } + + cursors().validate() + runs().forEach { it.validate() } + parsedQuery() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cursors.asKnown().getOrNull()?.validity() ?: 0) + + (runs.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (parsedQuery.asKnown().isPresent) 1 else 0) + + class Cursors + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Cursors]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Cursors]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(cursors: Cursors) = apply { + additionalProperties = cursors.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Cursors]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Cursors = Cursors(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Cursors = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cursors && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Cursors{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunQueryResponse && + cursors == other.cursors && + runs == other.runs && + parsedQuery == other.parsedQuery && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(cursors, runs, parsedQuery, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RunQueryResponse{cursors=$cursors, runs=$runs, parsedQuery=$parsedQuery, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunRetrieveParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunRetrieveParams.kt new file mode 100644 index 00000000..b4c7f7eb --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunRetrieveParams.kt @@ -0,0 +1,258 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.runs + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get the shared run. */ +class RunRetrieveParams +private constructor( + private val shareToken: String, + private val id: String?, + private val excludeS3StoredAttributes: Boolean?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun shareToken(): String = shareToken + + fun id(): Optional<String> = Optional.ofNullable(id) + + fun excludeS3StoredAttributes(): Optional<Boolean> = + Optional.ofNullable(excludeS3StoredAttributes) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RunRetrieveParams]. + * + * The following fields are required: + * ```java + * .shareToken() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunRetrieveParams]. */ + class Builder internal constructor() { + + private var shareToken: String? = null + private var id: String? = null + private var excludeS3StoredAttributes: Boolean? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(runRetrieveParams: RunRetrieveParams) = apply { + shareToken = runRetrieveParams.shareToken + id = runRetrieveParams.id + excludeS3StoredAttributes = runRetrieveParams.excludeS3StoredAttributes + additionalHeaders = runRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = runRetrieveParams.additionalQueryParams.toBuilder() + } + + fun shareToken(shareToken: String) = apply { this.shareToken = shareToken } + + fun id(id: String?) = apply { this.id = id } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<String>) = id(id.getOrNull()) + + fun excludeS3StoredAttributes(excludeS3StoredAttributes: Boolean?) = apply { + this.excludeS3StoredAttributes = excludeS3StoredAttributes + } + + /** + * Alias for [Builder.excludeS3StoredAttributes]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun excludeS3StoredAttributes(excludeS3StoredAttributes: Boolean) = + excludeS3StoredAttributes(excludeS3StoredAttributes as Boolean?) + + /** + * Alias for calling [Builder.excludeS3StoredAttributes] with + * `excludeS3StoredAttributes.orElse(null)`. + */ + fun excludeS3StoredAttributes(excludeS3StoredAttributes: Optional<Boolean>) = + excludeS3StoredAttributes(excludeS3StoredAttributes.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RunRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .shareToken() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RunRetrieveParams = + RunRetrieveParams( + checkRequired("shareToken", shareToken), + id, + excludeS3StoredAttributes, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> shareToken + 1 -> id ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + excludeS3StoredAttributes?.let { + put("exclude_s3_stored_attributes", it.toString()) + } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunRetrieveParams && + shareToken == other.shareToken && + id == other.id && + excludeS3StoredAttributes == other.excludeS3StoredAttributes && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + shareToken, + id, + excludeS3StoredAttributes, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "RunRetrieveParams{shareToken=$shareToken, id=$id, excludeS3StoredAttributes=$excludeS3StoredAttributes, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/schemas/SchemaRetrieveMessageJsonParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/schemas/SchemaRetrieveMessageJsonParams.kt new file mode 100644 index 00000000..9e258a39 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/schemas/SchemaRetrieveMessageJsonParams.kt @@ -0,0 +1,198 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.schemas + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get Message Json Schema */ +class SchemaRetrieveMessageJsonParams +private constructor( + private val version: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun version(): Optional<String> = Optional.ofNullable(version) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): SchemaRetrieveMessageJsonParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [SchemaRetrieveMessageJsonParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SchemaRetrieveMessageJsonParams]. */ + class Builder internal constructor() { + + private var version: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(schemaRetrieveMessageJsonParams: SchemaRetrieveMessageJsonParams) = + apply { + version = schemaRetrieveMessageJsonParams.version + additionalHeaders = schemaRetrieveMessageJsonParams.additionalHeaders.toBuilder() + additionalQueryParams = + schemaRetrieveMessageJsonParams.additionalQueryParams.toBuilder() + } + + fun version(version: String?) = apply { this.version = version } + + /** Alias for calling [Builder.version] with `version.orElse(null)`. */ + fun version(version: Optional<String>) = version(version.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SchemaRetrieveMessageJsonParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SchemaRetrieveMessageJsonParams = + SchemaRetrieveMessageJsonParams( + version, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> version ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SchemaRetrieveMessageJsonParams && + version == other.version && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(version, additionalHeaders, additionalQueryParams) + + override fun toString() = + "SchemaRetrieveMessageJsonParams{version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/schemas/SchemaRetrieveMessageJsonResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/schemas/SchemaRetrieveMessageJsonResponse.kt new file mode 100644 index 00000000..9230650a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/schemas/SchemaRetrieveMessageJsonResponse.kt @@ -0,0 +1,121 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.schemas + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class SchemaRetrieveMessageJsonResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SchemaRetrieveMessageJsonResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SchemaRetrieveMessageJsonResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(schemaRetrieveMessageJsonResponse: SchemaRetrieveMessageJsonResponse) = + apply { + additionalProperties = + schemaRetrieveMessageJsonResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SchemaRetrieveMessageJsonResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SchemaRetrieveMessageJsonResponse = + SchemaRetrieveMessageJsonResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): SchemaRetrieveMessageJsonResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SchemaRetrieveMessageJsonResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SchemaRetrieveMessageJsonResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/schemas/SchemaRetrieveTooldefJsonParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/schemas/SchemaRetrieveTooldefJsonParams.kt new file mode 100644 index 00000000..271c6902 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/schemas/SchemaRetrieveTooldefJsonParams.kt @@ -0,0 +1,198 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.schemas + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get Tool Def Json Schema */ +class SchemaRetrieveTooldefJsonParams +private constructor( + private val version: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun version(): Optional<String> = Optional.ofNullable(version) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): SchemaRetrieveTooldefJsonParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [SchemaRetrieveTooldefJsonParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SchemaRetrieveTooldefJsonParams]. */ + class Builder internal constructor() { + + private var version: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(schemaRetrieveTooldefJsonParams: SchemaRetrieveTooldefJsonParams) = + apply { + version = schemaRetrieveTooldefJsonParams.version + additionalHeaders = schemaRetrieveTooldefJsonParams.additionalHeaders.toBuilder() + additionalQueryParams = + schemaRetrieveTooldefJsonParams.additionalQueryParams.toBuilder() + } + + fun version(version: String?) = apply { this.version = version } + + /** Alias for calling [Builder.version] with `version.orElse(null)`. */ + fun version(version: Optional<String>) = version(version.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SchemaRetrieveTooldefJsonParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SchemaRetrieveTooldefJsonParams = + SchemaRetrieveTooldefJsonParams( + version, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> version ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SchemaRetrieveTooldefJsonParams && + version == other.version && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(version, additionalHeaders, additionalQueryParams) + + override fun toString() = + "SchemaRetrieveTooldefJsonParams{version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/schemas/SchemaRetrieveTooldefJsonResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/schemas/SchemaRetrieveTooldefJsonResponse.kt new file mode 100644 index 00000000..149526d4 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/public_/schemas/SchemaRetrieveTooldefJsonResponse.kt @@ -0,0 +1,121 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.schemas + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class SchemaRetrieveTooldefJsonResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SchemaRetrieveTooldefJsonResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SchemaRetrieveTooldefJsonResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(schemaRetrieveTooldefJsonResponse: SchemaRetrieveTooldefJsonResponse) = + apply { + additionalProperties = + schemaRetrieveTooldefJsonResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SchemaRetrieveTooldefJsonResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SchemaRetrieveTooldefJsonResponse = + SchemaRetrieveTooldefJsonResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): SchemaRetrieveTooldefJsonResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SchemaRetrieveTooldefJsonResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SchemaRetrieveTooldefJsonResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/CreateRepoResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/CreateRepoResponse.kt new file mode 100644 index 00000000..d833012d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/CreateRepoResponse.kt @@ -0,0 +1,172 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class CreateRepoResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val repo: JsonField<RepoWithLookups>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("repo") @ExcludeMissing repo: JsonField<RepoWithLookups> = JsonMissing.of() + ) : this(repo, mutableMapOf()) + + /** + * All database fields for repos, plus helpful computed fields. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun repo(): RepoWithLookups = repo.getRequired("repo") + + /** + * Returns the raw JSON value of [repo]. + * + * Unlike [repo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("repo") @ExcludeMissing fun _repo(): JsonField<RepoWithLookups> = repo + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CreateRepoResponse]. + * + * The following fields are required: + * ```java + * .repo() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreateRepoResponse]. */ + class Builder internal constructor() { + + private var repo: JsonField<RepoWithLookups>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(createRepoResponse: CreateRepoResponse) = apply { + repo = createRepoResponse.repo + additionalProperties = createRepoResponse.additionalProperties.toMutableMap() + } + + /** All database fields for repos, plus helpful computed fields. */ + fun repo(repo: RepoWithLookups) = repo(JsonField.of(repo)) + + /** + * Sets [Builder.repo] to an arbitrary JSON value. + * + * You should usually call [Builder.repo] with a well-typed [RepoWithLookups] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun repo(repo: JsonField<RepoWithLookups>) = apply { this.repo = repo } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CreateRepoResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .repo() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CreateRepoResponse = + CreateRepoResponse(checkRequired("repo", repo), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): CreateRepoResponse = apply { + if (validated) { + return@apply + } + + repo().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (repo.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreateRepoResponse && + repo == other.repo && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(repo, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreateRepoResponse{repo=$repo, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/DemoConfig.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/DemoConfig.kt new file mode 100644 index 00000000..3210850b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/DemoConfig.kt @@ -0,0 +1,290 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class DemoConfig +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val examples: JsonField<List<JsonValue>>, + private val messageIndex: JsonField<Long>, + private val metaprompt: JsonValue, + private val overallFeedback: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("examples") + @ExcludeMissing + examples: JsonField<List<JsonValue>> = JsonMissing.of(), + @JsonProperty("message_index") + @ExcludeMissing + messageIndex: JsonField<Long> = JsonMissing.of(), + @JsonProperty("metaprompt") @ExcludeMissing metaprompt: JsonValue = JsonMissing.of(), + @JsonProperty("overall_feedback") + @ExcludeMissing + overallFeedback: JsonField<String> = JsonMissing.of(), + ) : this(examples, messageIndex, metaprompt, overallFeedback, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun examples(): List<JsonValue> = examples.getRequired("examples") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun messageIndex(): Long = messageIndex.getRequired("message_index") + + @JsonProperty("metaprompt") @ExcludeMissing fun _metaprompt(): JsonValue = metaprompt + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun overallFeedback(): Optional<String> = overallFeedback.getOptional("overall_feedback") + + /** + * Returns the raw JSON value of [examples]. + * + * Unlike [examples], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("examples") @ExcludeMissing fun _examples(): JsonField<List<JsonValue>> = examples + + /** + * Returns the raw JSON value of [messageIndex]. + * + * Unlike [messageIndex], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message_index") + @ExcludeMissing + fun _messageIndex(): JsonField<Long> = messageIndex + + /** + * Returns the raw JSON value of [overallFeedback]. + * + * Unlike [overallFeedback], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("overall_feedback") + @ExcludeMissing + fun _overallFeedback(): JsonField<String> = overallFeedback + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DemoConfig]. + * + * The following fields are required: + * ```java + * .examples() + * .messageIndex() + * .metaprompt() + * .overallFeedback() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DemoConfig]. */ + class Builder internal constructor() { + + private var examples: JsonField<MutableList<JsonValue>>? = null + private var messageIndex: JsonField<Long>? = null + private var metaprompt: JsonValue? = null + private var overallFeedback: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(demoConfig: DemoConfig) = apply { + examples = demoConfig.examples.map { it.toMutableList() } + messageIndex = demoConfig.messageIndex + metaprompt = demoConfig.metaprompt + overallFeedback = demoConfig.overallFeedback + additionalProperties = demoConfig.additionalProperties.toMutableMap() + } + + fun examples(examples: List<JsonValue>) = examples(JsonField.of(examples)) + + /** + * Sets [Builder.examples] to an arbitrary JSON value. + * + * You should usually call [Builder.examples] with a well-typed `List<JsonValue>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun examples(examples: JsonField<List<JsonValue>>) = apply { + this.examples = examples.map { it.toMutableList() } + } + + /** + * Adds a single [JsonValue] to [examples]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExample(example: JsonValue) = apply { + examples = + (examples ?: JsonField.of(mutableListOf())).also { + checkKnown("examples", it).add(example) + } + } + + fun messageIndex(messageIndex: Long) = messageIndex(JsonField.of(messageIndex)) + + /** + * Sets [Builder.messageIndex] to an arbitrary JSON value. + * + * You should usually call [Builder.messageIndex] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun messageIndex(messageIndex: JsonField<Long>) = apply { this.messageIndex = messageIndex } + + fun metaprompt(metaprompt: JsonValue) = apply { this.metaprompt = metaprompt } + + fun overallFeedback(overallFeedback: String?) = + overallFeedback(JsonField.ofNullable(overallFeedback)) + + /** Alias for calling [Builder.overallFeedback] with `overallFeedback.orElse(null)`. */ + fun overallFeedback(overallFeedback: Optional<String>) = + overallFeedback(overallFeedback.getOrNull()) + + /** + * Sets [Builder.overallFeedback] to an arbitrary JSON value. + * + * You should usually call [Builder.overallFeedback] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun overallFeedback(overallFeedback: JsonField<String>) = apply { + this.overallFeedback = overallFeedback + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DemoConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .examples() + * .messageIndex() + * .metaprompt() + * .overallFeedback() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DemoConfig = + DemoConfig( + checkRequired("examples", examples).map { it.toImmutable() }, + checkRequired("messageIndex", messageIndex), + checkRequired("metaprompt", metaprompt), + checkRequired("overallFeedback", overallFeedback), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DemoConfig = apply { + if (validated) { + return@apply + } + + examples() + messageIndex() + overallFeedback() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (examples.asKnown().getOrNull()?.size ?: 0) + + (if (messageIndex.asKnown().isPresent) 1 else 0) + + (if (overallFeedback.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DemoConfig && + examples == other.examples && + messageIndex == other.messageIndex && + metaprompt == other.metaprompt && + overallFeedback == other.overallFeedback && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(examples, messageIndex, metaprompt, overallFeedback, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DemoConfig{examples=$examples, messageIndex=$messageIndex, metaprompt=$metaprompt, overallFeedback=$overallFeedback, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/EPromptOptimizationAlgorithm.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/EPromptOptimizationAlgorithm.kt new file mode 100644 index 00000000..17181c61 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/EPromptOptimizationAlgorithm.kt @@ -0,0 +1,143 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos + +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException + +class EPromptOptimizationAlgorithm +@JsonCreator +private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't match + * any known member, and you want to know that value. For example, if the SDK is on an older + * version than the API, then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val PROMPTIM = of("promptim") + + @JvmField val DEMO = of("demo") + + @JvmStatic fun of(value: String) = EPromptOptimizationAlgorithm(JsonField.of(value)) + } + + /** An enum containing [EPromptOptimizationAlgorithm]'s known values. */ + enum class Known { + PROMPTIM, + DEMO, + } + + /** + * An enum containing [EPromptOptimizationAlgorithm]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [EPromptOptimizationAlgorithm] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, if the SDK + * is on an older version than the API, then the API may respond with new members that the SDK + * is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PROMPTIM, + DEMO, + /** + * An enum member indicating that [EPromptOptimizationAlgorithm] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if + * the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want to + * throw for the unknown case. + */ + fun value(): Value = + when (this) { + PROMPTIM -> Value.PROMPTIM + DEMO -> Value.DEMO + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't want + * to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PROMPTIM -> Known.PROMPTIM + DEMO -> Known.DEMO + else -> + throw LangsmithApiInvalidDataException( + "Unknown EPromptOptimizationAlgorithm: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): EPromptOptimizationAlgorithm = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EPromptOptimizationAlgorithm && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/GetRepoResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/GetRepoResponse.kt new file mode 100644 index 00000000..2b91a85b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/GetRepoResponse.kt @@ -0,0 +1,172 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class GetRepoResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val repo: JsonField<RepoWithLookups>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("repo") @ExcludeMissing repo: JsonField<RepoWithLookups> = JsonMissing.of() + ) : this(repo, mutableMapOf()) + + /** + * All database fields for repos, plus helpful computed fields. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun repo(): RepoWithLookups = repo.getRequired("repo") + + /** + * Returns the raw JSON value of [repo]. + * + * Unlike [repo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("repo") @ExcludeMissing fun _repo(): JsonField<RepoWithLookups> = repo + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [GetRepoResponse]. + * + * The following fields are required: + * ```java + * .repo() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GetRepoResponse]. */ + class Builder internal constructor() { + + private var repo: JsonField<RepoWithLookups>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(getRepoResponse: GetRepoResponse) = apply { + repo = getRepoResponse.repo + additionalProperties = getRepoResponse.additionalProperties.toMutableMap() + } + + /** All database fields for repos, plus helpful computed fields. */ + fun repo(repo: RepoWithLookups) = repo(JsonField.of(repo)) + + /** + * Sets [Builder.repo] to an arbitrary JSON value. + * + * You should usually call [Builder.repo] with a well-typed [RepoWithLookups] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun repo(repo: JsonField<RepoWithLookups>) = apply { this.repo = repo } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GetRepoResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .repo() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GetRepoResponse = + GetRepoResponse(checkRequired("repo", repo), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): GetRepoResponse = apply { + if (validated) { + return@apply + } + + repo().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (repo.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GetRepoResponse && + repo == other.repo && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(repo, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GetRepoResponse{repo=$repo, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/PromptimConfig.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/PromptimConfig.kt new file mode 100644 index 00000000..d2fa112a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/PromptimConfig.kt @@ -0,0 +1,517 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class PromptimConfig +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val autoCommit: JsonField<Boolean>, + private val datasetName: JsonField<String>, + private val devSplit: JsonField<String>, + private val evaluators: JsonField<List<String>>, + private val messageIndex: JsonField<Long>, + private val numEpochs: JsonField<Long>, + private val taskDescription: JsonField<String>, + private val testSplit: JsonField<String>, + private val trainSplit: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("auto_commit") + @ExcludeMissing + autoCommit: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("dataset_name") + @ExcludeMissing + datasetName: JsonField<String> = JsonMissing.of(), + @JsonProperty("dev_split") @ExcludeMissing devSplit: JsonField<String> = JsonMissing.of(), + @JsonProperty("evaluators") + @ExcludeMissing + evaluators: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("message_index") + @ExcludeMissing + messageIndex: JsonField<Long> = JsonMissing.of(), + @JsonProperty("num_epochs") @ExcludeMissing numEpochs: JsonField<Long> = JsonMissing.of(), + @JsonProperty("task_description") + @ExcludeMissing + taskDescription: JsonField<String> = JsonMissing.of(), + @JsonProperty("test_split") @ExcludeMissing testSplit: JsonField<String> = JsonMissing.of(), + @JsonProperty("train_split") + @ExcludeMissing + trainSplit: JsonField<String> = JsonMissing.of(), + ) : this( + autoCommit, + datasetName, + devSplit, + evaluators, + messageIndex, + numEpochs, + taskDescription, + testSplit, + trainSplit, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun autoCommit(): Boolean = autoCommit.getRequired("auto_commit") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun datasetName(): String = datasetName.getRequired("dataset_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun devSplit(): Optional<String> = devSplit.getOptional("dev_split") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun evaluators(): List<String> = evaluators.getRequired("evaluators") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun messageIndex(): Long = messageIndex.getRequired("message_index") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun numEpochs(): Long = numEpochs.getRequired("num_epochs") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun taskDescription(): String = taskDescription.getRequired("task_description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun testSplit(): Optional<String> = testSplit.getOptional("test_split") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun trainSplit(): Optional<String> = trainSplit.getOptional("train_split") + + /** + * Returns the raw JSON value of [autoCommit]. + * + * Unlike [autoCommit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("auto_commit") @ExcludeMissing fun _autoCommit(): JsonField<Boolean> = autoCommit + + /** + * Returns the raw JSON value of [datasetName]. + * + * Unlike [datasetName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dataset_name") + @ExcludeMissing + fun _datasetName(): JsonField<String> = datasetName + + /** + * Returns the raw JSON value of [devSplit]. + * + * Unlike [devSplit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dev_split") @ExcludeMissing fun _devSplit(): JsonField<String> = devSplit + + /** + * Returns the raw JSON value of [evaluators]. + * + * Unlike [evaluators], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("evaluators") + @ExcludeMissing + fun _evaluators(): JsonField<List<String>> = evaluators + + /** + * Returns the raw JSON value of [messageIndex]. + * + * Unlike [messageIndex], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message_index") + @ExcludeMissing + fun _messageIndex(): JsonField<Long> = messageIndex + + /** + * Returns the raw JSON value of [numEpochs]. + * + * Unlike [numEpochs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("num_epochs") @ExcludeMissing fun _numEpochs(): JsonField<Long> = numEpochs + + /** + * Returns the raw JSON value of [taskDescription]. + * + * Unlike [taskDescription], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("task_description") + @ExcludeMissing + fun _taskDescription(): JsonField<String> = taskDescription + + /** + * Returns the raw JSON value of [testSplit]. + * + * Unlike [testSplit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("test_split") @ExcludeMissing fun _testSplit(): JsonField<String> = testSplit + + /** + * Returns the raw JSON value of [trainSplit]. + * + * Unlike [trainSplit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("train_split") @ExcludeMissing fun _trainSplit(): JsonField<String> = trainSplit + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PromptimConfig]. + * + * The following fields are required: + * ```java + * .autoCommit() + * .datasetName() + * .devSplit() + * .evaluators() + * .messageIndex() + * .numEpochs() + * .taskDescription() + * .testSplit() + * .trainSplit() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PromptimConfig]. */ + class Builder internal constructor() { + + private var autoCommit: JsonField<Boolean>? = null + private var datasetName: JsonField<String>? = null + private var devSplit: JsonField<String>? = null + private var evaluators: JsonField<MutableList<String>>? = null + private var messageIndex: JsonField<Long>? = null + private var numEpochs: JsonField<Long>? = null + private var taskDescription: JsonField<String>? = null + private var testSplit: JsonField<String>? = null + private var trainSplit: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(promptimConfig: PromptimConfig) = apply { + autoCommit = promptimConfig.autoCommit + datasetName = promptimConfig.datasetName + devSplit = promptimConfig.devSplit + evaluators = promptimConfig.evaluators.map { it.toMutableList() } + messageIndex = promptimConfig.messageIndex + numEpochs = promptimConfig.numEpochs + taskDescription = promptimConfig.taskDescription + testSplit = promptimConfig.testSplit + trainSplit = promptimConfig.trainSplit + additionalProperties = promptimConfig.additionalProperties.toMutableMap() + } + + fun autoCommit(autoCommit: Boolean) = autoCommit(JsonField.of(autoCommit)) + + /** + * Sets [Builder.autoCommit] to an arbitrary JSON value. + * + * You should usually call [Builder.autoCommit] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun autoCommit(autoCommit: JsonField<Boolean>) = apply { this.autoCommit = autoCommit } + + fun datasetName(datasetName: String) = datasetName(JsonField.of(datasetName)) + + /** + * Sets [Builder.datasetName] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun datasetName(datasetName: JsonField<String>) = apply { this.datasetName = datasetName } + + fun devSplit(devSplit: String?) = devSplit(JsonField.ofNullable(devSplit)) + + /** Alias for calling [Builder.devSplit] with `devSplit.orElse(null)`. */ + fun devSplit(devSplit: Optional<String>) = devSplit(devSplit.getOrNull()) + + /** + * Sets [Builder.devSplit] to an arbitrary JSON value. + * + * You should usually call [Builder.devSplit] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun devSplit(devSplit: JsonField<String>) = apply { this.devSplit = devSplit } + + fun evaluators(evaluators: List<String>) = evaluators(JsonField.of(evaluators)) + + /** + * Sets [Builder.evaluators] to an arbitrary JSON value. + * + * You should usually call [Builder.evaluators] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun evaluators(evaluators: JsonField<List<String>>) = apply { + this.evaluators = evaluators.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [evaluators]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvaluator(evaluator: String) = apply { + evaluators = + (evaluators ?: JsonField.of(mutableListOf())).also { + checkKnown("evaluators", it).add(evaluator) + } + } + + fun messageIndex(messageIndex: Long) = messageIndex(JsonField.of(messageIndex)) + + /** + * Sets [Builder.messageIndex] to an arbitrary JSON value. + * + * You should usually call [Builder.messageIndex] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun messageIndex(messageIndex: JsonField<Long>) = apply { this.messageIndex = messageIndex } + + fun numEpochs(numEpochs: Long) = numEpochs(JsonField.of(numEpochs)) + + /** + * Sets [Builder.numEpochs] to an arbitrary JSON value. + * + * You should usually call [Builder.numEpochs] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun numEpochs(numEpochs: JsonField<Long>) = apply { this.numEpochs = numEpochs } + + fun taskDescription(taskDescription: String) = + taskDescription(JsonField.of(taskDescription)) + + /** + * Sets [Builder.taskDescription] to an arbitrary JSON value. + * + * You should usually call [Builder.taskDescription] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun taskDescription(taskDescription: JsonField<String>) = apply { + this.taskDescription = taskDescription + } + + fun testSplit(testSplit: String?) = testSplit(JsonField.ofNullable(testSplit)) + + /** Alias for calling [Builder.testSplit] with `testSplit.orElse(null)`. */ + fun testSplit(testSplit: Optional<String>) = testSplit(testSplit.getOrNull()) + + /** + * Sets [Builder.testSplit] to an arbitrary JSON value. + * + * You should usually call [Builder.testSplit] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun testSplit(testSplit: JsonField<String>) = apply { this.testSplit = testSplit } + + fun trainSplit(trainSplit: String?) = trainSplit(JsonField.ofNullable(trainSplit)) + + /** Alias for calling [Builder.trainSplit] with `trainSplit.orElse(null)`. */ + fun trainSplit(trainSplit: Optional<String>) = trainSplit(trainSplit.getOrNull()) + + /** + * Sets [Builder.trainSplit] to an arbitrary JSON value. + * + * You should usually call [Builder.trainSplit] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun trainSplit(trainSplit: JsonField<String>) = apply { this.trainSplit = trainSplit } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PromptimConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .autoCommit() + * .datasetName() + * .devSplit() + * .evaluators() + * .messageIndex() + * .numEpochs() + * .taskDescription() + * .testSplit() + * .trainSplit() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PromptimConfig = + PromptimConfig( + checkRequired("autoCommit", autoCommit), + checkRequired("datasetName", datasetName), + checkRequired("devSplit", devSplit), + checkRequired("evaluators", evaluators).map { it.toImmutable() }, + checkRequired("messageIndex", messageIndex), + checkRequired("numEpochs", numEpochs), + checkRequired("taskDescription", taskDescription), + checkRequired("testSplit", testSplit), + checkRequired("trainSplit", trainSplit), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PromptimConfig = apply { + if (validated) { + return@apply + } + + autoCommit() + datasetName() + devSplit() + evaluators() + messageIndex() + numEpochs() + taskDescription() + testSplit() + trainSplit() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (autoCommit.asKnown().isPresent) 1 else 0) + + (if (datasetName.asKnown().isPresent) 1 else 0) + + (if (devSplit.asKnown().isPresent) 1 else 0) + + (evaluators.asKnown().getOrNull()?.size ?: 0) + + (if (messageIndex.asKnown().isPresent) 1 else 0) + + (if (numEpochs.asKnown().isPresent) 1 else 0) + + (if (taskDescription.asKnown().isPresent) 1 else 0) + + (if (testSplit.asKnown().isPresent) 1 else 0) + + (if (trainSplit.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PromptimConfig && + autoCommit == other.autoCommit && + datasetName == other.datasetName && + devSplit == other.devSplit && + evaluators == other.evaluators && + messageIndex == other.messageIndex && + numEpochs == other.numEpochs && + taskDescription == other.taskDescription && + testSplit == other.testSplit && + trainSplit == other.trainSplit && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + autoCommit, + datasetName, + devSplit, + evaluators, + messageIndex, + numEpochs, + taskDescription, + testSplit, + trainSplit, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PromptimConfig{autoCommit=$autoCommit, datasetName=$datasetName, devSplit=$devSplit, evaluators=$evaluators, messageIndex=$messageIndex, numEpochs=$numEpochs, taskDescription=$taskDescription, testSplit=$testSplit, trainSplit=$trainSplit, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoCreateParams.kt new file mode 100644 index 00000000..0fff1a96 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoCreateParams.kt @@ -0,0 +1,699 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create a repo. */ +class RepoCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun isPublic(): Boolean = body.isPublic() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun repoHandle(): String = body.repoHandle() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = body.description() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun readme(): Optional<String> = body.readme() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tags(): Optional<List<String>> = body.tags() + + /** + * Returns the raw JSON value of [isPublic]. + * + * Unlike [isPublic], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _isPublic(): JsonField<Boolean> = body._isPublic() + + /** + * Returns the raw JSON value of [repoHandle]. + * + * Unlike [repoHandle], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _repoHandle(): JsonField<String> = body._repoHandle() + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _description(): JsonField<String> = body._description() + + /** + * Returns the raw JSON value of [readme]. + * + * Unlike [readme], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _readme(): JsonField<String> = body._readme() + + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _tags(): JsonField<List<String>> = body._tags() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RepoCreateParams]. + * + * The following fields are required: + * ```java + * .isPublic() + * .repoHandle() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RepoCreateParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(repoCreateParams: RepoCreateParams) = apply { + body = repoCreateParams.body.toBuilder() + additionalHeaders = repoCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = repoCreateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [isPublic] + * - [repoHandle] + * - [description] + * - [readme] + * - [tags] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun isPublic(isPublic: Boolean) = apply { body.isPublic(isPublic) } + + /** + * Sets [Builder.isPublic] to an arbitrary JSON value. + * + * You should usually call [Builder.isPublic] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isPublic(isPublic: JsonField<Boolean>) = apply { body.isPublic(isPublic) } + + fun repoHandle(repoHandle: String) = apply { body.repoHandle(repoHandle) } + + /** + * Sets [Builder.repoHandle] to an arbitrary JSON value. + * + * You should usually call [Builder.repoHandle] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun repoHandle(repoHandle: JsonField<String>) = apply { body.repoHandle(repoHandle) } + + fun description(description: String?) = apply { body.description(description) } + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { body.description(description) } + + fun readme(readme: String?) = apply { body.readme(readme) } + + /** Alias for calling [Builder.readme] with `readme.orElse(null)`. */ + fun readme(readme: Optional<String>) = readme(readme.getOrNull()) + + /** + * Sets [Builder.readme] to an arbitrary JSON value. + * + * You should usually call [Builder.readme] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun readme(readme: JsonField<String>) = apply { body.readme(readme) } + + fun tags(tags: List<String>?) = apply { body.tags(tags) } + + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ + fun tags(tags: Optional<List<String>>) = tags(tags.getOrNull()) + + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List<String>` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tags(tags: JsonField<List<String>>) = apply { body.tags(tags) } + + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { body.addTag(tag) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RepoCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .isPublic() + * .repoHandle() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RepoCreateParams = + RepoCreateParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Fields to create a repo */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val isPublic: JsonField<Boolean>, + private val repoHandle: JsonField<String>, + private val description: JsonField<String>, + private val readme: JsonField<String>, + private val tags: JsonField<List<String>>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("is_public") + @ExcludeMissing + isPublic: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("repo_handle") + @ExcludeMissing + repoHandle: JsonField<String> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("readme") @ExcludeMissing readme: JsonField<String> = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing tags: JsonField<List<String>> = JsonMissing.of(), + ) : this(isPublic, repoHandle, description, readme, tags, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun isPublic(): Boolean = isPublic.getRequired("is_public") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun repoHandle(): String = repoHandle.getRequired("repo_handle") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun readme(): Optional<String> = readme.getOptional("readme") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun tags(): Optional<List<String>> = tags.getOptional("tags") + + /** + * Returns the raw JSON value of [isPublic]. + * + * Unlike [isPublic], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_public") @ExcludeMissing fun _isPublic(): JsonField<Boolean> = isPublic + + /** + * Returns the raw JSON value of [repoHandle]. + * + * Unlike [repoHandle], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("repo_handle") + @ExcludeMissing + fun _repoHandle(): JsonField<String> = repoHandle + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [readme]. + * + * Unlike [readme], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("readme") @ExcludeMissing fun _readme(): JsonField<String> = readme + + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField<List<String>> = tags + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .isPublic() + * .repoHandle() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var isPublic: JsonField<Boolean>? = null + private var repoHandle: JsonField<String>? = null + private var description: JsonField<String> = JsonMissing.of() + private var readme: JsonField<String> = JsonMissing.of() + private var tags: JsonField<MutableList<String>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + isPublic = body.isPublic + repoHandle = body.repoHandle + description = body.description + readme = body.readme + tags = body.tags.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun isPublic(isPublic: Boolean) = isPublic(JsonField.of(isPublic)) + + /** + * Sets [Builder.isPublic] to an arbitrary JSON value. + * + * You should usually call [Builder.isPublic] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isPublic(isPublic: JsonField<Boolean>) = apply { this.isPublic = isPublic } + + fun repoHandle(repoHandle: String) = repoHandle(JsonField.of(repoHandle)) + + /** + * Sets [Builder.repoHandle] to an arbitrary JSON value. + * + * You should usually call [Builder.repoHandle] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun repoHandle(repoHandle: JsonField<String>) = apply { this.repoHandle = repoHandle } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField<String>) = apply { + this.description = description + } + + fun readme(readme: String?) = readme(JsonField.ofNullable(readme)) + + /** Alias for calling [Builder.readme] with `readme.orElse(null)`. */ + fun readme(readme: Optional<String>) = readme(readme.getOrNull()) + + /** + * Sets [Builder.readme] to an arbitrary JSON value. + * + * You should usually call [Builder.readme] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun readme(readme: JsonField<String>) = apply { this.readme = readme } + + fun tags(tags: List<String>?) = tags(JsonField.ofNullable(tags)) + + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ + fun tags(tags: Optional<List<String>>) = tags(tags.getOrNull()) + + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tags(tags: JsonField<List<String>>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { + tags = + (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .isPublic() + * .repoHandle() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("isPublic", isPublic), + checkRequired("repoHandle", repoHandle), + description, + readme, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + isPublic() + repoHandle() + description() + readme() + tags() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (isPublic.asKnown().isPresent) 1 else 0) + + (if (repoHandle.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (readme.asKnown().isPresent) 1 else 0) + + (tags.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + isPublic == other.isPublic && + repoHandle == other.repoHandle && + description == other.description && + readme == other.readme && + tags == other.tags && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(isPublic, repoHandle, description, readme, tags, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{isPublic=$isPublic, repoHandle=$repoHandle, description=$description, readme=$readme, tags=$tags, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RepoCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "RepoCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoDeleteParams.kt new file mode 100644 index 00000000..b308967f --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoDeleteParams.kt @@ -0,0 +1,258 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete a repo. */ +class RepoDeleteParams +private constructor( + private val owner: String, + private val repo: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun owner(): String = owner + + fun repo(): Optional<String> = Optional.ofNullable(repo) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RepoDeleteParams]. + * + * The following fields are required: + * ```java + * .owner() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RepoDeleteParams]. */ + class Builder internal constructor() { + + private var owner: String? = null + private var repo: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(repoDeleteParams: RepoDeleteParams) = apply { + owner = repoDeleteParams.owner + repo = repoDeleteParams.repo + additionalHeaders = repoDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = repoDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = repoDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun owner(owner: String) = apply { this.owner = owner } + + fun repo(repo: String?) = apply { this.repo = repo } + + /** Alias for calling [Builder.repo] with `repo.orElse(null)`. */ + fun repo(repo: Optional<String>) = repo(repo.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [RepoDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .owner() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RepoDeleteParams = + RepoDeleteParams( + checkRequired("owner", owner), + repo, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> owner + 1 -> repo ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RepoDeleteParams && + owner == other.owner && + repo == other.repo && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + owner, + repo, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "RepoDeleteParams{owner=$owner, repo=$repo, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoDeleteResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoDeleteResponse.kt new file mode 100644 index 00000000..d2fe6887 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoDeleteResponse.kt @@ -0,0 +1,113 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class RepoDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [RepoDeleteResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RepoDeleteResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(repoDeleteResponse: RepoDeleteResponse) = apply { + additionalProperties = repoDeleteResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RepoDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RepoDeleteResponse = RepoDeleteResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): RepoDeleteResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RepoDeleteResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "RepoDeleteResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoForkParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoForkParams.kt new file mode 100644 index 00000000..0ea9db5f --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoForkParams.kt @@ -0,0 +1,750 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Fork a repo. */ +class RepoForkParams +private constructor( + private val owner: String, + private val repo: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun owner(): String = owner + + fun repo(): Optional<String> = Optional.ofNullable(repo) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun repoHandle(): String = body.repoHandle() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = body.description() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun isPublic(): Optional<Boolean> = body.isPublic() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun readme(): Optional<String> = body.readme() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tags(): Optional<List<String>> = body.tags() + + /** + * Returns the raw JSON value of [repoHandle]. + * + * Unlike [repoHandle], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _repoHandle(): JsonField<String> = body._repoHandle() + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _description(): JsonField<String> = body._description() + + /** + * Returns the raw JSON value of [isPublic]. + * + * Unlike [isPublic], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _isPublic(): JsonField<Boolean> = body._isPublic() + + /** + * Returns the raw JSON value of [readme]. + * + * Unlike [readme], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _readme(): JsonField<String> = body._readme() + + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _tags(): JsonField<List<String>> = body._tags() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RepoForkParams]. + * + * The following fields are required: + * ```java + * .owner() + * .repoHandle() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RepoForkParams]. */ + class Builder internal constructor() { + + private var owner: String? = null + private var repo: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(repoForkParams: RepoForkParams) = apply { + owner = repoForkParams.owner + repo = repoForkParams.repo + body = repoForkParams.body.toBuilder() + additionalHeaders = repoForkParams.additionalHeaders.toBuilder() + additionalQueryParams = repoForkParams.additionalQueryParams.toBuilder() + } + + fun owner(owner: String) = apply { this.owner = owner } + + fun repo(repo: String?) = apply { this.repo = repo } + + /** Alias for calling [Builder.repo] with `repo.orElse(null)`. */ + fun repo(repo: Optional<String>) = repo(repo.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [repoHandle] + * - [description] + * - [isPublic] + * - [readme] + * - [tags] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun repoHandle(repoHandle: String) = apply { body.repoHandle(repoHandle) } + + /** + * Sets [Builder.repoHandle] to an arbitrary JSON value. + * + * You should usually call [Builder.repoHandle] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun repoHandle(repoHandle: JsonField<String>) = apply { body.repoHandle(repoHandle) } + + fun description(description: String?) = apply { body.description(description) } + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { body.description(description) } + + fun isPublic(isPublic: Boolean?) = apply { body.isPublic(isPublic) } + + /** + * Alias for [Builder.isPublic]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun isPublic(isPublic: Boolean) = isPublic(isPublic as Boolean?) + + /** Alias for calling [Builder.isPublic] with `isPublic.orElse(null)`. */ + fun isPublic(isPublic: Optional<Boolean>) = isPublic(isPublic.getOrNull()) + + /** + * Sets [Builder.isPublic] to an arbitrary JSON value. + * + * You should usually call [Builder.isPublic] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isPublic(isPublic: JsonField<Boolean>) = apply { body.isPublic(isPublic) } + + fun readme(readme: String?) = apply { body.readme(readme) } + + /** Alias for calling [Builder.readme] with `readme.orElse(null)`. */ + fun readme(readme: Optional<String>) = readme(readme.getOrNull()) + + /** + * Sets [Builder.readme] to an arbitrary JSON value. + * + * You should usually call [Builder.readme] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun readme(readme: JsonField<String>) = apply { body.readme(readme) } + + fun tags(tags: List<String>?) = apply { body.tags(tags) } + + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ + fun tags(tags: Optional<List<String>>) = tags(tags.getOrNull()) + + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List<String>` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tags(tags: JsonField<List<String>>) = apply { body.tags(tags) } + + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { body.addTag(tag) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RepoForkParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .owner() + * .repoHandle() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RepoForkParams = + RepoForkParams( + checkRequired("owner", owner), + repo, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> owner + 1 -> repo ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Fields to fork a repo */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val repoHandle: JsonField<String>, + private val description: JsonField<String>, + private val isPublic: JsonField<Boolean>, + private val readme: JsonField<String>, + private val tags: JsonField<List<String>>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("repo_handle") + @ExcludeMissing + repoHandle: JsonField<String> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("is_public") + @ExcludeMissing + isPublic: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("readme") @ExcludeMissing readme: JsonField<String> = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing tags: JsonField<List<String>> = JsonMissing.of(), + ) : this(repoHandle, description, isPublic, readme, tags, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun repoHandle(): String = repoHandle.getRequired("repo_handle") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun isPublic(): Optional<Boolean> = isPublic.getOptional("is_public") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun readme(): Optional<String> = readme.getOptional("readme") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun tags(): Optional<List<String>> = tags.getOptional("tags") + + /** + * Returns the raw JSON value of [repoHandle]. + * + * Unlike [repoHandle], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("repo_handle") + @ExcludeMissing + fun _repoHandle(): JsonField<String> = repoHandle + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [isPublic]. + * + * Unlike [isPublic], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_public") @ExcludeMissing fun _isPublic(): JsonField<Boolean> = isPublic + + /** + * Returns the raw JSON value of [readme]. + * + * Unlike [readme], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("readme") @ExcludeMissing fun _readme(): JsonField<String> = readme + + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField<List<String>> = tags + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .repoHandle() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var repoHandle: JsonField<String>? = null + private var description: JsonField<String> = JsonMissing.of() + private var isPublic: JsonField<Boolean> = JsonMissing.of() + private var readme: JsonField<String> = JsonMissing.of() + private var tags: JsonField<MutableList<String>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + repoHandle = body.repoHandle + description = body.description + isPublic = body.isPublic + readme = body.readme + tags = body.tags.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun repoHandle(repoHandle: String) = repoHandle(JsonField.of(repoHandle)) + + /** + * Sets [Builder.repoHandle] to an arbitrary JSON value. + * + * You should usually call [Builder.repoHandle] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun repoHandle(repoHandle: JsonField<String>) = apply { this.repoHandle = repoHandle } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField<String>) = apply { + this.description = description + } + + fun isPublic(isPublic: Boolean?) = isPublic(JsonField.ofNullable(isPublic)) + + /** + * Alias for [Builder.isPublic]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun isPublic(isPublic: Boolean) = isPublic(isPublic as Boolean?) + + /** Alias for calling [Builder.isPublic] with `isPublic.orElse(null)`. */ + fun isPublic(isPublic: Optional<Boolean>) = isPublic(isPublic.getOrNull()) + + /** + * Sets [Builder.isPublic] to an arbitrary JSON value. + * + * You should usually call [Builder.isPublic] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isPublic(isPublic: JsonField<Boolean>) = apply { this.isPublic = isPublic } + + fun readme(readme: String?) = readme(JsonField.ofNullable(readme)) + + /** Alias for calling [Builder.readme] with `readme.orElse(null)`. */ + fun readme(readme: Optional<String>) = readme(readme.getOrNull()) + + /** + * Sets [Builder.readme] to an arbitrary JSON value. + * + * You should usually call [Builder.readme] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun readme(readme: JsonField<String>) = apply { this.readme = readme } + + fun tags(tags: List<String>?) = tags(JsonField.ofNullable(tags)) + + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ + fun tags(tags: Optional<List<String>>) = tags(tags.getOrNull()) + + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tags(tags: JsonField<List<String>>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { + tags = + (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .repoHandle() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("repoHandle", repoHandle), + description, + isPublic, + readme, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + repoHandle() + description() + isPublic() + readme() + tags() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (repoHandle.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (isPublic.asKnown().isPresent) 1 else 0) + + (if (readme.asKnown().isPresent) 1 else 0) + + (tags.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + repoHandle == other.repoHandle && + description == other.description && + isPublic == other.isPublic && + readme == other.readme && + tags == other.tags && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(repoHandle, description, isPublic, readme, tags, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{repoHandle=$repoHandle, description=$description, isPublic=$isPublic, readme=$readme, tags=$tags, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RepoForkParams && + owner == other.owner && + repo == other.repo && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(owner, repo, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "RepoForkParams{owner=$owner, repo=$repo, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoListParams.kt new file mode 100644 index 00000000..52b16f9d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoListParams.kt @@ -0,0 +1,1002 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos + +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get all repos. */ +class RepoListParams +private constructor( + private val hasCommits: Boolean?, + private val isArchived: IsArchived?, + private val isPublic: IsPublic?, + private val limit: Long?, + private val offset: Long?, + private val query: String?, + private val sortDirection: SortDirection?, + private val sortField: SortField?, + private val tagValueId: List<String>?, + private val tags: List<String>?, + private val tenantHandle: String?, + private val tenantId: String?, + private val upstreamRepoHandle: String?, + private val upstreamRepoOwner: String?, + private val withLatestManifest: Boolean?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun hasCommits(): Optional<Boolean> = Optional.ofNullable(hasCommits) + + fun isArchived(): Optional<IsArchived> = Optional.ofNullable(isArchived) + + fun isPublic(): Optional<IsPublic> = Optional.ofNullable(isPublic) + + fun limit(): Optional<Long> = Optional.ofNullable(limit) + + fun offset(): Optional<Long> = Optional.ofNullable(offset) + + fun query(): Optional<String> = Optional.ofNullable(query) + + fun sortDirection(): Optional<SortDirection> = Optional.ofNullable(sortDirection) + + fun sortField(): Optional<SortField> = Optional.ofNullable(sortField) + + fun tagValueId(): Optional<List<String>> = Optional.ofNullable(tagValueId) + + fun tags(): Optional<List<String>> = Optional.ofNullable(tags) + + fun tenantHandle(): Optional<String> = Optional.ofNullable(tenantHandle) + + fun tenantId(): Optional<String> = Optional.ofNullable(tenantId) + + fun upstreamRepoHandle(): Optional<String> = Optional.ofNullable(upstreamRepoHandle) + + fun upstreamRepoOwner(): Optional<String> = Optional.ofNullable(upstreamRepoOwner) + + fun withLatestManifest(): Optional<Boolean> = Optional.ofNullable(withLatestManifest) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): RepoListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [RepoListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RepoListParams]. */ + class Builder internal constructor() { + + private var hasCommits: Boolean? = null + private var isArchived: IsArchived? = null + private var isPublic: IsPublic? = null + private var limit: Long? = null + private var offset: Long? = null + private var query: String? = null + private var sortDirection: SortDirection? = null + private var sortField: SortField? = null + private var tagValueId: MutableList<String>? = null + private var tags: MutableList<String>? = null + private var tenantHandle: String? = null + private var tenantId: String? = null + private var upstreamRepoHandle: String? = null + private var upstreamRepoOwner: String? = null + private var withLatestManifest: Boolean? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(repoListParams: RepoListParams) = apply { + hasCommits = repoListParams.hasCommits + isArchived = repoListParams.isArchived + isPublic = repoListParams.isPublic + limit = repoListParams.limit + offset = repoListParams.offset + query = repoListParams.query + sortDirection = repoListParams.sortDirection + sortField = repoListParams.sortField + tagValueId = repoListParams.tagValueId?.toMutableList() + tags = repoListParams.tags?.toMutableList() + tenantHandle = repoListParams.tenantHandle + tenantId = repoListParams.tenantId + upstreamRepoHandle = repoListParams.upstreamRepoHandle + upstreamRepoOwner = repoListParams.upstreamRepoOwner + withLatestManifest = repoListParams.withLatestManifest + additionalHeaders = repoListParams.additionalHeaders.toBuilder() + additionalQueryParams = repoListParams.additionalQueryParams.toBuilder() + } + + fun hasCommits(hasCommits: Boolean?) = apply { this.hasCommits = hasCommits } + + /** + * Alias for [Builder.hasCommits]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun hasCommits(hasCommits: Boolean) = hasCommits(hasCommits as Boolean?) + + /** Alias for calling [Builder.hasCommits] with `hasCommits.orElse(null)`. */ + fun hasCommits(hasCommits: Optional<Boolean>) = hasCommits(hasCommits.getOrNull()) + + fun isArchived(isArchived: IsArchived?) = apply { this.isArchived = isArchived } + + /** Alias for calling [Builder.isArchived] with `isArchived.orElse(null)`. */ + fun isArchived(isArchived: Optional<IsArchived>) = isArchived(isArchived.getOrNull()) + + fun isPublic(isPublic: IsPublic?) = apply { this.isPublic = isPublic } + + /** Alias for calling [Builder.isPublic] with `isPublic.orElse(null)`. */ + fun isPublic(isPublic: Optional<IsPublic>) = isPublic(isPublic.getOrNull()) + + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional<Long>) = limit(limit.getOrNull()) + + fun offset(offset: Long?) = apply { this.offset = offset } + + /** + * Alias for [Builder.offset]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun offset(offset: Long) = offset(offset as Long?) + + /** Alias for calling [Builder.offset] with `offset.orElse(null)`. */ + fun offset(offset: Optional<Long>) = offset(offset.getOrNull()) + + fun query(query: String?) = apply { this.query = query } + + /** Alias for calling [Builder.query] with `query.orElse(null)`. */ + fun query(query: Optional<String>) = query(query.getOrNull()) + + fun sortDirection(sortDirection: SortDirection?) = apply { + this.sortDirection = sortDirection + } + + /** Alias for calling [Builder.sortDirection] with `sortDirection.orElse(null)`. */ + fun sortDirection(sortDirection: Optional<SortDirection>) = + sortDirection(sortDirection.getOrNull()) + + fun sortField(sortField: SortField?) = apply { this.sortField = sortField } + + /** Alias for calling [Builder.sortField] with `sortField.orElse(null)`. */ + fun sortField(sortField: Optional<SortField>) = sortField(sortField.getOrNull()) + + fun tagValueId(tagValueId: List<String>?) = apply { + this.tagValueId = tagValueId?.toMutableList() + } + + /** Alias for calling [Builder.tagValueId] with `tagValueId.orElse(null)`. */ + fun tagValueId(tagValueId: Optional<List<String>>) = tagValueId(tagValueId.getOrNull()) + + /** + * Adds a single [String] to [Builder.tagValueId]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTagValueId(tagValueId: String) = apply { + this.tagValueId = (this.tagValueId ?: mutableListOf()).apply { add(tagValueId) } + } + + fun tags(tags: List<String>?) = apply { this.tags = tags?.toMutableList() } + + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ + fun tags(tags: Optional<List<String>>) = tags(tags.getOrNull()) + + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { tags = (tags ?: mutableListOf()).apply { add(tag) } } + + fun tenantHandle(tenantHandle: String?) = apply { this.tenantHandle = tenantHandle } + + /** Alias for calling [Builder.tenantHandle] with `tenantHandle.orElse(null)`. */ + fun tenantHandle(tenantHandle: Optional<String>) = tenantHandle(tenantHandle.getOrNull()) + + fun tenantId(tenantId: String?) = apply { this.tenantId = tenantId } + + /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ + fun tenantId(tenantId: Optional<String>) = tenantId(tenantId.getOrNull()) + + fun upstreamRepoHandle(upstreamRepoHandle: String?) = apply { + this.upstreamRepoHandle = upstreamRepoHandle + } + + /** + * Alias for calling [Builder.upstreamRepoHandle] with `upstreamRepoHandle.orElse(null)`. + */ + fun upstreamRepoHandle(upstreamRepoHandle: Optional<String>) = + upstreamRepoHandle(upstreamRepoHandle.getOrNull()) + + fun upstreamRepoOwner(upstreamRepoOwner: String?) = apply { + this.upstreamRepoOwner = upstreamRepoOwner + } + + /** Alias for calling [Builder.upstreamRepoOwner] with `upstreamRepoOwner.orElse(null)`. */ + fun upstreamRepoOwner(upstreamRepoOwner: Optional<String>) = + upstreamRepoOwner(upstreamRepoOwner.getOrNull()) + + fun withLatestManifest(withLatestManifest: Boolean?) = apply { + this.withLatestManifest = withLatestManifest + } + + /** + * Alias for [Builder.withLatestManifest]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun withLatestManifest(withLatestManifest: Boolean) = + withLatestManifest(withLatestManifest as Boolean?) + + /** + * Alias for calling [Builder.withLatestManifest] with `withLatestManifest.orElse(null)`. + */ + fun withLatestManifest(withLatestManifest: Optional<Boolean>) = + withLatestManifest(withLatestManifest.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RepoListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RepoListParams = + RepoListParams( + hasCommits, + isArchived, + isPublic, + limit, + offset, + query, + sortDirection, + sortField, + tagValueId?.toImmutable(), + tags?.toImmutable(), + tenantHandle, + tenantId, + upstreamRepoHandle, + upstreamRepoOwner, + withLatestManifest, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + hasCommits?.let { put("has_commits", it.toString()) } + isArchived?.let { put("is_archived", it.toString()) } + isPublic?.let { put("is_public", it.toString()) } + limit?.let { put("limit", it.toString()) } + offset?.let { put("offset", it.toString()) } + query?.let { put("query", it) } + sortDirection?.let { put("sort_direction", it.toString()) } + sortField?.let { put("sort_field", it.toString()) } + tagValueId?.let { put("tag_value_id", it.joinToString(",")) } + tags?.let { put("tags", it.joinToString(",")) } + tenantHandle?.let { put("tenant_handle", it) } + tenantId?.let { put("tenant_id", it) } + upstreamRepoHandle?.let { put("upstream_repo_handle", it) } + upstreamRepoOwner?.let { put("upstream_repo_owner", it) } + withLatestManifest?.let { put("with_latest_manifest", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + class IsArchived @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val TRUE = of("true") + + @JvmField val ALLOW = of("allow") + + @JvmField val FALSE = of("false") + + @JvmStatic fun of(value: String) = IsArchived(JsonField.of(value)) + } + + /** An enum containing [IsArchived]'s known values. */ + enum class Known { + TRUE, + ALLOW, + FALSE, + } + + /** + * An enum containing [IsArchived]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [IsArchived] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TRUE, + ALLOW, + FALSE, + /** + * An enum member indicating that [IsArchived] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TRUE -> Value.TRUE + ALLOW -> Value.ALLOW + FALSE -> Value.FALSE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TRUE -> Known.TRUE + ALLOW -> Known.ALLOW + FALSE -> Known.FALSE + else -> throw LangsmithApiInvalidDataException("Unknown IsArchived: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): IsArchived = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is IsArchived && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class IsPublic @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val TRUE = of("true") + + @JvmField val FALSE = of("false") + + @JvmStatic fun of(value: String) = IsPublic(JsonField.of(value)) + } + + /** An enum containing [IsPublic]'s known values. */ + enum class Known { + TRUE, + FALSE, + } + + /** + * An enum containing [IsPublic]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [IsPublic] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TRUE, + FALSE, + /** An enum member indicating that [IsPublic] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TRUE -> Value.TRUE + FALSE -> Value.FALSE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TRUE -> Known.TRUE + FALSE -> Known.FALSE + else -> throw LangsmithApiInvalidDataException("Unknown IsPublic: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): IsPublic = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is IsPublic && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class SortDirection @JsonCreator private constructor(private val value: JsonField<String>) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val ASC = of("asc") + + @JvmField val DESC = of("desc") + + @JvmStatic fun of(value: String) = SortDirection(JsonField.of(value)) + } + + /** An enum containing [SortDirection]'s known values. */ + enum class Known { + ASC, + DESC, + } + + /** + * An enum containing [SortDirection]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [SortDirection] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ASC, + DESC, + /** + * An enum member indicating that [SortDirection] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ASC -> Value.ASC + DESC -> Value.DESC + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ASC -> Known.ASC + DESC -> Known.DESC + else -> throw LangsmithApiInvalidDataException("Unknown SortDirection: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): SortDirection = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SortDirection && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class SortField @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val NUM_LIKES = of("num_likes") + + @JvmField val NUM_DOWNLOADS = of("num_downloads") + + @JvmField val NUM_VIEWS = of("num_views") + + @JvmField val UPDATED_AT = of("updated_at") + + @JvmField val RELEVANCE = of("relevance") + + @JvmStatic fun of(value: String) = SortField(JsonField.of(value)) + } + + /** An enum containing [SortField]'s known values. */ + enum class Known { + NUM_LIKES, + NUM_DOWNLOADS, + NUM_VIEWS, + UPDATED_AT, + RELEVANCE, + } + + /** + * An enum containing [SortField]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [SortField] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + NUM_LIKES, + NUM_DOWNLOADS, + NUM_VIEWS, + UPDATED_AT, + RELEVANCE, + /** + * An enum member indicating that [SortField] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + NUM_LIKES -> Value.NUM_LIKES + NUM_DOWNLOADS -> Value.NUM_DOWNLOADS + NUM_VIEWS -> Value.NUM_VIEWS + UPDATED_AT -> Value.UPDATED_AT + RELEVANCE -> Value.RELEVANCE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + NUM_LIKES -> Known.NUM_LIKES + NUM_DOWNLOADS -> Known.NUM_DOWNLOADS + NUM_VIEWS -> Known.NUM_VIEWS + UPDATED_AT -> Known.UPDATED_AT + RELEVANCE -> Known.RELEVANCE + else -> throw LangsmithApiInvalidDataException("Unknown SortField: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): SortField = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SortField && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RepoListParams && + hasCommits == other.hasCommits && + isArchived == other.isArchived && + isPublic == other.isPublic && + limit == other.limit && + offset == other.offset && + query == other.query && + sortDirection == other.sortDirection && + sortField == other.sortField && + tagValueId == other.tagValueId && + tags == other.tags && + tenantHandle == other.tenantHandle && + tenantId == other.tenantId && + upstreamRepoHandle == other.upstreamRepoHandle && + upstreamRepoOwner == other.upstreamRepoOwner && + withLatestManifest == other.withLatestManifest && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + hasCommits, + isArchived, + isPublic, + limit, + offset, + query, + sortDirection, + sortField, + tagValueId, + tags, + tenantHandle, + tenantId, + upstreamRepoHandle, + upstreamRepoOwner, + withLatestManifest, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "RepoListParams{hasCommits=$hasCommits, isArchived=$isArchived, isPublic=$isPublic, limit=$limit, offset=$offset, query=$query, sortDirection=$sortDirection, sortField=$sortField, tagValueId=$tagValueId, tags=$tags, tenantHandle=$tenantHandle, tenantId=$tenantId, upstreamRepoHandle=$upstreamRepoHandle, upstreamRepoOwner=$upstreamRepoOwner, withLatestManifest=$withLatestManifest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoListResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoListResponse.kt new file mode 100644 index 00000000..498b8d15 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoListResponse.kt @@ -0,0 +1,223 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class RepoListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val repos: JsonField<List<RepoWithLookups>>, + private val total: JsonField<Long>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("repos") + @ExcludeMissing + repos: JsonField<List<RepoWithLookups>> = JsonMissing.of(), + @JsonProperty("total") @ExcludeMissing total: JsonField<Long> = JsonMissing.of(), + ) : this(repos, total, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun repos(): List<RepoWithLookups> = repos.getRequired("repos") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun total(): Long = total.getRequired("total") + + /** + * Returns the raw JSON value of [repos]. + * + * Unlike [repos], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("repos") @ExcludeMissing fun _repos(): JsonField<List<RepoWithLookups>> = repos + + /** + * Returns the raw JSON value of [total]. + * + * Unlike [total], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total") @ExcludeMissing fun _total(): JsonField<Long> = total + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RepoListResponse]. + * + * The following fields are required: + * ```java + * .repos() + * .total() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RepoListResponse]. */ + class Builder internal constructor() { + + private var repos: JsonField<MutableList<RepoWithLookups>>? = null + private var total: JsonField<Long>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(repoListResponse: RepoListResponse) = apply { + repos = repoListResponse.repos.map { it.toMutableList() } + total = repoListResponse.total + additionalProperties = repoListResponse.additionalProperties.toMutableMap() + } + + fun repos(repos: List<RepoWithLookups>) = repos(JsonField.of(repos)) + + /** + * Sets [Builder.repos] to an arbitrary JSON value. + * + * You should usually call [Builder.repos] with a well-typed `List<RepoWithLookups>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun repos(repos: JsonField<List<RepoWithLookups>>) = apply { + this.repos = repos.map { it.toMutableList() } + } + + /** + * Adds a single [RepoWithLookups] to [repos]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRepo(repo: RepoWithLookups) = apply { + repos = + (repos ?: JsonField.of(mutableListOf())).also { checkKnown("repos", it).add(repo) } + } + + fun total(total: Long) = total(JsonField.of(total)) + + /** + * Sets [Builder.total] to an arbitrary JSON value. + * + * You should usually call [Builder.total] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun total(total: JsonField<Long>) = apply { this.total = total } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RepoListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .repos() + * .total() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RepoListResponse = + RepoListResponse( + checkRequired("repos", repos).map { it.toImmutable() }, + checkRequired("total", total), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RepoListResponse = apply { + if (validated) { + return@apply + } + + repos().forEach { it.validate() } + total() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (repos.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (total.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RepoListResponse && + repos == other.repos && + total == other.total && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(repos, total, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RepoListResponse{repos=$repos, total=$total, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoOptimizeJobParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoOptimizeJobParams.kt new file mode 100644 index 00000000..87b0370f --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoOptimizeJobParams.kt @@ -0,0 +1,748 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos + +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 com.langsmith_api.api.core.BaseDeserializer +import com.langsmith_api.api.core.BaseSerializer +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.allMaxBy +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Optimize prompt */ +class RepoOptimizeJobParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun algorithm(): EPromptOptimizationAlgorithm = body.algorithm() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun config(): Config = body.config() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun promptName(): String = body.promptName() + + /** + * Returns the raw JSON value of [algorithm]. + * + * Unlike [algorithm], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _algorithm(): JsonField<EPromptOptimizationAlgorithm> = body._algorithm() + + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _config(): JsonField<Config> = body._config() + + /** + * Returns the raw JSON value of [promptName]. + * + * Unlike [promptName], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _promptName(): JsonField<String> = body._promptName() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RepoOptimizeJobParams]. + * + * The following fields are required: + * ```java + * .algorithm() + * .config() + * .promptName() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RepoOptimizeJobParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(repoOptimizeJobParams: RepoOptimizeJobParams) = apply { + body = repoOptimizeJobParams.body.toBuilder() + additionalHeaders = repoOptimizeJobParams.additionalHeaders.toBuilder() + additionalQueryParams = repoOptimizeJobParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [algorithm] + * - [config] + * - [promptName] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun algorithm(algorithm: EPromptOptimizationAlgorithm) = apply { body.algorithm(algorithm) } + + /** + * Sets [Builder.algorithm] to an arbitrary JSON value. + * + * You should usually call [Builder.algorithm] with a well-typed + * [EPromptOptimizationAlgorithm] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun algorithm(algorithm: JsonField<EPromptOptimizationAlgorithm>) = apply { + body.algorithm(algorithm) + } + + fun config(config: Config) = apply { body.config(config) } + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed [Config] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun config(config: JsonField<Config>) = apply { body.config(config) } + + /** Alias for calling [config] with `Config.ofPromptim(promptim)`. */ + fun config(promptim: PromptimConfig) = apply { body.config(promptim) } + + /** Alias for calling [config] with `Config.ofDemo(demo)`. */ + fun config(demo: DemoConfig) = apply { body.config(demo) } + + fun promptName(promptName: String) = apply { body.promptName(promptName) } + + /** + * Sets [Builder.promptName] to an arbitrary JSON value. + * + * You should usually call [Builder.promptName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun promptName(promptName: JsonField<String>) = apply { body.promptName(promptName) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RepoOptimizeJobParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .algorithm() + * .config() + * .promptName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RepoOptimizeJobParams = + RepoOptimizeJobParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Request to optimize a prompt. */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val algorithm: JsonField<EPromptOptimizationAlgorithm>, + private val config: JsonField<Config>, + private val promptName: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("algorithm") + @ExcludeMissing + algorithm: JsonField<EPromptOptimizationAlgorithm> = JsonMissing.of(), + @JsonProperty("config") @ExcludeMissing config: JsonField<Config> = JsonMissing.of(), + @JsonProperty("prompt_name") + @ExcludeMissing + promptName: JsonField<String> = JsonMissing.of(), + ) : this(algorithm, config, promptName, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun algorithm(): EPromptOptimizationAlgorithm = algorithm.getRequired("algorithm") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun config(): Config = config.getRequired("config") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun promptName(): String = promptName.getRequired("prompt_name") + + /** + * Returns the raw JSON value of [algorithm]. + * + * Unlike [algorithm], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("algorithm") + @ExcludeMissing + fun _algorithm(): JsonField<EPromptOptimizationAlgorithm> = algorithm + + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("config") @ExcludeMissing fun _config(): JsonField<Config> = config + + /** + * Returns the raw JSON value of [promptName]. + * + * Unlike [promptName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prompt_name") + @ExcludeMissing + fun _promptName(): JsonField<String> = promptName + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .algorithm() + * .config() + * .promptName() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var algorithm: JsonField<EPromptOptimizationAlgorithm>? = null + private var config: JsonField<Config>? = null + private var promptName: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + algorithm = body.algorithm + config = body.config + promptName = body.promptName + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun algorithm(algorithm: EPromptOptimizationAlgorithm) = + algorithm(JsonField.of(algorithm)) + + /** + * Sets [Builder.algorithm] to an arbitrary JSON value. + * + * You should usually call [Builder.algorithm] with a well-typed + * [EPromptOptimizationAlgorithm] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun algorithm(algorithm: JsonField<EPromptOptimizationAlgorithm>) = apply { + this.algorithm = algorithm + } + + fun config(config: Config) = config(JsonField.of(config)) + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed [Config] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun config(config: JsonField<Config>) = apply { this.config = config } + + /** Alias for calling [config] with `Config.ofPromptim(promptim)`. */ + fun config(promptim: PromptimConfig) = config(Config.ofPromptim(promptim)) + + /** Alias for calling [config] with `Config.ofDemo(demo)`. */ + fun config(demo: DemoConfig) = config(Config.ofDemo(demo)) + + fun promptName(promptName: String) = promptName(JsonField.of(promptName)) + + /** + * Sets [Builder.promptName] to an arbitrary JSON value. + * + * You should usually call [Builder.promptName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun promptName(promptName: JsonField<String>) = apply { this.promptName = promptName } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .algorithm() + * .config() + * .promptName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("algorithm", algorithm), + checkRequired("config", config), + checkRequired("promptName", promptName), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + algorithm().validate() + config().validate() + promptName() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (algorithm.asKnown().getOrNull()?.validity() ?: 0) + + (config.asKnown().getOrNull()?.validity() ?: 0) + + (if (promptName.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + algorithm == other.algorithm && + config == other.config && + promptName == other.promptName && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(algorithm, config, promptName, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{algorithm=$algorithm, config=$config, promptName=$promptName, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = Config.Deserializer::class) + @JsonSerialize(using = Config.Serializer::class) + class Config + private constructor( + private val promptim: PromptimConfig? = null, + private val demo: DemoConfig? = null, + private val _json: JsonValue? = null, + ) { + + fun promptim(): Optional<PromptimConfig> = Optional.ofNullable(promptim) + + fun demo(): Optional<DemoConfig> = Optional.ofNullable(demo) + + fun isPromptim(): Boolean = promptim != null + + fun isDemo(): Boolean = demo != null + + fun asPromptim(): PromptimConfig = promptim.getOrThrow("promptim") + + fun asDemo(): DemoConfig = demo.getOrThrow("demo") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + promptim != null -> visitor.visitPromptim(promptim) + demo != null -> visitor.visitDemo(demo) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Config = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitPromptim(promptim: PromptimConfig) { + promptim.validate() + } + + override fun visitDemo(demo: DemoConfig) { + demo.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitPromptim(promptim: PromptimConfig) = promptim.validity() + + override fun visitDemo(demo: DemoConfig) = demo.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Config && promptim == other.promptim && demo == other.demo + } + + override fun hashCode(): Int = Objects.hash(promptim, demo) + + override fun toString(): String = + when { + promptim != null -> "Config{promptim=$promptim}" + demo != null -> "Config{demo=$demo}" + _json != null -> "Config{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Config") + } + + companion object { + + @JvmStatic fun ofPromptim(promptim: PromptimConfig) = Config(promptim = promptim) + + @JvmStatic fun ofDemo(demo: DemoConfig) = Config(demo = demo) + } + + /** An interface that defines how to map each variant of [Config] to a value of type [T]. */ + interface Visitor<out T> { + + fun visitPromptim(promptim: PromptimConfig): T + + fun visitDemo(demo: DemoConfig): T + + /** + * Maps an unknown variant of [Config] to a value of type [T]. + * + * An instance of [Config] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Config: $json") + } + } + + internal class Deserializer : BaseDeserializer<Config>(Config::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Config { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<PromptimConfig>())?.let { + Config(promptim = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<DemoConfig>())?.let { + Config(demo = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> Config(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Config>(Config::class) { + + override fun serialize( + value: Config, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.promptim != null -> generator.writeObject(value.promptim) + value.demo != null -> generator.writeObject(value.demo) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Config") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RepoOptimizeJobParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "RepoOptimizeJobParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoOptimizeJobResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoOptimizeJobResponse.kt new file mode 100644 index 00000000..060ee584 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoOptimizeJobResponse.kt @@ -0,0 +1,181 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +/** Response from optimizing a prompt. */ +class RepoOptimizeJobResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val optimizationJobId: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("optimization_job_id") + @ExcludeMissing + optimizationJobId: JsonField<String> = JsonMissing.of() + ) : this(optimizationJobId, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun optimizationJobId(): String = optimizationJobId.getRequired("optimization_job_id") + + /** + * Returns the raw JSON value of [optimizationJobId]. + * + * Unlike [optimizationJobId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("optimization_job_id") + @ExcludeMissing + fun _optimizationJobId(): JsonField<String> = optimizationJobId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RepoOptimizeJobResponse]. + * + * The following fields are required: + * ```java + * .optimizationJobId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RepoOptimizeJobResponse]. */ + class Builder internal constructor() { + + private var optimizationJobId: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(repoOptimizeJobResponse: RepoOptimizeJobResponse) = apply { + optimizationJobId = repoOptimizeJobResponse.optimizationJobId + additionalProperties = repoOptimizeJobResponse.additionalProperties.toMutableMap() + } + + fun optimizationJobId(optimizationJobId: String) = + optimizationJobId(JsonField.of(optimizationJobId)) + + /** + * Sets [Builder.optimizationJobId] to an arbitrary JSON value. + * + * You should usually call [Builder.optimizationJobId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun optimizationJobId(optimizationJobId: JsonField<String>) = apply { + this.optimizationJobId = optimizationJobId + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RepoOptimizeJobResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .optimizationJobId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RepoOptimizeJobResponse = + RepoOptimizeJobResponse( + checkRequired("optimizationJobId", optimizationJobId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RepoOptimizeJobResponse = apply { + if (validated) { + return@apply + } + + optimizationJobId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (optimizationJobId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RepoOptimizeJobResponse && + optimizationJobId == other.optimizationJobId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(optimizationJobId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RepoOptimizeJobResponse{optimizationJobId=$optimizationJobId, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoRetrieveParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoRetrieveParams.kt new file mode 100644 index 00000000..256a2281 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoRetrieveParams.kt @@ -0,0 +1,217 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get a repo. */ +class RepoRetrieveParams +private constructor( + private val owner: String, + private val repo: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun owner(): String = owner + + fun repo(): Optional<String> = Optional.ofNullable(repo) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RepoRetrieveParams]. + * + * The following fields are required: + * ```java + * .owner() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RepoRetrieveParams]. */ + class Builder internal constructor() { + + private var owner: String? = null + private var repo: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(repoRetrieveParams: RepoRetrieveParams) = apply { + owner = repoRetrieveParams.owner + repo = repoRetrieveParams.repo + additionalHeaders = repoRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = repoRetrieveParams.additionalQueryParams.toBuilder() + } + + fun owner(owner: String) = apply { this.owner = owner } + + fun repo(repo: String?) = apply { this.repo = repo } + + /** Alias for calling [Builder.repo] with `repo.orElse(null)`. */ + fun repo(repo: Optional<String>) = repo(repo.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RepoRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .owner() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RepoRetrieveParams = + RepoRetrieveParams( + checkRequired("owner", owner), + repo, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> owner + 1 -> repo ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RepoRetrieveParams && + owner == other.owner && + repo == other.repo && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(owner, repo, additionalHeaders, additionalQueryParams) + + override fun toString() = + "RepoRetrieveParams{owner=$owner, repo=$repo, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoUpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoUpdateParams.kt new file mode 100644 index 00000000..7d8dc409 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoUpdateParams.kt @@ -0,0 +1,754 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Update a repo. */ +class RepoUpdateParams +private constructor( + private val owner: String, + private val repo: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun owner(): String = owner + + fun repo(): Optional<String> = Optional.ofNullable(repo) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = body.description() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun isArchived(): Optional<Boolean> = body.isArchived() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun isPublic(): Optional<Boolean> = body.isPublic() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun readme(): Optional<String> = body.readme() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tags(): Optional<List<String>> = body.tags() + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _description(): JsonField<String> = body._description() + + /** + * Returns the raw JSON value of [isArchived]. + * + * Unlike [isArchived], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _isArchived(): JsonField<Boolean> = body._isArchived() + + /** + * Returns the raw JSON value of [isPublic]. + * + * Unlike [isPublic], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _isPublic(): JsonField<Boolean> = body._isPublic() + + /** + * Returns the raw JSON value of [readme]. + * + * Unlike [readme], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _readme(): JsonField<String> = body._readme() + + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _tags(): JsonField<List<String>> = body._tags() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RepoUpdateParams]. + * + * The following fields are required: + * ```java + * .owner() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RepoUpdateParams]. */ + class Builder internal constructor() { + + private var owner: String? = null + private var repo: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(repoUpdateParams: RepoUpdateParams) = apply { + owner = repoUpdateParams.owner + repo = repoUpdateParams.repo + body = repoUpdateParams.body.toBuilder() + additionalHeaders = repoUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = repoUpdateParams.additionalQueryParams.toBuilder() + } + + fun owner(owner: String) = apply { this.owner = owner } + + fun repo(repo: String?) = apply { this.repo = repo } + + /** Alias for calling [Builder.repo] with `repo.orElse(null)`. */ + fun repo(repo: Optional<String>) = repo(repo.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [description] + * - [isArchived] + * - [isPublic] + * - [readme] + * - [tags] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun description(description: String?) = apply { body.description(description) } + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { body.description(description) } + + fun isArchived(isArchived: Boolean?) = apply { body.isArchived(isArchived) } + + /** + * Alias for [Builder.isArchived]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun isArchived(isArchived: Boolean) = isArchived(isArchived as Boolean?) + + /** Alias for calling [Builder.isArchived] with `isArchived.orElse(null)`. */ + fun isArchived(isArchived: Optional<Boolean>) = isArchived(isArchived.getOrNull()) + + /** + * Sets [Builder.isArchived] to an arbitrary JSON value. + * + * You should usually call [Builder.isArchived] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isArchived(isArchived: JsonField<Boolean>) = apply { body.isArchived(isArchived) } + + fun isPublic(isPublic: Boolean?) = apply { body.isPublic(isPublic) } + + /** + * Alias for [Builder.isPublic]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun isPublic(isPublic: Boolean) = isPublic(isPublic as Boolean?) + + /** Alias for calling [Builder.isPublic] with `isPublic.orElse(null)`. */ + fun isPublic(isPublic: Optional<Boolean>) = isPublic(isPublic.getOrNull()) + + /** + * Sets [Builder.isPublic] to an arbitrary JSON value. + * + * You should usually call [Builder.isPublic] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isPublic(isPublic: JsonField<Boolean>) = apply { body.isPublic(isPublic) } + + fun readme(readme: String?) = apply { body.readme(readme) } + + /** Alias for calling [Builder.readme] with `readme.orElse(null)`. */ + fun readme(readme: Optional<String>) = readme(readme.getOrNull()) + + /** + * Sets [Builder.readme] to an arbitrary JSON value. + * + * You should usually call [Builder.readme] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun readme(readme: JsonField<String>) = apply { body.readme(readme) } + + fun tags(tags: List<String>?) = apply { body.tags(tags) } + + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ + fun tags(tags: Optional<List<String>>) = tags(tags.getOrNull()) + + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List<String>` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tags(tags: JsonField<List<String>>) = apply { body.tags(tags) } + + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { body.addTag(tag) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RepoUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .owner() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RepoUpdateParams = + RepoUpdateParams( + checkRequired("owner", owner), + repo, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> owner + 1 -> repo ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Fields to update a repo */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val description: JsonField<String>, + private val isArchived: JsonField<Boolean>, + private val isPublic: JsonField<Boolean>, + private val readme: JsonField<String>, + private val tags: JsonField<List<String>>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("is_archived") + @ExcludeMissing + isArchived: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("is_public") + @ExcludeMissing + isPublic: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("readme") @ExcludeMissing readme: JsonField<String> = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing tags: JsonField<List<String>> = JsonMissing.of(), + ) : this(description, isArchived, isPublic, readme, tags, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun isArchived(): Optional<Boolean> = isArchived.getOptional("is_archived") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun isPublic(): Optional<Boolean> = isPublic.getOptional("is_public") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun readme(): Optional<String> = readme.getOptional("readme") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun tags(): Optional<List<String>> = tags.getOptional("tags") + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [isArchived]. + * + * Unlike [isArchived], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_archived") + @ExcludeMissing + fun _isArchived(): JsonField<Boolean> = isArchived + + /** + * Returns the raw JSON value of [isPublic]. + * + * Unlike [isPublic], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_public") @ExcludeMissing fun _isPublic(): JsonField<Boolean> = isPublic + + /** + * Returns the raw JSON value of [readme]. + * + * Unlike [readme], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("readme") @ExcludeMissing fun _readme(): JsonField<String> = readme + + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField<List<String>> = tags + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var description: JsonField<String> = JsonMissing.of() + private var isArchived: JsonField<Boolean> = JsonMissing.of() + private var isPublic: JsonField<Boolean> = JsonMissing.of() + private var readme: JsonField<String> = JsonMissing.of() + private var tags: JsonField<MutableList<String>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + description = body.description + isArchived = body.isArchived + isPublic = body.isPublic + readme = body.readme + tags = body.tags.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField<String>) = apply { + this.description = description + } + + fun isArchived(isArchived: Boolean?) = isArchived(JsonField.ofNullable(isArchived)) + + /** + * Alias for [Builder.isArchived]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun isArchived(isArchived: Boolean) = isArchived(isArchived as Boolean?) + + /** Alias for calling [Builder.isArchived] with `isArchived.orElse(null)`. */ + fun isArchived(isArchived: Optional<Boolean>) = isArchived(isArchived.getOrNull()) + + /** + * Sets [Builder.isArchived] to an arbitrary JSON value. + * + * You should usually call [Builder.isArchived] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isArchived(isArchived: JsonField<Boolean>) = apply { this.isArchived = isArchived } + + fun isPublic(isPublic: Boolean?) = isPublic(JsonField.ofNullable(isPublic)) + + /** + * Alias for [Builder.isPublic]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun isPublic(isPublic: Boolean) = isPublic(isPublic as Boolean?) + + /** Alias for calling [Builder.isPublic] with `isPublic.orElse(null)`. */ + fun isPublic(isPublic: Optional<Boolean>) = isPublic(isPublic.getOrNull()) + + /** + * Sets [Builder.isPublic] to an arbitrary JSON value. + * + * You should usually call [Builder.isPublic] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isPublic(isPublic: JsonField<Boolean>) = apply { this.isPublic = isPublic } + + fun readme(readme: String?) = readme(JsonField.ofNullable(readme)) + + /** Alias for calling [Builder.readme] with `readme.orElse(null)`. */ + fun readme(readme: Optional<String>) = readme(readme.getOrNull()) + + /** + * Sets [Builder.readme] to an arbitrary JSON value. + * + * You should usually call [Builder.readme] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun readme(readme: JsonField<String>) = apply { this.readme = readme } + + fun tags(tags: List<String>?) = tags(JsonField.ofNullable(tags)) + + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ + fun tags(tags: Optional<List<String>>) = tags(tags.getOrNull()) + + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tags(tags: JsonField<List<String>>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { + tags = + (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = + Body( + description, + isArchived, + isPublic, + readme, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + description() + isArchived() + isPublic() + readme() + tags() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (description.asKnown().isPresent) 1 else 0) + + (if (isArchived.asKnown().isPresent) 1 else 0) + + (if (isPublic.asKnown().isPresent) 1 else 0) + + (if (readme.asKnown().isPresent) 1 else 0) + + (tags.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + description == other.description && + isArchived == other.isArchived && + isPublic == other.isPublic && + readme == other.readme && + tags == other.tags && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(description, isArchived, isPublic, readme, tags, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{description=$description, isArchived=$isArchived, isPublic=$isPublic, readme=$readme, tags=$tags, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RepoUpdateParams && + owner == other.owner && + repo == other.repo && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(owner, repo, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "RepoUpdateParams{owner=$owner, repo=$repo, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoWithLookups.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoWithLookups.kt new file mode 100644 index 00000000..0646767f --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoWithLookups.kt @@ -0,0 +1,1094 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.commits.CommitManifestResponse +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** All database fields for repos, plus helpful computed fields. */ +class RepoWithLookups +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val fullName: JsonField<String>, + private val isArchived: JsonField<Boolean>, + private val isPublic: JsonField<Boolean>, + private val numCommits: JsonField<Long>, + private val numDownloads: JsonField<Long>, + private val numLikes: JsonField<Long>, + private val numViews: JsonField<Long>, + private val owner: JsonField<String>, + private val repoHandle: JsonField<String>, + private val tags: JsonField<List<String>>, + private val tenantId: JsonField<String>, + private val updatedAt: JsonField<OffsetDateTime>, + private val description: JsonField<String>, + private val lastCommitHash: JsonField<String>, + private val latestCommitManifest: JsonField<CommitManifestResponse>, + private val likedByAuthUser: JsonField<Boolean>, + private val originalRepoFullName: JsonField<String>, + private val originalRepoId: JsonField<String>, + private val readme: JsonField<String>, + private val upstreamRepoFullName: JsonField<String>, + private val upstreamRepoId: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("full_name") @ExcludeMissing fullName: JsonField<String> = JsonMissing.of(), + @JsonProperty("is_archived") + @ExcludeMissing + isArchived: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("is_public") @ExcludeMissing isPublic: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("num_commits") @ExcludeMissing numCommits: JsonField<Long> = JsonMissing.of(), + @JsonProperty("num_downloads") + @ExcludeMissing + numDownloads: JsonField<Long> = JsonMissing.of(), + @JsonProperty("num_likes") @ExcludeMissing numLikes: JsonField<Long> = JsonMissing.of(), + @JsonProperty("num_views") @ExcludeMissing numViews: JsonField<Long> = JsonMissing.of(), + @JsonProperty("owner") @ExcludeMissing owner: JsonField<String> = JsonMissing.of(), + @JsonProperty("repo_handle") + @ExcludeMissing + repoHandle: JsonField<String> = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing tags: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("tenant_id") @ExcludeMissing tenantId: JsonField<String> = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("last_commit_hash") + @ExcludeMissing + lastCommitHash: JsonField<String> = JsonMissing.of(), + @JsonProperty("latest_commit_manifest") + @ExcludeMissing + latestCommitManifest: JsonField<CommitManifestResponse> = JsonMissing.of(), + @JsonProperty("liked_by_auth_user") + @ExcludeMissing + likedByAuthUser: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("original_repo_full_name") + @ExcludeMissing + originalRepoFullName: JsonField<String> = JsonMissing.of(), + @JsonProperty("original_repo_id") + @ExcludeMissing + originalRepoId: JsonField<String> = JsonMissing.of(), + @JsonProperty("readme") @ExcludeMissing readme: JsonField<String> = JsonMissing.of(), + @JsonProperty("upstream_repo_full_name") + @ExcludeMissing + upstreamRepoFullName: JsonField<String> = JsonMissing.of(), + @JsonProperty("upstream_repo_id") + @ExcludeMissing + upstreamRepoId: JsonField<String> = JsonMissing.of(), + ) : this( + id, + createdAt, + fullName, + isArchived, + isPublic, + numCommits, + numDownloads, + numLikes, + numViews, + owner, + repoHandle, + tags, + tenantId, + updatedAt, + description, + lastCommitHash, + latestCommitManifest, + likedByAuthUser, + originalRepoFullName, + originalRepoId, + readme, + upstreamRepoFullName, + upstreamRepoId, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun fullName(): String = fullName.getRequired("full_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun isArchived(): Boolean = isArchived.getRequired("is_archived") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun isPublic(): Boolean = isPublic.getRequired("is_public") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun numCommits(): Long = numCommits.getRequired("num_commits") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun numDownloads(): Long = numDownloads.getRequired("num_downloads") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun numLikes(): Long = numLikes.getRequired("num_likes") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun numViews(): Long = numViews.getRequired("num_views") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun owner(): Optional<String> = owner.getOptional("owner") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun repoHandle(): String = repoHandle.getRequired("repo_handle") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tags(): List<String> = tags.getRequired("tags") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tenantId(): String = tenantId.getRequired("tenant_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updatedAt(): OffsetDateTime = updatedAt.getRequired("updated_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun lastCommitHash(): Optional<String> = lastCommitHash.getOptional("last_commit_hash") + + /** + * Response model for get_commit_manifest. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun latestCommitManifest(): Optional<CommitManifestResponse> = + latestCommitManifest.getOptional("latest_commit_manifest") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun likedByAuthUser(): Optional<Boolean> = likedByAuthUser.getOptional("liked_by_auth_user") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun originalRepoFullName(): Optional<String> = + originalRepoFullName.getOptional("original_repo_full_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun originalRepoId(): Optional<String> = originalRepoId.getOptional("original_repo_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun readme(): Optional<String> = readme.getOptional("readme") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun upstreamRepoFullName(): Optional<String> = + upstreamRepoFullName.getOptional("upstream_repo_full_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun upstreamRepoId(): Optional<String> = upstreamRepoId.getOptional("upstream_repo_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [fullName]. + * + * Unlike [fullName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("full_name") @ExcludeMissing fun _fullName(): JsonField<String> = fullName + + /** + * Returns the raw JSON value of [isArchived]. + * + * Unlike [isArchived], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_archived") @ExcludeMissing fun _isArchived(): JsonField<Boolean> = isArchived + + /** + * Returns the raw JSON value of [isPublic]. + * + * Unlike [isPublic], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_public") @ExcludeMissing fun _isPublic(): JsonField<Boolean> = isPublic + + /** + * Returns the raw JSON value of [numCommits]. + * + * Unlike [numCommits], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("num_commits") @ExcludeMissing fun _numCommits(): JsonField<Long> = numCommits + + /** + * Returns the raw JSON value of [numDownloads]. + * + * Unlike [numDownloads], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("num_downloads") + @ExcludeMissing + fun _numDownloads(): JsonField<Long> = numDownloads + + /** + * Returns the raw JSON value of [numLikes]. + * + * Unlike [numLikes], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("num_likes") @ExcludeMissing fun _numLikes(): JsonField<Long> = numLikes + + /** + * Returns the raw JSON value of [numViews]. + * + * Unlike [numViews], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("num_views") @ExcludeMissing fun _numViews(): JsonField<Long> = numViews + + /** + * Returns the raw JSON value of [owner]. + * + * Unlike [owner], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("owner") @ExcludeMissing fun _owner(): JsonField<String> = owner + + /** + * Returns the raw JSON value of [repoHandle]. + * + * Unlike [repoHandle], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("repo_handle") @ExcludeMissing fun _repoHandle(): JsonField<String> = repoHandle + + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField<List<String>> = tags + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_id") @ExcludeMissing fun _tenantId(): JsonField<String> = tenantId + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField<OffsetDateTime> = updatedAt + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [lastCommitHash]. + * + * Unlike [lastCommitHash], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("last_commit_hash") + @ExcludeMissing + fun _lastCommitHash(): JsonField<String> = lastCommitHash + + /** + * Returns the raw JSON value of [latestCommitManifest]. + * + * Unlike [latestCommitManifest], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("latest_commit_manifest") + @ExcludeMissing + fun _latestCommitManifest(): JsonField<CommitManifestResponse> = latestCommitManifest + + /** + * Returns the raw JSON value of [likedByAuthUser]. + * + * Unlike [likedByAuthUser], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("liked_by_auth_user") + @ExcludeMissing + fun _likedByAuthUser(): JsonField<Boolean> = likedByAuthUser + + /** + * Returns the raw JSON value of [originalRepoFullName]. + * + * Unlike [originalRepoFullName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("original_repo_full_name") + @ExcludeMissing + fun _originalRepoFullName(): JsonField<String> = originalRepoFullName + + /** + * Returns the raw JSON value of [originalRepoId]. + * + * Unlike [originalRepoId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("original_repo_id") + @ExcludeMissing + fun _originalRepoId(): JsonField<String> = originalRepoId + + /** + * Returns the raw JSON value of [readme]. + * + * Unlike [readme], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("readme") @ExcludeMissing fun _readme(): JsonField<String> = readme + + /** + * Returns the raw JSON value of [upstreamRepoFullName]. + * + * Unlike [upstreamRepoFullName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("upstream_repo_full_name") + @ExcludeMissing + fun _upstreamRepoFullName(): JsonField<String> = upstreamRepoFullName + + /** + * Returns the raw JSON value of [upstreamRepoId]. + * + * Unlike [upstreamRepoId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("upstream_repo_id") + @ExcludeMissing + fun _upstreamRepoId(): JsonField<String> = upstreamRepoId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RepoWithLookups]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .fullName() + * .isArchived() + * .isPublic() + * .numCommits() + * .numDownloads() + * .numLikes() + * .numViews() + * .owner() + * .repoHandle() + * .tags() + * .tenantId() + * .updatedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RepoWithLookups]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var createdAt: JsonField<OffsetDateTime>? = null + private var fullName: JsonField<String>? = null + private var isArchived: JsonField<Boolean>? = null + private var isPublic: JsonField<Boolean>? = null + private var numCommits: JsonField<Long>? = null + private var numDownloads: JsonField<Long>? = null + private var numLikes: JsonField<Long>? = null + private var numViews: JsonField<Long>? = null + private var owner: JsonField<String>? = null + private var repoHandle: JsonField<String>? = null + private var tags: JsonField<MutableList<String>>? = null + private var tenantId: JsonField<String>? = null + private var updatedAt: JsonField<OffsetDateTime>? = null + private var description: JsonField<String> = JsonMissing.of() + private var lastCommitHash: JsonField<String> = JsonMissing.of() + private var latestCommitManifest: JsonField<CommitManifestResponse> = JsonMissing.of() + private var likedByAuthUser: JsonField<Boolean> = JsonMissing.of() + private var originalRepoFullName: JsonField<String> = JsonMissing.of() + private var originalRepoId: JsonField<String> = JsonMissing.of() + private var readme: JsonField<String> = JsonMissing.of() + private var upstreamRepoFullName: JsonField<String> = JsonMissing.of() + private var upstreamRepoId: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(repoWithLookups: RepoWithLookups) = apply { + id = repoWithLookups.id + createdAt = repoWithLookups.createdAt + fullName = repoWithLookups.fullName + isArchived = repoWithLookups.isArchived + isPublic = repoWithLookups.isPublic + numCommits = repoWithLookups.numCommits + numDownloads = repoWithLookups.numDownloads + numLikes = repoWithLookups.numLikes + numViews = repoWithLookups.numViews + owner = repoWithLookups.owner + repoHandle = repoWithLookups.repoHandle + tags = repoWithLookups.tags.map { it.toMutableList() } + tenantId = repoWithLookups.tenantId + updatedAt = repoWithLookups.updatedAt + description = repoWithLookups.description + lastCommitHash = repoWithLookups.lastCommitHash + latestCommitManifest = repoWithLookups.latestCommitManifest + likedByAuthUser = repoWithLookups.likedByAuthUser + originalRepoFullName = repoWithLookups.originalRepoFullName + originalRepoId = repoWithLookups.originalRepoId + readme = repoWithLookups.readme + upstreamRepoFullName = repoWithLookups.upstreamRepoFullName + upstreamRepoId = repoWithLookups.upstreamRepoId + additionalProperties = repoWithLookups.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun fullName(fullName: String) = fullName(JsonField.of(fullName)) + + /** + * Sets [Builder.fullName] to an arbitrary JSON value. + * + * You should usually call [Builder.fullName] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun fullName(fullName: JsonField<String>) = apply { this.fullName = fullName } + + fun isArchived(isArchived: Boolean) = isArchived(JsonField.of(isArchived)) + + /** + * Sets [Builder.isArchived] to an arbitrary JSON value. + * + * You should usually call [Builder.isArchived] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isArchived(isArchived: JsonField<Boolean>) = apply { this.isArchived = isArchived } + + fun isPublic(isPublic: Boolean) = isPublic(JsonField.of(isPublic)) + + /** + * Sets [Builder.isPublic] to an arbitrary JSON value. + * + * You should usually call [Builder.isPublic] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isPublic(isPublic: JsonField<Boolean>) = apply { this.isPublic = isPublic } + + fun numCommits(numCommits: Long) = numCommits(JsonField.of(numCommits)) + + /** + * Sets [Builder.numCommits] to an arbitrary JSON value. + * + * You should usually call [Builder.numCommits] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun numCommits(numCommits: JsonField<Long>) = apply { this.numCommits = numCommits } + + fun numDownloads(numDownloads: Long) = numDownloads(JsonField.of(numDownloads)) + + /** + * Sets [Builder.numDownloads] to an arbitrary JSON value. + * + * You should usually call [Builder.numDownloads] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun numDownloads(numDownloads: JsonField<Long>) = apply { this.numDownloads = numDownloads } + + fun numLikes(numLikes: Long) = numLikes(JsonField.of(numLikes)) + + /** + * Sets [Builder.numLikes] to an arbitrary JSON value. + * + * You should usually call [Builder.numLikes] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun numLikes(numLikes: JsonField<Long>) = apply { this.numLikes = numLikes } + + fun numViews(numViews: Long) = numViews(JsonField.of(numViews)) + + /** + * Sets [Builder.numViews] to an arbitrary JSON value. + * + * You should usually call [Builder.numViews] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun numViews(numViews: JsonField<Long>) = apply { this.numViews = numViews } + + fun owner(owner: String?) = owner(JsonField.ofNullable(owner)) + + /** Alias for calling [Builder.owner] with `owner.orElse(null)`. */ + fun owner(owner: Optional<String>) = owner(owner.getOrNull()) + + /** + * Sets [Builder.owner] to an arbitrary JSON value. + * + * You should usually call [Builder.owner] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun owner(owner: JsonField<String>) = apply { this.owner = owner } + + fun repoHandle(repoHandle: String) = repoHandle(JsonField.of(repoHandle)) + + /** + * Sets [Builder.repoHandle] to an arbitrary JSON value. + * + * You should usually call [Builder.repoHandle] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun repoHandle(repoHandle: JsonField<String>) = apply { this.repoHandle = repoHandle } + + fun tags(tags: List<String>) = tags(JsonField.of(tags)) + + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List<String>` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tags(tags: JsonField<List<String>>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } + + fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tenantId(tenantId: JsonField<String>) = apply { this.tenantId = tenantId } + + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField<OffsetDateTime>) = apply { this.updatedAt = updatedAt } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { this.description = description } + + fun lastCommitHash(lastCommitHash: String?) = + lastCommitHash(JsonField.ofNullable(lastCommitHash)) + + /** Alias for calling [Builder.lastCommitHash] with `lastCommitHash.orElse(null)`. */ + fun lastCommitHash(lastCommitHash: Optional<String>) = + lastCommitHash(lastCommitHash.getOrNull()) + + /** + * Sets [Builder.lastCommitHash] to an arbitrary JSON value. + * + * You should usually call [Builder.lastCommitHash] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lastCommitHash(lastCommitHash: JsonField<String>) = apply { + this.lastCommitHash = lastCommitHash + } + + /** Response model for get_commit_manifest. */ + fun latestCommitManifest(latestCommitManifest: CommitManifestResponse?) = + latestCommitManifest(JsonField.ofNullable(latestCommitManifest)) + + /** + * Alias for calling [Builder.latestCommitManifest] with + * `latestCommitManifest.orElse(null)`. + */ + fun latestCommitManifest(latestCommitManifest: Optional<CommitManifestResponse>) = + latestCommitManifest(latestCommitManifest.getOrNull()) + + /** + * Sets [Builder.latestCommitManifest] to an arbitrary JSON value. + * + * You should usually call [Builder.latestCommitManifest] with a well-typed + * [CommitManifestResponse] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun latestCommitManifest(latestCommitManifest: JsonField<CommitManifestResponse>) = apply { + this.latestCommitManifest = latestCommitManifest + } + + fun likedByAuthUser(likedByAuthUser: Boolean?) = + likedByAuthUser(JsonField.ofNullable(likedByAuthUser)) + + /** + * Alias for [Builder.likedByAuthUser]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun likedByAuthUser(likedByAuthUser: Boolean) = likedByAuthUser(likedByAuthUser as Boolean?) + + /** Alias for calling [Builder.likedByAuthUser] with `likedByAuthUser.orElse(null)`. */ + fun likedByAuthUser(likedByAuthUser: Optional<Boolean>) = + likedByAuthUser(likedByAuthUser.getOrNull()) + + /** + * Sets [Builder.likedByAuthUser] to an arbitrary JSON value. + * + * You should usually call [Builder.likedByAuthUser] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun likedByAuthUser(likedByAuthUser: JsonField<Boolean>) = apply { + this.likedByAuthUser = likedByAuthUser + } + + fun originalRepoFullName(originalRepoFullName: String?) = + originalRepoFullName(JsonField.ofNullable(originalRepoFullName)) + + /** + * Alias for calling [Builder.originalRepoFullName] with + * `originalRepoFullName.orElse(null)`. + */ + fun originalRepoFullName(originalRepoFullName: Optional<String>) = + originalRepoFullName(originalRepoFullName.getOrNull()) + + /** + * Sets [Builder.originalRepoFullName] to an arbitrary JSON value. + * + * You should usually call [Builder.originalRepoFullName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun originalRepoFullName(originalRepoFullName: JsonField<String>) = apply { + this.originalRepoFullName = originalRepoFullName + } + + fun originalRepoId(originalRepoId: String?) = + originalRepoId(JsonField.ofNullable(originalRepoId)) + + /** Alias for calling [Builder.originalRepoId] with `originalRepoId.orElse(null)`. */ + fun originalRepoId(originalRepoId: Optional<String>) = + originalRepoId(originalRepoId.getOrNull()) + + /** + * Sets [Builder.originalRepoId] to an arbitrary JSON value. + * + * You should usually call [Builder.originalRepoId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun originalRepoId(originalRepoId: JsonField<String>) = apply { + this.originalRepoId = originalRepoId + } + + fun readme(readme: String?) = readme(JsonField.ofNullable(readme)) + + /** Alias for calling [Builder.readme] with `readme.orElse(null)`. */ + fun readme(readme: Optional<String>) = readme(readme.getOrNull()) + + /** + * Sets [Builder.readme] to an arbitrary JSON value. + * + * You should usually call [Builder.readme] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun readme(readme: JsonField<String>) = apply { this.readme = readme } + + fun upstreamRepoFullName(upstreamRepoFullName: String?) = + upstreamRepoFullName(JsonField.ofNullable(upstreamRepoFullName)) + + /** + * Alias for calling [Builder.upstreamRepoFullName] with + * `upstreamRepoFullName.orElse(null)`. + */ + fun upstreamRepoFullName(upstreamRepoFullName: Optional<String>) = + upstreamRepoFullName(upstreamRepoFullName.getOrNull()) + + /** + * Sets [Builder.upstreamRepoFullName] to an arbitrary JSON value. + * + * You should usually call [Builder.upstreamRepoFullName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun upstreamRepoFullName(upstreamRepoFullName: JsonField<String>) = apply { + this.upstreamRepoFullName = upstreamRepoFullName + } + + fun upstreamRepoId(upstreamRepoId: String?) = + upstreamRepoId(JsonField.ofNullable(upstreamRepoId)) + + /** Alias for calling [Builder.upstreamRepoId] with `upstreamRepoId.orElse(null)`. */ + fun upstreamRepoId(upstreamRepoId: Optional<String>) = + upstreamRepoId(upstreamRepoId.getOrNull()) + + /** + * Sets [Builder.upstreamRepoId] to an arbitrary JSON value. + * + * You should usually call [Builder.upstreamRepoId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun upstreamRepoId(upstreamRepoId: JsonField<String>) = apply { + this.upstreamRepoId = upstreamRepoId + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RepoWithLookups]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .fullName() + * .isArchived() + * .isPublic() + * .numCommits() + * .numDownloads() + * .numLikes() + * .numViews() + * .owner() + * .repoHandle() + * .tags() + * .tenantId() + * .updatedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RepoWithLookups = + RepoWithLookups( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("fullName", fullName), + checkRequired("isArchived", isArchived), + checkRequired("isPublic", isPublic), + checkRequired("numCommits", numCommits), + checkRequired("numDownloads", numDownloads), + checkRequired("numLikes", numLikes), + checkRequired("numViews", numViews), + checkRequired("owner", owner), + checkRequired("repoHandle", repoHandle), + checkRequired("tags", tags).map { it.toImmutable() }, + checkRequired("tenantId", tenantId), + checkRequired("updatedAt", updatedAt), + description, + lastCommitHash, + latestCommitManifest, + likedByAuthUser, + originalRepoFullName, + originalRepoId, + readme, + upstreamRepoFullName, + upstreamRepoId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RepoWithLookups = apply { + if (validated) { + return@apply + } + + id() + createdAt() + fullName() + isArchived() + isPublic() + numCommits() + numDownloads() + numLikes() + numViews() + owner() + repoHandle() + tags() + tenantId() + updatedAt() + description() + lastCommitHash() + latestCommitManifest().ifPresent { it.validate() } + likedByAuthUser() + originalRepoFullName() + originalRepoId() + readme() + upstreamRepoFullName() + upstreamRepoId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (fullName.asKnown().isPresent) 1 else 0) + + (if (isArchived.asKnown().isPresent) 1 else 0) + + (if (isPublic.asKnown().isPresent) 1 else 0) + + (if (numCommits.asKnown().isPresent) 1 else 0) + + (if (numDownloads.asKnown().isPresent) 1 else 0) + + (if (numLikes.asKnown().isPresent) 1 else 0) + + (if (numViews.asKnown().isPresent) 1 else 0) + + (if (owner.asKnown().isPresent) 1 else 0) + + (if (repoHandle.asKnown().isPresent) 1 else 0) + + (tags.asKnown().getOrNull()?.size ?: 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (lastCommitHash.asKnown().isPresent) 1 else 0) + + (latestCommitManifest.asKnown().getOrNull()?.validity() ?: 0) + + (if (likedByAuthUser.asKnown().isPresent) 1 else 0) + + (if (originalRepoFullName.asKnown().isPresent) 1 else 0) + + (if (originalRepoId.asKnown().isPresent) 1 else 0) + + (if (readme.asKnown().isPresent) 1 else 0) + + (if (upstreamRepoFullName.asKnown().isPresent) 1 else 0) + + (if (upstreamRepoId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RepoWithLookups && + id == other.id && + createdAt == other.createdAt && + fullName == other.fullName && + isArchived == other.isArchived && + isPublic == other.isPublic && + numCommits == other.numCommits && + numDownloads == other.numDownloads && + numLikes == other.numLikes && + numViews == other.numViews && + owner == other.owner && + repoHandle == other.repoHandle && + tags == other.tags && + tenantId == other.tenantId && + updatedAt == other.updatedAt && + description == other.description && + lastCommitHash == other.lastCommitHash && + latestCommitManifest == other.latestCommitManifest && + likedByAuthUser == other.likedByAuthUser && + originalRepoFullName == other.originalRepoFullName && + originalRepoId == other.originalRepoId && + readme == other.readme && + upstreamRepoFullName == other.upstreamRepoFullName && + upstreamRepoId == other.upstreamRepoId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + createdAt, + fullName, + isArchived, + isPublic, + numCommits, + numDownloads, + numLikes, + numViews, + owner, + repoHandle, + tags, + tenantId, + updatedAt, + description, + lastCommitHash, + latestCommitManifest, + likedByAuthUser, + originalRepoFullName, + originalRepoId, + readme, + upstreamRepoFullName, + upstreamRepoId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RepoWithLookups{id=$id, createdAt=$createdAt, fullName=$fullName, isArchived=$isArchived, isPublic=$isPublic, numCommits=$numCommits, numDownloads=$numDownloads, numLikes=$numLikes, numViews=$numViews, owner=$owner, repoHandle=$repoHandle, tags=$tags, tenantId=$tenantId, updatedAt=$updatedAt, description=$description, lastCommitHash=$lastCommitHash, latestCommitManifest=$latestCommitManifest, likedByAuthUser=$likedByAuthUser, originalRepoFullName=$originalRepoFullName, originalRepoId=$originalRepoId, readme=$readme, upstreamRepoFullName=$upstreamRepoFullName, upstreamRepoId=$upstreamRepoId, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/EPromptOptimizationJobStatus.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/EPromptOptimizationJobStatus.kt new file mode 100644 index 00000000..018e3d46 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/EPromptOptimizationJobStatus.kt @@ -0,0 +1,155 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.optimizationjobs + +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException + +class EPromptOptimizationJobStatus +@JsonCreator +private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't match + * any known member, and you want to know that value. For example, if the SDK is on an older + * version than the API, then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val CREATED = of("created") + + @JvmField val RUNNING = of("running") + + @JvmField val SUCCESSFUL = of("successful") + + @JvmField val FAILED = of("failed") + + @JvmStatic fun of(value: String) = EPromptOptimizationJobStatus(JsonField.of(value)) + } + + /** An enum containing [EPromptOptimizationJobStatus]'s known values. */ + enum class Known { + CREATED, + RUNNING, + SUCCESSFUL, + FAILED, + } + + /** + * An enum containing [EPromptOptimizationJobStatus]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [EPromptOptimizationJobStatus] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, if the SDK + * is on an older version than the API, then the API may respond with new members that the SDK + * is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CREATED, + RUNNING, + SUCCESSFUL, + FAILED, + /** + * An enum member indicating that [EPromptOptimizationJobStatus] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if + * the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want to + * throw for the unknown case. + */ + fun value(): Value = + when (this) { + CREATED -> Value.CREATED + RUNNING -> Value.RUNNING + SUCCESSFUL -> Value.SUCCESSFUL + FAILED -> Value.FAILED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't want + * to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CREATED -> Known.CREATED + RUNNING -> Known.RUNNING + SUCCESSFUL -> Known.SUCCESSFUL + FAILED -> Known.FAILED + else -> + throw LangsmithApiInvalidDataException( + "Unknown EPromptOptimizationJobStatus: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): EPromptOptimizationJobStatus = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EPromptOptimizationJobStatus && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobDeleteParams.kt new file mode 100644 index 00000000..01d132c3 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobDeleteParams.kt @@ -0,0 +1,272 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.optimizationjobs + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete a prompt optimization job. */ +class OptimizationJobDeleteParams +private constructor( + private val owner: String, + private val repo: String, + private val jobId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun owner(): String = owner + + fun repo(): String = repo + + fun jobId(): Optional<String> = Optional.ofNullable(jobId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [OptimizationJobDeleteParams]. + * + * The following fields are required: + * ```java + * .owner() + * .repo() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OptimizationJobDeleteParams]. */ + class Builder internal constructor() { + + private var owner: String? = null + private var repo: String? = null + private var jobId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(optimizationJobDeleteParams: OptimizationJobDeleteParams) = apply { + owner = optimizationJobDeleteParams.owner + repo = optimizationJobDeleteParams.repo + jobId = optimizationJobDeleteParams.jobId + additionalHeaders = optimizationJobDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = optimizationJobDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + optimizationJobDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun owner(owner: String) = apply { this.owner = owner } + + fun repo(repo: String) = apply { this.repo = repo } + + fun jobId(jobId: String?) = apply { this.jobId = jobId } + + /** Alias for calling [Builder.jobId] with `jobId.orElse(null)`. */ + fun jobId(jobId: Optional<String>) = jobId(jobId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [OptimizationJobDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .owner() + * .repo() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): OptimizationJobDeleteParams = + OptimizationJobDeleteParams( + checkRequired("owner", owner), + checkRequired("repo", repo), + jobId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> owner + 1 -> repo + 2 -> jobId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OptimizationJobDeleteParams && + owner == other.owner && + repo == other.repo && + jobId == other.jobId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + owner, + repo, + jobId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "OptimizationJobDeleteParams{owner=$owner, repo=$repo, jobId=$jobId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobDeleteResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobDeleteResponse.kt new file mode 100644 index 00000000..cce06550 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobDeleteResponse.kt @@ -0,0 +1,119 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.optimizationjobs + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class OptimizationJobDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [OptimizationJobDeleteResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OptimizationJobDeleteResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(optimizationJobDeleteResponse: OptimizationJobDeleteResponse) = apply { + additionalProperties = optimizationJobDeleteResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OptimizationJobDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OptimizationJobDeleteResponse = + OptimizationJobDeleteResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): OptimizationJobDeleteResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OptimizationJobDeleteResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OptimizationJobDeleteResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobOptimizationJobsParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobOptimizationJobsParams.kt new file mode 100644 index 00000000..21633704 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobOptimizationJobsParams.kt @@ -0,0 +1,718 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.optimizationjobs + +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 com.langsmith_api.api.core.BaseDeserializer +import com.langsmith_api.api.core.BaseSerializer +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.allMaxBy +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.repos.DemoConfig +import com.langsmith_api.api.models.api.v1.repos.EPromptOptimizationAlgorithm +import com.langsmith_api.api.models.api.v1.repos.PromptimConfig +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create a new prompt optimization job. */ +class OptimizationJobOptimizationJobsParams +private constructor( + private val owner: String, + private val repo: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun owner(): String = owner + + fun repo(): Optional<String> = Optional.ofNullable(repo) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun algorithm(): EPromptOptimizationAlgorithm = body.algorithm() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun config(): Config = body.config() + + /** + * Returns the raw JSON value of [algorithm]. + * + * Unlike [algorithm], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _algorithm(): JsonField<EPromptOptimizationAlgorithm> = body._algorithm() + + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _config(): JsonField<Config> = body._config() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [OptimizationJobOptimizationJobsParams]. + * + * The following fields are required: + * ```java + * .owner() + * .algorithm() + * .config() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OptimizationJobOptimizationJobsParams]. */ + class Builder internal constructor() { + + private var owner: String? = null + private var repo: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + optimizationJobOptimizationJobsParams: OptimizationJobOptimizationJobsParams + ) = apply { + owner = optimizationJobOptimizationJobsParams.owner + repo = optimizationJobOptimizationJobsParams.repo + body = optimizationJobOptimizationJobsParams.body.toBuilder() + additionalHeaders = optimizationJobOptimizationJobsParams.additionalHeaders.toBuilder() + additionalQueryParams = + optimizationJobOptimizationJobsParams.additionalQueryParams.toBuilder() + } + + fun owner(owner: String) = apply { this.owner = owner } + + fun repo(repo: String?) = apply { this.repo = repo } + + /** Alias for calling [Builder.repo] with `repo.orElse(null)`. */ + fun repo(repo: Optional<String>) = repo(repo.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [algorithm] + * - [config] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun algorithm(algorithm: EPromptOptimizationAlgorithm) = apply { body.algorithm(algorithm) } + + /** + * Sets [Builder.algorithm] to an arbitrary JSON value. + * + * You should usually call [Builder.algorithm] with a well-typed + * [EPromptOptimizationAlgorithm] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun algorithm(algorithm: JsonField<EPromptOptimizationAlgorithm>) = apply { + body.algorithm(algorithm) + } + + fun config(config: Config) = apply { body.config(config) } + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed [Config] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun config(config: JsonField<Config>) = apply { body.config(config) } + + /** Alias for calling [config] with `Config.ofPromptim(promptim)`. */ + fun config(promptim: PromptimConfig) = apply { body.config(promptim) } + + /** Alias for calling [config] with `Config.ofDemo(demo)`. */ + fun config(demo: DemoConfig) = apply { body.config(demo) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [OptimizationJobOptimizationJobsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .owner() + * .algorithm() + * .config() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): OptimizationJobOptimizationJobsParams = + OptimizationJobOptimizationJobsParams( + checkRequired("owner", owner), + repo, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> owner + 1 -> repo ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val algorithm: JsonField<EPromptOptimizationAlgorithm>, + private val config: JsonField<Config>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("algorithm") + @ExcludeMissing + algorithm: JsonField<EPromptOptimizationAlgorithm> = JsonMissing.of(), + @JsonProperty("config") @ExcludeMissing config: JsonField<Config> = JsonMissing.of(), + ) : this(algorithm, config, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun algorithm(): EPromptOptimizationAlgorithm = algorithm.getRequired("algorithm") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun config(): Config = config.getRequired("config") + + /** + * Returns the raw JSON value of [algorithm]. + * + * Unlike [algorithm], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("algorithm") + @ExcludeMissing + fun _algorithm(): JsonField<EPromptOptimizationAlgorithm> = algorithm + + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("config") @ExcludeMissing fun _config(): JsonField<Config> = config + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .algorithm() + * .config() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var algorithm: JsonField<EPromptOptimizationAlgorithm>? = null + private var config: JsonField<Config>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + algorithm = body.algorithm + config = body.config + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun algorithm(algorithm: EPromptOptimizationAlgorithm) = + algorithm(JsonField.of(algorithm)) + + /** + * Sets [Builder.algorithm] to an arbitrary JSON value. + * + * You should usually call [Builder.algorithm] with a well-typed + * [EPromptOptimizationAlgorithm] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun algorithm(algorithm: JsonField<EPromptOptimizationAlgorithm>) = apply { + this.algorithm = algorithm + } + + fun config(config: Config) = config(JsonField.of(config)) + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed [Config] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun config(config: JsonField<Config>) = apply { this.config = config } + + /** Alias for calling [config] with `Config.ofPromptim(promptim)`. */ + fun config(promptim: PromptimConfig) = config(Config.ofPromptim(promptim)) + + /** Alias for calling [config] with `Config.ofDemo(demo)`. */ + fun config(demo: DemoConfig) = config(Config.ofDemo(demo)) + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .algorithm() + * .config() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("algorithm", algorithm), + checkRequired("config", config), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + algorithm().validate() + config().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (algorithm.asKnown().getOrNull()?.validity() ?: 0) + + (config.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + algorithm == other.algorithm && + config == other.config && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(algorithm, config, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{algorithm=$algorithm, config=$config, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = Config.Deserializer::class) + @JsonSerialize(using = Config.Serializer::class) + class Config + private constructor( + private val promptim: PromptimConfig? = null, + private val demo: DemoConfig? = null, + private val _json: JsonValue? = null, + ) { + + fun promptim(): Optional<PromptimConfig> = Optional.ofNullable(promptim) + + fun demo(): Optional<DemoConfig> = Optional.ofNullable(demo) + + fun isPromptim(): Boolean = promptim != null + + fun isDemo(): Boolean = demo != null + + fun asPromptim(): PromptimConfig = promptim.getOrThrow("promptim") + + fun asDemo(): DemoConfig = demo.getOrThrow("demo") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + promptim != null -> visitor.visitPromptim(promptim) + demo != null -> visitor.visitDemo(demo) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Config = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitPromptim(promptim: PromptimConfig) { + promptim.validate() + } + + override fun visitDemo(demo: DemoConfig) { + demo.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitPromptim(promptim: PromptimConfig) = promptim.validity() + + override fun visitDemo(demo: DemoConfig) = demo.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Config && promptim == other.promptim && demo == other.demo + } + + override fun hashCode(): Int = Objects.hash(promptim, demo) + + override fun toString(): String = + when { + promptim != null -> "Config{promptim=$promptim}" + demo != null -> "Config{demo=$demo}" + _json != null -> "Config{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Config") + } + + companion object { + + @JvmStatic fun ofPromptim(promptim: PromptimConfig) = Config(promptim = promptim) + + @JvmStatic fun ofDemo(demo: DemoConfig) = Config(demo = demo) + } + + /** An interface that defines how to map each variant of [Config] to a value of type [T]. */ + interface Visitor<out T> { + + fun visitPromptim(promptim: PromptimConfig): T + + fun visitDemo(demo: DemoConfig): T + + /** + * Maps an unknown variant of [Config] to a value of type [T]. + * + * An instance of [Config] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Config: $json") + } + } + + internal class Deserializer : BaseDeserializer<Config>(Config::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Config { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<PromptimConfig>())?.let { + Config(promptim = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<DemoConfig>())?.let { + Config(demo = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> Config(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Config>(Config::class) { + + override fun serialize( + value: Config, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.promptim != null -> generator.writeObject(value.promptim) + value.demo != null -> generator.writeObject(value.demo) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Config") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OptimizationJobOptimizationJobsParams && + owner == other.owner && + repo == other.repo && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(owner, repo, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "OptimizationJobOptimizationJobsParams{owner=$owner, repo=$repo, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobRetrieveOptimizationJobsParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobRetrieveOptimizationJobsParams.kt new file mode 100644 index 00000000..96021cbe --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobRetrieveOptimizationJobsParams.kt @@ -0,0 +1,223 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.optimizationjobs + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** List all prompt optimization jobs. */ +class OptimizationJobRetrieveOptimizationJobsParams +private constructor( + private val owner: String, + private val repo: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun owner(): String = owner + + fun repo(): Optional<String> = Optional.ofNullable(repo) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [OptimizationJobRetrieveOptimizationJobsParams]. + * + * The following fields are required: + * ```java + * .owner() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OptimizationJobRetrieveOptimizationJobsParams]. */ + class Builder internal constructor() { + + private var owner: String? = null + private var repo: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + optimizationJobRetrieveOptimizationJobsParams: + OptimizationJobRetrieveOptimizationJobsParams + ) = apply { + owner = optimizationJobRetrieveOptimizationJobsParams.owner + repo = optimizationJobRetrieveOptimizationJobsParams.repo + additionalHeaders = + optimizationJobRetrieveOptimizationJobsParams.additionalHeaders.toBuilder() + additionalQueryParams = + optimizationJobRetrieveOptimizationJobsParams.additionalQueryParams.toBuilder() + } + + fun owner(owner: String) = apply { this.owner = owner } + + fun repo(repo: String?) = apply { this.repo = repo } + + /** Alias for calling [Builder.repo] with `repo.orElse(null)`. */ + fun repo(repo: Optional<String>) = repo(repo.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [OptimizationJobRetrieveOptimizationJobsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .owner() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): OptimizationJobRetrieveOptimizationJobsParams = + OptimizationJobRetrieveOptimizationJobsParams( + checkRequired("owner", owner), + repo, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> owner + 1 -> repo ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OptimizationJobRetrieveOptimizationJobsParams && + owner == other.owner && + repo == other.repo && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(owner, repo, additionalHeaders, additionalQueryParams) + + override fun toString() = + "OptimizationJobRetrieveOptimizationJobsParams{owner=$owner, repo=$repo, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobRetrieveParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobRetrieveParams.kt new file mode 100644 index 00000000..146e7740 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobRetrieveParams.kt @@ -0,0 +1,230 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.optimizationjobs + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get a specific optimization job. */ +class OptimizationJobRetrieveParams +private constructor( + private val owner: String, + private val repo: String, + private val jobId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun owner(): String = owner + + fun repo(): String = repo + + fun jobId(): Optional<String> = Optional.ofNullable(jobId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [OptimizationJobRetrieveParams]. + * + * The following fields are required: + * ```java + * .owner() + * .repo() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OptimizationJobRetrieveParams]. */ + class Builder internal constructor() { + + private var owner: String? = null + private var repo: String? = null + private var jobId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(optimizationJobRetrieveParams: OptimizationJobRetrieveParams) = apply { + owner = optimizationJobRetrieveParams.owner + repo = optimizationJobRetrieveParams.repo + jobId = optimizationJobRetrieveParams.jobId + additionalHeaders = optimizationJobRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = optimizationJobRetrieveParams.additionalQueryParams.toBuilder() + } + + fun owner(owner: String) = apply { this.owner = owner } + + fun repo(repo: String) = apply { this.repo = repo } + + fun jobId(jobId: String?) = apply { this.jobId = jobId } + + /** Alias for calling [Builder.jobId] with `jobId.orElse(null)`. */ + fun jobId(jobId: Optional<String>) = jobId(jobId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [OptimizationJobRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .owner() + * .repo() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): OptimizationJobRetrieveParams = + OptimizationJobRetrieveParams( + checkRequired("owner", owner), + checkRequired("repo", repo), + jobId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> owner + 1 -> repo + 2 -> jobId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OptimizationJobRetrieveParams && + owner == other.owner && + repo == other.repo && + jobId == other.jobId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(owner, repo, jobId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "OptimizationJobRetrieveParams{owner=$owner, repo=$repo, jobId=$jobId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobRetrieveResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobRetrieveResponse.kt new file mode 100644 index 00000000..b5039f05 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobRetrieveResponse.kt @@ -0,0 +1,750 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.optimizationjobs + +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 com.langsmith_api.api.core.BaseDeserializer +import com.langsmith_api.api.core.BaseSerializer +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.allMaxBy +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.repos.DemoConfig +import com.langsmith_api.api.models.api.v1.repos.EPromptOptimizationAlgorithm +import com.langsmith_api.api.models.api.v1.repos.PromptimConfig +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs.PromptOptimizationJobLog +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class OptimizationJobRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val algorithm: JsonField<EPromptOptimizationAlgorithm>, + private val config: JsonField<Config>, + private val createdAt: JsonField<OffsetDateTime>, + private val logs: JsonField<List<PromptOptimizationJobLog>>, + private val repoId: JsonField<String>, + private val status: JsonField<EPromptOptimizationJobStatus>, + private val tenantId: JsonField<String>, + private val updatedAt: JsonField<OffsetDateTime>, + private val results: JsonField<List<PromptOptimizationResult>>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("algorithm") + @ExcludeMissing + algorithm: JsonField<EPromptOptimizationAlgorithm> = JsonMissing.of(), + @JsonProperty("config") @ExcludeMissing config: JsonField<Config> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("logs") + @ExcludeMissing + logs: JsonField<List<PromptOptimizationJobLog>> = JsonMissing.of(), + @JsonProperty("repo_id") @ExcludeMissing repoId: JsonField<String> = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField<EPromptOptimizationJobStatus> = JsonMissing.of(), + @JsonProperty("tenant_id") @ExcludeMissing tenantId: JsonField<String> = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("results") + @ExcludeMissing + results: JsonField<List<PromptOptimizationResult>> = JsonMissing.of(), + ) : this( + id, + algorithm, + config, + createdAt, + logs, + repoId, + status, + tenantId, + updatedAt, + results, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun algorithm(): EPromptOptimizationAlgorithm = algorithm.getRequired("algorithm") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun config(): Config = config.getRequired("config") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun logs(): List<PromptOptimizationJobLog> = logs.getRequired("logs") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun repoId(): String = repoId.getRequired("repo_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): EPromptOptimizationJobStatus = status.getRequired("status") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tenantId(): String = tenantId.getRequired("tenant_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updatedAt(): OffsetDateTime = updatedAt.getRequired("updated_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun results(): Optional<List<PromptOptimizationResult>> = results.getOptional("results") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [algorithm]. + * + * Unlike [algorithm], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("algorithm") + @ExcludeMissing + fun _algorithm(): JsonField<EPromptOptimizationAlgorithm> = algorithm + + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("config") @ExcludeMissing fun _config(): JsonField<Config> = config + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [logs]. + * + * Unlike [logs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("logs") + @ExcludeMissing + fun _logs(): JsonField<List<PromptOptimizationJobLog>> = logs + + /** + * Returns the raw JSON value of [repoId]. + * + * Unlike [repoId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("repo_id") @ExcludeMissing fun _repoId(): JsonField<String> = repoId + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") + @ExcludeMissing + fun _status(): JsonField<EPromptOptimizationJobStatus> = status + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_id") @ExcludeMissing fun _tenantId(): JsonField<String> = tenantId + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField<OffsetDateTime> = updatedAt + + /** + * Returns the raw JSON value of [results]. + * + * Unlike [results], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("results") + @ExcludeMissing + fun _results(): JsonField<List<PromptOptimizationResult>> = results + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [OptimizationJobRetrieveResponse]. + * + * The following fields are required: + * ```java + * .id() + * .algorithm() + * .config() + * .createdAt() + * .logs() + * .repoId() + * .status() + * .tenantId() + * .updatedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OptimizationJobRetrieveResponse]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var algorithm: JsonField<EPromptOptimizationAlgorithm>? = null + private var config: JsonField<Config>? = null + private var createdAt: JsonField<OffsetDateTime>? = null + private var logs: JsonField<MutableList<PromptOptimizationJobLog>>? = null + private var repoId: JsonField<String>? = null + private var status: JsonField<EPromptOptimizationJobStatus>? = null + private var tenantId: JsonField<String>? = null + private var updatedAt: JsonField<OffsetDateTime>? = null + private var results: JsonField<MutableList<PromptOptimizationResult>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(optimizationJobRetrieveResponse: OptimizationJobRetrieveResponse) = + apply { + id = optimizationJobRetrieveResponse.id + algorithm = optimizationJobRetrieveResponse.algorithm + config = optimizationJobRetrieveResponse.config + createdAt = optimizationJobRetrieveResponse.createdAt + logs = optimizationJobRetrieveResponse.logs.map { it.toMutableList() } + repoId = optimizationJobRetrieveResponse.repoId + status = optimizationJobRetrieveResponse.status + tenantId = optimizationJobRetrieveResponse.tenantId + updatedAt = optimizationJobRetrieveResponse.updatedAt + results = optimizationJobRetrieveResponse.results.map { it.toMutableList() } + additionalProperties = + optimizationJobRetrieveResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun algorithm(algorithm: EPromptOptimizationAlgorithm) = algorithm(JsonField.of(algorithm)) + + /** + * Sets [Builder.algorithm] to an arbitrary JSON value. + * + * You should usually call [Builder.algorithm] with a well-typed + * [EPromptOptimizationAlgorithm] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun algorithm(algorithm: JsonField<EPromptOptimizationAlgorithm>) = apply { + this.algorithm = algorithm + } + + fun config(config: Config) = config(JsonField.of(config)) + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed [Config] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun config(config: JsonField<Config>) = apply { this.config = config } + + /** Alias for calling [config] with `Config.ofPromptim(promptim)`. */ + fun config(promptim: PromptimConfig) = config(Config.ofPromptim(promptim)) + + /** Alias for calling [config] with `Config.ofDemo(demo)`. */ + fun config(demo: DemoConfig) = config(Config.ofDemo(demo)) + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun logs(logs: List<PromptOptimizationJobLog>) = logs(JsonField.of(logs)) + + /** + * Sets [Builder.logs] to an arbitrary JSON value. + * + * You should usually call [Builder.logs] with a well-typed `List<PromptOptimizationJobLog>` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun logs(logs: JsonField<List<PromptOptimizationJobLog>>) = apply { + this.logs = logs.map { it.toMutableList() } + } + + /** + * Adds a single [PromptOptimizationJobLog] to [logs]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLog(log: PromptOptimizationJobLog) = apply { + logs = (logs ?: JsonField.of(mutableListOf())).also { checkKnown("logs", it).add(log) } + } + + fun repoId(repoId: String) = repoId(JsonField.of(repoId)) + + /** + * Sets [Builder.repoId] to an arbitrary JSON value. + * + * You should usually call [Builder.repoId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun repoId(repoId: JsonField<String>) = apply { this.repoId = repoId } + + fun status(status: EPromptOptimizationJobStatus) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [EPromptOptimizationJobStatus] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun status(status: JsonField<EPromptOptimizationJobStatus>) = apply { this.status = status } + + fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tenantId(tenantId: JsonField<String>) = apply { this.tenantId = tenantId } + + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField<OffsetDateTime>) = apply { this.updatedAt = updatedAt } + + fun results(results: List<PromptOptimizationResult>) = results(JsonField.of(results)) + + /** + * Sets [Builder.results] to an arbitrary JSON value. + * + * You should usually call [Builder.results] with a well-typed + * `List<PromptOptimizationResult>` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun results(results: JsonField<List<PromptOptimizationResult>>) = apply { + this.results = results.map { it.toMutableList() } + } + + /** + * Adds a single [PromptOptimizationResult] to [results]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResult(result: PromptOptimizationResult) = apply { + results = + (results ?: JsonField.of(mutableListOf())).also { + checkKnown("results", it).add(result) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OptimizationJobRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .algorithm() + * .config() + * .createdAt() + * .logs() + * .repoId() + * .status() + * .tenantId() + * .updatedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): OptimizationJobRetrieveResponse = + OptimizationJobRetrieveResponse( + checkRequired("id", id), + checkRequired("algorithm", algorithm), + checkRequired("config", config), + checkRequired("createdAt", createdAt), + checkRequired("logs", logs).map { it.toImmutable() }, + checkRequired("repoId", repoId), + checkRequired("status", status), + checkRequired("tenantId", tenantId), + checkRequired("updatedAt", updatedAt), + (results ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OptimizationJobRetrieveResponse = apply { + if (validated) { + return@apply + } + + id() + algorithm().validate() + config().validate() + createdAt() + logs().forEach { it.validate() } + repoId() + status().validate() + tenantId() + updatedAt() + results().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (algorithm.asKnown().getOrNull()?.validity() ?: 0) + + (config.asKnown().getOrNull()?.validity() ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (logs.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (repoId.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (results.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + @JsonDeserialize(using = Config.Deserializer::class) + @JsonSerialize(using = Config.Serializer::class) + class Config + private constructor( + private val promptim: PromptimConfig? = null, + private val demo: DemoConfig? = null, + private val _json: JsonValue? = null, + ) { + + fun promptim(): Optional<PromptimConfig> = Optional.ofNullable(promptim) + + fun demo(): Optional<DemoConfig> = Optional.ofNullable(demo) + + fun isPromptim(): Boolean = promptim != null + + fun isDemo(): Boolean = demo != null + + fun asPromptim(): PromptimConfig = promptim.getOrThrow("promptim") + + fun asDemo(): DemoConfig = demo.getOrThrow("demo") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + promptim != null -> visitor.visitPromptim(promptim) + demo != null -> visitor.visitDemo(demo) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Config = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitPromptim(promptim: PromptimConfig) { + promptim.validate() + } + + override fun visitDemo(demo: DemoConfig) { + demo.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitPromptim(promptim: PromptimConfig) = promptim.validity() + + override fun visitDemo(demo: DemoConfig) = demo.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Config && promptim == other.promptim && demo == other.demo + } + + override fun hashCode(): Int = Objects.hash(promptim, demo) + + override fun toString(): String = + when { + promptim != null -> "Config{promptim=$promptim}" + demo != null -> "Config{demo=$demo}" + _json != null -> "Config{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Config") + } + + companion object { + + @JvmStatic fun ofPromptim(promptim: PromptimConfig) = Config(promptim = promptim) + + @JvmStatic fun ofDemo(demo: DemoConfig) = Config(demo = demo) + } + + /** An interface that defines how to map each variant of [Config] to a value of type [T]. */ + interface Visitor<out T> { + + fun visitPromptim(promptim: PromptimConfig): T + + fun visitDemo(demo: DemoConfig): T + + /** + * Maps an unknown variant of [Config] to a value of type [T]. + * + * An instance of [Config] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Config: $json") + } + } + + internal class Deserializer : BaseDeserializer<Config>(Config::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Config { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<PromptimConfig>())?.let { + Config(promptim = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<DemoConfig>())?.let { + Config(demo = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> Config(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Config>(Config::class) { + + override fun serialize( + value: Config, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.promptim != null -> generator.writeObject(value.promptim) + value.demo != null -> generator.writeObject(value.demo) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Config") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OptimizationJobRetrieveResponse && + id == other.id && + algorithm == other.algorithm && + config == other.config && + createdAt == other.createdAt && + logs == other.logs && + repoId == other.repoId && + status == other.status && + tenantId == other.tenantId && + updatedAt == other.updatedAt && + results == other.results && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + algorithm, + config, + createdAt, + logs, + repoId, + status, + tenantId, + updatedAt, + results, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OptimizationJobRetrieveResponse{id=$id, algorithm=$algorithm, config=$config, createdAt=$createdAt, logs=$logs, repoId=$repoId, status=$status, tenantId=$tenantId, updatedAt=$updatedAt, results=$results, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobUpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobUpdateParams.kt new file mode 100644 index 00000000..d2f31fb0 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobUpdateParams.kt @@ -0,0 +1,518 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.optimizationjobs + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Replace an existing prompt optimization job with a new, modified job. */ +class OptimizationJobUpdateParams +private constructor( + private val owner: String, + private val repo: String, + private val jobId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun owner(): String = owner + + fun repo(): String = repo + + fun jobId(): Optional<String> = Optional.ofNullable(jobId) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun result(): Optional<PromptOptimizationResult> = body.result() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun status(): Optional<EPromptOptimizationJobStatus> = body.status() + + /** + * Returns the raw JSON value of [result]. + * + * Unlike [result], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _result(): JsonField<PromptOptimizationResult> = body._result() + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _status(): JsonField<EPromptOptimizationJobStatus> = body._status() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [OptimizationJobUpdateParams]. + * + * The following fields are required: + * ```java + * .owner() + * .repo() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OptimizationJobUpdateParams]. */ + class Builder internal constructor() { + + private var owner: String? = null + private var repo: String? = null + private var jobId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(optimizationJobUpdateParams: OptimizationJobUpdateParams) = apply { + owner = optimizationJobUpdateParams.owner + repo = optimizationJobUpdateParams.repo + jobId = optimizationJobUpdateParams.jobId + body = optimizationJobUpdateParams.body.toBuilder() + additionalHeaders = optimizationJobUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = optimizationJobUpdateParams.additionalQueryParams.toBuilder() + } + + fun owner(owner: String) = apply { this.owner = owner } + + fun repo(repo: String) = apply { this.repo = repo } + + fun jobId(jobId: String?) = apply { this.jobId = jobId } + + /** Alias for calling [Builder.jobId] with `jobId.orElse(null)`. */ + fun jobId(jobId: Optional<String>) = jobId(jobId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [result] + * - [status] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun result(result: PromptOptimizationResult?) = apply { body.result(result) } + + /** Alias for calling [Builder.result] with `result.orElse(null)`. */ + fun result(result: Optional<PromptOptimizationResult>) = result(result.getOrNull()) + + /** + * Sets [Builder.result] to an arbitrary JSON value. + * + * You should usually call [Builder.result] with a well-typed [PromptOptimizationResult] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun result(result: JsonField<PromptOptimizationResult>) = apply { body.result(result) } + + fun status(status: EPromptOptimizationJobStatus?) = apply { body.status(status) } + + /** Alias for calling [Builder.status] with `status.orElse(null)`. */ + fun status(status: Optional<EPromptOptimizationJobStatus>) = status(status.getOrNull()) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [EPromptOptimizationJobStatus] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun status(status: JsonField<EPromptOptimizationJobStatus>) = apply { body.status(status) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [OptimizationJobUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .owner() + * .repo() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): OptimizationJobUpdateParams = + OptimizationJobUpdateParams( + checkRequired("owner", owner), + checkRequired("repo", repo), + jobId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> owner + 1 -> repo + 2 -> jobId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val result: JsonField<PromptOptimizationResult>, + private val status: JsonField<EPromptOptimizationJobStatus>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("result") + @ExcludeMissing + result: JsonField<PromptOptimizationResult> = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField<EPromptOptimizationJobStatus> = JsonMissing.of(), + ) : this(result, status, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun result(): Optional<PromptOptimizationResult> = result.getOptional("result") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun status(): Optional<EPromptOptimizationJobStatus> = status.getOptional("status") + + /** + * Returns the raw JSON value of [result]. + * + * Unlike [result], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("result") + @ExcludeMissing + fun _result(): JsonField<PromptOptimizationResult> = result + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") + @ExcludeMissing + fun _status(): JsonField<EPromptOptimizationJobStatus> = status + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var result: JsonField<PromptOptimizationResult> = JsonMissing.of() + private var status: JsonField<EPromptOptimizationJobStatus> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + result = body.result + status = body.status + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun result(result: PromptOptimizationResult?) = result(JsonField.ofNullable(result)) + + /** Alias for calling [Builder.result] with `result.orElse(null)`. */ + fun result(result: Optional<PromptOptimizationResult>) = result(result.getOrNull()) + + /** + * Sets [Builder.result] to an arbitrary JSON value. + * + * You should usually call [Builder.result] with a well-typed [PromptOptimizationResult] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun result(result: JsonField<PromptOptimizationResult>) = apply { this.result = result } + + fun status(status: EPromptOptimizationJobStatus?) = status(JsonField.ofNullable(status)) + + /** Alias for calling [Builder.status] with `status.orElse(null)`. */ + fun status(status: Optional<EPromptOptimizationJobStatus>) = status(status.getOrNull()) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed + * [EPromptOptimizationJobStatus] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField<EPromptOptimizationJobStatus>) = apply { + this.status = status + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = Body(result, status, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + result().ifPresent { it.validate() } + status().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (result.asKnown().getOrNull()?.validity() ?: 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + result == other.result && + status == other.status && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(result, status, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{result=$result, status=$status, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OptimizationJobUpdateParams && + owner == other.owner && + repo == other.repo && + jobId == other.jobId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(owner, repo, jobId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "OptimizationJobUpdateParams{owner=$owner, repo=$repo, jobId=$jobId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/PromptOptimizationJob.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/PromptOptimizationJob.kt new file mode 100644 index 00000000..7f71c792 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/PromptOptimizationJob.kt @@ -0,0 +1,695 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.optimizationjobs + +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 com.langsmith_api.api.core.BaseDeserializer +import com.langsmith_api.api.core.BaseSerializer +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.allMaxBy +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.repos.DemoConfig +import com.langsmith_api.api.models.api.v1.repos.EPromptOptimizationAlgorithm +import com.langsmith_api.api.models.api.v1.repos.PromptimConfig +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class PromptOptimizationJob +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val algorithm: JsonField<EPromptOptimizationAlgorithm>, + private val config: JsonField<Config>, + private val createdAt: JsonField<OffsetDateTime>, + private val repoId: JsonField<String>, + private val status: JsonField<EPromptOptimizationJobStatus>, + private val tenantId: JsonField<String>, + private val updatedAt: JsonField<OffsetDateTime>, + private val results: JsonField<List<PromptOptimizationResult>>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("algorithm") + @ExcludeMissing + algorithm: JsonField<EPromptOptimizationAlgorithm> = JsonMissing.of(), + @JsonProperty("config") @ExcludeMissing config: JsonField<Config> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("repo_id") @ExcludeMissing repoId: JsonField<String> = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField<EPromptOptimizationJobStatus> = JsonMissing.of(), + @JsonProperty("tenant_id") @ExcludeMissing tenantId: JsonField<String> = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("results") + @ExcludeMissing + results: JsonField<List<PromptOptimizationResult>> = JsonMissing.of(), + ) : this( + id, + algorithm, + config, + createdAt, + repoId, + status, + tenantId, + updatedAt, + results, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun algorithm(): EPromptOptimizationAlgorithm = algorithm.getRequired("algorithm") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun config(): Config = config.getRequired("config") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun repoId(): String = repoId.getRequired("repo_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): EPromptOptimizationJobStatus = status.getRequired("status") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tenantId(): String = tenantId.getRequired("tenant_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updatedAt(): OffsetDateTime = updatedAt.getRequired("updated_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun results(): Optional<List<PromptOptimizationResult>> = results.getOptional("results") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [algorithm]. + * + * Unlike [algorithm], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("algorithm") + @ExcludeMissing + fun _algorithm(): JsonField<EPromptOptimizationAlgorithm> = algorithm + + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("config") @ExcludeMissing fun _config(): JsonField<Config> = config + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [repoId]. + * + * Unlike [repoId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("repo_id") @ExcludeMissing fun _repoId(): JsonField<String> = repoId + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") + @ExcludeMissing + fun _status(): JsonField<EPromptOptimizationJobStatus> = status + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_id") @ExcludeMissing fun _tenantId(): JsonField<String> = tenantId + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField<OffsetDateTime> = updatedAt + + /** + * Returns the raw JSON value of [results]. + * + * Unlike [results], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("results") + @ExcludeMissing + fun _results(): JsonField<List<PromptOptimizationResult>> = results + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PromptOptimizationJob]. + * + * The following fields are required: + * ```java + * .id() + * .algorithm() + * .config() + * .createdAt() + * .repoId() + * .status() + * .tenantId() + * .updatedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PromptOptimizationJob]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var algorithm: JsonField<EPromptOptimizationAlgorithm>? = null + private var config: JsonField<Config>? = null + private var createdAt: JsonField<OffsetDateTime>? = null + private var repoId: JsonField<String>? = null + private var status: JsonField<EPromptOptimizationJobStatus>? = null + private var tenantId: JsonField<String>? = null + private var updatedAt: JsonField<OffsetDateTime>? = null + private var results: JsonField<MutableList<PromptOptimizationResult>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(promptOptimizationJob: PromptOptimizationJob) = apply { + id = promptOptimizationJob.id + algorithm = promptOptimizationJob.algorithm + config = promptOptimizationJob.config + createdAt = promptOptimizationJob.createdAt + repoId = promptOptimizationJob.repoId + status = promptOptimizationJob.status + tenantId = promptOptimizationJob.tenantId + updatedAt = promptOptimizationJob.updatedAt + results = promptOptimizationJob.results.map { it.toMutableList() } + additionalProperties = promptOptimizationJob.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun algorithm(algorithm: EPromptOptimizationAlgorithm) = algorithm(JsonField.of(algorithm)) + + /** + * Sets [Builder.algorithm] to an arbitrary JSON value. + * + * You should usually call [Builder.algorithm] with a well-typed + * [EPromptOptimizationAlgorithm] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun algorithm(algorithm: JsonField<EPromptOptimizationAlgorithm>) = apply { + this.algorithm = algorithm + } + + fun config(config: Config) = config(JsonField.of(config)) + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed [Config] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun config(config: JsonField<Config>) = apply { this.config = config } + + /** Alias for calling [config] with `Config.ofPromptim(promptim)`. */ + fun config(promptim: PromptimConfig) = config(Config.ofPromptim(promptim)) + + /** Alias for calling [config] with `Config.ofDemo(demo)`. */ + fun config(demo: DemoConfig) = config(Config.ofDemo(demo)) + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun repoId(repoId: String) = repoId(JsonField.of(repoId)) + + /** + * Sets [Builder.repoId] to an arbitrary JSON value. + * + * You should usually call [Builder.repoId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun repoId(repoId: JsonField<String>) = apply { this.repoId = repoId } + + fun status(status: EPromptOptimizationJobStatus) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [EPromptOptimizationJobStatus] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun status(status: JsonField<EPromptOptimizationJobStatus>) = apply { this.status = status } + + fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tenantId(tenantId: JsonField<String>) = apply { this.tenantId = tenantId } + + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField<OffsetDateTime>) = apply { this.updatedAt = updatedAt } + + fun results(results: List<PromptOptimizationResult>) = results(JsonField.of(results)) + + /** + * Sets [Builder.results] to an arbitrary JSON value. + * + * You should usually call [Builder.results] with a well-typed + * `List<PromptOptimizationResult>` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun results(results: JsonField<List<PromptOptimizationResult>>) = apply { + this.results = results.map { it.toMutableList() } + } + + /** + * Adds a single [PromptOptimizationResult] to [results]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResult(result: PromptOptimizationResult) = apply { + results = + (results ?: JsonField.of(mutableListOf())).also { + checkKnown("results", it).add(result) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PromptOptimizationJob]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .algorithm() + * .config() + * .createdAt() + * .repoId() + * .status() + * .tenantId() + * .updatedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PromptOptimizationJob = + PromptOptimizationJob( + checkRequired("id", id), + checkRequired("algorithm", algorithm), + checkRequired("config", config), + checkRequired("createdAt", createdAt), + checkRequired("repoId", repoId), + checkRequired("status", status), + checkRequired("tenantId", tenantId), + checkRequired("updatedAt", updatedAt), + (results ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PromptOptimizationJob = apply { + if (validated) { + return@apply + } + + id() + algorithm().validate() + config().validate() + createdAt() + repoId() + status().validate() + tenantId() + updatedAt() + results().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (algorithm.asKnown().getOrNull()?.validity() ?: 0) + + (config.asKnown().getOrNull()?.validity() ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (repoId.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (results.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + @JsonDeserialize(using = Config.Deserializer::class) + @JsonSerialize(using = Config.Serializer::class) + class Config + private constructor( + private val promptim: PromptimConfig? = null, + private val demo: DemoConfig? = null, + private val _json: JsonValue? = null, + ) { + + fun promptim(): Optional<PromptimConfig> = Optional.ofNullable(promptim) + + fun demo(): Optional<DemoConfig> = Optional.ofNullable(demo) + + fun isPromptim(): Boolean = promptim != null + + fun isDemo(): Boolean = demo != null + + fun asPromptim(): PromptimConfig = promptim.getOrThrow("promptim") + + fun asDemo(): DemoConfig = demo.getOrThrow("demo") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + promptim != null -> visitor.visitPromptim(promptim) + demo != null -> visitor.visitDemo(demo) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Config = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitPromptim(promptim: PromptimConfig) { + promptim.validate() + } + + override fun visitDemo(demo: DemoConfig) { + demo.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitPromptim(promptim: PromptimConfig) = promptim.validity() + + override fun visitDemo(demo: DemoConfig) = demo.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Config && promptim == other.promptim && demo == other.demo + } + + override fun hashCode(): Int = Objects.hash(promptim, demo) + + override fun toString(): String = + when { + promptim != null -> "Config{promptim=$promptim}" + demo != null -> "Config{demo=$demo}" + _json != null -> "Config{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Config") + } + + companion object { + + @JvmStatic fun ofPromptim(promptim: PromptimConfig) = Config(promptim = promptim) + + @JvmStatic fun ofDemo(demo: DemoConfig) = Config(demo = demo) + } + + /** An interface that defines how to map each variant of [Config] to a value of type [T]. */ + interface Visitor<out T> { + + fun visitPromptim(promptim: PromptimConfig): T + + fun visitDemo(demo: DemoConfig): T + + /** + * Maps an unknown variant of [Config] to a value of type [T]. + * + * An instance of [Config] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Config: $json") + } + } + + internal class Deserializer : BaseDeserializer<Config>(Config::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Config { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<PromptimConfig>())?.let { + Config(promptim = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<DemoConfig>())?.let { + Config(demo = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> Config(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<Config>(Config::class) { + + override fun serialize( + value: Config, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.promptim != null -> generator.writeObject(value.promptim) + value.demo != null -> generator.writeObject(value.demo) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Config") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PromptOptimizationJob && + id == other.id && + algorithm == other.algorithm && + config == other.config && + createdAt == other.createdAt && + repoId == other.repoId && + status == other.status && + tenantId == other.tenantId && + updatedAt == other.updatedAt && + results == other.results && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + algorithm, + config, + createdAt, + repoId, + status, + tenantId, + updatedAt, + results, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PromptOptimizationJob{id=$id, algorithm=$algorithm, config=$config, createdAt=$createdAt, repoId=$repoId, status=$status, tenantId=$tenantId, updatedAt=$updatedAt, results=$results, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/PromptOptimizationResult.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/PromptOptimizationResult.kt new file mode 100644 index 00000000..5f3ab1d1 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/PromptOptimizationResult.kt @@ -0,0 +1,244 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.optimizationjobs + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects + +class PromptOptimizationResult +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val timestamp: JsonField<OffsetDateTime>, + private val x: JsonField<Double>, + private val y: JsonField<Double>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("timestamp") + @ExcludeMissing + timestamp: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("x") @ExcludeMissing x: JsonField<Double> = JsonMissing.of(), + @JsonProperty("y") @ExcludeMissing y: JsonField<Double> = JsonMissing.of(), + ) : this(timestamp, x, y, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun timestamp(): OffsetDateTime = timestamp.getRequired("timestamp") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun x(): Double = x.getRequired("x") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun y(): Double = y.getRequired("y") + + /** + * Returns the raw JSON value of [timestamp]. + * + * Unlike [timestamp], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("timestamp") + @ExcludeMissing + fun _timestamp(): JsonField<OffsetDateTime> = timestamp + + /** + * Returns the raw JSON value of [x]. + * + * Unlike [x], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("x") @ExcludeMissing fun _x(): JsonField<Double> = x + + /** + * Returns the raw JSON value of [y]. + * + * Unlike [y], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("y") @ExcludeMissing fun _y(): JsonField<Double> = y + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PromptOptimizationResult]. + * + * The following fields are required: + * ```java + * .timestamp() + * .x() + * .y() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PromptOptimizationResult]. */ + class Builder internal constructor() { + + private var timestamp: JsonField<OffsetDateTime>? = null + private var x: JsonField<Double>? = null + private var y: JsonField<Double>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(promptOptimizationResult: PromptOptimizationResult) = apply { + timestamp = promptOptimizationResult.timestamp + x = promptOptimizationResult.x + y = promptOptimizationResult.y + additionalProperties = promptOptimizationResult.additionalProperties.toMutableMap() + } + + fun timestamp(timestamp: OffsetDateTime) = timestamp(JsonField.of(timestamp)) + + /** + * Sets [Builder.timestamp] to an arbitrary JSON value. + * + * You should usually call [Builder.timestamp] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun timestamp(timestamp: JsonField<OffsetDateTime>) = apply { this.timestamp = timestamp } + + fun x(x: Double) = x(JsonField.of(x)) + + /** + * Sets [Builder.x] to an arbitrary JSON value. + * + * You should usually call [Builder.x] with a well-typed [Double] value instead. This method + * is primarily for setting the field to an undocumented or not yet supported value. + */ + fun x(x: JsonField<Double>) = apply { this.x = x } + + fun y(y: Double) = y(JsonField.of(y)) + + /** + * Sets [Builder.y] to an arbitrary JSON value. + * + * You should usually call [Builder.y] with a well-typed [Double] value instead. This method + * is primarily for setting the field to an undocumented or not yet supported value. + */ + fun y(y: JsonField<Double>) = apply { this.y = y } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PromptOptimizationResult]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .timestamp() + * .x() + * .y() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PromptOptimizationResult = + PromptOptimizationResult( + checkRequired("timestamp", timestamp), + checkRequired("x", x), + checkRequired("y", y), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PromptOptimizationResult = apply { + if (validated) { + return@apply + } + + timestamp() + x() + y() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (timestamp.asKnown().isPresent) 1 else 0) + + (if (x.asKnown().isPresent) 1 else 0) + + (if (y.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PromptOptimizationResult && + timestamp == other.timestamp && + x == other.x && + y == other.y && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(timestamp, x, y, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PromptOptimizationResult{timestamp=$timestamp, x=$x, y=$y, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/EPromptOptimizationJobLogType.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/EPromptOptimizationJobLogType.kt new file mode 100644 index 00000000..a040400b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/EPromptOptimizationJobLogType.kt @@ -0,0 +1,155 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs + +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException + +class EPromptOptimizationJobLogType +@JsonCreator +private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't match + * any known member, and you want to know that value. For example, if the SDK is on an older + * version than the API, then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val INFO = of("info") + + @JvmField val RESULT = of("result") + + @JvmField val ERROR = of("error") + + @JvmField val LINK = of("link") + + @JvmStatic fun of(value: String) = EPromptOptimizationJobLogType(JsonField.of(value)) + } + + /** An enum containing [EPromptOptimizationJobLogType]'s known values. */ + enum class Known { + INFO, + RESULT, + ERROR, + LINK, + } + + /** + * An enum containing [EPromptOptimizationJobLogType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [EPromptOptimizationJobLogType] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, if the SDK + * is on an older version than the API, then the API may respond with new members that the SDK + * is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INFO, + RESULT, + ERROR, + LINK, + /** + * An enum member indicating that [EPromptOptimizationJobLogType] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if + * the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want to + * throw for the unknown case. + */ + fun value(): Value = + when (this) { + INFO -> Value.INFO + RESULT -> Value.RESULT + ERROR -> Value.ERROR + LINK -> Value.LINK + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't want + * to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INFO -> Known.INFO + RESULT -> Known.RESULT + ERROR -> Known.ERROR + LINK -> Known.LINK + else -> + throw LangsmithApiInvalidDataException( + "Unknown EPromptOptimizationJobLogType: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): EPromptOptimizationJobLogType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EPromptOptimizationJobLogType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogCreateParams.kt new file mode 100644 index 00000000..2b318a4b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogCreateParams.kt @@ -0,0 +1,545 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create a new log entry for a prompt optimization job. */ +class LogCreateParams +private constructor( + private val owner: String, + private val repo: String, + private val jobId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun owner(): String = owner + + fun repo(): String = repo + + fun jobId(): Optional<String> = Optional.ofNullable(jobId) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun logType(): EPromptOptimizationJobLogType = body.logType() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun message(): String = body.message() + + fun _data(): JsonValue = body._data() + + /** + * Returns the raw JSON value of [logType]. + * + * Unlike [logType], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _logType(): JsonField<EPromptOptimizationJobLogType> = body._logType() + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _message(): JsonField<String> = body._message() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LogCreateParams]. + * + * The following fields are required: + * ```java + * .owner() + * .repo() + * .logType() + * .message() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LogCreateParams]. */ + class Builder internal constructor() { + + private var owner: String? = null + private var repo: String? = null + private var jobId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(logCreateParams: LogCreateParams) = apply { + owner = logCreateParams.owner + repo = logCreateParams.repo + jobId = logCreateParams.jobId + body = logCreateParams.body.toBuilder() + additionalHeaders = logCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = logCreateParams.additionalQueryParams.toBuilder() + } + + fun owner(owner: String) = apply { this.owner = owner } + + fun repo(repo: String) = apply { this.repo = repo } + + fun jobId(jobId: String?) = apply { this.jobId = jobId } + + /** Alias for calling [Builder.jobId] with `jobId.orElse(null)`. */ + fun jobId(jobId: Optional<String>) = jobId(jobId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [logType] + * - [message] + * - [data] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun logType(logType: EPromptOptimizationJobLogType) = apply { body.logType(logType) } + + /** + * Sets [Builder.logType] to an arbitrary JSON value. + * + * You should usually call [Builder.logType] with a well-typed + * [EPromptOptimizationJobLogType] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun logType(logType: JsonField<EPromptOptimizationJobLogType>) = apply { + body.logType(logType) + } + + fun message(message: String) = apply { body.message(message) } + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun message(message: JsonField<String>) = apply { body.message(message) } + + fun data(data: JsonValue) = apply { body.data(data) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LogCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .owner() + * .repo() + * .logType() + * .message() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LogCreateParams = + LogCreateParams( + checkRequired("owner", owner), + checkRequired("repo", repo), + jobId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> owner + 1 -> repo + 2 -> jobId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val logType: JsonField<EPromptOptimizationJobLogType>, + private val message: JsonField<String>, + private val data: JsonValue, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("log_type") + @ExcludeMissing + logType: JsonField<EPromptOptimizationJobLogType> = JsonMissing.of(), + @JsonProperty("message") @ExcludeMissing message: JsonField<String> = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonValue = JsonMissing.of(), + ) : this(logType, message, data, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun logType(): EPromptOptimizationJobLogType = logType.getRequired("log_type") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun message(): String = message.getRequired("message") + + @JsonProperty("data") @ExcludeMissing fun _data(): JsonValue = data + + /** + * Returns the raw JSON value of [logType]. + * + * Unlike [logType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("log_type") + @ExcludeMissing + fun _logType(): JsonField<EPromptOptimizationJobLogType> = logType + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField<String> = message + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .logType() + * .message() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var logType: JsonField<EPromptOptimizationJobLogType>? = null + private var message: JsonField<String>? = null + private var data: JsonValue = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + logType = body.logType + message = body.message + data = body.data + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun logType(logType: EPromptOptimizationJobLogType) = logType(JsonField.of(logType)) + + /** + * Sets [Builder.logType] to an arbitrary JSON value. + * + * You should usually call [Builder.logType] with a well-typed + * [EPromptOptimizationJobLogType] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun logType(logType: JsonField<EPromptOptimizationJobLogType>) = apply { + this.logType = logType + } + + fun message(message: String) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun message(message: JsonField<String>) = apply { this.message = message } + + fun data(data: JsonValue) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .logType() + * .message() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("logType", logType), + checkRequired("message", message), + data, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + logType().validate() + message() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (logType.asKnown().getOrNull()?.validity() ?: 0) + + (if (message.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + logType == other.logType && + message == other.message && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(logType, message, data, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{logType=$logType, message=$message, data=$data, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LogCreateParams && + owner == other.owner && + repo == other.repo && + jobId == other.jobId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(owner, repo, jobId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "LogCreateParams{owner=$owner, repo=$repo, jobId=$jobId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogDeleteParams.kt new file mode 100644 index 00000000..ec2a0830 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogDeleteParams.kt @@ -0,0 +1,284 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete a prompt optimization job log. */ +class LogDeleteParams +private constructor( + private val owner: String, + private val repo: String, + private val jobId: String, + private val logId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun owner(): String = owner + + fun repo(): String = repo + + fun jobId(): String = jobId + + fun logId(): Optional<String> = Optional.ofNullable(logId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LogDeleteParams]. + * + * The following fields are required: + * ```java + * .owner() + * .repo() + * .jobId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LogDeleteParams]. */ + class Builder internal constructor() { + + private var owner: String? = null + private var repo: String? = null + private var jobId: String? = null + private var logId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(logDeleteParams: LogDeleteParams) = apply { + owner = logDeleteParams.owner + repo = logDeleteParams.repo + jobId = logDeleteParams.jobId + logId = logDeleteParams.logId + additionalHeaders = logDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = logDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = logDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun owner(owner: String) = apply { this.owner = owner } + + fun repo(repo: String) = apply { this.repo = repo } + + fun jobId(jobId: String) = apply { this.jobId = jobId } + + fun logId(logId: String?) = apply { this.logId = logId } + + /** Alias for calling [Builder.logId] with `logId.orElse(null)`. */ + fun logId(logId: Optional<String>) = logId(logId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [LogDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .owner() + * .repo() + * .jobId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LogDeleteParams = + LogDeleteParams( + checkRequired("owner", owner), + checkRequired("repo", repo), + checkRequired("jobId", jobId), + logId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> owner + 1 -> repo + 2 -> jobId + 3 -> logId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LogDeleteParams && + owner == other.owner && + repo == other.repo && + jobId == other.jobId && + logId == other.logId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + owner, + repo, + jobId, + logId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "LogDeleteParams{owner=$owner, repo=$repo, jobId=$jobId, logId=$logId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogDeleteResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogDeleteResponse.kt new file mode 100644 index 00000000..503e9889 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogDeleteResponse.kt @@ -0,0 +1,113 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class LogDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [LogDeleteResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LogDeleteResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(logDeleteResponse: LogDeleteResponse) = apply { + additionalProperties = logDeleteResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LogDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LogDeleteResponse = LogDeleteResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): LogDeleteResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LogDeleteResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "LogDeleteResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogListParams.kt new file mode 100644 index 00000000..50c78747 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogListParams.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** List all logs for a specific prompt optimization job. */ +class LogListParams +private constructor( + private val owner: String, + private val repo: String, + private val jobId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun owner(): String = owner + + fun repo(): String = repo + + fun jobId(): Optional<String> = Optional.ofNullable(jobId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LogListParams]. + * + * The following fields are required: + * ```java + * .owner() + * .repo() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LogListParams]. */ + class Builder internal constructor() { + + private var owner: String? = null + private var repo: String? = null + private var jobId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(logListParams: LogListParams) = apply { + owner = logListParams.owner + repo = logListParams.repo + jobId = logListParams.jobId + additionalHeaders = logListParams.additionalHeaders.toBuilder() + additionalQueryParams = logListParams.additionalQueryParams.toBuilder() + } + + fun owner(owner: String) = apply { this.owner = owner } + + fun repo(repo: String) = apply { this.repo = repo } + + fun jobId(jobId: String?) = apply { this.jobId = jobId } + + /** Alias for calling [Builder.jobId] with `jobId.orElse(null)`. */ + fun jobId(jobId: Optional<String>) = jobId(jobId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LogListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .owner() + * .repo() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LogListParams = + LogListParams( + checkRequired("owner", owner), + checkRequired("repo", repo), + jobId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> owner + 1 -> repo + 2 -> jobId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LogListParams && + owner == other.owner && + repo == other.repo && + jobId == other.jobId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(owner, repo, jobId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "LogListParams{owner=$owner, repo=$repo, jobId=$jobId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogRetrieveParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogRetrieveParams.kt new file mode 100644 index 00000000..b6cbb5a4 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogRetrieveParams.kt @@ -0,0 +1,241 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get a specific prompt optimization job log. */ +class LogRetrieveParams +private constructor( + private val owner: String, + private val repo: String, + private val jobId: String, + private val logId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun owner(): String = owner + + fun repo(): String = repo + + fun jobId(): String = jobId + + fun logId(): Optional<String> = Optional.ofNullable(logId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LogRetrieveParams]. + * + * The following fields are required: + * ```java + * .owner() + * .repo() + * .jobId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LogRetrieveParams]. */ + class Builder internal constructor() { + + private var owner: String? = null + private var repo: String? = null + private var jobId: String? = null + private var logId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(logRetrieveParams: LogRetrieveParams) = apply { + owner = logRetrieveParams.owner + repo = logRetrieveParams.repo + jobId = logRetrieveParams.jobId + logId = logRetrieveParams.logId + additionalHeaders = logRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = logRetrieveParams.additionalQueryParams.toBuilder() + } + + fun owner(owner: String) = apply { this.owner = owner } + + fun repo(repo: String) = apply { this.repo = repo } + + fun jobId(jobId: String) = apply { this.jobId = jobId } + + fun logId(logId: String?) = apply { this.logId = logId } + + /** Alias for calling [Builder.logId] with `logId.orElse(null)`. */ + fun logId(logId: Optional<String>) = logId(logId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LogRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .owner() + * .repo() + * .jobId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LogRetrieveParams = + LogRetrieveParams( + checkRequired("owner", owner), + checkRequired("repo", repo), + checkRequired("jobId", jobId), + logId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> owner + 1 -> repo + 2 -> jobId + 3 -> logId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LogRetrieveParams && + owner == other.owner && + repo == other.repo && + jobId == other.jobId && + logId == other.logId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(owner, repo, jobId, logId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "LogRetrieveParams{owner=$owner, repo=$repo, jobId=$jobId, logId=$logId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/PromptOptimizationJobLog.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/PromptOptimizationJobLog.kt new file mode 100644 index 00000000..2a4f189b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/PromptOptimizationJobLog.kt @@ -0,0 +1,330 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class PromptOptimizationJobLog +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val jobId: JsonField<String>, + private val logType: JsonField<EPromptOptimizationJobLogType>, + private val message: JsonField<String>, + private val data: JsonValue, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("job_id") @ExcludeMissing jobId: JsonField<String> = JsonMissing.of(), + @JsonProperty("log_type") + @ExcludeMissing + logType: JsonField<EPromptOptimizationJobLogType> = JsonMissing.of(), + @JsonProperty("message") @ExcludeMissing message: JsonField<String> = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonValue = JsonMissing.of(), + ) : this(id, createdAt, jobId, logType, message, data, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun jobId(): String = jobId.getRequired("job_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun logType(): EPromptOptimizationJobLogType = logType.getRequired("log_type") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun message(): String = message.getRequired("message") + + @JsonProperty("data") @ExcludeMissing fun _data(): JsonValue = data + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [jobId]. + * + * Unlike [jobId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("job_id") @ExcludeMissing fun _jobId(): JsonField<String> = jobId + + /** + * Returns the raw JSON value of [logType]. + * + * Unlike [logType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("log_type") + @ExcludeMissing + fun _logType(): JsonField<EPromptOptimizationJobLogType> = logType + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField<String> = message + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PromptOptimizationJobLog]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .jobId() + * .logType() + * .message() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PromptOptimizationJobLog]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var createdAt: JsonField<OffsetDateTime>? = null + private var jobId: JsonField<String>? = null + private var logType: JsonField<EPromptOptimizationJobLogType>? = null + private var message: JsonField<String>? = null + private var data: JsonValue = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(promptOptimizationJobLog: PromptOptimizationJobLog) = apply { + id = promptOptimizationJobLog.id + createdAt = promptOptimizationJobLog.createdAt + jobId = promptOptimizationJobLog.jobId + logType = promptOptimizationJobLog.logType + message = promptOptimizationJobLog.message + data = promptOptimizationJobLog.data + additionalProperties = promptOptimizationJobLog.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun jobId(jobId: String) = jobId(JsonField.of(jobId)) + + /** + * Sets [Builder.jobId] to an arbitrary JSON value. + * + * You should usually call [Builder.jobId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun jobId(jobId: JsonField<String>) = apply { this.jobId = jobId } + + fun logType(logType: EPromptOptimizationJobLogType) = logType(JsonField.of(logType)) + + /** + * Sets [Builder.logType] to an arbitrary JSON value. + * + * You should usually call [Builder.logType] with a well-typed + * [EPromptOptimizationJobLogType] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun logType(logType: JsonField<EPromptOptimizationJobLogType>) = apply { + this.logType = logType + } + + fun message(message: String) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun message(message: JsonField<String>) = apply { this.message = message } + + fun data(data: JsonValue) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PromptOptimizationJobLog]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .jobId() + * .logType() + * .message() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PromptOptimizationJobLog = + PromptOptimizationJobLog( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("jobId", jobId), + checkRequired("logType", logType), + checkRequired("message", message), + data, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PromptOptimizationJobLog = apply { + if (validated) { + return@apply + } + + id() + createdAt() + jobId() + logType().validate() + message() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (jobId.asKnown().isPresent) 1 else 0) + + (logType.asKnown().getOrNull()?.validity() ?: 0) + + (if (message.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PromptOptimizationJobLog && + id == other.id && + createdAt == other.createdAt && + jobId == other.jobId && + logType == other.logType && + message == other.message && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, createdAt, jobId, logType, message, data, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PromptOptimizationJobLog{id=$id, createdAt=$createdAt, jobId=$jobId, logType=$logType, message=$message, data=$data, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/RepoTag.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/RepoTag.kt new file mode 100644 index 00000000..5169599c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/RepoTag.kt @@ -0,0 +1,396 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.tags + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects + +/** Fields for a prompt tag */ +class RepoTag +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val commitHash: JsonField<String>, + private val commitId: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val repoId: JsonField<String>, + private val tagName: JsonField<String>, + private val updatedAt: JsonField<OffsetDateTime>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("commit_hash") + @ExcludeMissing + commitHash: JsonField<String> = JsonMissing.of(), + @JsonProperty("commit_id") @ExcludeMissing commitId: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("repo_id") @ExcludeMissing repoId: JsonField<String> = JsonMissing.of(), + @JsonProperty("tag_name") @ExcludeMissing tagName: JsonField<String> = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + ) : this(id, commitHash, commitId, createdAt, repoId, tagName, updatedAt, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun commitHash(): String = commitHash.getRequired("commit_hash") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun commitId(): String = commitId.getRequired("commit_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun repoId(): String = repoId.getRequired("repo_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tagName(): String = tagName.getRequired("tag_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updatedAt(): OffsetDateTime = updatedAt.getRequired("updated_at") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [commitHash]. + * + * Unlike [commitHash], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("commit_hash") @ExcludeMissing fun _commitHash(): JsonField<String> = commitHash + + /** + * Returns the raw JSON value of [commitId]. + * + * Unlike [commitId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("commit_id") @ExcludeMissing fun _commitId(): JsonField<String> = commitId + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [repoId]. + * + * Unlike [repoId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("repo_id") @ExcludeMissing fun _repoId(): JsonField<String> = repoId + + /** + * Returns the raw JSON value of [tagName]. + * + * Unlike [tagName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tag_name") @ExcludeMissing fun _tagName(): JsonField<String> = tagName + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField<OffsetDateTime> = updatedAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RepoTag]. + * + * The following fields are required: + * ```java + * .id() + * .commitHash() + * .commitId() + * .createdAt() + * .repoId() + * .tagName() + * .updatedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RepoTag]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var commitHash: JsonField<String>? = null + private var commitId: JsonField<String>? = null + private var createdAt: JsonField<OffsetDateTime>? = null + private var repoId: JsonField<String>? = null + private var tagName: JsonField<String>? = null + private var updatedAt: JsonField<OffsetDateTime>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(repoTag: RepoTag) = apply { + id = repoTag.id + commitHash = repoTag.commitHash + commitId = repoTag.commitId + createdAt = repoTag.createdAt + repoId = repoTag.repoId + tagName = repoTag.tagName + updatedAt = repoTag.updatedAt + additionalProperties = repoTag.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun commitHash(commitHash: String) = commitHash(JsonField.of(commitHash)) + + /** + * Sets [Builder.commitHash] to an arbitrary JSON value. + * + * You should usually call [Builder.commitHash] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun commitHash(commitHash: JsonField<String>) = apply { this.commitHash = commitHash } + + fun commitId(commitId: String) = commitId(JsonField.of(commitId)) + + /** + * Sets [Builder.commitId] to an arbitrary JSON value. + * + * You should usually call [Builder.commitId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun commitId(commitId: JsonField<String>) = apply { this.commitId = commitId } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun repoId(repoId: String) = repoId(JsonField.of(repoId)) + + /** + * Sets [Builder.repoId] to an arbitrary JSON value. + * + * You should usually call [Builder.repoId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun repoId(repoId: JsonField<String>) = apply { this.repoId = repoId } + + fun tagName(tagName: String) = tagName(JsonField.of(tagName)) + + /** + * Sets [Builder.tagName] to an arbitrary JSON value. + * + * You should usually call [Builder.tagName] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tagName(tagName: JsonField<String>) = apply { this.tagName = tagName } + + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField<OffsetDateTime>) = apply { this.updatedAt = updatedAt } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RepoTag]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .commitHash() + * .commitId() + * .createdAt() + * .repoId() + * .tagName() + * .updatedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RepoTag = + RepoTag( + checkRequired("id", id), + checkRequired("commitHash", commitHash), + checkRequired("commitId", commitId), + checkRequired("createdAt", createdAt), + checkRequired("repoId", repoId), + checkRequired("tagName", tagName), + checkRequired("updatedAt", updatedAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RepoTag = apply { + if (validated) { + return@apply + } + + id() + commitHash() + commitId() + createdAt() + repoId() + tagName() + updatedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (commitHash.asKnown().isPresent) 1 else 0) + + (if (commitId.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (repoId.asKnown().isPresent) 1 else 0) + + (if (tagName.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RepoTag && + id == other.id && + commitHash == other.commitHash && + commitId == other.commitId && + createdAt == other.createdAt && + repoId == other.repoId && + tagName == other.tagName && + updatedAt == other.updatedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + commitHash, + commitId, + createdAt, + repoId, + tagName, + updatedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RepoTag{id=$id, commitHash=$commitHash, commitId=$commitId, createdAt=$createdAt, repoId=$repoId, tagName=$tagName, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagCreateParams.kt new file mode 100644 index 00000000..5d4cb3c7 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagCreateParams.kt @@ -0,0 +1,776 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.tags + +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 com.langsmith_api.api.core.BaseDeserializer +import com.langsmith_api.api.core.BaseSerializer +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.allMaxBy +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create Tag */ +class TagCreateParams +private constructor( + private val owner: String, + private val repo: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun owner(): String = owner + + fun repo(): Optional<String> = Optional.ofNullable(repo) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun commitId(): String = body.commitId() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tagName(): String = body.tagName() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun skipWebhooks(): Optional<SkipWebhooks> = body.skipWebhooks() + + /** + * Returns the raw JSON value of [commitId]. + * + * Unlike [commitId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _commitId(): JsonField<String> = body._commitId() + + /** + * Returns the raw JSON value of [tagName]. + * + * Unlike [tagName], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _tagName(): JsonField<String> = body._tagName() + + /** + * Returns the raw JSON value of [skipWebhooks]. + * + * Unlike [skipWebhooks], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _skipWebhooks(): JsonField<SkipWebhooks> = body._skipWebhooks() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TagCreateParams]. + * + * The following fields are required: + * ```java + * .owner() + * .commitId() + * .tagName() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TagCreateParams]. */ + class Builder internal constructor() { + + private var owner: String? = null + private var repo: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(tagCreateParams: TagCreateParams) = apply { + owner = tagCreateParams.owner + repo = tagCreateParams.repo + body = tagCreateParams.body.toBuilder() + additionalHeaders = tagCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = tagCreateParams.additionalQueryParams.toBuilder() + } + + fun owner(owner: String) = apply { this.owner = owner } + + fun repo(repo: String?) = apply { this.repo = repo } + + /** Alias for calling [Builder.repo] with `repo.orElse(null)`. */ + fun repo(repo: Optional<String>) = repo(repo.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [commitId] + * - [tagName] + * - [skipWebhooks] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun commitId(commitId: String) = apply { body.commitId(commitId) } + + /** + * Sets [Builder.commitId] to an arbitrary JSON value. + * + * You should usually call [Builder.commitId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun commitId(commitId: JsonField<String>) = apply { body.commitId(commitId) } + + fun tagName(tagName: String) = apply { body.tagName(tagName) } + + /** + * Sets [Builder.tagName] to an arbitrary JSON value. + * + * You should usually call [Builder.tagName] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tagName(tagName: JsonField<String>) = apply { body.tagName(tagName) } + + fun skipWebhooks(skipWebhooks: SkipWebhooks) = apply { body.skipWebhooks(skipWebhooks) } + + /** + * Sets [Builder.skipWebhooks] to an arbitrary JSON value. + * + * You should usually call [Builder.skipWebhooks] with a well-typed [SkipWebhooks] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun skipWebhooks(skipWebhooks: JsonField<SkipWebhooks>) = apply { + body.skipWebhooks(skipWebhooks) + } + + /** Alias for calling [skipWebhooks] with `SkipWebhooks.ofBool(bool)`. */ + fun skipWebhooks(bool: Boolean) = apply { body.skipWebhooks(bool) } + + /** Alias for calling [skipWebhooks] with `SkipWebhooks.ofStrings(strings)`. */ + fun skipWebhooksOfStrings(strings: List<String>) = apply { + body.skipWebhooksOfStrings(strings) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TagCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .owner() + * .commitId() + * .tagName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TagCreateParams = + TagCreateParams( + checkRequired("owner", owner), + repo, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> owner + 1 -> repo ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Fields to create a prompt tag */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val commitId: JsonField<String>, + private val tagName: JsonField<String>, + private val skipWebhooks: JsonField<SkipWebhooks>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("commit_id") + @ExcludeMissing + commitId: JsonField<String> = JsonMissing.of(), + @JsonProperty("tag_name") @ExcludeMissing tagName: JsonField<String> = JsonMissing.of(), + @JsonProperty("skip_webhooks") + @ExcludeMissing + skipWebhooks: JsonField<SkipWebhooks> = JsonMissing.of(), + ) : this(commitId, tagName, skipWebhooks, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun commitId(): String = commitId.getRequired("commit_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tagName(): String = tagName.getRequired("tag_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun skipWebhooks(): Optional<SkipWebhooks> = skipWebhooks.getOptional("skip_webhooks") + + /** + * Returns the raw JSON value of [commitId]. + * + * Unlike [commitId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("commit_id") @ExcludeMissing fun _commitId(): JsonField<String> = commitId + + /** + * Returns the raw JSON value of [tagName]. + * + * Unlike [tagName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tag_name") @ExcludeMissing fun _tagName(): JsonField<String> = tagName + + /** + * Returns the raw JSON value of [skipWebhooks]. + * + * Unlike [skipWebhooks], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("skip_webhooks") + @ExcludeMissing + fun _skipWebhooks(): JsonField<SkipWebhooks> = skipWebhooks + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .commitId() + * .tagName() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var commitId: JsonField<String>? = null + private var tagName: JsonField<String>? = null + private var skipWebhooks: JsonField<SkipWebhooks> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + commitId = body.commitId + tagName = body.tagName + skipWebhooks = body.skipWebhooks + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun commitId(commitId: String) = commitId(JsonField.of(commitId)) + + /** + * Sets [Builder.commitId] to an arbitrary JSON value. + * + * You should usually call [Builder.commitId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun commitId(commitId: JsonField<String>) = apply { this.commitId = commitId } + + fun tagName(tagName: String) = tagName(JsonField.of(tagName)) + + /** + * Sets [Builder.tagName] to an arbitrary JSON value. + * + * You should usually call [Builder.tagName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tagName(tagName: JsonField<String>) = apply { this.tagName = tagName } + + fun skipWebhooks(skipWebhooks: SkipWebhooks) = skipWebhooks(JsonField.of(skipWebhooks)) + + /** + * Sets [Builder.skipWebhooks] to an arbitrary JSON value. + * + * You should usually call [Builder.skipWebhooks] with a well-typed [SkipWebhooks] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun skipWebhooks(skipWebhooks: JsonField<SkipWebhooks>) = apply { + this.skipWebhooks = skipWebhooks + } + + /** Alias for calling [skipWebhooks] with `SkipWebhooks.ofBool(bool)`. */ + fun skipWebhooks(bool: Boolean) = skipWebhooks(SkipWebhooks.ofBool(bool)) + + /** Alias for calling [skipWebhooks] with `SkipWebhooks.ofStrings(strings)`. */ + fun skipWebhooksOfStrings(strings: List<String>) = + skipWebhooks(SkipWebhooks.ofStrings(strings)) + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .commitId() + * .tagName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("commitId", commitId), + checkRequired("tagName", tagName), + skipWebhooks, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + commitId() + tagName() + skipWebhooks().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (commitId.asKnown().isPresent) 1 else 0) + + (if (tagName.asKnown().isPresent) 1 else 0) + + (skipWebhooks.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + commitId == other.commitId && + tagName == other.tagName && + skipWebhooks == other.skipWebhooks && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(commitId, tagName, skipWebhooks, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{commitId=$commitId, tagName=$tagName, skipWebhooks=$skipWebhooks, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = SkipWebhooks.Deserializer::class) + @JsonSerialize(using = SkipWebhooks.Serializer::class) + class SkipWebhooks + private constructor( + private val bool: Boolean? = null, + private val strings: List<String>? = null, + private val _json: JsonValue? = null, + ) { + + fun bool(): Optional<Boolean> = Optional.ofNullable(bool) + + fun strings(): Optional<List<String>> = Optional.ofNullable(strings) + + fun isBool(): Boolean = bool != null + + fun isStrings(): Boolean = strings != null + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun asStrings(): List<String> = strings.getOrThrow("strings") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + bool != null -> visitor.visitBool(bool) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): SkipWebhooks = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitBool(bool: Boolean) {} + + override fun visitStrings(strings: List<String>) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitBool(bool: Boolean) = 1 + + override fun visitStrings(strings: List<String>) = strings.size + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SkipWebhooks && bool == other.bool && strings == other.strings + } + + override fun hashCode(): Int = Objects.hash(bool, strings) + + override fun toString(): String = + when { + bool != null -> "SkipWebhooks{bool=$bool}" + strings != null -> "SkipWebhooks{strings=$strings}" + _json != null -> "SkipWebhooks{_unknown=$_json}" + else -> throw IllegalStateException("Invalid SkipWebhooks") + } + + companion object { + + @JvmStatic fun ofBool(bool: Boolean) = SkipWebhooks(bool = bool) + + @JvmStatic + fun ofStrings(strings: List<String>) = SkipWebhooks(strings = strings.toImmutable()) + } + + /** + * An interface that defines how to map each variant of [SkipWebhooks] to a value of type + * [T]. + */ + interface Visitor<out T> { + + fun visitBool(bool: Boolean): T + + fun visitStrings(strings: List<String>): T + + /** + * Maps an unknown variant of [SkipWebhooks] to a value of type [T]. + * + * An instance of [SkipWebhooks] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown SkipWebhooks: $json") + } + } + + internal class Deserializer : BaseDeserializer<SkipWebhooks>(SkipWebhooks::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): SkipWebhooks { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<Boolean>())?.let { + SkipWebhooks(bool = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<List<String>>())?.let { + SkipWebhooks(strings = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from string). + 0 -> SkipWebhooks(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<SkipWebhooks>(SkipWebhooks::class) { + + override fun serialize( + value: SkipWebhooks, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.bool != null -> generator.writeObject(value.bool) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid SkipWebhooks") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TagCreateParams && + owner == other.owner && + repo == other.repo && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(owner, repo, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TagCreateParams{owner=$owner, repo=$repo, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagDeleteParams.kt new file mode 100644 index 00000000..33ccbe58 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagDeleteParams.kt @@ -0,0 +1,271 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.tags + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete Tag */ +class TagDeleteParams +private constructor( + private val owner: String, + private val repo: String, + private val tagName: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun owner(): String = owner + + fun repo(): String = repo + + fun tagName(): Optional<String> = Optional.ofNullable(tagName) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TagDeleteParams]. + * + * The following fields are required: + * ```java + * .owner() + * .repo() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TagDeleteParams]. */ + class Builder internal constructor() { + + private var owner: String? = null + private var repo: String? = null + private var tagName: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(tagDeleteParams: TagDeleteParams) = apply { + owner = tagDeleteParams.owner + repo = tagDeleteParams.repo + tagName = tagDeleteParams.tagName + additionalHeaders = tagDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = tagDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = tagDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun owner(owner: String) = apply { this.owner = owner } + + fun repo(repo: String) = apply { this.repo = repo } + + fun tagName(tagName: String?) = apply { this.tagName = tagName } + + /** Alias for calling [Builder.tagName] with `tagName.orElse(null)`. */ + fun tagName(tagName: Optional<String>) = tagName(tagName.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [TagDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .owner() + * .repo() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TagDeleteParams = + TagDeleteParams( + checkRequired("owner", owner), + checkRequired("repo", repo), + tagName, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> owner + 1 -> repo + 2 -> tagName ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TagDeleteParams && + owner == other.owner && + repo == other.repo && + tagName == other.tagName && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + owner, + repo, + tagName, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "TagDeleteParams{owner=$owner, repo=$repo, tagName=$tagName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagDeleteResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagDeleteResponse.kt new file mode 100644 index 00000000..27699dfd --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagDeleteResponse.kt @@ -0,0 +1,113 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.tags + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class TagDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [TagDeleteResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TagDeleteResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(tagDeleteResponse: TagDeleteResponse) = apply { + additionalProperties = tagDeleteResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TagDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TagDeleteResponse = TagDeleteResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): TagDeleteResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TagDeleteResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "TagDeleteResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagListParams.kt new file mode 100644 index 00000000..2bfe347d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagListParams.kt @@ -0,0 +1,217 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.tags + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get Tags */ +class TagListParams +private constructor( + private val owner: String, + private val repo: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun owner(): String = owner + + fun repo(): Optional<String> = Optional.ofNullable(repo) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TagListParams]. + * + * The following fields are required: + * ```java + * .owner() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TagListParams]. */ + class Builder internal constructor() { + + private var owner: String? = null + private var repo: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(tagListParams: TagListParams) = apply { + owner = tagListParams.owner + repo = tagListParams.repo + additionalHeaders = tagListParams.additionalHeaders.toBuilder() + additionalQueryParams = tagListParams.additionalQueryParams.toBuilder() + } + + fun owner(owner: String) = apply { this.owner = owner } + + fun repo(repo: String?) = apply { this.repo = repo } + + /** Alias for calling [Builder.repo] with `repo.orElse(null)`. */ + fun repo(repo: Optional<String>) = repo(repo.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TagListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .owner() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TagListParams = + TagListParams( + checkRequired("owner", owner), + repo, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> owner + 1 -> repo ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TagListParams && + owner == other.owner && + repo == other.repo && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(owner, repo, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TagListParams{owner=$owner, repo=$repo, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagRetrieveParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagRetrieveParams.kt new file mode 100644 index 00000000..992757dc --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagRetrieveParams.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.tags + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get Tag */ +class TagRetrieveParams +private constructor( + private val owner: String, + private val repo: String, + private val tagName: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun owner(): String = owner + + fun repo(): String = repo + + fun tagName(): Optional<String> = Optional.ofNullable(tagName) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TagRetrieveParams]. + * + * The following fields are required: + * ```java + * .owner() + * .repo() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TagRetrieveParams]. */ + class Builder internal constructor() { + + private var owner: String? = null + private var repo: String? = null + private var tagName: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(tagRetrieveParams: TagRetrieveParams) = apply { + owner = tagRetrieveParams.owner + repo = tagRetrieveParams.repo + tagName = tagRetrieveParams.tagName + additionalHeaders = tagRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = tagRetrieveParams.additionalQueryParams.toBuilder() + } + + fun owner(owner: String) = apply { this.owner = owner } + + fun repo(repo: String) = apply { this.repo = repo } + + fun tagName(tagName: String?) = apply { this.tagName = tagName } + + /** Alias for calling [Builder.tagName] with `tagName.orElse(null)`. */ + fun tagName(tagName: Optional<String>) = tagName(tagName.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TagRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .owner() + * .repo() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TagRetrieveParams = + TagRetrieveParams( + checkRequired("owner", owner), + checkRequired("repo", repo), + tagName, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> owner + 1 -> repo + 2 -> tagName ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TagRetrieveParams && + owner == other.owner && + repo == other.repo && + tagName == other.tagName && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(owner, repo, tagName, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TagRetrieveParams{owner=$owner, repo=$repo, tagName=$tagName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagUpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagUpdateParams.kt new file mode 100644 index 00000000..e9d6a9c2 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagUpdateParams.kt @@ -0,0 +1,728 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.tags + +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 com.langsmith_api.api.core.BaseDeserializer +import com.langsmith_api.api.core.BaseSerializer +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.allMaxBy +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Update Tag */ +class TagUpdateParams +private constructor( + private val owner: String, + private val repo: String, + private val tagName: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun owner(): String = owner + + fun repo(): String = repo + + fun tagName(): Optional<String> = Optional.ofNullable(tagName) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun commitId(): String = body.commitId() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun skipWebhooks(): Optional<SkipWebhooks> = body.skipWebhooks() + + /** + * Returns the raw JSON value of [commitId]. + * + * Unlike [commitId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _commitId(): JsonField<String> = body._commitId() + + /** + * Returns the raw JSON value of [skipWebhooks]. + * + * Unlike [skipWebhooks], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _skipWebhooks(): JsonField<SkipWebhooks> = body._skipWebhooks() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TagUpdateParams]. + * + * The following fields are required: + * ```java + * .owner() + * .repo() + * .commitId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TagUpdateParams]. */ + class Builder internal constructor() { + + private var owner: String? = null + private var repo: String? = null + private var tagName: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(tagUpdateParams: TagUpdateParams) = apply { + owner = tagUpdateParams.owner + repo = tagUpdateParams.repo + tagName = tagUpdateParams.tagName + body = tagUpdateParams.body.toBuilder() + additionalHeaders = tagUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = tagUpdateParams.additionalQueryParams.toBuilder() + } + + fun owner(owner: String) = apply { this.owner = owner } + + fun repo(repo: String) = apply { this.repo = repo } + + fun tagName(tagName: String?) = apply { this.tagName = tagName } + + /** Alias for calling [Builder.tagName] with `tagName.orElse(null)`. */ + fun tagName(tagName: Optional<String>) = tagName(tagName.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [commitId] + * - [skipWebhooks] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun commitId(commitId: String) = apply { body.commitId(commitId) } + + /** + * Sets [Builder.commitId] to an arbitrary JSON value. + * + * You should usually call [Builder.commitId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun commitId(commitId: JsonField<String>) = apply { body.commitId(commitId) } + + fun skipWebhooks(skipWebhooks: SkipWebhooks) = apply { body.skipWebhooks(skipWebhooks) } + + /** + * Sets [Builder.skipWebhooks] to an arbitrary JSON value. + * + * You should usually call [Builder.skipWebhooks] with a well-typed [SkipWebhooks] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun skipWebhooks(skipWebhooks: JsonField<SkipWebhooks>) = apply { + body.skipWebhooks(skipWebhooks) + } + + /** Alias for calling [skipWebhooks] with `SkipWebhooks.ofBool(bool)`. */ + fun skipWebhooks(bool: Boolean) = apply { body.skipWebhooks(bool) } + + /** Alias for calling [skipWebhooks] with `SkipWebhooks.ofStrings(strings)`. */ + fun skipWebhooksOfStrings(strings: List<String>) = apply { + body.skipWebhooksOfStrings(strings) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TagUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .owner() + * .repo() + * .commitId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TagUpdateParams = + TagUpdateParams( + checkRequired("owner", owner), + checkRequired("repo", repo), + tagName, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> owner + 1 -> repo + 2 -> tagName ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Fields to update a prompt tag */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val commitId: JsonField<String>, + private val skipWebhooks: JsonField<SkipWebhooks>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("commit_id") + @ExcludeMissing + commitId: JsonField<String> = JsonMissing.of(), + @JsonProperty("skip_webhooks") + @ExcludeMissing + skipWebhooks: JsonField<SkipWebhooks> = JsonMissing.of(), + ) : this(commitId, skipWebhooks, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun commitId(): String = commitId.getRequired("commit_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun skipWebhooks(): Optional<SkipWebhooks> = skipWebhooks.getOptional("skip_webhooks") + + /** + * Returns the raw JSON value of [commitId]. + * + * Unlike [commitId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("commit_id") @ExcludeMissing fun _commitId(): JsonField<String> = commitId + + /** + * Returns the raw JSON value of [skipWebhooks]. + * + * Unlike [skipWebhooks], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("skip_webhooks") + @ExcludeMissing + fun _skipWebhooks(): JsonField<SkipWebhooks> = skipWebhooks + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .commitId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var commitId: JsonField<String>? = null + private var skipWebhooks: JsonField<SkipWebhooks> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + commitId = body.commitId + skipWebhooks = body.skipWebhooks + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun commitId(commitId: String) = commitId(JsonField.of(commitId)) + + /** + * Sets [Builder.commitId] to an arbitrary JSON value. + * + * You should usually call [Builder.commitId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun commitId(commitId: JsonField<String>) = apply { this.commitId = commitId } + + fun skipWebhooks(skipWebhooks: SkipWebhooks) = skipWebhooks(JsonField.of(skipWebhooks)) + + /** + * Sets [Builder.skipWebhooks] to an arbitrary JSON value. + * + * You should usually call [Builder.skipWebhooks] with a well-typed [SkipWebhooks] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun skipWebhooks(skipWebhooks: JsonField<SkipWebhooks>) = apply { + this.skipWebhooks = skipWebhooks + } + + /** Alias for calling [skipWebhooks] with `SkipWebhooks.ofBool(bool)`. */ + fun skipWebhooks(bool: Boolean) = skipWebhooks(SkipWebhooks.ofBool(bool)) + + /** Alias for calling [skipWebhooks] with `SkipWebhooks.ofStrings(strings)`. */ + fun skipWebhooksOfStrings(strings: List<String>) = + skipWebhooks(SkipWebhooks.ofStrings(strings)) + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .commitId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("commitId", commitId), + skipWebhooks, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + commitId() + skipWebhooks().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (commitId.asKnown().isPresent) 1 else 0) + + (skipWebhooks.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + commitId == other.commitId && + skipWebhooks == other.skipWebhooks && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(commitId, skipWebhooks, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{commitId=$commitId, skipWebhooks=$skipWebhooks, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = SkipWebhooks.Deserializer::class) + @JsonSerialize(using = SkipWebhooks.Serializer::class) + class SkipWebhooks + private constructor( + private val bool: Boolean? = null, + private val strings: List<String>? = null, + private val _json: JsonValue? = null, + ) { + + fun bool(): Optional<Boolean> = Optional.ofNullable(bool) + + fun strings(): Optional<List<String>> = Optional.ofNullable(strings) + + fun isBool(): Boolean = bool != null + + fun isStrings(): Boolean = strings != null + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun asStrings(): List<String> = strings.getOrThrow("strings") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + bool != null -> visitor.visitBool(bool) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): SkipWebhooks = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitBool(bool: Boolean) {} + + override fun visitStrings(strings: List<String>) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitBool(bool: Boolean) = 1 + + override fun visitStrings(strings: List<String>) = strings.size + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SkipWebhooks && bool == other.bool && strings == other.strings + } + + override fun hashCode(): Int = Objects.hash(bool, strings) + + override fun toString(): String = + when { + bool != null -> "SkipWebhooks{bool=$bool}" + strings != null -> "SkipWebhooks{strings=$strings}" + _json != null -> "SkipWebhooks{_unknown=$_json}" + else -> throw IllegalStateException("Invalid SkipWebhooks") + } + + companion object { + + @JvmStatic fun ofBool(bool: Boolean) = SkipWebhooks(bool = bool) + + @JvmStatic + fun ofStrings(strings: List<String>) = SkipWebhooks(strings = strings.toImmutable()) + } + + /** + * An interface that defines how to map each variant of [SkipWebhooks] to a value of type + * [T]. + */ + interface Visitor<out T> { + + fun visitBool(bool: Boolean): T + + fun visitStrings(strings: List<String>): T + + /** + * Maps an unknown variant of [SkipWebhooks] to a value of type [T]. + * + * An instance of [SkipWebhooks] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown SkipWebhooks: $json") + } + } + + internal class Deserializer : BaseDeserializer<SkipWebhooks>(SkipWebhooks::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): SkipWebhooks { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<Boolean>())?.let { + SkipWebhooks(bool = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<List<String>>())?.let { + SkipWebhooks(strings = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from string). + 0 -> SkipWebhooks(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<SkipWebhooks>(SkipWebhooks::class) { + + override fun serialize( + value: SkipWebhooks, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.bool != null -> generator.writeObject(value.bool) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid SkipWebhooks") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TagUpdateParams && + owner == other.owner && + repo == other.repo && + tagName == other.tagName && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(owner, repo, tagName, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TagUpdateParams{owner=$owner, repo=$repo, tagName=$tagName, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/BodyParamsForRunSchema.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/BodyParamsForRunSchema.kt new file mode 100644 index 00000000..ff64ab73 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/BodyParamsForRunSchema.kt @@ -0,0 +1,1754 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs + +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.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Query params for run endpoints. */ +class BodyParamsForRunSchema +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<List<String>>, + private val cursor: JsonField<String>, + private val dataSourceType: JsonField<RunsFilterDataSourceTypeEnum>, + private val endTime: JsonField<OffsetDateTime>, + private val error: JsonField<Boolean>, + private val executionOrder: JsonField<Long>, + private val filter: JsonField<String>, + private val isRoot: JsonField<Boolean>, + private val limit: JsonField<Long>, + private val order: JsonField<Order>, + private val parentRun: JsonField<String>, + private val query: JsonField<String>, + private val referenceExample: JsonField<List<String>>, + private val runType: JsonField<RunTypeEnum>, + private val searchFilter: JsonField<String>, + private val select: JsonField<List<Select>>, + private val session: JsonField<List<String>>, + private val skipPagination: JsonField<Boolean>, + private val skipPrevCursor: JsonField<Boolean>, + private val startTime: JsonField<OffsetDateTime>, + private val trace: JsonField<String>, + private val traceFilter: JsonField<String>, + private val treeFilter: JsonField<String>, + private val useExperimentalSearch: JsonField<Boolean>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("cursor") @ExcludeMissing cursor: JsonField<String> = JsonMissing.of(), + @JsonProperty("data_source_type") + @ExcludeMissing + dataSourceType: JsonField<RunsFilterDataSourceTypeEnum> = JsonMissing.of(), + @JsonProperty("end_time") + @ExcludeMissing + endTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("error") @ExcludeMissing error: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("execution_order") + @ExcludeMissing + executionOrder: JsonField<Long> = JsonMissing.of(), + @JsonProperty("filter") @ExcludeMissing filter: JsonField<String> = JsonMissing.of(), + @JsonProperty("is_root") @ExcludeMissing isRoot: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("limit") @ExcludeMissing limit: JsonField<Long> = JsonMissing.of(), + @JsonProperty("order") @ExcludeMissing order: JsonField<Order> = JsonMissing.of(), + @JsonProperty("parent_run") @ExcludeMissing parentRun: JsonField<String> = JsonMissing.of(), + @JsonProperty("query") @ExcludeMissing query: JsonField<String> = JsonMissing.of(), + @JsonProperty("reference_example") + @ExcludeMissing + referenceExample: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("run_type") + @ExcludeMissing + runType: JsonField<RunTypeEnum> = JsonMissing.of(), + @JsonProperty("search_filter") + @ExcludeMissing + searchFilter: JsonField<String> = JsonMissing.of(), + @JsonProperty("select") @ExcludeMissing select: JsonField<List<Select>> = JsonMissing.of(), + @JsonProperty("session") + @ExcludeMissing + session: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("skip_pagination") + @ExcludeMissing + skipPagination: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("skip_prev_cursor") + @ExcludeMissing + skipPrevCursor: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("trace") @ExcludeMissing trace: JsonField<String> = JsonMissing.of(), + @JsonProperty("trace_filter") + @ExcludeMissing + traceFilter: JsonField<String> = JsonMissing.of(), + @JsonProperty("tree_filter") + @ExcludeMissing + treeFilter: JsonField<String> = JsonMissing.of(), + @JsonProperty("use_experimental_search") + @ExcludeMissing + useExperimentalSearch: JsonField<Boolean> = JsonMissing.of(), + ) : this( + id, + cursor, + dataSourceType, + endTime, + error, + executionOrder, + filter, + isRoot, + limit, + order, + parentRun, + query, + referenceExample, + runType, + searchFilter, + select, + session, + skipPagination, + skipPrevCursor, + startTime, + trace, + traceFilter, + treeFilter, + useExperimentalSearch, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional<List<String>> = id.getOptional("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun cursor(): Optional<String> = cursor.getOptional("cursor") + + /** + * Enum for run data source types. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dataSourceType(): Optional<RunsFilterDataSourceTypeEnum> = + dataSourceType.getOptional("data_source_type") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endTime(): Optional<OffsetDateTime> = endTime.getOptional("end_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun error(): Optional<Boolean> = error.getOptional("error") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun executionOrder(): Optional<Long> = executionOrder.getOptional("execution_order") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun filter(): Optional<String> = filter.getOptional("filter") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun isRoot(): Optional<Boolean> = isRoot.getOptional("is_root") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun limit(): Optional<Long> = limit.getOptional("limit") + + /** + * Enum for run start date order. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun order(): Optional<Order> = order.getOptional("order") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun parentRun(): Optional<String> = parentRun.getOptional("parent_run") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun query(): Optional<String> = query.getOptional("query") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceExample(): Optional<List<String>> = + referenceExample.getOptional("reference_example") + + /** + * Enum for run types. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun runType(): Optional<RunTypeEnum> = runType.getOptional("run_type") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun searchFilter(): Optional<String> = searchFilter.getOptional("search_filter") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun select(): Optional<List<Select>> = select.getOptional("select") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun session(): Optional<List<String>> = session.getOptional("session") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun skipPagination(): Optional<Boolean> = skipPagination.getOptional("skip_pagination") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun skipPrevCursor(): Optional<Boolean> = skipPrevCursor.getOptional("skip_prev_cursor") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun startTime(): Optional<OffsetDateTime> = startTime.getOptional("start_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun trace(): Optional<String> = trace.getOptional("trace") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun traceFilter(): Optional<String> = traceFilter.getOptional("trace_filter") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun treeFilter(): Optional<String> = treeFilter.getOptional("tree_filter") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun useExperimentalSearch(): Optional<Boolean> = + useExperimentalSearch.getOptional("use_experimental_search") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<List<String>> = id + + /** + * Returns the raw JSON value of [cursor]. + * + * Unlike [cursor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField<String> = cursor + + /** + * Returns the raw JSON value of [dataSourceType]. + * + * Unlike [dataSourceType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data_source_type") + @ExcludeMissing + fun _dataSourceType(): JsonField<RunsFilterDataSourceTypeEnum> = dataSourceType + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_time") @ExcludeMissing fun _endTime(): JsonField<OffsetDateTime> = endTime + + /** + * Returns the raw JSON value of [error]. + * + * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("error") @ExcludeMissing fun _error(): JsonField<Boolean> = error + + /** + * Returns the raw JSON value of [executionOrder]. + * + * Unlike [executionOrder], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("execution_order") + @ExcludeMissing + fun _executionOrder(): JsonField<Long> = executionOrder + + /** + * Returns the raw JSON value of [filter]. + * + * Unlike [filter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField<String> = filter + + /** + * Returns the raw JSON value of [isRoot]. + * + * Unlike [isRoot], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_root") @ExcludeMissing fun _isRoot(): JsonField<Boolean> = isRoot + + /** + * Returns the raw JSON value of [limit]. + * + * Unlike [limit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("limit") @ExcludeMissing fun _limit(): JsonField<Long> = limit + + /** + * Returns the raw JSON value of [order]. + * + * Unlike [order], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("order") @ExcludeMissing fun _order(): JsonField<Order> = order + + /** + * Returns the raw JSON value of [parentRun]. + * + * Unlike [parentRun], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("parent_run") @ExcludeMissing fun _parentRun(): JsonField<String> = parentRun + + /** + * Returns the raw JSON value of [query]. + * + * Unlike [query], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("query") @ExcludeMissing fun _query(): JsonField<String> = query + + /** + * Returns the raw JSON value of [referenceExample]. + * + * Unlike [referenceExample], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reference_example") + @ExcludeMissing + fun _referenceExample(): JsonField<List<String>> = referenceExample + + /** + * Returns the raw JSON value of [runType]. + * + * Unlike [runType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_type") @ExcludeMissing fun _runType(): JsonField<RunTypeEnum> = runType + + /** + * Returns the raw JSON value of [searchFilter]. + * + * Unlike [searchFilter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("search_filter") + @ExcludeMissing + fun _searchFilter(): JsonField<String> = searchFilter + + /** + * Returns the raw JSON value of [select]. + * + * Unlike [select], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("select") @ExcludeMissing fun _select(): JsonField<List<Select>> = select + + /** + * Returns the raw JSON value of [session]. + * + * Unlike [session], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session") @ExcludeMissing fun _session(): JsonField<List<String>> = session + + /** + * Returns the raw JSON value of [skipPagination]. + * + * Unlike [skipPagination], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("skip_pagination") + @ExcludeMissing + fun _skipPagination(): JsonField<Boolean> = skipPagination + + /** + * Returns the raw JSON value of [skipPrevCursor]. + * + * Unlike [skipPrevCursor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("skip_prev_cursor") + @ExcludeMissing + fun _skipPrevCursor(): JsonField<Boolean> = skipPrevCursor + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_time") + @ExcludeMissing + fun _startTime(): JsonField<OffsetDateTime> = startTime + + /** + * Returns the raw JSON value of [trace]. + * + * Unlike [trace], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trace") @ExcludeMissing fun _trace(): JsonField<String> = trace + + /** + * Returns the raw JSON value of [traceFilter]. + * + * Unlike [traceFilter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trace_filter") + @ExcludeMissing + fun _traceFilter(): JsonField<String> = traceFilter + + /** + * Returns the raw JSON value of [treeFilter]. + * + * Unlike [treeFilter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tree_filter") @ExcludeMissing fun _treeFilter(): JsonField<String> = treeFilter + + /** + * Returns the raw JSON value of [useExperimentalSearch]. + * + * Unlike [useExperimentalSearch], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("use_experimental_search") + @ExcludeMissing + fun _useExperimentalSearch(): JsonField<Boolean> = useExperimentalSearch + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [BodyParamsForRunSchema]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BodyParamsForRunSchema]. */ + class Builder internal constructor() { + + private var id: JsonField<MutableList<String>>? = null + private var cursor: JsonField<String> = JsonMissing.of() + private var dataSourceType: JsonField<RunsFilterDataSourceTypeEnum> = JsonMissing.of() + private var endTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var error: JsonField<Boolean> = JsonMissing.of() + private var executionOrder: JsonField<Long> = JsonMissing.of() + private var filter: JsonField<String> = JsonMissing.of() + private var isRoot: JsonField<Boolean> = JsonMissing.of() + private var limit: JsonField<Long> = JsonMissing.of() + private var order: JsonField<Order> = JsonMissing.of() + private var parentRun: JsonField<String> = JsonMissing.of() + private var query: JsonField<String> = JsonMissing.of() + private var referenceExample: JsonField<MutableList<String>>? = null + private var runType: JsonField<RunTypeEnum> = JsonMissing.of() + private var searchFilter: JsonField<String> = JsonMissing.of() + private var select: JsonField<MutableList<Select>>? = null + private var session: JsonField<MutableList<String>>? = null + private var skipPagination: JsonField<Boolean> = JsonMissing.of() + private var skipPrevCursor: JsonField<Boolean> = JsonMissing.of() + private var startTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var trace: JsonField<String> = JsonMissing.of() + private var traceFilter: JsonField<String> = JsonMissing.of() + private var treeFilter: JsonField<String> = JsonMissing.of() + private var useExperimentalSearch: JsonField<Boolean> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(bodyParamsForRunSchema: BodyParamsForRunSchema) = apply { + id = bodyParamsForRunSchema.id.map { it.toMutableList() } + cursor = bodyParamsForRunSchema.cursor + dataSourceType = bodyParamsForRunSchema.dataSourceType + endTime = bodyParamsForRunSchema.endTime + error = bodyParamsForRunSchema.error + executionOrder = bodyParamsForRunSchema.executionOrder + filter = bodyParamsForRunSchema.filter + isRoot = bodyParamsForRunSchema.isRoot + limit = bodyParamsForRunSchema.limit + order = bodyParamsForRunSchema.order + parentRun = bodyParamsForRunSchema.parentRun + query = bodyParamsForRunSchema.query + referenceExample = bodyParamsForRunSchema.referenceExample.map { it.toMutableList() } + runType = bodyParamsForRunSchema.runType + searchFilter = bodyParamsForRunSchema.searchFilter + select = bodyParamsForRunSchema.select.map { it.toMutableList() } + session = bodyParamsForRunSchema.session.map { it.toMutableList() } + skipPagination = bodyParamsForRunSchema.skipPagination + skipPrevCursor = bodyParamsForRunSchema.skipPrevCursor + startTime = bodyParamsForRunSchema.startTime + trace = bodyParamsForRunSchema.trace + traceFilter = bodyParamsForRunSchema.traceFilter + treeFilter = bodyParamsForRunSchema.treeFilter + useExperimentalSearch = bodyParamsForRunSchema.useExperimentalSearch + additionalProperties = bodyParamsForRunSchema.additionalProperties.toMutableMap() + } + + fun id(id: List<String>?) = id(JsonField.ofNullable(id)) + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<List<String>>) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed `List<String>` value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<List<String>>) = apply { this.id = id.map { it.toMutableList() } } + + /** + * Adds a single [String] to [Builder.id]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addId(id: String) = apply { + this.id = + (this.id ?: JsonField.of(mutableListOf())).also { checkKnown("id", it).add(id) } + } + + fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional<String>) = cursor(cursor.getOrNull()) + + /** + * Sets [Builder.cursor] to an arbitrary JSON value. + * + * You should usually call [Builder.cursor] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun cursor(cursor: JsonField<String>) = apply { this.cursor = cursor } + + /** Enum for run data source types. */ + fun dataSourceType(dataSourceType: RunsFilterDataSourceTypeEnum?) = + dataSourceType(JsonField.ofNullable(dataSourceType)) + + /** Alias for calling [Builder.dataSourceType] with `dataSourceType.orElse(null)`. */ + fun dataSourceType(dataSourceType: Optional<RunsFilterDataSourceTypeEnum>) = + dataSourceType(dataSourceType.getOrNull()) + + /** + * Sets [Builder.dataSourceType] to an arbitrary JSON value. + * + * You should usually call [Builder.dataSourceType] with a well-typed + * [RunsFilterDataSourceTypeEnum] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun dataSourceType(dataSourceType: JsonField<RunsFilterDataSourceTypeEnum>) = apply { + this.dataSourceType = dataSourceType + } + + fun endTime(endTime: OffsetDateTime?) = endTime(JsonField.ofNullable(endTime)) + + /** Alias for calling [Builder.endTime] with `endTime.orElse(null)`. */ + fun endTime(endTime: Optional<OffsetDateTime>) = endTime(endTime.getOrNull()) + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endTime(endTime: JsonField<OffsetDateTime>) = apply { this.endTime = endTime } + + fun error(error: Boolean?) = error(JsonField.ofNullable(error)) + + /** + * Alias for [Builder.error]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun error(error: Boolean) = error(error as Boolean?) + + /** Alias for calling [Builder.error] with `error.orElse(null)`. */ + fun error(error: Optional<Boolean>) = error(error.getOrNull()) + + /** + * Sets [Builder.error] to an arbitrary JSON value. + * + * You should usually call [Builder.error] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun error(error: JsonField<Boolean>) = apply { this.error = error } + + fun executionOrder(executionOrder: Long?) = + executionOrder(JsonField.ofNullable(executionOrder)) + + /** + * Alias for [Builder.executionOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun executionOrder(executionOrder: Long) = executionOrder(executionOrder as Long?) + + /** Alias for calling [Builder.executionOrder] with `executionOrder.orElse(null)`. */ + fun executionOrder(executionOrder: Optional<Long>) = + executionOrder(executionOrder.getOrNull()) + + /** + * Sets [Builder.executionOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.executionOrder] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun executionOrder(executionOrder: JsonField<Long>) = apply { + this.executionOrder = executionOrder + } + + fun filter(filter: String?) = filter(JsonField.ofNullable(filter)) + + /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ + fun filter(filter: Optional<String>) = filter(filter.getOrNull()) + + /** + * Sets [Builder.filter] to an arbitrary JSON value. + * + * You should usually call [Builder.filter] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun filter(filter: JsonField<String>) = apply { this.filter = filter } + + fun isRoot(isRoot: Boolean?) = isRoot(JsonField.ofNullable(isRoot)) + + /** + * Alias for [Builder.isRoot]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun isRoot(isRoot: Boolean) = isRoot(isRoot as Boolean?) + + /** Alias for calling [Builder.isRoot] with `isRoot.orElse(null)`. */ + fun isRoot(isRoot: Optional<Boolean>) = isRoot(isRoot.getOrNull()) + + /** + * Sets [Builder.isRoot] to an arbitrary JSON value. + * + * You should usually call [Builder.isRoot] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun isRoot(isRoot: JsonField<Boolean>) = apply { this.isRoot = isRoot } + + fun limit(limit: Long) = limit(JsonField.of(limit)) + + /** + * Sets [Builder.limit] to an arbitrary JSON value. + * + * You should usually call [Builder.limit] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun limit(limit: JsonField<Long>) = apply { this.limit = limit } + + /** Enum for run start date order. */ + fun order(order: Order) = order(JsonField.of(order)) + + /** + * Sets [Builder.order] to an arbitrary JSON value. + * + * You should usually call [Builder.order] with a well-typed [Order] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun order(order: JsonField<Order>) = apply { this.order = order } + + fun parentRun(parentRun: String?) = parentRun(JsonField.ofNullable(parentRun)) + + /** Alias for calling [Builder.parentRun] with `parentRun.orElse(null)`. */ + fun parentRun(parentRun: Optional<String>) = parentRun(parentRun.getOrNull()) + + /** + * Sets [Builder.parentRun] to an arbitrary JSON value. + * + * You should usually call [Builder.parentRun] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun parentRun(parentRun: JsonField<String>) = apply { this.parentRun = parentRun } + + fun query(query: String?) = query(JsonField.ofNullable(query)) + + /** Alias for calling [Builder.query] with `query.orElse(null)`. */ + fun query(query: Optional<String>) = query(query.getOrNull()) + + /** + * Sets [Builder.query] to an arbitrary JSON value. + * + * You should usually call [Builder.query] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun query(query: JsonField<String>) = apply { this.query = query } + + fun referenceExample(referenceExample: List<String>?) = + referenceExample(JsonField.ofNullable(referenceExample)) + + /** Alias for calling [Builder.referenceExample] with `referenceExample.orElse(null)`. */ + fun referenceExample(referenceExample: Optional<List<String>>) = + referenceExample(referenceExample.getOrNull()) + + /** + * Sets [Builder.referenceExample] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceExample] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun referenceExample(referenceExample: JsonField<List<String>>) = apply { + this.referenceExample = referenceExample.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.referenceExample]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addReferenceExample(referenceExample: String) = apply { + this.referenceExample = + (this.referenceExample ?: JsonField.of(mutableListOf())).also { + checkKnown("referenceExample", it).add(referenceExample) + } + } + + /** Enum for run types. */ + fun runType(runType: RunTypeEnum?) = runType(JsonField.ofNullable(runType)) + + /** Alias for calling [Builder.runType] with `runType.orElse(null)`. */ + fun runType(runType: Optional<RunTypeEnum>) = runType(runType.getOrNull()) + + /** + * Sets [Builder.runType] to an arbitrary JSON value. + * + * You should usually call [Builder.runType] with a well-typed [RunTypeEnum] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun runType(runType: JsonField<RunTypeEnum>) = apply { this.runType = runType } + + fun searchFilter(searchFilter: String?) = searchFilter(JsonField.ofNullable(searchFilter)) + + /** Alias for calling [Builder.searchFilter] with `searchFilter.orElse(null)`. */ + fun searchFilter(searchFilter: Optional<String>) = searchFilter(searchFilter.getOrNull()) + + /** + * Sets [Builder.searchFilter] to an arbitrary JSON value. + * + * You should usually call [Builder.searchFilter] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun searchFilter(searchFilter: JsonField<String>) = apply { + this.searchFilter = searchFilter + } + + fun select(select: List<Select>) = select(JsonField.of(select)) + + /** + * Sets [Builder.select] to an arbitrary JSON value. + * + * You should usually call [Builder.select] with a well-typed `List<Select>` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun select(select: JsonField<List<Select>>) = apply { + this.select = select.map { it.toMutableList() } + } + + /** + * Adds a single [Select] to [Builder.select]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSelect(select: Select) = apply { + this.select = + (this.select ?: JsonField.of(mutableListOf())).also { + checkKnown("select", it).add(select) + } + } + + fun session(session: List<String>?) = session(JsonField.ofNullable(session)) + + /** Alias for calling [Builder.session] with `session.orElse(null)`. */ + fun session(session: Optional<List<String>>) = session(session.getOrNull()) + + /** + * Sets [Builder.session] to an arbitrary JSON value. + * + * You should usually call [Builder.session] with a well-typed `List<String>` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun session(session: JsonField<List<String>>) = apply { + this.session = session.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.session]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSession(session: String) = apply { + this.session = + (this.session ?: JsonField.of(mutableListOf())).also { + checkKnown("session", it).add(session) + } + } + + fun skipPagination(skipPagination: Boolean?) = + skipPagination(JsonField.ofNullable(skipPagination)) + + /** + * Alias for [Builder.skipPagination]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun skipPagination(skipPagination: Boolean) = skipPagination(skipPagination as Boolean?) + + /** Alias for calling [Builder.skipPagination] with `skipPagination.orElse(null)`. */ + fun skipPagination(skipPagination: Optional<Boolean>) = + skipPagination(skipPagination.getOrNull()) + + /** + * Sets [Builder.skipPagination] to an arbitrary JSON value. + * + * You should usually call [Builder.skipPagination] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun skipPagination(skipPagination: JsonField<Boolean>) = apply { + this.skipPagination = skipPagination + } + + fun skipPrevCursor(skipPrevCursor: Boolean) = skipPrevCursor(JsonField.of(skipPrevCursor)) + + /** + * Sets [Builder.skipPrevCursor] to an arbitrary JSON value. + * + * You should usually call [Builder.skipPrevCursor] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun skipPrevCursor(skipPrevCursor: JsonField<Boolean>) = apply { + this.skipPrevCursor = skipPrevCursor + } + + fun startTime(startTime: OffsetDateTime?) = startTime(JsonField.ofNullable(startTime)) + + /** Alias for calling [Builder.startTime] with `startTime.orElse(null)`. */ + fun startTime(startTime: Optional<OffsetDateTime>) = startTime(startTime.getOrNull()) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField<OffsetDateTime>) = apply { this.startTime = startTime } + + fun trace(trace: String?) = trace(JsonField.ofNullable(trace)) + + /** Alias for calling [Builder.trace] with `trace.orElse(null)`. */ + fun trace(trace: Optional<String>) = trace(trace.getOrNull()) + + /** + * Sets [Builder.trace] to an arbitrary JSON value. + * + * You should usually call [Builder.trace] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun trace(trace: JsonField<String>) = apply { this.trace = trace } + + fun traceFilter(traceFilter: String?) = traceFilter(JsonField.ofNullable(traceFilter)) + + /** Alias for calling [Builder.traceFilter] with `traceFilter.orElse(null)`. */ + fun traceFilter(traceFilter: Optional<String>) = traceFilter(traceFilter.getOrNull()) + + /** + * Sets [Builder.traceFilter] to an arbitrary JSON value. + * + * You should usually call [Builder.traceFilter] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun traceFilter(traceFilter: JsonField<String>) = apply { this.traceFilter = traceFilter } + + fun treeFilter(treeFilter: String?) = treeFilter(JsonField.ofNullable(treeFilter)) + + /** Alias for calling [Builder.treeFilter] with `treeFilter.orElse(null)`. */ + fun treeFilter(treeFilter: Optional<String>) = treeFilter(treeFilter.getOrNull()) + + /** + * Sets [Builder.treeFilter] to an arbitrary JSON value. + * + * You should usually call [Builder.treeFilter] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun treeFilter(treeFilter: JsonField<String>) = apply { this.treeFilter = treeFilter } + + fun useExperimentalSearch(useExperimentalSearch: Boolean) = + useExperimentalSearch(JsonField.of(useExperimentalSearch)) + + /** + * Sets [Builder.useExperimentalSearch] to an arbitrary JSON value. + * + * You should usually call [Builder.useExperimentalSearch] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun useExperimentalSearch(useExperimentalSearch: JsonField<Boolean>) = apply { + this.useExperimentalSearch = useExperimentalSearch + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BodyParamsForRunSchema]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BodyParamsForRunSchema = + BodyParamsForRunSchema( + (id ?: JsonMissing.of()).map { it.toImmutable() }, + cursor, + dataSourceType, + endTime, + error, + executionOrder, + filter, + isRoot, + limit, + order, + parentRun, + query, + (referenceExample ?: JsonMissing.of()).map { it.toImmutable() }, + runType, + searchFilter, + (select ?: JsonMissing.of()).map { it.toImmutable() }, + (session ?: JsonMissing.of()).map { it.toImmutable() }, + skipPagination, + skipPrevCursor, + startTime, + trace, + traceFilter, + treeFilter, + useExperimentalSearch, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BodyParamsForRunSchema = apply { + if (validated) { + return@apply + } + + id() + cursor() + dataSourceType().ifPresent { it.validate() } + endTime() + error() + executionOrder() + filter() + isRoot() + limit() + order().ifPresent { it.validate() } + parentRun() + query() + referenceExample() + runType().ifPresent { it.validate() } + searchFilter() + select().ifPresent { it.forEach { it.validate() } } + session() + skipPagination() + skipPrevCursor() + startTime() + trace() + traceFilter() + treeFilter() + useExperimentalSearch() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (id.asKnown().getOrNull()?.size ?: 0) + + (if (cursor.asKnown().isPresent) 1 else 0) + + (dataSourceType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endTime.asKnown().isPresent) 1 else 0) + + (if (error.asKnown().isPresent) 1 else 0) + + (if (executionOrder.asKnown().isPresent) 1 else 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (if (isRoot.asKnown().isPresent) 1 else 0) + + (if (limit.asKnown().isPresent) 1 else 0) + + (order.asKnown().getOrNull()?.validity() ?: 0) + + (if (parentRun.asKnown().isPresent) 1 else 0) + + (if (query.asKnown().isPresent) 1 else 0) + + (referenceExample.asKnown().getOrNull()?.size ?: 0) + + (runType.asKnown().getOrNull()?.validity() ?: 0) + + (if (searchFilter.asKnown().isPresent) 1 else 0) + + (select.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (session.asKnown().getOrNull()?.size ?: 0) + + (if (skipPagination.asKnown().isPresent) 1 else 0) + + (if (skipPrevCursor.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + (if (trace.asKnown().isPresent) 1 else 0) + + (if (traceFilter.asKnown().isPresent) 1 else 0) + + (if (treeFilter.asKnown().isPresent) 1 else 0) + + (if (useExperimentalSearch.asKnown().isPresent) 1 else 0) + + /** Enum for run start date order. */ + class Order @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val ASC = of("asc") + + @JvmField val DESC = of("desc") + + @JvmStatic fun of(value: String) = Order(JsonField.of(value)) + } + + /** An enum containing [Order]'s known values. */ + enum class Known { + ASC, + DESC, + } + + /** + * An enum containing [Order]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Order] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ASC, + DESC, + /** An enum member indicating that [Order] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ASC -> Value.ASC + DESC -> Value.DESC + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ASC -> Known.ASC + DESC -> Known.DESC + else -> throw LangsmithApiInvalidDataException("Unknown Order: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Order = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Order && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Enum for available run columns. */ + class Select @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val ID = of("id") + + @JvmField val NAME = of("name") + + @JvmField val RUN_TYPE = of("run_type") + + @JvmField val START_TIME = of("start_time") + + @JvmField val END_TIME = of("end_time") + + @JvmField val STATUS = of("status") + + @JvmField val ERROR = of("error") + + @JvmField val EXTRA = of("extra") + + @JvmField val EVENTS = of("events") + + @JvmField val INPUTS = of("inputs") + + @JvmField val INPUTS_PREVIEW = of("inputs_preview") + + @JvmField val INPUTS_S3_URLS = of("inputs_s3_urls") + + @JvmField val INPUTS_OR_SIGNED_URL = of("inputs_or_signed_url") + + @JvmField val OUTPUTS = of("outputs") + + @JvmField val OUTPUTS_PREVIEW = of("outputs_preview") + + @JvmField val OUTPUTS_S3_URLS = of("outputs_s3_urls") + + @JvmField val OUTPUTS_OR_SIGNED_URL = of("outputs_or_signed_url") + + @JvmField val S3_URLS = of("s3_urls") + + @JvmField val ERROR_OR_SIGNED_URL = of("error_or_signed_url") + + @JvmField val EVENTS_OR_SIGNED_URL = of("events_or_signed_url") + + @JvmField val EXTRA_OR_SIGNED_URL = of("extra_or_signed_url") + + @JvmField val SERIALIZED_OR_SIGNED_URL = of("serialized_or_signed_url") + + @JvmField val PARENT_RUN_ID = of("parent_run_id") + + @JvmField val MANIFEST_ID = of("manifest_id") + + @JvmField val MANIFEST_S3_ID = of("manifest_s3_id") + + @JvmField val MANIFEST = of("manifest") + + @JvmField val SESSION_ID = of("session_id") + + @JvmField val SERIALIZED = of("serialized") + + @JvmField val REFERENCE_EXAMPLE_ID = of("reference_example_id") + + @JvmField val REFERENCE_DATASET_ID = of("reference_dataset_id") + + @JvmField val TOTAL_TOKENS = of("total_tokens") + + @JvmField val PROMPT_TOKENS = of("prompt_tokens") + + @JvmField val PROMPT_TOKEN_DETAILS = of("prompt_token_details") + + @JvmField val COMPLETION_TOKENS = of("completion_tokens") + + @JvmField val COMPLETION_TOKEN_DETAILS = of("completion_token_details") + + @JvmField val TOTAL_COST = of("total_cost") + + @JvmField val PROMPT_COST = of("prompt_cost") + + @JvmField val PROMPT_COST_DETAILS = of("prompt_cost_details") + + @JvmField val COMPLETION_COST = of("completion_cost") + + @JvmField val COMPLETION_COST_DETAILS = of("completion_cost_details") + + @JvmField val PRICE_MODEL_ID = of("price_model_id") + + @JvmField val FIRST_TOKEN_TIME = of("first_token_time") + + @JvmField val TRACE_ID = of("trace_id") + + @JvmField val DOTTED_ORDER = of("dotted_order") + + @JvmField val LAST_QUEUED_AT = of("last_queued_at") + + @JvmField val FEEDBACK_STATS = of("feedback_stats") + + @JvmField val CHILD_RUN_IDS = of("child_run_ids") + + @JvmField val PARENT_RUN_IDS = of("parent_run_ids") + + @JvmField val TAGS = of("tags") + + @JvmField val IN_DATASET = of("in_dataset") + + @JvmField val APP_PATH = of("app_path") + + @JvmField val SHARE_TOKEN = of("share_token") + + @JvmField val TRACE_TIER = of("trace_tier") + + @JvmField val TRACE_FIRST_RECEIVED_AT = of("trace_first_received_at") + + @JvmField val TTL_SECONDS = of("ttl_seconds") + + @JvmField val TRACE_UPGRADE = of("trace_upgrade") + + @JvmField val THREAD_ID = of("thread_id") + + @JvmField val TRACE_MIN_MAX_START_TIME = of("trace_min_max_start_time") + + @JvmStatic fun of(value: String) = Select(JsonField.of(value)) + } + + /** An enum containing [Select]'s known values. */ + enum class Known { + ID, + NAME, + RUN_TYPE, + START_TIME, + END_TIME, + STATUS, + ERROR, + EXTRA, + EVENTS, + INPUTS, + INPUTS_PREVIEW, + INPUTS_S3_URLS, + INPUTS_OR_SIGNED_URL, + OUTPUTS, + OUTPUTS_PREVIEW, + OUTPUTS_S3_URLS, + OUTPUTS_OR_SIGNED_URL, + S3_URLS, + ERROR_OR_SIGNED_URL, + EVENTS_OR_SIGNED_URL, + EXTRA_OR_SIGNED_URL, + SERIALIZED_OR_SIGNED_URL, + PARENT_RUN_ID, + MANIFEST_ID, + MANIFEST_S3_ID, + MANIFEST, + SESSION_ID, + SERIALIZED, + REFERENCE_EXAMPLE_ID, + REFERENCE_DATASET_ID, + TOTAL_TOKENS, + PROMPT_TOKENS, + PROMPT_TOKEN_DETAILS, + COMPLETION_TOKENS, + COMPLETION_TOKEN_DETAILS, + TOTAL_COST, + PROMPT_COST, + PROMPT_COST_DETAILS, + COMPLETION_COST, + COMPLETION_COST_DETAILS, + PRICE_MODEL_ID, + FIRST_TOKEN_TIME, + TRACE_ID, + DOTTED_ORDER, + LAST_QUEUED_AT, + FEEDBACK_STATS, + CHILD_RUN_IDS, + PARENT_RUN_IDS, + TAGS, + IN_DATASET, + APP_PATH, + SHARE_TOKEN, + TRACE_TIER, + TRACE_FIRST_RECEIVED_AT, + TTL_SECONDS, + TRACE_UPGRADE, + THREAD_ID, + TRACE_MIN_MAX_START_TIME, + } + + /** + * An enum containing [Select]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Select] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ID, + NAME, + RUN_TYPE, + START_TIME, + END_TIME, + STATUS, + ERROR, + EXTRA, + EVENTS, + INPUTS, + INPUTS_PREVIEW, + INPUTS_S3_URLS, + INPUTS_OR_SIGNED_URL, + OUTPUTS, + OUTPUTS_PREVIEW, + OUTPUTS_S3_URLS, + OUTPUTS_OR_SIGNED_URL, + S3_URLS, + ERROR_OR_SIGNED_URL, + EVENTS_OR_SIGNED_URL, + EXTRA_OR_SIGNED_URL, + SERIALIZED_OR_SIGNED_URL, + PARENT_RUN_ID, + MANIFEST_ID, + MANIFEST_S3_ID, + MANIFEST, + SESSION_ID, + SERIALIZED, + REFERENCE_EXAMPLE_ID, + REFERENCE_DATASET_ID, + TOTAL_TOKENS, + PROMPT_TOKENS, + PROMPT_TOKEN_DETAILS, + COMPLETION_TOKENS, + COMPLETION_TOKEN_DETAILS, + TOTAL_COST, + PROMPT_COST, + PROMPT_COST_DETAILS, + COMPLETION_COST, + COMPLETION_COST_DETAILS, + PRICE_MODEL_ID, + FIRST_TOKEN_TIME, + TRACE_ID, + DOTTED_ORDER, + LAST_QUEUED_AT, + FEEDBACK_STATS, + CHILD_RUN_IDS, + PARENT_RUN_IDS, + TAGS, + IN_DATASET, + APP_PATH, + SHARE_TOKEN, + TRACE_TIER, + TRACE_FIRST_RECEIVED_AT, + TTL_SECONDS, + TRACE_UPGRADE, + THREAD_ID, + TRACE_MIN_MAX_START_TIME, + /** An enum member indicating that [Select] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ID -> Value.ID + NAME -> Value.NAME + RUN_TYPE -> Value.RUN_TYPE + START_TIME -> Value.START_TIME + END_TIME -> Value.END_TIME + STATUS -> Value.STATUS + ERROR -> Value.ERROR + EXTRA -> Value.EXTRA + EVENTS -> Value.EVENTS + INPUTS -> Value.INPUTS + INPUTS_PREVIEW -> Value.INPUTS_PREVIEW + INPUTS_S3_URLS -> Value.INPUTS_S3_URLS + INPUTS_OR_SIGNED_URL -> Value.INPUTS_OR_SIGNED_URL + OUTPUTS -> Value.OUTPUTS + OUTPUTS_PREVIEW -> Value.OUTPUTS_PREVIEW + OUTPUTS_S3_URLS -> Value.OUTPUTS_S3_URLS + OUTPUTS_OR_SIGNED_URL -> Value.OUTPUTS_OR_SIGNED_URL + S3_URLS -> Value.S3_URLS + ERROR_OR_SIGNED_URL -> Value.ERROR_OR_SIGNED_URL + EVENTS_OR_SIGNED_URL -> Value.EVENTS_OR_SIGNED_URL + EXTRA_OR_SIGNED_URL -> Value.EXTRA_OR_SIGNED_URL + SERIALIZED_OR_SIGNED_URL -> Value.SERIALIZED_OR_SIGNED_URL + PARENT_RUN_ID -> Value.PARENT_RUN_ID + MANIFEST_ID -> Value.MANIFEST_ID + MANIFEST_S3_ID -> Value.MANIFEST_S3_ID + MANIFEST -> Value.MANIFEST + SESSION_ID -> Value.SESSION_ID + SERIALIZED -> Value.SERIALIZED + REFERENCE_EXAMPLE_ID -> Value.REFERENCE_EXAMPLE_ID + REFERENCE_DATASET_ID -> Value.REFERENCE_DATASET_ID + TOTAL_TOKENS -> Value.TOTAL_TOKENS + PROMPT_TOKENS -> Value.PROMPT_TOKENS + PROMPT_TOKEN_DETAILS -> Value.PROMPT_TOKEN_DETAILS + COMPLETION_TOKENS -> Value.COMPLETION_TOKENS + COMPLETION_TOKEN_DETAILS -> Value.COMPLETION_TOKEN_DETAILS + TOTAL_COST -> Value.TOTAL_COST + PROMPT_COST -> Value.PROMPT_COST + PROMPT_COST_DETAILS -> Value.PROMPT_COST_DETAILS + COMPLETION_COST -> Value.COMPLETION_COST + COMPLETION_COST_DETAILS -> Value.COMPLETION_COST_DETAILS + PRICE_MODEL_ID -> Value.PRICE_MODEL_ID + FIRST_TOKEN_TIME -> Value.FIRST_TOKEN_TIME + TRACE_ID -> Value.TRACE_ID + DOTTED_ORDER -> Value.DOTTED_ORDER + LAST_QUEUED_AT -> Value.LAST_QUEUED_AT + FEEDBACK_STATS -> Value.FEEDBACK_STATS + CHILD_RUN_IDS -> Value.CHILD_RUN_IDS + PARENT_RUN_IDS -> Value.PARENT_RUN_IDS + TAGS -> Value.TAGS + IN_DATASET -> Value.IN_DATASET + APP_PATH -> Value.APP_PATH + SHARE_TOKEN -> Value.SHARE_TOKEN + TRACE_TIER -> Value.TRACE_TIER + TRACE_FIRST_RECEIVED_AT -> Value.TRACE_FIRST_RECEIVED_AT + TTL_SECONDS -> Value.TTL_SECONDS + TRACE_UPGRADE -> Value.TRACE_UPGRADE + THREAD_ID -> Value.THREAD_ID + TRACE_MIN_MAX_START_TIME -> Value.TRACE_MIN_MAX_START_TIME + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ID -> Known.ID + NAME -> Known.NAME + RUN_TYPE -> Known.RUN_TYPE + START_TIME -> Known.START_TIME + END_TIME -> Known.END_TIME + STATUS -> Known.STATUS + ERROR -> Known.ERROR + EXTRA -> Known.EXTRA + EVENTS -> Known.EVENTS + INPUTS -> Known.INPUTS + INPUTS_PREVIEW -> Known.INPUTS_PREVIEW + INPUTS_S3_URLS -> Known.INPUTS_S3_URLS + INPUTS_OR_SIGNED_URL -> Known.INPUTS_OR_SIGNED_URL + OUTPUTS -> Known.OUTPUTS + OUTPUTS_PREVIEW -> Known.OUTPUTS_PREVIEW + OUTPUTS_S3_URLS -> Known.OUTPUTS_S3_URLS + OUTPUTS_OR_SIGNED_URL -> Known.OUTPUTS_OR_SIGNED_URL + S3_URLS -> Known.S3_URLS + ERROR_OR_SIGNED_URL -> Known.ERROR_OR_SIGNED_URL + EVENTS_OR_SIGNED_URL -> Known.EVENTS_OR_SIGNED_URL + EXTRA_OR_SIGNED_URL -> Known.EXTRA_OR_SIGNED_URL + SERIALIZED_OR_SIGNED_URL -> Known.SERIALIZED_OR_SIGNED_URL + PARENT_RUN_ID -> Known.PARENT_RUN_ID + MANIFEST_ID -> Known.MANIFEST_ID + MANIFEST_S3_ID -> Known.MANIFEST_S3_ID + MANIFEST -> Known.MANIFEST + SESSION_ID -> Known.SESSION_ID + SERIALIZED -> Known.SERIALIZED + REFERENCE_EXAMPLE_ID -> Known.REFERENCE_EXAMPLE_ID + REFERENCE_DATASET_ID -> Known.REFERENCE_DATASET_ID + TOTAL_TOKENS -> Known.TOTAL_TOKENS + PROMPT_TOKENS -> Known.PROMPT_TOKENS + PROMPT_TOKEN_DETAILS -> Known.PROMPT_TOKEN_DETAILS + COMPLETION_TOKENS -> Known.COMPLETION_TOKENS + COMPLETION_TOKEN_DETAILS -> Known.COMPLETION_TOKEN_DETAILS + TOTAL_COST -> Known.TOTAL_COST + PROMPT_COST -> Known.PROMPT_COST + PROMPT_COST_DETAILS -> Known.PROMPT_COST_DETAILS + COMPLETION_COST -> Known.COMPLETION_COST + COMPLETION_COST_DETAILS -> Known.COMPLETION_COST_DETAILS + PRICE_MODEL_ID -> Known.PRICE_MODEL_ID + FIRST_TOKEN_TIME -> Known.FIRST_TOKEN_TIME + TRACE_ID -> Known.TRACE_ID + DOTTED_ORDER -> Known.DOTTED_ORDER + LAST_QUEUED_AT -> Known.LAST_QUEUED_AT + FEEDBACK_STATS -> Known.FEEDBACK_STATS + CHILD_RUN_IDS -> Known.CHILD_RUN_IDS + PARENT_RUN_IDS -> Known.PARENT_RUN_IDS + TAGS -> Known.TAGS + IN_DATASET -> Known.IN_DATASET + APP_PATH -> Known.APP_PATH + SHARE_TOKEN -> Known.SHARE_TOKEN + TRACE_TIER -> Known.TRACE_TIER + TRACE_FIRST_RECEIVED_AT -> Known.TRACE_FIRST_RECEIVED_AT + TTL_SECONDS -> Known.TTL_SECONDS + TRACE_UPGRADE -> Known.TRACE_UPGRADE + THREAD_ID -> Known.THREAD_ID + TRACE_MIN_MAX_START_TIME -> Known.TRACE_MIN_MAX_START_TIME + else -> throw LangsmithApiInvalidDataException("Unknown Select: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Select = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Select && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BodyParamsForRunSchema && + id == other.id && + cursor == other.cursor && + dataSourceType == other.dataSourceType && + endTime == other.endTime && + error == other.error && + executionOrder == other.executionOrder && + filter == other.filter && + isRoot == other.isRoot && + limit == other.limit && + order == other.order && + parentRun == other.parentRun && + query == other.query && + referenceExample == other.referenceExample && + runType == other.runType && + searchFilter == other.searchFilter && + select == other.select && + session == other.session && + skipPagination == other.skipPagination && + skipPrevCursor == other.skipPrevCursor && + startTime == other.startTime && + trace == other.trace && + traceFilter == other.traceFilter && + treeFilter == other.treeFilter && + useExperimentalSearch == other.useExperimentalSearch && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + cursor, + dataSourceType, + endTime, + error, + executionOrder, + filter, + isRoot, + limit, + order, + parentRun, + query, + referenceExample, + runType, + searchFilter, + select, + session, + skipPagination, + skipPrevCursor, + startTime, + trace, + traceFilter, + treeFilter, + useExperimentalSearch, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BodyParamsForRunSchema{id=$id, cursor=$cursor, dataSourceType=$dataSourceType, endTime=$endTime, error=$error, executionOrder=$executionOrder, filter=$filter, isRoot=$isRoot, limit=$limit, order=$order, parentRun=$parentRun, query=$query, referenceExample=$referenceExample, runType=$runType, searchFilter=$searchFilter, select=$select, session=$session, skipPagination=$skipPagination, skipPrevCursor=$skipPrevCursor, startTime=$startTime, trace=$trace, traceFilter=$traceFilter, treeFilter=$treeFilter, useExperimentalSearch=$useExperimentalSearch, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RequestBodyForRunsGenerateQuery.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RequestBodyForRunsGenerateQuery.kt new file mode 100644 index 00000000..f0e464bb --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RequestBodyForRunsGenerateQuery.kt @@ -0,0 +1,391 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs + +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.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class RequestBodyForRunsGenerateQuery +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val query: JsonField<String>, + private val feedbackKeys: JsonField<List<FeedbackKey>>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("query") @ExcludeMissing query: JsonField<String> = JsonMissing.of(), + @JsonProperty("feedback_keys") + @ExcludeMissing + feedbackKeys: JsonField<List<FeedbackKey>> = JsonMissing.of(), + ) : this(query, feedbackKeys, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun query(): String = query.getRequired("query") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun feedbackKeys(): Optional<List<FeedbackKey>> = feedbackKeys.getOptional("feedback_keys") + + /** + * Returns the raw JSON value of [query]. + * + * Unlike [query], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("query") @ExcludeMissing fun _query(): JsonField<String> = query + + /** + * Returns the raw JSON value of [feedbackKeys]. + * + * Unlike [feedbackKeys], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feedback_keys") + @ExcludeMissing + fun _feedbackKeys(): JsonField<List<FeedbackKey>> = feedbackKeys + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [RequestBodyForRunsGenerateQuery]. + * + * The following fields are required: + * ```java + * .query() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RequestBodyForRunsGenerateQuery]. */ + class Builder internal constructor() { + + private var query: JsonField<String>? = null + private var feedbackKeys: JsonField<MutableList<FeedbackKey>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(requestBodyForRunsGenerateQuery: RequestBodyForRunsGenerateQuery) = + apply { + query = requestBodyForRunsGenerateQuery.query + feedbackKeys = + requestBodyForRunsGenerateQuery.feedbackKeys.map { it.toMutableList() } + additionalProperties = + requestBodyForRunsGenerateQuery.additionalProperties.toMutableMap() + } + + fun query(query: String) = query(JsonField.of(query)) + + /** + * Sets [Builder.query] to an arbitrary JSON value. + * + * You should usually call [Builder.query] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun query(query: JsonField<String>) = apply { this.query = query } + + fun feedbackKeys(feedbackKeys: List<FeedbackKey>) = feedbackKeys(JsonField.of(feedbackKeys)) + + /** + * Sets [Builder.feedbackKeys] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackKeys] with a well-typed `List<FeedbackKey>` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun feedbackKeys(feedbackKeys: JsonField<List<FeedbackKey>>) = apply { + this.feedbackKeys = feedbackKeys.map { it.toMutableList() } + } + + /** + * Adds a single [FeedbackKey] to [feedbackKeys]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFeedbackKey(feedbackKey: FeedbackKey) = apply { + feedbackKeys = + (feedbackKeys ?: JsonField.of(mutableListOf())).also { + checkKnown("feedbackKeys", it).add(feedbackKey) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RequestBodyForRunsGenerateQuery]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .query() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RequestBodyForRunsGenerateQuery = + RequestBodyForRunsGenerateQuery( + checkRequired("query", query), + (feedbackKeys ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RequestBodyForRunsGenerateQuery = apply { + if (validated) { + return@apply + } + + query() + feedbackKeys().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (query.asKnown().isPresent) 1 else 0) + + (feedbackKeys.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class FeedbackKey @JsonCreator private constructor(private val value: JsonField<String>) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val USER_SCORE = of("user_score") + + @JvmField val USER_EDITED = of("user_edited") + + @JvmField val USER_REMOVED = of("user_removed") + + @JvmField val USER_OPENED_RUN = of("user_opened_run") + + @JvmField val USER_SELECTED_RUN = of("user_selected_run") + + @JvmField val RESULTS_SIZE = of("results_size") + + @JvmField val VALID_FILTER = of("valid_filter") + + @JvmStatic fun of(value: String) = FeedbackKey(JsonField.of(value)) + } + + /** An enum containing [FeedbackKey]'s known values. */ + enum class Known { + USER_SCORE, + USER_EDITED, + USER_REMOVED, + USER_OPENED_RUN, + USER_SELECTED_RUN, + RESULTS_SIZE, + VALID_FILTER, + } + + /** + * An enum containing [FeedbackKey]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [FeedbackKey] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USER_SCORE, + USER_EDITED, + USER_REMOVED, + USER_OPENED_RUN, + USER_SELECTED_RUN, + RESULTS_SIZE, + VALID_FILTER, + /** + * An enum member indicating that [FeedbackKey] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USER_SCORE -> Value.USER_SCORE + USER_EDITED -> Value.USER_EDITED + USER_REMOVED -> Value.USER_REMOVED + USER_OPENED_RUN -> Value.USER_OPENED_RUN + USER_SELECTED_RUN -> Value.USER_SELECTED_RUN + RESULTS_SIZE -> Value.RESULTS_SIZE + VALID_FILTER -> Value.VALID_FILTER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USER_SCORE -> Known.USER_SCORE + USER_EDITED -> Known.USER_EDITED + USER_REMOVED -> Known.USER_REMOVED + USER_OPENED_RUN -> Known.USER_OPENED_RUN + USER_SELECTED_RUN -> Known.USER_SELECTED_RUN + RESULTS_SIZE -> Known.RESULTS_SIZE + VALID_FILTER -> Known.VALID_FILTER + else -> throw LangsmithApiInvalidDataException("Unknown FeedbackKey: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): FeedbackKey = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackKey && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RequestBodyForRunsGenerateQuery && + query == other.query && + feedbackKeys == other.feedbackKeys && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(query, feedbackKeys, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RequestBodyForRunsGenerateQuery{query=$query, feedbackKeys=$feedbackKeys, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/ResponseBodyForRunsGenerateQuery.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/ResponseBodyForRunsGenerateQuery.kt new file mode 100644 index 00000000..3db547c6 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/ResponseBodyForRunsGenerateQuery.kt @@ -0,0 +1,316 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class ResponseBodyForRunsGenerateQuery +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val feedbackUrls: JsonField<FeedbackUrls>, + private val filter: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("feedback_urls") + @ExcludeMissing + feedbackUrls: JsonField<FeedbackUrls> = JsonMissing.of(), + @JsonProperty("filter") @ExcludeMissing filter: JsonField<String> = JsonMissing.of(), + ) : this(feedbackUrls, filter, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun feedbackUrls(): FeedbackUrls = feedbackUrls.getRequired("feedback_urls") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun filter(): String = filter.getRequired("filter") + + /** + * Returns the raw JSON value of [feedbackUrls]. + * + * Unlike [feedbackUrls], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feedback_urls") + @ExcludeMissing + fun _feedbackUrls(): JsonField<FeedbackUrls> = feedbackUrls + + /** + * Returns the raw JSON value of [filter]. + * + * Unlike [filter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField<String> = filter + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ResponseBodyForRunsGenerateQuery]. + * + * The following fields are required: + * ```java + * .feedbackUrls() + * .filter() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ResponseBodyForRunsGenerateQuery]. */ + class Builder internal constructor() { + + private var feedbackUrls: JsonField<FeedbackUrls>? = null + private var filter: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(responseBodyForRunsGenerateQuery: ResponseBodyForRunsGenerateQuery) = + apply { + feedbackUrls = responseBodyForRunsGenerateQuery.feedbackUrls + filter = responseBodyForRunsGenerateQuery.filter + additionalProperties = + responseBodyForRunsGenerateQuery.additionalProperties.toMutableMap() + } + + fun feedbackUrls(feedbackUrls: FeedbackUrls) = feedbackUrls(JsonField.of(feedbackUrls)) + + /** + * Sets [Builder.feedbackUrls] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackUrls] with a well-typed [FeedbackUrls] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun feedbackUrls(feedbackUrls: JsonField<FeedbackUrls>) = apply { + this.feedbackUrls = feedbackUrls + } + + fun filter(filter: String) = filter(JsonField.of(filter)) + + /** + * Sets [Builder.filter] to an arbitrary JSON value. + * + * You should usually call [Builder.filter] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun filter(filter: JsonField<String>) = apply { this.filter = filter } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ResponseBodyForRunsGenerateQuery]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .feedbackUrls() + * .filter() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ResponseBodyForRunsGenerateQuery = + ResponseBodyForRunsGenerateQuery( + checkRequired("feedbackUrls", feedbackUrls), + checkRequired("filter", filter), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ResponseBodyForRunsGenerateQuery = apply { + if (validated) { + return@apply + } + + feedbackUrls().validate() + filter() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (feedbackUrls.asKnown().getOrNull()?.validity() ?: 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + class FeedbackUrls + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [FeedbackUrls]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackUrls]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(feedbackUrls: FeedbackUrls) = apply { + additionalProperties = feedbackUrls.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FeedbackUrls]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FeedbackUrls = FeedbackUrls(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): FeedbackUrls = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackUrls && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "FeedbackUrls{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ResponseBodyForRunsGenerateQuery && + feedbackUrls == other.feedbackUrls && + filter == other.filter && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(feedbackUrls, filter, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ResponseBodyForRunsGenerateQuery{feedbackUrls=$feedbackUrls, filter=$filter, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunDeleteParams.kt new file mode 100644 index 00000000..1ac27fa9 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunDeleteParams.kt @@ -0,0 +1,650 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete specific runs by trace IDs or metadata key-value pairs. */ +class RunDeleteParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional<Metadata> = body.metadata() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun sessionId(): Optional<String> = body.sessionId() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun traceIds(): Optional<List<String>> = body.traceIds() + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _metadata(): JsonField<Metadata> = body._metadata() + + /** + * Returns the raw JSON value of [sessionId]. + * + * Unlike [sessionId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _sessionId(): JsonField<String> = body._sessionId() + + /** + * Returns the raw JSON value of [traceIds]. + * + * Unlike [traceIds], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _traceIds(): JsonField<List<String>> = body._traceIds() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): RunDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [RunDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunDeleteParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(runDeleteParams: RunDeleteParams) = apply { + body = runDeleteParams.body.toBuilder() + additionalHeaders = runDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = runDeleteParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [metadata] + * - [sessionId] + * - [traceIds] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional<Metadata>) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField<Metadata>) = apply { body.metadata(metadata) } + + fun sessionId(sessionId: String?) = apply { body.sessionId(sessionId) } + + /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ + fun sessionId(sessionId: Optional<String>) = sessionId(sessionId.getOrNull()) + + /** + * Sets [Builder.sessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun sessionId(sessionId: JsonField<String>) = apply { body.sessionId(sessionId) } + + fun traceIds(traceIds: List<String>?) = apply { body.traceIds(traceIds) } + + /** Alias for calling [Builder.traceIds] with `traceIds.orElse(null)`. */ + fun traceIds(traceIds: Optional<List<String>>) = traceIds(traceIds.getOrNull()) + + /** + * Sets [Builder.traceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.traceIds] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun traceIds(traceIds: JsonField<List<String>>) = apply { body.traceIds(traceIds) } + + /** + * Adds a single [String] to [traceIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTraceId(traceId: String) = apply { body.addTraceId(traceId) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RunDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RunDeleteParams = + RunDeleteParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val metadata: JsonField<Metadata>, + private val sessionId: JsonField<String>, + private val traceIds: JsonField<List<String>>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField<Metadata> = JsonMissing.of(), + @JsonProperty("session_id") + @ExcludeMissing + sessionId: JsonField<String> = JsonMissing.of(), + @JsonProperty("trace_ids") + @ExcludeMissing + traceIds: JsonField<List<String>> = JsonMissing.of(), + ) : this(metadata, sessionId, traceIds, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun metadata(): Optional<Metadata> = metadata.getOptional("metadata") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun sessionId(): Optional<String> = sessionId.getOptional("session_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun traceIds(): Optional<List<String>> = traceIds.getOptional("trace_ids") + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField<Metadata> = metadata + + /** + * Returns the raw JSON value of [sessionId]. + * + * Unlike [sessionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session_id") @ExcludeMissing fun _sessionId(): JsonField<String> = sessionId + + /** + * Returns the raw JSON value of [traceIds]. + * + * Unlike [traceIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trace_ids") + @ExcludeMissing + fun _traceIds(): JsonField<List<String>> = traceIds + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var metadata: JsonField<Metadata> = JsonMissing.of() + private var sessionId: JsonField<String> = JsonMissing.of() + private var traceIds: JsonField<MutableList<String>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + metadata = body.metadata + sessionId = body.sessionId + traceIds = body.traceIds.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional<Metadata>) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField<Metadata>) = apply { this.metadata = metadata } + + fun sessionId(sessionId: String?) = sessionId(JsonField.ofNullable(sessionId)) + + /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ + fun sessionId(sessionId: Optional<String>) = sessionId(sessionId.getOrNull()) + + /** + * Sets [Builder.sessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sessionId(sessionId: JsonField<String>) = apply { this.sessionId = sessionId } + + fun traceIds(traceIds: List<String>?) = traceIds(JsonField.ofNullable(traceIds)) + + /** Alias for calling [Builder.traceIds] with `traceIds.orElse(null)`. */ + fun traceIds(traceIds: Optional<List<String>>) = traceIds(traceIds.getOrNull()) + + /** + * Sets [Builder.traceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.traceIds] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun traceIds(traceIds: JsonField<List<String>>) = apply { + this.traceIds = traceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [traceIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTraceId(traceId: String) = apply { + traceIds = + (traceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("traceIds", it).add(traceId) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = + Body( + metadata, + sessionId, + (traceIds ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + metadata().ifPresent { it.validate() } + sessionId() + traceIds() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (sessionId.asKnown().isPresent) 1 else 0) + + (traceIds.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + metadata == other.metadata && + sessionId == other.sessionId && + traceIds == other.traceIds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(metadata, sessionId, traceIds, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{metadata=$metadata, sessionId=$sessionId, traceIds=$traceIds, additionalProperties=$additionalProperties}" + } + + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunDeleteParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "RunDeleteParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunDeleteResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunDeleteResponse.kt new file mode 100644 index 00000000..e6c29da8 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunDeleteResponse.kt @@ -0,0 +1,113 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class RunDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [RunDeleteResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunDeleteResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(runDeleteResponse: RunDeleteResponse) = apply { + additionalProperties = runDeleteResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RunDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RunDeleteResponse = RunDeleteResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): RunDeleteResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunDeleteResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "RunDeleteResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunGenerateQueryParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunGenerateQueryParams.kt new file mode 100644 index 00000000..88dedd98 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunGenerateQueryParams.kt @@ -0,0 +1,205 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** Get runs filter expression query for a given natural language query. */ +class RunGenerateQueryParams +private constructor( + private val requestBodyForRunsGenerateQuery: RequestBodyForRunsGenerateQuery, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun requestBodyForRunsGenerateQuery(): RequestBodyForRunsGenerateQuery = + requestBodyForRunsGenerateQuery + + fun _additionalBodyProperties(): Map<String, JsonValue> = + requestBodyForRunsGenerateQuery._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RunGenerateQueryParams]. + * + * The following fields are required: + * ```java + * .requestBodyForRunsGenerateQuery() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunGenerateQueryParams]. */ + class Builder internal constructor() { + + private var requestBodyForRunsGenerateQuery: RequestBodyForRunsGenerateQuery? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(runGenerateQueryParams: RunGenerateQueryParams) = apply { + requestBodyForRunsGenerateQuery = runGenerateQueryParams.requestBodyForRunsGenerateQuery + additionalHeaders = runGenerateQueryParams.additionalHeaders.toBuilder() + additionalQueryParams = runGenerateQueryParams.additionalQueryParams.toBuilder() + } + + fun requestBodyForRunsGenerateQuery( + requestBodyForRunsGenerateQuery: RequestBodyForRunsGenerateQuery + ) = apply { this.requestBodyForRunsGenerateQuery = requestBodyForRunsGenerateQuery } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RunGenerateQueryParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .requestBodyForRunsGenerateQuery() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RunGenerateQueryParams = + RunGenerateQueryParams( + checkRequired("requestBodyForRunsGenerateQuery", requestBodyForRunsGenerateQuery), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): RequestBodyForRunsGenerateQuery = requestBodyForRunsGenerateQuery + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunGenerateQueryParams && + requestBodyForRunsGenerateQuery == other.requestBodyForRunsGenerateQuery && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(requestBodyForRunsGenerateQuery, additionalHeaders, additionalQueryParams) + + override fun toString() = + "RunGenerateQueryParams{requestBodyForRunsGenerateQuery=$requestBodyForRunsGenerateQuery, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunQueryParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunQueryParams.kt new file mode 100644 index 00000000..aa8b1643 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunQueryParams.kt @@ -0,0 +1,206 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** Query Runs */ +class RunQueryParams +private constructor( + private val bodyParamsForRunSchema: BodyParamsForRunSchema, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Query params for run endpoints. */ + fun bodyParamsForRunSchema(): BodyParamsForRunSchema = bodyParamsForRunSchema + + fun _additionalBodyProperties(): Map<String, JsonValue> = + bodyParamsForRunSchema._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RunQueryParams]. + * + * The following fields are required: + * ```java + * .bodyParamsForRunSchema() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunQueryParams]. */ + class Builder internal constructor() { + + private var bodyParamsForRunSchema: BodyParamsForRunSchema? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(runQueryParams: RunQueryParams) = apply { + bodyParamsForRunSchema = runQueryParams.bodyParamsForRunSchema + additionalHeaders = runQueryParams.additionalHeaders.toBuilder() + additionalQueryParams = runQueryParams.additionalQueryParams.toBuilder() + } + + /** Query params for run endpoints. */ + fun bodyParamsForRunSchema(bodyParamsForRunSchema: BodyParamsForRunSchema) = apply { + this.bodyParamsForRunSchema = bodyParamsForRunSchema + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RunQueryParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bodyParamsForRunSchema() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RunQueryParams = + RunQueryParams( + checkRequired("bodyParamsForRunSchema", bodyParamsForRunSchema), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): BodyParamsForRunSchema = bodyParamsForRunSchema + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunQueryParams && + bodyParamsForRunSchema == other.bodyParamsForRunSchema && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(bodyParamsForRunSchema, additionalHeaders, additionalQueryParams) + + override fun toString() = + "RunQueryParams{bodyParamsForRunSchema=$bodyParamsForRunSchema, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunQueryResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunQueryResponse.kt new file mode 100644 index 00000000..2a90c961 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunQueryResponse.kt @@ -0,0 +1,503 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class RunQueryResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val cursors: JsonField<Cursors>, + private val runs: JsonField<List<RunSchema>>, + private val parsedQuery: JsonField<String>, + private val searchCursors: JsonField<SearchCursors>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("cursors") @ExcludeMissing cursors: JsonField<Cursors> = JsonMissing.of(), + @JsonProperty("runs") @ExcludeMissing runs: JsonField<List<RunSchema>> = JsonMissing.of(), + @JsonProperty("parsed_query") + @ExcludeMissing + parsedQuery: JsonField<String> = JsonMissing.of(), + @JsonProperty("search_cursors") + @ExcludeMissing + searchCursors: JsonField<SearchCursors> = JsonMissing.of(), + ) : this(cursors, runs, parsedQuery, searchCursors, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cursors(): Cursors = cursors.getRequired("cursors") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun runs(): List<RunSchema> = runs.getRequired("runs") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun parsedQuery(): Optional<String> = parsedQuery.getOptional("parsed_query") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun searchCursors(): Optional<SearchCursors> = searchCursors.getOptional("search_cursors") + + /** + * Returns the raw JSON value of [cursors]. + * + * Unlike [cursors], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cursors") @ExcludeMissing fun _cursors(): JsonField<Cursors> = cursors + + /** + * Returns the raw JSON value of [runs]. + * + * Unlike [runs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("runs") @ExcludeMissing fun _runs(): JsonField<List<RunSchema>> = runs + + /** + * Returns the raw JSON value of [parsedQuery]. + * + * Unlike [parsedQuery], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("parsed_query") + @ExcludeMissing + fun _parsedQuery(): JsonField<String> = parsedQuery + + /** + * Returns the raw JSON value of [searchCursors]. + * + * Unlike [searchCursors], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("search_cursors") + @ExcludeMissing + fun _searchCursors(): JsonField<SearchCursors> = searchCursors + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RunQueryResponse]. + * + * The following fields are required: + * ```java + * .cursors() + * .runs() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunQueryResponse]. */ + class Builder internal constructor() { + + private var cursors: JsonField<Cursors>? = null + private var runs: JsonField<MutableList<RunSchema>>? = null + private var parsedQuery: JsonField<String> = JsonMissing.of() + private var searchCursors: JsonField<SearchCursors> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(runQueryResponse: RunQueryResponse) = apply { + cursors = runQueryResponse.cursors + runs = runQueryResponse.runs.map { it.toMutableList() } + parsedQuery = runQueryResponse.parsedQuery + searchCursors = runQueryResponse.searchCursors + additionalProperties = runQueryResponse.additionalProperties.toMutableMap() + } + + fun cursors(cursors: Cursors) = cursors(JsonField.of(cursors)) + + /** + * Sets [Builder.cursors] to an arbitrary JSON value. + * + * You should usually call [Builder.cursors] with a well-typed [Cursors] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun cursors(cursors: JsonField<Cursors>) = apply { this.cursors = cursors } + + fun runs(runs: List<RunSchema>) = runs(JsonField.of(runs)) + + /** + * Sets [Builder.runs] to an arbitrary JSON value. + * + * You should usually call [Builder.runs] with a well-typed `List<RunSchema>` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun runs(runs: JsonField<List<RunSchema>>) = apply { + this.runs = runs.map { it.toMutableList() } + } + + /** + * Adds a single [RunSchema] to [runs]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRun(run: RunSchema) = apply { + runs = (runs ?: JsonField.of(mutableListOf())).also { checkKnown("runs", it).add(run) } + } + + fun parsedQuery(parsedQuery: String?) = parsedQuery(JsonField.ofNullable(parsedQuery)) + + /** Alias for calling [Builder.parsedQuery] with `parsedQuery.orElse(null)`. */ + fun parsedQuery(parsedQuery: Optional<String>) = parsedQuery(parsedQuery.getOrNull()) + + /** + * Sets [Builder.parsedQuery] to an arbitrary JSON value. + * + * You should usually call [Builder.parsedQuery] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun parsedQuery(parsedQuery: JsonField<String>) = apply { this.parsedQuery = parsedQuery } + + fun searchCursors(searchCursors: SearchCursors?) = + searchCursors(JsonField.ofNullable(searchCursors)) + + /** Alias for calling [Builder.searchCursors] with `searchCursors.orElse(null)`. */ + fun searchCursors(searchCursors: Optional<SearchCursors>) = + searchCursors(searchCursors.getOrNull()) + + /** + * Sets [Builder.searchCursors] to an arbitrary JSON value. + * + * You should usually call [Builder.searchCursors] with a well-typed [SearchCursors] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun searchCursors(searchCursors: JsonField<SearchCursors>) = apply { + this.searchCursors = searchCursors + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RunQueryResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cursors() + * .runs() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RunQueryResponse = + RunQueryResponse( + checkRequired("cursors", cursors), + checkRequired("runs", runs).map { it.toImmutable() }, + parsedQuery, + searchCursors, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RunQueryResponse = apply { + if (validated) { + return@apply + } + + cursors().validate() + runs().forEach { it.validate() } + parsedQuery() + searchCursors().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cursors.asKnown().getOrNull()?.validity() ?: 0) + + (runs.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (parsedQuery.asKnown().isPresent) 1 else 0) + + (searchCursors.asKnown().getOrNull()?.validity() ?: 0) + + class Cursors + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Cursors]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Cursors]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(cursors: Cursors) = apply { + additionalProperties = cursors.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Cursors]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Cursors = Cursors(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Cursors = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cursors && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Cursors{additionalProperties=$additionalProperties}" + } + + class SearchCursors + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [SearchCursors]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SearchCursors]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(searchCursors: SearchCursors) = apply { + additionalProperties = searchCursors.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SearchCursors]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SearchCursors = SearchCursors(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): SearchCursors = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SearchCursors && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "SearchCursors{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunQueryResponse && + cursors == other.cursors && + runs == other.runs && + parsedQuery == other.parsedQuery && + searchCursors == other.searchCursors && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(cursors, runs, parsedQuery, searchCursors, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RunQueryResponse{cursors=$cursors, runs=$runs, parsedQuery=$parsedQuery, searchCursors=$searchCursors, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunRetrieveParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunRetrieveParams.kt new file mode 100644 index 00000000..8fe767ea --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunRetrieveParams.kt @@ -0,0 +1,291 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get a specific run. */ +class RunRetrieveParams +private constructor( + private val runId: String?, + private val excludeS3StoredAttributes: Boolean?, + private val excludeSerialized: Boolean?, + private val sessionId: String?, + private val startTime: OffsetDateTime?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun runId(): Optional<String> = Optional.ofNullable(runId) + + fun excludeS3StoredAttributes(): Optional<Boolean> = + Optional.ofNullable(excludeS3StoredAttributes) + + fun excludeSerialized(): Optional<Boolean> = Optional.ofNullable(excludeSerialized) + + fun sessionId(): Optional<String> = Optional.ofNullable(sessionId) + + fun startTime(): Optional<OffsetDateTime> = Optional.ofNullable(startTime) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): RunRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [RunRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunRetrieveParams]. */ + class Builder internal constructor() { + + private var runId: String? = null + private var excludeS3StoredAttributes: Boolean? = null + private var excludeSerialized: Boolean? = null + private var sessionId: String? = null + private var startTime: OffsetDateTime? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(runRetrieveParams: RunRetrieveParams) = apply { + runId = runRetrieveParams.runId + excludeS3StoredAttributes = runRetrieveParams.excludeS3StoredAttributes + excludeSerialized = runRetrieveParams.excludeSerialized + sessionId = runRetrieveParams.sessionId + startTime = runRetrieveParams.startTime + additionalHeaders = runRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = runRetrieveParams.additionalQueryParams.toBuilder() + } + + fun runId(runId: String?) = apply { this.runId = runId } + + /** Alias for calling [Builder.runId] with `runId.orElse(null)`. */ + fun runId(runId: Optional<String>) = runId(runId.getOrNull()) + + fun excludeS3StoredAttributes(excludeS3StoredAttributes: Boolean?) = apply { + this.excludeS3StoredAttributes = excludeS3StoredAttributes + } + + /** + * Alias for [Builder.excludeS3StoredAttributes]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun excludeS3StoredAttributes(excludeS3StoredAttributes: Boolean) = + excludeS3StoredAttributes(excludeS3StoredAttributes as Boolean?) + + /** + * Alias for calling [Builder.excludeS3StoredAttributes] with + * `excludeS3StoredAttributes.orElse(null)`. + */ + fun excludeS3StoredAttributes(excludeS3StoredAttributes: Optional<Boolean>) = + excludeS3StoredAttributes(excludeS3StoredAttributes.getOrNull()) + + fun excludeSerialized(excludeSerialized: Boolean?) = apply { + this.excludeSerialized = excludeSerialized + } + + /** + * Alias for [Builder.excludeSerialized]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun excludeSerialized(excludeSerialized: Boolean) = + excludeSerialized(excludeSerialized as Boolean?) + + /** Alias for calling [Builder.excludeSerialized] with `excludeSerialized.orElse(null)`. */ + fun excludeSerialized(excludeSerialized: Optional<Boolean>) = + excludeSerialized(excludeSerialized.getOrNull()) + + fun sessionId(sessionId: String?) = apply { this.sessionId = sessionId } + + /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ + fun sessionId(sessionId: Optional<String>) = sessionId(sessionId.getOrNull()) + + fun startTime(startTime: OffsetDateTime?) = apply { this.startTime = startTime } + + /** Alias for calling [Builder.startTime] with `startTime.orElse(null)`. */ + fun startTime(startTime: Optional<OffsetDateTime>) = startTime(startTime.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RunRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RunRetrieveParams = + RunRetrieveParams( + runId, + excludeS3StoredAttributes, + excludeSerialized, + sessionId, + startTime, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> runId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + excludeS3StoredAttributes?.let { + put("exclude_s3_stored_attributes", it.toString()) + } + excludeSerialized?.let { put("exclude_serialized", it.toString()) } + sessionId?.let { put("session_id", it) } + startTime?.let { + put("start_time", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunRetrieveParams && + runId == other.runId && + excludeS3StoredAttributes == other.excludeS3StoredAttributes && + excludeSerialized == other.excludeSerialized && + sessionId == other.sessionId && + startTime == other.startTime && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + runId, + excludeS3StoredAttributes, + excludeSerialized, + sessionId, + startTime, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "RunRetrieveParams{runId=$runId, excludeS3StoredAttributes=$excludeS3StoredAttributes, excludeSerialized=$excludeSerialized, sessionId=$sessionId, startTime=$startTime, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunSchema.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunSchema.kt new file mode 100644 index 00000000..59570491 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunSchema.kt @@ -0,0 +1,2770 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TraceTier +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Run schema. */ +class RunSchema +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val appPath: JsonField<String>, + private val dottedOrder: JsonField<String>, + private val name: JsonField<String>, + private val runType: JsonField<RunTypeEnum>, + private val sessionId: JsonField<String>, + private val status: JsonField<String>, + private val traceId: JsonField<String>, + private val childRunIds: JsonField<List<String>>, + private val completionCost: JsonField<String>, + private val completionCostDetails: JsonField<CompletionCostDetails>, + private val completionTokenDetails: JsonField<CompletionTokenDetails>, + private val completionTokens: JsonField<Long>, + private val directChildRunIds: JsonField<List<String>>, + private val endTime: JsonField<OffsetDateTime>, + private val error: JsonField<String>, + private val events: JsonField<List<JsonValue>>, + private val executionOrder: JsonField<Long>, + private val extra: JsonValue, + private val feedbackStats: JsonField<FeedbackStats>, + private val firstTokenTime: JsonField<OffsetDateTime>, + private val inDataset: JsonField<Boolean>, + private val inputs: JsonValue, + private val inputsPreview: JsonField<String>, + private val inputsS3Urls: JsonValue, + private val lastQueuedAt: JsonField<OffsetDateTime>, + private val manifestId: JsonField<String>, + private val manifestS3Id: JsonField<String>, + private val outputs: JsonValue, + private val outputsPreview: JsonField<String>, + private val outputsS3Urls: JsonValue, + private val parentRunId: JsonField<String>, + private val parentRunIds: JsonField<List<String>>, + private val priceModelId: JsonField<String>, + private val promptCost: JsonField<String>, + private val promptCostDetails: JsonField<PromptCostDetails>, + private val promptTokenDetails: JsonField<PromptTokenDetails>, + private val promptTokens: JsonField<Long>, + private val referenceDatasetId: JsonField<String>, + private val referenceExampleId: JsonField<String>, + private val s3Urls: JsonValue, + private val serialized: JsonValue, + private val shareToken: JsonField<String>, + private val startTime: JsonField<OffsetDateTime>, + private val tags: JsonField<List<String>>, + private val threadId: JsonField<String>, + private val totalCost: JsonField<String>, + private val totalTokens: JsonField<Long>, + private val traceFirstReceivedAt: JsonField<OffsetDateTime>, + private val traceMaxStartTime: JsonField<OffsetDateTime>, + private val traceMinStartTime: JsonField<OffsetDateTime>, + private val traceTier: JsonField<TraceTier>, + private val traceUpgrade: JsonField<Boolean>, + private val ttlSeconds: JsonField<Long>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("app_path") @ExcludeMissing appPath: JsonField<String> = JsonMissing.of(), + @JsonProperty("dotted_order") + @ExcludeMissing + dottedOrder: JsonField<String> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("run_type") + @ExcludeMissing + runType: JsonField<RunTypeEnum> = JsonMissing.of(), + @JsonProperty("session_id") @ExcludeMissing sessionId: JsonField<String> = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField<String> = JsonMissing.of(), + @JsonProperty("trace_id") @ExcludeMissing traceId: JsonField<String> = JsonMissing.of(), + @JsonProperty("child_run_ids") + @ExcludeMissing + childRunIds: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("completion_cost") + @ExcludeMissing + completionCost: JsonField<String> = JsonMissing.of(), + @JsonProperty("completion_cost_details") + @ExcludeMissing + completionCostDetails: JsonField<CompletionCostDetails> = JsonMissing.of(), + @JsonProperty("completion_token_details") + @ExcludeMissing + completionTokenDetails: JsonField<CompletionTokenDetails> = JsonMissing.of(), + @JsonProperty("completion_tokens") + @ExcludeMissing + completionTokens: JsonField<Long> = JsonMissing.of(), + @JsonProperty("direct_child_run_ids") + @ExcludeMissing + directChildRunIds: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("end_time") + @ExcludeMissing + endTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("error") @ExcludeMissing error: JsonField<String> = JsonMissing.of(), + @JsonProperty("events") + @ExcludeMissing + events: JsonField<List<JsonValue>> = JsonMissing.of(), + @JsonProperty("execution_order") + @ExcludeMissing + executionOrder: JsonField<Long> = JsonMissing.of(), + @JsonProperty("extra") @ExcludeMissing extra: JsonValue = JsonMissing.of(), + @JsonProperty("feedback_stats") + @ExcludeMissing + feedbackStats: JsonField<FeedbackStats> = JsonMissing.of(), + @JsonProperty("first_token_time") + @ExcludeMissing + firstTokenTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("in_dataset") + @ExcludeMissing + inDataset: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("inputs") @ExcludeMissing inputs: JsonValue = JsonMissing.of(), + @JsonProperty("inputs_preview") + @ExcludeMissing + inputsPreview: JsonField<String> = JsonMissing.of(), + @JsonProperty("inputs_s3_urls") @ExcludeMissing inputsS3Urls: JsonValue = JsonMissing.of(), + @JsonProperty("last_queued_at") + @ExcludeMissing + lastQueuedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("manifest_id") + @ExcludeMissing + manifestId: JsonField<String> = JsonMissing.of(), + @JsonProperty("manifest_s3_id") + @ExcludeMissing + manifestS3Id: JsonField<String> = JsonMissing.of(), + @JsonProperty("outputs") @ExcludeMissing outputs: JsonValue = JsonMissing.of(), + @JsonProperty("outputs_preview") + @ExcludeMissing + outputsPreview: JsonField<String> = JsonMissing.of(), + @JsonProperty("outputs_s3_urls") + @ExcludeMissing + outputsS3Urls: JsonValue = JsonMissing.of(), + @JsonProperty("parent_run_id") + @ExcludeMissing + parentRunId: JsonField<String> = JsonMissing.of(), + @JsonProperty("parent_run_ids") + @ExcludeMissing + parentRunIds: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("price_model_id") + @ExcludeMissing + priceModelId: JsonField<String> = JsonMissing.of(), + @JsonProperty("prompt_cost") + @ExcludeMissing + promptCost: JsonField<String> = JsonMissing.of(), + @JsonProperty("prompt_cost_details") + @ExcludeMissing + promptCostDetails: JsonField<PromptCostDetails> = JsonMissing.of(), + @JsonProperty("prompt_token_details") + @ExcludeMissing + promptTokenDetails: JsonField<PromptTokenDetails> = JsonMissing.of(), + @JsonProperty("prompt_tokens") + @ExcludeMissing + promptTokens: JsonField<Long> = JsonMissing.of(), + @JsonProperty("reference_dataset_id") + @ExcludeMissing + referenceDatasetId: JsonField<String> = JsonMissing.of(), + @JsonProperty("reference_example_id") + @ExcludeMissing + referenceExampleId: JsonField<String> = JsonMissing.of(), + @JsonProperty("s3_urls") @ExcludeMissing s3Urls: JsonValue = JsonMissing.of(), + @JsonProperty("serialized") @ExcludeMissing serialized: JsonValue = JsonMissing.of(), + @JsonProperty("share_token") + @ExcludeMissing + shareToken: JsonField<String> = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing tags: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("thread_id") @ExcludeMissing threadId: JsonField<String> = JsonMissing.of(), + @JsonProperty("total_cost") @ExcludeMissing totalCost: JsonField<String> = JsonMissing.of(), + @JsonProperty("total_tokens") + @ExcludeMissing + totalTokens: JsonField<Long> = JsonMissing.of(), + @JsonProperty("trace_first_received_at") + @ExcludeMissing + traceFirstReceivedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("trace_max_start_time") + @ExcludeMissing + traceMaxStartTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("trace_min_start_time") + @ExcludeMissing + traceMinStartTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("trace_tier") + @ExcludeMissing + traceTier: JsonField<TraceTier> = JsonMissing.of(), + @JsonProperty("trace_upgrade") + @ExcludeMissing + traceUpgrade: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("ttl_seconds") @ExcludeMissing ttlSeconds: JsonField<Long> = JsonMissing.of(), + ) : this( + id, + appPath, + dottedOrder, + name, + runType, + sessionId, + status, + traceId, + childRunIds, + completionCost, + completionCostDetails, + completionTokenDetails, + completionTokens, + directChildRunIds, + endTime, + error, + events, + executionOrder, + extra, + feedbackStats, + firstTokenTime, + inDataset, + inputs, + inputsPreview, + inputsS3Urls, + lastQueuedAt, + manifestId, + manifestS3Id, + outputs, + outputsPreview, + outputsS3Urls, + parentRunId, + parentRunIds, + priceModelId, + promptCost, + promptCostDetails, + promptTokenDetails, + promptTokens, + referenceDatasetId, + referenceExampleId, + s3Urls, + serialized, + shareToken, + startTime, + tags, + threadId, + totalCost, + totalTokens, + traceFirstReceivedAt, + traceMaxStartTime, + traceMinStartTime, + traceTier, + traceUpgrade, + ttlSeconds, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun appPath(): String = appPath.getRequired("app_path") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun dottedOrder(): String = dottedOrder.getRequired("dotted_order") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Enum for run types. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun runType(): RunTypeEnum = runType.getRequired("run_type") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun sessionId(): String = sessionId.getRequired("session_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): String = status.getRequired("status") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun traceId(): String = traceId.getRequired("trace_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun childRunIds(): Optional<List<String>> = childRunIds.getOptional("child_run_ids") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun completionCost(): Optional<String> = completionCost.getOptional("completion_cost") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun completionCostDetails(): Optional<CompletionCostDetails> = + completionCostDetails.getOptional("completion_cost_details") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun completionTokenDetails(): Optional<CompletionTokenDetails> = + completionTokenDetails.getOptional("completion_token_details") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun completionTokens(): Optional<Long> = completionTokens.getOptional("completion_tokens") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun directChildRunIds(): Optional<List<String>> = + directChildRunIds.getOptional("direct_child_run_ids") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endTime(): Optional<OffsetDateTime> = endTime.getOptional("end_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun error(): Optional<String> = error.getOptional("error") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun events(): Optional<List<JsonValue>> = events.getOptional("events") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun executionOrder(): Optional<Long> = executionOrder.getOptional("execution_order") + + @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonValue = extra + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun feedbackStats(): Optional<FeedbackStats> = feedbackStats.getOptional("feedback_stats") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun firstTokenTime(): Optional<OffsetDateTime> = firstTokenTime.getOptional("first_token_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun inDataset(): Optional<Boolean> = inDataset.getOptional("in_dataset") + + @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonValue = inputs + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun inputsPreview(): Optional<String> = inputsPreview.getOptional("inputs_preview") + + @JsonProperty("inputs_s3_urls") @ExcludeMissing fun _inputsS3Urls(): JsonValue = inputsS3Urls + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun lastQueuedAt(): Optional<OffsetDateTime> = lastQueuedAt.getOptional("last_queued_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun manifestId(): Optional<String> = manifestId.getOptional("manifest_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun manifestS3Id(): Optional<String> = manifestS3Id.getOptional("manifest_s3_id") + + @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonValue = outputs + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun outputsPreview(): Optional<String> = outputsPreview.getOptional("outputs_preview") + + @JsonProperty("outputs_s3_urls") @ExcludeMissing fun _outputsS3Urls(): JsonValue = outputsS3Urls + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun parentRunId(): Optional<String> = parentRunId.getOptional("parent_run_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun parentRunIds(): Optional<List<String>> = parentRunIds.getOptional("parent_run_ids") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun priceModelId(): Optional<String> = priceModelId.getOptional("price_model_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun promptCost(): Optional<String> = promptCost.getOptional("prompt_cost") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun promptCostDetails(): Optional<PromptCostDetails> = + promptCostDetails.getOptional("prompt_cost_details") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun promptTokenDetails(): Optional<PromptTokenDetails> = + promptTokenDetails.getOptional("prompt_token_details") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun promptTokens(): Optional<Long> = promptTokens.getOptional("prompt_tokens") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceDatasetId(): Optional<String> = + referenceDatasetId.getOptional("reference_dataset_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceExampleId(): Optional<String> = + referenceExampleId.getOptional("reference_example_id") + + @JsonProperty("s3_urls") @ExcludeMissing fun _s3Urls(): JsonValue = s3Urls + + @JsonProperty("serialized") @ExcludeMissing fun _serialized(): JsonValue = serialized + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun shareToken(): Optional<String> = shareToken.getOptional("share_token") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun startTime(): Optional<OffsetDateTime> = startTime.getOptional("start_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tags(): Optional<List<String>> = tags.getOptional("tags") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun threadId(): Optional<String> = threadId.getOptional("thread_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun totalCost(): Optional<String> = totalCost.getOptional("total_cost") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun totalTokens(): Optional<Long> = totalTokens.getOptional("total_tokens") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun traceFirstReceivedAt(): Optional<OffsetDateTime> = + traceFirstReceivedAt.getOptional("trace_first_received_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun traceMaxStartTime(): Optional<OffsetDateTime> = + traceMaxStartTime.getOptional("trace_max_start_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun traceMinStartTime(): Optional<OffsetDateTime> = + traceMinStartTime.getOptional("trace_min_start_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun traceTier(): Optional<TraceTier> = traceTier.getOptional("trace_tier") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun traceUpgrade(): Optional<Boolean> = traceUpgrade.getOptional("trace_upgrade") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun ttlSeconds(): Optional<Long> = ttlSeconds.getOptional("ttl_seconds") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [appPath]. + * + * Unlike [appPath], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("app_path") @ExcludeMissing fun _appPath(): JsonField<String> = appPath + + /** + * Returns the raw JSON value of [dottedOrder]. + * + * Unlike [dottedOrder], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dotted_order") + @ExcludeMissing + fun _dottedOrder(): JsonField<String> = dottedOrder + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [runType]. + * + * Unlike [runType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_type") @ExcludeMissing fun _runType(): JsonField<RunTypeEnum> = runType + + /** + * Returns the raw JSON value of [sessionId]. + * + * Unlike [sessionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session_id") @ExcludeMissing fun _sessionId(): JsonField<String> = sessionId + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField<String> = status + + /** + * Returns the raw JSON value of [traceId]. + * + * Unlike [traceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trace_id") @ExcludeMissing fun _traceId(): JsonField<String> = traceId + + /** + * Returns the raw JSON value of [childRunIds]. + * + * Unlike [childRunIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("child_run_ids") + @ExcludeMissing + fun _childRunIds(): JsonField<List<String>> = childRunIds + + /** + * Returns the raw JSON value of [completionCost]. + * + * Unlike [completionCost], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("completion_cost") + @ExcludeMissing + fun _completionCost(): JsonField<String> = completionCost + + /** + * Returns the raw JSON value of [completionCostDetails]. + * + * Unlike [completionCostDetails], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("completion_cost_details") + @ExcludeMissing + fun _completionCostDetails(): JsonField<CompletionCostDetails> = completionCostDetails + + /** + * Returns the raw JSON value of [completionTokenDetails]. + * + * Unlike [completionTokenDetails], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("completion_token_details") + @ExcludeMissing + fun _completionTokenDetails(): JsonField<CompletionTokenDetails> = completionTokenDetails + + /** + * Returns the raw JSON value of [completionTokens]. + * + * Unlike [completionTokens], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("completion_tokens") + @ExcludeMissing + fun _completionTokens(): JsonField<Long> = completionTokens + + /** + * Returns the raw JSON value of [directChildRunIds]. + * + * Unlike [directChildRunIds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("direct_child_run_ids") + @ExcludeMissing + fun _directChildRunIds(): JsonField<List<String>> = directChildRunIds + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_time") @ExcludeMissing fun _endTime(): JsonField<OffsetDateTime> = endTime + + /** + * Returns the raw JSON value of [error]. + * + * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("error") @ExcludeMissing fun _error(): JsonField<String> = error + + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("events") @ExcludeMissing fun _events(): JsonField<List<JsonValue>> = events + + /** + * Returns the raw JSON value of [executionOrder]. + * + * Unlike [executionOrder], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("execution_order") + @ExcludeMissing + fun _executionOrder(): JsonField<Long> = executionOrder + + /** + * Returns the raw JSON value of [feedbackStats]. + * + * Unlike [feedbackStats], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feedback_stats") + @ExcludeMissing + fun _feedbackStats(): JsonField<FeedbackStats> = feedbackStats + + /** + * Returns the raw JSON value of [firstTokenTime]. + * + * Unlike [firstTokenTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("first_token_time") + @ExcludeMissing + fun _firstTokenTime(): JsonField<OffsetDateTime> = firstTokenTime + + /** + * Returns the raw JSON value of [inDataset]. + * + * Unlike [inDataset], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("in_dataset") @ExcludeMissing fun _inDataset(): JsonField<Boolean> = inDataset + + /** + * Returns the raw JSON value of [inputsPreview]. + * + * Unlike [inputsPreview], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inputs_preview") + @ExcludeMissing + fun _inputsPreview(): JsonField<String> = inputsPreview + + /** + * Returns the raw JSON value of [lastQueuedAt]. + * + * Unlike [lastQueuedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("last_queued_at") + @ExcludeMissing + fun _lastQueuedAt(): JsonField<OffsetDateTime> = lastQueuedAt + + /** + * Returns the raw JSON value of [manifestId]. + * + * Unlike [manifestId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("manifest_id") @ExcludeMissing fun _manifestId(): JsonField<String> = manifestId + + /** + * Returns the raw JSON value of [manifestS3Id]. + * + * Unlike [manifestS3Id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("manifest_s3_id") + @ExcludeMissing + fun _manifestS3Id(): JsonField<String> = manifestS3Id + + /** + * Returns the raw JSON value of [outputsPreview]. + * + * Unlike [outputsPreview], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outputs_preview") + @ExcludeMissing + fun _outputsPreview(): JsonField<String> = outputsPreview + + /** + * Returns the raw JSON value of [parentRunId]. + * + * Unlike [parentRunId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("parent_run_id") + @ExcludeMissing + fun _parentRunId(): JsonField<String> = parentRunId + + /** + * Returns the raw JSON value of [parentRunIds]. + * + * Unlike [parentRunIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("parent_run_ids") + @ExcludeMissing + fun _parentRunIds(): JsonField<List<String>> = parentRunIds + + /** + * Returns the raw JSON value of [priceModelId]. + * + * Unlike [priceModelId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_model_id") + @ExcludeMissing + fun _priceModelId(): JsonField<String> = priceModelId + + /** + * Returns the raw JSON value of [promptCost]. + * + * Unlike [promptCost], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prompt_cost") @ExcludeMissing fun _promptCost(): JsonField<String> = promptCost + + /** + * Returns the raw JSON value of [promptCostDetails]. + * + * Unlike [promptCostDetails], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("prompt_cost_details") + @ExcludeMissing + fun _promptCostDetails(): JsonField<PromptCostDetails> = promptCostDetails + + /** + * Returns the raw JSON value of [promptTokenDetails]. + * + * Unlike [promptTokenDetails], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("prompt_token_details") + @ExcludeMissing + fun _promptTokenDetails(): JsonField<PromptTokenDetails> = promptTokenDetails + + /** + * Returns the raw JSON value of [promptTokens]. + * + * Unlike [promptTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prompt_tokens") + @ExcludeMissing + fun _promptTokens(): JsonField<Long> = promptTokens + + /** + * Returns the raw JSON value of [referenceDatasetId]. + * + * Unlike [referenceDatasetId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reference_dataset_id") + @ExcludeMissing + fun _referenceDatasetId(): JsonField<String> = referenceDatasetId + + /** + * Returns the raw JSON value of [referenceExampleId]. + * + * Unlike [referenceExampleId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reference_example_id") + @ExcludeMissing + fun _referenceExampleId(): JsonField<String> = referenceExampleId + + /** + * Returns the raw JSON value of [shareToken]. + * + * Unlike [shareToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("share_token") @ExcludeMissing fun _shareToken(): JsonField<String> = shareToken + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_time") + @ExcludeMissing + fun _startTime(): JsonField<OffsetDateTime> = startTime + + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField<List<String>> = tags + + /** + * Returns the raw JSON value of [threadId]. + * + * Unlike [threadId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("thread_id") @ExcludeMissing fun _threadId(): JsonField<String> = threadId + + /** + * Returns the raw JSON value of [totalCost]. + * + * Unlike [totalCost], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total_cost") @ExcludeMissing fun _totalCost(): JsonField<String> = totalCost + + /** + * Returns the raw JSON value of [totalTokens]. + * + * Unlike [totalTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total_tokens") @ExcludeMissing fun _totalTokens(): JsonField<Long> = totalTokens + + /** + * Returns the raw JSON value of [traceFirstReceivedAt]. + * + * Unlike [traceFirstReceivedAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("trace_first_received_at") + @ExcludeMissing + fun _traceFirstReceivedAt(): JsonField<OffsetDateTime> = traceFirstReceivedAt + + /** + * Returns the raw JSON value of [traceMaxStartTime]. + * + * Unlike [traceMaxStartTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("trace_max_start_time") + @ExcludeMissing + fun _traceMaxStartTime(): JsonField<OffsetDateTime> = traceMaxStartTime + + /** + * Returns the raw JSON value of [traceMinStartTime]. + * + * Unlike [traceMinStartTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("trace_min_start_time") + @ExcludeMissing + fun _traceMinStartTime(): JsonField<OffsetDateTime> = traceMinStartTime + + /** + * Returns the raw JSON value of [traceTier]. + * + * Unlike [traceTier], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trace_tier") @ExcludeMissing fun _traceTier(): JsonField<TraceTier> = traceTier + + /** + * Returns the raw JSON value of [traceUpgrade]. + * + * Unlike [traceUpgrade], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trace_upgrade") + @ExcludeMissing + fun _traceUpgrade(): JsonField<Boolean> = traceUpgrade + + /** + * Returns the raw JSON value of [ttlSeconds]. + * + * Unlike [ttlSeconds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ttl_seconds") @ExcludeMissing fun _ttlSeconds(): JsonField<Long> = ttlSeconds + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RunSchema]. + * + * The following fields are required: + * ```java + * .id() + * .appPath() + * .dottedOrder() + * .name() + * .runType() + * .sessionId() + * .status() + * .traceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunSchema]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var appPath: JsonField<String>? = null + private var dottedOrder: JsonField<String>? = null + private var name: JsonField<String>? = null + private var runType: JsonField<RunTypeEnum>? = null + private var sessionId: JsonField<String>? = null + private var status: JsonField<String>? = null + private var traceId: JsonField<String>? = null + private var childRunIds: JsonField<MutableList<String>>? = null + private var completionCost: JsonField<String> = JsonMissing.of() + private var completionCostDetails: JsonField<CompletionCostDetails> = JsonMissing.of() + private var completionTokenDetails: JsonField<CompletionTokenDetails> = JsonMissing.of() + private var completionTokens: JsonField<Long> = JsonMissing.of() + private var directChildRunIds: JsonField<MutableList<String>>? = null + private var endTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var error: JsonField<String> = JsonMissing.of() + private var events: JsonField<MutableList<JsonValue>>? = null + private var executionOrder: JsonField<Long> = JsonMissing.of() + private var extra: JsonValue = JsonMissing.of() + private var feedbackStats: JsonField<FeedbackStats> = JsonMissing.of() + private var firstTokenTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var inDataset: JsonField<Boolean> = JsonMissing.of() + private var inputs: JsonValue = JsonMissing.of() + private var inputsPreview: JsonField<String> = JsonMissing.of() + private var inputsS3Urls: JsonValue = JsonMissing.of() + private var lastQueuedAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var manifestId: JsonField<String> = JsonMissing.of() + private var manifestS3Id: JsonField<String> = JsonMissing.of() + private var outputs: JsonValue = JsonMissing.of() + private var outputsPreview: JsonField<String> = JsonMissing.of() + private var outputsS3Urls: JsonValue = JsonMissing.of() + private var parentRunId: JsonField<String> = JsonMissing.of() + private var parentRunIds: JsonField<MutableList<String>>? = null + private var priceModelId: JsonField<String> = JsonMissing.of() + private var promptCost: JsonField<String> = JsonMissing.of() + private var promptCostDetails: JsonField<PromptCostDetails> = JsonMissing.of() + private var promptTokenDetails: JsonField<PromptTokenDetails> = JsonMissing.of() + private var promptTokens: JsonField<Long> = JsonMissing.of() + private var referenceDatasetId: JsonField<String> = JsonMissing.of() + private var referenceExampleId: JsonField<String> = JsonMissing.of() + private var s3Urls: JsonValue = JsonMissing.of() + private var serialized: JsonValue = JsonMissing.of() + private var shareToken: JsonField<String> = JsonMissing.of() + private var startTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var tags: JsonField<MutableList<String>>? = null + private var threadId: JsonField<String> = JsonMissing.of() + private var totalCost: JsonField<String> = JsonMissing.of() + private var totalTokens: JsonField<Long> = JsonMissing.of() + private var traceFirstReceivedAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var traceMaxStartTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var traceMinStartTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var traceTier: JsonField<TraceTier> = JsonMissing.of() + private var traceUpgrade: JsonField<Boolean> = JsonMissing.of() + private var ttlSeconds: JsonField<Long> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(runSchema: RunSchema) = apply { + id = runSchema.id + appPath = runSchema.appPath + dottedOrder = runSchema.dottedOrder + name = runSchema.name + runType = runSchema.runType + sessionId = runSchema.sessionId + status = runSchema.status + traceId = runSchema.traceId + childRunIds = runSchema.childRunIds.map { it.toMutableList() } + completionCost = runSchema.completionCost + completionCostDetails = runSchema.completionCostDetails + completionTokenDetails = runSchema.completionTokenDetails + completionTokens = runSchema.completionTokens + directChildRunIds = runSchema.directChildRunIds.map { it.toMutableList() } + endTime = runSchema.endTime + error = runSchema.error + events = runSchema.events.map { it.toMutableList() } + executionOrder = runSchema.executionOrder + extra = runSchema.extra + feedbackStats = runSchema.feedbackStats + firstTokenTime = runSchema.firstTokenTime + inDataset = runSchema.inDataset + inputs = runSchema.inputs + inputsPreview = runSchema.inputsPreview + inputsS3Urls = runSchema.inputsS3Urls + lastQueuedAt = runSchema.lastQueuedAt + manifestId = runSchema.manifestId + manifestS3Id = runSchema.manifestS3Id + outputs = runSchema.outputs + outputsPreview = runSchema.outputsPreview + outputsS3Urls = runSchema.outputsS3Urls + parentRunId = runSchema.parentRunId + parentRunIds = runSchema.parentRunIds.map { it.toMutableList() } + priceModelId = runSchema.priceModelId + promptCost = runSchema.promptCost + promptCostDetails = runSchema.promptCostDetails + promptTokenDetails = runSchema.promptTokenDetails + promptTokens = runSchema.promptTokens + referenceDatasetId = runSchema.referenceDatasetId + referenceExampleId = runSchema.referenceExampleId + s3Urls = runSchema.s3Urls + serialized = runSchema.serialized + shareToken = runSchema.shareToken + startTime = runSchema.startTime + tags = runSchema.tags.map { it.toMutableList() } + threadId = runSchema.threadId + totalCost = runSchema.totalCost + totalTokens = runSchema.totalTokens + traceFirstReceivedAt = runSchema.traceFirstReceivedAt + traceMaxStartTime = runSchema.traceMaxStartTime + traceMinStartTime = runSchema.traceMinStartTime + traceTier = runSchema.traceTier + traceUpgrade = runSchema.traceUpgrade + ttlSeconds = runSchema.ttlSeconds + additionalProperties = runSchema.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun appPath(appPath: String) = appPath(JsonField.of(appPath)) + + /** + * Sets [Builder.appPath] to an arbitrary JSON value. + * + * You should usually call [Builder.appPath] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun appPath(appPath: JsonField<String>) = apply { this.appPath = appPath } + + fun dottedOrder(dottedOrder: String) = dottedOrder(JsonField.of(dottedOrder)) + + /** + * Sets [Builder.dottedOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.dottedOrder] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dottedOrder(dottedOrder: JsonField<String>) = apply { this.dottedOrder = dottedOrder } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + /** Enum for run types. */ + fun runType(runType: RunTypeEnum) = runType(JsonField.of(runType)) + + /** + * Sets [Builder.runType] to an arbitrary JSON value. + * + * You should usually call [Builder.runType] with a well-typed [RunTypeEnum] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun runType(runType: JsonField<RunTypeEnum>) = apply { this.runType = runType } + + fun sessionId(sessionId: String) = sessionId(JsonField.of(sessionId)) + + /** + * Sets [Builder.sessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun sessionId(sessionId: JsonField<String>) = apply { this.sessionId = sessionId } + + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField<String>) = apply { this.status = status } + + fun traceId(traceId: String) = traceId(JsonField.of(traceId)) + + /** + * Sets [Builder.traceId] to an arbitrary JSON value. + * + * You should usually call [Builder.traceId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun traceId(traceId: JsonField<String>) = apply { this.traceId = traceId } + + fun childRunIds(childRunIds: List<String>?) = childRunIds(JsonField.ofNullable(childRunIds)) + + /** Alias for calling [Builder.childRunIds] with `childRunIds.orElse(null)`. */ + fun childRunIds(childRunIds: Optional<List<String>>) = childRunIds(childRunIds.getOrNull()) + + /** + * Sets [Builder.childRunIds] to an arbitrary JSON value. + * + * You should usually call [Builder.childRunIds] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun childRunIds(childRunIds: JsonField<List<String>>) = apply { + this.childRunIds = childRunIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [childRunIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChildRunId(childRunId: String) = apply { + childRunIds = + (childRunIds ?: JsonField.of(mutableListOf())).also { + checkKnown("childRunIds", it).add(childRunId) + } + } + + fun completionCost(completionCost: String?) = + completionCost(JsonField.ofNullable(completionCost)) + + /** Alias for calling [Builder.completionCost] with `completionCost.orElse(null)`. */ + fun completionCost(completionCost: Optional<String>) = + completionCost(completionCost.getOrNull()) + + /** + * Sets [Builder.completionCost] to an arbitrary JSON value. + * + * You should usually call [Builder.completionCost] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun completionCost(completionCost: JsonField<String>) = apply { + this.completionCost = completionCost + } + + fun completionCostDetails(completionCostDetails: CompletionCostDetails?) = + completionCostDetails(JsonField.ofNullable(completionCostDetails)) + + /** + * Alias for calling [Builder.completionCostDetails] with + * `completionCostDetails.orElse(null)`. + */ + fun completionCostDetails(completionCostDetails: Optional<CompletionCostDetails>) = + completionCostDetails(completionCostDetails.getOrNull()) + + /** + * Sets [Builder.completionCostDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.completionCostDetails] with a well-typed + * [CompletionCostDetails] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun completionCostDetails(completionCostDetails: JsonField<CompletionCostDetails>) = apply { + this.completionCostDetails = completionCostDetails + } + + fun completionTokenDetails(completionTokenDetails: CompletionTokenDetails?) = + completionTokenDetails(JsonField.ofNullable(completionTokenDetails)) + + /** + * Alias for calling [Builder.completionTokenDetails] with + * `completionTokenDetails.orElse(null)`. + */ + fun completionTokenDetails(completionTokenDetails: Optional<CompletionTokenDetails>) = + completionTokenDetails(completionTokenDetails.getOrNull()) + + /** + * Sets [Builder.completionTokenDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.completionTokenDetails] with a well-typed + * [CompletionTokenDetails] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun completionTokenDetails(completionTokenDetails: JsonField<CompletionTokenDetails>) = + apply { + this.completionTokenDetails = completionTokenDetails + } + + fun completionTokens(completionTokens: Long) = + completionTokens(JsonField.of(completionTokens)) + + /** + * Sets [Builder.completionTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.completionTokens] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun completionTokens(completionTokens: JsonField<Long>) = apply { + this.completionTokens = completionTokens + } + + fun directChildRunIds(directChildRunIds: List<String>?) = + directChildRunIds(JsonField.ofNullable(directChildRunIds)) + + /** Alias for calling [Builder.directChildRunIds] with `directChildRunIds.orElse(null)`. */ + fun directChildRunIds(directChildRunIds: Optional<List<String>>) = + directChildRunIds(directChildRunIds.getOrNull()) + + /** + * Sets [Builder.directChildRunIds] to an arbitrary JSON value. + * + * You should usually call [Builder.directChildRunIds] with a well-typed `List<String>` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun directChildRunIds(directChildRunIds: JsonField<List<String>>) = apply { + this.directChildRunIds = directChildRunIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [directChildRunIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addDirectChildRunId(directChildRunId: String) = apply { + directChildRunIds = + (directChildRunIds ?: JsonField.of(mutableListOf())).also { + checkKnown("directChildRunIds", it).add(directChildRunId) + } + } + + fun endTime(endTime: OffsetDateTime?) = endTime(JsonField.ofNullable(endTime)) + + /** Alias for calling [Builder.endTime] with `endTime.orElse(null)`. */ + fun endTime(endTime: Optional<OffsetDateTime>) = endTime(endTime.getOrNull()) + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endTime(endTime: JsonField<OffsetDateTime>) = apply { this.endTime = endTime } + + fun error(error: String?) = error(JsonField.ofNullable(error)) + + /** Alias for calling [Builder.error] with `error.orElse(null)`. */ + fun error(error: Optional<String>) = error(error.getOrNull()) + + /** + * Sets [Builder.error] to an arbitrary JSON value. + * + * You should usually call [Builder.error] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun error(error: JsonField<String>) = apply { this.error = error } + + fun events(events: List<JsonValue>?) = events(JsonField.ofNullable(events)) + + /** Alias for calling [Builder.events] with `events.orElse(null)`. */ + fun events(events: Optional<List<JsonValue>>) = events(events.getOrNull()) + + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed `List<JsonValue>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun events(events: JsonField<List<JsonValue>>) = apply { + this.events = events.map { it.toMutableList() } + } + + /** + * Adds a single [JsonValue] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvent(event: JsonValue) = apply { + events = + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) + } + } + + fun executionOrder(executionOrder: Long) = executionOrder(JsonField.of(executionOrder)) + + /** + * Sets [Builder.executionOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.executionOrder] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun executionOrder(executionOrder: JsonField<Long>) = apply { + this.executionOrder = executionOrder + } + + fun extra(extra: JsonValue) = apply { this.extra = extra } + + fun feedbackStats(feedbackStats: FeedbackStats?) = + feedbackStats(JsonField.ofNullable(feedbackStats)) + + /** Alias for calling [Builder.feedbackStats] with `feedbackStats.orElse(null)`. */ + fun feedbackStats(feedbackStats: Optional<FeedbackStats>) = + feedbackStats(feedbackStats.getOrNull()) + + /** + * Sets [Builder.feedbackStats] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackStats] with a well-typed [FeedbackStats] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun feedbackStats(feedbackStats: JsonField<FeedbackStats>) = apply { + this.feedbackStats = feedbackStats + } + + fun firstTokenTime(firstTokenTime: OffsetDateTime?) = + firstTokenTime(JsonField.ofNullable(firstTokenTime)) + + /** Alias for calling [Builder.firstTokenTime] with `firstTokenTime.orElse(null)`. */ + fun firstTokenTime(firstTokenTime: Optional<OffsetDateTime>) = + firstTokenTime(firstTokenTime.getOrNull()) + + /** + * Sets [Builder.firstTokenTime] to an arbitrary JSON value. + * + * You should usually call [Builder.firstTokenTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun firstTokenTime(firstTokenTime: JsonField<OffsetDateTime>) = apply { + this.firstTokenTime = firstTokenTime + } + + fun inDataset(inDataset: Boolean?) = inDataset(JsonField.ofNullable(inDataset)) + + /** + * Alias for [Builder.inDataset]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun inDataset(inDataset: Boolean) = inDataset(inDataset as Boolean?) + + /** Alias for calling [Builder.inDataset] with `inDataset.orElse(null)`. */ + fun inDataset(inDataset: Optional<Boolean>) = inDataset(inDataset.getOrNull()) + + /** + * Sets [Builder.inDataset] to an arbitrary JSON value. + * + * You should usually call [Builder.inDataset] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun inDataset(inDataset: JsonField<Boolean>) = apply { this.inDataset = inDataset } + + fun inputs(inputs: JsonValue) = apply { this.inputs = inputs } + + fun inputsPreview(inputsPreview: String?) = + inputsPreview(JsonField.ofNullable(inputsPreview)) + + /** Alias for calling [Builder.inputsPreview] with `inputsPreview.orElse(null)`. */ + fun inputsPreview(inputsPreview: Optional<String>) = + inputsPreview(inputsPreview.getOrNull()) + + /** + * Sets [Builder.inputsPreview] to an arbitrary JSON value. + * + * You should usually call [Builder.inputsPreview] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun inputsPreview(inputsPreview: JsonField<String>) = apply { + this.inputsPreview = inputsPreview + } + + fun inputsS3Urls(inputsS3Urls: JsonValue) = apply { this.inputsS3Urls = inputsS3Urls } + + fun lastQueuedAt(lastQueuedAt: OffsetDateTime?) = + lastQueuedAt(JsonField.ofNullable(lastQueuedAt)) + + /** Alias for calling [Builder.lastQueuedAt] with `lastQueuedAt.orElse(null)`. */ + fun lastQueuedAt(lastQueuedAt: Optional<OffsetDateTime>) = + lastQueuedAt(lastQueuedAt.getOrNull()) + + /** + * Sets [Builder.lastQueuedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.lastQueuedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lastQueuedAt(lastQueuedAt: JsonField<OffsetDateTime>) = apply { + this.lastQueuedAt = lastQueuedAt + } + + fun manifestId(manifestId: String?) = manifestId(JsonField.ofNullable(manifestId)) + + /** Alias for calling [Builder.manifestId] with `manifestId.orElse(null)`. */ + fun manifestId(manifestId: Optional<String>) = manifestId(manifestId.getOrNull()) + + /** + * Sets [Builder.manifestId] to an arbitrary JSON value. + * + * You should usually call [Builder.manifestId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun manifestId(manifestId: JsonField<String>) = apply { this.manifestId = manifestId } + + fun manifestS3Id(manifestS3Id: String?) = manifestS3Id(JsonField.ofNullable(manifestS3Id)) + + /** Alias for calling [Builder.manifestS3Id] with `manifestS3Id.orElse(null)`. */ + fun manifestS3Id(manifestS3Id: Optional<String>) = manifestS3Id(manifestS3Id.getOrNull()) + + /** + * Sets [Builder.manifestS3Id] to an arbitrary JSON value. + * + * You should usually call [Builder.manifestS3Id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun manifestS3Id(manifestS3Id: JsonField<String>) = apply { + this.manifestS3Id = manifestS3Id + } + + fun outputs(outputs: JsonValue) = apply { this.outputs = outputs } + + fun outputsPreview(outputsPreview: String?) = + outputsPreview(JsonField.ofNullable(outputsPreview)) + + /** Alias for calling [Builder.outputsPreview] with `outputsPreview.orElse(null)`. */ + fun outputsPreview(outputsPreview: Optional<String>) = + outputsPreview(outputsPreview.getOrNull()) + + /** + * Sets [Builder.outputsPreview] to an arbitrary JSON value. + * + * You should usually call [Builder.outputsPreview] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun outputsPreview(outputsPreview: JsonField<String>) = apply { + this.outputsPreview = outputsPreview + } + + fun outputsS3Urls(outputsS3Urls: JsonValue) = apply { this.outputsS3Urls = outputsS3Urls } + + fun parentRunId(parentRunId: String?) = parentRunId(JsonField.ofNullable(parentRunId)) + + /** Alias for calling [Builder.parentRunId] with `parentRunId.orElse(null)`. */ + fun parentRunId(parentRunId: Optional<String>) = parentRunId(parentRunId.getOrNull()) + + /** + * Sets [Builder.parentRunId] to an arbitrary JSON value. + * + * You should usually call [Builder.parentRunId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun parentRunId(parentRunId: JsonField<String>) = apply { this.parentRunId = parentRunId } + + fun parentRunIds(parentRunIds: List<String>?) = + parentRunIds(JsonField.ofNullable(parentRunIds)) + + /** Alias for calling [Builder.parentRunIds] with `parentRunIds.orElse(null)`. */ + fun parentRunIds(parentRunIds: Optional<List<String>>) = + parentRunIds(parentRunIds.getOrNull()) + + /** + * Sets [Builder.parentRunIds] to an arbitrary JSON value. + * + * You should usually call [Builder.parentRunIds] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun parentRunIds(parentRunIds: JsonField<List<String>>) = apply { + this.parentRunIds = parentRunIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [parentRunIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addParentRunId(parentRunId: String) = apply { + parentRunIds = + (parentRunIds ?: JsonField.of(mutableListOf())).also { + checkKnown("parentRunIds", it).add(parentRunId) + } + } + + fun priceModelId(priceModelId: String?) = priceModelId(JsonField.ofNullable(priceModelId)) + + /** Alias for calling [Builder.priceModelId] with `priceModelId.orElse(null)`. */ + fun priceModelId(priceModelId: Optional<String>) = priceModelId(priceModelId.getOrNull()) + + /** + * Sets [Builder.priceModelId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceModelId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun priceModelId(priceModelId: JsonField<String>) = apply { + this.priceModelId = priceModelId + } + + fun promptCost(promptCost: String?) = promptCost(JsonField.ofNullable(promptCost)) + + /** Alias for calling [Builder.promptCost] with `promptCost.orElse(null)`. */ + fun promptCost(promptCost: Optional<String>) = promptCost(promptCost.getOrNull()) + + /** + * Sets [Builder.promptCost] to an arbitrary JSON value. + * + * You should usually call [Builder.promptCost] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun promptCost(promptCost: JsonField<String>) = apply { this.promptCost = promptCost } + + fun promptCostDetails(promptCostDetails: PromptCostDetails?) = + promptCostDetails(JsonField.ofNullable(promptCostDetails)) + + /** Alias for calling [Builder.promptCostDetails] with `promptCostDetails.orElse(null)`. */ + fun promptCostDetails(promptCostDetails: Optional<PromptCostDetails>) = + promptCostDetails(promptCostDetails.getOrNull()) + + /** + * Sets [Builder.promptCostDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.promptCostDetails] with a well-typed [PromptCostDetails] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun promptCostDetails(promptCostDetails: JsonField<PromptCostDetails>) = apply { + this.promptCostDetails = promptCostDetails + } + + fun promptTokenDetails(promptTokenDetails: PromptTokenDetails?) = + promptTokenDetails(JsonField.ofNullable(promptTokenDetails)) + + /** + * Alias for calling [Builder.promptTokenDetails] with `promptTokenDetails.orElse(null)`. + */ + fun promptTokenDetails(promptTokenDetails: Optional<PromptTokenDetails>) = + promptTokenDetails(promptTokenDetails.getOrNull()) + + /** + * Sets [Builder.promptTokenDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.promptTokenDetails] with a well-typed + * [PromptTokenDetails] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun promptTokenDetails(promptTokenDetails: JsonField<PromptTokenDetails>) = apply { + this.promptTokenDetails = promptTokenDetails + } + + fun promptTokens(promptTokens: Long) = promptTokens(JsonField.of(promptTokens)) + + /** + * Sets [Builder.promptTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.promptTokens] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun promptTokens(promptTokens: JsonField<Long>) = apply { this.promptTokens = promptTokens } + + fun referenceDatasetId(referenceDatasetId: String?) = + referenceDatasetId(JsonField.ofNullable(referenceDatasetId)) + + /** + * Alias for calling [Builder.referenceDatasetId] with `referenceDatasetId.orElse(null)`. + */ + fun referenceDatasetId(referenceDatasetId: Optional<String>) = + referenceDatasetId(referenceDatasetId.getOrNull()) + + /** + * Sets [Builder.referenceDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceDatasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun referenceDatasetId(referenceDatasetId: JsonField<String>) = apply { + this.referenceDatasetId = referenceDatasetId + } + + fun referenceExampleId(referenceExampleId: String?) = + referenceExampleId(JsonField.ofNullable(referenceExampleId)) + + /** + * Alias for calling [Builder.referenceExampleId] with `referenceExampleId.orElse(null)`. + */ + fun referenceExampleId(referenceExampleId: Optional<String>) = + referenceExampleId(referenceExampleId.getOrNull()) + + /** + * Sets [Builder.referenceExampleId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceExampleId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun referenceExampleId(referenceExampleId: JsonField<String>) = apply { + this.referenceExampleId = referenceExampleId + } + + fun s3Urls(s3Urls: JsonValue) = apply { this.s3Urls = s3Urls } + + fun serialized(serialized: JsonValue) = apply { this.serialized = serialized } + + fun shareToken(shareToken: String?) = shareToken(JsonField.ofNullable(shareToken)) + + /** Alias for calling [Builder.shareToken] with `shareToken.orElse(null)`. */ + fun shareToken(shareToken: Optional<String>) = shareToken(shareToken.getOrNull()) + + /** + * Sets [Builder.shareToken] to an arbitrary JSON value. + * + * You should usually call [Builder.shareToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun shareToken(shareToken: JsonField<String>) = apply { this.shareToken = shareToken } + + fun startTime(startTime: OffsetDateTime) = startTime(JsonField.of(startTime)) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField<OffsetDateTime>) = apply { this.startTime = startTime } + + fun tags(tags: List<String>?) = tags(JsonField.ofNullable(tags)) + + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ + fun tags(tags: Optional<List<String>>) = tags(tags.getOrNull()) + + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List<String>` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tags(tags: JsonField<List<String>>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } + + fun threadId(threadId: String?) = threadId(JsonField.ofNullable(threadId)) + + /** Alias for calling [Builder.threadId] with `threadId.orElse(null)`. */ + fun threadId(threadId: Optional<String>) = threadId(threadId.getOrNull()) + + /** + * Sets [Builder.threadId] to an arbitrary JSON value. + * + * You should usually call [Builder.threadId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun threadId(threadId: JsonField<String>) = apply { this.threadId = threadId } + + fun totalCost(totalCost: String?) = totalCost(JsonField.ofNullable(totalCost)) + + /** Alias for calling [Builder.totalCost] with `totalCost.orElse(null)`. */ + fun totalCost(totalCost: Optional<String>) = totalCost(totalCost.getOrNull()) + + /** + * Sets [Builder.totalCost] to an arbitrary JSON value. + * + * You should usually call [Builder.totalCost] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun totalCost(totalCost: JsonField<String>) = apply { this.totalCost = totalCost } + + fun totalTokens(totalTokens: Long) = totalTokens(JsonField.of(totalTokens)) + + /** + * Sets [Builder.totalTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.totalTokens] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun totalTokens(totalTokens: JsonField<Long>) = apply { this.totalTokens = totalTokens } + + fun traceFirstReceivedAt(traceFirstReceivedAt: OffsetDateTime?) = + traceFirstReceivedAt(JsonField.ofNullable(traceFirstReceivedAt)) + + /** + * Alias for calling [Builder.traceFirstReceivedAt] with + * `traceFirstReceivedAt.orElse(null)`. + */ + fun traceFirstReceivedAt(traceFirstReceivedAt: Optional<OffsetDateTime>) = + traceFirstReceivedAt(traceFirstReceivedAt.getOrNull()) + + /** + * Sets [Builder.traceFirstReceivedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.traceFirstReceivedAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun traceFirstReceivedAt(traceFirstReceivedAt: JsonField<OffsetDateTime>) = apply { + this.traceFirstReceivedAt = traceFirstReceivedAt + } + + fun traceMaxStartTime(traceMaxStartTime: OffsetDateTime?) = + traceMaxStartTime(JsonField.ofNullable(traceMaxStartTime)) + + /** Alias for calling [Builder.traceMaxStartTime] with `traceMaxStartTime.orElse(null)`. */ + fun traceMaxStartTime(traceMaxStartTime: Optional<OffsetDateTime>) = + traceMaxStartTime(traceMaxStartTime.getOrNull()) + + /** + * Sets [Builder.traceMaxStartTime] to an arbitrary JSON value. + * + * You should usually call [Builder.traceMaxStartTime] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun traceMaxStartTime(traceMaxStartTime: JsonField<OffsetDateTime>) = apply { + this.traceMaxStartTime = traceMaxStartTime + } + + fun traceMinStartTime(traceMinStartTime: OffsetDateTime?) = + traceMinStartTime(JsonField.ofNullable(traceMinStartTime)) + + /** Alias for calling [Builder.traceMinStartTime] with `traceMinStartTime.orElse(null)`. */ + fun traceMinStartTime(traceMinStartTime: Optional<OffsetDateTime>) = + traceMinStartTime(traceMinStartTime.getOrNull()) + + /** + * Sets [Builder.traceMinStartTime] to an arbitrary JSON value. + * + * You should usually call [Builder.traceMinStartTime] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun traceMinStartTime(traceMinStartTime: JsonField<OffsetDateTime>) = apply { + this.traceMinStartTime = traceMinStartTime + } + + fun traceTier(traceTier: TraceTier?) = traceTier(JsonField.ofNullable(traceTier)) + + /** Alias for calling [Builder.traceTier] with `traceTier.orElse(null)`. */ + fun traceTier(traceTier: Optional<TraceTier>) = traceTier(traceTier.getOrNull()) + + /** + * Sets [Builder.traceTier] to an arbitrary JSON value. + * + * You should usually call [Builder.traceTier] with a well-typed [TraceTier] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun traceTier(traceTier: JsonField<TraceTier>) = apply { this.traceTier = traceTier } + + fun traceUpgrade(traceUpgrade: Boolean) = traceUpgrade(JsonField.of(traceUpgrade)) + + /** + * Sets [Builder.traceUpgrade] to an arbitrary JSON value. + * + * You should usually call [Builder.traceUpgrade] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun traceUpgrade(traceUpgrade: JsonField<Boolean>) = apply { + this.traceUpgrade = traceUpgrade + } + + fun ttlSeconds(ttlSeconds: Long?) = ttlSeconds(JsonField.ofNullable(ttlSeconds)) + + /** + * Alias for [Builder.ttlSeconds]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun ttlSeconds(ttlSeconds: Long) = ttlSeconds(ttlSeconds as Long?) + + /** Alias for calling [Builder.ttlSeconds] with `ttlSeconds.orElse(null)`. */ + fun ttlSeconds(ttlSeconds: Optional<Long>) = ttlSeconds(ttlSeconds.getOrNull()) + + /** + * Sets [Builder.ttlSeconds] to an arbitrary JSON value. + * + * You should usually call [Builder.ttlSeconds] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun ttlSeconds(ttlSeconds: JsonField<Long>) = apply { this.ttlSeconds = ttlSeconds } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RunSchema]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .appPath() + * .dottedOrder() + * .name() + * .runType() + * .sessionId() + * .status() + * .traceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RunSchema = + RunSchema( + checkRequired("id", id), + checkRequired("appPath", appPath), + checkRequired("dottedOrder", dottedOrder), + checkRequired("name", name), + checkRequired("runType", runType), + checkRequired("sessionId", sessionId), + checkRequired("status", status), + checkRequired("traceId", traceId), + (childRunIds ?: JsonMissing.of()).map { it.toImmutable() }, + completionCost, + completionCostDetails, + completionTokenDetails, + completionTokens, + (directChildRunIds ?: JsonMissing.of()).map { it.toImmutable() }, + endTime, + error, + (events ?: JsonMissing.of()).map { it.toImmutable() }, + executionOrder, + extra, + feedbackStats, + firstTokenTime, + inDataset, + inputs, + inputsPreview, + inputsS3Urls, + lastQueuedAt, + manifestId, + manifestS3Id, + outputs, + outputsPreview, + outputsS3Urls, + parentRunId, + (parentRunIds ?: JsonMissing.of()).map { it.toImmutable() }, + priceModelId, + promptCost, + promptCostDetails, + promptTokenDetails, + promptTokens, + referenceDatasetId, + referenceExampleId, + s3Urls, + serialized, + shareToken, + startTime, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + threadId, + totalCost, + totalTokens, + traceFirstReceivedAt, + traceMaxStartTime, + traceMinStartTime, + traceTier, + traceUpgrade, + ttlSeconds, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RunSchema = apply { + if (validated) { + return@apply + } + + id() + appPath() + dottedOrder() + name() + runType().validate() + sessionId() + status() + traceId() + childRunIds() + completionCost() + completionCostDetails().ifPresent { it.validate() } + completionTokenDetails().ifPresent { it.validate() } + completionTokens() + directChildRunIds() + endTime() + error() + events() + executionOrder() + feedbackStats().ifPresent { it.validate() } + firstTokenTime() + inDataset() + inputsPreview() + lastQueuedAt() + manifestId() + manifestS3Id() + outputsPreview() + parentRunId() + parentRunIds() + priceModelId() + promptCost() + promptCostDetails().ifPresent { it.validate() } + promptTokenDetails().ifPresent { it.validate() } + promptTokens() + referenceDatasetId() + referenceExampleId() + shareToken() + startTime() + tags() + threadId() + totalCost() + totalTokens() + traceFirstReceivedAt() + traceMaxStartTime() + traceMinStartTime() + traceTier().ifPresent { it.validate() } + traceUpgrade() + ttlSeconds() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (appPath.asKnown().isPresent) 1 else 0) + + (if (dottedOrder.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (runType.asKnown().getOrNull()?.validity() ?: 0) + + (if (sessionId.asKnown().isPresent) 1 else 0) + + (if (status.asKnown().isPresent) 1 else 0) + + (if (traceId.asKnown().isPresent) 1 else 0) + + (childRunIds.asKnown().getOrNull()?.size ?: 0) + + (if (completionCost.asKnown().isPresent) 1 else 0) + + (completionCostDetails.asKnown().getOrNull()?.validity() ?: 0) + + (completionTokenDetails.asKnown().getOrNull()?.validity() ?: 0) + + (if (completionTokens.asKnown().isPresent) 1 else 0) + + (directChildRunIds.asKnown().getOrNull()?.size ?: 0) + + (if (endTime.asKnown().isPresent) 1 else 0) + + (if (error.asKnown().isPresent) 1 else 0) + + (events.asKnown().getOrNull()?.size ?: 0) + + (if (executionOrder.asKnown().isPresent) 1 else 0) + + (feedbackStats.asKnown().getOrNull()?.validity() ?: 0) + + (if (firstTokenTime.asKnown().isPresent) 1 else 0) + + (if (inDataset.asKnown().isPresent) 1 else 0) + + (if (inputsPreview.asKnown().isPresent) 1 else 0) + + (if (lastQueuedAt.asKnown().isPresent) 1 else 0) + + (if (manifestId.asKnown().isPresent) 1 else 0) + + (if (manifestS3Id.asKnown().isPresent) 1 else 0) + + (if (outputsPreview.asKnown().isPresent) 1 else 0) + + (if (parentRunId.asKnown().isPresent) 1 else 0) + + (parentRunIds.asKnown().getOrNull()?.size ?: 0) + + (if (priceModelId.asKnown().isPresent) 1 else 0) + + (if (promptCost.asKnown().isPresent) 1 else 0) + + (promptCostDetails.asKnown().getOrNull()?.validity() ?: 0) + + (promptTokenDetails.asKnown().getOrNull()?.validity() ?: 0) + + (if (promptTokens.asKnown().isPresent) 1 else 0) + + (if (referenceDatasetId.asKnown().isPresent) 1 else 0) + + (if (referenceExampleId.asKnown().isPresent) 1 else 0) + + (if (shareToken.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + (tags.asKnown().getOrNull()?.size ?: 0) + + (if (threadId.asKnown().isPresent) 1 else 0) + + (if (totalCost.asKnown().isPresent) 1 else 0) + + (if (totalTokens.asKnown().isPresent) 1 else 0) + + (if (traceFirstReceivedAt.asKnown().isPresent) 1 else 0) + + (if (traceMaxStartTime.asKnown().isPresent) 1 else 0) + + (if (traceMinStartTime.asKnown().isPresent) 1 else 0) + + (traceTier.asKnown().getOrNull()?.validity() ?: 0) + + (if (traceUpgrade.asKnown().isPresent) 1 else 0) + + (if (ttlSeconds.asKnown().isPresent) 1 else 0) + + class CompletionCostDetails + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompletionCostDetails]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CompletionCostDetails]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(completionCostDetails: CompletionCostDetails) = apply { + additionalProperties = completionCostDetails.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompletionCostDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CompletionCostDetails = + CompletionCostDetails(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): CompletionCostDetails = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompletionCostDetails && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompletionCostDetails{additionalProperties=$additionalProperties}" + } + + class CompletionTokenDetails + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompletionTokenDetails]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CompletionTokenDetails]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(completionTokenDetails: CompletionTokenDetails) = apply { + additionalProperties = completionTokenDetails.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompletionTokenDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CompletionTokenDetails = + CompletionTokenDetails(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): CompletionTokenDetails = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompletionTokenDetails && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompletionTokenDetails{additionalProperties=$additionalProperties}" + } + + class FeedbackStats + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [FeedbackStats]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackStats]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(feedbackStats: FeedbackStats) = apply { + additionalProperties = feedbackStats.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FeedbackStats]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FeedbackStats = FeedbackStats(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): FeedbackStats = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackStats && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "FeedbackStats{additionalProperties=$additionalProperties}" + } + + class PromptCostDetails + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [PromptCostDetails]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PromptCostDetails]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(promptCostDetails: PromptCostDetails) = apply { + additionalProperties = promptCostDetails.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PromptCostDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PromptCostDetails = PromptCostDetails(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): PromptCostDetails = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PromptCostDetails && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "PromptCostDetails{additionalProperties=$additionalProperties}" + } + + class PromptTokenDetails + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [PromptTokenDetails]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PromptTokenDetails]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(promptTokenDetails: PromptTokenDetails) = apply { + additionalProperties = promptTokenDetails.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PromptTokenDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PromptTokenDetails = PromptTokenDetails(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): PromptTokenDetails = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PromptTokenDetails && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "PromptTokenDetails{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunSchema && + id == other.id && + appPath == other.appPath && + dottedOrder == other.dottedOrder && + name == other.name && + runType == other.runType && + sessionId == other.sessionId && + status == other.status && + traceId == other.traceId && + childRunIds == other.childRunIds && + completionCost == other.completionCost && + completionCostDetails == other.completionCostDetails && + completionTokenDetails == other.completionTokenDetails && + completionTokens == other.completionTokens && + directChildRunIds == other.directChildRunIds && + endTime == other.endTime && + error == other.error && + events == other.events && + executionOrder == other.executionOrder && + extra == other.extra && + feedbackStats == other.feedbackStats && + firstTokenTime == other.firstTokenTime && + inDataset == other.inDataset && + inputs == other.inputs && + inputsPreview == other.inputsPreview && + inputsS3Urls == other.inputsS3Urls && + lastQueuedAt == other.lastQueuedAt && + manifestId == other.manifestId && + manifestS3Id == other.manifestS3Id && + outputs == other.outputs && + outputsPreview == other.outputsPreview && + outputsS3Urls == other.outputsS3Urls && + parentRunId == other.parentRunId && + parentRunIds == other.parentRunIds && + priceModelId == other.priceModelId && + promptCost == other.promptCost && + promptCostDetails == other.promptCostDetails && + promptTokenDetails == other.promptTokenDetails && + promptTokens == other.promptTokens && + referenceDatasetId == other.referenceDatasetId && + referenceExampleId == other.referenceExampleId && + s3Urls == other.s3Urls && + serialized == other.serialized && + shareToken == other.shareToken && + startTime == other.startTime && + tags == other.tags && + threadId == other.threadId && + totalCost == other.totalCost && + totalTokens == other.totalTokens && + traceFirstReceivedAt == other.traceFirstReceivedAt && + traceMaxStartTime == other.traceMaxStartTime && + traceMinStartTime == other.traceMinStartTime && + traceTier == other.traceTier && + traceUpgrade == other.traceUpgrade && + ttlSeconds == other.ttlSeconds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + appPath, + dottedOrder, + name, + runType, + sessionId, + status, + traceId, + childRunIds, + completionCost, + completionCostDetails, + completionTokenDetails, + completionTokens, + directChildRunIds, + endTime, + error, + events, + executionOrder, + extra, + feedbackStats, + firstTokenTime, + inDataset, + inputs, + inputsPreview, + inputsS3Urls, + lastQueuedAt, + manifestId, + manifestS3Id, + outputs, + outputsPreview, + outputsS3Urls, + parentRunId, + parentRunIds, + priceModelId, + promptCost, + promptCostDetails, + promptTokenDetails, + promptTokens, + referenceDatasetId, + referenceExampleId, + s3Urls, + serialized, + shareToken, + startTime, + tags, + threadId, + totalCost, + totalTokens, + traceFirstReceivedAt, + traceMaxStartTime, + traceMinStartTime, + traceTier, + traceUpgrade, + ttlSeconds, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RunSchema{id=$id, appPath=$appPath, dottedOrder=$dottedOrder, name=$name, runType=$runType, sessionId=$sessionId, status=$status, traceId=$traceId, childRunIds=$childRunIds, completionCost=$completionCost, completionCostDetails=$completionCostDetails, completionTokenDetails=$completionTokenDetails, completionTokens=$completionTokens, directChildRunIds=$directChildRunIds, endTime=$endTime, error=$error, events=$events, executionOrder=$executionOrder, extra=$extra, feedbackStats=$feedbackStats, firstTokenTime=$firstTokenTime, inDataset=$inDataset, inputs=$inputs, inputsPreview=$inputsPreview, inputsS3Urls=$inputsS3Urls, lastQueuedAt=$lastQueuedAt, manifestId=$manifestId, manifestS3Id=$manifestS3Id, outputs=$outputs, outputsPreview=$outputsPreview, outputsS3Urls=$outputsS3Urls, parentRunId=$parentRunId, parentRunIds=$parentRunIds, priceModelId=$priceModelId, promptCost=$promptCost, promptCostDetails=$promptCostDetails, promptTokenDetails=$promptTokenDetails, promptTokens=$promptTokens, referenceDatasetId=$referenceDatasetId, referenceExampleId=$referenceExampleId, s3Urls=$s3Urls, serialized=$serialized, shareToken=$shareToken, startTime=$startTime, tags=$tags, threadId=$threadId, totalCost=$totalCost, totalTokens=$totalTokens, traceFirstReceivedAt=$traceFirstReceivedAt, traceMaxStartTime=$traceMaxStartTime, traceMinStartTime=$traceMinStartTime, traceTier=$traceTier, traceUpgrade=$traceUpgrade, ttlSeconds=$ttlSeconds, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunStatsParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunStatsParams.kt new file mode 100644 index 00000000..86784b03 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunStatsParams.kt @@ -0,0 +1,206 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** Get all runs by query in body payload. */ +class RunStatsParams +private constructor( + private val runStatsQueryParams: RunStatsQueryParams, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Query params for run stats. */ + fun runStatsQueryParams(): RunStatsQueryParams = runStatsQueryParams + + fun _additionalBodyProperties(): Map<String, JsonValue> = + runStatsQueryParams._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RunStatsParams]. + * + * The following fields are required: + * ```java + * .runStatsQueryParams() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunStatsParams]. */ + class Builder internal constructor() { + + private var runStatsQueryParams: RunStatsQueryParams? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(runStatsParams: RunStatsParams) = apply { + runStatsQueryParams = runStatsParams.runStatsQueryParams + additionalHeaders = runStatsParams.additionalHeaders.toBuilder() + additionalQueryParams = runStatsParams.additionalQueryParams.toBuilder() + } + + /** Query params for run stats. */ + fun runStatsQueryParams(runStatsQueryParams: RunStatsQueryParams) = apply { + this.runStatsQueryParams = runStatsQueryParams + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RunStatsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .runStatsQueryParams() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RunStatsParams = + RunStatsParams( + checkRequired("runStatsQueryParams", runStatsQueryParams), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): RunStatsQueryParams = runStatsQueryParams + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunStatsParams && + runStatsQueryParams == other.runStatsQueryParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(runStatsQueryParams, additionalHeaders, additionalQueryParams) + + override fun toString() = + "RunStatsParams{runStatsQueryParams=$runStatsQueryParams, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunStatsQueryParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunStatsQueryParams.kt new file mode 100644 index 00000000..ed86b33a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunStatsQueryParams.kt @@ -0,0 +1,1428 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs + +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.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.sessions.RunStatsGroupBy +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Query params for run stats. */ +class RunStatsQueryParams +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<List<String>>, + private val dataSourceType: JsonField<RunsFilterDataSourceTypeEnum>, + private val endTime: JsonField<OffsetDateTime>, + private val error: JsonField<Boolean>, + private val executionOrder: JsonField<Long>, + private val filter: JsonField<String>, + private val groupBy: JsonField<RunStatsGroupBy>, + private val groups: JsonField<List<String?>>, + private val isRoot: JsonField<Boolean>, + private val parentRun: JsonField<String>, + private val query: JsonField<String>, + private val referenceExample: JsonField<List<String>>, + private val runType: JsonField<RunTypeEnum>, + private val searchFilter: JsonField<String>, + private val select: JsonField<List<Select>>, + private val session: JsonField<List<String>>, + private val skipPagination: JsonField<Boolean>, + private val startTime: JsonField<OffsetDateTime>, + private val trace: JsonField<String>, + private val traceFilter: JsonField<String>, + private val treeFilter: JsonField<String>, + private val useExperimentalSearch: JsonField<Boolean>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("data_source_type") + @ExcludeMissing + dataSourceType: JsonField<RunsFilterDataSourceTypeEnum> = JsonMissing.of(), + @JsonProperty("end_time") + @ExcludeMissing + endTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("error") @ExcludeMissing error: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("execution_order") + @ExcludeMissing + executionOrder: JsonField<Long> = JsonMissing.of(), + @JsonProperty("filter") @ExcludeMissing filter: JsonField<String> = JsonMissing.of(), + @JsonProperty("group_by") + @ExcludeMissing + groupBy: JsonField<RunStatsGroupBy> = JsonMissing.of(), + @JsonProperty("groups") @ExcludeMissing groups: JsonField<List<String?>> = JsonMissing.of(), + @JsonProperty("is_root") @ExcludeMissing isRoot: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("parent_run") @ExcludeMissing parentRun: JsonField<String> = JsonMissing.of(), + @JsonProperty("query") @ExcludeMissing query: JsonField<String> = JsonMissing.of(), + @JsonProperty("reference_example") + @ExcludeMissing + referenceExample: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("run_type") + @ExcludeMissing + runType: JsonField<RunTypeEnum> = JsonMissing.of(), + @JsonProperty("search_filter") + @ExcludeMissing + searchFilter: JsonField<String> = JsonMissing.of(), + @JsonProperty("select") @ExcludeMissing select: JsonField<List<Select>> = JsonMissing.of(), + @JsonProperty("session") + @ExcludeMissing + session: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("skip_pagination") + @ExcludeMissing + skipPagination: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("trace") @ExcludeMissing trace: JsonField<String> = JsonMissing.of(), + @JsonProperty("trace_filter") + @ExcludeMissing + traceFilter: JsonField<String> = JsonMissing.of(), + @JsonProperty("tree_filter") + @ExcludeMissing + treeFilter: JsonField<String> = JsonMissing.of(), + @JsonProperty("use_experimental_search") + @ExcludeMissing + useExperimentalSearch: JsonField<Boolean> = JsonMissing.of(), + ) : this( + id, + dataSourceType, + endTime, + error, + executionOrder, + filter, + groupBy, + groups, + isRoot, + parentRun, + query, + referenceExample, + runType, + searchFilter, + select, + session, + skipPagination, + startTime, + trace, + traceFilter, + treeFilter, + useExperimentalSearch, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional<List<String>> = id.getOptional("id") + + /** + * Enum for run data source types. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dataSourceType(): Optional<RunsFilterDataSourceTypeEnum> = + dataSourceType.getOptional("data_source_type") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endTime(): Optional<OffsetDateTime> = endTime.getOptional("end_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun error(): Optional<Boolean> = error.getOptional("error") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun executionOrder(): Optional<Long> = executionOrder.getOptional("execution_order") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun filter(): Optional<String> = filter.getOptional("filter") + + /** + * Group by param for run stats. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun groupBy(): Optional<RunStatsGroupBy> = groupBy.getOptional("group_by") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun groups(): Optional<List<String?>> = groups.getOptional("groups") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun isRoot(): Optional<Boolean> = isRoot.getOptional("is_root") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun parentRun(): Optional<String> = parentRun.getOptional("parent_run") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun query(): Optional<String> = query.getOptional("query") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceExample(): Optional<List<String>> = + referenceExample.getOptional("reference_example") + + /** + * Enum for run types. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun runType(): Optional<RunTypeEnum> = runType.getOptional("run_type") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun searchFilter(): Optional<String> = searchFilter.getOptional("search_filter") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun select(): Optional<List<Select>> = select.getOptional("select") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun session(): Optional<List<String>> = session.getOptional("session") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun skipPagination(): Optional<Boolean> = skipPagination.getOptional("skip_pagination") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun startTime(): Optional<OffsetDateTime> = startTime.getOptional("start_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun trace(): Optional<String> = trace.getOptional("trace") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun traceFilter(): Optional<String> = traceFilter.getOptional("trace_filter") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun treeFilter(): Optional<String> = treeFilter.getOptional("tree_filter") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun useExperimentalSearch(): Optional<Boolean> = + useExperimentalSearch.getOptional("use_experimental_search") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<List<String>> = id + + /** + * Returns the raw JSON value of [dataSourceType]. + * + * Unlike [dataSourceType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data_source_type") + @ExcludeMissing + fun _dataSourceType(): JsonField<RunsFilterDataSourceTypeEnum> = dataSourceType + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_time") @ExcludeMissing fun _endTime(): JsonField<OffsetDateTime> = endTime + + /** + * Returns the raw JSON value of [error]. + * + * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("error") @ExcludeMissing fun _error(): JsonField<Boolean> = error + + /** + * Returns the raw JSON value of [executionOrder]. + * + * Unlike [executionOrder], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("execution_order") + @ExcludeMissing + fun _executionOrder(): JsonField<Long> = executionOrder + + /** + * Returns the raw JSON value of [filter]. + * + * Unlike [filter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField<String> = filter + + /** + * Returns the raw JSON value of [groupBy]. + * + * Unlike [groupBy], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("group_by") @ExcludeMissing fun _groupBy(): JsonField<RunStatsGroupBy> = groupBy + + /** + * Returns the raw JSON value of [groups]. + * + * Unlike [groups], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("groups") @ExcludeMissing fun _groups(): JsonField<List<String?>> = groups + + /** + * Returns the raw JSON value of [isRoot]. + * + * Unlike [isRoot], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_root") @ExcludeMissing fun _isRoot(): JsonField<Boolean> = isRoot + + /** + * Returns the raw JSON value of [parentRun]. + * + * Unlike [parentRun], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("parent_run") @ExcludeMissing fun _parentRun(): JsonField<String> = parentRun + + /** + * Returns the raw JSON value of [query]. + * + * Unlike [query], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("query") @ExcludeMissing fun _query(): JsonField<String> = query + + /** + * Returns the raw JSON value of [referenceExample]. + * + * Unlike [referenceExample], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reference_example") + @ExcludeMissing + fun _referenceExample(): JsonField<List<String>> = referenceExample + + /** + * Returns the raw JSON value of [runType]. + * + * Unlike [runType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_type") @ExcludeMissing fun _runType(): JsonField<RunTypeEnum> = runType + + /** + * Returns the raw JSON value of [searchFilter]. + * + * Unlike [searchFilter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("search_filter") + @ExcludeMissing + fun _searchFilter(): JsonField<String> = searchFilter + + /** + * Returns the raw JSON value of [select]. + * + * Unlike [select], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("select") @ExcludeMissing fun _select(): JsonField<List<Select>> = select + + /** + * Returns the raw JSON value of [session]. + * + * Unlike [session], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session") @ExcludeMissing fun _session(): JsonField<List<String>> = session + + /** + * Returns the raw JSON value of [skipPagination]. + * + * Unlike [skipPagination], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("skip_pagination") + @ExcludeMissing + fun _skipPagination(): JsonField<Boolean> = skipPagination + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_time") + @ExcludeMissing + fun _startTime(): JsonField<OffsetDateTime> = startTime + + /** + * Returns the raw JSON value of [trace]. + * + * Unlike [trace], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trace") @ExcludeMissing fun _trace(): JsonField<String> = trace + + /** + * Returns the raw JSON value of [traceFilter]. + * + * Unlike [traceFilter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trace_filter") + @ExcludeMissing + fun _traceFilter(): JsonField<String> = traceFilter + + /** + * Returns the raw JSON value of [treeFilter]. + * + * Unlike [treeFilter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tree_filter") @ExcludeMissing fun _treeFilter(): JsonField<String> = treeFilter + + /** + * Returns the raw JSON value of [useExperimentalSearch]. + * + * Unlike [useExperimentalSearch], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("use_experimental_search") + @ExcludeMissing + fun _useExperimentalSearch(): JsonField<Boolean> = useExperimentalSearch + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [RunStatsQueryParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunStatsQueryParams]. */ + class Builder internal constructor() { + + private var id: JsonField<MutableList<String>>? = null + private var dataSourceType: JsonField<RunsFilterDataSourceTypeEnum> = JsonMissing.of() + private var endTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var error: JsonField<Boolean> = JsonMissing.of() + private var executionOrder: JsonField<Long> = JsonMissing.of() + private var filter: JsonField<String> = JsonMissing.of() + private var groupBy: JsonField<RunStatsGroupBy> = JsonMissing.of() + private var groups: JsonField<MutableList<String?>>? = null + private var isRoot: JsonField<Boolean> = JsonMissing.of() + private var parentRun: JsonField<String> = JsonMissing.of() + private var query: JsonField<String> = JsonMissing.of() + private var referenceExample: JsonField<MutableList<String>>? = null + private var runType: JsonField<RunTypeEnum> = JsonMissing.of() + private var searchFilter: JsonField<String> = JsonMissing.of() + private var select: JsonField<MutableList<Select>>? = null + private var session: JsonField<MutableList<String>>? = null + private var skipPagination: JsonField<Boolean> = JsonMissing.of() + private var startTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var trace: JsonField<String> = JsonMissing.of() + private var traceFilter: JsonField<String> = JsonMissing.of() + private var treeFilter: JsonField<String> = JsonMissing.of() + private var useExperimentalSearch: JsonField<Boolean> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(runStatsQueryParams: RunStatsQueryParams) = apply { + id = runStatsQueryParams.id.map { it.toMutableList() } + dataSourceType = runStatsQueryParams.dataSourceType + endTime = runStatsQueryParams.endTime + error = runStatsQueryParams.error + executionOrder = runStatsQueryParams.executionOrder + filter = runStatsQueryParams.filter + groupBy = runStatsQueryParams.groupBy + groups = runStatsQueryParams.groups.map { it.toMutableList() } + isRoot = runStatsQueryParams.isRoot + parentRun = runStatsQueryParams.parentRun + query = runStatsQueryParams.query + referenceExample = runStatsQueryParams.referenceExample.map { it.toMutableList() } + runType = runStatsQueryParams.runType + searchFilter = runStatsQueryParams.searchFilter + select = runStatsQueryParams.select.map { it.toMutableList() } + session = runStatsQueryParams.session.map { it.toMutableList() } + skipPagination = runStatsQueryParams.skipPagination + startTime = runStatsQueryParams.startTime + trace = runStatsQueryParams.trace + traceFilter = runStatsQueryParams.traceFilter + treeFilter = runStatsQueryParams.treeFilter + useExperimentalSearch = runStatsQueryParams.useExperimentalSearch + additionalProperties = runStatsQueryParams.additionalProperties.toMutableMap() + } + + fun id(id: List<String>?) = id(JsonField.ofNullable(id)) + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<List<String>>) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed `List<String>` value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<List<String>>) = apply { this.id = id.map { it.toMutableList() } } + + /** + * Adds a single [String] to [Builder.id]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addId(id: String) = apply { + this.id = + (this.id ?: JsonField.of(mutableListOf())).also { checkKnown("id", it).add(id) } + } + + /** Enum for run data source types. */ + fun dataSourceType(dataSourceType: RunsFilterDataSourceTypeEnum?) = + dataSourceType(JsonField.ofNullable(dataSourceType)) + + /** Alias for calling [Builder.dataSourceType] with `dataSourceType.orElse(null)`. */ + fun dataSourceType(dataSourceType: Optional<RunsFilterDataSourceTypeEnum>) = + dataSourceType(dataSourceType.getOrNull()) + + /** + * Sets [Builder.dataSourceType] to an arbitrary JSON value. + * + * You should usually call [Builder.dataSourceType] with a well-typed + * [RunsFilterDataSourceTypeEnum] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun dataSourceType(dataSourceType: JsonField<RunsFilterDataSourceTypeEnum>) = apply { + this.dataSourceType = dataSourceType + } + + fun endTime(endTime: OffsetDateTime?) = endTime(JsonField.ofNullable(endTime)) + + /** Alias for calling [Builder.endTime] with `endTime.orElse(null)`. */ + fun endTime(endTime: Optional<OffsetDateTime>) = endTime(endTime.getOrNull()) + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endTime(endTime: JsonField<OffsetDateTime>) = apply { this.endTime = endTime } + + fun error(error: Boolean?) = error(JsonField.ofNullable(error)) + + /** + * Alias for [Builder.error]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun error(error: Boolean) = error(error as Boolean?) + + /** Alias for calling [Builder.error] with `error.orElse(null)`. */ + fun error(error: Optional<Boolean>) = error(error.getOrNull()) + + /** + * Sets [Builder.error] to an arbitrary JSON value. + * + * You should usually call [Builder.error] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun error(error: JsonField<Boolean>) = apply { this.error = error } + + fun executionOrder(executionOrder: Long?) = + executionOrder(JsonField.ofNullable(executionOrder)) + + /** + * Alias for [Builder.executionOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun executionOrder(executionOrder: Long) = executionOrder(executionOrder as Long?) + + /** Alias for calling [Builder.executionOrder] with `executionOrder.orElse(null)`. */ + fun executionOrder(executionOrder: Optional<Long>) = + executionOrder(executionOrder.getOrNull()) + + /** + * Sets [Builder.executionOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.executionOrder] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun executionOrder(executionOrder: JsonField<Long>) = apply { + this.executionOrder = executionOrder + } + + fun filter(filter: String?) = filter(JsonField.ofNullable(filter)) + + /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ + fun filter(filter: Optional<String>) = filter(filter.getOrNull()) + + /** + * Sets [Builder.filter] to an arbitrary JSON value. + * + * You should usually call [Builder.filter] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun filter(filter: JsonField<String>) = apply { this.filter = filter } + + /** Group by param for run stats. */ + fun groupBy(groupBy: RunStatsGroupBy?) = groupBy(JsonField.ofNullable(groupBy)) + + /** Alias for calling [Builder.groupBy] with `groupBy.orElse(null)`. */ + fun groupBy(groupBy: Optional<RunStatsGroupBy>) = groupBy(groupBy.getOrNull()) + + /** + * Sets [Builder.groupBy] to an arbitrary JSON value. + * + * You should usually call [Builder.groupBy] with a well-typed [RunStatsGroupBy] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupBy(groupBy: JsonField<RunStatsGroupBy>) = apply { this.groupBy = groupBy } + + fun groups(groups: List<String?>?) = groups(JsonField.ofNullable(groups)) + + /** Alias for calling [Builder.groups] with `groups.orElse(null)`. */ + fun groups(groups: Optional<List<String?>>) = groups(groups.getOrNull()) + + /** + * Sets [Builder.groups] to an arbitrary JSON value. + * + * You should usually call [Builder.groups] with a well-typed `List<String?>` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groups(groups: JsonField<List<String?>>) = apply { + this.groups = groups.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [groups]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addGroup(group: String) = apply { + groups = + (groups ?: JsonField.of(mutableListOf())).also { + checkKnown("groups", it).add(group) + } + } + + fun isRoot(isRoot: Boolean?) = isRoot(JsonField.ofNullable(isRoot)) + + /** + * Alias for [Builder.isRoot]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun isRoot(isRoot: Boolean) = isRoot(isRoot as Boolean?) + + /** Alias for calling [Builder.isRoot] with `isRoot.orElse(null)`. */ + fun isRoot(isRoot: Optional<Boolean>) = isRoot(isRoot.getOrNull()) + + /** + * Sets [Builder.isRoot] to an arbitrary JSON value. + * + * You should usually call [Builder.isRoot] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun isRoot(isRoot: JsonField<Boolean>) = apply { this.isRoot = isRoot } + + fun parentRun(parentRun: String?) = parentRun(JsonField.ofNullable(parentRun)) + + /** Alias for calling [Builder.parentRun] with `parentRun.orElse(null)`. */ + fun parentRun(parentRun: Optional<String>) = parentRun(parentRun.getOrNull()) + + /** + * Sets [Builder.parentRun] to an arbitrary JSON value. + * + * You should usually call [Builder.parentRun] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun parentRun(parentRun: JsonField<String>) = apply { this.parentRun = parentRun } + + fun query(query: String?) = query(JsonField.ofNullable(query)) + + /** Alias for calling [Builder.query] with `query.orElse(null)`. */ + fun query(query: Optional<String>) = query(query.getOrNull()) + + /** + * Sets [Builder.query] to an arbitrary JSON value. + * + * You should usually call [Builder.query] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun query(query: JsonField<String>) = apply { this.query = query } + + fun referenceExample(referenceExample: List<String>?) = + referenceExample(JsonField.ofNullable(referenceExample)) + + /** Alias for calling [Builder.referenceExample] with `referenceExample.orElse(null)`. */ + fun referenceExample(referenceExample: Optional<List<String>>) = + referenceExample(referenceExample.getOrNull()) + + /** + * Sets [Builder.referenceExample] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceExample] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun referenceExample(referenceExample: JsonField<List<String>>) = apply { + this.referenceExample = referenceExample.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.referenceExample]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addReferenceExample(referenceExample: String) = apply { + this.referenceExample = + (this.referenceExample ?: JsonField.of(mutableListOf())).also { + checkKnown("referenceExample", it).add(referenceExample) + } + } + + /** Enum for run types. */ + fun runType(runType: RunTypeEnum?) = runType(JsonField.ofNullable(runType)) + + /** Alias for calling [Builder.runType] with `runType.orElse(null)`. */ + fun runType(runType: Optional<RunTypeEnum>) = runType(runType.getOrNull()) + + /** + * Sets [Builder.runType] to an arbitrary JSON value. + * + * You should usually call [Builder.runType] with a well-typed [RunTypeEnum] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun runType(runType: JsonField<RunTypeEnum>) = apply { this.runType = runType } + + fun searchFilter(searchFilter: String?) = searchFilter(JsonField.ofNullable(searchFilter)) + + /** Alias for calling [Builder.searchFilter] with `searchFilter.orElse(null)`. */ + fun searchFilter(searchFilter: Optional<String>) = searchFilter(searchFilter.getOrNull()) + + /** + * Sets [Builder.searchFilter] to an arbitrary JSON value. + * + * You should usually call [Builder.searchFilter] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun searchFilter(searchFilter: JsonField<String>) = apply { + this.searchFilter = searchFilter + } + + fun select(select: List<Select>?) = select(JsonField.ofNullable(select)) + + /** Alias for calling [Builder.select] with `select.orElse(null)`. */ + fun select(select: Optional<List<Select>>) = select(select.getOrNull()) + + /** + * Sets [Builder.select] to an arbitrary JSON value. + * + * You should usually call [Builder.select] with a well-typed `List<Select>` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun select(select: JsonField<List<Select>>) = apply { + this.select = select.map { it.toMutableList() } + } + + /** + * Adds a single [Select] to [Builder.select]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSelect(select: Select) = apply { + this.select = + (this.select ?: JsonField.of(mutableListOf())).also { + checkKnown("select", it).add(select) + } + } + + fun session(session: List<String>?) = session(JsonField.ofNullable(session)) + + /** Alias for calling [Builder.session] with `session.orElse(null)`. */ + fun session(session: Optional<List<String>>) = session(session.getOrNull()) + + /** + * Sets [Builder.session] to an arbitrary JSON value. + * + * You should usually call [Builder.session] with a well-typed `List<String>` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun session(session: JsonField<List<String>>) = apply { + this.session = session.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.session]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSession(session: String) = apply { + this.session = + (this.session ?: JsonField.of(mutableListOf())).also { + checkKnown("session", it).add(session) + } + } + + fun skipPagination(skipPagination: Boolean?) = + skipPagination(JsonField.ofNullable(skipPagination)) + + /** + * Alias for [Builder.skipPagination]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun skipPagination(skipPagination: Boolean) = skipPagination(skipPagination as Boolean?) + + /** Alias for calling [Builder.skipPagination] with `skipPagination.orElse(null)`. */ + fun skipPagination(skipPagination: Optional<Boolean>) = + skipPagination(skipPagination.getOrNull()) + + /** + * Sets [Builder.skipPagination] to an arbitrary JSON value. + * + * You should usually call [Builder.skipPagination] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun skipPagination(skipPagination: JsonField<Boolean>) = apply { + this.skipPagination = skipPagination + } + + fun startTime(startTime: OffsetDateTime?) = startTime(JsonField.ofNullable(startTime)) + + /** Alias for calling [Builder.startTime] with `startTime.orElse(null)`. */ + fun startTime(startTime: Optional<OffsetDateTime>) = startTime(startTime.getOrNull()) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField<OffsetDateTime>) = apply { this.startTime = startTime } + + fun trace(trace: String?) = trace(JsonField.ofNullable(trace)) + + /** Alias for calling [Builder.trace] with `trace.orElse(null)`. */ + fun trace(trace: Optional<String>) = trace(trace.getOrNull()) + + /** + * Sets [Builder.trace] to an arbitrary JSON value. + * + * You should usually call [Builder.trace] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun trace(trace: JsonField<String>) = apply { this.trace = trace } + + fun traceFilter(traceFilter: String?) = traceFilter(JsonField.ofNullable(traceFilter)) + + /** Alias for calling [Builder.traceFilter] with `traceFilter.orElse(null)`. */ + fun traceFilter(traceFilter: Optional<String>) = traceFilter(traceFilter.getOrNull()) + + /** + * Sets [Builder.traceFilter] to an arbitrary JSON value. + * + * You should usually call [Builder.traceFilter] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun traceFilter(traceFilter: JsonField<String>) = apply { this.traceFilter = traceFilter } + + fun treeFilter(treeFilter: String?) = treeFilter(JsonField.ofNullable(treeFilter)) + + /** Alias for calling [Builder.treeFilter] with `treeFilter.orElse(null)`. */ + fun treeFilter(treeFilter: Optional<String>) = treeFilter(treeFilter.getOrNull()) + + /** + * Sets [Builder.treeFilter] to an arbitrary JSON value. + * + * You should usually call [Builder.treeFilter] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun treeFilter(treeFilter: JsonField<String>) = apply { this.treeFilter = treeFilter } + + fun useExperimentalSearch(useExperimentalSearch: Boolean) = + useExperimentalSearch(JsonField.of(useExperimentalSearch)) + + /** + * Sets [Builder.useExperimentalSearch] to an arbitrary JSON value. + * + * You should usually call [Builder.useExperimentalSearch] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun useExperimentalSearch(useExperimentalSearch: JsonField<Boolean>) = apply { + this.useExperimentalSearch = useExperimentalSearch + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RunStatsQueryParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RunStatsQueryParams = + RunStatsQueryParams( + (id ?: JsonMissing.of()).map { it.toImmutable() }, + dataSourceType, + endTime, + error, + executionOrder, + filter, + groupBy, + (groups ?: JsonMissing.of()).map { it.toImmutable() }, + isRoot, + parentRun, + query, + (referenceExample ?: JsonMissing.of()).map { it.toImmutable() }, + runType, + searchFilter, + (select ?: JsonMissing.of()).map { it.toImmutable() }, + (session ?: JsonMissing.of()).map { it.toImmutable() }, + skipPagination, + startTime, + trace, + traceFilter, + treeFilter, + useExperimentalSearch, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RunStatsQueryParams = apply { + if (validated) { + return@apply + } + + id() + dataSourceType().ifPresent { it.validate() } + endTime() + error() + executionOrder() + filter() + groupBy().ifPresent { it.validate() } + groups() + isRoot() + parentRun() + query() + referenceExample() + runType().ifPresent { it.validate() } + searchFilter() + select().ifPresent { it.forEach { it.validate() } } + session() + skipPagination() + startTime() + trace() + traceFilter() + treeFilter() + useExperimentalSearch() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (id.asKnown().getOrNull()?.size ?: 0) + + (dataSourceType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endTime.asKnown().isPresent) 1 else 0) + + (if (error.asKnown().isPresent) 1 else 0) + + (if (executionOrder.asKnown().isPresent) 1 else 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (groupBy.asKnown().getOrNull()?.validity() ?: 0) + + (groups.asKnown().getOrNull()?.sumOf { (if (it == null) 0 else 1).toInt() } ?: 0) + + (if (isRoot.asKnown().isPresent) 1 else 0) + + (if (parentRun.asKnown().isPresent) 1 else 0) + + (if (query.asKnown().isPresent) 1 else 0) + + (referenceExample.asKnown().getOrNull()?.size ?: 0) + + (runType.asKnown().getOrNull()?.validity() ?: 0) + + (if (searchFilter.asKnown().isPresent) 1 else 0) + + (select.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (session.asKnown().getOrNull()?.size ?: 0) + + (if (skipPagination.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + (if (trace.asKnown().isPresent) 1 else 0) + + (if (traceFilter.asKnown().isPresent) 1 else 0) + + (if (treeFilter.asKnown().isPresent) 1 else 0) + + (if (useExperimentalSearch.asKnown().isPresent) 1 else 0) + + /** Metrics you can select from run stats endpoint. */ + class Select @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val RUN_COUNT = of("run_count") + + @JvmField val LATENCY_P50 = of("latency_p50") + + @JvmField val LATENCY_P99 = of("latency_p99") + + @JvmField val LATENCY_AVG = of("latency_avg") + + @JvmField val FIRST_TOKEN_P50 = of("first_token_p50") + + @JvmField val FIRST_TOKEN_P99 = of("first_token_p99") + + @JvmField val TOTAL_TOKENS = of("total_tokens") + + @JvmField val PROMPT_TOKENS = of("prompt_tokens") + + @JvmField val COMPLETION_TOKENS = of("completion_tokens") + + @JvmField val MEDIAN_TOKENS = of("median_tokens") + + @JvmField val COMPLETION_TOKENS_P50 = of("completion_tokens_p50") + + @JvmField val PROMPT_TOKENS_P50 = of("prompt_tokens_p50") + + @JvmField val TOKENS_P99 = of("tokens_p99") + + @JvmField val COMPLETION_TOKENS_P99 = of("completion_tokens_p99") + + @JvmField val PROMPT_TOKENS_P99 = of("prompt_tokens_p99") + + @JvmField val LAST_RUN_START_TIME = of("last_run_start_time") + + @JvmField val FEEDBACK_STATS = of("feedback_stats") + + @JvmField val THREAD_FEEDBACK_STATS = of("thread_feedback_stats") + + @JvmField val RUN_FACETS = of("run_facets") + + @JvmField val ERROR_RATE = of("error_rate") + + @JvmField val STREAMING_RATE = of("streaming_rate") + + @JvmField val TOTAL_COST = of("total_cost") + + @JvmField val PROMPT_COST = of("prompt_cost") + + @JvmField val COMPLETION_COST = of("completion_cost") + + @JvmField val COST_P50 = of("cost_p50") + + @JvmField val COST_P99 = of("cost_p99") + + @JvmField val SESSION_FEEDBACK_STATS = of("session_feedback_stats") + + @JvmField val ALL_RUN_STATS = of("all_run_stats") + + @JvmField val ALL_TOKEN_STATS = of("all_token_stats") + + @JvmField val PROMPT_TOKEN_DETAILS = of("prompt_token_details") + + @JvmField val COMPLETION_TOKEN_DETAILS = of("completion_token_details") + + @JvmField val PROMPT_COST_DETAILS = of("prompt_cost_details") + + @JvmField val COMPLETION_COST_DETAILS = of("completion_cost_details") + + @JvmStatic fun of(value: String) = Select(JsonField.of(value)) + } + + /** An enum containing [Select]'s known values. */ + enum class Known { + RUN_COUNT, + LATENCY_P50, + LATENCY_P99, + LATENCY_AVG, + FIRST_TOKEN_P50, + FIRST_TOKEN_P99, + TOTAL_TOKENS, + PROMPT_TOKENS, + COMPLETION_TOKENS, + MEDIAN_TOKENS, + COMPLETION_TOKENS_P50, + PROMPT_TOKENS_P50, + TOKENS_P99, + COMPLETION_TOKENS_P99, + PROMPT_TOKENS_P99, + LAST_RUN_START_TIME, + FEEDBACK_STATS, + THREAD_FEEDBACK_STATS, + RUN_FACETS, + ERROR_RATE, + STREAMING_RATE, + TOTAL_COST, + PROMPT_COST, + COMPLETION_COST, + COST_P50, + COST_P99, + SESSION_FEEDBACK_STATS, + ALL_RUN_STATS, + ALL_TOKEN_STATS, + PROMPT_TOKEN_DETAILS, + COMPLETION_TOKEN_DETAILS, + PROMPT_COST_DETAILS, + COMPLETION_COST_DETAILS, + } + + /** + * An enum containing [Select]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Select] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + RUN_COUNT, + LATENCY_P50, + LATENCY_P99, + LATENCY_AVG, + FIRST_TOKEN_P50, + FIRST_TOKEN_P99, + TOTAL_TOKENS, + PROMPT_TOKENS, + COMPLETION_TOKENS, + MEDIAN_TOKENS, + COMPLETION_TOKENS_P50, + PROMPT_TOKENS_P50, + TOKENS_P99, + COMPLETION_TOKENS_P99, + PROMPT_TOKENS_P99, + LAST_RUN_START_TIME, + FEEDBACK_STATS, + THREAD_FEEDBACK_STATS, + RUN_FACETS, + ERROR_RATE, + STREAMING_RATE, + TOTAL_COST, + PROMPT_COST, + COMPLETION_COST, + COST_P50, + COST_P99, + SESSION_FEEDBACK_STATS, + ALL_RUN_STATS, + ALL_TOKEN_STATS, + PROMPT_TOKEN_DETAILS, + COMPLETION_TOKEN_DETAILS, + PROMPT_COST_DETAILS, + COMPLETION_COST_DETAILS, + /** An enum member indicating that [Select] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + RUN_COUNT -> Value.RUN_COUNT + LATENCY_P50 -> Value.LATENCY_P50 + LATENCY_P99 -> Value.LATENCY_P99 + LATENCY_AVG -> Value.LATENCY_AVG + FIRST_TOKEN_P50 -> Value.FIRST_TOKEN_P50 + FIRST_TOKEN_P99 -> Value.FIRST_TOKEN_P99 + TOTAL_TOKENS -> Value.TOTAL_TOKENS + PROMPT_TOKENS -> Value.PROMPT_TOKENS + COMPLETION_TOKENS -> Value.COMPLETION_TOKENS + MEDIAN_TOKENS -> Value.MEDIAN_TOKENS + COMPLETION_TOKENS_P50 -> Value.COMPLETION_TOKENS_P50 + PROMPT_TOKENS_P50 -> Value.PROMPT_TOKENS_P50 + TOKENS_P99 -> Value.TOKENS_P99 + COMPLETION_TOKENS_P99 -> Value.COMPLETION_TOKENS_P99 + PROMPT_TOKENS_P99 -> Value.PROMPT_TOKENS_P99 + LAST_RUN_START_TIME -> Value.LAST_RUN_START_TIME + FEEDBACK_STATS -> Value.FEEDBACK_STATS + THREAD_FEEDBACK_STATS -> Value.THREAD_FEEDBACK_STATS + RUN_FACETS -> Value.RUN_FACETS + ERROR_RATE -> Value.ERROR_RATE + STREAMING_RATE -> Value.STREAMING_RATE + TOTAL_COST -> Value.TOTAL_COST + PROMPT_COST -> Value.PROMPT_COST + COMPLETION_COST -> Value.COMPLETION_COST + COST_P50 -> Value.COST_P50 + COST_P99 -> Value.COST_P99 + SESSION_FEEDBACK_STATS -> Value.SESSION_FEEDBACK_STATS + ALL_RUN_STATS -> Value.ALL_RUN_STATS + ALL_TOKEN_STATS -> Value.ALL_TOKEN_STATS + PROMPT_TOKEN_DETAILS -> Value.PROMPT_TOKEN_DETAILS + COMPLETION_TOKEN_DETAILS -> Value.COMPLETION_TOKEN_DETAILS + PROMPT_COST_DETAILS -> Value.PROMPT_COST_DETAILS + COMPLETION_COST_DETAILS -> Value.COMPLETION_COST_DETAILS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + RUN_COUNT -> Known.RUN_COUNT + LATENCY_P50 -> Known.LATENCY_P50 + LATENCY_P99 -> Known.LATENCY_P99 + LATENCY_AVG -> Known.LATENCY_AVG + FIRST_TOKEN_P50 -> Known.FIRST_TOKEN_P50 + FIRST_TOKEN_P99 -> Known.FIRST_TOKEN_P99 + TOTAL_TOKENS -> Known.TOTAL_TOKENS + PROMPT_TOKENS -> Known.PROMPT_TOKENS + COMPLETION_TOKENS -> Known.COMPLETION_TOKENS + MEDIAN_TOKENS -> Known.MEDIAN_TOKENS + COMPLETION_TOKENS_P50 -> Known.COMPLETION_TOKENS_P50 + PROMPT_TOKENS_P50 -> Known.PROMPT_TOKENS_P50 + TOKENS_P99 -> Known.TOKENS_P99 + COMPLETION_TOKENS_P99 -> Known.COMPLETION_TOKENS_P99 + PROMPT_TOKENS_P99 -> Known.PROMPT_TOKENS_P99 + LAST_RUN_START_TIME -> Known.LAST_RUN_START_TIME + FEEDBACK_STATS -> Known.FEEDBACK_STATS + THREAD_FEEDBACK_STATS -> Known.THREAD_FEEDBACK_STATS + RUN_FACETS -> Known.RUN_FACETS + ERROR_RATE -> Known.ERROR_RATE + STREAMING_RATE -> Known.STREAMING_RATE + TOTAL_COST -> Known.TOTAL_COST + PROMPT_COST -> Known.PROMPT_COST + COMPLETION_COST -> Known.COMPLETION_COST + COST_P50 -> Known.COST_P50 + COST_P99 -> Known.COST_P99 + SESSION_FEEDBACK_STATS -> Known.SESSION_FEEDBACK_STATS + ALL_RUN_STATS -> Known.ALL_RUN_STATS + ALL_TOKEN_STATS -> Known.ALL_TOKEN_STATS + PROMPT_TOKEN_DETAILS -> Known.PROMPT_TOKEN_DETAILS + COMPLETION_TOKEN_DETAILS -> Known.COMPLETION_TOKEN_DETAILS + PROMPT_COST_DETAILS -> Known.PROMPT_COST_DETAILS + COMPLETION_COST_DETAILS -> Known.COMPLETION_COST_DETAILS + else -> throw LangsmithApiInvalidDataException("Unknown Select: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Select = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Select && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunStatsQueryParams && + id == other.id && + dataSourceType == other.dataSourceType && + endTime == other.endTime && + error == other.error && + executionOrder == other.executionOrder && + filter == other.filter && + groupBy == other.groupBy && + groups == other.groups && + isRoot == other.isRoot && + parentRun == other.parentRun && + query == other.query && + referenceExample == other.referenceExample && + runType == other.runType && + searchFilter == other.searchFilter && + select == other.select && + session == other.session && + skipPagination == other.skipPagination && + startTime == other.startTime && + trace == other.trace && + traceFilter == other.traceFilter && + treeFilter == other.treeFilter && + useExperimentalSearch == other.useExperimentalSearch && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + dataSourceType, + endTime, + error, + executionOrder, + filter, + groupBy, + groups, + isRoot, + parentRun, + query, + referenceExample, + runType, + searchFilter, + select, + session, + skipPagination, + startTime, + trace, + traceFilter, + treeFilter, + useExperimentalSearch, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RunStatsQueryParams{id=$id, dataSourceType=$dataSourceType, endTime=$endTime, error=$error, executionOrder=$executionOrder, filter=$filter, groupBy=$groupBy, groups=$groups, isRoot=$isRoot, parentRun=$parentRun, query=$query, referenceExample=$referenceExample, runType=$runType, searchFilter=$searchFilter, select=$select, session=$session, skipPagination=$skipPagination, startTime=$startTime, trace=$trace, traceFilter=$traceFilter, treeFilter=$treeFilter, useExperimentalSearch=$useExperimentalSearch, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunStatsResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunStatsResponse.kt new file mode 100644 index 00000000..20506de6 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunStatsResponse.kt @@ -0,0 +1,299 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonCreator +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 com.langsmith_api.api.core.BaseDeserializer +import com.langsmith_api.api.core.BaseSerializer +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.allMaxBy +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunStats +import java.util.Objects +import java.util.Optional + +@JsonDeserialize(using = RunStatsResponse.Deserializer::class) +@JsonSerialize(using = RunStatsResponse.Serializer::class) +class RunStatsResponse +private constructor( + private val runStats: RunStats? = null, + private val unionMember1: UnionMember1? = null, + private val _json: JsonValue? = null, +) { + + fun runStats(): Optional<RunStats> = Optional.ofNullable(runStats) + + fun unionMember1(): Optional<UnionMember1> = Optional.ofNullable(unionMember1) + + fun isRunStats(): Boolean = runStats != null + + fun isUnionMember1(): Boolean = unionMember1 != null + + fun asRunStats(): RunStats = runStats.getOrThrow("runStats") + + fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + runStats != null -> visitor.visitRunStats(runStats) + unionMember1 != null -> visitor.visitUnionMember1(unionMember1) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): RunStatsResponse = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitRunStats(runStats: RunStats) { + runStats.validate() + } + + override fun visitUnionMember1(unionMember1: UnionMember1) { + unionMember1.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitRunStats(runStats: RunStats) = runStats.validity() + + override fun visitUnionMember1(unionMember1: UnionMember1) = unionMember1.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunStatsResponse && + runStats == other.runStats && + unionMember1 == other.unionMember1 + } + + override fun hashCode(): Int = Objects.hash(runStats, unionMember1) + + override fun toString(): String = + when { + runStats != null -> "RunStatsResponse{runStats=$runStats}" + unionMember1 != null -> "RunStatsResponse{unionMember1=$unionMember1}" + _json != null -> "RunStatsResponse{_unknown=$_json}" + else -> throw IllegalStateException("Invalid RunStatsResponse") + } + + companion object { + + @JvmStatic fun ofRunStats(runStats: RunStats) = RunStatsResponse(runStats = runStats) + + @JvmStatic + fun ofUnionMember1(unionMember1: UnionMember1) = + RunStatsResponse(unionMember1 = unionMember1) + } + + /** + * An interface that defines how to map each variant of [RunStatsResponse] to a value of type + * [T]. + */ + interface Visitor<out T> { + + fun visitRunStats(runStats: RunStats): T + + fun visitUnionMember1(unionMember1: UnionMember1): T + + /** + * Maps an unknown variant of [RunStatsResponse] to a value of type [T]. + * + * An instance of [RunStatsResponse] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is unaware + * of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown RunStatsResponse: $json") + } + } + + internal class Deserializer : BaseDeserializer<RunStatsResponse>(RunStatsResponse::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): RunStatsResponse { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef<RunStats>())?.let { + RunStatsResponse(runStats = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef<UnionMember1>())?.let { + RunStatsResponse(unionMember1 = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with all + // the possible variants (e.g. deserializing from boolean). + 0 -> RunStatsResponse(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer<RunStatsResponse>(RunStatsResponse::class) { + + override fun serialize( + value: RunStatsResponse, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.runStats != null -> generator.writeObject(value.runStats) + value.unionMember1 != null -> generator.writeObject(value.unionMember1) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid RunStatsResponse") + } + } + } + + class UnionMember1 + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember1]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember1]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember1: UnionMember1) = apply { + additionalProperties = unionMember1.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember1]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember1 = UnionMember1(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): UnionMember1 = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember1 && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "UnionMember1{additionalProperties=$additionalProperties}" + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunTypeEnum.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunTypeEnum.kt new file mode 100644 index 00000000..d5ec0d5d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunTypeEnum.kt @@ -0,0 +1,164 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs + +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException + +/** Enum for run types. */ +class RunTypeEnum @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't match + * any known member, and you want to know that value. For example, if the SDK is on an older + * version than the API, then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val TOOL = of("tool") + + @JvmField val CHAIN = of("chain") + + @JvmField val LLM = of("llm") + + @JvmField val RETRIEVER = of("retriever") + + @JvmField val EMBEDDING = of("embedding") + + @JvmField val PROMPT = of("prompt") + + @JvmField val PARSER = of("parser") + + @JvmStatic fun of(value: String) = RunTypeEnum(JsonField.of(value)) + } + + /** An enum containing [RunTypeEnum]'s known values. */ + enum class Known { + TOOL, + CHAIN, + LLM, + RETRIEVER, + EMBEDDING, + PROMPT, + PARSER, + } + + /** + * An enum containing [RunTypeEnum]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [RunTypeEnum] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the SDK + * is on an older version than the API, then the API may respond with new members that the SDK + * is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TOOL, + CHAIN, + LLM, + RETRIEVER, + EMBEDDING, + PROMPT, + PARSER, + /** An enum member indicating that [RunTypeEnum] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if + * the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want to + * throw for the unknown case. + */ + fun value(): Value = + when (this) { + TOOL -> Value.TOOL + CHAIN -> Value.CHAIN + LLM -> Value.LLM + RETRIEVER -> Value.RETRIEVER + EMBEDDING -> Value.EMBEDDING + PROMPT -> Value.PROMPT + PARSER -> Value.PARSER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't want + * to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TOOL -> Known.TOOL + CHAIN -> Known.CHAIN + LLM -> Known.LLM + RETRIEVER -> Known.RETRIEVER + EMBEDDING -> Known.EMBEDDING + PROMPT -> Known.PROMPT + PARSER -> Known.PARSER + else -> throw LangsmithApiInvalidDataException("Unknown RunTypeEnum: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): RunTypeEnum = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunTypeEnum && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunUpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunUpdateParams.kt new file mode 100644 index 00000000..ec7b2fdf --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunUpdateParams.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Update a run. */ +class RunUpdateParams +private constructor( + private val runId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun runId(): Optional<String> = Optional.ofNullable(runId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): RunUpdateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [RunUpdateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunUpdateParams]. */ + class Builder internal constructor() { + + private var runId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(runUpdateParams: RunUpdateParams) = apply { + runId = runUpdateParams.runId + additionalHeaders = runUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = runUpdateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = runUpdateParams.additionalBodyProperties.toMutableMap() + } + + fun runId(runId: String?) = apply { this.runId = runId } + + /** Alias for calling [Builder.runId] with `runId.orElse(null)`. */ + fun runId(runId: Optional<String>) = runId(runId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [RunUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RunUpdateParams = + RunUpdateParams( + runId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> runId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunUpdateParams && + runId == other.runId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(runId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "RunUpdateParams{runId=$runId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunUpdateResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunUpdateResponse.kt new file mode 100644 index 00000000..c9884530 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunUpdateResponse.kt @@ -0,0 +1,113 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class RunUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [RunUpdateResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunUpdateResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(runUpdateResponse: RunUpdateResponse) = apply { + additionalProperties = runUpdateResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RunUpdateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RunUpdateResponse = RunUpdateResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): RunUpdateResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunUpdateResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "RunUpdateResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunsFilterDataSourceTypeEnum.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunsFilterDataSourceTypeEnum.kt new file mode 100644 index 00000000..b3a45b11 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/RunsFilterDataSourceTypeEnum.kt @@ -0,0 +1,162 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs + +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException + +/** Enum for run data source types. */ +class RunsFilterDataSourceTypeEnum +@JsonCreator +private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't match + * any known member, and you want to know that value. For example, if the SDK is on an older + * version than the API, then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val CURRENT = of("current") + + @JvmField val HISTORICAL = of("historical") + + @JvmField val LITE = of("lite") + + @JvmField val ROOT_LITE = of("root_lite") + + @JvmField val RUNS_FEEDBACKS_RMT_WIDE = of("runs_feedbacks_rmt_wide") + + @JvmStatic fun of(value: String) = RunsFilterDataSourceTypeEnum(JsonField.of(value)) + } + + /** An enum containing [RunsFilterDataSourceTypeEnum]'s known values. */ + enum class Known { + CURRENT, + HISTORICAL, + LITE, + ROOT_LITE, + RUNS_FEEDBACKS_RMT_WIDE, + } + + /** + * An enum containing [RunsFilterDataSourceTypeEnum]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RunsFilterDataSourceTypeEnum] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, if the SDK + * is on an older version than the API, then the API may respond with new members that the SDK + * is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CURRENT, + HISTORICAL, + LITE, + ROOT_LITE, + RUNS_FEEDBACKS_RMT_WIDE, + /** + * An enum member indicating that [RunsFilterDataSourceTypeEnum] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if + * the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want to + * throw for the unknown case. + */ + fun value(): Value = + when (this) { + CURRENT -> Value.CURRENT + HISTORICAL -> Value.HISTORICAL + LITE -> Value.LITE + ROOT_LITE -> Value.ROOT_LITE + RUNS_FEEDBACKS_RMT_WIDE -> Value.RUNS_FEEDBACKS_RMT_WIDE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't want + * to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CURRENT -> Known.CURRENT + HISTORICAL -> Known.HISTORICAL + LITE -> Known.LITE + ROOT_LITE -> Known.ROOT_LITE + RUNS_FEEDBACKS_RMT_WIDE -> Known.RUNS_FEEDBACKS_RMT_WIDE + else -> + throw LangsmithApiInvalidDataException( + "Unknown RunsFilterDataSourceTypeEnum: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): RunsFilterDataSourceTypeEnum = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunsFilterDataSourceTypeEnum && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/group/GroupCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/group/GroupCreateParams.kt new file mode 100644 index 00000000..365fcd84 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/group/GroupCreateParams.kt @@ -0,0 +1,224 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.group + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get runs grouped by an expression */ +class GroupCreateParams +private constructor( + private val accept: String?, + private val runGroupRequest: RunGroupRequest, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun accept(): Optional<String> = Optional.ofNullable(accept) + + fun runGroupRequest(): RunGroupRequest = runGroupRequest + + fun _additionalBodyProperties(): Map<String, JsonValue> = + runGroupRequest._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [GroupCreateParams]. + * + * The following fields are required: + * ```java + * .runGroupRequest() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupCreateParams]. */ + class Builder internal constructor() { + + private var accept: String? = null + private var runGroupRequest: RunGroupRequest? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(groupCreateParams: GroupCreateParams) = apply { + accept = groupCreateParams.accept + runGroupRequest = groupCreateParams.runGroupRequest + additionalHeaders = groupCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = groupCreateParams.additionalQueryParams.toBuilder() + } + + fun accept(accept: String?) = apply { this.accept = accept } + + /** Alias for calling [Builder.accept] with `accept.orElse(null)`. */ + fun accept(accept: Optional<String>) = accept(accept.getOrNull()) + + fun runGroupRequest(runGroupRequest: RunGroupRequest) = apply { + this.runGroupRequest = runGroupRequest + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [GroupCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .runGroupRequest() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupCreateParams = + GroupCreateParams( + accept, + checkRequired("runGroupRequest", runGroupRequest), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): RunGroupRequest = runGroupRequest + + override fun _headers(): Headers = + Headers.builder() + .apply { + accept?.let { put("accept", it) } + putAll(additionalHeaders) + } + .build() + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupCreateParams && + accept == other.accept && + runGroupRequest == other.runGroupRequest && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(accept, runGroupRequest, additionalHeaders, additionalQueryParams) + + override fun toString() = + "GroupCreateParams{accept=$accept, runGroupRequest=$runGroupRequest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/group/GroupCreateResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/group/GroupCreateResponse.kt new file mode 100644 index 00000000..8c517357 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/group/GroupCreateResponse.kt @@ -0,0 +1,113 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.group + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class GroupCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [GroupCreateResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupCreateResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(groupCreateResponse: GroupCreateResponse) = apply { + additionalProperties = groupCreateResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): GroupCreateResponse = GroupCreateResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): GroupCreateResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupCreateResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "GroupCreateResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/group/GroupStatsParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/group/GroupStatsParams.kt new file mode 100644 index 00000000..6d75c605 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/group/GroupStatsParams.kt @@ -0,0 +1,204 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.group + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** Get stats for the grouped runs. */ +class GroupStatsParams +private constructor( + private val runGroupRequest: RunGroupRequest, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun runGroupRequest(): RunGroupRequest = runGroupRequest + + fun _additionalBodyProperties(): Map<String, JsonValue> = + runGroupRequest._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [GroupStatsParams]. + * + * The following fields are required: + * ```java + * .runGroupRequest() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupStatsParams]. */ + class Builder internal constructor() { + + private var runGroupRequest: RunGroupRequest? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(groupStatsParams: GroupStatsParams) = apply { + runGroupRequest = groupStatsParams.runGroupRequest + additionalHeaders = groupStatsParams.additionalHeaders.toBuilder() + additionalQueryParams = groupStatsParams.additionalQueryParams.toBuilder() + } + + fun runGroupRequest(runGroupRequest: RunGroupRequest) = apply { + this.runGroupRequest = runGroupRequest + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [GroupStatsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .runGroupRequest() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupStatsParams = + GroupStatsParams( + checkRequired("runGroupRequest", runGroupRequest), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): RunGroupRequest = runGroupRequest + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupStatsParams && + runGroupRequest == other.runGroupRequest && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(runGroupRequest, additionalHeaders, additionalQueryParams) + + override fun toString() = + "GroupStatsParams{runGroupRequest=$runGroupRequest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/group/GroupStatsResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/group/GroupStatsResponse.kt new file mode 100644 index 00000000..dee986a8 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/group/GroupStatsResponse.kt @@ -0,0 +1,1355 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.group + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class GroupStatsResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val groupCount: JsonField<Long>, + private val completionCost: JsonField<String>, + private val completionCostDetails: JsonValue, + private val completionTokenDetails: JsonValue, + private val completionTokens: JsonField<Long>, + private val completionTokensP50: JsonField<Long>, + private val completionTokensP99: JsonField<Long>, + private val costP50: JsonField<String>, + private val costP99: JsonField<String>, + private val errorRate: JsonField<Double>, + private val feedbackStats: JsonValue, + private val firstTokenP50: JsonField<Double>, + private val firstTokenP99: JsonField<Double>, + private val lastRunStartTime: JsonField<OffsetDateTime>, + private val latencyP50: JsonField<Double>, + private val latencyP99: JsonField<Double>, + private val medianTokens: JsonField<Long>, + private val promptCost: JsonField<String>, + private val promptCostDetails: JsonValue, + private val promptTokenDetails: JsonValue, + private val promptTokens: JsonField<Long>, + private val promptTokensP50: JsonField<Long>, + private val promptTokensP99: JsonField<Long>, + private val runCount: JsonField<Long>, + private val runFacets: JsonField<List<JsonValue>>, + private val streamingRate: JsonField<Double>, + private val tokensP99: JsonField<Long>, + private val totalCost: JsonField<String>, + private val totalTokens: JsonField<Long>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("group_count") @ExcludeMissing groupCount: JsonField<Long> = JsonMissing.of(), + @JsonProperty("completion_cost") + @ExcludeMissing + completionCost: JsonField<String> = JsonMissing.of(), + @JsonProperty("completion_cost_details") + @ExcludeMissing + completionCostDetails: JsonValue = JsonMissing.of(), + @JsonProperty("completion_token_details") + @ExcludeMissing + completionTokenDetails: JsonValue = JsonMissing.of(), + @JsonProperty("completion_tokens") + @ExcludeMissing + completionTokens: JsonField<Long> = JsonMissing.of(), + @JsonProperty("completion_tokens_p50") + @ExcludeMissing + completionTokensP50: JsonField<Long> = JsonMissing.of(), + @JsonProperty("completion_tokens_p99") + @ExcludeMissing + completionTokensP99: JsonField<Long> = JsonMissing.of(), + @JsonProperty("cost_p50") @ExcludeMissing costP50: JsonField<String> = JsonMissing.of(), + @JsonProperty("cost_p99") @ExcludeMissing costP99: JsonField<String> = JsonMissing.of(), + @JsonProperty("error_rate") @ExcludeMissing errorRate: JsonField<Double> = JsonMissing.of(), + @JsonProperty("feedback_stats") @ExcludeMissing feedbackStats: JsonValue = JsonMissing.of(), + @JsonProperty("first_token_p50") + @ExcludeMissing + firstTokenP50: JsonField<Double> = JsonMissing.of(), + @JsonProperty("first_token_p99") + @ExcludeMissing + firstTokenP99: JsonField<Double> = JsonMissing.of(), + @JsonProperty("last_run_start_time") + @ExcludeMissing + lastRunStartTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("latency_p50") + @ExcludeMissing + latencyP50: JsonField<Double> = JsonMissing.of(), + @JsonProperty("latency_p99") + @ExcludeMissing + latencyP99: JsonField<Double> = JsonMissing.of(), + @JsonProperty("median_tokens") + @ExcludeMissing + medianTokens: JsonField<Long> = JsonMissing.of(), + @JsonProperty("prompt_cost") + @ExcludeMissing + promptCost: JsonField<String> = JsonMissing.of(), + @JsonProperty("prompt_cost_details") + @ExcludeMissing + promptCostDetails: JsonValue = JsonMissing.of(), + @JsonProperty("prompt_token_details") + @ExcludeMissing + promptTokenDetails: JsonValue = JsonMissing.of(), + @JsonProperty("prompt_tokens") + @ExcludeMissing + promptTokens: JsonField<Long> = JsonMissing.of(), + @JsonProperty("prompt_tokens_p50") + @ExcludeMissing + promptTokensP50: JsonField<Long> = JsonMissing.of(), + @JsonProperty("prompt_tokens_p99") + @ExcludeMissing + promptTokensP99: JsonField<Long> = JsonMissing.of(), + @JsonProperty("run_count") @ExcludeMissing runCount: JsonField<Long> = JsonMissing.of(), + @JsonProperty("run_facets") + @ExcludeMissing + runFacets: JsonField<List<JsonValue>> = JsonMissing.of(), + @JsonProperty("streaming_rate") + @ExcludeMissing + streamingRate: JsonField<Double> = JsonMissing.of(), + @JsonProperty("tokens_p99") @ExcludeMissing tokensP99: JsonField<Long> = JsonMissing.of(), + @JsonProperty("total_cost") @ExcludeMissing totalCost: JsonField<String> = JsonMissing.of(), + @JsonProperty("total_tokens") + @ExcludeMissing + totalTokens: JsonField<Long> = JsonMissing.of(), + ) : this( + groupCount, + completionCost, + completionCostDetails, + completionTokenDetails, + completionTokens, + completionTokensP50, + completionTokensP99, + costP50, + costP99, + errorRate, + feedbackStats, + firstTokenP50, + firstTokenP99, + lastRunStartTime, + latencyP50, + latencyP99, + medianTokens, + promptCost, + promptCostDetails, + promptTokenDetails, + promptTokens, + promptTokensP50, + promptTokensP99, + runCount, + runFacets, + streamingRate, + tokensP99, + totalCost, + totalTokens, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupCount(): Long = groupCount.getRequired("group_count") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun completionCost(): Optional<String> = completionCost.getOptional("completion_cost") + + @JsonProperty("completion_cost_details") + @ExcludeMissing + fun _completionCostDetails(): JsonValue = completionCostDetails + + @JsonProperty("completion_token_details") + @ExcludeMissing + fun _completionTokenDetails(): JsonValue = completionTokenDetails + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun completionTokens(): Optional<Long> = completionTokens.getOptional("completion_tokens") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun completionTokensP50(): Optional<Long> = + completionTokensP50.getOptional("completion_tokens_p50") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun completionTokensP99(): Optional<Long> = + completionTokensP99.getOptional("completion_tokens_p99") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun costP50(): Optional<String> = costP50.getOptional("cost_p50") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun costP99(): Optional<String> = costP99.getOptional("cost_p99") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun errorRate(): Optional<Double> = errorRate.getOptional("error_rate") + + @JsonProperty("feedback_stats") @ExcludeMissing fun _feedbackStats(): JsonValue = feedbackStats + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun firstTokenP50(): Optional<Double> = firstTokenP50.getOptional("first_token_p50") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun firstTokenP99(): Optional<Double> = firstTokenP99.getOptional("first_token_p99") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun lastRunStartTime(): Optional<OffsetDateTime> = + lastRunStartTime.getOptional("last_run_start_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun latencyP50(): Optional<Double> = latencyP50.getOptional("latency_p50") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun latencyP99(): Optional<Double> = latencyP99.getOptional("latency_p99") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun medianTokens(): Optional<Long> = medianTokens.getOptional("median_tokens") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun promptCost(): Optional<String> = promptCost.getOptional("prompt_cost") + + @JsonProperty("prompt_cost_details") + @ExcludeMissing + fun _promptCostDetails(): JsonValue = promptCostDetails + + @JsonProperty("prompt_token_details") + @ExcludeMissing + fun _promptTokenDetails(): JsonValue = promptTokenDetails + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun promptTokens(): Optional<Long> = promptTokens.getOptional("prompt_tokens") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun promptTokensP50(): Optional<Long> = promptTokensP50.getOptional("prompt_tokens_p50") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun promptTokensP99(): Optional<Long> = promptTokensP99.getOptional("prompt_tokens_p99") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun runCount(): Optional<Long> = runCount.getOptional("run_count") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun runFacets(): Optional<List<JsonValue>> = runFacets.getOptional("run_facets") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun streamingRate(): Optional<Double> = streamingRate.getOptional("streaming_rate") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tokensP99(): Optional<Long> = tokensP99.getOptional("tokens_p99") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun totalCost(): Optional<String> = totalCost.getOptional("total_cost") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun totalTokens(): Optional<Long> = totalTokens.getOptional("total_tokens") + + /** + * Returns the raw JSON value of [groupCount]. + * + * Unlike [groupCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("group_count") @ExcludeMissing fun _groupCount(): JsonField<Long> = groupCount + + /** + * Returns the raw JSON value of [completionCost]. + * + * Unlike [completionCost], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("completion_cost") + @ExcludeMissing + fun _completionCost(): JsonField<String> = completionCost + + /** + * Returns the raw JSON value of [completionTokens]. + * + * Unlike [completionTokens], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("completion_tokens") + @ExcludeMissing + fun _completionTokens(): JsonField<Long> = completionTokens + + /** + * Returns the raw JSON value of [completionTokensP50]. + * + * Unlike [completionTokensP50], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("completion_tokens_p50") + @ExcludeMissing + fun _completionTokensP50(): JsonField<Long> = completionTokensP50 + + /** + * Returns the raw JSON value of [completionTokensP99]. + * + * Unlike [completionTokensP99], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("completion_tokens_p99") + @ExcludeMissing + fun _completionTokensP99(): JsonField<Long> = completionTokensP99 + + /** + * Returns the raw JSON value of [costP50]. + * + * Unlike [costP50], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cost_p50") @ExcludeMissing fun _costP50(): JsonField<String> = costP50 + + /** + * Returns the raw JSON value of [costP99]. + * + * Unlike [costP99], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cost_p99") @ExcludeMissing fun _costP99(): JsonField<String> = costP99 + + /** + * Returns the raw JSON value of [errorRate]. + * + * Unlike [errorRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("error_rate") @ExcludeMissing fun _errorRate(): JsonField<Double> = errorRate + + /** + * Returns the raw JSON value of [firstTokenP50]. + * + * Unlike [firstTokenP50], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("first_token_p50") + @ExcludeMissing + fun _firstTokenP50(): JsonField<Double> = firstTokenP50 + + /** + * Returns the raw JSON value of [firstTokenP99]. + * + * Unlike [firstTokenP99], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("first_token_p99") + @ExcludeMissing + fun _firstTokenP99(): JsonField<Double> = firstTokenP99 + + /** + * Returns the raw JSON value of [lastRunStartTime]. + * + * Unlike [lastRunStartTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("last_run_start_time") + @ExcludeMissing + fun _lastRunStartTime(): JsonField<OffsetDateTime> = lastRunStartTime + + /** + * Returns the raw JSON value of [latencyP50]. + * + * Unlike [latencyP50], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("latency_p50") @ExcludeMissing fun _latencyP50(): JsonField<Double> = latencyP50 + + /** + * Returns the raw JSON value of [latencyP99]. + * + * Unlike [latencyP99], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("latency_p99") @ExcludeMissing fun _latencyP99(): JsonField<Double> = latencyP99 + + /** + * Returns the raw JSON value of [medianTokens]. + * + * Unlike [medianTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("median_tokens") + @ExcludeMissing + fun _medianTokens(): JsonField<Long> = medianTokens + + /** + * Returns the raw JSON value of [promptCost]. + * + * Unlike [promptCost], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prompt_cost") @ExcludeMissing fun _promptCost(): JsonField<String> = promptCost + + /** + * Returns the raw JSON value of [promptTokens]. + * + * Unlike [promptTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prompt_tokens") + @ExcludeMissing + fun _promptTokens(): JsonField<Long> = promptTokens + + /** + * Returns the raw JSON value of [promptTokensP50]. + * + * Unlike [promptTokensP50], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prompt_tokens_p50") + @ExcludeMissing + fun _promptTokensP50(): JsonField<Long> = promptTokensP50 + + /** + * Returns the raw JSON value of [promptTokensP99]. + * + * Unlike [promptTokensP99], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prompt_tokens_p99") + @ExcludeMissing + fun _promptTokensP99(): JsonField<Long> = promptTokensP99 + + /** + * Returns the raw JSON value of [runCount]. + * + * Unlike [runCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_count") @ExcludeMissing fun _runCount(): JsonField<Long> = runCount + + /** + * Returns the raw JSON value of [runFacets]. + * + * Unlike [runFacets], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_facets") + @ExcludeMissing + fun _runFacets(): JsonField<List<JsonValue>> = runFacets + + /** + * Returns the raw JSON value of [streamingRate]. + * + * Unlike [streamingRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("streaming_rate") + @ExcludeMissing + fun _streamingRate(): JsonField<Double> = streamingRate + + /** + * Returns the raw JSON value of [tokensP99]. + * + * Unlike [tokensP99], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tokens_p99") @ExcludeMissing fun _tokensP99(): JsonField<Long> = tokensP99 + + /** + * Returns the raw JSON value of [totalCost]. + * + * Unlike [totalCost], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total_cost") @ExcludeMissing fun _totalCost(): JsonField<String> = totalCost + + /** + * Returns the raw JSON value of [totalTokens]. + * + * Unlike [totalTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total_tokens") @ExcludeMissing fun _totalTokens(): JsonField<Long> = totalTokens + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [GroupStatsResponse]. + * + * The following fields are required: + * ```java + * .groupCount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupStatsResponse]. */ + class Builder internal constructor() { + + private var groupCount: JsonField<Long>? = null + private var completionCost: JsonField<String> = JsonMissing.of() + private var completionCostDetails: JsonValue = JsonMissing.of() + private var completionTokenDetails: JsonValue = JsonMissing.of() + private var completionTokens: JsonField<Long> = JsonMissing.of() + private var completionTokensP50: JsonField<Long> = JsonMissing.of() + private var completionTokensP99: JsonField<Long> = JsonMissing.of() + private var costP50: JsonField<String> = JsonMissing.of() + private var costP99: JsonField<String> = JsonMissing.of() + private var errorRate: JsonField<Double> = JsonMissing.of() + private var feedbackStats: JsonValue = JsonMissing.of() + private var firstTokenP50: JsonField<Double> = JsonMissing.of() + private var firstTokenP99: JsonField<Double> = JsonMissing.of() + private var lastRunStartTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var latencyP50: JsonField<Double> = JsonMissing.of() + private var latencyP99: JsonField<Double> = JsonMissing.of() + private var medianTokens: JsonField<Long> = JsonMissing.of() + private var promptCost: JsonField<String> = JsonMissing.of() + private var promptCostDetails: JsonValue = JsonMissing.of() + private var promptTokenDetails: JsonValue = JsonMissing.of() + private var promptTokens: JsonField<Long> = JsonMissing.of() + private var promptTokensP50: JsonField<Long> = JsonMissing.of() + private var promptTokensP99: JsonField<Long> = JsonMissing.of() + private var runCount: JsonField<Long> = JsonMissing.of() + private var runFacets: JsonField<MutableList<JsonValue>>? = null + private var streamingRate: JsonField<Double> = JsonMissing.of() + private var tokensP99: JsonField<Long> = JsonMissing.of() + private var totalCost: JsonField<String> = JsonMissing.of() + private var totalTokens: JsonField<Long> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(groupStatsResponse: GroupStatsResponse) = apply { + groupCount = groupStatsResponse.groupCount + completionCost = groupStatsResponse.completionCost + completionCostDetails = groupStatsResponse.completionCostDetails + completionTokenDetails = groupStatsResponse.completionTokenDetails + completionTokens = groupStatsResponse.completionTokens + completionTokensP50 = groupStatsResponse.completionTokensP50 + completionTokensP99 = groupStatsResponse.completionTokensP99 + costP50 = groupStatsResponse.costP50 + costP99 = groupStatsResponse.costP99 + errorRate = groupStatsResponse.errorRate + feedbackStats = groupStatsResponse.feedbackStats + firstTokenP50 = groupStatsResponse.firstTokenP50 + firstTokenP99 = groupStatsResponse.firstTokenP99 + lastRunStartTime = groupStatsResponse.lastRunStartTime + latencyP50 = groupStatsResponse.latencyP50 + latencyP99 = groupStatsResponse.latencyP99 + medianTokens = groupStatsResponse.medianTokens + promptCost = groupStatsResponse.promptCost + promptCostDetails = groupStatsResponse.promptCostDetails + promptTokenDetails = groupStatsResponse.promptTokenDetails + promptTokens = groupStatsResponse.promptTokens + promptTokensP50 = groupStatsResponse.promptTokensP50 + promptTokensP99 = groupStatsResponse.promptTokensP99 + runCount = groupStatsResponse.runCount + runFacets = groupStatsResponse.runFacets.map { it.toMutableList() } + streamingRate = groupStatsResponse.streamingRate + tokensP99 = groupStatsResponse.tokensP99 + totalCost = groupStatsResponse.totalCost + totalTokens = groupStatsResponse.totalTokens + additionalProperties = groupStatsResponse.additionalProperties.toMutableMap() + } + + fun groupCount(groupCount: Long) = groupCount(JsonField.of(groupCount)) + + /** + * Sets [Builder.groupCount] to an arbitrary JSON value. + * + * You should usually call [Builder.groupCount] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun groupCount(groupCount: JsonField<Long>) = apply { this.groupCount = groupCount } + + fun completionCost(completionCost: String?) = + completionCost(JsonField.ofNullable(completionCost)) + + /** Alias for calling [Builder.completionCost] with `completionCost.orElse(null)`. */ + fun completionCost(completionCost: Optional<String>) = + completionCost(completionCost.getOrNull()) + + /** + * Sets [Builder.completionCost] to an arbitrary JSON value. + * + * You should usually call [Builder.completionCost] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun completionCost(completionCost: JsonField<String>) = apply { + this.completionCost = completionCost + } + + fun completionCostDetails(completionCostDetails: JsonValue) = apply { + this.completionCostDetails = completionCostDetails + } + + fun completionTokenDetails(completionTokenDetails: JsonValue) = apply { + this.completionTokenDetails = completionTokenDetails + } + + fun completionTokens(completionTokens: Long?) = + completionTokens(JsonField.ofNullable(completionTokens)) + + /** + * Alias for [Builder.completionTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun completionTokens(completionTokens: Long) = completionTokens(completionTokens as Long?) + + /** Alias for calling [Builder.completionTokens] with `completionTokens.orElse(null)`. */ + fun completionTokens(completionTokens: Optional<Long>) = + completionTokens(completionTokens.getOrNull()) + + /** + * Sets [Builder.completionTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.completionTokens] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun completionTokens(completionTokens: JsonField<Long>) = apply { + this.completionTokens = completionTokens + } + + fun completionTokensP50(completionTokensP50: Long?) = + completionTokensP50(JsonField.ofNullable(completionTokensP50)) + + /** + * Alias for [Builder.completionTokensP50]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun completionTokensP50(completionTokensP50: Long) = + completionTokensP50(completionTokensP50 as Long?) + + /** + * Alias for calling [Builder.completionTokensP50] with `completionTokensP50.orElse(null)`. + */ + fun completionTokensP50(completionTokensP50: Optional<Long>) = + completionTokensP50(completionTokensP50.getOrNull()) + + /** + * Sets [Builder.completionTokensP50] to an arbitrary JSON value. + * + * You should usually call [Builder.completionTokensP50] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun completionTokensP50(completionTokensP50: JsonField<Long>) = apply { + this.completionTokensP50 = completionTokensP50 + } + + fun completionTokensP99(completionTokensP99: Long?) = + completionTokensP99(JsonField.ofNullable(completionTokensP99)) + + /** + * Alias for [Builder.completionTokensP99]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun completionTokensP99(completionTokensP99: Long) = + completionTokensP99(completionTokensP99 as Long?) + + /** + * Alias for calling [Builder.completionTokensP99] with `completionTokensP99.orElse(null)`. + */ + fun completionTokensP99(completionTokensP99: Optional<Long>) = + completionTokensP99(completionTokensP99.getOrNull()) + + /** + * Sets [Builder.completionTokensP99] to an arbitrary JSON value. + * + * You should usually call [Builder.completionTokensP99] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun completionTokensP99(completionTokensP99: JsonField<Long>) = apply { + this.completionTokensP99 = completionTokensP99 + } + + fun costP50(costP50: String?) = costP50(JsonField.ofNullable(costP50)) + + /** Alias for calling [Builder.costP50] with `costP50.orElse(null)`. */ + fun costP50(costP50: Optional<String>) = costP50(costP50.getOrNull()) + + /** + * Sets [Builder.costP50] to an arbitrary JSON value. + * + * You should usually call [Builder.costP50] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun costP50(costP50: JsonField<String>) = apply { this.costP50 = costP50 } + + fun costP99(costP99: String?) = costP99(JsonField.ofNullable(costP99)) + + /** Alias for calling [Builder.costP99] with `costP99.orElse(null)`. */ + fun costP99(costP99: Optional<String>) = costP99(costP99.getOrNull()) + + /** + * Sets [Builder.costP99] to an arbitrary JSON value. + * + * You should usually call [Builder.costP99] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun costP99(costP99: JsonField<String>) = apply { this.costP99 = costP99 } + + fun errorRate(errorRate: Double?) = errorRate(JsonField.ofNullable(errorRate)) + + /** + * Alias for [Builder.errorRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun errorRate(errorRate: Double) = errorRate(errorRate as Double?) + + /** Alias for calling [Builder.errorRate] with `errorRate.orElse(null)`. */ + fun errorRate(errorRate: Optional<Double>) = errorRate(errorRate.getOrNull()) + + /** + * Sets [Builder.errorRate] to an arbitrary JSON value. + * + * You should usually call [Builder.errorRate] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun errorRate(errorRate: JsonField<Double>) = apply { this.errorRate = errorRate } + + fun feedbackStats(feedbackStats: JsonValue) = apply { this.feedbackStats = feedbackStats } + + fun firstTokenP50(firstTokenP50: Double?) = + firstTokenP50(JsonField.ofNullable(firstTokenP50)) + + /** + * Alias for [Builder.firstTokenP50]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun firstTokenP50(firstTokenP50: Double) = firstTokenP50(firstTokenP50 as Double?) + + /** Alias for calling [Builder.firstTokenP50] with `firstTokenP50.orElse(null)`. */ + fun firstTokenP50(firstTokenP50: Optional<Double>) = + firstTokenP50(firstTokenP50.getOrNull()) + + /** + * Sets [Builder.firstTokenP50] to an arbitrary JSON value. + * + * You should usually call [Builder.firstTokenP50] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun firstTokenP50(firstTokenP50: JsonField<Double>) = apply { + this.firstTokenP50 = firstTokenP50 + } + + fun firstTokenP99(firstTokenP99: Double?) = + firstTokenP99(JsonField.ofNullable(firstTokenP99)) + + /** + * Alias for [Builder.firstTokenP99]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun firstTokenP99(firstTokenP99: Double) = firstTokenP99(firstTokenP99 as Double?) + + /** Alias for calling [Builder.firstTokenP99] with `firstTokenP99.orElse(null)`. */ + fun firstTokenP99(firstTokenP99: Optional<Double>) = + firstTokenP99(firstTokenP99.getOrNull()) + + /** + * Sets [Builder.firstTokenP99] to an arbitrary JSON value. + * + * You should usually call [Builder.firstTokenP99] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun firstTokenP99(firstTokenP99: JsonField<Double>) = apply { + this.firstTokenP99 = firstTokenP99 + } + + fun lastRunStartTime(lastRunStartTime: OffsetDateTime?) = + lastRunStartTime(JsonField.ofNullable(lastRunStartTime)) + + /** Alias for calling [Builder.lastRunStartTime] with `lastRunStartTime.orElse(null)`. */ + fun lastRunStartTime(lastRunStartTime: Optional<OffsetDateTime>) = + lastRunStartTime(lastRunStartTime.getOrNull()) + + /** + * Sets [Builder.lastRunStartTime] to an arbitrary JSON value. + * + * You should usually call [Builder.lastRunStartTime] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun lastRunStartTime(lastRunStartTime: JsonField<OffsetDateTime>) = apply { + this.lastRunStartTime = lastRunStartTime + } + + fun latencyP50(latencyP50: Double?) = latencyP50(JsonField.ofNullable(latencyP50)) + + /** + * Alias for [Builder.latencyP50]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun latencyP50(latencyP50: Double) = latencyP50(latencyP50 as Double?) + + /** Alias for calling [Builder.latencyP50] with `latencyP50.orElse(null)`. */ + fun latencyP50(latencyP50: Optional<Double>) = latencyP50(latencyP50.getOrNull()) + + /** + * Sets [Builder.latencyP50] to an arbitrary JSON value. + * + * You should usually call [Builder.latencyP50] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun latencyP50(latencyP50: JsonField<Double>) = apply { this.latencyP50 = latencyP50 } + + fun latencyP99(latencyP99: Double?) = latencyP99(JsonField.ofNullable(latencyP99)) + + /** + * Alias for [Builder.latencyP99]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun latencyP99(latencyP99: Double) = latencyP99(latencyP99 as Double?) + + /** Alias for calling [Builder.latencyP99] with `latencyP99.orElse(null)`. */ + fun latencyP99(latencyP99: Optional<Double>) = latencyP99(latencyP99.getOrNull()) + + /** + * Sets [Builder.latencyP99] to an arbitrary JSON value. + * + * You should usually call [Builder.latencyP99] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun latencyP99(latencyP99: JsonField<Double>) = apply { this.latencyP99 = latencyP99 } + + fun medianTokens(medianTokens: Long?) = medianTokens(JsonField.ofNullable(medianTokens)) + + /** + * Alias for [Builder.medianTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun medianTokens(medianTokens: Long) = medianTokens(medianTokens as Long?) + + /** Alias for calling [Builder.medianTokens] with `medianTokens.orElse(null)`. */ + fun medianTokens(medianTokens: Optional<Long>) = medianTokens(medianTokens.getOrNull()) + + /** + * Sets [Builder.medianTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.medianTokens] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun medianTokens(medianTokens: JsonField<Long>) = apply { this.medianTokens = medianTokens } + + fun promptCost(promptCost: String?) = promptCost(JsonField.ofNullable(promptCost)) + + /** Alias for calling [Builder.promptCost] with `promptCost.orElse(null)`. */ + fun promptCost(promptCost: Optional<String>) = promptCost(promptCost.getOrNull()) + + /** + * Sets [Builder.promptCost] to an arbitrary JSON value. + * + * You should usually call [Builder.promptCost] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun promptCost(promptCost: JsonField<String>) = apply { this.promptCost = promptCost } + + fun promptCostDetails(promptCostDetails: JsonValue) = apply { + this.promptCostDetails = promptCostDetails + } + + fun promptTokenDetails(promptTokenDetails: JsonValue) = apply { + this.promptTokenDetails = promptTokenDetails + } + + fun promptTokens(promptTokens: Long?) = promptTokens(JsonField.ofNullable(promptTokens)) + + /** + * Alias for [Builder.promptTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun promptTokens(promptTokens: Long) = promptTokens(promptTokens as Long?) + + /** Alias for calling [Builder.promptTokens] with `promptTokens.orElse(null)`. */ + fun promptTokens(promptTokens: Optional<Long>) = promptTokens(promptTokens.getOrNull()) + + /** + * Sets [Builder.promptTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.promptTokens] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun promptTokens(promptTokens: JsonField<Long>) = apply { this.promptTokens = promptTokens } + + fun promptTokensP50(promptTokensP50: Long?) = + promptTokensP50(JsonField.ofNullable(promptTokensP50)) + + /** + * Alias for [Builder.promptTokensP50]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun promptTokensP50(promptTokensP50: Long) = promptTokensP50(promptTokensP50 as Long?) + + /** Alias for calling [Builder.promptTokensP50] with `promptTokensP50.orElse(null)`. */ + fun promptTokensP50(promptTokensP50: Optional<Long>) = + promptTokensP50(promptTokensP50.getOrNull()) + + /** + * Sets [Builder.promptTokensP50] to an arbitrary JSON value. + * + * You should usually call [Builder.promptTokensP50] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun promptTokensP50(promptTokensP50: JsonField<Long>) = apply { + this.promptTokensP50 = promptTokensP50 + } + + fun promptTokensP99(promptTokensP99: Long?) = + promptTokensP99(JsonField.ofNullable(promptTokensP99)) + + /** + * Alias for [Builder.promptTokensP99]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun promptTokensP99(promptTokensP99: Long) = promptTokensP99(promptTokensP99 as Long?) + + /** Alias for calling [Builder.promptTokensP99] with `promptTokensP99.orElse(null)`. */ + fun promptTokensP99(promptTokensP99: Optional<Long>) = + promptTokensP99(promptTokensP99.getOrNull()) + + /** + * Sets [Builder.promptTokensP99] to an arbitrary JSON value. + * + * You should usually call [Builder.promptTokensP99] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun promptTokensP99(promptTokensP99: JsonField<Long>) = apply { + this.promptTokensP99 = promptTokensP99 + } + + fun runCount(runCount: Long?) = runCount(JsonField.ofNullable(runCount)) + + /** + * Alias for [Builder.runCount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun runCount(runCount: Long) = runCount(runCount as Long?) + + /** Alias for calling [Builder.runCount] with `runCount.orElse(null)`. */ + fun runCount(runCount: Optional<Long>) = runCount(runCount.getOrNull()) + + /** + * Sets [Builder.runCount] to an arbitrary JSON value. + * + * You should usually call [Builder.runCount] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun runCount(runCount: JsonField<Long>) = apply { this.runCount = runCount } + + fun runFacets(runFacets: List<JsonValue>?) = runFacets(JsonField.ofNullable(runFacets)) + + /** Alias for calling [Builder.runFacets] with `runFacets.orElse(null)`. */ + fun runFacets(runFacets: Optional<List<JsonValue>>) = runFacets(runFacets.getOrNull()) + + /** + * Sets [Builder.runFacets] to an arbitrary JSON value. + * + * You should usually call [Builder.runFacets] with a well-typed `List<JsonValue>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun runFacets(runFacets: JsonField<List<JsonValue>>) = apply { + this.runFacets = runFacets.map { it.toMutableList() } + } + + /** + * Adds a single [JsonValue] to [runFacets]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRunFacet(runFacet: JsonValue) = apply { + runFacets = + (runFacets ?: JsonField.of(mutableListOf())).also { + checkKnown("runFacets", it).add(runFacet) + } + } + + fun streamingRate(streamingRate: Double?) = + streamingRate(JsonField.ofNullable(streamingRate)) + + /** + * Alias for [Builder.streamingRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun streamingRate(streamingRate: Double) = streamingRate(streamingRate as Double?) + + /** Alias for calling [Builder.streamingRate] with `streamingRate.orElse(null)`. */ + fun streamingRate(streamingRate: Optional<Double>) = + streamingRate(streamingRate.getOrNull()) + + /** + * Sets [Builder.streamingRate] to an arbitrary JSON value. + * + * You should usually call [Builder.streamingRate] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun streamingRate(streamingRate: JsonField<Double>) = apply { + this.streamingRate = streamingRate + } + + fun tokensP99(tokensP99: Long?) = tokensP99(JsonField.ofNullable(tokensP99)) + + /** + * Alias for [Builder.tokensP99]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun tokensP99(tokensP99: Long) = tokensP99(tokensP99 as Long?) + + /** Alias for calling [Builder.tokensP99] with `tokensP99.orElse(null)`. */ + fun tokensP99(tokensP99: Optional<Long>) = tokensP99(tokensP99.getOrNull()) + + /** + * Sets [Builder.tokensP99] to an arbitrary JSON value. + * + * You should usually call [Builder.tokensP99] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tokensP99(tokensP99: JsonField<Long>) = apply { this.tokensP99 = tokensP99 } + + fun totalCost(totalCost: String?) = totalCost(JsonField.ofNullable(totalCost)) + + /** Alias for calling [Builder.totalCost] with `totalCost.orElse(null)`. */ + fun totalCost(totalCost: Optional<String>) = totalCost(totalCost.getOrNull()) + + /** + * Sets [Builder.totalCost] to an arbitrary JSON value. + * + * You should usually call [Builder.totalCost] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun totalCost(totalCost: JsonField<String>) = apply { this.totalCost = totalCost } + + fun totalTokens(totalTokens: Long?) = totalTokens(JsonField.ofNullable(totalTokens)) + + /** + * Alias for [Builder.totalTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun totalTokens(totalTokens: Long) = totalTokens(totalTokens as Long?) + + /** Alias for calling [Builder.totalTokens] with `totalTokens.orElse(null)`. */ + fun totalTokens(totalTokens: Optional<Long>) = totalTokens(totalTokens.getOrNull()) + + /** + * Sets [Builder.totalTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.totalTokens] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun totalTokens(totalTokens: JsonField<Long>) = apply { this.totalTokens = totalTokens } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupStatsResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupCount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupStatsResponse = + GroupStatsResponse( + checkRequired("groupCount", groupCount), + completionCost, + completionCostDetails, + completionTokenDetails, + completionTokens, + completionTokensP50, + completionTokensP99, + costP50, + costP99, + errorRate, + feedbackStats, + firstTokenP50, + firstTokenP99, + lastRunStartTime, + latencyP50, + latencyP99, + medianTokens, + promptCost, + promptCostDetails, + promptTokenDetails, + promptTokens, + promptTokensP50, + promptTokensP99, + runCount, + (runFacets ?: JsonMissing.of()).map { it.toImmutable() }, + streamingRate, + tokensP99, + totalCost, + totalTokens, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupStatsResponse = apply { + if (validated) { + return@apply + } + + groupCount() + completionCost() + completionTokens() + completionTokensP50() + completionTokensP99() + costP50() + costP99() + errorRate() + firstTokenP50() + firstTokenP99() + lastRunStartTime() + latencyP50() + latencyP99() + medianTokens() + promptCost() + promptTokens() + promptTokensP50() + promptTokensP99() + runCount() + runFacets() + streamingRate() + tokensP99() + totalCost() + totalTokens() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (groupCount.asKnown().isPresent) 1 else 0) + + (if (completionCost.asKnown().isPresent) 1 else 0) + + (if (completionTokens.asKnown().isPresent) 1 else 0) + + (if (completionTokensP50.asKnown().isPresent) 1 else 0) + + (if (completionTokensP99.asKnown().isPresent) 1 else 0) + + (if (costP50.asKnown().isPresent) 1 else 0) + + (if (costP99.asKnown().isPresent) 1 else 0) + + (if (errorRate.asKnown().isPresent) 1 else 0) + + (if (firstTokenP50.asKnown().isPresent) 1 else 0) + + (if (firstTokenP99.asKnown().isPresent) 1 else 0) + + (if (lastRunStartTime.asKnown().isPresent) 1 else 0) + + (if (latencyP50.asKnown().isPresent) 1 else 0) + + (if (latencyP99.asKnown().isPresent) 1 else 0) + + (if (medianTokens.asKnown().isPresent) 1 else 0) + + (if (promptCost.asKnown().isPresent) 1 else 0) + + (if (promptTokens.asKnown().isPresent) 1 else 0) + + (if (promptTokensP50.asKnown().isPresent) 1 else 0) + + (if (promptTokensP99.asKnown().isPresent) 1 else 0) + + (if (runCount.asKnown().isPresent) 1 else 0) + + (runFacets.asKnown().getOrNull()?.size ?: 0) + + (if (streamingRate.asKnown().isPresent) 1 else 0) + + (if (tokensP99.asKnown().isPresent) 1 else 0) + + (if (totalCost.asKnown().isPresent) 1 else 0) + + (if (totalTokens.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupStatsResponse && + groupCount == other.groupCount && + completionCost == other.completionCost && + completionCostDetails == other.completionCostDetails && + completionTokenDetails == other.completionTokenDetails && + completionTokens == other.completionTokens && + completionTokensP50 == other.completionTokensP50 && + completionTokensP99 == other.completionTokensP99 && + costP50 == other.costP50 && + costP99 == other.costP99 && + errorRate == other.errorRate && + feedbackStats == other.feedbackStats && + firstTokenP50 == other.firstTokenP50 && + firstTokenP99 == other.firstTokenP99 && + lastRunStartTime == other.lastRunStartTime && + latencyP50 == other.latencyP50 && + latencyP99 == other.latencyP99 && + medianTokens == other.medianTokens && + promptCost == other.promptCost && + promptCostDetails == other.promptCostDetails && + promptTokenDetails == other.promptTokenDetails && + promptTokens == other.promptTokens && + promptTokensP50 == other.promptTokensP50 && + promptTokensP99 == other.promptTokensP99 && + runCount == other.runCount && + runFacets == other.runFacets && + streamingRate == other.streamingRate && + tokensP99 == other.tokensP99 && + totalCost == other.totalCost && + totalTokens == other.totalTokens && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupCount, + completionCost, + completionCostDetails, + completionTokenDetails, + completionTokens, + completionTokensP50, + completionTokensP99, + costP50, + costP99, + errorRate, + feedbackStats, + firstTokenP50, + firstTokenP99, + lastRunStartTime, + latencyP50, + latencyP99, + medianTokens, + promptCost, + promptCostDetails, + promptTokenDetails, + promptTokens, + promptTokensP50, + promptTokensP99, + runCount, + runFacets, + streamingRate, + tokensP99, + totalCost, + totalTokens, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupStatsResponse{groupCount=$groupCount, completionCost=$completionCost, completionCostDetails=$completionCostDetails, completionTokenDetails=$completionTokenDetails, completionTokens=$completionTokens, completionTokensP50=$completionTokensP50, completionTokensP99=$completionTokensP99, costP50=$costP50, costP99=$costP99, errorRate=$errorRate, feedbackStats=$feedbackStats, firstTokenP50=$firstTokenP50, firstTokenP99=$firstTokenP99, lastRunStartTime=$lastRunStartTime, latencyP50=$latencyP50, latencyP99=$latencyP99, medianTokens=$medianTokens, promptCost=$promptCost, promptCostDetails=$promptCostDetails, promptTokenDetails=$promptTokenDetails, promptTokens=$promptTokens, promptTokensP50=$promptTokensP50, promptTokensP99=$promptTokensP99, runCount=$runCount, runFacets=$runFacets, streamingRate=$streamingRate, tokensP99=$tokensP99, totalCost=$totalCost, totalTokens=$totalTokens, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/group/RunGroupRequest.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/group/RunGroupRequest.kt new file mode 100644 index 00000000..b6c14ce6 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/group/RunGroupRequest.kt @@ -0,0 +1,514 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.group + +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.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class RunGroupRequest +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val groupBy: JsonField<GroupBy>, + private val sessionId: JsonField<String>, + private val endTime: JsonField<OffsetDateTime>, + private val filter: JsonField<String>, + private val limit: JsonField<Long>, + private val offset: JsonField<Long>, + private val startTime: JsonField<OffsetDateTime>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("group_by") @ExcludeMissing groupBy: JsonField<GroupBy> = JsonMissing.of(), + @JsonProperty("session_id") @ExcludeMissing sessionId: JsonField<String> = JsonMissing.of(), + @JsonProperty("end_time") + @ExcludeMissing + endTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("filter") @ExcludeMissing filter: JsonField<String> = JsonMissing.of(), + @JsonProperty("limit") @ExcludeMissing limit: JsonField<Long> = JsonMissing.of(), + @JsonProperty("offset") @ExcludeMissing offset: JsonField<Long> = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField<OffsetDateTime> = JsonMissing.of(), + ) : this(groupBy, sessionId, endTime, filter, limit, offset, startTime, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupBy(): GroupBy = groupBy.getRequired("group_by") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun sessionId(): String = sessionId.getRequired("session_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endTime(): Optional<OffsetDateTime> = endTime.getOptional("end_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun filter(): Optional<String> = filter.getOptional("filter") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun limit(): Optional<Long> = limit.getOptional("limit") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun offset(): Optional<Long> = offset.getOptional("offset") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun startTime(): Optional<OffsetDateTime> = startTime.getOptional("start_time") + + /** + * Returns the raw JSON value of [groupBy]. + * + * Unlike [groupBy], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("group_by") @ExcludeMissing fun _groupBy(): JsonField<GroupBy> = groupBy + + /** + * Returns the raw JSON value of [sessionId]. + * + * Unlike [sessionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session_id") @ExcludeMissing fun _sessionId(): JsonField<String> = sessionId + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_time") @ExcludeMissing fun _endTime(): JsonField<OffsetDateTime> = endTime + + /** + * Returns the raw JSON value of [filter]. + * + * Unlike [filter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField<String> = filter + + /** + * Returns the raw JSON value of [limit]. + * + * Unlike [limit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("limit") @ExcludeMissing fun _limit(): JsonField<Long> = limit + + /** + * Returns the raw JSON value of [offset]. + * + * Unlike [offset], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("offset") @ExcludeMissing fun _offset(): JsonField<Long> = offset + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_time") + @ExcludeMissing + fun _startTime(): JsonField<OffsetDateTime> = startTime + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RunGroupRequest]. + * + * The following fields are required: + * ```java + * .groupBy() + * .sessionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunGroupRequest]. */ + class Builder internal constructor() { + + private var groupBy: JsonField<GroupBy>? = null + private var sessionId: JsonField<String>? = null + private var endTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var filter: JsonField<String> = JsonMissing.of() + private var limit: JsonField<Long> = JsonMissing.of() + private var offset: JsonField<Long> = JsonMissing.of() + private var startTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(runGroupRequest: RunGroupRequest) = apply { + groupBy = runGroupRequest.groupBy + sessionId = runGroupRequest.sessionId + endTime = runGroupRequest.endTime + filter = runGroupRequest.filter + limit = runGroupRequest.limit + offset = runGroupRequest.offset + startTime = runGroupRequest.startTime + additionalProperties = runGroupRequest.additionalProperties.toMutableMap() + } + + fun groupBy(groupBy: GroupBy) = groupBy(JsonField.of(groupBy)) + + /** + * Sets [Builder.groupBy] to an arbitrary JSON value. + * + * You should usually call [Builder.groupBy] with a well-typed [GroupBy] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun groupBy(groupBy: JsonField<GroupBy>) = apply { this.groupBy = groupBy } + + fun sessionId(sessionId: String) = sessionId(JsonField.of(sessionId)) + + /** + * Sets [Builder.sessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun sessionId(sessionId: JsonField<String>) = apply { this.sessionId = sessionId } + + fun endTime(endTime: OffsetDateTime?) = endTime(JsonField.ofNullable(endTime)) + + /** Alias for calling [Builder.endTime] with `endTime.orElse(null)`. */ + fun endTime(endTime: Optional<OffsetDateTime>) = endTime(endTime.getOrNull()) + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endTime(endTime: JsonField<OffsetDateTime>) = apply { this.endTime = endTime } + + fun filter(filter: String?) = filter(JsonField.ofNullable(filter)) + + /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ + fun filter(filter: Optional<String>) = filter(filter.getOrNull()) + + /** + * Sets [Builder.filter] to an arbitrary JSON value. + * + * You should usually call [Builder.filter] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun filter(filter: JsonField<String>) = apply { this.filter = filter } + + fun limit(limit: Long) = limit(JsonField.of(limit)) + + /** + * Sets [Builder.limit] to an arbitrary JSON value. + * + * You should usually call [Builder.limit] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun limit(limit: JsonField<Long>) = apply { this.limit = limit } + + fun offset(offset: Long) = offset(JsonField.of(offset)) + + /** + * Sets [Builder.offset] to an arbitrary JSON value. + * + * You should usually call [Builder.offset] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun offset(offset: JsonField<Long>) = apply { this.offset = offset } + + fun startTime(startTime: OffsetDateTime?) = startTime(JsonField.ofNullable(startTime)) + + /** Alias for calling [Builder.startTime] with `startTime.orElse(null)`. */ + fun startTime(startTime: Optional<OffsetDateTime>) = startTime(startTime.getOrNull()) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField<OffsetDateTime>) = apply { this.startTime = startTime } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RunGroupRequest]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupBy() + * .sessionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RunGroupRequest = + RunGroupRequest( + checkRequired("groupBy", groupBy), + checkRequired("sessionId", sessionId), + endTime, + filter, + limit, + offset, + startTime, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RunGroupRequest = apply { + if (validated) { + return@apply + } + + groupBy().validate() + sessionId() + endTime() + filter() + limit() + offset() + startTime() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (groupBy.asKnown().getOrNull()?.validity() ?: 0) + + (if (sessionId.asKnown().isPresent) 1 else 0) + + (if (endTime.asKnown().isPresent) 1 else 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (if (limit.asKnown().isPresent) 1 else 0) + + (if (offset.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + class GroupBy @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val CONVERSATION = of("conversation") + + @JvmStatic fun of(value: String) = GroupBy(JsonField.of(value)) + } + + /** An enum containing [GroupBy]'s known values. */ + enum class Known { + CONVERSATION + } + + /** + * An enum containing [GroupBy]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [GroupBy] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CONVERSATION, + /** An enum member indicating that [GroupBy] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CONVERSATION -> Value.CONVERSATION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CONVERSATION -> Known.CONVERSATION + else -> throw LangsmithApiInvalidDataException("Unknown GroupBy: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): GroupBy = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupBy && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunGroupRequest && + groupBy == other.groupBy && + sessionId == other.sessionId && + endTime == other.endTime && + filter == other.filter && + limit == other.limit && + offset == other.offset && + startTime == other.startTime && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupBy, + sessionId, + endTime, + filter, + limit, + offset, + startTime, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RunGroupRequest{groupBy=$groupBy, sessionId=$sessionId, endTime=$endTime, filter=$filter, limit=$limit, offset=$offset, startTime=$startTime, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/CodeEvaluatorTopLevel.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/CodeEvaluatorTopLevel.kt new file mode 100644 index 00000000..413e71b0 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/CodeEvaluatorTopLevel.kt @@ -0,0 +1,336 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.rules + +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.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class CodeEvaluatorTopLevel +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val code: JsonField<String>, + private val language: JsonField<Language>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField<String> = JsonMissing.of(), + @JsonProperty("language") @ExcludeMissing language: JsonField<Language> = JsonMissing.of(), + ) : this(code, language, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): String = code.getRequired("code") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun language(): Optional<Language> = language.getOptional("language") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField<String> = code + + /** + * Returns the raw JSON value of [language]. + * + * Unlike [language], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("language") @ExcludeMissing fun _language(): JsonField<Language> = language + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CodeEvaluatorTopLevel]. + * + * The following fields are required: + * ```java + * .code() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CodeEvaluatorTopLevel]. */ + class Builder internal constructor() { + + private var code: JsonField<String>? = null + private var language: JsonField<Language> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(codeEvaluatorTopLevel: CodeEvaluatorTopLevel) = apply { + code = codeEvaluatorTopLevel.code + language = codeEvaluatorTopLevel.language + additionalProperties = codeEvaluatorTopLevel.additionalProperties.toMutableMap() + } + + fun code(code: String) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun code(code: JsonField<String>) = apply { this.code = code } + + fun language(language: Language?) = language(JsonField.ofNullable(language)) + + /** Alias for calling [Builder.language] with `language.orElse(null)`. */ + fun language(language: Optional<Language>) = language(language.getOrNull()) + + /** + * Sets [Builder.language] to an arbitrary JSON value. + * + * You should usually call [Builder.language] with a well-typed [Language] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun language(language: JsonField<Language>) = apply { this.language = language } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CodeEvaluatorTopLevel]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CodeEvaluatorTopLevel = + CodeEvaluatorTopLevel( + checkRequired("code", code), + language, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CodeEvaluatorTopLevel = apply { + if (validated) { + return@apply + } + + code() + language().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + (language.asKnown().getOrNull()?.validity() ?: 0) + + class Language @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val PYTHON = of("python") + + @JvmField val JAVASCRIPT = of("javascript") + + @JvmStatic fun of(value: String) = Language(JsonField.of(value)) + } + + /** An enum containing [Language]'s known values. */ + enum class Known { + PYTHON, + JAVASCRIPT, + } + + /** + * An enum containing [Language]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Language] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PYTHON, + JAVASCRIPT, + /** An enum member indicating that [Language] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PYTHON -> Value.PYTHON + JAVASCRIPT -> Value.JAVASCRIPT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PYTHON -> Known.PYTHON + JAVASCRIPT -> Known.JAVASCRIPT + else -> throw LangsmithApiInvalidDataException("Unknown Language: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Language = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Language && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CodeEvaluatorTopLevel && + code == other.code && + language == other.language && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(code, language, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CodeEvaluatorTopLevel{code=$code, language=$language, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/EvaluatorTopLevel.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/EvaluatorTopLevel.kt new file mode 100644 index 00000000..093264bc --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/EvaluatorTopLevel.kt @@ -0,0 +1,605 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.rules + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class EvaluatorTopLevel +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val structured: JsonField<Structured>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("structured") + @ExcludeMissing + structured: JsonField<Structured> = JsonMissing.of() + ) : this(structured, mutableMapOf()) + + /** + * Evaluator structured output schema. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun structured(): Structured = structured.getRequired("structured") + + /** + * Returns the raw JSON value of [structured]. + * + * Unlike [structured], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("structured") + @ExcludeMissing + fun _structured(): JsonField<Structured> = structured + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [EvaluatorTopLevel]. + * + * The following fields are required: + * ```java + * .structured() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EvaluatorTopLevel]. */ + class Builder internal constructor() { + + private var structured: JsonField<Structured>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(evaluatorTopLevel: EvaluatorTopLevel) = apply { + structured = evaluatorTopLevel.structured + additionalProperties = evaluatorTopLevel.additionalProperties.toMutableMap() + } + + /** Evaluator structured output schema. */ + fun structured(structured: Structured) = structured(JsonField.of(structured)) + + /** + * Sets [Builder.structured] to an arbitrary JSON value. + * + * You should usually call [Builder.structured] with a well-typed [Structured] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun structured(structured: JsonField<Structured>) = apply { this.structured = structured } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EvaluatorTopLevel]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .structured() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EvaluatorTopLevel = + EvaluatorTopLevel( + checkRequired("structured", structured), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EvaluatorTopLevel = apply { + if (validated) { + return@apply + } + + structured().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (structured.asKnown().getOrNull()?.validity() ?: 0) + + /** Evaluator structured output schema. */ + class Structured + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val hubRef: JsonField<String>, + private val model: JsonValue, + private val prompt: JsonField<List<List<JsonValue>>>, + private val schema: JsonValue, + private val templateFormat: JsonField<String>, + private val variableMapping: JsonField<VariableMapping>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("hub_ref") @ExcludeMissing hubRef: JsonField<String> = JsonMissing.of(), + @JsonProperty("model") @ExcludeMissing model: JsonValue = JsonMissing.of(), + @JsonProperty("prompt") + @ExcludeMissing + prompt: JsonField<List<List<JsonValue>>> = JsonMissing.of(), + @JsonProperty("schema") @ExcludeMissing schema: JsonValue = JsonMissing.of(), + @JsonProperty("template_format") + @ExcludeMissing + templateFormat: JsonField<String> = JsonMissing.of(), + @JsonProperty("variable_mapping") + @ExcludeMissing + variableMapping: JsonField<VariableMapping> = JsonMissing.of(), + ) : this(hubRef, model, prompt, schema, templateFormat, variableMapping, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun hubRef(): Optional<String> = hubRef.getOptional("hub_ref") + + @JsonProperty("model") @ExcludeMissing fun _model(): JsonValue = model + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun prompt(): Optional<List<List<JsonValue>>> = prompt.getOptional("prompt") + + @JsonProperty("schema") @ExcludeMissing fun _schema(): JsonValue = schema + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun templateFormat(): Optional<String> = templateFormat.getOptional("template_format") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun variableMapping(): Optional<VariableMapping> = + variableMapping.getOptional("variable_mapping") + + /** + * Returns the raw JSON value of [hubRef]. + * + * Unlike [hubRef], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("hub_ref") @ExcludeMissing fun _hubRef(): JsonField<String> = hubRef + + /** + * Returns the raw JSON value of [prompt]. + * + * Unlike [prompt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prompt") + @ExcludeMissing + fun _prompt(): JsonField<List<List<JsonValue>>> = prompt + + /** + * Returns the raw JSON value of [templateFormat]. + * + * Unlike [templateFormat], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("template_format") + @ExcludeMissing + fun _templateFormat(): JsonField<String> = templateFormat + + /** + * Returns the raw JSON value of [variableMapping]. + * + * Unlike [variableMapping], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("variable_mapping") + @ExcludeMissing + fun _variableMapping(): JsonField<VariableMapping> = variableMapping + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Structured]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Structured]. */ + class Builder internal constructor() { + + private var hubRef: JsonField<String> = JsonMissing.of() + private var model: JsonValue = JsonMissing.of() + private var prompt: JsonField<MutableList<List<JsonValue>>>? = null + private var schema: JsonValue = JsonMissing.of() + private var templateFormat: JsonField<String> = JsonMissing.of() + private var variableMapping: JsonField<VariableMapping> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(structured: Structured) = apply { + hubRef = structured.hubRef + model = structured.model + prompt = structured.prompt.map { it.toMutableList() } + schema = structured.schema + templateFormat = structured.templateFormat + variableMapping = structured.variableMapping + additionalProperties = structured.additionalProperties.toMutableMap() + } + + fun hubRef(hubRef: String?) = hubRef(JsonField.ofNullable(hubRef)) + + /** Alias for calling [Builder.hubRef] with `hubRef.orElse(null)`. */ + fun hubRef(hubRef: Optional<String>) = hubRef(hubRef.getOrNull()) + + /** + * Sets [Builder.hubRef] to an arbitrary JSON value. + * + * You should usually call [Builder.hubRef] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun hubRef(hubRef: JsonField<String>) = apply { this.hubRef = hubRef } + + fun model(model: JsonValue) = apply { this.model = model } + + fun prompt(prompt: List<List<JsonValue>>?) = prompt(JsonField.ofNullable(prompt)) + + /** Alias for calling [Builder.prompt] with `prompt.orElse(null)`. */ + fun prompt(prompt: Optional<List<List<JsonValue>>>) = prompt(prompt.getOrNull()) + + /** + * Sets [Builder.prompt] to an arbitrary JSON value. + * + * You should usually call [Builder.prompt] with a well-typed `List<List<JsonValue>>` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun prompt(prompt: JsonField<List<List<JsonValue>>>) = apply { + this.prompt = prompt.map { it.toMutableList() } + } + + /** + * Adds a single [List<JsonValue>] to [Builder.prompt]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPrompt(prompt: List<JsonValue>) = apply { + this.prompt = + (this.prompt ?: JsonField.of(mutableListOf())).also { + checkKnown("prompt", it).add(prompt) + } + } + + fun schema(schema: JsonValue) = apply { this.schema = schema } + + fun templateFormat(templateFormat: String?) = + templateFormat(JsonField.ofNullable(templateFormat)) + + /** Alias for calling [Builder.templateFormat] with `templateFormat.orElse(null)`. */ + fun templateFormat(templateFormat: Optional<String>) = + templateFormat(templateFormat.getOrNull()) + + /** + * Sets [Builder.templateFormat] to an arbitrary JSON value. + * + * You should usually call [Builder.templateFormat] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun templateFormat(templateFormat: JsonField<String>) = apply { + this.templateFormat = templateFormat + } + + fun variableMapping(variableMapping: VariableMapping?) = + variableMapping(JsonField.ofNullable(variableMapping)) + + /** Alias for calling [Builder.variableMapping] with `variableMapping.orElse(null)`. */ + fun variableMapping(variableMapping: Optional<VariableMapping>) = + variableMapping(variableMapping.getOrNull()) + + /** + * Sets [Builder.variableMapping] to an arbitrary JSON value. + * + * You should usually call [Builder.variableMapping] with a well-typed [VariableMapping] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun variableMapping(variableMapping: JsonField<VariableMapping>) = apply { + this.variableMapping = variableMapping + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Structured]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Structured = + Structured( + hubRef, + model, + (prompt ?: JsonMissing.of()).map { it.toImmutable() }, + schema, + templateFormat, + variableMapping, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Structured = apply { + if (validated) { + return@apply + } + + hubRef() + prompt() + templateFormat() + variableMapping().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (hubRef.asKnown().isPresent) 1 else 0) + + (prompt.asKnown().getOrNull()?.sumOf { it.size.toInt() } ?: 0) + + (if (templateFormat.asKnown().isPresent) 1 else 0) + + (variableMapping.asKnown().getOrNull()?.validity() ?: 0) + + class VariableMapping + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [VariableMapping]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VariableMapping]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(variableMapping: VariableMapping) = apply { + additionalProperties = variableMapping.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [VariableMapping]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VariableMapping = VariableMapping(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): VariableMapping = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VariableMapping && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "VariableMapping{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Structured && + hubRef == other.hubRef && + model == other.model && + prompt == other.prompt && + schema == other.schema && + templateFormat == other.templateFormat && + variableMapping == other.variableMapping && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + hubRef, + model, + prompt, + schema, + templateFormat, + variableMapping, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Structured{hubRef=$hubRef, model=$model, prompt=$prompt, schema=$schema, templateFormat=$templateFormat, variableMapping=$variableMapping, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EvaluatorTopLevel && + structured == other.structured && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(structured, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EvaluatorTopLevel{structured=$structured, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleCreateParams.kt new file mode 100644 index 00000000..540c854b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleCreateParams.kt @@ -0,0 +1,2316 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.rules + +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.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create a new run rule. */ +class RuleCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun displayName(): String = body.displayName() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun samplingRate(): Double = body.samplingRate() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun addToAnnotationQueueId(): Optional<String> = body.addToAnnotationQueueId() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun addToDatasetId(): Optional<String> = body.addToDatasetId() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun addToDatasetPreferCorrection(): Optional<Boolean> = body.addToDatasetPreferCorrection() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun alerts(): Optional<List<RunRulesPagerdutyAlertSchema>> = body.alerts() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun backfillFrom(): Optional<OffsetDateTime> = body.backfillFrom() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun codeEvaluators(): Optional<List<CodeEvaluatorTopLevel>> = body.codeEvaluators() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun createAlignmentQueue(): Optional<Boolean> = body.createAlignmentQueue() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun datasetId(): Optional<String> = body.datasetId() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun evaluatorVersion(): Optional<Long> = body.evaluatorVersion() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun evaluators(): Optional<List<EvaluatorTopLevel>> = body.evaluators() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun extendOnly(): Optional<Boolean> = body.extendOnly() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun filter(): Optional<String> = body.filter() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun groupBy(): Optional<GroupBy> = body.groupBy() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun includeExtendedStats(): Optional<Boolean> = body.includeExtendedStats() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun isEnabled(): Optional<Boolean> = body.isEnabled() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun numFewShotExamples(): Optional<Long> = body.numFewShotExamples() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun sessionId(): Optional<String> = body.sessionId() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun traceFilter(): Optional<String> = body.traceFilter() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun transient_(): Optional<Boolean> = body.transient_() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun treeFilter(): Optional<String> = body.treeFilter() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun useCorrectionsDataset(): Optional<Boolean> = body.useCorrectionsDataset() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webhooks(): Optional<List<RunRulesWebhookSchema>> = body.webhooks() + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _displayName(): JsonField<String> = body._displayName() + + /** + * Returns the raw JSON value of [samplingRate]. + * + * Unlike [samplingRate], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _samplingRate(): JsonField<Double> = body._samplingRate() + + /** + * Returns the raw JSON value of [addToAnnotationQueueId]. + * + * Unlike [addToAnnotationQueueId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _addToAnnotationQueueId(): JsonField<String> = body._addToAnnotationQueueId() + + /** + * Returns the raw JSON value of [addToDatasetId]. + * + * Unlike [addToDatasetId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _addToDatasetId(): JsonField<String> = body._addToDatasetId() + + /** + * Returns the raw JSON value of [addToDatasetPreferCorrection]. + * + * Unlike [addToDatasetPreferCorrection], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _addToDatasetPreferCorrection(): JsonField<Boolean> = body._addToDatasetPreferCorrection() + + /** + * Returns the raw JSON value of [alerts]. + * + * Unlike [alerts], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _alerts(): JsonField<List<RunRulesPagerdutyAlertSchema>> = body._alerts() + + /** + * Returns the raw JSON value of [backfillFrom]. + * + * Unlike [backfillFrom], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _backfillFrom(): JsonField<OffsetDateTime> = body._backfillFrom() + + /** + * Returns the raw JSON value of [codeEvaluators]. + * + * Unlike [codeEvaluators], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _codeEvaluators(): JsonField<List<CodeEvaluatorTopLevel>> = body._codeEvaluators() + + /** + * Returns the raw JSON value of [createAlignmentQueue]. + * + * Unlike [createAlignmentQueue], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _createAlignmentQueue(): JsonField<Boolean> = body._createAlignmentQueue() + + /** + * Returns the raw JSON value of [datasetId]. + * + * Unlike [datasetId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _datasetId(): JsonField<String> = body._datasetId() + + /** + * Returns the raw JSON value of [evaluatorVersion]. + * + * Unlike [evaluatorVersion], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _evaluatorVersion(): JsonField<Long> = body._evaluatorVersion() + + /** + * Returns the raw JSON value of [evaluators]. + * + * Unlike [evaluators], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _evaluators(): JsonField<List<EvaluatorTopLevel>> = body._evaluators() + + /** + * Returns the raw JSON value of [extendOnly]. + * + * Unlike [extendOnly], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _extendOnly(): JsonField<Boolean> = body._extendOnly() + + /** + * Returns the raw JSON value of [filter]. + * + * Unlike [filter], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _filter(): JsonField<String> = body._filter() + + /** + * Returns the raw JSON value of [groupBy]. + * + * Unlike [groupBy], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _groupBy(): JsonField<GroupBy> = body._groupBy() + + /** + * Returns the raw JSON value of [includeExtendedStats]. + * + * Unlike [includeExtendedStats], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _includeExtendedStats(): JsonField<Boolean> = body._includeExtendedStats() + + /** + * Returns the raw JSON value of [isEnabled]. + * + * Unlike [isEnabled], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _isEnabled(): JsonField<Boolean> = body._isEnabled() + + /** + * Returns the raw JSON value of [numFewShotExamples]. + * + * Unlike [numFewShotExamples], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _numFewShotExamples(): JsonField<Long> = body._numFewShotExamples() + + /** + * Returns the raw JSON value of [sessionId]. + * + * Unlike [sessionId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _sessionId(): JsonField<String> = body._sessionId() + + /** + * Returns the raw JSON value of [traceFilter]. + * + * Unlike [traceFilter], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _traceFilter(): JsonField<String> = body._traceFilter() + + /** + * Returns the raw JSON value of [transient_]. + * + * Unlike [transient_], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _transient_(): JsonField<Boolean> = body._transient_() + + /** + * Returns the raw JSON value of [treeFilter]. + * + * Unlike [treeFilter], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _treeFilter(): JsonField<String> = body._treeFilter() + + /** + * Returns the raw JSON value of [useCorrectionsDataset]. + * + * Unlike [useCorrectionsDataset], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _useCorrectionsDataset(): JsonField<Boolean> = body._useCorrectionsDataset() + + /** + * Returns the raw JSON value of [webhooks]. + * + * Unlike [webhooks], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _webhooks(): JsonField<List<RunRulesWebhookSchema>> = body._webhooks() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RuleCreateParams]. + * + * The following fields are required: + * ```java + * .displayName() + * .samplingRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RuleCreateParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(ruleCreateParams: RuleCreateParams) = apply { + body = ruleCreateParams.body.toBuilder() + additionalHeaders = ruleCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = ruleCreateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [displayName] + * - [samplingRate] + * - [addToAnnotationQueueId] + * - [addToDatasetId] + * - [addToDatasetPreferCorrection] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun displayName(displayName: String) = apply { body.displayName(displayName) } + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun displayName(displayName: JsonField<String>) = apply { body.displayName(displayName) } + + fun samplingRate(samplingRate: Double) = apply { body.samplingRate(samplingRate) } + + /** + * Sets [Builder.samplingRate] to an arbitrary JSON value. + * + * You should usually call [Builder.samplingRate] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun samplingRate(samplingRate: JsonField<Double>) = apply { + body.samplingRate(samplingRate) + } + + fun addToAnnotationQueueId(addToAnnotationQueueId: String?) = apply { + body.addToAnnotationQueueId(addToAnnotationQueueId) + } + + /** + * Alias for calling [Builder.addToAnnotationQueueId] with + * `addToAnnotationQueueId.orElse(null)`. + */ + fun addToAnnotationQueueId(addToAnnotationQueueId: Optional<String>) = + addToAnnotationQueueId(addToAnnotationQueueId.getOrNull()) + + /** + * Sets [Builder.addToAnnotationQueueId] to an arbitrary JSON value. + * + * You should usually call [Builder.addToAnnotationQueueId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun addToAnnotationQueueId(addToAnnotationQueueId: JsonField<String>) = apply { + body.addToAnnotationQueueId(addToAnnotationQueueId) + } + + fun addToDatasetId(addToDatasetId: String?) = apply { body.addToDatasetId(addToDatasetId) } + + /** Alias for calling [Builder.addToDatasetId] with `addToDatasetId.orElse(null)`. */ + fun addToDatasetId(addToDatasetId: Optional<String>) = + addToDatasetId(addToDatasetId.getOrNull()) + + /** + * Sets [Builder.addToDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.addToDatasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun addToDatasetId(addToDatasetId: JsonField<String>) = apply { + body.addToDatasetId(addToDatasetId) + } + + fun addToDatasetPreferCorrection(addToDatasetPreferCorrection: Boolean) = apply { + body.addToDatasetPreferCorrection(addToDatasetPreferCorrection) + } + + /** + * Sets [Builder.addToDatasetPreferCorrection] to an arbitrary JSON value. + * + * You should usually call [Builder.addToDatasetPreferCorrection] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun addToDatasetPreferCorrection(addToDatasetPreferCorrection: JsonField<Boolean>) = apply { + body.addToDatasetPreferCorrection(addToDatasetPreferCorrection) + } + + fun alerts(alerts: List<RunRulesPagerdutyAlertSchema>?) = apply { body.alerts(alerts) } + + /** Alias for calling [Builder.alerts] with `alerts.orElse(null)`. */ + fun alerts(alerts: Optional<List<RunRulesPagerdutyAlertSchema>>) = + alerts(alerts.getOrNull()) + + /** + * Sets [Builder.alerts] to an arbitrary JSON value. + * + * You should usually call [Builder.alerts] with a well-typed + * `List<RunRulesPagerdutyAlertSchema>` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun alerts(alerts: JsonField<List<RunRulesPagerdutyAlertSchema>>) = apply { + body.alerts(alerts) + } + + /** + * Adds a single [RunRulesPagerdutyAlertSchema] to [alerts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAlert(alert: RunRulesPagerdutyAlertSchema) = apply { body.addAlert(alert) } + + fun backfillFrom(backfillFrom: OffsetDateTime?) = apply { body.backfillFrom(backfillFrom) } + + /** Alias for calling [Builder.backfillFrom] with `backfillFrom.orElse(null)`. */ + fun backfillFrom(backfillFrom: Optional<OffsetDateTime>) = + backfillFrom(backfillFrom.getOrNull()) + + /** + * Sets [Builder.backfillFrom] to an arbitrary JSON value. + * + * You should usually call [Builder.backfillFrom] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun backfillFrom(backfillFrom: JsonField<OffsetDateTime>) = apply { + body.backfillFrom(backfillFrom) + } + + fun codeEvaluators(codeEvaluators: List<CodeEvaluatorTopLevel>?) = apply { + body.codeEvaluators(codeEvaluators) + } + + /** Alias for calling [Builder.codeEvaluators] with `codeEvaluators.orElse(null)`. */ + fun codeEvaluators(codeEvaluators: Optional<List<CodeEvaluatorTopLevel>>) = + codeEvaluators(codeEvaluators.getOrNull()) + + /** + * Sets [Builder.codeEvaluators] to an arbitrary JSON value. + * + * You should usually call [Builder.codeEvaluators] with a well-typed + * `List<CodeEvaluatorTopLevel>` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun codeEvaluators(codeEvaluators: JsonField<List<CodeEvaluatorTopLevel>>) = apply { + body.codeEvaluators(codeEvaluators) + } + + /** + * Adds a single [CodeEvaluatorTopLevel] to [codeEvaluators]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCodeEvaluator(codeEvaluator: CodeEvaluatorTopLevel) = apply { + body.addCodeEvaluator(codeEvaluator) + } + + fun createAlignmentQueue(createAlignmentQueue: Boolean) = apply { + body.createAlignmentQueue(createAlignmentQueue) + } + + /** + * Sets [Builder.createAlignmentQueue] to an arbitrary JSON value. + * + * You should usually call [Builder.createAlignmentQueue] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createAlignmentQueue(createAlignmentQueue: JsonField<Boolean>) = apply { + body.createAlignmentQueue(createAlignmentQueue) + } + + fun datasetId(datasetId: String?) = apply { body.datasetId(datasetId) } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + /** + * Sets [Builder.datasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun datasetId(datasetId: JsonField<String>) = apply { body.datasetId(datasetId) } + + fun evaluatorVersion(evaluatorVersion: Long?) = apply { + body.evaluatorVersion(evaluatorVersion) + } + + /** + * Alias for [Builder.evaluatorVersion]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun evaluatorVersion(evaluatorVersion: Long) = evaluatorVersion(evaluatorVersion as Long?) + + /** Alias for calling [Builder.evaluatorVersion] with `evaluatorVersion.orElse(null)`. */ + fun evaluatorVersion(evaluatorVersion: Optional<Long>) = + evaluatorVersion(evaluatorVersion.getOrNull()) + + /** + * Sets [Builder.evaluatorVersion] to an arbitrary JSON value. + * + * You should usually call [Builder.evaluatorVersion] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun evaluatorVersion(evaluatorVersion: JsonField<Long>) = apply { + body.evaluatorVersion(evaluatorVersion) + } + + fun evaluators(evaluators: List<EvaluatorTopLevel>?) = apply { body.evaluators(evaluators) } + + /** Alias for calling [Builder.evaluators] with `evaluators.orElse(null)`. */ + fun evaluators(evaluators: Optional<List<EvaluatorTopLevel>>) = + evaluators(evaluators.getOrNull()) + + /** + * Sets [Builder.evaluators] to an arbitrary JSON value. + * + * You should usually call [Builder.evaluators] with a well-typed `List<EvaluatorTopLevel>` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun evaluators(evaluators: JsonField<List<EvaluatorTopLevel>>) = apply { + body.evaluators(evaluators) + } + + /** + * Adds a single [EvaluatorTopLevel] to [evaluators]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvaluator(evaluator: EvaluatorTopLevel) = apply { body.addEvaluator(evaluator) } + + fun extendOnly(extendOnly: Boolean) = apply { body.extendOnly(extendOnly) } + + /** + * Sets [Builder.extendOnly] to an arbitrary JSON value. + * + * You should usually call [Builder.extendOnly] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun extendOnly(extendOnly: JsonField<Boolean>) = apply { body.extendOnly(extendOnly) } + + fun filter(filter: String?) = apply { body.filter(filter) } + + /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ + fun filter(filter: Optional<String>) = filter(filter.getOrNull()) + + /** + * Sets [Builder.filter] to an arbitrary JSON value. + * + * You should usually call [Builder.filter] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun filter(filter: JsonField<String>) = apply { body.filter(filter) } + + fun groupBy(groupBy: GroupBy?) = apply { body.groupBy(groupBy) } + + /** Alias for calling [Builder.groupBy] with `groupBy.orElse(null)`. */ + fun groupBy(groupBy: Optional<GroupBy>) = groupBy(groupBy.getOrNull()) + + /** + * Sets [Builder.groupBy] to an arbitrary JSON value. + * + * You should usually call [Builder.groupBy] with a well-typed [GroupBy] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun groupBy(groupBy: JsonField<GroupBy>) = apply { body.groupBy(groupBy) } + + fun includeExtendedStats(includeExtendedStats: Boolean) = apply { + body.includeExtendedStats(includeExtendedStats) + } + + /** + * Sets [Builder.includeExtendedStats] to an arbitrary JSON value. + * + * You should usually call [Builder.includeExtendedStats] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun includeExtendedStats(includeExtendedStats: JsonField<Boolean>) = apply { + body.includeExtendedStats(includeExtendedStats) + } + + fun isEnabled(isEnabled: Boolean) = apply { body.isEnabled(isEnabled) } + + /** + * Sets [Builder.isEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.isEnabled] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isEnabled(isEnabled: JsonField<Boolean>) = apply { body.isEnabled(isEnabled) } + + fun numFewShotExamples(numFewShotExamples: Long?) = apply { + body.numFewShotExamples(numFewShotExamples) + } + + /** + * Alias for [Builder.numFewShotExamples]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun numFewShotExamples(numFewShotExamples: Long) = + numFewShotExamples(numFewShotExamples as Long?) + + /** + * Alias for calling [Builder.numFewShotExamples] with `numFewShotExamples.orElse(null)`. + */ + fun numFewShotExamples(numFewShotExamples: Optional<Long>) = + numFewShotExamples(numFewShotExamples.getOrNull()) + + /** + * Sets [Builder.numFewShotExamples] to an arbitrary JSON value. + * + * You should usually call [Builder.numFewShotExamples] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun numFewShotExamples(numFewShotExamples: JsonField<Long>) = apply { + body.numFewShotExamples(numFewShotExamples) + } + + fun sessionId(sessionId: String?) = apply { body.sessionId(sessionId) } + + /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ + fun sessionId(sessionId: Optional<String>) = sessionId(sessionId.getOrNull()) + + /** + * Sets [Builder.sessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun sessionId(sessionId: JsonField<String>) = apply { body.sessionId(sessionId) } + + fun traceFilter(traceFilter: String?) = apply { body.traceFilter(traceFilter) } + + /** Alias for calling [Builder.traceFilter] with `traceFilter.orElse(null)`. */ + fun traceFilter(traceFilter: Optional<String>) = traceFilter(traceFilter.getOrNull()) + + /** + * Sets [Builder.traceFilter] to an arbitrary JSON value. + * + * You should usually call [Builder.traceFilter] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun traceFilter(traceFilter: JsonField<String>) = apply { body.traceFilter(traceFilter) } + + fun transient_(transient_: Boolean) = apply { body.transient_(transient_) } + + /** + * Sets [Builder.transient_] to an arbitrary JSON value. + * + * You should usually call [Builder.transient_] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun transient_(transient_: JsonField<Boolean>) = apply { body.transient_(transient_) } + + fun treeFilter(treeFilter: String?) = apply { body.treeFilter(treeFilter) } + + /** Alias for calling [Builder.treeFilter] with `treeFilter.orElse(null)`. */ + fun treeFilter(treeFilter: Optional<String>) = treeFilter(treeFilter.getOrNull()) + + /** + * Sets [Builder.treeFilter] to an arbitrary JSON value. + * + * You should usually call [Builder.treeFilter] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun treeFilter(treeFilter: JsonField<String>) = apply { body.treeFilter(treeFilter) } + + fun useCorrectionsDataset(useCorrectionsDataset: Boolean) = apply { + body.useCorrectionsDataset(useCorrectionsDataset) + } + + /** + * Sets [Builder.useCorrectionsDataset] to an arbitrary JSON value. + * + * You should usually call [Builder.useCorrectionsDataset] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun useCorrectionsDataset(useCorrectionsDataset: JsonField<Boolean>) = apply { + body.useCorrectionsDataset(useCorrectionsDataset) + } + + fun webhooks(webhooks: List<RunRulesWebhookSchema>?) = apply { body.webhooks(webhooks) } + + /** Alias for calling [Builder.webhooks] with `webhooks.orElse(null)`. */ + fun webhooks(webhooks: Optional<List<RunRulesWebhookSchema>>) = + webhooks(webhooks.getOrNull()) + + /** + * Sets [Builder.webhooks] to an arbitrary JSON value. + * + * You should usually call [Builder.webhooks] with a well-typed + * `List<RunRulesWebhookSchema>` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun webhooks(webhooks: JsonField<List<RunRulesWebhookSchema>>) = apply { + body.webhooks(webhooks) + } + + /** + * Adds a single [RunRulesWebhookSchema] to [webhooks]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWebhook(webhook: RunRulesWebhookSchema) = apply { body.addWebhook(webhook) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RuleCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .displayName() + * .samplingRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RuleCreateParams = + RuleCreateParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val displayName: JsonField<String>, + private val samplingRate: JsonField<Double>, + private val addToAnnotationQueueId: JsonField<String>, + private val addToDatasetId: JsonField<String>, + private val addToDatasetPreferCorrection: JsonField<Boolean>, + private val alerts: JsonField<List<RunRulesPagerdutyAlertSchema>>, + private val backfillFrom: JsonField<OffsetDateTime>, + private val codeEvaluators: JsonField<List<CodeEvaluatorTopLevel>>, + private val createAlignmentQueue: JsonField<Boolean>, + private val datasetId: JsonField<String>, + private val evaluatorVersion: JsonField<Long>, + private val evaluators: JsonField<List<EvaluatorTopLevel>>, + private val extendOnly: JsonField<Boolean>, + private val filter: JsonField<String>, + private val groupBy: JsonField<GroupBy>, + private val includeExtendedStats: JsonField<Boolean>, + private val isEnabled: JsonField<Boolean>, + private val numFewShotExamples: JsonField<Long>, + private val sessionId: JsonField<String>, + private val traceFilter: JsonField<String>, + private val transient_: JsonField<Boolean>, + private val treeFilter: JsonField<String>, + private val useCorrectionsDataset: JsonField<Boolean>, + private val webhooks: JsonField<List<RunRulesWebhookSchema>>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField<String> = JsonMissing.of(), + @JsonProperty("sampling_rate") + @ExcludeMissing + samplingRate: JsonField<Double> = JsonMissing.of(), + @JsonProperty("add_to_annotation_queue_id") + @ExcludeMissing + addToAnnotationQueueId: JsonField<String> = JsonMissing.of(), + @JsonProperty("add_to_dataset_id") + @ExcludeMissing + addToDatasetId: JsonField<String> = JsonMissing.of(), + @JsonProperty("add_to_dataset_prefer_correction") + @ExcludeMissing + addToDatasetPreferCorrection: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("alerts") + @ExcludeMissing + alerts: JsonField<List<RunRulesPagerdutyAlertSchema>> = JsonMissing.of(), + @JsonProperty("backfill_from") + @ExcludeMissing + backfillFrom: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("code_evaluators") + @ExcludeMissing + codeEvaluators: JsonField<List<CodeEvaluatorTopLevel>> = JsonMissing.of(), + @JsonProperty("create_alignment_queue") + @ExcludeMissing + createAlignmentQueue: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("dataset_id") + @ExcludeMissing + datasetId: JsonField<String> = JsonMissing.of(), + @JsonProperty("evaluator_version") + @ExcludeMissing + evaluatorVersion: JsonField<Long> = JsonMissing.of(), + @JsonProperty("evaluators") + @ExcludeMissing + evaluators: JsonField<List<EvaluatorTopLevel>> = JsonMissing.of(), + @JsonProperty("extend_only") + @ExcludeMissing + extendOnly: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("filter") @ExcludeMissing filter: JsonField<String> = JsonMissing.of(), + @JsonProperty("group_by") + @ExcludeMissing + groupBy: JsonField<GroupBy> = JsonMissing.of(), + @JsonProperty("include_extended_stats") + @ExcludeMissing + includeExtendedStats: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("is_enabled") + @ExcludeMissing + isEnabled: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("num_few_shot_examples") + @ExcludeMissing + numFewShotExamples: JsonField<Long> = JsonMissing.of(), + @JsonProperty("session_id") + @ExcludeMissing + sessionId: JsonField<String> = JsonMissing.of(), + @JsonProperty("trace_filter") + @ExcludeMissing + traceFilter: JsonField<String> = JsonMissing.of(), + @JsonProperty("transient") + @ExcludeMissing + transient_: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("tree_filter") + @ExcludeMissing + treeFilter: JsonField<String> = JsonMissing.of(), + @JsonProperty("use_corrections_dataset") + @ExcludeMissing + useCorrectionsDataset: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("webhooks") + @ExcludeMissing + webhooks: JsonField<List<RunRulesWebhookSchema>> = JsonMissing.of(), + ) : this( + displayName, + samplingRate, + addToAnnotationQueueId, + addToDatasetId, + addToDatasetPreferCorrection, + alerts, + backfillFrom, + codeEvaluators, + createAlignmentQueue, + datasetId, + evaluatorVersion, + evaluators, + extendOnly, + filter, + groupBy, + includeExtendedStats, + isEnabled, + numFewShotExamples, + sessionId, + traceFilter, + transient_, + treeFilter, + useCorrectionsDataset, + webhooks, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun displayName(): String = displayName.getRequired("display_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun samplingRate(): Double = samplingRate.getRequired("sampling_rate") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun addToAnnotationQueueId(): Optional<String> = + addToAnnotationQueueId.getOptional("add_to_annotation_queue_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun addToDatasetId(): Optional<String> = addToDatasetId.getOptional("add_to_dataset_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun addToDatasetPreferCorrection(): Optional<Boolean> = + addToDatasetPreferCorrection.getOptional("add_to_dataset_prefer_correction") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun alerts(): Optional<List<RunRulesPagerdutyAlertSchema>> = alerts.getOptional("alerts") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun backfillFrom(): Optional<OffsetDateTime> = backfillFrom.getOptional("backfill_from") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun codeEvaluators(): Optional<List<CodeEvaluatorTopLevel>> = + codeEvaluators.getOptional("code_evaluators") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun createAlignmentQueue(): Optional<Boolean> = + createAlignmentQueue.getOptional("create_alignment_queue") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun datasetId(): Optional<String> = datasetId.getOptional("dataset_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun evaluatorVersion(): Optional<Long> = evaluatorVersion.getOptional("evaluator_version") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun evaluators(): Optional<List<EvaluatorTopLevel>> = evaluators.getOptional("evaluators") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun extendOnly(): Optional<Boolean> = extendOnly.getOptional("extend_only") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun filter(): Optional<String> = filter.getOptional("filter") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun groupBy(): Optional<GroupBy> = groupBy.getOptional("group_by") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun includeExtendedStats(): Optional<Boolean> = + includeExtendedStats.getOptional("include_extended_stats") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun isEnabled(): Optional<Boolean> = isEnabled.getOptional("is_enabled") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun numFewShotExamples(): Optional<Long> = + numFewShotExamples.getOptional("num_few_shot_examples") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun sessionId(): Optional<String> = sessionId.getOptional("session_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun traceFilter(): Optional<String> = traceFilter.getOptional("trace_filter") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun transient_(): Optional<Boolean> = transient_.getOptional("transient") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun treeFilter(): Optional<String> = treeFilter.getOptional("tree_filter") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun useCorrectionsDataset(): Optional<Boolean> = + useCorrectionsDataset.getOptional("use_corrections_dataset") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun webhooks(): Optional<List<RunRulesWebhookSchema>> = webhooks.getOptional("webhooks") + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField<String> = displayName + + /** + * Returns the raw JSON value of [samplingRate]. + * + * Unlike [samplingRate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("sampling_rate") + @ExcludeMissing + fun _samplingRate(): JsonField<Double> = samplingRate + + /** + * Returns the raw JSON value of [addToAnnotationQueueId]. + * + * Unlike [addToAnnotationQueueId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("add_to_annotation_queue_id") + @ExcludeMissing + fun _addToAnnotationQueueId(): JsonField<String> = addToAnnotationQueueId + + /** + * Returns the raw JSON value of [addToDatasetId]. + * + * Unlike [addToDatasetId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("add_to_dataset_id") + @ExcludeMissing + fun _addToDatasetId(): JsonField<String> = addToDatasetId + + /** + * Returns the raw JSON value of [addToDatasetPreferCorrection]. + * + * Unlike [addToDatasetPreferCorrection], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("add_to_dataset_prefer_correction") + @ExcludeMissing + fun _addToDatasetPreferCorrection(): JsonField<Boolean> = addToDatasetPreferCorrection + + /** + * Returns the raw JSON value of [alerts]. + * + * Unlike [alerts], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("alerts") + @ExcludeMissing + fun _alerts(): JsonField<List<RunRulesPagerdutyAlertSchema>> = alerts + + /** + * Returns the raw JSON value of [backfillFrom]. + * + * Unlike [backfillFrom], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("backfill_from") + @ExcludeMissing + fun _backfillFrom(): JsonField<OffsetDateTime> = backfillFrom + + /** + * Returns the raw JSON value of [codeEvaluators]. + * + * Unlike [codeEvaluators], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("code_evaluators") + @ExcludeMissing + fun _codeEvaluators(): JsonField<List<CodeEvaluatorTopLevel>> = codeEvaluators + + /** + * Returns the raw JSON value of [createAlignmentQueue]. + * + * Unlike [createAlignmentQueue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("create_alignment_queue") + @ExcludeMissing + fun _createAlignmentQueue(): JsonField<Boolean> = createAlignmentQueue + + /** + * Returns the raw JSON value of [datasetId]. + * + * Unlike [datasetId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField<String> = datasetId + + /** + * Returns the raw JSON value of [evaluatorVersion]. + * + * Unlike [evaluatorVersion], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("evaluator_version") + @ExcludeMissing + fun _evaluatorVersion(): JsonField<Long> = evaluatorVersion + + /** + * Returns the raw JSON value of [evaluators]. + * + * Unlike [evaluators], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("evaluators") + @ExcludeMissing + fun _evaluators(): JsonField<List<EvaluatorTopLevel>> = evaluators + + /** + * Returns the raw JSON value of [extendOnly]. + * + * Unlike [extendOnly], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("extend_only") + @ExcludeMissing + fun _extendOnly(): JsonField<Boolean> = extendOnly + + /** + * Returns the raw JSON value of [filter]. + * + * Unlike [filter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField<String> = filter + + /** + * Returns the raw JSON value of [groupBy]. + * + * Unlike [groupBy], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("group_by") @ExcludeMissing fun _groupBy(): JsonField<GroupBy> = groupBy + + /** + * Returns the raw JSON value of [includeExtendedStats]. + * + * Unlike [includeExtendedStats], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("include_extended_stats") + @ExcludeMissing + fun _includeExtendedStats(): JsonField<Boolean> = includeExtendedStats + + /** + * Returns the raw JSON value of [isEnabled]. + * + * Unlike [isEnabled], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_enabled") @ExcludeMissing fun _isEnabled(): JsonField<Boolean> = isEnabled + + /** + * Returns the raw JSON value of [numFewShotExamples]. + * + * Unlike [numFewShotExamples], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("num_few_shot_examples") + @ExcludeMissing + fun _numFewShotExamples(): JsonField<Long> = numFewShotExamples + + /** + * Returns the raw JSON value of [sessionId]. + * + * Unlike [sessionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session_id") @ExcludeMissing fun _sessionId(): JsonField<String> = sessionId + + /** + * Returns the raw JSON value of [traceFilter]. + * + * Unlike [traceFilter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trace_filter") + @ExcludeMissing + fun _traceFilter(): JsonField<String> = traceFilter + + /** + * Returns the raw JSON value of [transient_]. + * + * Unlike [transient_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("transient") + @ExcludeMissing + fun _transient_(): JsonField<Boolean> = transient_ + + /** + * Returns the raw JSON value of [treeFilter]. + * + * Unlike [treeFilter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tree_filter") + @ExcludeMissing + fun _treeFilter(): JsonField<String> = treeFilter + + /** + * Returns the raw JSON value of [useCorrectionsDataset]. + * + * Unlike [useCorrectionsDataset], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("use_corrections_dataset") + @ExcludeMissing + fun _useCorrectionsDataset(): JsonField<Boolean> = useCorrectionsDataset + + /** + * Returns the raw JSON value of [webhooks]. + * + * Unlike [webhooks], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("webhooks") + @ExcludeMissing + fun _webhooks(): JsonField<List<RunRulesWebhookSchema>> = webhooks + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .displayName() + * .samplingRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var displayName: JsonField<String>? = null + private var samplingRate: JsonField<Double>? = null + private var addToAnnotationQueueId: JsonField<String> = JsonMissing.of() + private var addToDatasetId: JsonField<String> = JsonMissing.of() + private var addToDatasetPreferCorrection: JsonField<Boolean> = JsonMissing.of() + private var alerts: JsonField<MutableList<RunRulesPagerdutyAlertSchema>>? = null + private var backfillFrom: JsonField<OffsetDateTime> = JsonMissing.of() + private var codeEvaluators: JsonField<MutableList<CodeEvaluatorTopLevel>>? = null + private var createAlignmentQueue: JsonField<Boolean> = JsonMissing.of() + private var datasetId: JsonField<String> = JsonMissing.of() + private var evaluatorVersion: JsonField<Long> = JsonMissing.of() + private var evaluators: JsonField<MutableList<EvaluatorTopLevel>>? = null + private var extendOnly: JsonField<Boolean> = JsonMissing.of() + private var filter: JsonField<String> = JsonMissing.of() + private var groupBy: JsonField<GroupBy> = JsonMissing.of() + private var includeExtendedStats: JsonField<Boolean> = JsonMissing.of() + private var isEnabled: JsonField<Boolean> = JsonMissing.of() + private var numFewShotExamples: JsonField<Long> = JsonMissing.of() + private var sessionId: JsonField<String> = JsonMissing.of() + private var traceFilter: JsonField<String> = JsonMissing.of() + private var transient_: JsonField<Boolean> = JsonMissing.of() + private var treeFilter: JsonField<String> = JsonMissing.of() + private var useCorrectionsDataset: JsonField<Boolean> = JsonMissing.of() + private var webhooks: JsonField<MutableList<RunRulesWebhookSchema>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + displayName = body.displayName + samplingRate = body.samplingRate + addToAnnotationQueueId = body.addToAnnotationQueueId + addToDatasetId = body.addToDatasetId + addToDatasetPreferCorrection = body.addToDatasetPreferCorrection + alerts = body.alerts.map { it.toMutableList() } + backfillFrom = body.backfillFrom + codeEvaluators = body.codeEvaluators.map { it.toMutableList() } + createAlignmentQueue = body.createAlignmentQueue + datasetId = body.datasetId + evaluatorVersion = body.evaluatorVersion + evaluators = body.evaluators.map { it.toMutableList() } + extendOnly = body.extendOnly + filter = body.filter + groupBy = body.groupBy + includeExtendedStats = body.includeExtendedStats + isEnabled = body.isEnabled + numFewShotExamples = body.numFewShotExamples + sessionId = body.sessionId + traceFilter = body.traceFilter + transient_ = body.transient_ + treeFilter = body.treeFilter + useCorrectionsDataset = body.useCorrectionsDataset + webhooks = body.webhooks.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun displayName(displayName: String) = displayName(JsonField.of(displayName)) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun displayName(displayName: JsonField<String>) = apply { + this.displayName = displayName + } + + fun samplingRate(samplingRate: Double) = samplingRate(JsonField.of(samplingRate)) + + /** + * Sets [Builder.samplingRate] to an arbitrary JSON value. + * + * You should usually call [Builder.samplingRate] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun samplingRate(samplingRate: JsonField<Double>) = apply { + this.samplingRate = samplingRate + } + + fun addToAnnotationQueueId(addToAnnotationQueueId: String?) = + addToAnnotationQueueId(JsonField.ofNullable(addToAnnotationQueueId)) + + /** + * Alias for calling [Builder.addToAnnotationQueueId] with + * `addToAnnotationQueueId.orElse(null)`. + */ + fun addToAnnotationQueueId(addToAnnotationQueueId: Optional<String>) = + addToAnnotationQueueId(addToAnnotationQueueId.getOrNull()) + + /** + * Sets [Builder.addToAnnotationQueueId] to an arbitrary JSON value. + * + * You should usually call [Builder.addToAnnotationQueueId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun addToAnnotationQueueId(addToAnnotationQueueId: JsonField<String>) = apply { + this.addToAnnotationQueueId = addToAnnotationQueueId + } + + fun addToDatasetId(addToDatasetId: String?) = + addToDatasetId(JsonField.ofNullable(addToDatasetId)) + + /** Alias for calling [Builder.addToDatasetId] with `addToDatasetId.orElse(null)`. */ + fun addToDatasetId(addToDatasetId: Optional<String>) = + addToDatasetId(addToDatasetId.getOrNull()) + + /** + * Sets [Builder.addToDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.addToDatasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun addToDatasetId(addToDatasetId: JsonField<String>) = apply { + this.addToDatasetId = addToDatasetId + } + + fun addToDatasetPreferCorrection(addToDatasetPreferCorrection: Boolean) = + addToDatasetPreferCorrection(JsonField.of(addToDatasetPreferCorrection)) + + /** + * Sets [Builder.addToDatasetPreferCorrection] to an arbitrary JSON value. + * + * You should usually call [Builder.addToDatasetPreferCorrection] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun addToDatasetPreferCorrection(addToDatasetPreferCorrection: JsonField<Boolean>) = + apply { + this.addToDatasetPreferCorrection = addToDatasetPreferCorrection + } + + fun alerts(alerts: List<RunRulesPagerdutyAlertSchema>?) = + alerts(JsonField.ofNullable(alerts)) + + /** Alias for calling [Builder.alerts] with `alerts.orElse(null)`. */ + fun alerts(alerts: Optional<List<RunRulesPagerdutyAlertSchema>>) = + alerts(alerts.getOrNull()) + + /** + * Sets [Builder.alerts] to an arbitrary JSON value. + * + * You should usually call [Builder.alerts] with a well-typed + * `List<RunRulesPagerdutyAlertSchema>` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun alerts(alerts: JsonField<List<RunRulesPagerdutyAlertSchema>>) = apply { + this.alerts = alerts.map { it.toMutableList() } + } + + /** + * Adds a single [RunRulesPagerdutyAlertSchema] to [alerts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAlert(alert: RunRulesPagerdutyAlertSchema) = apply { + alerts = + (alerts ?: JsonField.of(mutableListOf())).also { + checkKnown("alerts", it).add(alert) + } + } + + fun backfillFrom(backfillFrom: OffsetDateTime?) = + backfillFrom(JsonField.ofNullable(backfillFrom)) + + /** Alias for calling [Builder.backfillFrom] with `backfillFrom.orElse(null)`. */ + fun backfillFrom(backfillFrom: Optional<OffsetDateTime>) = + backfillFrom(backfillFrom.getOrNull()) + + /** + * Sets [Builder.backfillFrom] to an arbitrary JSON value. + * + * You should usually call [Builder.backfillFrom] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun backfillFrom(backfillFrom: JsonField<OffsetDateTime>) = apply { + this.backfillFrom = backfillFrom + } + + fun codeEvaluators(codeEvaluators: List<CodeEvaluatorTopLevel>?) = + codeEvaluators(JsonField.ofNullable(codeEvaluators)) + + /** Alias for calling [Builder.codeEvaluators] with `codeEvaluators.orElse(null)`. */ + fun codeEvaluators(codeEvaluators: Optional<List<CodeEvaluatorTopLevel>>) = + codeEvaluators(codeEvaluators.getOrNull()) + + /** + * Sets [Builder.codeEvaluators] to an arbitrary JSON value. + * + * You should usually call [Builder.codeEvaluators] with a well-typed + * `List<CodeEvaluatorTopLevel>` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun codeEvaluators(codeEvaluators: JsonField<List<CodeEvaluatorTopLevel>>) = apply { + this.codeEvaluators = codeEvaluators.map { it.toMutableList() } + } + + /** + * Adds a single [CodeEvaluatorTopLevel] to [codeEvaluators]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCodeEvaluator(codeEvaluator: CodeEvaluatorTopLevel) = apply { + codeEvaluators = + (codeEvaluators ?: JsonField.of(mutableListOf())).also { + checkKnown("codeEvaluators", it).add(codeEvaluator) + } + } + + fun createAlignmentQueue(createAlignmentQueue: Boolean) = + createAlignmentQueue(JsonField.of(createAlignmentQueue)) + + /** + * Sets [Builder.createAlignmentQueue] to an arbitrary JSON value. + * + * You should usually call [Builder.createAlignmentQueue] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun createAlignmentQueue(createAlignmentQueue: JsonField<Boolean>) = apply { + this.createAlignmentQueue = createAlignmentQueue + } + + fun datasetId(datasetId: String?) = datasetId(JsonField.ofNullable(datasetId)) + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + /** + * Sets [Builder.datasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun datasetId(datasetId: JsonField<String>) = apply { this.datasetId = datasetId } + + fun evaluatorVersion(evaluatorVersion: Long?) = + evaluatorVersion(JsonField.ofNullable(evaluatorVersion)) + + /** + * Alias for [Builder.evaluatorVersion]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun evaluatorVersion(evaluatorVersion: Long) = + evaluatorVersion(evaluatorVersion as Long?) + + /** + * Alias for calling [Builder.evaluatorVersion] with `evaluatorVersion.orElse(null)`. + */ + fun evaluatorVersion(evaluatorVersion: Optional<Long>) = + evaluatorVersion(evaluatorVersion.getOrNull()) + + /** + * Sets [Builder.evaluatorVersion] to an arbitrary JSON value. + * + * You should usually call [Builder.evaluatorVersion] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun evaluatorVersion(evaluatorVersion: JsonField<Long>) = apply { + this.evaluatorVersion = evaluatorVersion + } + + fun evaluators(evaluators: List<EvaluatorTopLevel>?) = + evaluators(JsonField.ofNullable(evaluators)) + + /** Alias for calling [Builder.evaluators] with `evaluators.orElse(null)`. */ + fun evaluators(evaluators: Optional<List<EvaluatorTopLevel>>) = + evaluators(evaluators.getOrNull()) + + /** + * Sets [Builder.evaluators] to an arbitrary JSON value. + * + * You should usually call [Builder.evaluators] with a well-typed + * `List<EvaluatorTopLevel>` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun evaluators(evaluators: JsonField<List<EvaluatorTopLevel>>) = apply { + this.evaluators = evaluators.map { it.toMutableList() } + } + + /** + * Adds a single [EvaluatorTopLevel] to [evaluators]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvaluator(evaluator: EvaluatorTopLevel) = apply { + evaluators = + (evaluators ?: JsonField.of(mutableListOf())).also { + checkKnown("evaluators", it).add(evaluator) + } + } + + fun extendOnly(extendOnly: Boolean) = extendOnly(JsonField.of(extendOnly)) + + /** + * Sets [Builder.extendOnly] to an arbitrary JSON value. + * + * You should usually call [Builder.extendOnly] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun extendOnly(extendOnly: JsonField<Boolean>) = apply { this.extendOnly = extendOnly } + + fun filter(filter: String?) = filter(JsonField.ofNullable(filter)) + + /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ + fun filter(filter: Optional<String>) = filter(filter.getOrNull()) + + /** + * Sets [Builder.filter] to an arbitrary JSON value. + * + * You should usually call [Builder.filter] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun filter(filter: JsonField<String>) = apply { this.filter = filter } + + fun groupBy(groupBy: GroupBy?) = groupBy(JsonField.ofNullable(groupBy)) + + /** Alias for calling [Builder.groupBy] with `groupBy.orElse(null)`. */ + fun groupBy(groupBy: Optional<GroupBy>) = groupBy(groupBy.getOrNull()) + + /** + * Sets [Builder.groupBy] to an arbitrary JSON value. + * + * You should usually call [Builder.groupBy] with a well-typed [GroupBy] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupBy(groupBy: JsonField<GroupBy>) = apply { this.groupBy = groupBy } + + fun includeExtendedStats(includeExtendedStats: Boolean) = + includeExtendedStats(JsonField.of(includeExtendedStats)) + + /** + * Sets [Builder.includeExtendedStats] to an arbitrary JSON value. + * + * You should usually call [Builder.includeExtendedStats] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun includeExtendedStats(includeExtendedStats: JsonField<Boolean>) = apply { + this.includeExtendedStats = includeExtendedStats + } + + fun isEnabled(isEnabled: Boolean) = isEnabled(JsonField.of(isEnabled)) + + /** + * Sets [Builder.isEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.isEnabled] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isEnabled(isEnabled: JsonField<Boolean>) = apply { this.isEnabled = isEnabled } + + fun numFewShotExamples(numFewShotExamples: Long?) = + numFewShotExamples(JsonField.ofNullable(numFewShotExamples)) + + /** + * Alias for [Builder.numFewShotExamples]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun numFewShotExamples(numFewShotExamples: Long) = + numFewShotExamples(numFewShotExamples as Long?) + + /** + * Alias for calling [Builder.numFewShotExamples] with + * `numFewShotExamples.orElse(null)`. + */ + fun numFewShotExamples(numFewShotExamples: Optional<Long>) = + numFewShotExamples(numFewShotExamples.getOrNull()) + + /** + * Sets [Builder.numFewShotExamples] to an arbitrary JSON value. + * + * You should usually call [Builder.numFewShotExamples] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun numFewShotExamples(numFewShotExamples: JsonField<Long>) = apply { + this.numFewShotExamples = numFewShotExamples + } + + fun sessionId(sessionId: String?) = sessionId(JsonField.ofNullable(sessionId)) + + /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ + fun sessionId(sessionId: Optional<String>) = sessionId(sessionId.getOrNull()) + + /** + * Sets [Builder.sessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sessionId(sessionId: JsonField<String>) = apply { this.sessionId = sessionId } + + fun traceFilter(traceFilter: String?) = traceFilter(JsonField.ofNullable(traceFilter)) + + /** Alias for calling [Builder.traceFilter] with `traceFilter.orElse(null)`. */ + fun traceFilter(traceFilter: Optional<String>) = traceFilter(traceFilter.getOrNull()) + + /** + * Sets [Builder.traceFilter] to an arbitrary JSON value. + * + * You should usually call [Builder.traceFilter] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun traceFilter(traceFilter: JsonField<String>) = apply { + this.traceFilter = traceFilter + } + + fun transient_(transient_: Boolean) = transient_(JsonField.of(transient_)) + + /** + * Sets [Builder.transient_] to an arbitrary JSON value. + * + * You should usually call [Builder.transient_] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun transient_(transient_: JsonField<Boolean>) = apply { this.transient_ = transient_ } + + fun treeFilter(treeFilter: String?) = treeFilter(JsonField.ofNullable(treeFilter)) + + /** Alias for calling [Builder.treeFilter] with `treeFilter.orElse(null)`. */ + fun treeFilter(treeFilter: Optional<String>) = treeFilter(treeFilter.getOrNull()) + + /** + * Sets [Builder.treeFilter] to an arbitrary JSON value. + * + * You should usually call [Builder.treeFilter] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun treeFilter(treeFilter: JsonField<String>) = apply { this.treeFilter = treeFilter } + + fun useCorrectionsDataset(useCorrectionsDataset: Boolean) = + useCorrectionsDataset(JsonField.of(useCorrectionsDataset)) + + /** + * Sets [Builder.useCorrectionsDataset] to an arbitrary JSON value. + * + * You should usually call [Builder.useCorrectionsDataset] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun useCorrectionsDataset(useCorrectionsDataset: JsonField<Boolean>) = apply { + this.useCorrectionsDataset = useCorrectionsDataset + } + + fun webhooks(webhooks: List<RunRulesWebhookSchema>?) = + webhooks(JsonField.ofNullable(webhooks)) + + /** Alias for calling [Builder.webhooks] with `webhooks.orElse(null)`. */ + fun webhooks(webhooks: Optional<List<RunRulesWebhookSchema>>) = + webhooks(webhooks.getOrNull()) + + /** + * Sets [Builder.webhooks] to an arbitrary JSON value. + * + * You should usually call [Builder.webhooks] with a well-typed + * `List<RunRulesWebhookSchema>` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun webhooks(webhooks: JsonField<List<RunRulesWebhookSchema>>) = apply { + this.webhooks = webhooks.map { it.toMutableList() } + } + + /** + * Adds a single [RunRulesWebhookSchema] to [webhooks]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWebhook(webhook: RunRulesWebhookSchema) = apply { + webhooks = + (webhooks ?: JsonField.of(mutableListOf())).also { + checkKnown("webhooks", it).add(webhook) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .displayName() + * .samplingRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("displayName", displayName), + checkRequired("samplingRate", samplingRate), + addToAnnotationQueueId, + addToDatasetId, + addToDatasetPreferCorrection, + (alerts ?: JsonMissing.of()).map { it.toImmutable() }, + backfillFrom, + (codeEvaluators ?: JsonMissing.of()).map { it.toImmutable() }, + createAlignmentQueue, + datasetId, + evaluatorVersion, + (evaluators ?: JsonMissing.of()).map { it.toImmutable() }, + extendOnly, + filter, + groupBy, + includeExtendedStats, + isEnabled, + numFewShotExamples, + sessionId, + traceFilter, + transient_, + treeFilter, + useCorrectionsDataset, + (webhooks ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + displayName() + samplingRate() + addToAnnotationQueueId() + addToDatasetId() + addToDatasetPreferCorrection() + alerts().ifPresent { it.forEach { it.validate() } } + backfillFrom() + codeEvaluators().ifPresent { it.forEach { it.validate() } } + createAlignmentQueue() + datasetId() + evaluatorVersion() + evaluators().ifPresent { it.forEach { it.validate() } } + extendOnly() + filter() + groupBy().ifPresent { it.validate() } + includeExtendedStats() + isEnabled() + numFewShotExamples() + sessionId() + traceFilter() + transient_() + treeFilter() + useCorrectionsDataset() + webhooks().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (displayName.asKnown().isPresent) 1 else 0) + + (if (samplingRate.asKnown().isPresent) 1 else 0) + + (if (addToAnnotationQueueId.asKnown().isPresent) 1 else 0) + + (if (addToDatasetId.asKnown().isPresent) 1 else 0) + + (if (addToDatasetPreferCorrection.asKnown().isPresent) 1 else 0) + + (alerts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (backfillFrom.asKnown().isPresent) 1 else 0) + + (codeEvaluators.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (createAlignmentQueue.asKnown().isPresent) 1 else 0) + + (if (datasetId.asKnown().isPresent) 1 else 0) + + (if (evaluatorVersion.asKnown().isPresent) 1 else 0) + + (evaluators.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (extendOnly.asKnown().isPresent) 1 else 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (groupBy.asKnown().getOrNull()?.validity() ?: 0) + + (if (includeExtendedStats.asKnown().isPresent) 1 else 0) + + (if (isEnabled.asKnown().isPresent) 1 else 0) + + (if (numFewShotExamples.asKnown().isPresent) 1 else 0) + + (if (sessionId.asKnown().isPresent) 1 else 0) + + (if (traceFilter.asKnown().isPresent) 1 else 0) + + (if (transient_.asKnown().isPresent) 1 else 0) + + (if (treeFilter.asKnown().isPresent) 1 else 0) + + (if (useCorrectionsDataset.asKnown().isPresent) 1 else 0) + + (webhooks.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + displayName == other.displayName && + samplingRate == other.samplingRate && + addToAnnotationQueueId == other.addToAnnotationQueueId && + addToDatasetId == other.addToDatasetId && + addToDatasetPreferCorrection == other.addToDatasetPreferCorrection && + alerts == other.alerts && + backfillFrom == other.backfillFrom && + codeEvaluators == other.codeEvaluators && + createAlignmentQueue == other.createAlignmentQueue && + datasetId == other.datasetId && + evaluatorVersion == other.evaluatorVersion && + evaluators == other.evaluators && + extendOnly == other.extendOnly && + filter == other.filter && + groupBy == other.groupBy && + includeExtendedStats == other.includeExtendedStats && + isEnabled == other.isEnabled && + numFewShotExamples == other.numFewShotExamples && + sessionId == other.sessionId && + traceFilter == other.traceFilter && + transient_ == other.transient_ && + treeFilter == other.treeFilter && + useCorrectionsDataset == other.useCorrectionsDataset && + webhooks == other.webhooks && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + displayName, + samplingRate, + addToAnnotationQueueId, + addToDatasetId, + addToDatasetPreferCorrection, + alerts, + backfillFrom, + codeEvaluators, + createAlignmentQueue, + datasetId, + evaluatorVersion, + evaluators, + extendOnly, + filter, + groupBy, + includeExtendedStats, + isEnabled, + numFewShotExamples, + sessionId, + traceFilter, + transient_, + treeFilter, + useCorrectionsDataset, + webhooks, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{displayName=$displayName, samplingRate=$samplingRate, addToAnnotationQueueId=$addToAnnotationQueueId, addToDatasetId=$addToDatasetId, addToDatasetPreferCorrection=$addToDatasetPreferCorrection, alerts=$alerts, backfillFrom=$backfillFrom, codeEvaluators=$codeEvaluators, createAlignmentQueue=$createAlignmentQueue, datasetId=$datasetId, evaluatorVersion=$evaluatorVersion, evaluators=$evaluators, extendOnly=$extendOnly, filter=$filter, groupBy=$groupBy, includeExtendedStats=$includeExtendedStats, isEnabled=$isEnabled, numFewShotExamples=$numFewShotExamples, sessionId=$sessionId, traceFilter=$traceFilter, transient_=$transient_, treeFilter=$treeFilter, useCorrectionsDataset=$useCorrectionsDataset, webhooks=$webhooks, additionalProperties=$additionalProperties}" + } + + class GroupBy @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val THREAD_ID = of("thread_id") + + @JvmStatic fun of(value: String) = GroupBy(JsonField.of(value)) + } + + /** An enum containing [GroupBy]'s known values. */ + enum class Known { + THREAD_ID + } + + /** + * An enum containing [GroupBy]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [GroupBy] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + THREAD_ID, + /** An enum member indicating that [GroupBy] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + THREAD_ID -> Value.THREAD_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + THREAD_ID -> Known.THREAD_ID + else -> throw LangsmithApiInvalidDataException("Unknown GroupBy: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): GroupBy = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupBy && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RuleCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "RuleCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleDeleteParams.kt new file mode 100644 index 00000000..75e17473 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleDeleteParams.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.rules + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete a run rule. */ +class RuleDeleteParams +private constructor( + private val ruleId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun ruleId(): Optional<String> = Optional.ofNullable(ruleId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): RuleDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [RuleDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RuleDeleteParams]. */ + class Builder internal constructor() { + + private var ruleId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(ruleDeleteParams: RuleDeleteParams) = apply { + ruleId = ruleDeleteParams.ruleId + additionalHeaders = ruleDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = ruleDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = ruleDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun ruleId(ruleId: String?) = apply { this.ruleId = ruleId } + + /** Alias for calling [Builder.ruleId] with `ruleId.orElse(null)`. */ + fun ruleId(ruleId: Optional<String>) = ruleId(ruleId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [RuleDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RuleDeleteParams = + RuleDeleteParams( + ruleId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> ruleId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RuleDeleteParams && + ruleId == other.ruleId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(ruleId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "RuleDeleteParams{ruleId=$ruleId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleDeleteResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleDeleteResponse.kt new file mode 100644 index 00000000..a3d99c91 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleDeleteResponse.kt @@ -0,0 +1,113 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.rules + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class RuleDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [RuleDeleteResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RuleDeleteResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(ruleDeleteResponse: RuleDeleteResponse) = apply { + additionalProperties = ruleDeleteResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RuleDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RuleDeleteResponse = RuleDeleteResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): RuleDeleteResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RuleDeleteResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "RuleDeleteResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleListParams.kt new file mode 100644 index 00000000..9b2be54a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleListParams.kt @@ -0,0 +1,393 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.rules + +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** List all run rules. */ +class RuleListParams +private constructor( + private val id: List<String>?, + private val datasetId: String?, + private val nameContains: String?, + private val sessionId: String?, + private val type: Type?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun id(): Optional<List<String>> = Optional.ofNullable(id) + + fun datasetId(): Optional<String> = Optional.ofNullable(datasetId) + + fun nameContains(): Optional<String> = Optional.ofNullable(nameContains) + + fun sessionId(): Optional<String> = Optional.ofNullable(sessionId) + + fun type(): Optional<Type> = Optional.ofNullable(type) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): RuleListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [RuleListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RuleListParams]. */ + class Builder internal constructor() { + + private var id: MutableList<String>? = null + private var datasetId: String? = null + private var nameContains: String? = null + private var sessionId: String? = null + private var type: Type? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(ruleListParams: RuleListParams) = apply { + id = ruleListParams.id?.toMutableList() + datasetId = ruleListParams.datasetId + nameContains = ruleListParams.nameContains + sessionId = ruleListParams.sessionId + type = ruleListParams.type + additionalHeaders = ruleListParams.additionalHeaders.toBuilder() + additionalQueryParams = ruleListParams.additionalQueryParams.toBuilder() + } + + fun id(id: List<String>?) = apply { this.id = id?.toMutableList() } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<List<String>>) = id(id.getOrNull()) + + /** + * Adds a single [String] to [Builder.id]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addId(id: String) = apply { this.id = (this.id ?: mutableListOf()).apply { add(id) } } + + fun datasetId(datasetId: String?) = apply { this.datasetId = datasetId } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + fun nameContains(nameContains: String?) = apply { this.nameContains = nameContains } + + /** Alias for calling [Builder.nameContains] with `nameContains.orElse(null)`. */ + fun nameContains(nameContains: Optional<String>) = nameContains(nameContains.getOrNull()) + + fun sessionId(sessionId: String?) = apply { this.sessionId = sessionId } + + /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ + fun sessionId(sessionId: Optional<String>) = sessionId(sessionId.getOrNull()) + + fun type(type: Type?) = apply { this.type = type } + + /** Alias for calling [Builder.type] with `type.orElse(null)`. */ + fun type(type: Optional<Type>) = type(type.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RuleListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RuleListParams = + RuleListParams( + id?.toImmutable(), + datasetId, + nameContains, + sessionId, + type, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + id?.let { put("id", it.joinToString(",")) } + datasetId?.let { put("dataset_id", it) } + nameContains?.let { put("name_contains", it) } + sessionId?.let { put("session_id", it) } + type?.let { put("type", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + class Type @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val SESSION = of("session") + + @JvmField val DATASET = of("dataset") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + SESSION, + DATASET, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SESSION, + DATASET, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SESSION -> Value.SESSION + DATASET -> Value.DATASET + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SESSION -> Known.SESSION + DATASET -> Known.DATASET + else -> throw LangsmithApiInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RuleListParams && + id == other.id && + datasetId == other.datasetId && + nameContains == other.nameContains && + sessionId == other.sessionId && + type == other.type && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + id, + datasetId, + nameContains, + sessionId, + type, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "RuleListParams{id=$id, datasetId=$datasetId, nameContains=$nameContains, sessionId=$sessionId, type=$type, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleLogActionResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleLogActionResponse.kt new file mode 100644 index 00000000..0093aa92 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleLogActionResponse.kt @@ -0,0 +1,315 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.rules + +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.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class RuleLogActionResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val outcome: JsonField<Outcome>, + private val payload: JsonValue, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("outcome") @ExcludeMissing outcome: JsonField<Outcome> = JsonMissing.of(), + @JsonProperty("payload") @ExcludeMissing payload: JsonValue = JsonMissing.of(), + ) : this(outcome, payload, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun outcome(): Outcome = outcome.getRequired("outcome") + + @JsonProperty("payload") @ExcludeMissing fun _payload(): JsonValue = payload + + /** + * Returns the raw JSON value of [outcome]. + * + * Unlike [outcome], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outcome") @ExcludeMissing fun _outcome(): JsonField<Outcome> = outcome + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RuleLogActionResponse]. + * + * The following fields are required: + * ```java + * .outcome() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RuleLogActionResponse]. */ + class Builder internal constructor() { + + private var outcome: JsonField<Outcome>? = null + private var payload: JsonValue = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(ruleLogActionResponse: RuleLogActionResponse) = apply { + outcome = ruleLogActionResponse.outcome + payload = ruleLogActionResponse.payload + additionalProperties = ruleLogActionResponse.additionalProperties.toMutableMap() + } + + fun outcome(outcome: Outcome) = outcome(JsonField.of(outcome)) + + /** + * Sets [Builder.outcome] to an arbitrary JSON value. + * + * You should usually call [Builder.outcome] with a well-typed [Outcome] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun outcome(outcome: JsonField<Outcome>) = apply { this.outcome = outcome } + + fun payload(payload: JsonValue) = apply { this.payload = payload } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RuleLogActionResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .outcome() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RuleLogActionResponse = + RuleLogActionResponse( + checkRequired("outcome", outcome), + payload, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RuleLogActionResponse = apply { + if (validated) { + return@apply + } + + outcome().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (outcome.asKnown().getOrNull()?.validity() ?: 0) + + class Outcome @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val SUCCESS = of("success") + + @JvmField val SKIPPED = of("skipped") + + @JvmField val ERROR = of("error") + + @JvmStatic fun of(value: String) = Outcome(JsonField.of(value)) + } + + /** An enum containing [Outcome]'s known values. */ + enum class Known { + SUCCESS, + SKIPPED, + ERROR, + } + + /** + * An enum containing [Outcome]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Outcome] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SUCCESS, + SKIPPED, + ERROR, + /** An enum member indicating that [Outcome] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SUCCESS -> Value.SUCCESS + SKIPPED -> Value.SKIPPED + ERROR -> Value.ERROR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SUCCESS -> Known.SUCCESS + SKIPPED -> Known.SKIPPED + ERROR -> Known.ERROR + else -> throw LangsmithApiInvalidDataException("Unknown Outcome: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Outcome = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Outcome && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RuleLogActionResponse && + outcome == other.outcome && + payload == other.payload && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(outcome, payload, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RuleLogActionResponse{outcome=$outcome, payload=$payload, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleLogSchema.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleLogSchema.kt new file mode 100644 index 00000000..769553fc --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleLogSchema.kt @@ -0,0 +1,716 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.rules + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Run rules log schema. */ +class RuleLogSchema +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val endTime: JsonField<OffsetDateTime>, + private val ruleId: JsonField<String>, + private val runId: JsonField<String>, + private val startTime: JsonField<OffsetDateTime>, + private val addToAnnotationQueue: JsonField<RuleLogActionResponse>, + private val addToDataset: JsonField<RuleLogActionResponse>, + private val alerts: JsonField<RuleLogActionResponse>, + private val applicationTime: JsonField<OffsetDateTime>, + private val evaluators: JsonField<RuleLogActionResponse>, + private val runName: JsonField<String>, + private val runSessionId: JsonField<String>, + private val runType: JsonField<String>, + private val threadId: JsonField<String>, + private val webhooks: JsonField<RuleLogActionResponse>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("end_time") + @ExcludeMissing + endTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("rule_id") @ExcludeMissing ruleId: JsonField<String> = JsonMissing.of(), + @JsonProperty("run_id") @ExcludeMissing runId: JsonField<String> = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("add_to_annotation_queue") + @ExcludeMissing + addToAnnotationQueue: JsonField<RuleLogActionResponse> = JsonMissing.of(), + @JsonProperty("add_to_dataset") + @ExcludeMissing + addToDataset: JsonField<RuleLogActionResponse> = JsonMissing.of(), + @JsonProperty("alerts") + @ExcludeMissing + alerts: JsonField<RuleLogActionResponse> = JsonMissing.of(), + @JsonProperty("application_time") + @ExcludeMissing + applicationTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("evaluators") + @ExcludeMissing + evaluators: JsonField<RuleLogActionResponse> = JsonMissing.of(), + @JsonProperty("run_name") @ExcludeMissing runName: JsonField<String> = JsonMissing.of(), + @JsonProperty("run_session_id") + @ExcludeMissing + runSessionId: JsonField<String> = JsonMissing.of(), + @JsonProperty("run_type") @ExcludeMissing runType: JsonField<String> = JsonMissing.of(), + @JsonProperty("thread_id") @ExcludeMissing threadId: JsonField<String> = JsonMissing.of(), + @JsonProperty("webhooks") + @ExcludeMissing + webhooks: JsonField<RuleLogActionResponse> = JsonMissing.of(), + ) : this( + endTime, + ruleId, + runId, + startTime, + addToAnnotationQueue, + addToDataset, + alerts, + applicationTime, + evaluators, + runName, + runSessionId, + runType, + threadId, + webhooks, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun endTime(): OffsetDateTime = endTime.getRequired("end_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun ruleId(): String = ruleId.getRequired("rule_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun runId(): String = runId.getRequired("run_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun startTime(): OffsetDateTime = startTime.getRequired("start_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun addToAnnotationQueue(): Optional<RuleLogActionResponse> = + addToAnnotationQueue.getOptional("add_to_annotation_queue") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun addToDataset(): Optional<RuleLogActionResponse> = addToDataset.getOptional("add_to_dataset") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun alerts(): Optional<RuleLogActionResponse> = alerts.getOptional("alerts") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun applicationTime(): Optional<OffsetDateTime> = + applicationTime.getOptional("application_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun evaluators(): Optional<RuleLogActionResponse> = evaluators.getOptional("evaluators") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun runName(): Optional<String> = runName.getOptional("run_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun runSessionId(): Optional<String> = runSessionId.getOptional("run_session_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun runType(): Optional<String> = runType.getOptional("run_type") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun threadId(): Optional<String> = threadId.getOptional("thread_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webhooks(): Optional<RuleLogActionResponse> = webhooks.getOptional("webhooks") + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_time") @ExcludeMissing fun _endTime(): JsonField<OffsetDateTime> = endTime + + /** + * Returns the raw JSON value of [ruleId]. + * + * Unlike [ruleId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rule_id") @ExcludeMissing fun _ruleId(): JsonField<String> = ruleId + + /** + * Returns the raw JSON value of [runId]. + * + * Unlike [runId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_id") @ExcludeMissing fun _runId(): JsonField<String> = runId + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_time") + @ExcludeMissing + fun _startTime(): JsonField<OffsetDateTime> = startTime + + /** + * Returns the raw JSON value of [addToAnnotationQueue]. + * + * Unlike [addToAnnotationQueue], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("add_to_annotation_queue") + @ExcludeMissing + fun _addToAnnotationQueue(): JsonField<RuleLogActionResponse> = addToAnnotationQueue + + /** + * Returns the raw JSON value of [addToDataset]. + * + * Unlike [addToDataset], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("add_to_dataset") + @ExcludeMissing + fun _addToDataset(): JsonField<RuleLogActionResponse> = addToDataset + + /** + * Returns the raw JSON value of [alerts]. + * + * Unlike [alerts], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("alerts") @ExcludeMissing fun _alerts(): JsonField<RuleLogActionResponse> = alerts + + /** + * Returns the raw JSON value of [applicationTime]. + * + * Unlike [applicationTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("application_time") + @ExcludeMissing + fun _applicationTime(): JsonField<OffsetDateTime> = applicationTime + + /** + * Returns the raw JSON value of [evaluators]. + * + * Unlike [evaluators], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("evaluators") + @ExcludeMissing + fun _evaluators(): JsonField<RuleLogActionResponse> = evaluators + + /** + * Returns the raw JSON value of [runName]. + * + * Unlike [runName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_name") @ExcludeMissing fun _runName(): JsonField<String> = runName + + /** + * Returns the raw JSON value of [runSessionId]. + * + * Unlike [runSessionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_session_id") + @ExcludeMissing + fun _runSessionId(): JsonField<String> = runSessionId + + /** + * Returns the raw JSON value of [runType]. + * + * Unlike [runType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_type") @ExcludeMissing fun _runType(): JsonField<String> = runType + + /** + * Returns the raw JSON value of [threadId]. + * + * Unlike [threadId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("thread_id") @ExcludeMissing fun _threadId(): JsonField<String> = threadId + + /** + * Returns the raw JSON value of [webhooks]. + * + * Unlike [webhooks], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("webhooks") + @ExcludeMissing + fun _webhooks(): JsonField<RuleLogActionResponse> = webhooks + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RuleLogSchema]. + * + * The following fields are required: + * ```java + * .endTime() + * .ruleId() + * .runId() + * .startTime() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RuleLogSchema]. */ + class Builder internal constructor() { + + private var endTime: JsonField<OffsetDateTime>? = null + private var ruleId: JsonField<String>? = null + private var runId: JsonField<String>? = null + private var startTime: JsonField<OffsetDateTime>? = null + private var addToAnnotationQueue: JsonField<RuleLogActionResponse> = JsonMissing.of() + private var addToDataset: JsonField<RuleLogActionResponse> = JsonMissing.of() + private var alerts: JsonField<RuleLogActionResponse> = JsonMissing.of() + private var applicationTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var evaluators: JsonField<RuleLogActionResponse> = JsonMissing.of() + private var runName: JsonField<String> = JsonMissing.of() + private var runSessionId: JsonField<String> = JsonMissing.of() + private var runType: JsonField<String> = JsonMissing.of() + private var threadId: JsonField<String> = JsonMissing.of() + private var webhooks: JsonField<RuleLogActionResponse> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(ruleLogSchema: RuleLogSchema) = apply { + endTime = ruleLogSchema.endTime + ruleId = ruleLogSchema.ruleId + runId = ruleLogSchema.runId + startTime = ruleLogSchema.startTime + addToAnnotationQueue = ruleLogSchema.addToAnnotationQueue + addToDataset = ruleLogSchema.addToDataset + alerts = ruleLogSchema.alerts + applicationTime = ruleLogSchema.applicationTime + evaluators = ruleLogSchema.evaluators + runName = ruleLogSchema.runName + runSessionId = ruleLogSchema.runSessionId + runType = ruleLogSchema.runType + threadId = ruleLogSchema.threadId + webhooks = ruleLogSchema.webhooks + additionalProperties = ruleLogSchema.additionalProperties.toMutableMap() + } + + fun endTime(endTime: OffsetDateTime) = endTime(JsonField.of(endTime)) + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endTime(endTime: JsonField<OffsetDateTime>) = apply { this.endTime = endTime } + + fun ruleId(ruleId: String) = ruleId(JsonField.of(ruleId)) + + /** + * Sets [Builder.ruleId] to an arbitrary JSON value. + * + * You should usually call [Builder.ruleId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun ruleId(ruleId: JsonField<String>) = apply { this.ruleId = ruleId } + + fun runId(runId: String) = runId(JsonField.of(runId)) + + /** + * Sets [Builder.runId] to an arbitrary JSON value. + * + * You should usually call [Builder.runId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun runId(runId: JsonField<String>) = apply { this.runId = runId } + + fun startTime(startTime: OffsetDateTime) = startTime(JsonField.of(startTime)) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField<OffsetDateTime>) = apply { this.startTime = startTime } + + fun addToAnnotationQueue(addToAnnotationQueue: RuleLogActionResponse?) = + addToAnnotationQueue(JsonField.ofNullable(addToAnnotationQueue)) + + /** + * Alias for calling [Builder.addToAnnotationQueue] with + * `addToAnnotationQueue.orElse(null)`. + */ + fun addToAnnotationQueue(addToAnnotationQueue: Optional<RuleLogActionResponse>) = + addToAnnotationQueue(addToAnnotationQueue.getOrNull()) + + /** + * Sets [Builder.addToAnnotationQueue] to an arbitrary JSON value. + * + * You should usually call [Builder.addToAnnotationQueue] with a well-typed + * [RuleLogActionResponse] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun addToAnnotationQueue(addToAnnotationQueue: JsonField<RuleLogActionResponse>) = apply { + this.addToAnnotationQueue = addToAnnotationQueue + } + + fun addToDataset(addToDataset: RuleLogActionResponse?) = + addToDataset(JsonField.ofNullable(addToDataset)) + + /** Alias for calling [Builder.addToDataset] with `addToDataset.orElse(null)`. */ + fun addToDataset(addToDataset: Optional<RuleLogActionResponse>) = + addToDataset(addToDataset.getOrNull()) + + /** + * Sets [Builder.addToDataset] to an arbitrary JSON value. + * + * You should usually call [Builder.addToDataset] with a well-typed [RuleLogActionResponse] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun addToDataset(addToDataset: JsonField<RuleLogActionResponse>) = apply { + this.addToDataset = addToDataset + } + + fun alerts(alerts: RuleLogActionResponse?) = alerts(JsonField.ofNullable(alerts)) + + /** Alias for calling [Builder.alerts] with `alerts.orElse(null)`. */ + fun alerts(alerts: Optional<RuleLogActionResponse>) = alerts(alerts.getOrNull()) + + /** + * Sets [Builder.alerts] to an arbitrary JSON value. + * + * You should usually call [Builder.alerts] with a well-typed [RuleLogActionResponse] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun alerts(alerts: JsonField<RuleLogActionResponse>) = apply { this.alerts = alerts } + + fun applicationTime(applicationTime: OffsetDateTime?) = + applicationTime(JsonField.ofNullable(applicationTime)) + + /** Alias for calling [Builder.applicationTime] with `applicationTime.orElse(null)`. */ + fun applicationTime(applicationTime: Optional<OffsetDateTime>) = + applicationTime(applicationTime.getOrNull()) + + /** + * Sets [Builder.applicationTime] to an arbitrary JSON value. + * + * You should usually call [Builder.applicationTime] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun applicationTime(applicationTime: JsonField<OffsetDateTime>) = apply { + this.applicationTime = applicationTime + } + + fun evaluators(evaluators: RuleLogActionResponse?) = + evaluators(JsonField.ofNullable(evaluators)) + + /** Alias for calling [Builder.evaluators] with `evaluators.orElse(null)`. */ + fun evaluators(evaluators: Optional<RuleLogActionResponse>) = + evaluators(evaluators.getOrNull()) + + /** + * Sets [Builder.evaluators] to an arbitrary JSON value. + * + * You should usually call [Builder.evaluators] with a well-typed [RuleLogActionResponse] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun evaluators(evaluators: JsonField<RuleLogActionResponse>) = apply { + this.evaluators = evaluators + } + + fun runName(runName: String?) = runName(JsonField.ofNullable(runName)) + + /** Alias for calling [Builder.runName] with `runName.orElse(null)`. */ + fun runName(runName: Optional<String>) = runName(runName.getOrNull()) + + /** + * Sets [Builder.runName] to an arbitrary JSON value. + * + * You should usually call [Builder.runName] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun runName(runName: JsonField<String>) = apply { this.runName = runName } + + fun runSessionId(runSessionId: String?) = runSessionId(JsonField.ofNullable(runSessionId)) + + /** Alias for calling [Builder.runSessionId] with `runSessionId.orElse(null)`. */ + fun runSessionId(runSessionId: Optional<String>) = runSessionId(runSessionId.getOrNull()) + + /** + * Sets [Builder.runSessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.runSessionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun runSessionId(runSessionId: JsonField<String>) = apply { + this.runSessionId = runSessionId + } + + fun runType(runType: String?) = runType(JsonField.ofNullable(runType)) + + /** Alias for calling [Builder.runType] with `runType.orElse(null)`. */ + fun runType(runType: Optional<String>) = runType(runType.getOrNull()) + + /** + * Sets [Builder.runType] to an arbitrary JSON value. + * + * You should usually call [Builder.runType] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun runType(runType: JsonField<String>) = apply { this.runType = runType } + + fun threadId(threadId: String?) = threadId(JsonField.ofNullable(threadId)) + + /** Alias for calling [Builder.threadId] with `threadId.orElse(null)`. */ + fun threadId(threadId: Optional<String>) = threadId(threadId.getOrNull()) + + /** + * Sets [Builder.threadId] to an arbitrary JSON value. + * + * You should usually call [Builder.threadId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun threadId(threadId: JsonField<String>) = apply { this.threadId = threadId } + + fun webhooks(webhooks: RuleLogActionResponse?) = webhooks(JsonField.ofNullable(webhooks)) + + /** Alias for calling [Builder.webhooks] with `webhooks.orElse(null)`. */ + fun webhooks(webhooks: Optional<RuleLogActionResponse>) = webhooks(webhooks.getOrNull()) + + /** + * Sets [Builder.webhooks] to an arbitrary JSON value. + * + * You should usually call [Builder.webhooks] with a well-typed [RuleLogActionResponse] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun webhooks(webhooks: JsonField<RuleLogActionResponse>) = apply { + this.webhooks = webhooks + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RuleLogSchema]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .endTime() + * .ruleId() + * .runId() + * .startTime() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RuleLogSchema = + RuleLogSchema( + checkRequired("endTime", endTime), + checkRequired("ruleId", ruleId), + checkRequired("runId", runId), + checkRequired("startTime", startTime), + addToAnnotationQueue, + addToDataset, + alerts, + applicationTime, + evaluators, + runName, + runSessionId, + runType, + threadId, + webhooks, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RuleLogSchema = apply { + if (validated) { + return@apply + } + + endTime() + ruleId() + runId() + startTime() + addToAnnotationQueue().ifPresent { it.validate() } + addToDataset().ifPresent { it.validate() } + alerts().ifPresent { it.validate() } + applicationTime() + evaluators().ifPresent { it.validate() } + runName() + runSessionId() + runType() + threadId() + webhooks().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (endTime.asKnown().isPresent) 1 else 0) + + (if (ruleId.asKnown().isPresent) 1 else 0) + + (if (runId.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + (addToAnnotationQueue.asKnown().getOrNull()?.validity() ?: 0) + + (addToDataset.asKnown().getOrNull()?.validity() ?: 0) + + (alerts.asKnown().getOrNull()?.validity() ?: 0) + + (if (applicationTime.asKnown().isPresent) 1 else 0) + + (evaluators.asKnown().getOrNull()?.validity() ?: 0) + + (if (runName.asKnown().isPresent) 1 else 0) + + (if (runSessionId.asKnown().isPresent) 1 else 0) + + (if (runType.asKnown().isPresent) 1 else 0) + + (if (threadId.asKnown().isPresent) 1 else 0) + + (webhooks.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RuleLogSchema && + endTime == other.endTime && + ruleId == other.ruleId && + runId == other.runId && + startTime == other.startTime && + addToAnnotationQueue == other.addToAnnotationQueue && + addToDataset == other.addToDataset && + alerts == other.alerts && + applicationTime == other.applicationTime && + evaluators == other.evaluators && + runName == other.runName && + runSessionId == other.runSessionId && + runType == other.runType && + threadId == other.threadId && + webhooks == other.webhooks && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + endTime, + ruleId, + runId, + startTime, + addToAnnotationQueue, + addToDataset, + alerts, + applicationTime, + evaluators, + runName, + runSessionId, + runType, + threadId, + webhooks, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RuleLogSchema{endTime=$endTime, ruleId=$ruleId, runId=$runId, startTime=$startTime, addToAnnotationQueue=$addToAnnotationQueue, addToDataset=$addToDataset, alerts=$alerts, applicationTime=$applicationTime, evaluators=$evaluators, runName=$runName, runSessionId=$runSessionId, runType=$runType, threadId=$threadId, webhooks=$webhooks, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleRetrieveLastAppliedParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleRetrieveLastAppliedParams.kt new file mode 100644 index 00000000..a854ef6d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleRetrieveLastAppliedParams.kt @@ -0,0 +1,196 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.rules + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get the last applied rule. */ +class RuleRetrieveLastAppliedParams +private constructor( + private val ruleId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun ruleId(): Optional<String> = Optional.ofNullable(ruleId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): RuleRetrieveLastAppliedParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [RuleRetrieveLastAppliedParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RuleRetrieveLastAppliedParams]. */ + class Builder internal constructor() { + + private var ruleId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(ruleRetrieveLastAppliedParams: RuleRetrieveLastAppliedParams) = apply { + ruleId = ruleRetrieveLastAppliedParams.ruleId + additionalHeaders = ruleRetrieveLastAppliedParams.additionalHeaders.toBuilder() + additionalQueryParams = ruleRetrieveLastAppliedParams.additionalQueryParams.toBuilder() + } + + fun ruleId(ruleId: String?) = apply { this.ruleId = ruleId } + + /** Alias for calling [Builder.ruleId] with `ruleId.orElse(null)`. */ + fun ruleId(ruleId: Optional<String>) = ruleId(ruleId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RuleRetrieveLastAppliedParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RuleRetrieveLastAppliedParams = + RuleRetrieveLastAppliedParams( + ruleId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> ruleId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RuleRetrieveLastAppliedParams && + ruleId == other.ruleId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(ruleId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "RuleRetrieveLastAppliedParams{ruleId=$ruleId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleRetrieveLogsParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleRetrieveLogsParams.kt new file mode 100644 index 00000000..658d3469 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleRetrieveLogsParams.kt @@ -0,0 +1,277 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.rules + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** List logs for a particular rule */ +class RuleRetrieveLogsParams +private constructor( + private val ruleId: String?, + private val endTime: OffsetDateTime?, + private val limit: Long?, + private val offset: Long?, + private val startTime: OffsetDateTime?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun ruleId(): Optional<String> = Optional.ofNullable(ruleId) + + fun endTime(): Optional<OffsetDateTime> = Optional.ofNullable(endTime) + + fun limit(): Optional<Long> = Optional.ofNullable(limit) + + fun offset(): Optional<Long> = Optional.ofNullable(offset) + + fun startTime(): Optional<OffsetDateTime> = Optional.ofNullable(startTime) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): RuleRetrieveLogsParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [RuleRetrieveLogsParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RuleRetrieveLogsParams]. */ + class Builder internal constructor() { + + private var ruleId: String? = null + private var endTime: OffsetDateTime? = null + private var limit: Long? = null + private var offset: Long? = null + private var startTime: OffsetDateTime? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(ruleRetrieveLogsParams: RuleRetrieveLogsParams) = apply { + ruleId = ruleRetrieveLogsParams.ruleId + endTime = ruleRetrieveLogsParams.endTime + limit = ruleRetrieveLogsParams.limit + offset = ruleRetrieveLogsParams.offset + startTime = ruleRetrieveLogsParams.startTime + additionalHeaders = ruleRetrieveLogsParams.additionalHeaders.toBuilder() + additionalQueryParams = ruleRetrieveLogsParams.additionalQueryParams.toBuilder() + } + + fun ruleId(ruleId: String?) = apply { this.ruleId = ruleId } + + /** Alias for calling [Builder.ruleId] with `ruleId.orElse(null)`. */ + fun ruleId(ruleId: Optional<String>) = ruleId(ruleId.getOrNull()) + + fun endTime(endTime: OffsetDateTime?) = apply { this.endTime = endTime } + + /** Alias for calling [Builder.endTime] with `endTime.orElse(null)`. */ + fun endTime(endTime: Optional<OffsetDateTime>) = endTime(endTime.getOrNull()) + + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional<Long>) = limit(limit.getOrNull()) + + fun offset(offset: Long?) = apply { this.offset = offset } + + /** + * Alias for [Builder.offset]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun offset(offset: Long) = offset(offset as Long?) + + /** Alias for calling [Builder.offset] with `offset.orElse(null)`. */ + fun offset(offset: Optional<Long>) = offset(offset.getOrNull()) + + fun startTime(startTime: OffsetDateTime?) = apply { this.startTime = startTime } + + /** Alias for calling [Builder.startTime] with `startTime.orElse(null)`. */ + fun startTime(startTime: Optional<OffsetDateTime>) = startTime(startTime.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RuleRetrieveLogsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RuleRetrieveLogsParams = + RuleRetrieveLogsParams( + ruleId, + endTime, + limit, + offset, + startTime, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> ruleId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + endTime?.let { put("end_time", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) } + limit?.let { put("limit", it.toString()) } + offset?.let { put("offset", it.toString()) } + startTime?.let { + put("start_time", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RuleRetrieveLogsParams && + ruleId == other.ruleId && + endTime == other.endTime && + limit == other.limit && + offset == other.offset && + startTime == other.startTime && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + ruleId, + endTime, + limit, + offset, + startTime, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "RuleRetrieveLogsParams{ruleId=$ruleId, endTime=$endTime, limit=$limit, offset=$offset, startTime=$startTime, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleUpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleUpdateParams.kt new file mode 100644 index 00000000..9c7c9f06 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleUpdateParams.kt @@ -0,0 +1,2152 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.rules + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Update a run rule. */ +class RuleUpdateParams +private constructor( + private val ruleId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun ruleId(): Optional<String> = Optional.ofNullable(ruleId) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun displayName(): String = body.displayName() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun samplingRate(): Double = body.samplingRate() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun addToAnnotationQueueId(): Optional<String> = body.addToAnnotationQueueId() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun addToDatasetId(): Optional<String> = body.addToDatasetId() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun addToDatasetPreferCorrection(): Optional<Boolean> = body.addToDatasetPreferCorrection() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun alerts(): Optional<List<RunRulesPagerdutyAlertSchema>> = body.alerts() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun backfillFrom(): Optional<OffsetDateTime> = body.backfillFrom() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun codeEvaluators(): Optional<List<CodeEvaluatorTopLevel>> = body.codeEvaluators() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun createAlignmentQueue(): Optional<Boolean> = body.createAlignmentQueue() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun datasetId(): Optional<String> = body.datasetId() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun evaluatorVersion(): Optional<Long> = body.evaluatorVersion() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun evaluators(): Optional<List<EvaluatorTopLevel>> = body.evaluators() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun extendOnly(): Optional<Boolean> = body.extendOnly() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun filter(): Optional<String> = body.filter() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun includeExtendedStats(): Optional<Boolean> = body.includeExtendedStats() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun isEnabled(): Optional<Boolean> = body.isEnabled() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun numFewShotExamples(): Optional<Long> = body.numFewShotExamples() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun sessionId(): Optional<String> = body.sessionId() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun traceFilter(): Optional<String> = body.traceFilter() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun transient_(): Optional<Boolean> = body.transient_() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun treeFilter(): Optional<String> = body.treeFilter() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun useCorrectionsDataset(): Optional<Boolean> = body.useCorrectionsDataset() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webhooks(): Optional<List<RunRulesWebhookSchema>> = body.webhooks() + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _displayName(): JsonField<String> = body._displayName() + + /** + * Returns the raw JSON value of [samplingRate]. + * + * Unlike [samplingRate], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _samplingRate(): JsonField<Double> = body._samplingRate() + + /** + * Returns the raw JSON value of [addToAnnotationQueueId]. + * + * Unlike [addToAnnotationQueueId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _addToAnnotationQueueId(): JsonField<String> = body._addToAnnotationQueueId() + + /** + * Returns the raw JSON value of [addToDatasetId]. + * + * Unlike [addToDatasetId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _addToDatasetId(): JsonField<String> = body._addToDatasetId() + + /** + * Returns the raw JSON value of [addToDatasetPreferCorrection]. + * + * Unlike [addToDatasetPreferCorrection], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _addToDatasetPreferCorrection(): JsonField<Boolean> = body._addToDatasetPreferCorrection() + + /** + * Returns the raw JSON value of [alerts]. + * + * Unlike [alerts], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _alerts(): JsonField<List<RunRulesPagerdutyAlertSchema>> = body._alerts() + + /** + * Returns the raw JSON value of [backfillFrom]. + * + * Unlike [backfillFrom], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _backfillFrom(): JsonField<OffsetDateTime> = body._backfillFrom() + + /** + * Returns the raw JSON value of [codeEvaluators]. + * + * Unlike [codeEvaluators], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _codeEvaluators(): JsonField<List<CodeEvaluatorTopLevel>> = body._codeEvaluators() + + /** + * Returns the raw JSON value of [createAlignmentQueue]. + * + * Unlike [createAlignmentQueue], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _createAlignmentQueue(): JsonField<Boolean> = body._createAlignmentQueue() + + /** + * Returns the raw JSON value of [datasetId]. + * + * Unlike [datasetId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _datasetId(): JsonField<String> = body._datasetId() + + /** + * Returns the raw JSON value of [evaluatorVersion]. + * + * Unlike [evaluatorVersion], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _evaluatorVersion(): JsonField<Long> = body._evaluatorVersion() + + /** + * Returns the raw JSON value of [evaluators]. + * + * Unlike [evaluators], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _evaluators(): JsonField<List<EvaluatorTopLevel>> = body._evaluators() + + /** + * Returns the raw JSON value of [extendOnly]. + * + * Unlike [extendOnly], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _extendOnly(): JsonField<Boolean> = body._extendOnly() + + /** + * Returns the raw JSON value of [filter]. + * + * Unlike [filter], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _filter(): JsonField<String> = body._filter() + + /** + * Returns the raw JSON value of [includeExtendedStats]. + * + * Unlike [includeExtendedStats], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _includeExtendedStats(): JsonField<Boolean> = body._includeExtendedStats() + + /** + * Returns the raw JSON value of [isEnabled]. + * + * Unlike [isEnabled], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _isEnabled(): JsonField<Boolean> = body._isEnabled() + + /** + * Returns the raw JSON value of [numFewShotExamples]. + * + * Unlike [numFewShotExamples], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _numFewShotExamples(): JsonField<Long> = body._numFewShotExamples() + + /** + * Returns the raw JSON value of [sessionId]. + * + * Unlike [sessionId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _sessionId(): JsonField<String> = body._sessionId() + + /** + * Returns the raw JSON value of [traceFilter]. + * + * Unlike [traceFilter], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _traceFilter(): JsonField<String> = body._traceFilter() + + /** + * Returns the raw JSON value of [transient_]. + * + * Unlike [transient_], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _transient_(): JsonField<Boolean> = body._transient_() + + /** + * Returns the raw JSON value of [treeFilter]. + * + * Unlike [treeFilter], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _treeFilter(): JsonField<String> = body._treeFilter() + + /** + * Returns the raw JSON value of [useCorrectionsDataset]. + * + * Unlike [useCorrectionsDataset], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _useCorrectionsDataset(): JsonField<Boolean> = body._useCorrectionsDataset() + + /** + * Returns the raw JSON value of [webhooks]. + * + * Unlike [webhooks], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _webhooks(): JsonField<List<RunRulesWebhookSchema>> = body._webhooks() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RuleUpdateParams]. + * + * The following fields are required: + * ```java + * .displayName() + * .samplingRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RuleUpdateParams]. */ + class Builder internal constructor() { + + private var ruleId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(ruleUpdateParams: RuleUpdateParams) = apply { + ruleId = ruleUpdateParams.ruleId + body = ruleUpdateParams.body.toBuilder() + additionalHeaders = ruleUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = ruleUpdateParams.additionalQueryParams.toBuilder() + } + + fun ruleId(ruleId: String?) = apply { this.ruleId = ruleId } + + /** Alias for calling [Builder.ruleId] with `ruleId.orElse(null)`. */ + fun ruleId(ruleId: Optional<String>) = ruleId(ruleId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [displayName] + * - [samplingRate] + * - [addToAnnotationQueueId] + * - [addToDatasetId] + * - [addToDatasetPreferCorrection] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun displayName(displayName: String) = apply { body.displayName(displayName) } + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun displayName(displayName: JsonField<String>) = apply { body.displayName(displayName) } + + fun samplingRate(samplingRate: Double) = apply { body.samplingRate(samplingRate) } + + /** + * Sets [Builder.samplingRate] to an arbitrary JSON value. + * + * You should usually call [Builder.samplingRate] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun samplingRate(samplingRate: JsonField<Double>) = apply { + body.samplingRate(samplingRate) + } + + fun addToAnnotationQueueId(addToAnnotationQueueId: String?) = apply { + body.addToAnnotationQueueId(addToAnnotationQueueId) + } + + /** + * Alias for calling [Builder.addToAnnotationQueueId] with + * `addToAnnotationQueueId.orElse(null)`. + */ + fun addToAnnotationQueueId(addToAnnotationQueueId: Optional<String>) = + addToAnnotationQueueId(addToAnnotationQueueId.getOrNull()) + + /** + * Sets [Builder.addToAnnotationQueueId] to an arbitrary JSON value. + * + * You should usually call [Builder.addToAnnotationQueueId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun addToAnnotationQueueId(addToAnnotationQueueId: JsonField<String>) = apply { + body.addToAnnotationQueueId(addToAnnotationQueueId) + } + + fun addToDatasetId(addToDatasetId: String?) = apply { body.addToDatasetId(addToDatasetId) } + + /** Alias for calling [Builder.addToDatasetId] with `addToDatasetId.orElse(null)`. */ + fun addToDatasetId(addToDatasetId: Optional<String>) = + addToDatasetId(addToDatasetId.getOrNull()) + + /** + * Sets [Builder.addToDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.addToDatasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun addToDatasetId(addToDatasetId: JsonField<String>) = apply { + body.addToDatasetId(addToDatasetId) + } + + fun addToDatasetPreferCorrection(addToDatasetPreferCorrection: Boolean) = apply { + body.addToDatasetPreferCorrection(addToDatasetPreferCorrection) + } + + /** + * Sets [Builder.addToDatasetPreferCorrection] to an arbitrary JSON value. + * + * You should usually call [Builder.addToDatasetPreferCorrection] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun addToDatasetPreferCorrection(addToDatasetPreferCorrection: JsonField<Boolean>) = apply { + body.addToDatasetPreferCorrection(addToDatasetPreferCorrection) + } + + fun alerts(alerts: List<RunRulesPagerdutyAlertSchema>?) = apply { body.alerts(alerts) } + + /** Alias for calling [Builder.alerts] with `alerts.orElse(null)`. */ + fun alerts(alerts: Optional<List<RunRulesPagerdutyAlertSchema>>) = + alerts(alerts.getOrNull()) + + /** + * Sets [Builder.alerts] to an arbitrary JSON value. + * + * You should usually call [Builder.alerts] with a well-typed + * `List<RunRulesPagerdutyAlertSchema>` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun alerts(alerts: JsonField<List<RunRulesPagerdutyAlertSchema>>) = apply { + body.alerts(alerts) + } + + /** + * Adds a single [RunRulesPagerdutyAlertSchema] to [alerts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAlert(alert: RunRulesPagerdutyAlertSchema) = apply { body.addAlert(alert) } + + fun backfillFrom(backfillFrom: OffsetDateTime?) = apply { body.backfillFrom(backfillFrom) } + + /** Alias for calling [Builder.backfillFrom] with `backfillFrom.orElse(null)`. */ + fun backfillFrom(backfillFrom: Optional<OffsetDateTime>) = + backfillFrom(backfillFrom.getOrNull()) + + /** + * Sets [Builder.backfillFrom] to an arbitrary JSON value. + * + * You should usually call [Builder.backfillFrom] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun backfillFrom(backfillFrom: JsonField<OffsetDateTime>) = apply { + body.backfillFrom(backfillFrom) + } + + fun codeEvaluators(codeEvaluators: List<CodeEvaluatorTopLevel>?) = apply { + body.codeEvaluators(codeEvaluators) + } + + /** Alias for calling [Builder.codeEvaluators] with `codeEvaluators.orElse(null)`. */ + fun codeEvaluators(codeEvaluators: Optional<List<CodeEvaluatorTopLevel>>) = + codeEvaluators(codeEvaluators.getOrNull()) + + /** + * Sets [Builder.codeEvaluators] to an arbitrary JSON value. + * + * You should usually call [Builder.codeEvaluators] with a well-typed + * `List<CodeEvaluatorTopLevel>` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun codeEvaluators(codeEvaluators: JsonField<List<CodeEvaluatorTopLevel>>) = apply { + body.codeEvaluators(codeEvaluators) + } + + /** + * Adds a single [CodeEvaluatorTopLevel] to [codeEvaluators]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCodeEvaluator(codeEvaluator: CodeEvaluatorTopLevel) = apply { + body.addCodeEvaluator(codeEvaluator) + } + + fun createAlignmentQueue(createAlignmentQueue: Boolean) = apply { + body.createAlignmentQueue(createAlignmentQueue) + } + + /** + * Sets [Builder.createAlignmentQueue] to an arbitrary JSON value. + * + * You should usually call [Builder.createAlignmentQueue] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createAlignmentQueue(createAlignmentQueue: JsonField<Boolean>) = apply { + body.createAlignmentQueue(createAlignmentQueue) + } + + fun datasetId(datasetId: String?) = apply { body.datasetId(datasetId) } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + /** + * Sets [Builder.datasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun datasetId(datasetId: JsonField<String>) = apply { body.datasetId(datasetId) } + + fun evaluatorVersion(evaluatorVersion: Long?) = apply { + body.evaluatorVersion(evaluatorVersion) + } + + /** + * Alias for [Builder.evaluatorVersion]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun evaluatorVersion(evaluatorVersion: Long) = evaluatorVersion(evaluatorVersion as Long?) + + /** Alias for calling [Builder.evaluatorVersion] with `evaluatorVersion.orElse(null)`. */ + fun evaluatorVersion(evaluatorVersion: Optional<Long>) = + evaluatorVersion(evaluatorVersion.getOrNull()) + + /** + * Sets [Builder.evaluatorVersion] to an arbitrary JSON value. + * + * You should usually call [Builder.evaluatorVersion] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun evaluatorVersion(evaluatorVersion: JsonField<Long>) = apply { + body.evaluatorVersion(evaluatorVersion) + } + + fun evaluators(evaluators: List<EvaluatorTopLevel>?) = apply { body.evaluators(evaluators) } + + /** Alias for calling [Builder.evaluators] with `evaluators.orElse(null)`. */ + fun evaluators(evaluators: Optional<List<EvaluatorTopLevel>>) = + evaluators(evaluators.getOrNull()) + + /** + * Sets [Builder.evaluators] to an arbitrary JSON value. + * + * You should usually call [Builder.evaluators] with a well-typed `List<EvaluatorTopLevel>` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun evaluators(evaluators: JsonField<List<EvaluatorTopLevel>>) = apply { + body.evaluators(evaluators) + } + + /** + * Adds a single [EvaluatorTopLevel] to [evaluators]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvaluator(evaluator: EvaluatorTopLevel) = apply { body.addEvaluator(evaluator) } + + fun extendOnly(extendOnly: Boolean) = apply { body.extendOnly(extendOnly) } + + /** + * Sets [Builder.extendOnly] to an arbitrary JSON value. + * + * You should usually call [Builder.extendOnly] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun extendOnly(extendOnly: JsonField<Boolean>) = apply { body.extendOnly(extendOnly) } + + fun filter(filter: String?) = apply { body.filter(filter) } + + /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ + fun filter(filter: Optional<String>) = filter(filter.getOrNull()) + + /** + * Sets [Builder.filter] to an arbitrary JSON value. + * + * You should usually call [Builder.filter] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun filter(filter: JsonField<String>) = apply { body.filter(filter) } + + fun includeExtendedStats(includeExtendedStats: Boolean) = apply { + body.includeExtendedStats(includeExtendedStats) + } + + /** + * Sets [Builder.includeExtendedStats] to an arbitrary JSON value. + * + * You should usually call [Builder.includeExtendedStats] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun includeExtendedStats(includeExtendedStats: JsonField<Boolean>) = apply { + body.includeExtendedStats(includeExtendedStats) + } + + fun isEnabled(isEnabled: Boolean) = apply { body.isEnabled(isEnabled) } + + /** + * Sets [Builder.isEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.isEnabled] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isEnabled(isEnabled: JsonField<Boolean>) = apply { body.isEnabled(isEnabled) } + + fun numFewShotExamples(numFewShotExamples: Long?) = apply { + body.numFewShotExamples(numFewShotExamples) + } + + /** + * Alias for [Builder.numFewShotExamples]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun numFewShotExamples(numFewShotExamples: Long) = + numFewShotExamples(numFewShotExamples as Long?) + + /** + * Alias for calling [Builder.numFewShotExamples] with `numFewShotExamples.orElse(null)`. + */ + fun numFewShotExamples(numFewShotExamples: Optional<Long>) = + numFewShotExamples(numFewShotExamples.getOrNull()) + + /** + * Sets [Builder.numFewShotExamples] to an arbitrary JSON value. + * + * You should usually call [Builder.numFewShotExamples] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun numFewShotExamples(numFewShotExamples: JsonField<Long>) = apply { + body.numFewShotExamples(numFewShotExamples) + } + + fun sessionId(sessionId: String?) = apply { body.sessionId(sessionId) } + + /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ + fun sessionId(sessionId: Optional<String>) = sessionId(sessionId.getOrNull()) + + /** + * Sets [Builder.sessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun sessionId(sessionId: JsonField<String>) = apply { body.sessionId(sessionId) } + + fun traceFilter(traceFilter: String?) = apply { body.traceFilter(traceFilter) } + + /** Alias for calling [Builder.traceFilter] with `traceFilter.orElse(null)`. */ + fun traceFilter(traceFilter: Optional<String>) = traceFilter(traceFilter.getOrNull()) + + /** + * Sets [Builder.traceFilter] to an arbitrary JSON value. + * + * You should usually call [Builder.traceFilter] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun traceFilter(traceFilter: JsonField<String>) = apply { body.traceFilter(traceFilter) } + + fun transient_(transient_: Boolean) = apply { body.transient_(transient_) } + + /** + * Sets [Builder.transient_] to an arbitrary JSON value. + * + * You should usually call [Builder.transient_] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun transient_(transient_: JsonField<Boolean>) = apply { body.transient_(transient_) } + + fun treeFilter(treeFilter: String?) = apply { body.treeFilter(treeFilter) } + + /** Alias for calling [Builder.treeFilter] with `treeFilter.orElse(null)`. */ + fun treeFilter(treeFilter: Optional<String>) = treeFilter(treeFilter.getOrNull()) + + /** + * Sets [Builder.treeFilter] to an arbitrary JSON value. + * + * You should usually call [Builder.treeFilter] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun treeFilter(treeFilter: JsonField<String>) = apply { body.treeFilter(treeFilter) } + + fun useCorrectionsDataset(useCorrectionsDataset: Boolean) = apply { + body.useCorrectionsDataset(useCorrectionsDataset) + } + + /** + * Sets [Builder.useCorrectionsDataset] to an arbitrary JSON value. + * + * You should usually call [Builder.useCorrectionsDataset] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun useCorrectionsDataset(useCorrectionsDataset: JsonField<Boolean>) = apply { + body.useCorrectionsDataset(useCorrectionsDataset) + } + + fun webhooks(webhooks: List<RunRulesWebhookSchema>?) = apply { body.webhooks(webhooks) } + + /** Alias for calling [Builder.webhooks] with `webhooks.orElse(null)`. */ + fun webhooks(webhooks: Optional<List<RunRulesWebhookSchema>>) = + webhooks(webhooks.getOrNull()) + + /** + * Sets [Builder.webhooks] to an arbitrary JSON value. + * + * You should usually call [Builder.webhooks] with a well-typed + * `List<RunRulesWebhookSchema>` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun webhooks(webhooks: JsonField<List<RunRulesWebhookSchema>>) = apply { + body.webhooks(webhooks) + } + + /** + * Adds a single [RunRulesWebhookSchema] to [webhooks]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWebhook(webhook: RunRulesWebhookSchema) = apply { body.addWebhook(webhook) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RuleUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .displayName() + * .samplingRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RuleUpdateParams = + RuleUpdateParams( + ruleId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> ruleId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val displayName: JsonField<String>, + private val samplingRate: JsonField<Double>, + private val addToAnnotationQueueId: JsonField<String>, + private val addToDatasetId: JsonField<String>, + private val addToDatasetPreferCorrection: JsonField<Boolean>, + private val alerts: JsonField<List<RunRulesPagerdutyAlertSchema>>, + private val backfillFrom: JsonField<OffsetDateTime>, + private val codeEvaluators: JsonField<List<CodeEvaluatorTopLevel>>, + private val createAlignmentQueue: JsonField<Boolean>, + private val datasetId: JsonField<String>, + private val evaluatorVersion: JsonField<Long>, + private val evaluators: JsonField<List<EvaluatorTopLevel>>, + private val extendOnly: JsonField<Boolean>, + private val filter: JsonField<String>, + private val includeExtendedStats: JsonField<Boolean>, + private val isEnabled: JsonField<Boolean>, + private val numFewShotExamples: JsonField<Long>, + private val sessionId: JsonField<String>, + private val traceFilter: JsonField<String>, + private val transient_: JsonField<Boolean>, + private val treeFilter: JsonField<String>, + private val useCorrectionsDataset: JsonField<Boolean>, + private val webhooks: JsonField<List<RunRulesWebhookSchema>>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField<String> = JsonMissing.of(), + @JsonProperty("sampling_rate") + @ExcludeMissing + samplingRate: JsonField<Double> = JsonMissing.of(), + @JsonProperty("add_to_annotation_queue_id") + @ExcludeMissing + addToAnnotationQueueId: JsonField<String> = JsonMissing.of(), + @JsonProperty("add_to_dataset_id") + @ExcludeMissing + addToDatasetId: JsonField<String> = JsonMissing.of(), + @JsonProperty("add_to_dataset_prefer_correction") + @ExcludeMissing + addToDatasetPreferCorrection: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("alerts") + @ExcludeMissing + alerts: JsonField<List<RunRulesPagerdutyAlertSchema>> = JsonMissing.of(), + @JsonProperty("backfill_from") + @ExcludeMissing + backfillFrom: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("code_evaluators") + @ExcludeMissing + codeEvaluators: JsonField<List<CodeEvaluatorTopLevel>> = JsonMissing.of(), + @JsonProperty("create_alignment_queue") + @ExcludeMissing + createAlignmentQueue: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("dataset_id") + @ExcludeMissing + datasetId: JsonField<String> = JsonMissing.of(), + @JsonProperty("evaluator_version") + @ExcludeMissing + evaluatorVersion: JsonField<Long> = JsonMissing.of(), + @JsonProperty("evaluators") + @ExcludeMissing + evaluators: JsonField<List<EvaluatorTopLevel>> = JsonMissing.of(), + @JsonProperty("extend_only") + @ExcludeMissing + extendOnly: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("filter") @ExcludeMissing filter: JsonField<String> = JsonMissing.of(), + @JsonProperty("include_extended_stats") + @ExcludeMissing + includeExtendedStats: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("is_enabled") + @ExcludeMissing + isEnabled: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("num_few_shot_examples") + @ExcludeMissing + numFewShotExamples: JsonField<Long> = JsonMissing.of(), + @JsonProperty("session_id") + @ExcludeMissing + sessionId: JsonField<String> = JsonMissing.of(), + @JsonProperty("trace_filter") + @ExcludeMissing + traceFilter: JsonField<String> = JsonMissing.of(), + @JsonProperty("transient") + @ExcludeMissing + transient_: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("tree_filter") + @ExcludeMissing + treeFilter: JsonField<String> = JsonMissing.of(), + @JsonProperty("use_corrections_dataset") + @ExcludeMissing + useCorrectionsDataset: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("webhooks") + @ExcludeMissing + webhooks: JsonField<List<RunRulesWebhookSchema>> = JsonMissing.of(), + ) : this( + displayName, + samplingRate, + addToAnnotationQueueId, + addToDatasetId, + addToDatasetPreferCorrection, + alerts, + backfillFrom, + codeEvaluators, + createAlignmentQueue, + datasetId, + evaluatorVersion, + evaluators, + extendOnly, + filter, + includeExtendedStats, + isEnabled, + numFewShotExamples, + sessionId, + traceFilter, + transient_, + treeFilter, + useCorrectionsDataset, + webhooks, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun displayName(): String = displayName.getRequired("display_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun samplingRate(): Double = samplingRate.getRequired("sampling_rate") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun addToAnnotationQueueId(): Optional<String> = + addToAnnotationQueueId.getOptional("add_to_annotation_queue_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun addToDatasetId(): Optional<String> = addToDatasetId.getOptional("add_to_dataset_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun addToDatasetPreferCorrection(): Optional<Boolean> = + addToDatasetPreferCorrection.getOptional("add_to_dataset_prefer_correction") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun alerts(): Optional<List<RunRulesPagerdutyAlertSchema>> = alerts.getOptional("alerts") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun backfillFrom(): Optional<OffsetDateTime> = backfillFrom.getOptional("backfill_from") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun codeEvaluators(): Optional<List<CodeEvaluatorTopLevel>> = + codeEvaluators.getOptional("code_evaluators") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun createAlignmentQueue(): Optional<Boolean> = + createAlignmentQueue.getOptional("create_alignment_queue") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun datasetId(): Optional<String> = datasetId.getOptional("dataset_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun evaluatorVersion(): Optional<Long> = evaluatorVersion.getOptional("evaluator_version") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun evaluators(): Optional<List<EvaluatorTopLevel>> = evaluators.getOptional("evaluators") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun extendOnly(): Optional<Boolean> = extendOnly.getOptional("extend_only") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun filter(): Optional<String> = filter.getOptional("filter") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun includeExtendedStats(): Optional<Boolean> = + includeExtendedStats.getOptional("include_extended_stats") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun isEnabled(): Optional<Boolean> = isEnabled.getOptional("is_enabled") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun numFewShotExamples(): Optional<Long> = + numFewShotExamples.getOptional("num_few_shot_examples") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun sessionId(): Optional<String> = sessionId.getOptional("session_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun traceFilter(): Optional<String> = traceFilter.getOptional("trace_filter") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun transient_(): Optional<Boolean> = transient_.getOptional("transient") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun treeFilter(): Optional<String> = treeFilter.getOptional("tree_filter") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun useCorrectionsDataset(): Optional<Boolean> = + useCorrectionsDataset.getOptional("use_corrections_dataset") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun webhooks(): Optional<List<RunRulesWebhookSchema>> = webhooks.getOptional("webhooks") + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField<String> = displayName + + /** + * Returns the raw JSON value of [samplingRate]. + * + * Unlike [samplingRate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("sampling_rate") + @ExcludeMissing + fun _samplingRate(): JsonField<Double> = samplingRate + + /** + * Returns the raw JSON value of [addToAnnotationQueueId]. + * + * Unlike [addToAnnotationQueueId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("add_to_annotation_queue_id") + @ExcludeMissing + fun _addToAnnotationQueueId(): JsonField<String> = addToAnnotationQueueId + + /** + * Returns the raw JSON value of [addToDatasetId]. + * + * Unlike [addToDatasetId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("add_to_dataset_id") + @ExcludeMissing + fun _addToDatasetId(): JsonField<String> = addToDatasetId + + /** + * Returns the raw JSON value of [addToDatasetPreferCorrection]. + * + * Unlike [addToDatasetPreferCorrection], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("add_to_dataset_prefer_correction") + @ExcludeMissing + fun _addToDatasetPreferCorrection(): JsonField<Boolean> = addToDatasetPreferCorrection + + /** + * Returns the raw JSON value of [alerts]. + * + * Unlike [alerts], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("alerts") + @ExcludeMissing + fun _alerts(): JsonField<List<RunRulesPagerdutyAlertSchema>> = alerts + + /** + * Returns the raw JSON value of [backfillFrom]. + * + * Unlike [backfillFrom], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("backfill_from") + @ExcludeMissing + fun _backfillFrom(): JsonField<OffsetDateTime> = backfillFrom + + /** + * Returns the raw JSON value of [codeEvaluators]. + * + * Unlike [codeEvaluators], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("code_evaluators") + @ExcludeMissing + fun _codeEvaluators(): JsonField<List<CodeEvaluatorTopLevel>> = codeEvaluators + + /** + * Returns the raw JSON value of [createAlignmentQueue]. + * + * Unlike [createAlignmentQueue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("create_alignment_queue") + @ExcludeMissing + fun _createAlignmentQueue(): JsonField<Boolean> = createAlignmentQueue + + /** + * Returns the raw JSON value of [datasetId]. + * + * Unlike [datasetId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField<String> = datasetId + + /** + * Returns the raw JSON value of [evaluatorVersion]. + * + * Unlike [evaluatorVersion], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("evaluator_version") + @ExcludeMissing + fun _evaluatorVersion(): JsonField<Long> = evaluatorVersion + + /** + * Returns the raw JSON value of [evaluators]. + * + * Unlike [evaluators], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("evaluators") + @ExcludeMissing + fun _evaluators(): JsonField<List<EvaluatorTopLevel>> = evaluators + + /** + * Returns the raw JSON value of [extendOnly]. + * + * Unlike [extendOnly], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("extend_only") + @ExcludeMissing + fun _extendOnly(): JsonField<Boolean> = extendOnly + + /** + * Returns the raw JSON value of [filter]. + * + * Unlike [filter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField<String> = filter + + /** + * Returns the raw JSON value of [includeExtendedStats]. + * + * Unlike [includeExtendedStats], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("include_extended_stats") + @ExcludeMissing + fun _includeExtendedStats(): JsonField<Boolean> = includeExtendedStats + + /** + * Returns the raw JSON value of [isEnabled]. + * + * Unlike [isEnabled], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_enabled") @ExcludeMissing fun _isEnabled(): JsonField<Boolean> = isEnabled + + /** + * Returns the raw JSON value of [numFewShotExamples]. + * + * Unlike [numFewShotExamples], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("num_few_shot_examples") + @ExcludeMissing + fun _numFewShotExamples(): JsonField<Long> = numFewShotExamples + + /** + * Returns the raw JSON value of [sessionId]. + * + * Unlike [sessionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session_id") @ExcludeMissing fun _sessionId(): JsonField<String> = sessionId + + /** + * Returns the raw JSON value of [traceFilter]. + * + * Unlike [traceFilter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trace_filter") + @ExcludeMissing + fun _traceFilter(): JsonField<String> = traceFilter + + /** + * Returns the raw JSON value of [transient_]. + * + * Unlike [transient_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("transient") + @ExcludeMissing + fun _transient_(): JsonField<Boolean> = transient_ + + /** + * Returns the raw JSON value of [treeFilter]. + * + * Unlike [treeFilter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tree_filter") + @ExcludeMissing + fun _treeFilter(): JsonField<String> = treeFilter + + /** + * Returns the raw JSON value of [useCorrectionsDataset]. + * + * Unlike [useCorrectionsDataset], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("use_corrections_dataset") + @ExcludeMissing + fun _useCorrectionsDataset(): JsonField<Boolean> = useCorrectionsDataset + + /** + * Returns the raw JSON value of [webhooks]. + * + * Unlike [webhooks], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("webhooks") + @ExcludeMissing + fun _webhooks(): JsonField<List<RunRulesWebhookSchema>> = webhooks + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .displayName() + * .samplingRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var displayName: JsonField<String>? = null + private var samplingRate: JsonField<Double>? = null + private var addToAnnotationQueueId: JsonField<String> = JsonMissing.of() + private var addToDatasetId: JsonField<String> = JsonMissing.of() + private var addToDatasetPreferCorrection: JsonField<Boolean> = JsonMissing.of() + private var alerts: JsonField<MutableList<RunRulesPagerdutyAlertSchema>>? = null + private var backfillFrom: JsonField<OffsetDateTime> = JsonMissing.of() + private var codeEvaluators: JsonField<MutableList<CodeEvaluatorTopLevel>>? = null + private var createAlignmentQueue: JsonField<Boolean> = JsonMissing.of() + private var datasetId: JsonField<String> = JsonMissing.of() + private var evaluatorVersion: JsonField<Long> = JsonMissing.of() + private var evaluators: JsonField<MutableList<EvaluatorTopLevel>>? = null + private var extendOnly: JsonField<Boolean> = JsonMissing.of() + private var filter: JsonField<String> = JsonMissing.of() + private var includeExtendedStats: JsonField<Boolean> = JsonMissing.of() + private var isEnabled: JsonField<Boolean> = JsonMissing.of() + private var numFewShotExamples: JsonField<Long> = JsonMissing.of() + private var sessionId: JsonField<String> = JsonMissing.of() + private var traceFilter: JsonField<String> = JsonMissing.of() + private var transient_: JsonField<Boolean> = JsonMissing.of() + private var treeFilter: JsonField<String> = JsonMissing.of() + private var useCorrectionsDataset: JsonField<Boolean> = JsonMissing.of() + private var webhooks: JsonField<MutableList<RunRulesWebhookSchema>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + displayName = body.displayName + samplingRate = body.samplingRate + addToAnnotationQueueId = body.addToAnnotationQueueId + addToDatasetId = body.addToDatasetId + addToDatasetPreferCorrection = body.addToDatasetPreferCorrection + alerts = body.alerts.map { it.toMutableList() } + backfillFrom = body.backfillFrom + codeEvaluators = body.codeEvaluators.map { it.toMutableList() } + createAlignmentQueue = body.createAlignmentQueue + datasetId = body.datasetId + evaluatorVersion = body.evaluatorVersion + evaluators = body.evaluators.map { it.toMutableList() } + extendOnly = body.extendOnly + filter = body.filter + includeExtendedStats = body.includeExtendedStats + isEnabled = body.isEnabled + numFewShotExamples = body.numFewShotExamples + sessionId = body.sessionId + traceFilter = body.traceFilter + transient_ = body.transient_ + treeFilter = body.treeFilter + useCorrectionsDataset = body.useCorrectionsDataset + webhooks = body.webhooks.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun displayName(displayName: String) = displayName(JsonField.of(displayName)) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun displayName(displayName: JsonField<String>) = apply { + this.displayName = displayName + } + + fun samplingRate(samplingRate: Double) = samplingRate(JsonField.of(samplingRate)) + + /** + * Sets [Builder.samplingRate] to an arbitrary JSON value. + * + * You should usually call [Builder.samplingRate] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun samplingRate(samplingRate: JsonField<Double>) = apply { + this.samplingRate = samplingRate + } + + fun addToAnnotationQueueId(addToAnnotationQueueId: String?) = + addToAnnotationQueueId(JsonField.ofNullable(addToAnnotationQueueId)) + + /** + * Alias for calling [Builder.addToAnnotationQueueId] with + * `addToAnnotationQueueId.orElse(null)`. + */ + fun addToAnnotationQueueId(addToAnnotationQueueId: Optional<String>) = + addToAnnotationQueueId(addToAnnotationQueueId.getOrNull()) + + /** + * Sets [Builder.addToAnnotationQueueId] to an arbitrary JSON value. + * + * You should usually call [Builder.addToAnnotationQueueId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun addToAnnotationQueueId(addToAnnotationQueueId: JsonField<String>) = apply { + this.addToAnnotationQueueId = addToAnnotationQueueId + } + + fun addToDatasetId(addToDatasetId: String?) = + addToDatasetId(JsonField.ofNullable(addToDatasetId)) + + /** Alias for calling [Builder.addToDatasetId] with `addToDatasetId.orElse(null)`. */ + fun addToDatasetId(addToDatasetId: Optional<String>) = + addToDatasetId(addToDatasetId.getOrNull()) + + /** + * Sets [Builder.addToDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.addToDatasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun addToDatasetId(addToDatasetId: JsonField<String>) = apply { + this.addToDatasetId = addToDatasetId + } + + fun addToDatasetPreferCorrection(addToDatasetPreferCorrection: Boolean) = + addToDatasetPreferCorrection(JsonField.of(addToDatasetPreferCorrection)) + + /** + * Sets [Builder.addToDatasetPreferCorrection] to an arbitrary JSON value. + * + * You should usually call [Builder.addToDatasetPreferCorrection] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun addToDatasetPreferCorrection(addToDatasetPreferCorrection: JsonField<Boolean>) = + apply { + this.addToDatasetPreferCorrection = addToDatasetPreferCorrection + } + + fun alerts(alerts: List<RunRulesPagerdutyAlertSchema>?) = + alerts(JsonField.ofNullable(alerts)) + + /** Alias for calling [Builder.alerts] with `alerts.orElse(null)`. */ + fun alerts(alerts: Optional<List<RunRulesPagerdutyAlertSchema>>) = + alerts(alerts.getOrNull()) + + /** + * Sets [Builder.alerts] to an arbitrary JSON value. + * + * You should usually call [Builder.alerts] with a well-typed + * `List<RunRulesPagerdutyAlertSchema>` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun alerts(alerts: JsonField<List<RunRulesPagerdutyAlertSchema>>) = apply { + this.alerts = alerts.map { it.toMutableList() } + } + + /** + * Adds a single [RunRulesPagerdutyAlertSchema] to [alerts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAlert(alert: RunRulesPagerdutyAlertSchema) = apply { + alerts = + (alerts ?: JsonField.of(mutableListOf())).also { + checkKnown("alerts", it).add(alert) + } + } + + fun backfillFrom(backfillFrom: OffsetDateTime?) = + backfillFrom(JsonField.ofNullable(backfillFrom)) + + /** Alias for calling [Builder.backfillFrom] with `backfillFrom.orElse(null)`. */ + fun backfillFrom(backfillFrom: Optional<OffsetDateTime>) = + backfillFrom(backfillFrom.getOrNull()) + + /** + * Sets [Builder.backfillFrom] to an arbitrary JSON value. + * + * You should usually call [Builder.backfillFrom] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun backfillFrom(backfillFrom: JsonField<OffsetDateTime>) = apply { + this.backfillFrom = backfillFrom + } + + fun codeEvaluators(codeEvaluators: List<CodeEvaluatorTopLevel>?) = + codeEvaluators(JsonField.ofNullable(codeEvaluators)) + + /** Alias for calling [Builder.codeEvaluators] with `codeEvaluators.orElse(null)`. */ + fun codeEvaluators(codeEvaluators: Optional<List<CodeEvaluatorTopLevel>>) = + codeEvaluators(codeEvaluators.getOrNull()) + + /** + * Sets [Builder.codeEvaluators] to an arbitrary JSON value. + * + * You should usually call [Builder.codeEvaluators] with a well-typed + * `List<CodeEvaluatorTopLevel>` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun codeEvaluators(codeEvaluators: JsonField<List<CodeEvaluatorTopLevel>>) = apply { + this.codeEvaluators = codeEvaluators.map { it.toMutableList() } + } + + /** + * Adds a single [CodeEvaluatorTopLevel] to [codeEvaluators]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCodeEvaluator(codeEvaluator: CodeEvaluatorTopLevel) = apply { + codeEvaluators = + (codeEvaluators ?: JsonField.of(mutableListOf())).also { + checkKnown("codeEvaluators", it).add(codeEvaluator) + } + } + + fun createAlignmentQueue(createAlignmentQueue: Boolean) = + createAlignmentQueue(JsonField.of(createAlignmentQueue)) + + /** + * Sets [Builder.createAlignmentQueue] to an arbitrary JSON value. + * + * You should usually call [Builder.createAlignmentQueue] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun createAlignmentQueue(createAlignmentQueue: JsonField<Boolean>) = apply { + this.createAlignmentQueue = createAlignmentQueue + } + + fun datasetId(datasetId: String?) = datasetId(JsonField.ofNullable(datasetId)) + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + /** + * Sets [Builder.datasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun datasetId(datasetId: JsonField<String>) = apply { this.datasetId = datasetId } + + fun evaluatorVersion(evaluatorVersion: Long?) = + evaluatorVersion(JsonField.ofNullable(evaluatorVersion)) + + /** + * Alias for [Builder.evaluatorVersion]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun evaluatorVersion(evaluatorVersion: Long) = + evaluatorVersion(evaluatorVersion as Long?) + + /** + * Alias for calling [Builder.evaluatorVersion] with `evaluatorVersion.orElse(null)`. + */ + fun evaluatorVersion(evaluatorVersion: Optional<Long>) = + evaluatorVersion(evaluatorVersion.getOrNull()) + + /** + * Sets [Builder.evaluatorVersion] to an arbitrary JSON value. + * + * You should usually call [Builder.evaluatorVersion] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun evaluatorVersion(evaluatorVersion: JsonField<Long>) = apply { + this.evaluatorVersion = evaluatorVersion + } + + fun evaluators(evaluators: List<EvaluatorTopLevel>?) = + evaluators(JsonField.ofNullable(evaluators)) + + /** Alias for calling [Builder.evaluators] with `evaluators.orElse(null)`. */ + fun evaluators(evaluators: Optional<List<EvaluatorTopLevel>>) = + evaluators(evaluators.getOrNull()) + + /** + * Sets [Builder.evaluators] to an arbitrary JSON value. + * + * You should usually call [Builder.evaluators] with a well-typed + * `List<EvaluatorTopLevel>` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun evaluators(evaluators: JsonField<List<EvaluatorTopLevel>>) = apply { + this.evaluators = evaluators.map { it.toMutableList() } + } + + /** + * Adds a single [EvaluatorTopLevel] to [evaluators]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvaluator(evaluator: EvaluatorTopLevel) = apply { + evaluators = + (evaluators ?: JsonField.of(mutableListOf())).also { + checkKnown("evaluators", it).add(evaluator) + } + } + + fun extendOnly(extendOnly: Boolean) = extendOnly(JsonField.of(extendOnly)) + + /** + * Sets [Builder.extendOnly] to an arbitrary JSON value. + * + * You should usually call [Builder.extendOnly] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun extendOnly(extendOnly: JsonField<Boolean>) = apply { this.extendOnly = extendOnly } + + fun filter(filter: String?) = filter(JsonField.ofNullable(filter)) + + /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ + fun filter(filter: Optional<String>) = filter(filter.getOrNull()) + + /** + * Sets [Builder.filter] to an arbitrary JSON value. + * + * You should usually call [Builder.filter] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun filter(filter: JsonField<String>) = apply { this.filter = filter } + + fun includeExtendedStats(includeExtendedStats: Boolean) = + includeExtendedStats(JsonField.of(includeExtendedStats)) + + /** + * Sets [Builder.includeExtendedStats] to an arbitrary JSON value. + * + * You should usually call [Builder.includeExtendedStats] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun includeExtendedStats(includeExtendedStats: JsonField<Boolean>) = apply { + this.includeExtendedStats = includeExtendedStats + } + + fun isEnabled(isEnabled: Boolean) = isEnabled(JsonField.of(isEnabled)) + + /** + * Sets [Builder.isEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.isEnabled] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isEnabled(isEnabled: JsonField<Boolean>) = apply { this.isEnabled = isEnabled } + + fun numFewShotExamples(numFewShotExamples: Long?) = + numFewShotExamples(JsonField.ofNullable(numFewShotExamples)) + + /** + * Alias for [Builder.numFewShotExamples]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun numFewShotExamples(numFewShotExamples: Long) = + numFewShotExamples(numFewShotExamples as Long?) + + /** + * Alias for calling [Builder.numFewShotExamples] with + * `numFewShotExamples.orElse(null)`. + */ + fun numFewShotExamples(numFewShotExamples: Optional<Long>) = + numFewShotExamples(numFewShotExamples.getOrNull()) + + /** + * Sets [Builder.numFewShotExamples] to an arbitrary JSON value. + * + * You should usually call [Builder.numFewShotExamples] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun numFewShotExamples(numFewShotExamples: JsonField<Long>) = apply { + this.numFewShotExamples = numFewShotExamples + } + + fun sessionId(sessionId: String?) = sessionId(JsonField.ofNullable(sessionId)) + + /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ + fun sessionId(sessionId: Optional<String>) = sessionId(sessionId.getOrNull()) + + /** + * Sets [Builder.sessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sessionId(sessionId: JsonField<String>) = apply { this.sessionId = sessionId } + + fun traceFilter(traceFilter: String?) = traceFilter(JsonField.ofNullable(traceFilter)) + + /** Alias for calling [Builder.traceFilter] with `traceFilter.orElse(null)`. */ + fun traceFilter(traceFilter: Optional<String>) = traceFilter(traceFilter.getOrNull()) + + /** + * Sets [Builder.traceFilter] to an arbitrary JSON value. + * + * You should usually call [Builder.traceFilter] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun traceFilter(traceFilter: JsonField<String>) = apply { + this.traceFilter = traceFilter + } + + fun transient_(transient_: Boolean) = transient_(JsonField.of(transient_)) + + /** + * Sets [Builder.transient_] to an arbitrary JSON value. + * + * You should usually call [Builder.transient_] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun transient_(transient_: JsonField<Boolean>) = apply { this.transient_ = transient_ } + + fun treeFilter(treeFilter: String?) = treeFilter(JsonField.ofNullable(treeFilter)) + + /** Alias for calling [Builder.treeFilter] with `treeFilter.orElse(null)`. */ + fun treeFilter(treeFilter: Optional<String>) = treeFilter(treeFilter.getOrNull()) + + /** + * Sets [Builder.treeFilter] to an arbitrary JSON value. + * + * You should usually call [Builder.treeFilter] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun treeFilter(treeFilter: JsonField<String>) = apply { this.treeFilter = treeFilter } + + fun useCorrectionsDataset(useCorrectionsDataset: Boolean) = + useCorrectionsDataset(JsonField.of(useCorrectionsDataset)) + + /** + * Sets [Builder.useCorrectionsDataset] to an arbitrary JSON value. + * + * You should usually call [Builder.useCorrectionsDataset] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun useCorrectionsDataset(useCorrectionsDataset: JsonField<Boolean>) = apply { + this.useCorrectionsDataset = useCorrectionsDataset + } + + fun webhooks(webhooks: List<RunRulesWebhookSchema>?) = + webhooks(JsonField.ofNullable(webhooks)) + + /** Alias for calling [Builder.webhooks] with `webhooks.orElse(null)`. */ + fun webhooks(webhooks: Optional<List<RunRulesWebhookSchema>>) = + webhooks(webhooks.getOrNull()) + + /** + * Sets [Builder.webhooks] to an arbitrary JSON value. + * + * You should usually call [Builder.webhooks] with a well-typed + * `List<RunRulesWebhookSchema>` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun webhooks(webhooks: JsonField<List<RunRulesWebhookSchema>>) = apply { + this.webhooks = webhooks.map { it.toMutableList() } + } + + /** + * Adds a single [RunRulesWebhookSchema] to [webhooks]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWebhook(webhook: RunRulesWebhookSchema) = apply { + webhooks = + (webhooks ?: JsonField.of(mutableListOf())).also { + checkKnown("webhooks", it).add(webhook) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .displayName() + * .samplingRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("displayName", displayName), + checkRequired("samplingRate", samplingRate), + addToAnnotationQueueId, + addToDatasetId, + addToDatasetPreferCorrection, + (alerts ?: JsonMissing.of()).map { it.toImmutable() }, + backfillFrom, + (codeEvaluators ?: JsonMissing.of()).map { it.toImmutable() }, + createAlignmentQueue, + datasetId, + evaluatorVersion, + (evaluators ?: JsonMissing.of()).map { it.toImmutable() }, + extendOnly, + filter, + includeExtendedStats, + isEnabled, + numFewShotExamples, + sessionId, + traceFilter, + transient_, + treeFilter, + useCorrectionsDataset, + (webhooks ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + displayName() + samplingRate() + addToAnnotationQueueId() + addToDatasetId() + addToDatasetPreferCorrection() + alerts().ifPresent { it.forEach { it.validate() } } + backfillFrom() + codeEvaluators().ifPresent { it.forEach { it.validate() } } + createAlignmentQueue() + datasetId() + evaluatorVersion() + evaluators().ifPresent { it.forEach { it.validate() } } + extendOnly() + filter() + includeExtendedStats() + isEnabled() + numFewShotExamples() + sessionId() + traceFilter() + transient_() + treeFilter() + useCorrectionsDataset() + webhooks().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (displayName.asKnown().isPresent) 1 else 0) + + (if (samplingRate.asKnown().isPresent) 1 else 0) + + (if (addToAnnotationQueueId.asKnown().isPresent) 1 else 0) + + (if (addToDatasetId.asKnown().isPresent) 1 else 0) + + (if (addToDatasetPreferCorrection.asKnown().isPresent) 1 else 0) + + (alerts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (backfillFrom.asKnown().isPresent) 1 else 0) + + (codeEvaluators.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (createAlignmentQueue.asKnown().isPresent) 1 else 0) + + (if (datasetId.asKnown().isPresent) 1 else 0) + + (if (evaluatorVersion.asKnown().isPresent) 1 else 0) + + (evaluators.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (extendOnly.asKnown().isPresent) 1 else 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (if (includeExtendedStats.asKnown().isPresent) 1 else 0) + + (if (isEnabled.asKnown().isPresent) 1 else 0) + + (if (numFewShotExamples.asKnown().isPresent) 1 else 0) + + (if (sessionId.asKnown().isPresent) 1 else 0) + + (if (traceFilter.asKnown().isPresent) 1 else 0) + + (if (transient_.asKnown().isPresent) 1 else 0) + + (if (treeFilter.asKnown().isPresent) 1 else 0) + + (if (useCorrectionsDataset.asKnown().isPresent) 1 else 0) + + (webhooks.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + displayName == other.displayName && + samplingRate == other.samplingRate && + addToAnnotationQueueId == other.addToAnnotationQueueId && + addToDatasetId == other.addToDatasetId && + addToDatasetPreferCorrection == other.addToDatasetPreferCorrection && + alerts == other.alerts && + backfillFrom == other.backfillFrom && + codeEvaluators == other.codeEvaluators && + createAlignmentQueue == other.createAlignmentQueue && + datasetId == other.datasetId && + evaluatorVersion == other.evaluatorVersion && + evaluators == other.evaluators && + extendOnly == other.extendOnly && + filter == other.filter && + includeExtendedStats == other.includeExtendedStats && + isEnabled == other.isEnabled && + numFewShotExamples == other.numFewShotExamples && + sessionId == other.sessionId && + traceFilter == other.traceFilter && + transient_ == other.transient_ && + treeFilter == other.treeFilter && + useCorrectionsDataset == other.useCorrectionsDataset && + webhooks == other.webhooks && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + displayName, + samplingRate, + addToAnnotationQueueId, + addToDatasetId, + addToDatasetPreferCorrection, + alerts, + backfillFrom, + codeEvaluators, + createAlignmentQueue, + datasetId, + evaluatorVersion, + evaluators, + extendOnly, + filter, + includeExtendedStats, + isEnabled, + numFewShotExamples, + sessionId, + traceFilter, + transient_, + treeFilter, + useCorrectionsDataset, + webhooks, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{displayName=$displayName, samplingRate=$samplingRate, addToAnnotationQueueId=$addToAnnotationQueueId, addToDatasetId=$addToDatasetId, addToDatasetPreferCorrection=$addToDatasetPreferCorrection, alerts=$alerts, backfillFrom=$backfillFrom, codeEvaluators=$codeEvaluators, createAlignmentQueue=$createAlignmentQueue, datasetId=$datasetId, evaluatorVersion=$evaluatorVersion, evaluators=$evaluators, extendOnly=$extendOnly, filter=$filter, includeExtendedStats=$includeExtendedStats, isEnabled=$isEnabled, numFewShotExamples=$numFewShotExamples, sessionId=$sessionId, traceFilter=$traceFilter, transient_=$transient_, treeFilter=$treeFilter, useCorrectionsDataset=$useCorrectionsDataset, webhooks=$webhooks, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RuleUpdateParams && + ruleId == other.ruleId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(ruleId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "RuleUpdateParams{ruleId=$ruleId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RunRulesPagerdutyAlertSchema.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RunRulesPagerdutyAlertSchema.kt new file mode 100644 index 00000000..10811e00 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RunRulesPagerdutyAlertSchema.kt @@ -0,0 +1,551 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.rules + +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.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class RunRulesPagerdutyAlertSchema +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val routingKey: JsonField<String>, + private val severity: JsonField<Severity>, + private val summary: JsonField<String>, + private val type: JsonField<Type>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("routing_key") + @ExcludeMissing + routingKey: JsonField<String> = JsonMissing.of(), + @JsonProperty("severity") @ExcludeMissing severity: JsonField<Severity> = JsonMissing.of(), + @JsonProperty("summary") @ExcludeMissing summary: JsonField<String> = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField<Type> = JsonMissing.of(), + ) : this(routingKey, severity, summary, type, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun routingKey(): String = routingKey.getRequired("routing_key") + + /** + * Enum for severity. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun severity(): Optional<Severity> = severity.getOptional("severity") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun summary(): Optional<String> = summary.getOptional("summary") + + /** + * Enum for alert types. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun type(): Optional<Type> = type.getOptional("type") + + /** + * Returns the raw JSON value of [routingKey]. + * + * Unlike [routingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("routing_key") @ExcludeMissing fun _routingKey(): JsonField<String> = routingKey + + /** + * Returns the raw JSON value of [severity]. + * + * Unlike [severity], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("severity") @ExcludeMissing fun _severity(): JsonField<Severity> = severity + + /** + * Returns the raw JSON value of [summary]. + * + * Unlike [summary], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("summary") @ExcludeMissing fun _summary(): JsonField<String> = summary + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField<Type> = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RunRulesPagerdutyAlertSchema]. + * + * The following fields are required: + * ```java + * .routingKey() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunRulesPagerdutyAlertSchema]. */ + class Builder internal constructor() { + + private var routingKey: JsonField<String>? = null + private var severity: JsonField<Severity> = JsonMissing.of() + private var summary: JsonField<String> = JsonMissing.of() + private var type: JsonField<Type> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(runRulesPagerdutyAlertSchema: RunRulesPagerdutyAlertSchema) = apply { + routingKey = runRulesPagerdutyAlertSchema.routingKey + severity = runRulesPagerdutyAlertSchema.severity + summary = runRulesPagerdutyAlertSchema.summary + type = runRulesPagerdutyAlertSchema.type + additionalProperties = runRulesPagerdutyAlertSchema.additionalProperties.toMutableMap() + } + + fun routingKey(routingKey: String) = routingKey(JsonField.of(routingKey)) + + /** + * Sets [Builder.routingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.routingKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun routingKey(routingKey: JsonField<String>) = apply { this.routingKey = routingKey } + + /** Enum for severity. */ + fun severity(severity: Severity?) = severity(JsonField.ofNullable(severity)) + + /** Alias for calling [Builder.severity] with `severity.orElse(null)`. */ + fun severity(severity: Optional<Severity>) = severity(severity.getOrNull()) + + /** + * Sets [Builder.severity] to an arbitrary JSON value. + * + * You should usually call [Builder.severity] with a well-typed [Severity] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun severity(severity: JsonField<Severity>) = apply { this.severity = severity } + + fun summary(summary: String?) = summary(JsonField.ofNullable(summary)) + + /** Alias for calling [Builder.summary] with `summary.orElse(null)`. */ + fun summary(summary: Optional<String>) = summary(summary.getOrNull()) + + /** + * Sets [Builder.summary] to an arbitrary JSON value. + * + * You should usually call [Builder.summary] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun summary(summary: JsonField<String>) = apply { this.summary = summary } + + /** Enum for alert types. */ + fun type(type: Type?) = type(JsonField.ofNullable(type)) + + /** Alias for calling [Builder.type] with `type.orElse(null)`. */ + fun type(type: Optional<Type>) = type(type.getOrNull()) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField<Type>) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RunRulesPagerdutyAlertSchema]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .routingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RunRulesPagerdutyAlertSchema = + RunRulesPagerdutyAlertSchema( + checkRequired("routingKey", routingKey), + severity, + summary, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RunRulesPagerdutyAlertSchema = apply { + if (validated) { + return@apply + } + + routingKey() + severity().ifPresent { it.validate() } + summary() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (routingKey.asKnown().isPresent) 1 else 0) + + (severity.asKnown().getOrNull()?.validity() ?: 0) + + (if (summary.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + /** Enum for severity. */ + class Severity @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val CRITICAL = of("critical") + + @JvmField val WARNING = of("warning") + + @JvmField val ERROR = of("error") + + @JvmField val INFO = of("info") + + @JvmStatic fun of(value: String) = Severity(JsonField.of(value)) + } + + /** An enum containing [Severity]'s known values. */ + enum class Known { + CRITICAL, + WARNING, + ERROR, + INFO, + } + + /** + * An enum containing [Severity]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Severity] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CRITICAL, + WARNING, + ERROR, + INFO, + /** An enum member indicating that [Severity] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CRITICAL -> Value.CRITICAL + WARNING -> Value.WARNING + ERROR -> Value.ERROR + INFO -> Value.INFO + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CRITICAL -> Known.CRITICAL + WARNING -> Known.WARNING + ERROR -> Known.ERROR + INFO -> Known.INFO + else -> throw LangsmithApiInvalidDataException("Unknown Severity: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Severity = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Severity && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Enum for alert types. */ + class Type @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val PAGERDUTY = of("pagerduty") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + PAGERDUTY + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PAGERDUTY, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PAGERDUTY -> Value.PAGERDUTY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PAGERDUTY -> Known.PAGERDUTY + else -> throw LangsmithApiInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunRulesPagerdutyAlertSchema && + routingKey == other.routingKey && + severity == other.severity && + summary == other.summary && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(routingKey, severity, summary, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RunRulesPagerdutyAlertSchema{routingKey=$routingKey, severity=$severity, summary=$summary, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RunRulesSchema.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RunRulesSchema.kt new file mode 100644 index 00000000..af97ed11 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RunRulesSchema.kt @@ -0,0 +1,1759 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.rules + +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.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Run rules schema. */ +class RunRulesSchema +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val displayName: JsonField<String>, + private val evaluatorVersion: JsonField<Long>, + private val samplingRate: JsonField<Double>, + private val tenantId: JsonField<String>, + private val updatedAt: JsonField<OffsetDateTime>, + private val webhooks: JsonField<List<RunRulesWebhookSchema>>, + private val addToAnnotationQueueId: JsonField<String>, + private val addToAnnotationQueueName: JsonField<String>, + private val addToDatasetId: JsonField<String>, + private val addToDatasetName: JsonField<String>, + private val addToDatasetPreferCorrection: JsonField<Boolean>, + private val alerts: JsonField<List<RunRulesPagerdutyAlertSchema>>, + private val alignmentAnnotationQueueId: JsonField<String>, + private val backfillFrom: JsonField<OffsetDateTime>, + private val codeEvaluators: JsonField<List<CodeEvaluatorTopLevel>>, + private val correctionsDatasetId: JsonField<String>, + private val datasetId: JsonField<String>, + private val datasetName: JsonField<String>, + private val evaluatorId: JsonField<String>, + private val evaluators: JsonField<List<EvaluatorTopLevel>>, + private val extendOnly: JsonField<Boolean>, + private val filter: JsonField<String>, + private val groupBy: JsonField<GroupBy>, + private val includeExtendedStats: JsonField<Boolean>, + private val isEnabled: JsonField<Boolean>, + private val numFewShotExamples: JsonField<Long>, + private val sessionId: JsonField<String>, + private val sessionName: JsonField<String>, + private val traceFilter: JsonField<String>, + private val transient_: JsonField<Boolean>, + private val treeFilter: JsonField<String>, + private val useCorrectionsDataset: JsonField<Boolean>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField<String> = JsonMissing.of(), + @JsonProperty("evaluator_version") + @ExcludeMissing + evaluatorVersion: JsonField<Long> = JsonMissing.of(), + @JsonProperty("sampling_rate") + @ExcludeMissing + samplingRate: JsonField<Double> = JsonMissing.of(), + @JsonProperty("tenant_id") @ExcludeMissing tenantId: JsonField<String> = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("webhooks") + @ExcludeMissing + webhooks: JsonField<List<RunRulesWebhookSchema>> = JsonMissing.of(), + @JsonProperty("add_to_annotation_queue_id") + @ExcludeMissing + addToAnnotationQueueId: JsonField<String> = JsonMissing.of(), + @JsonProperty("add_to_annotation_queue_name") + @ExcludeMissing + addToAnnotationQueueName: JsonField<String> = JsonMissing.of(), + @JsonProperty("add_to_dataset_id") + @ExcludeMissing + addToDatasetId: JsonField<String> = JsonMissing.of(), + @JsonProperty("add_to_dataset_name") + @ExcludeMissing + addToDatasetName: JsonField<String> = JsonMissing.of(), + @JsonProperty("add_to_dataset_prefer_correction") + @ExcludeMissing + addToDatasetPreferCorrection: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("alerts") + @ExcludeMissing + alerts: JsonField<List<RunRulesPagerdutyAlertSchema>> = JsonMissing.of(), + @JsonProperty("alignment_annotation_queue_id") + @ExcludeMissing + alignmentAnnotationQueueId: JsonField<String> = JsonMissing.of(), + @JsonProperty("backfill_from") + @ExcludeMissing + backfillFrom: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("code_evaluators") + @ExcludeMissing + codeEvaluators: JsonField<List<CodeEvaluatorTopLevel>> = JsonMissing.of(), + @JsonProperty("corrections_dataset_id") + @ExcludeMissing + correctionsDatasetId: JsonField<String> = JsonMissing.of(), + @JsonProperty("dataset_id") @ExcludeMissing datasetId: JsonField<String> = JsonMissing.of(), + @JsonProperty("dataset_name") + @ExcludeMissing + datasetName: JsonField<String> = JsonMissing.of(), + @JsonProperty("evaluator_id") + @ExcludeMissing + evaluatorId: JsonField<String> = JsonMissing.of(), + @JsonProperty("evaluators") + @ExcludeMissing + evaluators: JsonField<List<EvaluatorTopLevel>> = JsonMissing.of(), + @JsonProperty("extend_only") + @ExcludeMissing + extendOnly: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("filter") @ExcludeMissing filter: JsonField<String> = JsonMissing.of(), + @JsonProperty("group_by") @ExcludeMissing groupBy: JsonField<GroupBy> = JsonMissing.of(), + @JsonProperty("include_extended_stats") + @ExcludeMissing + includeExtendedStats: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("is_enabled") + @ExcludeMissing + isEnabled: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("num_few_shot_examples") + @ExcludeMissing + numFewShotExamples: JsonField<Long> = JsonMissing.of(), + @JsonProperty("session_id") @ExcludeMissing sessionId: JsonField<String> = JsonMissing.of(), + @JsonProperty("session_name") + @ExcludeMissing + sessionName: JsonField<String> = JsonMissing.of(), + @JsonProperty("trace_filter") + @ExcludeMissing + traceFilter: JsonField<String> = JsonMissing.of(), + @JsonProperty("transient") + @ExcludeMissing + transient_: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("tree_filter") + @ExcludeMissing + treeFilter: JsonField<String> = JsonMissing.of(), + @JsonProperty("use_corrections_dataset") + @ExcludeMissing + useCorrectionsDataset: JsonField<Boolean> = JsonMissing.of(), + ) : this( + id, + createdAt, + displayName, + evaluatorVersion, + samplingRate, + tenantId, + updatedAt, + webhooks, + addToAnnotationQueueId, + addToAnnotationQueueName, + addToDatasetId, + addToDatasetName, + addToDatasetPreferCorrection, + alerts, + alignmentAnnotationQueueId, + backfillFrom, + codeEvaluators, + correctionsDatasetId, + datasetId, + datasetName, + evaluatorId, + evaluators, + extendOnly, + filter, + groupBy, + includeExtendedStats, + isEnabled, + numFewShotExamples, + sessionId, + sessionName, + traceFilter, + transient_, + treeFilter, + useCorrectionsDataset, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun displayName(): String = displayName.getRequired("display_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun evaluatorVersion(): Long = evaluatorVersion.getRequired("evaluator_version") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun samplingRate(): Double = samplingRate.getRequired("sampling_rate") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tenantId(): String = tenantId.getRequired("tenant_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updatedAt(): OffsetDateTime = updatedAt.getRequired("updated_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webhooks(): Optional<List<RunRulesWebhookSchema>> = webhooks.getOptional("webhooks") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun addToAnnotationQueueId(): Optional<String> = + addToAnnotationQueueId.getOptional("add_to_annotation_queue_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun addToAnnotationQueueName(): Optional<String> = + addToAnnotationQueueName.getOptional("add_to_annotation_queue_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun addToDatasetId(): Optional<String> = addToDatasetId.getOptional("add_to_dataset_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun addToDatasetName(): Optional<String> = addToDatasetName.getOptional("add_to_dataset_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun addToDatasetPreferCorrection(): Optional<Boolean> = + addToDatasetPreferCorrection.getOptional("add_to_dataset_prefer_correction") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun alerts(): Optional<List<RunRulesPagerdutyAlertSchema>> = alerts.getOptional("alerts") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun alignmentAnnotationQueueId(): Optional<String> = + alignmentAnnotationQueueId.getOptional("alignment_annotation_queue_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun backfillFrom(): Optional<OffsetDateTime> = backfillFrom.getOptional("backfill_from") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun codeEvaluators(): Optional<List<CodeEvaluatorTopLevel>> = + codeEvaluators.getOptional("code_evaluators") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun correctionsDatasetId(): Optional<String> = + correctionsDatasetId.getOptional("corrections_dataset_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun datasetId(): Optional<String> = datasetId.getOptional("dataset_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun datasetName(): Optional<String> = datasetName.getOptional("dataset_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun evaluatorId(): Optional<String> = evaluatorId.getOptional("evaluator_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun evaluators(): Optional<List<EvaluatorTopLevel>> = evaluators.getOptional("evaluators") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun extendOnly(): Optional<Boolean> = extendOnly.getOptional("extend_only") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun filter(): Optional<String> = filter.getOptional("filter") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun groupBy(): Optional<GroupBy> = groupBy.getOptional("group_by") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun includeExtendedStats(): Optional<Boolean> = + includeExtendedStats.getOptional("include_extended_stats") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun isEnabled(): Optional<Boolean> = isEnabled.getOptional("is_enabled") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun numFewShotExamples(): Optional<Long> = + numFewShotExamples.getOptional("num_few_shot_examples") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun sessionId(): Optional<String> = sessionId.getOptional("session_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun sessionName(): Optional<String> = sessionName.getOptional("session_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun traceFilter(): Optional<String> = traceFilter.getOptional("trace_filter") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun transient_(): Optional<Boolean> = transient_.getOptional("transient") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun treeFilter(): Optional<String> = treeFilter.getOptional("tree_filter") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun useCorrectionsDataset(): Optional<Boolean> = + useCorrectionsDataset.getOptional("use_corrections_dataset") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField<String> = displayName + + /** + * Returns the raw JSON value of [evaluatorVersion]. + * + * Unlike [evaluatorVersion], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("evaluator_version") + @ExcludeMissing + fun _evaluatorVersion(): JsonField<Long> = evaluatorVersion + + /** + * Returns the raw JSON value of [samplingRate]. + * + * Unlike [samplingRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sampling_rate") + @ExcludeMissing + fun _samplingRate(): JsonField<Double> = samplingRate + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_id") @ExcludeMissing fun _tenantId(): JsonField<String> = tenantId + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField<OffsetDateTime> = updatedAt + + /** + * Returns the raw JSON value of [webhooks]. + * + * Unlike [webhooks], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("webhooks") + @ExcludeMissing + fun _webhooks(): JsonField<List<RunRulesWebhookSchema>> = webhooks + + /** + * Returns the raw JSON value of [addToAnnotationQueueId]. + * + * Unlike [addToAnnotationQueueId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("add_to_annotation_queue_id") + @ExcludeMissing + fun _addToAnnotationQueueId(): JsonField<String> = addToAnnotationQueueId + + /** + * Returns the raw JSON value of [addToAnnotationQueueName]. + * + * Unlike [addToAnnotationQueueName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("add_to_annotation_queue_name") + @ExcludeMissing + fun _addToAnnotationQueueName(): JsonField<String> = addToAnnotationQueueName + + /** + * Returns the raw JSON value of [addToDatasetId]. + * + * Unlike [addToDatasetId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("add_to_dataset_id") + @ExcludeMissing + fun _addToDatasetId(): JsonField<String> = addToDatasetId + + /** + * Returns the raw JSON value of [addToDatasetName]. + * + * Unlike [addToDatasetName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("add_to_dataset_name") + @ExcludeMissing + fun _addToDatasetName(): JsonField<String> = addToDatasetName + + /** + * Returns the raw JSON value of [addToDatasetPreferCorrection]. + * + * Unlike [addToDatasetPreferCorrection], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("add_to_dataset_prefer_correction") + @ExcludeMissing + fun _addToDatasetPreferCorrection(): JsonField<Boolean> = addToDatasetPreferCorrection + + /** + * Returns the raw JSON value of [alerts]. + * + * Unlike [alerts], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("alerts") + @ExcludeMissing + fun _alerts(): JsonField<List<RunRulesPagerdutyAlertSchema>> = alerts + + /** + * Returns the raw JSON value of [alignmentAnnotationQueueId]. + * + * Unlike [alignmentAnnotationQueueId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("alignment_annotation_queue_id") + @ExcludeMissing + fun _alignmentAnnotationQueueId(): JsonField<String> = alignmentAnnotationQueueId + + /** + * Returns the raw JSON value of [backfillFrom]. + * + * Unlike [backfillFrom], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("backfill_from") + @ExcludeMissing + fun _backfillFrom(): JsonField<OffsetDateTime> = backfillFrom + + /** + * Returns the raw JSON value of [codeEvaluators]. + * + * Unlike [codeEvaluators], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code_evaluators") + @ExcludeMissing + fun _codeEvaluators(): JsonField<List<CodeEvaluatorTopLevel>> = codeEvaluators + + /** + * Returns the raw JSON value of [correctionsDatasetId]. + * + * Unlike [correctionsDatasetId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("corrections_dataset_id") + @ExcludeMissing + fun _correctionsDatasetId(): JsonField<String> = correctionsDatasetId + + /** + * Returns the raw JSON value of [datasetId]. + * + * Unlike [datasetId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField<String> = datasetId + + /** + * Returns the raw JSON value of [datasetName]. + * + * Unlike [datasetName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dataset_name") + @ExcludeMissing + fun _datasetName(): JsonField<String> = datasetName + + /** + * Returns the raw JSON value of [evaluatorId]. + * + * Unlike [evaluatorId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("evaluator_id") + @ExcludeMissing + fun _evaluatorId(): JsonField<String> = evaluatorId + + /** + * Returns the raw JSON value of [evaluators]. + * + * Unlike [evaluators], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("evaluators") + @ExcludeMissing + fun _evaluators(): JsonField<List<EvaluatorTopLevel>> = evaluators + + /** + * Returns the raw JSON value of [extendOnly]. + * + * Unlike [extendOnly], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("extend_only") @ExcludeMissing fun _extendOnly(): JsonField<Boolean> = extendOnly + + /** + * Returns the raw JSON value of [filter]. + * + * Unlike [filter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField<String> = filter + + /** + * Returns the raw JSON value of [groupBy]. + * + * Unlike [groupBy], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("group_by") @ExcludeMissing fun _groupBy(): JsonField<GroupBy> = groupBy + + /** + * Returns the raw JSON value of [includeExtendedStats]. + * + * Unlike [includeExtendedStats], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("include_extended_stats") + @ExcludeMissing + fun _includeExtendedStats(): JsonField<Boolean> = includeExtendedStats + + /** + * Returns the raw JSON value of [isEnabled]. + * + * Unlike [isEnabled], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_enabled") @ExcludeMissing fun _isEnabled(): JsonField<Boolean> = isEnabled + + /** + * Returns the raw JSON value of [numFewShotExamples]. + * + * Unlike [numFewShotExamples], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("num_few_shot_examples") + @ExcludeMissing + fun _numFewShotExamples(): JsonField<Long> = numFewShotExamples + + /** + * Returns the raw JSON value of [sessionId]. + * + * Unlike [sessionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session_id") @ExcludeMissing fun _sessionId(): JsonField<String> = sessionId + + /** + * Returns the raw JSON value of [sessionName]. + * + * Unlike [sessionName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session_name") + @ExcludeMissing + fun _sessionName(): JsonField<String> = sessionName + + /** + * Returns the raw JSON value of [traceFilter]. + * + * Unlike [traceFilter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trace_filter") + @ExcludeMissing + fun _traceFilter(): JsonField<String> = traceFilter + + /** + * Returns the raw JSON value of [transient_]. + * + * Unlike [transient_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("transient") @ExcludeMissing fun _transient_(): JsonField<Boolean> = transient_ + + /** + * Returns the raw JSON value of [treeFilter]. + * + * Unlike [treeFilter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tree_filter") @ExcludeMissing fun _treeFilter(): JsonField<String> = treeFilter + + /** + * Returns the raw JSON value of [useCorrectionsDataset]. + * + * Unlike [useCorrectionsDataset], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("use_corrections_dataset") + @ExcludeMissing + fun _useCorrectionsDataset(): JsonField<Boolean> = useCorrectionsDataset + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RunRulesSchema]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .displayName() + * .evaluatorVersion() + * .samplingRate() + * .tenantId() + * .updatedAt() + * .webhooks() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunRulesSchema]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var createdAt: JsonField<OffsetDateTime>? = null + private var displayName: JsonField<String>? = null + private var evaluatorVersion: JsonField<Long>? = null + private var samplingRate: JsonField<Double>? = null + private var tenantId: JsonField<String>? = null + private var updatedAt: JsonField<OffsetDateTime>? = null + private var webhooks: JsonField<MutableList<RunRulesWebhookSchema>>? = null + private var addToAnnotationQueueId: JsonField<String> = JsonMissing.of() + private var addToAnnotationQueueName: JsonField<String> = JsonMissing.of() + private var addToDatasetId: JsonField<String> = JsonMissing.of() + private var addToDatasetName: JsonField<String> = JsonMissing.of() + private var addToDatasetPreferCorrection: JsonField<Boolean> = JsonMissing.of() + private var alerts: JsonField<MutableList<RunRulesPagerdutyAlertSchema>>? = null + private var alignmentAnnotationQueueId: JsonField<String> = JsonMissing.of() + private var backfillFrom: JsonField<OffsetDateTime> = JsonMissing.of() + private var codeEvaluators: JsonField<MutableList<CodeEvaluatorTopLevel>>? = null + private var correctionsDatasetId: JsonField<String> = JsonMissing.of() + private var datasetId: JsonField<String> = JsonMissing.of() + private var datasetName: JsonField<String> = JsonMissing.of() + private var evaluatorId: JsonField<String> = JsonMissing.of() + private var evaluators: JsonField<MutableList<EvaluatorTopLevel>>? = null + private var extendOnly: JsonField<Boolean> = JsonMissing.of() + private var filter: JsonField<String> = JsonMissing.of() + private var groupBy: JsonField<GroupBy> = JsonMissing.of() + private var includeExtendedStats: JsonField<Boolean> = JsonMissing.of() + private var isEnabled: JsonField<Boolean> = JsonMissing.of() + private var numFewShotExamples: JsonField<Long> = JsonMissing.of() + private var sessionId: JsonField<String> = JsonMissing.of() + private var sessionName: JsonField<String> = JsonMissing.of() + private var traceFilter: JsonField<String> = JsonMissing.of() + private var transient_: JsonField<Boolean> = JsonMissing.of() + private var treeFilter: JsonField<String> = JsonMissing.of() + private var useCorrectionsDataset: JsonField<Boolean> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(runRulesSchema: RunRulesSchema) = apply { + id = runRulesSchema.id + createdAt = runRulesSchema.createdAt + displayName = runRulesSchema.displayName + evaluatorVersion = runRulesSchema.evaluatorVersion + samplingRate = runRulesSchema.samplingRate + tenantId = runRulesSchema.tenantId + updatedAt = runRulesSchema.updatedAt + webhooks = runRulesSchema.webhooks.map { it.toMutableList() } + addToAnnotationQueueId = runRulesSchema.addToAnnotationQueueId + addToAnnotationQueueName = runRulesSchema.addToAnnotationQueueName + addToDatasetId = runRulesSchema.addToDatasetId + addToDatasetName = runRulesSchema.addToDatasetName + addToDatasetPreferCorrection = runRulesSchema.addToDatasetPreferCorrection + alerts = runRulesSchema.alerts.map { it.toMutableList() } + alignmentAnnotationQueueId = runRulesSchema.alignmentAnnotationQueueId + backfillFrom = runRulesSchema.backfillFrom + codeEvaluators = runRulesSchema.codeEvaluators.map { it.toMutableList() } + correctionsDatasetId = runRulesSchema.correctionsDatasetId + datasetId = runRulesSchema.datasetId + datasetName = runRulesSchema.datasetName + evaluatorId = runRulesSchema.evaluatorId + evaluators = runRulesSchema.evaluators.map { it.toMutableList() } + extendOnly = runRulesSchema.extendOnly + filter = runRulesSchema.filter + groupBy = runRulesSchema.groupBy + includeExtendedStats = runRulesSchema.includeExtendedStats + isEnabled = runRulesSchema.isEnabled + numFewShotExamples = runRulesSchema.numFewShotExamples + sessionId = runRulesSchema.sessionId + sessionName = runRulesSchema.sessionName + traceFilter = runRulesSchema.traceFilter + transient_ = runRulesSchema.transient_ + treeFilter = runRulesSchema.treeFilter + useCorrectionsDataset = runRulesSchema.useCorrectionsDataset + additionalProperties = runRulesSchema.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun displayName(displayName: String) = displayName(JsonField.of(displayName)) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun displayName(displayName: JsonField<String>) = apply { this.displayName = displayName } + + fun evaluatorVersion(evaluatorVersion: Long) = + evaluatorVersion(JsonField.of(evaluatorVersion)) + + /** + * Sets [Builder.evaluatorVersion] to an arbitrary JSON value. + * + * You should usually call [Builder.evaluatorVersion] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun evaluatorVersion(evaluatorVersion: JsonField<Long>) = apply { + this.evaluatorVersion = evaluatorVersion + } + + fun samplingRate(samplingRate: Double) = samplingRate(JsonField.of(samplingRate)) + + /** + * Sets [Builder.samplingRate] to an arbitrary JSON value. + * + * You should usually call [Builder.samplingRate] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun samplingRate(samplingRate: JsonField<Double>) = apply { + this.samplingRate = samplingRate + } + + fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tenantId(tenantId: JsonField<String>) = apply { this.tenantId = tenantId } + + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField<OffsetDateTime>) = apply { this.updatedAt = updatedAt } + + fun webhooks(webhooks: List<RunRulesWebhookSchema>?) = + webhooks(JsonField.ofNullable(webhooks)) + + /** Alias for calling [Builder.webhooks] with `webhooks.orElse(null)`. */ + fun webhooks(webhooks: Optional<List<RunRulesWebhookSchema>>) = + webhooks(webhooks.getOrNull()) + + /** + * Sets [Builder.webhooks] to an arbitrary JSON value. + * + * You should usually call [Builder.webhooks] with a well-typed + * `List<RunRulesWebhookSchema>` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun webhooks(webhooks: JsonField<List<RunRulesWebhookSchema>>) = apply { + this.webhooks = webhooks.map { it.toMutableList() } + } + + /** + * Adds a single [RunRulesWebhookSchema] to [webhooks]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWebhook(webhook: RunRulesWebhookSchema) = apply { + webhooks = + (webhooks ?: JsonField.of(mutableListOf())).also { + checkKnown("webhooks", it).add(webhook) + } + } + + fun addToAnnotationQueueId(addToAnnotationQueueId: String?) = + addToAnnotationQueueId(JsonField.ofNullable(addToAnnotationQueueId)) + + /** + * Alias for calling [Builder.addToAnnotationQueueId] with + * `addToAnnotationQueueId.orElse(null)`. + */ + fun addToAnnotationQueueId(addToAnnotationQueueId: Optional<String>) = + addToAnnotationQueueId(addToAnnotationQueueId.getOrNull()) + + /** + * Sets [Builder.addToAnnotationQueueId] to an arbitrary JSON value. + * + * You should usually call [Builder.addToAnnotationQueueId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun addToAnnotationQueueId(addToAnnotationQueueId: JsonField<String>) = apply { + this.addToAnnotationQueueId = addToAnnotationQueueId + } + + fun addToAnnotationQueueName(addToAnnotationQueueName: String?) = + addToAnnotationQueueName(JsonField.ofNullable(addToAnnotationQueueName)) + + /** + * Alias for calling [Builder.addToAnnotationQueueName] with + * `addToAnnotationQueueName.orElse(null)`. + */ + fun addToAnnotationQueueName(addToAnnotationQueueName: Optional<String>) = + addToAnnotationQueueName(addToAnnotationQueueName.getOrNull()) + + /** + * Sets [Builder.addToAnnotationQueueName] to an arbitrary JSON value. + * + * You should usually call [Builder.addToAnnotationQueueName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun addToAnnotationQueueName(addToAnnotationQueueName: JsonField<String>) = apply { + this.addToAnnotationQueueName = addToAnnotationQueueName + } + + fun addToDatasetId(addToDatasetId: String?) = + addToDatasetId(JsonField.ofNullable(addToDatasetId)) + + /** Alias for calling [Builder.addToDatasetId] with `addToDatasetId.orElse(null)`. */ + fun addToDatasetId(addToDatasetId: Optional<String>) = + addToDatasetId(addToDatasetId.getOrNull()) + + /** + * Sets [Builder.addToDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.addToDatasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun addToDatasetId(addToDatasetId: JsonField<String>) = apply { + this.addToDatasetId = addToDatasetId + } + + fun addToDatasetName(addToDatasetName: String?) = + addToDatasetName(JsonField.ofNullable(addToDatasetName)) + + /** Alias for calling [Builder.addToDatasetName] with `addToDatasetName.orElse(null)`. */ + fun addToDatasetName(addToDatasetName: Optional<String>) = + addToDatasetName(addToDatasetName.getOrNull()) + + /** + * Sets [Builder.addToDatasetName] to an arbitrary JSON value. + * + * You should usually call [Builder.addToDatasetName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun addToDatasetName(addToDatasetName: JsonField<String>) = apply { + this.addToDatasetName = addToDatasetName + } + + fun addToDatasetPreferCorrection(addToDatasetPreferCorrection: Boolean) = + addToDatasetPreferCorrection(JsonField.of(addToDatasetPreferCorrection)) + + /** + * Sets [Builder.addToDatasetPreferCorrection] to an arbitrary JSON value. + * + * You should usually call [Builder.addToDatasetPreferCorrection] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun addToDatasetPreferCorrection(addToDatasetPreferCorrection: JsonField<Boolean>) = apply { + this.addToDatasetPreferCorrection = addToDatasetPreferCorrection + } + + fun alerts(alerts: List<RunRulesPagerdutyAlertSchema>?) = + alerts(JsonField.ofNullable(alerts)) + + /** Alias for calling [Builder.alerts] with `alerts.orElse(null)`. */ + fun alerts(alerts: Optional<List<RunRulesPagerdutyAlertSchema>>) = + alerts(alerts.getOrNull()) + + /** + * Sets [Builder.alerts] to an arbitrary JSON value. + * + * You should usually call [Builder.alerts] with a well-typed + * `List<RunRulesPagerdutyAlertSchema>` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun alerts(alerts: JsonField<List<RunRulesPagerdutyAlertSchema>>) = apply { + this.alerts = alerts.map { it.toMutableList() } + } + + /** + * Adds a single [RunRulesPagerdutyAlertSchema] to [alerts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAlert(alert: RunRulesPagerdutyAlertSchema) = apply { + alerts = + (alerts ?: JsonField.of(mutableListOf())).also { + checkKnown("alerts", it).add(alert) + } + } + + fun alignmentAnnotationQueueId(alignmentAnnotationQueueId: String?) = + alignmentAnnotationQueueId(JsonField.ofNullable(alignmentAnnotationQueueId)) + + /** + * Alias for calling [Builder.alignmentAnnotationQueueId] with + * `alignmentAnnotationQueueId.orElse(null)`. + */ + fun alignmentAnnotationQueueId(alignmentAnnotationQueueId: Optional<String>) = + alignmentAnnotationQueueId(alignmentAnnotationQueueId.getOrNull()) + + /** + * Sets [Builder.alignmentAnnotationQueueId] to an arbitrary JSON value. + * + * You should usually call [Builder.alignmentAnnotationQueueId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun alignmentAnnotationQueueId(alignmentAnnotationQueueId: JsonField<String>) = apply { + this.alignmentAnnotationQueueId = alignmentAnnotationQueueId + } + + fun backfillFrom(backfillFrom: OffsetDateTime?) = + backfillFrom(JsonField.ofNullable(backfillFrom)) + + /** Alias for calling [Builder.backfillFrom] with `backfillFrom.orElse(null)`. */ + fun backfillFrom(backfillFrom: Optional<OffsetDateTime>) = + backfillFrom(backfillFrom.getOrNull()) + + /** + * Sets [Builder.backfillFrom] to an arbitrary JSON value. + * + * You should usually call [Builder.backfillFrom] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun backfillFrom(backfillFrom: JsonField<OffsetDateTime>) = apply { + this.backfillFrom = backfillFrom + } + + fun codeEvaluators(codeEvaluators: List<CodeEvaluatorTopLevel>?) = + codeEvaluators(JsonField.ofNullable(codeEvaluators)) + + /** Alias for calling [Builder.codeEvaluators] with `codeEvaluators.orElse(null)`. */ + fun codeEvaluators(codeEvaluators: Optional<List<CodeEvaluatorTopLevel>>) = + codeEvaluators(codeEvaluators.getOrNull()) + + /** + * Sets [Builder.codeEvaluators] to an arbitrary JSON value. + * + * You should usually call [Builder.codeEvaluators] with a well-typed + * `List<CodeEvaluatorTopLevel>` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun codeEvaluators(codeEvaluators: JsonField<List<CodeEvaluatorTopLevel>>) = apply { + this.codeEvaluators = codeEvaluators.map { it.toMutableList() } + } + + /** + * Adds a single [CodeEvaluatorTopLevel] to [codeEvaluators]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCodeEvaluator(codeEvaluator: CodeEvaluatorTopLevel) = apply { + codeEvaluators = + (codeEvaluators ?: JsonField.of(mutableListOf())).also { + checkKnown("codeEvaluators", it).add(codeEvaluator) + } + } + + fun correctionsDatasetId(correctionsDatasetId: String?) = + correctionsDatasetId(JsonField.ofNullable(correctionsDatasetId)) + + /** + * Alias for calling [Builder.correctionsDatasetId] with + * `correctionsDatasetId.orElse(null)`. + */ + fun correctionsDatasetId(correctionsDatasetId: Optional<String>) = + correctionsDatasetId(correctionsDatasetId.getOrNull()) + + /** + * Sets [Builder.correctionsDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.correctionsDatasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun correctionsDatasetId(correctionsDatasetId: JsonField<String>) = apply { + this.correctionsDatasetId = correctionsDatasetId + } + + fun datasetId(datasetId: String?) = datasetId(JsonField.ofNullable(datasetId)) + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + /** + * Sets [Builder.datasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun datasetId(datasetId: JsonField<String>) = apply { this.datasetId = datasetId } + + fun datasetName(datasetName: String?) = datasetName(JsonField.ofNullable(datasetName)) + + /** Alias for calling [Builder.datasetName] with `datasetName.orElse(null)`. */ + fun datasetName(datasetName: Optional<String>) = datasetName(datasetName.getOrNull()) + + /** + * Sets [Builder.datasetName] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun datasetName(datasetName: JsonField<String>) = apply { this.datasetName = datasetName } + + fun evaluatorId(evaluatorId: String?) = evaluatorId(JsonField.ofNullable(evaluatorId)) + + /** Alias for calling [Builder.evaluatorId] with `evaluatorId.orElse(null)`. */ + fun evaluatorId(evaluatorId: Optional<String>) = evaluatorId(evaluatorId.getOrNull()) + + /** + * Sets [Builder.evaluatorId] to an arbitrary JSON value. + * + * You should usually call [Builder.evaluatorId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun evaluatorId(evaluatorId: JsonField<String>) = apply { this.evaluatorId = evaluatorId } + + fun evaluators(evaluators: List<EvaluatorTopLevel>?) = + evaluators(JsonField.ofNullable(evaluators)) + + /** Alias for calling [Builder.evaluators] with `evaluators.orElse(null)`. */ + fun evaluators(evaluators: Optional<List<EvaluatorTopLevel>>) = + evaluators(evaluators.getOrNull()) + + /** + * Sets [Builder.evaluators] to an arbitrary JSON value. + * + * You should usually call [Builder.evaluators] with a well-typed `List<EvaluatorTopLevel>` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun evaluators(evaluators: JsonField<List<EvaluatorTopLevel>>) = apply { + this.evaluators = evaluators.map { it.toMutableList() } + } + + /** + * Adds a single [EvaluatorTopLevel] to [evaluators]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvaluator(evaluator: EvaluatorTopLevel) = apply { + evaluators = + (evaluators ?: JsonField.of(mutableListOf())).also { + checkKnown("evaluators", it).add(evaluator) + } + } + + fun extendOnly(extendOnly: Boolean) = extendOnly(JsonField.of(extendOnly)) + + /** + * Sets [Builder.extendOnly] to an arbitrary JSON value. + * + * You should usually call [Builder.extendOnly] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun extendOnly(extendOnly: JsonField<Boolean>) = apply { this.extendOnly = extendOnly } + + fun filter(filter: String?) = filter(JsonField.ofNullable(filter)) + + /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ + fun filter(filter: Optional<String>) = filter(filter.getOrNull()) + + /** + * Sets [Builder.filter] to an arbitrary JSON value. + * + * You should usually call [Builder.filter] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun filter(filter: JsonField<String>) = apply { this.filter = filter } + + fun groupBy(groupBy: GroupBy?) = groupBy(JsonField.ofNullable(groupBy)) + + /** Alias for calling [Builder.groupBy] with `groupBy.orElse(null)`. */ + fun groupBy(groupBy: Optional<GroupBy>) = groupBy(groupBy.getOrNull()) + + /** + * Sets [Builder.groupBy] to an arbitrary JSON value. + * + * You should usually call [Builder.groupBy] with a well-typed [GroupBy] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun groupBy(groupBy: JsonField<GroupBy>) = apply { this.groupBy = groupBy } + + fun includeExtendedStats(includeExtendedStats: Boolean) = + includeExtendedStats(JsonField.of(includeExtendedStats)) + + /** + * Sets [Builder.includeExtendedStats] to an arbitrary JSON value. + * + * You should usually call [Builder.includeExtendedStats] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun includeExtendedStats(includeExtendedStats: JsonField<Boolean>) = apply { + this.includeExtendedStats = includeExtendedStats + } + + fun isEnabled(isEnabled: Boolean) = isEnabled(JsonField.of(isEnabled)) + + /** + * Sets [Builder.isEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.isEnabled] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isEnabled(isEnabled: JsonField<Boolean>) = apply { this.isEnabled = isEnabled } + + fun numFewShotExamples(numFewShotExamples: Long?) = + numFewShotExamples(JsonField.ofNullable(numFewShotExamples)) + + /** + * Alias for [Builder.numFewShotExamples]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun numFewShotExamples(numFewShotExamples: Long) = + numFewShotExamples(numFewShotExamples as Long?) + + /** + * Alias for calling [Builder.numFewShotExamples] with `numFewShotExamples.orElse(null)`. + */ + fun numFewShotExamples(numFewShotExamples: Optional<Long>) = + numFewShotExamples(numFewShotExamples.getOrNull()) + + /** + * Sets [Builder.numFewShotExamples] to an arbitrary JSON value. + * + * You should usually call [Builder.numFewShotExamples] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun numFewShotExamples(numFewShotExamples: JsonField<Long>) = apply { + this.numFewShotExamples = numFewShotExamples + } + + fun sessionId(sessionId: String?) = sessionId(JsonField.ofNullable(sessionId)) + + /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ + fun sessionId(sessionId: Optional<String>) = sessionId(sessionId.getOrNull()) + + /** + * Sets [Builder.sessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun sessionId(sessionId: JsonField<String>) = apply { this.sessionId = sessionId } + + fun sessionName(sessionName: String?) = sessionName(JsonField.ofNullable(sessionName)) + + /** Alias for calling [Builder.sessionName] with `sessionName.orElse(null)`. */ + fun sessionName(sessionName: Optional<String>) = sessionName(sessionName.getOrNull()) + + /** + * Sets [Builder.sessionName] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun sessionName(sessionName: JsonField<String>) = apply { this.sessionName = sessionName } + + fun traceFilter(traceFilter: String?) = traceFilter(JsonField.ofNullable(traceFilter)) + + /** Alias for calling [Builder.traceFilter] with `traceFilter.orElse(null)`. */ + fun traceFilter(traceFilter: Optional<String>) = traceFilter(traceFilter.getOrNull()) + + /** + * Sets [Builder.traceFilter] to an arbitrary JSON value. + * + * You should usually call [Builder.traceFilter] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun traceFilter(traceFilter: JsonField<String>) = apply { this.traceFilter = traceFilter } + + fun transient_(transient_: Boolean) = transient_(JsonField.of(transient_)) + + /** + * Sets [Builder.transient_] to an arbitrary JSON value. + * + * You should usually call [Builder.transient_] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun transient_(transient_: JsonField<Boolean>) = apply { this.transient_ = transient_ } + + fun treeFilter(treeFilter: String?) = treeFilter(JsonField.ofNullable(treeFilter)) + + /** Alias for calling [Builder.treeFilter] with `treeFilter.orElse(null)`. */ + fun treeFilter(treeFilter: Optional<String>) = treeFilter(treeFilter.getOrNull()) + + /** + * Sets [Builder.treeFilter] to an arbitrary JSON value. + * + * You should usually call [Builder.treeFilter] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun treeFilter(treeFilter: JsonField<String>) = apply { this.treeFilter = treeFilter } + + fun useCorrectionsDataset(useCorrectionsDataset: Boolean) = + useCorrectionsDataset(JsonField.of(useCorrectionsDataset)) + + /** + * Sets [Builder.useCorrectionsDataset] to an arbitrary JSON value. + * + * You should usually call [Builder.useCorrectionsDataset] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun useCorrectionsDataset(useCorrectionsDataset: JsonField<Boolean>) = apply { + this.useCorrectionsDataset = useCorrectionsDataset + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RunRulesSchema]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .displayName() + * .evaluatorVersion() + * .samplingRate() + * .tenantId() + * .updatedAt() + * .webhooks() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RunRulesSchema = + RunRulesSchema( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("displayName", displayName), + checkRequired("evaluatorVersion", evaluatorVersion), + checkRequired("samplingRate", samplingRate), + checkRequired("tenantId", tenantId), + checkRequired("updatedAt", updatedAt), + checkRequired("webhooks", webhooks).map { it.toImmutable() }, + addToAnnotationQueueId, + addToAnnotationQueueName, + addToDatasetId, + addToDatasetName, + addToDatasetPreferCorrection, + (alerts ?: JsonMissing.of()).map { it.toImmutable() }, + alignmentAnnotationQueueId, + backfillFrom, + (codeEvaluators ?: JsonMissing.of()).map { it.toImmutable() }, + correctionsDatasetId, + datasetId, + datasetName, + evaluatorId, + (evaluators ?: JsonMissing.of()).map { it.toImmutable() }, + extendOnly, + filter, + groupBy, + includeExtendedStats, + isEnabled, + numFewShotExamples, + sessionId, + sessionName, + traceFilter, + transient_, + treeFilter, + useCorrectionsDataset, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RunRulesSchema = apply { + if (validated) { + return@apply + } + + id() + createdAt() + displayName() + evaluatorVersion() + samplingRate() + tenantId() + updatedAt() + webhooks().ifPresent { it.forEach { it.validate() } } + addToAnnotationQueueId() + addToAnnotationQueueName() + addToDatasetId() + addToDatasetName() + addToDatasetPreferCorrection() + alerts().ifPresent { it.forEach { it.validate() } } + alignmentAnnotationQueueId() + backfillFrom() + codeEvaluators().ifPresent { it.forEach { it.validate() } } + correctionsDatasetId() + datasetId() + datasetName() + evaluatorId() + evaluators().ifPresent { it.forEach { it.validate() } } + extendOnly() + filter() + groupBy().ifPresent { it.validate() } + includeExtendedStats() + isEnabled() + numFewShotExamples() + sessionId() + sessionName() + traceFilter() + transient_() + treeFilter() + useCorrectionsDataset() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (displayName.asKnown().isPresent) 1 else 0) + + (if (evaluatorVersion.asKnown().isPresent) 1 else 0) + + (if (samplingRate.asKnown().isPresent) 1 else 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (webhooks.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (addToAnnotationQueueId.asKnown().isPresent) 1 else 0) + + (if (addToAnnotationQueueName.asKnown().isPresent) 1 else 0) + + (if (addToDatasetId.asKnown().isPresent) 1 else 0) + + (if (addToDatasetName.asKnown().isPresent) 1 else 0) + + (if (addToDatasetPreferCorrection.asKnown().isPresent) 1 else 0) + + (alerts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (alignmentAnnotationQueueId.asKnown().isPresent) 1 else 0) + + (if (backfillFrom.asKnown().isPresent) 1 else 0) + + (codeEvaluators.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (correctionsDatasetId.asKnown().isPresent) 1 else 0) + + (if (datasetId.asKnown().isPresent) 1 else 0) + + (if (datasetName.asKnown().isPresent) 1 else 0) + + (if (evaluatorId.asKnown().isPresent) 1 else 0) + + (evaluators.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (extendOnly.asKnown().isPresent) 1 else 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (groupBy.asKnown().getOrNull()?.validity() ?: 0) + + (if (includeExtendedStats.asKnown().isPresent) 1 else 0) + + (if (isEnabled.asKnown().isPresent) 1 else 0) + + (if (numFewShotExamples.asKnown().isPresent) 1 else 0) + + (if (sessionId.asKnown().isPresent) 1 else 0) + + (if (sessionName.asKnown().isPresent) 1 else 0) + + (if (traceFilter.asKnown().isPresent) 1 else 0) + + (if (transient_.asKnown().isPresent) 1 else 0) + + (if (treeFilter.asKnown().isPresent) 1 else 0) + + (if (useCorrectionsDataset.asKnown().isPresent) 1 else 0) + + class GroupBy @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val THREAD_ID = of("thread_id") + + @JvmStatic fun of(value: String) = GroupBy(JsonField.of(value)) + } + + /** An enum containing [GroupBy]'s known values. */ + enum class Known { + THREAD_ID + } + + /** + * An enum containing [GroupBy]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [GroupBy] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + THREAD_ID, + /** An enum member indicating that [GroupBy] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + THREAD_ID -> Value.THREAD_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + THREAD_ID -> Known.THREAD_ID + else -> throw LangsmithApiInvalidDataException("Unknown GroupBy: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): GroupBy = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupBy && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunRulesSchema && + id == other.id && + createdAt == other.createdAt && + displayName == other.displayName && + evaluatorVersion == other.evaluatorVersion && + samplingRate == other.samplingRate && + tenantId == other.tenantId && + updatedAt == other.updatedAt && + webhooks == other.webhooks && + addToAnnotationQueueId == other.addToAnnotationQueueId && + addToAnnotationQueueName == other.addToAnnotationQueueName && + addToDatasetId == other.addToDatasetId && + addToDatasetName == other.addToDatasetName && + addToDatasetPreferCorrection == other.addToDatasetPreferCorrection && + alerts == other.alerts && + alignmentAnnotationQueueId == other.alignmentAnnotationQueueId && + backfillFrom == other.backfillFrom && + codeEvaluators == other.codeEvaluators && + correctionsDatasetId == other.correctionsDatasetId && + datasetId == other.datasetId && + datasetName == other.datasetName && + evaluatorId == other.evaluatorId && + evaluators == other.evaluators && + extendOnly == other.extendOnly && + filter == other.filter && + groupBy == other.groupBy && + includeExtendedStats == other.includeExtendedStats && + isEnabled == other.isEnabled && + numFewShotExamples == other.numFewShotExamples && + sessionId == other.sessionId && + sessionName == other.sessionName && + traceFilter == other.traceFilter && + transient_ == other.transient_ && + treeFilter == other.treeFilter && + useCorrectionsDataset == other.useCorrectionsDataset && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + createdAt, + displayName, + evaluatorVersion, + samplingRate, + tenantId, + updatedAt, + webhooks, + addToAnnotationQueueId, + addToAnnotationQueueName, + addToDatasetId, + addToDatasetName, + addToDatasetPreferCorrection, + alerts, + alignmentAnnotationQueueId, + backfillFrom, + codeEvaluators, + correctionsDatasetId, + datasetId, + datasetName, + evaluatorId, + evaluators, + extendOnly, + filter, + groupBy, + includeExtendedStats, + isEnabled, + numFewShotExamples, + sessionId, + sessionName, + traceFilter, + transient_, + treeFilter, + useCorrectionsDataset, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RunRulesSchema{id=$id, createdAt=$createdAt, displayName=$displayName, evaluatorVersion=$evaluatorVersion, samplingRate=$samplingRate, tenantId=$tenantId, updatedAt=$updatedAt, webhooks=$webhooks, addToAnnotationQueueId=$addToAnnotationQueueId, addToAnnotationQueueName=$addToAnnotationQueueName, addToDatasetId=$addToDatasetId, addToDatasetName=$addToDatasetName, addToDatasetPreferCorrection=$addToDatasetPreferCorrection, alerts=$alerts, alignmentAnnotationQueueId=$alignmentAnnotationQueueId, backfillFrom=$backfillFrom, codeEvaluators=$codeEvaluators, correctionsDatasetId=$correctionsDatasetId, datasetId=$datasetId, datasetName=$datasetName, evaluatorId=$evaluatorId, evaluators=$evaluators, extendOnly=$extendOnly, filter=$filter, groupBy=$groupBy, includeExtendedStats=$includeExtendedStats, isEnabled=$isEnabled, numFewShotExamples=$numFewShotExamples, sessionId=$sessionId, sessionName=$sessionName, traceFilter=$traceFilter, transient_=$transient_, treeFilter=$treeFilter, useCorrectionsDataset=$useCorrectionsDataset, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RunRulesWebhookSchema.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RunRulesWebhookSchema.kt new file mode 100644 index 00000000..50199775 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RunRulesWebhookSchema.kt @@ -0,0 +1,307 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.rules + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class RunRulesWebhookSchema +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val url: JsonField<String>, + private val headers: JsonField<Headers>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("url") @ExcludeMissing url: JsonField<String> = JsonMissing.of(), + @JsonProperty("headers") @ExcludeMissing headers: JsonField<Headers> = JsonMissing.of(), + ) : this(url, headers, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun url(): String = url.getRequired("url") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun headers(): Optional<Headers> = headers.getOptional("headers") + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField<String> = url + + /** + * Returns the raw JSON value of [headers]. + * + * Unlike [headers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("headers") @ExcludeMissing fun _headers(): JsonField<Headers> = headers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RunRulesWebhookSchema]. + * + * The following fields are required: + * ```java + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunRulesWebhookSchema]. */ + class Builder internal constructor() { + + private var url: JsonField<String>? = null + private var headers: JsonField<Headers> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(runRulesWebhookSchema: RunRulesWebhookSchema) = apply { + url = runRulesWebhookSchema.url + headers = runRulesWebhookSchema.headers + additionalProperties = runRulesWebhookSchema.additionalProperties.toMutableMap() + } + + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun url(url: JsonField<String>) = apply { this.url = url } + + fun headers(headers: Headers?) = headers(JsonField.ofNullable(headers)) + + /** Alias for calling [Builder.headers] with `headers.orElse(null)`. */ + fun headers(headers: Optional<Headers>) = headers(headers.getOrNull()) + + /** + * Sets [Builder.headers] to an arbitrary JSON value. + * + * You should usually call [Builder.headers] with a well-typed [Headers] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun headers(headers: JsonField<Headers>) = apply { this.headers = headers } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RunRulesWebhookSchema]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RunRulesWebhookSchema = + RunRulesWebhookSchema( + checkRequired("url", url), + headers, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RunRulesWebhookSchema = apply { + if (validated) { + return@apply + } + + url() + headers().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (url.asKnown().isPresent) 1 else 0) + (headers.asKnown().getOrNull()?.validity() ?: 0) + + class Headers + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Headers]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Headers]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(headers: Headers) = apply { + additionalProperties = headers.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Headers]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Headers = Headers(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Headers = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Headers && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Headers{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunRulesWebhookSchema && + url == other.url && + headers == other.headers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(url, headers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RunRulesWebhookSchema{url=$url, headers=$headers, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/trigger/TriggerCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/trigger/TriggerCreateParams.kt new file mode 100644 index 00000000..5a9accbc --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/trigger/TriggerCreateParams.kt @@ -0,0 +1,486 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.rules.trigger + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Trigger an array of run rules manually. */ +class TriggerCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun datasetId(): Optional<String> = body.datasetId() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun ruleIds(): Optional<List<String>> = body.ruleIds() + + /** + * Returns the raw JSON value of [datasetId]. + * + * Unlike [datasetId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _datasetId(): JsonField<String> = body._datasetId() + + /** + * Returns the raw JSON value of [ruleIds]. + * + * Unlike [ruleIds], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _ruleIds(): JsonField<List<String>> = body._ruleIds() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): TriggerCreateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [TriggerCreateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TriggerCreateParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(triggerCreateParams: TriggerCreateParams) = apply { + body = triggerCreateParams.body.toBuilder() + additionalHeaders = triggerCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = triggerCreateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [datasetId] + * - [ruleIds] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun datasetId(datasetId: String?) = apply { body.datasetId(datasetId) } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + /** + * Sets [Builder.datasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun datasetId(datasetId: JsonField<String>) = apply { body.datasetId(datasetId) } + + fun ruleIds(ruleIds: List<String>?) = apply { body.ruleIds(ruleIds) } + + /** Alias for calling [Builder.ruleIds] with `ruleIds.orElse(null)`. */ + fun ruleIds(ruleIds: Optional<List<String>>) = ruleIds(ruleIds.getOrNull()) + + /** + * Sets [Builder.ruleIds] to an arbitrary JSON value. + * + * You should usually call [Builder.ruleIds] with a well-typed `List<String>` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ruleIds(ruleIds: JsonField<List<String>>) = apply { body.ruleIds(ruleIds) } + + /** + * Adds a single [String] to [ruleIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRuleId(ruleId: String) = apply { body.addRuleId(ruleId) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TriggerCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TriggerCreateParams = + TriggerCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val datasetId: JsonField<String>, + private val ruleIds: JsonField<List<String>>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dataset_id") + @ExcludeMissing + datasetId: JsonField<String> = JsonMissing.of(), + @JsonProperty("rule_ids") + @ExcludeMissing + ruleIds: JsonField<List<String>> = JsonMissing.of(), + ) : this(datasetId, ruleIds, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun datasetId(): Optional<String> = datasetId.getOptional("dataset_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun ruleIds(): Optional<List<String>> = ruleIds.getOptional("rule_ids") + + /** + * Returns the raw JSON value of [datasetId]. + * + * Unlike [datasetId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField<String> = datasetId + + /** + * Returns the raw JSON value of [ruleIds]. + * + * Unlike [ruleIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rule_ids") @ExcludeMissing fun _ruleIds(): JsonField<List<String>> = ruleIds + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var datasetId: JsonField<String> = JsonMissing.of() + private var ruleIds: JsonField<MutableList<String>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + datasetId = body.datasetId + ruleIds = body.ruleIds.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun datasetId(datasetId: String?) = datasetId(JsonField.ofNullable(datasetId)) + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<String>) = datasetId(datasetId.getOrNull()) + + /** + * Sets [Builder.datasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun datasetId(datasetId: JsonField<String>) = apply { this.datasetId = datasetId } + + fun ruleIds(ruleIds: List<String>?) = ruleIds(JsonField.ofNullable(ruleIds)) + + /** Alias for calling [Builder.ruleIds] with `ruleIds.orElse(null)`. */ + fun ruleIds(ruleIds: Optional<List<String>>) = ruleIds(ruleIds.getOrNull()) + + /** + * Sets [Builder.ruleIds] to an arbitrary JSON value. + * + * You should usually call [Builder.ruleIds] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun ruleIds(ruleIds: JsonField<List<String>>) = apply { + this.ruleIds = ruleIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [ruleIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRuleId(ruleId: String) = apply { + ruleIds = + (ruleIds ?: JsonField.of(mutableListOf())).also { + checkKnown("ruleIds", it).add(ruleId) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = + Body( + datasetId, + (ruleIds ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + datasetId() + ruleIds() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (datasetId.asKnown().isPresent) 1 else 0) + + (ruleIds.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + datasetId == other.datasetId && + ruleIds == other.ruleIds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(datasetId, ruleIds, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{datasetId=$datasetId, ruleIds=$ruleIds, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TriggerCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TriggerCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/trigger/TriggerCreateResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/trigger/TriggerCreateResponse.kt new file mode 100644 index 00000000..4cc7f213 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/trigger/TriggerCreateResponse.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.rules.trigger + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class TriggerCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [TriggerCreateResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TriggerCreateResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(triggerCreateResponse: TriggerCreateResponse) = apply { + additionalProperties = triggerCreateResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TriggerCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TriggerCreateResponse = + TriggerCreateResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): TriggerCreateResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TriggerCreateResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "TriggerCreateResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/share/RunShareSchema.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/share/RunShareSchema.kt new file mode 100644 index 00000000..ce1a4e65 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/share/RunShareSchema.kt @@ -0,0 +1,207 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.share + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class RunShareSchema +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val runId: JsonField<String>, + private val shareToken: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("run_id") @ExcludeMissing runId: JsonField<String> = JsonMissing.of(), + @JsonProperty("share_token") + @ExcludeMissing + shareToken: JsonField<String> = JsonMissing.of(), + ) : this(runId, shareToken, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun runId(): String = runId.getRequired("run_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun shareToken(): String = shareToken.getRequired("share_token") + + /** + * Returns the raw JSON value of [runId]. + * + * Unlike [runId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_id") @ExcludeMissing fun _runId(): JsonField<String> = runId + + /** + * Returns the raw JSON value of [shareToken]. + * + * Unlike [shareToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("share_token") @ExcludeMissing fun _shareToken(): JsonField<String> = shareToken + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RunShareSchema]. + * + * The following fields are required: + * ```java + * .runId() + * .shareToken() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunShareSchema]. */ + class Builder internal constructor() { + + private var runId: JsonField<String>? = null + private var shareToken: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(runShareSchema: RunShareSchema) = apply { + runId = runShareSchema.runId + shareToken = runShareSchema.shareToken + additionalProperties = runShareSchema.additionalProperties.toMutableMap() + } + + fun runId(runId: String) = runId(JsonField.of(runId)) + + /** + * Sets [Builder.runId] to an arbitrary JSON value. + * + * You should usually call [Builder.runId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun runId(runId: JsonField<String>) = apply { this.runId = runId } + + fun shareToken(shareToken: String) = shareToken(JsonField.of(shareToken)) + + /** + * Sets [Builder.shareToken] to an arbitrary JSON value. + * + * You should usually call [Builder.shareToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun shareToken(shareToken: JsonField<String>) = apply { this.shareToken = shareToken } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RunShareSchema]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .runId() + * .shareToken() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RunShareSchema = + RunShareSchema( + checkRequired("runId", runId), + checkRequired("shareToken", shareToken), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RunShareSchema = apply { + if (validated) { + return@apply + } + + runId() + shareToken() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (runId.asKnown().isPresent) 1 else 0) + (if (shareToken.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunShareSchema && + runId == other.runId && + shareToken == other.shareToken && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(runId, shareToken, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RunShareSchema{runId=$runId, shareToken=$shareToken, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/share/ShareCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/share/ShareCreateParams.kt new file mode 100644 index 00000000..ee3ab977 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/share/ShareCreateParams.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.share + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Share a run. */ +class ShareCreateParams +private constructor( + private val runId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun runId(): Optional<String> = Optional.ofNullable(runId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ShareCreateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ShareCreateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ShareCreateParams]. */ + class Builder internal constructor() { + + private var runId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(shareCreateParams: ShareCreateParams) = apply { + runId = shareCreateParams.runId + additionalHeaders = shareCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = shareCreateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = shareCreateParams.additionalBodyProperties.toMutableMap() + } + + fun runId(runId: String?) = apply { this.runId = runId } + + /** Alias for calling [Builder.runId] with `runId.orElse(null)`. */ + fun runId(runId: Optional<String>) = runId(runId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [ShareCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ShareCreateParams = + ShareCreateParams( + runId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> runId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ShareCreateParams && + runId == other.runId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(runId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "ShareCreateParams{runId=$runId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/share/ShareDeleteAllParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/share/ShareDeleteAllParams.kt new file mode 100644 index 00000000..faecf13e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/share/ShareDeleteAllParams.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.share + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Unshare a run. */ +class ShareDeleteAllParams +private constructor( + private val runId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun runId(): Optional<String> = Optional.ofNullable(runId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ShareDeleteAllParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ShareDeleteAllParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ShareDeleteAllParams]. */ + class Builder internal constructor() { + + private var runId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(shareDeleteAllParams: ShareDeleteAllParams) = apply { + runId = shareDeleteAllParams.runId + additionalHeaders = shareDeleteAllParams.additionalHeaders.toBuilder() + additionalQueryParams = shareDeleteAllParams.additionalQueryParams.toBuilder() + additionalBodyProperties = shareDeleteAllParams.additionalBodyProperties.toMutableMap() + } + + fun runId(runId: String?) = apply { this.runId = runId } + + /** Alias for calling [Builder.runId] with `runId.orElse(null)`. */ + fun runId(runId: Optional<String>) = runId(runId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [ShareDeleteAllParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ShareDeleteAllParams = + ShareDeleteAllParams( + runId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> runId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ShareDeleteAllParams && + runId == other.runId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(runId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "ShareDeleteAllParams{runId=$runId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/share/ShareDeleteAllResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/share/ShareDeleteAllResponse.kt new file mode 100644 index 00000000..bd4fb4f5 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/share/ShareDeleteAllResponse.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.share + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class ShareDeleteAllResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ShareDeleteAllResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ShareDeleteAllResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(shareDeleteAllResponse: ShareDeleteAllResponse) = apply { + additionalProperties = shareDeleteAllResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ShareDeleteAllResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ShareDeleteAllResponse = + ShareDeleteAllResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): ShareDeleteAllResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ShareDeleteAllResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "ShareDeleteAllResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/share/ShareListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/share/ShareListParams.kt new file mode 100644 index 00000000..c1935422 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/runs/share/ShareListParams.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.share + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get the state of sharing of a run. */ +class ShareListParams +private constructor( + private val runId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun runId(): Optional<String> = Optional.ofNullable(runId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ShareListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ShareListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ShareListParams]. */ + class Builder internal constructor() { + + private var runId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(shareListParams: ShareListParams) = apply { + runId = shareListParams.runId + additionalHeaders = shareListParams.additionalHeaders.toBuilder() + additionalQueryParams = shareListParams.additionalQueryParams.toBuilder() + } + + fun runId(runId: String?) = apply { this.runId = runId } + + /** Alias for calling [Builder.runId] with `runId.orElse(null)`. */ + fun runId(runId: Optional<String>) = runId(runId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ShareListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ShareListParams = + ShareListParams(runId, additionalHeaders.build(), additionalQueryParams.build()) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> runId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ShareListParams && + runId == other.runId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(runId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ShareListParams{runId=$runId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountDeleteParams.kt new file mode 100644 index 00000000..fb6d20ab --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountDeleteParams.kt @@ -0,0 +1,240 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.serviceaccounts + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete a service account */ +class ServiceAccountDeleteParams +private constructor( + private val serviceAccountId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun serviceAccountId(): Optional<String> = Optional.ofNullable(serviceAccountId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ServiceAccountDeleteParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [ServiceAccountDeleteParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ServiceAccountDeleteParams]. */ + class Builder internal constructor() { + + private var serviceAccountId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(serviceAccountDeleteParams: ServiceAccountDeleteParams) = apply { + serviceAccountId = serviceAccountDeleteParams.serviceAccountId + additionalHeaders = serviceAccountDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = serviceAccountDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + serviceAccountDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun serviceAccountId(serviceAccountId: String?) = apply { + this.serviceAccountId = serviceAccountId + } + + /** Alias for calling [Builder.serviceAccountId] with `serviceAccountId.orElse(null)`. */ + fun serviceAccountId(serviceAccountId: Optional<String>) = + serviceAccountId(serviceAccountId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [ServiceAccountDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ServiceAccountDeleteParams = + ServiceAccountDeleteParams( + serviceAccountId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> serviceAccountId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ServiceAccountDeleteParams && + serviceAccountId == other.serviceAccountId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + serviceAccountId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "ServiceAccountDeleteParams{serviceAccountId=$serviceAccountId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountDeleteResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountDeleteResponse.kt new file mode 100644 index 00000000..166474f1 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountDeleteResponse.kt @@ -0,0 +1,383 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.serviceaccounts + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ServiceAccountDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val defaultWorkspaceId: JsonField<String>, + private val name: JsonField<String>, + private val organizationId: JsonField<String>, + private val updatedAt: JsonField<OffsetDateTime>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("default_workspace_id") + @ExcludeMissing + defaultWorkspaceId: JsonField<String> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("organization_id") + @ExcludeMissing + organizationId: JsonField<String> = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + ) : this(id, createdAt, defaultWorkspaceId, name, organizationId, updatedAt, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun defaultWorkspaceId(): Optional<String> = + defaultWorkspaceId.getOptional("default_workspace_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun organizationId(): String = organizationId.getRequired("organization_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updatedAt(): OffsetDateTime = updatedAt.getRequired("updated_at") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [defaultWorkspaceId]. + * + * Unlike [defaultWorkspaceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("default_workspace_id") + @ExcludeMissing + fun _defaultWorkspaceId(): JsonField<String> = defaultWorkspaceId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [organizationId]. + * + * Unlike [organizationId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("organization_id") + @ExcludeMissing + fun _organizationId(): JsonField<String> = organizationId + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField<OffsetDateTime> = updatedAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ServiceAccountDeleteResponse]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .defaultWorkspaceId() + * .name() + * .organizationId() + * .updatedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ServiceAccountDeleteResponse]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var createdAt: JsonField<OffsetDateTime>? = null + private var defaultWorkspaceId: JsonField<String>? = null + private var name: JsonField<String>? = null + private var organizationId: JsonField<String>? = null + private var updatedAt: JsonField<OffsetDateTime>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(serviceAccountDeleteResponse: ServiceAccountDeleteResponse) = apply { + id = serviceAccountDeleteResponse.id + createdAt = serviceAccountDeleteResponse.createdAt + defaultWorkspaceId = serviceAccountDeleteResponse.defaultWorkspaceId + name = serviceAccountDeleteResponse.name + organizationId = serviceAccountDeleteResponse.organizationId + updatedAt = serviceAccountDeleteResponse.updatedAt + additionalProperties = serviceAccountDeleteResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun defaultWorkspaceId(defaultWorkspaceId: String?) = + defaultWorkspaceId(JsonField.ofNullable(defaultWorkspaceId)) + + /** + * Alias for calling [Builder.defaultWorkspaceId] with `defaultWorkspaceId.orElse(null)`. + */ + fun defaultWorkspaceId(defaultWorkspaceId: Optional<String>) = + defaultWorkspaceId(defaultWorkspaceId.getOrNull()) + + /** + * Sets [Builder.defaultWorkspaceId] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultWorkspaceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun defaultWorkspaceId(defaultWorkspaceId: JsonField<String>) = apply { + this.defaultWorkspaceId = defaultWorkspaceId + } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun organizationId(organizationId: String) = organizationId(JsonField.of(organizationId)) + + /** + * Sets [Builder.organizationId] to an arbitrary JSON value. + * + * You should usually call [Builder.organizationId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun organizationId(organizationId: JsonField<String>) = apply { + this.organizationId = organizationId + } + + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField<OffsetDateTime>) = apply { this.updatedAt = updatedAt } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ServiceAccountDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .defaultWorkspaceId() + * .name() + * .organizationId() + * .updatedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ServiceAccountDeleteResponse = + ServiceAccountDeleteResponse( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("defaultWorkspaceId", defaultWorkspaceId), + checkRequired("name", name), + checkRequired("organizationId", organizationId), + checkRequired("updatedAt", updatedAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ServiceAccountDeleteResponse = apply { + if (validated) { + return@apply + } + + id() + createdAt() + defaultWorkspaceId() + name() + organizationId() + updatedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (defaultWorkspaceId.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (organizationId.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ServiceAccountDeleteResponse && + id == other.id && + createdAt == other.createdAt && + defaultWorkspaceId == other.defaultWorkspaceId && + name == other.name && + organizationId == other.organizationId && + updatedAt == other.updatedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + createdAt, + defaultWorkspaceId, + name, + organizationId, + updatedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ServiceAccountDeleteResponse{id=$id, createdAt=$createdAt, defaultWorkspaceId=$defaultWorkspaceId, name=$name, organizationId=$organizationId, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountRetrieveServiceAccountsParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountRetrieveServiceAccountsParams.kt new file mode 100644 index 00000000..8958c780 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountRetrieveServiceAccountsParams.kt @@ -0,0 +1,180 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.serviceaccounts + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** Get the current organization's service accounts. */ +class ServiceAccountRetrieveServiceAccountsParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ServiceAccountRetrieveServiceAccountsParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [ServiceAccountRetrieveServiceAccountsParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ServiceAccountRetrieveServiceAccountsParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + serviceAccountRetrieveServiceAccountsParams: ServiceAccountRetrieveServiceAccountsParams + ) = apply { + additionalHeaders = + serviceAccountRetrieveServiceAccountsParams.additionalHeaders.toBuilder() + additionalQueryParams = + serviceAccountRetrieveServiceAccountsParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ServiceAccountRetrieveServiceAccountsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ServiceAccountRetrieveServiceAccountsParams = + ServiceAccountRetrieveServiceAccountsParams( + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ServiceAccountRetrieveServiceAccountsParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "ServiceAccountRetrieveServiceAccountsParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountRetrieveServiceAccountsResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountRetrieveServiceAccountsResponse.kt new file mode 100644 index 00000000..96c55077 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountRetrieveServiceAccountsResponse.kt @@ -0,0 +1,388 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.serviceaccounts + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ServiceAccountRetrieveServiceAccountsResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val defaultWorkspaceId: JsonField<String>, + private val name: JsonField<String>, + private val organizationId: JsonField<String>, + private val updatedAt: JsonField<OffsetDateTime>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("default_workspace_id") + @ExcludeMissing + defaultWorkspaceId: JsonField<String> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("organization_id") + @ExcludeMissing + organizationId: JsonField<String> = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + ) : this(id, createdAt, defaultWorkspaceId, name, organizationId, updatedAt, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun defaultWorkspaceId(): Optional<String> = + defaultWorkspaceId.getOptional("default_workspace_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun organizationId(): String = organizationId.getRequired("organization_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updatedAt(): OffsetDateTime = updatedAt.getRequired("updated_at") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [defaultWorkspaceId]. + * + * Unlike [defaultWorkspaceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("default_workspace_id") + @ExcludeMissing + fun _defaultWorkspaceId(): JsonField<String> = defaultWorkspaceId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [organizationId]. + * + * Unlike [organizationId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("organization_id") + @ExcludeMissing + fun _organizationId(): JsonField<String> = organizationId + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField<OffsetDateTime> = updatedAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ServiceAccountRetrieveServiceAccountsResponse]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .defaultWorkspaceId() + * .name() + * .organizationId() + * .updatedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ServiceAccountRetrieveServiceAccountsResponse]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var createdAt: JsonField<OffsetDateTime>? = null + private var defaultWorkspaceId: JsonField<String>? = null + private var name: JsonField<String>? = null + private var organizationId: JsonField<String>? = null + private var updatedAt: JsonField<OffsetDateTime>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from( + serviceAccountRetrieveServiceAccountsResponse: + ServiceAccountRetrieveServiceAccountsResponse + ) = apply { + id = serviceAccountRetrieveServiceAccountsResponse.id + createdAt = serviceAccountRetrieveServiceAccountsResponse.createdAt + defaultWorkspaceId = serviceAccountRetrieveServiceAccountsResponse.defaultWorkspaceId + name = serviceAccountRetrieveServiceAccountsResponse.name + organizationId = serviceAccountRetrieveServiceAccountsResponse.organizationId + updatedAt = serviceAccountRetrieveServiceAccountsResponse.updatedAt + additionalProperties = + serviceAccountRetrieveServiceAccountsResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun defaultWorkspaceId(defaultWorkspaceId: String?) = + defaultWorkspaceId(JsonField.ofNullable(defaultWorkspaceId)) + + /** + * Alias for calling [Builder.defaultWorkspaceId] with `defaultWorkspaceId.orElse(null)`. + */ + fun defaultWorkspaceId(defaultWorkspaceId: Optional<String>) = + defaultWorkspaceId(defaultWorkspaceId.getOrNull()) + + /** + * Sets [Builder.defaultWorkspaceId] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultWorkspaceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun defaultWorkspaceId(defaultWorkspaceId: JsonField<String>) = apply { + this.defaultWorkspaceId = defaultWorkspaceId + } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun organizationId(organizationId: String) = organizationId(JsonField.of(organizationId)) + + /** + * Sets [Builder.organizationId] to an arbitrary JSON value. + * + * You should usually call [Builder.organizationId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun organizationId(organizationId: JsonField<String>) = apply { + this.organizationId = organizationId + } + + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField<OffsetDateTime>) = apply { this.updatedAt = updatedAt } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ServiceAccountRetrieveServiceAccountsResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .defaultWorkspaceId() + * .name() + * .organizationId() + * .updatedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ServiceAccountRetrieveServiceAccountsResponse = + ServiceAccountRetrieveServiceAccountsResponse( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("defaultWorkspaceId", defaultWorkspaceId), + checkRequired("name", name), + checkRequired("organizationId", organizationId), + checkRequired("updatedAt", updatedAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ServiceAccountRetrieveServiceAccountsResponse = apply { + if (validated) { + return@apply + } + + id() + createdAt() + defaultWorkspaceId() + name() + organizationId() + updatedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (defaultWorkspaceId.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (organizationId.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ServiceAccountRetrieveServiceAccountsResponse && + id == other.id && + createdAt == other.createdAt && + defaultWorkspaceId == other.defaultWorkspaceId && + name == other.name && + organizationId == other.organizationId && + updatedAt == other.updatedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + createdAt, + defaultWorkspaceId, + name, + organizationId, + updatedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ServiceAccountRetrieveServiceAccountsResponse{id=$id, createdAt=$createdAt, defaultWorkspaceId=$defaultWorkspaceId, name=$name, organizationId=$organizationId, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountServiceAccountsParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountServiceAccountsParams.kt new file mode 100644 index 00000000..9ead7ff1 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountServiceAccountsParams.kt @@ -0,0 +1,707 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.serviceaccounts + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create a service account */ +class ServiceAccountServiceAccountsParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = body.name() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun workspaces(): Optional<List<Workspace>> = body.workspaces() + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _name(): JsonField<String> = body._name() + + /** + * Returns the raw JSON value of [workspaces]. + * + * Unlike [workspaces], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _workspaces(): JsonField<List<Workspace>> = body._workspaces() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ServiceAccountServiceAccountsParams]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ServiceAccountServiceAccountsParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + serviceAccountServiceAccountsParams: ServiceAccountServiceAccountsParams + ) = apply { + body = serviceAccountServiceAccountsParams.body.toBuilder() + additionalHeaders = serviceAccountServiceAccountsParams.additionalHeaders.toBuilder() + additionalQueryParams = + serviceAccountServiceAccountsParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [name] + * - [workspaces] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun name(name: String) = apply { body.name(name) } + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { body.name(name) } + + fun workspaces(workspaces: List<Workspace>) = apply { body.workspaces(workspaces) } + + /** + * Sets [Builder.workspaces] to an arbitrary JSON value. + * + * You should usually call [Builder.workspaces] with a well-typed `List<Workspace>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun workspaces(workspaces: JsonField<List<Workspace>>) = apply { + body.workspaces(workspaces) + } + + /** + * Adds a single [Workspace] to [workspaces]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWorkspace(workspace: Workspace) = apply { body.addWorkspace(workspace) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ServiceAccountServiceAccountsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ServiceAccountServiceAccountsParams = + ServiceAccountServiceAccountsParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val name: JsonField<String>, + private val workspaces: JsonField<List<Workspace>>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("workspaces") + @ExcludeMissing + workspaces: JsonField<List<Workspace>> = JsonMissing.of(), + ) : this(name, workspaces, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun workspaces(): Optional<List<Workspace>> = workspaces.getOptional("workspaces") + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [workspaces]. + * + * Unlike [workspaces], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("workspaces") + @ExcludeMissing + fun _workspaces(): JsonField<List<Workspace>> = workspaces + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var name: JsonField<String>? = null + private var workspaces: JsonField<MutableList<Workspace>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + name = body.name + workspaces = body.workspaces.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun workspaces(workspaces: List<Workspace>) = workspaces(JsonField.of(workspaces)) + + /** + * Sets [Builder.workspaces] to an arbitrary JSON value. + * + * You should usually call [Builder.workspaces] with a well-typed `List<Workspace>` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun workspaces(workspaces: JsonField<List<Workspace>>) = apply { + this.workspaces = workspaces.map { it.toMutableList() } + } + + /** + * Adds a single [Workspace] to [workspaces]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWorkspace(workspace: Workspace) = apply { + workspaces = + (workspaces ?: JsonField.of(mutableListOf())).also { + checkKnown("workspaces", it).add(workspace) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("name", name), + (workspaces ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + name() + workspaces().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (name.asKnown().isPresent) 1 else 0) + + (workspaces.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + name == other.name && + workspaces == other.workspaces && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(name, workspaces, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{name=$name, workspaces=$workspaces, additionalProperties=$additionalProperties}" + } + + class Workspace + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val workspaceId: JsonField<String>, + private val roleId: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("workspace_id") + @ExcludeMissing + workspaceId: JsonField<String> = JsonMissing.of(), + @JsonProperty("role_id") @ExcludeMissing roleId: JsonField<String> = JsonMissing.of(), + ) : this(workspaceId, roleId, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun workspaceId(): String = workspaceId.getRequired("workspace_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun roleId(): Optional<String> = roleId.getOptional("role_id") + + /** + * Returns the raw JSON value of [workspaceId]. + * + * Unlike [workspaceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("workspace_id") + @ExcludeMissing + fun _workspaceId(): JsonField<String> = workspaceId + + /** + * Returns the raw JSON value of [roleId]. + * + * Unlike [roleId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("role_id") @ExcludeMissing fun _roleId(): JsonField<String> = roleId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Workspace]. + * + * The following fields are required: + * ```java + * .workspaceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Workspace]. */ + class Builder internal constructor() { + + private var workspaceId: JsonField<String>? = null + private var roleId: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(workspace: Workspace) = apply { + workspaceId = workspace.workspaceId + roleId = workspace.roleId + additionalProperties = workspace.additionalProperties.toMutableMap() + } + + fun workspaceId(workspaceId: String) = workspaceId(JsonField.of(workspaceId)) + + /** + * Sets [Builder.workspaceId] to an arbitrary JSON value. + * + * You should usually call [Builder.workspaceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun workspaceId(workspaceId: JsonField<String>) = apply { + this.workspaceId = workspaceId + } + + fun roleId(roleId: String?) = roleId(JsonField.ofNullable(roleId)) + + /** Alias for calling [Builder.roleId] with `roleId.orElse(null)`. */ + fun roleId(roleId: Optional<String>) = roleId(roleId.getOrNull()) + + /** + * Sets [Builder.roleId] to an arbitrary JSON value. + * + * You should usually call [Builder.roleId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun roleId(roleId: JsonField<String>) = apply { this.roleId = roleId } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Workspace]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .workspaceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Workspace = + Workspace( + checkRequired("workspaceId", workspaceId), + roleId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Workspace = apply { + if (validated) { + return@apply + } + + workspaceId() + roleId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (workspaceId.asKnown().isPresent) 1 else 0) + + (if (roleId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Workspace && + workspaceId == other.workspaceId && + roleId == other.roleId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(workspaceId, roleId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Workspace{workspaceId=$workspaceId, roleId=$roleId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ServiceAccountServiceAccountsParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ServiceAccountServiceAccountsParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountServiceAccountsResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountServiceAccountsResponse.kt new file mode 100644 index 00000000..41219451 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountServiceAccountsResponse.kt @@ -0,0 +1,440 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.serviceaccounts + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ServiceAccountServiceAccountsResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val defaultWorkspaceId: JsonField<String>, + private val name: JsonField<String>, + private val organizationId: JsonField<String>, + private val organizationIdentityId: JsonField<String>, + private val updatedAt: JsonField<OffsetDateTime>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("default_workspace_id") + @ExcludeMissing + defaultWorkspaceId: JsonField<String> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("organization_id") + @ExcludeMissing + organizationId: JsonField<String> = JsonMissing.of(), + @JsonProperty("organization_identity_id") + @ExcludeMissing + organizationIdentityId: JsonField<String> = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + ) : this( + id, + createdAt, + defaultWorkspaceId, + name, + organizationId, + organizationIdentityId, + updatedAt, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun defaultWorkspaceId(): Optional<String> = + defaultWorkspaceId.getOptional("default_workspace_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun organizationId(): String = organizationId.getRequired("organization_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun organizationIdentityId(): String = + organizationIdentityId.getRequired("organization_identity_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updatedAt(): OffsetDateTime = updatedAt.getRequired("updated_at") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [defaultWorkspaceId]. + * + * Unlike [defaultWorkspaceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("default_workspace_id") + @ExcludeMissing + fun _defaultWorkspaceId(): JsonField<String> = defaultWorkspaceId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [organizationId]. + * + * Unlike [organizationId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("organization_id") + @ExcludeMissing + fun _organizationId(): JsonField<String> = organizationId + + /** + * Returns the raw JSON value of [organizationIdentityId]. + * + * Unlike [organizationIdentityId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("organization_identity_id") + @ExcludeMissing + fun _organizationIdentityId(): JsonField<String> = organizationIdentityId + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField<OffsetDateTime> = updatedAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ServiceAccountServiceAccountsResponse]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .defaultWorkspaceId() + * .name() + * .organizationId() + * .organizationIdentityId() + * .updatedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ServiceAccountServiceAccountsResponse]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var createdAt: JsonField<OffsetDateTime>? = null + private var defaultWorkspaceId: JsonField<String>? = null + private var name: JsonField<String>? = null + private var organizationId: JsonField<String>? = null + private var organizationIdentityId: JsonField<String>? = null + private var updatedAt: JsonField<OffsetDateTime>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from( + serviceAccountServiceAccountsResponse: ServiceAccountServiceAccountsResponse + ) = apply { + id = serviceAccountServiceAccountsResponse.id + createdAt = serviceAccountServiceAccountsResponse.createdAt + defaultWorkspaceId = serviceAccountServiceAccountsResponse.defaultWorkspaceId + name = serviceAccountServiceAccountsResponse.name + organizationId = serviceAccountServiceAccountsResponse.organizationId + organizationIdentityId = serviceAccountServiceAccountsResponse.organizationIdentityId + updatedAt = serviceAccountServiceAccountsResponse.updatedAt + additionalProperties = + serviceAccountServiceAccountsResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun defaultWorkspaceId(defaultWorkspaceId: String?) = + defaultWorkspaceId(JsonField.ofNullable(defaultWorkspaceId)) + + /** + * Alias for calling [Builder.defaultWorkspaceId] with `defaultWorkspaceId.orElse(null)`. + */ + fun defaultWorkspaceId(defaultWorkspaceId: Optional<String>) = + defaultWorkspaceId(defaultWorkspaceId.getOrNull()) + + /** + * Sets [Builder.defaultWorkspaceId] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultWorkspaceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun defaultWorkspaceId(defaultWorkspaceId: JsonField<String>) = apply { + this.defaultWorkspaceId = defaultWorkspaceId + } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun organizationId(organizationId: String) = organizationId(JsonField.of(organizationId)) + + /** + * Sets [Builder.organizationId] to an arbitrary JSON value. + * + * You should usually call [Builder.organizationId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun organizationId(organizationId: JsonField<String>) = apply { + this.organizationId = organizationId + } + + fun organizationIdentityId(organizationIdentityId: String) = + organizationIdentityId(JsonField.of(organizationIdentityId)) + + /** + * Sets [Builder.organizationIdentityId] to an arbitrary JSON value. + * + * You should usually call [Builder.organizationIdentityId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun organizationIdentityId(organizationIdentityId: JsonField<String>) = apply { + this.organizationIdentityId = organizationIdentityId + } + + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField<OffsetDateTime>) = apply { this.updatedAt = updatedAt } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ServiceAccountServiceAccountsResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .defaultWorkspaceId() + * .name() + * .organizationId() + * .organizationIdentityId() + * .updatedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ServiceAccountServiceAccountsResponse = + ServiceAccountServiceAccountsResponse( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("defaultWorkspaceId", defaultWorkspaceId), + checkRequired("name", name), + checkRequired("organizationId", organizationId), + checkRequired("organizationIdentityId", organizationIdentityId), + checkRequired("updatedAt", updatedAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ServiceAccountServiceAccountsResponse = apply { + if (validated) { + return@apply + } + + id() + createdAt() + defaultWorkspaceId() + name() + organizationId() + organizationIdentityId() + updatedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (defaultWorkspaceId.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (organizationId.asKnown().isPresent) 1 else 0) + + (if (organizationIdentityId.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ServiceAccountServiceAccountsResponse && + id == other.id && + createdAt == other.createdAt && + defaultWorkspaceId == other.defaultWorkspaceId && + name == other.name && + organizationId == other.organizationId && + organizationIdentityId == other.organizationIdentityId && + updatedAt == other.updatedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + createdAt, + defaultWorkspaceId, + name, + organizationId, + organizationIdentityId, + updatedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ServiceAccountServiceAccountsResponse{id=$id, createdAt=$createdAt, defaultWorkspaceId=$defaultWorkspaceId, name=$name, organizationId=$organizationId, organizationIdentityId=$organizationIdentityId, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/CustomChartsSection.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/CustomChartsSection.kt new file mode 100644 index 00000000..aff15a0b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/CustomChartsSection.kt @@ -0,0 +1,762 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.charts.SingleCustomChartResponse +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class CustomChartsSection +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val charts: JsonField<List<SingleCustomChartResponse>>, + private val title: JsonField<String>, + private val description: JsonField<String>, + private val index: JsonField<Long>, + private val sessionId: JsonField<String>, + private val subSections: JsonField<List<SubSection>>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("charts") + @ExcludeMissing + charts: JsonField<List<SingleCustomChartResponse>> = JsonMissing.of(), + @JsonProperty("title") @ExcludeMissing title: JsonField<String> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("index") @ExcludeMissing index: JsonField<Long> = JsonMissing.of(), + @JsonProperty("session_id") @ExcludeMissing sessionId: JsonField<String> = JsonMissing.of(), + @JsonProperty("sub_sections") + @ExcludeMissing + subSections: JsonField<List<SubSection>> = JsonMissing.of(), + ) : this(id, charts, title, description, index, sessionId, subSections, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun charts(): List<SingleCustomChartResponse> = charts.getRequired("charts") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun title(): String = title.getRequired("title") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun index(): Optional<Long> = index.getOptional("index") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun sessionId(): Optional<String> = sessionId.getOptional("session_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun subSections(): Optional<List<SubSection>> = subSections.getOptional("sub_sections") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [charts]. + * + * Unlike [charts], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("charts") + @ExcludeMissing + fun _charts(): JsonField<List<SingleCustomChartResponse>> = charts + + /** + * Returns the raw JSON value of [title]. + * + * Unlike [title], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("title") @ExcludeMissing fun _title(): JsonField<String> = title + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [index]. + * + * Unlike [index], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("index") @ExcludeMissing fun _index(): JsonField<Long> = index + + /** + * Returns the raw JSON value of [sessionId]. + * + * Unlike [sessionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session_id") @ExcludeMissing fun _sessionId(): JsonField<String> = sessionId + + /** + * Returns the raw JSON value of [subSections]. + * + * Unlike [subSections], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sub_sections") + @ExcludeMissing + fun _subSections(): JsonField<List<SubSection>> = subSections + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CustomChartsSection]. + * + * The following fields are required: + * ```java + * .id() + * .charts() + * .title() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomChartsSection]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var charts: JsonField<MutableList<SingleCustomChartResponse>>? = null + private var title: JsonField<String>? = null + private var description: JsonField<String> = JsonMissing.of() + private var index: JsonField<Long> = JsonMissing.of() + private var sessionId: JsonField<String> = JsonMissing.of() + private var subSections: JsonField<MutableList<SubSection>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(customChartsSection: CustomChartsSection) = apply { + id = customChartsSection.id + charts = customChartsSection.charts.map { it.toMutableList() } + title = customChartsSection.title + description = customChartsSection.description + index = customChartsSection.index + sessionId = customChartsSection.sessionId + subSections = customChartsSection.subSections.map { it.toMutableList() } + additionalProperties = customChartsSection.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun charts(charts: List<SingleCustomChartResponse>) = charts(JsonField.of(charts)) + + /** + * Sets [Builder.charts] to an arbitrary JSON value. + * + * You should usually call [Builder.charts] with a well-typed + * `List<SingleCustomChartResponse>` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun charts(charts: JsonField<List<SingleCustomChartResponse>>) = apply { + this.charts = charts.map { it.toMutableList() } + } + + /** + * Adds a single [SingleCustomChartResponse] to [charts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChart(chart: SingleCustomChartResponse) = apply { + charts = + (charts ?: JsonField.of(mutableListOf())).also { + checkKnown("charts", it).add(chart) + } + } + + fun title(title: String) = title(JsonField.of(title)) + + /** + * Sets [Builder.title] to an arbitrary JSON value. + * + * You should usually call [Builder.title] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun title(title: JsonField<String>) = apply { this.title = title } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { this.description = description } + + fun index(index: Long?) = index(JsonField.ofNullable(index)) + + /** + * Alias for [Builder.index]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun index(index: Long) = index(index as Long?) + + /** Alias for calling [Builder.index] with `index.orElse(null)`. */ + fun index(index: Optional<Long>) = index(index.getOrNull()) + + /** + * Sets [Builder.index] to an arbitrary JSON value. + * + * You should usually call [Builder.index] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun index(index: JsonField<Long>) = apply { this.index = index } + + fun sessionId(sessionId: String?) = sessionId(JsonField.ofNullable(sessionId)) + + /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ + fun sessionId(sessionId: Optional<String>) = sessionId(sessionId.getOrNull()) + + /** + * Sets [Builder.sessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun sessionId(sessionId: JsonField<String>) = apply { this.sessionId = sessionId } + + fun subSections(subSections: List<SubSection>?) = + subSections(JsonField.ofNullable(subSections)) + + /** Alias for calling [Builder.subSections] with `subSections.orElse(null)`. */ + fun subSections(subSections: Optional<List<SubSection>>) = + subSections(subSections.getOrNull()) + + /** + * Sets [Builder.subSections] to an arbitrary JSON value. + * + * You should usually call [Builder.subSections] with a well-typed `List<SubSection>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subSections(subSections: JsonField<List<SubSection>>) = apply { + this.subSections = subSections.map { it.toMutableList() } + } + + /** + * Adds a single [SubSection] to [subSections]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSubSection(subSection: SubSection) = apply { + subSections = + (subSections ?: JsonField.of(mutableListOf())).also { + checkKnown("subSections", it).add(subSection) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomChartsSection]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .charts() + * .title() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomChartsSection = + CustomChartsSection( + checkRequired("id", id), + checkRequired("charts", charts).map { it.toImmutable() }, + checkRequired("title", title), + description, + index, + sessionId, + (subSections ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CustomChartsSection = apply { + if (validated) { + return@apply + } + + id() + charts().forEach { it.validate() } + title() + description() + index() + sessionId() + subSections().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (charts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (title.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (index.asKnown().isPresent) 1 else 0) + + (if (sessionId.asKnown().isPresent) 1 else 0) + + (subSections.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class SubSection + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField<String>, + private val charts: JsonField<List<SingleCustomChartResponse>>, + private val index: JsonField<Long>, + private val title: JsonField<String>, + private val description: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("charts") + @ExcludeMissing + charts: JsonField<List<SingleCustomChartResponse>> = JsonMissing.of(), + @JsonProperty("index") @ExcludeMissing index: JsonField<Long> = JsonMissing.of(), + @JsonProperty("title") @ExcludeMissing title: JsonField<String> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + ) : this(id, charts, index, title, description, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun charts(): List<SingleCustomChartResponse> = charts.getRequired("charts") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun index(): Long = index.getRequired("index") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun title(): String = title.getRequired("title") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [charts]. + * + * Unlike [charts], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("charts") + @ExcludeMissing + fun _charts(): JsonField<List<SingleCustomChartResponse>> = charts + + /** + * Returns the raw JSON value of [index]. + * + * Unlike [index], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("index") @ExcludeMissing fun _index(): JsonField<Long> = index + + /** + * Returns the raw JSON value of [title]. + * + * Unlike [title], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("title") @ExcludeMissing fun _title(): JsonField<String> = title + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField<String> = description + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SubSection]. + * + * The following fields are required: + * ```java + * .id() + * .charts() + * .index() + * .title() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SubSection]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var charts: JsonField<MutableList<SingleCustomChartResponse>>? = null + private var index: JsonField<Long>? = null + private var title: JsonField<String>? = null + private var description: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(subSection: SubSection) = apply { + id = subSection.id + charts = subSection.charts.map { it.toMutableList() } + index = subSection.index + title = subSection.title + description = subSection.description + additionalProperties = subSection.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun charts(charts: List<SingleCustomChartResponse>) = charts(JsonField.of(charts)) + + /** + * Sets [Builder.charts] to an arbitrary JSON value. + * + * You should usually call [Builder.charts] with a well-typed + * `List<SingleCustomChartResponse>` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun charts(charts: JsonField<List<SingleCustomChartResponse>>) = apply { + this.charts = charts.map { it.toMutableList() } + } + + /** + * Adds a single [SingleCustomChartResponse] to [charts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChart(chart: SingleCustomChartResponse) = apply { + charts = + (charts ?: JsonField.of(mutableListOf())).also { + checkKnown("charts", it).add(chart) + } + } + + fun index(index: Long) = index(JsonField.of(index)) + + /** + * Sets [Builder.index] to an arbitrary JSON value. + * + * You should usually call [Builder.index] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun index(index: JsonField<Long>) = apply { this.index = index } + + fun title(title: String) = title(JsonField.of(title)) + + /** + * Sets [Builder.title] to an arbitrary JSON value. + * + * You should usually call [Builder.title] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun title(title: JsonField<String>) = apply { this.title = title } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField<String>) = apply { + this.description = description + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SubSection]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .charts() + * .index() + * .title() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SubSection = + SubSection( + checkRequired("id", id), + checkRequired("charts", charts).map { it.toImmutable() }, + checkRequired("index", index), + checkRequired("title", title), + description, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SubSection = apply { + if (validated) { + return@apply + } + + id() + charts().forEach { it.validate() } + index() + title() + description() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (charts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (index.asKnown().isPresent) 1 else 0) + + (if (title.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SubSection && + id == other.id && + charts == other.charts && + index == other.index && + title == other.title && + description == other.description && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, charts, index, title, description, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SubSection{id=$id, charts=$charts, index=$index, title=$title, description=$description, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomChartsSection && + id == other.id && + charts == other.charts && + title == other.title && + description == other.description && + index == other.index && + sessionId == other.sessionId && + subSections == other.subSections && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + charts, + title, + description, + index, + sessionId, + subSections, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomChartsSection{id=$id, charts=$charts, title=$title, description=$description, index=$index, sessionId=$sessionId, subSections=$subSections, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/CustomChartsSectionRequest.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/CustomChartsSectionRequest.kt new file mode 100644 index 00000000..eaeb7ee6 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/CustomChartsSectionRequest.kt @@ -0,0 +1,349 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class CustomChartsSectionRequest +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val endTime: JsonField<OffsetDateTime>, + private val groupBy: JsonField<RunStatsGroupBy>, + private val omitData: JsonField<Boolean>, + private val startTime: JsonField<OffsetDateTime>, + private val stride: JsonField<TimedeltaInput>, + private val timezone: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("end_time") + @ExcludeMissing + endTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("group_by") + @ExcludeMissing + groupBy: JsonField<RunStatsGroupBy> = JsonMissing.of(), + @JsonProperty("omit_data") @ExcludeMissing omitData: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("stride") + @ExcludeMissing + stride: JsonField<TimedeltaInput> = JsonMissing.of(), + @JsonProperty("timezone") @ExcludeMissing timezone: JsonField<String> = JsonMissing.of(), + ) : this(endTime, groupBy, omitData, startTime, stride, timezone, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endTime(): Optional<OffsetDateTime> = endTime.getOptional("end_time") + + /** + * Group by param for run stats. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun groupBy(): Optional<RunStatsGroupBy> = groupBy.getOptional("group_by") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun omitData(): Optional<Boolean> = omitData.getOptional("omit_data") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun startTime(): Optional<OffsetDateTime> = startTime.getOptional("start_time") + + /** + * Timedelta input. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun stride(): Optional<TimedeltaInput> = stride.getOptional("stride") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun timezone(): Optional<String> = timezone.getOptional("timezone") + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_time") @ExcludeMissing fun _endTime(): JsonField<OffsetDateTime> = endTime + + /** + * Returns the raw JSON value of [groupBy]. + * + * Unlike [groupBy], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("group_by") @ExcludeMissing fun _groupBy(): JsonField<RunStatsGroupBy> = groupBy + + /** + * Returns the raw JSON value of [omitData]. + * + * Unlike [omitData], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("omit_data") @ExcludeMissing fun _omitData(): JsonField<Boolean> = omitData + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_time") + @ExcludeMissing + fun _startTime(): JsonField<OffsetDateTime> = startTime + + /** + * Returns the raw JSON value of [stride]. + * + * Unlike [stride], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("stride") @ExcludeMissing fun _stride(): JsonField<TimedeltaInput> = stride + + /** + * Returns the raw JSON value of [timezone]. + * + * Unlike [timezone], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("timezone") @ExcludeMissing fun _timezone(): JsonField<String> = timezone + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CustomChartsSectionRequest]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomChartsSectionRequest]. */ + class Builder internal constructor() { + + private var endTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var groupBy: JsonField<RunStatsGroupBy> = JsonMissing.of() + private var omitData: JsonField<Boolean> = JsonMissing.of() + private var startTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var stride: JsonField<TimedeltaInput> = JsonMissing.of() + private var timezone: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(customChartsSectionRequest: CustomChartsSectionRequest) = apply { + endTime = customChartsSectionRequest.endTime + groupBy = customChartsSectionRequest.groupBy + omitData = customChartsSectionRequest.omitData + startTime = customChartsSectionRequest.startTime + stride = customChartsSectionRequest.stride + timezone = customChartsSectionRequest.timezone + additionalProperties = customChartsSectionRequest.additionalProperties.toMutableMap() + } + + fun endTime(endTime: OffsetDateTime?) = endTime(JsonField.ofNullable(endTime)) + + /** Alias for calling [Builder.endTime] with `endTime.orElse(null)`. */ + fun endTime(endTime: Optional<OffsetDateTime>) = endTime(endTime.getOrNull()) + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endTime(endTime: JsonField<OffsetDateTime>) = apply { this.endTime = endTime } + + /** Group by param for run stats. */ + fun groupBy(groupBy: RunStatsGroupBy?) = groupBy(JsonField.ofNullable(groupBy)) + + /** Alias for calling [Builder.groupBy] with `groupBy.orElse(null)`. */ + fun groupBy(groupBy: Optional<RunStatsGroupBy>) = groupBy(groupBy.getOrNull()) + + /** + * Sets [Builder.groupBy] to an arbitrary JSON value. + * + * You should usually call [Builder.groupBy] with a well-typed [RunStatsGroupBy] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupBy(groupBy: JsonField<RunStatsGroupBy>) = apply { this.groupBy = groupBy } + + fun omitData(omitData: Boolean) = omitData(JsonField.of(omitData)) + + /** + * Sets [Builder.omitData] to an arbitrary JSON value. + * + * You should usually call [Builder.omitData] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun omitData(omitData: JsonField<Boolean>) = apply { this.omitData = omitData } + + fun startTime(startTime: OffsetDateTime?) = startTime(JsonField.ofNullable(startTime)) + + /** Alias for calling [Builder.startTime] with `startTime.orElse(null)`. */ + fun startTime(startTime: Optional<OffsetDateTime>) = startTime(startTime.getOrNull()) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField<OffsetDateTime>) = apply { this.startTime = startTime } + + /** Timedelta input. */ + fun stride(stride: TimedeltaInput) = stride(JsonField.of(stride)) + + /** + * Sets [Builder.stride] to an arbitrary JSON value. + * + * You should usually call [Builder.stride] with a well-typed [TimedeltaInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun stride(stride: JsonField<TimedeltaInput>) = apply { this.stride = stride } + + fun timezone(timezone: String) = timezone(JsonField.of(timezone)) + + /** + * Sets [Builder.timezone] to an arbitrary JSON value. + * + * You should usually call [Builder.timezone] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun timezone(timezone: JsonField<String>) = apply { this.timezone = timezone } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomChartsSectionRequest]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CustomChartsSectionRequest = + CustomChartsSectionRequest( + endTime, + groupBy, + omitData, + startTime, + stride, + timezone, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CustomChartsSectionRequest = apply { + if (validated) { + return@apply + } + + endTime() + groupBy().ifPresent { it.validate() } + omitData() + startTime() + stride().ifPresent { it.validate() } + timezone() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (endTime.asKnown().isPresent) 1 else 0) + + (groupBy.asKnown().getOrNull()?.validity() ?: 0) + + (if (omitData.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + (stride.asKnown().getOrNull()?.validity() ?: 0) + + (if (timezone.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomChartsSectionRequest && + endTime == other.endTime && + groupBy == other.groupBy && + omitData == other.omitData && + startTime == other.startTime && + stride == other.stride && + timezone == other.timezone && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(endTime, groupBy, omitData, startTime, stride, timezone, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomChartsSectionRequest{endTime=$endTime, groupBy=$groupBy, omitData=$omitData, startTime=$startTime, stride=$stride, timezone=$timezone, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/RunStatsGroupBy.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/RunStatsGroupBy.kt new file mode 100644 index 00000000..2cd3591d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/RunStatsGroupBy.kt @@ -0,0 +1,387 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions + +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.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Group by param for run stats. */ +class RunStatsGroupBy +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val attribute: JsonField<Attribute>, + private val maxGroups: JsonField<Long>, + private val path: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("attribute") + @ExcludeMissing + attribute: JsonField<Attribute> = JsonMissing.of(), + @JsonProperty("max_groups") @ExcludeMissing maxGroups: JsonField<Long> = JsonMissing.of(), + @JsonProperty("path") @ExcludeMissing path: JsonField<String> = JsonMissing.of(), + ) : this(attribute, maxGroups, path, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun attribute(): Attribute = attribute.getRequired("attribute") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun maxGroups(): Optional<Long> = maxGroups.getOptional("max_groups") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun path(): Optional<String> = path.getOptional("path") + + /** + * Returns the raw JSON value of [attribute]. + * + * Unlike [attribute], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("attribute") @ExcludeMissing fun _attribute(): JsonField<Attribute> = attribute + + /** + * Returns the raw JSON value of [maxGroups]. + * + * Unlike [maxGroups], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("max_groups") @ExcludeMissing fun _maxGroups(): JsonField<Long> = maxGroups + + /** + * Returns the raw JSON value of [path]. + * + * Unlike [path], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("path") @ExcludeMissing fun _path(): JsonField<String> = path + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RunStatsGroupBy]. + * + * The following fields are required: + * ```java + * .attribute() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunStatsGroupBy]. */ + class Builder internal constructor() { + + private var attribute: JsonField<Attribute>? = null + private var maxGroups: JsonField<Long> = JsonMissing.of() + private var path: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(runStatsGroupBy: RunStatsGroupBy) = apply { + attribute = runStatsGroupBy.attribute + maxGroups = runStatsGroupBy.maxGroups + path = runStatsGroupBy.path + additionalProperties = runStatsGroupBy.additionalProperties.toMutableMap() + } + + fun attribute(attribute: Attribute) = attribute(JsonField.of(attribute)) + + /** + * Sets [Builder.attribute] to an arbitrary JSON value. + * + * You should usually call [Builder.attribute] with a well-typed [Attribute] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun attribute(attribute: JsonField<Attribute>) = apply { this.attribute = attribute } + + fun maxGroups(maxGroups: Long) = maxGroups(JsonField.of(maxGroups)) + + /** + * Sets [Builder.maxGroups] to an arbitrary JSON value. + * + * You should usually call [Builder.maxGroups] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun maxGroups(maxGroups: JsonField<Long>) = apply { this.maxGroups = maxGroups } + + fun path(path: String?) = path(JsonField.ofNullable(path)) + + /** Alias for calling [Builder.path] with `path.orElse(null)`. */ + fun path(path: Optional<String>) = path(path.getOrNull()) + + /** + * Sets [Builder.path] to an arbitrary JSON value. + * + * You should usually call [Builder.path] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun path(path: JsonField<String>) = apply { this.path = path } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RunStatsGroupBy]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .attribute() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RunStatsGroupBy = + RunStatsGroupBy( + checkRequired("attribute", attribute), + maxGroups, + path, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RunStatsGroupBy = apply { + if (validated) { + return@apply + } + + attribute().validate() + maxGroups() + path() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (attribute.asKnown().getOrNull()?.validity() ?: 0) + + (if (maxGroups.asKnown().isPresent) 1 else 0) + + (if (path.asKnown().isPresent) 1 else 0) + + class Attribute @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val NAME = of("name") + + @JvmField val RUN_TYPE = of("run_type") + + @JvmField val TAG = of("tag") + + @JvmField val METADATA = of("metadata") + + @JvmStatic fun of(value: String) = Attribute(JsonField.of(value)) + } + + /** An enum containing [Attribute]'s known values. */ + enum class Known { + NAME, + RUN_TYPE, + TAG, + METADATA, + } + + /** + * An enum containing [Attribute]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Attribute] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + NAME, + RUN_TYPE, + TAG, + METADATA, + /** + * An enum member indicating that [Attribute] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + NAME -> Value.NAME + RUN_TYPE -> Value.RUN_TYPE + TAG -> Value.TAG + METADATA -> Value.METADATA + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + NAME -> Known.NAME + RUN_TYPE -> Known.RUN_TYPE + TAG -> Known.TAG + METADATA -> Known.METADATA + else -> throw LangsmithApiInvalidDataException("Unknown Attribute: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Attribute = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Attribute && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunStatsGroupBy && + attribute == other.attribute && + maxGroups == other.maxGroups && + path == other.path && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(attribute, maxGroups, path, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RunStatsGroupBy{attribute=$attribute, maxGroups=$maxGroups, path=$path, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionCreateParams.kt new file mode 100644 index 00000000..32ae39a7 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionCreateParams.kt @@ -0,0 +1,947 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TraceTier +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create a new session. */ +class SessionCreateParams +private constructor( + private val upsert: Boolean?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun upsert(): Optional<Boolean> = Optional.ofNullable(upsert) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional<String> = body.id() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun defaultDatasetId(): Optional<String> = body.defaultDatasetId() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = body.description() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endTime(): Optional<OffsetDateTime> = body.endTime() + + fun _extra(): JsonValue = body._extra() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional<String> = body.name() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceDatasetId(): Optional<String> = body.referenceDatasetId() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun startTime(): Optional<OffsetDateTime> = body.startTime() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun traceTier(): Optional<TraceTier> = body.traceTier() + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _id(): JsonField<String> = body._id() + + /** + * Returns the raw JSON value of [defaultDatasetId]. + * + * Unlike [defaultDatasetId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _defaultDatasetId(): JsonField<String> = body._defaultDatasetId() + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _description(): JsonField<String> = body._description() + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _endTime(): JsonField<OffsetDateTime> = body._endTime() + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _name(): JsonField<String> = body._name() + + /** + * Returns the raw JSON value of [referenceDatasetId]. + * + * Unlike [referenceDatasetId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _referenceDatasetId(): JsonField<String> = body._referenceDatasetId() + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _startTime(): JsonField<OffsetDateTime> = body._startTime() + + /** + * Returns the raw JSON value of [traceTier]. + * + * Unlike [traceTier], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _traceTier(): JsonField<TraceTier> = body._traceTier() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): SessionCreateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [SessionCreateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SessionCreateParams]. */ + class Builder internal constructor() { + + private var upsert: Boolean? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(sessionCreateParams: SessionCreateParams) = apply { + upsert = sessionCreateParams.upsert + body = sessionCreateParams.body.toBuilder() + additionalHeaders = sessionCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = sessionCreateParams.additionalQueryParams.toBuilder() + } + + fun upsert(upsert: Boolean?) = apply { this.upsert = upsert } + + /** + * Alias for [Builder.upsert]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun upsert(upsert: Boolean) = upsert(upsert as Boolean?) + + /** Alias for calling [Builder.upsert] with `upsert.orElse(null)`. */ + fun upsert(upsert: Optional<Boolean>) = upsert(upsert.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [id] + * - [defaultDatasetId] + * - [description] + * - [endTime] + * - [extra] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun id(id: String?) = apply { body.id(id) } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<String>) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { body.id(id) } + + fun defaultDatasetId(defaultDatasetId: String?) = apply { + body.defaultDatasetId(defaultDatasetId) + } + + /** Alias for calling [Builder.defaultDatasetId] with `defaultDatasetId.orElse(null)`. */ + fun defaultDatasetId(defaultDatasetId: Optional<String>) = + defaultDatasetId(defaultDatasetId.getOrNull()) + + /** + * Sets [Builder.defaultDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultDatasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun defaultDatasetId(defaultDatasetId: JsonField<String>) = apply { + body.defaultDatasetId(defaultDatasetId) + } + + fun description(description: String?) = apply { body.description(description) } + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { body.description(description) } + + fun endTime(endTime: OffsetDateTime?) = apply { body.endTime(endTime) } + + /** Alias for calling [Builder.endTime] with `endTime.orElse(null)`. */ + fun endTime(endTime: Optional<OffsetDateTime>) = endTime(endTime.getOrNull()) + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endTime(endTime: JsonField<OffsetDateTime>) = apply { body.endTime(endTime) } + + fun extra(extra: JsonValue) = apply { body.extra(extra) } + + fun name(name: String) = apply { body.name(name) } + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { body.name(name) } + + fun referenceDatasetId(referenceDatasetId: String?) = apply { + body.referenceDatasetId(referenceDatasetId) + } + + /** + * Alias for calling [Builder.referenceDatasetId] with `referenceDatasetId.orElse(null)`. + */ + fun referenceDatasetId(referenceDatasetId: Optional<String>) = + referenceDatasetId(referenceDatasetId.getOrNull()) + + /** + * Sets [Builder.referenceDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceDatasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun referenceDatasetId(referenceDatasetId: JsonField<String>) = apply { + body.referenceDatasetId(referenceDatasetId) + } + + fun startTime(startTime: OffsetDateTime) = apply { body.startTime(startTime) } + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField<OffsetDateTime>) = apply { body.startTime(startTime) } + + fun traceTier(traceTier: TraceTier?) = apply { body.traceTier(traceTier) } + + /** Alias for calling [Builder.traceTier] with `traceTier.orElse(null)`. */ + fun traceTier(traceTier: Optional<TraceTier>) = traceTier(traceTier.getOrNull()) + + /** + * Sets [Builder.traceTier] to an arbitrary JSON value. + * + * You should usually call [Builder.traceTier] with a well-typed [TraceTier] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun traceTier(traceTier: JsonField<TraceTier>) = apply { body.traceTier(traceTier) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SessionCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SessionCreateParams = + SessionCreateParams( + upsert, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + upsert?.let { put("upsert", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + /** Create class for TracerSession. */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField<String>, + private val defaultDatasetId: JsonField<String>, + private val description: JsonField<String>, + private val endTime: JsonField<OffsetDateTime>, + private val extra: JsonValue, + private val name: JsonField<String>, + private val referenceDatasetId: JsonField<String>, + private val startTime: JsonField<OffsetDateTime>, + private val traceTier: JsonField<TraceTier>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("default_dataset_id") + @ExcludeMissing + defaultDatasetId: JsonField<String> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("end_time") + @ExcludeMissing + endTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("extra") @ExcludeMissing extra: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("reference_dataset_id") + @ExcludeMissing + referenceDatasetId: JsonField<String> = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("trace_tier") + @ExcludeMissing + traceTier: JsonField<TraceTier> = JsonMissing.of(), + ) : this( + id, + defaultDatasetId, + description, + endTime, + extra, + name, + referenceDatasetId, + startTime, + traceTier, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun defaultDatasetId(): Optional<String> = + defaultDatasetId.getOptional("default_dataset_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun endTime(): Optional<OffsetDateTime> = endTime.getOptional("end_time") + + @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonValue = extra + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun name(): Optional<String> = name.getOptional("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun referenceDatasetId(): Optional<String> = + referenceDatasetId.getOptional("reference_dataset_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun startTime(): Optional<OffsetDateTime> = startTime.getOptional("start_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun traceTier(): Optional<TraceTier> = traceTier.getOptional("trace_tier") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [defaultDatasetId]. + * + * Unlike [defaultDatasetId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("default_dataset_id") + @ExcludeMissing + fun _defaultDatasetId(): JsonField<String> = defaultDatasetId + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_time") + @ExcludeMissing + fun _endTime(): JsonField<OffsetDateTime> = endTime + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [referenceDatasetId]. + * + * Unlike [referenceDatasetId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_dataset_id") + @ExcludeMissing + fun _referenceDatasetId(): JsonField<String> = referenceDatasetId + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_time") + @ExcludeMissing + fun _startTime(): JsonField<OffsetDateTime> = startTime + + /** + * Returns the raw JSON value of [traceTier]. + * + * Unlike [traceTier], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trace_tier") + @ExcludeMissing + fun _traceTier(): JsonField<TraceTier> = traceTier + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var id: JsonField<String> = JsonMissing.of() + private var defaultDatasetId: JsonField<String> = JsonMissing.of() + private var description: JsonField<String> = JsonMissing.of() + private var endTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var extra: JsonValue = JsonMissing.of() + private var name: JsonField<String> = JsonMissing.of() + private var referenceDatasetId: JsonField<String> = JsonMissing.of() + private var startTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var traceTier: JsonField<TraceTier> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + id = body.id + defaultDatasetId = body.defaultDatasetId + description = body.description + endTime = body.endTime + extra = body.extra + name = body.name + referenceDatasetId = body.referenceDatasetId + startTime = body.startTime + traceTier = body.traceTier + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun id(id: String?) = id(JsonField.ofNullable(id)) + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<String>) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun defaultDatasetId(defaultDatasetId: String?) = + defaultDatasetId(JsonField.ofNullable(defaultDatasetId)) + + /** + * Alias for calling [Builder.defaultDatasetId] with `defaultDatasetId.orElse(null)`. + */ + fun defaultDatasetId(defaultDatasetId: Optional<String>) = + defaultDatasetId(defaultDatasetId.getOrNull()) + + /** + * Sets [Builder.defaultDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultDatasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun defaultDatasetId(defaultDatasetId: JsonField<String>) = apply { + this.defaultDatasetId = defaultDatasetId + } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField<String>) = apply { + this.description = description + } + + fun endTime(endTime: OffsetDateTime?) = endTime(JsonField.ofNullable(endTime)) + + /** Alias for calling [Builder.endTime] with `endTime.orElse(null)`. */ + fun endTime(endTime: Optional<OffsetDateTime>) = endTime(endTime.getOrNull()) + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endTime(endTime: JsonField<OffsetDateTime>) = apply { this.endTime = endTime } + + fun extra(extra: JsonValue) = apply { this.extra = extra } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun referenceDatasetId(referenceDatasetId: String?) = + referenceDatasetId(JsonField.ofNullable(referenceDatasetId)) + + /** + * Alias for calling [Builder.referenceDatasetId] with + * `referenceDatasetId.orElse(null)`. + */ + fun referenceDatasetId(referenceDatasetId: Optional<String>) = + referenceDatasetId(referenceDatasetId.getOrNull()) + + /** + * Sets [Builder.referenceDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceDatasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun referenceDatasetId(referenceDatasetId: JsonField<String>) = apply { + this.referenceDatasetId = referenceDatasetId + } + + fun startTime(startTime: OffsetDateTime) = startTime(JsonField.of(startTime)) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField<OffsetDateTime>) = apply { + this.startTime = startTime + } + + fun traceTier(traceTier: TraceTier?) = traceTier(JsonField.ofNullable(traceTier)) + + /** Alias for calling [Builder.traceTier] with `traceTier.orElse(null)`. */ + fun traceTier(traceTier: Optional<TraceTier>) = traceTier(traceTier.getOrNull()) + + /** + * Sets [Builder.traceTier] to an arbitrary JSON value. + * + * You should usually call [Builder.traceTier] with a well-typed [TraceTier] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun traceTier(traceTier: JsonField<TraceTier>) = apply { this.traceTier = traceTier } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = + Body( + id, + defaultDatasetId, + description, + endTime, + extra, + name, + referenceDatasetId, + startTime, + traceTier, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + id() + defaultDatasetId() + description() + endTime() + name() + referenceDatasetId() + startTime() + traceTier().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (defaultDatasetId.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endTime.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (referenceDatasetId.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + (traceTier.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + id == other.id && + defaultDatasetId == other.defaultDatasetId && + description == other.description && + endTime == other.endTime && + extra == other.extra && + name == other.name && + referenceDatasetId == other.referenceDatasetId && + startTime == other.startTime && + traceTier == other.traceTier && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + defaultDatasetId, + description, + endTime, + extra, + name, + referenceDatasetId, + startTime, + traceTier, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{id=$id, defaultDatasetId=$defaultDatasetId, description=$description, endTime=$endTime, extra=$extra, name=$name, referenceDatasetId=$referenceDatasetId, startTime=$startTime, traceTier=$traceTier, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SessionCreateParams && + upsert == other.upsert && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(upsert, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "SessionCreateParams{upsert=$upsert, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDashboardParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDashboardParams.kt new file mode 100644 index 00000000..25f4accc --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDashboardParams.kt @@ -0,0 +1,249 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get a prebuilt dashboard for a tracing project. */ +class SessionDashboardParams +private constructor( + private val sessionId: String?, + private val accept: String?, + private val customChartsSectionRequest: CustomChartsSectionRequest, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun sessionId(): Optional<String> = Optional.ofNullable(sessionId) + + fun accept(): Optional<String> = Optional.ofNullable(accept) + + fun customChartsSectionRequest(): CustomChartsSectionRequest = customChartsSectionRequest + + fun _additionalBodyProperties(): Map<String, JsonValue> = + customChartsSectionRequest._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SessionDashboardParams]. + * + * The following fields are required: + * ```java + * .customChartsSectionRequest() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SessionDashboardParams]. */ + class Builder internal constructor() { + + private var sessionId: String? = null + private var accept: String? = null + private var customChartsSectionRequest: CustomChartsSectionRequest? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(sessionDashboardParams: SessionDashboardParams) = apply { + sessionId = sessionDashboardParams.sessionId + accept = sessionDashboardParams.accept + customChartsSectionRequest = sessionDashboardParams.customChartsSectionRequest + additionalHeaders = sessionDashboardParams.additionalHeaders.toBuilder() + additionalQueryParams = sessionDashboardParams.additionalQueryParams.toBuilder() + } + + fun sessionId(sessionId: String?) = apply { this.sessionId = sessionId } + + /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ + fun sessionId(sessionId: Optional<String>) = sessionId(sessionId.getOrNull()) + + fun accept(accept: String?) = apply { this.accept = accept } + + /** Alias for calling [Builder.accept] with `accept.orElse(null)`. */ + fun accept(accept: Optional<String>) = accept(accept.getOrNull()) + + fun customChartsSectionRequest(customChartsSectionRequest: CustomChartsSectionRequest) = + apply { + this.customChartsSectionRequest = customChartsSectionRequest + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SessionDashboardParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .customChartsSectionRequest() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SessionDashboardParams = + SessionDashboardParams( + sessionId, + accept, + checkRequired("customChartsSectionRequest", customChartsSectionRequest), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): CustomChartsSectionRequest = customChartsSectionRequest + + fun _pathParam(index: Int): String = + when (index) { + 0 -> sessionId ?: "" + else -> "" + } + + override fun _headers(): Headers = + Headers.builder() + .apply { + accept?.let { put("accept", it) } + putAll(additionalHeaders) + } + .build() + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SessionDashboardParams && + sessionId == other.sessionId && + accept == other.accept && + customChartsSectionRequest == other.customChartsSectionRequest && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + sessionId, + accept, + customChartsSectionRequest, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "SessionDashboardParams{sessionId=$sessionId, accept=$accept, customChartsSectionRequest=$customChartsSectionRequest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDeleteAllParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDeleteAllParams.kt new file mode 100644 index 00000000..89daf712 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDeleteAllParams.kt @@ -0,0 +1,250 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional + +/** Delete a specific session. */ +class SessionDeleteAllParams +private constructor( + private val sessionIds: List<String>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun sessionIds(): List<String> = sessionIds + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SessionDeleteAllParams]. + * + * The following fields are required: + * ```java + * .sessionIds() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SessionDeleteAllParams]. */ + class Builder internal constructor() { + + private var sessionIds: MutableList<String>? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(sessionDeleteAllParams: SessionDeleteAllParams) = apply { + sessionIds = sessionDeleteAllParams.sessionIds.toMutableList() + additionalHeaders = sessionDeleteAllParams.additionalHeaders.toBuilder() + additionalQueryParams = sessionDeleteAllParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + sessionDeleteAllParams.additionalBodyProperties.toMutableMap() + } + + fun sessionIds(sessionIds: List<String>) = apply { + this.sessionIds = sessionIds.toMutableList() + } + + /** + * Adds a single [String] to [sessionIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSessionId(sessionId: String) = apply { + sessionIds = (sessionIds ?: mutableListOf()).apply { add(sessionId) } + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [SessionDeleteAllParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .sessionIds() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SessionDeleteAllParams = + SessionDeleteAllParams( + checkRequired("sessionIds", sessionIds).toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("session_ids", sessionIds.joinToString(",")) + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SessionDeleteAllParams && + sessionIds == other.sessionIds && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(sessionIds, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "SessionDeleteAllParams{sessionIds=$sessionIds, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDeleteAllResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDeleteAllResponse.kt new file mode 100644 index 00000000..f6b1b80d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDeleteAllResponse.kt @@ -0,0 +1,115 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class SessionDeleteAllResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [SessionDeleteAllResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SessionDeleteAllResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(sessionDeleteAllResponse: SessionDeleteAllResponse) = apply { + additionalProperties = sessionDeleteAllResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SessionDeleteAllResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SessionDeleteAllResponse = + SessionDeleteAllResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): SessionDeleteAllResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SessionDeleteAllResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "SessionDeleteAllResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDeleteParams.kt new file mode 100644 index 00000000..718e9101 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDeleteParams.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete a specific session. */ +class SessionDeleteParams +private constructor( + private val sessionId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun sessionId(): Optional<String> = Optional.ofNullable(sessionId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): SessionDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [SessionDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SessionDeleteParams]. */ + class Builder internal constructor() { + + private var sessionId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(sessionDeleteParams: SessionDeleteParams) = apply { + sessionId = sessionDeleteParams.sessionId + additionalHeaders = sessionDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = sessionDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = sessionDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun sessionId(sessionId: String?) = apply { this.sessionId = sessionId } + + /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ + fun sessionId(sessionId: Optional<String>) = sessionId(sessionId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [SessionDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SessionDeleteParams = + SessionDeleteParams( + sessionId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> sessionId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SessionDeleteParams && + sessionId == other.sessionId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(sessionId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "SessionDeleteParams{sessionId=$sessionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDeleteResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDeleteResponse.kt new file mode 100644 index 00000000..7f3a5fde --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDeleteResponse.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class SessionDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [SessionDeleteResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SessionDeleteResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(sessionDeleteResponse: SessionDeleteResponse) = apply { + additionalProperties = sessionDeleteResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SessionDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SessionDeleteResponse = + SessionDeleteResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): SessionDeleteResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SessionDeleteResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "SessionDeleteResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionListParams.kt new file mode 100644 index 00000000..ea83e9f4 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionListParams.kt @@ -0,0 +1,551 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get all sessions. */ +class SessionListParams +private constructor( + private val id: List<String>?, + private val datasetVersion: String?, + private val facets: Boolean?, + private val filter: String?, + private val includeStats: Boolean?, + private val limit: Long?, + private val metadata: String?, + private val name: String?, + private val nameContains: String?, + private val offset: Long?, + private val referenceDataset: List<String>?, + private val referenceFree: Boolean?, + private val sortBy: SessionSortableColumns?, + private val sortByDesc: Boolean?, + private val sortByFeedbackKey: String?, + private val statsStartTime: OffsetDateTime?, + private val tagValueId: List<String>?, + private val useApproxStats: Boolean?, + private val accept: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun id(): Optional<List<String>> = Optional.ofNullable(id) + + fun datasetVersion(): Optional<String> = Optional.ofNullable(datasetVersion) + + fun facets(): Optional<Boolean> = Optional.ofNullable(facets) + + fun filter(): Optional<String> = Optional.ofNullable(filter) + + fun includeStats(): Optional<Boolean> = Optional.ofNullable(includeStats) + + fun limit(): Optional<Long> = Optional.ofNullable(limit) + + fun metadata(): Optional<String> = Optional.ofNullable(metadata) + + fun name(): Optional<String> = Optional.ofNullable(name) + + fun nameContains(): Optional<String> = Optional.ofNullable(nameContains) + + fun offset(): Optional<Long> = Optional.ofNullable(offset) + + fun referenceDataset(): Optional<List<String>> = Optional.ofNullable(referenceDataset) + + fun referenceFree(): Optional<Boolean> = Optional.ofNullable(referenceFree) + + fun sortBy(): Optional<SessionSortableColumns> = Optional.ofNullable(sortBy) + + fun sortByDesc(): Optional<Boolean> = Optional.ofNullable(sortByDesc) + + fun sortByFeedbackKey(): Optional<String> = Optional.ofNullable(sortByFeedbackKey) + + fun statsStartTime(): Optional<OffsetDateTime> = Optional.ofNullable(statsStartTime) + + fun tagValueId(): Optional<List<String>> = Optional.ofNullable(tagValueId) + + fun useApproxStats(): Optional<Boolean> = Optional.ofNullable(useApproxStats) + + fun accept(): Optional<String> = Optional.ofNullable(accept) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): SessionListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [SessionListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SessionListParams]. */ + class Builder internal constructor() { + + private var id: MutableList<String>? = null + private var datasetVersion: String? = null + private var facets: Boolean? = null + private var filter: String? = null + private var includeStats: Boolean? = null + private var limit: Long? = null + private var metadata: String? = null + private var name: String? = null + private var nameContains: String? = null + private var offset: Long? = null + private var referenceDataset: MutableList<String>? = null + private var referenceFree: Boolean? = null + private var sortBy: SessionSortableColumns? = null + private var sortByDesc: Boolean? = null + private var sortByFeedbackKey: String? = null + private var statsStartTime: OffsetDateTime? = null + private var tagValueId: MutableList<String>? = null + private var useApproxStats: Boolean? = null + private var accept: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(sessionListParams: SessionListParams) = apply { + id = sessionListParams.id?.toMutableList() + datasetVersion = sessionListParams.datasetVersion + facets = sessionListParams.facets + filter = sessionListParams.filter + includeStats = sessionListParams.includeStats + limit = sessionListParams.limit + metadata = sessionListParams.metadata + name = sessionListParams.name + nameContains = sessionListParams.nameContains + offset = sessionListParams.offset + referenceDataset = sessionListParams.referenceDataset?.toMutableList() + referenceFree = sessionListParams.referenceFree + sortBy = sessionListParams.sortBy + sortByDesc = sessionListParams.sortByDesc + sortByFeedbackKey = sessionListParams.sortByFeedbackKey + statsStartTime = sessionListParams.statsStartTime + tagValueId = sessionListParams.tagValueId?.toMutableList() + useApproxStats = sessionListParams.useApproxStats + accept = sessionListParams.accept + additionalHeaders = sessionListParams.additionalHeaders.toBuilder() + additionalQueryParams = sessionListParams.additionalQueryParams.toBuilder() + } + + fun id(id: List<String>?) = apply { this.id = id?.toMutableList() } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<List<String>>) = id(id.getOrNull()) + + /** + * Adds a single [String] to [Builder.id]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addId(id: String) = apply { this.id = (this.id ?: mutableListOf()).apply { add(id) } } + + fun datasetVersion(datasetVersion: String?) = apply { this.datasetVersion = datasetVersion } + + /** Alias for calling [Builder.datasetVersion] with `datasetVersion.orElse(null)`. */ + fun datasetVersion(datasetVersion: Optional<String>) = + datasetVersion(datasetVersion.getOrNull()) + + fun facets(facets: Boolean?) = apply { this.facets = facets } + + /** + * Alias for [Builder.facets]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun facets(facets: Boolean) = facets(facets as Boolean?) + + /** Alias for calling [Builder.facets] with `facets.orElse(null)`. */ + fun facets(facets: Optional<Boolean>) = facets(facets.getOrNull()) + + fun filter(filter: String?) = apply { this.filter = filter } + + /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ + fun filter(filter: Optional<String>) = filter(filter.getOrNull()) + + fun includeStats(includeStats: Boolean?) = apply { this.includeStats = includeStats } + + /** + * Alias for [Builder.includeStats]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun includeStats(includeStats: Boolean) = includeStats(includeStats as Boolean?) + + /** Alias for calling [Builder.includeStats] with `includeStats.orElse(null)`. */ + fun includeStats(includeStats: Optional<Boolean>) = includeStats(includeStats.getOrNull()) + + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional<Long>) = limit(limit.getOrNull()) + + fun metadata(metadata: String?) = apply { this.metadata = metadata } + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional<String>) = metadata(metadata.getOrNull()) + + fun name(name: String?) = apply { this.name = name } + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional<String>) = name(name.getOrNull()) + + fun nameContains(nameContains: String?) = apply { this.nameContains = nameContains } + + /** Alias for calling [Builder.nameContains] with `nameContains.orElse(null)`. */ + fun nameContains(nameContains: Optional<String>) = nameContains(nameContains.getOrNull()) + + fun offset(offset: Long?) = apply { this.offset = offset } + + /** + * Alias for [Builder.offset]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun offset(offset: Long) = offset(offset as Long?) + + /** Alias for calling [Builder.offset] with `offset.orElse(null)`. */ + fun offset(offset: Optional<Long>) = offset(offset.getOrNull()) + + fun referenceDataset(referenceDataset: List<String>?) = apply { + this.referenceDataset = referenceDataset?.toMutableList() + } + + /** Alias for calling [Builder.referenceDataset] with `referenceDataset.orElse(null)`. */ + fun referenceDataset(referenceDataset: Optional<List<String>>) = + referenceDataset(referenceDataset.getOrNull()) + + /** + * Adds a single [String] to [Builder.referenceDataset]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addReferenceDataset(referenceDataset: String) = apply { + this.referenceDataset = + (this.referenceDataset ?: mutableListOf()).apply { add(referenceDataset) } + } + + fun referenceFree(referenceFree: Boolean?) = apply { this.referenceFree = referenceFree } + + /** + * Alias for [Builder.referenceFree]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun referenceFree(referenceFree: Boolean) = referenceFree(referenceFree as Boolean?) + + /** Alias for calling [Builder.referenceFree] with `referenceFree.orElse(null)`. */ + fun referenceFree(referenceFree: Optional<Boolean>) = + referenceFree(referenceFree.getOrNull()) + + fun sortBy(sortBy: SessionSortableColumns?) = apply { this.sortBy = sortBy } + + /** Alias for calling [Builder.sortBy] with `sortBy.orElse(null)`. */ + fun sortBy(sortBy: Optional<SessionSortableColumns>) = sortBy(sortBy.getOrNull()) + + fun sortByDesc(sortByDesc: Boolean?) = apply { this.sortByDesc = sortByDesc } + + /** + * Alias for [Builder.sortByDesc]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun sortByDesc(sortByDesc: Boolean) = sortByDesc(sortByDesc as Boolean?) + + /** Alias for calling [Builder.sortByDesc] with `sortByDesc.orElse(null)`. */ + fun sortByDesc(sortByDesc: Optional<Boolean>) = sortByDesc(sortByDesc.getOrNull()) + + fun sortByFeedbackKey(sortByFeedbackKey: String?) = apply { + this.sortByFeedbackKey = sortByFeedbackKey + } + + /** Alias for calling [Builder.sortByFeedbackKey] with `sortByFeedbackKey.orElse(null)`. */ + fun sortByFeedbackKey(sortByFeedbackKey: Optional<String>) = + sortByFeedbackKey(sortByFeedbackKey.getOrNull()) + + fun statsStartTime(statsStartTime: OffsetDateTime?) = apply { + this.statsStartTime = statsStartTime + } + + /** Alias for calling [Builder.statsStartTime] with `statsStartTime.orElse(null)`. */ + fun statsStartTime(statsStartTime: Optional<OffsetDateTime>) = + statsStartTime(statsStartTime.getOrNull()) + + fun tagValueId(tagValueId: List<String>?) = apply { + this.tagValueId = tagValueId?.toMutableList() + } + + /** Alias for calling [Builder.tagValueId] with `tagValueId.orElse(null)`. */ + fun tagValueId(tagValueId: Optional<List<String>>) = tagValueId(tagValueId.getOrNull()) + + /** + * Adds a single [String] to [Builder.tagValueId]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTagValueId(tagValueId: String) = apply { + this.tagValueId = (this.tagValueId ?: mutableListOf()).apply { add(tagValueId) } + } + + fun useApproxStats(useApproxStats: Boolean?) = apply { + this.useApproxStats = useApproxStats + } + + /** + * Alias for [Builder.useApproxStats]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun useApproxStats(useApproxStats: Boolean) = useApproxStats(useApproxStats as Boolean?) + + /** Alias for calling [Builder.useApproxStats] with `useApproxStats.orElse(null)`. */ + fun useApproxStats(useApproxStats: Optional<Boolean>) = + useApproxStats(useApproxStats.getOrNull()) + + fun accept(accept: String?) = apply { this.accept = accept } + + /** Alias for calling [Builder.accept] with `accept.orElse(null)`. */ + fun accept(accept: Optional<String>) = accept(accept.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SessionListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SessionListParams = + SessionListParams( + id?.toImmutable(), + datasetVersion, + facets, + filter, + includeStats, + limit, + metadata, + name, + nameContains, + offset, + referenceDataset?.toImmutable(), + referenceFree, + sortBy, + sortByDesc, + sortByFeedbackKey, + statsStartTime, + tagValueId?.toImmutable(), + useApproxStats, + accept, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = + Headers.builder() + .apply { + accept?.let { put("accept", it) } + putAll(additionalHeaders) + } + .build() + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + id?.let { put("id", it.joinToString(",")) } + datasetVersion?.let { put("dataset_version", it) } + facets?.let { put("facets", it.toString()) } + filter?.let { put("filter", it) } + includeStats?.let { put("include_stats", it.toString()) } + limit?.let { put("limit", it.toString()) } + metadata?.let { put("metadata", it) } + name?.let { put("name", it) } + nameContains?.let { put("name_contains", it) } + offset?.let { put("offset", it.toString()) } + referenceDataset?.let { put("reference_dataset", it.joinToString(",")) } + referenceFree?.let { put("reference_free", it.toString()) } + sortBy?.let { put("sort_by", it.toString()) } + sortByDesc?.let { put("sort_by_desc", it.toString()) } + sortByFeedbackKey?.let { put("sort_by_feedback_key", it) } + statsStartTime?.let { + put("stats_start_time", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + tagValueId?.let { put("tag_value_id", it.joinToString(",")) } + useApproxStats?.let { put("use_approx_stats", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SessionListParams && + id == other.id && + datasetVersion == other.datasetVersion && + facets == other.facets && + filter == other.filter && + includeStats == other.includeStats && + limit == other.limit && + metadata == other.metadata && + name == other.name && + nameContains == other.nameContains && + offset == other.offset && + referenceDataset == other.referenceDataset && + referenceFree == other.referenceFree && + sortBy == other.sortBy && + sortByDesc == other.sortByDesc && + sortByFeedbackKey == other.sortByFeedbackKey && + statsStartTime == other.statsStartTime && + tagValueId == other.tagValueId && + useApproxStats == other.useApproxStats && + accept == other.accept && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + id, + datasetVersion, + facets, + filter, + includeStats, + limit, + metadata, + name, + nameContains, + offset, + referenceDataset, + referenceFree, + sortBy, + sortByDesc, + sortByFeedbackKey, + statsStartTime, + tagValueId, + useApproxStats, + accept, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "SessionListParams{id=$id, datasetVersion=$datasetVersion, facets=$facets, filter=$filter, includeStats=$includeStats, limit=$limit, metadata=$metadata, name=$name, nameContains=$nameContains, offset=$offset, referenceDataset=$referenceDataset, referenceFree=$referenceFree, sortBy=$sortBy, sortByDesc=$sortByDesc, sortByFeedbackKey=$sortByFeedbackKey, statsStartTime=$statsStartTime, tagValueId=$tagValueId, useApproxStats=$useApproxStats, accept=$accept, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionRetrieveMetadataParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionRetrieveMetadataParams.kt new file mode 100644 index 00000000..006307ad --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionRetrieveMetadataParams.kt @@ -0,0 +1,296 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Given a session, a number K, and (optionally) a list of metadata keys, return the top K values + * for each key. + */ +class SessionRetrieveMetadataParams +private constructor( + private val sessionId: String?, + private val k: Long?, + private val metadataKeys: List<String>?, + private val rootRunsOnly: Boolean?, + private val startTime: OffsetDateTime?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun sessionId(): Optional<String> = Optional.ofNullable(sessionId) + + fun k(): Optional<Long> = Optional.ofNullable(k) + + fun metadataKeys(): Optional<List<String>> = Optional.ofNullable(metadataKeys) + + fun rootRunsOnly(): Optional<Boolean> = Optional.ofNullable(rootRunsOnly) + + fun startTime(): Optional<OffsetDateTime> = Optional.ofNullable(startTime) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): SessionRetrieveMetadataParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [SessionRetrieveMetadataParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SessionRetrieveMetadataParams]. */ + class Builder internal constructor() { + + private var sessionId: String? = null + private var k: Long? = null + private var metadataKeys: MutableList<String>? = null + private var rootRunsOnly: Boolean? = null + private var startTime: OffsetDateTime? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(sessionRetrieveMetadataParams: SessionRetrieveMetadataParams) = apply { + sessionId = sessionRetrieveMetadataParams.sessionId + k = sessionRetrieveMetadataParams.k + metadataKeys = sessionRetrieveMetadataParams.metadataKeys?.toMutableList() + rootRunsOnly = sessionRetrieveMetadataParams.rootRunsOnly + startTime = sessionRetrieveMetadataParams.startTime + additionalHeaders = sessionRetrieveMetadataParams.additionalHeaders.toBuilder() + additionalQueryParams = sessionRetrieveMetadataParams.additionalQueryParams.toBuilder() + } + + fun sessionId(sessionId: String?) = apply { this.sessionId = sessionId } + + /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ + fun sessionId(sessionId: Optional<String>) = sessionId(sessionId.getOrNull()) + + fun k(k: Long?) = apply { this.k = k } + + /** + * Alias for [Builder.k]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun k(k: Long) = k(k as Long?) + + /** Alias for calling [Builder.k] with `k.orElse(null)`. */ + fun k(k: Optional<Long>) = k(k.getOrNull()) + + fun metadataKeys(metadataKeys: List<String>?) = apply { + this.metadataKeys = metadataKeys?.toMutableList() + } + + /** Alias for calling [Builder.metadataKeys] with `metadataKeys.orElse(null)`. */ + fun metadataKeys(metadataKeys: Optional<List<String>>) = + metadataKeys(metadataKeys.getOrNull()) + + /** + * Adds a single [String] to [metadataKeys]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMetadataKey(metadataKey: String) = apply { + metadataKeys = (metadataKeys ?: mutableListOf()).apply { add(metadataKey) } + } + + fun rootRunsOnly(rootRunsOnly: Boolean?) = apply { this.rootRunsOnly = rootRunsOnly } + + /** + * Alias for [Builder.rootRunsOnly]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun rootRunsOnly(rootRunsOnly: Boolean) = rootRunsOnly(rootRunsOnly as Boolean?) + + /** Alias for calling [Builder.rootRunsOnly] with `rootRunsOnly.orElse(null)`. */ + fun rootRunsOnly(rootRunsOnly: Optional<Boolean>) = rootRunsOnly(rootRunsOnly.getOrNull()) + + fun startTime(startTime: OffsetDateTime?) = apply { this.startTime = startTime } + + /** Alias for calling [Builder.startTime] with `startTime.orElse(null)`. */ + fun startTime(startTime: Optional<OffsetDateTime>) = startTime(startTime.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SessionRetrieveMetadataParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SessionRetrieveMetadataParams = + SessionRetrieveMetadataParams( + sessionId, + k, + metadataKeys?.toImmutable(), + rootRunsOnly, + startTime, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> sessionId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + k?.let { put("k", it.toString()) } + metadataKeys?.let { put("metadata_keys", it.joinToString(",")) } + rootRunsOnly?.let { put("root_runs_only", it.toString()) } + startTime?.let { + put("start_time", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SessionRetrieveMetadataParams && + sessionId == other.sessionId && + k == other.k && + metadataKeys == other.metadataKeys && + rootRunsOnly == other.rootRunsOnly && + startTime == other.startTime && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + sessionId, + k, + metadataKeys, + rootRunsOnly, + startTime, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "SessionRetrieveMetadataParams{sessionId=$sessionId, k=$k, metadataKeys=$metadataKeys, rootRunsOnly=$rootRunsOnly, startTime=$startTime, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionRetrieveMetadataResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionRetrieveMetadataResponse.kt new file mode 100644 index 00000000..1d5cb031 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionRetrieveMetadataResponse.kt @@ -0,0 +1,117 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Objects + +class SessionRetrieveMetadataResponse +@JsonCreator +private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> +) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SessionRetrieveMetadataResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SessionRetrieveMetadataResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(sessionRetrieveMetadataResponse: SessionRetrieveMetadataResponse) = + apply { + additionalProperties = + sessionRetrieveMetadataResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SessionRetrieveMetadataResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SessionRetrieveMetadataResponse = + SessionRetrieveMetadataResponse(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): SessionRetrieveMetadataResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SessionRetrieveMetadataResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SessionRetrieveMetadataResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionRetrieveParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionRetrieveParams.kt new file mode 100644 index 00000000..a26164d6 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionRetrieveParams.kt @@ -0,0 +1,264 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get a specific session. */ +class SessionRetrieveParams +private constructor( + private val sessionId: String?, + private val includeStats: Boolean?, + private val statsStartTime: OffsetDateTime?, + private val accept: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun sessionId(): Optional<String> = Optional.ofNullable(sessionId) + + fun includeStats(): Optional<Boolean> = Optional.ofNullable(includeStats) + + fun statsStartTime(): Optional<OffsetDateTime> = Optional.ofNullable(statsStartTime) + + fun accept(): Optional<String> = Optional.ofNullable(accept) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): SessionRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [SessionRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SessionRetrieveParams]. */ + class Builder internal constructor() { + + private var sessionId: String? = null + private var includeStats: Boolean? = null + private var statsStartTime: OffsetDateTime? = null + private var accept: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(sessionRetrieveParams: SessionRetrieveParams) = apply { + sessionId = sessionRetrieveParams.sessionId + includeStats = sessionRetrieveParams.includeStats + statsStartTime = sessionRetrieveParams.statsStartTime + accept = sessionRetrieveParams.accept + additionalHeaders = sessionRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = sessionRetrieveParams.additionalQueryParams.toBuilder() + } + + fun sessionId(sessionId: String?) = apply { this.sessionId = sessionId } + + /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ + fun sessionId(sessionId: Optional<String>) = sessionId(sessionId.getOrNull()) + + fun includeStats(includeStats: Boolean?) = apply { this.includeStats = includeStats } + + /** + * Alias for [Builder.includeStats]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun includeStats(includeStats: Boolean) = includeStats(includeStats as Boolean?) + + /** Alias for calling [Builder.includeStats] with `includeStats.orElse(null)`. */ + fun includeStats(includeStats: Optional<Boolean>) = includeStats(includeStats.getOrNull()) + + fun statsStartTime(statsStartTime: OffsetDateTime?) = apply { + this.statsStartTime = statsStartTime + } + + /** Alias for calling [Builder.statsStartTime] with `statsStartTime.orElse(null)`. */ + fun statsStartTime(statsStartTime: Optional<OffsetDateTime>) = + statsStartTime(statsStartTime.getOrNull()) + + fun accept(accept: String?) = apply { this.accept = accept } + + /** Alias for calling [Builder.accept] with `accept.orElse(null)`. */ + fun accept(accept: Optional<String>) = accept(accept.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SessionRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SessionRetrieveParams = + SessionRetrieveParams( + sessionId, + includeStats, + statsStartTime, + accept, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> sessionId ?: "" + else -> "" + } + + override fun _headers(): Headers = + Headers.builder() + .apply { + accept?.let { put("accept", it) } + putAll(additionalHeaders) + } + .build() + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + includeStats?.let { put("include_stats", it.toString()) } + statsStartTime?.let { + put("stats_start_time", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SessionRetrieveParams && + sessionId == other.sessionId && + includeStats == other.includeStats && + statsStartTime == other.statsStartTime && + accept == other.accept && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + sessionId, + includeStats, + statsStartTime, + accept, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "SessionRetrieveParams{sessionId=$sessionId, includeStats=$includeStats, statsStartTime=$statsStartTime, accept=$accept, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionSortableColumns.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionSortableColumns.kt new file mode 100644 index 00000000..8b97c2e1 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionSortableColumns.kt @@ -0,0 +1,174 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions + +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException + +class SessionSortableColumns +@JsonCreator +private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't match + * any known member, and you want to know that value. For example, if the SDK is on an older + * version than the API, then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val NAME = of("name") + + @JvmField val START_TIME = of("start_time") + + @JvmField val LAST_RUN_START_TIME = of("last_run_start_time") + + @JvmField val LATENCY_P50 = of("latency_p50") + + @JvmField val LATENCY_P99 = of("latency_p99") + + @JvmField val ERROR_RATE = of("error_rate") + + @JvmField val FEEDBACK = of("feedback") + + @JvmField val RUNS_COUNT = of("runs_count") + + @JvmStatic fun of(value: String) = SessionSortableColumns(JsonField.of(value)) + } + + /** An enum containing [SessionSortableColumns]'s known values. */ + enum class Known { + NAME, + START_TIME, + LAST_RUN_START_TIME, + LATENCY_P50, + LATENCY_P99, + ERROR_RATE, + FEEDBACK, + RUNS_COUNT, + } + + /** + * An enum containing [SessionSortableColumns]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [SessionSortableColumns] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the SDK + * is on an older version than the API, then the API may respond with new members that the SDK + * is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + NAME, + START_TIME, + LAST_RUN_START_TIME, + LATENCY_P50, + LATENCY_P99, + ERROR_RATE, + FEEDBACK, + RUNS_COUNT, + /** + * An enum member indicating that [SessionSortableColumns] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if + * the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want to + * throw for the unknown case. + */ + fun value(): Value = + when (this) { + NAME -> Value.NAME + START_TIME -> Value.START_TIME + LAST_RUN_START_TIME -> Value.LAST_RUN_START_TIME + LATENCY_P50 -> Value.LATENCY_P50 + LATENCY_P99 -> Value.LATENCY_P99 + ERROR_RATE -> Value.ERROR_RATE + FEEDBACK -> Value.FEEDBACK + RUNS_COUNT -> Value.RUNS_COUNT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't want + * to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + NAME -> Known.NAME + START_TIME -> Known.START_TIME + LAST_RUN_START_TIME -> Known.LAST_RUN_START_TIME + LATENCY_P50 -> Known.LATENCY_P50 + LATENCY_P99 -> Known.LATENCY_P99 + ERROR_RATE -> Known.ERROR_RATE + FEEDBACK -> Known.FEEDBACK + RUNS_COUNT -> Known.RUNS_COUNT + else -> throw LangsmithApiInvalidDataException("Unknown SessionSortableColumns: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): SessionSortableColumns = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SessionSortableColumns && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionUpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionUpdateParams.kt new file mode 100644 index 00000000..4a1460f2 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionUpdateParams.kt @@ -0,0 +1,726 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TraceTier +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create a new session. */ +class SessionUpdateParams +private constructor( + private val sessionId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun sessionId(): Optional<String> = Optional.ofNullable(sessionId) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun defaultDatasetId(): Optional<String> = body.defaultDatasetId() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = body.description() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endTime(): Optional<OffsetDateTime> = body.endTime() + + fun _extra(): JsonValue = body._extra() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional<String> = body.name() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun traceTier(): Optional<TraceTier> = body.traceTier() + + /** + * Returns the raw JSON value of [defaultDatasetId]. + * + * Unlike [defaultDatasetId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _defaultDatasetId(): JsonField<String> = body._defaultDatasetId() + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _description(): JsonField<String> = body._description() + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _endTime(): JsonField<OffsetDateTime> = body._endTime() + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _name(): JsonField<String> = body._name() + + /** + * Returns the raw JSON value of [traceTier]. + * + * Unlike [traceTier], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _traceTier(): JsonField<TraceTier> = body._traceTier() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): SessionUpdateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [SessionUpdateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SessionUpdateParams]. */ + class Builder internal constructor() { + + private var sessionId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(sessionUpdateParams: SessionUpdateParams) = apply { + sessionId = sessionUpdateParams.sessionId + body = sessionUpdateParams.body.toBuilder() + additionalHeaders = sessionUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = sessionUpdateParams.additionalQueryParams.toBuilder() + } + + fun sessionId(sessionId: String?) = apply { this.sessionId = sessionId } + + /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ + fun sessionId(sessionId: Optional<String>) = sessionId(sessionId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [defaultDatasetId] + * - [description] + * - [endTime] + * - [extra] + * - [name] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun defaultDatasetId(defaultDatasetId: String?) = apply { + body.defaultDatasetId(defaultDatasetId) + } + + /** Alias for calling [Builder.defaultDatasetId] with `defaultDatasetId.orElse(null)`. */ + fun defaultDatasetId(defaultDatasetId: Optional<String>) = + defaultDatasetId(defaultDatasetId.getOrNull()) + + /** + * Sets [Builder.defaultDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultDatasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun defaultDatasetId(defaultDatasetId: JsonField<String>) = apply { + body.defaultDatasetId(defaultDatasetId) + } + + fun description(description: String?) = apply { body.description(description) } + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { body.description(description) } + + fun endTime(endTime: OffsetDateTime?) = apply { body.endTime(endTime) } + + /** Alias for calling [Builder.endTime] with `endTime.orElse(null)`. */ + fun endTime(endTime: Optional<OffsetDateTime>) = endTime(endTime.getOrNull()) + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endTime(endTime: JsonField<OffsetDateTime>) = apply { body.endTime(endTime) } + + fun extra(extra: JsonValue) = apply { body.extra(extra) } + + fun name(name: String?) = apply { body.name(name) } + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional<String>) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { body.name(name) } + + fun traceTier(traceTier: TraceTier?) = apply { body.traceTier(traceTier) } + + /** Alias for calling [Builder.traceTier] with `traceTier.orElse(null)`. */ + fun traceTier(traceTier: Optional<TraceTier>) = traceTier(traceTier.getOrNull()) + + /** + * Sets [Builder.traceTier] to an arbitrary JSON value. + * + * You should usually call [Builder.traceTier] with a well-typed [TraceTier] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun traceTier(traceTier: JsonField<TraceTier>) = apply { body.traceTier(traceTier) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SessionUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SessionUpdateParams = + SessionUpdateParams( + sessionId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> sessionId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Update class for TracerSession. */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val defaultDatasetId: JsonField<String>, + private val description: JsonField<String>, + private val endTime: JsonField<OffsetDateTime>, + private val extra: JsonValue, + private val name: JsonField<String>, + private val traceTier: JsonField<TraceTier>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("default_dataset_id") + @ExcludeMissing + defaultDatasetId: JsonField<String> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("end_time") + @ExcludeMissing + endTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("extra") @ExcludeMissing extra: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("trace_tier") + @ExcludeMissing + traceTier: JsonField<TraceTier> = JsonMissing.of(), + ) : this(defaultDatasetId, description, endTime, extra, name, traceTier, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun defaultDatasetId(): Optional<String> = + defaultDatasetId.getOptional("default_dataset_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun endTime(): Optional<OffsetDateTime> = endTime.getOptional("end_time") + + @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonValue = extra + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun name(): Optional<String> = name.getOptional("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun traceTier(): Optional<TraceTier> = traceTier.getOptional("trace_tier") + + /** + * Returns the raw JSON value of [defaultDatasetId]. + * + * Unlike [defaultDatasetId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("default_dataset_id") + @ExcludeMissing + fun _defaultDatasetId(): JsonField<String> = defaultDatasetId + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_time") + @ExcludeMissing + fun _endTime(): JsonField<OffsetDateTime> = endTime + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [traceTier]. + * + * Unlike [traceTier], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trace_tier") + @ExcludeMissing + fun _traceTier(): JsonField<TraceTier> = traceTier + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var defaultDatasetId: JsonField<String> = JsonMissing.of() + private var description: JsonField<String> = JsonMissing.of() + private var endTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var extra: JsonValue = JsonMissing.of() + private var name: JsonField<String> = JsonMissing.of() + private var traceTier: JsonField<TraceTier> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + defaultDatasetId = body.defaultDatasetId + description = body.description + endTime = body.endTime + extra = body.extra + name = body.name + traceTier = body.traceTier + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun defaultDatasetId(defaultDatasetId: String?) = + defaultDatasetId(JsonField.ofNullable(defaultDatasetId)) + + /** + * Alias for calling [Builder.defaultDatasetId] with `defaultDatasetId.orElse(null)`. + */ + fun defaultDatasetId(defaultDatasetId: Optional<String>) = + defaultDatasetId(defaultDatasetId.getOrNull()) + + /** + * Sets [Builder.defaultDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultDatasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun defaultDatasetId(defaultDatasetId: JsonField<String>) = apply { + this.defaultDatasetId = defaultDatasetId + } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField<String>) = apply { + this.description = description + } + + fun endTime(endTime: OffsetDateTime?) = endTime(JsonField.ofNullable(endTime)) + + /** Alias for calling [Builder.endTime] with `endTime.orElse(null)`. */ + fun endTime(endTime: Optional<OffsetDateTime>) = endTime(endTime.getOrNull()) + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endTime(endTime: JsonField<OffsetDateTime>) = apply { this.endTime = endTime } + + fun extra(extra: JsonValue) = apply { this.extra = extra } + + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional<String>) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun traceTier(traceTier: TraceTier?) = traceTier(JsonField.ofNullable(traceTier)) + + /** Alias for calling [Builder.traceTier] with `traceTier.orElse(null)`. */ + fun traceTier(traceTier: Optional<TraceTier>) = traceTier(traceTier.getOrNull()) + + /** + * Sets [Builder.traceTier] to an arbitrary JSON value. + * + * You should usually call [Builder.traceTier] with a well-typed [TraceTier] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun traceTier(traceTier: JsonField<TraceTier>) = apply { this.traceTier = traceTier } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = + Body( + defaultDatasetId, + description, + endTime, + extra, + name, + traceTier, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + defaultDatasetId() + description() + endTime() + name() + traceTier().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (defaultDatasetId.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endTime.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (traceTier.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + defaultDatasetId == other.defaultDatasetId && + description == other.description && + endTime == other.endTime && + extra == other.extra && + name == other.name && + traceTier == other.traceTier && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + defaultDatasetId, + description, + endTime, + extra, + name, + traceTier, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{defaultDatasetId=$defaultDatasetId, description=$description, endTime=$endTime, extra=$extra, name=$name, traceTier=$traceTier, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SessionUpdateParams && + sessionId == other.sessionId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(sessionId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "SessionUpdateParams{sessionId=$sessionId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/TimedeltaInput.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/TimedeltaInput.kt new file mode 100644 index 00000000..faef52b1 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/TimedeltaInput.kt @@ -0,0 +1,216 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional + +/** Timedelta input. */ +class TimedeltaInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val days: JsonField<Long>, + private val hours: JsonField<Long>, + private val minutes: JsonField<Long>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("days") @ExcludeMissing days: JsonField<Long> = JsonMissing.of(), + @JsonProperty("hours") @ExcludeMissing hours: JsonField<Long> = JsonMissing.of(), + @JsonProperty("minutes") @ExcludeMissing minutes: JsonField<Long> = JsonMissing.of(), + ) : this(days, hours, minutes, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun days(): Optional<Long> = days.getOptional("days") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun hours(): Optional<Long> = hours.getOptional("hours") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun minutes(): Optional<Long> = minutes.getOptional("minutes") + + /** + * Returns the raw JSON value of [days]. + * + * Unlike [days], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("days") @ExcludeMissing fun _days(): JsonField<Long> = days + + /** + * Returns the raw JSON value of [hours]. + * + * Unlike [hours], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("hours") @ExcludeMissing fun _hours(): JsonField<Long> = hours + + /** + * Returns the raw JSON value of [minutes]. + * + * Unlike [minutes], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("minutes") @ExcludeMissing fun _minutes(): JsonField<Long> = minutes + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [TimedeltaInput]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TimedeltaInput]. */ + class Builder internal constructor() { + + private var days: JsonField<Long> = JsonMissing.of() + private var hours: JsonField<Long> = JsonMissing.of() + private var minutes: JsonField<Long> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(timedeltaInput: TimedeltaInput) = apply { + days = timedeltaInput.days + hours = timedeltaInput.hours + minutes = timedeltaInput.minutes + additionalProperties = timedeltaInput.additionalProperties.toMutableMap() + } + + fun days(days: Long) = days(JsonField.of(days)) + + /** + * Sets [Builder.days] to an arbitrary JSON value. + * + * You should usually call [Builder.days] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun days(days: JsonField<Long>) = apply { this.days = days } + + fun hours(hours: Long) = hours(JsonField.of(hours)) + + /** + * Sets [Builder.hours] to an arbitrary JSON value. + * + * You should usually call [Builder.hours] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun hours(hours: JsonField<Long>) = apply { this.hours = hours } + + fun minutes(minutes: Long) = minutes(JsonField.of(minutes)) + + /** + * Sets [Builder.minutes] to an arbitrary JSON value. + * + * You should usually call [Builder.minutes] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun minutes(minutes: JsonField<Long>) = apply { this.minutes = minutes } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TimedeltaInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TimedeltaInput = + TimedeltaInput(days, hours, minutes, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): TimedeltaInput = apply { + if (validated) { + return@apply + } + + days() + hours() + minutes() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (days.asKnown().isPresent) 1 else 0) + + (if (hours.asKnown().isPresent) 1 else 0) + + (if (minutes.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TimedeltaInput && + days == other.days && + hours == other.hours && + minutes == other.minutes && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(days, hours, minutes, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TimedeltaInput{days=$days, hours=$hours, minutes=$minutes, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/TracerSession.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/TracerSession.kt new file mode 100644 index 00000000..cc054f41 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/TracerSession.kt @@ -0,0 +1,1352 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TraceTier +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** TracerSession schema. */ +class TracerSession +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val tenantId: JsonField<String>, + private val completionCost: JsonField<String>, + private val completionTokens: JsonField<Long>, + private val defaultDatasetId: JsonField<String>, + private val description: JsonField<String>, + private val endTime: JsonField<OffsetDateTime>, + private val errorRate: JsonField<Double>, + private val extra: JsonValue, + private val feedbackStats: JsonValue, + private val firstTokenP50: JsonField<Double>, + private val firstTokenP99: JsonField<Double>, + private val lastRunStartTime: JsonField<OffsetDateTime>, + private val lastRunStartTimeLive: JsonField<OffsetDateTime>, + private val latencyP50: JsonField<Double>, + private val latencyP99: JsonField<Double>, + private val name: JsonField<String>, + private val promptCost: JsonField<String>, + private val promptTokens: JsonField<Long>, + private val referenceDatasetId: JsonField<String>, + private val runCount: JsonField<Long>, + private val runFacets: JsonField<List<JsonValue>>, + private val sessionFeedbackStats: JsonValue, + private val startTime: JsonField<OffsetDateTime>, + private val streamingRate: JsonField<Double>, + private val testRunNumber: JsonField<Long>, + private val totalCost: JsonField<String>, + private val totalTokens: JsonField<Long>, + private val traceTier: JsonField<TraceTier>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("tenant_id") @ExcludeMissing tenantId: JsonField<String> = JsonMissing.of(), + @JsonProperty("completion_cost") + @ExcludeMissing + completionCost: JsonField<String> = JsonMissing.of(), + @JsonProperty("completion_tokens") + @ExcludeMissing + completionTokens: JsonField<Long> = JsonMissing.of(), + @JsonProperty("default_dataset_id") + @ExcludeMissing + defaultDatasetId: JsonField<String> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("end_time") + @ExcludeMissing + endTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("error_rate") @ExcludeMissing errorRate: JsonField<Double> = JsonMissing.of(), + @JsonProperty("extra") @ExcludeMissing extra: JsonValue = JsonMissing.of(), + @JsonProperty("feedback_stats") @ExcludeMissing feedbackStats: JsonValue = JsonMissing.of(), + @JsonProperty("first_token_p50") + @ExcludeMissing + firstTokenP50: JsonField<Double> = JsonMissing.of(), + @JsonProperty("first_token_p99") + @ExcludeMissing + firstTokenP99: JsonField<Double> = JsonMissing.of(), + @JsonProperty("last_run_start_time") + @ExcludeMissing + lastRunStartTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("last_run_start_time_live") + @ExcludeMissing + lastRunStartTimeLive: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("latency_p50") + @ExcludeMissing + latencyP50: JsonField<Double> = JsonMissing.of(), + @JsonProperty("latency_p99") + @ExcludeMissing + latencyP99: JsonField<Double> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("prompt_cost") + @ExcludeMissing + promptCost: JsonField<String> = JsonMissing.of(), + @JsonProperty("prompt_tokens") + @ExcludeMissing + promptTokens: JsonField<Long> = JsonMissing.of(), + @JsonProperty("reference_dataset_id") + @ExcludeMissing + referenceDatasetId: JsonField<String> = JsonMissing.of(), + @JsonProperty("run_count") @ExcludeMissing runCount: JsonField<Long> = JsonMissing.of(), + @JsonProperty("run_facets") + @ExcludeMissing + runFacets: JsonField<List<JsonValue>> = JsonMissing.of(), + @JsonProperty("session_feedback_stats") + @ExcludeMissing + sessionFeedbackStats: JsonValue = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("streaming_rate") + @ExcludeMissing + streamingRate: JsonField<Double> = JsonMissing.of(), + @JsonProperty("test_run_number") + @ExcludeMissing + testRunNumber: JsonField<Long> = JsonMissing.of(), + @JsonProperty("total_cost") @ExcludeMissing totalCost: JsonField<String> = JsonMissing.of(), + @JsonProperty("total_tokens") + @ExcludeMissing + totalTokens: JsonField<Long> = JsonMissing.of(), + @JsonProperty("trace_tier") + @ExcludeMissing + traceTier: JsonField<TraceTier> = JsonMissing.of(), + ) : this( + id, + tenantId, + completionCost, + completionTokens, + defaultDatasetId, + description, + endTime, + errorRate, + extra, + feedbackStats, + firstTokenP50, + firstTokenP99, + lastRunStartTime, + lastRunStartTimeLive, + latencyP50, + latencyP99, + name, + promptCost, + promptTokens, + referenceDatasetId, + runCount, + runFacets, + sessionFeedbackStats, + startTime, + streamingRate, + testRunNumber, + totalCost, + totalTokens, + traceTier, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tenantId(): String = tenantId.getRequired("tenant_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun completionCost(): Optional<String> = completionCost.getOptional("completion_cost") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun completionTokens(): Optional<Long> = completionTokens.getOptional("completion_tokens") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun defaultDatasetId(): Optional<String> = defaultDatasetId.getOptional("default_dataset_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endTime(): Optional<OffsetDateTime> = endTime.getOptional("end_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun errorRate(): Optional<Double> = errorRate.getOptional("error_rate") + + @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonValue = extra + + @JsonProperty("feedback_stats") @ExcludeMissing fun _feedbackStats(): JsonValue = feedbackStats + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun firstTokenP50(): Optional<Double> = firstTokenP50.getOptional("first_token_p50") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun firstTokenP99(): Optional<Double> = firstTokenP99.getOptional("first_token_p99") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun lastRunStartTime(): Optional<OffsetDateTime> = + lastRunStartTime.getOptional("last_run_start_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun lastRunStartTimeLive(): Optional<OffsetDateTime> = + lastRunStartTimeLive.getOptional("last_run_start_time_live") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun latencyP50(): Optional<Double> = latencyP50.getOptional("latency_p50") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun latencyP99(): Optional<Double> = latencyP99.getOptional("latency_p99") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional<String> = name.getOptional("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun promptCost(): Optional<String> = promptCost.getOptional("prompt_cost") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun promptTokens(): Optional<Long> = promptTokens.getOptional("prompt_tokens") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceDatasetId(): Optional<String> = + referenceDatasetId.getOptional("reference_dataset_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun runCount(): Optional<Long> = runCount.getOptional("run_count") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun runFacets(): Optional<List<JsonValue>> = runFacets.getOptional("run_facets") + + @JsonProperty("session_feedback_stats") + @ExcludeMissing + fun _sessionFeedbackStats(): JsonValue = sessionFeedbackStats + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun startTime(): Optional<OffsetDateTime> = startTime.getOptional("start_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun streamingRate(): Optional<Double> = streamingRate.getOptional("streaming_rate") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun testRunNumber(): Optional<Long> = testRunNumber.getOptional("test_run_number") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun totalCost(): Optional<String> = totalCost.getOptional("total_cost") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun totalTokens(): Optional<Long> = totalTokens.getOptional("total_tokens") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun traceTier(): Optional<TraceTier> = traceTier.getOptional("trace_tier") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_id") @ExcludeMissing fun _tenantId(): JsonField<String> = tenantId + + /** + * Returns the raw JSON value of [completionCost]. + * + * Unlike [completionCost], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("completion_cost") + @ExcludeMissing + fun _completionCost(): JsonField<String> = completionCost + + /** + * Returns the raw JSON value of [completionTokens]. + * + * Unlike [completionTokens], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("completion_tokens") + @ExcludeMissing + fun _completionTokens(): JsonField<Long> = completionTokens + + /** + * Returns the raw JSON value of [defaultDatasetId]. + * + * Unlike [defaultDatasetId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("default_dataset_id") + @ExcludeMissing + fun _defaultDatasetId(): JsonField<String> = defaultDatasetId + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_time") @ExcludeMissing fun _endTime(): JsonField<OffsetDateTime> = endTime + + /** + * Returns the raw JSON value of [errorRate]. + * + * Unlike [errorRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("error_rate") @ExcludeMissing fun _errorRate(): JsonField<Double> = errorRate + + /** + * Returns the raw JSON value of [firstTokenP50]. + * + * Unlike [firstTokenP50], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("first_token_p50") + @ExcludeMissing + fun _firstTokenP50(): JsonField<Double> = firstTokenP50 + + /** + * Returns the raw JSON value of [firstTokenP99]. + * + * Unlike [firstTokenP99], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("first_token_p99") + @ExcludeMissing + fun _firstTokenP99(): JsonField<Double> = firstTokenP99 + + /** + * Returns the raw JSON value of [lastRunStartTime]. + * + * Unlike [lastRunStartTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("last_run_start_time") + @ExcludeMissing + fun _lastRunStartTime(): JsonField<OffsetDateTime> = lastRunStartTime + + /** + * Returns the raw JSON value of [lastRunStartTimeLive]. + * + * Unlike [lastRunStartTimeLive], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("last_run_start_time_live") + @ExcludeMissing + fun _lastRunStartTimeLive(): JsonField<OffsetDateTime> = lastRunStartTimeLive + + /** + * Returns the raw JSON value of [latencyP50]. + * + * Unlike [latencyP50], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("latency_p50") @ExcludeMissing fun _latencyP50(): JsonField<Double> = latencyP50 + + /** + * Returns the raw JSON value of [latencyP99]. + * + * Unlike [latencyP99], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("latency_p99") @ExcludeMissing fun _latencyP99(): JsonField<Double> = latencyP99 + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [promptCost]. + * + * Unlike [promptCost], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prompt_cost") @ExcludeMissing fun _promptCost(): JsonField<String> = promptCost + + /** + * Returns the raw JSON value of [promptTokens]. + * + * Unlike [promptTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prompt_tokens") + @ExcludeMissing + fun _promptTokens(): JsonField<Long> = promptTokens + + /** + * Returns the raw JSON value of [referenceDatasetId]. + * + * Unlike [referenceDatasetId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reference_dataset_id") + @ExcludeMissing + fun _referenceDatasetId(): JsonField<String> = referenceDatasetId + + /** + * Returns the raw JSON value of [runCount]. + * + * Unlike [runCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_count") @ExcludeMissing fun _runCount(): JsonField<Long> = runCount + + /** + * Returns the raw JSON value of [runFacets]. + * + * Unlike [runFacets], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_facets") + @ExcludeMissing + fun _runFacets(): JsonField<List<JsonValue>> = runFacets + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_time") + @ExcludeMissing + fun _startTime(): JsonField<OffsetDateTime> = startTime + + /** + * Returns the raw JSON value of [streamingRate]. + * + * Unlike [streamingRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("streaming_rate") + @ExcludeMissing + fun _streamingRate(): JsonField<Double> = streamingRate + + /** + * Returns the raw JSON value of [testRunNumber]. + * + * Unlike [testRunNumber], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("test_run_number") + @ExcludeMissing + fun _testRunNumber(): JsonField<Long> = testRunNumber + + /** + * Returns the raw JSON value of [totalCost]. + * + * Unlike [totalCost], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total_cost") @ExcludeMissing fun _totalCost(): JsonField<String> = totalCost + + /** + * Returns the raw JSON value of [totalTokens]. + * + * Unlike [totalTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total_tokens") @ExcludeMissing fun _totalTokens(): JsonField<Long> = totalTokens + + /** + * Returns the raw JSON value of [traceTier]. + * + * Unlike [traceTier], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trace_tier") @ExcludeMissing fun _traceTier(): JsonField<TraceTier> = traceTier + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TracerSession]. + * + * The following fields are required: + * ```java + * .id() + * .tenantId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TracerSession]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var tenantId: JsonField<String>? = null + private var completionCost: JsonField<String> = JsonMissing.of() + private var completionTokens: JsonField<Long> = JsonMissing.of() + private var defaultDatasetId: JsonField<String> = JsonMissing.of() + private var description: JsonField<String> = JsonMissing.of() + private var endTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var errorRate: JsonField<Double> = JsonMissing.of() + private var extra: JsonValue = JsonMissing.of() + private var feedbackStats: JsonValue = JsonMissing.of() + private var firstTokenP50: JsonField<Double> = JsonMissing.of() + private var firstTokenP99: JsonField<Double> = JsonMissing.of() + private var lastRunStartTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var lastRunStartTimeLive: JsonField<OffsetDateTime> = JsonMissing.of() + private var latencyP50: JsonField<Double> = JsonMissing.of() + private var latencyP99: JsonField<Double> = JsonMissing.of() + private var name: JsonField<String> = JsonMissing.of() + private var promptCost: JsonField<String> = JsonMissing.of() + private var promptTokens: JsonField<Long> = JsonMissing.of() + private var referenceDatasetId: JsonField<String> = JsonMissing.of() + private var runCount: JsonField<Long> = JsonMissing.of() + private var runFacets: JsonField<MutableList<JsonValue>>? = null + private var sessionFeedbackStats: JsonValue = JsonMissing.of() + private var startTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var streamingRate: JsonField<Double> = JsonMissing.of() + private var testRunNumber: JsonField<Long> = JsonMissing.of() + private var totalCost: JsonField<String> = JsonMissing.of() + private var totalTokens: JsonField<Long> = JsonMissing.of() + private var traceTier: JsonField<TraceTier> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(tracerSession: TracerSession) = apply { + id = tracerSession.id + tenantId = tracerSession.tenantId + completionCost = tracerSession.completionCost + completionTokens = tracerSession.completionTokens + defaultDatasetId = tracerSession.defaultDatasetId + description = tracerSession.description + endTime = tracerSession.endTime + errorRate = tracerSession.errorRate + extra = tracerSession.extra + feedbackStats = tracerSession.feedbackStats + firstTokenP50 = tracerSession.firstTokenP50 + firstTokenP99 = tracerSession.firstTokenP99 + lastRunStartTime = tracerSession.lastRunStartTime + lastRunStartTimeLive = tracerSession.lastRunStartTimeLive + latencyP50 = tracerSession.latencyP50 + latencyP99 = tracerSession.latencyP99 + name = tracerSession.name + promptCost = tracerSession.promptCost + promptTokens = tracerSession.promptTokens + referenceDatasetId = tracerSession.referenceDatasetId + runCount = tracerSession.runCount + runFacets = tracerSession.runFacets.map { it.toMutableList() } + sessionFeedbackStats = tracerSession.sessionFeedbackStats + startTime = tracerSession.startTime + streamingRate = tracerSession.streamingRate + testRunNumber = tracerSession.testRunNumber + totalCost = tracerSession.totalCost + totalTokens = tracerSession.totalTokens + traceTier = tracerSession.traceTier + additionalProperties = tracerSession.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tenantId(tenantId: JsonField<String>) = apply { this.tenantId = tenantId } + + fun completionCost(completionCost: String?) = + completionCost(JsonField.ofNullable(completionCost)) + + /** Alias for calling [Builder.completionCost] with `completionCost.orElse(null)`. */ + fun completionCost(completionCost: Optional<String>) = + completionCost(completionCost.getOrNull()) + + /** + * Sets [Builder.completionCost] to an arbitrary JSON value. + * + * You should usually call [Builder.completionCost] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun completionCost(completionCost: JsonField<String>) = apply { + this.completionCost = completionCost + } + + fun completionTokens(completionTokens: Long?) = + completionTokens(JsonField.ofNullable(completionTokens)) + + /** + * Alias for [Builder.completionTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun completionTokens(completionTokens: Long) = completionTokens(completionTokens as Long?) + + /** Alias for calling [Builder.completionTokens] with `completionTokens.orElse(null)`. */ + fun completionTokens(completionTokens: Optional<Long>) = + completionTokens(completionTokens.getOrNull()) + + /** + * Sets [Builder.completionTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.completionTokens] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun completionTokens(completionTokens: JsonField<Long>) = apply { + this.completionTokens = completionTokens + } + + fun defaultDatasetId(defaultDatasetId: String?) = + defaultDatasetId(JsonField.ofNullable(defaultDatasetId)) + + /** Alias for calling [Builder.defaultDatasetId] with `defaultDatasetId.orElse(null)`. */ + fun defaultDatasetId(defaultDatasetId: Optional<String>) = + defaultDatasetId(defaultDatasetId.getOrNull()) + + /** + * Sets [Builder.defaultDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultDatasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun defaultDatasetId(defaultDatasetId: JsonField<String>) = apply { + this.defaultDatasetId = defaultDatasetId + } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { this.description = description } + + fun endTime(endTime: OffsetDateTime?) = endTime(JsonField.ofNullable(endTime)) + + /** Alias for calling [Builder.endTime] with `endTime.orElse(null)`. */ + fun endTime(endTime: Optional<OffsetDateTime>) = endTime(endTime.getOrNull()) + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endTime(endTime: JsonField<OffsetDateTime>) = apply { this.endTime = endTime } + + fun errorRate(errorRate: Double?) = errorRate(JsonField.ofNullable(errorRate)) + + /** + * Alias for [Builder.errorRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun errorRate(errorRate: Double) = errorRate(errorRate as Double?) + + /** Alias for calling [Builder.errorRate] with `errorRate.orElse(null)`. */ + fun errorRate(errorRate: Optional<Double>) = errorRate(errorRate.getOrNull()) + + /** + * Sets [Builder.errorRate] to an arbitrary JSON value. + * + * You should usually call [Builder.errorRate] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun errorRate(errorRate: JsonField<Double>) = apply { this.errorRate = errorRate } + + fun extra(extra: JsonValue) = apply { this.extra = extra } + + fun feedbackStats(feedbackStats: JsonValue) = apply { this.feedbackStats = feedbackStats } + + fun firstTokenP50(firstTokenP50: Double?) = + firstTokenP50(JsonField.ofNullable(firstTokenP50)) + + /** + * Alias for [Builder.firstTokenP50]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun firstTokenP50(firstTokenP50: Double) = firstTokenP50(firstTokenP50 as Double?) + + /** Alias for calling [Builder.firstTokenP50] with `firstTokenP50.orElse(null)`. */ + fun firstTokenP50(firstTokenP50: Optional<Double>) = + firstTokenP50(firstTokenP50.getOrNull()) + + /** + * Sets [Builder.firstTokenP50] to an arbitrary JSON value. + * + * You should usually call [Builder.firstTokenP50] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun firstTokenP50(firstTokenP50: JsonField<Double>) = apply { + this.firstTokenP50 = firstTokenP50 + } + + fun firstTokenP99(firstTokenP99: Double?) = + firstTokenP99(JsonField.ofNullable(firstTokenP99)) + + /** + * Alias for [Builder.firstTokenP99]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun firstTokenP99(firstTokenP99: Double) = firstTokenP99(firstTokenP99 as Double?) + + /** Alias for calling [Builder.firstTokenP99] with `firstTokenP99.orElse(null)`. */ + fun firstTokenP99(firstTokenP99: Optional<Double>) = + firstTokenP99(firstTokenP99.getOrNull()) + + /** + * Sets [Builder.firstTokenP99] to an arbitrary JSON value. + * + * You should usually call [Builder.firstTokenP99] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun firstTokenP99(firstTokenP99: JsonField<Double>) = apply { + this.firstTokenP99 = firstTokenP99 + } + + fun lastRunStartTime(lastRunStartTime: OffsetDateTime?) = + lastRunStartTime(JsonField.ofNullable(lastRunStartTime)) + + /** Alias for calling [Builder.lastRunStartTime] with `lastRunStartTime.orElse(null)`. */ + fun lastRunStartTime(lastRunStartTime: Optional<OffsetDateTime>) = + lastRunStartTime(lastRunStartTime.getOrNull()) + + /** + * Sets [Builder.lastRunStartTime] to an arbitrary JSON value. + * + * You should usually call [Builder.lastRunStartTime] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun lastRunStartTime(lastRunStartTime: JsonField<OffsetDateTime>) = apply { + this.lastRunStartTime = lastRunStartTime + } + + fun lastRunStartTimeLive(lastRunStartTimeLive: OffsetDateTime?) = + lastRunStartTimeLive(JsonField.ofNullable(lastRunStartTimeLive)) + + /** + * Alias for calling [Builder.lastRunStartTimeLive] with + * `lastRunStartTimeLive.orElse(null)`. + */ + fun lastRunStartTimeLive(lastRunStartTimeLive: Optional<OffsetDateTime>) = + lastRunStartTimeLive(lastRunStartTimeLive.getOrNull()) + + /** + * Sets [Builder.lastRunStartTimeLive] to an arbitrary JSON value. + * + * You should usually call [Builder.lastRunStartTimeLive] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun lastRunStartTimeLive(lastRunStartTimeLive: JsonField<OffsetDateTime>) = apply { + this.lastRunStartTimeLive = lastRunStartTimeLive + } + + fun latencyP50(latencyP50: Double?) = latencyP50(JsonField.ofNullable(latencyP50)) + + /** + * Alias for [Builder.latencyP50]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun latencyP50(latencyP50: Double) = latencyP50(latencyP50 as Double?) + + /** Alias for calling [Builder.latencyP50] with `latencyP50.orElse(null)`. */ + fun latencyP50(latencyP50: Optional<Double>) = latencyP50(latencyP50.getOrNull()) + + /** + * Sets [Builder.latencyP50] to an arbitrary JSON value. + * + * You should usually call [Builder.latencyP50] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun latencyP50(latencyP50: JsonField<Double>) = apply { this.latencyP50 = latencyP50 } + + fun latencyP99(latencyP99: Double?) = latencyP99(JsonField.ofNullable(latencyP99)) + + /** + * Alias for [Builder.latencyP99]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun latencyP99(latencyP99: Double) = latencyP99(latencyP99 as Double?) + + /** Alias for calling [Builder.latencyP99] with `latencyP99.orElse(null)`. */ + fun latencyP99(latencyP99: Optional<Double>) = latencyP99(latencyP99.getOrNull()) + + /** + * Sets [Builder.latencyP99] to an arbitrary JSON value. + * + * You should usually call [Builder.latencyP99] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun latencyP99(latencyP99: JsonField<Double>) = apply { this.latencyP99 = latencyP99 } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun promptCost(promptCost: String?) = promptCost(JsonField.ofNullable(promptCost)) + + /** Alias for calling [Builder.promptCost] with `promptCost.orElse(null)`. */ + fun promptCost(promptCost: Optional<String>) = promptCost(promptCost.getOrNull()) + + /** + * Sets [Builder.promptCost] to an arbitrary JSON value. + * + * You should usually call [Builder.promptCost] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun promptCost(promptCost: JsonField<String>) = apply { this.promptCost = promptCost } + + fun promptTokens(promptTokens: Long?) = promptTokens(JsonField.ofNullable(promptTokens)) + + /** + * Alias for [Builder.promptTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun promptTokens(promptTokens: Long) = promptTokens(promptTokens as Long?) + + /** Alias for calling [Builder.promptTokens] with `promptTokens.orElse(null)`. */ + fun promptTokens(promptTokens: Optional<Long>) = promptTokens(promptTokens.getOrNull()) + + /** + * Sets [Builder.promptTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.promptTokens] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun promptTokens(promptTokens: JsonField<Long>) = apply { this.promptTokens = promptTokens } + + fun referenceDatasetId(referenceDatasetId: String?) = + referenceDatasetId(JsonField.ofNullable(referenceDatasetId)) + + /** + * Alias for calling [Builder.referenceDatasetId] with `referenceDatasetId.orElse(null)`. + */ + fun referenceDatasetId(referenceDatasetId: Optional<String>) = + referenceDatasetId(referenceDatasetId.getOrNull()) + + /** + * Sets [Builder.referenceDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceDatasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun referenceDatasetId(referenceDatasetId: JsonField<String>) = apply { + this.referenceDatasetId = referenceDatasetId + } + + fun runCount(runCount: Long?) = runCount(JsonField.ofNullable(runCount)) + + /** + * Alias for [Builder.runCount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun runCount(runCount: Long) = runCount(runCount as Long?) + + /** Alias for calling [Builder.runCount] with `runCount.orElse(null)`. */ + fun runCount(runCount: Optional<Long>) = runCount(runCount.getOrNull()) + + /** + * Sets [Builder.runCount] to an arbitrary JSON value. + * + * You should usually call [Builder.runCount] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun runCount(runCount: JsonField<Long>) = apply { this.runCount = runCount } + + fun runFacets(runFacets: List<JsonValue>?) = runFacets(JsonField.ofNullable(runFacets)) + + /** Alias for calling [Builder.runFacets] with `runFacets.orElse(null)`. */ + fun runFacets(runFacets: Optional<List<JsonValue>>) = runFacets(runFacets.getOrNull()) + + /** + * Sets [Builder.runFacets] to an arbitrary JSON value. + * + * You should usually call [Builder.runFacets] with a well-typed `List<JsonValue>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun runFacets(runFacets: JsonField<List<JsonValue>>) = apply { + this.runFacets = runFacets.map { it.toMutableList() } + } + + /** + * Adds a single [JsonValue] to [runFacets]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRunFacet(runFacet: JsonValue) = apply { + runFacets = + (runFacets ?: JsonField.of(mutableListOf())).also { + checkKnown("runFacets", it).add(runFacet) + } + } + + fun sessionFeedbackStats(sessionFeedbackStats: JsonValue) = apply { + this.sessionFeedbackStats = sessionFeedbackStats + } + + fun startTime(startTime: OffsetDateTime) = startTime(JsonField.of(startTime)) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField<OffsetDateTime>) = apply { this.startTime = startTime } + + fun streamingRate(streamingRate: Double?) = + streamingRate(JsonField.ofNullable(streamingRate)) + + /** + * Alias for [Builder.streamingRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun streamingRate(streamingRate: Double) = streamingRate(streamingRate as Double?) + + /** Alias for calling [Builder.streamingRate] with `streamingRate.orElse(null)`. */ + fun streamingRate(streamingRate: Optional<Double>) = + streamingRate(streamingRate.getOrNull()) + + /** + * Sets [Builder.streamingRate] to an arbitrary JSON value. + * + * You should usually call [Builder.streamingRate] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun streamingRate(streamingRate: JsonField<Double>) = apply { + this.streamingRate = streamingRate + } + + fun testRunNumber(testRunNumber: Long?) = testRunNumber(JsonField.ofNullable(testRunNumber)) + + /** + * Alias for [Builder.testRunNumber]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun testRunNumber(testRunNumber: Long) = testRunNumber(testRunNumber as Long?) + + /** Alias for calling [Builder.testRunNumber] with `testRunNumber.orElse(null)`. */ + fun testRunNumber(testRunNumber: Optional<Long>) = testRunNumber(testRunNumber.getOrNull()) + + /** + * Sets [Builder.testRunNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.testRunNumber] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun testRunNumber(testRunNumber: JsonField<Long>) = apply { + this.testRunNumber = testRunNumber + } + + fun totalCost(totalCost: String?) = totalCost(JsonField.ofNullable(totalCost)) + + /** Alias for calling [Builder.totalCost] with `totalCost.orElse(null)`. */ + fun totalCost(totalCost: Optional<String>) = totalCost(totalCost.getOrNull()) + + /** + * Sets [Builder.totalCost] to an arbitrary JSON value. + * + * You should usually call [Builder.totalCost] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun totalCost(totalCost: JsonField<String>) = apply { this.totalCost = totalCost } + + fun totalTokens(totalTokens: Long?) = totalTokens(JsonField.ofNullable(totalTokens)) + + /** + * Alias for [Builder.totalTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun totalTokens(totalTokens: Long) = totalTokens(totalTokens as Long?) + + /** Alias for calling [Builder.totalTokens] with `totalTokens.orElse(null)`. */ + fun totalTokens(totalTokens: Optional<Long>) = totalTokens(totalTokens.getOrNull()) + + /** + * Sets [Builder.totalTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.totalTokens] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun totalTokens(totalTokens: JsonField<Long>) = apply { this.totalTokens = totalTokens } + + fun traceTier(traceTier: TraceTier?) = traceTier(JsonField.ofNullable(traceTier)) + + /** Alias for calling [Builder.traceTier] with `traceTier.orElse(null)`. */ + fun traceTier(traceTier: Optional<TraceTier>) = traceTier(traceTier.getOrNull()) + + /** + * Sets [Builder.traceTier] to an arbitrary JSON value. + * + * You should usually call [Builder.traceTier] with a well-typed [TraceTier] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun traceTier(traceTier: JsonField<TraceTier>) = apply { this.traceTier = traceTier } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TracerSession]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .tenantId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TracerSession = + TracerSession( + checkRequired("id", id), + checkRequired("tenantId", tenantId), + completionCost, + completionTokens, + defaultDatasetId, + description, + endTime, + errorRate, + extra, + feedbackStats, + firstTokenP50, + firstTokenP99, + lastRunStartTime, + lastRunStartTimeLive, + latencyP50, + latencyP99, + name, + promptCost, + promptTokens, + referenceDatasetId, + runCount, + (runFacets ?: JsonMissing.of()).map { it.toImmutable() }, + sessionFeedbackStats, + startTime, + streamingRate, + testRunNumber, + totalCost, + totalTokens, + traceTier, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TracerSession = apply { + if (validated) { + return@apply + } + + id() + tenantId() + completionCost() + completionTokens() + defaultDatasetId() + description() + endTime() + errorRate() + firstTokenP50() + firstTokenP99() + lastRunStartTime() + lastRunStartTimeLive() + latencyP50() + latencyP99() + name() + promptCost() + promptTokens() + referenceDatasetId() + runCount() + runFacets() + startTime() + streamingRate() + testRunNumber() + totalCost() + totalTokens() + traceTier().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + (if (completionCost.asKnown().isPresent) 1 else 0) + + (if (completionTokens.asKnown().isPresent) 1 else 0) + + (if (defaultDatasetId.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endTime.asKnown().isPresent) 1 else 0) + + (if (errorRate.asKnown().isPresent) 1 else 0) + + (if (firstTokenP50.asKnown().isPresent) 1 else 0) + + (if (firstTokenP99.asKnown().isPresent) 1 else 0) + + (if (lastRunStartTime.asKnown().isPresent) 1 else 0) + + (if (lastRunStartTimeLive.asKnown().isPresent) 1 else 0) + + (if (latencyP50.asKnown().isPresent) 1 else 0) + + (if (latencyP99.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (promptCost.asKnown().isPresent) 1 else 0) + + (if (promptTokens.asKnown().isPresent) 1 else 0) + + (if (referenceDatasetId.asKnown().isPresent) 1 else 0) + + (if (runCount.asKnown().isPresent) 1 else 0) + + (runFacets.asKnown().getOrNull()?.size ?: 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + (if (streamingRate.asKnown().isPresent) 1 else 0) + + (if (testRunNumber.asKnown().isPresent) 1 else 0) + + (if (totalCost.asKnown().isPresent) 1 else 0) + + (if (totalTokens.asKnown().isPresent) 1 else 0) + + (traceTier.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TracerSession && + id == other.id && + tenantId == other.tenantId && + completionCost == other.completionCost && + completionTokens == other.completionTokens && + defaultDatasetId == other.defaultDatasetId && + description == other.description && + endTime == other.endTime && + errorRate == other.errorRate && + extra == other.extra && + feedbackStats == other.feedbackStats && + firstTokenP50 == other.firstTokenP50 && + firstTokenP99 == other.firstTokenP99 && + lastRunStartTime == other.lastRunStartTime && + lastRunStartTimeLive == other.lastRunStartTimeLive && + latencyP50 == other.latencyP50 && + latencyP99 == other.latencyP99 && + name == other.name && + promptCost == other.promptCost && + promptTokens == other.promptTokens && + referenceDatasetId == other.referenceDatasetId && + runCount == other.runCount && + runFacets == other.runFacets && + sessionFeedbackStats == other.sessionFeedbackStats && + startTime == other.startTime && + streamingRate == other.streamingRate && + testRunNumber == other.testRunNumber && + totalCost == other.totalCost && + totalTokens == other.totalTokens && + traceTier == other.traceTier && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + tenantId, + completionCost, + completionTokens, + defaultDatasetId, + description, + endTime, + errorRate, + extra, + feedbackStats, + firstTokenP50, + firstTokenP99, + lastRunStartTime, + lastRunStartTimeLive, + latencyP50, + latencyP99, + name, + promptCost, + promptTokens, + referenceDatasetId, + runCount, + runFacets, + sessionFeedbackStats, + startTime, + streamingRate, + testRunNumber, + totalCost, + totalTokens, + traceTier, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TracerSession{id=$id, tenantId=$tenantId, completionCost=$completionCost, completionTokens=$completionTokens, defaultDatasetId=$defaultDatasetId, description=$description, endTime=$endTime, errorRate=$errorRate, extra=$extra, feedbackStats=$feedbackStats, firstTokenP50=$firstTokenP50, firstTokenP99=$firstTokenP99, lastRunStartTime=$lastRunStartTime, lastRunStartTimeLive=$lastRunStartTimeLive, latencyP50=$latencyP50, latencyP99=$latencyP99, name=$name, promptCost=$promptCost, promptTokens=$promptTokens, referenceDatasetId=$referenceDatasetId, runCount=$runCount, runFacets=$runFacets, sessionFeedbackStats=$sessionFeedbackStats, startTime=$startTime, streamingRate=$streamingRate, testRunNumber=$testRunNumber, totalCost=$totalCost, totalTokens=$totalTokens, traceTier=$traceTier, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/TracerSessionWithoutVirtualFields.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/TracerSessionWithoutVirtualFields.kt new file mode 100644 index 00000000..4ed55ea3 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/TracerSessionWithoutVirtualFields.kt @@ -0,0 +1,568 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TraceTier +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** TracerSession schema. */ +class TracerSessionWithoutVirtualFields +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val tenantId: JsonField<String>, + private val defaultDatasetId: JsonField<String>, + private val description: JsonField<String>, + private val endTime: JsonField<OffsetDateTime>, + private val extra: JsonValue, + private val lastRunStartTimeLive: JsonField<OffsetDateTime>, + private val name: JsonField<String>, + private val referenceDatasetId: JsonField<String>, + private val startTime: JsonField<OffsetDateTime>, + private val traceTier: JsonField<TraceTier>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("tenant_id") @ExcludeMissing tenantId: JsonField<String> = JsonMissing.of(), + @JsonProperty("default_dataset_id") + @ExcludeMissing + defaultDatasetId: JsonField<String> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("end_time") + @ExcludeMissing + endTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("extra") @ExcludeMissing extra: JsonValue = JsonMissing.of(), + @JsonProperty("last_run_start_time_live") + @ExcludeMissing + lastRunStartTimeLive: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("reference_dataset_id") + @ExcludeMissing + referenceDatasetId: JsonField<String> = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("trace_tier") + @ExcludeMissing + traceTier: JsonField<TraceTier> = JsonMissing.of(), + ) : this( + id, + tenantId, + defaultDatasetId, + description, + endTime, + extra, + lastRunStartTimeLive, + name, + referenceDatasetId, + startTime, + traceTier, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tenantId(): String = tenantId.getRequired("tenant_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun defaultDatasetId(): Optional<String> = defaultDatasetId.getOptional("default_dataset_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endTime(): Optional<OffsetDateTime> = endTime.getOptional("end_time") + + @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonValue = extra + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun lastRunStartTimeLive(): Optional<OffsetDateTime> = + lastRunStartTimeLive.getOptional("last_run_start_time_live") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional<String> = name.getOptional("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceDatasetId(): Optional<String> = + referenceDatasetId.getOptional("reference_dataset_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun startTime(): Optional<OffsetDateTime> = startTime.getOptional("start_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun traceTier(): Optional<TraceTier> = traceTier.getOptional("trace_tier") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_id") @ExcludeMissing fun _tenantId(): JsonField<String> = tenantId + + /** + * Returns the raw JSON value of [defaultDatasetId]. + * + * Unlike [defaultDatasetId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("default_dataset_id") + @ExcludeMissing + fun _defaultDatasetId(): JsonField<String> = defaultDatasetId + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_time") @ExcludeMissing fun _endTime(): JsonField<OffsetDateTime> = endTime + + /** + * Returns the raw JSON value of [lastRunStartTimeLive]. + * + * Unlike [lastRunStartTimeLive], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("last_run_start_time_live") + @ExcludeMissing + fun _lastRunStartTimeLive(): JsonField<OffsetDateTime> = lastRunStartTimeLive + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [referenceDatasetId]. + * + * Unlike [referenceDatasetId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reference_dataset_id") + @ExcludeMissing + fun _referenceDatasetId(): JsonField<String> = referenceDatasetId + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_time") + @ExcludeMissing + fun _startTime(): JsonField<OffsetDateTime> = startTime + + /** + * Returns the raw JSON value of [traceTier]. + * + * Unlike [traceTier], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trace_tier") @ExcludeMissing fun _traceTier(): JsonField<TraceTier> = traceTier + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TracerSessionWithoutVirtualFields]. + * + * The following fields are required: + * ```java + * .id() + * .tenantId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TracerSessionWithoutVirtualFields]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var tenantId: JsonField<String>? = null + private var defaultDatasetId: JsonField<String> = JsonMissing.of() + private var description: JsonField<String> = JsonMissing.of() + private var endTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var extra: JsonValue = JsonMissing.of() + private var lastRunStartTimeLive: JsonField<OffsetDateTime> = JsonMissing.of() + private var name: JsonField<String> = JsonMissing.of() + private var referenceDatasetId: JsonField<String> = JsonMissing.of() + private var startTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var traceTier: JsonField<TraceTier> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(tracerSessionWithoutVirtualFields: TracerSessionWithoutVirtualFields) = + apply { + id = tracerSessionWithoutVirtualFields.id + tenantId = tracerSessionWithoutVirtualFields.tenantId + defaultDatasetId = tracerSessionWithoutVirtualFields.defaultDatasetId + description = tracerSessionWithoutVirtualFields.description + endTime = tracerSessionWithoutVirtualFields.endTime + extra = tracerSessionWithoutVirtualFields.extra + lastRunStartTimeLive = tracerSessionWithoutVirtualFields.lastRunStartTimeLive + name = tracerSessionWithoutVirtualFields.name + referenceDatasetId = tracerSessionWithoutVirtualFields.referenceDatasetId + startTime = tracerSessionWithoutVirtualFields.startTime + traceTier = tracerSessionWithoutVirtualFields.traceTier + additionalProperties = + tracerSessionWithoutVirtualFields.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tenantId(tenantId: JsonField<String>) = apply { this.tenantId = tenantId } + + fun defaultDatasetId(defaultDatasetId: String?) = + defaultDatasetId(JsonField.ofNullable(defaultDatasetId)) + + /** Alias for calling [Builder.defaultDatasetId] with `defaultDatasetId.orElse(null)`. */ + fun defaultDatasetId(defaultDatasetId: Optional<String>) = + defaultDatasetId(defaultDatasetId.getOrNull()) + + /** + * Sets [Builder.defaultDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultDatasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun defaultDatasetId(defaultDatasetId: JsonField<String>) = apply { + this.defaultDatasetId = defaultDatasetId + } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { this.description = description } + + fun endTime(endTime: OffsetDateTime?) = endTime(JsonField.ofNullable(endTime)) + + /** Alias for calling [Builder.endTime] with `endTime.orElse(null)`. */ + fun endTime(endTime: Optional<OffsetDateTime>) = endTime(endTime.getOrNull()) + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endTime(endTime: JsonField<OffsetDateTime>) = apply { this.endTime = endTime } + + fun extra(extra: JsonValue) = apply { this.extra = extra } + + fun lastRunStartTimeLive(lastRunStartTimeLive: OffsetDateTime?) = + lastRunStartTimeLive(JsonField.ofNullable(lastRunStartTimeLive)) + + /** + * Alias for calling [Builder.lastRunStartTimeLive] with + * `lastRunStartTimeLive.orElse(null)`. + */ + fun lastRunStartTimeLive(lastRunStartTimeLive: Optional<OffsetDateTime>) = + lastRunStartTimeLive(lastRunStartTimeLive.getOrNull()) + + /** + * Sets [Builder.lastRunStartTimeLive] to an arbitrary JSON value. + * + * You should usually call [Builder.lastRunStartTimeLive] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun lastRunStartTimeLive(lastRunStartTimeLive: JsonField<OffsetDateTime>) = apply { + this.lastRunStartTimeLive = lastRunStartTimeLive + } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun referenceDatasetId(referenceDatasetId: String?) = + referenceDatasetId(JsonField.ofNullable(referenceDatasetId)) + + /** + * Alias for calling [Builder.referenceDatasetId] with `referenceDatasetId.orElse(null)`. + */ + fun referenceDatasetId(referenceDatasetId: Optional<String>) = + referenceDatasetId(referenceDatasetId.getOrNull()) + + /** + * Sets [Builder.referenceDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceDatasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun referenceDatasetId(referenceDatasetId: JsonField<String>) = apply { + this.referenceDatasetId = referenceDatasetId + } + + fun startTime(startTime: OffsetDateTime) = startTime(JsonField.of(startTime)) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField<OffsetDateTime>) = apply { this.startTime = startTime } + + fun traceTier(traceTier: TraceTier?) = traceTier(JsonField.ofNullable(traceTier)) + + /** Alias for calling [Builder.traceTier] with `traceTier.orElse(null)`. */ + fun traceTier(traceTier: Optional<TraceTier>) = traceTier(traceTier.getOrNull()) + + /** + * Sets [Builder.traceTier] to an arbitrary JSON value. + * + * You should usually call [Builder.traceTier] with a well-typed [TraceTier] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun traceTier(traceTier: JsonField<TraceTier>) = apply { this.traceTier = traceTier } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TracerSessionWithoutVirtualFields]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .tenantId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TracerSessionWithoutVirtualFields = + TracerSessionWithoutVirtualFields( + checkRequired("id", id), + checkRequired("tenantId", tenantId), + defaultDatasetId, + description, + endTime, + extra, + lastRunStartTimeLive, + name, + referenceDatasetId, + startTime, + traceTier, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TracerSessionWithoutVirtualFields = apply { + if (validated) { + return@apply + } + + id() + tenantId() + defaultDatasetId() + description() + endTime() + lastRunStartTimeLive() + name() + referenceDatasetId() + startTime() + traceTier().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + (if (defaultDatasetId.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endTime.asKnown().isPresent) 1 else 0) + + (if (lastRunStartTimeLive.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (referenceDatasetId.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + (traceTier.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TracerSessionWithoutVirtualFields && + id == other.id && + tenantId == other.tenantId && + defaultDatasetId == other.defaultDatasetId && + description == other.description && + endTime == other.endTime && + extra == other.extra && + lastRunStartTimeLive == other.lastRunStartTimeLive && + name == other.name && + referenceDatasetId == other.referenceDatasetId && + startTime == other.startTime && + traceTier == other.traceTier && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + tenantId, + defaultDatasetId, + description, + endTime, + extra, + lastRunStartTimeLive, + name, + referenceDatasetId, + startTime, + traceTier, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TracerSessionWithoutVirtualFields{id=$id, tenantId=$tenantId, defaultDatasetId=$defaultDatasetId, description=$description, endTime=$endTime, extra=$extra, lastRunStartTimeLive=$lastRunStartTimeLive, name=$name, referenceDatasetId=$referenceDatasetId, startTime=$startTime, traceTier=$traceTier, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/CreateRunClusteringJobRequest.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/CreateRunClusteringJobRequest.kt new file mode 100644 index 00000000..0116ce60 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/CreateRunClusteringJobRequest.kt @@ -0,0 +1,983 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights + +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.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Request to create a run clustering job. */ +class CreateRunClusteringJobRequest +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val attributeSchemas: JsonValue, + private val endTime: JsonField<OffsetDateTime>, + private val filter: JsonField<String>, + private val hierarchy: JsonField<List<Long>>, + private val lastNHours: JsonField<Long>, + private val model: JsonField<Model>, + private val name: JsonField<String>, + private val partitions: JsonField<Partitions>, + private val sample: JsonField<Double>, + private val startTime: JsonField<OffsetDateTime>, + private val summaryPrompt: JsonField<String>, + private val userContext: JsonField<UserContext>, + private val validateModelSecrets: JsonField<Boolean>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("attribute_schemas") + @ExcludeMissing + attributeSchemas: JsonValue = JsonMissing.of(), + @JsonProperty("end_time") + @ExcludeMissing + endTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("filter") @ExcludeMissing filter: JsonField<String> = JsonMissing.of(), + @JsonProperty("hierarchy") + @ExcludeMissing + hierarchy: JsonField<List<Long>> = JsonMissing.of(), + @JsonProperty("last_n_hours") + @ExcludeMissing + lastNHours: JsonField<Long> = JsonMissing.of(), + @JsonProperty("model") @ExcludeMissing model: JsonField<Model> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("partitions") + @ExcludeMissing + partitions: JsonField<Partitions> = JsonMissing.of(), + @JsonProperty("sample") @ExcludeMissing sample: JsonField<Double> = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("summary_prompt") + @ExcludeMissing + summaryPrompt: JsonField<String> = JsonMissing.of(), + @JsonProperty("user_context") + @ExcludeMissing + userContext: JsonField<UserContext> = JsonMissing.of(), + @JsonProperty("validate_model_secrets") + @ExcludeMissing + validateModelSecrets: JsonField<Boolean> = JsonMissing.of(), + ) : this( + attributeSchemas, + endTime, + filter, + hierarchy, + lastNHours, + model, + name, + partitions, + sample, + startTime, + summaryPrompt, + userContext, + validateModelSecrets, + mutableMapOf(), + ) + + @JsonProperty("attribute_schemas") + @ExcludeMissing + fun _attributeSchemas(): JsonValue = attributeSchemas + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endTime(): Optional<OffsetDateTime> = endTime.getOptional("end_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun filter(): Optional<String> = filter.getOptional("filter") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun hierarchy(): Optional<List<Long>> = hierarchy.getOptional("hierarchy") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun lastNHours(): Optional<Long> = lastNHours.getOptional("last_n_hours") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun model(): Optional<Model> = model.getOptional("model") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional<String> = name.getOptional("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun partitions(): Optional<Partitions> = partitions.getOptional("partitions") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun sample(): Optional<Double> = sample.getOptional("sample") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun startTime(): Optional<OffsetDateTime> = startTime.getOptional("start_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun summaryPrompt(): Optional<String> = summaryPrompt.getOptional("summary_prompt") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun userContext(): Optional<UserContext> = userContext.getOptional("user_context") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun validateModelSecrets(): Optional<Boolean> = + validateModelSecrets.getOptional("validate_model_secrets") + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_time") @ExcludeMissing fun _endTime(): JsonField<OffsetDateTime> = endTime + + /** + * Returns the raw JSON value of [filter]. + * + * Unlike [filter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField<String> = filter + + /** + * Returns the raw JSON value of [hierarchy]. + * + * Unlike [hierarchy], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("hierarchy") @ExcludeMissing fun _hierarchy(): JsonField<List<Long>> = hierarchy + + /** + * Returns the raw JSON value of [lastNHours]. + * + * Unlike [lastNHours], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("last_n_hours") @ExcludeMissing fun _lastNHours(): JsonField<Long> = lastNHours + + /** + * Returns the raw JSON value of [model]. + * + * Unlike [model], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("model") @ExcludeMissing fun _model(): JsonField<Model> = model + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [partitions]. + * + * Unlike [partitions], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("partitions") + @ExcludeMissing + fun _partitions(): JsonField<Partitions> = partitions + + /** + * Returns the raw JSON value of [sample]. + * + * Unlike [sample], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sample") @ExcludeMissing fun _sample(): JsonField<Double> = sample + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_time") + @ExcludeMissing + fun _startTime(): JsonField<OffsetDateTime> = startTime + + /** + * Returns the raw JSON value of [summaryPrompt]. + * + * Unlike [summaryPrompt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("summary_prompt") + @ExcludeMissing + fun _summaryPrompt(): JsonField<String> = summaryPrompt + + /** + * Returns the raw JSON value of [userContext]. + * + * Unlike [userContext], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user_context") + @ExcludeMissing + fun _userContext(): JsonField<UserContext> = userContext + + /** + * Returns the raw JSON value of [validateModelSecrets]. + * + * Unlike [validateModelSecrets], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("validate_model_secrets") + @ExcludeMissing + fun _validateModelSecrets(): JsonField<Boolean> = validateModelSecrets + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CreateRunClusteringJobRequest]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreateRunClusteringJobRequest]. */ + class Builder internal constructor() { + + private var attributeSchemas: JsonValue = JsonMissing.of() + private var endTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var filter: JsonField<String> = JsonMissing.of() + private var hierarchy: JsonField<MutableList<Long>>? = null + private var lastNHours: JsonField<Long> = JsonMissing.of() + private var model: JsonField<Model> = JsonMissing.of() + private var name: JsonField<String> = JsonMissing.of() + private var partitions: JsonField<Partitions> = JsonMissing.of() + private var sample: JsonField<Double> = JsonMissing.of() + private var startTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var summaryPrompt: JsonField<String> = JsonMissing.of() + private var userContext: JsonField<UserContext> = JsonMissing.of() + private var validateModelSecrets: JsonField<Boolean> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(createRunClusteringJobRequest: CreateRunClusteringJobRequest) = apply { + attributeSchemas = createRunClusteringJobRequest.attributeSchemas + endTime = createRunClusteringJobRequest.endTime + filter = createRunClusteringJobRequest.filter + hierarchy = createRunClusteringJobRequest.hierarchy.map { it.toMutableList() } + lastNHours = createRunClusteringJobRequest.lastNHours + model = createRunClusteringJobRequest.model + name = createRunClusteringJobRequest.name + partitions = createRunClusteringJobRequest.partitions + sample = createRunClusteringJobRequest.sample + startTime = createRunClusteringJobRequest.startTime + summaryPrompt = createRunClusteringJobRequest.summaryPrompt + userContext = createRunClusteringJobRequest.userContext + validateModelSecrets = createRunClusteringJobRequest.validateModelSecrets + additionalProperties = createRunClusteringJobRequest.additionalProperties.toMutableMap() + } + + fun attributeSchemas(attributeSchemas: JsonValue) = apply { + this.attributeSchemas = attributeSchemas + } + + fun endTime(endTime: OffsetDateTime?) = endTime(JsonField.ofNullable(endTime)) + + /** Alias for calling [Builder.endTime] with `endTime.orElse(null)`. */ + fun endTime(endTime: Optional<OffsetDateTime>) = endTime(endTime.getOrNull()) + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endTime(endTime: JsonField<OffsetDateTime>) = apply { this.endTime = endTime } + + fun filter(filter: String?) = filter(JsonField.ofNullable(filter)) + + /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ + fun filter(filter: Optional<String>) = filter(filter.getOrNull()) + + /** + * Sets [Builder.filter] to an arbitrary JSON value. + * + * You should usually call [Builder.filter] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun filter(filter: JsonField<String>) = apply { this.filter = filter } + + fun hierarchy(hierarchy: List<Long>?) = hierarchy(JsonField.ofNullable(hierarchy)) + + /** Alias for calling [Builder.hierarchy] with `hierarchy.orElse(null)`. */ + fun hierarchy(hierarchy: Optional<List<Long>>) = hierarchy(hierarchy.getOrNull()) + + /** + * Sets [Builder.hierarchy] to an arbitrary JSON value. + * + * You should usually call [Builder.hierarchy] with a well-typed `List<Long>` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun hierarchy(hierarchy: JsonField<List<Long>>) = apply { + this.hierarchy = hierarchy.map { it.toMutableList() } + } + + /** + * Adds a single [Long] to [Builder.hierarchy]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addHierarchy(hierarchy: Long) = apply { + this.hierarchy = + (this.hierarchy ?: JsonField.of(mutableListOf())).also { + checkKnown("hierarchy", it).add(hierarchy) + } + } + + fun lastNHours(lastNHours: Long?) = lastNHours(JsonField.ofNullable(lastNHours)) + + /** + * Alias for [Builder.lastNHours]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun lastNHours(lastNHours: Long) = lastNHours(lastNHours as Long?) + + /** Alias for calling [Builder.lastNHours] with `lastNHours.orElse(null)`. */ + fun lastNHours(lastNHours: Optional<Long>) = lastNHours(lastNHours.getOrNull()) + + /** + * Sets [Builder.lastNHours] to an arbitrary JSON value. + * + * You should usually call [Builder.lastNHours] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun lastNHours(lastNHours: JsonField<Long>) = apply { this.lastNHours = lastNHours } + + fun model(model: Model) = model(JsonField.of(model)) + + /** + * Sets [Builder.model] to an arbitrary JSON value. + * + * You should usually call [Builder.model] with a well-typed [Model] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun model(model: JsonField<Model>) = apply { this.model = model } + + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional<String>) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun partitions(partitions: Partitions?) = partitions(JsonField.ofNullable(partitions)) + + /** Alias for calling [Builder.partitions] with `partitions.orElse(null)`. */ + fun partitions(partitions: Optional<Partitions>) = partitions(partitions.getOrNull()) + + /** + * Sets [Builder.partitions] to an arbitrary JSON value. + * + * You should usually call [Builder.partitions] with a well-typed [Partitions] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun partitions(partitions: JsonField<Partitions>) = apply { this.partitions = partitions } + + fun sample(sample: Double?) = sample(JsonField.ofNullable(sample)) + + /** + * Alias for [Builder.sample]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun sample(sample: Double) = sample(sample as Double?) + + /** Alias for calling [Builder.sample] with `sample.orElse(null)`. */ + fun sample(sample: Optional<Double>) = sample(sample.getOrNull()) + + /** + * Sets [Builder.sample] to an arbitrary JSON value. + * + * You should usually call [Builder.sample] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun sample(sample: JsonField<Double>) = apply { this.sample = sample } + + fun startTime(startTime: OffsetDateTime?) = startTime(JsonField.ofNullable(startTime)) + + /** Alias for calling [Builder.startTime] with `startTime.orElse(null)`. */ + fun startTime(startTime: Optional<OffsetDateTime>) = startTime(startTime.getOrNull()) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField<OffsetDateTime>) = apply { this.startTime = startTime } + + fun summaryPrompt(summaryPrompt: String?) = + summaryPrompt(JsonField.ofNullable(summaryPrompt)) + + /** Alias for calling [Builder.summaryPrompt] with `summaryPrompt.orElse(null)`. */ + fun summaryPrompt(summaryPrompt: Optional<String>) = + summaryPrompt(summaryPrompt.getOrNull()) + + /** + * Sets [Builder.summaryPrompt] to an arbitrary JSON value. + * + * You should usually call [Builder.summaryPrompt] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun summaryPrompt(summaryPrompt: JsonField<String>) = apply { + this.summaryPrompt = summaryPrompt + } + + fun userContext(userContext: UserContext?) = userContext(JsonField.ofNullable(userContext)) + + /** Alias for calling [Builder.userContext] with `userContext.orElse(null)`. */ + fun userContext(userContext: Optional<UserContext>) = userContext(userContext.getOrNull()) + + /** + * Sets [Builder.userContext] to an arbitrary JSON value. + * + * You should usually call [Builder.userContext] with a well-typed [UserContext] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun userContext(userContext: JsonField<UserContext>) = apply { + this.userContext = userContext + } + + fun validateModelSecrets(validateModelSecrets: Boolean) = + validateModelSecrets(JsonField.of(validateModelSecrets)) + + /** + * Sets [Builder.validateModelSecrets] to an arbitrary JSON value. + * + * You should usually call [Builder.validateModelSecrets] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun validateModelSecrets(validateModelSecrets: JsonField<Boolean>) = apply { + this.validateModelSecrets = validateModelSecrets + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CreateRunClusteringJobRequest]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CreateRunClusteringJobRequest = + CreateRunClusteringJobRequest( + attributeSchemas, + endTime, + filter, + (hierarchy ?: JsonMissing.of()).map { it.toImmutable() }, + lastNHours, + model, + name, + partitions, + sample, + startTime, + summaryPrompt, + userContext, + validateModelSecrets, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CreateRunClusteringJobRequest = apply { + if (validated) { + return@apply + } + + endTime() + filter() + hierarchy() + lastNHours() + model().ifPresent { it.validate() } + name() + partitions().ifPresent { it.validate() } + sample() + startTime() + summaryPrompt() + userContext().ifPresent { it.validate() } + validateModelSecrets() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (endTime.asKnown().isPresent) 1 else 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (hierarchy.asKnown().getOrNull()?.size ?: 0) + + (if (lastNHours.asKnown().isPresent) 1 else 0) + + (model.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (partitions.asKnown().getOrNull()?.validity() ?: 0) + + (if (sample.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + (if (summaryPrompt.asKnown().isPresent) 1 else 0) + + (userContext.asKnown().getOrNull()?.validity() ?: 0) + + (if (validateModelSecrets.asKnown().isPresent) 1 else 0) + + class Model @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val OPENAI = of("openai") + + @JvmField val ANTHROPIC = of("anthropic") + + @JvmStatic fun of(value: String) = Model(JsonField.of(value)) + } + + /** An enum containing [Model]'s known values. */ + enum class Known { + OPENAI, + ANTHROPIC, + } + + /** + * An enum containing [Model]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Model] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + OPENAI, + ANTHROPIC, + /** An enum member indicating that [Model] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + OPENAI -> Value.OPENAI + ANTHROPIC -> Value.ANTHROPIC + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + OPENAI -> Known.OPENAI + ANTHROPIC -> Known.ANTHROPIC + else -> throw LangsmithApiInvalidDataException("Unknown Model: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Model = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Model && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Partitions + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Partitions]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Partitions]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(partitions: Partitions) = apply { + additionalProperties = partitions.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Partitions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Partitions = Partitions(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Partitions = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Partitions && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Partitions{additionalProperties=$additionalProperties}" + } + + class UserContext + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UserContext]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UserContext]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(userContext: UserContext) = apply { + additionalProperties = userContext.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UserContext]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UserContext = UserContext(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): UserContext = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UserContext && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "UserContext{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreateRunClusteringJobRequest && + attributeSchemas == other.attributeSchemas && + endTime == other.endTime && + filter == other.filter && + hierarchy == other.hierarchy && + lastNHours == other.lastNHours && + model == other.model && + name == other.name && + partitions == other.partitions && + sample == other.sample && + startTime == other.startTime && + summaryPrompt == other.summaryPrompt && + userContext == other.userContext && + validateModelSecrets == other.validateModelSecrets && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + attributeSchemas, + endTime, + filter, + hierarchy, + lastNHours, + model, + name, + partitions, + sample, + startTime, + summaryPrompt, + userContext, + validateModelSecrets, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreateRunClusteringJobRequest{attributeSchemas=$attributeSchemas, endTime=$endTime, filter=$filter, hierarchy=$hierarchy, lastNHours=$lastNHours, model=$model, name=$name, partitions=$partitions, sample=$sample, startTime=$startTime, summaryPrompt=$summaryPrompt, userContext=$userContext, validateModelSecrets=$validateModelSecrets, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightCreateParams.kt new file mode 100644 index 00000000..e2ee6d82 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightCreateParams.kt @@ -0,0 +1,232 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create an insights job. */ +class InsightCreateParams +private constructor( + private val sessionId: String?, + private val createRunClusteringJobRequest: CreateRunClusteringJobRequest, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun sessionId(): Optional<String> = Optional.ofNullable(sessionId) + + /** Request to create a run clustering job. */ + fun createRunClusteringJobRequest(): CreateRunClusteringJobRequest = + createRunClusteringJobRequest + + fun _additionalBodyProperties(): Map<String, JsonValue> = + createRunClusteringJobRequest._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InsightCreateParams]. + * + * The following fields are required: + * ```java + * .createRunClusteringJobRequest() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InsightCreateParams]. */ + class Builder internal constructor() { + + private var sessionId: String? = null + private var createRunClusteringJobRequest: CreateRunClusteringJobRequest? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(insightCreateParams: InsightCreateParams) = apply { + sessionId = insightCreateParams.sessionId + createRunClusteringJobRequest = insightCreateParams.createRunClusteringJobRequest + additionalHeaders = insightCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = insightCreateParams.additionalQueryParams.toBuilder() + } + + fun sessionId(sessionId: String?) = apply { this.sessionId = sessionId } + + /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ + fun sessionId(sessionId: Optional<String>) = sessionId(sessionId.getOrNull()) + + /** Request to create a run clustering job. */ + fun createRunClusteringJobRequest( + createRunClusteringJobRequest: CreateRunClusteringJobRequest + ) = apply { this.createRunClusteringJobRequest = createRunClusteringJobRequest } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [InsightCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .createRunClusteringJobRequest() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InsightCreateParams = + InsightCreateParams( + sessionId, + checkRequired("createRunClusteringJobRequest", createRunClusteringJobRequest), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): CreateRunClusteringJobRequest = createRunClusteringJobRequest + + fun _pathParam(index: Int): String = + when (index) { + 0 -> sessionId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InsightCreateParams && + sessionId == other.sessionId && + createRunClusteringJobRequest == other.createRunClusteringJobRequest && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + sessionId, + createRunClusteringJobRequest, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "InsightCreateParams{sessionId=$sessionId, createRunClusteringJobRequest=$createRunClusteringJobRequest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightCreateResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightCreateResponse.kt new file mode 100644 index 00000000..f694db92 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightCreateResponse.kt @@ -0,0 +1,277 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Response to creating a run clustering job. */ +class InsightCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val name: JsonField<String>, + private val status: JsonField<String>, + private val error: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField<String> = JsonMissing.of(), + @JsonProperty("error") @ExcludeMissing error: JsonField<String> = JsonMissing.of(), + ) : this(id, name, status, error, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): String = status.getRequired("status") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun error(): Optional<String> = error.getOptional("error") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField<String> = status + + /** + * Returns the raw JSON value of [error]. + * + * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("error") @ExcludeMissing fun _error(): JsonField<String> = error + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InsightCreateResponse]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InsightCreateResponse]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var name: JsonField<String>? = null + private var status: JsonField<String>? = null + private var error: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(insightCreateResponse: InsightCreateResponse) = apply { + id = insightCreateResponse.id + name = insightCreateResponse.name + status = insightCreateResponse.status + error = insightCreateResponse.error + additionalProperties = insightCreateResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField<String>) = apply { this.status = status } + + fun error(error: String?) = error(JsonField.ofNullable(error)) + + /** Alias for calling [Builder.error] with `error.orElse(null)`. */ + fun error(error: Optional<String>) = error(error.getOrNull()) + + /** + * Sets [Builder.error] to an arbitrary JSON value. + * + * You should usually call [Builder.error] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun error(error: JsonField<String>) = apply { this.error = error } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InsightCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InsightCreateResponse = + InsightCreateResponse( + checkRequired("id", id), + checkRequired("name", name), + checkRequired("status", status), + error, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InsightCreateResponse = apply { + if (validated) { + return@apply + } + + id() + name() + status() + error() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (status.asKnown().isPresent) 1 else 0) + + (if (error.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InsightCreateResponse && + id == other.id && + name == other.name && + status == other.status && + error == other.error && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, name, status, error, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InsightCreateResponse{id=$id, name=$name, status=$status, error=$error, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightDeleteParams.kt new file mode 100644 index 00000000..c78dc2b0 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightDeleteParams.kt @@ -0,0 +1,258 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete a session cluster job. */ +class InsightDeleteParams +private constructor( + private val sessionId: String, + private val jobId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun sessionId(): String = sessionId + + fun jobId(): Optional<String> = Optional.ofNullable(jobId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InsightDeleteParams]. + * + * The following fields are required: + * ```java + * .sessionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InsightDeleteParams]. */ + class Builder internal constructor() { + + private var sessionId: String? = null + private var jobId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(insightDeleteParams: InsightDeleteParams) = apply { + sessionId = insightDeleteParams.sessionId + jobId = insightDeleteParams.jobId + additionalHeaders = insightDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = insightDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = insightDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun sessionId(sessionId: String) = apply { this.sessionId = sessionId } + + fun jobId(jobId: String?) = apply { this.jobId = jobId } + + /** Alias for calling [Builder.jobId] with `jobId.orElse(null)`. */ + fun jobId(jobId: Optional<String>) = jobId(jobId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [InsightDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .sessionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InsightDeleteParams = + InsightDeleteParams( + checkRequired("sessionId", sessionId), + jobId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> sessionId + 1 -> jobId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InsightDeleteParams && + sessionId == other.sessionId && + jobId == other.jobId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + sessionId, + jobId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "InsightDeleteParams{sessionId=$sessionId, jobId=$jobId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightDeleteResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightDeleteResponse.kt new file mode 100644 index 00000000..8658620c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightDeleteResponse.kt @@ -0,0 +1,205 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +/** Response to delete a session cluster job. */ +class InsightDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val message: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("message") @ExcludeMissing message: JsonField<String> = JsonMissing.of(), + ) : this(id, message, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun message(): String = message.getRequired("message") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField<String> = message + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InsightDeleteResponse]. + * + * The following fields are required: + * ```java + * .id() + * .message() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InsightDeleteResponse]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var message: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(insightDeleteResponse: InsightDeleteResponse) = apply { + id = insightDeleteResponse.id + message = insightDeleteResponse.message + additionalProperties = insightDeleteResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun message(message: String) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun message(message: JsonField<String>) = apply { this.message = message } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InsightDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .message() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InsightDeleteResponse = + InsightDeleteResponse( + checkRequired("id", id), + checkRequired("message", message), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InsightDeleteResponse = apply { + if (validated) { + return@apply + } + + id() + message() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (message.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InsightDeleteResponse && + id == other.id && + message == other.message && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, message, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InsightDeleteResponse{id=$id, message=$message, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightListParams.kt new file mode 100644 index 00000000..e3dc4c49 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightListParams.kt @@ -0,0 +1,239 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get all clusters for a session. */ +class InsightListParams +private constructor( + private val sessionId: String?, + private val limit: Long?, + private val offset: Long?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun sessionId(): Optional<String> = Optional.ofNullable(sessionId) + + fun limit(): Optional<Long> = Optional.ofNullable(limit) + + fun offset(): Optional<Long> = Optional.ofNullable(offset) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): InsightListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [InsightListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InsightListParams]. */ + class Builder internal constructor() { + + private var sessionId: String? = null + private var limit: Long? = null + private var offset: Long? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(insightListParams: InsightListParams) = apply { + sessionId = insightListParams.sessionId + limit = insightListParams.limit + offset = insightListParams.offset + additionalHeaders = insightListParams.additionalHeaders.toBuilder() + additionalQueryParams = insightListParams.additionalQueryParams.toBuilder() + } + + fun sessionId(sessionId: String?) = apply { this.sessionId = sessionId } + + /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ + fun sessionId(sessionId: Optional<String>) = sessionId(sessionId.getOrNull()) + + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional<Long>) = limit(limit.getOrNull()) + + fun offset(offset: Long?) = apply { this.offset = offset } + + /** + * Alias for [Builder.offset]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun offset(offset: Long) = offset(offset as Long?) + + /** Alias for calling [Builder.offset] with `offset.orElse(null)`. */ + fun offset(offset: Optional<Long>) = offset(offset.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [InsightListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InsightListParams = + InsightListParams( + sessionId, + limit, + offset, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> sessionId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + limit?.let { put("limit", it.toString()) } + offset?.let { put("offset", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InsightListParams && + sessionId == other.sessionId && + limit == other.limit && + offset == other.offset && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(sessionId, limit, offset, additionalHeaders, additionalQueryParams) + + override fun toString() = + "InsightListParams{sessionId=$sessionId, limit=$limit, offset=$offset, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightListResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightListResponse.kt new file mode 100644 index 00000000..79be2bc0 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightListResponse.kt @@ -0,0 +1,611 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Response to get all cluster jobs for a session. */ +class InsightListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val clusteringJobs: JsonField<List<ClusteringJob>>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("clustering_jobs") + @ExcludeMissing + clusteringJobs: JsonField<List<ClusteringJob>> = JsonMissing.of() + ) : this(clusteringJobs, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun clusteringJobs(): List<ClusteringJob> = clusteringJobs.getRequired("clustering_jobs") + + /** + * Returns the raw JSON value of [clusteringJobs]. + * + * Unlike [clusteringJobs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("clustering_jobs") + @ExcludeMissing + fun _clusteringJobs(): JsonField<List<ClusteringJob>> = clusteringJobs + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InsightListResponse]. + * + * The following fields are required: + * ```java + * .clusteringJobs() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InsightListResponse]. */ + class Builder internal constructor() { + + private var clusteringJobs: JsonField<MutableList<ClusteringJob>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(insightListResponse: InsightListResponse) = apply { + clusteringJobs = insightListResponse.clusteringJobs.map { it.toMutableList() } + additionalProperties = insightListResponse.additionalProperties.toMutableMap() + } + + fun clusteringJobs(clusteringJobs: List<ClusteringJob>) = + clusteringJobs(JsonField.of(clusteringJobs)) + + /** + * Sets [Builder.clusteringJobs] to an arbitrary JSON value. + * + * You should usually call [Builder.clusteringJobs] with a well-typed `List<ClusteringJob>` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun clusteringJobs(clusteringJobs: JsonField<List<ClusteringJob>>) = apply { + this.clusteringJobs = clusteringJobs.map { it.toMutableList() } + } + + /** + * Adds a single [ClusteringJob] to [clusteringJobs]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addClusteringJob(clusteringJob: ClusteringJob) = apply { + clusteringJobs = + (clusteringJobs ?: JsonField.of(mutableListOf())).also { + checkKnown("clusteringJobs", it).add(clusteringJob) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InsightListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .clusteringJobs() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InsightListResponse = + InsightListResponse( + checkRequired("clusteringJobs", clusteringJobs).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InsightListResponse = apply { + if (validated) { + return@apply + } + + clusteringJobs().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (clusteringJobs.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Session cluster job */ + class ClusteringJob + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField<String>, + private val name: JsonField<String>, + private val status: JsonField<String>, + private val endTime: JsonField<OffsetDateTime>, + private val error: JsonField<String>, + private val metadata: JsonValue, + private val shape: JsonField<List<Long>>, + private val startTime: JsonField<OffsetDateTime>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField<String> = JsonMissing.of(), + @JsonProperty("end_time") + @ExcludeMissing + endTime: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("error") @ExcludeMissing error: JsonField<String> = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("shape") @ExcludeMissing shape: JsonField<List<Long>> = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField<OffsetDateTime> = JsonMissing.of(), + ) : this(id, name, status, endTime, error, metadata, shape, startTime, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): String = status.getRequired("status") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun endTime(): Optional<OffsetDateTime> = endTime.getOptional("end_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun error(): Optional<String> = error.getOptional("error") + + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun shape(): Optional<List<Long>> = shape.getOptional("shape") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun startTime(): Optional<OffsetDateTime> = startTime.getOptional("start_time") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField<String> = status + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_time") + @ExcludeMissing + fun _endTime(): JsonField<OffsetDateTime> = endTime + + /** + * Returns the raw JSON value of [error]. + * + * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("error") @ExcludeMissing fun _error(): JsonField<String> = error + + /** + * Returns the raw JSON value of [shape]. + * + * Unlike [shape], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("shape") @ExcludeMissing fun _shape(): JsonField<List<Long>> = shape + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_time") + @ExcludeMissing + fun _startTime(): JsonField<OffsetDateTime> = startTime + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ClusteringJob]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ClusteringJob]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var name: JsonField<String>? = null + private var status: JsonField<String>? = null + private var endTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var error: JsonField<String> = JsonMissing.of() + private var metadata: JsonValue = JsonMissing.of() + private var shape: JsonField<MutableList<Long>>? = null + private var startTime: JsonField<OffsetDateTime> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(clusteringJob: ClusteringJob) = apply { + id = clusteringJob.id + name = clusteringJob.name + status = clusteringJob.status + endTime = clusteringJob.endTime + error = clusteringJob.error + metadata = clusteringJob.metadata + shape = clusteringJob.shape.map { it.toMutableList() } + startTime = clusteringJob.startTime + additionalProperties = clusteringJob.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField<String>) = apply { this.status = status } + + fun endTime(endTime: OffsetDateTime?) = endTime(JsonField.ofNullable(endTime)) + + /** Alias for calling [Builder.endTime] with `endTime.orElse(null)`. */ + fun endTime(endTime: Optional<OffsetDateTime>) = endTime(endTime.getOrNull()) + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endTime(endTime: JsonField<OffsetDateTime>) = apply { this.endTime = endTime } + + fun error(error: String?) = error(JsonField.ofNullable(error)) + + /** Alias for calling [Builder.error] with `error.orElse(null)`. */ + fun error(error: Optional<String>) = error(error.getOrNull()) + + /** + * Sets [Builder.error] to an arbitrary JSON value. + * + * You should usually call [Builder.error] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun error(error: JsonField<String>) = apply { this.error = error } + + fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + + fun shape(shape: List<Long>?) = shape(JsonField.ofNullable(shape)) + + /** Alias for calling [Builder.shape] with `shape.orElse(null)`. */ + fun shape(shape: Optional<List<Long>>) = shape(shape.getOrNull()) + + /** + * Sets [Builder.shape] to an arbitrary JSON value. + * + * You should usually call [Builder.shape] with a well-typed `List<Long>` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun shape(shape: JsonField<List<Long>>) = apply { + this.shape = shape.map { it.toMutableList() } + } + + /** + * Adds a single [Long] to [Builder.shape]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addShape(shape: Long) = apply { + this.shape = + (this.shape ?: JsonField.of(mutableListOf())).also { + checkKnown("shape", it).add(shape) + } + } + + fun startTime(startTime: OffsetDateTime?) = startTime(JsonField.ofNullable(startTime)) + + /** Alias for calling [Builder.startTime] with `startTime.orElse(null)`. */ + fun startTime(startTime: Optional<OffsetDateTime>) = startTime(startTime.getOrNull()) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField<OffsetDateTime>) = apply { + this.startTime = startTime + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ClusteringJob]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ClusteringJob = + ClusteringJob( + checkRequired("id", id), + checkRequired("name", name), + checkRequired("status", status), + endTime, + error, + metadata, + (shape ?: JsonMissing.of()).map { it.toImmutable() }, + startTime, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ClusteringJob = apply { + if (validated) { + return@apply + } + + id() + name() + status() + endTime() + error() + shape() + startTime() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (status.asKnown().isPresent) 1 else 0) + + (if (endTime.asKnown().isPresent) 1 else 0) + + (if (error.asKnown().isPresent) 1 else 0) + + (shape.asKnown().getOrNull()?.size ?: 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ClusteringJob && + id == other.id && + name == other.name && + status == other.status && + endTime == other.endTime && + error == other.error && + metadata == other.metadata && + shape == other.shape && + startTime == other.startTime && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + name, + status, + endTime, + error, + metadata, + shape, + startTime, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ClusteringJob{id=$id, name=$name, status=$status, endTime=$endTime, error=$error, metadata=$metadata, shape=$shape, startTime=$startTime, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InsightListResponse && + clusteringJobs == other.clusteringJobs && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(clusteringJobs, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InsightListResponse{clusteringJobs=$clusteringJobs, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightRetrieveParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightRetrieveParams.kt new file mode 100644 index 00000000..73eb463d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightRetrieveParams.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get a specific cluster for a session. */ +class InsightRetrieveParams +private constructor( + private val sessionId: String, + private val jobId: String, + private val clusterId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun sessionId(): String = sessionId + + fun jobId(): String = jobId + + fun clusterId(): Optional<String> = Optional.ofNullable(clusterId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InsightRetrieveParams]. + * + * The following fields are required: + * ```java + * .sessionId() + * .jobId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InsightRetrieveParams]. */ + class Builder internal constructor() { + + private var sessionId: String? = null + private var jobId: String? = null + private var clusterId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(insightRetrieveParams: InsightRetrieveParams) = apply { + sessionId = insightRetrieveParams.sessionId + jobId = insightRetrieveParams.jobId + clusterId = insightRetrieveParams.clusterId + additionalHeaders = insightRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = insightRetrieveParams.additionalQueryParams.toBuilder() + } + + fun sessionId(sessionId: String) = apply { this.sessionId = sessionId } + + fun jobId(jobId: String) = apply { this.jobId = jobId } + + fun clusterId(clusterId: String?) = apply { this.clusterId = clusterId } + + /** Alias for calling [Builder.clusterId] with `clusterId.orElse(null)`. */ + fun clusterId(clusterId: Optional<String>) = clusterId(clusterId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [InsightRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .sessionId() + * .jobId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InsightRetrieveParams = + InsightRetrieveParams( + checkRequired("sessionId", sessionId), + checkRequired("jobId", jobId), + clusterId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> sessionId + 1 -> jobId + 2 -> clusterId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InsightRetrieveParams && + sessionId == other.sessionId && + jobId == other.jobId && + clusterId == other.clusterId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(sessionId, jobId, clusterId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "InsightRetrieveParams{sessionId=$sessionId, jobId=$jobId, clusterId=$clusterId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightRetrieveResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightRetrieveResponse.kt new file mode 100644 index 00000000..3ef34ce0 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightRetrieveResponse.kt @@ -0,0 +1,349 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Response to get a specific cluster from a specific cluster job. */ +class InsightRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val description: JsonField<String>, + private val level: JsonField<Long>, + private val name: JsonField<String>, + private val numChildren: JsonField<Long>, + private val parentId: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("level") @ExcludeMissing level: JsonField<Long> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("num_children") + @ExcludeMissing + numChildren: JsonField<Long> = JsonMissing.of(), + @JsonProperty("parent_id") @ExcludeMissing parentId: JsonField<String> = JsonMissing.of(), + ) : this(id, description, level, name, numChildren, parentId, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun description(): String = description.getRequired("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun level(): Long = level.getRequired("level") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun numChildren(): Long = numChildren.getRequired("num_children") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun parentId(): Optional<String> = parentId.getOptional("parent_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [level]. + * + * Unlike [level], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("level") @ExcludeMissing fun _level(): JsonField<Long> = level + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [numChildren]. + * + * Unlike [numChildren], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("num_children") @ExcludeMissing fun _numChildren(): JsonField<Long> = numChildren + + /** + * Returns the raw JSON value of [parentId]. + * + * Unlike [parentId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("parent_id") @ExcludeMissing fun _parentId(): JsonField<String> = parentId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InsightRetrieveResponse]. + * + * The following fields are required: + * ```java + * .id() + * .description() + * .level() + * .name() + * .numChildren() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InsightRetrieveResponse]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var description: JsonField<String>? = null + private var level: JsonField<Long>? = null + private var name: JsonField<String>? = null + private var numChildren: JsonField<Long>? = null + private var parentId: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(insightRetrieveResponse: InsightRetrieveResponse) = apply { + id = insightRetrieveResponse.id + description = insightRetrieveResponse.description + level = insightRetrieveResponse.level + name = insightRetrieveResponse.name + numChildren = insightRetrieveResponse.numChildren + parentId = insightRetrieveResponse.parentId + additionalProperties = insightRetrieveResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { this.description = description } + + fun level(level: Long) = level(JsonField.of(level)) + + /** + * Sets [Builder.level] to an arbitrary JSON value. + * + * You should usually call [Builder.level] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun level(level: JsonField<Long>) = apply { this.level = level } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun numChildren(numChildren: Long) = numChildren(JsonField.of(numChildren)) + + /** + * Sets [Builder.numChildren] to an arbitrary JSON value. + * + * You should usually call [Builder.numChildren] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun numChildren(numChildren: JsonField<Long>) = apply { this.numChildren = numChildren } + + fun parentId(parentId: String?) = parentId(JsonField.ofNullable(parentId)) + + /** Alias for calling [Builder.parentId] with `parentId.orElse(null)`. */ + fun parentId(parentId: Optional<String>) = parentId(parentId.getOrNull()) + + /** + * Sets [Builder.parentId] to an arbitrary JSON value. + * + * You should usually call [Builder.parentId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun parentId(parentId: JsonField<String>) = apply { this.parentId = parentId } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InsightRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .description() + * .level() + * .name() + * .numChildren() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InsightRetrieveResponse = + InsightRetrieveResponse( + checkRequired("id", id), + checkRequired("description", description), + checkRequired("level", level), + checkRequired("name", name), + checkRequired("numChildren", numChildren), + parentId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InsightRetrieveResponse = apply { + if (validated) { + return@apply + } + + id() + description() + level() + name() + numChildren() + parentId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (level.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (numChildren.asKnown().isPresent) 1 else 0) + + (if (parentId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InsightRetrieveResponse && + id == other.id && + description == other.description && + level == other.level && + name == other.name && + numChildren == other.numChildren && + parentId == other.parentId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, description, level, name, numChildren, parentId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InsightRetrieveResponse{id=$id, description=$description, level=$level, name=$name, numChildren=$numChildren, parentId=$parentId, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightRetrieveRunsParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightRetrieveRunsParams.kt new file mode 100644 index 00000000..a657d58c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightRetrieveRunsParams.kt @@ -0,0 +1,455 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights + +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get all runs for a cluster job, optionally filtered by cluster. */ +class InsightRetrieveRunsParams +private constructor( + private val sessionId: String, + private val jobId: String?, + private val attributeSortKey: String?, + private val attributeSortOrder: AttributeSortOrder?, + private val clusterId: String?, + private val limit: Long?, + private val offset: Long?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun sessionId(): String = sessionId + + fun jobId(): Optional<String> = Optional.ofNullable(jobId) + + fun attributeSortKey(): Optional<String> = Optional.ofNullable(attributeSortKey) + + fun attributeSortOrder(): Optional<AttributeSortOrder> = Optional.ofNullable(attributeSortOrder) + + fun clusterId(): Optional<String> = Optional.ofNullable(clusterId) + + fun limit(): Optional<Long> = Optional.ofNullable(limit) + + fun offset(): Optional<Long> = Optional.ofNullable(offset) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InsightRetrieveRunsParams]. + * + * The following fields are required: + * ```java + * .sessionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InsightRetrieveRunsParams]. */ + class Builder internal constructor() { + + private var sessionId: String? = null + private var jobId: String? = null + private var attributeSortKey: String? = null + private var attributeSortOrder: AttributeSortOrder? = null + private var clusterId: String? = null + private var limit: Long? = null + private var offset: Long? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(insightRetrieveRunsParams: InsightRetrieveRunsParams) = apply { + sessionId = insightRetrieveRunsParams.sessionId + jobId = insightRetrieveRunsParams.jobId + attributeSortKey = insightRetrieveRunsParams.attributeSortKey + attributeSortOrder = insightRetrieveRunsParams.attributeSortOrder + clusterId = insightRetrieveRunsParams.clusterId + limit = insightRetrieveRunsParams.limit + offset = insightRetrieveRunsParams.offset + additionalHeaders = insightRetrieveRunsParams.additionalHeaders.toBuilder() + additionalQueryParams = insightRetrieveRunsParams.additionalQueryParams.toBuilder() + } + + fun sessionId(sessionId: String) = apply { this.sessionId = sessionId } + + fun jobId(jobId: String?) = apply { this.jobId = jobId } + + /** Alias for calling [Builder.jobId] with `jobId.orElse(null)`. */ + fun jobId(jobId: Optional<String>) = jobId(jobId.getOrNull()) + + fun attributeSortKey(attributeSortKey: String?) = apply { + this.attributeSortKey = attributeSortKey + } + + /** Alias for calling [Builder.attributeSortKey] with `attributeSortKey.orElse(null)`. */ + fun attributeSortKey(attributeSortKey: Optional<String>) = + attributeSortKey(attributeSortKey.getOrNull()) + + fun attributeSortOrder(attributeSortOrder: AttributeSortOrder?) = apply { + this.attributeSortOrder = attributeSortOrder + } + + /** + * Alias for calling [Builder.attributeSortOrder] with `attributeSortOrder.orElse(null)`. + */ + fun attributeSortOrder(attributeSortOrder: Optional<AttributeSortOrder>) = + attributeSortOrder(attributeSortOrder.getOrNull()) + + fun clusterId(clusterId: String?) = apply { this.clusterId = clusterId } + + /** Alias for calling [Builder.clusterId] with `clusterId.orElse(null)`. */ + fun clusterId(clusterId: Optional<String>) = clusterId(clusterId.getOrNull()) + + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional<Long>) = limit(limit.getOrNull()) + + fun offset(offset: Long?) = apply { this.offset = offset } + + /** + * Alias for [Builder.offset]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun offset(offset: Long) = offset(offset as Long?) + + /** Alias for calling [Builder.offset] with `offset.orElse(null)`. */ + fun offset(offset: Optional<Long>) = offset(offset.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [InsightRetrieveRunsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .sessionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InsightRetrieveRunsParams = + InsightRetrieveRunsParams( + checkRequired("sessionId", sessionId), + jobId, + attributeSortKey, + attributeSortOrder, + clusterId, + limit, + offset, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> sessionId + 1 -> jobId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + attributeSortKey?.let { put("attribute_sort_key", it) } + attributeSortOrder?.let { put("attribute_sort_order", it.toString()) } + clusterId?.let { put("cluster_id", it) } + limit?.let { put("limit", it.toString()) } + offset?.let { put("offset", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + class AttributeSortOrder + @JsonCreator + private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val ASC = of("asc") + + @JvmField val DESC = of("desc") + + @JvmStatic fun of(value: String) = AttributeSortOrder(JsonField.of(value)) + } + + /** An enum containing [AttributeSortOrder]'s known values. */ + enum class Known { + ASC, + DESC, + } + + /** + * An enum containing [AttributeSortOrder]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AttributeSortOrder] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ASC, + DESC, + /** + * An enum member indicating that [AttributeSortOrder] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ASC -> Value.ASC + DESC -> Value.DESC + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ASC -> Known.ASC + DESC -> Known.DESC + else -> throw LangsmithApiInvalidDataException("Unknown AttributeSortOrder: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AttributeSortOrder = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AttributeSortOrder && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InsightRetrieveRunsParams && + sessionId == other.sessionId && + jobId == other.jobId && + attributeSortKey == other.attributeSortKey && + attributeSortOrder == other.attributeSortOrder && + clusterId == other.clusterId && + limit == other.limit && + offset == other.offset && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + sessionId, + jobId, + attributeSortKey, + attributeSortOrder, + clusterId, + limit, + offset, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "InsightRetrieveRunsParams{sessionId=$sessionId, jobId=$jobId, attributeSortKey=$attributeSortKey, attributeSortOrder=$attributeSortOrder, clusterId=$clusterId, limit=$limit, offset=$offset, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightRetrieveRunsResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightRetrieveRunsResponse.kt new file mode 100644 index 00000000..ba02d2ab --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightRetrieveRunsResponse.kt @@ -0,0 +1,230 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class InsightRetrieveRunsResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val offset: JsonField<Long>, + private val runs: JsonField<List<JsonValue>>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("offset") @ExcludeMissing offset: JsonField<Long> = JsonMissing.of(), + @JsonProperty("runs") @ExcludeMissing runs: JsonField<List<JsonValue>> = JsonMissing.of(), + ) : this(offset, runs, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun offset(): Optional<Long> = offset.getOptional("offset") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun runs(): List<JsonValue> = runs.getRequired("runs") + + /** + * Returns the raw JSON value of [offset]. + * + * Unlike [offset], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("offset") @ExcludeMissing fun _offset(): JsonField<Long> = offset + + /** + * Returns the raw JSON value of [runs]. + * + * Unlike [runs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("runs") @ExcludeMissing fun _runs(): JsonField<List<JsonValue>> = runs + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InsightRetrieveRunsResponse]. + * + * The following fields are required: + * ```java + * .offset() + * .runs() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InsightRetrieveRunsResponse]. */ + class Builder internal constructor() { + + private var offset: JsonField<Long>? = null + private var runs: JsonField<MutableList<JsonValue>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(insightRetrieveRunsResponse: InsightRetrieveRunsResponse) = apply { + offset = insightRetrieveRunsResponse.offset + runs = insightRetrieveRunsResponse.runs.map { it.toMutableList() } + additionalProperties = insightRetrieveRunsResponse.additionalProperties.toMutableMap() + } + + fun offset(offset: Long?) = offset(JsonField.ofNullable(offset)) + + /** + * Alias for [Builder.offset]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun offset(offset: Long) = offset(offset as Long?) + + /** Alias for calling [Builder.offset] with `offset.orElse(null)`. */ + fun offset(offset: Optional<Long>) = offset(offset.getOrNull()) + + /** + * Sets [Builder.offset] to an arbitrary JSON value. + * + * You should usually call [Builder.offset] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun offset(offset: JsonField<Long>) = apply { this.offset = offset } + + fun runs(runs: List<JsonValue>) = runs(JsonField.of(runs)) + + /** + * Sets [Builder.runs] to an arbitrary JSON value. + * + * You should usually call [Builder.runs] with a well-typed `List<JsonValue>` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun runs(runs: JsonField<List<JsonValue>>) = apply { + this.runs = runs.map { it.toMutableList() } + } + + /** + * Adds a single [JsonValue] to [runs]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRun(run: JsonValue) = apply { + runs = (runs ?: JsonField.of(mutableListOf())).also { checkKnown("runs", it).add(run) } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InsightRetrieveRunsResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .offset() + * .runs() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InsightRetrieveRunsResponse = + InsightRetrieveRunsResponse( + checkRequired("offset", offset), + checkRequired("runs", runs).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InsightRetrieveRunsResponse = apply { + if (validated) { + return@apply + } + + offset() + runs() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (offset.asKnown().isPresent) 1 else 0) + (runs.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InsightRetrieveRunsResponse && + offset == other.offset && + runs == other.runs && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(offset, runs, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InsightRetrieveRunsResponse{offset=$offset, runs=$runs, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightUpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightUpdateParams.kt new file mode 100644 index 00000000..76f05196 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightUpdateParams.kt @@ -0,0 +1,442 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Update a session cluster job. */ +class InsightUpdateParams +private constructor( + private val sessionId: String, + private val jobId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun sessionId(): String = sessionId + + fun jobId(): Optional<String> = Optional.ofNullable(jobId) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = body.name() + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _name(): JsonField<String> = body._name() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InsightUpdateParams]. + * + * The following fields are required: + * ```java + * .sessionId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InsightUpdateParams]. */ + class Builder internal constructor() { + + private var sessionId: String? = null + private var jobId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(insightUpdateParams: InsightUpdateParams) = apply { + sessionId = insightUpdateParams.sessionId + jobId = insightUpdateParams.jobId + body = insightUpdateParams.body.toBuilder() + additionalHeaders = insightUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = insightUpdateParams.additionalQueryParams.toBuilder() + } + + fun sessionId(sessionId: String) = apply { this.sessionId = sessionId } + + fun jobId(jobId: String?) = apply { this.jobId = jobId } + + /** Alias for calling [Builder.jobId] with `jobId.orElse(null)`. */ + fun jobId(jobId: Optional<String>) = jobId(jobId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [name] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun name(name: String) = apply { body.name(name) } + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { body.name(name) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [InsightUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .sessionId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InsightUpdateParams = + InsightUpdateParams( + checkRequired("sessionId", sessionId), + jobId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> sessionId + 1 -> jobId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Request to update a session cluster job. */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val name: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of() + ) : this(name, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var name: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + name = body.name + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body(checkRequired("name", name), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Body{name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InsightUpdateParams && + sessionId == other.sessionId && + jobId == other.jobId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(sessionId, jobId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "InsightUpdateParams{sessionId=$sessionId, jobId=$jobId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightUpdateResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightUpdateResponse.kt new file mode 100644 index 00000000..478e1b11 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightUpdateResponse.kt @@ -0,0 +1,205 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +/** Response to update a session cluster job. */ +class InsightUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val name: JsonField<String>, + private val status: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField<String> = JsonMissing.of(), + ) : this(name, status, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): String = status.getRequired("status") + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField<String> = status + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InsightUpdateResponse]. + * + * The following fields are required: + * ```java + * .name() + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InsightUpdateResponse]. */ + class Builder internal constructor() { + + private var name: JsonField<String>? = null + private var status: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(insightUpdateResponse: InsightUpdateResponse) = apply { + name = insightUpdateResponse.name + status = insightUpdateResponse.status + additionalProperties = insightUpdateResponse.additionalProperties.toMutableMap() + } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField<String>) = apply { this.status = status } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InsightUpdateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InsightUpdateResponse = + InsightUpdateResponse( + checkRequired("name", name), + checkRequired("status", status), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InsightUpdateResponse = apply { + if (validated) { + return@apply + } + + name() + status() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (name.asKnown().isPresent) 1 else 0) + (if (status.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InsightUpdateResponse && + name == other.name && + status == other.status && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(name, status, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InsightUpdateResponse{name=$name, status=$status, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigCreateParams.kt new file mode 100644 index 00000000..c2ffa05e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigCreateParams.kt @@ -0,0 +1,581 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights.configs + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.sessions.insights.CreateRunClusteringJobRequest +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Save an insights job config. */ +class ConfigCreateParams +private constructor( + private val sessionId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun sessionId(): Optional<String> = Optional.ofNullable(sessionId) + + /** + * Request to create a run clustering job. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun config(): CreateRunClusteringJobRequest = body.config() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = body.name() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = body.description() + + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _config(): JsonField<CreateRunClusteringJobRequest> = body._config() + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _name(): JsonField<String> = body._name() + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _description(): JsonField<String> = body._description() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ConfigCreateParams]. + * + * The following fields are required: + * ```java + * .config() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConfigCreateParams]. */ + class Builder internal constructor() { + + private var sessionId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(configCreateParams: ConfigCreateParams) = apply { + sessionId = configCreateParams.sessionId + body = configCreateParams.body.toBuilder() + additionalHeaders = configCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = configCreateParams.additionalQueryParams.toBuilder() + } + + fun sessionId(sessionId: String?) = apply { this.sessionId = sessionId } + + /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ + fun sessionId(sessionId: Optional<String>) = sessionId(sessionId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [config] + * - [name] + * - [description] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** Request to create a run clustering job. */ + fun config(config: CreateRunClusteringJobRequest) = apply { body.config(config) } + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed + * [CreateRunClusteringJobRequest] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun config(config: JsonField<CreateRunClusteringJobRequest>) = apply { body.config(config) } + + fun name(name: String) = apply { body.name(name) } + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { body.name(name) } + + fun description(description: String?) = apply { body.description(description) } + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { body.description(description) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ConfigCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .config() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConfigCreateParams = + ConfigCreateParams( + sessionId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> sessionId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Request to create a clustering job config. */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val config: JsonField<CreateRunClusteringJobRequest>, + private val name: JsonField<String>, + private val description: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("config") + @ExcludeMissing + config: JsonField<CreateRunClusteringJobRequest> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + ) : this(config, name, description, mutableMapOf()) + + /** + * Request to create a run clustering job. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun config(): CreateRunClusteringJobRequest = config.getRequired("config") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("config") + @ExcludeMissing + fun _config(): JsonField<CreateRunClusteringJobRequest> = config + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField<String> = description + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .config() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var config: JsonField<CreateRunClusteringJobRequest>? = null + private var name: JsonField<String>? = null + private var description: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + config = body.config + name = body.name + description = body.description + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** Request to create a run clustering job. */ + fun config(config: CreateRunClusteringJobRequest) = config(JsonField.of(config)) + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed + * [CreateRunClusteringJobRequest] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun config(config: JsonField<CreateRunClusteringJobRequest>) = apply { + this.config = config + } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField<String>) = apply { + this.description = description + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .config() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("config", config), + checkRequired("name", name), + description, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + config().validate() + name() + description() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (config.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + config == other.config && + name == other.name && + description == other.description && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(config, name, description, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{config=$config, name=$name, description=$description, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConfigCreateParams && + sessionId == other.sessionId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(sessionId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ConfigCreateParams{sessionId=$sessionId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigDeleteParams.kt new file mode 100644 index 00000000..9d0c7d38 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigDeleteParams.kt @@ -0,0 +1,258 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights.configs + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete an insights job config. */ +class ConfigDeleteParams +private constructor( + private val sessionId: String, + private val configId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun sessionId(): String = sessionId + + fun configId(): Optional<String> = Optional.ofNullable(configId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ConfigDeleteParams]. + * + * The following fields are required: + * ```java + * .sessionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConfigDeleteParams]. */ + class Builder internal constructor() { + + private var sessionId: String? = null + private var configId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(configDeleteParams: ConfigDeleteParams) = apply { + sessionId = configDeleteParams.sessionId + configId = configDeleteParams.configId + additionalHeaders = configDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = configDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = configDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun sessionId(sessionId: String) = apply { this.sessionId = sessionId } + + fun configId(configId: String?) = apply { this.configId = configId } + + /** Alias for calling [Builder.configId] with `configId.orElse(null)`. */ + fun configId(configId: Optional<String>) = configId(configId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [ConfigDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .sessionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConfigDeleteParams = + ConfigDeleteParams( + checkRequired("sessionId", sessionId), + configId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> sessionId + 1 -> configId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConfigDeleteParams && + sessionId == other.sessionId && + configId == other.configId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + sessionId, + configId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "ConfigDeleteParams{sessionId=$sessionId, configId=$configId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigDeleteResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigDeleteResponse.kt new file mode 100644 index 00000000..c34ee541 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigDeleteResponse.kt @@ -0,0 +1,205 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights.configs + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +/** Response to delete a clustering job config. */ +class ConfigDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val message: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("message") @ExcludeMissing message: JsonField<String> = JsonMissing.of(), + ) : this(id, message, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun message(): String = message.getRequired("message") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField<String> = message + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ConfigDeleteResponse]. + * + * The following fields are required: + * ```java + * .id() + * .message() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConfigDeleteResponse]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var message: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(configDeleteResponse: ConfigDeleteResponse) = apply { + id = configDeleteResponse.id + message = configDeleteResponse.message + additionalProperties = configDeleteResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun message(message: String) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun message(message: JsonField<String>) = apply { this.message = message } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ConfigDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .message() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConfigDeleteResponse = + ConfigDeleteResponse( + checkRequired("id", id), + checkRequired("message", message), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConfigDeleteResponse = apply { + if (validated) { + return@apply + } + + id() + message() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (message.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConfigDeleteResponse && + id == other.id && + message == other.message && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, message, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConfigDeleteResponse{id=$id, message=$message, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigGenerateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigGenerateParams.kt new file mode 100644 index 00000000..e5cf4214 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigGenerateParams.kt @@ -0,0 +1,729 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights.configs + +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.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Auto-generate an insights job config. */ +class ConfigGenerateParams +private constructor( + private val sessionId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun sessionId(): Optional<String> = Optional.ofNullable(sessionId) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun userContext(): UserContext = body.userContext() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun model(): Optional<Model> = body.model() + + /** + * Returns the raw JSON value of [userContext]. + * + * Unlike [userContext], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _userContext(): JsonField<UserContext> = body._userContext() + + /** + * Returns the raw JSON value of [model]. + * + * Unlike [model], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _model(): JsonField<Model> = body._model() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ConfigGenerateParams]. + * + * The following fields are required: + * ```java + * .userContext() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConfigGenerateParams]. */ + class Builder internal constructor() { + + private var sessionId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(configGenerateParams: ConfigGenerateParams) = apply { + sessionId = configGenerateParams.sessionId + body = configGenerateParams.body.toBuilder() + additionalHeaders = configGenerateParams.additionalHeaders.toBuilder() + additionalQueryParams = configGenerateParams.additionalQueryParams.toBuilder() + } + + fun sessionId(sessionId: String?) = apply { this.sessionId = sessionId } + + /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ + fun sessionId(sessionId: Optional<String>) = sessionId(sessionId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [userContext] + * - [model] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun userContext(userContext: UserContext) = apply { body.userContext(userContext) } + + /** + * Sets [Builder.userContext] to an arbitrary JSON value. + * + * You should usually call [Builder.userContext] with a well-typed [UserContext] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun userContext(userContext: JsonField<UserContext>) = apply { + body.userContext(userContext) + } + + fun model(model: Model) = apply { body.model(model) } + + /** + * Sets [Builder.model] to an arbitrary JSON value. + * + * You should usually call [Builder.model] with a well-typed [Model] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun model(model: JsonField<Model>) = apply { body.model(model) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ConfigGenerateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .userContext() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConfigGenerateParams = + ConfigGenerateParams( + sessionId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> sessionId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Request to auto-generate a clustering job config. */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val userContext: JsonField<UserContext>, + private val model: JsonField<Model>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("user_context") + @ExcludeMissing + userContext: JsonField<UserContext> = JsonMissing.of(), + @JsonProperty("model") @ExcludeMissing model: JsonField<Model> = JsonMissing.of(), + ) : this(userContext, model, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun userContext(): UserContext = userContext.getRequired("user_context") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun model(): Optional<Model> = model.getOptional("model") + + /** + * Returns the raw JSON value of [userContext]. + * + * Unlike [userContext], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user_context") + @ExcludeMissing + fun _userContext(): JsonField<UserContext> = userContext + + /** + * Returns the raw JSON value of [model]. + * + * Unlike [model], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("model") @ExcludeMissing fun _model(): JsonField<Model> = model + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .userContext() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var userContext: JsonField<UserContext>? = null + private var model: JsonField<Model> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + userContext = body.userContext + model = body.model + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun userContext(userContext: UserContext) = userContext(JsonField.of(userContext)) + + /** + * Sets [Builder.userContext] to an arbitrary JSON value. + * + * You should usually call [Builder.userContext] with a well-typed [UserContext] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun userContext(userContext: JsonField<UserContext>) = apply { + this.userContext = userContext + } + + fun model(model: Model) = model(JsonField.of(model)) + + /** + * Sets [Builder.model] to an arbitrary JSON value. + * + * You should usually call [Builder.model] with a well-typed [Model] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun model(model: JsonField<Model>) = apply { this.model = model } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .userContext() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("userContext", userContext), + model, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + userContext().validate() + model().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (userContext.asKnown().getOrNull()?.validity() ?: 0) + + (model.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + userContext == other.userContext && + model == other.model && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(userContext, model, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{userContext=$userContext, model=$model, additionalProperties=$additionalProperties}" + } + + class UserContext + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UserContext]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UserContext]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(userContext: UserContext) = apply { + additionalProperties = userContext.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UserContext]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UserContext = UserContext(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): UserContext = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UserContext && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "UserContext{additionalProperties=$additionalProperties}" + } + + class Model @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val OPENAI = of("openai") + + @JvmField val ANTHROPIC = of("anthropic") + + @JvmStatic fun of(value: String) = Model(JsonField.of(value)) + } + + /** An enum containing [Model]'s known values. */ + enum class Known { + OPENAI, + ANTHROPIC, + } + + /** + * An enum containing [Model]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Model] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + OPENAI, + ANTHROPIC, + /** An enum member indicating that [Model] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + OPENAI -> Value.OPENAI + ANTHROPIC -> Value.ANTHROPIC + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + OPENAI -> Known.OPENAI + ANTHROPIC -> Known.ANTHROPIC + else -> throw LangsmithApiInvalidDataException("Unknown Model: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Model = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Model && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConfigGenerateParams && + sessionId == other.sessionId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(sessionId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ConfigGenerateParams{sessionId=$sessionId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigGenerateResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigGenerateResponse.kt new file mode 100644 index 00000000..a197d05b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigGenerateResponse.kt @@ -0,0 +1,362 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights.configs + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Auto-generated clustering job config. */ +class ConfigGenerateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val name: JsonField<String>, + private val summaryPrompt: JsonField<String>, + private val attributeSchemas: JsonField<AttributeSchemas>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("summary_prompt") + @ExcludeMissing + summaryPrompt: JsonField<String> = JsonMissing.of(), + @JsonProperty("attribute_schemas") + @ExcludeMissing + attributeSchemas: JsonField<AttributeSchemas> = JsonMissing.of(), + ) : this(name, summaryPrompt, attributeSchemas, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun summaryPrompt(): String = summaryPrompt.getRequired("summary_prompt") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun attributeSchemas(): Optional<AttributeSchemas> = + attributeSchemas.getOptional("attribute_schemas") + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [summaryPrompt]. + * + * Unlike [summaryPrompt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("summary_prompt") + @ExcludeMissing + fun _summaryPrompt(): JsonField<String> = summaryPrompt + + /** + * Returns the raw JSON value of [attributeSchemas]. + * + * Unlike [attributeSchemas], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("attribute_schemas") + @ExcludeMissing + fun _attributeSchemas(): JsonField<AttributeSchemas> = attributeSchemas + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ConfigGenerateResponse]. + * + * The following fields are required: + * ```java + * .name() + * .summaryPrompt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConfigGenerateResponse]. */ + class Builder internal constructor() { + + private var name: JsonField<String>? = null + private var summaryPrompt: JsonField<String>? = null + private var attributeSchemas: JsonField<AttributeSchemas> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(configGenerateResponse: ConfigGenerateResponse) = apply { + name = configGenerateResponse.name + summaryPrompt = configGenerateResponse.summaryPrompt + attributeSchemas = configGenerateResponse.attributeSchemas + additionalProperties = configGenerateResponse.additionalProperties.toMutableMap() + } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun summaryPrompt(summaryPrompt: String) = summaryPrompt(JsonField.of(summaryPrompt)) + + /** + * Sets [Builder.summaryPrompt] to an arbitrary JSON value. + * + * You should usually call [Builder.summaryPrompt] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun summaryPrompt(summaryPrompt: JsonField<String>) = apply { + this.summaryPrompt = summaryPrompt + } + + fun attributeSchemas(attributeSchemas: AttributeSchemas?) = + attributeSchemas(JsonField.ofNullable(attributeSchemas)) + + /** Alias for calling [Builder.attributeSchemas] with `attributeSchemas.orElse(null)`. */ + fun attributeSchemas(attributeSchemas: Optional<AttributeSchemas>) = + attributeSchemas(attributeSchemas.getOrNull()) + + /** + * Sets [Builder.attributeSchemas] to an arbitrary JSON value. + * + * You should usually call [Builder.attributeSchemas] with a well-typed [AttributeSchemas] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun attributeSchemas(attributeSchemas: JsonField<AttributeSchemas>) = apply { + this.attributeSchemas = attributeSchemas + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ConfigGenerateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .summaryPrompt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConfigGenerateResponse = + ConfigGenerateResponse( + checkRequired("name", name), + checkRequired("summaryPrompt", summaryPrompt), + attributeSchemas, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConfigGenerateResponse = apply { + if (validated) { + return@apply + } + + name() + summaryPrompt() + attributeSchemas().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (name.asKnown().isPresent) 1 else 0) + + (if (summaryPrompt.asKnown().isPresent) 1 else 0) + + (attributeSchemas.asKnown().getOrNull()?.validity() ?: 0) + + class AttributeSchemas + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [AttributeSchemas]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AttributeSchemas]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(attributeSchemas: AttributeSchemas) = apply { + additionalProperties = attributeSchemas.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AttributeSchemas]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AttributeSchemas = AttributeSchemas(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): AttributeSchemas = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AttributeSchemas && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "AttributeSchemas{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConfigGenerateResponse && + name == other.name && + summaryPrompt == other.summaryPrompt && + attributeSchemas == other.attributeSchemas && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(name, summaryPrompt, attributeSchemas, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConfigGenerateResponse{name=$name, summaryPrompt=$summaryPrompt, attributeSchemas=$attributeSchemas, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigListParams.kt new file mode 100644 index 00000000..8c2fed46 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigListParams.kt @@ -0,0 +1,223 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights.configs + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get all insights job configs for a session. */ +class ConfigListParams +private constructor( + private val sessionId: String?, + private val includePrebuilts: Boolean?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun sessionId(): Optional<String> = Optional.ofNullable(sessionId) + + fun includePrebuilts(): Optional<Boolean> = Optional.ofNullable(includePrebuilts) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ConfigListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ConfigListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConfigListParams]. */ + class Builder internal constructor() { + + private var sessionId: String? = null + private var includePrebuilts: Boolean? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(configListParams: ConfigListParams) = apply { + sessionId = configListParams.sessionId + includePrebuilts = configListParams.includePrebuilts + additionalHeaders = configListParams.additionalHeaders.toBuilder() + additionalQueryParams = configListParams.additionalQueryParams.toBuilder() + } + + fun sessionId(sessionId: String?) = apply { this.sessionId = sessionId } + + /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ + fun sessionId(sessionId: Optional<String>) = sessionId(sessionId.getOrNull()) + + fun includePrebuilts(includePrebuilts: Boolean?) = apply { + this.includePrebuilts = includePrebuilts + } + + /** + * Alias for [Builder.includePrebuilts]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun includePrebuilts(includePrebuilts: Boolean) = + includePrebuilts(includePrebuilts as Boolean?) + + /** Alias for calling [Builder.includePrebuilts] with `includePrebuilts.orElse(null)`. */ + fun includePrebuilts(includePrebuilts: Optional<Boolean>) = + includePrebuilts(includePrebuilts.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ConfigListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ConfigListParams = + ConfigListParams( + sessionId, + includePrebuilts, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> sessionId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + includePrebuilts?.let { put("include_prebuilts", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConfigListParams && + sessionId == other.sessionId && + includePrebuilts == other.includePrebuilts && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(sessionId, includePrebuilts, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ConfigListParams{sessionId=$sessionId, includePrebuilts=$includePrebuilts, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigListResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigListResponse.kt new file mode 100644 index 00000000..77312026 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigListResponse.kt @@ -0,0 +1,507 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights.configs + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Response to get clustering job configs. */ +class ConfigListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val configs: JsonField<List<Config>>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("configs") @ExcludeMissing configs: JsonField<List<Config>> = JsonMissing.of() + ) : this(configs, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun configs(): List<Config> = configs.getRequired("configs") + + /** + * Returns the raw JSON value of [configs]. + * + * Unlike [configs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("configs") @ExcludeMissing fun _configs(): JsonField<List<Config>> = configs + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ConfigListResponse]. + * + * The following fields are required: + * ```java + * .configs() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConfigListResponse]. */ + class Builder internal constructor() { + + private var configs: JsonField<MutableList<Config>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(configListResponse: ConfigListResponse) = apply { + configs = configListResponse.configs.map { it.toMutableList() } + additionalProperties = configListResponse.additionalProperties.toMutableMap() + } + + fun configs(configs: List<Config>) = configs(JsonField.of(configs)) + + /** + * Sets [Builder.configs] to an arbitrary JSON value. + * + * You should usually call [Builder.configs] with a well-typed `List<Config>` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun configs(configs: JsonField<List<Config>>) = apply { + this.configs = configs.map { it.toMutableList() } + } + + /** + * Adds a single [Config] to [configs]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addConfig(config: Config) = apply { + configs = + (configs ?: JsonField.of(mutableListOf())).also { + checkKnown("configs", it).add(config) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ConfigListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .configs() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConfigListResponse = + ConfigListResponse( + checkRequired("configs", configs).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConfigListResponse = apply { + if (validated) { + return@apply + } + + configs().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (configs.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Full clustering job config with all details. */ + class Config + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField<String>, + private val config: JsonField<SavedRunClusteringJobRequest>, + private val name: JsonField<String>, + private val prebuilt: JsonField<Boolean>, + private val description: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("config") + @ExcludeMissing + config: JsonField<SavedRunClusteringJobRequest> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("prebuilt") + @ExcludeMissing + prebuilt: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + ) : this(id, config, name, prebuilt, description, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * Request to create a run clustering job. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun config(): SavedRunClusteringJobRequest = config.getRequired("config") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun prebuilt(): Boolean = prebuilt.getRequired("prebuilt") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("config") + @ExcludeMissing + fun _config(): JsonField<SavedRunClusteringJobRequest> = config + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [prebuilt]. + * + * Unlike [prebuilt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prebuilt") @ExcludeMissing fun _prebuilt(): JsonField<Boolean> = prebuilt + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField<String> = description + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Config]. + * + * The following fields are required: + * ```java + * .id() + * .config() + * .name() + * .prebuilt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Config]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var config: JsonField<SavedRunClusteringJobRequest>? = null + private var name: JsonField<String>? = null + private var prebuilt: JsonField<Boolean>? = null + private var description: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(config: Config) = apply { + id = config.id + this.config = config.config + name = config.name + prebuilt = config.prebuilt + description = config.description + additionalProperties = config.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + /** Request to create a run clustering job. */ + fun config(config: SavedRunClusteringJobRequest) = config(JsonField.of(config)) + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed + * [SavedRunClusteringJobRequest] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun config(config: JsonField<SavedRunClusteringJobRequest>) = apply { + this.config = config + } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun prebuilt(prebuilt: Boolean) = prebuilt(JsonField.of(prebuilt)) + + /** + * Sets [Builder.prebuilt] to an arbitrary JSON value. + * + * You should usually call [Builder.prebuilt] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun prebuilt(prebuilt: JsonField<Boolean>) = apply { this.prebuilt = prebuilt } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField<String>) = apply { + this.description = description + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Config]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .config() + * .name() + * .prebuilt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Config = + Config( + checkRequired("id", id), + checkRequired("config", config), + checkRequired("name", name), + checkRequired("prebuilt", prebuilt), + description, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Config = apply { + if (validated) { + return@apply + } + + id() + config().validate() + name() + prebuilt() + description() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (config.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (prebuilt.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Config && + id == other.id && + config == other.config && + name == other.name && + prebuilt == other.prebuilt && + description == other.description && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, config, name, prebuilt, description, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Config{id=$id, config=$config, name=$name, prebuilt=$prebuilt, description=$description, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConfigListResponse && + configs == other.configs && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(configs, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConfigListResponse{configs=$configs, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigUpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigUpdateParams.kt new file mode 100644 index 00000000..69a37193 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigUpdateParams.kt @@ -0,0 +1,580 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights.configs + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.sessions.insights.CreateRunClusteringJobRequest +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Update an insights job config. */ +class ConfigUpdateParams +private constructor( + private val sessionId: String, + private val configId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun sessionId(): String = sessionId + + fun configId(): Optional<String> = Optional.ofNullable(configId) + + /** + * Request to create a run clustering job. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun config(): Optional<CreateRunClusteringJobRequest> = body.config() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = body.description() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional<String> = body.name() + + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _config(): JsonField<CreateRunClusteringJobRequest> = body._config() + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _description(): JsonField<String> = body._description() + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _name(): JsonField<String> = body._name() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ConfigUpdateParams]. + * + * The following fields are required: + * ```java + * .sessionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConfigUpdateParams]. */ + class Builder internal constructor() { + + private var sessionId: String? = null + private var configId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(configUpdateParams: ConfigUpdateParams) = apply { + sessionId = configUpdateParams.sessionId + configId = configUpdateParams.configId + body = configUpdateParams.body.toBuilder() + additionalHeaders = configUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = configUpdateParams.additionalQueryParams.toBuilder() + } + + fun sessionId(sessionId: String) = apply { this.sessionId = sessionId } + + fun configId(configId: String?) = apply { this.configId = configId } + + /** Alias for calling [Builder.configId] with `configId.orElse(null)`. */ + fun configId(configId: Optional<String>) = configId(configId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [config] + * - [description] + * - [name] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** Request to create a run clustering job. */ + fun config(config: CreateRunClusteringJobRequest?) = apply { body.config(config) } + + /** Alias for calling [Builder.config] with `config.orElse(null)`. */ + fun config(config: Optional<CreateRunClusteringJobRequest>) = config(config.getOrNull()) + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed + * [CreateRunClusteringJobRequest] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun config(config: JsonField<CreateRunClusteringJobRequest>) = apply { body.config(config) } + + fun description(description: String?) = apply { body.description(description) } + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { body.description(description) } + + fun name(name: String?) = apply { body.name(name) } + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional<String>) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { body.name(name) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ConfigUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .sessionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConfigUpdateParams = + ConfigUpdateParams( + checkRequired("sessionId", sessionId), + configId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> sessionId + 1 -> configId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Request to update a clustering job config. */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val config: JsonField<CreateRunClusteringJobRequest>, + private val description: JsonField<String>, + private val name: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("config") + @ExcludeMissing + config: JsonField<CreateRunClusteringJobRequest> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + ) : this(config, description, name, mutableMapOf()) + + /** + * Request to create a run clustering job. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun config(): Optional<CreateRunClusteringJobRequest> = config.getOptional("config") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun name(): Optional<String> = name.getOptional("name") + + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("config") + @ExcludeMissing + fun _config(): JsonField<CreateRunClusteringJobRequest> = config + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var config: JsonField<CreateRunClusteringJobRequest> = JsonMissing.of() + private var description: JsonField<String> = JsonMissing.of() + private var name: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + config = body.config + description = body.description + name = body.name + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** Request to create a run clustering job. */ + fun config(config: CreateRunClusteringJobRequest?) = + config(JsonField.ofNullable(config)) + + /** Alias for calling [Builder.config] with `config.orElse(null)`. */ + fun config(config: Optional<CreateRunClusteringJobRequest>) = config(config.getOrNull()) + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed + * [CreateRunClusteringJobRequest] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun config(config: JsonField<CreateRunClusteringJobRequest>) = apply { + this.config = config + } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField<String>) = apply { + this.description = description + } + + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional<String>) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = Body(config, description, name, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + config().ifPresent { it.validate() } + description() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (config.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + config == other.config && + description == other.description && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(config, description, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{config=$config, description=$description, name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConfigUpdateParams && + sessionId == other.sessionId && + configId == other.configId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(sessionId, configId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ConfigUpdateParams{sessionId=$sessionId, configId=$configId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/CreateClusteringJobConfigResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/CreateClusteringJobConfigResponse.kt new file mode 100644 index 00000000..793ce758 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/CreateClusteringJobConfigResponse.kt @@ -0,0 +1,293 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights.configs + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Response to create a clustering job config. */ +class CreateClusteringJobConfigResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val config: JsonField<SavedRunClusteringJobRequest>, + private val description: JsonField<String>, + private val name: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("config") + @ExcludeMissing + config: JsonField<SavedRunClusteringJobRequest> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + ) : this(id, config, description, name, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * Request to create a run clustering job. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun config(): SavedRunClusteringJobRequest = config.getRequired("config") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("config") + @ExcludeMissing + fun _config(): JsonField<SavedRunClusteringJobRequest> = config + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CreateClusteringJobConfigResponse]. + * + * The following fields are required: + * ```java + * .id() + * .config() + * .description() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreateClusteringJobConfigResponse]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var config: JsonField<SavedRunClusteringJobRequest>? = null + private var description: JsonField<String>? = null + private var name: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(createClusteringJobConfigResponse: CreateClusteringJobConfigResponse) = + apply { + id = createClusteringJobConfigResponse.id + config = createClusteringJobConfigResponse.config + description = createClusteringJobConfigResponse.description + name = createClusteringJobConfigResponse.name + additionalProperties = + createClusteringJobConfigResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + /** Request to create a run clustering job. */ + fun config(config: SavedRunClusteringJobRequest) = config(JsonField.of(config)) + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed [SavedRunClusteringJobRequest] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun config(config: JsonField<SavedRunClusteringJobRequest>) = apply { this.config = config } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { this.description = description } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CreateClusteringJobConfigResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .config() + * .description() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CreateClusteringJobConfigResponse = + CreateClusteringJobConfigResponse( + checkRequired("id", id), + checkRequired("config", config), + checkRequired("description", description), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CreateClusteringJobConfigResponse = apply { + if (validated) { + return@apply + } + + id() + config().validate() + description() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (config.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreateClusteringJobConfigResponse && + id == other.id && + config == other.config && + description == other.description && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, config, description, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreateClusteringJobConfigResponse{id=$id, config=$config, description=$description, name=$name, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/SavedRunClusteringJobRequest.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/SavedRunClusteringJobRequest.kt new file mode 100644 index 00000000..a47c4692 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/SavedRunClusteringJobRequest.kt @@ -0,0 +1,732 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights.configs + +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.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Request to create a run clustering job. */ +class SavedRunClusteringJobRequest +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val attributeSchemas: JsonValue, + private val filter: JsonField<String>, + private val hierarchy: JsonField<List<Long>>, + private val lastNHours: JsonField<Long>, + private val model: JsonField<Model>, + private val name: JsonField<String>, + private val partitions: JsonField<Partitions>, + private val sample: JsonField<Double>, + private val summaryPrompt: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("attribute_schemas") + @ExcludeMissing + attributeSchemas: JsonValue = JsonMissing.of(), + @JsonProperty("filter") @ExcludeMissing filter: JsonField<String> = JsonMissing.of(), + @JsonProperty("hierarchy") + @ExcludeMissing + hierarchy: JsonField<List<Long>> = JsonMissing.of(), + @JsonProperty("last_n_hours") + @ExcludeMissing + lastNHours: JsonField<Long> = JsonMissing.of(), + @JsonProperty("model") @ExcludeMissing model: JsonField<Model> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("partitions") + @ExcludeMissing + partitions: JsonField<Partitions> = JsonMissing.of(), + @JsonProperty("sample") @ExcludeMissing sample: JsonField<Double> = JsonMissing.of(), + @JsonProperty("summary_prompt") + @ExcludeMissing + summaryPrompt: JsonField<String> = JsonMissing.of(), + ) : this( + attributeSchemas, + filter, + hierarchy, + lastNHours, + model, + name, + partitions, + sample, + summaryPrompt, + mutableMapOf(), + ) + + @JsonProperty("attribute_schemas") + @ExcludeMissing + fun _attributeSchemas(): JsonValue = attributeSchemas + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun filter(): Optional<String> = filter.getOptional("filter") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun hierarchy(): Optional<List<Long>> = hierarchy.getOptional("hierarchy") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun lastNHours(): Long = lastNHours.getRequired("last_n_hours") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun model(): Model = model.getRequired("model") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun partitions(): Optional<Partitions> = partitions.getOptional("partitions") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun sample(): Optional<Double> = sample.getOptional("sample") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun summaryPrompt(): Optional<String> = summaryPrompt.getOptional("summary_prompt") + + /** + * Returns the raw JSON value of [filter]. + * + * Unlike [filter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField<String> = filter + + /** + * Returns the raw JSON value of [hierarchy]. + * + * Unlike [hierarchy], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("hierarchy") @ExcludeMissing fun _hierarchy(): JsonField<List<Long>> = hierarchy + + /** + * Returns the raw JSON value of [lastNHours]. + * + * Unlike [lastNHours], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("last_n_hours") @ExcludeMissing fun _lastNHours(): JsonField<Long> = lastNHours + + /** + * Returns the raw JSON value of [model]. + * + * Unlike [model], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("model") @ExcludeMissing fun _model(): JsonField<Model> = model + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [partitions]. + * + * Unlike [partitions], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("partitions") + @ExcludeMissing + fun _partitions(): JsonField<Partitions> = partitions + + /** + * Returns the raw JSON value of [sample]. + * + * Unlike [sample], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sample") @ExcludeMissing fun _sample(): JsonField<Double> = sample + + /** + * Returns the raw JSON value of [summaryPrompt]. + * + * Unlike [summaryPrompt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("summary_prompt") + @ExcludeMissing + fun _summaryPrompt(): JsonField<String> = summaryPrompt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SavedRunClusteringJobRequest]. + * + * The following fields are required: + * ```java + * .attributeSchemas() + * .filter() + * .hierarchy() + * .lastNHours() + * .model() + * .name() + * .partitions() + * .sample() + * .summaryPrompt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SavedRunClusteringJobRequest]. */ + class Builder internal constructor() { + + private var attributeSchemas: JsonValue? = null + private var filter: JsonField<String>? = null + private var hierarchy: JsonField<MutableList<Long>>? = null + private var lastNHours: JsonField<Long>? = null + private var model: JsonField<Model>? = null + private var name: JsonField<String>? = null + private var partitions: JsonField<Partitions>? = null + private var sample: JsonField<Double>? = null + private var summaryPrompt: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(savedRunClusteringJobRequest: SavedRunClusteringJobRequest) = apply { + attributeSchemas = savedRunClusteringJobRequest.attributeSchemas + filter = savedRunClusteringJobRequest.filter + hierarchy = savedRunClusteringJobRequest.hierarchy.map { it.toMutableList() } + lastNHours = savedRunClusteringJobRequest.lastNHours + model = savedRunClusteringJobRequest.model + name = savedRunClusteringJobRequest.name + partitions = savedRunClusteringJobRequest.partitions + sample = savedRunClusteringJobRequest.sample + summaryPrompt = savedRunClusteringJobRequest.summaryPrompt + additionalProperties = savedRunClusteringJobRequest.additionalProperties.toMutableMap() + } + + fun attributeSchemas(attributeSchemas: JsonValue) = apply { + this.attributeSchemas = attributeSchemas + } + + fun filter(filter: String?) = filter(JsonField.ofNullable(filter)) + + /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ + fun filter(filter: Optional<String>) = filter(filter.getOrNull()) + + /** + * Sets [Builder.filter] to an arbitrary JSON value. + * + * You should usually call [Builder.filter] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun filter(filter: JsonField<String>) = apply { this.filter = filter } + + fun hierarchy(hierarchy: List<Long>?) = hierarchy(JsonField.ofNullable(hierarchy)) + + /** Alias for calling [Builder.hierarchy] with `hierarchy.orElse(null)`. */ + fun hierarchy(hierarchy: Optional<List<Long>>) = hierarchy(hierarchy.getOrNull()) + + /** + * Sets [Builder.hierarchy] to an arbitrary JSON value. + * + * You should usually call [Builder.hierarchy] with a well-typed `List<Long>` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun hierarchy(hierarchy: JsonField<List<Long>>) = apply { + this.hierarchy = hierarchy.map { it.toMutableList() } + } + + /** + * Adds a single [Long] to [Builder.hierarchy]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addHierarchy(hierarchy: Long) = apply { + this.hierarchy = + (this.hierarchy ?: JsonField.of(mutableListOf())).also { + checkKnown("hierarchy", it).add(hierarchy) + } + } + + fun lastNHours(lastNHours: Long) = lastNHours(JsonField.of(lastNHours)) + + /** + * Sets [Builder.lastNHours] to an arbitrary JSON value. + * + * You should usually call [Builder.lastNHours] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun lastNHours(lastNHours: JsonField<Long>) = apply { this.lastNHours = lastNHours } + + fun model(model: Model) = model(JsonField.of(model)) + + /** + * Sets [Builder.model] to an arbitrary JSON value. + * + * You should usually call [Builder.model] with a well-typed [Model] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun model(model: JsonField<Model>) = apply { this.model = model } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun partitions(partitions: Partitions?) = partitions(JsonField.ofNullable(partitions)) + + /** Alias for calling [Builder.partitions] with `partitions.orElse(null)`. */ + fun partitions(partitions: Optional<Partitions>) = partitions(partitions.getOrNull()) + + /** + * Sets [Builder.partitions] to an arbitrary JSON value. + * + * You should usually call [Builder.partitions] with a well-typed [Partitions] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun partitions(partitions: JsonField<Partitions>) = apply { this.partitions = partitions } + + fun sample(sample: Double?) = sample(JsonField.ofNullable(sample)) + + /** + * Alias for [Builder.sample]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun sample(sample: Double) = sample(sample as Double?) + + /** Alias for calling [Builder.sample] with `sample.orElse(null)`. */ + fun sample(sample: Optional<Double>) = sample(sample.getOrNull()) + + /** + * Sets [Builder.sample] to an arbitrary JSON value. + * + * You should usually call [Builder.sample] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun sample(sample: JsonField<Double>) = apply { this.sample = sample } + + fun summaryPrompt(summaryPrompt: String?) = + summaryPrompt(JsonField.ofNullable(summaryPrompt)) + + /** Alias for calling [Builder.summaryPrompt] with `summaryPrompt.orElse(null)`. */ + fun summaryPrompt(summaryPrompt: Optional<String>) = + summaryPrompt(summaryPrompt.getOrNull()) + + /** + * Sets [Builder.summaryPrompt] to an arbitrary JSON value. + * + * You should usually call [Builder.summaryPrompt] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun summaryPrompt(summaryPrompt: JsonField<String>) = apply { + this.summaryPrompt = summaryPrompt + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SavedRunClusteringJobRequest]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .attributeSchemas() + * .filter() + * .hierarchy() + * .lastNHours() + * .model() + * .name() + * .partitions() + * .sample() + * .summaryPrompt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SavedRunClusteringJobRequest = + SavedRunClusteringJobRequest( + checkRequired("attributeSchemas", attributeSchemas), + checkRequired("filter", filter), + checkRequired("hierarchy", hierarchy).map { it.toImmutable() }, + checkRequired("lastNHours", lastNHours), + checkRequired("model", model), + checkRequired("name", name), + checkRequired("partitions", partitions), + checkRequired("sample", sample), + checkRequired("summaryPrompt", summaryPrompt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SavedRunClusteringJobRequest = apply { + if (validated) { + return@apply + } + + filter() + hierarchy() + lastNHours() + model().validate() + name() + partitions().ifPresent { it.validate() } + sample() + summaryPrompt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (filter.asKnown().isPresent) 1 else 0) + + (hierarchy.asKnown().getOrNull()?.size ?: 0) + + (if (lastNHours.asKnown().isPresent) 1 else 0) + + (model.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (partitions.asKnown().getOrNull()?.validity() ?: 0) + + (if (sample.asKnown().isPresent) 1 else 0) + + (if (summaryPrompt.asKnown().isPresent) 1 else 0) + + class Model @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val OPENAI = of("openai") + + @JvmField val ANTHROPIC = of("anthropic") + + @JvmStatic fun of(value: String) = Model(JsonField.of(value)) + } + + /** An enum containing [Model]'s known values. */ + enum class Known { + OPENAI, + ANTHROPIC, + } + + /** + * An enum containing [Model]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Model] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + OPENAI, + ANTHROPIC, + /** An enum member indicating that [Model] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + OPENAI -> Value.OPENAI + ANTHROPIC -> Value.ANTHROPIC + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + OPENAI -> Known.OPENAI + ANTHROPIC -> Known.ANTHROPIC + else -> throw LangsmithApiInvalidDataException("Unknown Model: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Model = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Model && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Partitions + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Partitions]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Partitions]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(partitions: Partitions) = apply { + additionalProperties = partitions.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Partitions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Partitions = Partitions(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Partitions = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Partitions && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Partitions{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SavedRunClusteringJobRequest && + attributeSchemas == other.attributeSchemas && + filter == other.filter && + hierarchy == other.hierarchy && + lastNHours == other.lastNHours && + model == other.model && + name == other.name && + partitions == other.partitions && + sample == other.sample && + summaryPrompt == other.summaryPrompt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + attributeSchemas, + filter, + hierarchy, + lastNHours, + model, + name, + partitions, + sample, + summaryPrompt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SavedRunClusteringJobRequest{attributeSchemas=$attributeSchemas, filter=$filter, hierarchy=$hierarchy, lastNHours=$lastNHours, model=$model, name=$name, partitions=$partitions, sample=$sample, summaryPrompt=$summaryPrompt, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/FilterView.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/FilterView.kt new file mode 100644 index 00000000..418920a7 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/FilterView.kt @@ -0,0 +1,548 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.views + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class FilterView +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val displayName: JsonField<String>, + private val updatedAt: JsonField<OffsetDateTime>, + private val description: JsonField<String>, + private val filterString: JsonField<String>, + private val sessionId: JsonField<String>, + private val traceFilterString: JsonField<String>, + private val treeFilterString: JsonField<String>, + private val type: JsonField<FilterViewType>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField<String> = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("filter_string") + @ExcludeMissing + filterString: JsonField<String> = JsonMissing.of(), + @JsonProperty("session_id") @ExcludeMissing sessionId: JsonField<String> = JsonMissing.of(), + @JsonProperty("trace_filter_string") + @ExcludeMissing + traceFilterString: JsonField<String> = JsonMissing.of(), + @JsonProperty("tree_filter_string") + @ExcludeMissing + treeFilterString: JsonField<String> = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField<FilterViewType> = JsonMissing.of(), + ) : this( + id, + createdAt, + displayName, + updatedAt, + description, + filterString, + sessionId, + traceFilterString, + treeFilterString, + type, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun displayName(): String = displayName.getRequired("display_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updatedAt(): OffsetDateTime = updatedAt.getRequired("updated_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun filterString(): Optional<String> = filterString.getOptional("filter_string") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun sessionId(): Optional<String> = sessionId.getOptional("session_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun traceFilterString(): Optional<String> = traceFilterString.getOptional("trace_filter_string") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun treeFilterString(): Optional<String> = treeFilterString.getOptional("tree_filter_string") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun type(): Optional<FilterViewType> = type.getOptional("type") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField<String> = displayName + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField<OffsetDateTime> = updatedAt + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [filterString]. + * + * Unlike [filterString], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filter_string") + @ExcludeMissing + fun _filterString(): JsonField<String> = filterString + + /** + * Returns the raw JSON value of [sessionId]. + * + * Unlike [sessionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session_id") @ExcludeMissing fun _sessionId(): JsonField<String> = sessionId + + /** + * Returns the raw JSON value of [traceFilterString]. + * + * Unlike [traceFilterString], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("trace_filter_string") + @ExcludeMissing + fun _traceFilterString(): JsonField<String> = traceFilterString + + /** + * Returns the raw JSON value of [treeFilterString]. + * + * Unlike [treeFilterString], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tree_filter_string") + @ExcludeMissing + fun _treeFilterString(): JsonField<String> = treeFilterString + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField<FilterViewType> = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [FilterView]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .displayName() + * .updatedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FilterView]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var createdAt: JsonField<OffsetDateTime>? = null + private var displayName: JsonField<String>? = null + private var updatedAt: JsonField<OffsetDateTime>? = null + private var description: JsonField<String> = JsonMissing.of() + private var filterString: JsonField<String> = JsonMissing.of() + private var sessionId: JsonField<String> = JsonMissing.of() + private var traceFilterString: JsonField<String> = JsonMissing.of() + private var treeFilterString: JsonField<String> = JsonMissing.of() + private var type: JsonField<FilterViewType> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(filterView: FilterView) = apply { + id = filterView.id + createdAt = filterView.createdAt + displayName = filterView.displayName + updatedAt = filterView.updatedAt + description = filterView.description + filterString = filterView.filterString + sessionId = filterView.sessionId + traceFilterString = filterView.traceFilterString + treeFilterString = filterView.treeFilterString + type = filterView.type + additionalProperties = filterView.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun displayName(displayName: String) = displayName(JsonField.of(displayName)) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun displayName(displayName: JsonField<String>) = apply { this.displayName = displayName } + + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField<OffsetDateTime>) = apply { this.updatedAt = updatedAt } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { this.description = description } + + fun filterString(filterString: String?) = filterString(JsonField.ofNullable(filterString)) + + /** Alias for calling [Builder.filterString] with `filterString.orElse(null)`. */ + fun filterString(filterString: Optional<String>) = filterString(filterString.getOrNull()) + + /** + * Sets [Builder.filterString] to an arbitrary JSON value. + * + * You should usually call [Builder.filterString] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun filterString(filterString: JsonField<String>) = apply { + this.filterString = filterString + } + + fun sessionId(sessionId: String?) = sessionId(JsonField.ofNullable(sessionId)) + + /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ + fun sessionId(sessionId: Optional<String>) = sessionId(sessionId.getOrNull()) + + /** + * Sets [Builder.sessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun sessionId(sessionId: JsonField<String>) = apply { this.sessionId = sessionId } + + fun traceFilterString(traceFilterString: String?) = + traceFilterString(JsonField.ofNullable(traceFilterString)) + + /** Alias for calling [Builder.traceFilterString] with `traceFilterString.orElse(null)`. */ + fun traceFilterString(traceFilterString: Optional<String>) = + traceFilterString(traceFilterString.getOrNull()) + + /** + * Sets [Builder.traceFilterString] to an arbitrary JSON value. + * + * You should usually call [Builder.traceFilterString] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun traceFilterString(traceFilterString: JsonField<String>) = apply { + this.traceFilterString = traceFilterString + } + + fun treeFilterString(treeFilterString: String?) = + treeFilterString(JsonField.ofNullable(treeFilterString)) + + /** Alias for calling [Builder.treeFilterString] with `treeFilterString.orElse(null)`. */ + fun treeFilterString(treeFilterString: Optional<String>) = + treeFilterString(treeFilterString.getOrNull()) + + /** + * Sets [Builder.treeFilterString] to an arbitrary JSON value. + * + * You should usually call [Builder.treeFilterString] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun treeFilterString(treeFilterString: JsonField<String>) = apply { + this.treeFilterString = treeFilterString + } + + fun type(type: FilterViewType) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [FilterViewType] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField<FilterViewType>) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FilterView]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .displayName() + * .updatedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FilterView = + FilterView( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("displayName", displayName), + checkRequired("updatedAt", updatedAt), + description, + filterString, + sessionId, + traceFilterString, + treeFilterString, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): FilterView = apply { + if (validated) { + return@apply + } + + id() + createdAt() + displayName() + updatedAt() + description() + filterString() + sessionId() + traceFilterString() + treeFilterString() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (displayName.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (filterString.asKnown().isPresent) 1 else 0) + + (if (sessionId.asKnown().isPresent) 1 else 0) + + (if (traceFilterString.asKnown().isPresent) 1 else 0) + + (if (treeFilterString.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FilterView && + id == other.id && + createdAt == other.createdAt && + displayName == other.displayName && + updatedAt == other.updatedAt && + description == other.description && + filterString == other.filterString && + sessionId == other.sessionId && + traceFilterString == other.traceFilterString && + treeFilterString == other.treeFilterString && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + createdAt, + displayName, + updatedAt, + description, + filterString, + sessionId, + traceFilterString, + treeFilterString, + type, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FilterView{id=$id, createdAt=$createdAt, displayName=$displayName, updatedAt=$updatedAt, description=$description, filterString=$filterString, sessionId=$sessionId, traceFilterString=$traceFilterString, treeFilterString=$treeFilterString, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/FilterViewType.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/FilterViewType.kt new file mode 100644 index 00000000..42f34330 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/FilterViewType.kt @@ -0,0 +1,135 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.views + +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException + +class FilterViewType @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't match + * any known member, and you want to know that value. For example, if the SDK is on an older + * version than the API, then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val RUNS = of("runs") + + @JvmField val THREADS = of("threads") + + @JvmStatic fun of(value: String) = FilterViewType(JsonField.of(value)) + } + + /** An enum containing [FilterViewType]'s known values. */ + enum class Known { + RUNS, + THREADS, + } + + /** + * An enum containing [FilterViewType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [FilterViewType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the SDK + * is on an older version than the API, then the API may respond with new members that the SDK + * is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + RUNS, + THREADS, + /** + * An enum member indicating that [FilterViewType] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if + * the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want to + * throw for the unknown case. + */ + fun value(): Value = + when (this) { + RUNS -> Value.RUNS + THREADS -> Value.THREADS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't want + * to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + RUNS -> Known.RUNS + THREADS -> Known.THREADS + else -> throw LangsmithApiInvalidDataException("Unknown FilterViewType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): FilterViewType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FilterViewType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewCreateParams.kt new file mode 100644 index 00000000..39ac7051 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewCreateParams.kt @@ -0,0 +1,822 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.views + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create a new filter view. */ +class ViewCreateParams +private constructor( + private val sessionId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun sessionId(): Optional<String> = Optional.ofNullable(sessionId) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun displayName(): String = body.displayName() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = body.description() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun filterString(): Optional<String> = body.filterString() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun traceFilterString(): Optional<String> = body.traceFilterString() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun treeFilterString(): Optional<String> = body.treeFilterString() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun type(): Optional<FilterViewType> = body.type() + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _displayName(): JsonField<String> = body._displayName() + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _description(): JsonField<String> = body._description() + + /** + * Returns the raw JSON value of [filterString]. + * + * Unlike [filterString], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _filterString(): JsonField<String> = body._filterString() + + /** + * Returns the raw JSON value of [traceFilterString]. + * + * Unlike [traceFilterString], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _traceFilterString(): JsonField<String> = body._traceFilterString() + + /** + * Returns the raw JSON value of [treeFilterString]. + * + * Unlike [treeFilterString], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _treeFilterString(): JsonField<String> = body._treeFilterString() + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _type(): JsonField<FilterViewType> = body._type() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ViewCreateParams]. + * + * The following fields are required: + * ```java + * .displayName() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ViewCreateParams]. */ + class Builder internal constructor() { + + private var sessionId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(viewCreateParams: ViewCreateParams) = apply { + sessionId = viewCreateParams.sessionId + body = viewCreateParams.body.toBuilder() + additionalHeaders = viewCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = viewCreateParams.additionalQueryParams.toBuilder() + } + + fun sessionId(sessionId: String?) = apply { this.sessionId = sessionId } + + /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ + fun sessionId(sessionId: Optional<String>) = sessionId(sessionId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [displayName] + * - [description] + * - [filterString] + * - [traceFilterString] + * - [treeFilterString] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun displayName(displayName: String) = apply { body.displayName(displayName) } + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun displayName(displayName: JsonField<String>) = apply { body.displayName(displayName) } + + fun description(description: String?) = apply { body.description(description) } + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { body.description(description) } + + fun filterString(filterString: String?) = apply { body.filterString(filterString) } + + /** Alias for calling [Builder.filterString] with `filterString.orElse(null)`. */ + fun filterString(filterString: Optional<String>) = filterString(filterString.getOrNull()) + + /** + * Sets [Builder.filterString] to an arbitrary JSON value. + * + * You should usually call [Builder.filterString] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun filterString(filterString: JsonField<String>) = apply { + body.filterString(filterString) + } + + fun traceFilterString(traceFilterString: String?) = apply { + body.traceFilterString(traceFilterString) + } + + /** Alias for calling [Builder.traceFilterString] with `traceFilterString.orElse(null)`. */ + fun traceFilterString(traceFilterString: Optional<String>) = + traceFilterString(traceFilterString.getOrNull()) + + /** + * Sets [Builder.traceFilterString] to an arbitrary JSON value. + * + * You should usually call [Builder.traceFilterString] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun traceFilterString(traceFilterString: JsonField<String>) = apply { + body.traceFilterString(traceFilterString) + } + + fun treeFilterString(treeFilterString: String?) = apply { + body.treeFilterString(treeFilterString) + } + + /** Alias for calling [Builder.treeFilterString] with `treeFilterString.orElse(null)`. */ + fun treeFilterString(treeFilterString: Optional<String>) = + treeFilterString(treeFilterString.getOrNull()) + + /** + * Sets [Builder.treeFilterString] to an arbitrary JSON value. + * + * You should usually call [Builder.treeFilterString] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun treeFilterString(treeFilterString: JsonField<String>) = apply { + body.treeFilterString(treeFilterString) + } + + fun type(type: FilterViewType) = apply { body.type(type) } + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [FilterViewType] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField<FilterViewType>) = apply { body.type(type) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ViewCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .displayName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ViewCreateParams = + ViewCreateParams( + sessionId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> sessionId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val displayName: JsonField<String>, + private val description: JsonField<String>, + private val filterString: JsonField<String>, + private val traceFilterString: JsonField<String>, + private val treeFilterString: JsonField<String>, + private val type: JsonField<FilterViewType>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField<String> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("filter_string") + @ExcludeMissing + filterString: JsonField<String> = JsonMissing.of(), + @JsonProperty("trace_filter_string") + @ExcludeMissing + traceFilterString: JsonField<String> = JsonMissing.of(), + @JsonProperty("tree_filter_string") + @ExcludeMissing + treeFilterString: JsonField<String> = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField<FilterViewType> = JsonMissing.of(), + ) : this( + displayName, + description, + filterString, + traceFilterString, + treeFilterString, + type, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun displayName(): String = displayName.getRequired("display_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun filterString(): Optional<String> = filterString.getOptional("filter_string") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun traceFilterString(): Optional<String> = + traceFilterString.getOptional("trace_filter_string") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun treeFilterString(): Optional<String> = + treeFilterString.getOptional("tree_filter_string") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun type(): Optional<FilterViewType> = type.getOptional("type") + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField<String> = displayName + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [filterString]. + * + * Unlike [filterString], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("filter_string") + @ExcludeMissing + fun _filterString(): JsonField<String> = filterString + + /** + * Returns the raw JSON value of [traceFilterString]. + * + * Unlike [traceFilterString], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("trace_filter_string") + @ExcludeMissing + fun _traceFilterString(): JsonField<String> = traceFilterString + + /** + * Returns the raw JSON value of [treeFilterString]. + * + * Unlike [treeFilterString], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tree_filter_string") + @ExcludeMissing + fun _treeFilterString(): JsonField<String> = treeFilterString + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField<FilterViewType> = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .displayName() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var displayName: JsonField<String>? = null + private var description: JsonField<String> = JsonMissing.of() + private var filterString: JsonField<String> = JsonMissing.of() + private var traceFilterString: JsonField<String> = JsonMissing.of() + private var treeFilterString: JsonField<String> = JsonMissing.of() + private var type: JsonField<FilterViewType> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + displayName = body.displayName + description = body.description + filterString = body.filterString + traceFilterString = body.traceFilterString + treeFilterString = body.treeFilterString + type = body.type + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun displayName(displayName: String) = displayName(JsonField.of(displayName)) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun displayName(displayName: JsonField<String>) = apply { + this.displayName = displayName + } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField<String>) = apply { + this.description = description + } + + fun filterString(filterString: String?) = + filterString(JsonField.ofNullable(filterString)) + + /** Alias for calling [Builder.filterString] with `filterString.orElse(null)`. */ + fun filterString(filterString: Optional<String>) = + filterString(filterString.getOrNull()) + + /** + * Sets [Builder.filterString] to an arbitrary JSON value. + * + * You should usually call [Builder.filterString] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun filterString(filterString: JsonField<String>) = apply { + this.filterString = filterString + } + + fun traceFilterString(traceFilterString: String?) = + traceFilterString(JsonField.ofNullable(traceFilterString)) + + /** + * Alias for calling [Builder.traceFilterString] with `traceFilterString.orElse(null)`. + */ + fun traceFilterString(traceFilterString: Optional<String>) = + traceFilterString(traceFilterString.getOrNull()) + + /** + * Sets [Builder.traceFilterString] to an arbitrary JSON value. + * + * You should usually call [Builder.traceFilterString] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun traceFilterString(traceFilterString: JsonField<String>) = apply { + this.traceFilterString = traceFilterString + } + + fun treeFilterString(treeFilterString: String?) = + treeFilterString(JsonField.ofNullable(treeFilterString)) + + /** + * Alias for calling [Builder.treeFilterString] with `treeFilterString.orElse(null)`. + */ + fun treeFilterString(treeFilterString: Optional<String>) = + treeFilterString(treeFilterString.getOrNull()) + + /** + * Sets [Builder.treeFilterString] to an arbitrary JSON value. + * + * You should usually call [Builder.treeFilterString] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun treeFilterString(treeFilterString: JsonField<String>) = apply { + this.treeFilterString = treeFilterString + } + + fun type(type: FilterViewType) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [FilterViewType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField<FilterViewType>) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .displayName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("displayName", displayName), + description, + filterString, + traceFilterString, + treeFilterString, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + displayName() + description() + filterString() + traceFilterString() + treeFilterString() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (displayName.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (filterString.asKnown().isPresent) 1 else 0) + + (if (traceFilterString.asKnown().isPresent) 1 else 0) + + (if (treeFilterString.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + displayName == other.displayName && + description == other.description && + filterString == other.filterString && + traceFilterString == other.traceFilterString && + treeFilterString == other.treeFilterString && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + displayName, + description, + filterString, + traceFilterString, + treeFilterString, + type, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{displayName=$displayName, description=$description, filterString=$filterString, traceFilterString=$traceFilterString, treeFilterString=$treeFilterString, type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ViewCreateParams && + sessionId == other.sessionId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(sessionId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ViewCreateParams{sessionId=$sessionId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewDeleteParams.kt new file mode 100644 index 00000000..24ef3129 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewDeleteParams.kt @@ -0,0 +1,258 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.views + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete a specific filter view. */ +class ViewDeleteParams +private constructor( + private val sessionId: String, + private val viewId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun sessionId(): String = sessionId + + fun viewId(): Optional<String> = Optional.ofNullable(viewId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ViewDeleteParams]. + * + * The following fields are required: + * ```java + * .sessionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ViewDeleteParams]. */ + class Builder internal constructor() { + + private var sessionId: String? = null + private var viewId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(viewDeleteParams: ViewDeleteParams) = apply { + sessionId = viewDeleteParams.sessionId + viewId = viewDeleteParams.viewId + additionalHeaders = viewDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = viewDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = viewDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun sessionId(sessionId: String) = apply { this.sessionId = sessionId } + + fun viewId(viewId: String?) = apply { this.viewId = viewId } + + /** Alias for calling [Builder.viewId] with `viewId.orElse(null)`. */ + fun viewId(viewId: Optional<String>) = viewId(viewId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [ViewDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .sessionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ViewDeleteParams = + ViewDeleteParams( + checkRequired("sessionId", sessionId), + viewId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> sessionId + 1 -> viewId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ViewDeleteParams && + sessionId == other.sessionId && + viewId == other.viewId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + sessionId, + viewId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "ViewDeleteParams{sessionId=$sessionId, viewId=$viewId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewDeleteResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewDeleteResponse.kt new file mode 100644 index 00000000..96d3ccf5 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewDeleteResponse.kt @@ -0,0 +1,113 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.views + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class ViewDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ViewDeleteResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ViewDeleteResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(viewDeleteResponse: ViewDeleteResponse) = apply { + additionalProperties = viewDeleteResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ViewDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ViewDeleteResponse = ViewDeleteResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): ViewDeleteResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ViewDeleteResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "ViewDeleteResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewListParams.kt new file mode 100644 index 00000000..b4d69807 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewListParams.kt @@ -0,0 +1,212 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.views + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get all filter views for a session. */ +class ViewListParams +private constructor( + private val sessionId: String?, + private val type: FilterViewType?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun sessionId(): Optional<String> = Optional.ofNullable(sessionId) + + fun type(): Optional<FilterViewType> = Optional.ofNullable(type) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ViewListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ViewListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ViewListParams]. */ + class Builder internal constructor() { + + private var sessionId: String? = null + private var type: FilterViewType? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(viewListParams: ViewListParams) = apply { + sessionId = viewListParams.sessionId + type = viewListParams.type + additionalHeaders = viewListParams.additionalHeaders.toBuilder() + additionalQueryParams = viewListParams.additionalQueryParams.toBuilder() + } + + fun sessionId(sessionId: String?) = apply { this.sessionId = sessionId } + + /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ + fun sessionId(sessionId: Optional<String>) = sessionId(sessionId.getOrNull()) + + fun type(type: FilterViewType?) = apply { this.type = type } + + /** Alias for calling [Builder.type] with `type.orElse(null)`. */ + fun type(type: Optional<FilterViewType>) = type(type.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ViewListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ViewListParams = + ViewListParams( + sessionId, + type, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> sessionId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + type?.let { put("type", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ViewListParams && + sessionId == other.sessionId && + type == other.type && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(sessionId, type, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ViewListParams{sessionId=$sessionId, type=$type, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewRetrieveParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewRetrieveParams.kt new file mode 100644 index 00000000..e8685fce --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewRetrieveParams.kt @@ -0,0 +1,217 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.views + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get a specific filter view. */ +class ViewRetrieveParams +private constructor( + private val sessionId: String, + private val viewId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun sessionId(): String = sessionId + + fun viewId(): Optional<String> = Optional.ofNullable(viewId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ViewRetrieveParams]. + * + * The following fields are required: + * ```java + * .sessionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ViewRetrieveParams]. */ + class Builder internal constructor() { + + private var sessionId: String? = null + private var viewId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(viewRetrieveParams: ViewRetrieveParams) = apply { + sessionId = viewRetrieveParams.sessionId + viewId = viewRetrieveParams.viewId + additionalHeaders = viewRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = viewRetrieveParams.additionalQueryParams.toBuilder() + } + + fun sessionId(sessionId: String) = apply { this.sessionId = sessionId } + + fun viewId(viewId: String?) = apply { this.viewId = viewId } + + /** Alias for calling [Builder.viewId] with `viewId.orElse(null)`. */ + fun viewId(viewId: Optional<String>) = viewId(viewId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ViewRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .sessionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ViewRetrieveParams = + ViewRetrieveParams( + checkRequired("sessionId", sessionId), + viewId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> sessionId + 1 -> viewId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ViewRetrieveParams && + sessionId == other.sessionId && + viewId == other.viewId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(sessionId, viewId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ViewRetrieveParams{sessionId=$sessionId, viewId=$viewId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewUpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewUpdateParams.kt new file mode 100644 index 00000000..a0400e67 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewUpdateParams.kt @@ -0,0 +1,830 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.views + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Update a filter view. */ +class ViewUpdateParams +private constructor( + private val sessionId: String, + private val viewId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun sessionId(): String = sessionId + + fun viewId(): Optional<String> = Optional.ofNullable(viewId) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = body.description() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun displayName(): Optional<String> = body.displayName() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun filterString(): Optional<String> = body.filterString() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun traceFilterString(): Optional<String> = body.traceFilterString() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun treeFilterString(): Optional<String> = body.treeFilterString() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun type(): Optional<FilterViewType> = body.type() + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _description(): JsonField<String> = body._description() + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _displayName(): JsonField<String> = body._displayName() + + /** + * Returns the raw JSON value of [filterString]. + * + * Unlike [filterString], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _filterString(): JsonField<String> = body._filterString() + + /** + * Returns the raw JSON value of [traceFilterString]. + * + * Unlike [traceFilterString], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _traceFilterString(): JsonField<String> = body._traceFilterString() + + /** + * Returns the raw JSON value of [treeFilterString]. + * + * Unlike [treeFilterString], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _treeFilterString(): JsonField<String> = body._treeFilterString() + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _type(): JsonField<FilterViewType> = body._type() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ViewUpdateParams]. + * + * The following fields are required: + * ```java + * .sessionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ViewUpdateParams]. */ + class Builder internal constructor() { + + private var sessionId: String? = null + private var viewId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(viewUpdateParams: ViewUpdateParams) = apply { + sessionId = viewUpdateParams.sessionId + viewId = viewUpdateParams.viewId + body = viewUpdateParams.body.toBuilder() + additionalHeaders = viewUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = viewUpdateParams.additionalQueryParams.toBuilder() + } + + fun sessionId(sessionId: String) = apply { this.sessionId = sessionId } + + fun viewId(viewId: String?) = apply { this.viewId = viewId } + + /** Alias for calling [Builder.viewId] with `viewId.orElse(null)`. */ + fun viewId(viewId: Optional<String>) = viewId(viewId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [description] + * - [displayName] + * - [filterString] + * - [traceFilterString] + * - [treeFilterString] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun description(description: String?) = apply { body.description(description) } + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { body.description(description) } + + fun displayName(displayName: String?) = apply { body.displayName(displayName) } + + /** Alias for calling [Builder.displayName] with `displayName.orElse(null)`. */ + fun displayName(displayName: Optional<String>) = displayName(displayName.getOrNull()) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun displayName(displayName: JsonField<String>) = apply { body.displayName(displayName) } + + fun filterString(filterString: String?) = apply { body.filterString(filterString) } + + /** Alias for calling [Builder.filterString] with `filterString.orElse(null)`. */ + fun filterString(filterString: Optional<String>) = filterString(filterString.getOrNull()) + + /** + * Sets [Builder.filterString] to an arbitrary JSON value. + * + * You should usually call [Builder.filterString] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun filterString(filterString: JsonField<String>) = apply { + body.filterString(filterString) + } + + fun traceFilterString(traceFilterString: String?) = apply { + body.traceFilterString(traceFilterString) + } + + /** Alias for calling [Builder.traceFilterString] with `traceFilterString.orElse(null)`. */ + fun traceFilterString(traceFilterString: Optional<String>) = + traceFilterString(traceFilterString.getOrNull()) + + /** + * Sets [Builder.traceFilterString] to an arbitrary JSON value. + * + * You should usually call [Builder.traceFilterString] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun traceFilterString(traceFilterString: JsonField<String>) = apply { + body.traceFilterString(traceFilterString) + } + + fun treeFilterString(treeFilterString: String?) = apply { + body.treeFilterString(treeFilterString) + } + + /** Alias for calling [Builder.treeFilterString] with `treeFilterString.orElse(null)`. */ + fun treeFilterString(treeFilterString: Optional<String>) = + treeFilterString(treeFilterString.getOrNull()) + + /** + * Sets [Builder.treeFilterString] to an arbitrary JSON value. + * + * You should usually call [Builder.treeFilterString] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun treeFilterString(treeFilterString: JsonField<String>) = apply { + body.treeFilterString(treeFilterString) + } + + fun type(type: FilterViewType?) = apply { body.type(type) } + + /** Alias for calling [Builder.type] with `type.orElse(null)`. */ + fun type(type: Optional<FilterViewType>) = type(type.getOrNull()) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [FilterViewType] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField<FilterViewType>) = apply { body.type(type) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ViewUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .sessionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ViewUpdateParams = + ViewUpdateParams( + checkRequired("sessionId", sessionId), + viewId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> sessionId + 1 -> viewId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val description: JsonField<String>, + private val displayName: JsonField<String>, + private val filterString: JsonField<String>, + private val traceFilterString: JsonField<String>, + private val treeFilterString: JsonField<String>, + private val type: JsonField<FilterViewType>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField<String> = JsonMissing.of(), + @JsonProperty("filter_string") + @ExcludeMissing + filterString: JsonField<String> = JsonMissing.of(), + @JsonProperty("trace_filter_string") + @ExcludeMissing + traceFilterString: JsonField<String> = JsonMissing.of(), + @JsonProperty("tree_filter_string") + @ExcludeMissing + treeFilterString: JsonField<String> = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField<FilterViewType> = JsonMissing.of(), + ) : this( + description, + displayName, + filterString, + traceFilterString, + treeFilterString, + type, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun displayName(): Optional<String> = displayName.getOptional("display_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun filterString(): Optional<String> = filterString.getOptional("filter_string") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun traceFilterString(): Optional<String> = + traceFilterString.getOptional("trace_filter_string") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun treeFilterString(): Optional<String> = + treeFilterString.getOptional("tree_filter_string") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun type(): Optional<FilterViewType> = type.getOptional("type") + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField<String> = displayName + + /** + * Returns the raw JSON value of [filterString]. + * + * Unlike [filterString], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("filter_string") + @ExcludeMissing + fun _filterString(): JsonField<String> = filterString + + /** + * Returns the raw JSON value of [traceFilterString]. + * + * Unlike [traceFilterString], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("trace_filter_string") + @ExcludeMissing + fun _traceFilterString(): JsonField<String> = traceFilterString + + /** + * Returns the raw JSON value of [treeFilterString]. + * + * Unlike [treeFilterString], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tree_filter_string") + @ExcludeMissing + fun _treeFilterString(): JsonField<String> = treeFilterString + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField<FilterViewType> = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var description: JsonField<String> = JsonMissing.of() + private var displayName: JsonField<String> = JsonMissing.of() + private var filterString: JsonField<String> = JsonMissing.of() + private var traceFilterString: JsonField<String> = JsonMissing.of() + private var treeFilterString: JsonField<String> = JsonMissing.of() + private var type: JsonField<FilterViewType> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + description = body.description + displayName = body.displayName + filterString = body.filterString + traceFilterString = body.traceFilterString + treeFilterString = body.treeFilterString + type = body.type + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField<String>) = apply { + this.description = description + } + + fun displayName(displayName: String?) = displayName(JsonField.ofNullable(displayName)) + + /** Alias for calling [Builder.displayName] with `displayName.orElse(null)`. */ + fun displayName(displayName: Optional<String>) = displayName(displayName.getOrNull()) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun displayName(displayName: JsonField<String>) = apply { + this.displayName = displayName + } + + fun filterString(filterString: String?) = + filterString(JsonField.ofNullable(filterString)) + + /** Alias for calling [Builder.filterString] with `filterString.orElse(null)`. */ + fun filterString(filterString: Optional<String>) = + filterString(filterString.getOrNull()) + + /** + * Sets [Builder.filterString] to an arbitrary JSON value. + * + * You should usually call [Builder.filterString] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun filterString(filterString: JsonField<String>) = apply { + this.filterString = filterString + } + + fun traceFilterString(traceFilterString: String?) = + traceFilterString(JsonField.ofNullable(traceFilterString)) + + /** + * Alias for calling [Builder.traceFilterString] with `traceFilterString.orElse(null)`. + */ + fun traceFilterString(traceFilterString: Optional<String>) = + traceFilterString(traceFilterString.getOrNull()) + + /** + * Sets [Builder.traceFilterString] to an arbitrary JSON value. + * + * You should usually call [Builder.traceFilterString] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun traceFilterString(traceFilterString: JsonField<String>) = apply { + this.traceFilterString = traceFilterString + } + + fun treeFilterString(treeFilterString: String?) = + treeFilterString(JsonField.ofNullable(treeFilterString)) + + /** + * Alias for calling [Builder.treeFilterString] with `treeFilterString.orElse(null)`. + */ + fun treeFilterString(treeFilterString: Optional<String>) = + treeFilterString(treeFilterString.getOrNull()) + + /** + * Sets [Builder.treeFilterString] to an arbitrary JSON value. + * + * You should usually call [Builder.treeFilterString] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun treeFilterString(treeFilterString: JsonField<String>) = apply { + this.treeFilterString = treeFilterString + } + + fun type(type: FilterViewType?) = type(JsonField.ofNullable(type)) + + /** Alias for calling [Builder.type] with `type.orElse(null)`. */ + fun type(type: Optional<FilterViewType>) = type(type.getOrNull()) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [FilterViewType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField<FilterViewType>) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = + Body( + description, + displayName, + filterString, + traceFilterString, + treeFilterString, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + description() + displayName() + filterString() + traceFilterString() + treeFilterString() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (description.asKnown().isPresent) 1 else 0) + + (if (displayName.asKnown().isPresent) 1 else 0) + + (if (filterString.asKnown().isPresent) 1 else 0) + + (if (traceFilterString.asKnown().isPresent) 1 else 0) + + (if (treeFilterString.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + description == other.description && + displayName == other.displayName && + filterString == other.filterString && + traceFilterString == other.traceFilterString && + treeFilterString == other.treeFilterString && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + description, + displayName, + filterString, + traceFilterString, + treeFilterString, + type, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{description=$description, displayName=$displayName, filterString=$filterString, traceFilterString=$traceFilterString, treeFilterString=$treeFilterString, type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ViewUpdateParams && + sessionId == other.sessionId && + viewId == other.viewId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(sessionId, viewId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ViewUpdateParams{sessionId=$sessionId, viewId=$viewId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/settings/AppHubCrudTenantsTenant.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/settings/AppHubCrudTenantsTenant.kt new file mode 100644 index 00000000..c72d5862 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/settings/AppHubCrudTenantsTenant.kt @@ -0,0 +1,294 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.settings + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class AppHubCrudTenantsTenant +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val displayName: JsonField<String>, + private val tenantHandle: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField<String> = JsonMissing.of(), + @JsonProperty("tenant_handle") + @ExcludeMissing + tenantHandle: JsonField<String> = JsonMissing.of(), + ) : this(id, createdAt, displayName, tenantHandle, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun displayName(): String = displayName.getRequired("display_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tenantHandle(): Optional<String> = tenantHandle.getOptional("tenant_handle") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField<String> = displayName + + /** + * Returns the raw JSON value of [tenantHandle]. + * + * Unlike [tenantHandle], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_handle") + @ExcludeMissing + fun _tenantHandle(): JsonField<String> = tenantHandle + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AppHubCrudTenantsTenant]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .displayName() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AppHubCrudTenantsTenant]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var createdAt: JsonField<OffsetDateTime>? = null + private var displayName: JsonField<String>? = null + private var tenantHandle: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(appHubCrudTenantsTenant: AppHubCrudTenantsTenant) = apply { + id = appHubCrudTenantsTenant.id + createdAt = appHubCrudTenantsTenant.createdAt + displayName = appHubCrudTenantsTenant.displayName + tenantHandle = appHubCrudTenantsTenant.tenantHandle + additionalProperties = appHubCrudTenantsTenant.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun displayName(displayName: String) = displayName(JsonField.of(displayName)) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun displayName(displayName: JsonField<String>) = apply { this.displayName = displayName } + + fun tenantHandle(tenantHandle: String?) = tenantHandle(JsonField.ofNullable(tenantHandle)) + + /** Alias for calling [Builder.tenantHandle] with `tenantHandle.orElse(null)`. */ + fun tenantHandle(tenantHandle: Optional<String>) = tenantHandle(tenantHandle.getOrNull()) + + /** + * Sets [Builder.tenantHandle] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantHandle] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tenantHandle(tenantHandle: JsonField<String>) = apply { + this.tenantHandle = tenantHandle + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AppHubCrudTenantsTenant]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .displayName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AppHubCrudTenantsTenant = + AppHubCrudTenantsTenant( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("displayName", displayName), + tenantHandle, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AppHubCrudTenantsTenant = apply { + if (validated) { + return@apply + } + + id() + createdAt() + displayName() + tenantHandle() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (displayName.asKnown().isPresent) 1 else 0) + + (if (tenantHandle.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AppHubCrudTenantsTenant && + id == other.id && + createdAt == other.createdAt && + displayName == other.displayName && + tenantHandle == other.tenantHandle && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, createdAt, displayName, tenantHandle, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AppHubCrudTenantsTenant{id=$id, createdAt=$createdAt, displayName=$displayName, tenantHandle=$tenantHandle, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/settings/SettingHandleParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/settings/SettingHandleParams.kt new file mode 100644 index 00000000..9525d744 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/settings/SettingHandleParams.kt @@ -0,0 +1,423 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.settings + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +/** Set tenant handle. */ +class SettingHandleParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tenantHandle(): String = body.tenantHandle() + + /** + * Returns the raw JSON value of [tenantHandle]. + * + * Unlike [tenantHandle], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _tenantHandle(): JsonField<String> = body._tenantHandle() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SettingHandleParams]. + * + * The following fields are required: + * ```java + * .tenantHandle() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SettingHandleParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(settingHandleParams: SettingHandleParams) = apply { + body = settingHandleParams.body.toBuilder() + additionalHeaders = settingHandleParams.additionalHeaders.toBuilder() + additionalQueryParams = settingHandleParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [tenantHandle] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun tenantHandle(tenantHandle: String) = apply { body.tenantHandle(tenantHandle) } + + /** + * Sets [Builder.tenantHandle] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantHandle] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tenantHandle(tenantHandle: JsonField<String>) = apply { + body.tenantHandle(tenantHandle) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SettingHandleParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tenantHandle() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SettingHandleParams = + SettingHandleParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tenantHandle: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tenant_handle") + @ExcludeMissing + tenantHandle: JsonField<String> = JsonMissing.of() + ) : this(tenantHandle, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tenantHandle(): String = tenantHandle.getRequired("tenant_handle") + + /** + * Returns the raw JSON value of [tenantHandle]. + * + * Unlike [tenantHandle], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tenant_handle") + @ExcludeMissing + fun _tenantHandle(): JsonField<String> = tenantHandle + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .tenantHandle() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var tenantHandle: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + tenantHandle = body.tenantHandle + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun tenantHandle(tenantHandle: String) = tenantHandle(JsonField.of(tenantHandle)) + + /** + * Sets [Builder.tenantHandle] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantHandle] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tenantHandle(tenantHandle: JsonField<String>) = apply { + this.tenantHandle = tenantHandle + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tenantHandle() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("tenantHandle", tenantHandle), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + tenantHandle() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (tenantHandle.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + tenantHandle == other.tenantHandle && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tenantHandle, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{tenantHandle=$tenantHandle, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SettingHandleParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "SettingHandleParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/settings/SettingListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/settings/SettingListParams.kt new file mode 100644 index 00000000..bc44bc7b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/settings/SettingListParams.kt @@ -0,0 +1,170 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.settings + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** Get settings. */ +class SettingListParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): SettingListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [SettingListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SettingListParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(settingListParams: SettingListParams) = apply { + additionalHeaders = settingListParams.additionalHeaders.toBuilder() + additionalQueryParams = settingListParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SettingListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SettingListParams = + SettingListParams(additionalHeaders.build(), additionalQueryParams.build()) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SettingListParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "SettingListParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sso/SsoRetrieveParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sso/SsoRetrieveParams.kt new file mode 100644 index 00000000..9b6126f3 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sso/SsoRetrieveParams.kt @@ -0,0 +1,194 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sso + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get SSO provider settings from login slug. */ +class SsoRetrieveParams +private constructor( + private val ssoLoginSlug: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun ssoLoginSlug(): Optional<String> = Optional.ofNullable(ssoLoginSlug) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): SsoRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [SsoRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SsoRetrieveParams]. */ + class Builder internal constructor() { + + private var ssoLoginSlug: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(ssoRetrieveParams: SsoRetrieveParams) = apply { + ssoLoginSlug = ssoRetrieveParams.ssoLoginSlug + additionalHeaders = ssoRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = ssoRetrieveParams.additionalQueryParams.toBuilder() + } + + fun ssoLoginSlug(ssoLoginSlug: String?) = apply { this.ssoLoginSlug = ssoLoginSlug } + + /** Alias for calling [Builder.ssoLoginSlug] with `ssoLoginSlug.orElse(null)`. */ + fun ssoLoginSlug(ssoLoginSlug: Optional<String>) = ssoLoginSlug(ssoLoginSlug.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SsoRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SsoRetrieveParams = + SsoRetrieveParams( + ssoLoginSlug, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> ssoLoginSlug ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SsoRetrieveParams && + ssoLoginSlug == other.ssoLoginSlug && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(ssoLoginSlug, additionalHeaders, additionalQueryParams) + + override fun toString() = + "SsoRetrieveParams{ssoLoginSlug=$ssoLoginSlug, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sso/SsoRetrieveResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sso/SsoRetrieveResponse.kt new file mode 100644 index 00000000..62e353a9 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sso/SsoRetrieveResponse.kt @@ -0,0 +1,260 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sso + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class SsoRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val organizationDisplayName: JsonField<String>, + private val organizationId: JsonField<String>, + private val providerId: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("organization_display_name") + @ExcludeMissing + organizationDisplayName: JsonField<String> = JsonMissing.of(), + @JsonProperty("organization_id") + @ExcludeMissing + organizationId: JsonField<String> = JsonMissing.of(), + @JsonProperty("provider_id") + @ExcludeMissing + providerId: JsonField<String> = JsonMissing.of(), + ) : this(organizationDisplayName, organizationId, providerId, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun organizationDisplayName(): String = + organizationDisplayName.getRequired("organization_display_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun organizationId(): String = organizationId.getRequired("organization_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun providerId(): String = providerId.getRequired("provider_id") + + /** + * Returns the raw JSON value of [organizationDisplayName]. + * + * Unlike [organizationDisplayName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("organization_display_name") + @ExcludeMissing + fun _organizationDisplayName(): JsonField<String> = organizationDisplayName + + /** + * Returns the raw JSON value of [organizationId]. + * + * Unlike [organizationId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("organization_id") + @ExcludeMissing + fun _organizationId(): JsonField<String> = organizationId + + /** + * Returns the raw JSON value of [providerId]. + * + * Unlike [providerId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("provider_id") @ExcludeMissing fun _providerId(): JsonField<String> = providerId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SsoRetrieveResponse]. + * + * The following fields are required: + * ```java + * .organizationDisplayName() + * .organizationId() + * .providerId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SsoRetrieveResponse]. */ + class Builder internal constructor() { + + private var organizationDisplayName: JsonField<String>? = null + private var organizationId: JsonField<String>? = null + private var providerId: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(ssoRetrieveResponse: SsoRetrieveResponse) = apply { + organizationDisplayName = ssoRetrieveResponse.organizationDisplayName + organizationId = ssoRetrieveResponse.organizationId + providerId = ssoRetrieveResponse.providerId + additionalProperties = ssoRetrieveResponse.additionalProperties.toMutableMap() + } + + fun organizationDisplayName(organizationDisplayName: String) = + organizationDisplayName(JsonField.of(organizationDisplayName)) + + /** + * Sets [Builder.organizationDisplayName] to an arbitrary JSON value. + * + * You should usually call [Builder.organizationDisplayName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun organizationDisplayName(organizationDisplayName: JsonField<String>) = apply { + this.organizationDisplayName = organizationDisplayName + } + + fun organizationId(organizationId: String) = organizationId(JsonField.of(organizationId)) + + /** + * Sets [Builder.organizationId] to an arbitrary JSON value. + * + * You should usually call [Builder.organizationId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun organizationId(organizationId: JsonField<String>) = apply { + this.organizationId = organizationId + } + + fun providerId(providerId: String) = providerId(JsonField.of(providerId)) + + /** + * Sets [Builder.providerId] to an arbitrary JSON value. + * + * You should usually call [Builder.providerId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun providerId(providerId: JsonField<String>) = apply { this.providerId = providerId } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SsoRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .organizationDisplayName() + * .organizationId() + * .providerId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SsoRetrieveResponse = + SsoRetrieveResponse( + checkRequired("organizationDisplayName", organizationDisplayName), + checkRequired("organizationId", organizationId), + checkRequired("providerId", providerId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SsoRetrieveResponse = apply { + if (validated) { + return@apply + } + + organizationDisplayName() + organizationId() + providerId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (organizationDisplayName.asKnown().isPresent) 1 else 0) + + (if (organizationId.asKnown().isPresent) 1 else 0) + + (if (providerId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SsoRetrieveResponse && + organizationDisplayName == other.organizationDisplayName && + organizationId == other.organizationId && + providerId == other.providerId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(organizationDisplayName, organizationId, providerId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SsoRetrieveResponse{organizationDisplayName=$organizationDisplayName, organizationId=$organizationId, providerId=$providerId, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationConfirmParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationConfirmParams.kt new file mode 100644 index 00000000..b265bfeb --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationConfirmParams.kt @@ -0,0 +1,409 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sso.emailverification + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +/** Confirm the email of an SSO user. */ +class EmailVerificationConfirmParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun token(): String = body.token() + + /** + * Returns the raw JSON value of [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _token(): JsonField<String> = body._token() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [EmailVerificationConfirmParams]. + * + * The following fields are required: + * ```java + * .token() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EmailVerificationConfirmParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(emailVerificationConfirmParams: EmailVerificationConfirmParams) = apply { + body = emailVerificationConfirmParams.body.toBuilder() + additionalHeaders = emailVerificationConfirmParams.additionalHeaders.toBuilder() + additionalQueryParams = emailVerificationConfirmParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [token] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun token(token: String) = apply { body.token(token) } + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun token(token: JsonField<String>) = apply { body.token(token) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [EmailVerificationConfirmParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EmailVerificationConfirmParams = + EmailVerificationConfirmParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val token: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField<String> = JsonMissing.of() + ) : this(token, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun token(): String = token.getRequired("token") + + /** + * Returns the raw JSON value of [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField<String> = token + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .token() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var token: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + token = body.token + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun token(token: JsonField<String>) = apply { this.token = token } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body(checkRequired("token", token), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + token() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (token.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + token == other.token && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(token, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Body{token=$token, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EmailVerificationConfirmParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "EmailVerificationConfirmParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationConfirmResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationConfirmResponse.kt new file mode 100644 index 00000000..00820f9c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationConfirmResponse.kt @@ -0,0 +1,121 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sso.emailverification + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class EmailVerificationConfirmResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [EmailVerificationConfirmResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EmailVerificationConfirmResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(emailVerificationConfirmResponse: EmailVerificationConfirmResponse) = + apply { + additionalProperties = + emailVerificationConfirmResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EmailVerificationConfirmResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): EmailVerificationConfirmResponse = + EmailVerificationConfirmResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): EmailVerificationConfirmResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EmailVerificationConfirmResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EmailVerificationConfirmResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationSendParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationSendParams.kt new file mode 100644 index 00000000..0656a515 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationSendParams.kt @@ -0,0 +1,487 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sso.emailverification + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +/** Send an email to confirm the email address for an SSO user. */ +class EmailVerificationSendParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun email(): String = body.email() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun samlProviderId(): String = body.samlProviderId() + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _email(): JsonField<String> = body._email() + + /** + * Returns the raw JSON value of [samlProviderId]. + * + * Unlike [samlProviderId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _samlProviderId(): JsonField<String> = body._samlProviderId() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [EmailVerificationSendParams]. + * + * The following fields are required: + * ```java + * .email() + * .samlProviderId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EmailVerificationSendParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(emailVerificationSendParams: EmailVerificationSendParams) = apply { + body = emailVerificationSendParams.body.toBuilder() + additionalHeaders = emailVerificationSendParams.additionalHeaders.toBuilder() + additionalQueryParams = emailVerificationSendParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [email] + * - [samlProviderId] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun email(email: String) = apply { body.email(email) } + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun email(email: JsonField<String>) = apply { body.email(email) } + + fun samlProviderId(samlProviderId: String) = apply { body.samlProviderId(samlProviderId) } + + /** + * Sets [Builder.samlProviderId] to an arbitrary JSON value. + * + * You should usually call [Builder.samlProviderId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun samlProviderId(samlProviderId: JsonField<String>) = apply { + body.samlProviderId(samlProviderId) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [EmailVerificationSendParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .email() + * .samlProviderId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EmailVerificationSendParams = + EmailVerificationSendParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val email: JsonField<String>, + private val samlProviderId: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("email") @ExcludeMissing email: JsonField<String> = JsonMissing.of(), + @JsonProperty("saml_provider_id") + @ExcludeMissing + samlProviderId: JsonField<String> = JsonMissing.of(), + ) : this(email, samlProviderId, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun email(): String = email.getRequired("email") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun samlProviderId(): String = samlProviderId.getRequired("saml_provider_id") + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField<String> = email + + /** + * Returns the raw JSON value of [samlProviderId]. + * + * Unlike [samlProviderId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("saml_provider_id") + @ExcludeMissing + fun _samlProviderId(): JsonField<String> = samlProviderId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .email() + * .samlProviderId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var email: JsonField<String>? = null + private var samlProviderId: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + email = body.email + samlProviderId = body.samlProviderId + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun email(email: String) = email(JsonField.of(email)) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun email(email: JsonField<String>) = apply { this.email = email } + + fun samlProviderId(samlProviderId: String) = + samlProviderId(JsonField.of(samlProviderId)) + + /** + * Sets [Builder.samlProviderId] to an arbitrary JSON value. + * + * You should usually call [Builder.samlProviderId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun samlProviderId(samlProviderId: JsonField<String>) = apply { + this.samlProviderId = samlProviderId + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .email() + * .samlProviderId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("email", email), + checkRequired("samlProviderId", samlProviderId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + email() + samlProviderId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (email.asKnown().isPresent) 1 else 0) + + (if (samlProviderId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + email == other.email && + samlProviderId == other.samlProviderId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(email, samlProviderId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{email=$email, samlProviderId=$samlProviderId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EmailVerificationSendParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "EmailVerificationSendParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationSendResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationSendResponse.kt new file mode 100644 index 00000000..2e33c58d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationSendResponse.kt @@ -0,0 +1,119 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sso.emailverification + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class EmailVerificationSendResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [EmailVerificationSendResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EmailVerificationSendResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(emailVerificationSendResponse: EmailVerificationSendResponse) = apply { + additionalProperties = emailVerificationSendResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EmailVerificationSendResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): EmailVerificationSendResponse = + EmailVerificationSendResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): EmailVerificationSendResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EmailVerificationSendResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EmailVerificationSendResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationStatusParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationStatusParams.kt new file mode 100644 index 00000000..1ea1e661 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationStatusParams.kt @@ -0,0 +1,488 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sso.emailverification + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +/** Retrieve the email verification status of an SSO user. */ +class EmailVerificationStatusParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun email(): String = body.email() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun samlProviderId(): String = body.samlProviderId() + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _email(): JsonField<String> = body._email() + + /** + * Returns the raw JSON value of [samlProviderId]. + * + * Unlike [samlProviderId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _samlProviderId(): JsonField<String> = body._samlProviderId() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [EmailVerificationStatusParams]. + * + * The following fields are required: + * ```java + * .email() + * .samlProviderId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EmailVerificationStatusParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(emailVerificationStatusParams: EmailVerificationStatusParams) = apply { + body = emailVerificationStatusParams.body.toBuilder() + additionalHeaders = emailVerificationStatusParams.additionalHeaders.toBuilder() + additionalQueryParams = emailVerificationStatusParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [email] + * - [samlProviderId] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun email(email: String) = apply { body.email(email) } + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun email(email: JsonField<String>) = apply { body.email(email) } + + fun samlProviderId(samlProviderId: String) = apply { body.samlProviderId(samlProviderId) } + + /** + * Sets [Builder.samlProviderId] to an arbitrary JSON value. + * + * You should usually call [Builder.samlProviderId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun samlProviderId(samlProviderId: JsonField<String>) = apply { + body.samlProviderId(samlProviderId) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [EmailVerificationStatusParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .email() + * .samlProviderId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EmailVerificationStatusParams = + EmailVerificationStatusParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val email: JsonField<String>, + private val samlProviderId: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("email") @ExcludeMissing email: JsonField<String> = JsonMissing.of(), + @JsonProperty("saml_provider_id") + @ExcludeMissing + samlProviderId: JsonField<String> = JsonMissing.of(), + ) : this(email, samlProviderId, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun email(): String = email.getRequired("email") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun samlProviderId(): String = samlProviderId.getRequired("saml_provider_id") + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField<String> = email + + /** + * Returns the raw JSON value of [samlProviderId]. + * + * Unlike [samlProviderId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("saml_provider_id") + @ExcludeMissing + fun _samlProviderId(): JsonField<String> = samlProviderId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .email() + * .samlProviderId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var email: JsonField<String>? = null + private var samlProviderId: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + email = body.email + samlProviderId = body.samlProviderId + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun email(email: String) = email(JsonField.of(email)) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun email(email: JsonField<String>) = apply { this.email = email } + + fun samlProviderId(samlProviderId: String) = + samlProviderId(JsonField.of(samlProviderId)) + + /** + * Sets [Builder.samlProviderId] to an arbitrary JSON value. + * + * You should usually call [Builder.samlProviderId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun samlProviderId(samlProviderId: JsonField<String>) = apply { + this.samlProviderId = samlProviderId + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .email() + * .samlProviderId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("email", email), + checkRequired("samlProviderId", samlProviderId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + email() + samlProviderId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (email.asKnown().isPresent) 1 else 0) + + (if (samlProviderId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + email == other.email && + samlProviderId == other.samlProviderId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(email, samlProviderId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{email=$email, samlProviderId=$samlProviderId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EmailVerificationStatusParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "EmailVerificationStatusParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationStatusResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationStatusResponse.kt new file mode 100644 index 00000000..8898b068 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationStatusResponse.kt @@ -0,0 +1,175 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sso.emailverification + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class EmailVerificationStatusResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val emailConfirmedAt: JsonField<OffsetDateTime>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("email_confirmed_at") + @ExcludeMissing + emailConfirmedAt: JsonField<OffsetDateTime> = JsonMissing.of() + ) : this(emailConfirmedAt, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun emailConfirmedAt(): Optional<OffsetDateTime> = + emailConfirmedAt.getOptional("email_confirmed_at") + + /** + * Returns the raw JSON value of [emailConfirmedAt]. + * + * Unlike [emailConfirmedAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("email_confirmed_at") + @ExcludeMissing + fun _emailConfirmedAt(): JsonField<OffsetDateTime> = emailConfirmedAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [EmailVerificationStatusResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EmailVerificationStatusResponse]. */ + class Builder internal constructor() { + + private var emailConfirmedAt: JsonField<OffsetDateTime> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(emailVerificationStatusResponse: EmailVerificationStatusResponse) = + apply { + emailConfirmedAt = emailVerificationStatusResponse.emailConfirmedAt + additionalProperties = + emailVerificationStatusResponse.additionalProperties.toMutableMap() + } + + fun emailConfirmedAt(emailConfirmedAt: OffsetDateTime?) = + emailConfirmedAt(JsonField.ofNullable(emailConfirmedAt)) + + /** Alias for calling [Builder.emailConfirmedAt] with `emailConfirmedAt.orElse(null)`. */ + fun emailConfirmedAt(emailConfirmedAt: Optional<OffsetDateTime>) = + emailConfirmedAt(emailConfirmedAt.getOrNull()) + + /** + * Sets [Builder.emailConfirmedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.emailConfirmedAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun emailConfirmedAt(emailConfirmedAt: JsonField<OffsetDateTime>) = apply { + this.emailConfirmedAt = emailConfirmedAt + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EmailVerificationStatusResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): EmailVerificationStatusResponse = + EmailVerificationStatusResponse(emailConfirmedAt, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): EmailVerificationStatusResponse = apply { + if (validated) { + return@apply + } + + emailConfirmedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (emailConfirmedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EmailVerificationStatusResponse && + emailConfirmedAt == other.emailConfirmedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(emailConfirmedAt, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EmailVerificationStatusResponse{emailConfirmedAt=$emailConfirmedAt, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/tenants/AppSchemasTenant.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/tenants/AppSchemasTenant.kt new file mode 100644 index 00000000..6d145374 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/tenants/AppSchemasTenant.kt @@ -0,0 +1,428 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.tenants + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Tenant schema. */ +class AppSchemasTenant +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val displayName: JsonField<String>, + private val isDeleted: JsonField<Boolean>, + private val isPersonal: JsonField<Boolean>, + private val organizationId: JsonField<String>, + private val tenantHandle: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField<String> = JsonMissing.of(), + @JsonProperty("is_deleted") + @ExcludeMissing + isDeleted: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("is_personal") + @ExcludeMissing + isPersonal: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("organization_id") + @ExcludeMissing + organizationId: JsonField<String> = JsonMissing.of(), + @JsonProperty("tenant_handle") + @ExcludeMissing + tenantHandle: JsonField<String> = JsonMissing.of(), + ) : this( + id, + createdAt, + displayName, + isDeleted, + isPersonal, + organizationId, + tenantHandle, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun displayName(): String = displayName.getRequired("display_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun isDeleted(): Boolean = isDeleted.getRequired("is_deleted") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun isPersonal(): Boolean = isPersonal.getRequired("is_personal") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun organizationId(): Optional<String> = organizationId.getOptional("organization_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tenantHandle(): Optional<String> = tenantHandle.getOptional("tenant_handle") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField<String> = displayName + + /** + * Returns the raw JSON value of [isDeleted]. + * + * Unlike [isDeleted], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_deleted") @ExcludeMissing fun _isDeleted(): JsonField<Boolean> = isDeleted + + /** + * Returns the raw JSON value of [isPersonal]. + * + * Unlike [isPersonal], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_personal") @ExcludeMissing fun _isPersonal(): JsonField<Boolean> = isPersonal + + /** + * Returns the raw JSON value of [organizationId]. + * + * Unlike [organizationId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("organization_id") + @ExcludeMissing + fun _organizationId(): JsonField<String> = organizationId + + /** + * Returns the raw JSON value of [tenantHandle]. + * + * Unlike [tenantHandle], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_handle") + @ExcludeMissing + fun _tenantHandle(): JsonField<String> = tenantHandle + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AppSchemasTenant]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .displayName() + * .isDeleted() + * .isPersonal() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AppSchemasTenant]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var createdAt: JsonField<OffsetDateTime>? = null + private var displayName: JsonField<String>? = null + private var isDeleted: JsonField<Boolean>? = null + private var isPersonal: JsonField<Boolean>? = null + private var organizationId: JsonField<String> = JsonMissing.of() + private var tenantHandle: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(appSchemasTenant: AppSchemasTenant) = apply { + id = appSchemasTenant.id + createdAt = appSchemasTenant.createdAt + displayName = appSchemasTenant.displayName + isDeleted = appSchemasTenant.isDeleted + isPersonal = appSchemasTenant.isPersonal + organizationId = appSchemasTenant.organizationId + tenantHandle = appSchemasTenant.tenantHandle + additionalProperties = appSchemasTenant.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun displayName(displayName: String) = displayName(JsonField.of(displayName)) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun displayName(displayName: JsonField<String>) = apply { this.displayName = displayName } + + fun isDeleted(isDeleted: Boolean) = isDeleted(JsonField.of(isDeleted)) + + /** + * Sets [Builder.isDeleted] to an arbitrary JSON value. + * + * You should usually call [Builder.isDeleted] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isDeleted(isDeleted: JsonField<Boolean>) = apply { this.isDeleted = isDeleted } + + fun isPersonal(isPersonal: Boolean) = isPersonal(JsonField.of(isPersonal)) + + /** + * Sets [Builder.isPersonal] to an arbitrary JSON value. + * + * You should usually call [Builder.isPersonal] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isPersonal(isPersonal: JsonField<Boolean>) = apply { this.isPersonal = isPersonal } + + fun organizationId(organizationId: String?) = + organizationId(JsonField.ofNullable(organizationId)) + + /** Alias for calling [Builder.organizationId] with `organizationId.orElse(null)`. */ + fun organizationId(organizationId: Optional<String>) = + organizationId(organizationId.getOrNull()) + + /** + * Sets [Builder.organizationId] to an arbitrary JSON value. + * + * You should usually call [Builder.organizationId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun organizationId(organizationId: JsonField<String>) = apply { + this.organizationId = organizationId + } + + fun tenantHandle(tenantHandle: String?) = tenantHandle(JsonField.ofNullable(tenantHandle)) + + /** Alias for calling [Builder.tenantHandle] with `tenantHandle.orElse(null)`. */ + fun tenantHandle(tenantHandle: Optional<String>) = tenantHandle(tenantHandle.getOrNull()) + + /** + * Sets [Builder.tenantHandle] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantHandle] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tenantHandle(tenantHandle: JsonField<String>) = apply { + this.tenantHandle = tenantHandle + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AppSchemasTenant]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .displayName() + * .isDeleted() + * .isPersonal() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AppSchemasTenant = + AppSchemasTenant( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("displayName", displayName), + checkRequired("isDeleted", isDeleted), + checkRequired("isPersonal", isPersonal), + organizationId, + tenantHandle, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AppSchemasTenant = apply { + if (validated) { + return@apply + } + + id() + createdAt() + displayName() + isDeleted() + isPersonal() + organizationId() + tenantHandle() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (displayName.asKnown().isPresent) 1 else 0) + + (if (isDeleted.asKnown().isPresent) 1 else 0) + + (if (isPersonal.asKnown().isPresent) 1 else 0) + + (if (organizationId.asKnown().isPresent) 1 else 0) + + (if (tenantHandle.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AppSchemasTenant && + id == other.id && + createdAt == other.createdAt && + displayName == other.displayName && + isDeleted == other.isDeleted && + isPersonal == other.isPersonal && + organizationId == other.organizationId && + tenantHandle == other.tenantHandle && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + createdAt, + displayName, + isDeleted, + isPersonal, + organizationId, + tenantHandle, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AppSchemasTenant{id=$id, createdAt=$createdAt, displayName=$displayName, isDeleted=$isDeleted, isPersonal=$isPersonal, organizationId=$organizationId, tenantHandle=$tenantHandle, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/tenants/TenantCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/tenants/TenantCreateParams.kt new file mode 100644 index 00000000..a148a186 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/tenants/TenantCreateParams.kt @@ -0,0 +1,700 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.tenants + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create a new organization and corresponding workspace. */ +class TenantCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun displayName(): String = body.displayName() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional<String> = body.id() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun isPersonal(): Optional<Boolean> = body.isPersonal() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun organizationId(): Optional<String> = body.organizationId() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tenantHandle(): Optional<String> = body.tenantHandle() + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _displayName(): JsonField<String> = body._displayName() + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _id(): JsonField<String> = body._id() + + /** + * Returns the raw JSON value of [isPersonal]. + * + * Unlike [isPersonal], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _isPersonal(): JsonField<Boolean> = body._isPersonal() + + /** + * Returns the raw JSON value of [organizationId]. + * + * Unlike [organizationId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _organizationId(): JsonField<String> = body._organizationId() + + /** + * Returns the raw JSON value of [tenantHandle]. + * + * Unlike [tenantHandle], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _tenantHandle(): JsonField<String> = body._tenantHandle() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TenantCreateParams]. + * + * The following fields are required: + * ```java + * .displayName() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TenantCreateParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(tenantCreateParams: TenantCreateParams) = apply { + body = tenantCreateParams.body.toBuilder() + additionalHeaders = tenantCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = tenantCreateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [displayName] + * - [id] + * - [isPersonal] + * - [organizationId] + * - [tenantHandle] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun displayName(displayName: String) = apply { body.displayName(displayName) } + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun displayName(displayName: JsonField<String>) = apply { body.displayName(displayName) } + + fun id(id: String) = apply { body.id(id) } + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { body.id(id) } + + fun isPersonal(isPersonal: Boolean) = apply { body.isPersonal(isPersonal) } + + /** + * Sets [Builder.isPersonal] to an arbitrary JSON value. + * + * You should usually call [Builder.isPersonal] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isPersonal(isPersonal: JsonField<Boolean>) = apply { body.isPersonal(isPersonal) } + + fun organizationId(organizationId: String?) = apply { body.organizationId(organizationId) } + + /** Alias for calling [Builder.organizationId] with `organizationId.orElse(null)`. */ + fun organizationId(organizationId: Optional<String>) = + organizationId(organizationId.getOrNull()) + + /** + * Sets [Builder.organizationId] to an arbitrary JSON value. + * + * You should usually call [Builder.organizationId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun organizationId(organizationId: JsonField<String>) = apply { + body.organizationId(organizationId) + } + + fun tenantHandle(tenantHandle: String?) = apply { body.tenantHandle(tenantHandle) } + + /** Alias for calling [Builder.tenantHandle] with `tenantHandle.orElse(null)`. */ + fun tenantHandle(tenantHandle: Optional<String>) = tenantHandle(tenantHandle.getOrNull()) + + /** + * Sets [Builder.tenantHandle] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantHandle] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tenantHandle(tenantHandle: JsonField<String>) = apply { + body.tenantHandle(tenantHandle) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TenantCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .displayName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TenantCreateParams = + TenantCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Creation model for the tenant. */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val displayName: JsonField<String>, + private val id: JsonField<String>, + private val isPersonal: JsonField<Boolean>, + private val organizationId: JsonField<String>, + private val tenantHandle: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField<String> = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("is_personal") + @ExcludeMissing + isPersonal: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("organization_id") + @ExcludeMissing + organizationId: JsonField<String> = JsonMissing.of(), + @JsonProperty("tenant_handle") + @ExcludeMissing + tenantHandle: JsonField<String> = JsonMissing.of(), + ) : this(displayName, id, isPersonal, organizationId, tenantHandle, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun displayName(): String = displayName.getRequired("display_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun isPersonal(): Optional<Boolean> = isPersonal.getOptional("is_personal") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun organizationId(): Optional<String> = organizationId.getOptional("organization_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun tenantHandle(): Optional<String> = tenantHandle.getOptional("tenant_handle") + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField<String> = displayName + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [isPersonal]. + * + * Unlike [isPersonal], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_personal") + @ExcludeMissing + fun _isPersonal(): JsonField<Boolean> = isPersonal + + /** + * Returns the raw JSON value of [organizationId]. + * + * Unlike [organizationId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("organization_id") + @ExcludeMissing + fun _organizationId(): JsonField<String> = organizationId + + /** + * Returns the raw JSON value of [tenantHandle]. + * + * Unlike [tenantHandle], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tenant_handle") + @ExcludeMissing + fun _tenantHandle(): JsonField<String> = tenantHandle + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .displayName() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var displayName: JsonField<String>? = null + private var id: JsonField<String> = JsonMissing.of() + private var isPersonal: JsonField<Boolean> = JsonMissing.of() + private var organizationId: JsonField<String> = JsonMissing.of() + private var tenantHandle: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + displayName = body.displayName + id = body.id + isPersonal = body.isPersonal + organizationId = body.organizationId + tenantHandle = body.tenantHandle + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun displayName(displayName: String) = displayName(JsonField.of(displayName)) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun displayName(displayName: JsonField<String>) = apply { + this.displayName = displayName + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun isPersonal(isPersonal: Boolean) = isPersonal(JsonField.of(isPersonal)) + + /** + * Sets [Builder.isPersonal] to an arbitrary JSON value. + * + * You should usually call [Builder.isPersonal] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isPersonal(isPersonal: JsonField<Boolean>) = apply { this.isPersonal = isPersonal } + + fun organizationId(organizationId: String?) = + organizationId(JsonField.ofNullable(organizationId)) + + /** Alias for calling [Builder.organizationId] with `organizationId.orElse(null)`. */ + fun organizationId(organizationId: Optional<String>) = + organizationId(organizationId.getOrNull()) + + /** + * Sets [Builder.organizationId] to an arbitrary JSON value. + * + * You should usually call [Builder.organizationId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun organizationId(organizationId: JsonField<String>) = apply { + this.organizationId = organizationId + } + + fun tenantHandle(tenantHandle: String?) = + tenantHandle(JsonField.ofNullable(tenantHandle)) + + /** Alias for calling [Builder.tenantHandle] with `tenantHandle.orElse(null)`. */ + fun tenantHandle(tenantHandle: Optional<String>) = + tenantHandle(tenantHandle.getOrNull()) + + /** + * Sets [Builder.tenantHandle] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantHandle] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tenantHandle(tenantHandle: JsonField<String>) = apply { + this.tenantHandle = tenantHandle + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .displayName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("displayName", displayName), + id, + isPersonal, + organizationId, + tenantHandle, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + displayName() + id() + isPersonal() + organizationId() + tenantHandle() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (displayName.asKnown().isPresent) 1 else 0) + + (if (id.asKnown().isPresent) 1 else 0) + + (if (isPersonal.asKnown().isPresent) 1 else 0) + + (if (organizationId.asKnown().isPresent) 1 else 0) + + (if (tenantHandle.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + displayName == other.displayName && + id == other.id && + isPersonal == other.isPersonal && + organizationId == other.organizationId && + tenantHandle == other.tenantHandle && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + displayName, + id, + isPersonal, + organizationId, + tenantHandle, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{displayName=$displayName, id=$id, isPersonal=$isPersonal, organizationId=$organizationId, tenantHandle=$tenantHandle, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TenantCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TenantCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/tenants/TenantForUser.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/tenants/TenantForUser.kt new file mode 100644 index 00000000..88482919 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/tenants/TenantForUser.kt @@ -0,0 +1,590 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.tenants + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class TenantForUser +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val displayName: JsonField<String>, + private val isDeleted: JsonField<Boolean>, + private val isPersonal: JsonField<Boolean>, + private val organizationId: JsonField<String>, + private val permissions: JsonField<List<String>>, + private val readOnly: JsonField<Boolean>, + private val roleId: JsonField<String>, + private val roleName: JsonField<String>, + private val tenantHandle: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField<String> = JsonMissing.of(), + @JsonProperty("is_deleted") + @ExcludeMissing + isDeleted: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("is_personal") + @ExcludeMissing + isPersonal: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("organization_id") + @ExcludeMissing + organizationId: JsonField<String> = JsonMissing.of(), + @JsonProperty("permissions") + @ExcludeMissing + permissions: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("read_only") @ExcludeMissing readOnly: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("role_id") @ExcludeMissing roleId: JsonField<String> = JsonMissing.of(), + @JsonProperty("role_name") @ExcludeMissing roleName: JsonField<String> = JsonMissing.of(), + @JsonProperty("tenant_handle") + @ExcludeMissing + tenantHandle: JsonField<String> = JsonMissing.of(), + ) : this( + id, + createdAt, + displayName, + isDeleted, + isPersonal, + organizationId, + permissions, + readOnly, + roleId, + roleName, + tenantHandle, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun displayName(): String = displayName.getRequired("display_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun isDeleted(): Boolean = isDeleted.getRequired("is_deleted") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun isPersonal(): Boolean = isPersonal.getRequired("is_personal") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun organizationId(): Optional<String> = organizationId.getOptional("organization_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun permissions(): Optional<List<String>> = permissions.getOptional("permissions") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun readOnly(): Optional<Boolean> = readOnly.getOptional("read_only") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun roleId(): Optional<String> = roleId.getOptional("role_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun roleName(): Optional<String> = roleName.getOptional("role_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tenantHandle(): Optional<String> = tenantHandle.getOptional("tenant_handle") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField<String> = displayName + + /** + * Returns the raw JSON value of [isDeleted]. + * + * Unlike [isDeleted], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_deleted") @ExcludeMissing fun _isDeleted(): JsonField<Boolean> = isDeleted + + /** + * Returns the raw JSON value of [isPersonal]. + * + * Unlike [isPersonal], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_personal") @ExcludeMissing fun _isPersonal(): JsonField<Boolean> = isPersonal + + /** + * Returns the raw JSON value of [organizationId]. + * + * Unlike [organizationId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("organization_id") + @ExcludeMissing + fun _organizationId(): JsonField<String> = organizationId + + /** + * Returns the raw JSON value of [permissions]. + * + * Unlike [permissions], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("permissions") + @ExcludeMissing + fun _permissions(): JsonField<List<String>> = permissions + + /** + * Returns the raw JSON value of [readOnly]. + * + * Unlike [readOnly], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("read_only") @ExcludeMissing fun _readOnly(): JsonField<Boolean> = readOnly + + /** + * Returns the raw JSON value of [roleId]. + * + * Unlike [roleId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("role_id") @ExcludeMissing fun _roleId(): JsonField<String> = roleId + + /** + * Returns the raw JSON value of [roleName]. + * + * Unlike [roleName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("role_name") @ExcludeMissing fun _roleName(): JsonField<String> = roleName + + /** + * Returns the raw JSON value of [tenantHandle]. + * + * Unlike [tenantHandle], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_handle") + @ExcludeMissing + fun _tenantHandle(): JsonField<String> = tenantHandle + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TenantForUser]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .displayName() + * .isDeleted() + * .isPersonal() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TenantForUser]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var createdAt: JsonField<OffsetDateTime>? = null + private var displayName: JsonField<String>? = null + private var isDeleted: JsonField<Boolean>? = null + private var isPersonal: JsonField<Boolean>? = null + private var organizationId: JsonField<String> = JsonMissing.of() + private var permissions: JsonField<MutableList<String>>? = null + private var readOnly: JsonField<Boolean> = JsonMissing.of() + private var roleId: JsonField<String> = JsonMissing.of() + private var roleName: JsonField<String> = JsonMissing.of() + private var tenantHandle: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(tenantForUser: TenantForUser) = apply { + id = tenantForUser.id + createdAt = tenantForUser.createdAt + displayName = tenantForUser.displayName + isDeleted = tenantForUser.isDeleted + isPersonal = tenantForUser.isPersonal + organizationId = tenantForUser.organizationId + permissions = tenantForUser.permissions.map { it.toMutableList() } + readOnly = tenantForUser.readOnly + roleId = tenantForUser.roleId + roleName = tenantForUser.roleName + tenantHandle = tenantForUser.tenantHandle + additionalProperties = tenantForUser.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun displayName(displayName: String) = displayName(JsonField.of(displayName)) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun displayName(displayName: JsonField<String>) = apply { this.displayName = displayName } + + fun isDeleted(isDeleted: Boolean) = isDeleted(JsonField.of(isDeleted)) + + /** + * Sets [Builder.isDeleted] to an arbitrary JSON value. + * + * You should usually call [Builder.isDeleted] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isDeleted(isDeleted: JsonField<Boolean>) = apply { this.isDeleted = isDeleted } + + fun isPersonal(isPersonal: Boolean) = isPersonal(JsonField.of(isPersonal)) + + /** + * Sets [Builder.isPersonal] to an arbitrary JSON value. + * + * You should usually call [Builder.isPersonal] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isPersonal(isPersonal: JsonField<Boolean>) = apply { this.isPersonal = isPersonal } + + fun organizationId(organizationId: String?) = + organizationId(JsonField.ofNullable(organizationId)) + + /** Alias for calling [Builder.organizationId] with `organizationId.orElse(null)`. */ + fun organizationId(organizationId: Optional<String>) = + organizationId(organizationId.getOrNull()) + + /** + * Sets [Builder.organizationId] to an arbitrary JSON value. + * + * You should usually call [Builder.organizationId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun organizationId(organizationId: JsonField<String>) = apply { + this.organizationId = organizationId + } + + fun permissions(permissions: List<String>?) = permissions(JsonField.ofNullable(permissions)) + + /** Alias for calling [Builder.permissions] with `permissions.orElse(null)`. */ + fun permissions(permissions: Optional<List<String>>) = permissions(permissions.getOrNull()) + + /** + * Sets [Builder.permissions] to an arbitrary JSON value. + * + * You should usually call [Builder.permissions] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun permissions(permissions: JsonField<List<String>>) = apply { + this.permissions = permissions.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [permissions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPermission(permission: String) = apply { + permissions = + (permissions ?: JsonField.of(mutableListOf())).also { + checkKnown("permissions", it).add(permission) + } + } + + fun readOnly(readOnly: Boolean) = readOnly(JsonField.of(readOnly)) + + /** + * Sets [Builder.readOnly] to an arbitrary JSON value. + * + * You should usually call [Builder.readOnly] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun readOnly(readOnly: JsonField<Boolean>) = apply { this.readOnly = readOnly } + + fun roleId(roleId: String?) = roleId(JsonField.ofNullable(roleId)) + + /** Alias for calling [Builder.roleId] with `roleId.orElse(null)`. */ + fun roleId(roleId: Optional<String>) = roleId(roleId.getOrNull()) + + /** + * Sets [Builder.roleId] to an arbitrary JSON value. + * + * You should usually call [Builder.roleId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun roleId(roleId: JsonField<String>) = apply { this.roleId = roleId } + + fun roleName(roleName: String?) = roleName(JsonField.ofNullable(roleName)) + + /** Alias for calling [Builder.roleName] with `roleName.orElse(null)`. */ + fun roleName(roleName: Optional<String>) = roleName(roleName.getOrNull()) + + /** + * Sets [Builder.roleName] to an arbitrary JSON value. + * + * You should usually call [Builder.roleName] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun roleName(roleName: JsonField<String>) = apply { this.roleName = roleName } + + fun tenantHandle(tenantHandle: String?) = tenantHandle(JsonField.ofNullable(tenantHandle)) + + /** Alias for calling [Builder.tenantHandle] with `tenantHandle.orElse(null)`. */ + fun tenantHandle(tenantHandle: Optional<String>) = tenantHandle(tenantHandle.getOrNull()) + + /** + * Sets [Builder.tenantHandle] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantHandle] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tenantHandle(tenantHandle: JsonField<String>) = apply { + this.tenantHandle = tenantHandle + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TenantForUser]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .displayName() + * .isDeleted() + * .isPersonal() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TenantForUser = + TenantForUser( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("displayName", displayName), + checkRequired("isDeleted", isDeleted), + checkRequired("isPersonal", isPersonal), + organizationId, + (permissions ?: JsonMissing.of()).map { it.toImmutable() }, + readOnly, + roleId, + roleName, + tenantHandle, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TenantForUser = apply { + if (validated) { + return@apply + } + + id() + createdAt() + displayName() + isDeleted() + isPersonal() + organizationId() + permissions() + readOnly() + roleId() + roleName() + tenantHandle() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (displayName.asKnown().isPresent) 1 else 0) + + (if (isDeleted.asKnown().isPresent) 1 else 0) + + (if (isPersonal.asKnown().isPresent) 1 else 0) + + (if (organizationId.asKnown().isPresent) 1 else 0) + + (permissions.asKnown().getOrNull()?.size ?: 0) + + (if (readOnly.asKnown().isPresent) 1 else 0) + + (if (roleId.asKnown().isPresent) 1 else 0) + + (if (roleName.asKnown().isPresent) 1 else 0) + + (if (tenantHandle.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TenantForUser && + id == other.id && + createdAt == other.createdAt && + displayName == other.displayName && + isDeleted == other.isDeleted && + isPersonal == other.isPersonal && + organizationId == other.organizationId && + permissions == other.permissions && + readOnly == other.readOnly && + roleId == other.roleId && + roleName == other.roleName && + tenantHandle == other.tenantHandle && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + createdAt, + displayName, + isDeleted, + isPersonal, + organizationId, + permissions, + readOnly, + roleId, + roleName, + tenantHandle, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TenantForUser{id=$id, createdAt=$createdAt, displayName=$displayName, isDeleted=$isDeleted, isPersonal=$isPersonal, organizationId=$organizationId, permissions=$permissions, readOnly=$readOnly, roleId=$roleId, roleName=$roleName, tenantHandle=$tenantHandle, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/tenants/TenantListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/tenants/TenantListParams.kt new file mode 100644 index 00000000..a5ea8876 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/tenants/TenantListParams.kt @@ -0,0 +1,224 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.tenants + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get all tenants visible to this auth */ +class TenantListParams +private constructor( + private val includeDeleted: Boolean?, + private val skipCreate: Boolean?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun includeDeleted(): Optional<Boolean> = Optional.ofNullable(includeDeleted) + + fun skipCreate(): Optional<Boolean> = Optional.ofNullable(skipCreate) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): TenantListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [TenantListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TenantListParams]. */ + class Builder internal constructor() { + + private var includeDeleted: Boolean? = null + private var skipCreate: Boolean? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(tenantListParams: TenantListParams) = apply { + includeDeleted = tenantListParams.includeDeleted + skipCreate = tenantListParams.skipCreate + additionalHeaders = tenantListParams.additionalHeaders.toBuilder() + additionalQueryParams = tenantListParams.additionalQueryParams.toBuilder() + } + + fun includeDeleted(includeDeleted: Boolean?) = apply { + this.includeDeleted = includeDeleted + } + + /** + * Alias for [Builder.includeDeleted]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun includeDeleted(includeDeleted: Boolean) = includeDeleted(includeDeleted as Boolean?) + + /** Alias for calling [Builder.includeDeleted] with `includeDeleted.orElse(null)`. */ + fun includeDeleted(includeDeleted: Optional<Boolean>) = + includeDeleted(includeDeleted.getOrNull()) + + fun skipCreate(skipCreate: Boolean?) = apply { this.skipCreate = skipCreate } + + /** + * Alias for [Builder.skipCreate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun skipCreate(skipCreate: Boolean) = skipCreate(skipCreate as Boolean?) + + /** Alias for calling [Builder.skipCreate] with `skipCreate.orElse(null)`. */ + fun skipCreate(skipCreate: Optional<Boolean>) = skipCreate(skipCreate.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TenantListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TenantListParams = + TenantListParams( + includeDeleted, + skipCreate, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + includeDeleted?.let { put("include_deleted", it.toString()) } + skipCreate?.let { put("skip_create", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TenantListParams && + includeDeleted == other.includeDeleted && + skipCreate == other.skipCreate && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(includeDeleted, skipCreate, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TenantListParams{includeDeleted=$includeDeleted, skipCreate=$skipCreate, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/ttlsettings/TtlSettingRetrieveTtlSettingsParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/ttlsettings/TtlSettingRetrieveTtlSettingsParams.kt new file mode 100644 index 00000000..c2114d84 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/ttlsettings/TtlSettingRetrieveTtlSettingsParams.kt @@ -0,0 +1,179 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.ttlsettings + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** List out the configured TTL settings for a given tenant. */ +class TtlSettingRetrieveTtlSettingsParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): TtlSettingRetrieveTtlSettingsParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [TtlSettingRetrieveTtlSettingsParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TtlSettingRetrieveTtlSettingsParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + ttlSettingRetrieveTtlSettingsParams: TtlSettingRetrieveTtlSettingsParams + ) = apply { + additionalHeaders = ttlSettingRetrieveTtlSettingsParams.additionalHeaders.toBuilder() + additionalQueryParams = + ttlSettingRetrieveTtlSettingsParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TtlSettingRetrieveTtlSettingsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TtlSettingRetrieveTtlSettingsParams = + TtlSettingRetrieveTtlSettingsParams( + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TtlSettingRetrieveTtlSettingsParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "TtlSettingRetrieveTtlSettingsParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/ttlsettings/TtlSettingUpdateTtlSettingsParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/ttlsettings/TtlSettingUpdateTtlSettingsParams.kt new file mode 100644 index 00000000..cba1e13d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/ttlsettings/TtlSettingUpdateTtlSettingsParams.kt @@ -0,0 +1,211 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.ttlsettings + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.UpsertTtlSettingsRequest +import java.util.Objects + +/** Upsert Ttl Settings */ +class TtlSettingUpdateTtlSettingsParams +private constructor( + private val upsertTtlSettingsRequest: UpsertTtlSettingsRequest, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Base TTL settings model. */ + fun upsertTtlSettingsRequest(): UpsertTtlSettingsRequest = upsertTtlSettingsRequest + + fun _additionalBodyProperties(): Map<String, JsonValue> = + upsertTtlSettingsRequest._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TtlSettingUpdateTtlSettingsParams]. + * + * The following fields are required: + * ```java + * .upsertTtlSettingsRequest() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TtlSettingUpdateTtlSettingsParams]. */ + class Builder internal constructor() { + + private var upsertTtlSettingsRequest: UpsertTtlSettingsRequest? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(ttlSettingUpdateTtlSettingsParams: TtlSettingUpdateTtlSettingsParams) = + apply { + upsertTtlSettingsRequest = + ttlSettingUpdateTtlSettingsParams.upsertTtlSettingsRequest + additionalHeaders = ttlSettingUpdateTtlSettingsParams.additionalHeaders.toBuilder() + additionalQueryParams = + ttlSettingUpdateTtlSettingsParams.additionalQueryParams.toBuilder() + } + + /** Base TTL settings model. */ + fun upsertTtlSettingsRequest(upsertTtlSettingsRequest: UpsertTtlSettingsRequest) = apply { + this.upsertTtlSettingsRequest = upsertTtlSettingsRequest + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TtlSettingUpdateTtlSettingsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .upsertTtlSettingsRequest() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TtlSettingUpdateTtlSettingsParams = + TtlSettingUpdateTtlSettingsParams( + checkRequired("upsertTtlSettingsRequest", upsertTtlSettingsRequest), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): UpsertTtlSettingsRequest = upsertTtlSettingsRequest + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TtlSettingUpdateTtlSettingsParams && + upsertTtlSettingsRequest == other.upsertTtlSettingsRequest && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(upsertTtlSettingsRequest, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TtlSettingUpdateTtlSettingsParams{upsertTtlSettingsRequest=$upsertTtlSettingsRequest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimit.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimit.kt new file mode 100644 index 00000000..23a0d723 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimit.kt @@ -0,0 +1,367 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.usagelimits + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Usage limit model. */ +class UsageLimit +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val createdAt: JsonField<OffsetDateTime>, + private val limitType: JsonField<UsageLimitType>, + private val limitValue: JsonField<Long>, + private val tenantId: JsonField<String>, + private val updatedAt: JsonField<OffsetDateTime>, + private val id: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("limit_type") + @ExcludeMissing + limitType: JsonField<UsageLimitType> = JsonMissing.of(), + @JsonProperty("limit_value") @ExcludeMissing limitValue: JsonField<Long> = JsonMissing.of(), + @JsonProperty("tenant_id") @ExcludeMissing tenantId: JsonField<String> = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + ) : this(createdAt, limitType, limitValue, tenantId, updatedAt, id, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * Type of usage limit. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun limitType(): UsageLimitType = limitType.getRequired("limit_type") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun limitValue(): Long = limitValue.getRequired("limit_value") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tenantId(): String = tenantId.getRequired("tenant_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updatedAt(): OffsetDateTime = updatedAt.getRequired("updated_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [limitType]. + * + * Unlike [limitType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("limit_type") + @ExcludeMissing + fun _limitType(): JsonField<UsageLimitType> = limitType + + /** + * Returns the raw JSON value of [limitValue]. + * + * Unlike [limitValue], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("limit_value") @ExcludeMissing fun _limitValue(): JsonField<Long> = limitValue + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_id") @ExcludeMissing fun _tenantId(): JsonField<String> = tenantId + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField<OffsetDateTime> = updatedAt + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UsageLimit]. + * + * The following fields are required: + * ```java + * .createdAt() + * .limitType() + * .limitValue() + * .tenantId() + * .updatedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UsageLimit]. */ + class Builder internal constructor() { + + private var createdAt: JsonField<OffsetDateTime>? = null + private var limitType: JsonField<UsageLimitType>? = null + private var limitValue: JsonField<Long>? = null + private var tenantId: JsonField<String>? = null + private var updatedAt: JsonField<OffsetDateTime>? = null + private var id: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(usageLimit: UsageLimit) = apply { + createdAt = usageLimit.createdAt + limitType = usageLimit.limitType + limitValue = usageLimit.limitValue + tenantId = usageLimit.tenantId + updatedAt = usageLimit.updatedAt + id = usageLimit.id + additionalProperties = usageLimit.additionalProperties.toMutableMap() + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + /** Type of usage limit. */ + fun limitType(limitType: UsageLimitType) = limitType(JsonField.of(limitType)) + + /** + * Sets [Builder.limitType] to an arbitrary JSON value. + * + * You should usually call [Builder.limitType] with a well-typed [UsageLimitType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun limitType(limitType: JsonField<UsageLimitType>) = apply { this.limitType = limitType } + + fun limitValue(limitValue: Long) = limitValue(JsonField.of(limitValue)) + + /** + * Sets [Builder.limitValue] to an arbitrary JSON value. + * + * You should usually call [Builder.limitValue] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun limitValue(limitValue: JsonField<Long>) = apply { this.limitValue = limitValue } + + fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tenantId(tenantId: JsonField<String>) = apply { this.tenantId = tenantId } + + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField<OffsetDateTime>) = apply { this.updatedAt = updatedAt } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UsageLimit]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .createdAt() + * .limitType() + * .limitValue() + * .tenantId() + * .updatedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UsageLimit = + UsageLimit( + checkRequired("createdAt", createdAt), + checkRequired("limitType", limitType), + checkRequired("limitValue", limitValue), + checkRequired("tenantId", tenantId), + checkRequired("updatedAt", updatedAt), + id, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UsageLimit = apply { + if (validated) { + return@apply + } + + createdAt() + limitType().validate() + limitValue() + tenantId() + updatedAt() + id() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (createdAt.asKnown().isPresent) 1 else 0) + + (limitType.asKnown().getOrNull()?.validity() ?: 0) + + (if (limitValue.asKnown().isPresent) 1 else 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (if (id.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UsageLimit && + createdAt == other.createdAt && + limitType == other.limitType && + limitValue == other.limitValue && + tenantId == other.tenantId && + updatedAt == other.updatedAt && + id == other.id && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + createdAt, + limitType, + limitValue, + tenantId, + updatedAt, + id, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UsageLimit{createdAt=$createdAt, limitType=$limitType, limitValue=$limitValue, tenantId=$tenantId, updatedAt=$updatedAt, id=$id, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitDeleteParams.kt new file mode 100644 index 00000000..85966adc --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitDeleteParams.kt @@ -0,0 +1,235 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.usagelimits + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete a specific usage limit. */ +class UsageLimitDeleteParams +private constructor( + private val usageLimitId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun usageLimitId(): Optional<String> = Optional.ofNullable(usageLimitId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): UsageLimitDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [UsageLimitDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UsageLimitDeleteParams]. */ + class Builder internal constructor() { + + private var usageLimitId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(usageLimitDeleteParams: UsageLimitDeleteParams) = apply { + usageLimitId = usageLimitDeleteParams.usageLimitId + additionalHeaders = usageLimitDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = usageLimitDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + usageLimitDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun usageLimitId(usageLimitId: String?) = apply { this.usageLimitId = usageLimitId } + + /** Alias for calling [Builder.usageLimitId] with `usageLimitId.orElse(null)`. */ + fun usageLimitId(usageLimitId: Optional<String>) = usageLimitId(usageLimitId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [UsageLimitDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UsageLimitDeleteParams = + UsageLimitDeleteParams( + usageLimitId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> usageLimitId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UsageLimitDeleteParams && + usageLimitId == other.usageLimitId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + usageLimitId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "UsageLimitDeleteParams{usageLimitId=$usageLimitId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitDeleteResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitDeleteResponse.kt new file mode 100644 index 00000000..dd2d93e2 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitDeleteResponse.kt @@ -0,0 +1,115 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.usagelimits + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class UsageLimitDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UsageLimitDeleteResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UsageLimitDeleteResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(usageLimitDeleteResponse: UsageLimitDeleteResponse) = apply { + additionalProperties = usageLimitDeleteResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UsageLimitDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UsageLimitDeleteResponse = + UsageLimitDeleteResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): UsageLimitDeleteResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UsageLimitDeleteResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "UsageLimitDeleteResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitRetrieveOrgParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitRetrieveOrgParams.kt new file mode 100644 index 00000000..6efc7d33 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitRetrieveOrgParams.kt @@ -0,0 +1,172 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.usagelimits + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** List out the configured usage limits for a given organization. */ +class UsageLimitRetrieveOrgParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): UsageLimitRetrieveOrgParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [UsageLimitRetrieveOrgParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UsageLimitRetrieveOrgParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(usageLimitRetrieveOrgParams: UsageLimitRetrieveOrgParams) = apply { + additionalHeaders = usageLimitRetrieveOrgParams.additionalHeaders.toBuilder() + additionalQueryParams = usageLimitRetrieveOrgParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [UsageLimitRetrieveOrgParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UsageLimitRetrieveOrgParams = + UsageLimitRetrieveOrgParams(additionalHeaders.build(), additionalQueryParams.build()) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UsageLimitRetrieveOrgParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "UsageLimitRetrieveOrgParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitRetrieveUsageLimitsParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitRetrieveUsageLimitsParams.kt new file mode 100644 index 00000000..d704c06a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitRetrieveUsageLimitsParams.kt @@ -0,0 +1,179 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.usagelimits + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** List out the configured usage limits for a given tenant. */ +class UsageLimitRetrieveUsageLimitsParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): UsageLimitRetrieveUsageLimitsParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [UsageLimitRetrieveUsageLimitsParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UsageLimitRetrieveUsageLimitsParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + usageLimitRetrieveUsageLimitsParams: UsageLimitRetrieveUsageLimitsParams + ) = apply { + additionalHeaders = usageLimitRetrieveUsageLimitsParams.additionalHeaders.toBuilder() + additionalQueryParams = + usageLimitRetrieveUsageLimitsParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [UsageLimitRetrieveUsageLimitsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UsageLimitRetrieveUsageLimitsParams = + UsageLimitRetrieveUsageLimitsParams( + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UsageLimitRetrieveUsageLimitsParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "UsageLimitRetrieveUsageLimitsParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitType.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitType.kt new file mode 100644 index 00000000..ec85e0c8 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitType.kt @@ -0,0 +1,136 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.usagelimits + +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException + +/** Type of usage limit. */ +class UsageLimitType @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't match + * any known member, and you want to know that value. For example, if the SDK is on an older + * version than the API, then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val MONTHLY_TRACES = of("monthly_traces") + + @JvmField val MONTHLY_LONGLIVED_TRACES = of("monthly_longlived_traces") + + @JvmStatic fun of(value: String) = UsageLimitType(JsonField.of(value)) + } + + /** An enum containing [UsageLimitType]'s known values. */ + enum class Known { + MONTHLY_TRACES, + MONTHLY_LONGLIVED_TRACES, + } + + /** + * An enum containing [UsageLimitType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [UsageLimitType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the SDK + * is on an older version than the API, then the API may respond with new members that the SDK + * is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MONTHLY_TRACES, + MONTHLY_LONGLIVED_TRACES, + /** + * An enum member indicating that [UsageLimitType] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if + * the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want to + * throw for the unknown case. + */ + fun value(): Value = + when (this) { + MONTHLY_TRACES -> Value.MONTHLY_TRACES + MONTHLY_LONGLIVED_TRACES -> Value.MONTHLY_LONGLIVED_TRACES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't want + * to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MONTHLY_TRACES -> Known.MONTHLY_TRACES + MONTHLY_LONGLIVED_TRACES -> Known.MONTHLY_LONGLIVED_TRACES + else -> throw LangsmithApiInvalidDataException("Unknown UsageLimitType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): UsageLimitType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UsageLimitType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitUpdateUsageLimitsParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitUpdateUsageLimitsParams.kt new file mode 100644 index 00000000..9f080f48 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitUpdateUsageLimitsParams.kt @@ -0,0 +1,553 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.usagelimits + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create a new usage limit. */ +class UsageLimitUpdateUsageLimitsParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Type of usage limit. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun limitType(): UsageLimitType = body.limitType() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun limitValue(): Long = body.limitValue() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional<String> = body.id() + + /** + * Returns the raw JSON value of [limitType]. + * + * Unlike [limitType], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _limitType(): JsonField<UsageLimitType> = body._limitType() + + /** + * Returns the raw JSON value of [limitValue]. + * + * Unlike [limitValue], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _limitValue(): JsonField<Long> = body._limitValue() + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _id(): JsonField<String> = body._id() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UsageLimitUpdateUsageLimitsParams]. + * + * The following fields are required: + * ```java + * .limitType() + * .limitValue() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UsageLimitUpdateUsageLimitsParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(usageLimitUpdateUsageLimitsParams: UsageLimitUpdateUsageLimitsParams) = + apply { + body = usageLimitUpdateUsageLimitsParams.body.toBuilder() + additionalHeaders = usageLimitUpdateUsageLimitsParams.additionalHeaders.toBuilder() + additionalQueryParams = + usageLimitUpdateUsageLimitsParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [limitType] + * - [limitValue] + * - [id] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** Type of usage limit. */ + fun limitType(limitType: UsageLimitType) = apply { body.limitType(limitType) } + + /** + * Sets [Builder.limitType] to an arbitrary JSON value. + * + * You should usually call [Builder.limitType] with a well-typed [UsageLimitType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun limitType(limitType: JsonField<UsageLimitType>) = apply { body.limitType(limitType) } + + fun limitValue(limitValue: Long) = apply { body.limitValue(limitValue) } + + /** + * Sets [Builder.limitValue] to an arbitrary JSON value. + * + * You should usually call [Builder.limitValue] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun limitValue(limitValue: JsonField<Long>) = apply { body.limitValue(limitValue) } + + fun id(id: String) = apply { body.id(id) } + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { body.id(id) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [UsageLimitUpdateUsageLimitsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .limitType() + * .limitValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UsageLimitUpdateUsageLimitsParams = + UsageLimitUpdateUsageLimitsParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Request body for creating or updating a usage limit. */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val limitType: JsonField<UsageLimitType>, + private val limitValue: JsonField<Long>, + private val id: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("limit_type") + @ExcludeMissing + limitType: JsonField<UsageLimitType> = JsonMissing.of(), + @JsonProperty("limit_value") + @ExcludeMissing + limitValue: JsonField<Long> = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + ) : this(limitType, limitValue, id, mutableMapOf()) + + /** + * Type of usage limit. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun limitType(): UsageLimitType = limitType.getRequired("limit_type") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun limitValue(): Long = limitValue.getRequired("limit_value") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + /** + * Returns the raw JSON value of [limitType]. + * + * Unlike [limitType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("limit_type") + @ExcludeMissing + fun _limitType(): JsonField<UsageLimitType> = limitType + + /** + * Returns the raw JSON value of [limitValue]. + * + * Unlike [limitValue], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("limit_value") @ExcludeMissing fun _limitValue(): JsonField<Long> = limitValue + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .limitType() + * .limitValue() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var limitType: JsonField<UsageLimitType>? = null + private var limitValue: JsonField<Long>? = null + private var id: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + limitType = body.limitType + limitValue = body.limitValue + id = body.id + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** Type of usage limit. */ + fun limitType(limitType: UsageLimitType) = limitType(JsonField.of(limitType)) + + /** + * Sets [Builder.limitType] to an arbitrary JSON value. + * + * You should usually call [Builder.limitType] with a well-typed [UsageLimitType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun limitType(limitType: JsonField<UsageLimitType>) = apply { + this.limitType = limitType + } + + fun limitValue(limitValue: Long) = limitValue(JsonField.of(limitValue)) + + /** + * Sets [Builder.limitValue] to an arbitrary JSON value. + * + * You should usually call [Builder.limitValue] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun limitValue(limitValue: JsonField<Long>) = apply { this.limitValue = limitValue } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .limitType() + * .limitValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("limitType", limitType), + checkRequired("limitValue", limitValue), + id, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + limitType().validate() + limitValue() + id() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (limitType.asKnown().getOrNull()?.validity() ?: 0) + + (if (limitValue.asKnown().isPresent) 1 else 0) + + (if (id.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + limitType == other.limitType && + limitValue == other.limitValue && + id == other.id && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(limitType, limitValue, id, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{limitType=$limitType, limitValue=$limitValue, id=$id, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UsageLimitUpdateUsageLimitsParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "UsageLimitUpdateUsageLimitsParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceCreateParams.kt new file mode 100644 index 00000000..8d42e05a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceCreateParams.kt @@ -0,0 +1,556 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create a new workspace. */ +class WorkspaceCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun displayName(): String = body.displayName() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional<String> = body.id() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tenantHandle(): Optional<String> = body.tenantHandle() + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _displayName(): JsonField<String> = body._displayName() + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _id(): JsonField<String> = body._id() + + /** + * Returns the raw JSON value of [tenantHandle]. + * + * Unlike [tenantHandle], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _tenantHandle(): JsonField<String> = body._tenantHandle() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [WorkspaceCreateParams]. + * + * The following fields are required: + * ```java + * .displayName() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WorkspaceCreateParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(workspaceCreateParams: WorkspaceCreateParams) = apply { + body = workspaceCreateParams.body.toBuilder() + additionalHeaders = workspaceCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = workspaceCreateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [displayName] + * - [id] + * - [tenantHandle] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun displayName(displayName: String) = apply { body.displayName(displayName) } + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun displayName(displayName: JsonField<String>) = apply { body.displayName(displayName) } + + fun id(id: String) = apply { body.id(id) } + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { body.id(id) } + + fun tenantHandle(tenantHandle: String?) = apply { body.tenantHandle(tenantHandle) } + + /** Alias for calling [Builder.tenantHandle] with `tenantHandle.orElse(null)`. */ + fun tenantHandle(tenantHandle: Optional<String>) = tenantHandle(tenantHandle.getOrNull()) + + /** + * Sets [Builder.tenantHandle] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantHandle] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tenantHandle(tenantHandle: JsonField<String>) = apply { + body.tenantHandle(tenantHandle) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [WorkspaceCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .displayName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): WorkspaceCreateParams = + WorkspaceCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Creation model for the workspace. */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val displayName: JsonField<String>, + private val id: JsonField<String>, + private val tenantHandle: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField<String> = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("tenant_handle") + @ExcludeMissing + tenantHandle: JsonField<String> = JsonMissing.of(), + ) : this(displayName, id, tenantHandle, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun displayName(): String = displayName.getRequired("display_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun tenantHandle(): Optional<String> = tenantHandle.getOptional("tenant_handle") + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField<String> = displayName + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [tenantHandle]. + * + * Unlike [tenantHandle], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tenant_handle") + @ExcludeMissing + fun _tenantHandle(): JsonField<String> = tenantHandle + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .displayName() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var displayName: JsonField<String>? = null + private var id: JsonField<String> = JsonMissing.of() + private var tenantHandle: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + displayName = body.displayName + id = body.id + tenantHandle = body.tenantHandle + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun displayName(displayName: String) = displayName(JsonField.of(displayName)) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun displayName(displayName: JsonField<String>) = apply { + this.displayName = displayName + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun tenantHandle(tenantHandle: String?) = + tenantHandle(JsonField.ofNullable(tenantHandle)) + + /** Alias for calling [Builder.tenantHandle] with `tenantHandle.orElse(null)`. */ + fun tenantHandle(tenantHandle: Optional<String>) = + tenantHandle(tenantHandle.getOrNull()) + + /** + * Sets [Builder.tenantHandle] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantHandle] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tenantHandle(tenantHandle: JsonField<String>) = apply { + this.tenantHandle = tenantHandle + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .displayName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("displayName", displayName), + id, + tenantHandle, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + displayName() + id() + tenantHandle() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (displayName.asKnown().isPresent) 1 else 0) + + (if (id.asKnown().isPresent) 1 else 0) + + (if (tenantHandle.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + displayName == other.displayName && + id == other.id && + tenantHandle == other.tenantHandle && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(displayName, id, tenantHandle, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{displayName=$displayName, id=$id, tenantHandle=$tenantHandle, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is WorkspaceCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "WorkspaceCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceDeleteParams.kt new file mode 100644 index 00000000..97157292 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceDeleteParams.kt @@ -0,0 +1,234 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete Workspace */ +class WorkspaceDeleteParams +private constructor( + private val workspaceId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun workspaceId(): Optional<String> = Optional.ofNullable(workspaceId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): WorkspaceDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [WorkspaceDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WorkspaceDeleteParams]. */ + class Builder internal constructor() { + + private var workspaceId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(workspaceDeleteParams: WorkspaceDeleteParams) = apply { + workspaceId = workspaceDeleteParams.workspaceId + additionalHeaders = workspaceDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = workspaceDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = workspaceDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun workspaceId(workspaceId: String?) = apply { this.workspaceId = workspaceId } + + /** Alias for calling [Builder.workspaceId] with `workspaceId.orElse(null)`. */ + fun workspaceId(workspaceId: Optional<String>) = workspaceId(workspaceId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [WorkspaceDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): WorkspaceDeleteParams = + WorkspaceDeleteParams( + workspaceId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> workspaceId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is WorkspaceDeleteParams && + workspaceId == other.workspaceId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + workspaceId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "WorkspaceDeleteParams{workspaceId=$workspaceId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceDeleteResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceDeleteResponse.kt new file mode 100644 index 00000000..94c90c89 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceDeleteResponse.kt @@ -0,0 +1,115 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class WorkspaceDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [WorkspaceDeleteResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WorkspaceDeleteResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(workspaceDeleteResponse: WorkspaceDeleteResponse) = apply { + additionalProperties = workspaceDeleteResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [WorkspaceDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): WorkspaceDeleteResponse = + WorkspaceDeleteResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): WorkspaceDeleteResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is WorkspaceDeleteResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "WorkspaceDeleteResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceListParams.kt new file mode 100644 index 00000000..38903f9e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceListParams.kt @@ -0,0 +1,206 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Get all workspaces visible to this auth in the current org. Does not create a new workspace/org. + */ +class WorkspaceListParams +private constructor( + private val includeDeleted: Boolean?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun includeDeleted(): Optional<Boolean> = Optional.ofNullable(includeDeleted) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): WorkspaceListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [WorkspaceListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WorkspaceListParams]. */ + class Builder internal constructor() { + + private var includeDeleted: Boolean? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(workspaceListParams: WorkspaceListParams) = apply { + includeDeleted = workspaceListParams.includeDeleted + additionalHeaders = workspaceListParams.additionalHeaders.toBuilder() + additionalQueryParams = workspaceListParams.additionalQueryParams.toBuilder() + } + + fun includeDeleted(includeDeleted: Boolean?) = apply { + this.includeDeleted = includeDeleted + } + + /** + * Alias for [Builder.includeDeleted]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun includeDeleted(includeDeleted: Boolean) = includeDeleted(includeDeleted as Boolean?) + + /** Alias for calling [Builder.includeDeleted] with `includeDeleted.orElse(null)`. */ + fun includeDeleted(includeDeleted: Optional<Boolean>) = + includeDeleted(includeDeleted.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [WorkspaceListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): WorkspaceListParams = + WorkspaceListParams( + includeDeleted, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + includeDeleted?.let { put("include_deleted", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is WorkspaceListParams && + includeDeleted == other.includeDeleted && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(includeDeleted, additionalHeaders, additionalQueryParams) + + override fun toString() = + "WorkspaceListParams{includeDeleted=$includeDeleted, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceUpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceUpdateParams.kt new file mode 100644 index 00000000..49385f80 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceUpdateParams.kt @@ -0,0 +1,438 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Patch Workspace */ +class WorkspaceUpdateParams +private constructor( + private val workspaceId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun workspaceId(): Optional<String> = Optional.ofNullable(workspaceId) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun displayName(): String = body.displayName() + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _displayName(): JsonField<String> = body._displayName() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [WorkspaceUpdateParams]. + * + * The following fields are required: + * ```java + * .displayName() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WorkspaceUpdateParams]. */ + class Builder internal constructor() { + + private var workspaceId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(workspaceUpdateParams: WorkspaceUpdateParams) = apply { + workspaceId = workspaceUpdateParams.workspaceId + body = workspaceUpdateParams.body.toBuilder() + additionalHeaders = workspaceUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = workspaceUpdateParams.additionalQueryParams.toBuilder() + } + + fun workspaceId(workspaceId: String?) = apply { this.workspaceId = workspaceId } + + /** Alias for calling [Builder.workspaceId] with `workspaceId.orElse(null)`. */ + fun workspaceId(workspaceId: Optional<String>) = workspaceId(workspaceId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [displayName] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun displayName(displayName: String) = apply { body.displayName(displayName) } + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun displayName(displayName: JsonField<String>) = apply { body.displayName(displayName) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [WorkspaceUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .displayName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): WorkspaceUpdateParams = + WorkspaceUpdateParams( + workspaceId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> workspaceId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Patch model for the workspace. */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val displayName: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField<String> = JsonMissing.of() + ) : this(displayName, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun displayName(): String = displayName.getRequired("display_name") + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField<String> = displayName + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .displayName() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var displayName: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + displayName = body.displayName + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun displayName(displayName: String) = displayName(JsonField.of(displayName)) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun displayName(displayName: JsonField<String>) = apply { + this.displayName = displayName + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .displayName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body(checkRequired("displayName", displayName), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + displayName() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (displayName.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + displayName == other.displayName && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(displayName, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{displayName=$displayName, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is WorkspaceUpdateParams && + workspaceId == other.workspaceId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(workspaceId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "WorkspaceUpdateParams{workspaceId=$workspaceId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/CurrentRetrieveStatsParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/CurrentRetrieveStatsParams.kt new file mode 100644 index 00000000..1fea2988 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/CurrentRetrieveStatsParams.kt @@ -0,0 +1,208 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get Current Workspace Stats */ +class CurrentRetrieveStatsParams +private constructor( + private val tagValueId: List<String>?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun tagValueId(): Optional<List<String>> = Optional.ofNullable(tagValueId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): CurrentRetrieveStatsParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [CurrentRetrieveStatsParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CurrentRetrieveStatsParams]. */ + class Builder internal constructor() { + + private var tagValueId: MutableList<String>? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(currentRetrieveStatsParams: CurrentRetrieveStatsParams) = apply { + tagValueId = currentRetrieveStatsParams.tagValueId?.toMutableList() + additionalHeaders = currentRetrieveStatsParams.additionalHeaders.toBuilder() + additionalQueryParams = currentRetrieveStatsParams.additionalQueryParams.toBuilder() + } + + fun tagValueId(tagValueId: List<String>?) = apply { + this.tagValueId = tagValueId?.toMutableList() + } + + /** Alias for calling [Builder.tagValueId] with `tagValueId.orElse(null)`. */ + fun tagValueId(tagValueId: Optional<List<String>>) = tagValueId(tagValueId.getOrNull()) + + /** + * Adds a single [String] to [Builder.tagValueId]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTagValueId(tagValueId: String) = apply { + this.tagValueId = (this.tagValueId ?: mutableListOf()).apply { add(tagValueId) } + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [CurrentRetrieveStatsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CurrentRetrieveStatsParams = + CurrentRetrieveStatsParams( + tagValueId?.toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + tagValueId?.let { put("tag_value_id", it.joinToString(",")) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CurrentRetrieveStatsParams && + tagValueId == other.tagValueId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(tagValueId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "CurrentRetrieveStatsParams{tagValueId=$tagValueId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/CurrentRetrieveStatsResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/CurrentRetrieveStatsResponse.kt new file mode 100644 index 00000000..33ad4288 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/CurrentRetrieveStatsResponse.kt @@ -0,0 +1,428 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +/** Stats for a tenant. */ +class CurrentRetrieveStatsResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val annotationQueueCount: JsonField<Long>, + private val dashboardsCount: JsonField<Long>, + private val datasetCount: JsonField<Long>, + private val deploymentCount: JsonField<Long>, + private val repoCount: JsonField<Long>, + private val tenantId: JsonField<String>, + private val tracerSessionCount: JsonField<Long>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("annotation_queue_count") + @ExcludeMissing + annotationQueueCount: JsonField<Long> = JsonMissing.of(), + @JsonProperty("dashboards_count") + @ExcludeMissing + dashboardsCount: JsonField<Long> = JsonMissing.of(), + @JsonProperty("dataset_count") + @ExcludeMissing + datasetCount: JsonField<Long> = JsonMissing.of(), + @JsonProperty("deployment_count") + @ExcludeMissing + deploymentCount: JsonField<Long> = JsonMissing.of(), + @JsonProperty("repo_count") @ExcludeMissing repoCount: JsonField<Long> = JsonMissing.of(), + @JsonProperty("tenant_id") @ExcludeMissing tenantId: JsonField<String> = JsonMissing.of(), + @JsonProperty("tracer_session_count") + @ExcludeMissing + tracerSessionCount: JsonField<Long> = JsonMissing.of(), + ) : this( + annotationQueueCount, + dashboardsCount, + datasetCount, + deploymentCount, + repoCount, + tenantId, + tracerSessionCount, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun annotationQueueCount(): Long = annotationQueueCount.getRequired("annotation_queue_count") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun dashboardsCount(): Long = dashboardsCount.getRequired("dashboards_count") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun datasetCount(): Long = datasetCount.getRequired("dataset_count") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun deploymentCount(): Long = deploymentCount.getRequired("deployment_count") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun repoCount(): Long = repoCount.getRequired("repo_count") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tenantId(): String = tenantId.getRequired("tenant_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tracerSessionCount(): Long = tracerSessionCount.getRequired("tracer_session_count") + + /** + * Returns the raw JSON value of [annotationQueueCount]. + * + * Unlike [annotationQueueCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("annotation_queue_count") + @ExcludeMissing + fun _annotationQueueCount(): JsonField<Long> = annotationQueueCount + + /** + * Returns the raw JSON value of [dashboardsCount]. + * + * Unlike [dashboardsCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dashboards_count") + @ExcludeMissing + fun _dashboardsCount(): JsonField<Long> = dashboardsCount + + /** + * Returns the raw JSON value of [datasetCount]. + * + * Unlike [datasetCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dataset_count") + @ExcludeMissing + fun _datasetCount(): JsonField<Long> = datasetCount + + /** + * Returns the raw JSON value of [deploymentCount]. + * + * Unlike [deploymentCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("deployment_count") + @ExcludeMissing + fun _deploymentCount(): JsonField<Long> = deploymentCount + + /** + * Returns the raw JSON value of [repoCount]. + * + * Unlike [repoCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("repo_count") @ExcludeMissing fun _repoCount(): JsonField<Long> = repoCount + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_id") @ExcludeMissing fun _tenantId(): JsonField<String> = tenantId + + /** + * Returns the raw JSON value of [tracerSessionCount]. + * + * Unlike [tracerSessionCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tracer_session_count") + @ExcludeMissing + fun _tracerSessionCount(): JsonField<Long> = tracerSessionCount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CurrentRetrieveStatsResponse]. + * + * The following fields are required: + * ```java + * .annotationQueueCount() + * .dashboardsCount() + * .datasetCount() + * .deploymentCount() + * .repoCount() + * .tenantId() + * .tracerSessionCount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CurrentRetrieveStatsResponse]. */ + class Builder internal constructor() { + + private var annotationQueueCount: JsonField<Long>? = null + private var dashboardsCount: JsonField<Long>? = null + private var datasetCount: JsonField<Long>? = null + private var deploymentCount: JsonField<Long>? = null + private var repoCount: JsonField<Long>? = null + private var tenantId: JsonField<String>? = null + private var tracerSessionCount: JsonField<Long>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(currentRetrieveStatsResponse: CurrentRetrieveStatsResponse) = apply { + annotationQueueCount = currentRetrieveStatsResponse.annotationQueueCount + dashboardsCount = currentRetrieveStatsResponse.dashboardsCount + datasetCount = currentRetrieveStatsResponse.datasetCount + deploymentCount = currentRetrieveStatsResponse.deploymentCount + repoCount = currentRetrieveStatsResponse.repoCount + tenantId = currentRetrieveStatsResponse.tenantId + tracerSessionCount = currentRetrieveStatsResponse.tracerSessionCount + additionalProperties = currentRetrieveStatsResponse.additionalProperties.toMutableMap() + } + + fun annotationQueueCount(annotationQueueCount: Long) = + annotationQueueCount(JsonField.of(annotationQueueCount)) + + /** + * Sets [Builder.annotationQueueCount] to an arbitrary JSON value. + * + * You should usually call [Builder.annotationQueueCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun annotationQueueCount(annotationQueueCount: JsonField<Long>) = apply { + this.annotationQueueCount = annotationQueueCount + } + + fun dashboardsCount(dashboardsCount: Long) = dashboardsCount(JsonField.of(dashboardsCount)) + + /** + * Sets [Builder.dashboardsCount] to an arbitrary JSON value. + * + * You should usually call [Builder.dashboardsCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dashboardsCount(dashboardsCount: JsonField<Long>) = apply { + this.dashboardsCount = dashboardsCount + } + + fun datasetCount(datasetCount: Long) = datasetCount(JsonField.of(datasetCount)) + + /** + * Sets [Builder.datasetCount] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun datasetCount(datasetCount: JsonField<Long>) = apply { this.datasetCount = datasetCount } + + fun deploymentCount(deploymentCount: Long) = deploymentCount(JsonField.of(deploymentCount)) + + /** + * Sets [Builder.deploymentCount] to an arbitrary JSON value. + * + * You should usually call [Builder.deploymentCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun deploymentCount(deploymentCount: JsonField<Long>) = apply { + this.deploymentCount = deploymentCount + } + + fun repoCount(repoCount: Long) = repoCount(JsonField.of(repoCount)) + + /** + * Sets [Builder.repoCount] to an arbitrary JSON value. + * + * You should usually call [Builder.repoCount] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun repoCount(repoCount: JsonField<Long>) = apply { this.repoCount = repoCount } + + fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tenantId(tenantId: JsonField<String>) = apply { this.tenantId = tenantId } + + fun tracerSessionCount(tracerSessionCount: Long) = + tracerSessionCount(JsonField.of(tracerSessionCount)) + + /** + * Sets [Builder.tracerSessionCount] to an arbitrary JSON value. + * + * You should usually call [Builder.tracerSessionCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tracerSessionCount(tracerSessionCount: JsonField<Long>) = apply { + this.tracerSessionCount = tracerSessionCount + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CurrentRetrieveStatsResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .annotationQueueCount() + * .dashboardsCount() + * .datasetCount() + * .deploymentCount() + * .repoCount() + * .tenantId() + * .tracerSessionCount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CurrentRetrieveStatsResponse = + CurrentRetrieveStatsResponse( + checkRequired("annotationQueueCount", annotationQueueCount), + checkRequired("dashboardsCount", dashboardsCount), + checkRequired("datasetCount", datasetCount), + checkRequired("deploymentCount", deploymentCount), + checkRequired("repoCount", repoCount), + checkRequired("tenantId", tenantId), + checkRequired("tracerSessionCount", tracerSessionCount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CurrentRetrieveStatsResponse = apply { + if (validated) { + return@apply + } + + annotationQueueCount() + dashboardsCount() + datasetCount() + deploymentCount() + repoCount() + tenantId() + tracerSessionCount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (annotationQueueCount.asKnown().isPresent) 1 else 0) + + (if (dashboardsCount.asKnown().isPresent) 1 else 0) + + (if (datasetCount.asKnown().isPresent) 1 else 0) + + (if (deploymentCount.asKnown().isPresent) 1 else 0) + + (if (repoCount.asKnown().isPresent) 1 else 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + (if (tracerSessionCount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CurrentRetrieveStatsResponse && + annotationQueueCount == other.annotationQueueCount && + dashboardsCount == other.dashboardsCount && + datasetCount == other.datasetCount && + deploymentCount == other.deploymentCount && + repoCount == other.repoCount && + tenantId == other.tenantId && + tracerSessionCount == other.tracerSessionCount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + annotationQueueCount, + dashboardsCount, + datasetCount, + deploymentCount, + repoCount, + tenantId, + tracerSessionCount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CurrentRetrieveStatsResponse{annotationQueueCount=$annotationQueueCount, dashboardsCount=$dashboardsCount, datasetCount=$datasetCount, deploymentCount=$deploymentCount, repoCount=$repoCount, tenantId=$tenantId, tracerSessionCount=$tracerSessionCount, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/CurrentRetrieveUsageLimitsParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/CurrentRetrieveUsageLimitsParams.kt new file mode 100644 index 00000000..420e8333 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/CurrentRetrieveUsageLimitsParams.kt @@ -0,0 +1,178 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** Get Current Workspace Usage Limits Info */ +class CurrentRetrieveUsageLimitsParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): CurrentRetrieveUsageLimitsParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [CurrentRetrieveUsageLimitsParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CurrentRetrieveUsageLimitsParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(currentRetrieveUsageLimitsParams: CurrentRetrieveUsageLimitsParams) = + apply { + additionalHeaders = currentRetrieveUsageLimitsParams.additionalHeaders.toBuilder() + additionalQueryParams = + currentRetrieveUsageLimitsParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [CurrentRetrieveUsageLimitsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CurrentRetrieveUsageLimitsParams = + CurrentRetrieveUsageLimitsParams( + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CurrentRetrieveUsageLimitsParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "CurrentRetrieveUsageLimitsParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/CurrentRetrieveUsageLimitsResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/CurrentRetrieveUsageLimitsResponse.kt new file mode 100644 index 00000000..19ce0915 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/CurrentRetrieveUsageLimitsResponse.kt @@ -0,0 +1,434 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current + +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.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class CurrentRetrieveUsageLimitsResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val inRejectSet: JsonField<Boolean>, + private val tenantLimit: JsonField<Long>, + private val usageLimitType: JsonField<UsageLimitType>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("in_reject_set") + @ExcludeMissing + inRejectSet: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("tenant_limit") + @ExcludeMissing + tenantLimit: JsonField<Long> = JsonMissing.of(), + @JsonProperty("usage_limit_type") + @ExcludeMissing + usageLimitType: JsonField<UsageLimitType> = JsonMissing.of(), + ) : this(inRejectSet, tenantLimit, usageLimitType, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun inRejectSet(): Boolean = inRejectSet.getRequired("in_reject_set") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tenantLimit(): Optional<Long> = tenantLimit.getOptional("tenant_limit") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun usageLimitType(): Optional<UsageLimitType> = usageLimitType.getOptional("usage_limit_type") + + /** + * Returns the raw JSON value of [inRejectSet]. + * + * Unlike [inRejectSet], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("in_reject_set") + @ExcludeMissing + fun _inRejectSet(): JsonField<Boolean> = inRejectSet + + /** + * Returns the raw JSON value of [tenantLimit]. + * + * Unlike [tenantLimit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_limit") @ExcludeMissing fun _tenantLimit(): JsonField<Long> = tenantLimit + + /** + * Returns the raw JSON value of [usageLimitType]. + * + * Unlike [usageLimitType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("usage_limit_type") + @ExcludeMissing + fun _usageLimitType(): JsonField<UsageLimitType> = usageLimitType + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CurrentRetrieveUsageLimitsResponse]. + * + * The following fields are required: + * ```java + * .inRejectSet() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CurrentRetrieveUsageLimitsResponse]. */ + class Builder internal constructor() { + + private var inRejectSet: JsonField<Boolean>? = null + private var tenantLimit: JsonField<Long> = JsonMissing.of() + private var usageLimitType: JsonField<UsageLimitType> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(currentRetrieveUsageLimitsResponse: CurrentRetrieveUsageLimitsResponse) = + apply { + inRejectSet = currentRetrieveUsageLimitsResponse.inRejectSet + tenantLimit = currentRetrieveUsageLimitsResponse.tenantLimit + usageLimitType = currentRetrieveUsageLimitsResponse.usageLimitType + additionalProperties = + currentRetrieveUsageLimitsResponse.additionalProperties.toMutableMap() + } + + fun inRejectSet(inRejectSet: Boolean) = inRejectSet(JsonField.of(inRejectSet)) + + /** + * Sets [Builder.inRejectSet] to an arbitrary JSON value. + * + * You should usually call [Builder.inRejectSet] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun inRejectSet(inRejectSet: JsonField<Boolean>) = apply { this.inRejectSet = inRejectSet } + + fun tenantLimit(tenantLimit: Long?) = tenantLimit(JsonField.ofNullable(tenantLimit)) + + /** + * Alias for [Builder.tenantLimit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun tenantLimit(tenantLimit: Long) = tenantLimit(tenantLimit as Long?) + + /** Alias for calling [Builder.tenantLimit] with `tenantLimit.orElse(null)`. */ + fun tenantLimit(tenantLimit: Optional<Long>) = tenantLimit(tenantLimit.getOrNull()) + + /** + * Sets [Builder.tenantLimit] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantLimit] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tenantLimit(tenantLimit: JsonField<Long>) = apply { this.tenantLimit = tenantLimit } + + fun usageLimitType(usageLimitType: UsageLimitType?) = + usageLimitType(JsonField.ofNullable(usageLimitType)) + + /** Alias for calling [Builder.usageLimitType] with `usageLimitType.orElse(null)`. */ + fun usageLimitType(usageLimitType: Optional<UsageLimitType>) = + usageLimitType(usageLimitType.getOrNull()) + + /** + * Sets [Builder.usageLimitType] to an arbitrary JSON value. + * + * You should usually call [Builder.usageLimitType] with a well-typed [UsageLimitType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun usageLimitType(usageLimitType: JsonField<UsageLimitType>) = apply { + this.usageLimitType = usageLimitType + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CurrentRetrieveUsageLimitsResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .inRejectSet() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CurrentRetrieveUsageLimitsResponse = + CurrentRetrieveUsageLimitsResponse( + checkRequired("inRejectSet", inRejectSet), + tenantLimit, + usageLimitType, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CurrentRetrieveUsageLimitsResponse = apply { + if (validated) { + return@apply + } + + inRejectSet() + tenantLimit() + usageLimitType().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (inRejectSet.asKnown().isPresent) 1 else 0) + + (if (tenantLimit.asKnown().isPresent) 1 else 0) + + (usageLimitType.asKnown().getOrNull()?.validity() ?: 0) + + class UsageLimitType @JsonCreator private constructor(private val value: JsonField<String>) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val PAYLOAD_SIZE = of("payload_size") + + @JvmField val EVENTS_INGESTED_PER_HOUR = of("events_ingested_per_hour") + + @JvmField val TOTAL_UNIQUE_TRACES = of("total_unique_traces") + + @JvmField val EVENTS_INGESTED_PER_MINUTE = of("events_ingested_per_minute") + + @JvmField val USER_DEFINED_MONTHLY_TRACES = of("user_defined_monthly_traces") + + @JvmField + val USER_DEFINED_MONTHLY_LONGLIVED_TRACES = of("user_defined_monthly_longlived_traces") + + @JvmField val USER_DEFINED_UNKNOWN = of("user_defined_unknown") + + @JvmStatic fun of(value: String) = UsageLimitType(JsonField.of(value)) + } + + /** An enum containing [UsageLimitType]'s known values. */ + enum class Known { + PAYLOAD_SIZE, + EVENTS_INGESTED_PER_HOUR, + TOTAL_UNIQUE_TRACES, + EVENTS_INGESTED_PER_MINUTE, + USER_DEFINED_MONTHLY_TRACES, + USER_DEFINED_MONTHLY_LONGLIVED_TRACES, + USER_DEFINED_UNKNOWN, + } + + /** + * An enum containing [UsageLimitType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [UsageLimitType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PAYLOAD_SIZE, + EVENTS_INGESTED_PER_HOUR, + TOTAL_UNIQUE_TRACES, + EVENTS_INGESTED_PER_MINUTE, + USER_DEFINED_MONTHLY_TRACES, + USER_DEFINED_MONTHLY_LONGLIVED_TRACES, + USER_DEFINED_UNKNOWN, + /** + * An enum member indicating that [UsageLimitType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PAYLOAD_SIZE -> Value.PAYLOAD_SIZE + EVENTS_INGESTED_PER_HOUR -> Value.EVENTS_INGESTED_PER_HOUR + TOTAL_UNIQUE_TRACES -> Value.TOTAL_UNIQUE_TRACES + EVENTS_INGESTED_PER_MINUTE -> Value.EVENTS_INGESTED_PER_MINUTE + USER_DEFINED_MONTHLY_TRACES -> Value.USER_DEFINED_MONTHLY_TRACES + USER_DEFINED_MONTHLY_LONGLIVED_TRACES -> Value.USER_DEFINED_MONTHLY_LONGLIVED_TRACES + USER_DEFINED_UNKNOWN -> Value.USER_DEFINED_UNKNOWN + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PAYLOAD_SIZE -> Known.PAYLOAD_SIZE + EVENTS_INGESTED_PER_HOUR -> Known.EVENTS_INGESTED_PER_HOUR + TOTAL_UNIQUE_TRACES -> Known.TOTAL_UNIQUE_TRACES + EVENTS_INGESTED_PER_MINUTE -> Known.EVENTS_INGESTED_PER_MINUTE + USER_DEFINED_MONTHLY_TRACES -> Known.USER_DEFINED_MONTHLY_TRACES + USER_DEFINED_MONTHLY_LONGLIVED_TRACES -> Known.USER_DEFINED_MONTHLY_LONGLIVED_TRACES + USER_DEFINED_UNKNOWN -> Known.USER_DEFINED_UNKNOWN + else -> throw LangsmithApiInvalidDataException("Unknown UsageLimitType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): UsageLimitType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UsageLimitType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CurrentRetrieveUsageLimitsResponse && + inRejectSet == other.inRejectSet && + tenantLimit == other.tenantLimit && + usageLimitType == other.usageLimitType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(inRejectSet, tenantLimit, usageLimitType, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CurrentRetrieveUsageLimitsResponse{inRejectSet=$inRejectSet, tenantLimit=$tenantLimit, usageLimitType=$usageLimitType, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberBatchParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberBatchParams.kt new file mode 100644 index 00000000..a44b05f1 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberBatchParams.kt @@ -0,0 +1,208 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.members + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.models.api.v1.orgs.current.members.PendingIdentityCreate +import java.util.Objects + +/** Batch invite up to 500 users to the current workspace and organization. */ +class MemberBatchParams +private constructor( + private val body: List<PendingIdentityCreate>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun body(): List<PendingIdentityCreate> = body + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MemberBatchParams]. + * + * The following fields are required: + * ```java + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MemberBatchParams]. */ + class Builder internal constructor() { + + private var body: MutableList<PendingIdentityCreate>? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(memberBatchParams: MemberBatchParams) = apply { + body = memberBatchParams.body.toMutableList() + additionalHeaders = memberBatchParams.additionalHeaders.toBuilder() + additionalQueryParams = memberBatchParams.additionalQueryParams.toBuilder() + } + + fun body(body: List<PendingIdentityCreate>) = apply { this.body = body.toMutableList() } + + /** + * Adds a single [PendingIdentityCreate] to [Builder.body]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addBody(body: PendingIdentityCreate) = apply { + this.body = (this.body ?: mutableListOf()).apply { add(body) } + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [MemberBatchParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MemberBatchParams = + MemberBatchParams( + checkRequired("body", body).toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): List<PendingIdentityCreate> = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MemberBatchParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "MemberBatchParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberCreateParams.kt new file mode 100644 index 00000000..ccc6a3d3 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberCreateParams.kt @@ -0,0 +1,685 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.members + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Add an existing organization member to the current workspace. */ +class MemberCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun lsUserId(): Optional<String> = body.lsUserId() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun orgIdentityId(): Optional<String> = body.orgIdentityId() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun readOnly(): Optional<Boolean> = body.readOnly() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun roleId(): Optional<String> = body.roleId() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + @Deprecated("deprecated") fun userId(): Optional<String> = body.userId() + + /** + * Returns the raw JSON value of [lsUserId]. + * + * Unlike [lsUserId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _lsUserId(): JsonField<String> = body._lsUserId() + + /** + * Returns the raw JSON value of [orgIdentityId]. + * + * Unlike [orgIdentityId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _orgIdentityId(): JsonField<String> = body._orgIdentityId() + + /** + * Returns the raw JSON value of [readOnly]. + * + * Unlike [readOnly], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _readOnly(): JsonField<Boolean> = body._readOnly() + + /** + * Returns the raw JSON value of [roleId]. + * + * Unlike [roleId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _roleId(): JsonField<String> = body._roleId() + + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") fun _userId(): JsonField<String> = body._userId() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): MemberCreateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [MemberCreateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MemberCreateParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(memberCreateParams: MemberCreateParams) = apply { + body = memberCreateParams.body.toBuilder() + additionalHeaders = memberCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = memberCreateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [lsUserId] + * - [orgIdentityId] + * - [readOnly] + * - [roleId] + * - [userId] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun lsUserId(lsUserId: String?) = apply { body.lsUserId(lsUserId) } + + /** Alias for calling [Builder.lsUserId] with `lsUserId.orElse(null)`. */ + fun lsUserId(lsUserId: Optional<String>) = lsUserId(lsUserId.getOrNull()) + + /** + * Sets [Builder.lsUserId] to an arbitrary JSON value. + * + * You should usually call [Builder.lsUserId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun lsUserId(lsUserId: JsonField<String>) = apply { body.lsUserId(lsUserId) } + + fun orgIdentityId(orgIdentityId: String?) = apply { body.orgIdentityId(orgIdentityId) } + + /** Alias for calling [Builder.orgIdentityId] with `orgIdentityId.orElse(null)`. */ + fun orgIdentityId(orgIdentityId: Optional<String>) = + orgIdentityId(orgIdentityId.getOrNull()) + + /** + * Sets [Builder.orgIdentityId] to an arbitrary JSON value. + * + * You should usually call [Builder.orgIdentityId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun orgIdentityId(orgIdentityId: JsonField<String>) = apply { + body.orgIdentityId(orgIdentityId) + } + + fun readOnly(readOnly: Boolean?) = apply { body.readOnly(readOnly) } + + /** + * Alias for [Builder.readOnly]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun readOnly(readOnly: Boolean) = readOnly(readOnly as Boolean?) + + /** Alias for calling [Builder.readOnly] with `readOnly.orElse(null)`. */ + fun readOnly(readOnly: Optional<Boolean>) = readOnly(readOnly.getOrNull()) + + /** + * Sets [Builder.readOnly] to an arbitrary JSON value. + * + * You should usually call [Builder.readOnly] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun readOnly(readOnly: JsonField<Boolean>) = apply { body.readOnly(readOnly) } + + fun roleId(roleId: String?) = apply { body.roleId(roleId) } + + /** Alias for calling [Builder.roleId] with `roleId.orElse(null)`. */ + fun roleId(roleId: Optional<String>) = roleId(roleId.getOrNull()) + + /** + * Sets [Builder.roleId] to an arbitrary JSON value. + * + * You should usually call [Builder.roleId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun roleId(roleId: JsonField<String>) = apply { body.roleId(roleId) } + + @Deprecated("deprecated") fun userId(userId: String?) = apply { body.userId(userId) } + + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ + @Deprecated("deprecated") fun userId(userId: Optional<String>) = userId(userId.getOrNull()) + + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + @Deprecated("deprecated") + fun userId(userId: JsonField<String>) = apply { body.userId(userId) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [MemberCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MemberCreateParams = + MemberCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val lsUserId: JsonField<String>, + private val orgIdentityId: JsonField<String>, + private val readOnly: JsonField<Boolean>, + private val roleId: JsonField<String>, + private val userId: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("ls_user_id") + @ExcludeMissing + lsUserId: JsonField<String> = JsonMissing.of(), + @JsonProperty("org_identity_id") + @ExcludeMissing + orgIdentityId: JsonField<String> = JsonMissing.of(), + @JsonProperty("read_only") + @ExcludeMissing + readOnly: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("role_id") @ExcludeMissing roleId: JsonField<String> = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing userId: JsonField<String> = JsonMissing.of(), + ) : this(lsUserId, orgIdentityId, readOnly, roleId, userId, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun lsUserId(): Optional<String> = lsUserId.getOptional("ls_user_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun orgIdentityId(): Optional<String> = orgIdentityId.getOptional("org_identity_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun readOnly(): Optional<Boolean> = readOnly.getOptional("read_only") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun roleId(): Optional<String> = roleId.getOptional("role_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + @Deprecated("deprecated") fun userId(): Optional<String> = userId.getOptional("user_id") + + /** + * Returns the raw JSON value of [lsUserId]. + * + * Unlike [lsUserId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ls_user_id") @ExcludeMissing fun _lsUserId(): JsonField<String> = lsUserId + + /** + * Returns the raw JSON value of [orgIdentityId]. + * + * Unlike [orgIdentityId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("org_identity_id") + @ExcludeMissing + fun _orgIdentityId(): JsonField<String> = orgIdentityId + + /** + * Returns the raw JSON value of [readOnly]. + * + * Unlike [readOnly], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("read_only") @ExcludeMissing fun _readOnly(): JsonField<Boolean> = readOnly + + /** + * Returns the raw JSON value of [roleId]. + * + * Unlike [roleId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("role_id") @ExcludeMissing fun _roleId(): JsonField<String> = roleId + + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField<String> = userId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var lsUserId: JsonField<String> = JsonMissing.of() + private var orgIdentityId: JsonField<String> = JsonMissing.of() + private var readOnly: JsonField<Boolean> = JsonMissing.of() + private var roleId: JsonField<String> = JsonMissing.of() + private var userId: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + lsUserId = body.lsUserId + orgIdentityId = body.orgIdentityId + readOnly = body.readOnly + roleId = body.roleId + userId = body.userId + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun lsUserId(lsUserId: String?) = lsUserId(JsonField.ofNullable(lsUserId)) + + /** Alias for calling [Builder.lsUserId] with `lsUserId.orElse(null)`. */ + fun lsUserId(lsUserId: Optional<String>) = lsUserId(lsUserId.getOrNull()) + + /** + * Sets [Builder.lsUserId] to an arbitrary JSON value. + * + * You should usually call [Builder.lsUserId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lsUserId(lsUserId: JsonField<String>) = apply { this.lsUserId = lsUserId } + + fun orgIdentityId(orgIdentityId: String?) = + orgIdentityId(JsonField.ofNullable(orgIdentityId)) + + /** Alias for calling [Builder.orgIdentityId] with `orgIdentityId.orElse(null)`. */ + fun orgIdentityId(orgIdentityId: Optional<String>) = + orgIdentityId(orgIdentityId.getOrNull()) + + /** + * Sets [Builder.orgIdentityId] to an arbitrary JSON value. + * + * You should usually call [Builder.orgIdentityId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun orgIdentityId(orgIdentityId: JsonField<String>) = apply { + this.orgIdentityId = orgIdentityId + } + + fun readOnly(readOnly: Boolean?) = readOnly(JsonField.ofNullable(readOnly)) + + /** + * Alias for [Builder.readOnly]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun readOnly(readOnly: Boolean) = readOnly(readOnly as Boolean?) + + /** Alias for calling [Builder.readOnly] with `readOnly.orElse(null)`. */ + fun readOnly(readOnly: Optional<Boolean>) = readOnly(readOnly.getOrNull()) + + /** + * Sets [Builder.readOnly] to an arbitrary JSON value. + * + * You should usually call [Builder.readOnly] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun readOnly(readOnly: JsonField<Boolean>) = apply { this.readOnly = readOnly } + + fun roleId(roleId: String?) = roleId(JsonField.ofNullable(roleId)) + + /** Alias for calling [Builder.roleId] with `roleId.orElse(null)`. */ + fun roleId(roleId: Optional<String>) = roleId(roleId.getOrNull()) + + /** + * Sets [Builder.roleId] to an arbitrary JSON value. + * + * You should usually call [Builder.roleId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun roleId(roleId: JsonField<String>) = apply { this.roleId = roleId } + + @Deprecated("deprecated") + fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) + + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ + @Deprecated("deprecated") + fun userId(userId: Optional<String>) = userId(userId.getOrNull()) + + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun userId(userId: JsonField<String>) = apply { this.userId = userId } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = + Body( + lsUserId, + orgIdentityId, + readOnly, + roleId, + userId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + lsUserId() + orgIdentityId() + readOnly() + roleId() + userId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (lsUserId.asKnown().isPresent) 1 else 0) + + (if (orgIdentityId.asKnown().isPresent) 1 else 0) + + (if (readOnly.asKnown().isPresent) 1 else 0) + + (if (roleId.asKnown().isPresent) 1 else 0) + + (if (userId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + lsUserId == other.lsUserId && + orgIdentityId == other.orgIdentityId && + readOnly == other.readOnly && + roleId == other.roleId && + userId == other.userId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(lsUserId, orgIdentityId, readOnly, roleId, userId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{lsUserId=$lsUserId, orgIdentityId=$orgIdentityId, readOnly=$readOnly, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MemberCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "MemberCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberDeleteParams.kt new file mode 100644 index 00000000..f575404d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberDeleteParams.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.members + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete Current Workspace Member */ +class MemberDeleteParams +private constructor( + private val identityId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun identityId(): Optional<String> = Optional.ofNullable(identityId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): MemberDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [MemberDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MemberDeleteParams]. */ + class Builder internal constructor() { + + private var identityId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(memberDeleteParams: MemberDeleteParams) = apply { + identityId = memberDeleteParams.identityId + additionalHeaders = memberDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = memberDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = memberDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun identityId(identityId: String?) = apply { this.identityId = identityId } + + /** Alias for calling [Builder.identityId] with `identityId.orElse(null)`. */ + fun identityId(identityId: Optional<String>) = identityId(identityId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [MemberDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MemberDeleteParams = + MemberDeleteParams( + identityId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> identityId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MemberDeleteParams && + identityId == other.identityId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(identityId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "MemberDeleteParams{identityId=$identityId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberDeleteResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberDeleteResponse.kt new file mode 100644 index 00000000..0ece2c76 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberDeleteResponse.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.members + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class MemberDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [MemberDeleteResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MemberDeleteResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(memberDeleteResponse: MemberDeleteResponse) = apply { + additionalProperties = memberDeleteResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MemberDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MemberDeleteResponse = + MemberDeleteResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): MemberDeleteResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MemberDeleteResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "MemberDeleteResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberIdentity.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberIdentity.kt new file mode 100644 index 00000000..c728ba5c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberIdentity.kt @@ -0,0 +1,767 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.members + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.orgs.current.members.AccessScope +import com.langsmith_api.api.models.api.v1.orgs.current.user.ProviderUserSlim +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class MemberIdentity +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val lsUserId: JsonField<String>, + private val organizationId: JsonField<String>, + private val readOnly: JsonField<Boolean>, + private val userId: JsonField<String>, + private val accessScope: JsonField<AccessScope>, + private val avatarUrl: JsonField<String>, + private val email: JsonField<String>, + private val fullName: JsonField<String>, + private val linkedLoginMethods: JsonField<List<ProviderUserSlim>>, + private val orgRoleId: JsonField<String>, + private val orgRoleName: JsonField<String>, + private val roleId: JsonField<String>, + private val roleName: JsonField<String>, + private val tenantId: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("ls_user_id") @ExcludeMissing lsUserId: JsonField<String> = JsonMissing.of(), + @JsonProperty("organization_id") + @ExcludeMissing + organizationId: JsonField<String> = JsonMissing.of(), + @JsonProperty("read_only") @ExcludeMissing readOnly: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing userId: JsonField<String> = JsonMissing.of(), + @JsonProperty("access_scope") + @ExcludeMissing + accessScope: JsonField<AccessScope> = JsonMissing.of(), + @JsonProperty("avatar_url") @ExcludeMissing avatarUrl: JsonField<String> = JsonMissing.of(), + @JsonProperty("email") @ExcludeMissing email: JsonField<String> = JsonMissing.of(), + @JsonProperty("full_name") @ExcludeMissing fullName: JsonField<String> = JsonMissing.of(), + @JsonProperty("linked_login_methods") + @ExcludeMissing + linkedLoginMethods: JsonField<List<ProviderUserSlim>> = JsonMissing.of(), + @JsonProperty("org_role_id") + @ExcludeMissing + orgRoleId: JsonField<String> = JsonMissing.of(), + @JsonProperty("org_role_name") + @ExcludeMissing + orgRoleName: JsonField<String> = JsonMissing.of(), + @JsonProperty("role_id") @ExcludeMissing roleId: JsonField<String> = JsonMissing.of(), + @JsonProperty("role_name") @ExcludeMissing roleName: JsonField<String> = JsonMissing.of(), + @JsonProperty("tenant_id") @ExcludeMissing tenantId: JsonField<String> = JsonMissing.of(), + ) : this( + id, + createdAt, + lsUserId, + organizationId, + readOnly, + userId, + accessScope, + avatarUrl, + email, + fullName, + linkedLoginMethods, + orgRoleId, + orgRoleName, + roleId, + roleName, + tenantId, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun lsUserId(): String = lsUserId.getRequired("ls_user_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun organizationId(): String = organizationId.getRequired("organization_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun readOnly(): Boolean = readOnly.getRequired("read_only") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun userId(): String = userId.getRequired("user_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun accessScope(): Optional<AccessScope> = accessScope.getOptional("access_scope") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun avatarUrl(): Optional<String> = avatarUrl.getOptional("avatar_url") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun email(): Optional<String> = email.getOptional("email") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fullName(): Optional<String> = fullName.getOptional("full_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun linkedLoginMethods(): Optional<List<ProviderUserSlim>> = + linkedLoginMethods.getOptional("linked_login_methods") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun orgRoleId(): Optional<String> = orgRoleId.getOptional("org_role_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun orgRoleName(): Optional<String> = orgRoleName.getOptional("org_role_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun roleId(): Optional<String> = roleId.getOptional("role_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun roleName(): Optional<String> = roleName.getOptional("role_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tenantId(): Optional<String> = tenantId.getOptional("tenant_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [lsUserId]. + * + * Unlike [lsUserId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ls_user_id") @ExcludeMissing fun _lsUserId(): JsonField<String> = lsUserId + + /** + * Returns the raw JSON value of [organizationId]. + * + * Unlike [organizationId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("organization_id") + @ExcludeMissing + fun _organizationId(): JsonField<String> = organizationId + + /** + * Returns the raw JSON value of [readOnly]. + * + * Unlike [readOnly], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("read_only") @ExcludeMissing fun _readOnly(): JsonField<Boolean> = readOnly + + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField<String> = userId + + /** + * Returns the raw JSON value of [accessScope]. + * + * Unlike [accessScope], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("access_scope") + @ExcludeMissing + fun _accessScope(): JsonField<AccessScope> = accessScope + + /** + * Returns the raw JSON value of [avatarUrl]. + * + * Unlike [avatarUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("avatar_url") @ExcludeMissing fun _avatarUrl(): JsonField<String> = avatarUrl + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField<String> = email + + /** + * Returns the raw JSON value of [fullName]. + * + * Unlike [fullName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("full_name") @ExcludeMissing fun _fullName(): JsonField<String> = fullName + + /** + * Returns the raw JSON value of [linkedLoginMethods]. + * + * Unlike [linkedLoginMethods], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("linked_login_methods") + @ExcludeMissing + fun _linkedLoginMethods(): JsonField<List<ProviderUserSlim>> = linkedLoginMethods + + /** + * Returns the raw JSON value of [orgRoleId]. + * + * Unlike [orgRoleId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("org_role_id") @ExcludeMissing fun _orgRoleId(): JsonField<String> = orgRoleId + + /** + * Returns the raw JSON value of [orgRoleName]. + * + * Unlike [orgRoleName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("org_role_name") + @ExcludeMissing + fun _orgRoleName(): JsonField<String> = orgRoleName + + /** + * Returns the raw JSON value of [roleId]. + * + * Unlike [roleId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("role_id") @ExcludeMissing fun _roleId(): JsonField<String> = roleId + + /** + * Returns the raw JSON value of [roleName]. + * + * Unlike [roleName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("role_name") @ExcludeMissing fun _roleName(): JsonField<String> = roleName + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_id") @ExcludeMissing fun _tenantId(): JsonField<String> = tenantId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MemberIdentity]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .lsUserId() + * .organizationId() + * .readOnly() + * .userId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MemberIdentity]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var createdAt: JsonField<OffsetDateTime>? = null + private var lsUserId: JsonField<String>? = null + private var organizationId: JsonField<String>? = null + private var readOnly: JsonField<Boolean>? = null + private var userId: JsonField<String>? = null + private var accessScope: JsonField<AccessScope> = JsonMissing.of() + private var avatarUrl: JsonField<String> = JsonMissing.of() + private var email: JsonField<String> = JsonMissing.of() + private var fullName: JsonField<String> = JsonMissing.of() + private var linkedLoginMethods: JsonField<MutableList<ProviderUserSlim>>? = null + private var orgRoleId: JsonField<String> = JsonMissing.of() + private var orgRoleName: JsonField<String> = JsonMissing.of() + private var roleId: JsonField<String> = JsonMissing.of() + private var roleName: JsonField<String> = JsonMissing.of() + private var tenantId: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(memberIdentity: MemberIdentity) = apply { + id = memberIdentity.id + createdAt = memberIdentity.createdAt + lsUserId = memberIdentity.lsUserId + organizationId = memberIdentity.organizationId + readOnly = memberIdentity.readOnly + userId = memberIdentity.userId + accessScope = memberIdentity.accessScope + avatarUrl = memberIdentity.avatarUrl + email = memberIdentity.email + fullName = memberIdentity.fullName + linkedLoginMethods = memberIdentity.linkedLoginMethods.map { it.toMutableList() } + orgRoleId = memberIdentity.orgRoleId + orgRoleName = memberIdentity.orgRoleName + roleId = memberIdentity.roleId + roleName = memberIdentity.roleName + tenantId = memberIdentity.tenantId + additionalProperties = memberIdentity.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun lsUserId(lsUserId: String) = lsUserId(JsonField.of(lsUserId)) + + /** + * Sets [Builder.lsUserId] to an arbitrary JSON value. + * + * You should usually call [Builder.lsUserId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun lsUserId(lsUserId: JsonField<String>) = apply { this.lsUserId = lsUserId } + + fun organizationId(organizationId: String) = organizationId(JsonField.of(organizationId)) + + /** + * Sets [Builder.organizationId] to an arbitrary JSON value. + * + * You should usually call [Builder.organizationId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun organizationId(organizationId: JsonField<String>) = apply { + this.organizationId = organizationId + } + + fun readOnly(readOnly: Boolean) = readOnly(JsonField.of(readOnly)) + + /** + * Sets [Builder.readOnly] to an arbitrary JSON value. + * + * You should usually call [Builder.readOnly] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun readOnly(readOnly: JsonField<Boolean>) = apply { this.readOnly = readOnly } + + fun userId(userId: String) = userId(JsonField.of(userId)) + + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun userId(userId: JsonField<String>) = apply { this.userId = userId } + + fun accessScope(accessScope: AccessScope) = accessScope(JsonField.of(accessScope)) + + /** + * Sets [Builder.accessScope] to an arbitrary JSON value. + * + * You should usually call [Builder.accessScope] with a well-typed [AccessScope] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun accessScope(accessScope: JsonField<AccessScope>) = apply { + this.accessScope = accessScope + } + + fun avatarUrl(avatarUrl: String?) = avatarUrl(JsonField.ofNullable(avatarUrl)) + + /** Alias for calling [Builder.avatarUrl] with `avatarUrl.orElse(null)`. */ + fun avatarUrl(avatarUrl: Optional<String>) = avatarUrl(avatarUrl.getOrNull()) + + /** + * Sets [Builder.avatarUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.avatarUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun avatarUrl(avatarUrl: JsonField<String>) = apply { this.avatarUrl = avatarUrl } + + fun email(email: String?) = email(JsonField.ofNullable(email)) + + /** Alias for calling [Builder.email] with `email.orElse(null)`. */ + fun email(email: Optional<String>) = email(email.getOrNull()) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun email(email: JsonField<String>) = apply { this.email = email } + + fun fullName(fullName: String?) = fullName(JsonField.ofNullable(fullName)) + + /** Alias for calling [Builder.fullName] with `fullName.orElse(null)`. */ + fun fullName(fullName: Optional<String>) = fullName(fullName.getOrNull()) + + /** + * Sets [Builder.fullName] to an arbitrary JSON value. + * + * You should usually call [Builder.fullName] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun fullName(fullName: JsonField<String>) = apply { this.fullName = fullName } + + fun linkedLoginMethods(linkedLoginMethods: List<ProviderUserSlim>) = + linkedLoginMethods(JsonField.of(linkedLoginMethods)) + + /** + * Sets [Builder.linkedLoginMethods] to an arbitrary JSON value. + * + * You should usually call [Builder.linkedLoginMethods] with a well-typed + * `List<ProviderUserSlim>` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun linkedLoginMethods(linkedLoginMethods: JsonField<List<ProviderUserSlim>>) = apply { + this.linkedLoginMethods = linkedLoginMethods.map { it.toMutableList() } + } + + /** + * Adds a single [ProviderUserSlim] to [linkedLoginMethods]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLinkedLoginMethod(linkedLoginMethod: ProviderUserSlim) = apply { + linkedLoginMethods = + (linkedLoginMethods ?: JsonField.of(mutableListOf())).also { + checkKnown("linkedLoginMethods", it).add(linkedLoginMethod) + } + } + + fun orgRoleId(orgRoleId: String?) = orgRoleId(JsonField.ofNullable(orgRoleId)) + + /** Alias for calling [Builder.orgRoleId] with `orgRoleId.orElse(null)`. */ + fun orgRoleId(orgRoleId: Optional<String>) = orgRoleId(orgRoleId.getOrNull()) + + /** + * Sets [Builder.orgRoleId] to an arbitrary JSON value. + * + * You should usually call [Builder.orgRoleId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun orgRoleId(orgRoleId: JsonField<String>) = apply { this.orgRoleId = orgRoleId } + + fun orgRoleName(orgRoleName: String?) = orgRoleName(JsonField.ofNullable(orgRoleName)) + + /** Alias for calling [Builder.orgRoleName] with `orgRoleName.orElse(null)`. */ + fun orgRoleName(orgRoleName: Optional<String>) = orgRoleName(orgRoleName.getOrNull()) + + /** + * Sets [Builder.orgRoleName] to an arbitrary JSON value. + * + * You should usually call [Builder.orgRoleName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun orgRoleName(orgRoleName: JsonField<String>) = apply { this.orgRoleName = orgRoleName } + + fun roleId(roleId: String?) = roleId(JsonField.ofNullable(roleId)) + + /** Alias for calling [Builder.roleId] with `roleId.orElse(null)`. */ + fun roleId(roleId: Optional<String>) = roleId(roleId.getOrNull()) + + /** + * Sets [Builder.roleId] to an arbitrary JSON value. + * + * You should usually call [Builder.roleId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun roleId(roleId: JsonField<String>) = apply { this.roleId = roleId } + + fun roleName(roleName: String?) = roleName(JsonField.ofNullable(roleName)) + + /** Alias for calling [Builder.roleName] with `roleName.orElse(null)`. */ + fun roleName(roleName: Optional<String>) = roleName(roleName.getOrNull()) + + /** + * Sets [Builder.roleName] to an arbitrary JSON value. + * + * You should usually call [Builder.roleName] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun roleName(roleName: JsonField<String>) = apply { this.roleName = roleName } + + fun tenantId(tenantId: String?) = tenantId(JsonField.ofNullable(tenantId)) + + /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ + fun tenantId(tenantId: Optional<String>) = tenantId(tenantId.getOrNull()) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tenantId(tenantId: JsonField<String>) = apply { this.tenantId = tenantId } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MemberIdentity]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .lsUserId() + * .organizationId() + * .readOnly() + * .userId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MemberIdentity = + MemberIdentity( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("lsUserId", lsUserId), + checkRequired("organizationId", organizationId), + checkRequired("readOnly", readOnly), + checkRequired("userId", userId), + accessScope, + avatarUrl, + email, + fullName, + (linkedLoginMethods ?: JsonMissing.of()).map { it.toImmutable() }, + orgRoleId, + orgRoleName, + roleId, + roleName, + tenantId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MemberIdentity = apply { + if (validated) { + return@apply + } + + id() + createdAt() + lsUserId() + organizationId() + readOnly() + userId() + accessScope().ifPresent { it.validate() } + avatarUrl() + email() + fullName() + linkedLoginMethods().ifPresent { it.forEach { it.validate() } } + orgRoleId() + orgRoleName() + roleId() + roleName() + tenantId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (lsUserId.asKnown().isPresent) 1 else 0) + + (if (organizationId.asKnown().isPresent) 1 else 0) + + (if (readOnly.asKnown().isPresent) 1 else 0) + + (if (userId.asKnown().isPresent) 1 else 0) + + (accessScope.asKnown().getOrNull()?.validity() ?: 0) + + (if (avatarUrl.asKnown().isPresent) 1 else 0) + + (if (email.asKnown().isPresent) 1 else 0) + + (if (fullName.asKnown().isPresent) 1 else 0) + + (linkedLoginMethods.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (orgRoleId.asKnown().isPresent) 1 else 0) + + (if (orgRoleName.asKnown().isPresent) 1 else 0) + + (if (roleId.asKnown().isPresent) 1 else 0) + + (if (roleName.asKnown().isPresent) 1 else 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MemberIdentity && + id == other.id && + createdAt == other.createdAt && + lsUserId == other.lsUserId && + organizationId == other.organizationId && + readOnly == other.readOnly && + userId == other.userId && + accessScope == other.accessScope && + avatarUrl == other.avatarUrl && + email == other.email && + fullName == other.fullName && + linkedLoginMethods == other.linkedLoginMethods && + orgRoleId == other.orgRoleId && + orgRoleName == other.orgRoleName && + roleId == other.roleId && + roleName == other.roleName && + tenantId == other.tenantId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + createdAt, + lsUserId, + organizationId, + readOnly, + userId, + accessScope, + avatarUrl, + email, + fullName, + linkedLoginMethods, + orgRoleId, + orgRoleName, + roleId, + roleName, + tenantId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MemberIdentity{id=$id, createdAt=$createdAt, lsUserId=$lsUserId, organizationId=$organizationId, readOnly=$readOnly, userId=$userId, accessScope=$accessScope, avatarUrl=$avatarUrl, email=$email, fullName=$fullName, linkedLoginMethods=$linkedLoginMethods, orgRoleId=$orgRoleId, orgRoleName=$orgRoleName, roleId=$roleId, roleName=$roleName, tenantId=$tenantId, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberListParams.kt new file mode 100644 index 00000000..1534d749 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberListParams.kt @@ -0,0 +1,170 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.members + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** Get Current Workspace Members */ +class MemberListParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): MemberListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [MemberListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MemberListParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(memberListParams: MemberListParams) = apply { + additionalHeaders = memberListParams.additionalHeaders.toBuilder() + additionalQueryParams = memberListParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [MemberListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MemberListParams = + MemberListParams(additionalHeaders.build(), additionalQueryParams.build()) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MemberListParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "MemberListParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberListResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberListResponse.kt new file mode 100644 index 00000000..9ff6f7da --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberListResponse.kt @@ -0,0 +1,283 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.members + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.orgs.current.members.PendingIdentity +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** Tenant members schema. */ +class MemberListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val members: JsonField<List<MemberIdentity>>, + private val pending: JsonField<List<PendingIdentity>>, + private val tenantId: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("members") + @ExcludeMissing + members: JsonField<List<MemberIdentity>> = JsonMissing.of(), + @JsonProperty("pending") + @ExcludeMissing + pending: JsonField<List<PendingIdentity>> = JsonMissing.of(), + @JsonProperty("tenant_id") @ExcludeMissing tenantId: JsonField<String> = JsonMissing.of(), + ) : this(members, pending, tenantId, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun members(): List<MemberIdentity> = members.getRequired("members") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun pending(): List<PendingIdentity> = pending.getRequired("pending") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tenantId(): String = tenantId.getRequired("tenant_id") + + /** + * Returns the raw JSON value of [members]. + * + * Unlike [members], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("members") + @ExcludeMissing + fun _members(): JsonField<List<MemberIdentity>> = members + + /** + * Returns the raw JSON value of [pending]. + * + * Unlike [pending], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pending") + @ExcludeMissing + fun _pending(): JsonField<List<PendingIdentity>> = pending + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_id") @ExcludeMissing fun _tenantId(): JsonField<String> = tenantId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MemberListResponse]. + * + * The following fields are required: + * ```java + * .members() + * .pending() + * .tenantId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MemberListResponse]. */ + class Builder internal constructor() { + + private var members: JsonField<MutableList<MemberIdentity>>? = null + private var pending: JsonField<MutableList<PendingIdentity>>? = null + private var tenantId: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(memberListResponse: MemberListResponse) = apply { + members = memberListResponse.members.map { it.toMutableList() } + pending = memberListResponse.pending.map { it.toMutableList() } + tenantId = memberListResponse.tenantId + additionalProperties = memberListResponse.additionalProperties.toMutableMap() + } + + fun members(members: List<MemberIdentity>) = members(JsonField.of(members)) + + /** + * Sets [Builder.members] to an arbitrary JSON value. + * + * You should usually call [Builder.members] with a well-typed `List<MemberIdentity>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun members(members: JsonField<List<MemberIdentity>>) = apply { + this.members = members.map { it.toMutableList() } + } + + /** + * Adds a single [MemberIdentity] to [members]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMember(member: MemberIdentity) = apply { + members = + (members ?: JsonField.of(mutableListOf())).also { + checkKnown("members", it).add(member) + } + } + + fun pending(pending: List<PendingIdentity>) = pending(JsonField.of(pending)) + + /** + * Sets [Builder.pending] to an arbitrary JSON value. + * + * You should usually call [Builder.pending] with a well-typed `List<PendingIdentity>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun pending(pending: JsonField<List<PendingIdentity>>) = apply { + this.pending = pending.map { it.toMutableList() } + } + + /** + * Adds a single [PendingIdentity] to [Builder.pending]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPending(pending: PendingIdentity) = apply { + this.pending = + (this.pending ?: JsonField.of(mutableListOf())).also { + checkKnown("pending", it).add(pending) + } + } + + fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tenantId(tenantId: JsonField<String>) = apply { this.tenantId = tenantId } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MemberListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .members() + * .pending() + * .tenantId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MemberListResponse = + MemberListResponse( + checkRequired("members", members).map { it.toImmutable() }, + checkRequired("pending", pending).map { it.toImmutable() }, + checkRequired("tenantId", tenantId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MemberListResponse = apply { + if (validated) { + return@apply + } + + members().forEach { it.validate() } + pending().forEach { it.validate() } + tenantId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (members.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (pending.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MemberListResponse && + members == other.members && + pending == other.pending && + tenantId == other.tenantId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(members, pending, tenantId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MemberListResponse{members=$members, pending=$pending, tenantId=$tenantId, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberRetrieveActiveParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberRetrieveActiveParams.kt new file mode 100644 index 00000000..47481904 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberRetrieveActiveParams.kt @@ -0,0 +1,303 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.members + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get Current Active Workspace Members */ +class MemberRetrieveActiveParams +private constructor( + private val emails: List<String>?, + private val limit: Long?, + private val lsUserIds: List<String>?, + private val offset: Long?, + private val userIds: List<String>?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun emails(): Optional<List<String>> = Optional.ofNullable(emails) + + fun limit(): Optional<Long> = Optional.ofNullable(limit) + + fun lsUserIds(): Optional<List<String>> = Optional.ofNullable(lsUserIds) + + fun offset(): Optional<Long> = Optional.ofNullable(offset) + + @Deprecated("deprecated") fun userIds(): Optional<List<String>> = Optional.ofNullable(userIds) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): MemberRetrieveActiveParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [MemberRetrieveActiveParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MemberRetrieveActiveParams]. */ + class Builder internal constructor() { + + private var emails: MutableList<String>? = null + private var limit: Long? = null + private var lsUserIds: MutableList<String>? = null + private var offset: Long? = null + private var userIds: MutableList<String>? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(memberRetrieveActiveParams: MemberRetrieveActiveParams) = apply { + emails = memberRetrieveActiveParams.emails?.toMutableList() + limit = memberRetrieveActiveParams.limit + lsUserIds = memberRetrieveActiveParams.lsUserIds?.toMutableList() + offset = memberRetrieveActiveParams.offset + userIds = memberRetrieveActiveParams.userIds?.toMutableList() + additionalHeaders = memberRetrieveActiveParams.additionalHeaders.toBuilder() + additionalQueryParams = memberRetrieveActiveParams.additionalQueryParams.toBuilder() + } + + fun emails(emails: List<String>?) = apply { this.emails = emails?.toMutableList() } + + /** Alias for calling [Builder.emails] with `emails.orElse(null)`. */ + fun emails(emails: Optional<List<String>>) = emails(emails.getOrNull()) + + /** + * Adds a single [String] to [emails]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEmail(email: String) = apply { + emails = (emails ?: mutableListOf()).apply { add(email) } + } + + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional<Long>) = limit(limit.getOrNull()) + + fun lsUserIds(lsUserIds: List<String>?) = apply { + this.lsUserIds = lsUserIds?.toMutableList() + } + + /** Alias for calling [Builder.lsUserIds] with `lsUserIds.orElse(null)`. */ + fun lsUserIds(lsUserIds: Optional<List<String>>) = lsUserIds(lsUserIds.getOrNull()) + + /** + * Adds a single [String] to [lsUserIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLsUserId(lsUserId: String) = apply { + lsUserIds = (lsUserIds ?: mutableListOf()).apply { add(lsUserId) } + } + + fun offset(offset: Long?) = apply { this.offset = offset } + + /** + * Alias for [Builder.offset]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun offset(offset: Long) = offset(offset as Long?) + + /** Alias for calling [Builder.offset] with `offset.orElse(null)`. */ + fun offset(offset: Optional<Long>) = offset(offset.getOrNull()) + + @Deprecated("deprecated") + fun userIds(userIds: List<String>?) = apply { this.userIds = userIds?.toMutableList() } + + /** Alias for calling [Builder.userIds] with `userIds.orElse(null)`. */ + @Deprecated("deprecated") + fun userIds(userIds: Optional<List<String>>) = userIds(userIds.getOrNull()) + + /** + * Adds a single [String] to [userIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + @Deprecated("deprecated") + fun addUserId(userId: String) = apply { + userIds = (userIds ?: mutableListOf()).apply { add(userId) } + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [MemberRetrieveActiveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MemberRetrieveActiveParams = + MemberRetrieveActiveParams( + emails?.toImmutable(), + limit, + lsUserIds?.toImmutable(), + offset, + userIds?.toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + emails?.let { put("emails", it.joinToString(",")) } + limit?.let { put("limit", it.toString()) } + lsUserIds?.let { put("ls_user_ids", it.joinToString(",")) } + offset?.let { put("offset", it.toString()) } + userIds?.let { put("user_ids", it.joinToString(",")) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MemberRetrieveActiveParams && + emails == other.emails && + limit == other.limit && + lsUserIds == other.lsUserIds && + offset == other.offset && + userIds == other.userIds && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + emails, + limit, + lsUserIds, + offset, + userIds, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "MemberRetrieveActiveParams{emails=$emails, limit=$limit, lsUserIds=$lsUserIds, offset=$offset, userIds=$userIds, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberUpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberUpdateParams.kt new file mode 100644 index 00000000..29f2aa54 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberUpdateParams.kt @@ -0,0 +1,510 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.members + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Patch Current Workspace Member */ +class MemberUpdateParams +private constructor( + private val identityId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun identityId(): Optional<String> = Optional.ofNullable(identityId) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun roleId(): String = body.roleId() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun readOnly(): Optional<Boolean> = body.readOnly() + + /** + * Returns the raw JSON value of [roleId]. + * + * Unlike [roleId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _roleId(): JsonField<String> = body._roleId() + + /** + * Returns the raw JSON value of [readOnly]. + * + * Unlike [readOnly], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _readOnly(): JsonField<Boolean> = body._readOnly() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MemberUpdateParams]. + * + * The following fields are required: + * ```java + * .roleId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MemberUpdateParams]. */ + class Builder internal constructor() { + + private var identityId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(memberUpdateParams: MemberUpdateParams) = apply { + identityId = memberUpdateParams.identityId + body = memberUpdateParams.body.toBuilder() + additionalHeaders = memberUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = memberUpdateParams.additionalQueryParams.toBuilder() + } + + fun identityId(identityId: String?) = apply { this.identityId = identityId } + + /** Alias for calling [Builder.identityId] with `identityId.orElse(null)`. */ + fun identityId(identityId: Optional<String>) = identityId(identityId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [roleId] + * - [readOnly] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun roleId(roleId: String) = apply { body.roleId(roleId) } + + /** + * Sets [Builder.roleId] to an arbitrary JSON value. + * + * You should usually call [Builder.roleId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun roleId(roleId: JsonField<String>) = apply { body.roleId(roleId) } + + fun readOnly(readOnly: Boolean?) = apply { body.readOnly(readOnly) } + + /** + * Alias for [Builder.readOnly]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun readOnly(readOnly: Boolean) = readOnly(readOnly as Boolean?) + + /** Alias for calling [Builder.readOnly] with `readOnly.orElse(null)`. */ + fun readOnly(readOnly: Optional<Boolean>) = readOnly(readOnly.getOrNull()) + + /** + * Sets [Builder.readOnly] to an arbitrary JSON value. + * + * You should usually call [Builder.readOnly] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun readOnly(readOnly: JsonField<Boolean>) = apply { body.readOnly(readOnly) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [MemberUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .roleId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MemberUpdateParams = + MemberUpdateParams( + identityId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> identityId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val roleId: JsonField<String>, + private val readOnly: JsonField<Boolean>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("role_id") @ExcludeMissing roleId: JsonField<String> = JsonMissing.of(), + @JsonProperty("read_only") + @ExcludeMissing + readOnly: JsonField<Boolean> = JsonMissing.of(), + ) : this(roleId, readOnly, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun roleId(): String = roleId.getRequired("role_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun readOnly(): Optional<Boolean> = readOnly.getOptional("read_only") + + /** + * Returns the raw JSON value of [roleId]. + * + * Unlike [roleId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("role_id") @ExcludeMissing fun _roleId(): JsonField<String> = roleId + + /** + * Returns the raw JSON value of [readOnly]. + * + * Unlike [readOnly], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("read_only") @ExcludeMissing fun _readOnly(): JsonField<Boolean> = readOnly + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .roleId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var roleId: JsonField<String>? = null + private var readOnly: JsonField<Boolean> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + roleId = body.roleId + readOnly = body.readOnly + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun roleId(roleId: String) = roleId(JsonField.of(roleId)) + + /** + * Sets [Builder.roleId] to an arbitrary JSON value. + * + * You should usually call [Builder.roleId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun roleId(roleId: JsonField<String>) = apply { this.roleId = roleId } + + fun readOnly(readOnly: Boolean?) = readOnly(JsonField.ofNullable(readOnly)) + + /** + * Alias for [Builder.readOnly]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun readOnly(readOnly: Boolean) = readOnly(readOnly as Boolean?) + + /** Alias for calling [Builder.readOnly] with `readOnly.orElse(null)`. */ + fun readOnly(readOnly: Optional<Boolean>) = readOnly(readOnly.getOrNull()) + + /** + * Sets [Builder.readOnly] to an arbitrary JSON value. + * + * You should usually call [Builder.readOnly] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun readOnly(readOnly: JsonField<Boolean>) = apply { this.readOnly = readOnly } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .roleId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body(checkRequired("roleId", roleId), readOnly, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + roleId() + readOnly() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (roleId.asKnown().isPresent) 1 else 0) + + (if (readOnly.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + roleId == other.roleId && + readOnly == other.readOnly && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(roleId, readOnly, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{roleId=$roleId, readOnly=$readOnly, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MemberUpdateParams && + identityId == other.identityId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(identityId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "MemberUpdateParams{identityId=$identityId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberUpdateResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberUpdateResponse.kt new file mode 100644 index 00000000..eb192be5 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberUpdateResponse.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.members + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class MemberUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [MemberUpdateResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MemberUpdateResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(memberUpdateResponse: MemberUpdateResponse) = apply { + additionalProperties = memberUpdateResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MemberUpdateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MemberUpdateResponse = + MemberUpdateResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): MemberUpdateResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MemberUpdateResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "MemberUpdateResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/pending/PendingDeleteAllParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/pending/PendingDeleteAllParams.kt new file mode 100644 index 00000000..35692361 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/pending/PendingDeleteAllParams.kt @@ -0,0 +1,230 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.members.pending + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete Current Workspace Pending Member */ +class PendingDeleteAllParams +private constructor( + private val identityId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun identityId(): Optional<String> = Optional.ofNullable(identityId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): PendingDeleteAllParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [PendingDeleteAllParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PendingDeleteAllParams]. */ + class Builder internal constructor() { + + private var identityId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(pendingDeleteAllParams: PendingDeleteAllParams) = apply { + identityId = pendingDeleteAllParams.identityId + additionalHeaders = pendingDeleteAllParams.additionalHeaders.toBuilder() + additionalQueryParams = pendingDeleteAllParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + pendingDeleteAllParams.additionalBodyProperties.toMutableMap() + } + + fun identityId(identityId: String?) = apply { this.identityId = identityId } + + /** Alias for calling [Builder.identityId] with `identityId.orElse(null)`. */ + fun identityId(identityId: Optional<String>) = identityId(identityId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [PendingDeleteAllParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PendingDeleteAllParams = + PendingDeleteAllParams( + identityId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> identityId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PendingDeleteAllParams && + identityId == other.identityId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(identityId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "PendingDeleteAllParams{identityId=$identityId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/pending/PendingDeleteAllResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/pending/PendingDeleteAllResponse.kt new file mode 100644 index 00000000..d8a20145 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/pending/PendingDeleteAllResponse.kt @@ -0,0 +1,115 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.members.pending + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class PendingDeleteAllResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [PendingDeleteAllResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PendingDeleteAllResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(pendingDeleteAllResponse: PendingDeleteAllResponse) = apply { + additionalProperties = pendingDeleteAllResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PendingDeleteAllResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PendingDeleteAllResponse = + PendingDeleteAllResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): PendingDeleteAllResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PendingDeleteAllResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "PendingDeleteAllResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/pending/PendingListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/pending/PendingListParams.kt new file mode 100644 index 00000000..b7b859dc --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/pending/PendingListParams.kt @@ -0,0 +1,244 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.members.pending + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get Current Pending Workspace Members */ +class PendingListParams +private constructor( + private val emails: List<String>?, + private val limit: Long?, + private val offset: Long?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun emails(): Optional<List<String>> = Optional.ofNullable(emails) + + fun limit(): Optional<Long> = Optional.ofNullable(limit) + + fun offset(): Optional<Long> = Optional.ofNullable(offset) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): PendingListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [PendingListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PendingListParams]. */ + class Builder internal constructor() { + + private var emails: MutableList<String>? = null + private var limit: Long? = null + private var offset: Long? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(pendingListParams: PendingListParams) = apply { + emails = pendingListParams.emails?.toMutableList() + limit = pendingListParams.limit + offset = pendingListParams.offset + additionalHeaders = pendingListParams.additionalHeaders.toBuilder() + additionalQueryParams = pendingListParams.additionalQueryParams.toBuilder() + } + + fun emails(emails: List<String>?) = apply { this.emails = emails?.toMutableList() } + + /** Alias for calling [Builder.emails] with `emails.orElse(null)`. */ + fun emails(emails: Optional<List<String>>) = emails(emails.getOrNull()) + + /** + * Adds a single [String] to [emails]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEmail(email: String) = apply { + emails = (emails ?: mutableListOf()).apply { add(email) } + } + + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional<Long>) = limit(limit.getOrNull()) + + fun offset(offset: Long?) = apply { this.offset = offset } + + /** + * Alias for [Builder.offset]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun offset(offset: Long) = offset(offset as Long?) + + /** Alias for calling [Builder.offset] with `offset.orElse(null)`. */ + fun offset(offset: Optional<Long>) = offset(offset.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [PendingListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PendingListParams = + PendingListParams( + emails?.toImmutable(), + limit, + offset, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + emails?.let { put("emails", it.joinToString(",")) } + limit?.let { put("limit", it.toString()) } + offset?.let { put("offset", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PendingListParams && + emails == other.emails && + limit == other.limit && + offset == other.offset && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(emails, limit, offset, additionalHeaders, additionalQueryParams) + + override fun toString() = + "PendingListParams{emails=$emails, limit=$limit, offset=$offset, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretCreateParams.kt new file mode 100644 index 00000000..cb613f62 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretCreateParams.kt @@ -0,0 +1,413 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.secrets + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Upsert Current Workspace Secrets */ +class SecretCreateParams +private constructor( + private val body: List<Body>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun body(): List<Body> = body + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SecretCreateParams]. + * + * The following fields are required: + * ```java + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SecretCreateParams]. */ + class Builder internal constructor() { + + private var body: MutableList<Body>? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(secretCreateParams: SecretCreateParams) = apply { + body = secretCreateParams.body.toMutableList() + additionalHeaders = secretCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = secretCreateParams.additionalQueryParams.toBuilder() + } + + fun body(body: List<Body>) = apply { this.body = body.toMutableList() } + + /** + * Adds a single [Body] to [Builder.body]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addBody(body: Body) = apply { + this.body = (this.body ?: mutableListOf()).apply { add(body) } + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SecretCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SecretCreateParams = + SecretCreateParams( + checkRequired("body", body).toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): List<Body> = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val key: JsonField<String>, + private val value: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("key") @ExcludeMissing key: JsonField<String> = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField<String> = JsonMissing.of(), + ) : this(key, value, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun key(): String = key.getRequired("key") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun value(): Optional<String> = value.getOptional("value") + + /** + * Returns the raw JSON value of [key]. + * + * Unlike [key], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("key") @ExcludeMissing fun _key(): JsonField<String> = key + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField<String> = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .key() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var key: JsonField<String>? = null + private var value: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + key = body.key + value = body.value + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun key(key: String) = key(JsonField.of(key)) + + /** + * Sets [Builder.key] to an arbitrary JSON value. + * + * You should usually call [Builder.key] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun key(key: JsonField<String>) = apply { this.key = key } + + fun value(value: String?) = value(JsonField.ofNullable(value)) + + /** Alias for calling [Builder.value] with `value.orElse(null)`. */ + fun value(value: Optional<String>) = value(value.getOrNull()) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun value(value: JsonField<String>) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .key() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("key", key), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + key() + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (key.asKnown().isPresent) 1 else 0) + (if (value.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + key == other.key && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(key, value, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{key=$key, value=$value, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SecretCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "SecretCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretCreateResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretCreateResponse.kt new file mode 100644 index 00000000..452ba080 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretCreateResponse.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.secrets + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class SecretCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [SecretCreateResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SecretCreateResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(secretCreateResponse: SecretCreateResponse) = apply { + additionalProperties = secretCreateResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SecretCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SecretCreateResponse = + SecretCreateResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): SecretCreateResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SecretCreateResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "SecretCreateResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretListParams.kt new file mode 100644 index 00000000..b8811d02 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretListParams.kt @@ -0,0 +1,170 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.secrets + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** List Current Workspace Secrets */ +class SecretListParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): SecretListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [SecretListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SecretListParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(secretListParams: SecretListParams) = apply { + additionalHeaders = secretListParams.additionalHeaders.toBuilder() + additionalQueryParams = secretListParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SecretListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SecretListParams = + SecretListParams(additionalHeaders.build(), additionalQueryParams.build()) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SecretListParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "SecretListParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretListResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretListResponse.kt new file mode 100644 index 00000000..9d593085 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretListResponse.kt @@ -0,0 +1,167 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.secrets + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class SecretListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val key: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("key") @ExcludeMissing key: JsonField<String> = JsonMissing.of() + ) : this(key, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun key(): String = key.getRequired("key") + + /** + * Returns the raw JSON value of [key]. + * + * Unlike [key], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("key") @ExcludeMissing fun _key(): JsonField<String> = key + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SecretListResponse]. + * + * The following fields are required: + * ```java + * .key() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SecretListResponse]. */ + class Builder internal constructor() { + + private var key: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(secretListResponse: SecretListResponse) = apply { + key = secretListResponse.key + additionalProperties = secretListResponse.additionalProperties.toMutableMap() + } + + fun key(key: String) = key(JsonField.of(key)) + + /** + * Sets [Builder.key] to an arbitrary JSON value. + * + * You should usually call [Builder.key] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun key(key: JsonField<String>) = apply { this.key = key } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SecretListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .key() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SecretListResponse = + SecretListResponse(checkRequired("key", key), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): SecretListResponse = apply { + if (validated) { + return@apply + } + + key() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (key.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SecretListResponse && + key == other.key && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(key, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SecretListResponse{key=$key, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretRetrieveEncryptedParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretRetrieveEncryptedParams.kt new file mode 100644 index 00000000..2b7d1c26 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretRetrieveEncryptedParams.kt @@ -0,0 +1,330 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.secrets + +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Objects + +/** Get encrypted workspace secrets for use with Agent Builder and external services. */ +class SecretRetrieveEncryptedParams +private constructor( + private val service: Service, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Service requesting encrypted secrets */ + fun service(): Service = service + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SecretRetrieveEncryptedParams]. + * + * The following fields are required: + * ```java + * .service() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SecretRetrieveEncryptedParams]. */ + class Builder internal constructor() { + + private var service: Service? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(secretRetrieveEncryptedParams: SecretRetrieveEncryptedParams) = apply { + service = secretRetrieveEncryptedParams.service + additionalHeaders = secretRetrieveEncryptedParams.additionalHeaders.toBuilder() + additionalQueryParams = secretRetrieveEncryptedParams.additionalQueryParams.toBuilder() + } + + /** Service requesting encrypted secrets */ + fun service(service: Service) = apply { this.service = service } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SecretRetrieveEncryptedParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SecretRetrieveEncryptedParams = + SecretRetrieveEncryptedParams( + checkRequired("service", service), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("service", service.toString()) + putAll(additionalQueryParams) + } + .build() + + /** Service requesting encrypted secrets */ + class Service @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val AGENT_BUILDER = of("agent_builder") + + @JvmStatic fun of(value: String) = Service(JsonField.of(value)) + } + + /** An enum containing [Service]'s known values. */ + enum class Known { + AGENT_BUILDER + } + + /** + * An enum containing [Service]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Service] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AGENT_BUILDER, + /** An enum member indicating that [Service] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AGENT_BUILDER -> Value.AGENT_BUILDER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + AGENT_BUILDER -> Known.AGENT_BUILDER + else -> throw LangsmithApiInvalidDataException("Unknown Service: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Service = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Service && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SecretRetrieveEncryptedParams && + service == other.service && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(service, additionalHeaders, additionalQueryParams) + + override fun toString() = + "SecretRetrieveEncryptedParams{service=$service, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretRetrieveEncryptedResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretRetrieveEncryptedResponse.kt new file mode 100644 index 00000000..0485ffeb --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretRetrieveEncryptedResponse.kt @@ -0,0 +1,183 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.secrets + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class SecretRetrieveEncryptedResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val encryptedSecrets: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("encrypted_secrets") + @ExcludeMissing + encryptedSecrets: JsonField<String> = JsonMissing.of() + ) : this(encryptedSecrets, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun encryptedSecrets(): String = encryptedSecrets.getRequired("encrypted_secrets") + + /** + * Returns the raw JSON value of [encryptedSecrets]. + * + * Unlike [encryptedSecrets], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("encrypted_secrets") + @ExcludeMissing + fun _encryptedSecrets(): JsonField<String> = encryptedSecrets + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SecretRetrieveEncryptedResponse]. + * + * The following fields are required: + * ```java + * .encryptedSecrets() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SecretRetrieveEncryptedResponse]. */ + class Builder internal constructor() { + + private var encryptedSecrets: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(secretRetrieveEncryptedResponse: SecretRetrieveEncryptedResponse) = + apply { + encryptedSecrets = secretRetrieveEncryptedResponse.encryptedSecrets + additionalProperties = + secretRetrieveEncryptedResponse.additionalProperties.toMutableMap() + } + + fun encryptedSecrets(encryptedSecrets: String) = + encryptedSecrets(JsonField.of(encryptedSecrets)) + + /** + * Sets [Builder.encryptedSecrets] to an arbitrary JSON value. + * + * You should usually call [Builder.encryptedSecrets] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun encryptedSecrets(encryptedSecrets: JsonField<String>) = apply { + this.encryptedSecrets = encryptedSecrets + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SecretRetrieveEncryptedResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .encryptedSecrets() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SecretRetrieveEncryptedResponse = + SecretRetrieveEncryptedResponse( + checkRequired("encryptedSecrets", encryptedSecrets), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SecretRetrieveEncryptedResponse = apply { + if (validated) { + return@apply + } + + encryptedSecrets() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (encryptedSecrets.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SecretRetrieveEncryptedResponse && + encryptedSecrets == other.encryptedSecrets && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(encryptedSecrets, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SecretRetrieveEncryptedResponse{encryptedSecrets=$encryptedSecrets, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/shared/SharedDeleteAllParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/shared/SharedDeleteAllParams.kt new file mode 100644 index 00000000..4e5a87cf --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/shared/SharedDeleteAllParams.kt @@ -0,0 +1,417 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.shared + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Bulk unshare entities by share tokens for the workspace. */ +class SharedDeleteAllParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun shareTokens(): Optional<List<String>> = body.shareTokens() + + /** + * Returns the raw JSON value of [shareTokens]. + * + * Unlike [shareTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _shareTokens(): JsonField<List<String>> = body._shareTokens() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): SharedDeleteAllParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [SharedDeleteAllParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SharedDeleteAllParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(sharedDeleteAllParams: SharedDeleteAllParams) = apply { + body = sharedDeleteAllParams.body.toBuilder() + additionalHeaders = sharedDeleteAllParams.additionalHeaders.toBuilder() + additionalQueryParams = sharedDeleteAllParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [shareTokens] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun shareTokens(shareTokens: List<String>) = apply { body.shareTokens(shareTokens) } + + /** + * Sets [Builder.shareTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.shareTokens] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun shareTokens(shareTokens: JsonField<List<String>>) = apply { + body.shareTokens(shareTokens) + } + + /** + * Adds a single [String] to [shareTokens]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addShareToken(shareToken: String) = apply { body.addShareToken(shareToken) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SharedDeleteAllParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SharedDeleteAllParams = + SharedDeleteAllParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val shareTokens: JsonField<List<String>>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("share_tokens") + @ExcludeMissing + shareTokens: JsonField<List<String>> = JsonMissing.of() + ) : this(shareTokens, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun shareTokens(): Optional<List<String>> = shareTokens.getOptional("share_tokens") + + /** + * Returns the raw JSON value of [shareTokens]. + * + * Unlike [shareTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("share_tokens") + @ExcludeMissing + fun _shareTokens(): JsonField<List<String>> = shareTokens + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var shareTokens: JsonField<MutableList<String>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + shareTokens = body.shareTokens.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun shareTokens(shareTokens: List<String>) = shareTokens(JsonField.of(shareTokens)) + + /** + * Sets [Builder.shareTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.shareTokens] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun shareTokens(shareTokens: JsonField<List<String>>) = apply { + this.shareTokens = shareTokens.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [shareTokens]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addShareToken(shareToken: String) = apply { + shareTokens = + (shareTokens ?: JsonField.of(mutableListOf())).also { + checkKnown("shareTokens", it).add(shareToken) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = + Body( + (shareTokens ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + shareTokens() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (shareTokens.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + shareTokens == other.shareTokens && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(shareTokens, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{shareTokens=$shareTokens, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SharedDeleteAllParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "SharedDeleteAllParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/shared/SharedDeleteAllResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/shared/SharedDeleteAllResponse.kt new file mode 100644 index 00000000..dc0f288c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/shared/SharedDeleteAllResponse.kt @@ -0,0 +1,115 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.shared + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class SharedDeleteAllResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [SharedDeleteAllResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SharedDeleteAllResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(sharedDeleteAllResponse: SharedDeleteAllResponse) = apply { + additionalProperties = sharedDeleteAllResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SharedDeleteAllResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SharedDeleteAllResponse = + SharedDeleteAllResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): SharedDeleteAllResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SharedDeleteAllResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "SharedDeleteAllResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/shared/SharedListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/shared/SharedListParams.kt new file mode 100644 index 00000000..c7c97197 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/shared/SharedListParams.kt @@ -0,0 +1,221 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.shared + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** List all shared entities and their tokens by the workspace. */ +class SharedListParams +private constructor( + private val limit: Long?, + private val offset: Long?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun limit(): Optional<Long> = Optional.ofNullable(limit) + + fun offset(): Optional<Long> = Optional.ofNullable(offset) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): SharedListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [SharedListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SharedListParams]. */ + class Builder internal constructor() { + + private var limit: Long? = null + private var offset: Long? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(sharedListParams: SharedListParams) = apply { + limit = sharedListParams.limit + offset = sharedListParams.offset + additionalHeaders = sharedListParams.additionalHeaders.toBuilder() + additionalQueryParams = sharedListParams.additionalQueryParams.toBuilder() + } + + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional<Long>) = limit(limit.getOrNull()) + + fun offset(offset: Long?) = apply { this.offset = offset } + + /** + * Alias for [Builder.offset]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun offset(offset: Long) = offset(offset as Long?) + + /** Alias for calling [Builder.offset] with `offset.orElse(null)`. */ + fun offset(offset: Optional<Long>) = offset(offset.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SharedListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SharedListParams = + SharedListParams( + limit, + offset, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + limit?.let { put("limit", it.toString()) } + offset?.let { put("offset", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SharedListParams && + limit == other.limit && + offset == other.offset && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(limit, offset, additionalHeaders, additionalQueryParams) + + override fun toString() = + "SharedListParams{limit=$limit, offset=$offset, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/shared/SharedListResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/shared/SharedListResponse.kt new file mode 100644 index 00000000..21d78479 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/shared/SharedListResponse.kt @@ -0,0 +1,1178 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.shared + +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 com.langsmith_api.api.core.BaseDeserializer +import com.langsmith_api.api.core.BaseSerializer +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.getOrThrow +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class SharedListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val entities: JsonField<List<Entity>>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("entities") + @ExcludeMissing + entities: JsonField<List<Entity>> = JsonMissing.of() + ) : this(entities, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun entities(): List<Entity> = entities.getRequired("entities") + + /** + * Returns the raw JSON value of [entities]. + * + * Unlike [entities], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entities") @ExcludeMissing fun _entities(): JsonField<List<Entity>> = entities + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SharedListResponse]. + * + * The following fields are required: + * ```java + * .entities() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SharedListResponse]. */ + class Builder internal constructor() { + + private var entities: JsonField<MutableList<Entity>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(sharedListResponse: SharedListResponse) = apply { + entities = sharedListResponse.entities.map { it.toMutableList() } + additionalProperties = sharedListResponse.additionalProperties.toMutableMap() + } + + fun entities(entities: List<Entity>) = entities(JsonField.of(entities)) + + /** + * Sets [Builder.entities] to an arbitrary JSON value. + * + * You should usually call [Builder.entities] with a well-typed `List<Entity>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun entities(entities: JsonField<List<Entity>>) = apply { + this.entities = entities.map { it.toMutableList() } + } + + /** + * Adds a single [Entity] to [entities]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEntity(entity: Entity) = apply { + entities = + (entities ?: JsonField.of(mutableListOf())).also { + checkKnown("entities", it).add(entity) + } + } + + /** Alias for calling [addEntity] with `Entity.ofRun(run)`. */ + fun addEntity(run: Entity.Run) = addEntity(Entity.ofRun(run)) + + /** Alias for calling [addEntity] with `Entity.ofDataset(dataset)`. */ + fun addEntity(dataset: Entity.Dataset) = addEntity(Entity.ofDataset(dataset)) + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SharedListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entities() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SharedListResponse = + SharedListResponse( + checkRequired("entities", entities).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SharedListResponse = apply { + if (validated) { + return@apply + } + + entities().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (entities.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + @JsonDeserialize(using = Entity.Deserializer::class) + @JsonSerialize(using = Entity.Serializer::class) + class Entity + private constructor( + private val run: Run? = null, + private val dataset: Dataset? = null, + private val _json: JsonValue? = null, + ) { + + fun run(): Optional<Run> = Optional.ofNullable(run) + + fun dataset(): Optional<Dataset> = Optional.ofNullable(dataset) + + fun isRun(): Boolean = run != null + + fun isDataset(): Boolean = dataset != null + + fun asRun(): Run = run.getOrThrow("run") + + fun asDataset(): Dataset = dataset.getOrThrow("dataset") + + fun _json(): Optional<JsonValue> = Optional.ofNullable(_json) + + fun <T> accept(visitor: Visitor<T>): T = + when { + run != null -> visitor.visitRun(run) + dataset != null -> visitor.visitDataset(dataset) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Entity = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor<Unit> { + override fun visitRun(run: Run) { + run.validate() + } + + override fun visitDataset(dataset: Dataset) { + dataset.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor<Int> { + override fun visitRun(run: Run) = run.validity() + + override fun visitDataset(dataset: Dataset) = dataset.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Entity && run == other.run && dataset == other.dataset + } + + override fun hashCode(): Int = Objects.hash(run, dataset) + + override fun toString(): String = + when { + run != null -> "Entity{run=$run}" + dataset != null -> "Entity{dataset=$dataset}" + _json != null -> "Entity{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Entity") + } + + companion object { + + @JvmStatic fun ofRun(run: Run) = Entity(run = run) + + @JvmStatic fun ofDataset(dataset: Dataset) = Entity(dataset = dataset) + } + + /** An interface that defines how to map each variant of [Entity] to a value of type [T]. */ + interface Visitor<out T> { + + fun visitRun(run: Run): T + + fun visitDataset(dataset: Dataset): T + + /** + * Maps an unknown variant of [Entity] to a value of type [T]. + * + * An instance of [Entity] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws LangsmithApiInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LangsmithApiInvalidDataException("Unknown Entity: $json") + } + } + + internal class Deserializer : BaseDeserializer<Entity>(Entity::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Entity { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "run" -> { + return tryDeserialize(node, jacksonTypeRef<Run>())?.let { + Entity(run = it, _json = json) + } ?: Entity(_json = json) + } + "dataset" -> { + return tryDeserialize(node, jacksonTypeRef<Dataset>())?.let { + Entity(dataset = it, _json = json) + } ?: Entity(_json = json) + } + } + + return Entity(_json = json) + } + } + + internal class Serializer : BaseSerializer<Entity>(Entity::class) { + + override fun serialize( + value: Entity, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.run != null -> generator.writeObject(value.run) + value.dataset != null -> generator.writeObject(value.dataset) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Entity") + } + } + } + + class Run + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val createdAt: JsonField<OffsetDateTime>, + private val runId: JsonField<String>, + private val shareToken: JsonField<String>, + private val type: JsonValue, + private val runName: JsonField<String>, + private val runType: JsonField<String>, + private val sessionId: JsonField<String>, + private val sessionName: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("run_id") @ExcludeMissing runId: JsonField<String> = JsonMissing.of(), + @JsonProperty("share_token") + @ExcludeMissing + shareToken: JsonField<String> = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("run_name") + @ExcludeMissing + runName: JsonField<String> = JsonMissing.of(), + @JsonProperty("run_type") + @ExcludeMissing + runType: JsonField<String> = JsonMissing.of(), + @JsonProperty("session_id") + @ExcludeMissing + sessionId: JsonField<String> = JsonMissing.of(), + @JsonProperty("session_name") + @ExcludeMissing + sessionName: JsonField<String> = JsonMissing.of(), + ) : this( + createdAt, + runId, + shareToken, + type, + runName, + runType, + sessionId, + sessionName, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun runId(): String = runId.getRequired("run_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun shareToken(): String = shareToken.getRequired("share_token") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("run") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun runName(): Optional<String> = runName.getOptional("run_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun runType(): Optional<String> = runType.getOptional("run_type") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun sessionId(): Optional<String> = sessionId.getOptional("session_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun sessionName(): Optional<String> = sessionName.getOptional("session_name") + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [runId]. + * + * Unlike [runId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_id") @ExcludeMissing fun _runId(): JsonField<String> = runId + + /** + * Returns the raw JSON value of [shareToken]. + * + * Unlike [shareToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("share_token") + @ExcludeMissing + fun _shareToken(): JsonField<String> = shareToken + + /** + * Returns the raw JSON value of [runName]. + * + * Unlike [runName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_name") @ExcludeMissing fun _runName(): JsonField<String> = runName + + /** + * Returns the raw JSON value of [runType]. + * + * Unlike [runType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_type") @ExcludeMissing fun _runType(): JsonField<String> = runType + + /** + * Returns the raw JSON value of [sessionId]. + * + * Unlike [sessionId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("session_id") + @ExcludeMissing + fun _sessionId(): JsonField<String> = sessionId + + /** + * Returns the raw JSON value of [sessionName]. + * + * Unlike [sessionName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("session_name") + @ExcludeMissing + fun _sessionName(): JsonField<String> = sessionName + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Run]. + * + * The following fields are required: + * ```java + * .createdAt() + * .runId() + * .shareToken() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Run]. */ + class Builder internal constructor() { + + private var createdAt: JsonField<OffsetDateTime>? = null + private var runId: JsonField<String>? = null + private var shareToken: JsonField<String>? = null + private var type: JsonValue = JsonValue.from("run") + private var runName: JsonField<String> = JsonMissing.of() + private var runType: JsonField<String> = JsonMissing.of() + private var sessionId: JsonField<String> = JsonMissing.of() + private var sessionName: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(run: Run) = apply { + createdAt = run.createdAt + runId = run.runId + shareToken = run.shareToken + type = run.type + runName = run.runName + runType = run.runType + sessionId = run.sessionId + sessionName = run.sessionName + additionalProperties = run.additionalProperties.toMutableMap() + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { + this.createdAt = createdAt + } + + fun runId(runId: String) = runId(JsonField.of(runId)) + + /** + * Sets [Builder.runId] to an arbitrary JSON value. + * + * You should usually call [Builder.runId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun runId(runId: JsonField<String>) = apply { this.runId = runId } + + fun shareToken(shareToken: String) = shareToken(JsonField.of(shareToken)) + + /** + * Sets [Builder.shareToken] to an arbitrary JSON value. + * + * You should usually call [Builder.shareToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun shareToken(shareToken: JsonField<String>) = apply { + this.shareToken = shareToken + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("run") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun runName(runName: String?) = runName(JsonField.ofNullable(runName)) + + /** Alias for calling [Builder.runName] with `runName.orElse(null)`. */ + fun runName(runName: Optional<String>) = runName(runName.getOrNull()) + + /** + * Sets [Builder.runName] to an arbitrary JSON value. + * + * You should usually call [Builder.runName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun runName(runName: JsonField<String>) = apply { this.runName = runName } + + fun runType(runType: String?) = runType(JsonField.ofNullable(runType)) + + /** Alias for calling [Builder.runType] with `runType.orElse(null)`. */ + fun runType(runType: Optional<String>) = runType(runType.getOrNull()) + + /** + * Sets [Builder.runType] to an arbitrary JSON value. + * + * You should usually call [Builder.runType] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun runType(runType: JsonField<String>) = apply { this.runType = runType } + + fun sessionId(sessionId: String?) = sessionId(JsonField.ofNullable(sessionId)) + + /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ + fun sessionId(sessionId: Optional<String>) = sessionId(sessionId.getOrNull()) + + /** + * Sets [Builder.sessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun sessionId(sessionId: JsonField<String>) = apply { this.sessionId = sessionId } + + fun sessionName(sessionName: String?) = + sessionName(JsonField.ofNullable(sessionName)) + + /** Alias for calling [Builder.sessionName] with `sessionName.orElse(null)`. */ + fun sessionName(sessionName: Optional<String>) = + sessionName(sessionName.getOrNull()) + + /** + * Sets [Builder.sessionName] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun sessionName(sessionName: JsonField<String>) = apply { + this.sessionName = sessionName + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Run]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .createdAt() + * .runId() + * .shareToken() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Run = + Run( + checkRequired("createdAt", createdAt), + checkRequired("runId", runId), + checkRequired("shareToken", shareToken), + type, + runName, + runType, + sessionId, + sessionName, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Run = apply { + if (validated) { + return@apply + } + + createdAt() + runId() + shareToken() + _type().let { + if (it != JsonValue.from("run")) { + throw LangsmithApiInvalidDataException("'type' is invalid, received $it") + } + } + runName() + runType() + sessionId() + sessionName() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (runId.asKnown().isPresent) 1 else 0) + + (if (shareToken.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("run")) 1 else 0 } + + (if (runName.asKnown().isPresent) 1 else 0) + + (if (runType.asKnown().isPresent) 1 else 0) + + (if (sessionId.asKnown().isPresent) 1 else 0) + + (if (sessionName.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Run && + createdAt == other.createdAt && + runId == other.runId && + shareToken == other.shareToken && + type == other.type && + runName == other.runName && + runType == other.runType && + sessionId == other.sessionId && + sessionName == other.sessionName && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + createdAt, + runId, + shareToken, + type, + runName, + runType, + sessionId, + sessionName, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Run{createdAt=$createdAt, runId=$runId, shareToken=$shareToken, type=$type, runName=$runName, runType=$runType, sessionId=$sessionId, sessionName=$sessionName, additionalProperties=$additionalProperties}" + } + + class Dataset + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val createdAt: JsonField<OffsetDateTime>, + private val datasetId: JsonField<String>, + private val shareToken: JsonField<String>, + private val type: JsonValue, + private val datasetName: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("dataset_id") + @ExcludeMissing + datasetId: JsonField<String> = JsonMissing.of(), + @JsonProperty("share_token") + @ExcludeMissing + shareToken: JsonField<String> = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("dataset_name") + @ExcludeMissing + datasetName: JsonField<String> = JsonMissing.of(), + ) : this(createdAt, datasetId, shareToken, type, datasetName, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun datasetId(): String = datasetId.getRequired("dataset_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun shareToken(): String = shareToken.getRequired("share_token") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("dataset") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun datasetName(): Optional<String> = datasetName.getOptional("dataset_name") + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [datasetId]. + * + * Unlike [datasetId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dataset_id") + @ExcludeMissing + fun _datasetId(): JsonField<String> = datasetId + + /** + * Returns the raw JSON value of [shareToken]. + * + * Unlike [shareToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("share_token") + @ExcludeMissing + fun _shareToken(): JsonField<String> = shareToken + + /** + * Returns the raw JSON value of [datasetName]. + * + * Unlike [datasetName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dataset_name") + @ExcludeMissing + fun _datasetName(): JsonField<String> = datasetName + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Dataset]. + * + * The following fields are required: + * ```java + * .createdAt() + * .datasetId() + * .shareToken() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Dataset]. */ + class Builder internal constructor() { + + private var createdAt: JsonField<OffsetDateTime>? = null + private var datasetId: JsonField<String>? = null + private var shareToken: JsonField<String>? = null + private var type: JsonValue = JsonValue.from("dataset") + private var datasetName: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(dataset: Dataset) = apply { + createdAt = dataset.createdAt + datasetId = dataset.datasetId + shareToken = dataset.shareToken + type = dataset.type + datasetName = dataset.datasetName + additionalProperties = dataset.additionalProperties.toMutableMap() + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { + this.createdAt = createdAt + } + + fun datasetId(datasetId: String) = datasetId(JsonField.of(datasetId)) + + /** + * Sets [Builder.datasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun datasetId(datasetId: JsonField<String>) = apply { this.datasetId = datasetId } + + fun shareToken(shareToken: String) = shareToken(JsonField.of(shareToken)) + + /** + * Sets [Builder.shareToken] to an arbitrary JSON value. + * + * You should usually call [Builder.shareToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun shareToken(shareToken: JsonField<String>) = apply { + this.shareToken = shareToken + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("dataset") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun datasetName(datasetName: String?) = + datasetName(JsonField.ofNullable(datasetName)) + + /** Alias for calling [Builder.datasetName] with `datasetName.orElse(null)`. */ + fun datasetName(datasetName: Optional<String>) = + datasetName(datasetName.getOrNull()) + + /** + * Sets [Builder.datasetName] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun datasetName(datasetName: JsonField<String>) = apply { + this.datasetName = datasetName + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Dataset]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .createdAt() + * .datasetId() + * .shareToken() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Dataset = + Dataset( + checkRequired("createdAt", createdAt), + checkRequired("datasetId", datasetId), + checkRequired("shareToken", shareToken), + type, + datasetName, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Dataset = apply { + if (validated) { + return@apply + } + + createdAt() + datasetId() + shareToken() + _type().let { + if (it != JsonValue.from("dataset")) { + throw LangsmithApiInvalidDataException("'type' is invalid, received $it") + } + } + datasetName() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (datasetId.asKnown().isPresent) 1 else 0) + + (if (shareToken.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("dataset")) 1 else 0 } + + (if (datasetName.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Dataset && + createdAt == other.createdAt && + datasetId == other.datasetId && + shareToken == other.shareToken && + type == other.type && + datasetName == other.datasetName && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + createdAt, + datasetId, + shareToken, + type, + datasetName, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Dataset{createdAt=$createdAt, datasetId=$datasetId, shareToken=$shareToken, type=$type, datasetName=$datasetName, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SharedListResponse && + entities == other.entities && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(entities, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SharedListResponse{entities=$entities, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/Resource.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/Resource.kt new file mode 100644 index 00000000..ac5ecd29 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/Resource.kt @@ -0,0 +1,251 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.taggings + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class Resource +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val resourceId: JsonField<String>, + private val resourceName: JsonField<String>, + private val taggingId: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("resource_id") + @ExcludeMissing + resourceId: JsonField<String> = JsonMissing.of(), + @JsonProperty("resource_name") + @ExcludeMissing + resourceName: JsonField<String> = JsonMissing.of(), + @JsonProperty("tagging_id") @ExcludeMissing taggingId: JsonField<String> = JsonMissing.of(), + ) : this(resourceId, resourceName, taggingId, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun resourceId(): String = resourceId.getRequired("resource_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun resourceName(): String = resourceName.getRequired("resource_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun taggingId(): String = taggingId.getRequired("tagging_id") + + /** + * Returns the raw JSON value of [resourceId]. + * + * Unlike [resourceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("resource_id") @ExcludeMissing fun _resourceId(): JsonField<String> = resourceId + + /** + * Returns the raw JSON value of [resourceName]. + * + * Unlike [resourceName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("resource_name") + @ExcludeMissing + fun _resourceName(): JsonField<String> = resourceName + + /** + * Returns the raw JSON value of [taggingId]. + * + * Unlike [taggingId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tagging_id") @ExcludeMissing fun _taggingId(): JsonField<String> = taggingId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Resource]. + * + * The following fields are required: + * ```java + * .resourceId() + * .resourceName() + * .taggingId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Resource]. */ + class Builder internal constructor() { + + private var resourceId: JsonField<String>? = null + private var resourceName: JsonField<String>? = null + private var taggingId: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(resource: Resource) = apply { + resourceId = resource.resourceId + resourceName = resource.resourceName + taggingId = resource.taggingId + additionalProperties = resource.additionalProperties.toMutableMap() + } + + fun resourceId(resourceId: String) = resourceId(JsonField.of(resourceId)) + + /** + * Sets [Builder.resourceId] to an arbitrary JSON value. + * + * You should usually call [Builder.resourceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun resourceId(resourceId: JsonField<String>) = apply { this.resourceId = resourceId } + + fun resourceName(resourceName: String) = resourceName(JsonField.of(resourceName)) + + /** + * Sets [Builder.resourceName] to an arbitrary JSON value. + * + * You should usually call [Builder.resourceName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun resourceName(resourceName: JsonField<String>) = apply { + this.resourceName = resourceName + } + + fun taggingId(taggingId: String) = taggingId(JsonField.of(taggingId)) + + /** + * Sets [Builder.taggingId] to an arbitrary JSON value. + * + * You should usually call [Builder.taggingId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun taggingId(taggingId: JsonField<String>) = apply { this.taggingId = taggingId } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Resource]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .resourceId() + * .resourceName() + * .taggingId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Resource = + Resource( + checkRequired("resourceId", resourceId), + checkRequired("resourceName", resourceName), + checkRequired("taggingId", taggingId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Resource = apply { + if (validated) { + return@apply + } + + resourceId() + resourceName() + taggingId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (resourceId.asKnown().isPresent) 1 else 0) + + (if (resourceName.asKnown().isPresent) 1 else 0) + + (if (taggingId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Resource && + resourceId == other.resourceId && + resourceName == other.resourceName && + taggingId == other.taggingId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(resourceId, resourceName, taggingId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Resource{resourceId=$resourceId, resourceName=$resourceName, taggingId=$taggingId, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/Tagging.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/Tagging.kt new file mode 100644 index 00000000..56710cff --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/Tagging.kt @@ -0,0 +1,327 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.taggings + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.workspaces.current.tags.ResourceType +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class Tagging +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val resourceId: JsonField<String>, + private val resourceType: JsonField<ResourceType>, + private val tagValueId: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("resource_id") + @ExcludeMissing + resourceId: JsonField<String> = JsonMissing.of(), + @JsonProperty("resource_type") + @ExcludeMissing + resourceType: JsonField<ResourceType> = JsonMissing.of(), + @JsonProperty("tag_value_id") + @ExcludeMissing + tagValueId: JsonField<String> = JsonMissing.of(), + ) : this(id, createdAt, resourceId, resourceType, tagValueId, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun resourceId(): String = resourceId.getRequired("resource_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun resourceType(): ResourceType = resourceType.getRequired("resource_type") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tagValueId(): String = tagValueId.getRequired("tag_value_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [resourceId]. + * + * Unlike [resourceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("resource_id") @ExcludeMissing fun _resourceId(): JsonField<String> = resourceId + + /** + * Returns the raw JSON value of [resourceType]. + * + * Unlike [resourceType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("resource_type") + @ExcludeMissing + fun _resourceType(): JsonField<ResourceType> = resourceType + + /** + * Returns the raw JSON value of [tagValueId]. + * + * Unlike [tagValueId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tag_value_id") @ExcludeMissing fun _tagValueId(): JsonField<String> = tagValueId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tagging]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .resourceId() + * .resourceType() + * .tagValueId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tagging]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var createdAt: JsonField<OffsetDateTime>? = null + private var resourceId: JsonField<String>? = null + private var resourceType: JsonField<ResourceType>? = null + private var tagValueId: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(tagging: Tagging) = apply { + id = tagging.id + createdAt = tagging.createdAt + resourceId = tagging.resourceId + resourceType = tagging.resourceType + tagValueId = tagging.tagValueId + additionalProperties = tagging.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun resourceId(resourceId: String) = resourceId(JsonField.of(resourceId)) + + /** + * Sets [Builder.resourceId] to an arbitrary JSON value. + * + * You should usually call [Builder.resourceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun resourceId(resourceId: JsonField<String>) = apply { this.resourceId = resourceId } + + fun resourceType(resourceType: ResourceType) = resourceType(JsonField.of(resourceType)) + + /** + * Sets [Builder.resourceType] to an arbitrary JSON value. + * + * You should usually call [Builder.resourceType] with a well-typed [ResourceType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun resourceType(resourceType: JsonField<ResourceType>) = apply { + this.resourceType = resourceType + } + + fun tagValueId(tagValueId: String) = tagValueId(JsonField.of(tagValueId)) + + /** + * Sets [Builder.tagValueId] to an arbitrary JSON value. + * + * You should usually call [Builder.tagValueId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tagValueId(tagValueId: JsonField<String>) = apply { this.tagValueId = tagValueId } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tagging]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .resourceId() + * .resourceType() + * .tagValueId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tagging = + Tagging( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("resourceId", resourceId), + checkRequired("resourceType", resourceType), + checkRequired("tagValueId", tagValueId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tagging = apply { + if (validated) { + return@apply + } + + id() + createdAt() + resourceId() + resourceType().validate() + tagValueId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (resourceId.asKnown().isPresent) 1 else 0) + + (resourceType.asKnown().getOrNull()?.validity() ?: 0) + + (if (tagValueId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tagging && + id == other.id && + createdAt == other.createdAt && + resourceId == other.resourceId && + resourceType == other.resourceType && + tagValueId == other.tagValueId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, createdAt, resourceId, resourceType, tagValueId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tagging{id=$id, createdAt=$createdAt, resourceId=$resourceId, resourceType=$resourceType, tagValueId=$tagValueId, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingCreateParams.kt new file mode 100644 index 00000000..50380eb8 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingCreateParams.kt @@ -0,0 +1,558 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.taggings + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.workspaces.current.tags.ResourceType +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** Create Tagging */ +class TaggingCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun resourceId(): String = body.resourceId() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun resourceType(): ResourceType = body.resourceType() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tagValueId(): String = body.tagValueId() + + /** + * Returns the raw JSON value of [resourceId]. + * + * Unlike [resourceId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _resourceId(): JsonField<String> = body._resourceId() + + /** + * Returns the raw JSON value of [resourceType]. + * + * Unlike [resourceType], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _resourceType(): JsonField<ResourceType> = body._resourceType() + + /** + * Returns the raw JSON value of [tagValueId]. + * + * Unlike [tagValueId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _tagValueId(): JsonField<String> = body._tagValueId() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TaggingCreateParams]. + * + * The following fields are required: + * ```java + * .resourceId() + * .resourceType() + * .tagValueId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TaggingCreateParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(taggingCreateParams: TaggingCreateParams) = apply { + body = taggingCreateParams.body.toBuilder() + additionalHeaders = taggingCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = taggingCreateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [resourceId] + * - [resourceType] + * - [tagValueId] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun resourceId(resourceId: String) = apply { body.resourceId(resourceId) } + + /** + * Sets [Builder.resourceId] to an arbitrary JSON value. + * + * You should usually call [Builder.resourceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun resourceId(resourceId: JsonField<String>) = apply { body.resourceId(resourceId) } + + fun resourceType(resourceType: ResourceType) = apply { body.resourceType(resourceType) } + + /** + * Sets [Builder.resourceType] to an arbitrary JSON value. + * + * You should usually call [Builder.resourceType] with a well-typed [ResourceType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun resourceType(resourceType: JsonField<ResourceType>) = apply { + body.resourceType(resourceType) + } + + fun tagValueId(tagValueId: String) = apply { body.tagValueId(tagValueId) } + + /** + * Sets [Builder.tagValueId] to an arbitrary JSON value. + * + * You should usually call [Builder.tagValueId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tagValueId(tagValueId: JsonField<String>) = apply { body.tagValueId(tagValueId) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TaggingCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .resourceId() + * .resourceType() + * .tagValueId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TaggingCreateParams = + TaggingCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val resourceId: JsonField<String>, + private val resourceType: JsonField<ResourceType>, + private val tagValueId: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("resource_id") + @ExcludeMissing + resourceId: JsonField<String> = JsonMissing.of(), + @JsonProperty("resource_type") + @ExcludeMissing + resourceType: JsonField<ResourceType> = JsonMissing.of(), + @JsonProperty("tag_value_id") + @ExcludeMissing + tagValueId: JsonField<String> = JsonMissing.of(), + ) : this(resourceId, resourceType, tagValueId, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun resourceId(): String = resourceId.getRequired("resource_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun resourceType(): ResourceType = resourceType.getRequired("resource_type") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tagValueId(): String = tagValueId.getRequired("tag_value_id") + + /** + * Returns the raw JSON value of [resourceId]. + * + * Unlike [resourceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("resource_id") + @ExcludeMissing + fun _resourceId(): JsonField<String> = resourceId + + /** + * Returns the raw JSON value of [resourceType]. + * + * Unlike [resourceType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("resource_type") + @ExcludeMissing + fun _resourceType(): JsonField<ResourceType> = resourceType + + /** + * Returns the raw JSON value of [tagValueId]. + * + * Unlike [tagValueId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tag_value_id") + @ExcludeMissing + fun _tagValueId(): JsonField<String> = tagValueId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .resourceId() + * .resourceType() + * .tagValueId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var resourceId: JsonField<String>? = null + private var resourceType: JsonField<ResourceType>? = null + private var tagValueId: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + resourceId = body.resourceId + resourceType = body.resourceType + tagValueId = body.tagValueId + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun resourceId(resourceId: String) = resourceId(JsonField.of(resourceId)) + + /** + * Sets [Builder.resourceId] to an arbitrary JSON value. + * + * You should usually call [Builder.resourceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun resourceId(resourceId: JsonField<String>) = apply { this.resourceId = resourceId } + + fun resourceType(resourceType: ResourceType) = resourceType(JsonField.of(resourceType)) + + /** + * Sets [Builder.resourceType] to an arbitrary JSON value. + * + * You should usually call [Builder.resourceType] with a well-typed [ResourceType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun resourceType(resourceType: JsonField<ResourceType>) = apply { + this.resourceType = resourceType + } + + fun tagValueId(tagValueId: String) = tagValueId(JsonField.of(tagValueId)) + + /** + * Sets [Builder.tagValueId] to an arbitrary JSON value. + * + * You should usually call [Builder.tagValueId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tagValueId(tagValueId: JsonField<String>) = apply { this.tagValueId = tagValueId } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .resourceId() + * .resourceType() + * .tagValueId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("resourceId", resourceId), + checkRequired("resourceType", resourceType), + checkRequired("tagValueId", tagValueId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + resourceId() + resourceType().validate() + tagValueId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (resourceId.asKnown().isPresent) 1 else 0) + + (resourceType.asKnown().getOrNull()?.validity() ?: 0) + + (if (tagValueId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + resourceId == other.resourceId && + resourceType == other.resourceType && + tagValueId == other.tagValueId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(resourceId, resourceType, tagValueId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{resourceId=$resourceId, resourceType=$resourceType, tagValueId=$tagValueId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TaggingCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TaggingCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingDeleteParams.kt new file mode 100644 index 00000000..0c5b44eb --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingDeleteParams.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.taggings + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete Tagging */ +class TaggingDeleteParams +private constructor( + private val taggingId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun taggingId(): Optional<String> = Optional.ofNullable(taggingId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): TaggingDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [TaggingDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TaggingDeleteParams]. */ + class Builder internal constructor() { + + private var taggingId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(taggingDeleteParams: TaggingDeleteParams) = apply { + taggingId = taggingDeleteParams.taggingId + additionalHeaders = taggingDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = taggingDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = taggingDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun taggingId(taggingId: String?) = apply { this.taggingId = taggingId } + + /** Alias for calling [Builder.taggingId] with `taggingId.orElse(null)`. */ + fun taggingId(taggingId: Optional<String>) = taggingId(taggingId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [TaggingDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TaggingDeleteParams = + TaggingDeleteParams( + taggingId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> taggingId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TaggingDeleteParams && + taggingId == other.taggingId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(taggingId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "TaggingDeleteParams{taggingId=$taggingId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingDeleteResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingDeleteResponse.kt new file mode 100644 index 00000000..416560c8 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingDeleteResponse.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.taggings + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class TaggingDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [TaggingDeleteResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TaggingDeleteResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(taggingDeleteResponse: TaggingDeleteResponse) = apply { + additionalProperties = taggingDeleteResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TaggingDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TaggingDeleteResponse = + TaggingDeleteResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): TaggingDeleteResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TaggingDeleteResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "TaggingDeleteResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingListParams.kt new file mode 100644 index 00000000..db9684cc --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingListParams.kt @@ -0,0 +1,190 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.taggings + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** List Taggings */ +class TaggingListParams +private constructor( + private val tagValueId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun tagValueId(): Optional<String> = Optional.ofNullable(tagValueId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): TaggingListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [TaggingListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TaggingListParams]. */ + class Builder internal constructor() { + + private var tagValueId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(taggingListParams: TaggingListParams) = apply { + tagValueId = taggingListParams.tagValueId + additionalHeaders = taggingListParams.additionalHeaders.toBuilder() + additionalQueryParams = taggingListParams.additionalQueryParams.toBuilder() + } + + fun tagValueId(tagValueId: String?) = apply { this.tagValueId = tagValueId } + + /** Alias for calling [Builder.tagValueId] with `tagValueId.orElse(null)`. */ + fun tagValueId(tagValueId: Optional<String>) = tagValueId(tagValueId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TaggingListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TaggingListParams = + TaggingListParams(tagValueId, additionalHeaders.build(), additionalQueryParams.build()) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + tagValueId?.let { put("tag_value_id", it) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TaggingListParams && + tagValueId == other.tagValueId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(tagValueId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TaggingListParams{tagValueId=$tagValueId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingListResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingListResponse.kt new file mode 100644 index 00000000..28627ab8 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingListResponse.kt @@ -0,0 +1,794 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.taggings + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class TaggingListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val resources: JsonField<Resources>, + private val tagKey: JsonField<String>, + private val tagKeyId: JsonField<String>, + private val tagValue: JsonField<String>, + private val tagValueId: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("resources") + @ExcludeMissing + resources: JsonField<Resources> = JsonMissing.of(), + @JsonProperty("tag_key") @ExcludeMissing tagKey: JsonField<String> = JsonMissing.of(), + @JsonProperty("tag_key_id") @ExcludeMissing tagKeyId: JsonField<String> = JsonMissing.of(), + @JsonProperty("tag_value") @ExcludeMissing tagValue: JsonField<String> = JsonMissing.of(), + @JsonProperty("tag_value_id") + @ExcludeMissing + tagValueId: JsonField<String> = JsonMissing.of(), + ) : this(resources, tagKey, tagKeyId, tagValue, tagValueId, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun resources(): Resources = resources.getRequired("resources") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tagKey(): String = tagKey.getRequired("tag_key") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tagKeyId(): String = tagKeyId.getRequired("tag_key_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tagValue(): String = tagValue.getRequired("tag_value") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tagValueId(): String = tagValueId.getRequired("tag_value_id") + + /** + * Returns the raw JSON value of [resources]. + * + * Unlike [resources], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("resources") @ExcludeMissing fun _resources(): JsonField<Resources> = resources + + /** + * Returns the raw JSON value of [tagKey]. + * + * Unlike [tagKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tag_key") @ExcludeMissing fun _tagKey(): JsonField<String> = tagKey + + /** + * Returns the raw JSON value of [tagKeyId]. + * + * Unlike [tagKeyId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tag_key_id") @ExcludeMissing fun _tagKeyId(): JsonField<String> = tagKeyId + + /** + * Returns the raw JSON value of [tagValue]. + * + * Unlike [tagValue], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tag_value") @ExcludeMissing fun _tagValue(): JsonField<String> = tagValue + + /** + * Returns the raw JSON value of [tagValueId]. + * + * Unlike [tagValueId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tag_value_id") @ExcludeMissing fun _tagValueId(): JsonField<String> = tagValueId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TaggingListResponse]. + * + * The following fields are required: + * ```java + * .resources() + * .tagKey() + * .tagKeyId() + * .tagValue() + * .tagValueId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TaggingListResponse]. */ + class Builder internal constructor() { + + private var resources: JsonField<Resources>? = null + private var tagKey: JsonField<String>? = null + private var tagKeyId: JsonField<String>? = null + private var tagValue: JsonField<String>? = null + private var tagValueId: JsonField<String>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(taggingListResponse: TaggingListResponse) = apply { + resources = taggingListResponse.resources + tagKey = taggingListResponse.tagKey + tagKeyId = taggingListResponse.tagKeyId + tagValue = taggingListResponse.tagValue + tagValueId = taggingListResponse.tagValueId + additionalProperties = taggingListResponse.additionalProperties.toMutableMap() + } + + fun resources(resources: Resources) = resources(JsonField.of(resources)) + + /** + * Sets [Builder.resources] to an arbitrary JSON value. + * + * You should usually call [Builder.resources] with a well-typed [Resources] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun resources(resources: JsonField<Resources>) = apply { this.resources = resources } + + fun tagKey(tagKey: String) = tagKey(JsonField.of(tagKey)) + + /** + * Sets [Builder.tagKey] to an arbitrary JSON value. + * + * You should usually call [Builder.tagKey] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tagKey(tagKey: JsonField<String>) = apply { this.tagKey = tagKey } + + fun tagKeyId(tagKeyId: String) = tagKeyId(JsonField.of(tagKeyId)) + + /** + * Sets [Builder.tagKeyId] to an arbitrary JSON value. + * + * You should usually call [Builder.tagKeyId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tagKeyId(tagKeyId: JsonField<String>) = apply { this.tagKeyId = tagKeyId } + + fun tagValue(tagValue: String) = tagValue(JsonField.of(tagValue)) + + /** + * Sets [Builder.tagValue] to an arbitrary JSON value. + * + * You should usually call [Builder.tagValue] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tagValue(tagValue: JsonField<String>) = apply { this.tagValue = tagValue } + + fun tagValueId(tagValueId: String) = tagValueId(JsonField.of(tagValueId)) + + /** + * Sets [Builder.tagValueId] to an arbitrary JSON value. + * + * You should usually call [Builder.tagValueId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tagValueId(tagValueId: JsonField<String>) = apply { this.tagValueId = tagValueId } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TaggingListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .resources() + * .tagKey() + * .tagKeyId() + * .tagValue() + * .tagValueId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TaggingListResponse = + TaggingListResponse( + checkRequired("resources", resources), + checkRequired("tagKey", tagKey), + checkRequired("tagKeyId", tagKeyId), + checkRequired("tagValue", tagValue), + checkRequired("tagValueId", tagValueId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TaggingListResponse = apply { + if (validated) { + return@apply + } + + resources().validate() + tagKey() + tagKeyId() + tagValue() + tagValueId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (resources.asKnown().getOrNull()?.validity() ?: 0) + + (if (tagKey.asKnown().isPresent) 1 else 0) + + (if (tagKeyId.asKnown().isPresent) 1 else 0) + + (if (tagValue.asKnown().isPresent) 1 else 0) + + (if (tagValueId.asKnown().isPresent) 1 else 0) + + class Resources + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dashboards: JsonField<List<Resource>>, + private val datasets: JsonField<List<Resource>>, + private val deployments: JsonField<List<Resource>>, + private val experiments: JsonField<List<Resource>>, + private val projects: JsonField<List<Resource>>, + private val prompts: JsonField<List<Resource>>, + private val queues: JsonField<List<Resource>>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dashboards") + @ExcludeMissing + dashboards: JsonField<List<Resource>> = JsonMissing.of(), + @JsonProperty("datasets") + @ExcludeMissing + datasets: JsonField<List<Resource>> = JsonMissing.of(), + @JsonProperty("deployments") + @ExcludeMissing + deployments: JsonField<List<Resource>> = JsonMissing.of(), + @JsonProperty("experiments") + @ExcludeMissing + experiments: JsonField<List<Resource>> = JsonMissing.of(), + @JsonProperty("projects") + @ExcludeMissing + projects: JsonField<List<Resource>> = JsonMissing.of(), + @JsonProperty("prompts") + @ExcludeMissing + prompts: JsonField<List<Resource>> = JsonMissing.of(), + @JsonProperty("queues") + @ExcludeMissing + queues: JsonField<List<Resource>> = JsonMissing.of(), + ) : this( + dashboards, + datasets, + deployments, + experiments, + projects, + prompts, + queues, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun dashboards(): Optional<List<Resource>> = dashboards.getOptional("dashboards") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun datasets(): Optional<List<Resource>> = datasets.getOptional("datasets") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun deployments(): Optional<List<Resource>> = deployments.getOptional("deployments") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun experiments(): Optional<List<Resource>> = experiments.getOptional("experiments") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun projects(): Optional<List<Resource>> = projects.getOptional("projects") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun prompts(): Optional<List<Resource>> = prompts.getOptional("prompts") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun queues(): Optional<List<Resource>> = queues.getOptional("queues") + + /** + * Returns the raw JSON value of [dashboards]. + * + * Unlike [dashboards], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dashboards") + @ExcludeMissing + fun _dashboards(): JsonField<List<Resource>> = dashboards + + /** + * Returns the raw JSON value of [datasets]. + * + * Unlike [datasets], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("datasets") + @ExcludeMissing + fun _datasets(): JsonField<List<Resource>> = datasets + + /** + * Returns the raw JSON value of [deployments]. + * + * Unlike [deployments], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("deployments") + @ExcludeMissing + fun _deployments(): JsonField<List<Resource>> = deployments + + /** + * Returns the raw JSON value of [experiments]. + * + * Unlike [experiments], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("experiments") + @ExcludeMissing + fun _experiments(): JsonField<List<Resource>> = experiments + + /** + * Returns the raw JSON value of [projects]. + * + * Unlike [projects], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("projects") + @ExcludeMissing + fun _projects(): JsonField<List<Resource>> = projects + + /** + * Returns the raw JSON value of [prompts]. + * + * Unlike [prompts], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prompts") @ExcludeMissing fun _prompts(): JsonField<List<Resource>> = prompts + + /** + * Returns the raw JSON value of [queues]. + * + * Unlike [queues], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("queues") @ExcludeMissing fun _queues(): JsonField<List<Resource>> = queues + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Resources]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Resources]. */ + class Builder internal constructor() { + + private var dashboards: JsonField<MutableList<Resource>>? = null + private var datasets: JsonField<MutableList<Resource>>? = null + private var deployments: JsonField<MutableList<Resource>>? = null + private var experiments: JsonField<MutableList<Resource>>? = null + private var projects: JsonField<MutableList<Resource>>? = null + private var prompts: JsonField<MutableList<Resource>>? = null + private var queues: JsonField<MutableList<Resource>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(resources: Resources) = apply { + dashboards = resources.dashboards.map { it.toMutableList() } + datasets = resources.datasets.map { it.toMutableList() } + deployments = resources.deployments.map { it.toMutableList() } + experiments = resources.experiments.map { it.toMutableList() } + projects = resources.projects.map { it.toMutableList() } + prompts = resources.prompts.map { it.toMutableList() } + queues = resources.queues.map { it.toMutableList() } + additionalProperties = resources.additionalProperties.toMutableMap() + } + + fun dashboards(dashboards: List<Resource>) = dashboards(JsonField.of(dashboards)) + + /** + * Sets [Builder.dashboards] to an arbitrary JSON value. + * + * You should usually call [Builder.dashboards] with a well-typed `List<Resource>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dashboards(dashboards: JsonField<List<Resource>>) = apply { + this.dashboards = dashboards.map { it.toMutableList() } + } + + /** + * Adds a single [Resource] to [dashboards]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addDashboard(dashboard: Resource) = apply { + dashboards = + (dashboards ?: JsonField.of(mutableListOf())).also { + checkKnown("dashboards", it).add(dashboard) + } + } + + fun datasets(datasets: List<Resource>) = datasets(JsonField.of(datasets)) + + /** + * Sets [Builder.datasets] to an arbitrary JSON value. + * + * You should usually call [Builder.datasets] with a well-typed `List<Resource>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun datasets(datasets: JsonField<List<Resource>>) = apply { + this.datasets = datasets.map { it.toMutableList() } + } + + /** + * Adds a single [Resource] to [datasets]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addDataset(dataset: Resource) = apply { + datasets = + (datasets ?: JsonField.of(mutableListOf())).also { + checkKnown("datasets", it).add(dataset) + } + } + + fun deployments(deployments: List<Resource>) = deployments(JsonField.of(deployments)) + + /** + * Sets [Builder.deployments] to an arbitrary JSON value. + * + * You should usually call [Builder.deployments] with a well-typed `List<Resource>` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun deployments(deployments: JsonField<List<Resource>>) = apply { + this.deployments = deployments.map { it.toMutableList() } + } + + /** + * Adds a single [Resource] to [deployments]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addDeployment(deployment: Resource) = apply { + deployments = + (deployments ?: JsonField.of(mutableListOf())).also { + checkKnown("deployments", it).add(deployment) + } + } + + fun experiments(experiments: List<Resource>) = experiments(JsonField.of(experiments)) + + /** + * Sets [Builder.experiments] to an arbitrary JSON value. + * + * You should usually call [Builder.experiments] with a well-typed `List<Resource>` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun experiments(experiments: JsonField<List<Resource>>) = apply { + this.experiments = experiments.map { it.toMutableList() } + } + + /** + * Adds a single [Resource] to [experiments]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExperiment(experiment: Resource) = apply { + experiments = + (experiments ?: JsonField.of(mutableListOf())).also { + checkKnown("experiments", it).add(experiment) + } + } + + fun projects(projects: List<Resource>) = projects(JsonField.of(projects)) + + /** + * Sets [Builder.projects] to an arbitrary JSON value. + * + * You should usually call [Builder.projects] with a well-typed `List<Resource>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun projects(projects: JsonField<List<Resource>>) = apply { + this.projects = projects.map { it.toMutableList() } + } + + /** + * Adds a single [Resource] to [projects]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addProject(project: Resource) = apply { + projects = + (projects ?: JsonField.of(mutableListOf())).also { + checkKnown("projects", it).add(project) + } + } + + fun prompts(prompts: List<Resource>) = prompts(JsonField.of(prompts)) + + /** + * Sets [Builder.prompts] to an arbitrary JSON value. + * + * You should usually call [Builder.prompts] with a well-typed `List<Resource>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun prompts(prompts: JsonField<List<Resource>>) = apply { + this.prompts = prompts.map { it.toMutableList() } + } + + /** + * Adds a single [Resource] to [prompts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPrompt(prompt: Resource) = apply { + prompts = + (prompts ?: JsonField.of(mutableListOf())).also { + checkKnown("prompts", it).add(prompt) + } + } + + fun queues(queues: List<Resource>) = queues(JsonField.of(queues)) + + /** + * Sets [Builder.queues] to an arbitrary JSON value. + * + * You should usually call [Builder.queues] with a well-typed `List<Resource>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun queues(queues: JsonField<List<Resource>>) = apply { + this.queues = queues.map { it.toMutableList() } + } + + /** + * Adds a single [Resource] to [queues]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addQueue(queue: Resource) = apply { + queues = + (queues ?: JsonField.of(mutableListOf())).also { + checkKnown("queues", it).add(queue) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Resources]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Resources = + Resources( + (dashboards ?: JsonMissing.of()).map { it.toImmutable() }, + (datasets ?: JsonMissing.of()).map { it.toImmutable() }, + (deployments ?: JsonMissing.of()).map { it.toImmutable() }, + (experiments ?: JsonMissing.of()).map { it.toImmutable() }, + (projects ?: JsonMissing.of()).map { it.toImmutable() }, + (prompts ?: JsonMissing.of()).map { it.toImmutable() }, + (queues ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Resources = apply { + if (validated) { + return@apply + } + + dashboards().ifPresent { it.forEach { it.validate() } } + datasets().ifPresent { it.forEach { it.validate() } } + deployments().ifPresent { it.forEach { it.validate() } } + experiments().ifPresent { it.forEach { it.validate() } } + projects().ifPresent { it.forEach { it.validate() } } + prompts().ifPresent { it.forEach { it.validate() } } + queues().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dashboards.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (datasets.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (deployments.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (experiments.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (projects.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (prompts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (queues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Resources && + dashboards == other.dashboards && + datasets == other.datasets && + deployments == other.deployments && + experiments == other.experiments && + projects == other.projects && + prompts == other.prompts && + queues == other.queues && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + dashboards, + datasets, + deployments, + experiments, + projects, + prompts, + queues, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Resources{dashboards=$dashboards, datasets=$datasets, deployments=$deployments, experiments=$experiments, projects=$projects, prompts=$prompts, queues=$queues, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TaggingListResponse && + resources == other.resources && + tagKey == other.tagKey && + tagKeyId == other.tagKeyId && + tagValue == other.tagValue && + tagValueId == other.tagValueId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(resources, tagKey, tagKeyId, tagValue, tagValueId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TaggingListResponse{resources=$resources, tagKey=$tagKey, tagKeyId=$tagKeyId, tagValue=$tagValue, tagValueId=$tagValueId, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKey.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKey.kt new file mode 100644 index 00000000..7c888b2c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKey.kt @@ -0,0 +1,323 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class TagKey +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val key: JsonField<String>, + private val updatedAt: JsonField<OffsetDateTime>, + private val description: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("key") @ExcludeMissing key: JsonField<String> = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + ) : this(id, createdAt, key, updatedAt, description, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun key(): String = key.getRequired("key") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updatedAt(): OffsetDateTime = updatedAt.getRequired("updated_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [key]. + * + * Unlike [key], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("key") @ExcludeMissing fun _key(): JsonField<String> = key + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField<OffsetDateTime> = updatedAt + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField<String> = description + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TagKey]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .key() + * .updatedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TagKey]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var createdAt: JsonField<OffsetDateTime>? = null + private var key: JsonField<String>? = null + private var updatedAt: JsonField<OffsetDateTime>? = null + private var description: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(tagKey: TagKey) = apply { + id = tagKey.id + createdAt = tagKey.createdAt + key = tagKey.key + updatedAt = tagKey.updatedAt + description = tagKey.description + additionalProperties = tagKey.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun key(key: String) = key(JsonField.of(key)) + + /** + * Sets [Builder.key] to an arbitrary JSON value. + * + * You should usually call [Builder.key] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun key(key: JsonField<String>) = apply { this.key = key } + + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField<OffsetDateTime>) = apply { this.updatedAt = updatedAt } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { this.description = description } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TagKey]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .key() + * .updatedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TagKey = + TagKey( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("key", key), + checkRequired("updatedAt", updatedAt), + description, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TagKey = apply { + if (validated) { + return@apply + } + + id() + createdAt() + key() + updatedAt() + description() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (key.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TagKey && + id == other.id && + createdAt == other.createdAt && + key == other.key && + updatedAt == other.updatedAt && + description == other.description && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, createdAt, key, updatedAt, description, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TagKey{id=$id, createdAt=$createdAt, key=$key, updatedAt=$updatedAt, description=$description, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyDeleteParams.kt new file mode 100644 index 00000000..8c0caad4 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyDeleteParams.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete Tag Key */ +class TagKeyDeleteParams +private constructor( + private val tagKeyId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun tagKeyId(): Optional<String> = Optional.ofNullable(tagKeyId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): TagKeyDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [TagKeyDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TagKeyDeleteParams]. */ + class Builder internal constructor() { + + private var tagKeyId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(tagKeyDeleteParams: TagKeyDeleteParams) = apply { + tagKeyId = tagKeyDeleteParams.tagKeyId + additionalHeaders = tagKeyDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = tagKeyDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = tagKeyDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun tagKeyId(tagKeyId: String?) = apply { this.tagKeyId = tagKeyId } + + /** Alias for calling [Builder.tagKeyId] with `tagKeyId.orElse(null)`. */ + fun tagKeyId(tagKeyId: Optional<String>) = tagKeyId(tagKeyId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [TagKeyDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TagKeyDeleteParams = + TagKeyDeleteParams( + tagKeyId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> tagKeyId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TagKeyDeleteParams && + tagKeyId == other.tagKeyId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(tagKeyId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "TagKeyDeleteParams{tagKeyId=$tagKeyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyDeleteResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyDeleteResponse.kt new file mode 100644 index 00000000..ba71a092 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyDeleteResponse.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class TagKeyDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [TagKeyDeleteResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TagKeyDeleteResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(tagKeyDeleteResponse: TagKeyDeleteResponse) = apply { + additionalProperties = tagKeyDeleteResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TagKeyDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TagKeyDeleteResponse = + TagKeyDeleteResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): TagKeyDeleteResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TagKeyDeleteResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "TagKeyDeleteResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyRetrieveParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyRetrieveParams.kt new file mode 100644 index 00000000..bf8d2f71 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyRetrieveParams.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get Tag Key */ +class TagKeyRetrieveParams +private constructor( + private val tagKeyId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun tagKeyId(): Optional<String> = Optional.ofNullable(tagKeyId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): TagKeyRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [TagKeyRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TagKeyRetrieveParams]. */ + class Builder internal constructor() { + + private var tagKeyId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(tagKeyRetrieveParams: TagKeyRetrieveParams) = apply { + tagKeyId = tagKeyRetrieveParams.tagKeyId + additionalHeaders = tagKeyRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = tagKeyRetrieveParams.additionalQueryParams.toBuilder() + } + + fun tagKeyId(tagKeyId: String?) = apply { this.tagKeyId = tagKeyId } + + /** Alias for calling [Builder.tagKeyId] with `tagKeyId.orElse(null)`. */ + fun tagKeyId(tagKeyId: Optional<String>) = tagKeyId(tagKeyId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TagKeyRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TagKeyRetrieveParams = + TagKeyRetrieveParams(tagKeyId, additionalHeaders.build(), additionalQueryParams.build()) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> tagKeyId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TagKeyRetrieveParams && + tagKeyId == other.tagKeyId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(tagKeyId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TagKeyRetrieveParams{tagKeyId=$tagKeyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyRetrieveTagKeysParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyRetrieveTagKeysParams.kt new file mode 100644 index 00000000..85a6ff6d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyRetrieveTagKeysParams.kt @@ -0,0 +1,172 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** List Tag Keys */ +class TagKeyRetrieveTagKeysParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): TagKeyRetrieveTagKeysParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [TagKeyRetrieveTagKeysParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TagKeyRetrieveTagKeysParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(tagKeyRetrieveTagKeysParams: TagKeyRetrieveTagKeysParams) = apply { + additionalHeaders = tagKeyRetrieveTagKeysParams.additionalHeaders.toBuilder() + additionalQueryParams = tagKeyRetrieveTagKeysParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TagKeyRetrieveTagKeysParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TagKeyRetrieveTagKeysParams = + TagKeyRetrieveTagKeysParams(additionalHeaders.build(), additionalQueryParams.build()) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TagKeyRetrieveTagKeysParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "TagKeyRetrieveTagKeysParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyTagKeysParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyTagKeysParams.kt new file mode 100644 index 00000000..df7c984d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyTagKeysParams.kt @@ -0,0 +1,481 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create Tag Key */ +class TagKeyTagKeysParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun key(): String = body.key() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = body.description() + + /** + * Returns the raw JSON value of [key]. + * + * Unlike [key], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _key(): JsonField<String> = body._key() + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _description(): JsonField<String> = body._description() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TagKeyTagKeysParams]. + * + * The following fields are required: + * ```java + * .key() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TagKeyTagKeysParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(tagKeyTagKeysParams: TagKeyTagKeysParams) = apply { + body = tagKeyTagKeysParams.body.toBuilder() + additionalHeaders = tagKeyTagKeysParams.additionalHeaders.toBuilder() + additionalQueryParams = tagKeyTagKeysParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [key] + * - [description] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun key(key: String) = apply { body.key(key) } + + /** + * Sets [Builder.key] to an arbitrary JSON value. + * + * You should usually call [Builder.key] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun key(key: JsonField<String>) = apply { body.key(key) } + + fun description(description: String?) = apply { body.description(description) } + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { body.description(description) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TagKeyTagKeysParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .key() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TagKeyTagKeysParams = + TagKeyTagKeysParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val key: JsonField<String>, + private val description: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("key") @ExcludeMissing key: JsonField<String> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + ) : this(key, description, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun key(): String = key.getRequired("key") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + /** + * Returns the raw JSON value of [key]. + * + * Unlike [key], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("key") @ExcludeMissing fun _key(): JsonField<String> = key + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField<String> = description + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .key() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var key: JsonField<String>? = null + private var description: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + key = body.key + description = body.description + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun key(key: String) = key(JsonField.of(key)) + + /** + * Sets [Builder.key] to an arbitrary JSON value. + * + * You should usually call [Builder.key] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun key(key: JsonField<String>) = apply { this.key = key } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField<String>) = apply { + this.description = description + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .key() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body(checkRequired("key", key), description, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + key() + description() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (key.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + key == other.key && + description == other.description && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(key, description, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{key=$key, description=$description, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TagKeyTagKeysParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TagKeyTagKeysParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyUpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyUpdateParams.kt new file mode 100644 index 00000000..9589e0eb --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyUpdateParams.kt @@ -0,0 +1,478 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Update Tag Key */ +class TagKeyUpdateParams +private constructor( + private val tagKeyId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun tagKeyId(): Optional<String> = Optional.ofNullable(tagKeyId) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = body.description() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun key(): Optional<String> = body.key() + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _description(): JsonField<String> = body._description() + + /** + * Returns the raw JSON value of [key]. + * + * Unlike [key], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _key(): JsonField<String> = body._key() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): TagKeyUpdateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [TagKeyUpdateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TagKeyUpdateParams]. */ + class Builder internal constructor() { + + private var tagKeyId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(tagKeyUpdateParams: TagKeyUpdateParams) = apply { + tagKeyId = tagKeyUpdateParams.tagKeyId + body = tagKeyUpdateParams.body.toBuilder() + additionalHeaders = tagKeyUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = tagKeyUpdateParams.additionalQueryParams.toBuilder() + } + + fun tagKeyId(tagKeyId: String?) = apply { this.tagKeyId = tagKeyId } + + /** Alias for calling [Builder.tagKeyId] with `tagKeyId.orElse(null)`. */ + fun tagKeyId(tagKeyId: Optional<String>) = tagKeyId(tagKeyId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [description] + * - [key] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun description(description: String?) = apply { body.description(description) } + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { body.description(description) } + + fun key(key: String?) = apply { body.key(key) } + + /** Alias for calling [Builder.key] with `key.orElse(null)`. */ + fun key(key: Optional<String>) = key(key.getOrNull()) + + /** + * Sets [Builder.key] to an arbitrary JSON value. + * + * You should usually call [Builder.key] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun key(key: JsonField<String>) = apply { body.key(key) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TagKeyUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TagKeyUpdateParams = + TagKeyUpdateParams( + tagKeyId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> tagKeyId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val description: JsonField<String>, + private val key: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("key") @ExcludeMissing key: JsonField<String> = JsonMissing.of(), + ) : this(description, key, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun key(): Optional<String> = key.getOptional("key") + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [key]. + * + * Unlike [key], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("key") @ExcludeMissing fun _key(): JsonField<String> = key + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var description: JsonField<String> = JsonMissing.of() + private var key: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + description = body.description + key = body.key + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField<String>) = apply { + this.description = description + } + + fun key(key: String?) = key(JsonField.ofNullable(key)) + + /** Alias for calling [Builder.key] with `key.orElse(null)`. */ + fun key(key: Optional<String>) = key(key.getOrNull()) + + /** + * Sets [Builder.key] to an arbitrary JSON value. + * + * You should usually call [Builder.key] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun key(key: JsonField<String>) = apply { this.key = key } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = Body(description, key, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + description() + key() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (description.asKnown().isPresent) 1 else 0) + + (if (key.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + description == other.description && + key == other.key && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(description, key, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{description=$description, key=$key, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TagKeyUpdateParams && + tagKeyId == other.tagKeyId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(tagKeyId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TagKeyUpdateParams{tagKeyId=$tagKeyId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValue.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValue.kt new file mode 100644 index 00000000..855c8aa2 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValue.kt @@ -0,0 +1,356 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class TagValue +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val tagKeyId: JsonField<String>, + private val updatedAt: JsonField<OffsetDateTime>, + private val value: JsonField<String>, + private val description: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("tag_key_id") @ExcludeMissing tagKeyId: JsonField<String> = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField<String> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + ) : this(id, createdAt, tagKeyId, updatedAt, value, description, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tagKeyId(): String = tagKeyId.getRequired("tag_key_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updatedAt(): OffsetDateTime = updatedAt.getRequired("updated_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun value(): String = value.getRequired("value") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [tagKeyId]. + * + * Unlike [tagKeyId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tag_key_id") @ExcludeMissing fun _tagKeyId(): JsonField<String> = tagKeyId + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField<OffsetDateTime> = updatedAt + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField<String> = value + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField<String> = description + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TagValue]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .tagKeyId() + * .updatedAt() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TagValue]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var createdAt: JsonField<OffsetDateTime>? = null + private var tagKeyId: JsonField<String>? = null + private var updatedAt: JsonField<OffsetDateTime>? = null + private var value: JsonField<String>? = null + private var description: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(tagValue: TagValue) = apply { + id = tagValue.id + createdAt = tagValue.createdAt + tagKeyId = tagValue.tagKeyId + updatedAt = tagValue.updatedAt + value = tagValue.value + description = tagValue.description + additionalProperties = tagValue.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun tagKeyId(tagKeyId: String) = tagKeyId(JsonField.of(tagKeyId)) + + /** + * Sets [Builder.tagKeyId] to an arbitrary JSON value. + * + * You should usually call [Builder.tagKeyId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tagKeyId(tagKeyId: JsonField<String>) = apply { this.tagKeyId = tagKeyId } + + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField<OffsetDateTime>) = apply { this.updatedAt = updatedAt } + + fun value(value: String) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun value(value: JsonField<String>) = apply { this.value = value } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { this.description = description } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TagValue]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .tagKeyId() + * .updatedAt() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TagValue = + TagValue( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("tagKeyId", tagKeyId), + checkRequired("updatedAt", updatedAt), + checkRequired("value", value), + description, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TagValue = apply { + if (validated) { + return@apply + } + + id() + createdAt() + tagKeyId() + updatedAt() + value() + description() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (tagKeyId.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (if (value.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TagValue && + id == other.id && + createdAt == other.createdAt && + tagKeyId == other.tagKeyId && + updatedAt == other.updatedAt && + value == other.value && + description == other.description && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, createdAt, tagKeyId, updatedAt, value, description, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TagValue{id=$id, createdAt=$createdAt, tagKeyId=$tagKeyId, updatedAt=$updatedAt, value=$value, description=$description, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueDeleteParams.kt new file mode 100644 index 00000000..a6585314 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueDeleteParams.kt @@ -0,0 +1,258 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete Tag Value */ +class TagValueDeleteParams +private constructor( + private val tagKeyId: String, + private val tagValueId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun tagKeyId(): String = tagKeyId + + fun tagValueId(): Optional<String> = Optional.ofNullable(tagValueId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TagValueDeleteParams]. + * + * The following fields are required: + * ```java + * .tagKeyId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TagValueDeleteParams]. */ + class Builder internal constructor() { + + private var tagKeyId: String? = null + private var tagValueId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(tagValueDeleteParams: TagValueDeleteParams) = apply { + tagKeyId = tagValueDeleteParams.tagKeyId + tagValueId = tagValueDeleteParams.tagValueId + additionalHeaders = tagValueDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = tagValueDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = tagValueDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun tagKeyId(tagKeyId: String) = apply { this.tagKeyId = tagKeyId } + + fun tagValueId(tagValueId: String?) = apply { this.tagValueId = tagValueId } + + /** Alias for calling [Builder.tagValueId] with `tagValueId.orElse(null)`. */ + fun tagValueId(tagValueId: Optional<String>) = tagValueId(tagValueId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [TagValueDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tagKeyId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TagValueDeleteParams = + TagValueDeleteParams( + checkRequired("tagKeyId", tagKeyId), + tagValueId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> tagKeyId + 1 -> tagValueId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TagValueDeleteParams && + tagKeyId == other.tagKeyId && + tagValueId == other.tagValueId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + tagKeyId, + tagValueId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "TagValueDeleteParams{tagKeyId=$tagKeyId, tagValueId=$tagValueId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueDeleteResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueDeleteResponse.kt new file mode 100644 index 00000000..ff92330b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueDeleteResponse.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class TagValueDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [TagValueDeleteResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TagValueDeleteResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(tagValueDeleteResponse: TagValueDeleteResponse) = apply { + additionalProperties = tagValueDeleteResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TagValueDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TagValueDeleteResponse = + TagValueDeleteResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): TagValueDeleteResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TagValueDeleteResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "TagValueDeleteResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueRetrieveParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueRetrieveParams.kt new file mode 100644 index 00000000..cdadde4b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueRetrieveParams.kt @@ -0,0 +1,217 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get Tag Value */ +class TagValueRetrieveParams +private constructor( + private val tagKeyId: String, + private val tagValueId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun tagKeyId(): String = tagKeyId + + fun tagValueId(): Optional<String> = Optional.ofNullable(tagValueId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TagValueRetrieveParams]. + * + * The following fields are required: + * ```java + * .tagKeyId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TagValueRetrieveParams]. */ + class Builder internal constructor() { + + private var tagKeyId: String? = null + private var tagValueId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(tagValueRetrieveParams: TagValueRetrieveParams) = apply { + tagKeyId = tagValueRetrieveParams.tagKeyId + tagValueId = tagValueRetrieveParams.tagValueId + additionalHeaders = tagValueRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = tagValueRetrieveParams.additionalQueryParams.toBuilder() + } + + fun tagKeyId(tagKeyId: String) = apply { this.tagKeyId = tagKeyId } + + fun tagValueId(tagValueId: String?) = apply { this.tagValueId = tagValueId } + + /** Alias for calling [Builder.tagValueId] with `tagValueId.orElse(null)`. */ + fun tagValueId(tagValueId: Optional<String>) = tagValueId(tagValueId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TagValueRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tagKeyId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TagValueRetrieveParams = + TagValueRetrieveParams( + checkRequired("tagKeyId", tagKeyId), + tagValueId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> tagKeyId + 1 -> tagValueId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TagValueRetrieveParams && + tagKeyId == other.tagKeyId && + tagValueId == other.tagValueId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(tagKeyId, tagValueId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TagValueRetrieveParams{tagKeyId=$tagKeyId, tagValueId=$tagValueId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueRetrieveTagValuesParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueRetrieveTagValuesParams.kt new file mode 100644 index 00000000..14019ce6 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueRetrieveTagValuesParams.kt @@ -0,0 +1,198 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** List Tag Values */ +class TagValueRetrieveTagValuesParams +private constructor( + private val tagKeyId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun tagKeyId(): Optional<String> = Optional.ofNullable(tagKeyId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): TagValueRetrieveTagValuesParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [TagValueRetrieveTagValuesParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TagValueRetrieveTagValuesParams]. */ + class Builder internal constructor() { + + private var tagKeyId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(tagValueRetrieveTagValuesParams: TagValueRetrieveTagValuesParams) = + apply { + tagKeyId = tagValueRetrieveTagValuesParams.tagKeyId + additionalHeaders = tagValueRetrieveTagValuesParams.additionalHeaders.toBuilder() + additionalQueryParams = + tagValueRetrieveTagValuesParams.additionalQueryParams.toBuilder() + } + + fun tagKeyId(tagKeyId: String?) = apply { this.tagKeyId = tagKeyId } + + /** Alias for calling [Builder.tagKeyId] with `tagKeyId.orElse(null)`. */ + fun tagKeyId(tagKeyId: Optional<String>) = tagKeyId(tagKeyId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TagValueRetrieveTagValuesParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TagValueRetrieveTagValuesParams = + TagValueRetrieveTagValuesParams( + tagKeyId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> tagKeyId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TagValueRetrieveTagValuesParams && + tagKeyId == other.tagKeyId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(tagKeyId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TagValueRetrieveTagValuesParams{tagKeyId=$tagKeyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueTagValuesParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueTagValuesParams.kt new file mode 100644 index 00000000..d66ea5ee --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueTagValuesParams.kt @@ -0,0 +1,504 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create Tag Value */ +class TagValueTagValuesParams +private constructor( + private val tagKeyId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun tagKeyId(): Optional<String> = Optional.ofNullable(tagKeyId) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun value(): String = body.value() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = body.description() + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _value(): JsonField<String> = body._value() + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _description(): JsonField<String> = body._description() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TagValueTagValuesParams]. + * + * The following fields are required: + * ```java + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TagValueTagValuesParams]. */ + class Builder internal constructor() { + + private var tagKeyId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(tagValueTagValuesParams: TagValueTagValuesParams) = apply { + tagKeyId = tagValueTagValuesParams.tagKeyId + body = tagValueTagValuesParams.body.toBuilder() + additionalHeaders = tagValueTagValuesParams.additionalHeaders.toBuilder() + additionalQueryParams = tagValueTagValuesParams.additionalQueryParams.toBuilder() + } + + fun tagKeyId(tagKeyId: String?) = apply { this.tagKeyId = tagKeyId } + + /** Alias for calling [Builder.tagKeyId] with `tagKeyId.orElse(null)`. */ + fun tagKeyId(tagKeyId: Optional<String>) = tagKeyId(tagKeyId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [value] + * - [description] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun value(value: String) = apply { body.value(value) } + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun value(value: JsonField<String>) = apply { body.value(value) } + + fun description(description: String?) = apply { body.description(description) } + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { body.description(description) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TagValueTagValuesParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TagValueTagValuesParams = + TagValueTagValuesParams( + tagKeyId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> tagKeyId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val value: JsonField<String>, + private val description: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("value") @ExcludeMissing value: JsonField<String> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + ) : this(value, description, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun value(): String = value.getRequired("value") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField<String> = value + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField<String> = description + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var value: JsonField<String>? = null + private var description: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + value = body.value + description = body.description + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun value(value: String) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun value(value: JsonField<String>) = apply { this.value = value } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField<String>) = apply { + this.description = description + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("value", value), + description, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + value() + description() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (value.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + value == other.value && + description == other.description && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(value, description, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{value=$value, description=$description, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TagValueTagValuesParams && + tagKeyId == other.tagKeyId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(tagKeyId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TagValueTagValuesParams{tagKeyId=$tagKeyId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueUpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueUpdateParams.kt new file mode 100644 index 00000000..9bc12891 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueUpdateParams.kt @@ -0,0 +1,501 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Update Tag Value */ +class TagValueUpdateParams +private constructor( + private val tagKeyId: String, + private val tagValueId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun tagKeyId(): String = tagKeyId + + fun tagValueId(): Optional<String> = Optional.ofNullable(tagValueId) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = body.description() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun value(): Optional<String> = body.value() + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _description(): JsonField<String> = body._description() + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _value(): JsonField<String> = body._value() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TagValueUpdateParams]. + * + * The following fields are required: + * ```java + * .tagKeyId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TagValueUpdateParams]. */ + class Builder internal constructor() { + + private var tagKeyId: String? = null + private var tagValueId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(tagValueUpdateParams: TagValueUpdateParams) = apply { + tagKeyId = tagValueUpdateParams.tagKeyId + tagValueId = tagValueUpdateParams.tagValueId + body = tagValueUpdateParams.body.toBuilder() + additionalHeaders = tagValueUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = tagValueUpdateParams.additionalQueryParams.toBuilder() + } + + fun tagKeyId(tagKeyId: String) = apply { this.tagKeyId = tagKeyId } + + fun tagValueId(tagValueId: String?) = apply { this.tagValueId = tagValueId } + + /** Alias for calling [Builder.tagValueId] with `tagValueId.orElse(null)`. */ + fun tagValueId(tagValueId: Optional<String>) = tagValueId(tagValueId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [description] + * - [value] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun description(description: String?) = apply { body.description(description) } + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { body.description(description) } + + fun value(value: String?) = apply { body.value(value) } + + /** Alias for calling [Builder.value] with `value.orElse(null)`. */ + fun value(value: Optional<String>) = value(value.getOrNull()) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun value(value: JsonField<String>) = apply { body.value(value) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TagValueUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tagKeyId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TagValueUpdateParams = + TagValueUpdateParams( + checkRequired("tagKeyId", tagKeyId), + tagValueId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> tagKeyId + 1 -> tagValueId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val description: JsonField<String>, + private val value: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField<String> = JsonMissing.of(), + ) : this(description, value, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun value(): Optional<String> = value.getOptional("value") + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField<String> = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var description: JsonField<String> = JsonMissing.of() + private var value: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + description = body.description + value = body.value + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField<String>) = apply { + this.description = description + } + + fun value(value: String?) = value(JsonField.ofNullable(value)) + + /** Alias for calling [Builder.value] with `value.orElse(null)`. */ + fun value(value: Optional<String>) = value(value.getOrNull()) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun value(value: JsonField<String>) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = Body(description, value, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + description() + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (description.asKnown().isPresent) 1 else 0) + + (if (value.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + description == other.description && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(description, value, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{description=$description, value=$value, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TagValueUpdateParams && + tagKeyId == other.tagKeyId && + tagValueId == other.tagValueId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(tagKeyId, tagValueId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TagValueUpdateParams{tagKeyId=$tagKeyId, tagValueId=$tagValueId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/ResourceType.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/ResourceType.kt new file mode 100644 index 00000000..6f569939 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/ResourceType.kt @@ -0,0 +1,163 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tags + +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException + +class ResourceType @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't match + * any known member, and you want to know that value. For example, if the SDK is on an older + * version than the API, then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val PROMPT = of("prompt") + + @JvmField val PROJECT = of("project") + + @JvmField val QUEUE = of("queue") + + @JvmField val DEPLOYMENT = of("deployment") + + @JvmField val EXPERIMENT = of("experiment") + + @JvmField val DATASET = of("dataset") + + @JvmField val DASHBOARD = of("dashboard") + + @JvmStatic fun of(value: String) = ResourceType(JsonField.of(value)) + } + + /** An enum containing [ResourceType]'s known values. */ + enum class Known { + PROMPT, + PROJECT, + QUEUE, + DEPLOYMENT, + EXPERIMENT, + DATASET, + DASHBOARD, + } + + /** + * An enum containing [ResourceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ResourceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the SDK + * is on an older version than the API, then the API may respond with new members that the SDK + * is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PROMPT, + PROJECT, + QUEUE, + DEPLOYMENT, + EXPERIMENT, + DATASET, + DASHBOARD, + /** An enum member indicating that [ResourceType] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if + * the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want to + * throw for the unknown case. + */ + fun value(): Value = + when (this) { + PROMPT -> Value.PROMPT + PROJECT -> Value.PROJECT + QUEUE -> Value.QUEUE + DEPLOYMENT -> Value.DEPLOYMENT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + DASHBOARD -> Value.DASHBOARD + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't want + * to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PROMPT -> Known.PROMPT + PROJECT -> Known.PROJECT + QUEUE -> Known.QUEUE + DEPLOYMENT -> Known.DEPLOYMENT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + DASHBOARD -> Known.DASHBOARD + else -> throw LangsmithApiInvalidDataException("Unknown ResourceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ResourceType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ResourceType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagListParams.kt new file mode 100644 index 00000000..13059902 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagListParams.kt @@ -0,0 +1,170 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tags + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** List Tags */ +class TagListParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): TagListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [TagListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TagListParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(tagListParams: TagListParams) = apply { + additionalHeaders = tagListParams.additionalHeaders.toBuilder() + additionalQueryParams = tagListParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TagListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TagListParams = + TagListParams(additionalHeaders.build(), additionalQueryParams.build()) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TagListParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "TagListParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagListResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagListResponse.kt new file mode 100644 index 00000000..bd2fa8cb --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagListResponse.kt @@ -0,0 +1,372 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tags + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues.TagValue +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class TagListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val key: JsonField<String>, + private val updatedAt: JsonField<OffsetDateTime>, + private val description: JsonField<String>, + private val values: JsonField<List<TagValue>>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("key") @ExcludeMissing key: JsonField<String> = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("values") @ExcludeMissing values: JsonField<List<TagValue>> = JsonMissing.of(), + ) : this(id, createdAt, key, updatedAt, description, values, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun key(): String = key.getRequired("key") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updatedAt(): OffsetDateTime = updatedAt.getRequired("updated_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun values(): Optional<List<TagValue>> = values.getOptional("values") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [key]. + * + * Unlike [key], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("key") @ExcludeMissing fun _key(): JsonField<String> = key + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField<OffsetDateTime> = updatedAt + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField<List<TagValue>> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TagListResponse]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .key() + * .updatedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TagListResponse]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var createdAt: JsonField<OffsetDateTime>? = null + private var key: JsonField<String>? = null + private var updatedAt: JsonField<OffsetDateTime>? = null + private var description: JsonField<String> = JsonMissing.of() + private var values: JsonField<MutableList<TagValue>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(tagListResponse: TagListResponse) = apply { + id = tagListResponse.id + createdAt = tagListResponse.createdAt + key = tagListResponse.key + updatedAt = tagListResponse.updatedAt + description = tagListResponse.description + values = tagListResponse.values.map { it.toMutableList() } + additionalProperties = tagListResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun key(key: String) = key(JsonField.of(key)) + + /** + * Sets [Builder.key] to an arbitrary JSON value. + * + * You should usually call [Builder.key] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun key(key: JsonField<String>) = apply { this.key = key } + + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField<OffsetDateTime>) = apply { this.updatedAt = updatedAt } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { this.description = description } + + fun values(values: List<TagValue>) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List<TagValue>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun values(values: JsonField<List<TagValue>>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [TagValue] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: TagValue) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TagListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .key() + * .updatedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TagListResponse = + TagListResponse( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("key", key), + checkRequired("updatedAt", updatedAt), + description, + (values ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TagListResponse = apply { + if (validated) { + return@apply + } + + id() + createdAt() + key() + updatedAt() + description() + values().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (key.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (values.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TagListResponse && + id == other.id && + createdAt == other.createdAt && + key == other.key && + updatedAt == other.updatedAt && + description == other.description && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, createdAt, key, updatedAt, description, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TagListResponse{id=$id, createdAt=$createdAt, key=$key, updatedAt=$updatedAt, description=$description, values=$values, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagResourcesParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagResourcesParams.kt new file mode 100644 index 00000000..2249d914 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagResourcesParams.kt @@ -0,0 +1,423 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tags + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** List Tags For Resources */ +class TagResourcesParams +private constructor( + private val body: List<Body>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun body(): List<Body> = body + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TagResourcesParams]. + * + * The following fields are required: + * ```java + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TagResourcesParams]. */ + class Builder internal constructor() { + + private var body: MutableList<Body>? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(tagResourcesParams: TagResourcesParams) = apply { + body = tagResourcesParams.body.toMutableList() + additionalHeaders = tagResourcesParams.additionalHeaders.toBuilder() + additionalQueryParams = tagResourcesParams.additionalQueryParams.toBuilder() + } + + fun body(body: List<Body>) = apply { this.body = body.toMutableList() } + + /** + * Adds a single [Body] to [Builder.body]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addBody(body: Body) = apply { + this.body = (this.body ?: mutableListOf()).apply { add(body) } + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TagResourcesParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TagResourcesParams = + TagResourcesParams( + checkRequired("body", body).toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): List<Body> = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val resourceId: JsonField<String>, + private val resourceType: JsonField<ResourceType>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("resource_id") + @ExcludeMissing + resourceId: JsonField<String> = JsonMissing.of(), + @JsonProperty("resource_type") + @ExcludeMissing + resourceType: JsonField<ResourceType> = JsonMissing.of(), + ) : this(resourceId, resourceType, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun resourceId(): String = resourceId.getRequired("resource_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun resourceType(): ResourceType = resourceType.getRequired("resource_type") + + /** + * Returns the raw JSON value of [resourceId]. + * + * Unlike [resourceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("resource_id") + @ExcludeMissing + fun _resourceId(): JsonField<String> = resourceId + + /** + * Returns the raw JSON value of [resourceType]. + * + * Unlike [resourceType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("resource_type") + @ExcludeMissing + fun _resourceType(): JsonField<ResourceType> = resourceType + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .resourceId() + * .resourceType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var resourceId: JsonField<String>? = null + private var resourceType: JsonField<ResourceType>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + resourceId = body.resourceId + resourceType = body.resourceType + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun resourceId(resourceId: String) = resourceId(JsonField.of(resourceId)) + + /** + * Sets [Builder.resourceId] to an arbitrary JSON value. + * + * You should usually call [Builder.resourceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun resourceId(resourceId: JsonField<String>) = apply { this.resourceId = resourceId } + + fun resourceType(resourceType: ResourceType) = resourceType(JsonField.of(resourceType)) + + /** + * Sets [Builder.resourceType] to an arbitrary JSON value. + * + * You should usually call [Builder.resourceType] with a well-typed [ResourceType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun resourceType(resourceType: JsonField<ResourceType>) = apply { + this.resourceType = resourceType + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .resourceId() + * .resourceType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("resourceId", resourceId), + checkRequired("resourceType", resourceType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + resourceId() + resourceType().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (resourceId.asKnown().isPresent) 1 else 0) + + (resourceType.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + resourceId == other.resourceId && + resourceType == other.resourceType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(resourceId, resourceType, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{resourceId=$resourceId, resourceType=$resourceType, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TagResourcesParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TagResourcesParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagResourcesResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagResourcesResponse.kt new file mode 100644 index 00000000..015bcf99 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagResourcesResponse.kt @@ -0,0 +1,109 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tags + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Objects + +class TagResourcesResponse +@JsonCreator +private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> +) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [TagResourcesResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TagResourcesResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(tagResourcesResponse: TagResourcesResponse) = apply { + additionalProperties = tagResourcesResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TagResourcesResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TagResourcesResponse = TagResourcesResponse(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): TagResourcesResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TagResourcesResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "TagResourcesResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagRetrieveResourceParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagRetrieveResourceParams.kt new file mode 100644 index 00000000..4efb12c5 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagRetrieveResourceParams.kt @@ -0,0 +1,214 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tags + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** List Tags For Resource */ +class TagRetrieveResourceParams +private constructor( + private val resourceId: String, + private val resourceType: ResourceType, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun resourceId(): String = resourceId + + fun resourceType(): ResourceType = resourceType + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TagRetrieveResourceParams]. + * + * The following fields are required: + * ```java + * .resourceId() + * .resourceType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TagRetrieveResourceParams]. */ + class Builder internal constructor() { + + private var resourceId: String? = null + private var resourceType: ResourceType? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(tagRetrieveResourceParams: TagRetrieveResourceParams) = apply { + resourceId = tagRetrieveResourceParams.resourceId + resourceType = tagRetrieveResourceParams.resourceType + additionalHeaders = tagRetrieveResourceParams.additionalHeaders.toBuilder() + additionalQueryParams = tagRetrieveResourceParams.additionalQueryParams.toBuilder() + } + + fun resourceId(resourceId: String) = apply { this.resourceId = resourceId } + + fun resourceType(resourceType: ResourceType) = apply { this.resourceType = resourceType } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TagRetrieveResourceParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .resourceId() + * .resourceType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TagRetrieveResourceParams = + TagRetrieveResourceParams( + checkRequired("resourceId", resourceId), + checkRequired("resourceType", resourceType), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("resource_id", resourceId) + put("resource_type", resourceType.toString()) + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TagRetrieveResourceParams && + resourceId == other.resourceId && + resourceType == other.resourceType && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(resourceId, resourceType, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TagRetrieveResourceParams{resourceId=$resourceId, resourceType=$resourceType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagRetrieveResourceResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagRetrieveResourceResponse.kt new file mode 100644 index 00000000..792f8bf3 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagRetrieveResourceResponse.kt @@ -0,0 +1,782 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tags + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.workspaces.current.taggings.Tagging +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class TagRetrieveResourceResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val key: JsonField<String>, + private val updatedAt: JsonField<OffsetDateTime>, + private val description: JsonField<String>, + private val values: JsonField<List<Value>>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("key") @ExcludeMissing key: JsonField<String> = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("values") @ExcludeMissing values: JsonField<List<Value>> = JsonMissing.of(), + ) : this(id, createdAt, key, updatedAt, description, values, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun key(): String = key.getRequired("key") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updatedAt(): OffsetDateTime = updatedAt.getRequired("updated_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun values(): Optional<List<Value>> = values.getOptional("values") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [key]. + * + * Unlike [key], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("key") @ExcludeMissing fun _key(): JsonField<String> = key + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField<OffsetDateTime> = updatedAt + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField<List<Value>> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TagRetrieveResourceResponse]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .key() + * .updatedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TagRetrieveResourceResponse]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var createdAt: JsonField<OffsetDateTime>? = null + private var key: JsonField<String>? = null + private var updatedAt: JsonField<OffsetDateTime>? = null + private var description: JsonField<String> = JsonMissing.of() + private var values: JsonField<MutableList<Value>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(tagRetrieveResourceResponse: TagRetrieveResourceResponse) = apply { + id = tagRetrieveResourceResponse.id + createdAt = tagRetrieveResourceResponse.createdAt + key = tagRetrieveResourceResponse.key + updatedAt = tagRetrieveResourceResponse.updatedAt + description = tagRetrieveResourceResponse.description + values = tagRetrieveResourceResponse.values.map { it.toMutableList() } + additionalProperties = tagRetrieveResourceResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { this.createdAt = createdAt } + + fun key(key: String) = key(JsonField.of(key)) + + /** + * Sets [Builder.key] to an arbitrary JSON value. + * + * You should usually call [Builder.key] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun key(key: JsonField<String>) = apply { this.key = key } + + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField<OffsetDateTime>) = apply { this.updatedAt = updatedAt } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { this.description = description } + + fun values(values: List<Value>) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List<Value>` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun values(values: JsonField<List<Value>>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [Value] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: Value) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TagRetrieveResourceResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .key() + * .updatedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TagRetrieveResourceResponse = + TagRetrieveResourceResponse( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("key", key), + checkRequired("updatedAt", updatedAt), + description, + (values ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TagRetrieveResourceResponse = apply { + if (validated) { + return@apply + } + + id() + createdAt() + key() + updatedAt() + description() + values().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (key.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (values.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class Value + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField<String>, + private val createdAt: JsonField<OffsetDateTime>, + private val tagKeyId: JsonField<String>, + private val updatedAt: JsonField<OffsetDateTime>, + private val value: JsonField<String>, + private val description: JsonField<String>, + private val taggings: JsonField<List<Tagging>>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("tag_key_id") + @ExcludeMissing + tagKeyId: JsonField<String> = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField<OffsetDateTime> = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField<String> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("taggings") + @ExcludeMissing + taggings: JsonField<List<Tagging>> = JsonMissing.of(), + ) : this(id, createdAt, tagKeyId, updatedAt, value, description, taggings, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tagKeyId(): String = tagKeyId.getRequired("tag_key_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updatedAt(): OffsetDateTime = updatedAt.getRequired("updated_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun value(): String = value.getRequired("value") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun taggings(): Optional<List<Tagging>> = taggings.getOptional("taggings") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField<OffsetDateTime> = createdAt + + /** + * Returns the raw JSON value of [tagKeyId]. + * + * Unlike [tagKeyId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tag_key_id") @ExcludeMissing fun _tagKeyId(): JsonField<String> = tagKeyId + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField<OffsetDateTime> = updatedAt + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField<String> = value + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [taggings]. + * + * Unlike [taggings], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("taggings") + @ExcludeMissing + fun _taggings(): JsonField<List<Tagging>> = taggings + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Value]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .tagKeyId() + * .updatedAt() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Value]. */ + class Builder internal constructor() { + + private var id: JsonField<String>? = null + private var createdAt: JsonField<OffsetDateTime>? = null + private var tagKeyId: JsonField<String>? = null + private var updatedAt: JsonField<OffsetDateTime>? = null + private var value: JsonField<String>? = null + private var description: JsonField<String> = JsonMissing.of() + private var taggings: JsonField<MutableList<Tagging>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(value: Value) = apply { + id = value.id + createdAt = value.createdAt + tagKeyId = value.tagKeyId + updatedAt = value.updatedAt + this.value = value.value + description = value.description + taggings = value.taggings.map { it.toMutableList() } + additionalProperties = value.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<OffsetDateTime>) = apply { + this.createdAt = createdAt + } + + fun tagKeyId(tagKeyId: String) = tagKeyId(JsonField.of(tagKeyId)) + + /** + * Sets [Builder.tagKeyId] to an arbitrary JSON value. + * + * You should usually call [Builder.tagKeyId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tagKeyId(tagKeyId: JsonField<String>) = apply { this.tagKeyId = tagKeyId } + + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField<OffsetDateTime>) = apply { + this.updatedAt = updatedAt + } + + fun value(value: String) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun value(value: JsonField<String>) = apply { this.value = value } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional<String>) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField<String>) = apply { + this.description = description + } + + fun taggings(taggings: List<Tagging>) = taggings(JsonField.of(taggings)) + + /** + * Sets [Builder.taggings] to an arbitrary JSON value. + * + * You should usually call [Builder.taggings] with a well-typed `List<Tagging>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun taggings(taggings: JsonField<List<Tagging>>) = apply { + this.taggings = taggings.map { it.toMutableList() } + } + + /** + * Adds a single [Tagging] to [taggings]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTagging(tagging: Tagging) = apply { + taggings = + (taggings ?: JsonField.of(mutableListOf())).also { + checkKnown("taggings", it).add(tagging) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Value]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .tagKeyId() + * .updatedAt() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Value = + Value( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("tagKeyId", tagKeyId), + checkRequired("updatedAt", updatedAt), + checkRequired("value", value), + description, + (taggings ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Value = apply { + if (validated) { + return@apply + } + + id() + createdAt() + tagKeyId() + updatedAt() + value() + description() + taggings().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (tagKeyId.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (if (value.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (taggings.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + id == other.id && + createdAt == other.createdAt && + tagKeyId == other.tagKeyId && + updatedAt == other.updatedAt && + value == other.value && + description == other.description && + taggings == other.taggings && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + createdAt, + tagKeyId, + updatedAt, + value, + description, + taggings, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Value{id=$id, createdAt=$createdAt, tagKeyId=$tagKeyId, updatedAt=$updatedAt, value=$value, description=$description, taggings=$taggings, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TagRetrieveResourceResponse && + id == other.id && + createdAt == other.createdAt && + key == other.key && + updatedAt == other.updatedAt && + description == other.description && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, createdAt, key, updatedAt, description, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TagRetrieveResourceResponse{id=$id, createdAt=$createdAt, key=$key, updatedAt=$updatedAt, description=$description, values=$values, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingClaimParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingClaimParams.kt new file mode 100644 index 00000000..b1ddddf2 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingClaimParams.kt @@ -0,0 +1,235 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.pending + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Claim Pending Workspace Invite */ +@Deprecated("deprecated") +class PendingClaimParams +private constructor( + private val workspaceId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun workspaceId(): Optional<String> = Optional.ofNullable(workspaceId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): PendingClaimParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [PendingClaimParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PendingClaimParams]. */ + class Builder internal constructor() { + + private var workspaceId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(pendingClaimParams: PendingClaimParams) = apply { + workspaceId = pendingClaimParams.workspaceId + additionalHeaders = pendingClaimParams.additionalHeaders.toBuilder() + additionalQueryParams = pendingClaimParams.additionalQueryParams.toBuilder() + additionalBodyProperties = pendingClaimParams.additionalBodyProperties.toMutableMap() + } + + fun workspaceId(workspaceId: String?) = apply { this.workspaceId = workspaceId } + + /** Alias for calling [Builder.workspaceId] with `workspaceId.orElse(null)`. */ + fun workspaceId(workspaceId: Optional<String>) = workspaceId(workspaceId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [PendingClaimParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PendingClaimParams = + PendingClaimParams( + workspaceId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> workspaceId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PendingClaimParams && + workspaceId == other.workspaceId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + workspaceId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "PendingClaimParams{workspaceId=$workspaceId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingClaimResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingClaimResponse.kt new file mode 100644 index 00000000..c0af0704 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingClaimResponse.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.pending + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class PendingClaimResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [PendingClaimResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PendingClaimResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(pendingClaimResponse: PendingClaimResponse) = apply { + additionalProperties = pendingClaimResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PendingClaimResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PendingClaimResponse = + PendingClaimResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): PendingClaimResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PendingClaimResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "PendingClaimResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingDeleteParams.kt new file mode 100644 index 00000000..8e3019f7 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingDeleteParams.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.pending + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete Pending Workspace Invite */ +class PendingDeleteParams +private constructor( + private val id: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun id(): Optional<String> = Optional.ofNullable(id) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): PendingDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [PendingDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PendingDeleteParams]. */ + class Builder internal constructor() { + + private var id: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(pendingDeleteParams: PendingDeleteParams) = apply { + id = pendingDeleteParams.id + additionalHeaders = pendingDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = pendingDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = pendingDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun id(id: String?) = apply { this.id = id } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<String>) = id(id.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [PendingDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PendingDeleteParams = + PendingDeleteParams( + id, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> id ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PendingDeleteParams && + id == other.id && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(id, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "PendingDeleteParams{id=$id, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingDeleteResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingDeleteResponse.kt new file mode 100644 index 00000000..d34536a3 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingDeleteResponse.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.pending + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects + +class PendingDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap<String, JsonValue>) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [PendingDeleteResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PendingDeleteResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(pendingDeleteResponse: PendingDeleteResponse) = apply { + additionalProperties = pendingDeleteResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PendingDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PendingDeleteResponse = + PendingDeleteResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): PendingDeleteResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PendingDeleteResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "PendingDeleteResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingListParams.kt new file mode 100644 index 00000000..1036c3e3 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingListParams.kt @@ -0,0 +1,170 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.pending + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** Get all workspaces visible to this auth */ +class PendingListParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): PendingListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [PendingListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PendingListParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(pendingListParams: PendingListParams) = apply { + additionalHeaders = pendingListParams.additionalHeaders.toBuilder() + additionalQueryParams = pendingListParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [PendingListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PendingListParams = + PendingListParams(additionalHeaders.build(), additionalQueryParams.build()) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PendingListParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "PendingListParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ColumnOverride.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ColumnOverride.kt new file mode 100644 index 00000000..4b2958f2 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ColumnOverride.kt @@ -0,0 +1,423 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.datasets.experimentviewoverrides + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ColumnOverride +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val column: JsonField<String>, + private val colorGradient: JsonField<List<List<JsonValue>>>, + private val colorMap: JsonField<ColorMap>, + private val hide: JsonField<Boolean>, + private val precision: JsonField<Long>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("column") @ExcludeMissing column: JsonField<String> = JsonMissing.of(), + @JsonProperty("color_gradient") + @ExcludeMissing + colorGradient: JsonField<List<List<JsonValue>>> = JsonMissing.of(), + @JsonProperty("color_map") @ExcludeMissing colorMap: JsonField<ColorMap> = JsonMissing.of(), + @JsonProperty("hide") @ExcludeMissing hide: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("precision") @ExcludeMissing precision: JsonField<Long> = JsonMissing.of(), + ) : this(column, colorGradient, colorMap, hide, precision, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun column(): String = column.getRequired("column") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun colorGradient(): Optional<List<List<JsonValue>>> = + colorGradient.getOptional("color_gradient") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun colorMap(): Optional<ColorMap> = colorMap.getOptional("color_map") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun hide(): Optional<Boolean> = hide.getOptional("hide") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun precision(): Optional<Long> = precision.getOptional("precision") + + /** + * Returns the raw JSON value of [column]. + * + * Unlike [column], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("column") @ExcludeMissing fun _column(): JsonField<String> = column + + /** + * Returns the raw JSON value of [colorGradient]. + * + * Unlike [colorGradient], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("color_gradient") + @ExcludeMissing + fun _colorGradient(): JsonField<List<List<JsonValue>>> = colorGradient + + /** + * Returns the raw JSON value of [colorMap]. + * + * Unlike [colorMap], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("color_map") @ExcludeMissing fun _colorMap(): JsonField<ColorMap> = colorMap + + /** + * Returns the raw JSON value of [hide]. + * + * Unlike [hide], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("hide") @ExcludeMissing fun _hide(): JsonField<Boolean> = hide + + /** + * Returns the raw JSON value of [precision]. + * + * Unlike [precision], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("precision") @ExcludeMissing fun _precision(): JsonField<Long> = precision + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ColumnOverride]. + * + * The following fields are required: + * ```java + * .column() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ColumnOverride]. */ + class Builder internal constructor() { + + private var column: JsonField<String>? = null + private var colorGradient: JsonField<MutableList<List<JsonValue>>>? = null + private var colorMap: JsonField<ColorMap> = JsonMissing.of() + private var hide: JsonField<Boolean> = JsonMissing.of() + private var precision: JsonField<Long> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(columnOverride: ColumnOverride) = apply { + column = columnOverride.column + colorGradient = columnOverride.colorGradient.map { it.toMutableList() } + colorMap = columnOverride.colorMap + hide = columnOverride.hide + precision = columnOverride.precision + additionalProperties = columnOverride.additionalProperties.toMutableMap() + } + + fun column(column: String) = column(JsonField.of(column)) + + /** + * Sets [Builder.column] to an arbitrary JSON value. + * + * You should usually call [Builder.column] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun column(column: JsonField<String>) = apply { this.column = column } + + fun colorGradient(colorGradient: List<List<JsonValue>>) = + colorGradient(JsonField.of(colorGradient)) + + /** + * Sets [Builder.colorGradient] to an arbitrary JSON value. + * + * You should usually call [Builder.colorGradient] with a well-typed `List<List<JsonValue>>` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun colorGradient(colorGradient: JsonField<List<List<JsonValue>>>) = apply { + this.colorGradient = colorGradient.map { it.toMutableList() } + } + + /** + * Adds a single [List<JsonValue>] to [Builder.colorGradient]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addColorGradient(colorGradient: List<JsonValue>) = apply { + this.colorGradient = + (this.colorGradient ?: JsonField.of(mutableListOf())).also { + checkKnown("colorGradient", it).add(colorGradient) + } + } + + fun colorMap(colorMap: ColorMap) = colorMap(JsonField.of(colorMap)) + + /** + * Sets [Builder.colorMap] to an arbitrary JSON value. + * + * You should usually call [Builder.colorMap] with a well-typed [ColorMap] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun colorMap(colorMap: JsonField<ColorMap>) = apply { this.colorMap = colorMap } + + fun hide(hide: Boolean) = hide(JsonField.of(hide)) + + /** + * Sets [Builder.hide] to an arbitrary JSON value. + * + * You should usually call [Builder.hide] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun hide(hide: JsonField<Boolean>) = apply { this.hide = hide } + + fun precision(precision: Long) = precision(JsonField.of(precision)) + + /** + * Sets [Builder.precision] to an arbitrary JSON value. + * + * You should usually call [Builder.precision] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun precision(precision: JsonField<Long>) = apply { this.precision = precision } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ColumnOverride]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .column() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ColumnOverride = + ColumnOverride( + checkRequired("column", column), + (colorGradient ?: JsonMissing.of()).map { it.toImmutable() }, + colorMap, + hide, + precision, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ColumnOverride = apply { + if (validated) { + return@apply + } + + column() + colorGradient() + colorMap().ifPresent { it.validate() } + hide() + precision() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (column.asKnown().isPresent) 1 else 0) + + (colorGradient.asKnown().getOrNull()?.sumOf { it.size.toInt() } ?: 0) + + (colorMap.asKnown().getOrNull()?.validity() ?: 0) + + (if (hide.asKnown().isPresent) 1 else 0) + + (if (precision.asKnown().isPresent) 1 else 0) + + class ColorMap + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ColorMap]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ColorMap]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(colorMap: ColorMap) = apply { + additionalProperties = colorMap.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ColorMap]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ColorMap = ColorMap(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ColorMap = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ColorMap && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "ColorMap{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ColumnOverride && + column == other.column && + colorGradient == other.colorGradient && + colorMap == other.colorMap && + hide == other.hide && + precision == other.precision && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(column, colorGradient, colorMap, hide, precision, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ColumnOverride{column=$column, colorGradient=$colorGradient, colorMap=$colorMap, hide=$hide, precision=$precision, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverride.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverride.kt new file mode 100644 index 00000000..1290244c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverride.kt @@ -0,0 +1,313 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.datasets.experimentviewoverrides + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ExperimentViewOverride +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val columnOverrides: JsonField<List<ColumnOverride>>, + private val createdAt: JsonField<String>, + private val datasetId: JsonField<String>, + private val modifiedAt: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("column_overrides") + @ExcludeMissing + columnOverrides: JsonField<List<ColumnOverride>> = JsonMissing.of(), + @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField<String> = JsonMissing.of(), + @JsonProperty("dataset_id") @ExcludeMissing datasetId: JsonField<String> = JsonMissing.of(), + @JsonProperty("modified_at") + @ExcludeMissing + modifiedAt: JsonField<String> = JsonMissing.of(), + ) : this(id, columnOverrides, createdAt, datasetId, modifiedAt, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun columnOverrides(): Optional<List<ColumnOverride>> = + columnOverrides.getOptional("column_overrides") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun createdAt(): Optional<String> = createdAt.getOptional("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun datasetId(): Optional<String> = datasetId.getOptional("dataset_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun modifiedAt(): Optional<String> = modifiedAt.getOptional("modified_at") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [columnOverrides]. + * + * Unlike [columnOverrides], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("column_overrides") + @ExcludeMissing + fun _columnOverrides(): JsonField<List<ColumnOverride>> = columnOverrides + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") @ExcludeMissing fun _createdAt(): JsonField<String> = createdAt + + /** + * Returns the raw JSON value of [datasetId]. + * + * Unlike [datasetId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField<String> = datasetId + + /** + * Returns the raw JSON value of [modifiedAt]. + * + * Unlike [modifiedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("modified_at") @ExcludeMissing fun _modifiedAt(): JsonField<String> = modifiedAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ExperimentViewOverride]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExperimentViewOverride]. */ + class Builder internal constructor() { + + private var id: JsonField<String> = JsonMissing.of() + private var columnOverrides: JsonField<MutableList<ColumnOverride>>? = null + private var createdAt: JsonField<String> = JsonMissing.of() + private var datasetId: JsonField<String> = JsonMissing.of() + private var modifiedAt: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(experimentViewOverride: ExperimentViewOverride) = apply { + id = experimentViewOverride.id + columnOverrides = experimentViewOverride.columnOverrides.map { it.toMutableList() } + createdAt = experimentViewOverride.createdAt + datasetId = experimentViewOverride.datasetId + modifiedAt = experimentViewOverride.modifiedAt + additionalProperties = experimentViewOverride.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun columnOverrides(columnOverrides: List<ColumnOverride>) = + columnOverrides(JsonField.of(columnOverrides)) + + /** + * Sets [Builder.columnOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.columnOverrides] with a well-typed + * `List<ColumnOverride>` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun columnOverrides(columnOverrides: JsonField<List<ColumnOverride>>) = apply { + this.columnOverrides = columnOverrides.map { it.toMutableList() } + } + + /** + * Adds a single [ColumnOverride] to [columnOverrides]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addColumnOverride(columnOverride: ColumnOverride) = apply { + columnOverrides = + (columnOverrides ?: JsonField.of(mutableListOf())).also { + checkKnown("columnOverrides", it).add(columnOverride) + } + } + + fun createdAt(createdAt: String) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun createdAt(createdAt: JsonField<String>) = apply { this.createdAt = createdAt } + + fun datasetId(datasetId: String) = datasetId(JsonField.of(datasetId)) + + /** + * Sets [Builder.datasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun datasetId(datasetId: JsonField<String>) = apply { this.datasetId = datasetId } + + fun modifiedAt(modifiedAt: String) = modifiedAt(JsonField.of(modifiedAt)) + + /** + * Sets [Builder.modifiedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.modifiedAt] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun modifiedAt(modifiedAt: JsonField<String>) = apply { this.modifiedAt = modifiedAt } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ExperimentViewOverride]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ExperimentViewOverride = + ExperimentViewOverride( + id, + (columnOverrides ?: JsonMissing.of()).map { it.toImmutable() }, + createdAt, + datasetId, + modifiedAt, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ExperimentViewOverride = apply { + if (validated) { + return@apply + } + + id() + columnOverrides().ifPresent { it.forEach { it.validate() } } + createdAt() + datasetId() + modifiedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (columnOverrides.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (datasetId.asKnown().isPresent) 1 else 0) + + (if (modifiedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExperimentViewOverride && + id == other.id && + columnOverrides == other.columnOverrides && + createdAt == other.createdAt && + datasetId == other.datasetId && + modifiedAt == other.modifiedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, columnOverrides, createdAt, datasetId, modifiedAt, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ExperimentViewOverride{id=$id, columnOverrides=$columnOverrides, createdAt=$createdAt, datasetId=$datasetId, modifiedAt=$modifiedAt, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideCreateParams.kt new file mode 100644 index 00000000..269ec6c8 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideCreateParams.kt @@ -0,0 +1,493 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.datasets.experimentviewoverrides + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Creates a new experiment view override configuration for a dataset with column display settings. + * This endpoint allows you to customize how experiment results are displayed by configuring + * column-specific overrides including colors, precision, and visibility. + * + * The request must include a 'column_overrides' array with at least one override configuration. + * Each column override can specify: + * - column: Required field name (must start with inputs, outputs, reference_outputs, feedback, + * metrics, attachments, or metadata) + * - color_gradient: Optional array of [number, color] tuples for numeric data visualization + * - precision: Optional number (1-6) for decimal places in numeric columns + * - hide: Optional boolean to control column visibility + * + * Example request body: { "column_overrides": + * [ { "column": "outputs.accuracy", "color_gradient": [[0.0, "#ff0000"], [0.5, "#ffff00"], + * [1.0, "#00ff00"]], "precision": 3 }, { "column": "inputs.model_type", "hide": false } ] } + * + * This operation fails if an override already exists for the dataset (use PATCH to update). + */ +class ExperimentViewOverrideCreateParams +private constructor( + private val datasetId: JsonValue?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun datasetId(): Optional<JsonValue> = Optional.ofNullable(datasetId) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun columnOverrides(): List<ColumnOverride> = body.columnOverrides() + + /** + * Returns the raw JSON value of [columnOverrides]. + * + * Unlike [columnOverrides], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _columnOverrides(): JsonField<List<ColumnOverride>> = body._columnOverrides() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ExperimentViewOverrideCreateParams]. + * + * The following fields are required: + * ```java + * .columnOverrides() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExperimentViewOverrideCreateParams]. */ + class Builder internal constructor() { + + private var datasetId: JsonValue? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(experimentViewOverrideCreateParams: ExperimentViewOverrideCreateParams) = + apply { + datasetId = experimentViewOverrideCreateParams.datasetId + body = experimentViewOverrideCreateParams.body.toBuilder() + additionalHeaders = experimentViewOverrideCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = + experimentViewOverrideCreateParams.additionalQueryParams.toBuilder() + } + + fun datasetId(datasetId: JsonValue?) = apply { this.datasetId = datasetId } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<JsonValue>) = datasetId(datasetId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [columnOverrides] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun columnOverrides(columnOverrides: List<ColumnOverride>) = apply { + body.columnOverrides(columnOverrides) + } + + /** + * Sets [Builder.columnOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.columnOverrides] with a well-typed + * `List<ColumnOverride>` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun columnOverrides(columnOverrides: JsonField<List<ColumnOverride>>) = apply { + body.columnOverrides(columnOverrides) + } + + /** + * Adds a single [ColumnOverride] to [columnOverrides]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addColumnOverride(columnOverride: ColumnOverride) = apply { + body.addColumnOverride(columnOverride) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ExperimentViewOverrideCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .columnOverrides() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ExperimentViewOverrideCreateParams = + ExperimentViewOverrideCreateParams( + datasetId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> datasetId?.toString() ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val columnOverrides: JsonField<List<ColumnOverride>>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("column_overrides") + @ExcludeMissing + columnOverrides: JsonField<List<ColumnOverride>> = JsonMissing.of() + ) : this(columnOverrides, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun columnOverrides(): List<ColumnOverride> = + columnOverrides.getRequired("column_overrides") + + /** + * Returns the raw JSON value of [columnOverrides]. + * + * Unlike [columnOverrides], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("column_overrides") + @ExcludeMissing + fun _columnOverrides(): JsonField<List<ColumnOverride>> = columnOverrides + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .columnOverrides() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var columnOverrides: JsonField<MutableList<ColumnOverride>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + columnOverrides = body.columnOverrides.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun columnOverrides(columnOverrides: List<ColumnOverride>) = + columnOverrides(JsonField.of(columnOverrides)) + + /** + * Sets [Builder.columnOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.columnOverrides] with a well-typed + * `List<ColumnOverride>` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun columnOverrides(columnOverrides: JsonField<List<ColumnOverride>>) = apply { + this.columnOverrides = columnOverrides.map { it.toMutableList() } + } + + /** + * Adds a single [ColumnOverride] to [columnOverrides]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addColumnOverride(columnOverride: ColumnOverride) = apply { + columnOverrides = + (columnOverrides ?: JsonField.of(mutableListOf())).also { + checkKnown("columnOverrides", it).add(columnOverride) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .columnOverrides() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("columnOverrides", columnOverrides).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + columnOverrides().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (columnOverrides.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + columnOverrides == other.columnOverrides && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(columnOverrides, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{columnOverrides=$columnOverrides, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExperimentViewOverrideCreateParams && + datasetId == other.datasetId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(datasetId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ExperimentViewOverrideCreateParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideDeleteParams.kt new file mode 100644 index 00000000..9150fec3 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideDeleteParams.kt @@ -0,0 +1,274 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.datasets.experimentviewoverrides + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Permanently deletes an experiment view override configuration for a dataset. This operation + * removes all column override settings including color gradients, precision configurations, and + * visibility settings. + * + * After deletion, the experiment view will revert to default column display settings. This action + * cannot be undone - you will need to recreate the override configuration if you want to restore + * custom column settings. + * + * Both the dataset and override must exist and be accessible by the authenticated user. The + * operation will fail if the override doesn't exist or if the user doesn't have appropriate + * permissions for the dataset. + */ +class ExperimentViewOverrideDeleteParams +private constructor( + private val datasetId: JsonValue, + private val id: JsonValue?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun datasetId(): JsonValue = datasetId + + fun id(): Optional<JsonValue> = Optional.ofNullable(id) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ExperimentViewOverrideDeleteParams]. + * + * The following fields are required: + * ```java + * .datasetId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExperimentViewOverrideDeleteParams]. */ + class Builder internal constructor() { + + private var datasetId: JsonValue? = null + private var id: JsonValue? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(experimentViewOverrideDeleteParams: ExperimentViewOverrideDeleteParams) = + apply { + datasetId = experimentViewOverrideDeleteParams.datasetId + id = experimentViewOverrideDeleteParams.id + additionalHeaders = experimentViewOverrideDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = + experimentViewOverrideDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + experimentViewOverrideDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun datasetId(datasetId: JsonValue) = apply { this.datasetId = datasetId } + + fun id(id: JsonValue?) = apply { this.id = id } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<JsonValue>) = id(id.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [ExperimentViewOverrideDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .datasetId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ExperimentViewOverrideDeleteParams = + ExperimentViewOverrideDeleteParams( + checkRequired("datasetId", datasetId), + id, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> datasetId.toString() + 1 -> id?.toString() ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExperimentViewOverrideDeleteParams && + datasetId == other.datasetId && + id == other.id && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + datasetId, + id, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "ExperimentViewOverrideDeleteParams{datasetId=$datasetId, id=$id, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideListParams.kt new file mode 100644 index 00000000..660ef31f --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideListParams.kt @@ -0,0 +1,210 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.datasets.experimentviewoverrides + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Retrieves all experiment view override configurations for a specific dataset. This endpoint + * returns column display overrides including color gradients, precision settings, and column + * visibility configurations that customize how experiment results are displayed in the UI. + * + * The response includes all column overrides with their display settings: + * - Column identifiers (must start with inputs, outputs, reference_outputs, feedback, metrics, + * attachments, or metadata) + * - Color gradients for numeric data visualization + * - Precision settings for numeric columns (1-6 decimal places) + * - Hide flags to control column visibility + */ +class ExperimentViewOverrideListParams +private constructor( + private val datasetId: JsonValue?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun datasetId(): Optional<JsonValue> = Optional.ofNullable(datasetId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ExperimentViewOverrideListParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [ExperimentViewOverrideListParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExperimentViewOverrideListParams]. */ + class Builder internal constructor() { + + private var datasetId: JsonValue? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(experimentViewOverrideListParams: ExperimentViewOverrideListParams) = + apply { + datasetId = experimentViewOverrideListParams.datasetId + additionalHeaders = experimentViewOverrideListParams.additionalHeaders.toBuilder() + additionalQueryParams = + experimentViewOverrideListParams.additionalQueryParams.toBuilder() + } + + fun datasetId(datasetId: JsonValue?) = apply { this.datasetId = datasetId } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<JsonValue>) = datasetId(datasetId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ExperimentViewOverrideListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ExperimentViewOverrideListParams = + ExperimentViewOverrideListParams( + datasetId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> datasetId?.toString() ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExperimentViewOverrideListParams && + datasetId == other.datasetId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(datasetId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ExperimentViewOverrideListParams{datasetId=$datasetId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideRetrieveParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideRetrieveParams.kt new file mode 100644 index 00000000..c4a76e8f --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideRetrieveParams.kt @@ -0,0 +1,234 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.datasets.experimentviewoverrides + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Retrieves a specific experiment view override configuration using both dataset ID and override + * ID. This endpoint provides more precise access to experiment view overrides when you have the + * specific override ID, useful for direct links or cached references. + * + * The response includes the same column override information as the dataset-level endpoint: + * - Column identifiers with validation prefixes + * - Color gradient settings for numeric data visualization + * - Numeric precision configurations + * - Column visibility controls + * + * Both the dataset and override must exist and be accessible by the authenticated user. + */ +class ExperimentViewOverrideRetrieveParams +private constructor( + private val datasetId: JsonValue, + private val id: JsonValue?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun datasetId(): JsonValue = datasetId + + fun id(): Optional<JsonValue> = Optional.ofNullable(id) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ExperimentViewOverrideRetrieveParams]. + * + * The following fields are required: + * ```java + * .datasetId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExperimentViewOverrideRetrieveParams]. */ + class Builder internal constructor() { + + private var datasetId: JsonValue? = null + private var id: JsonValue? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + experimentViewOverrideRetrieveParams: ExperimentViewOverrideRetrieveParams + ) = apply { + datasetId = experimentViewOverrideRetrieveParams.datasetId + id = experimentViewOverrideRetrieveParams.id + additionalHeaders = experimentViewOverrideRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = + experimentViewOverrideRetrieveParams.additionalQueryParams.toBuilder() + } + + fun datasetId(datasetId: JsonValue) = apply { this.datasetId = datasetId } + + fun id(id: JsonValue?) = apply { this.id = id } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<JsonValue>) = id(id.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ExperimentViewOverrideRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .datasetId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ExperimentViewOverrideRetrieveParams = + ExperimentViewOverrideRetrieveParams( + checkRequired("datasetId", datasetId), + id, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> datasetId.toString() + 1 -> id?.toString() ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExperimentViewOverrideRetrieveParams && + datasetId == other.datasetId && + id == other.id && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(datasetId, id, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ExperimentViewOverrideRetrieveParams{datasetId=$datasetId, id=$id, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideUpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideUpdateParams.kt new file mode 100644 index 00000000..1b53e19d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideUpdateParams.kt @@ -0,0 +1,504 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.datasets.experimentviewoverrides + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Updates an existing experiment view override configuration by completely replacing the column + * overrides for the specified dataset and override ID. + * + * This endpoint performs a complete replacement of the column overrides configuration. All existing + * column overrides will be replaced with the new configuration provided in the request body. To add + * or modify individual columns, include the complete desired configuration in the request. + * + * The request format is identical to the create endpoint: + * - column_overrides: Required array with at least one override configuration + * - Each override can specify color gradients, precision, and visibility + * + * Example request body: { "column_overrides": + * [ { "column": "metrics.f1_score", "color_gradient": [[0.0, "#ff4444"], [0.8, "#44ff44"]], + * "precision": 4 }, { "column": "feedback.rating", "hide": false } ] } + * + * Both the dataset and override must exist and be accessible by the authenticated user. + */ +class ExperimentViewOverrideUpdateParams +private constructor( + private val datasetId: JsonValue, + private val id: JsonValue?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun datasetId(): JsonValue = datasetId + + fun id(): Optional<JsonValue> = Optional.ofNullable(id) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun columnOverrides(): List<ColumnOverride> = body.columnOverrides() + + /** + * Returns the raw JSON value of [columnOverrides]. + * + * Unlike [columnOverrides], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _columnOverrides(): JsonField<List<ColumnOverride>> = body._columnOverrides() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ExperimentViewOverrideUpdateParams]. + * + * The following fields are required: + * ```java + * .datasetId() + * .columnOverrides() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExperimentViewOverrideUpdateParams]. */ + class Builder internal constructor() { + + private var datasetId: JsonValue? = null + private var id: JsonValue? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(experimentViewOverrideUpdateParams: ExperimentViewOverrideUpdateParams) = + apply { + datasetId = experimentViewOverrideUpdateParams.datasetId + id = experimentViewOverrideUpdateParams.id + body = experimentViewOverrideUpdateParams.body.toBuilder() + additionalHeaders = experimentViewOverrideUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = + experimentViewOverrideUpdateParams.additionalQueryParams.toBuilder() + } + + fun datasetId(datasetId: JsonValue) = apply { this.datasetId = datasetId } + + fun id(id: JsonValue?) = apply { this.id = id } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional<JsonValue>) = id(id.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [columnOverrides] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun columnOverrides(columnOverrides: List<ColumnOverride>) = apply { + body.columnOverrides(columnOverrides) + } + + /** + * Sets [Builder.columnOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.columnOverrides] with a well-typed + * `List<ColumnOverride>` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun columnOverrides(columnOverrides: JsonField<List<ColumnOverride>>) = apply { + body.columnOverrides(columnOverrides) + } + + /** + * Adds a single [ColumnOverride] to [columnOverrides]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addColumnOverride(columnOverride: ColumnOverride) = apply { + body.addColumnOverride(columnOverride) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ExperimentViewOverrideUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .datasetId() + * .columnOverrides() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ExperimentViewOverrideUpdateParams = + ExperimentViewOverrideUpdateParams( + checkRequired("datasetId", datasetId), + id, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> datasetId.toString() + 1 -> id?.toString() ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val columnOverrides: JsonField<List<ColumnOverride>>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("column_overrides") + @ExcludeMissing + columnOverrides: JsonField<List<ColumnOverride>> = JsonMissing.of() + ) : this(columnOverrides, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun columnOverrides(): List<ColumnOverride> = + columnOverrides.getRequired("column_overrides") + + /** + * Returns the raw JSON value of [columnOverrides]. + * + * Unlike [columnOverrides], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("column_overrides") + @ExcludeMissing + fun _columnOverrides(): JsonField<List<ColumnOverride>> = columnOverrides + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .columnOverrides() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var columnOverrides: JsonField<MutableList<ColumnOverride>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + columnOverrides = body.columnOverrides.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun columnOverrides(columnOverrides: List<ColumnOverride>) = + columnOverrides(JsonField.of(columnOverrides)) + + /** + * Sets [Builder.columnOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.columnOverrides] with a well-typed + * `List<ColumnOverride>` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun columnOverrides(columnOverrides: JsonField<List<ColumnOverride>>) = apply { + this.columnOverrides = columnOverrides.map { it.toMutableList() } + } + + /** + * Adds a single [ColumnOverride] to [columnOverrides]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addColumnOverride(columnOverride: ColumnOverride) = apply { + columnOverrides = + (columnOverrides ?: JsonField.of(mutableListOf())).also { + checkKnown("columnOverrides", it).add(columnOverride) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .columnOverrides() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("columnOverrides", columnOverrides).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + columnOverrides().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (columnOverrides.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + columnOverrides == other.columnOverrides && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(columnOverrides, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{columnOverrides=$columnOverrides, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExperimentViewOverrideUpdateParams && + datasetId == other.datasetId && + id == other.id && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(datasetId, id, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ExperimentViewOverrideUpdateParams{datasetId=$datasetId, id=$id, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/feedback/FeedbackIngestBatchParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/feedback/FeedbackIngestBatchParams.kt new file mode 100644 index 00000000..791aec46 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/feedback/FeedbackIngestBatchParams.kt @@ -0,0 +1,1727 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.feedback + +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.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Ingests a batch of feedback objects in a single JSON array payload. */ +class FeedbackIngestBatchParams +private constructor( + private val body: List<Body>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun body(): List<Body> = body + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [FeedbackIngestBatchParams]. + * + * The following fields are required: + * ```java + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackIngestBatchParams]. */ + class Builder internal constructor() { + + private var body: MutableList<Body>? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(feedbackIngestBatchParams: FeedbackIngestBatchParams) = apply { + body = feedbackIngestBatchParams.body.toMutableList() + additionalHeaders = feedbackIngestBatchParams.additionalHeaders.toBuilder() + additionalQueryParams = feedbackIngestBatchParams.additionalQueryParams.toBuilder() + } + + fun body(body: List<Body>) = apply { this.body = body.toMutableList() } + + /** + * Adds a single [Body] to [Builder.body]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addBody(body: Body) = apply { + this.body = (this.body ?: mutableListOf()).apply { add(body) } + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [FeedbackIngestBatchParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FeedbackIngestBatchParams = + FeedbackIngestBatchParams( + checkRequired("body", body).toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): List<Body> = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField<String>, + private val comment: JsonField<String>, + private val comparativeExperimentId: JsonField<String>, + private val correction: JsonValue, + private val createdAt: JsonField<String>, + private val error: JsonField<Boolean>, + private val feedbackConfig: JsonField<FeedbackConfig>, + private val feedbackGroupId: JsonField<String>, + private val feedbackSource: JsonField<FeedbackSource>, + private val key: JsonField<String>, + private val modifiedAt: JsonField<String>, + private val runId: JsonField<String>, + private val score: JsonValue, + private val sessionId: JsonField<String>, + private val traceId: JsonField<String>, + private val value: JsonValue, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("comment") @ExcludeMissing comment: JsonField<String> = JsonMissing.of(), + @JsonProperty("comparative_experiment_id") + @ExcludeMissing + comparativeExperimentId: JsonField<String> = JsonMissing.of(), + @JsonProperty("correction") @ExcludeMissing correction: JsonValue = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<String> = JsonMissing.of(), + @JsonProperty("error") @ExcludeMissing error: JsonField<Boolean> = JsonMissing.of(), + @JsonProperty("feedback_config") + @ExcludeMissing + feedbackConfig: JsonField<FeedbackConfig> = JsonMissing.of(), + @JsonProperty("feedback_group_id") + @ExcludeMissing + feedbackGroupId: JsonField<String> = JsonMissing.of(), + @JsonProperty("feedback_source") + @ExcludeMissing + feedbackSource: JsonField<FeedbackSource> = JsonMissing.of(), + @JsonProperty("key") @ExcludeMissing key: JsonField<String> = JsonMissing.of(), + @JsonProperty("modified_at") + @ExcludeMissing + modifiedAt: JsonField<String> = JsonMissing.of(), + @JsonProperty("run_id") @ExcludeMissing runId: JsonField<String> = JsonMissing.of(), + @JsonProperty("score") @ExcludeMissing score: JsonValue = JsonMissing.of(), + @JsonProperty("session_id") + @ExcludeMissing + sessionId: JsonField<String> = JsonMissing.of(), + @JsonProperty("trace_id") @ExcludeMissing traceId: JsonField<String> = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonValue = JsonMissing.of(), + ) : this( + id, + comment, + comparativeExperimentId, + correction, + createdAt, + error, + feedbackConfig, + feedbackGroupId, + feedbackSource, + key, + modifiedAt, + runId, + score, + sessionId, + traceId, + value, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun comment(): Optional<String> = comment.getOptional("comment") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun comparativeExperimentId(): Optional<String> = + comparativeExperimentId.getOptional("comparative_experiment_id") + + @JsonProperty("correction") @ExcludeMissing fun _correction(): JsonValue = correction + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun createdAt(): Optional<String> = createdAt.getOptional("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun error(): Optional<Boolean> = error.getOptional("error") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun feedbackConfig(): Optional<FeedbackConfig> = + feedbackConfig.getOptional("feedback_config") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun feedbackGroupId(): Optional<String> = feedbackGroupId.getOptional("feedback_group_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun feedbackSource(): Optional<FeedbackSource> = + feedbackSource.getOptional("feedback_source") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun key(): Optional<String> = key.getOptional("key") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun modifiedAt(): Optional<String> = modifiedAt.getOptional("modified_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun runId(): Optional<String> = runId.getOptional("run_id") + + @JsonProperty("score") @ExcludeMissing fun _score(): JsonValue = score + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun sessionId(): Optional<String> = sessionId.getOptional("session_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun traceId(): Optional<String> = traceId.getOptional("trace_id") + + @JsonProperty("value") @ExcludeMissing fun _value(): JsonValue = value + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [comment]. + * + * Unlike [comment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("comment") @ExcludeMissing fun _comment(): JsonField<String> = comment + + /** + * Returns the raw JSON value of [comparativeExperimentId]. + * + * Unlike [comparativeExperimentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("comparative_experiment_id") + @ExcludeMissing + fun _comparativeExperimentId(): JsonField<String> = comparativeExperimentId + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") @ExcludeMissing fun _createdAt(): JsonField<String> = createdAt + + /** + * Returns the raw JSON value of [error]. + * + * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("error") @ExcludeMissing fun _error(): JsonField<Boolean> = error + + /** + * Returns the raw JSON value of [feedbackConfig]. + * + * Unlike [feedbackConfig], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("feedback_config") + @ExcludeMissing + fun _feedbackConfig(): JsonField<FeedbackConfig> = feedbackConfig + + /** + * Returns the raw JSON value of [feedbackGroupId]. + * + * Unlike [feedbackGroupId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("feedback_group_id") + @ExcludeMissing + fun _feedbackGroupId(): JsonField<String> = feedbackGroupId + + /** + * Returns the raw JSON value of [feedbackSource]. + * + * Unlike [feedbackSource], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("feedback_source") + @ExcludeMissing + fun _feedbackSource(): JsonField<FeedbackSource> = feedbackSource + + /** + * Returns the raw JSON value of [key]. + * + * Unlike [key], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("key") @ExcludeMissing fun _key(): JsonField<String> = key + + /** + * Returns the raw JSON value of [modifiedAt]. + * + * Unlike [modifiedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("modified_at") + @ExcludeMissing + fun _modifiedAt(): JsonField<String> = modifiedAt + + /** + * Returns the raw JSON value of [runId]. + * + * Unlike [runId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_id") @ExcludeMissing fun _runId(): JsonField<String> = runId + + /** + * Returns the raw JSON value of [sessionId]. + * + * Unlike [sessionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session_id") @ExcludeMissing fun _sessionId(): JsonField<String> = sessionId + + /** + * Returns the raw JSON value of [traceId]. + * + * Unlike [traceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trace_id") @ExcludeMissing fun _traceId(): JsonField<String> = traceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var id: JsonField<String> = JsonMissing.of() + private var comment: JsonField<String> = JsonMissing.of() + private var comparativeExperimentId: JsonField<String> = JsonMissing.of() + private var correction: JsonValue = JsonMissing.of() + private var createdAt: JsonField<String> = JsonMissing.of() + private var error: JsonField<Boolean> = JsonMissing.of() + private var feedbackConfig: JsonField<FeedbackConfig> = JsonMissing.of() + private var feedbackGroupId: JsonField<String> = JsonMissing.of() + private var feedbackSource: JsonField<FeedbackSource> = JsonMissing.of() + private var key: JsonField<String> = JsonMissing.of() + private var modifiedAt: JsonField<String> = JsonMissing.of() + private var runId: JsonField<String> = JsonMissing.of() + private var score: JsonValue = JsonMissing.of() + private var sessionId: JsonField<String> = JsonMissing.of() + private var traceId: JsonField<String> = JsonMissing.of() + private var value: JsonValue = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + id = body.id + comment = body.comment + comparativeExperimentId = body.comparativeExperimentId + correction = body.correction + createdAt = body.createdAt + error = body.error + feedbackConfig = body.feedbackConfig + feedbackGroupId = body.feedbackGroupId + feedbackSource = body.feedbackSource + key = body.key + modifiedAt = body.modifiedAt + runId = body.runId + score = body.score + sessionId = body.sessionId + traceId = body.traceId + value = body.value + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun comment(comment: String) = comment(JsonField.of(comment)) + + /** + * Sets [Builder.comment] to an arbitrary JSON value. + * + * You should usually call [Builder.comment] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun comment(comment: JsonField<String>) = apply { this.comment = comment } + + fun comparativeExperimentId(comparativeExperimentId: String) = + comparativeExperimentId(JsonField.of(comparativeExperimentId)) + + /** + * Sets [Builder.comparativeExperimentId] to an arbitrary JSON value. + * + * You should usually call [Builder.comparativeExperimentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun comparativeExperimentId(comparativeExperimentId: JsonField<String>) = apply { + this.comparativeExperimentId = comparativeExperimentId + } + + fun correction(correction: JsonValue) = apply { this.correction = correction } + + fun createdAt(createdAt: String) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<String>) = apply { this.createdAt = createdAt } + + fun error(error: Boolean) = error(JsonField.of(error)) + + /** + * Sets [Builder.error] to an arbitrary JSON value. + * + * You should usually call [Builder.error] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun error(error: JsonField<Boolean>) = apply { this.error = error } + + fun feedbackConfig(feedbackConfig: FeedbackConfig) = + feedbackConfig(JsonField.of(feedbackConfig)) + + /** + * Sets [Builder.feedbackConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackConfig] with a well-typed [FeedbackConfig] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun feedbackConfig(feedbackConfig: JsonField<FeedbackConfig>) = apply { + this.feedbackConfig = feedbackConfig + } + + fun feedbackGroupId(feedbackGroupId: String) = + feedbackGroupId(JsonField.of(feedbackGroupId)) + + /** + * Sets [Builder.feedbackGroupId] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackGroupId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun feedbackGroupId(feedbackGroupId: JsonField<String>) = apply { + this.feedbackGroupId = feedbackGroupId + } + + fun feedbackSource(feedbackSource: FeedbackSource) = + feedbackSource(JsonField.of(feedbackSource)) + + /** + * Sets [Builder.feedbackSource] to an arbitrary JSON value. + * + * You should usually call [Builder.feedbackSource] with a well-typed [FeedbackSource] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun feedbackSource(feedbackSource: JsonField<FeedbackSource>) = apply { + this.feedbackSource = feedbackSource + } + + fun key(key: String) = key(JsonField.of(key)) + + /** + * Sets [Builder.key] to an arbitrary JSON value. + * + * You should usually call [Builder.key] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun key(key: JsonField<String>) = apply { this.key = key } + + fun modifiedAt(modifiedAt: String) = modifiedAt(JsonField.of(modifiedAt)) + + /** + * Sets [Builder.modifiedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.modifiedAt] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modifiedAt(modifiedAt: JsonField<String>) = apply { this.modifiedAt = modifiedAt } + + fun runId(runId: String) = runId(JsonField.of(runId)) + + /** + * Sets [Builder.runId] to an arbitrary JSON value. + * + * You should usually call [Builder.runId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun runId(runId: JsonField<String>) = apply { this.runId = runId } + + fun score(score: JsonValue) = apply { this.score = score } + + fun sessionId(sessionId: String) = sessionId(JsonField.of(sessionId)) + + /** + * Sets [Builder.sessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sessionId(sessionId: JsonField<String>) = apply { this.sessionId = sessionId } + + fun traceId(traceId: String) = traceId(JsonField.of(traceId)) + + /** + * Sets [Builder.traceId] to an arbitrary JSON value. + * + * You should usually call [Builder.traceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun traceId(traceId: JsonField<String>) = apply { this.traceId = traceId } + + fun value(value: JsonValue) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = + Body( + id, + comment, + comparativeExperimentId, + correction, + createdAt, + error, + feedbackConfig, + feedbackGroupId, + feedbackSource, + key, + modifiedAt, + runId, + score, + sessionId, + traceId, + value, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + id() + comment() + comparativeExperimentId() + createdAt() + error() + feedbackConfig().ifPresent { it.validate() } + feedbackGroupId() + feedbackSource().ifPresent { it.validate() } + key() + modifiedAt() + runId() + sessionId() + traceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (comment.asKnown().isPresent) 1 else 0) + + (if (comparativeExperimentId.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (error.asKnown().isPresent) 1 else 0) + + (feedbackConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (feedbackGroupId.asKnown().isPresent) 1 else 0) + + (feedbackSource.asKnown().getOrNull()?.validity() ?: 0) + + (if (key.asKnown().isPresent) 1 else 0) + + (if (modifiedAt.asKnown().isPresent) 1 else 0) + + (if (runId.asKnown().isPresent) 1 else 0) + + (if (sessionId.asKnown().isPresent) 1 else 0) + + (if (traceId.asKnown().isPresent) 1 else 0) + + class FeedbackConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val categories: JsonField<List<Category>>, + private val max: JsonField<Double>, + private val min: JsonField<Double>, + private val type: JsonField<Type>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("categories") + @ExcludeMissing + categories: JsonField<List<Category>> = JsonMissing.of(), + @JsonProperty("max") @ExcludeMissing max: JsonField<Double> = JsonMissing.of(), + @JsonProperty("min") @ExcludeMissing min: JsonField<Double> = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField<Type> = JsonMissing.of(), + ) : this(categories, max, min, type, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun categories(): Optional<List<Category>> = categories.getOptional("categories") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun max(): Optional<Double> = max.getOptional("max") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun min(): Optional<Double> = min.getOptional("min") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun type(): Optional<Type> = type.getOptional("type") + + /** + * Returns the raw JSON value of [categories]. + * + * Unlike [categories], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("categories") + @ExcludeMissing + fun _categories(): JsonField<List<Category>> = categories + + /** + * Returns the raw JSON value of [max]. + * + * Unlike [max], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("max") @ExcludeMissing fun _max(): JsonField<Double> = max + + /** + * Returns the raw JSON value of [min]. + * + * Unlike [min], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("min") @ExcludeMissing fun _min(): JsonField<Double> = min + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField<Type> = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [FeedbackConfig]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackConfig]. */ + class Builder internal constructor() { + + private var categories: JsonField<MutableList<Category>>? = null + private var max: JsonField<Double> = JsonMissing.of() + private var min: JsonField<Double> = JsonMissing.of() + private var type: JsonField<Type> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(feedbackConfig: FeedbackConfig) = apply { + categories = feedbackConfig.categories.map { it.toMutableList() } + max = feedbackConfig.max + min = feedbackConfig.min + type = feedbackConfig.type + additionalProperties = feedbackConfig.additionalProperties.toMutableMap() + } + + fun categories(categories: List<Category>) = categories(JsonField.of(categories)) + + /** + * Sets [Builder.categories] to an arbitrary JSON value. + * + * You should usually call [Builder.categories] with a well-typed `List<Category>` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun categories(categories: JsonField<List<Category>>) = apply { + this.categories = categories.map { it.toMutableList() } + } + + /** + * Adds a single [Category] to [categories]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCategory(category: Category) = apply { + categories = + (categories ?: JsonField.of(mutableListOf())).also { + checkKnown("categories", it).add(category) + } + } + + fun max(max: Double) = max(JsonField.of(max)) + + /** + * Sets [Builder.max] to an arbitrary JSON value. + * + * You should usually call [Builder.max] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun max(max: JsonField<Double>) = apply { this.max = max } + + fun min(min: Double) = min(JsonField.of(min)) + + /** + * Sets [Builder.min] to an arbitrary JSON value. + * + * You should usually call [Builder.min] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun min(min: JsonField<Double>) = apply { this.min = min } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField<Type>) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FeedbackConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FeedbackConfig = + FeedbackConfig( + (categories ?: JsonMissing.of()).map { it.toImmutable() }, + max, + min, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): FeedbackConfig = apply { + if (validated) { + return@apply + } + + categories().ifPresent { it.forEach { it.validate() } } + max() + min() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (categories.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (max.asKnown().isPresent) 1 else 0) + + (if (min.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Category + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val label: JsonField<String>, + private val value: JsonField<Double>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("label") + @ExcludeMissing + label: JsonField<String> = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + value: JsonField<Double> = JsonMissing.of(), + ) : this(label, value, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun label(): Optional<String> = label.getOptional("label") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun value(): Optional<Double> = value.getOptional("value") + + /** + * Returns the raw JSON value of [label]. + * + * Unlike [label], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("label") @ExcludeMissing fun _label(): JsonField<String> = label + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField<Double> = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Category]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Category]. */ + class Builder internal constructor() { + + private var label: JsonField<String> = JsonMissing.of() + private var value: JsonField<Double> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(category: Category) = apply { + label = category.label + value = category.value + additionalProperties = category.additionalProperties.toMutableMap() + } + + fun label(label: String) = label(JsonField.of(label)) + + /** + * Sets [Builder.label] to an arbitrary JSON value. + * + * You should usually call [Builder.label] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun label(label: JsonField<String>) = apply { this.label = label } + + fun value(value: Double) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun value(value: JsonField<Double>) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Category]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Category = + Category(label, value, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Category = apply { + if (validated) { + return@apply + } + + label() + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (label.asKnown().isPresent) 1 else 0) + + (if (value.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Category && + label == other.label && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(label, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Category{label=$label, value=$value, additionalProperties=$additionalProperties}" + } + + class Type @JsonCreator private constructor(private val value: JsonField<String>) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val CONTINUOUS = of("continuous") + + @JvmField val CATEGORICAL = of("categorical") + + @JvmField val FREEFORM = of("freeform") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + CONTINUOUS, + CATEGORICAL, + FREEFORM, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CONTINUOUS, + CATEGORICAL, + FREEFORM, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CONTINUOUS -> Value.CONTINUOUS + CATEGORICAL -> Value.CATEGORICAL + FREEFORM -> Value.FREEFORM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + CONTINUOUS -> Known.CONTINUOUS + CATEGORICAL -> Known.CATEGORICAL + FREEFORM -> Known.FREEFORM + else -> throw LangsmithApiInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackConfig && + categories == other.categories && + max == other.max && + min == other.min && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(categories, max, min, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FeedbackConfig{categories=$categories, max=$max, min=$min, type=$type, additionalProperties=$additionalProperties}" + } + + class FeedbackSource + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val metadata: JsonField<Metadata>, + private val type: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField<Metadata> = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField<String> = JsonMissing.of(), + ) : this(metadata, type, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun metadata(): Optional<Metadata> = metadata.getOptional("metadata") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun type(): Optional<String> = type.getOptional("type") + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField<Metadata> = metadata + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField<String> = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [FeedbackSource]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackSource]. */ + class Builder internal constructor() { + + private var metadata: JsonField<Metadata> = JsonMissing.of() + private var type: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(feedbackSource: FeedbackSource) = apply { + metadata = feedbackSource.metadata + type = feedbackSource.type + additionalProperties = feedbackSource.additionalProperties.toMutableMap() + } + + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun metadata(metadata: JsonField<Metadata>) = apply { this.metadata = metadata } + + fun type(type: String) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField<String>) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FeedbackSource]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FeedbackSource = + FeedbackSource(metadata, type, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): FeedbackSource = apply { + if (validated) { + return@apply + } + + metadata().ifPresent { it.validate() } + type() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (type.asKnown().isPresent) 1 else 0) + + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackSource && + metadata == other.metadata && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(metadata, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FeedbackSource{metadata=$metadata, type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + id == other.id && + comment == other.comment && + comparativeExperimentId == other.comparativeExperimentId && + correction == other.correction && + createdAt == other.createdAt && + error == other.error && + feedbackConfig == other.feedbackConfig && + feedbackGroupId == other.feedbackGroupId && + feedbackSource == other.feedbackSource && + key == other.key && + modifiedAt == other.modifiedAt && + runId == other.runId && + score == other.score && + sessionId == other.sessionId && + traceId == other.traceId && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + comment, + comparativeExperimentId, + correction, + createdAt, + error, + feedbackConfig, + feedbackGroupId, + feedbackSource, + key, + modifiedAt, + runId, + score, + sessionId, + traceId, + value, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{id=$id, comment=$comment, comparativeExperimentId=$comparativeExperimentId, correction=$correction, createdAt=$createdAt, error=$error, feedbackConfig=$feedbackConfig, feedbackGroupId=$feedbackGroupId, feedbackSource=$feedbackSource, key=$key, modifiedAt=$modifiedAt, runId=$runId, score=$score, sessionId=$sessionId, traceId=$traceId, value=$value, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackIngestBatchParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "FeedbackIngestBatchParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/feedback/FeedbackIngestBatchResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/feedback/FeedbackIngestBatchResponse.kt new file mode 100644 index 00000000..18175bca --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/feedback/FeedbackIngestBatchResponse.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.feedback + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Objects + +class FeedbackIngestBatchResponse +@JsonCreator +private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> +) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [FeedbackIngestBatchResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FeedbackIngestBatchResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(feedbackIngestBatchResponse: FeedbackIngestBatchResponse) = apply { + additionalProperties = feedbackIngestBatchResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FeedbackIngestBatchResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FeedbackIngestBatchResponse = + FeedbackIngestBatchResponse(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): FeedbackIngestBatchResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FeedbackIngestBatchResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FeedbackIngestBatchResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertActionBase.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertActionBase.kt new file mode 100644 index 00000000..06c70975 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertActionBase.kt @@ -0,0 +1,383 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.alerts + +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.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class AlertActionBase +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val config: JsonValue, + private val target: JsonField<Target>, + private val id: JsonField<String>, + private val alertRuleId: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("config") @ExcludeMissing config: JsonValue = JsonMissing.of(), + @JsonProperty("target") @ExcludeMissing target: JsonField<Target> = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("alert_rule_id") + @ExcludeMissing + alertRuleId: JsonField<String> = JsonMissing.of(), + ) : this(config, target, id, alertRuleId, mutableMapOf()) + + @JsonProperty("config") @ExcludeMissing fun _config(): JsonValue = config + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun target(): Target = target.getRequired("target") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun alertRuleId(): Optional<String> = alertRuleId.getOptional("alert_rule_id") + + /** + * Returns the raw JSON value of [target]. + * + * Unlike [target], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("target") @ExcludeMissing fun _target(): JsonField<Target> = target + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [alertRuleId]. + * + * Unlike [alertRuleId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("alert_rule_id") + @ExcludeMissing + fun _alertRuleId(): JsonField<String> = alertRuleId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AlertActionBase]. + * + * The following fields are required: + * ```java + * .config() + * .target() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AlertActionBase]. */ + class Builder internal constructor() { + + private var config: JsonValue? = null + private var target: JsonField<Target>? = null + private var id: JsonField<String> = JsonMissing.of() + private var alertRuleId: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(alertActionBase: AlertActionBase) = apply { + config = alertActionBase.config + target = alertActionBase.target + id = alertActionBase.id + alertRuleId = alertActionBase.alertRuleId + additionalProperties = alertActionBase.additionalProperties.toMutableMap() + } + + fun config(config: JsonValue) = apply { this.config = config } + + fun target(target: Target) = target(JsonField.of(target)) + + /** + * Sets [Builder.target] to an arbitrary JSON value. + * + * You should usually call [Builder.target] with a well-typed [Target] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun target(target: JsonField<Target>) = apply { this.target = target } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun alertRuleId(alertRuleId: String) = alertRuleId(JsonField.of(alertRuleId)) + + /** + * Sets [Builder.alertRuleId] to an arbitrary JSON value. + * + * You should usually call [Builder.alertRuleId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun alertRuleId(alertRuleId: JsonField<String>) = apply { this.alertRuleId = alertRuleId } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AlertActionBase]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .config() + * .target() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AlertActionBase = + AlertActionBase( + checkRequired("config", config), + checkRequired("target", target), + id, + alertRuleId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AlertActionBase = apply { + if (validated) { + return@apply + } + + target().validate() + id() + alertRuleId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (target.asKnown().getOrNull()?.validity() ?: 0) + + (if (id.asKnown().isPresent) 1 else 0) + + (if (alertRuleId.asKnown().isPresent) 1 else 0) + + class Target @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val PAGERDUTY = of("pagerduty") + + @JvmField val WEBHOOK = of("webhook") + + @JvmStatic fun of(value: String) = Target(JsonField.of(value)) + } + + /** An enum containing [Target]'s known values. */ + enum class Known { + PAGERDUTY, + WEBHOOK, + } + + /** + * An enum containing [Target]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Target] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PAGERDUTY, + WEBHOOK, + /** An enum member indicating that [Target] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PAGERDUTY -> Value.PAGERDUTY + WEBHOOK -> Value.WEBHOOK + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PAGERDUTY -> Known.PAGERDUTY + WEBHOOK -> Known.WEBHOOK + else -> throw LangsmithApiInvalidDataException("Unknown Target: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Target = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Target && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AlertActionBase && + config == other.config && + target == other.target && + id == other.id && + alertRuleId == other.alertRuleId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(config, target, id, alertRuleId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AlertActionBase{config=$config, target=$target, id=$id, alertRuleId=$alertRuleId, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertCreateParams.kt new file mode 100644 index 00000000..0149cb98 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertCreateParams.kt @@ -0,0 +1,527 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.alerts + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Creates a new alert rule. The request body must be a JSON-encoded alert rule object that follows + * the CreateAlertRuleRequest schema. + */ +class AlertCreateParams +private constructor( + private val sessionId: JsonValue?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun sessionId(): Optional<JsonValue> = Optional.ofNullable(sessionId) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun actions(): List<AlertActionBase> = body.actions() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun rule(): AlertRuleBase = body.rule() + + /** + * Returns the raw JSON value of [actions]. + * + * Unlike [actions], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _actions(): JsonField<List<AlertActionBase>> = body._actions() + + /** + * Returns the raw JSON value of [rule]. + * + * Unlike [rule], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _rule(): JsonField<AlertRuleBase> = body._rule() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AlertCreateParams]. + * + * The following fields are required: + * ```java + * .actions() + * .rule() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AlertCreateParams]. */ + class Builder internal constructor() { + + private var sessionId: JsonValue? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(alertCreateParams: AlertCreateParams) = apply { + sessionId = alertCreateParams.sessionId + body = alertCreateParams.body.toBuilder() + additionalHeaders = alertCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = alertCreateParams.additionalQueryParams.toBuilder() + } + + fun sessionId(sessionId: JsonValue?) = apply { this.sessionId = sessionId } + + /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ + fun sessionId(sessionId: Optional<JsonValue>) = sessionId(sessionId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [actions] + * - [rule] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun actions(actions: List<AlertActionBase>) = apply { body.actions(actions) } + + /** + * Sets [Builder.actions] to an arbitrary JSON value. + * + * You should usually call [Builder.actions] with a well-typed `List<AlertActionBase>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun actions(actions: JsonField<List<AlertActionBase>>) = apply { body.actions(actions) } + + /** + * Adds a single [AlertActionBase] to [actions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAction(action: AlertActionBase) = apply { body.addAction(action) } + + fun rule(rule: AlertRuleBase) = apply { body.rule(rule) } + + /** + * Sets [Builder.rule] to an arbitrary JSON value. + * + * You should usually call [Builder.rule] with a well-typed [AlertRuleBase] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun rule(rule: JsonField<AlertRuleBase>) = apply { body.rule(rule) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [AlertCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .actions() + * .rule() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AlertCreateParams = + AlertCreateParams( + sessionId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> sessionId?.toString() ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val actions: JsonField<List<AlertActionBase>>, + private val rule: JsonField<AlertRuleBase>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("actions") + @ExcludeMissing + actions: JsonField<List<AlertActionBase>> = JsonMissing.of(), + @JsonProperty("rule") @ExcludeMissing rule: JsonField<AlertRuleBase> = JsonMissing.of(), + ) : this(actions, rule, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun actions(): List<AlertActionBase> = actions.getRequired("actions") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun rule(): AlertRuleBase = rule.getRequired("rule") + + /** + * Returns the raw JSON value of [actions]. + * + * Unlike [actions], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("actions") + @ExcludeMissing + fun _actions(): JsonField<List<AlertActionBase>> = actions + + /** + * Returns the raw JSON value of [rule]. + * + * Unlike [rule], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rule") @ExcludeMissing fun _rule(): JsonField<AlertRuleBase> = rule + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .actions() + * .rule() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var actions: JsonField<MutableList<AlertActionBase>>? = null + private var rule: JsonField<AlertRuleBase>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + actions = body.actions.map { it.toMutableList() } + rule = body.rule + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun actions(actions: List<AlertActionBase>) = actions(JsonField.of(actions)) + + /** + * Sets [Builder.actions] to an arbitrary JSON value. + * + * You should usually call [Builder.actions] with a well-typed `List<AlertActionBase>` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun actions(actions: JsonField<List<AlertActionBase>>) = apply { + this.actions = actions.map { it.toMutableList() } + } + + /** + * Adds a single [AlertActionBase] to [actions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAction(action: AlertActionBase) = apply { + actions = + (actions ?: JsonField.of(mutableListOf())).also { + checkKnown("actions", it).add(action) + } + } + + fun rule(rule: AlertRuleBase) = rule(JsonField.of(rule)) + + /** + * Sets [Builder.rule] to an arbitrary JSON value. + * + * You should usually call [Builder.rule] with a well-typed [AlertRuleBase] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rule(rule: JsonField<AlertRuleBase>) = apply { this.rule = rule } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .actions() + * .rule() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("actions", actions).map { it.toImmutable() }, + checkRequired("rule", rule), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + actions().forEach { it.validate() } + rule().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (actions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (rule.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + actions == other.actions && + rule == other.rule && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(actions, rule, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{actions=$actions, rule=$rule, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AlertCreateParams && + sessionId == other.sessionId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(sessionId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "AlertCreateParams{sessionId=$sessionId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertDeleteParams.kt new file mode 100644 index 00000000..28411b53 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertDeleteParams.kt @@ -0,0 +1,258 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.alerts + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Deletes an alert rule */ +class AlertDeleteParams +private constructor( + private val sessionId: JsonValue, + private val alertRuleId: JsonValue?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun sessionId(): JsonValue = sessionId + + fun alertRuleId(): Optional<JsonValue> = Optional.ofNullable(alertRuleId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AlertDeleteParams]. + * + * The following fields are required: + * ```java + * .sessionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AlertDeleteParams]. */ + class Builder internal constructor() { + + private var sessionId: JsonValue? = null + private var alertRuleId: JsonValue? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(alertDeleteParams: AlertDeleteParams) = apply { + sessionId = alertDeleteParams.sessionId + alertRuleId = alertDeleteParams.alertRuleId + additionalHeaders = alertDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = alertDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = alertDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun sessionId(sessionId: JsonValue) = apply { this.sessionId = sessionId } + + fun alertRuleId(alertRuleId: JsonValue?) = apply { this.alertRuleId = alertRuleId } + + /** Alias for calling [Builder.alertRuleId] with `alertRuleId.orElse(null)`. */ + fun alertRuleId(alertRuleId: Optional<JsonValue>) = alertRuleId(alertRuleId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [AlertDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .sessionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AlertDeleteParams = + AlertDeleteParams( + checkRequired("sessionId", sessionId), + alertRuleId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> sessionId.toString() + 1 -> alertRuleId?.toString() ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AlertDeleteParams && + sessionId == other.sessionId && + alertRuleId == other.alertRuleId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + sessionId, + alertRuleId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "AlertDeleteParams{sessionId=$sessionId, alertRuleId=$alertRuleId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertDeleteResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertDeleteResponse.kt new file mode 100644 index 00000000..d9f54b0c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertDeleteResponse.kt @@ -0,0 +1,109 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.alerts + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Objects + +class AlertDeleteResponse +@JsonCreator +private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> +) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [AlertDeleteResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AlertDeleteResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(alertDeleteResponse: AlertDeleteResponse) = apply { + additionalProperties = alertDeleteResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AlertDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AlertDeleteResponse = AlertDeleteResponse(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): AlertDeleteResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AlertDeleteResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "AlertDeleteResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertRetrieveParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertRetrieveParams.kt new file mode 100644 index 00000000..c0ab531f --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertRetrieveParams.kt @@ -0,0 +1,218 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.alerts + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Gets an alert rule. */ +class AlertRetrieveParams +private constructor( + private val sessionId: JsonValue, + private val alertRuleId: JsonValue?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun sessionId(): JsonValue = sessionId + + fun alertRuleId(): Optional<JsonValue> = Optional.ofNullable(alertRuleId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AlertRetrieveParams]. + * + * The following fields are required: + * ```java + * .sessionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AlertRetrieveParams]. */ + class Builder internal constructor() { + + private var sessionId: JsonValue? = null + private var alertRuleId: JsonValue? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(alertRetrieveParams: AlertRetrieveParams) = apply { + sessionId = alertRetrieveParams.sessionId + alertRuleId = alertRetrieveParams.alertRuleId + additionalHeaders = alertRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = alertRetrieveParams.additionalQueryParams.toBuilder() + } + + fun sessionId(sessionId: JsonValue) = apply { this.sessionId = sessionId } + + fun alertRuleId(alertRuleId: JsonValue?) = apply { this.alertRuleId = alertRuleId } + + /** Alias for calling [Builder.alertRuleId] with `alertRuleId.orElse(null)`. */ + fun alertRuleId(alertRuleId: Optional<JsonValue>) = alertRuleId(alertRuleId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [AlertRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .sessionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AlertRetrieveParams = + AlertRetrieveParams( + checkRequired("sessionId", sessionId), + alertRuleId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> sessionId.toString() + 1 -> alertRuleId?.toString() ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AlertRetrieveParams && + sessionId == other.sessionId && + alertRuleId == other.alertRuleId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(sessionId, alertRuleId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "AlertRetrieveParams{sessionId=$sessionId, alertRuleId=$alertRuleId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertRuleBase.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertRuleBase.kt new file mode 100644 index 00000000..3e95ba9d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertRuleBase.kt @@ -0,0 +1,1182 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.alerts + +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.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class AlertRuleBase +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val aggregation: JsonField<Aggregation>, + private val attribute: JsonField<Attribute>, + private val description: JsonField<String>, + private val name: JsonField<String>, + private val operator: JsonField<Operator>, + private val type: JsonField<Type>, + private val windowMinutes: JsonField<Long>, + private val id: JsonField<String>, + private val denominatorFilter: JsonField<String>, + private val filter: JsonField<String>, + private val threshold: JsonField<Double>, + private val thresholdMultiplier: JsonField<Double>, + private val thresholdWindowMinutes: JsonField<Long>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("aggregation") + @ExcludeMissing + aggregation: JsonField<Aggregation> = JsonMissing.of(), + @JsonProperty("attribute") + @ExcludeMissing + attribute: JsonField<Attribute> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("operator") @ExcludeMissing operator: JsonField<Operator> = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField<Type> = JsonMissing.of(), + @JsonProperty("window_minutes") + @ExcludeMissing + windowMinutes: JsonField<Long> = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("denominator_filter") + @ExcludeMissing + denominatorFilter: JsonField<String> = JsonMissing.of(), + @JsonProperty("filter") @ExcludeMissing filter: JsonField<String> = JsonMissing.of(), + @JsonProperty("threshold") @ExcludeMissing threshold: JsonField<Double> = JsonMissing.of(), + @JsonProperty("threshold_multiplier") + @ExcludeMissing + thresholdMultiplier: JsonField<Double> = JsonMissing.of(), + @JsonProperty("threshold_window_minutes") + @ExcludeMissing + thresholdWindowMinutes: JsonField<Long> = JsonMissing.of(), + ) : this( + aggregation, + attribute, + description, + name, + operator, + type, + windowMinutes, + id, + denominatorFilter, + filter, + threshold, + thresholdMultiplier, + thresholdWindowMinutes, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun aggregation(): Aggregation = aggregation.getRequired("aggregation") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun attribute(): Attribute = attribute.getRequired("attribute") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun description(): String = description.getRequired("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * max 15 minutes for alert rule + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun windowMinutes(): Long = windowMinutes.getRequired("window_minutes") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun denominatorFilter(): Optional<String> = denominatorFilter.getOptional("denominator_filter") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun filter(): Optional<String> = filter.getOptional("filter") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun threshold(): Optional<Double> = threshold.getOptional("threshold") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun thresholdMultiplier(): Optional<Double> = + thresholdMultiplier.getOptional("threshold_multiplier") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun thresholdWindowMinutes(): Optional<Long> = + thresholdWindowMinutes.getOptional("threshold_window_minutes") + + /** + * Returns the raw JSON value of [aggregation]. + * + * Unlike [aggregation], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("aggregation") + @ExcludeMissing + fun _aggregation(): JsonField<Aggregation> = aggregation + + /** + * Returns the raw JSON value of [attribute]. + * + * Unlike [attribute], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("attribute") @ExcludeMissing fun _attribute(): JsonField<Attribute> = attribute + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField<Operator> = operator + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField<Type> = type + + /** + * Returns the raw JSON value of [windowMinutes]. + * + * Unlike [windowMinutes], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("window_minutes") + @ExcludeMissing + fun _windowMinutes(): JsonField<Long> = windowMinutes + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [denominatorFilter]. + * + * Unlike [denominatorFilter], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("denominator_filter") + @ExcludeMissing + fun _denominatorFilter(): JsonField<String> = denominatorFilter + + /** + * Returns the raw JSON value of [filter]. + * + * Unlike [filter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField<String> = filter + + /** + * Returns the raw JSON value of [threshold]. + * + * Unlike [threshold], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("threshold") @ExcludeMissing fun _threshold(): JsonField<Double> = threshold + + /** + * Returns the raw JSON value of [thresholdMultiplier]. + * + * Unlike [thresholdMultiplier], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("threshold_multiplier") + @ExcludeMissing + fun _thresholdMultiplier(): JsonField<Double> = thresholdMultiplier + + /** + * Returns the raw JSON value of [thresholdWindowMinutes]. + * + * Unlike [thresholdWindowMinutes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("threshold_window_minutes") + @ExcludeMissing + fun _thresholdWindowMinutes(): JsonField<Long> = thresholdWindowMinutes + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AlertRuleBase]. + * + * The following fields are required: + * ```java + * .aggregation() + * .attribute() + * .description() + * .name() + * .operator() + * .type() + * .windowMinutes() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AlertRuleBase]. */ + class Builder internal constructor() { + + private var aggregation: JsonField<Aggregation>? = null + private var attribute: JsonField<Attribute>? = null + private var description: JsonField<String>? = null + private var name: JsonField<String>? = null + private var operator: JsonField<Operator>? = null + private var type: JsonField<Type>? = null + private var windowMinutes: JsonField<Long>? = null + private var id: JsonField<String> = JsonMissing.of() + private var denominatorFilter: JsonField<String> = JsonMissing.of() + private var filter: JsonField<String> = JsonMissing.of() + private var threshold: JsonField<Double> = JsonMissing.of() + private var thresholdMultiplier: JsonField<Double> = JsonMissing.of() + private var thresholdWindowMinutes: JsonField<Long> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(alertRuleBase: AlertRuleBase) = apply { + aggregation = alertRuleBase.aggregation + attribute = alertRuleBase.attribute + description = alertRuleBase.description + name = alertRuleBase.name + operator = alertRuleBase.operator + type = alertRuleBase.type + windowMinutes = alertRuleBase.windowMinutes + id = alertRuleBase.id + denominatorFilter = alertRuleBase.denominatorFilter + filter = alertRuleBase.filter + threshold = alertRuleBase.threshold + thresholdMultiplier = alertRuleBase.thresholdMultiplier + thresholdWindowMinutes = alertRuleBase.thresholdWindowMinutes + additionalProperties = alertRuleBase.additionalProperties.toMutableMap() + } + + fun aggregation(aggregation: Aggregation) = aggregation(JsonField.of(aggregation)) + + /** + * Sets [Builder.aggregation] to an arbitrary JSON value. + * + * You should usually call [Builder.aggregation] with a well-typed [Aggregation] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun aggregation(aggregation: JsonField<Aggregation>) = apply { + this.aggregation = aggregation + } + + fun attribute(attribute: Attribute) = attribute(JsonField.of(attribute)) + + /** + * Sets [Builder.attribute] to an arbitrary JSON value. + * + * You should usually call [Builder.attribute] with a well-typed [Attribute] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun attribute(attribute: JsonField<Attribute>) = apply { this.attribute = attribute } + + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { this.description = description } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun operator(operator: JsonField<Operator>) = apply { this.operator = operator } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField<Type>) = apply { this.type = type } + + /** max 15 minutes for alert rule */ + fun windowMinutes(windowMinutes: Long) = windowMinutes(JsonField.of(windowMinutes)) + + /** + * Sets [Builder.windowMinutes] to an arbitrary JSON value. + * + * You should usually call [Builder.windowMinutes] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun windowMinutes(windowMinutes: JsonField<Long>) = apply { + this.windowMinutes = windowMinutes + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun denominatorFilter(denominatorFilter: String) = + denominatorFilter(JsonField.of(denominatorFilter)) + + /** + * Sets [Builder.denominatorFilter] to an arbitrary JSON value. + * + * You should usually call [Builder.denominatorFilter] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun denominatorFilter(denominatorFilter: JsonField<String>) = apply { + this.denominatorFilter = denominatorFilter + } + + fun filter(filter: String) = filter(JsonField.of(filter)) + + /** + * Sets [Builder.filter] to an arbitrary JSON value. + * + * You should usually call [Builder.filter] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun filter(filter: JsonField<String>) = apply { this.filter = filter } + + fun threshold(threshold: Double) = threshold(JsonField.of(threshold)) + + /** + * Sets [Builder.threshold] to an arbitrary JSON value. + * + * You should usually call [Builder.threshold] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun threshold(threshold: JsonField<Double>) = apply { this.threshold = threshold } + + fun thresholdMultiplier(thresholdMultiplier: Double) = + thresholdMultiplier(JsonField.of(thresholdMultiplier)) + + /** + * Sets [Builder.thresholdMultiplier] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdMultiplier] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun thresholdMultiplier(thresholdMultiplier: JsonField<Double>) = apply { + this.thresholdMultiplier = thresholdMultiplier + } + + fun thresholdWindowMinutes(thresholdWindowMinutes: Long) = + thresholdWindowMinutes(JsonField.of(thresholdWindowMinutes)) + + /** + * Sets [Builder.thresholdWindowMinutes] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdWindowMinutes] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun thresholdWindowMinutes(thresholdWindowMinutes: JsonField<Long>) = apply { + this.thresholdWindowMinutes = thresholdWindowMinutes + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AlertRuleBase]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .aggregation() + * .attribute() + * .description() + * .name() + * .operator() + * .type() + * .windowMinutes() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AlertRuleBase = + AlertRuleBase( + checkRequired("aggregation", aggregation), + checkRequired("attribute", attribute), + checkRequired("description", description), + checkRequired("name", name), + checkRequired("operator", operator), + checkRequired("type", type), + checkRequired("windowMinutes", windowMinutes), + id, + denominatorFilter, + filter, + threshold, + thresholdMultiplier, + thresholdWindowMinutes, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AlertRuleBase = apply { + if (validated) { + return@apply + } + + aggregation().validate() + attribute().validate() + description() + name() + operator().validate() + type().validate() + windowMinutes() + id() + denominatorFilter() + filter() + threshold() + thresholdMultiplier() + thresholdWindowMinutes() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (aggregation.asKnown().getOrNull()?.validity() ?: 0) + + (attribute.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (operator.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (windowMinutes.asKnown().isPresent) 1 else 0) + + (if (id.asKnown().isPresent) 1 else 0) + + (if (denominatorFilter.asKnown().isPresent) 1 else 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (if (threshold.asKnown().isPresent) 1 else 0) + + (if (thresholdMultiplier.asKnown().isPresent) 1 else 0) + + (if (thresholdWindowMinutes.asKnown().isPresent) 1 else 0) + + class Aggregation @JsonCreator private constructor(private val value: JsonField<String>) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val AVG = of("avg") + + @JvmField val SUM = of("sum") + + @JvmField val PCT = of("pct") + + @JvmStatic fun of(value: String) = Aggregation(JsonField.of(value)) + } + + /** An enum containing [Aggregation]'s known values. */ + enum class Known { + AVG, + SUM, + PCT, + } + + /** + * An enum containing [Aggregation]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Aggregation] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AVG, + SUM, + PCT, + /** + * An enum member indicating that [Aggregation] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AVG -> Value.AVG + SUM -> Value.SUM + PCT -> Value.PCT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + AVG -> Known.AVG + SUM -> Known.SUM + PCT -> Known.PCT + else -> throw LangsmithApiInvalidDataException("Unknown Aggregation: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Aggregation = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Aggregation && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Attribute @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val LATENCY = of("latency") + + @JvmField val ERROR_COUNT = of("error_count") + + @JvmField val FEEDBACK_SCORE = of("feedback_score") + + @JvmField val RUN_LATENCY = of("run_latency") + + @JvmField val RUN_COUNT = of("run_count") + + @JvmStatic fun of(value: String) = Attribute(JsonField.of(value)) + } + + /** An enum containing [Attribute]'s known values. */ + enum class Known { + LATENCY, + ERROR_COUNT, + FEEDBACK_SCORE, + RUN_LATENCY, + RUN_COUNT, + } + + /** + * An enum containing [Attribute]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Attribute] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LATENCY, + ERROR_COUNT, + FEEDBACK_SCORE, + RUN_LATENCY, + RUN_COUNT, + /** + * An enum member indicating that [Attribute] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LATENCY -> Value.LATENCY + ERROR_COUNT -> Value.ERROR_COUNT + FEEDBACK_SCORE -> Value.FEEDBACK_SCORE + RUN_LATENCY -> Value.RUN_LATENCY + RUN_COUNT -> Value.RUN_COUNT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + LATENCY -> Known.LATENCY + ERROR_COUNT -> Known.ERROR_COUNT + FEEDBACK_SCORE -> Known.FEEDBACK_SCORE + RUN_LATENCY -> Known.RUN_LATENCY + RUN_COUNT -> Known.RUN_COUNT + else -> throw LangsmithApiInvalidDataException("Unknown Attribute: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Attribute = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Attribute && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Operator @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val GTE = of("gte") + + @JvmField val LTE = of("lte") + + @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + GTE, + LTE, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GTE, + LTE, + /** An enum member indicating that [Operator] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GTE -> Value.GTE + LTE -> Value.LTE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + GTE -> Known.GTE + LTE -> Known.LTE + else -> throw LangsmithApiInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Type @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val THRESHOLD = of("threshold") + + @JvmField val CHANGE = of("change") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + THRESHOLD, + CHANGE, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + THRESHOLD, + CHANGE, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + THRESHOLD -> Value.THRESHOLD + CHANGE -> Value.CHANGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + THRESHOLD -> Known.THRESHOLD + CHANGE -> Known.CHANGE + else -> throw LangsmithApiInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AlertRuleBase && + aggregation == other.aggregation && + attribute == other.attribute && + description == other.description && + name == other.name && + operator == other.operator && + type == other.type && + windowMinutes == other.windowMinutes && + id == other.id && + denominatorFilter == other.denominatorFilter && + filter == other.filter && + threshold == other.threshold && + thresholdMultiplier == other.thresholdMultiplier && + thresholdWindowMinutes == other.thresholdWindowMinutes && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + aggregation, + attribute, + description, + name, + operator, + type, + windowMinutes, + id, + denominatorFilter, + filter, + threshold, + thresholdMultiplier, + thresholdWindowMinutes, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AlertRuleBase{aggregation=$aggregation, attribute=$attribute, description=$description, name=$name, operator=$operator, type=$type, windowMinutes=$windowMinutes, id=$id, denominatorFilter=$denominatorFilter, filter=$filter, threshold=$threshold, thresholdMultiplier=$thresholdMultiplier, thresholdWindowMinutes=$thresholdWindowMinutes, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertRuleResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertRuleResponse.kt new file mode 100644 index 00000000..f2c8204a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertRuleResponse.kt @@ -0,0 +1,1916 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.alerts + +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.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class AlertRuleResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val actions: JsonField<List<Action>>, + private val rule: JsonField<Rule>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("actions") + @ExcludeMissing + actions: JsonField<List<Action>> = JsonMissing.of(), + @JsonProperty("rule") @ExcludeMissing rule: JsonField<Rule> = JsonMissing.of(), + ) : this(actions, rule, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun actions(): Optional<List<Action>> = actions.getOptional("actions") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun rule(): Optional<Rule> = rule.getOptional("rule") + + /** + * Returns the raw JSON value of [actions]. + * + * Unlike [actions], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("actions") @ExcludeMissing fun _actions(): JsonField<List<Action>> = actions + + /** + * Returns the raw JSON value of [rule]. + * + * Unlike [rule], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rule") @ExcludeMissing fun _rule(): JsonField<Rule> = rule + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [AlertRuleResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AlertRuleResponse]. */ + class Builder internal constructor() { + + private var actions: JsonField<MutableList<Action>>? = null + private var rule: JsonField<Rule> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(alertRuleResponse: AlertRuleResponse) = apply { + actions = alertRuleResponse.actions.map { it.toMutableList() } + rule = alertRuleResponse.rule + additionalProperties = alertRuleResponse.additionalProperties.toMutableMap() + } + + fun actions(actions: List<Action>) = actions(JsonField.of(actions)) + + /** + * Sets [Builder.actions] to an arbitrary JSON value. + * + * You should usually call [Builder.actions] with a well-typed `List<Action>` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun actions(actions: JsonField<List<Action>>) = apply { + this.actions = actions.map { it.toMutableList() } + } + + /** + * Adds a single [Action] to [actions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAction(action: Action) = apply { + actions = + (actions ?: JsonField.of(mutableListOf())).also { + checkKnown("actions", it).add(action) + } + } + + fun rule(rule: Rule) = rule(JsonField.of(rule)) + + /** + * Sets [Builder.rule] to an arbitrary JSON value. + * + * You should usually call [Builder.rule] with a well-typed [Rule] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun rule(rule: JsonField<Rule>) = apply { this.rule = rule } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AlertRuleResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AlertRuleResponse = + AlertRuleResponse( + (actions ?: JsonMissing.of()).map { it.toImmutable() }, + rule, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AlertRuleResponse = apply { + if (validated) { + return@apply + } + + actions().ifPresent { it.forEach { it.validate() } } + rule().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (actions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (rule.asKnown().getOrNull()?.validity() ?: 0) + + class Action + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val config: JsonValue, + private val target: JsonField<Target>, + private val id: JsonField<String>, + private val alertRuleId: JsonField<String>, + private val createdAt: JsonField<String>, + private val updatedAt: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("config") @ExcludeMissing config: JsonValue = JsonMissing.of(), + @JsonProperty("target") @ExcludeMissing target: JsonField<Target> = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("alert_rule_id") + @ExcludeMissing + alertRuleId: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<String> = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField<String> = JsonMissing.of(), + ) : this(config, target, id, alertRuleId, createdAt, updatedAt, mutableMapOf()) + + @JsonProperty("config") @ExcludeMissing fun _config(): JsonValue = config + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun target(): Target = target.getRequired("target") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun alertRuleId(): Optional<String> = alertRuleId.getOptional("alert_rule_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun createdAt(): Optional<String> = createdAt.getOptional("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun updatedAt(): Optional<String> = updatedAt.getOptional("updated_at") + + /** + * Returns the raw JSON value of [target]. + * + * Unlike [target], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("target") @ExcludeMissing fun _target(): JsonField<Target> = target + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [alertRuleId]. + * + * Unlike [alertRuleId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("alert_rule_id") + @ExcludeMissing + fun _alertRuleId(): JsonField<String> = alertRuleId + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") @ExcludeMissing fun _createdAt(): JsonField<String> = createdAt + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") @ExcludeMissing fun _updatedAt(): JsonField<String> = updatedAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Action]. + * + * The following fields are required: + * ```java + * .config() + * .target() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Action]. */ + class Builder internal constructor() { + + private var config: JsonValue? = null + private var target: JsonField<Target>? = null + private var id: JsonField<String> = JsonMissing.of() + private var alertRuleId: JsonField<String> = JsonMissing.of() + private var createdAt: JsonField<String> = JsonMissing.of() + private var updatedAt: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(action: Action) = apply { + config = action.config + target = action.target + id = action.id + alertRuleId = action.alertRuleId + createdAt = action.createdAt + updatedAt = action.updatedAt + additionalProperties = action.additionalProperties.toMutableMap() + } + + fun config(config: JsonValue) = apply { this.config = config } + + fun target(target: Target) = target(JsonField.of(target)) + + /** + * Sets [Builder.target] to an arbitrary JSON value. + * + * You should usually call [Builder.target] with a well-typed [Target] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun target(target: JsonField<Target>) = apply { this.target = target } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun alertRuleId(alertRuleId: String) = alertRuleId(JsonField.of(alertRuleId)) + + /** + * Sets [Builder.alertRuleId] to an arbitrary JSON value. + * + * You should usually call [Builder.alertRuleId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun alertRuleId(alertRuleId: JsonField<String>) = apply { + this.alertRuleId = alertRuleId + } + + fun createdAt(createdAt: String) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<String>) = apply { this.createdAt = createdAt } + + fun updatedAt(updatedAt: String) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField<String>) = apply { this.updatedAt = updatedAt } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Action]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .config() + * .target() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Action = + Action( + checkRequired("config", config), + checkRequired("target", target), + id, + alertRuleId, + createdAt, + updatedAt, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Action = apply { + if (validated) { + return@apply + } + + target().validate() + id() + alertRuleId() + createdAt() + updatedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (target.asKnown().getOrNull()?.validity() ?: 0) + + (if (id.asKnown().isPresent) 1 else 0) + + (if (alertRuleId.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + class Target @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val PAGERDUTY = of("pagerduty") + + @JvmField val WEBHOOK = of("webhook") + + @JvmStatic fun of(value: String) = Target(JsonField.of(value)) + } + + /** An enum containing [Target]'s known values. */ + enum class Known { + PAGERDUTY, + WEBHOOK, + } + + /** + * An enum containing [Target]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Target] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PAGERDUTY, + WEBHOOK, + /** + * An enum member indicating that [Target] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PAGERDUTY -> Value.PAGERDUTY + WEBHOOK -> Value.WEBHOOK + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + PAGERDUTY -> Known.PAGERDUTY + WEBHOOK -> Known.WEBHOOK + else -> throw LangsmithApiInvalidDataException("Unknown Target: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Target = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Target && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Action && + config == other.config && + target == other.target && + id == other.id && + alertRuleId == other.alertRuleId && + createdAt == other.createdAt && + updatedAt == other.updatedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + config, + target, + id, + alertRuleId, + createdAt, + updatedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Action{config=$config, target=$target, id=$id, alertRuleId=$alertRuleId, createdAt=$createdAt, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" + } + + class Rule + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val aggregation: JsonField<Aggregation>, + private val attribute: JsonField<Attribute>, + private val description: JsonField<String>, + private val name: JsonField<String>, + private val operator: JsonField<Operator>, + private val type: JsonField<Type>, + private val windowMinutes: JsonField<Long>, + private val id: JsonField<String>, + private val createdAt: JsonField<String>, + private val denominatorFilter: JsonField<String>, + private val filter: JsonField<String>, + private val threshold: JsonField<Double>, + private val thresholdMultiplier: JsonField<Double>, + private val thresholdWindowMinutes: JsonField<Long>, + private val updatedAt: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("aggregation") + @ExcludeMissing + aggregation: JsonField<Aggregation> = JsonMissing.of(), + @JsonProperty("attribute") + @ExcludeMissing + attribute: JsonField<Attribute> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField<Operator> = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField<Type> = JsonMissing.of(), + @JsonProperty("window_minutes") + @ExcludeMissing + windowMinutes: JsonField<Long> = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField<String> = JsonMissing.of(), + @JsonProperty("denominator_filter") + @ExcludeMissing + denominatorFilter: JsonField<String> = JsonMissing.of(), + @JsonProperty("filter") @ExcludeMissing filter: JsonField<String> = JsonMissing.of(), + @JsonProperty("threshold") + @ExcludeMissing + threshold: JsonField<Double> = JsonMissing.of(), + @JsonProperty("threshold_multiplier") + @ExcludeMissing + thresholdMultiplier: JsonField<Double> = JsonMissing.of(), + @JsonProperty("threshold_window_minutes") + @ExcludeMissing + thresholdWindowMinutes: JsonField<Long> = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField<String> = JsonMissing.of(), + ) : this( + aggregation, + attribute, + description, + name, + operator, + type, + windowMinutes, + id, + createdAt, + denominatorFilter, + filter, + threshold, + thresholdMultiplier, + thresholdWindowMinutes, + updatedAt, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun aggregation(): Aggregation = aggregation.getRequired("aggregation") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun attribute(): Attribute = attribute.getRequired("attribute") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun description(): String = description.getRequired("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * max 15 minutes for alert rule + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun windowMinutes(): Long = windowMinutes.getRequired("window_minutes") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun createdAt(): Optional<String> = createdAt.getOptional("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun denominatorFilter(): Optional<String> = + denominatorFilter.getOptional("denominator_filter") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun filter(): Optional<String> = filter.getOptional("filter") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun threshold(): Optional<Double> = threshold.getOptional("threshold") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun thresholdMultiplier(): Optional<Double> = + thresholdMultiplier.getOptional("threshold_multiplier") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun thresholdWindowMinutes(): Optional<Long> = + thresholdWindowMinutes.getOptional("threshold_window_minutes") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun updatedAt(): Optional<String> = updatedAt.getOptional("updated_at") + + /** + * Returns the raw JSON value of [aggregation]. + * + * Unlike [aggregation], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("aggregation") + @ExcludeMissing + fun _aggregation(): JsonField<Aggregation> = aggregation + + /** + * Returns the raw JSON value of [attribute]. + * + * Unlike [attribute], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("attribute") + @ExcludeMissing + fun _attribute(): JsonField<Attribute> = attribute + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField<Operator> = operator + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField<Type> = type + + /** + * Returns the raw JSON value of [windowMinutes]. + * + * Unlike [windowMinutes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("window_minutes") + @ExcludeMissing + fun _windowMinutes(): JsonField<Long> = windowMinutes + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") @ExcludeMissing fun _createdAt(): JsonField<String> = createdAt + + /** + * Returns the raw JSON value of [denominatorFilter]. + * + * Unlike [denominatorFilter], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("denominator_filter") + @ExcludeMissing + fun _denominatorFilter(): JsonField<String> = denominatorFilter + + /** + * Returns the raw JSON value of [filter]. + * + * Unlike [filter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField<String> = filter + + /** + * Returns the raw JSON value of [threshold]. + * + * Unlike [threshold], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("threshold") @ExcludeMissing fun _threshold(): JsonField<Double> = threshold + + /** + * Returns the raw JSON value of [thresholdMultiplier]. + * + * Unlike [thresholdMultiplier], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("threshold_multiplier") + @ExcludeMissing + fun _thresholdMultiplier(): JsonField<Double> = thresholdMultiplier + + /** + * Returns the raw JSON value of [thresholdWindowMinutes]. + * + * Unlike [thresholdWindowMinutes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("threshold_window_minutes") + @ExcludeMissing + fun _thresholdWindowMinutes(): JsonField<Long> = thresholdWindowMinutes + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") @ExcludeMissing fun _updatedAt(): JsonField<String> = updatedAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Rule]. + * + * The following fields are required: + * ```java + * .aggregation() + * .attribute() + * .description() + * .name() + * .operator() + * .type() + * .windowMinutes() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Rule]. */ + class Builder internal constructor() { + + private var aggregation: JsonField<Aggregation>? = null + private var attribute: JsonField<Attribute>? = null + private var description: JsonField<String>? = null + private var name: JsonField<String>? = null + private var operator: JsonField<Operator>? = null + private var type: JsonField<Type>? = null + private var windowMinutes: JsonField<Long>? = null + private var id: JsonField<String> = JsonMissing.of() + private var createdAt: JsonField<String> = JsonMissing.of() + private var denominatorFilter: JsonField<String> = JsonMissing.of() + private var filter: JsonField<String> = JsonMissing.of() + private var threshold: JsonField<Double> = JsonMissing.of() + private var thresholdMultiplier: JsonField<Double> = JsonMissing.of() + private var thresholdWindowMinutes: JsonField<Long> = JsonMissing.of() + private var updatedAt: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(rule: Rule) = apply { + aggregation = rule.aggregation + attribute = rule.attribute + description = rule.description + name = rule.name + operator = rule.operator + type = rule.type + windowMinutes = rule.windowMinutes + id = rule.id + createdAt = rule.createdAt + denominatorFilter = rule.denominatorFilter + filter = rule.filter + threshold = rule.threshold + thresholdMultiplier = rule.thresholdMultiplier + thresholdWindowMinutes = rule.thresholdWindowMinutes + updatedAt = rule.updatedAt + additionalProperties = rule.additionalProperties.toMutableMap() + } + + fun aggregation(aggregation: Aggregation) = aggregation(JsonField.of(aggregation)) + + /** + * Sets [Builder.aggregation] to an arbitrary JSON value. + * + * You should usually call [Builder.aggregation] with a well-typed [Aggregation] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun aggregation(aggregation: JsonField<Aggregation>) = apply { + this.aggregation = aggregation + } + + fun attribute(attribute: Attribute) = attribute(JsonField.of(attribute)) + + /** + * Sets [Builder.attribute] to an arbitrary JSON value. + * + * You should usually call [Builder.attribute] with a well-typed [Attribute] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun attribute(attribute: JsonField<Attribute>) = apply { this.attribute = attribute } + + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField<String>) = apply { + this.description = description + } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun operator(operator: JsonField<Operator>) = apply { this.operator = operator } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField<Type>) = apply { this.type = type } + + /** max 15 minutes for alert rule */ + fun windowMinutes(windowMinutes: Long) = windowMinutes(JsonField.of(windowMinutes)) + + /** + * Sets [Builder.windowMinutes] to an arbitrary JSON value. + * + * You should usually call [Builder.windowMinutes] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun windowMinutes(windowMinutes: JsonField<Long>) = apply { + this.windowMinutes = windowMinutes + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun createdAt(createdAt: String) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField<String>) = apply { this.createdAt = createdAt } + + fun denominatorFilter(denominatorFilter: String) = + denominatorFilter(JsonField.of(denominatorFilter)) + + /** + * Sets [Builder.denominatorFilter] to an arbitrary JSON value. + * + * You should usually call [Builder.denominatorFilter] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun denominatorFilter(denominatorFilter: JsonField<String>) = apply { + this.denominatorFilter = denominatorFilter + } + + fun filter(filter: String) = filter(JsonField.of(filter)) + + /** + * Sets [Builder.filter] to an arbitrary JSON value. + * + * You should usually call [Builder.filter] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun filter(filter: JsonField<String>) = apply { this.filter = filter } + + fun threshold(threshold: Double) = threshold(JsonField.of(threshold)) + + /** + * Sets [Builder.threshold] to an arbitrary JSON value. + * + * You should usually call [Builder.threshold] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun threshold(threshold: JsonField<Double>) = apply { this.threshold = threshold } + + fun thresholdMultiplier(thresholdMultiplier: Double) = + thresholdMultiplier(JsonField.of(thresholdMultiplier)) + + /** + * Sets [Builder.thresholdMultiplier] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdMultiplier] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun thresholdMultiplier(thresholdMultiplier: JsonField<Double>) = apply { + this.thresholdMultiplier = thresholdMultiplier + } + + fun thresholdWindowMinutes(thresholdWindowMinutes: Long) = + thresholdWindowMinutes(JsonField.of(thresholdWindowMinutes)) + + /** + * Sets [Builder.thresholdWindowMinutes] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdWindowMinutes] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun thresholdWindowMinutes(thresholdWindowMinutes: JsonField<Long>) = apply { + this.thresholdWindowMinutes = thresholdWindowMinutes + } + + fun updatedAt(updatedAt: String) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField<String>) = apply { this.updatedAt = updatedAt } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Rule]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .aggregation() + * .attribute() + * .description() + * .name() + * .operator() + * .type() + * .windowMinutes() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Rule = + Rule( + checkRequired("aggregation", aggregation), + checkRequired("attribute", attribute), + checkRequired("description", description), + checkRequired("name", name), + checkRequired("operator", operator), + checkRequired("type", type), + checkRequired("windowMinutes", windowMinutes), + id, + createdAt, + denominatorFilter, + filter, + threshold, + thresholdMultiplier, + thresholdWindowMinutes, + updatedAt, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Rule = apply { + if (validated) { + return@apply + } + + aggregation().validate() + attribute().validate() + description() + name() + operator().validate() + type().validate() + windowMinutes() + id() + createdAt() + denominatorFilter() + filter() + threshold() + thresholdMultiplier() + thresholdWindowMinutes() + updatedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (aggregation.asKnown().getOrNull()?.validity() ?: 0) + + (attribute.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (operator.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (windowMinutes.asKnown().isPresent) 1 else 0) + + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (denominatorFilter.asKnown().isPresent) 1 else 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (if (threshold.asKnown().isPresent) 1 else 0) + + (if (thresholdMultiplier.asKnown().isPresent) 1 else 0) + + (if (thresholdWindowMinutes.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + class Aggregation @JsonCreator private constructor(private val value: JsonField<String>) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val AVG = of("avg") + + @JvmField val SUM = of("sum") + + @JvmField val PCT = of("pct") + + @JvmStatic fun of(value: String) = Aggregation(JsonField.of(value)) + } + + /** An enum containing [Aggregation]'s known values. */ + enum class Known { + AVG, + SUM, + PCT, + } + + /** + * An enum containing [Aggregation]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Aggregation] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AVG, + SUM, + PCT, + /** + * An enum member indicating that [Aggregation] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AVG -> Value.AVG + SUM -> Value.SUM + PCT -> Value.PCT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + AVG -> Known.AVG + SUM -> Known.SUM + PCT -> Known.PCT + else -> throw LangsmithApiInvalidDataException("Unknown Aggregation: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Aggregation = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Aggregation && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Attribute @JsonCreator private constructor(private val value: JsonField<String>) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val LATENCY = of("latency") + + @JvmField val ERROR_COUNT = of("error_count") + + @JvmField val FEEDBACK_SCORE = of("feedback_score") + + @JvmField val RUN_LATENCY = of("run_latency") + + @JvmField val RUN_COUNT = of("run_count") + + @JvmStatic fun of(value: String) = Attribute(JsonField.of(value)) + } + + /** An enum containing [Attribute]'s known values. */ + enum class Known { + LATENCY, + ERROR_COUNT, + FEEDBACK_SCORE, + RUN_LATENCY, + RUN_COUNT, + } + + /** + * An enum containing [Attribute]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Attribute] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LATENCY, + ERROR_COUNT, + FEEDBACK_SCORE, + RUN_LATENCY, + RUN_COUNT, + /** + * An enum member indicating that [Attribute] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LATENCY -> Value.LATENCY + ERROR_COUNT -> Value.ERROR_COUNT + FEEDBACK_SCORE -> Value.FEEDBACK_SCORE + RUN_LATENCY -> Value.RUN_LATENCY + RUN_COUNT -> Value.RUN_COUNT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + LATENCY -> Known.LATENCY + ERROR_COUNT -> Known.ERROR_COUNT + FEEDBACK_SCORE -> Known.FEEDBACK_SCORE + RUN_LATENCY -> Known.RUN_LATENCY + RUN_COUNT -> Known.RUN_COUNT + else -> throw LangsmithApiInvalidDataException("Unknown Attribute: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Attribute = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Attribute && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Operator @JsonCreator private constructor(private val value: JsonField<String>) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val GTE = of("gte") + + @JvmField val LTE = of("lte") + + @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + GTE, + LTE, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GTE, + LTE, + /** + * An enum member indicating that [Operator] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GTE -> Value.GTE + LTE -> Value.LTE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + GTE -> Known.GTE + LTE -> Known.LTE + else -> throw LangsmithApiInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Type @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val THRESHOLD = of("threshold") + + @JvmField val CHANGE = of("change") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + THRESHOLD, + CHANGE, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + THRESHOLD, + CHANGE, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + THRESHOLD -> Value.THRESHOLD + CHANGE -> Value.CHANGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + THRESHOLD -> Known.THRESHOLD + CHANGE -> Known.CHANGE + else -> throw LangsmithApiInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Rule && + aggregation == other.aggregation && + attribute == other.attribute && + description == other.description && + name == other.name && + operator == other.operator && + type == other.type && + windowMinutes == other.windowMinutes && + id == other.id && + createdAt == other.createdAt && + denominatorFilter == other.denominatorFilter && + filter == other.filter && + threshold == other.threshold && + thresholdMultiplier == other.thresholdMultiplier && + thresholdWindowMinutes == other.thresholdWindowMinutes && + updatedAt == other.updatedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + aggregation, + attribute, + description, + name, + operator, + type, + windowMinutes, + id, + createdAt, + denominatorFilter, + filter, + threshold, + thresholdMultiplier, + thresholdWindowMinutes, + updatedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Rule{aggregation=$aggregation, attribute=$attribute, description=$description, name=$name, operator=$operator, type=$type, windowMinutes=$windowMinutes, id=$id, createdAt=$createdAt, denominatorFilter=$denominatorFilter, filter=$filter, threshold=$threshold, thresholdMultiplier=$thresholdMultiplier, thresholdWindowMinutes=$thresholdWindowMinutes, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AlertRuleResponse && + actions == other.actions && + rule == other.rule && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(actions, rule, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AlertRuleResponse{actions=$actions, rule=$rule, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertTestParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertTestParams.kt new file mode 100644 index 00000000..99324a52 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertTestParams.kt @@ -0,0 +1,232 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.alerts + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Tests an alert action which will fire a notification to all configured recipients if the + * configuration is valid. + */ +class AlertTestParams +private constructor( + private val sessionId: JsonValue?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun sessionId(): Optional<JsonValue> = Optional.ofNullable(sessionId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): AlertTestParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AlertTestParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AlertTestParams]. */ + class Builder internal constructor() { + + private var sessionId: JsonValue? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(alertTestParams: AlertTestParams) = apply { + sessionId = alertTestParams.sessionId + additionalHeaders = alertTestParams.additionalHeaders.toBuilder() + additionalQueryParams = alertTestParams.additionalQueryParams.toBuilder() + additionalBodyProperties = alertTestParams.additionalBodyProperties.toMutableMap() + } + + fun sessionId(sessionId: JsonValue?) = apply { this.sessionId = sessionId } + + /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ + fun sessionId(sessionId: Optional<JsonValue>) = sessionId(sessionId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [AlertTestParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AlertTestParams = + AlertTestParams( + sessionId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> sessionId?.toString() ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AlertTestParams && + sessionId == other.sessionId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(sessionId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "AlertTestParams{sessionId=$sessionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertTestResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertTestResponse.kt new file mode 100644 index 00000000..acb9a568 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertTestResponse.kt @@ -0,0 +1,109 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.alerts + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Objects + +class AlertTestResponse +@JsonCreator +private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> +) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [AlertTestResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AlertTestResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(alertTestResponse: AlertTestResponse) = apply { + additionalProperties = alertTestResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AlertTestResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AlertTestResponse = AlertTestResponse(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): AlertTestResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AlertTestResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "AlertTestResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertUpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertUpdateParams.kt new file mode 100644 index 00000000..25f63cb1 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertUpdateParams.kt @@ -0,0 +1,536 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.alerts + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Updates an alert rule. */ +class AlertUpdateParams +private constructor( + private val sessionId: JsonValue, + private val alertRuleId: JsonValue?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun sessionId(): JsonValue = sessionId + + fun alertRuleId(): Optional<JsonValue> = Optional.ofNullable(alertRuleId) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun actions(): List<AlertActionBase> = body.actions() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun rule(): AlertRuleBase = body.rule() + + /** + * Returns the raw JSON value of [actions]. + * + * Unlike [actions], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _actions(): JsonField<List<AlertActionBase>> = body._actions() + + /** + * Returns the raw JSON value of [rule]. + * + * Unlike [rule], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _rule(): JsonField<AlertRuleBase> = body._rule() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AlertUpdateParams]. + * + * The following fields are required: + * ```java + * .sessionId() + * .actions() + * .rule() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AlertUpdateParams]. */ + class Builder internal constructor() { + + private var sessionId: JsonValue? = null + private var alertRuleId: JsonValue? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(alertUpdateParams: AlertUpdateParams) = apply { + sessionId = alertUpdateParams.sessionId + alertRuleId = alertUpdateParams.alertRuleId + body = alertUpdateParams.body.toBuilder() + additionalHeaders = alertUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = alertUpdateParams.additionalQueryParams.toBuilder() + } + + fun sessionId(sessionId: JsonValue) = apply { this.sessionId = sessionId } + + fun alertRuleId(alertRuleId: JsonValue?) = apply { this.alertRuleId = alertRuleId } + + /** Alias for calling [Builder.alertRuleId] with `alertRuleId.orElse(null)`. */ + fun alertRuleId(alertRuleId: Optional<JsonValue>) = alertRuleId(alertRuleId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [actions] + * - [rule] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun actions(actions: List<AlertActionBase>) = apply { body.actions(actions) } + + /** + * Sets [Builder.actions] to an arbitrary JSON value. + * + * You should usually call [Builder.actions] with a well-typed `List<AlertActionBase>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun actions(actions: JsonField<List<AlertActionBase>>) = apply { body.actions(actions) } + + /** + * Adds a single [AlertActionBase] to [actions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAction(action: AlertActionBase) = apply { body.addAction(action) } + + fun rule(rule: AlertRuleBase) = apply { body.rule(rule) } + + /** + * Sets [Builder.rule] to an arbitrary JSON value. + * + * You should usually call [Builder.rule] with a well-typed [AlertRuleBase] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun rule(rule: JsonField<AlertRuleBase>) = apply { body.rule(rule) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [AlertUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .sessionId() + * .actions() + * .rule() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AlertUpdateParams = + AlertUpdateParams( + checkRequired("sessionId", sessionId), + alertRuleId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> sessionId.toString() + 1 -> alertRuleId?.toString() ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val actions: JsonField<List<AlertActionBase>>, + private val rule: JsonField<AlertRuleBase>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("actions") + @ExcludeMissing + actions: JsonField<List<AlertActionBase>> = JsonMissing.of(), + @JsonProperty("rule") @ExcludeMissing rule: JsonField<AlertRuleBase> = JsonMissing.of(), + ) : this(actions, rule, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun actions(): List<AlertActionBase> = actions.getRequired("actions") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun rule(): AlertRuleBase = rule.getRequired("rule") + + /** + * Returns the raw JSON value of [actions]. + * + * Unlike [actions], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("actions") + @ExcludeMissing + fun _actions(): JsonField<List<AlertActionBase>> = actions + + /** + * Returns the raw JSON value of [rule]. + * + * Unlike [rule], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rule") @ExcludeMissing fun _rule(): JsonField<AlertRuleBase> = rule + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .actions() + * .rule() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var actions: JsonField<MutableList<AlertActionBase>>? = null + private var rule: JsonField<AlertRuleBase>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + actions = body.actions.map { it.toMutableList() } + rule = body.rule + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun actions(actions: List<AlertActionBase>) = actions(JsonField.of(actions)) + + /** + * Sets [Builder.actions] to an arbitrary JSON value. + * + * You should usually call [Builder.actions] with a well-typed `List<AlertActionBase>` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun actions(actions: JsonField<List<AlertActionBase>>) = apply { + this.actions = actions.map { it.toMutableList() } + } + + /** + * Adds a single [AlertActionBase] to [actions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAction(action: AlertActionBase) = apply { + actions = + (actions ?: JsonField.of(mutableListOf())).also { + checkKnown("actions", it).add(action) + } + } + + fun rule(rule: AlertRuleBase) = rule(JsonField.of(rule)) + + /** + * Sets [Builder.rule] to an arbitrary JSON value. + * + * You should usually call [Builder.rule] with a well-typed [AlertRuleBase] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rule(rule: JsonField<AlertRuleBase>) = apply { this.rule = rule } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .actions() + * .rule() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("actions", actions).map { it.toImmutable() }, + checkRequired("rule", rule), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + actions().forEach { it.validate() } + rule().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (actions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (rule.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + actions == other.actions && + rule == other.rule && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(actions, rule, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{actions=$actions, rule=$rule, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AlertUpdateParams && + sessionId == other.sessionId && + alertRuleId == other.alertRuleId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(sessionId, alertRuleId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "AlertUpdateParams{sessionId=$sessionId, alertRuleId=$alertRuleId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertUpdateResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertUpdateResponse.kt new file mode 100644 index 00000000..06d4effa --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/alerts/AlertUpdateResponse.kt @@ -0,0 +1,109 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.alerts + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Objects + +class AlertUpdateResponse +@JsonCreator +private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> +) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [AlertUpdateResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AlertUpdateResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(alertUpdateResponse: AlertUpdateResponse) = apply { + additionalProperties = alertUpdateResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AlertUpdateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AlertUpdateResponse = AlertUpdateResponse(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): AlertUpdateResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AlertUpdateResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "AlertUpdateResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleHardDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleHardDeleteParams.kt new file mode 100644 index 00000000..2f3eda2e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleHardDeleteParams.kt @@ -0,0 +1,532 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.datasets.examples + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** + * This endpoint hard deletes *all* versions of a dataset example(s). Deletion is performed by + * setting inputs, outputs, and metadata to null and deleting attachment files while keeping the + * example ID, dataset ID, and creation timestamp. IMPORTANT: attachment files can take up to 7 days + * to be deleted. inputs, outputs and metadata are nullified immediately. + */ +class ExampleHardDeleteParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * ExampleIDs is a list of UUIDs identifying the examples to delete. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun exampleIds(): List<String> = body.exampleIds() + + /** + * HardDelete indicates whether to perform a hard delete. Currently only True is supported. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun hardDelete(): Boolean = body.hardDelete() + + /** + * Returns the raw JSON value of [exampleIds]. + * + * Unlike [exampleIds], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _exampleIds(): JsonField<List<String>> = body._exampleIds() + + /** + * Returns the raw JSON value of [hardDelete]. + * + * Unlike [hardDelete], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _hardDelete(): JsonField<Boolean> = body._hardDelete() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ExampleHardDeleteParams]. + * + * The following fields are required: + * ```java + * .exampleIds() + * .hardDelete() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExampleHardDeleteParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(exampleHardDeleteParams: ExampleHardDeleteParams) = apply { + body = exampleHardDeleteParams.body.toBuilder() + additionalHeaders = exampleHardDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = exampleHardDeleteParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [exampleIds] + * - [hardDelete] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** ExampleIDs is a list of UUIDs identifying the examples to delete. */ + fun exampleIds(exampleIds: List<String>) = apply { body.exampleIds(exampleIds) } + + /** + * Sets [Builder.exampleIds] to an arbitrary JSON value. + * + * You should usually call [Builder.exampleIds] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun exampleIds(exampleIds: JsonField<List<String>>) = apply { body.exampleIds(exampleIds) } + + /** + * Adds a single [String] to [exampleIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExampleId(exampleId: String) = apply { body.addExampleId(exampleId) } + + /** + * HardDelete indicates whether to perform a hard delete. Currently only True is supported. + */ + fun hardDelete(hardDelete: Boolean) = apply { body.hardDelete(hardDelete) } + + /** + * Sets [Builder.hardDelete] to an arbitrary JSON value. + * + * You should usually call [Builder.hardDelete] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun hardDelete(hardDelete: JsonField<Boolean>) = apply { body.hardDelete(hardDelete) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ExampleHardDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .exampleIds() + * .hardDelete() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ExampleHardDeleteParams = + ExampleHardDeleteParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val exampleIds: JsonField<List<String>>, + private val hardDelete: JsonField<Boolean>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("example_ids") + @ExcludeMissing + exampleIds: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("hard_delete") + @ExcludeMissing + hardDelete: JsonField<Boolean> = JsonMissing.of(), + ) : this(exampleIds, hardDelete, mutableMapOf()) + + /** + * ExampleIDs is a list of UUIDs identifying the examples to delete. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun exampleIds(): List<String> = exampleIds.getRequired("example_ids") + + /** + * HardDelete indicates whether to perform a hard delete. Currently only True is supported. + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun hardDelete(): Boolean = hardDelete.getRequired("hard_delete") + + /** + * Returns the raw JSON value of [exampleIds]. + * + * Unlike [exampleIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("example_ids") + @ExcludeMissing + fun _exampleIds(): JsonField<List<String>> = exampleIds + + /** + * Returns the raw JSON value of [hardDelete]. + * + * Unlike [hardDelete], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("hard_delete") + @ExcludeMissing + fun _hardDelete(): JsonField<Boolean> = hardDelete + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .exampleIds() + * .hardDelete() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var exampleIds: JsonField<MutableList<String>>? = null + private var hardDelete: JsonField<Boolean>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + exampleIds = body.exampleIds.map { it.toMutableList() } + hardDelete = body.hardDelete + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** ExampleIDs is a list of UUIDs identifying the examples to delete. */ + fun exampleIds(exampleIds: List<String>) = exampleIds(JsonField.of(exampleIds)) + + /** + * Sets [Builder.exampleIds] to an arbitrary JSON value. + * + * You should usually call [Builder.exampleIds] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun exampleIds(exampleIds: JsonField<List<String>>) = apply { + this.exampleIds = exampleIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [exampleIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExampleId(exampleId: String) = apply { + exampleIds = + (exampleIds ?: JsonField.of(mutableListOf())).also { + checkKnown("exampleIds", it).add(exampleId) + } + } + + /** + * HardDelete indicates whether to perform a hard delete. Currently only True is + * supported. + */ + fun hardDelete(hardDelete: Boolean) = hardDelete(JsonField.of(hardDelete)) + + /** + * Sets [Builder.hardDelete] to an arbitrary JSON value. + * + * You should usually call [Builder.hardDelete] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun hardDelete(hardDelete: JsonField<Boolean>) = apply { this.hardDelete = hardDelete } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .exampleIds() + * .hardDelete() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("exampleIds", exampleIds).map { it.toImmutable() }, + checkRequired("hardDelete", hardDelete), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + exampleIds() + hardDelete() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (exampleIds.asKnown().getOrNull()?.size ?: 0) + + (if (hardDelete.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + exampleIds == other.exampleIds && + hardDelete == other.hardDelete && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(exampleIds, hardDelete, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{exampleIds=$exampleIds, hardDelete=$hardDelete, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExampleHardDeleteParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ExampleHardDeleteParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleHardDeleteResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleHardDeleteResponse.kt new file mode 100644 index 00000000..e2b30648 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleHardDeleteResponse.kt @@ -0,0 +1,212 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.datasets.examples + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ExampleHardDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val count: JsonField<Long>, + private val exampleIds: JsonField<List<String>>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("count") @ExcludeMissing count: JsonField<Long> = JsonMissing.of(), + @JsonProperty("example_ids") + @ExcludeMissing + exampleIds: JsonField<List<String>> = JsonMissing.of(), + ) : this(count, exampleIds, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun count(): Optional<Long> = count.getOptional("count") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun exampleIds(): Optional<List<String>> = exampleIds.getOptional("example_ids") + + /** + * Returns the raw JSON value of [count]. + * + * Unlike [count], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("count") @ExcludeMissing fun _count(): JsonField<Long> = count + + /** + * Returns the raw JSON value of [exampleIds]. + * + * Unlike [exampleIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("example_ids") + @ExcludeMissing + fun _exampleIds(): JsonField<List<String>> = exampleIds + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ExampleHardDeleteResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExampleHardDeleteResponse]. */ + class Builder internal constructor() { + + private var count: JsonField<Long> = JsonMissing.of() + private var exampleIds: JsonField<MutableList<String>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(exampleHardDeleteResponse: ExampleHardDeleteResponse) = apply { + count = exampleHardDeleteResponse.count + exampleIds = exampleHardDeleteResponse.exampleIds.map { it.toMutableList() } + additionalProperties = exampleHardDeleteResponse.additionalProperties.toMutableMap() + } + + fun count(count: Long) = count(JsonField.of(count)) + + /** + * Sets [Builder.count] to an arbitrary JSON value. + * + * You should usually call [Builder.count] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun count(count: JsonField<Long>) = apply { this.count = count } + + fun exampleIds(exampleIds: List<String>) = exampleIds(JsonField.of(exampleIds)) + + /** + * Sets [Builder.exampleIds] to an arbitrary JSON value. + * + * You should usually call [Builder.exampleIds] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun exampleIds(exampleIds: JsonField<List<String>>) = apply { + this.exampleIds = exampleIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [exampleIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExampleId(exampleId: String) = apply { + exampleIds = + (exampleIds ?: JsonField.of(mutableListOf())).also { + checkKnown("exampleIds", it).add(exampleId) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ExampleHardDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ExampleHardDeleteResponse = + ExampleHardDeleteResponse( + count, + (exampleIds ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ExampleHardDeleteResponse = apply { + if (validated) { + return@apply + } + + count() + exampleIds() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (count.asKnown().isPresent) 1 else 0) + (exampleIds.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExampleHardDeleteResponse && + count == other.count && + exampleIds == other.exampleIds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(count, exampleIds, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ExampleHardDeleteResponse{count=$count, exampleIds=$exampleIds, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleUpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleUpdateParams.kt new file mode 100644 index 00000000..0857ef6f --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleUpdateParams.kt @@ -0,0 +1,858 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.datasets.examples + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.MultipartField +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.io.InputStream +import java.nio.file.Path +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.io.path.inputStream +import kotlin.io.path.name +import kotlin.jvm.optionals.getOrNull + +/** + * This endpoint allows clients to update existing examples in a specified dataset by sending a + * multipart/form-data PATCH request. Each form part contains either JSON-encoded data or binary + * attachment files to update an example. + */ +class ExampleUpdateParams +private constructor( + private val datasetId: JsonValue?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun datasetId(): Optional<JsonValue> = Optional.ofNullable(datasetId) + + /** + * The Example update info as JSON. Can have fields 'metadata', 'split' + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun exampleId(): InputStream = body.exampleId() + + /** + * New file attachment named {name} + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun exampleIdAttachmentName(): Optional<InputStream> = body.exampleIdAttachmentName() + + /** + * JSON describing attachment operations (retain, rename) + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun exampleIdAttachmentsOperations(): Optional<InputStream> = + body.exampleIdAttachmentsOperations() + + /** + * The updated Example inputs as JSON + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun exampleIdInputs(): Optional<InputStream> = body.exampleIdInputs() + + /** + * The updated Example outputs as JSON + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun exampleIdOutputs(): Optional<InputStream> = body.exampleIdOutputs() + + /** + * Returns the raw multipart value of [exampleId]. + * + * Unlike [exampleId], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _exampleId(): MultipartField<InputStream> = body._exampleId() + + /** + * Returns the raw multipart value of [exampleIdAttachmentName]. + * + * Unlike [exampleIdAttachmentName], this method doesn't throw if the multipart field has an + * unexpected type. + */ + fun _exampleIdAttachmentName(): MultipartField<InputStream> = body._exampleIdAttachmentName() + + /** + * Returns the raw multipart value of [exampleIdAttachmentsOperations]. + * + * Unlike [exampleIdAttachmentsOperations], this method doesn't throw if the multipart field has + * an unexpected type. + */ + fun _exampleIdAttachmentsOperations(): MultipartField<InputStream> = + body._exampleIdAttachmentsOperations() + + /** + * Returns the raw multipart value of [exampleIdInputs]. + * + * Unlike [exampleIdInputs], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _exampleIdInputs(): MultipartField<InputStream> = body._exampleIdInputs() + + /** + * Returns the raw multipart value of [exampleIdOutputs]. + * + * Unlike [exampleIdOutputs], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _exampleIdOutputs(): MultipartField<InputStream> = body._exampleIdOutputs() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ExampleUpdateParams]. + * + * The following fields are required: + * ```java + * .exampleId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExampleUpdateParams]. */ + class Builder internal constructor() { + + private var datasetId: JsonValue? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(exampleUpdateParams: ExampleUpdateParams) = apply { + datasetId = exampleUpdateParams.datasetId + body = exampleUpdateParams.body.toBuilder() + additionalHeaders = exampleUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = exampleUpdateParams.additionalQueryParams.toBuilder() + } + + fun datasetId(datasetId: JsonValue?) = apply { this.datasetId = datasetId } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<JsonValue>) = datasetId(datasetId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [exampleId] + * - [exampleIdAttachmentName] + * - [exampleIdAttachmentsOperations] + * - [exampleIdInputs] + * - [exampleIdOutputs] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** The Example update info as JSON. Can have fields 'metadata', 'split' */ + fun exampleId(exampleId: InputStream) = apply { body.exampleId(exampleId) } + + /** + * Sets [Builder.exampleId] to an arbitrary multipart value. + * + * You should usually call [Builder.exampleId] with a well-typed [InputStream] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun exampleId(exampleId: MultipartField<InputStream>) = apply { body.exampleId(exampleId) } + + /** The Example update info as JSON. Can have fields 'metadata', 'split' */ + fun exampleId(exampleId: ByteArray) = apply { body.exampleId(exampleId) } + + /** The Example update info as JSON. Can have fields 'metadata', 'split' */ + fun exampleId(path: Path) = apply { body.exampleId(path) } + + /** New file attachment named {name} */ + fun exampleIdAttachmentName(exampleIdAttachmentName: InputStream) = apply { + body.exampleIdAttachmentName(exampleIdAttachmentName) + } + + /** + * Sets [Builder.exampleIdAttachmentName] to an arbitrary multipart value. + * + * You should usually call [Builder.exampleIdAttachmentName] with a well-typed [InputStream] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun exampleIdAttachmentName(exampleIdAttachmentName: MultipartField<InputStream>) = apply { + body.exampleIdAttachmentName(exampleIdAttachmentName) + } + + /** New file attachment named {name} */ + fun exampleIdAttachmentName(exampleIdAttachmentName: ByteArray) = apply { + body.exampleIdAttachmentName(exampleIdAttachmentName) + } + + /** New file attachment named {name} */ + fun exampleIdAttachmentName(path: Path) = apply { body.exampleIdAttachmentName(path) } + + /** JSON describing attachment operations (retain, rename) */ + fun exampleIdAttachmentsOperations(exampleIdAttachmentsOperations: InputStream) = apply { + body.exampleIdAttachmentsOperations(exampleIdAttachmentsOperations) + } + + /** + * Sets [Builder.exampleIdAttachmentsOperations] to an arbitrary multipart value. + * + * You should usually call [Builder.exampleIdAttachmentsOperations] with a well-typed + * [InputStream] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun exampleIdAttachmentsOperations( + exampleIdAttachmentsOperations: MultipartField<InputStream> + ) = apply { body.exampleIdAttachmentsOperations(exampleIdAttachmentsOperations) } + + /** JSON describing attachment operations (retain, rename) */ + fun exampleIdAttachmentsOperations(exampleIdAttachmentsOperations: ByteArray) = apply { + body.exampleIdAttachmentsOperations(exampleIdAttachmentsOperations) + } + + /** JSON describing attachment operations (retain, rename) */ + fun exampleIdAttachmentsOperations(path: Path) = apply { + body.exampleIdAttachmentsOperations(path) + } + + /** The updated Example inputs as JSON */ + fun exampleIdInputs(exampleIdInputs: InputStream) = apply { + body.exampleIdInputs(exampleIdInputs) + } + + /** + * Sets [Builder.exampleIdInputs] to an arbitrary multipart value. + * + * You should usually call [Builder.exampleIdInputs] with a well-typed [InputStream] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun exampleIdInputs(exampleIdInputs: MultipartField<InputStream>) = apply { + body.exampleIdInputs(exampleIdInputs) + } + + /** The updated Example inputs as JSON */ + fun exampleIdInputs(exampleIdInputs: ByteArray) = apply { + body.exampleIdInputs(exampleIdInputs) + } + + /** The updated Example inputs as JSON */ + fun exampleIdInputs(path: Path) = apply { body.exampleIdInputs(path) } + + /** The updated Example outputs as JSON */ + fun exampleIdOutputs(exampleIdOutputs: InputStream) = apply { + body.exampleIdOutputs(exampleIdOutputs) + } + + /** + * Sets [Builder.exampleIdOutputs] to an arbitrary multipart value. + * + * You should usually call [Builder.exampleIdOutputs] with a well-typed [InputStream] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun exampleIdOutputs(exampleIdOutputs: MultipartField<InputStream>) = apply { + body.exampleIdOutputs(exampleIdOutputs) + } + + /** The updated Example outputs as JSON */ + fun exampleIdOutputs(exampleIdOutputs: ByteArray) = apply { + body.exampleIdOutputs(exampleIdOutputs) + } + + /** The updated Example outputs as JSON */ + fun exampleIdOutputs(path: Path) = apply { body.exampleIdOutputs(path) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ExampleUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .exampleId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ExampleUpdateParams = + ExampleUpdateParams( + datasetId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Map<String, MultipartField<*>> = + (mapOf( + "{example_id}" to _exampleId(), + "{example_id}.attachment.{name}" to _exampleIdAttachmentName(), + "{example_id}.attachments_operations" to _exampleIdAttachmentsOperations(), + "{example_id}.inputs" to _exampleIdInputs(), + "{example_id}.outputs" to _exampleIdOutputs(), + ) + _additionalBodyProperties().mapValues { (_, value) -> MultipartField.of(value) }) + .toImmutable() + + fun _pathParam(index: Int): String = + when (index) { + 0 -> datasetId?.toString() ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + private constructor( + private val exampleId: MultipartField<InputStream>, + private val exampleIdAttachmentName: MultipartField<InputStream>, + private val exampleIdAttachmentsOperations: MultipartField<InputStream>, + private val exampleIdInputs: MultipartField<InputStream>, + private val exampleIdOutputs: MultipartField<InputStream>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + /** + * The Example update info as JSON. Can have fields 'metadata', 'split' + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun exampleId(): InputStream = exampleId.value.getRequired("{example_id}") + + /** + * New file attachment named {name} + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun exampleIdAttachmentName(): Optional<InputStream> = + exampleIdAttachmentName.value.getOptional("{example_id}.attachment.{name}") + + /** + * JSON describing attachment operations (retain, rename) + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun exampleIdAttachmentsOperations(): Optional<InputStream> = + exampleIdAttachmentsOperations.value.getOptional("{example_id}.attachments_operations") + + /** + * The updated Example inputs as JSON + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun exampleIdInputs(): Optional<InputStream> = + exampleIdInputs.value.getOptional("{example_id}.inputs") + + /** + * The updated Example outputs as JSON + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun exampleIdOutputs(): Optional<InputStream> = + exampleIdOutputs.value.getOptional("{example_id}.outputs") + + /** + * Returns the raw multipart value of [exampleId]. + * + * Unlike [exampleId], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("{example_id}") + @ExcludeMissing + fun _exampleId(): MultipartField<InputStream> = exampleId + + /** + * Returns the raw multipart value of [exampleIdAttachmentName]. + * + * Unlike [exampleIdAttachmentName], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("{example_id}.attachment.{name}") + @ExcludeMissing + fun _exampleIdAttachmentName(): MultipartField<InputStream> = exampleIdAttachmentName + + /** + * Returns the raw multipart value of [exampleIdAttachmentsOperations]. + * + * Unlike [exampleIdAttachmentsOperations], this method doesn't throw if the multipart field + * has an unexpected type. + */ + @JsonProperty("{example_id}.attachments_operations") + @ExcludeMissing + fun _exampleIdAttachmentsOperations(): MultipartField<InputStream> = + exampleIdAttachmentsOperations + + /** + * Returns the raw multipart value of [exampleIdInputs]. + * + * Unlike [exampleIdInputs], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("{example_id}.inputs") + @ExcludeMissing + fun _exampleIdInputs(): MultipartField<InputStream> = exampleIdInputs + + /** + * Returns the raw multipart value of [exampleIdOutputs]. + * + * Unlike [exampleIdOutputs], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("{example_id}.outputs") + @ExcludeMissing + fun _exampleIdOutputs(): MultipartField<InputStream> = exampleIdOutputs + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .exampleId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var exampleId: MultipartField<InputStream>? = null + private var exampleIdAttachmentName: MultipartField<InputStream> = + MultipartField.of(null) + private var exampleIdAttachmentsOperations: MultipartField<InputStream> = + MultipartField.of(null) + private var exampleIdInputs: MultipartField<InputStream> = MultipartField.of(null) + private var exampleIdOutputs: MultipartField<InputStream> = MultipartField.of(null) + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + exampleId = body.exampleId + exampleIdAttachmentName = body.exampleIdAttachmentName + exampleIdAttachmentsOperations = body.exampleIdAttachmentsOperations + exampleIdInputs = body.exampleIdInputs + exampleIdOutputs = body.exampleIdOutputs + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** The Example update info as JSON. Can have fields 'metadata', 'split' */ + fun exampleId(exampleId: InputStream) = exampleId(MultipartField.of(exampleId)) + + /** + * Sets [Builder.exampleId] to an arbitrary multipart value. + * + * You should usually call [Builder.exampleId] with a well-typed [InputStream] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun exampleId(exampleId: MultipartField<InputStream>) = apply { + this.exampleId = exampleId + } + + /** The Example update info as JSON. Can have fields 'metadata', 'split' */ + fun exampleId(exampleId: ByteArray) = exampleId(exampleId.inputStream()) + + /** The Example update info as JSON. Can have fields 'metadata', 'split' */ + fun exampleId(path: Path) = + exampleId( + MultipartField.builder<InputStream>() + .value(path.inputStream()) + .filename(path.name) + .build() + ) + + /** New file attachment named {name} */ + fun exampleIdAttachmentName(exampleIdAttachmentName: InputStream) = + exampleIdAttachmentName(MultipartField.of(exampleIdAttachmentName)) + + /** + * Sets [Builder.exampleIdAttachmentName] to an arbitrary multipart value. + * + * You should usually call [Builder.exampleIdAttachmentName] with a well-typed + * [InputStream] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun exampleIdAttachmentName(exampleIdAttachmentName: MultipartField<InputStream>) = + apply { + this.exampleIdAttachmentName = exampleIdAttachmentName + } + + /** New file attachment named {name} */ + fun exampleIdAttachmentName(exampleIdAttachmentName: ByteArray) = + exampleIdAttachmentName(exampleIdAttachmentName.inputStream()) + + /** New file attachment named {name} */ + fun exampleIdAttachmentName(path: Path) = + exampleIdAttachmentName( + MultipartField.builder<InputStream>() + .value(path.inputStream()) + .filename(path.name) + .build() + ) + + /** JSON describing attachment operations (retain, rename) */ + fun exampleIdAttachmentsOperations(exampleIdAttachmentsOperations: InputStream) = + exampleIdAttachmentsOperations(MultipartField.of(exampleIdAttachmentsOperations)) + + /** + * Sets [Builder.exampleIdAttachmentsOperations] to an arbitrary multipart value. + * + * You should usually call [Builder.exampleIdAttachmentsOperations] with a well-typed + * [InputStream] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun exampleIdAttachmentsOperations( + exampleIdAttachmentsOperations: MultipartField<InputStream> + ) = apply { this.exampleIdAttachmentsOperations = exampleIdAttachmentsOperations } + + /** JSON describing attachment operations (retain, rename) */ + fun exampleIdAttachmentsOperations(exampleIdAttachmentsOperations: ByteArray) = + exampleIdAttachmentsOperations(exampleIdAttachmentsOperations.inputStream()) + + /** JSON describing attachment operations (retain, rename) */ + fun exampleIdAttachmentsOperations(path: Path) = + exampleIdAttachmentsOperations( + MultipartField.builder<InputStream>() + .value(path.inputStream()) + .filename(path.name) + .build() + ) + + /** The updated Example inputs as JSON */ + fun exampleIdInputs(exampleIdInputs: InputStream) = + exampleIdInputs(MultipartField.of(exampleIdInputs)) + + /** + * Sets [Builder.exampleIdInputs] to an arbitrary multipart value. + * + * You should usually call [Builder.exampleIdInputs] with a well-typed [InputStream] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun exampleIdInputs(exampleIdInputs: MultipartField<InputStream>) = apply { + this.exampleIdInputs = exampleIdInputs + } + + /** The updated Example inputs as JSON */ + fun exampleIdInputs(exampleIdInputs: ByteArray) = + exampleIdInputs(exampleIdInputs.inputStream()) + + /** The updated Example inputs as JSON */ + fun exampleIdInputs(path: Path) = + exampleIdInputs( + MultipartField.builder<InputStream>() + .value(path.inputStream()) + .filename(path.name) + .build() + ) + + /** The updated Example outputs as JSON */ + fun exampleIdOutputs(exampleIdOutputs: InputStream) = + exampleIdOutputs(MultipartField.of(exampleIdOutputs)) + + /** + * Sets [Builder.exampleIdOutputs] to an arbitrary multipart value. + * + * You should usually call [Builder.exampleIdOutputs] with a well-typed [InputStream] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun exampleIdOutputs(exampleIdOutputs: MultipartField<InputStream>) = apply { + this.exampleIdOutputs = exampleIdOutputs + } + + /** The updated Example outputs as JSON */ + fun exampleIdOutputs(exampleIdOutputs: ByteArray) = + exampleIdOutputs(exampleIdOutputs.inputStream()) + + /** The updated Example outputs as JSON */ + fun exampleIdOutputs(path: Path) = + exampleIdOutputs( + MultipartField.builder<InputStream>() + .value(path.inputStream()) + .filename(path.name) + .build() + ) + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .exampleId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("exampleId", exampleId), + exampleIdAttachmentName, + exampleIdAttachmentsOperations, + exampleIdInputs, + exampleIdOutputs, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + exampleId() + exampleIdAttachmentName() + exampleIdAttachmentsOperations() + exampleIdInputs() + exampleIdOutputs() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + exampleId == other.exampleId && + exampleIdAttachmentName == other.exampleIdAttachmentName && + exampleIdAttachmentsOperations == other.exampleIdAttachmentsOperations && + exampleIdInputs == other.exampleIdInputs && + exampleIdOutputs == other.exampleIdOutputs && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + exampleId, + exampleIdAttachmentName, + exampleIdAttachmentsOperations, + exampleIdInputs, + exampleIdOutputs, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{exampleId=$exampleId, exampleIdAttachmentName=$exampleIdAttachmentName, exampleIdAttachmentsOperations=$exampleIdAttachmentsOperations, exampleIdInputs=$exampleIdInputs, exampleIdOutputs=$exampleIdOutputs, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExampleUpdateParams && + datasetId == other.datasetId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(datasetId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ExampleUpdateParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleUpdateResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleUpdateResponse.kt new file mode 100644 index 00000000..9ea86c39 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleUpdateResponse.kt @@ -0,0 +1,210 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.datasets.examples + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ExampleUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val count: JsonField<Long>, + private val exampleIds: JsonField<List<String>>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("count") @ExcludeMissing count: JsonField<Long> = JsonMissing.of(), + @JsonProperty("example_ids") + @ExcludeMissing + exampleIds: JsonField<List<String>> = JsonMissing.of(), + ) : this(count, exampleIds, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun count(): Optional<Long> = count.getOptional("count") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun exampleIds(): Optional<List<String>> = exampleIds.getOptional("example_ids") + + /** + * Returns the raw JSON value of [count]. + * + * Unlike [count], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("count") @ExcludeMissing fun _count(): JsonField<Long> = count + + /** + * Returns the raw JSON value of [exampleIds]. + * + * Unlike [exampleIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("example_ids") + @ExcludeMissing + fun _exampleIds(): JsonField<List<String>> = exampleIds + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ExampleUpdateResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExampleUpdateResponse]. */ + class Builder internal constructor() { + + private var count: JsonField<Long> = JsonMissing.of() + private var exampleIds: JsonField<MutableList<String>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(exampleUpdateResponse: ExampleUpdateResponse) = apply { + count = exampleUpdateResponse.count + exampleIds = exampleUpdateResponse.exampleIds.map { it.toMutableList() } + additionalProperties = exampleUpdateResponse.additionalProperties.toMutableMap() + } + + fun count(count: Long) = count(JsonField.of(count)) + + /** + * Sets [Builder.count] to an arbitrary JSON value. + * + * You should usually call [Builder.count] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun count(count: JsonField<Long>) = apply { this.count = count } + + fun exampleIds(exampleIds: List<String>) = exampleIds(JsonField.of(exampleIds)) + + /** + * Sets [Builder.exampleIds] to an arbitrary JSON value. + * + * You should usually call [Builder.exampleIds] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun exampleIds(exampleIds: JsonField<List<String>>) = apply { + this.exampleIds = exampleIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [exampleIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExampleId(exampleId: String) = apply { + exampleIds = + (exampleIds ?: JsonField.of(mutableListOf())).also { + checkKnown("exampleIds", it).add(exampleId) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ExampleUpdateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ExampleUpdateResponse = + ExampleUpdateResponse( + count, + (exampleIds ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ExampleUpdateResponse = apply { + if (validated) { + return@apply + } + + count() + exampleIds() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (count.asKnown().isPresent) 1 else 0) + (exampleIds.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExampleUpdateResponse && + count == other.count && + exampleIds == other.exampleIds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(count, exampleIds, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ExampleUpdateResponse{count=$count, exampleIds=$exampleIds, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleUploadParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleUploadParams.kt new file mode 100644 index 00000000..13c1604a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleUploadParams.kt @@ -0,0 +1,780 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.datasets.examples + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.MultipartField +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.io.InputStream +import java.nio.file.Path +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.io.path.inputStream +import kotlin.io.path.name +import kotlin.jvm.optionals.getOrNull + +/** + * This endpoint allows clients to upload examples to a specified dataset by sending a + * multipart/form-data POST request. Each form part contains either JSON-encoded data or binary + * attachment files associated with an example. + */ +class ExampleUploadParams +private constructor( + private val datasetId: JsonValue?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun datasetId(): Optional<JsonValue> = Optional.ofNullable(datasetId) + + /** + * The Example info as JSON. Can have fields 'metadata', 'split', 'use_source_run_io', + * 'source_run_id', 'created_at', 'modified_at' + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun exampleId(): InputStream = body.exampleId() + + /** + * The Example inputs as JSON + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun exampleIdInputs(): InputStream = body.exampleIdInputs() + + /** + * File attachment named {name} + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun exampleIdAttachmentsName(): Optional<InputStream> = body.exampleIdAttachmentsName() + + /** + * THe Example outputs as JSON + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun exampleIdOutputs(): Optional<InputStream> = body.exampleIdOutputs() + + /** + * Returns the raw multipart value of [exampleId]. + * + * Unlike [exampleId], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _exampleId(): MultipartField<InputStream> = body._exampleId() + + /** + * Returns the raw multipart value of [exampleIdInputs]. + * + * Unlike [exampleIdInputs], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _exampleIdInputs(): MultipartField<InputStream> = body._exampleIdInputs() + + /** + * Returns the raw multipart value of [exampleIdAttachmentsName]. + * + * Unlike [exampleIdAttachmentsName], this method doesn't throw if the multipart field has an + * unexpected type. + */ + fun _exampleIdAttachmentsName(): MultipartField<InputStream> = body._exampleIdAttachmentsName() + + /** + * Returns the raw multipart value of [exampleIdOutputs]. + * + * Unlike [exampleIdOutputs], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _exampleIdOutputs(): MultipartField<InputStream> = body._exampleIdOutputs() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ExampleUploadParams]. + * + * The following fields are required: + * ```java + * .exampleId() + * .exampleIdInputs() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExampleUploadParams]. */ + class Builder internal constructor() { + + private var datasetId: JsonValue? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(exampleUploadParams: ExampleUploadParams) = apply { + datasetId = exampleUploadParams.datasetId + body = exampleUploadParams.body.toBuilder() + additionalHeaders = exampleUploadParams.additionalHeaders.toBuilder() + additionalQueryParams = exampleUploadParams.additionalQueryParams.toBuilder() + } + + fun datasetId(datasetId: JsonValue?) = apply { this.datasetId = datasetId } + + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ + fun datasetId(datasetId: Optional<JsonValue>) = datasetId(datasetId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [exampleId] + * - [exampleIdInputs] + * - [exampleIdAttachmentsName] + * - [exampleIdOutputs] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * The Example info as JSON. Can have fields 'metadata', 'split', 'use_source_run_io', + * 'source_run_id', 'created_at', 'modified_at' + */ + fun exampleId(exampleId: InputStream) = apply { body.exampleId(exampleId) } + + /** + * Sets [Builder.exampleId] to an arbitrary multipart value. + * + * You should usually call [Builder.exampleId] with a well-typed [InputStream] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun exampleId(exampleId: MultipartField<InputStream>) = apply { body.exampleId(exampleId) } + + /** + * The Example info as JSON. Can have fields 'metadata', 'split', 'use_source_run_io', + * 'source_run_id', 'created_at', 'modified_at' + */ + fun exampleId(exampleId: ByteArray) = apply { body.exampleId(exampleId) } + + /** + * The Example info as JSON. Can have fields 'metadata', 'split', 'use_source_run_io', + * 'source_run_id', 'created_at', 'modified_at' + */ + fun exampleId(path: Path) = apply { body.exampleId(path) } + + /** The Example inputs as JSON */ + fun exampleIdInputs(exampleIdInputs: InputStream) = apply { + body.exampleIdInputs(exampleIdInputs) + } + + /** + * Sets [Builder.exampleIdInputs] to an arbitrary multipart value. + * + * You should usually call [Builder.exampleIdInputs] with a well-typed [InputStream] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun exampleIdInputs(exampleIdInputs: MultipartField<InputStream>) = apply { + body.exampleIdInputs(exampleIdInputs) + } + + /** The Example inputs as JSON */ + fun exampleIdInputs(exampleIdInputs: ByteArray) = apply { + body.exampleIdInputs(exampleIdInputs) + } + + /** The Example inputs as JSON */ + fun exampleIdInputs(path: Path) = apply { body.exampleIdInputs(path) } + + /** File attachment named {name} */ + fun exampleIdAttachmentsName(exampleIdAttachmentsName: InputStream) = apply { + body.exampleIdAttachmentsName(exampleIdAttachmentsName) + } + + /** + * Sets [Builder.exampleIdAttachmentsName] to an arbitrary multipart value. + * + * You should usually call [Builder.exampleIdAttachmentsName] with a well-typed + * [InputStream] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun exampleIdAttachmentsName(exampleIdAttachmentsName: MultipartField<InputStream>) = + apply { + body.exampleIdAttachmentsName(exampleIdAttachmentsName) + } + + /** File attachment named {name} */ + fun exampleIdAttachmentsName(exampleIdAttachmentsName: ByteArray) = apply { + body.exampleIdAttachmentsName(exampleIdAttachmentsName) + } + + /** File attachment named {name} */ + fun exampleIdAttachmentsName(path: Path) = apply { body.exampleIdAttachmentsName(path) } + + /** THe Example outputs as JSON */ + fun exampleIdOutputs(exampleIdOutputs: InputStream) = apply { + body.exampleIdOutputs(exampleIdOutputs) + } + + /** + * Sets [Builder.exampleIdOutputs] to an arbitrary multipart value. + * + * You should usually call [Builder.exampleIdOutputs] with a well-typed [InputStream] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun exampleIdOutputs(exampleIdOutputs: MultipartField<InputStream>) = apply { + body.exampleIdOutputs(exampleIdOutputs) + } + + /** THe Example outputs as JSON */ + fun exampleIdOutputs(exampleIdOutputs: ByteArray) = apply { + body.exampleIdOutputs(exampleIdOutputs) + } + + /** THe Example outputs as JSON */ + fun exampleIdOutputs(path: Path) = apply { body.exampleIdOutputs(path) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ExampleUploadParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .exampleId() + * .exampleIdInputs() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ExampleUploadParams = + ExampleUploadParams( + datasetId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Map<String, MultipartField<*>> = + (mapOf( + "{example_id}" to _exampleId(), + "{example_id}.inputs" to _exampleIdInputs(), + "{example_id}.attachments.{name}" to _exampleIdAttachmentsName(), + "{example_id}.outputs" to _exampleIdOutputs(), + ) + _additionalBodyProperties().mapValues { (_, value) -> MultipartField.of(value) }) + .toImmutable() + + fun _pathParam(index: Int): String = + when (index) { + 0 -> datasetId?.toString() ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + private constructor( + private val exampleId: MultipartField<InputStream>, + private val exampleIdInputs: MultipartField<InputStream>, + private val exampleIdAttachmentsName: MultipartField<InputStream>, + private val exampleIdOutputs: MultipartField<InputStream>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + /** + * The Example info as JSON. Can have fields 'metadata', 'split', 'use_source_run_io', + * 'source_run_id', 'created_at', 'modified_at' + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun exampleId(): InputStream = exampleId.value.getRequired("{example_id}") + + /** + * The Example inputs as JSON + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun exampleIdInputs(): InputStream = + exampleIdInputs.value.getRequired("{example_id}.inputs") + + /** + * File attachment named {name} + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun exampleIdAttachmentsName(): Optional<InputStream> = + exampleIdAttachmentsName.value.getOptional("{example_id}.attachments.{name}") + + /** + * THe Example outputs as JSON + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun exampleIdOutputs(): Optional<InputStream> = + exampleIdOutputs.value.getOptional("{example_id}.outputs") + + /** + * Returns the raw multipart value of [exampleId]. + * + * Unlike [exampleId], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("{example_id}") + @ExcludeMissing + fun _exampleId(): MultipartField<InputStream> = exampleId + + /** + * Returns the raw multipart value of [exampleIdInputs]. + * + * Unlike [exampleIdInputs], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("{example_id}.inputs") + @ExcludeMissing + fun _exampleIdInputs(): MultipartField<InputStream> = exampleIdInputs + + /** + * Returns the raw multipart value of [exampleIdAttachmentsName]. + * + * Unlike [exampleIdAttachmentsName], this method doesn't throw if the multipart field has + * an unexpected type. + */ + @JsonProperty("{example_id}.attachments.{name}") + @ExcludeMissing + fun _exampleIdAttachmentsName(): MultipartField<InputStream> = exampleIdAttachmentsName + + /** + * Returns the raw multipart value of [exampleIdOutputs]. + * + * Unlike [exampleIdOutputs], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("{example_id}.outputs") + @ExcludeMissing + fun _exampleIdOutputs(): MultipartField<InputStream> = exampleIdOutputs + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .exampleId() + * .exampleIdInputs() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var exampleId: MultipartField<InputStream>? = null + private var exampleIdInputs: MultipartField<InputStream>? = null + private var exampleIdAttachmentsName: MultipartField<InputStream> = + MultipartField.of(null) + private var exampleIdOutputs: MultipartField<InputStream> = MultipartField.of(null) + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + exampleId = body.exampleId + exampleIdInputs = body.exampleIdInputs + exampleIdAttachmentsName = body.exampleIdAttachmentsName + exampleIdOutputs = body.exampleIdOutputs + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * The Example info as JSON. Can have fields 'metadata', 'split', 'use_source_run_io', + * 'source_run_id', 'created_at', 'modified_at' + */ + fun exampleId(exampleId: InputStream) = exampleId(MultipartField.of(exampleId)) + + /** + * Sets [Builder.exampleId] to an arbitrary multipart value. + * + * You should usually call [Builder.exampleId] with a well-typed [InputStream] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun exampleId(exampleId: MultipartField<InputStream>) = apply { + this.exampleId = exampleId + } + + /** + * The Example info as JSON. Can have fields 'metadata', 'split', 'use_source_run_io', + * 'source_run_id', 'created_at', 'modified_at' + */ + fun exampleId(exampleId: ByteArray) = exampleId(exampleId.inputStream()) + + /** + * The Example info as JSON. Can have fields 'metadata', 'split', 'use_source_run_io', + * 'source_run_id', 'created_at', 'modified_at' + */ + fun exampleId(path: Path) = + exampleId( + MultipartField.builder<InputStream>() + .value(path.inputStream()) + .filename(path.name) + .build() + ) + + /** The Example inputs as JSON */ + fun exampleIdInputs(exampleIdInputs: InputStream) = + exampleIdInputs(MultipartField.of(exampleIdInputs)) + + /** + * Sets [Builder.exampleIdInputs] to an arbitrary multipart value. + * + * You should usually call [Builder.exampleIdInputs] with a well-typed [InputStream] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun exampleIdInputs(exampleIdInputs: MultipartField<InputStream>) = apply { + this.exampleIdInputs = exampleIdInputs + } + + /** The Example inputs as JSON */ + fun exampleIdInputs(exampleIdInputs: ByteArray) = + exampleIdInputs(exampleIdInputs.inputStream()) + + /** The Example inputs as JSON */ + fun exampleIdInputs(path: Path) = + exampleIdInputs( + MultipartField.builder<InputStream>() + .value(path.inputStream()) + .filename(path.name) + .build() + ) + + /** File attachment named {name} */ + fun exampleIdAttachmentsName(exampleIdAttachmentsName: InputStream) = + exampleIdAttachmentsName(MultipartField.of(exampleIdAttachmentsName)) + + /** + * Sets [Builder.exampleIdAttachmentsName] to an arbitrary multipart value. + * + * You should usually call [Builder.exampleIdAttachmentsName] with a well-typed + * [InputStream] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun exampleIdAttachmentsName(exampleIdAttachmentsName: MultipartField<InputStream>) = + apply { + this.exampleIdAttachmentsName = exampleIdAttachmentsName + } + + /** File attachment named {name} */ + fun exampleIdAttachmentsName(exampleIdAttachmentsName: ByteArray) = + exampleIdAttachmentsName(exampleIdAttachmentsName.inputStream()) + + /** File attachment named {name} */ + fun exampleIdAttachmentsName(path: Path) = + exampleIdAttachmentsName( + MultipartField.builder<InputStream>() + .value(path.inputStream()) + .filename(path.name) + .build() + ) + + /** THe Example outputs as JSON */ + fun exampleIdOutputs(exampleIdOutputs: InputStream) = + exampleIdOutputs(MultipartField.of(exampleIdOutputs)) + + /** + * Sets [Builder.exampleIdOutputs] to an arbitrary multipart value. + * + * You should usually call [Builder.exampleIdOutputs] with a well-typed [InputStream] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun exampleIdOutputs(exampleIdOutputs: MultipartField<InputStream>) = apply { + this.exampleIdOutputs = exampleIdOutputs + } + + /** THe Example outputs as JSON */ + fun exampleIdOutputs(exampleIdOutputs: ByteArray) = + exampleIdOutputs(exampleIdOutputs.inputStream()) + + /** THe Example outputs as JSON */ + fun exampleIdOutputs(path: Path) = + exampleIdOutputs( + MultipartField.builder<InputStream>() + .value(path.inputStream()) + .filename(path.name) + .build() + ) + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .exampleId() + * .exampleIdInputs() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("exampleId", exampleId), + checkRequired("exampleIdInputs", exampleIdInputs), + exampleIdAttachmentsName, + exampleIdOutputs, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + exampleId() + exampleIdInputs() + exampleIdAttachmentsName() + exampleIdOutputs() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + exampleId == other.exampleId && + exampleIdInputs == other.exampleIdInputs && + exampleIdAttachmentsName == other.exampleIdAttachmentsName && + exampleIdOutputs == other.exampleIdOutputs && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + exampleId, + exampleIdInputs, + exampleIdAttachmentsName, + exampleIdOutputs, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{exampleId=$exampleId, exampleIdInputs=$exampleIdInputs, exampleIdAttachmentsName=$exampleIdAttachmentsName, exampleIdOutputs=$exampleIdOutputs, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExampleUploadParams && + datasetId == other.datasetId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(datasetId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ExampleUploadParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleUploadResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleUploadResponse.kt new file mode 100644 index 00000000..c1c507f5 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleUploadResponse.kt @@ -0,0 +1,210 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.datasets.examples + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ExampleUploadResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val count: JsonField<Long>, + private val exampleIds: JsonField<List<String>>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("count") @ExcludeMissing count: JsonField<Long> = JsonMissing.of(), + @JsonProperty("example_ids") + @ExcludeMissing + exampleIds: JsonField<List<String>> = JsonMissing.of(), + ) : this(count, exampleIds, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun count(): Optional<Long> = count.getOptional("count") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun exampleIds(): Optional<List<String>> = exampleIds.getOptional("example_ids") + + /** + * Returns the raw JSON value of [count]. + * + * Unlike [count], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("count") @ExcludeMissing fun _count(): JsonField<Long> = count + + /** + * Returns the raw JSON value of [exampleIds]. + * + * Unlike [exampleIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("example_ids") + @ExcludeMissing + fun _exampleIds(): JsonField<List<String>> = exampleIds + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ExampleUploadResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExampleUploadResponse]. */ + class Builder internal constructor() { + + private var count: JsonField<Long> = JsonMissing.of() + private var exampleIds: JsonField<MutableList<String>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(exampleUploadResponse: ExampleUploadResponse) = apply { + count = exampleUploadResponse.count + exampleIds = exampleUploadResponse.exampleIds.map { it.toMutableList() } + additionalProperties = exampleUploadResponse.additionalProperties.toMutableMap() + } + + fun count(count: Long) = count(JsonField.of(count)) + + /** + * Sets [Builder.count] to an arbitrary JSON value. + * + * You should usually call [Builder.count] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun count(count: JsonField<Long>) = apply { this.count = count } + + fun exampleIds(exampleIds: List<String>) = exampleIds(JsonField.of(exampleIds)) + + /** + * Sets [Builder.exampleIds] to an arbitrary JSON value. + * + * You should usually call [Builder.exampleIds] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun exampleIds(exampleIds: JsonField<List<String>>) = apply { + this.exampleIds = exampleIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [exampleIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExampleId(exampleId: String) = apply { + exampleIds = + (exampleIds ?: JsonField.of(mutableListOf())).also { + checkKnown("exampleIds", it).add(exampleId) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ExampleUploadResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ExampleUploadResponse = + ExampleUploadResponse( + count, + (exampleIds ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ExampleUploadResponse = apply { + if (validated) { + return@apply + } + + count() + exampleIds() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (count.asKnown().isPresent) 1 else 0) + (exampleIds.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExampleUploadResponse && + count == other.count && + exampleIds == other.exampleIds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(count, exampleIds, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ExampleUploadResponse{count=$count, exampleIds=$exampleIds, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicy.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicy.kt new file mode 100644 index 00000000..c3422ea6 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicy.kt @@ -0,0 +1,443 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.orgs.current.accesspolicies + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class AccessPolicy +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val conditionGroups: JsonField<List<ConditionGroup>>, + private val createdAt: JsonField<String>, + private val description: JsonField<String>, + private val effect: JsonField<String>, + private val name: JsonField<String>, + private val roleIds: JsonField<List<String>>, + private val updatedAt: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("condition_groups") + @ExcludeMissing + conditionGroups: JsonField<List<ConditionGroup>> = JsonMissing.of(), + @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField<String> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("effect") @ExcludeMissing effect: JsonField<String> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("role_ids") + @ExcludeMissing + roleIds: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("updated_at") @ExcludeMissing updatedAt: JsonField<String> = JsonMissing.of(), + ) : this( + id, + conditionGroups, + createdAt, + description, + effect, + name, + roleIds, + updatedAt, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conditionGroups(): Optional<List<ConditionGroup>> = + conditionGroups.getOptional("condition_groups") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun createdAt(): Optional<String> = createdAt.getOptional("created_at") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun effect(): Optional<String> = effect.getOptional("effect") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional<String> = name.getOptional("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun roleIds(): Optional<List<String>> = roleIds.getOptional("role_ids") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun updatedAt(): Optional<String> = updatedAt.getOptional("updated_at") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [conditionGroups]. + * + * Unlike [conditionGroups], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("condition_groups") + @ExcludeMissing + fun _conditionGroups(): JsonField<List<ConditionGroup>> = conditionGroups + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") @ExcludeMissing fun _createdAt(): JsonField<String> = createdAt + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [effect]. + * + * Unlike [effect], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("effect") @ExcludeMissing fun _effect(): JsonField<String> = effect + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [roleIds]. + * + * Unlike [roleIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("role_ids") @ExcludeMissing fun _roleIds(): JsonField<List<String>> = roleIds + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") @ExcludeMissing fun _updatedAt(): JsonField<String> = updatedAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [AccessPolicy]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AccessPolicy]. */ + class Builder internal constructor() { + + private var id: JsonField<String> = JsonMissing.of() + private var conditionGroups: JsonField<MutableList<ConditionGroup>>? = null + private var createdAt: JsonField<String> = JsonMissing.of() + private var description: JsonField<String> = JsonMissing.of() + private var effect: JsonField<String> = JsonMissing.of() + private var name: JsonField<String> = JsonMissing.of() + private var roleIds: JsonField<MutableList<String>>? = null + private var updatedAt: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(accessPolicy: AccessPolicy) = apply { + id = accessPolicy.id + conditionGroups = accessPolicy.conditionGroups.map { it.toMutableList() } + createdAt = accessPolicy.createdAt + description = accessPolicy.description + effect = accessPolicy.effect + name = accessPolicy.name + roleIds = accessPolicy.roleIds.map { it.toMutableList() } + updatedAt = accessPolicy.updatedAt + additionalProperties = accessPolicy.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun conditionGroups(conditionGroups: List<ConditionGroup>) = + conditionGroups(JsonField.of(conditionGroups)) + + /** + * Sets [Builder.conditionGroups] to an arbitrary JSON value. + * + * You should usually call [Builder.conditionGroups] with a well-typed + * `List<ConditionGroup>` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun conditionGroups(conditionGroups: JsonField<List<ConditionGroup>>) = apply { + this.conditionGroups = conditionGroups.map { it.toMutableList() } + } + + /** + * Adds a single [ConditionGroup] to [conditionGroups]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addConditionGroup(conditionGroup: ConditionGroup) = apply { + conditionGroups = + (conditionGroups ?: JsonField.of(mutableListOf())).also { + checkKnown("conditionGroups", it).add(conditionGroup) + } + } + + fun createdAt(createdAt: String) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun createdAt(createdAt: JsonField<String>) = apply { this.createdAt = createdAt } + + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField<String>) = apply { this.description = description } + + fun effect(effect: String) = effect(JsonField.of(effect)) + + /** + * Sets [Builder.effect] to an arbitrary JSON value. + * + * You should usually call [Builder.effect] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun effect(effect: JsonField<String>) = apply { this.effect = effect } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun roleIds(roleIds: List<String>) = roleIds(JsonField.of(roleIds)) + + /** + * Sets [Builder.roleIds] to an arbitrary JSON value. + * + * You should usually call [Builder.roleIds] with a well-typed `List<String>` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun roleIds(roleIds: JsonField<List<String>>) = apply { + this.roleIds = roleIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [roleIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRoleId(roleId: String) = apply { + roleIds = + (roleIds ?: JsonField.of(mutableListOf())).also { + checkKnown("roleIds", it).add(roleId) + } + } + + fun updatedAt(updatedAt: String) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun updatedAt(updatedAt: JsonField<String>) = apply { this.updatedAt = updatedAt } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AccessPolicy]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AccessPolicy = + AccessPolicy( + id, + (conditionGroups ?: JsonMissing.of()).map { it.toImmutable() }, + createdAt, + description, + effect, + name, + (roleIds ?: JsonMissing.of()).map { it.toImmutable() }, + updatedAt, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AccessPolicy = apply { + if (validated) { + return@apply + } + + id() + conditionGroups().ifPresent { it.forEach { it.validate() } } + createdAt() + description() + effect() + name() + roleIds() + updatedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (conditionGroups.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (effect.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (roleIds.asKnown().getOrNull()?.size ?: 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AccessPolicy && + id == other.id && + conditionGroups == other.conditionGroups && + createdAt == other.createdAt && + description == other.description && + effect == other.effect && + name == other.name && + roleIds == other.roleIds && + updatedAt == other.updatedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + conditionGroups, + createdAt, + description, + effect, + name, + roleIds, + updatedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AccessPolicy{id=$id, conditionGroups=$conditionGroups, createdAt=$createdAt, description=$description, effect=$effect, name=$name, roleIds=$roleIds, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyCreateParams.kt new file mode 100644 index 00000000..15a03753 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyCreateParams.kt @@ -0,0 +1,709 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.orgs.current.accesspolicies + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Creates a new access policy. The request body must be a JSON-encoded access policy object that + * follows the CreateAccessPolicyRequest schema. + */ +class AccessPolicyCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun payload(): Optional<Payload> = body.payload() + + /** + * Returns the raw JSON value of [payload]. + * + * Unlike [payload], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _payload(): JsonField<Payload> = body._payload() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): AccessPolicyCreateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AccessPolicyCreateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AccessPolicyCreateParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(accessPolicyCreateParams: AccessPolicyCreateParams) = apply { + body = accessPolicyCreateParams.body.toBuilder() + additionalHeaders = accessPolicyCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = accessPolicyCreateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [payload] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun payload(payload: Payload) = apply { body.payload(payload) } + + /** + * Sets [Builder.payload] to an arbitrary JSON value. + * + * You should usually call [Builder.payload] with a well-typed [Payload] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun payload(payload: JsonField<Payload>) = apply { body.payload(payload) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [AccessPolicyCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AccessPolicyCreateParams = + AccessPolicyCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val payload: JsonField<Payload>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("payload") @ExcludeMissing payload: JsonField<Payload> = JsonMissing.of() + ) : this(payload, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun payload(): Optional<Payload> = payload.getOptional("payload") + + /** + * Returns the raw JSON value of [payload]. + * + * Unlike [payload], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("payload") @ExcludeMissing fun _payload(): JsonField<Payload> = payload + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var payload: JsonField<Payload> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + payload = body.payload + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun payload(payload: Payload) = payload(JsonField.of(payload)) + + /** + * Sets [Builder.payload] to an arbitrary JSON value. + * + * You should usually call [Builder.payload] with a well-typed [Payload] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun payload(payload: JsonField<Payload>) = apply { this.payload = payload } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = Body(payload, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + payload().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (payload.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + payload == other.payload && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(payload, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{payload=$payload, additionalProperties=$additionalProperties}" + } + + class Payload + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val conditionGroups: JsonField<List<ConditionGroup>>, + private val description: JsonField<String>, + private val effect: JsonField<String>, + private val name: JsonField<String>, + private val roleIds: JsonField<List<String>>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("condition_groups") + @ExcludeMissing + conditionGroups: JsonField<List<ConditionGroup>> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField<String> = JsonMissing.of(), + @JsonProperty("effect") @ExcludeMissing effect: JsonField<String> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("role_ids") + @ExcludeMissing + roleIds: JsonField<List<String>> = JsonMissing.of(), + ) : this(conditionGroups, description, effect, name, roleIds, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun conditionGroups(): Optional<List<ConditionGroup>> = + conditionGroups.getOptional("condition_groups") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional<String> = description.getOptional("description") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun effect(): Optional<String> = effect.getOptional("effect") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun name(): Optional<String> = name.getOptional("name") + + /** + * if present, attach to the specified roles + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun roleIds(): Optional<List<String>> = roleIds.getOptional("role_ids") + + /** + * Returns the raw JSON value of [conditionGroups]. + * + * Unlike [conditionGroups], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("condition_groups") + @ExcludeMissing + fun _conditionGroups(): JsonField<List<ConditionGroup>> = conditionGroups + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField<String> = description + + /** + * Returns the raw JSON value of [effect]. + * + * Unlike [effect], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("effect") @ExcludeMissing fun _effect(): JsonField<String> = effect + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [roleIds]. + * + * Unlike [roleIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("role_ids") @ExcludeMissing fun _roleIds(): JsonField<List<String>> = roleIds + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Payload]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Payload]. */ + class Builder internal constructor() { + + private var conditionGroups: JsonField<MutableList<ConditionGroup>>? = null + private var description: JsonField<String> = JsonMissing.of() + private var effect: JsonField<String> = JsonMissing.of() + private var name: JsonField<String> = JsonMissing.of() + private var roleIds: JsonField<MutableList<String>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(payload: Payload) = apply { + conditionGroups = payload.conditionGroups.map { it.toMutableList() } + description = payload.description + effect = payload.effect + name = payload.name + roleIds = payload.roleIds.map { it.toMutableList() } + additionalProperties = payload.additionalProperties.toMutableMap() + } + + fun conditionGroups(conditionGroups: List<ConditionGroup>) = + conditionGroups(JsonField.of(conditionGroups)) + + /** + * Sets [Builder.conditionGroups] to an arbitrary JSON value. + * + * You should usually call [Builder.conditionGroups] with a well-typed + * `List<ConditionGroup>` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun conditionGroups(conditionGroups: JsonField<List<ConditionGroup>>) = apply { + this.conditionGroups = conditionGroups.map { it.toMutableList() } + } + + /** + * Adds a single [ConditionGroup] to [conditionGroups]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addConditionGroup(conditionGroup: ConditionGroup) = apply { + conditionGroups = + (conditionGroups ?: JsonField.of(mutableListOf())).also { + checkKnown("conditionGroups", it).add(conditionGroup) + } + } + + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField<String>) = apply { + this.description = description + } + + fun effect(effect: String) = effect(JsonField.of(effect)) + + /** + * Sets [Builder.effect] to an arbitrary JSON value. + * + * You should usually call [Builder.effect] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun effect(effect: JsonField<String>) = apply { this.effect = effect } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + /** if present, attach to the specified roles */ + fun roleIds(roleIds: List<String>) = roleIds(JsonField.of(roleIds)) + + /** + * Sets [Builder.roleIds] to an arbitrary JSON value. + * + * You should usually call [Builder.roleIds] with a well-typed `List<String>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun roleIds(roleIds: JsonField<List<String>>) = apply { + this.roleIds = roleIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [roleIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRoleId(roleId: String) = apply { + roleIds = + (roleIds ?: JsonField.of(mutableListOf())).also { + checkKnown("roleIds", it).add(roleId) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Payload]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Payload = + Payload( + (conditionGroups ?: JsonMissing.of()).map { it.toImmutable() }, + description, + effect, + name, + (roleIds ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Payload = apply { + if (validated) { + return@apply + } + + conditionGroups().ifPresent { it.forEach { it.validate() } } + description() + effect() + name() + roleIds() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (conditionGroups.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (effect.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (roleIds.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Payload && + conditionGroups == other.conditionGroups && + description == other.description && + effect == other.effect && + name == other.name && + roleIds == other.roleIds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(conditionGroups, description, effect, name, roleIds, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Payload{conditionGroups=$conditionGroups, description=$description, effect=$effect, name=$name, roleIds=$roleIds, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AccessPolicyCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "AccessPolicyCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyCreateResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyCreateResponse.kt new file mode 100644 index 00000000..1febf90e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyCreateResponse.kt @@ -0,0 +1,155 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.orgs.current.accesspolicies + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional + +class AccessPolicyCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of() + ) : this(id, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AccessPolicyCreateResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AccessPolicyCreateResponse]. */ + class Builder internal constructor() { + + private var id: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(accessPolicyCreateResponse: AccessPolicyCreateResponse) = apply { + id = accessPolicyCreateResponse.id + additionalProperties = accessPolicyCreateResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AccessPolicyCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AccessPolicyCreateResponse = + AccessPolicyCreateResponse(id, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): AccessPolicyCreateResponse = apply { + if (validated) { + return@apply + } + + id() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AccessPolicyCreateResponse && + id == other.id && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AccessPolicyCreateResponse{id=$id, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyDeleteParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyDeleteParams.kt new file mode 100644 index 00000000..47f006b6 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyDeleteParams.kt @@ -0,0 +1,238 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.orgs.current.accesspolicies + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Deletes a specific access policy by ID. */ +class AccessPolicyDeleteParams +private constructor( + private val accessPolicyId: JsonValue?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map<String, JsonValue>, +) : Params { + + fun accessPolicyId(): Optional<JsonValue> = Optional.ofNullable(accessPolicyId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): AccessPolicyDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AccessPolicyDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AccessPolicyDeleteParams]. */ + class Builder internal constructor() { + + private var accessPolicyId: JsonValue? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(accessPolicyDeleteParams: AccessPolicyDeleteParams) = apply { + accessPolicyId = accessPolicyDeleteParams.accessPolicyId + additionalHeaders = accessPolicyDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = accessPolicyDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + accessPolicyDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun accessPolicyId(accessPolicyId: JsonValue?) = apply { + this.accessPolicyId = accessPolicyId + } + + /** Alias for calling [Builder.accessPolicyId] with `accessPolicyId.orElse(null)`. */ + fun accessPolicyId(accessPolicyId: Optional<JsonValue>) = + accessPolicyId(accessPolicyId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [AccessPolicyDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AccessPolicyDeleteParams = + AccessPolicyDeleteParams( + accessPolicyId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional<Map<String, JsonValue>> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> accessPolicyId?.toString() ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AccessPolicyDeleteParams && + accessPolicyId == other.accessPolicyId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + accessPolicyId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "AccessPolicyDeleteParams{accessPolicyId=$accessPolicyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyListParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyListParams.kt new file mode 100644 index 00000000..0e3f37db --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyListParams.kt @@ -0,0 +1,170 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.orgs.current.accesspolicies + +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** Lists all access policies for the organization. */ +class AccessPolicyListParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): AccessPolicyListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AccessPolicyListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AccessPolicyListParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(accessPolicyListParams: AccessPolicyListParams) = apply { + additionalHeaders = accessPolicyListParams.additionalHeaders.toBuilder() + additionalQueryParams = accessPolicyListParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [AccessPolicyListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AccessPolicyListParams = + AccessPolicyListParams(additionalHeaders.build(), additionalQueryParams.build()) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AccessPolicyListParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "AccessPolicyListParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyListResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyListResponse.kt new file mode 100644 index 00000000..65058a09 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyListResponse.kt @@ -0,0 +1,182 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.orgs.current.accesspolicies + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class AccessPolicyListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val accessPolicies: JsonField<List<AccessPolicy>>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("access_policies") + @ExcludeMissing + accessPolicies: JsonField<List<AccessPolicy>> = JsonMissing.of() + ) : this(accessPolicies, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun accessPolicies(): Optional<List<AccessPolicy>> = + accessPolicies.getOptional("access_policies") + + /** + * Returns the raw JSON value of [accessPolicies]. + * + * Unlike [accessPolicies], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("access_policies") + @ExcludeMissing + fun _accessPolicies(): JsonField<List<AccessPolicy>> = accessPolicies + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [AccessPolicyListResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AccessPolicyListResponse]. */ + class Builder internal constructor() { + + private var accessPolicies: JsonField<MutableList<AccessPolicy>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(accessPolicyListResponse: AccessPolicyListResponse) = apply { + accessPolicies = accessPolicyListResponse.accessPolicies.map { it.toMutableList() } + additionalProperties = accessPolicyListResponse.additionalProperties.toMutableMap() + } + + fun accessPolicies(accessPolicies: List<AccessPolicy>) = + accessPolicies(JsonField.of(accessPolicies)) + + /** + * Sets [Builder.accessPolicies] to an arbitrary JSON value. + * + * You should usually call [Builder.accessPolicies] with a well-typed `List<AccessPolicy>` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun accessPolicies(accessPolicies: JsonField<List<AccessPolicy>>) = apply { + this.accessPolicies = accessPolicies.map { it.toMutableList() } + } + + /** + * Adds a single [AccessPolicy] to [accessPolicies]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAccessPolicy(accessPolicy: AccessPolicy) = apply { + accessPolicies = + (accessPolicies ?: JsonField.of(mutableListOf())).also { + checkKnown("accessPolicies", it).add(accessPolicy) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AccessPolicyListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AccessPolicyListResponse = + AccessPolicyListResponse( + (accessPolicies ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AccessPolicyListResponse = apply { + if (validated) { + return@apply + } + + accessPolicies().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (accessPolicies.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AccessPolicyListResponse && + accessPolicies == other.accessPolicies && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(accessPolicies, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AccessPolicyListResponse{accessPolicies=$accessPolicies, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyRetrieveParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyRetrieveParams.kt new file mode 100644 index 00000000..a0ddef99 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyRetrieveParams.kt @@ -0,0 +1,200 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.orgs.current.accesspolicies + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Gets a specific access policy by ID. */ +class AccessPolicyRetrieveParams +private constructor( + private val accessPolicyId: JsonValue?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun accessPolicyId(): Optional<JsonValue> = Optional.ofNullable(accessPolicyId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): AccessPolicyRetrieveParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [AccessPolicyRetrieveParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AccessPolicyRetrieveParams]. */ + class Builder internal constructor() { + + private var accessPolicyId: JsonValue? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(accessPolicyRetrieveParams: AccessPolicyRetrieveParams) = apply { + accessPolicyId = accessPolicyRetrieveParams.accessPolicyId + additionalHeaders = accessPolicyRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = accessPolicyRetrieveParams.additionalQueryParams.toBuilder() + } + + fun accessPolicyId(accessPolicyId: JsonValue?) = apply { + this.accessPolicyId = accessPolicyId + } + + /** Alias for calling [Builder.accessPolicyId] with `accessPolicyId.orElse(null)`. */ + fun accessPolicyId(accessPolicyId: Optional<JsonValue>) = + accessPolicyId(accessPolicyId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [AccessPolicyRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AccessPolicyRetrieveParams = + AccessPolicyRetrieveParams( + accessPolicyId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> accessPolicyId?.toString() ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AccessPolicyRetrieveParams && + accessPolicyId == other.accessPolicyId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(accessPolicyId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "AccessPolicyRetrieveParams{accessPolicyId=$accessPolicyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/ConditionGroup.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/ConditionGroup.kt new file mode 100644 index 00000000..06c9ac7b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/ConditionGroup.kt @@ -0,0 +1,1208 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.orgs.current.accesspolicies + +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.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ConditionGroup +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val conditions: JsonField<List<Condition>>, + private val permission: JsonField<Permission>, + private val resourceType: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("conditions") + @ExcludeMissing + conditions: JsonField<List<Condition>> = JsonMissing.of(), + @JsonProperty("permission") + @ExcludeMissing + permission: JsonField<Permission> = JsonMissing.of(), + @JsonProperty("resource_type") + @ExcludeMissing + resourceType: JsonField<String> = JsonMissing.of(), + ) : this(conditions, permission, resourceType, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conditions(): Optional<List<Condition>> = conditions.getOptional("conditions") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun permission(): Optional<Permission> = permission.getOptional("permission") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun resourceType(): Optional<String> = resourceType.getOptional("resource_type") + + /** + * Returns the raw JSON value of [conditions]. + * + * Unlike [conditions], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("conditions") + @ExcludeMissing + fun _conditions(): JsonField<List<Condition>> = conditions + + /** + * Returns the raw JSON value of [permission]. + * + * Unlike [permission], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("permission") + @ExcludeMissing + fun _permission(): JsonField<Permission> = permission + + /** + * Returns the raw JSON value of [resourceType]. + * + * Unlike [resourceType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("resource_type") + @ExcludeMissing + fun _resourceType(): JsonField<String> = resourceType + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ConditionGroup]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConditionGroup]. */ + class Builder internal constructor() { + + private var conditions: JsonField<MutableList<Condition>>? = null + private var permission: JsonField<Permission> = JsonMissing.of() + private var resourceType: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(conditionGroup: ConditionGroup) = apply { + conditions = conditionGroup.conditions.map { it.toMutableList() } + permission = conditionGroup.permission + resourceType = conditionGroup.resourceType + additionalProperties = conditionGroup.additionalProperties.toMutableMap() + } + + fun conditions(conditions: List<Condition>) = conditions(JsonField.of(conditions)) + + /** + * Sets [Builder.conditions] to an arbitrary JSON value. + * + * You should usually call [Builder.conditions] with a well-typed `List<Condition>` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun conditions(conditions: JsonField<List<Condition>>) = apply { + this.conditions = conditions.map { it.toMutableList() } + } + + /** + * Adds a single [Condition] to [conditions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCondition(condition: Condition) = apply { + conditions = + (conditions ?: JsonField.of(mutableListOf())).also { + checkKnown("conditions", it).add(condition) + } + } + + fun permission(permission: Permission) = permission(JsonField.of(permission)) + + /** + * Sets [Builder.permission] to an arbitrary JSON value. + * + * You should usually call [Builder.permission] with a well-typed [Permission] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun permission(permission: JsonField<Permission>) = apply { this.permission = permission } + + fun resourceType(resourceType: String) = resourceType(JsonField.of(resourceType)) + + /** + * Sets [Builder.resourceType] to an arbitrary JSON value. + * + * You should usually call [Builder.resourceType] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun resourceType(resourceType: JsonField<String>) = apply { + this.resourceType = resourceType + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ConditionGroup]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ConditionGroup = + ConditionGroup( + (conditions ?: JsonMissing.of()).map { it.toImmutable() }, + permission, + resourceType, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConditionGroup = apply { + if (validated) { + return@apply + } + + conditions().ifPresent { it.forEach { it.validate() } } + permission().ifPresent { it.validate() } + resourceType() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (conditions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (permission.asKnown().getOrNull()?.validity() ?: 0) + + (if (resourceType.asKnown().isPresent) 1 else 0) + + class Condition + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val attributeKey: JsonField<String>, + private val attributeName: JsonField<AttributeName>, + private val attributeValue: JsonField<String>, + private val operator: JsonField<Operator>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("attribute_key") + @ExcludeMissing + attributeKey: JsonField<String> = JsonMissing.of(), + @JsonProperty("attribute_name") + @ExcludeMissing + attributeName: JsonField<AttributeName> = JsonMissing.of(), + @JsonProperty("attribute_value") + @ExcludeMissing + attributeValue: JsonField<String> = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField<Operator> = JsonMissing.of(), + ) : this(attributeKey, attributeName, attributeValue, operator, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun attributeKey(): Optional<String> = attributeKey.getOptional("attribute_key") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun attributeName(): Optional<AttributeName> = attributeName.getOptional("attribute_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun attributeValue(): Optional<String> = attributeValue.getOptional("attribute_value") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun operator(): Optional<Operator> = operator.getOptional("operator") + + /** + * Returns the raw JSON value of [attributeKey]. + * + * Unlike [attributeKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("attribute_key") + @ExcludeMissing + fun _attributeKey(): JsonField<String> = attributeKey + + /** + * Returns the raw JSON value of [attributeName]. + * + * Unlike [attributeName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("attribute_name") + @ExcludeMissing + fun _attributeName(): JsonField<AttributeName> = attributeName + + /** + * Returns the raw JSON value of [attributeValue]. + * + * Unlike [attributeValue], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("attribute_value") + @ExcludeMissing + fun _attributeValue(): JsonField<String> = attributeValue + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField<Operator> = operator + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Condition]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Condition]. */ + class Builder internal constructor() { + + private var attributeKey: JsonField<String> = JsonMissing.of() + private var attributeName: JsonField<AttributeName> = JsonMissing.of() + private var attributeValue: JsonField<String> = JsonMissing.of() + private var operator: JsonField<Operator> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(condition: Condition) = apply { + attributeKey = condition.attributeKey + attributeName = condition.attributeName + attributeValue = condition.attributeValue + operator = condition.operator + additionalProperties = condition.additionalProperties.toMutableMap() + } + + fun attributeKey(attributeKey: String) = attributeKey(JsonField.of(attributeKey)) + + /** + * Sets [Builder.attributeKey] to an arbitrary JSON value. + * + * You should usually call [Builder.attributeKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun attributeKey(attributeKey: JsonField<String>) = apply { + this.attributeKey = attributeKey + } + + fun attributeName(attributeName: AttributeName) = + attributeName(JsonField.of(attributeName)) + + /** + * Sets [Builder.attributeName] to an arbitrary JSON value. + * + * You should usually call [Builder.attributeName] with a well-typed [AttributeName] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun attributeName(attributeName: JsonField<AttributeName>) = apply { + this.attributeName = attributeName + } + + fun attributeValue(attributeValue: String) = + attributeValue(JsonField.of(attributeValue)) + + /** + * Sets [Builder.attributeValue] to an arbitrary JSON value. + * + * You should usually call [Builder.attributeValue] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun attributeValue(attributeValue: JsonField<String>) = apply { + this.attributeValue = attributeValue + } + + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun operator(operator: JsonField<Operator>) = apply { this.operator = operator } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Condition]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Condition = + Condition( + attributeKey, + attributeName, + attributeValue, + operator, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Condition = apply { + if (validated) { + return@apply + } + + attributeKey() + attributeName().ifPresent { it.validate() } + attributeValue() + operator().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (attributeKey.asKnown().isPresent) 1 else 0) + + (attributeName.asKnown().getOrNull()?.validity() ?: 0) + + (if (attributeValue.asKnown().isPresent) 1 else 0) + + (operator.asKnown().getOrNull()?.validity() ?: 0) + + class AttributeName @JsonCreator private constructor(private val value: JsonField<String>) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val RESOURCE_TAG_KEY = of("resource_tag_key") + + @JvmStatic fun of(value: String) = AttributeName(JsonField.of(value)) + } + + /** An enum containing [AttributeName]'s known values. */ + enum class Known { + RESOURCE_TAG_KEY + } + + /** + * An enum containing [AttributeName]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AttributeName] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + RESOURCE_TAG_KEY, + /** + * An enum member indicating that [AttributeName] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + RESOURCE_TAG_KEY -> Value.RESOURCE_TAG_KEY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + RESOURCE_TAG_KEY -> Known.RESOURCE_TAG_KEY + else -> throw LangsmithApiInvalidDataException("Unknown AttributeName: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AttributeName = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AttributeName && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Operator @JsonCreator private constructor(private val value: JsonField<String>) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val EQUALS = of("equals") + + @JvmField val NOT_EQUALS = of("not_equals") + + @JvmField val EQUALS_IGNORE_CASE = of("equals_ignore_case") + + @JvmField val NOT_EQUALS_IGNORE_CASE = of("not_equals_ignore_case") + + @JvmField val MATCHES = of("matches") + + @JvmField val NOT_MATCHES = of("not_matches") + + @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + EQUALS, + NOT_EQUALS, + EQUALS_IGNORE_CASE, + NOT_EQUALS_IGNORE_CASE, + MATCHES, + NOT_MATCHES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + EQUALS, + NOT_EQUALS, + EQUALS_IGNORE_CASE, + NOT_EQUALS_IGNORE_CASE, + MATCHES, + NOT_MATCHES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + EQUALS -> Value.EQUALS + NOT_EQUALS -> Value.NOT_EQUALS + EQUALS_IGNORE_CASE -> Value.EQUALS_IGNORE_CASE + NOT_EQUALS_IGNORE_CASE -> Value.NOT_EQUALS_IGNORE_CASE + MATCHES -> Value.MATCHES + NOT_MATCHES -> Value.NOT_MATCHES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + EQUALS -> Known.EQUALS + NOT_EQUALS -> Known.NOT_EQUALS + EQUALS_IGNORE_CASE -> Known.EQUALS_IGNORE_CASE + NOT_EQUALS_IGNORE_CASE -> Known.NOT_EQUALS_IGNORE_CASE + MATCHES -> Known.MATCHES + NOT_MATCHES -> Known.NOT_MATCHES + else -> throw LangsmithApiInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Condition && + attributeKey == other.attributeKey && + attributeName == other.attributeName && + attributeValue == other.attributeValue && + operator == other.operator && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + attributeKey, + attributeName, + attributeValue, + operator, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Condition{attributeKey=$attributeKey, attributeName=$attributeName, attributeValue=$attributeValue, operator=$operator, additionalProperties=$additionalProperties}" + } + + class Permission @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val ANNOTATION_QUEUES_CREATE = of("annotation-queues:create") + + @JvmField val ANNOTATION_QUEUES_DELETE = of("annotation-queues:delete") + + @JvmField val ANNOTATION_QUEUES_READ = of("annotation-queues:read") + + @JvmField val ANNOTATION_QUEUES_UPDATE = of("annotation-queues:update") + + @JvmField val CHARTS_CREATE = of("charts:create") + + @JvmField val CHARTS_DELETE = of("charts:delete") + + @JvmField val CHARTS_READ = of("charts:read") + + @JvmField val CHARTS_UPDATE = of("charts:update") + + @JvmField val DATASETS_CREATE = of("datasets:create") + + @JvmField val DATASETS_DELETE = of("datasets:delete") + + @JvmField val DATASETS_READ = of("datasets:read") + + @JvmField val DATASETS_SHARE = of("datasets:share") + + @JvmField val DATASETS_UPDATE = of("datasets:update") + + @JvmField val DEPLOYMENTS_CREATE = of("deployments:create") + + @JvmField val DEPLOYMENTS_DELETE = of("deployments:delete") + + @JvmField val DEPLOYMENTS_READ = of("deployments:read") + + @JvmField val DEPLOYMENTS_UPDATE = of("deployments:update") + + @JvmField val FEEDBACK_CREATE = of("feedback:create") + + @JvmField val FEEDBACK_DELETE = of("feedback:delete") + + @JvmField val FEEDBACK_READ = of("feedback:read") + + @JvmField val FEEDBACK_UPDATE = of("feedback:update") + + @JvmField val PROJECTS_CREATE = of("projects:create") + + @JvmField val PROJECTS_DELETE = of("projects:delete") + + @JvmField val PROJECTS_READ = of("projects:read") + + @JvmField val PROJECTS_UPDATE = of("projects:update") + + @JvmField val PROMPTS_CREATE = of("prompts:create") + + @JvmField val PROMPTS_DELETE = of("prompts:delete") + + @JvmField val PROMPTS_READ = of("prompts:read") + + @JvmField val PROMPTS_UPDATE = of("prompts:update") + + @JvmField val PROMPTS_SHARE = of("prompts:share") + + @JvmField val RULES_CREATE = of("rules:create") + + @JvmField val RULES_DELETE = of("rules:delete") + + @JvmField val RULES_READ = of("rules:read") + + @JvmField val RULES_UPDATE = of("rules:update") + + @JvmField val RUNS_CREATE = of("runs:create") + + @JvmField val RUNS_READ = of("runs:read") + + @JvmField val RUNS_SHARE = of("runs:share") + + @JvmField val RUNS_DELETE = of("runs:delete") + + @JvmField val WORKSPACES_MANAGE = of("workspaces:manage") + + @JvmField val WORKSPACES_READ = of("workspaces:read") + + @JvmField val ALERTS_CREATE = of("alerts:create") + + @JvmField val ALERTS_UPDATE = of("alerts:update") + + @JvmField val ALERTS_DELETE = of("alerts:delete") + + @JvmField val ALERTS_READ = of("alerts:read") + + @JvmField val ORGANIZATION_PATS_CREATE = of("organization:pats:create") + + @JvmField val ORGANIZATION_READ = of("organization:read") + + @JvmField val ORGANIZATION_MANAGE = of("organization:manage") + + @JvmStatic fun of(value: String) = Permission(JsonField.of(value)) + } + + /** An enum containing [Permission]'s known values. */ + enum class Known { + ANNOTATION_QUEUES_CREATE, + ANNOTATION_QUEUES_DELETE, + ANNOTATION_QUEUES_READ, + ANNOTATION_QUEUES_UPDATE, + CHARTS_CREATE, + CHARTS_DELETE, + CHARTS_READ, + CHARTS_UPDATE, + DATASETS_CREATE, + DATASETS_DELETE, + DATASETS_READ, + DATASETS_SHARE, + DATASETS_UPDATE, + DEPLOYMENTS_CREATE, + DEPLOYMENTS_DELETE, + DEPLOYMENTS_READ, + DEPLOYMENTS_UPDATE, + FEEDBACK_CREATE, + FEEDBACK_DELETE, + FEEDBACK_READ, + FEEDBACK_UPDATE, + PROJECTS_CREATE, + PROJECTS_DELETE, + PROJECTS_READ, + PROJECTS_UPDATE, + PROMPTS_CREATE, + PROMPTS_DELETE, + PROMPTS_READ, + PROMPTS_UPDATE, + PROMPTS_SHARE, + RULES_CREATE, + RULES_DELETE, + RULES_READ, + RULES_UPDATE, + RUNS_CREATE, + RUNS_READ, + RUNS_SHARE, + RUNS_DELETE, + WORKSPACES_MANAGE, + WORKSPACES_READ, + ALERTS_CREATE, + ALERTS_UPDATE, + ALERTS_DELETE, + ALERTS_READ, + ORGANIZATION_PATS_CREATE, + ORGANIZATION_READ, + ORGANIZATION_MANAGE, + } + + /** + * An enum containing [Permission]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Permission] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNOTATION_QUEUES_CREATE, + ANNOTATION_QUEUES_DELETE, + ANNOTATION_QUEUES_READ, + ANNOTATION_QUEUES_UPDATE, + CHARTS_CREATE, + CHARTS_DELETE, + CHARTS_READ, + CHARTS_UPDATE, + DATASETS_CREATE, + DATASETS_DELETE, + DATASETS_READ, + DATASETS_SHARE, + DATASETS_UPDATE, + DEPLOYMENTS_CREATE, + DEPLOYMENTS_DELETE, + DEPLOYMENTS_READ, + DEPLOYMENTS_UPDATE, + FEEDBACK_CREATE, + FEEDBACK_DELETE, + FEEDBACK_READ, + FEEDBACK_UPDATE, + PROJECTS_CREATE, + PROJECTS_DELETE, + PROJECTS_READ, + PROJECTS_UPDATE, + PROMPTS_CREATE, + PROMPTS_DELETE, + PROMPTS_READ, + PROMPTS_UPDATE, + PROMPTS_SHARE, + RULES_CREATE, + RULES_DELETE, + RULES_READ, + RULES_UPDATE, + RUNS_CREATE, + RUNS_READ, + RUNS_SHARE, + RUNS_DELETE, + WORKSPACES_MANAGE, + WORKSPACES_READ, + ALERTS_CREATE, + ALERTS_UPDATE, + ALERTS_DELETE, + ALERTS_READ, + ORGANIZATION_PATS_CREATE, + ORGANIZATION_READ, + ORGANIZATION_MANAGE, + /** + * An enum member indicating that [Permission] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNOTATION_QUEUES_CREATE -> Value.ANNOTATION_QUEUES_CREATE + ANNOTATION_QUEUES_DELETE -> Value.ANNOTATION_QUEUES_DELETE + ANNOTATION_QUEUES_READ -> Value.ANNOTATION_QUEUES_READ + ANNOTATION_QUEUES_UPDATE -> Value.ANNOTATION_QUEUES_UPDATE + CHARTS_CREATE -> Value.CHARTS_CREATE + CHARTS_DELETE -> Value.CHARTS_DELETE + CHARTS_READ -> Value.CHARTS_READ + CHARTS_UPDATE -> Value.CHARTS_UPDATE + DATASETS_CREATE -> Value.DATASETS_CREATE + DATASETS_DELETE -> Value.DATASETS_DELETE + DATASETS_READ -> Value.DATASETS_READ + DATASETS_SHARE -> Value.DATASETS_SHARE + DATASETS_UPDATE -> Value.DATASETS_UPDATE + DEPLOYMENTS_CREATE -> Value.DEPLOYMENTS_CREATE + DEPLOYMENTS_DELETE -> Value.DEPLOYMENTS_DELETE + DEPLOYMENTS_READ -> Value.DEPLOYMENTS_READ + DEPLOYMENTS_UPDATE -> Value.DEPLOYMENTS_UPDATE + FEEDBACK_CREATE -> Value.FEEDBACK_CREATE + FEEDBACK_DELETE -> Value.FEEDBACK_DELETE + FEEDBACK_READ -> Value.FEEDBACK_READ + FEEDBACK_UPDATE -> Value.FEEDBACK_UPDATE + PROJECTS_CREATE -> Value.PROJECTS_CREATE + PROJECTS_DELETE -> Value.PROJECTS_DELETE + PROJECTS_READ -> Value.PROJECTS_READ + PROJECTS_UPDATE -> Value.PROJECTS_UPDATE + PROMPTS_CREATE -> Value.PROMPTS_CREATE + PROMPTS_DELETE -> Value.PROMPTS_DELETE + PROMPTS_READ -> Value.PROMPTS_READ + PROMPTS_UPDATE -> Value.PROMPTS_UPDATE + PROMPTS_SHARE -> Value.PROMPTS_SHARE + RULES_CREATE -> Value.RULES_CREATE + RULES_DELETE -> Value.RULES_DELETE + RULES_READ -> Value.RULES_READ + RULES_UPDATE -> Value.RULES_UPDATE + RUNS_CREATE -> Value.RUNS_CREATE + RUNS_READ -> Value.RUNS_READ + RUNS_SHARE -> Value.RUNS_SHARE + RUNS_DELETE -> Value.RUNS_DELETE + WORKSPACES_MANAGE -> Value.WORKSPACES_MANAGE + WORKSPACES_READ -> Value.WORKSPACES_READ + ALERTS_CREATE -> Value.ALERTS_CREATE + ALERTS_UPDATE -> Value.ALERTS_UPDATE + ALERTS_DELETE -> Value.ALERTS_DELETE + ALERTS_READ -> Value.ALERTS_READ + ORGANIZATION_PATS_CREATE -> Value.ORGANIZATION_PATS_CREATE + ORGANIZATION_READ -> Value.ORGANIZATION_READ + ORGANIZATION_MANAGE -> Value.ORGANIZATION_MANAGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ANNOTATION_QUEUES_CREATE -> Known.ANNOTATION_QUEUES_CREATE + ANNOTATION_QUEUES_DELETE -> Known.ANNOTATION_QUEUES_DELETE + ANNOTATION_QUEUES_READ -> Known.ANNOTATION_QUEUES_READ + ANNOTATION_QUEUES_UPDATE -> Known.ANNOTATION_QUEUES_UPDATE + CHARTS_CREATE -> Known.CHARTS_CREATE + CHARTS_DELETE -> Known.CHARTS_DELETE + CHARTS_READ -> Known.CHARTS_READ + CHARTS_UPDATE -> Known.CHARTS_UPDATE + DATASETS_CREATE -> Known.DATASETS_CREATE + DATASETS_DELETE -> Known.DATASETS_DELETE + DATASETS_READ -> Known.DATASETS_READ + DATASETS_SHARE -> Known.DATASETS_SHARE + DATASETS_UPDATE -> Known.DATASETS_UPDATE + DEPLOYMENTS_CREATE -> Known.DEPLOYMENTS_CREATE + DEPLOYMENTS_DELETE -> Known.DEPLOYMENTS_DELETE + DEPLOYMENTS_READ -> Known.DEPLOYMENTS_READ + DEPLOYMENTS_UPDATE -> Known.DEPLOYMENTS_UPDATE + FEEDBACK_CREATE -> Known.FEEDBACK_CREATE + FEEDBACK_DELETE -> Known.FEEDBACK_DELETE + FEEDBACK_READ -> Known.FEEDBACK_READ + FEEDBACK_UPDATE -> Known.FEEDBACK_UPDATE + PROJECTS_CREATE -> Known.PROJECTS_CREATE + PROJECTS_DELETE -> Known.PROJECTS_DELETE + PROJECTS_READ -> Known.PROJECTS_READ + PROJECTS_UPDATE -> Known.PROJECTS_UPDATE + PROMPTS_CREATE -> Known.PROMPTS_CREATE + PROMPTS_DELETE -> Known.PROMPTS_DELETE + PROMPTS_READ -> Known.PROMPTS_READ + PROMPTS_UPDATE -> Known.PROMPTS_UPDATE + PROMPTS_SHARE -> Known.PROMPTS_SHARE + RULES_CREATE -> Known.RULES_CREATE + RULES_DELETE -> Known.RULES_DELETE + RULES_READ -> Known.RULES_READ + RULES_UPDATE -> Known.RULES_UPDATE + RUNS_CREATE -> Known.RUNS_CREATE + RUNS_READ -> Known.RUNS_READ + RUNS_SHARE -> Known.RUNS_SHARE + RUNS_DELETE -> Known.RUNS_DELETE + WORKSPACES_MANAGE -> Known.WORKSPACES_MANAGE + WORKSPACES_READ -> Known.WORKSPACES_READ + ALERTS_CREATE -> Known.ALERTS_CREATE + ALERTS_UPDATE -> Known.ALERTS_UPDATE + ALERTS_DELETE -> Known.ALERTS_DELETE + ALERTS_READ -> Known.ALERTS_READ + ORGANIZATION_PATS_CREATE -> Known.ORGANIZATION_PATS_CREATE + ORGANIZATION_READ -> Known.ORGANIZATION_READ + ORGANIZATION_MANAGE -> Known.ORGANIZATION_MANAGE + else -> throw LangsmithApiInvalidDataException("Unknown Permission: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Permission = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Permission && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConditionGroup && + conditions == other.conditions && + permission == other.permission && + resourceType == other.resourceType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(conditions, permission, resourceType, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConditionGroup{conditions=$conditions, permission=$permission, resourceType=$resourceType, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/roles/RoleAttachParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/roles/RoleAttachParams.kt new file mode 100644 index 00000000..e3ea982f --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/roles/RoleAttachParams.kt @@ -0,0 +1,572 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.orgs.current.accesspolicies.roles + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Attaches one or more access policies to a specific role. The request body must contain an array + * of access policy IDs. + */ +class RoleAttachParams +private constructor( + private val roleId: JsonValue?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun roleId(): Optional<JsonValue> = Optional.ofNullable(roleId) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun payload(): Optional<Payload> = body.payload() + + /** + * Returns the raw JSON value of [payload]. + * + * Unlike [payload], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _payload(): JsonField<Payload> = body._payload() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): RoleAttachParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [RoleAttachParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RoleAttachParams]. */ + class Builder internal constructor() { + + private var roleId: JsonValue? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(roleAttachParams: RoleAttachParams) = apply { + roleId = roleAttachParams.roleId + body = roleAttachParams.body.toBuilder() + additionalHeaders = roleAttachParams.additionalHeaders.toBuilder() + additionalQueryParams = roleAttachParams.additionalQueryParams.toBuilder() + } + + fun roleId(roleId: JsonValue?) = apply { this.roleId = roleId } + + /** Alias for calling [Builder.roleId] with `roleId.orElse(null)`. */ + fun roleId(roleId: Optional<JsonValue>) = roleId(roleId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [payload] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun payload(payload: Payload) = apply { body.payload(payload) } + + /** + * Sets [Builder.payload] to an arbitrary JSON value. + * + * You should usually call [Builder.payload] with a well-typed [Payload] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun payload(payload: JsonField<Payload>) = apply { body.payload(payload) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RoleAttachParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RoleAttachParams = + RoleAttachParams( + roleId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> roleId?.toString() ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val payload: JsonField<Payload>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("payload") @ExcludeMissing payload: JsonField<Payload> = JsonMissing.of() + ) : this(payload, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun payload(): Optional<Payload> = payload.getOptional("payload") + + /** + * Returns the raw JSON value of [payload]. + * + * Unlike [payload], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("payload") @ExcludeMissing fun _payload(): JsonField<Payload> = payload + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var payload: JsonField<Payload> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + payload = body.payload + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun payload(payload: Payload) = payload(JsonField.of(payload)) + + /** + * Sets [Builder.payload] to an arbitrary JSON value. + * + * You should usually call [Builder.payload] with a well-typed [Payload] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun payload(payload: JsonField<Payload>) = apply { this.payload = payload } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = Body(payload, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + payload().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (payload.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + payload == other.payload && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(payload, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{payload=$payload, additionalProperties=$additionalProperties}" + } + + class Payload + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val accessPolicyIds: JsonField<List<String>>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("access_policy_ids") + @ExcludeMissing + accessPolicyIds: JsonField<List<String>> = JsonMissing.of() + ) : this(accessPolicyIds, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun accessPolicyIds(): Optional<List<String>> = + accessPolicyIds.getOptional("access_policy_ids") + + /** + * Returns the raw JSON value of [accessPolicyIds]. + * + * Unlike [accessPolicyIds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("access_policy_ids") + @ExcludeMissing + fun _accessPolicyIds(): JsonField<List<String>> = accessPolicyIds + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Payload]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Payload]. */ + class Builder internal constructor() { + + private var accessPolicyIds: JsonField<MutableList<String>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(payload: Payload) = apply { + accessPolicyIds = payload.accessPolicyIds.map { it.toMutableList() } + additionalProperties = payload.additionalProperties.toMutableMap() + } + + fun accessPolicyIds(accessPolicyIds: List<String>) = + accessPolicyIds(JsonField.of(accessPolicyIds)) + + /** + * Sets [Builder.accessPolicyIds] to an arbitrary JSON value. + * + * You should usually call [Builder.accessPolicyIds] with a well-typed `List<String>` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun accessPolicyIds(accessPolicyIds: JsonField<List<String>>) = apply { + this.accessPolicyIds = accessPolicyIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [accessPolicyIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAccessPolicyId(accessPolicyId: String) = apply { + accessPolicyIds = + (accessPolicyIds ?: JsonField.of(mutableListOf())).also { + checkKnown("accessPolicyIds", it).add(accessPolicyId) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Payload]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Payload = + Payload( + (accessPolicyIds ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Payload = apply { + if (validated) { + return@apply + } + + accessPolicyIds() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (accessPolicyIds.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Payload && + accessPolicyIds == other.accessPolicyIds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(accessPolicyIds, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Payload{accessPolicyIds=$accessPolicyIds, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoleAttachParams && + roleId == other.roleId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(roleId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "RoleAttachParams{roleId=$roleId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/runs/Run.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/runs/Run.kt new file mode 100644 index 00000000..502648e8 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/runs/Run.kt @@ -0,0 +1,1759 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.runs + +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.langsmith_api.api.core.Enum +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class Run +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField<String>, + private val dottedOrder: JsonField<String>, + private val endTime: JsonField<String>, + private val error: JsonField<String>, + private val events: JsonField<List<Event>>, + private val extra: JsonField<Extra>, + private val inputAttachments: JsonField<InputAttachments>, + private val inputs: JsonField<Inputs>, + private val name: JsonField<String>, + private val outputAttachments: JsonField<OutputAttachments>, + private val outputs: JsonField<Outputs>, + private val parentRunId: JsonField<String>, + private val referenceExampleId: JsonField<String>, + private val runType: JsonField<RunType>, + private val serialized: JsonField<Serialized>, + private val sessionId: JsonField<String>, + private val sessionName: JsonField<String>, + private val startTime: JsonField<String>, + private val status: JsonField<String>, + private val tags: JsonField<List<String>>, + private val traceId: JsonField<String>, + private val additionalProperties: MutableMap<String, JsonValue>, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of(), + @JsonProperty("dotted_order") + @ExcludeMissing + dottedOrder: JsonField<String> = JsonMissing.of(), + @JsonProperty("end_time") @ExcludeMissing endTime: JsonField<String> = JsonMissing.of(), + @JsonProperty("error") @ExcludeMissing error: JsonField<String> = JsonMissing.of(), + @JsonProperty("events") @ExcludeMissing events: JsonField<List<Event>> = JsonMissing.of(), + @JsonProperty("extra") @ExcludeMissing extra: JsonField<Extra> = JsonMissing.of(), + @JsonProperty("input_attachments") + @ExcludeMissing + inputAttachments: JsonField<InputAttachments> = JsonMissing.of(), + @JsonProperty("inputs") @ExcludeMissing inputs: JsonField<Inputs> = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField<String> = JsonMissing.of(), + @JsonProperty("output_attachments") + @ExcludeMissing + outputAttachments: JsonField<OutputAttachments> = JsonMissing.of(), + @JsonProperty("outputs") @ExcludeMissing outputs: JsonField<Outputs> = JsonMissing.of(), + @JsonProperty("parent_run_id") + @ExcludeMissing + parentRunId: JsonField<String> = JsonMissing.of(), + @JsonProperty("reference_example_id") + @ExcludeMissing + referenceExampleId: JsonField<String> = JsonMissing.of(), + @JsonProperty("run_type") @ExcludeMissing runType: JsonField<RunType> = JsonMissing.of(), + @JsonProperty("serialized") + @ExcludeMissing + serialized: JsonField<Serialized> = JsonMissing.of(), + @JsonProperty("session_id") @ExcludeMissing sessionId: JsonField<String> = JsonMissing.of(), + @JsonProperty("session_name") + @ExcludeMissing + sessionName: JsonField<String> = JsonMissing.of(), + @JsonProperty("start_time") @ExcludeMissing startTime: JsonField<String> = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField<String> = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing tags: JsonField<List<String>> = JsonMissing.of(), + @JsonProperty("trace_id") @ExcludeMissing traceId: JsonField<String> = JsonMissing.of(), + ) : this( + id, + dottedOrder, + endTime, + error, + events, + extra, + inputAttachments, + inputs, + name, + outputAttachments, + outputs, + parentRunId, + referenceExampleId, + runType, + serialized, + sessionId, + sessionName, + startTime, + status, + tags, + traceId, + mutableMapOf(), + ) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional<String> = id.getOptional("id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dottedOrder(): Optional<String> = dottedOrder.getOptional("dotted_order") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endTime(): Optional<String> = endTime.getOptional("end_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun error(): Optional<String> = error.getOptional("error") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun events(): Optional<List<Event>> = events.getOptional("events") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun extra(): Optional<Extra> = extra.getOptional("extra") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun inputAttachments(): Optional<InputAttachments> = + inputAttachments.getOptional("input_attachments") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun inputs(): Optional<Inputs> = inputs.getOptional("inputs") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional<String> = name.getOptional("name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun outputAttachments(): Optional<OutputAttachments> = + outputAttachments.getOptional("output_attachments") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun outputs(): Optional<Outputs> = outputs.getOptional("outputs") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun parentRunId(): Optional<String> = parentRunId.getOptional("parent_run_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceExampleId(): Optional<String> = + referenceExampleId.getOptional("reference_example_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun runType(): Optional<RunType> = runType.getOptional("run_type") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun serialized(): Optional<Serialized> = serialized.getOptional("serialized") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun sessionId(): Optional<String> = sessionId.getOptional("session_id") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun sessionName(): Optional<String> = sessionName.getOptional("session_name") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun startTime(): Optional<String> = startTime.getOptional("start_time") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun status(): Optional<String> = status.getOptional("status") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tags(): Optional<List<String>> = tags.getOptional("tags") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun traceId(): Optional<String> = traceId.getOptional("trace_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id + + /** + * Returns the raw JSON value of [dottedOrder]. + * + * Unlike [dottedOrder], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dotted_order") + @ExcludeMissing + fun _dottedOrder(): JsonField<String> = dottedOrder + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_time") @ExcludeMissing fun _endTime(): JsonField<String> = endTime + + /** + * Returns the raw JSON value of [error]. + * + * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("error") @ExcludeMissing fun _error(): JsonField<String> = error + + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("events") @ExcludeMissing fun _events(): JsonField<List<Event>> = events + + /** + * Returns the raw JSON value of [extra]. + * + * Unlike [extra], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("extra") @ExcludeMissing fun _extra(): JsonField<Extra> = extra + + /** + * Returns the raw JSON value of [inputAttachments]. + * + * Unlike [inputAttachments], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("input_attachments") + @ExcludeMissing + fun _inputAttachments(): JsonField<InputAttachments> = inputAttachments + + /** + * Returns the raw JSON value of [inputs]. + * + * Unlike [inputs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inputs") @ExcludeMissing fun _inputs(): JsonField<Inputs> = inputs + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField<String> = name + + /** + * Returns the raw JSON value of [outputAttachments]. + * + * Unlike [outputAttachments], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("output_attachments") + @ExcludeMissing + fun _outputAttachments(): JsonField<OutputAttachments> = outputAttachments + + /** + * Returns the raw JSON value of [outputs]. + * + * Unlike [outputs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outputs") @ExcludeMissing fun _outputs(): JsonField<Outputs> = outputs + + /** + * Returns the raw JSON value of [parentRunId]. + * + * Unlike [parentRunId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("parent_run_id") + @ExcludeMissing + fun _parentRunId(): JsonField<String> = parentRunId + + /** + * Returns the raw JSON value of [referenceExampleId]. + * + * Unlike [referenceExampleId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reference_example_id") + @ExcludeMissing + fun _referenceExampleId(): JsonField<String> = referenceExampleId + + /** + * Returns the raw JSON value of [runType]. + * + * Unlike [runType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_type") @ExcludeMissing fun _runType(): JsonField<RunType> = runType + + /** + * Returns the raw JSON value of [serialized]. + * + * Unlike [serialized], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("serialized") + @ExcludeMissing + fun _serialized(): JsonField<Serialized> = serialized + + /** + * Returns the raw JSON value of [sessionId]. + * + * Unlike [sessionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session_id") @ExcludeMissing fun _sessionId(): JsonField<String> = sessionId + + /** + * Returns the raw JSON value of [sessionName]. + * + * Unlike [sessionName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session_name") + @ExcludeMissing + fun _sessionName(): JsonField<String> = sessionName + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_time") @ExcludeMissing fun _startTime(): JsonField<String> = startTime + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField<String> = status + + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField<List<String>> = tags + + /** + * Returns the raw JSON value of [traceId]. + * + * Unlike [traceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trace_id") @ExcludeMissing fun _traceId(): JsonField<String> = traceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Run]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Run]. */ + class Builder internal constructor() { + + private var id: JsonField<String> = JsonMissing.of() + private var dottedOrder: JsonField<String> = JsonMissing.of() + private var endTime: JsonField<String> = JsonMissing.of() + private var error: JsonField<String> = JsonMissing.of() + private var events: JsonField<MutableList<Event>>? = null + private var extra: JsonField<Extra> = JsonMissing.of() + private var inputAttachments: JsonField<InputAttachments> = JsonMissing.of() + private var inputs: JsonField<Inputs> = JsonMissing.of() + private var name: JsonField<String> = JsonMissing.of() + private var outputAttachments: JsonField<OutputAttachments> = JsonMissing.of() + private var outputs: JsonField<Outputs> = JsonMissing.of() + private var parentRunId: JsonField<String> = JsonMissing.of() + private var referenceExampleId: JsonField<String> = JsonMissing.of() + private var runType: JsonField<RunType> = JsonMissing.of() + private var serialized: JsonField<Serialized> = JsonMissing.of() + private var sessionId: JsonField<String> = JsonMissing.of() + private var sessionName: JsonField<String> = JsonMissing.of() + private var startTime: JsonField<String> = JsonMissing.of() + private var status: JsonField<String> = JsonMissing.of() + private var tags: JsonField<MutableList<String>>? = null + private var traceId: JsonField<String> = JsonMissing.of() + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(run: Run) = apply { + id = run.id + dottedOrder = run.dottedOrder + endTime = run.endTime + error = run.error + events = run.events.map { it.toMutableList() } + extra = run.extra + inputAttachments = run.inputAttachments + inputs = run.inputs + name = run.name + outputAttachments = run.outputAttachments + outputs = run.outputs + parentRunId = run.parentRunId + referenceExampleId = run.referenceExampleId + runType = run.runType + serialized = run.serialized + sessionId = run.sessionId + sessionName = run.sessionName + startTime = run.startTime + status = run.status + tags = run.tags.map { it.toMutableList() } + traceId = run.traceId + additionalProperties = run.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField<String>) = apply { this.id = id } + + fun dottedOrder(dottedOrder: String) = dottedOrder(JsonField.of(dottedOrder)) + + /** + * Sets [Builder.dottedOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.dottedOrder] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dottedOrder(dottedOrder: JsonField<String>) = apply { this.dottedOrder = dottedOrder } + + fun endTime(endTime: String) = endTime(JsonField.of(endTime)) + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun endTime(endTime: JsonField<String>) = apply { this.endTime = endTime } + + fun error(error: String) = error(JsonField.of(error)) + + /** + * Sets [Builder.error] to an arbitrary JSON value. + * + * You should usually call [Builder.error] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun error(error: JsonField<String>) = apply { this.error = error } + + fun events(events: List<Event>) = events(JsonField.of(events)) + + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed `List<Event>` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun events(events: JsonField<List<Event>>) = apply { + this.events = events.map { it.toMutableList() } + } + + /** + * Adds a single [Event] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvent(event: Event) = apply { + events = + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) + } + } + + fun extra(extra: Extra) = extra(JsonField.of(extra)) + + /** + * Sets [Builder.extra] to an arbitrary JSON value. + * + * You should usually call [Builder.extra] with a well-typed [Extra] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun extra(extra: JsonField<Extra>) = apply { this.extra = extra } + + fun inputAttachments(inputAttachments: InputAttachments) = + inputAttachments(JsonField.of(inputAttachments)) + + /** + * Sets [Builder.inputAttachments] to an arbitrary JSON value. + * + * You should usually call [Builder.inputAttachments] with a well-typed [InputAttachments] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun inputAttachments(inputAttachments: JsonField<InputAttachments>) = apply { + this.inputAttachments = inputAttachments + } + + fun inputs(inputs: Inputs) = inputs(JsonField.of(inputs)) + + /** + * Sets [Builder.inputs] to an arbitrary JSON value. + * + * You should usually call [Builder.inputs] with a well-typed [Inputs] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun inputs(inputs: JsonField<Inputs>) = apply { this.inputs = inputs } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField<String>) = apply { this.name = name } + + fun outputAttachments(outputAttachments: OutputAttachments) = + outputAttachments(JsonField.of(outputAttachments)) + + /** + * Sets [Builder.outputAttachments] to an arbitrary JSON value. + * + * You should usually call [Builder.outputAttachments] with a well-typed [OutputAttachments] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun outputAttachments(outputAttachments: JsonField<OutputAttachments>) = apply { + this.outputAttachments = outputAttachments + } + + fun outputs(outputs: Outputs) = outputs(JsonField.of(outputs)) + + /** + * Sets [Builder.outputs] to an arbitrary JSON value. + * + * You should usually call [Builder.outputs] with a well-typed [Outputs] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun outputs(outputs: JsonField<Outputs>) = apply { this.outputs = outputs } + + fun parentRunId(parentRunId: String) = parentRunId(JsonField.of(parentRunId)) + + /** + * Sets [Builder.parentRunId] to an arbitrary JSON value. + * + * You should usually call [Builder.parentRunId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun parentRunId(parentRunId: JsonField<String>) = apply { this.parentRunId = parentRunId } + + fun referenceExampleId(referenceExampleId: String) = + referenceExampleId(JsonField.of(referenceExampleId)) + + /** + * Sets [Builder.referenceExampleId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceExampleId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun referenceExampleId(referenceExampleId: JsonField<String>) = apply { + this.referenceExampleId = referenceExampleId + } + + fun runType(runType: RunType) = runType(JsonField.of(runType)) + + /** + * Sets [Builder.runType] to an arbitrary JSON value. + * + * You should usually call [Builder.runType] with a well-typed [RunType] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun runType(runType: JsonField<RunType>) = apply { this.runType = runType } + + fun serialized(serialized: Serialized) = serialized(JsonField.of(serialized)) + + /** + * Sets [Builder.serialized] to an arbitrary JSON value. + * + * You should usually call [Builder.serialized] with a well-typed [Serialized] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun serialized(serialized: JsonField<Serialized>) = apply { this.serialized = serialized } + + fun sessionId(sessionId: String) = sessionId(JsonField.of(sessionId)) + + /** + * Sets [Builder.sessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun sessionId(sessionId: JsonField<String>) = apply { this.sessionId = sessionId } + + fun sessionName(sessionName: String) = sessionName(JsonField.of(sessionName)) + + /** + * Sets [Builder.sessionName] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun sessionName(sessionName: JsonField<String>) = apply { this.sessionName = sessionName } + + fun startTime(startTime: String) = startTime(JsonField.of(startTime)) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun startTime(startTime: JsonField<String>) = apply { this.startTime = startTime } + + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField<String>) = apply { this.status = status } + + fun tags(tags: List<String>) = tags(JsonField.of(tags)) + + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List<String>` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tags(tags: JsonField<List<String>>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } + + fun traceId(traceId: String) = traceId(JsonField.of(traceId)) + + /** + * Sets [Builder.traceId] to an arbitrary JSON value. + * + * You should usually call [Builder.traceId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun traceId(traceId: JsonField<String>) = apply { this.traceId = traceId } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Run]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Run = + Run( + id, + dottedOrder, + endTime, + error, + (events ?: JsonMissing.of()).map { it.toImmutable() }, + extra, + inputAttachments, + inputs, + name, + outputAttachments, + outputs, + parentRunId, + referenceExampleId, + runType, + serialized, + sessionId, + sessionName, + startTime, + status, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + traceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Run = apply { + if (validated) { + return@apply + } + + id() + dottedOrder() + endTime() + error() + events().ifPresent { it.forEach { it.validate() } } + extra().ifPresent { it.validate() } + inputAttachments().ifPresent { it.validate() } + inputs().ifPresent { it.validate() } + name() + outputAttachments().ifPresent { it.validate() } + outputs().ifPresent { it.validate() } + parentRunId() + referenceExampleId() + runType().ifPresent { it.validate() } + serialized().ifPresent { it.validate() } + sessionId() + sessionName() + startTime() + status() + tags() + traceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (dottedOrder.asKnown().isPresent) 1 else 0) + + (if (endTime.asKnown().isPresent) 1 else 0) + + (if (error.asKnown().isPresent) 1 else 0) + + (events.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (extra.asKnown().getOrNull()?.validity() ?: 0) + + (inputAttachments.asKnown().getOrNull()?.validity() ?: 0) + + (inputs.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (outputAttachments.asKnown().getOrNull()?.validity() ?: 0) + + (outputs.asKnown().getOrNull()?.validity() ?: 0) + + (if (parentRunId.asKnown().isPresent) 1 else 0) + + (if (referenceExampleId.asKnown().isPresent) 1 else 0) + + (runType.asKnown().getOrNull()?.validity() ?: 0) + + (serialized.asKnown().getOrNull()?.validity() ?: 0) + + (if (sessionId.asKnown().isPresent) 1 else 0) + + (if (sessionName.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + (if (status.asKnown().isPresent) 1 else 0) + + (tags.asKnown().getOrNull()?.size ?: 0) + + (if (traceId.asKnown().isPresent) 1 else 0) + + class Event + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Event]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Event]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(event: Event) = apply { + additionalProperties = event.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Event]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Event = Event(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Event = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Event && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Event{additionalProperties=$additionalProperties}" + } + + class Extra + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Extra]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Extra]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(extra: Extra) = apply { + additionalProperties = extra.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Extra]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Extra = Extra(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Extra = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Extra && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Extra{additionalProperties=$additionalProperties}" + } + + class InputAttachments + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [InputAttachments]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InputAttachments]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(inputAttachments: InputAttachments) = apply { + additionalProperties = inputAttachments.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InputAttachments]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InputAttachments = InputAttachments(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): InputAttachments = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InputAttachments && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "InputAttachments{additionalProperties=$additionalProperties}" + } + + class Inputs + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Inputs]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Inputs]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(inputs: Inputs) = apply { + additionalProperties = inputs.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Inputs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Inputs = Inputs(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Inputs = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Inputs && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Inputs{additionalProperties=$additionalProperties}" + } + + class OutputAttachments + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [OutputAttachments]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OutputAttachments]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(outputAttachments: OutputAttachments) = apply { + additionalProperties = outputAttachments.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OutputAttachments]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OutputAttachments = OutputAttachments(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): OutputAttachments = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OutputAttachments && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "OutputAttachments{additionalProperties=$additionalProperties}" + } + + class Outputs + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Outputs]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Outputs]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(outputs: Outputs) = apply { + additionalProperties = outputs.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Outputs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Outputs = Outputs(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Outputs = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Outputs && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Outputs{additionalProperties=$additionalProperties}" + } + + class RunType @JsonCreator private constructor(private val value: JsonField<String>) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value + + companion object { + + @JvmField val TOOL = of("tool") + + @JvmField val CHAIN = of("chain") + + @JvmField val LLM = of("llm") + + @JvmField val RETRIEVER = of("retriever") + + @JvmField val EMBEDDING = of("embedding") + + @JvmField val PROMPT = of("prompt") + + @JvmField val PARSER = of("parser") + + @JvmStatic fun of(value: String) = RunType(JsonField.of(value)) + } + + /** An enum containing [RunType]'s known values. */ + enum class Known { + TOOL, + CHAIN, + LLM, + RETRIEVER, + EMBEDDING, + PROMPT, + PARSER, + } + + /** + * An enum containing [RunType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [RunType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TOOL, + CHAIN, + LLM, + RETRIEVER, + EMBEDDING, + PROMPT, + PARSER, + /** An enum member indicating that [RunType] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TOOL -> Value.TOOL + CHAIN -> Value.CHAIN + LLM -> Value.LLM + RETRIEVER -> Value.RETRIEVER + EMBEDDING -> Value.EMBEDDING + PROMPT -> Value.PROMPT + PARSER -> Value.PARSER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LangsmithApiInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TOOL -> Known.TOOL + CHAIN -> Known.CHAIN + LLM -> Known.LLM + RETRIEVER -> Known.RETRIEVER + EMBEDDING -> Known.EMBEDDING + PROMPT -> Known.PROMPT + PARSER -> Known.PARSER + else -> throw LangsmithApiInvalidDataException("Unknown RunType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangsmithApiInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangsmithApiInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): RunType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Serialized + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Serialized]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Serialized]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(serialized: Serialized) = apply { + additionalProperties = serialized.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Serialized]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Serialized = Serialized(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Serialized = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Serialized && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Serialized{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Run && + id == other.id && + dottedOrder == other.dottedOrder && + endTime == other.endTime && + error == other.error && + events == other.events && + extra == other.extra && + inputAttachments == other.inputAttachments && + inputs == other.inputs && + name == other.name && + outputAttachments == other.outputAttachments && + outputs == other.outputs && + parentRunId == other.parentRunId && + referenceExampleId == other.referenceExampleId && + runType == other.runType && + serialized == other.serialized && + sessionId == other.sessionId && + sessionName == other.sessionName && + startTime == other.startTime && + status == other.status && + tags == other.tags && + traceId == other.traceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + dottedOrder, + endTime, + error, + events, + extra, + inputAttachments, + inputs, + name, + outputAttachments, + outputs, + parentRunId, + referenceExampleId, + runType, + serialized, + sessionId, + sessionName, + startTime, + status, + tags, + traceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Run{id=$id, dottedOrder=$dottedOrder, endTime=$endTime, error=$error, events=$events, extra=$extra, inputAttachments=$inputAttachments, inputs=$inputs, name=$name, outputAttachments=$outputAttachments, outputs=$outputs, parentRunId=$parentRunId, referenceExampleId=$referenceExampleId, runType=$runType, serialized=$serialized, sessionId=$sessionId, sessionName=$sessionName, startTime=$startTime, status=$status, tags=$tags, traceId=$traceId, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/runs/RunCreateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/runs/RunCreateParams.kt new file mode 100644 index 00000000..e7394111 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/runs/RunCreateParams.kt @@ -0,0 +1,203 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.runs + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects + +/** + * Queues a single run for ingestion. The request body must be a JSON-encoded run object that + * follows the Run schema. + */ +class RunCreateParams +private constructor( + private val run: Run, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun run(): Run = run + + fun _additionalBodyProperties(): Map<String, JsonValue> = run._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RunCreateParams]. + * + * The following fields are required: + * ```java + * .run() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunCreateParams]. */ + class Builder internal constructor() { + + private var run: Run? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(runCreateParams: RunCreateParams) = apply { + run = runCreateParams.run + additionalHeaders = runCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = runCreateParams.additionalQueryParams.toBuilder() + } + + fun run(run: Run) = apply { this.run = run } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RunCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .run() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RunCreateParams = + RunCreateParams( + checkRequired("run", run), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Run = run + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunCreateParams && + run == other.run && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(run, additionalHeaders, additionalQueryParams) + + override fun toString() = + "RunCreateParams{run=$run, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/runs/RunCreateResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/runs/RunCreateResponse.kt new file mode 100644 index 00000000..633db3e0 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/runs/RunCreateResponse.kt @@ -0,0 +1,109 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.runs + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Objects + +class RunCreateResponse +@JsonCreator +private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> +) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [RunCreateResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunCreateResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(runCreateResponse: RunCreateResponse) = apply { + additionalProperties = runCreateResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RunCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RunCreateResponse = RunCreateResponse(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): RunCreateResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunCreateResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "RunCreateResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/runs/RunIngestBatchParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/runs/RunIngestBatchParams.kt new file mode 100644 index 00000000..02129b31 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/runs/RunIngestBatchParams.kt @@ -0,0 +1,494 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.runs + +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.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonField +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkKnown +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Ingests a batch of runs in a single JSON payload. The payload must have `post` and/or `patch` + * arrays containing run objects. Prefer this endpoint over single‑run ingestion when submitting + * hundreds of runs, but `/runs/multipart` offers better handling for very large fields and + * attachments. + */ +class RunIngestBatchParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun patch(): Optional<List<Run>> = body.patch() + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun post(): Optional<List<Run>> = body.post() + + /** + * Returns the raw JSON value of [patch]. + * + * Unlike [patch], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _patch(): JsonField<List<Run>> = body._patch() + + /** + * Returns the raw JSON value of [post]. + * + * Unlike [post], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _post(): JsonField<List<Run>> = body._post() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): RunIngestBatchParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [RunIngestBatchParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunIngestBatchParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(runIngestBatchParams: RunIngestBatchParams) = apply { + body = runIngestBatchParams.body.toBuilder() + additionalHeaders = runIngestBatchParams.additionalHeaders.toBuilder() + additionalQueryParams = runIngestBatchParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [patch] + * - [post] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun patch(patch: List<Run>) = apply { body.patch(patch) } + + /** + * Sets [Builder.patch] to an arbitrary JSON value. + * + * You should usually call [Builder.patch] with a well-typed `List<Run>` value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun patch(patch: JsonField<List<Run>>) = apply { body.patch(patch) } + + /** + * Adds a single [Run] to [Builder.patch]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPatch(patch: Run) = apply { body.addPatch(patch) } + + fun post(post: List<Run>) = apply { body.post(post) } + + /** + * Sets [Builder.post] to an arbitrary JSON value. + * + * You should usually call [Builder.post] with a well-typed `List<Run>` value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun post(post: JsonField<List<Run>>) = apply { body.post(post) } + + /** + * Adds a single [Run] to [Builder.post]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPost(post: Run) = apply { body.addPost(post) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RunIngestBatchParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RunIngestBatchParams = + RunIngestBatchParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val patch: JsonField<List<Run>>, + private val post: JsonField<List<Run>>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + @JsonCreator + private constructor( + @JsonProperty("patch") @ExcludeMissing patch: JsonField<List<Run>> = JsonMissing.of(), + @JsonProperty("post") @ExcludeMissing post: JsonField<List<Run>> = JsonMissing.of(), + ) : this(patch, post, mutableMapOf()) + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun patch(): Optional<List<Run>> = patch.getOptional("patch") + + /** + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun post(): Optional<List<Run>> = post.getOptional("post") + + /** + * Returns the raw JSON value of [patch]. + * + * Unlike [patch], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("patch") @ExcludeMissing fun _patch(): JsonField<List<Run>> = patch + + /** + * Returns the raw JSON value of [post]. + * + * Unlike [post], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("post") @ExcludeMissing fun _post(): JsonField<List<Run>> = post + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var patch: JsonField<MutableList<Run>>? = null + private var post: JsonField<MutableList<Run>>? = null + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + patch = body.patch.map { it.toMutableList() } + post = body.post.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun patch(patch: List<Run>) = patch(JsonField.of(patch)) + + /** + * Sets [Builder.patch] to an arbitrary JSON value. + * + * You should usually call [Builder.patch] with a well-typed `List<Run>` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun patch(patch: JsonField<List<Run>>) = apply { + this.patch = patch.map { it.toMutableList() } + } + + /** + * Adds a single [Run] to [Builder.patch]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPatch(patch: Run) = apply { + this.patch = + (this.patch ?: JsonField.of(mutableListOf())).also { + checkKnown("patch", it).add(patch) + } + } + + fun post(post: List<Run>) = post(JsonField.of(post)) + + /** + * Sets [Builder.post] to an arbitrary JSON value. + * + * You should usually call [Builder.post] with a well-typed `List<Run>` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun post(post: JsonField<List<Run>>) = apply { + this.post = post.map { it.toMutableList() } + } + + /** + * Adds a single [Run] to [Builder.post]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPost(post: Run) = apply { + this.post = + (this.post ?: JsonField.of(mutableListOf())).also { + checkKnown("post", it).add(post) + } + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = + Body( + (patch ?: JsonMissing.of()).map { it.toImmutable() }, + (post ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + patch().ifPresent { it.forEach { it.validate() } } + post().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (patch.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (post.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + patch == other.patch && + post == other.post && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(patch, post, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{patch=$patch, post=$post, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunIngestBatchParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "RunIngestBatchParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/runs/RunIngestBatchResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/runs/RunIngestBatchResponse.kt new file mode 100644 index 00000000..72be6d74 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/runs/RunIngestBatchResponse.kt @@ -0,0 +1,110 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.runs + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Objects + +class RunIngestBatchResponse +@JsonCreator +private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> +) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [RunIngestBatchResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunIngestBatchResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(runIngestBatchResponse: RunIngestBatchResponse) = apply { + additionalProperties = runIngestBatchResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RunIngestBatchResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RunIngestBatchResponse = + RunIngestBatchResponse(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): RunIngestBatchResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunIngestBatchResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "RunIngestBatchResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/runs/RunIngestMultipartParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/runs/RunIngestMultipartParams.kt new file mode 100644 index 00000000..519805cf --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/runs/RunIngestMultipartParams.kt @@ -0,0 +1,825 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.runs + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.MultipartField +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.io.InputStream +import java.nio.file.Path +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.io.path.inputStream +import kotlin.io.path.name + +/** + * Ingests multiple runs, feedback objects, and binary attachments in a single `multipart/form-data` + * request. **Part‑name pattern**: `<event>.<run_id>[.<field>]` where `event` ∈ {`post`, + * `patch`, `feedback`, `attachment`}. + * * `post|patch.<run_id>` – JSON run payload. + * * `post|patch.<run_id>.<field>` – out‑of‑band run data (`inputs`, `outputs`, `events`, + * `error`, `extra`, `serialized`). + * * `feedback.<run_id>` – JSON feedback payload (must include `trace_id`). + * * `attachment.<run_id>.<filename>` – arbitrary binary attachment stored in S3. **Headers**: + * every part must set `Content-Type` **and** either a `Content-Length` header or `length` + * parameter. Per‑part `Content-Encoding` is **not** allowed; the top‑level request may be + * `Content-Encoding: gzip` or `Content-Encoding: zstd`. **Best performance** for high‑volume + * ingestion. + */ +class RunIngestMultipartParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Binary attachment linked to run {run_id} */ + fun _attachmentRunIdFilename(): JsonValue = body._attachmentRunIdFilename() + + /** + * Feedback object (JSON) – must include trace_id + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun feedbackRunId(): Optional<InputStream> = body.feedbackRunId() + + /** + * Run to update (JSON) + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun patchRunId(): Optional<InputStream> = body.patchRunId() + + /** + * Large outputs object (JSON) stored out‑of‑band + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun patchRunIdOutputs(): Optional<InputStream> = body.patchRunIdOutputs() + + /** + * Run to create (JSON) + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun postRunId(): Optional<InputStream> = body.postRunId() + + /** + * Large inputs object (JSON) stored out‑of‑band + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun postRunIdInputs(): Optional<InputStream> = body.postRunIdInputs() + + /** + * Returns the raw multipart value of [feedbackRunId]. + * + * Unlike [feedbackRunId], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _feedbackRunId(): MultipartField<InputStream> = body._feedbackRunId() + + /** + * Returns the raw multipart value of [patchRunId]. + * + * Unlike [patchRunId], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _patchRunId(): MultipartField<InputStream> = body._patchRunId() + + /** + * Returns the raw multipart value of [patchRunIdOutputs]. + * + * Unlike [patchRunIdOutputs], this method doesn't throw if the multipart field has an + * unexpected type. + */ + fun _patchRunIdOutputs(): MultipartField<InputStream> = body._patchRunIdOutputs() + + /** + * Returns the raw multipart value of [postRunId]. + * + * Unlike [postRunId], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _postRunId(): MultipartField<InputStream> = body._postRunId() + + /** + * Returns the raw multipart value of [postRunIdInputs]. + * + * Unlike [postRunIdInputs], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _postRunIdInputs(): MultipartField<InputStream> = body._postRunIdInputs() + + fun _additionalBodyProperties(): Map<String, JsonValue> = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): RunIngestMultipartParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [RunIngestMultipartParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunIngestMultipartParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(runIngestMultipartParams: RunIngestMultipartParams) = apply { + body = runIngestMultipartParams.body.toBuilder() + additionalHeaders = runIngestMultipartParams.additionalHeaders.toBuilder() + additionalQueryParams = runIngestMultipartParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [attachmentRunIdFilename] + * - [feedbackRunId] + * - [patchRunId] + * - [patchRunIdOutputs] + * - [postRunId] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** Binary attachment linked to run {run_id} */ + fun attachmentRunIdFilename(attachmentRunIdFilename: JsonValue) = apply { + body.attachmentRunIdFilename(attachmentRunIdFilename) + } + + /** Feedback object (JSON) – must include trace_id */ + fun feedbackRunId(feedbackRunId: InputStream) = apply { body.feedbackRunId(feedbackRunId) } + + /** + * Sets [Builder.feedbackRunId] to an arbitrary multipart value. + * + * You should usually call [Builder.feedbackRunId] with a well-typed [InputStream] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun feedbackRunId(feedbackRunId: MultipartField<InputStream>) = apply { + body.feedbackRunId(feedbackRunId) + } + + /** Feedback object (JSON) – must include trace_id */ + fun feedbackRunId(feedbackRunId: ByteArray) = apply { body.feedbackRunId(feedbackRunId) } + + /** Feedback object (JSON) – must include trace_id */ + fun feedbackRunId(path: Path) = apply { body.feedbackRunId(path) } + + /** Run to update (JSON) */ + fun patchRunId(patchRunId: InputStream) = apply { body.patchRunId(patchRunId) } + + /** + * Sets [Builder.patchRunId] to an arbitrary multipart value. + * + * You should usually call [Builder.patchRunId] with a well-typed [InputStream] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun patchRunId(patchRunId: MultipartField<InputStream>) = apply { + body.patchRunId(patchRunId) + } + + /** Run to update (JSON) */ + fun patchRunId(patchRunId: ByteArray) = apply { body.patchRunId(patchRunId) } + + /** Run to update (JSON) */ + fun patchRunId(path: Path) = apply { body.patchRunId(path) } + + /** Large outputs object (JSON) stored out‑of‑band */ + fun patchRunIdOutputs(patchRunIdOutputs: InputStream) = apply { + body.patchRunIdOutputs(patchRunIdOutputs) + } + + /** + * Sets [Builder.patchRunIdOutputs] to an arbitrary multipart value. + * + * You should usually call [Builder.patchRunIdOutputs] with a well-typed [InputStream] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun patchRunIdOutputs(patchRunIdOutputs: MultipartField<InputStream>) = apply { + body.patchRunIdOutputs(patchRunIdOutputs) + } + + /** Large outputs object (JSON) stored out‑of‑band */ + fun patchRunIdOutputs(patchRunIdOutputs: ByteArray) = apply { + body.patchRunIdOutputs(patchRunIdOutputs) + } + + /** Large outputs object (JSON) stored out‑of‑band */ + fun patchRunIdOutputs(path: Path) = apply { body.patchRunIdOutputs(path) } + + /** Run to create (JSON) */ + fun postRunId(postRunId: InputStream) = apply { body.postRunId(postRunId) } + + /** + * Sets [Builder.postRunId] to an arbitrary multipart value. + * + * You should usually call [Builder.postRunId] with a well-typed [InputStream] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun postRunId(postRunId: MultipartField<InputStream>) = apply { body.postRunId(postRunId) } + + /** Run to create (JSON) */ + fun postRunId(postRunId: ByteArray) = apply { body.postRunId(postRunId) } + + /** Run to create (JSON) */ + fun postRunId(path: Path) = apply { body.postRunId(path) } + + /** Large inputs object (JSON) stored out‑of‑band */ + fun postRunIdInputs(postRunIdInputs: InputStream) = apply { + body.postRunIdInputs(postRunIdInputs) + } + + /** + * Sets [Builder.postRunIdInputs] to an arbitrary multipart value. + * + * You should usually call [Builder.postRunIdInputs] with a well-typed [InputStream] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun postRunIdInputs(postRunIdInputs: MultipartField<InputStream>) = apply { + body.postRunIdInputs(postRunIdInputs) + } + + /** Large inputs object (JSON) stored out‑of‑band */ + fun postRunIdInputs(postRunIdInputs: ByteArray) = apply { + body.postRunIdInputs(postRunIdInputs) + } + + /** Large inputs object (JSON) stored out‑of‑band */ + fun postRunIdInputs(path: Path) = apply { body.postRunIdInputs(path) } + + fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set<String>) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RunIngestMultipartParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RunIngestMultipartParams = + RunIngestMultipartParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Map<String, MultipartField<*>> = + (mapOf( + "attachment.{run_id}.{filename}" to _attachmentRunIdFilename(), + "feedback.{run_id}" to _feedbackRunId(), + "patch.{run_id}" to _patchRunId(), + "patch.{run_id}.outputs" to _patchRunIdOutputs(), + "post.{run_id}" to _postRunId(), + "post.{run_id}.inputs" to _postRunIdInputs(), + ) + _additionalBodyProperties().mapValues { (_, value) -> MultipartField.of(value) }) + .toImmutable() + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + private constructor( + private val attachmentRunIdFilename: JsonValue, + private val feedbackRunId: MultipartField<InputStream>, + private val patchRunId: MultipartField<InputStream>, + private val patchRunIdOutputs: MultipartField<InputStream>, + private val postRunId: MultipartField<InputStream>, + private val postRunIdInputs: MultipartField<InputStream>, + private val additionalProperties: MutableMap<String, JsonValue>, + ) { + + /** Binary attachment linked to run {run_id} */ + @JsonProperty("attachment.{run_id}.{filename}") + @ExcludeMissing + fun _attachmentRunIdFilename(): JsonValue = attachmentRunIdFilename + + /** + * Feedback object (JSON) – must include trace_id + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun feedbackRunId(): Optional<InputStream> = + feedbackRunId.value.getOptional("feedback.{run_id}") + + /** + * Run to update (JSON) + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun patchRunId(): Optional<InputStream> = patchRunId.value.getOptional("patch.{run_id}") + + /** + * Large outputs object (JSON) stored out‑of‑band + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun patchRunIdOutputs(): Optional<InputStream> = + patchRunIdOutputs.value.getOptional("patch.{run_id}.outputs") + + /** + * Run to create (JSON) + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun postRunId(): Optional<InputStream> = postRunId.value.getOptional("post.{run_id}") + + /** + * Large inputs object (JSON) stored out‑of‑band + * + * @throws LangsmithApiInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun postRunIdInputs(): Optional<InputStream> = + postRunIdInputs.value.getOptional("post.{run_id}.inputs") + + /** + * Returns the raw multipart value of [feedbackRunId]. + * + * Unlike [feedbackRunId], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("feedback.{run_id}") + @ExcludeMissing + fun _feedbackRunId(): MultipartField<InputStream> = feedbackRunId + + /** + * Returns the raw multipart value of [patchRunId]. + * + * Unlike [patchRunId], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("patch.{run_id}") + @ExcludeMissing + fun _patchRunId(): MultipartField<InputStream> = patchRunId + + /** + * Returns the raw multipart value of [patchRunIdOutputs]. + * + * Unlike [patchRunIdOutputs], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("patch.{run_id}.outputs") + @ExcludeMissing + fun _patchRunIdOutputs(): MultipartField<InputStream> = patchRunIdOutputs + + /** + * Returns the raw multipart value of [postRunId]. + * + * Unlike [postRunId], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("post.{run_id}") + @ExcludeMissing + fun _postRunId(): MultipartField<InputStream> = postRunId + + /** + * Returns the raw multipart value of [postRunIdInputs]. + * + * Unlike [postRunIdInputs], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("post.{run_id}.inputs") + @ExcludeMissing + fun _postRunIdInputs(): MultipartField<InputStream> = postRunIdInputs + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var attachmentRunIdFilename: JsonValue = JsonMissing.of() + private var feedbackRunId: MultipartField<InputStream> = MultipartField.of(null) + private var patchRunId: MultipartField<InputStream> = MultipartField.of(null) + private var patchRunIdOutputs: MultipartField<InputStream> = MultipartField.of(null) + private var postRunId: MultipartField<InputStream> = MultipartField.of(null) + private var postRunIdInputs: MultipartField<InputStream> = MultipartField.of(null) + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + attachmentRunIdFilename = body.attachmentRunIdFilename + feedbackRunId = body.feedbackRunId + patchRunId = body.patchRunId + patchRunIdOutputs = body.patchRunIdOutputs + postRunId = body.postRunId + postRunIdInputs = body.postRunIdInputs + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** Binary attachment linked to run {run_id} */ + fun attachmentRunIdFilename(attachmentRunIdFilename: JsonValue) = apply { + this.attachmentRunIdFilename = attachmentRunIdFilename + } + + /** Feedback object (JSON) – must include trace_id */ + fun feedbackRunId(feedbackRunId: InputStream) = + feedbackRunId(MultipartField.of(feedbackRunId)) + + /** + * Sets [Builder.feedbackRunId] to an arbitrary multipart value. + * + * You should usually call [Builder.feedbackRunId] with a well-typed [InputStream] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun feedbackRunId(feedbackRunId: MultipartField<InputStream>) = apply { + this.feedbackRunId = feedbackRunId + } + + /** Feedback object (JSON) – must include trace_id */ + fun feedbackRunId(feedbackRunId: ByteArray) = feedbackRunId(feedbackRunId.inputStream()) + + /** Feedback object (JSON) – must include trace_id */ + fun feedbackRunId(path: Path) = + feedbackRunId( + MultipartField.builder<InputStream>() + .value(path.inputStream()) + .filename(path.name) + .build() + ) + + /** Run to update (JSON) */ + fun patchRunId(patchRunId: InputStream) = patchRunId(MultipartField.of(patchRunId)) + + /** + * Sets [Builder.patchRunId] to an arbitrary multipart value. + * + * You should usually call [Builder.patchRunId] with a well-typed [InputStream] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun patchRunId(patchRunId: MultipartField<InputStream>) = apply { + this.patchRunId = patchRunId + } + + /** Run to update (JSON) */ + fun patchRunId(patchRunId: ByteArray) = patchRunId(patchRunId.inputStream()) + + /** Run to update (JSON) */ + fun patchRunId(path: Path) = + patchRunId( + MultipartField.builder<InputStream>() + .value(path.inputStream()) + .filename(path.name) + .build() + ) + + /** Large outputs object (JSON) stored out‑of‑band */ + fun patchRunIdOutputs(patchRunIdOutputs: InputStream) = + patchRunIdOutputs(MultipartField.of(patchRunIdOutputs)) + + /** + * Sets [Builder.patchRunIdOutputs] to an arbitrary multipart value. + * + * You should usually call [Builder.patchRunIdOutputs] with a well-typed [InputStream] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun patchRunIdOutputs(patchRunIdOutputs: MultipartField<InputStream>) = apply { + this.patchRunIdOutputs = patchRunIdOutputs + } + + /** Large outputs object (JSON) stored out‑of‑band */ + fun patchRunIdOutputs(patchRunIdOutputs: ByteArray) = + patchRunIdOutputs(patchRunIdOutputs.inputStream()) + + /** Large outputs object (JSON) stored out‑of‑band */ + fun patchRunIdOutputs(path: Path) = + patchRunIdOutputs( + MultipartField.builder<InputStream>() + .value(path.inputStream()) + .filename(path.name) + .build() + ) + + /** Run to create (JSON) */ + fun postRunId(postRunId: InputStream) = postRunId(MultipartField.of(postRunId)) + + /** + * Sets [Builder.postRunId] to an arbitrary multipart value. + * + * You should usually call [Builder.postRunId] with a well-typed [InputStream] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun postRunId(postRunId: MultipartField<InputStream>) = apply { + this.postRunId = postRunId + } + + /** Run to create (JSON) */ + fun postRunId(postRunId: ByteArray) = postRunId(postRunId.inputStream()) + + /** Run to create (JSON) */ + fun postRunId(path: Path) = + postRunId( + MultipartField.builder<InputStream>() + .value(path.inputStream()) + .filename(path.name) + .build() + ) + + /** Large inputs object (JSON) stored out‑of‑band */ + fun postRunIdInputs(postRunIdInputs: InputStream) = + postRunIdInputs(MultipartField.of(postRunIdInputs)) + + /** + * Sets [Builder.postRunIdInputs] to an arbitrary multipart value. + * + * You should usually call [Builder.postRunIdInputs] with a well-typed [InputStream] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun postRunIdInputs(postRunIdInputs: MultipartField<InputStream>) = apply { + this.postRunIdInputs = postRunIdInputs + } + + /** Large inputs object (JSON) stored out‑of‑band */ + fun postRunIdInputs(postRunIdInputs: ByteArray) = + postRunIdInputs(postRunIdInputs.inputStream()) + + /** Large inputs object (JSON) stored out‑of‑band */ + fun postRunIdInputs(path: Path) = + postRunIdInputs( + MultipartField.builder<InputStream>() + .value(path.inputStream()) + .filename(path.name) + .build() + ) + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = + Body( + attachmentRunIdFilename, + feedbackRunId, + patchRunId, + patchRunIdOutputs, + postRunId, + postRunIdInputs, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + feedbackRunId() + patchRunId() + patchRunIdOutputs() + postRunId() + postRunIdInputs() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + attachmentRunIdFilename == other.attachmentRunIdFilename && + feedbackRunId == other.feedbackRunId && + patchRunId == other.patchRunId && + patchRunIdOutputs == other.patchRunIdOutputs && + postRunId == other.postRunId && + postRunIdInputs == other.postRunIdInputs && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + attachmentRunIdFilename, + feedbackRunId, + patchRunId, + patchRunIdOutputs, + postRunId, + postRunIdInputs, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{attachmentRunIdFilename=$attachmentRunIdFilename, feedbackRunId=$feedbackRunId, patchRunId=$patchRunId, patchRunIdOutputs=$patchRunIdOutputs, postRunId=$postRunId, postRunIdInputs=$postRunIdInputs, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunIngestMultipartParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "RunIngestMultipartParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/runs/RunIngestMultipartResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/runs/RunIngestMultipartResponse.kt new file mode 100644 index 00000000..68d6249a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/runs/RunIngestMultipartResponse.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.runs + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Objects + +class RunIngestMultipartResponse +@JsonCreator +private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> +) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RunIngestMultipartResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunIngestMultipartResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(runIngestMultipartResponse: RunIngestMultipartResponse) = apply { + additionalProperties = runIngestMultipartResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RunIngestMultipartResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RunIngestMultipartResponse = + RunIngestMultipartResponse(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): RunIngestMultipartResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunIngestMultipartResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RunIngestMultipartResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/runs/RunUpdateParams.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/runs/RunUpdateParams.kt new file mode 100644 index 00000000..11777996 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/runs/RunUpdateParams.kt @@ -0,0 +1,224 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.runs + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.Params +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Updates a run identified by its ID. The body should contain only the fields to be changed; + * unknown fields are ignored. + */ +class RunUpdateParams +private constructor( + private val runId: JsonValue?, + private val run: Run, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun runId(): Optional<JsonValue> = Optional.ofNullable(runId) + + fun run(): Run = run + + fun _additionalBodyProperties(): Map<String, JsonValue> = run._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RunUpdateParams]. + * + * The following fields are required: + * ```java + * .run() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunUpdateParams]. */ + class Builder internal constructor() { + + private var runId: JsonValue? = null + private var run: Run? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(runUpdateParams: RunUpdateParams) = apply { + runId = runUpdateParams.runId + run = runUpdateParams.run + additionalHeaders = runUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = runUpdateParams.additionalQueryParams.toBuilder() + } + + fun runId(runId: JsonValue?) = apply { this.runId = runId } + + /** Alias for calling [Builder.runId] with `runId.orElse(null)`. */ + fun runId(runId: Optional<JsonValue>) = runId(runId.getOrNull()) + + fun run(run: Run) = apply { this.run = run } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable<String>) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set<String>) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable<String>) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set<String>) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RunUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .run() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RunUpdateParams = + RunUpdateParams( + runId, + checkRequired("run", run), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Run = run + + fun _pathParam(index: Int): String = + when (index) { + 0 -> runId?.toString() ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunUpdateParams && + runId == other.runId && + run == other.run && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(runId, run, additionalHeaders, additionalQueryParams) + + override fun toString() = + "RunUpdateParams{runId=$runId, run=$run, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/runs/RunUpdateResponse.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/runs/RunUpdateResponse.kt new file mode 100644 index 00000000..24099ce3 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/models/runs/RunUpdateResponse.kt @@ -0,0 +1,109 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.runs + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langsmith_api.api.core.ExcludeMissing +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.toImmutable +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.util.Objects + +class RunUpdateResponse +@JsonCreator +private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map<String, JsonValue> +) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [RunUpdateResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RunUpdateResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() + + @JvmSynthetic + internal fun from(runUpdateResponse: RunUpdateResponse) = apply { + additionalProperties = runUpdateResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set<String>) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RunUpdateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RunUpdateResponse = RunUpdateResponse(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): RunUpdateResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangsmithApiInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RunUpdateResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "RunUpdateResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/ApiServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/ApiServiceAsync.kt new file mode 100644 index 00000000..2ed00ef8 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/ApiServiceAsync.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.services.async.api.V1ServiceAsync +import java.util.function.Consumer + +interface ApiServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ApiServiceAsync + + fun v1(): V1ServiceAsync + + /** A view of [ApiServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ApiServiceAsync.WithRawResponse + + fun v1(): V1ServiceAsync.WithRawResponse + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/ApiServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/ApiServiceAsyncImpl.kt new file mode 100644 index 00000000..0a506195 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/ApiServiceAsyncImpl.kt @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.services.async.api.V1ServiceAsync +import com.langsmith_api.api.services.async.api.V1ServiceAsyncImpl +import java.util.function.Consumer + +class ApiServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ApiServiceAsync { + + private val withRawResponse: ApiServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val v1: V1ServiceAsync by lazy { V1ServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): ApiServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): ApiServiceAsync = + ApiServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun v1(): V1ServiceAsync = v1 + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ApiServiceAsync.WithRawResponse { + + private val v1: V1ServiceAsync.WithRawResponse by lazy { + V1ServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ApiServiceAsync.WithRawResponse = + ApiServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun v1(): V1ServiceAsync.WithRawResponse = v1 + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/DatasetServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/DatasetServiceAsync.kt new file mode 100644 index 00000000..1763f713 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/DatasetServiceAsync.kt @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.services.async.datasets.ExperimentViewOverrideServiceAsync +import java.util.function.Consumer + +interface DatasetServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): DatasetServiceAsync + + fun experimentViewOverrides(): ExperimentViewOverrideServiceAsync + + /** + * A view of [DatasetServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): DatasetServiceAsync.WithRawResponse + + fun experimentViewOverrides(): ExperimentViewOverrideServiceAsync.WithRawResponse + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/DatasetServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/DatasetServiceAsyncImpl.kt new file mode 100644 index 00000000..f48df624 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/DatasetServiceAsyncImpl.kt @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.services.async.datasets.ExperimentViewOverrideServiceAsync +import com.langsmith_api.api.services.async.datasets.ExperimentViewOverrideServiceAsyncImpl +import java.util.function.Consumer + +class DatasetServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + DatasetServiceAsync { + + private val withRawResponse: DatasetServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val experimentViewOverrides: ExperimentViewOverrideServiceAsync by lazy { + ExperimentViewOverrideServiceAsyncImpl(clientOptions) + } + + override fun withRawResponse(): DatasetServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): DatasetServiceAsync = + DatasetServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun experimentViewOverrides(): ExperimentViewOverrideServiceAsync = + experimentViewOverrides + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + DatasetServiceAsync.WithRawResponse { + + private val experimentViewOverrides: + ExperimentViewOverrideServiceAsync.WithRawResponse by lazy { + ExperimentViewOverrideServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): DatasetServiceAsync.WithRawResponse = + DatasetServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun experimentViewOverrides(): ExperimentViewOverrideServiceAsync.WithRawResponse = + experimentViewOverrides + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/FeedbackServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/FeedbackServiceAsync.kt new file mode 100644 index 00000000..f9a59c67 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/FeedbackServiceAsync.kt @@ -0,0 +1,67 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.feedback.FeedbackIngestBatchParams +import com.langsmith_api.api.models.feedback.FeedbackIngestBatchResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface FeedbackServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): FeedbackServiceAsync + + /** Ingests a batch of feedback objects in a single JSON array payload. */ + fun ingestBatch( + params: FeedbackIngestBatchParams + ): CompletableFuture<FeedbackIngestBatchResponse> = ingestBatch(params, RequestOptions.none()) + + /** @see ingestBatch */ + fun ingestBatch( + params: FeedbackIngestBatchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<FeedbackIngestBatchResponse> + + /** + * A view of [FeedbackServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): FeedbackServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /feedback/batch`, but is otherwise the same as + * [FeedbackServiceAsync.ingestBatch]. + */ + fun ingestBatch( + params: FeedbackIngestBatchParams + ): CompletableFuture<HttpResponseFor<FeedbackIngestBatchResponse>> = + ingestBatch(params, RequestOptions.none()) + + /** @see ingestBatch */ + fun ingestBatch( + params: FeedbackIngestBatchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<FeedbackIngestBatchResponse>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/FeedbackServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/FeedbackServiceAsyncImpl.kt new file mode 100644 index 00000000..0e0a7d78 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/FeedbackServiceAsyncImpl.kt @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.feedback.FeedbackIngestBatchParams +import com.langsmith_api.api.models.feedback.FeedbackIngestBatchResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class FeedbackServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + FeedbackServiceAsync { + + private val withRawResponse: FeedbackServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): FeedbackServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): FeedbackServiceAsync = + FeedbackServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun ingestBatch( + params: FeedbackIngestBatchParams, + requestOptions: RequestOptions, + ): CompletableFuture<FeedbackIngestBatchResponse> = + // post /feedback/batch + withRawResponse().ingestBatch(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + FeedbackServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): FeedbackServiceAsync.WithRawResponse = + FeedbackServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val ingestBatchHandler: Handler<FeedbackIngestBatchResponse> = + jsonHandler<FeedbackIngestBatchResponse>(clientOptions.jsonMapper) + + override fun ingestBatch( + params: FeedbackIngestBatchParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<FeedbackIngestBatchResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("feedback", "batch") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { ingestBatchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/PlatformServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/PlatformServiceAsync.kt new file mode 100644 index 00000000..ce86f56b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/PlatformServiceAsync.kt @@ -0,0 +1,51 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.services.async.platform.AlertServiceAsync +import com.langsmith_api.api.services.async.platform.DatasetServiceAsync +import com.langsmith_api.api.services.async.platform.OrgServiceAsync +import java.util.function.Consumer + +interface PlatformServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): PlatformServiceAsync + + fun alerts(): AlertServiceAsync + + fun datasets(): DatasetServiceAsync + + fun orgs(): OrgServiceAsync + + /** + * A view of [PlatformServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PlatformServiceAsync.WithRawResponse + + fun alerts(): AlertServiceAsync.WithRawResponse + + fun datasets(): DatasetServiceAsync.WithRawResponse + + fun orgs(): OrgServiceAsync.WithRawResponse + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/PlatformServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/PlatformServiceAsyncImpl.kt new file mode 100644 index 00000000..ef4b62be --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/PlatformServiceAsyncImpl.kt @@ -0,0 +1,66 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.services.async.platform.AlertServiceAsync +import com.langsmith_api.api.services.async.platform.AlertServiceAsyncImpl +import com.langsmith_api.api.services.async.platform.DatasetServiceAsync +import com.langsmith_api.api.services.async.platform.DatasetServiceAsyncImpl +import com.langsmith_api.api.services.async.platform.OrgServiceAsync +import com.langsmith_api.api.services.async.platform.OrgServiceAsyncImpl +import java.util.function.Consumer + +class PlatformServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + PlatformServiceAsync { + + private val withRawResponse: PlatformServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val alerts: AlertServiceAsync by lazy { AlertServiceAsyncImpl(clientOptions) } + + private val datasets: DatasetServiceAsync by lazy { DatasetServiceAsyncImpl(clientOptions) } + + private val orgs: OrgServiceAsync by lazy { OrgServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): PlatformServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): PlatformServiceAsync = + PlatformServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun alerts(): AlertServiceAsync = alerts + + override fun datasets(): DatasetServiceAsync = datasets + + override fun orgs(): OrgServiceAsync = orgs + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + PlatformServiceAsync.WithRawResponse { + + private val alerts: AlertServiceAsync.WithRawResponse by lazy { + AlertServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val datasets: DatasetServiceAsync.WithRawResponse by lazy { + DatasetServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val orgs: OrgServiceAsync.WithRawResponse by lazy { + OrgServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PlatformServiceAsync.WithRawResponse = + PlatformServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun alerts(): AlertServiceAsync.WithRawResponse = alerts + + override fun datasets(): DatasetServiceAsync.WithRawResponse = datasets + + override fun orgs(): OrgServiceAsync.WithRawResponse = orgs + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/RunServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/RunServiceAsync.kt new file mode 100644 index 00000000..00f247a2 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/RunServiceAsync.kt @@ -0,0 +1,254 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.runs.Run +import com.langsmith_api.api.models.runs.RunCreateParams +import com.langsmith_api.api.models.runs.RunCreateResponse +import com.langsmith_api.api.models.runs.RunIngestBatchParams +import com.langsmith_api.api.models.runs.RunIngestBatchResponse +import com.langsmith_api.api.models.runs.RunIngestMultipartParams +import com.langsmith_api.api.models.runs.RunIngestMultipartResponse +import com.langsmith_api.api.models.runs.RunUpdateParams +import com.langsmith_api.api.models.runs.RunUpdateResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface RunServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunServiceAsync + + /** + * Queues a single run for ingestion. The request body must be a JSON-encoded run object that + * follows the Run schema. + */ + fun create(params: RunCreateParams): CompletableFuture<RunCreateResponse> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: RunCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RunCreateResponse> + + /** @see create */ + fun create( + run: Run, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RunCreateResponse> = + create(RunCreateParams.builder().run(run).build(), requestOptions) + + /** @see create */ + fun create(run: Run): CompletableFuture<RunCreateResponse> = create(run, RequestOptions.none()) + + /** + * Updates a run identified by its ID. The body should contain only the fields to be changed; + * unknown fields are ignored. + */ + fun update(runId: JsonValue, params: RunUpdateParams): CompletableFuture<RunUpdateResponse> = + update(runId, params, RequestOptions.none()) + + /** @see update */ + fun update( + runId: JsonValue, + params: RunUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RunUpdateResponse> = + update(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see update */ + fun update(params: RunUpdateParams): CompletableFuture<RunUpdateResponse> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: RunUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RunUpdateResponse> + + /** + * Ingests a batch of runs in a single JSON payload. The payload must have `post` and/or `patch` + * arrays containing run objects. Prefer this endpoint over single‑run ingestion when + * submitting hundreds of runs, but `/runs/multipart` offers better handling for very large + * fields and attachments. + */ + fun ingestBatch(): CompletableFuture<RunIngestBatchResponse> = + ingestBatch(RunIngestBatchParams.none()) + + /** @see ingestBatch */ + fun ingestBatch( + params: RunIngestBatchParams = RunIngestBatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RunIngestBatchResponse> + + /** @see ingestBatch */ + fun ingestBatch( + params: RunIngestBatchParams = RunIngestBatchParams.none() + ): CompletableFuture<RunIngestBatchResponse> = ingestBatch(params, RequestOptions.none()) + + /** @see ingestBatch */ + fun ingestBatch(requestOptions: RequestOptions): CompletableFuture<RunIngestBatchResponse> = + ingestBatch(RunIngestBatchParams.none(), requestOptions) + + /** + * Ingests multiple runs, feedback objects, and binary attachments in a single + * `multipart/form-data` request. **Part‑name pattern**: `<event>.<run_id>[.<field>]` where + * `event` ∈ {`post`, `patch`, `feedback`, `attachment`}. + * * `post|patch.<run_id>` – JSON run payload. + * * `post|patch.<run_id>.<field>` – out‑of‑band run data (`inputs`, `outputs`, `events`, + * `error`, `extra`, `serialized`). + * * `feedback.<run_id>` – JSON feedback payload (must include `trace_id`). + * * `attachment.<run_id>.<filename>` – arbitrary binary attachment stored in S3. **Headers**: + * every part must set `Content-Type` **and** either a `Content-Length` header or `length` + * parameter. Per‑part `Content-Encoding` is **not** allowed; the top‑level request may be + * `Content-Encoding: gzip` or `Content-Encoding: zstd`. **Best performance** for + * high‑volume ingestion. + */ + fun ingestMultipart(): CompletableFuture<RunIngestMultipartResponse> = + ingestMultipart(RunIngestMultipartParams.none()) + + /** @see ingestMultipart */ + fun ingestMultipart( + params: RunIngestMultipartParams = RunIngestMultipartParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RunIngestMultipartResponse> + + /** @see ingestMultipart */ + fun ingestMultipart( + params: RunIngestMultipartParams = RunIngestMultipartParams.none() + ): CompletableFuture<RunIngestMultipartResponse> = + ingestMultipart(params, RequestOptions.none()) + + /** @see ingestMultipart */ + fun ingestMultipart( + requestOptions: RequestOptions + ): CompletableFuture<RunIngestMultipartResponse> = + ingestMultipart(RunIngestMultipartParams.none(), requestOptions) + + /** A view of [RunServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /runs`, but is otherwise the same as + * [RunServiceAsync.create]. + */ + fun create(params: RunCreateParams): CompletableFuture<HttpResponseFor<RunCreateResponse>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: RunCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RunCreateResponse>> + + /** @see create */ + fun create( + run: Run, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RunCreateResponse>> = + create(RunCreateParams.builder().run(run).build(), requestOptions) + + /** @see create */ + fun create(run: Run): CompletableFuture<HttpResponseFor<RunCreateResponse>> = + create(run, RequestOptions.none()) + + /** + * Returns a raw HTTP response for `patch /runs/{run_id}`, but is otherwise the same as + * [RunServiceAsync.update]. + */ + fun update( + runId: JsonValue, + params: RunUpdateParams, + ): CompletableFuture<HttpResponseFor<RunUpdateResponse>> = + update(runId, params, RequestOptions.none()) + + /** @see update */ + fun update( + runId: JsonValue, + params: RunUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RunUpdateResponse>> = + update(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see update */ + fun update(params: RunUpdateParams): CompletableFuture<HttpResponseFor<RunUpdateResponse>> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: RunUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RunUpdateResponse>> + + /** + * Returns a raw HTTP response for `post /runs/batch`, but is otherwise the same as + * [RunServiceAsync.ingestBatch]. + */ + fun ingestBatch(): CompletableFuture<HttpResponseFor<RunIngestBatchResponse>> = + ingestBatch(RunIngestBatchParams.none()) + + /** @see ingestBatch */ + fun ingestBatch( + params: RunIngestBatchParams = RunIngestBatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RunIngestBatchResponse>> + + /** @see ingestBatch */ + fun ingestBatch( + params: RunIngestBatchParams = RunIngestBatchParams.none() + ): CompletableFuture<HttpResponseFor<RunIngestBatchResponse>> = + ingestBatch(params, RequestOptions.none()) + + /** @see ingestBatch */ + fun ingestBatch( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<RunIngestBatchResponse>> = + ingestBatch(RunIngestBatchParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /runs/multipart`, but is otherwise the same as + * [RunServiceAsync.ingestMultipart]. + */ + fun ingestMultipart(): CompletableFuture<HttpResponseFor<RunIngestMultipartResponse>> = + ingestMultipart(RunIngestMultipartParams.none()) + + /** @see ingestMultipart */ + fun ingestMultipart( + params: RunIngestMultipartParams = RunIngestMultipartParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RunIngestMultipartResponse>> + + /** @see ingestMultipart */ + fun ingestMultipart( + params: RunIngestMultipartParams = RunIngestMultipartParams.none() + ): CompletableFuture<HttpResponseFor<RunIngestMultipartResponse>> = + ingestMultipart(params, RequestOptions.none()) + + /** @see ingestMultipart */ + fun ingestMultipart( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<RunIngestMultipartResponse>> = + ingestMultipart(RunIngestMultipartParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/RunServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/RunServiceAsyncImpl.kt new file mode 100644 index 00000000..6815b025 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/RunServiceAsyncImpl.kt @@ -0,0 +1,207 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.multipartFormData +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.runs.RunCreateParams +import com.langsmith_api.api.models.runs.RunCreateResponse +import com.langsmith_api.api.models.runs.RunIngestBatchParams +import com.langsmith_api.api.models.runs.RunIngestBatchResponse +import com.langsmith_api.api.models.runs.RunIngestMultipartParams +import com.langsmith_api.api.models.runs.RunIngestMultipartResponse +import com.langsmith_api.api.models.runs.RunUpdateParams +import com.langsmith_api.api.models.runs.RunUpdateResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class RunServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + RunServiceAsync { + + private val withRawResponse: RunServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): RunServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunServiceAsync = + RunServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: RunCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<RunCreateResponse> = + // post /runs + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: RunUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<RunUpdateResponse> = + // patch /runs/{run_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun ingestBatch( + params: RunIngestBatchParams, + requestOptions: RequestOptions, + ): CompletableFuture<RunIngestBatchResponse> = + // post /runs/batch + withRawResponse().ingestBatch(params, requestOptions).thenApply { it.parse() } + + override fun ingestMultipart( + params: RunIngestMultipartParams, + requestOptions: RequestOptions, + ): CompletableFuture<RunIngestMultipartResponse> = + // post /runs/multipart + withRawResponse().ingestMultipart(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RunServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): RunServiceAsync.WithRawResponse = + RunServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<RunCreateResponse> = + jsonHandler<RunCreateResponse>(clientOptions.jsonMapper) + + override fun create( + params: RunCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<RunCreateResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("runs") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler<RunUpdateResponse> = + jsonHandler<RunUpdateResponse>(clientOptions.jsonMapper) + + override fun update( + params: RunUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<RunUpdateResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("runs", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val ingestBatchHandler: Handler<RunIngestBatchResponse> = + jsonHandler<RunIngestBatchResponse>(clientOptions.jsonMapper) + + override fun ingestBatch( + params: RunIngestBatchParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<RunIngestBatchResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("runs", "batch") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { ingestBatchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val ingestMultipartHandler: Handler<RunIngestMultipartResponse> = + jsonHandler<RunIngestMultipartResponse>(clientOptions.jsonMapper) + + override fun ingestMultipart( + params: RunIngestMultipartParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<RunIngestMultipartResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("runs", "multipart") + .body(multipartFormData(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { ingestMultipartHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/V1ServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/V1ServiceAsync.kt new file mode 100644 index 00000000..2551da67 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/V1ServiceAsync.kt @@ -0,0 +1,357 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.V1EventsParams +import com.langsmith_api.api.models.api.v1.V1EventsResponse +import com.langsmith_api.api.models.api.v1.V1LoginParams +import com.langsmith_api.api.models.api.v1.V1LoginResponse +import com.langsmith_api.api.models.api.v1.V1RetrieveOkParams +import com.langsmith_api.api.models.api.v1.V1RetrieveOkResponse +import com.langsmith_api.api.models.api.v1.V1UpdateParams +import com.langsmith_api.api.models.api.v1.V1UpdateResponse +import com.langsmith_api.api.services.async.api.v1.AceServiceAsync +import com.langsmith_api.api.services.async.api.v1.AnnotationQueueServiceAsync +import com.langsmith_api.api.services.async.api.v1.ApiKeyServiceAsync +import com.langsmith_api.api.services.async.api.v1.BulkExportServiceAsync +import com.langsmith_api.api.services.async.api.v1.ChartServiceAsync +import com.langsmith_api.api.services.async.api.v1.CommentServiceAsync +import com.langsmith_api.api.services.async.api.v1.CommitServiceAsync +import com.langsmith_api.api.services.async.api.v1.DatasetServiceAsync +import com.langsmith_api.api.services.async.api.v1.ExampleServiceAsync +import com.langsmith_api.api.services.async.api.v1.FeedbackConfigServiceAsync +import com.langsmith_api.api.services.async.api.v1.FeedbackServiceAsync +import com.langsmith_api.api.services.async.api.v1.InfoServiceAsync +import com.langsmith_api.api.services.async.api.v1.MeServiceAsync +import com.langsmith_api.api.services.async.api.v1.ModelPriceMapServiceAsync +import com.langsmith_api.api.services.async.api.v1.OAuthServiceAsync +import com.langsmith_api.api.services.async.api.v1.OrgChartServiceAsync +import com.langsmith_api.api.services.async.api.v1.OrgServiceAsync +import com.langsmith_api.api.services.async.api.v1.PlaygroundSettingServiceAsync +import com.langsmith_api.api.services.async.api.v1.PromptServiceAsync +import com.langsmith_api.api.services.async.api.v1.PromptWebhookServiceAsync +import com.langsmith_api.api.services.async.api.v1.PublicServiceAsync +import com.langsmith_api.api.services.async.api.v1.RepoServiceAsync +import com.langsmith_api.api.services.async.api.v1.RunServiceAsync +import com.langsmith_api.api.services.async.api.v1.ServiceAccountServiceAsync +import com.langsmith_api.api.services.async.api.v1.SessionServiceAsync +import com.langsmith_api.api.services.async.api.v1.SettingServiceAsync +import com.langsmith_api.api.services.async.api.v1.SsoServiceAsync +import com.langsmith_api.api.services.async.api.v1.TenantServiceAsync +import com.langsmith_api.api.services.async.api.v1.TtlSettingServiceAsync +import com.langsmith_api.api.services.async.api.v1.UsageLimitServiceAsync +import com.langsmith_api.api.services.async.api.v1.WorkspaceServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface V1ServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): V1ServiceAsync + + fun sessions(): SessionServiceAsync + + fun orgs(): OrgServiceAsync + + fun oauth(): OAuthServiceAsync + + fun sso(): SsoServiceAsync + + fun apiKey(): ApiKeyServiceAsync + + fun examples(): ExampleServiceAsync + + fun datasets(): DatasetServiceAsync + + fun runs(): RunServiceAsync + + fun feedback(): FeedbackServiceAsync + + fun public_(): PublicServiceAsync + + fun annotationQueues(): AnnotationQueueServiceAsync + + fun ace(): AceServiceAsync + + fun bulkExports(): BulkExportServiceAsync + + fun tenants(): TenantServiceAsync + + fun info(): InfoServiceAsync + + fun feedbackConfigs(): FeedbackConfigServiceAsync + + fun modelPriceMap(): ModelPriceMapServiceAsync + + fun usageLimits(): UsageLimitServiceAsync + + fun ttlSettings(): TtlSettingServiceAsync + + fun prompts(): PromptServiceAsync + + fun promptWebhooks(): PromptWebhookServiceAsync + + fun workspaces(): WorkspaceServiceAsync + + fun playgroundSettings(): PlaygroundSettingServiceAsync + + fun me(): MeServiceAsync + + fun serviceAccounts(): ServiceAccountServiceAsync + + fun charts(): ChartServiceAsync + + fun orgCharts(): OrgChartServiceAsync + + fun repos(): RepoServiceAsync + + fun commits(): CommitServiceAsync + + fun settings(): SettingServiceAsync + + fun comments(): CommentServiceAsync + + /** Like a repo. */ + fun update(repo: String, params: V1UpdateParams): CompletableFuture<V1UpdateResponse> = + update(repo, params, RequestOptions.none()) + + /** @see update */ + fun update( + repo: String, + params: V1UpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<V1UpdateResponse> = + update(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see update */ + fun update(params: V1UpdateParams): CompletableFuture<V1UpdateResponse> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: V1UpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<V1UpdateResponse> + + /** Create Event */ + fun events(params: V1EventsParams): CompletableFuture<V1EventsResponse> = + events(params, RequestOptions.none()) + + /** @see events */ + fun events( + params: V1EventsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<V1EventsResponse> + + /** Login */ + fun login(): CompletableFuture<V1LoginResponse> = login(V1LoginParams.none()) + + /** @see login */ + fun login( + params: V1LoginParams = V1LoginParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<V1LoginResponse> + + /** @see login */ + fun login(params: V1LoginParams = V1LoginParams.none()): CompletableFuture<V1LoginResponse> = + login(params, RequestOptions.none()) + + /** @see login */ + fun login(requestOptions: RequestOptions): CompletableFuture<V1LoginResponse> = + login(V1LoginParams.none(), requestOptions) + + /** Ok */ + fun retrieveOk(): CompletableFuture<V1RetrieveOkResponse> = + retrieveOk(V1RetrieveOkParams.none()) + + /** @see retrieveOk */ + fun retrieveOk( + params: V1RetrieveOkParams = V1RetrieveOkParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<V1RetrieveOkResponse> + + /** @see retrieveOk */ + fun retrieveOk( + params: V1RetrieveOkParams = V1RetrieveOkParams.none() + ): CompletableFuture<V1RetrieveOkResponse> = retrieveOk(params, RequestOptions.none()) + + /** @see retrieveOk */ + fun retrieveOk(requestOptions: RequestOptions): CompletableFuture<V1RetrieveOkResponse> = + retrieveOk(V1RetrieveOkParams.none(), requestOptions) + + /** A view of [V1ServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): V1ServiceAsync.WithRawResponse + + fun sessions(): SessionServiceAsync.WithRawResponse + + fun orgs(): OrgServiceAsync.WithRawResponse + + fun oauth(): OAuthServiceAsync.WithRawResponse + + fun sso(): SsoServiceAsync.WithRawResponse + + fun apiKey(): ApiKeyServiceAsync.WithRawResponse + + fun examples(): ExampleServiceAsync.WithRawResponse + + fun datasets(): DatasetServiceAsync.WithRawResponse + + fun runs(): RunServiceAsync.WithRawResponse + + fun feedback(): FeedbackServiceAsync.WithRawResponse + + fun public_(): PublicServiceAsync.WithRawResponse + + fun annotationQueues(): AnnotationQueueServiceAsync.WithRawResponse + + fun ace(): AceServiceAsync.WithRawResponse + + fun bulkExports(): BulkExportServiceAsync.WithRawResponse + + fun tenants(): TenantServiceAsync.WithRawResponse + + fun info(): InfoServiceAsync.WithRawResponse + + fun feedbackConfigs(): FeedbackConfigServiceAsync.WithRawResponse + + fun modelPriceMap(): ModelPriceMapServiceAsync.WithRawResponse + + fun usageLimits(): UsageLimitServiceAsync.WithRawResponse + + fun ttlSettings(): TtlSettingServiceAsync.WithRawResponse + + fun prompts(): PromptServiceAsync.WithRawResponse + + fun promptWebhooks(): PromptWebhookServiceAsync.WithRawResponse + + fun workspaces(): WorkspaceServiceAsync.WithRawResponse + + fun playgroundSettings(): PlaygroundSettingServiceAsync.WithRawResponse + + fun me(): MeServiceAsync.WithRawResponse + + fun serviceAccounts(): ServiceAccountServiceAsync.WithRawResponse + + fun charts(): ChartServiceAsync.WithRawResponse + + fun orgCharts(): OrgChartServiceAsync.WithRawResponse + + fun repos(): RepoServiceAsync.WithRawResponse + + fun commits(): CommitServiceAsync.WithRawResponse + + fun settings(): SettingServiceAsync.WithRawResponse + + fun comments(): CommentServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/likes/{owner}/{repo}`, but is otherwise the + * same as [V1ServiceAsync.update]. + */ + fun update( + repo: String, + params: V1UpdateParams, + ): CompletableFuture<HttpResponseFor<V1UpdateResponse>> = + update(repo, params, RequestOptions.none()) + + /** @see update */ + fun update( + repo: String, + params: V1UpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<V1UpdateResponse>> = + update(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see update */ + fun update(params: V1UpdateParams): CompletableFuture<HttpResponseFor<V1UpdateResponse>> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: V1UpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<V1UpdateResponse>> + + /** + * Returns a raw HTTP response for `post /api/v1/events`, but is otherwise the same as + * [V1ServiceAsync.events]. + */ + fun events(params: V1EventsParams): CompletableFuture<HttpResponseFor<V1EventsResponse>> = + events(params, RequestOptions.none()) + + /** @see events */ + fun events( + params: V1EventsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<V1EventsResponse>> + + /** + * Returns a raw HTTP response for `post /api/v1/login`, but is otherwise the same as + * [V1ServiceAsync.login]. + */ + fun login(): CompletableFuture<HttpResponseFor<V1LoginResponse>> = + login(V1LoginParams.none()) + + /** @see login */ + fun login( + params: V1LoginParams = V1LoginParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<V1LoginResponse>> + + /** @see login */ + fun login( + params: V1LoginParams = V1LoginParams.none() + ): CompletableFuture<HttpResponseFor<V1LoginResponse>> = + login(params, RequestOptions.none()) + + /** @see login */ + fun login( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<V1LoginResponse>> = + login(V1LoginParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/ok`, but is otherwise the same as + * [V1ServiceAsync.retrieveOk]. + */ + fun retrieveOk(): CompletableFuture<HttpResponseFor<V1RetrieveOkResponse>> = + retrieveOk(V1RetrieveOkParams.none()) + + /** @see retrieveOk */ + fun retrieveOk( + params: V1RetrieveOkParams = V1RetrieveOkParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<V1RetrieveOkResponse>> + + /** @see retrieveOk */ + fun retrieveOk( + params: V1RetrieveOkParams = V1RetrieveOkParams.none() + ): CompletableFuture<HttpResponseFor<V1RetrieveOkResponse>> = + retrieveOk(params, RequestOptions.none()) + + /** @see retrieveOk */ + fun retrieveOk( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<V1RetrieveOkResponse>> = + retrieveOk(V1RetrieveOkParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/V1ServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/V1ServiceAsyncImpl.kt new file mode 100644 index 00000000..44dff5ff --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/V1ServiceAsyncImpl.kt @@ -0,0 +1,610 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.V1EventsParams +import com.langsmith_api.api.models.api.v1.V1EventsResponse +import com.langsmith_api.api.models.api.v1.V1LoginParams +import com.langsmith_api.api.models.api.v1.V1LoginResponse +import com.langsmith_api.api.models.api.v1.V1RetrieveOkParams +import com.langsmith_api.api.models.api.v1.V1RetrieveOkResponse +import com.langsmith_api.api.models.api.v1.V1UpdateParams +import com.langsmith_api.api.models.api.v1.V1UpdateResponse +import com.langsmith_api.api.services.async.api.v1.AceServiceAsync +import com.langsmith_api.api.services.async.api.v1.AceServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.AnnotationQueueServiceAsync +import com.langsmith_api.api.services.async.api.v1.AnnotationQueueServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.ApiKeyServiceAsync +import com.langsmith_api.api.services.async.api.v1.ApiKeyServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.BulkExportServiceAsync +import com.langsmith_api.api.services.async.api.v1.BulkExportServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.ChartServiceAsync +import com.langsmith_api.api.services.async.api.v1.ChartServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.CommentServiceAsync +import com.langsmith_api.api.services.async.api.v1.CommentServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.CommitServiceAsync +import com.langsmith_api.api.services.async.api.v1.CommitServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.DatasetServiceAsync +import com.langsmith_api.api.services.async.api.v1.DatasetServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.ExampleServiceAsync +import com.langsmith_api.api.services.async.api.v1.ExampleServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.FeedbackConfigServiceAsync +import com.langsmith_api.api.services.async.api.v1.FeedbackConfigServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.FeedbackServiceAsync +import com.langsmith_api.api.services.async.api.v1.FeedbackServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.InfoServiceAsync +import com.langsmith_api.api.services.async.api.v1.InfoServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.MeServiceAsync +import com.langsmith_api.api.services.async.api.v1.MeServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.ModelPriceMapServiceAsync +import com.langsmith_api.api.services.async.api.v1.ModelPriceMapServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.OAuthServiceAsync +import com.langsmith_api.api.services.async.api.v1.OAuthServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.OrgChartServiceAsync +import com.langsmith_api.api.services.async.api.v1.OrgChartServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.OrgServiceAsync +import com.langsmith_api.api.services.async.api.v1.OrgServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.PlaygroundSettingServiceAsync +import com.langsmith_api.api.services.async.api.v1.PlaygroundSettingServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.PromptServiceAsync +import com.langsmith_api.api.services.async.api.v1.PromptServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.PromptWebhookServiceAsync +import com.langsmith_api.api.services.async.api.v1.PromptWebhookServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.PublicServiceAsync +import com.langsmith_api.api.services.async.api.v1.PublicServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.RepoServiceAsync +import com.langsmith_api.api.services.async.api.v1.RepoServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.RunServiceAsync +import com.langsmith_api.api.services.async.api.v1.RunServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.ServiceAccountServiceAsync +import com.langsmith_api.api.services.async.api.v1.ServiceAccountServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.SessionServiceAsync +import com.langsmith_api.api.services.async.api.v1.SessionServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.SettingServiceAsync +import com.langsmith_api.api.services.async.api.v1.SettingServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.SsoServiceAsync +import com.langsmith_api.api.services.async.api.v1.SsoServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.TenantServiceAsync +import com.langsmith_api.api.services.async.api.v1.TenantServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.TtlSettingServiceAsync +import com.langsmith_api.api.services.async.api.v1.TtlSettingServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.UsageLimitServiceAsync +import com.langsmith_api.api.services.async.api.v1.UsageLimitServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.WorkspaceServiceAsync +import com.langsmith_api.api.services.async.api.v1.WorkspaceServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class V1ServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + V1ServiceAsync { + + private val withRawResponse: V1ServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val sessions: SessionServiceAsync by lazy { SessionServiceAsyncImpl(clientOptions) } + + private val orgs: OrgServiceAsync by lazy { OrgServiceAsyncImpl(clientOptions) } + + private val oauth: OAuthServiceAsync by lazy { OAuthServiceAsyncImpl(clientOptions) } + + private val sso: SsoServiceAsync by lazy { SsoServiceAsyncImpl(clientOptions) } + + private val apiKey: ApiKeyServiceAsync by lazy { ApiKeyServiceAsyncImpl(clientOptions) } + + private val examples: ExampleServiceAsync by lazy { ExampleServiceAsyncImpl(clientOptions) } + + private val datasets: DatasetServiceAsync by lazy { DatasetServiceAsyncImpl(clientOptions) } + + private val runs: RunServiceAsync by lazy { RunServiceAsyncImpl(clientOptions) } + + private val feedback: FeedbackServiceAsync by lazy { FeedbackServiceAsyncImpl(clientOptions) } + + private val public_: PublicServiceAsync by lazy { PublicServiceAsyncImpl(clientOptions) } + + private val annotationQueues: AnnotationQueueServiceAsync by lazy { + AnnotationQueueServiceAsyncImpl(clientOptions) + } + + private val ace: AceServiceAsync by lazy { AceServiceAsyncImpl(clientOptions) } + + private val bulkExports: BulkExportServiceAsync by lazy { + BulkExportServiceAsyncImpl(clientOptions) + } + + private val tenants: TenantServiceAsync by lazy { TenantServiceAsyncImpl(clientOptions) } + + private val info: InfoServiceAsync by lazy { InfoServiceAsyncImpl(clientOptions) } + + private val feedbackConfigs: FeedbackConfigServiceAsync by lazy { + FeedbackConfigServiceAsyncImpl(clientOptions) + } + + private val modelPriceMap: ModelPriceMapServiceAsync by lazy { + ModelPriceMapServiceAsyncImpl(clientOptions) + } + + private val usageLimits: UsageLimitServiceAsync by lazy { + UsageLimitServiceAsyncImpl(clientOptions) + } + + private val ttlSettings: TtlSettingServiceAsync by lazy { + TtlSettingServiceAsyncImpl(clientOptions) + } + + private val prompts: PromptServiceAsync by lazy { PromptServiceAsyncImpl(clientOptions) } + + private val promptWebhooks: PromptWebhookServiceAsync by lazy { + PromptWebhookServiceAsyncImpl(clientOptions) + } + + private val workspaces: WorkspaceServiceAsync by lazy { + WorkspaceServiceAsyncImpl(clientOptions) + } + + private val playgroundSettings: PlaygroundSettingServiceAsync by lazy { + PlaygroundSettingServiceAsyncImpl(clientOptions) + } + + private val me: MeServiceAsync by lazy { MeServiceAsyncImpl(clientOptions) } + + private val serviceAccounts: ServiceAccountServiceAsync by lazy { + ServiceAccountServiceAsyncImpl(clientOptions) + } + + private val charts: ChartServiceAsync by lazy { ChartServiceAsyncImpl(clientOptions) } + + private val orgCharts: OrgChartServiceAsync by lazy { OrgChartServiceAsyncImpl(clientOptions) } + + private val repos: RepoServiceAsync by lazy { RepoServiceAsyncImpl(clientOptions) } + + private val commits: CommitServiceAsync by lazy { CommitServiceAsyncImpl(clientOptions) } + + private val settings: SettingServiceAsync by lazy { SettingServiceAsyncImpl(clientOptions) } + + private val comments: CommentServiceAsync by lazy { CommentServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): V1ServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): V1ServiceAsync = + V1ServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun sessions(): SessionServiceAsync = sessions + + override fun orgs(): OrgServiceAsync = orgs + + override fun oauth(): OAuthServiceAsync = oauth + + override fun sso(): SsoServiceAsync = sso + + override fun apiKey(): ApiKeyServiceAsync = apiKey + + override fun examples(): ExampleServiceAsync = examples + + override fun datasets(): DatasetServiceAsync = datasets + + override fun runs(): RunServiceAsync = runs + + override fun feedback(): FeedbackServiceAsync = feedback + + override fun public_(): PublicServiceAsync = public_ + + override fun annotationQueues(): AnnotationQueueServiceAsync = annotationQueues + + override fun ace(): AceServiceAsync = ace + + override fun bulkExports(): BulkExportServiceAsync = bulkExports + + override fun tenants(): TenantServiceAsync = tenants + + override fun info(): InfoServiceAsync = info + + override fun feedbackConfigs(): FeedbackConfigServiceAsync = feedbackConfigs + + override fun modelPriceMap(): ModelPriceMapServiceAsync = modelPriceMap + + override fun usageLimits(): UsageLimitServiceAsync = usageLimits + + override fun ttlSettings(): TtlSettingServiceAsync = ttlSettings + + override fun prompts(): PromptServiceAsync = prompts + + override fun promptWebhooks(): PromptWebhookServiceAsync = promptWebhooks + + override fun workspaces(): WorkspaceServiceAsync = workspaces + + override fun playgroundSettings(): PlaygroundSettingServiceAsync = playgroundSettings + + override fun me(): MeServiceAsync = me + + override fun serviceAccounts(): ServiceAccountServiceAsync = serviceAccounts + + override fun charts(): ChartServiceAsync = charts + + override fun orgCharts(): OrgChartServiceAsync = orgCharts + + override fun repos(): RepoServiceAsync = repos + + override fun commits(): CommitServiceAsync = commits + + override fun settings(): SettingServiceAsync = settings + + override fun comments(): CommentServiceAsync = comments + + override fun update( + params: V1UpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<V1UpdateResponse> = + // post /api/v1/likes/{owner}/{repo} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun events( + params: V1EventsParams, + requestOptions: RequestOptions, + ): CompletableFuture<V1EventsResponse> = + // post /api/v1/events + withRawResponse().events(params, requestOptions).thenApply { it.parse() } + + override fun login( + params: V1LoginParams, + requestOptions: RequestOptions, + ): CompletableFuture<V1LoginResponse> = + // post /api/v1/login + withRawResponse().login(params, requestOptions).thenApply { it.parse() } + + override fun retrieveOk( + params: V1RetrieveOkParams, + requestOptions: RequestOptions, + ): CompletableFuture<V1RetrieveOkResponse> = + // get /api/v1/ok + withRawResponse().retrieveOk(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + V1ServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val sessions: SessionServiceAsync.WithRawResponse by lazy { + SessionServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val orgs: OrgServiceAsync.WithRawResponse by lazy { + OrgServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val oauth: OAuthServiceAsync.WithRawResponse by lazy { + OAuthServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val sso: SsoServiceAsync.WithRawResponse by lazy { + SsoServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val apiKey: ApiKeyServiceAsync.WithRawResponse by lazy { + ApiKeyServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val examples: ExampleServiceAsync.WithRawResponse by lazy { + ExampleServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val datasets: DatasetServiceAsync.WithRawResponse by lazy { + DatasetServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val runs: RunServiceAsync.WithRawResponse by lazy { + RunServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val feedback: FeedbackServiceAsync.WithRawResponse by lazy { + FeedbackServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val public_: PublicServiceAsync.WithRawResponse by lazy { + PublicServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val annotationQueues: AnnotationQueueServiceAsync.WithRawResponse by lazy { + AnnotationQueueServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val ace: AceServiceAsync.WithRawResponse by lazy { + AceServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val bulkExports: BulkExportServiceAsync.WithRawResponse by lazy { + BulkExportServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val tenants: TenantServiceAsync.WithRawResponse by lazy { + TenantServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val info: InfoServiceAsync.WithRawResponse by lazy { + InfoServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val feedbackConfigs: FeedbackConfigServiceAsync.WithRawResponse by lazy { + FeedbackConfigServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val modelPriceMap: ModelPriceMapServiceAsync.WithRawResponse by lazy { + ModelPriceMapServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val usageLimits: UsageLimitServiceAsync.WithRawResponse by lazy { + UsageLimitServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val ttlSettings: TtlSettingServiceAsync.WithRawResponse by lazy { + TtlSettingServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val prompts: PromptServiceAsync.WithRawResponse by lazy { + PromptServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val promptWebhooks: PromptWebhookServiceAsync.WithRawResponse by lazy { + PromptWebhookServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val workspaces: WorkspaceServiceAsync.WithRawResponse by lazy { + WorkspaceServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val playgroundSettings: PlaygroundSettingServiceAsync.WithRawResponse by lazy { + PlaygroundSettingServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val me: MeServiceAsync.WithRawResponse by lazy { + MeServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val serviceAccounts: ServiceAccountServiceAsync.WithRawResponse by lazy { + ServiceAccountServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val charts: ChartServiceAsync.WithRawResponse by lazy { + ChartServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val orgCharts: OrgChartServiceAsync.WithRawResponse by lazy { + OrgChartServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val repos: RepoServiceAsync.WithRawResponse by lazy { + RepoServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val commits: CommitServiceAsync.WithRawResponse by lazy { + CommitServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val settings: SettingServiceAsync.WithRawResponse by lazy { + SettingServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val comments: CommentServiceAsync.WithRawResponse by lazy { + CommentServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): V1ServiceAsync.WithRawResponse = + V1ServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun sessions(): SessionServiceAsync.WithRawResponse = sessions + + override fun orgs(): OrgServiceAsync.WithRawResponse = orgs + + override fun oauth(): OAuthServiceAsync.WithRawResponse = oauth + + override fun sso(): SsoServiceAsync.WithRawResponse = sso + + override fun apiKey(): ApiKeyServiceAsync.WithRawResponse = apiKey + + override fun examples(): ExampleServiceAsync.WithRawResponse = examples + + override fun datasets(): DatasetServiceAsync.WithRawResponse = datasets + + override fun runs(): RunServiceAsync.WithRawResponse = runs + + override fun feedback(): FeedbackServiceAsync.WithRawResponse = feedback + + override fun public_(): PublicServiceAsync.WithRawResponse = public_ + + override fun annotationQueues(): AnnotationQueueServiceAsync.WithRawResponse = + annotationQueues + + override fun ace(): AceServiceAsync.WithRawResponse = ace + + override fun bulkExports(): BulkExportServiceAsync.WithRawResponse = bulkExports + + override fun tenants(): TenantServiceAsync.WithRawResponse = tenants + + override fun info(): InfoServiceAsync.WithRawResponse = info + + override fun feedbackConfigs(): FeedbackConfigServiceAsync.WithRawResponse = feedbackConfigs + + override fun modelPriceMap(): ModelPriceMapServiceAsync.WithRawResponse = modelPriceMap + + override fun usageLimits(): UsageLimitServiceAsync.WithRawResponse = usageLimits + + override fun ttlSettings(): TtlSettingServiceAsync.WithRawResponse = ttlSettings + + override fun prompts(): PromptServiceAsync.WithRawResponse = prompts + + override fun promptWebhooks(): PromptWebhookServiceAsync.WithRawResponse = promptWebhooks + + override fun workspaces(): WorkspaceServiceAsync.WithRawResponse = workspaces + + override fun playgroundSettings(): PlaygroundSettingServiceAsync.WithRawResponse = + playgroundSettings + + override fun me(): MeServiceAsync.WithRawResponse = me + + override fun serviceAccounts(): ServiceAccountServiceAsync.WithRawResponse = serviceAccounts + + override fun charts(): ChartServiceAsync.WithRawResponse = charts + + override fun orgCharts(): OrgChartServiceAsync.WithRawResponse = orgCharts + + override fun repos(): RepoServiceAsync.WithRawResponse = repos + + override fun commits(): CommitServiceAsync.WithRawResponse = commits + + override fun settings(): SettingServiceAsync.WithRawResponse = settings + + override fun comments(): CommentServiceAsync.WithRawResponse = comments + + private val updateHandler: Handler<V1UpdateResponse> = + jsonHandler<V1UpdateResponse>(clientOptions.jsonMapper) + + override fun update( + params: V1UpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<V1UpdateResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("repo", params.repo().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "likes", + params._pathParam(0), + params._pathParam(1), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val eventsHandler: Handler<V1EventsResponse> = + jsonHandler<V1EventsResponse>(clientOptions.jsonMapper) + + override fun events( + params: V1EventsParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<V1EventsResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "events") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { eventsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val loginHandler: Handler<V1LoginResponse> = + jsonHandler<V1LoginResponse>(clientOptions.jsonMapper) + + override fun login( + params: V1LoginParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<V1LoginResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "login") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { loginHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveOkHandler: Handler<V1RetrieveOkResponse> = + jsonHandler<V1RetrieveOkResponse>(clientOptions.jsonMapper) + + override fun retrieveOk( + params: V1RetrieveOkParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<V1RetrieveOkResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "ok") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveOkHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/AceServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/AceServiceAsync.kt new file mode 100644 index 00000000..1fbf9235 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/AceServiceAsync.kt @@ -0,0 +1,62 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.ace.AceExecuteParams +import com.langsmith_api.api.models.api.v1.ace.AceExecuteResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface AceServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): AceServiceAsync + + /** Execute some custom code for testing purposes. */ + fun execute(params: AceExecuteParams): CompletableFuture<AceExecuteResponse> = + execute(params, RequestOptions.none()) + + /** @see execute */ + fun execute( + params: AceExecuteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<AceExecuteResponse> + + /** A view of [AceServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): AceServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/ace/execute`, but is otherwise the same as + * [AceServiceAsync.execute]. + */ + fun execute( + params: AceExecuteParams + ): CompletableFuture<HttpResponseFor<AceExecuteResponse>> = + execute(params, RequestOptions.none()) + + /** @see execute */ + fun execute( + params: AceExecuteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<AceExecuteResponse>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/AceServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/AceServiceAsyncImpl.kt new file mode 100644 index 00000000..77de956e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/AceServiceAsyncImpl.kt @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.ace.AceExecuteParams +import com.langsmith_api.api.models.api.v1.ace.AceExecuteResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class AceServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + AceServiceAsync { + + private val withRawResponse: AceServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): AceServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): AceServiceAsync = + AceServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun execute( + params: AceExecuteParams, + requestOptions: RequestOptions, + ): CompletableFuture<AceExecuteResponse> = + // post /api/v1/ace/execute + withRawResponse().execute(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AceServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): AceServiceAsync.WithRawResponse = + AceServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val executeHandler: Handler<AceExecuteResponse> = + jsonHandler<AceExecuteResponse>(clientOptions.jsonMapper) + + override fun execute( + params: AceExecuteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<AceExecuteResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "ace", "execute") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { executeHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/AnnotationQueueServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/AnnotationQueueServiceAsync.kt new file mode 100644 index 00000000..e9f608d1 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/AnnotationQueueServiceAsync.kt @@ -0,0 +1,827 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueAnnotationQueuesParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueDeleteParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueDeleteResponse +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueExportParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueExportResponse +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueuePopulateParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueuePopulateResponse +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueRetrieveAnnotationQueuesParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueRetrieveAnnotationQueuesResponse +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueRetrieveParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueRetrieveQueuesParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueRetrieveSizeParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueRetrieveTotalArchivedParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueRetrieveTotalSizeParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueSchema +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueSizeSchema +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueUpdateParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueUpdateResponse +import com.langsmith_api.api.models.api.v1.annotationqueues.RunSchemaWithAnnotationQueueInfo +import com.langsmith_api.api.services.async.api.v1.annotationqueues.RunServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface AnnotationQueueServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): AnnotationQueueServiceAsync + + fun runs(): RunServiceAsync + + /** Get a run from an annotation queue */ + fun retrieve( + index: Long, + params: AnnotationQueueRetrieveParams, + ): CompletableFuture<RunSchemaWithAnnotationQueueInfo> = + retrieve(index, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + index: Long, + params: AnnotationQueueRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RunSchemaWithAnnotationQueueInfo> = + retrieve(params.toBuilder().index(index).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + params: AnnotationQueueRetrieveParams + ): CompletableFuture<RunSchemaWithAnnotationQueueInfo> = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: AnnotationQueueRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RunSchemaWithAnnotationQueueInfo> + + /** Create Identity Annotation Queue Run Status */ + fun update(annotationQueueRunId: String): CompletableFuture<AnnotationQueueUpdateResponse> = + update(annotationQueueRunId, AnnotationQueueUpdateParams.none()) + + /** @see update */ + fun update( + annotationQueueRunId: String, + params: AnnotationQueueUpdateParams = AnnotationQueueUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<AnnotationQueueUpdateResponse> = + update( + params.toBuilder().annotationQueueRunId(annotationQueueRunId).build(), + requestOptions, + ) + + /** @see update */ + fun update( + annotationQueueRunId: String, + params: AnnotationQueueUpdateParams = AnnotationQueueUpdateParams.none(), + ): CompletableFuture<AnnotationQueueUpdateResponse> = + update(annotationQueueRunId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: AnnotationQueueUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<AnnotationQueueUpdateResponse> + + /** @see update */ + fun update( + params: AnnotationQueueUpdateParams + ): CompletableFuture<AnnotationQueueUpdateResponse> = update(params, RequestOptions.none()) + + /** @see update */ + fun update( + annotationQueueRunId: String, + requestOptions: RequestOptions, + ): CompletableFuture<AnnotationQueueUpdateResponse> = + update(annotationQueueRunId, AnnotationQueueUpdateParams.none(), requestOptions) + + /** Delete Annotation Queue */ + fun delete(queueId: String): CompletableFuture<AnnotationQueueDeleteResponse> = + delete(queueId, AnnotationQueueDeleteParams.none()) + + /** @see delete */ + fun delete( + queueId: String, + params: AnnotationQueueDeleteParams = AnnotationQueueDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<AnnotationQueueDeleteResponse> = + delete(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see delete */ + fun delete( + queueId: String, + params: AnnotationQueueDeleteParams = AnnotationQueueDeleteParams.none(), + ): CompletableFuture<AnnotationQueueDeleteResponse> = + delete(queueId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: AnnotationQueueDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<AnnotationQueueDeleteResponse> + + /** @see delete */ + fun delete( + params: AnnotationQueueDeleteParams + ): CompletableFuture<AnnotationQueueDeleteResponse> = delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + queueId: String, + requestOptions: RequestOptions, + ): CompletableFuture<AnnotationQueueDeleteResponse> = + delete(queueId, AnnotationQueueDeleteParams.none(), requestOptions) + + /** Create Annotation Queue */ + fun annotationQueues( + params: AnnotationQueueAnnotationQueuesParams + ): CompletableFuture<AnnotationQueueSchema> = annotationQueues(params, RequestOptions.none()) + + /** @see annotationQueues */ + fun annotationQueues( + params: AnnotationQueueAnnotationQueuesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<AnnotationQueueSchema> + + /** Export Annotation Queue Archived Runs */ + fun export(queueId: String): CompletableFuture<AnnotationQueueExportResponse> = + export(queueId, AnnotationQueueExportParams.none()) + + /** @see export */ + fun export( + queueId: String, + params: AnnotationQueueExportParams = AnnotationQueueExportParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<AnnotationQueueExportResponse> = + export(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see export */ + fun export( + queueId: String, + params: AnnotationQueueExportParams = AnnotationQueueExportParams.none(), + ): CompletableFuture<AnnotationQueueExportResponse> = + export(queueId, params, RequestOptions.none()) + + /** @see export */ + fun export( + params: AnnotationQueueExportParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<AnnotationQueueExportResponse> + + /** @see export */ + fun export( + params: AnnotationQueueExportParams + ): CompletableFuture<AnnotationQueueExportResponse> = export(params, RequestOptions.none()) + + /** @see export */ + fun export( + queueId: String, + requestOptions: RequestOptions, + ): CompletableFuture<AnnotationQueueExportResponse> = + export(queueId, AnnotationQueueExportParams.none(), requestOptions) + + /** Populate annotation queue with runs from an experiment. */ + fun populate( + params: AnnotationQueuePopulateParams + ): CompletableFuture<AnnotationQueuePopulateResponse> = populate(params, RequestOptions.none()) + + /** @see populate */ + fun populate( + params: AnnotationQueuePopulateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<AnnotationQueuePopulateResponse> + + /** Get Annotation Queues */ + fun retrieveAnnotationQueues(): + CompletableFuture<List<AnnotationQueueRetrieveAnnotationQueuesResponse>> = + retrieveAnnotationQueues(AnnotationQueueRetrieveAnnotationQueuesParams.none()) + + /** @see retrieveAnnotationQueues */ + fun retrieveAnnotationQueues( + params: AnnotationQueueRetrieveAnnotationQueuesParams = + AnnotationQueueRetrieveAnnotationQueuesParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<AnnotationQueueRetrieveAnnotationQueuesResponse>> + + /** @see retrieveAnnotationQueues */ + fun retrieveAnnotationQueues( + params: AnnotationQueueRetrieveAnnotationQueuesParams = + AnnotationQueueRetrieveAnnotationQueuesParams.none() + ): CompletableFuture<List<AnnotationQueueRetrieveAnnotationQueuesResponse>> = + retrieveAnnotationQueues(params, RequestOptions.none()) + + /** @see retrieveAnnotationQueues */ + fun retrieveAnnotationQueues( + requestOptions: RequestOptions + ): CompletableFuture<List<AnnotationQueueRetrieveAnnotationQueuesResponse>> = + retrieveAnnotationQueues( + AnnotationQueueRetrieveAnnotationQueuesParams.none(), + requestOptions, + ) + + /** Get Annotation Queues For Run */ + fun retrieveQueues(runId: String): CompletableFuture<List<AnnotationQueueSchema>> = + retrieveQueues(runId, AnnotationQueueRetrieveQueuesParams.none()) + + /** @see retrieveQueues */ + fun retrieveQueues( + runId: String, + params: AnnotationQueueRetrieveQueuesParams = AnnotationQueueRetrieveQueuesParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<AnnotationQueueSchema>> = + retrieveQueues(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see retrieveQueues */ + fun retrieveQueues( + runId: String, + params: AnnotationQueueRetrieveQueuesParams = AnnotationQueueRetrieveQueuesParams.none(), + ): CompletableFuture<List<AnnotationQueueSchema>> = + retrieveQueues(runId, params, RequestOptions.none()) + + /** @see retrieveQueues */ + fun retrieveQueues( + params: AnnotationQueueRetrieveQueuesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<AnnotationQueueSchema>> + + /** @see retrieveQueues */ + fun retrieveQueues( + params: AnnotationQueueRetrieveQueuesParams + ): CompletableFuture<List<AnnotationQueueSchema>> = + retrieveQueues(params, RequestOptions.none()) + + /** @see retrieveQueues */ + fun retrieveQueues( + runId: String, + requestOptions: RequestOptions, + ): CompletableFuture<List<AnnotationQueueSchema>> = + retrieveQueues(runId, AnnotationQueueRetrieveQueuesParams.none(), requestOptions) + + /** Get Size From Annotation Queue */ + fun retrieveSize(queueId: String): CompletableFuture<AnnotationQueueSizeSchema> = + retrieveSize(queueId, AnnotationQueueRetrieveSizeParams.none()) + + /** @see retrieveSize */ + fun retrieveSize( + queueId: String, + params: AnnotationQueueRetrieveSizeParams = AnnotationQueueRetrieveSizeParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<AnnotationQueueSizeSchema> = + retrieveSize(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see retrieveSize */ + fun retrieveSize( + queueId: String, + params: AnnotationQueueRetrieveSizeParams = AnnotationQueueRetrieveSizeParams.none(), + ): CompletableFuture<AnnotationQueueSizeSchema> = + retrieveSize(queueId, params, RequestOptions.none()) + + /** @see retrieveSize */ + fun retrieveSize( + params: AnnotationQueueRetrieveSizeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<AnnotationQueueSizeSchema> + + /** @see retrieveSize */ + fun retrieveSize( + params: AnnotationQueueRetrieveSizeParams + ): CompletableFuture<AnnotationQueueSizeSchema> = retrieveSize(params, RequestOptions.none()) + + /** @see retrieveSize */ + fun retrieveSize( + queueId: String, + requestOptions: RequestOptions, + ): CompletableFuture<AnnotationQueueSizeSchema> = + retrieveSize(queueId, AnnotationQueueRetrieveSizeParams.none(), requestOptions) + + /** Get Total Archived From Annotation Queue */ + fun retrieveTotalArchived(queueId: String): CompletableFuture<AnnotationQueueSizeSchema> = + retrieveTotalArchived(queueId, AnnotationQueueRetrieveTotalArchivedParams.none()) + + /** @see retrieveTotalArchived */ + fun retrieveTotalArchived( + queueId: String, + params: AnnotationQueueRetrieveTotalArchivedParams = + AnnotationQueueRetrieveTotalArchivedParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<AnnotationQueueSizeSchema> = + retrieveTotalArchived(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see retrieveTotalArchived */ + fun retrieveTotalArchived( + queueId: String, + params: AnnotationQueueRetrieveTotalArchivedParams = + AnnotationQueueRetrieveTotalArchivedParams.none(), + ): CompletableFuture<AnnotationQueueSizeSchema> = + retrieveTotalArchived(queueId, params, RequestOptions.none()) + + /** @see retrieveTotalArchived */ + fun retrieveTotalArchived( + params: AnnotationQueueRetrieveTotalArchivedParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<AnnotationQueueSizeSchema> + + /** @see retrieveTotalArchived */ + fun retrieveTotalArchived( + params: AnnotationQueueRetrieveTotalArchivedParams + ): CompletableFuture<AnnotationQueueSizeSchema> = + retrieveTotalArchived(params, RequestOptions.none()) + + /** @see retrieveTotalArchived */ + fun retrieveTotalArchived( + queueId: String, + requestOptions: RequestOptions, + ): CompletableFuture<AnnotationQueueSizeSchema> = + retrieveTotalArchived( + queueId, + AnnotationQueueRetrieveTotalArchivedParams.none(), + requestOptions, + ) + + /** Get Total Size From Annotation Queue */ + fun retrieveTotalSize(queueId: String): CompletableFuture<AnnotationQueueSizeSchema> = + retrieveTotalSize(queueId, AnnotationQueueRetrieveTotalSizeParams.none()) + + /** @see retrieveTotalSize */ + fun retrieveTotalSize( + queueId: String, + params: AnnotationQueueRetrieveTotalSizeParams = + AnnotationQueueRetrieveTotalSizeParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<AnnotationQueueSizeSchema> = + retrieveTotalSize(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see retrieveTotalSize */ + fun retrieveTotalSize( + queueId: String, + params: AnnotationQueueRetrieveTotalSizeParams = + AnnotationQueueRetrieveTotalSizeParams.none(), + ): CompletableFuture<AnnotationQueueSizeSchema> = + retrieveTotalSize(queueId, params, RequestOptions.none()) + + /** @see retrieveTotalSize */ + fun retrieveTotalSize( + params: AnnotationQueueRetrieveTotalSizeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<AnnotationQueueSizeSchema> + + /** @see retrieveTotalSize */ + fun retrieveTotalSize( + params: AnnotationQueueRetrieveTotalSizeParams + ): CompletableFuture<AnnotationQueueSizeSchema> = + retrieveTotalSize(params, RequestOptions.none()) + + /** @see retrieveTotalSize */ + fun retrieveTotalSize( + queueId: String, + requestOptions: RequestOptions, + ): CompletableFuture<AnnotationQueueSizeSchema> = + retrieveTotalSize(queueId, AnnotationQueueRetrieveTotalSizeParams.none(), requestOptions) + + /** + * A view of [AnnotationQueueServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): AnnotationQueueServiceAsync.WithRawResponse + + fun runs(): RunServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/annotation-queues/{queue_id}/run/{index}`, + * but is otherwise the same as [AnnotationQueueServiceAsync.retrieve]. + */ + fun retrieve( + index: Long, + params: AnnotationQueueRetrieveParams, + ): CompletableFuture<HttpResponseFor<RunSchemaWithAnnotationQueueInfo>> = + retrieve(index, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + index: Long, + params: AnnotationQueueRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RunSchemaWithAnnotationQueueInfo>> = + retrieve(params.toBuilder().index(index).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + params: AnnotationQueueRetrieveParams + ): CompletableFuture<HttpResponseFor<RunSchemaWithAnnotationQueueInfo>> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: AnnotationQueueRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RunSchemaWithAnnotationQueueInfo>> + + /** + * Returns a raw HTTP response for `post + * /api/v1/annotation-queues/status/{annotation_queue_run_id}`, but is otherwise the same as + * [AnnotationQueueServiceAsync.update]. + */ + fun update( + annotationQueueRunId: String + ): CompletableFuture<HttpResponseFor<AnnotationQueueUpdateResponse>> = + update(annotationQueueRunId, AnnotationQueueUpdateParams.none()) + + /** @see update */ + fun update( + annotationQueueRunId: String, + params: AnnotationQueueUpdateParams = AnnotationQueueUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<AnnotationQueueUpdateResponse>> = + update( + params.toBuilder().annotationQueueRunId(annotationQueueRunId).build(), + requestOptions, + ) + + /** @see update */ + fun update( + annotationQueueRunId: String, + params: AnnotationQueueUpdateParams = AnnotationQueueUpdateParams.none(), + ): CompletableFuture<HttpResponseFor<AnnotationQueueUpdateResponse>> = + update(annotationQueueRunId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: AnnotationQueueUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<AnnotationQueueUpdateResponse>> + + /** @see update */ + fun update( + params: AnnotationQueueUpdateParams + ): CompletableFuture<HttpResponseFor<AnnotationQueueUpdateResponse>> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + annotationQueueRunId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<AnnotationQueueUpdateResponse>> = + update(annotationQueueRunId, AnnotationQueueUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/annotation-queues/{queue_id}`, but is + * otherwise the same as [AnnotationQueueServiceAsync.delete]. + */ + fun delete( + queueId: String + ): CompletableFuture<HttpResponseFor<AnnotationQueueDeleteResponse>> = + delete(queueId, AnnotationQueueDeleteParams.none()) + + /** @see delete */ + fun delete( + queueId: String, + params: AnnotationQueueDeleteParams = AnnotationQueueDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<AnnotationQueueDeleteResponse>> = + delete(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see delete */ + fun delete( + queueId: String, + params: AnnotationQueueDeleteParams = AnnotationQueueDeleteParams.none(), + ): CompletableFuture<HttpResponseFor<AnnotationQueueDeleteResponse>> = + delete(queueId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: AnnotationQueueDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<AnnotationQueueDeleteResponse>> + + /** @see delete */ + fun delete( + params: AnnotationQueueDeleteParams + ): CompletableFuture<HttpResponseFor<AnnotationQueueDeleteResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + queueId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<AnnotationQueueDeleteResponse>> = + delete(queueId, AnnotationQueueDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/annotation-queues`, but is otherwise the + * same as [AnnotationQueueServiceAsync.annotationQueues]. + */ + fun annotationQueues( + params: AnnotationQueueAnnotationQueuesParams + ): CompletableFuture<HttpResponseFor<AnnotationQueueSchema>> = + annotationQueues(params, RequestOptions.none()) + + /** @see annotationQueues */ + fun annotationQueues( + params: AnnotationQueueAnnotationQueuesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<AnnotationQueueSchema>> + + /** + * Returns a raw HTTP response for `post /api/v1/annotation-queues/{queue_id}/export`, but + * is otherwise the same as [AnnotationQueueServiceAsync.export]. + */ + fun export( + queueId: String + ): CompletableFuture<HttpResponseFor<AnnotationQueueExportResponse>> = + export(queueId, AnnotationQueueExportParams.none()) + + /** @see export */ + fun export( + queueId: String, + params: AnnotationQueueExportParams = AnnotationQueueExportParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<AnnotationQueueExportResponse>> = + export(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see export */ + fun export( + queueId: String, + params: AnnotationQueueExportParams = AnnotationQueueExportParams.none(), + ): CompletableFuture<HttpResponseFor<AnnotationQueueExportResponse>> = + export(queueId, params, RequestOptions.none()) + + /** @see export */ + fun export( + params: AnnotationQueueExportParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<AnnotationQueueExportResponse>> + + /** @see export */ + fun export( + params: AnnotationQueueExportParams + ): CompletableFuture<HttpResponseFor<AnnotationQueueExportResponse>> = + export(params, RequestOptions.none()) + + /** @see export */ + fun export( + queueId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<AnnotationQueueExportResponse>> = + export(queueId, AnnotationQueueExportParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/annotation-queues/populate`, but is + * otherwise the same as [AnnotationQueueServiceAsync.populate]. + */ + fun populate( + params: AnnotationQueuePopulateParams + ): CompletableFuture<HttpResponseFor<AnnotationQueuePopulateResponse>> = + populate(params, RequestOptions.none()) + + /** @see populate */ + fun populate( + params: AnnotationQueuePopulateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<AnnotationQueuePopulateResponse>> + + /** + * Returns a raw HTTP response for `get /api/v1/annotation-queues`, but is otherwise the + * same as [AnnotationQueueServiceAsync.retrieveAnnotationQueues]. + */ + fun retrieveAnnotationQueues(): + CompletableFuture< + HttpResponseFor<List<AnnotationQueueRetrieveAnnotationQueuesResponse>> + > = retrieveAnnotationQueues(AnnotationQueueRetrieveAnnotationQueuesParams.none()) + + /** @see retrieveAnnotationQueues */ + fun retrieveAnnotationQueues( + params: AnnotationQueueRetrieveAnnotationQueuesParams = + AnnotationQueueRetrieveAnnotationQueuesParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<AnnotationQueueRetrieveAnnotationQueuesResponse>>> + + /** @see retrieveAnnotationQueues */ + fun retrieveAnnotationQueues( + params: AnnotationQueueRetrieveAnnotationQueuesParams = + AnnotationQueueRetrieveAnnotationQueuesParams.none() + ): CompletableFuture< + HttpResponseFor<List<AnnotationQueueRetrieveAnnotationQueuesResponse>> + > = retrieveAnnotationQueues(params, RequestOptions.none()) + + /** @see retrieveAnnotationQueues */ + fun retrieveAnnotationQueues( + requestOptions: RequestOptions + ): CompletableFuture< + HttpResponseFor<List<AnnotationQueueRetrieveAnnotationQueuesResponse>> + > = + retrieveAnnotationQueues( + AnnotationQueueRetrieveAnnotationQueuesParams.none(), + requestOptions, + ) + + /** + * Returns a raw HTTP response for `get /api/v1/annotation-queues/{run_id}/queues`, but is + * otherwise the same as [AnnotationQueueServiceAsync.retrieveQueues]. + */ + fun retrieveQueues( + runId: String + ): CompletableFuture<HttpResponseFor<List<AnnotationQueueSchema>>> = + retrieveQueues(runId, AnnotationQueueRetrieveQueuesParams.none()) + + /** @see retrieveQueues */ + fun retrieveQueues( + runId: String, + params: AnnotationQueueRetrieveQueuesParams = + AnnotationQueueRetrieveQueuesParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<AnnotationQueueSchema>>> = + retrieveQueues(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see retrieveQueues */ + fun retrieveQueues( + runId: String, + params: AnnotationQueueRetrieveQueuesParams = AnnotationQueueRetrieveQueuesParams.none(), + ): CompletableFuture<HttpResponseFor<List<AnnotationQueueSchema>>> = + retrieveQueues(runId, params, RequestOptions.none()) + + /** @see retrieveQueues */ + fun retrieveQueues( + params: AnnotationQueueRetrieveQueuesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<AnnotationQueueSchema>>> + + /** @see retrieveQueues */ + fun retrieveQueues( + params: AnnotationQueueRetrieveQueuesParams + ): CompletableFuture<HttpResponseFor<List<AnnotationQueueSchema>>> = + retrieveQueues(params, RequestOptions.none()) + + /** @see retrieveQueues */ + fun retrieveQueues( + runId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<AnnotationQueueSchema>>> = + retrieveQueues(runId, AnnotationQueueRetrieveQueuesParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/annotation-queues/{queue_id}/size`, but is + * otherwise the same as [AnnotationQueueServiceAsync.retrieveSize]. + */ + fun retrieveSize( + queueId: String + ): CompletableFuture<HttpResponseFor<AnnotationQueueSizeSchema>> = + retrieveSize(queueId, AnnotationQueueRetrieveSizeParams.none()) + + /** @see retrieveSize */ + fun retrieveSize( + queueId: String, + params: AnnotationQueueRetrieveSizeParams = AnnotationQueueRetrieveSizeParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<AnnotationQueueSizeSchema>> = + retrieveSize(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see retrieveSize */ + fun retrieveSize( + queueId: String, + params: AnnotationQueueRetrieveSizeParams = AnnotationQueueRetrieveSizeParams.none(), + ): CompletableFuture<HttpResponseFor<AnnotationQueueSizeSchema>> = + retrieveSize(queueId, params, RequestOptions.none()) + + /** @see retrieveSize */ + fun retrieveSize( + params: AnnotationQueueRetrieveSizeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<AnnotationQueueSizeSchema>> + + /** @see retrieveSize */ + fun retrieveSize( + params: AnnotationQueueRetrieveSizeParams + ): CompletableFuture<HttpResponseFor<AnnotationQueueSizeSchema>> = + retrieveSize(params, RequestOptions.none()) + + /** @see retrieveSize */ + fun retrieveSize( + queueId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<AnnotationQueueSizeSchema>> = + retrieveSize(queueId, AnnotationQueueRetrieveSizeParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get + * /api/v1/annotation-queues/{queue_id}/total_archived`, but is otherwise the same as + * [AnnotationQueueServiceAsync.retrieveTotalArchived]. + */ + fun retrieveTotalArchived( + queueId: String + ): CompletableFuture<HttpResponseFor<AnnotationQueueSizeSchema>> = + retrieveTotalArchived(queueId, AnnotationQueueRetrieveTotalArchivedParams.none()) + + /** @see retrieveTotalArchived */ + fun retrieveTotalArchived( + queueId: String, + params: AnnotationQueueRetrieveTotalArchivedParams = + AnnotationQueueRetrieveTotalArchivedParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<AnnotationQueueSizeSchema>> = + retrieveTotalArchived(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see retrieveTotalArchived */ + fun retrieveTotalArchived( + queueId: String, + params: AnnotationQueueRetrieveTotalArchivedParams = + AnnotationQueueRetrieveTotalArchivedParams.none(), + ): CompletableFuture<HttpResponseFor<AnnotationQueueSizeSchema>> = + retrieveTotalArchived(queueId, params, RequestOptions.none()) + + /** @see retrieveTotalArchived */ + fun retrieveTotalArchived( + params: AnnotationQueueRetrieveTotalArchivedParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<AnnotationQueueSizeSchema>> + + /** @see retrieveTotalArchived */ + fun retrieveTotalArchived( + params: AnnotationQueueRetrieveTotalArchivedParams + ): CompletableFuture<HttpResponseFor<AnnotationQueueSizeSchema>> = + retrieveTotalArchived(params, RequestOptions.none()) + + /** @see retrieveTotalArchived */ + fun retrieveTotalArchived( + queueId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<AnnotationQueueSizeSchema>> = + retrieveTotalArchived( + queueId, + AnnotationQueueRetrieveTotalArchivedParams.none(), + requestOptions, + ) + + /** + * Returns a raw HTTP response for `get /api/v1/annotation-queues/{queue_id}/total_size`, + * but is otherwise the same as [AnnotationQueueServiceAsync.retrieveTotalSize]. + */ + fun retrieveTotalSize( + queueId: String + ): CompletableFuture<HttpResponseFor<AnnotationQueueSizeSchema>> = + retrieveTotalSize(queueId, AnnotationQueueRetrieveTotalSizeParams.none()) + + /** @see retrieveTotalSize */ + fun retrieveTotalSize( + queueId: String, + params: AnnotationQueueRetrieveTotalSizeParams = + AnnotationQueueRetrieveTotalSizeParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<AnnotationQueueSizeSchema>> = + retrieveTotalSize(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see retrieveTotalSize */ + fun retrieveTotalSize( + queueId: String, + params: AnnotationQueueRetrieveTotalSizeParams = + AnnotationQueueRetrieveTotalSizeParams.none(), + ): CompletableFuture<HttpResponseFor<AnnotationQueueSizeSchema>> = + retrieveTotalSize(queueId, params, RequestOptions.none()) + + /** @see retrieveTotalSize */ + fun retrieveTotalSize( + params: AnnotationQueueRetrieveTotalSizeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<AnnotationQueueSizeSchema>> + + /** @see retrieveTotalSize */ + fun retrieveTotalSize( + params: AnnotationQueueRetrieveTotalSizeParams + ): CompletableFuture<HttpResponseFor<AnnotationQueueSizeSchema>> = + retrieveTotalSize(params, RequestOptions.none()) + + /** @see retrieveTotalSize */ + fun retrieveTotalSize( + queueId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<AnnotationQueueSizeSchema>> = + retrieveTotalSize( + queueId, + AnnotationQueueRetrieveTotalSizeParams.none(), + requestOptions, + ) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/AnnotationQueueServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/AnnotationQueueServiceAsyncImpl.kt new file mode 100644 index 00000000..0323f7ef --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/AnnotationQueueServiceAsyncImpl.kt @@ -0,0 +1,559 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueAnnotationQueuesParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueDeleteParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueDeleteResponse +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueExportParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueExportResponse +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueuePopulateParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueuePopulateResponse +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueRetrieveAnnotationQueuesParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueRetrieveAnnotationQueuesResponse +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueRetrieveParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueRetrieveQueuesParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueRetrieveSizeParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueRetrieveTotalArchivedParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueRetrieveTotalSizeParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueSchema +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueSizeSchema +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueUpdateParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueUpdateResponse +import com.langsmith_api.api.models.api.v1.annotationqueues.RunSchemaWithAnnotationQueueInfo +import com.langsmith_api.api.services.async.api.v1.annotationqueues.RunServiceAsync +import com.langsmith_api.api.services.async.api.v1.annotationqueues.RunServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class AnnotationQueueServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : AnnotationQueueServiceAsync { + + private val withRawResponse: AnnotationQueueServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val runs: RunServiceAsync by lazy { RunServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): AnnotationQueueServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): AnnotationQueueServiceAsync = + AnnotationQueueServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun runs(): RunServiceAsync = runs + + override fun retrieve( + params: AnnotationQueueRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<RunSchemaWithAnnotationQueueInfo> = + // get /api/v1/annotation-queues/{queue_id}/run/{index} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: AnnotationQueueUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<AnnotationQueueUpdateResponse> = + // post /api/v1/annotation-queues/status/{annotation_queue_run_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: AnnotationQueueDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<AnnotationQueueDeleteResponse> = + // delete /api/v1/annotation-queues/{queue_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + override fun annotationQueues( + params: AnnotationQueueAnnotationQueuesParams, + requestOptions: RequestOptions, + ): CompletableFuture<AnnotationQueueSchema> = + // post /api/v1/annotation-queues + withRawResponse().annotationQueues(params, requestOptions).thenApply { it.parse() } + + override fun export( + params: AnnotationQueueExportParams, + requestOptions: RequestOptions, + ): CompletableFuture<AnnotationQueueExportResponse> = + // post /api/v1/annotation-queues/{queue_id}/export + withRawResponse().export(params, requestOptions).thenApply { it.parse() } + + override fun populate( + params: AnnotationQueuePopulateParams, + requestOptions: RequestOptions, + ): CompletableFuture<AnnotationQueuePopulateResponse> = + // post /api/v1/annotation-queues/populate + withRawResponse().populate(params, requestOptions).thenApply { it.parse() } + + override fun retrieveAnnotationQueues( + params: AnnotationQueueRetrieveAnnotationQueuesParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<AnnotationQueueRetrieveAnnotationQueuesResponse>> = + // get /api/v1/annotation-queues + withRawResponse().retrieveAnnotationQueues(params, requestOptions).thenApply { it.parse() } + + override fun retrieveQueues( + params: AnnotationQueueRetrieveQueuesParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<AnnotationQueueSchema>> = + // get /api/v1/annotation-queues/{run_id}/queues + withRawResponse().retrieveQueues(params, requestOptions).thenApply { it.parse() } + + override fun retrieveSize( + params: AnnotationQueueRetrieveSizeParams, + requestOptions: RequestOptions, + ): CompletableFuture<AnnotationQueueSizeSchema> = + // get /api/v1/annotation-queues/{queue_id}/size + withRawResponse().retrieveSize(params, requestOptions).thenApply { it.parse() } + + override fun retrieveTotalArchived( + params: AnnotationQueueRetrieveTotalArchivedParams, + requestOptions: RequestOptions, + ): CompletableFuture<AnnotationQueueSizeSchema> = + // get /api/v1/annotation-queues/{queue_id}/total_archived + withRawResponse().retrieveTotalArchived(params, requestOptions).thenApply { it.parse() } + + override fun retrieveTotalSize( + params: AnnotationQueueRetrieveTotalSizeParams, + requestOptions: RequestOptions, + ): CompletableFuture<AnnotationQueueSizeSchema> = + // get /api/v1/annotation-queues/{queue_id}/total_size + withRawResponse().retrieveTotalSize(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AnnotationQueueServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val runs: RunServiceAsync.WithRawResponse by lazy { + RunServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): AnnotationQueueServiceAsync.WithRawResponse = + AnnotationQueueServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun runs(): RunServiceAsync.WithRawResponse = runs + + private val retrieveHandler: Handler<RunSchemaWithAnnotationQueueInfo> = + jsonHandler<RunSchemaWithAnnotationQueueInfo>(clientOptions.jsonMapper) + + override fun retrieve( + params: AnnotationQueueRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<RunSchemaWithAnnotationQueueInfo>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("index", params.index().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "annotation-queues", + params._pathParam(0), + "run", + params._pathParam(1), + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler<AnnotationQueueUpdateResponse> = + jsonHandler<AnnotationQueueUpdateResponse>(clientOptions.jsonMapper) + + override fun update( + params: AnnotationQueueUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<AnnotationQueueUpdateResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("annotationQueueRunId", params.annotationQueueRunId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "annotation-queues", + "status", + params._pathParam(0), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val deleteHandler: Handler<AnnotationQueueDeleteResponse> = + jsonHandler<AnnotationQueueDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: AnnotationQueueDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<AnnotationQueueDeleteResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("queueId", params.queueId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "annotation-queues", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val annotationQueuesHandler: Handler<AnnotationQueueSchema> = + jsonHandler<AnnotationQueueSchema>(clientOptions.jsonMapper) + + override fun annotationQueues( + params: AnnotationQueueAnnotationQueuesParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<AnnotationQueueSchema>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "annotation-queues") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { annotationQueuesHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val exportHandler: Handler<AnnotationQueueExportResponse> = + jsonHandler<AnnotationQueueExportResponse>(clientOptions.jsonMapper) + + override fun export( + params: AnnotationQueueExportParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<AnnotationQueueExportResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("queueId", params.queueId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "annotation-queues", + params._pathParam(0), + "export", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { exportHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val populateHandler: Handler<AnnotationQueuePopulateResponse> = + jsonHandler<AnnotationQueuePopulateResponse>(clientOptions.jsonMapper) + + override fun populate( + params: AnnotationQueuePopulateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<AnnotationQueuePopulateResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "annotation-queues", "populate") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { populateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveAnnotationQueuesHandler: + Handler<List<AnnotationQueueRetrieveAnnotationQueuesResponse>> = + jsonHandler<List<AnnotationQueueRetrieveAnnotationQueuesResponse>>( + clientOptions.jsonMapper + ) + + override fun retrieveAnnotationQueues( + params: AnnotationQueueRetrieveAnnotationQueuesParams, + requestOptions: RequestOptions, + ): CompletableFuture< + HttpResponseFor<List<AnnotationQueueRetrieveAnnotationQueuesResponse>> + > { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "annotation-queues") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveAnnotationQueuesHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val retrieveQueuesHandler: Handler<List<AnnotationQueueSchema>> = + jsonHandler<List<AnnotationQueueSchema>>(clientOptions.jsonMapper) + + override fun retrieveQueues( + params: AnnotationQueueRetrieveQueuesParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<AnnotationQueueSchema>>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("runId", params.runId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "annotation-queues", + params._pathParam(0), + "queues", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveQueuesHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val retrieveSizeHandler: Handler<AnnotationQueueSizeSchema> = + jsonHandler<AnnotationQueueSizeSchema>(clientOptions.jsonMapper) + + override fun retrieveSize( + params: AnnotationQueueRetrieveSizeParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<AnnotationQueueSizeSchema>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("queueId", params.queueId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "annotation-queues", params._pathParam(0), "size") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveSizeHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveTotalArchivedHandler: Handler<AnnotationQueueSizeSchema> = + jsonHandler<AnnotationQueueSizeSchema>(clientOptions.jsonMapper) + + override fun retrieveTotalArchived( + params: AnnotationQueueRetrieveTotalArchivedParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<AnnotationQueueSizeSchema>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("queueId", params.queueId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "annotation-queues", + params._pathParam(0), + "total_archived", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveTotalArchivedHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveTotalSizeHandler: Handler<AnnotationQueueSizeSchema> = + jsonHandler<AnnotationQueueSizeSchema>(clientOptions.jsonMapper) + + override fun retrieveTotalSize( + params: AnnotationQueueRetrieveTotalSizeParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<AnnotationQueueSizeSchema>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("queueId", params.queueId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "annotation-queues", + params._pathParam(0), + "total_size", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveTotalSizeHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ApiKeyServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ApiKeyServiceAsync.kt new file mode 100644 index 00000000..6c4b3073 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ApiKeyServiceAsync.kt @@ -0,0 +1,243 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.apikey.ApiKeyApiKeyParams +import com.langsmith_api.api.models.api.v1.apikey.ApiKeyDeleteParams +import com.langsmith_api.api.models.api.v1.apikey.ApiKeyRetrieveApiKeyParams +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyCreateRequest +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyCreateResponse +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyGetResponse +import com.langsmith_api.api.services.async.api.v1.apikey.CurrentServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface ApiKeyServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ApiKeyServiceAsync + + fun current(): CurrentServiceAsync + + /** Delete an api key for the user */ + fun delete(apiKeyId: String): CompletableFuture<ApiKeyGetResponse> = + delete(apiKeyId, ApiKeyDeleteParams.none()) + + /** @see delete */ + fun delete( + apiKeyId: String, + params: ApiKeyDeleteParams = ApiKeyDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ApiKeyGetResponse> = + delete(params.toBuilder().apiKeyId(apiKeyId).build(), requestOptions) + + /** @see delete */ + fun delete( + apiKeyId: String, + params: ApiKeyDeleteParams = ApiKeyDeleteParams.none(), + ): CompletableFuture<ApiKeyGetResponse> = delete(apiKeyId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ApiKeyDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ApiKeyGetResponse> + + /** @see delete */ + fun delete(params: ApiKeyDeleteParams): CompletableFuture<ApiKeyGetResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + apiKeyId: String, + requestOptions: RequestOptions, + ): CompletableFuture<ApiKeyGetResponse> = + delete(apiKeyId, ApiKeyDeleteParams.none(), requestOptions) + + /** Generate an api key for the user */ + fun apiKey(): CompletableFuture<ApiKeyCreateResponse> = apiKey(ApiKeyApiKeyParams.none()) + + /** @see apiKey */ + fun apiKey( + params: ApiKeyApiKeyParams = ApiKeyApiKeyParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ApiKeyCreateResponse> + + /** @see apiKey */ + fun apiKey( + params: ApiKeyApiKeyParams = ApiKeyApiKeyParams.none() + ): CompletableFuture<ApiKeyCreateResponse> = apiKey(params, RequestOptions.none()) + + /** @see apiKey */ + fun apiKey( + apiKeyCreateRequest: ApiKeyCreateRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ApiKeyCreateResponse> = + apiKey( + ApiKeyApiKeyParams.builder().apiKeyCreateRequest(apiKeyCreateRequest).build(), + requestOptions, + ) + + /** @see apiKey */ + fun apiKey(apiKeyCreateRequest: ApiKeyCreateRequest): CompletableFuture<ApiKeyCreateResponse> = + apiKey(apiKeyCreateRequest, RequestOptions.none()) + + /** @see apiKey */ + fun apiKey(requestOptions: RequestOptions): CompletableFuture<ApiKeyCreateResponse> = + apiKey(ApiKeyApiKeyParams.none(), requestOptions) + + /** Get the current tenant's API keys */ + fun retrieveApiKey(): CompletableFuture<List<ApiKeyGetResponse>> = + retrieveApiKey(ApiKeyRetrieveApiKeyParams.none()) + + /** @see retrieveApiKey */ + fun retrieveApiKey( + params: ApiKeyRetrieveApiKeyParams = ApiKeyRetrieveApiKeyParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<ApiKeyGetResponse>> + + /** @see retrieveApiKey */ + fun retrieveApiKey( + params: ApiKeyRetrieveApiKeyParams = ApiKeyRetrieveApiKeyParams.none() + ): CompletableFuture<List<ApiKeyGetResponse>> = retrieveApiKey(params, RequestOptions.none()) + + /** @see retrieveApiKey */ + fun retrieveApiKey(requestOptions: RequestOptions): CompletableFuture<List<ApiKeyGetResponse>> = + retrieveApiKey(ApiKeyRetrieveApiKeyParams.none(), requestOptions) + + /** + * A view of [ApiKeyServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ApiKeyServiceAsync.WithRawResponse + + fun current(): CurrentServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `delete /api/v1/api-key/{api_key_id}`, but is otherwise + * the same as [ApiKeyServiceAsync.delete]. + */ + fun delete(apiKeyId: String): CompletableFuture<HttpResponseFor<ApiKeyGetResponse>> = + delete(apiKeyId, ApiKeyDeleteParams.none()) + + /** @see delete */ + fun delete( + apiKeyId: String, + params: ApiKeyDeleteParams = ApiKeyDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ApiKeyGetResponse>> = + delete(params.toBuilder().apiKeyId(apiKeyId).build(), requestOptions) + + /** @see delete */ + fun delete( + apiKeyId: String, + params: ApiKeyDeleteParams = ApiKeyDeleteParams.none(), + ): CompletableFuture<HttpResponseFor<ApiKeyGetResponse>> = + delete(apiKeyId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ApiKeyDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ApiKeyGetResponse>> + + /** @see delete */ + fun delete( + params: ApiKeyDeleteParams + ): CompletableFuture<HttpResponseFor<ApiKeyGetResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + apiKeyId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ApiKeyGetResponse>> = + delete(apiKeyId, ApiKeyDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/api-key`, but is otherwise the same as + * [ApiKeyServiceAsync.apiKey]. + */ + fun apiKey(): CompletableFuture<HttpResponseFor<ApiKeyCreateResponse>> = + apiKey(ApiKeyApiKeyParams.none()) + + /** @see apiKey */ + fun apiKey( + params: ApiKeyApiKeyParams = ApiKeyApiKeyParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ApiKeyCreateResponse>> + + /** @see apiKey */ + fun apiKey( + params: ApiKeyApiKeyParams = ApiKeyApiKeyParams.none() + ): CompletableFuture<HttpResponseFor<ApiKeyCreateResponse>> = + apiKey(params, RequestOptions.none()) + + /** @see apiKey */ + fun apiKey( + apiKeyCreateRequest: ApiKeyCreateRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ApiKeyCreateResponse>> = + apiKey( + ApiKeyApiKeyParams.builder().apiKeyCreateRequest(apiKeyCreateRequest).build(), + requestOptions, + ) + + /** @see apiKey */ + fun apiKey( + apiKeyCreateRequest: ApiKeyCreateRequest + ): CompletableFuture<HttpResponseFor<ApiKeyCreateResponse>> = + apiKey(apiKeyCreateRequest, RequestOptions.none()) + + /** @see apiKey */ + fun apiKey( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<ApiKeyCreateResponse>> = + apiKey(ApiKeyApiKeyParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/api-key`, but is otherwise the same as + * [ApiKeyServiceAsync.retrieveApiKey]. + */ + fun retrieveApiKey(): CompletableFuture<HttpResponseFor<List<ApiKeyGetResponse>>> = + retrieveApiKey(ApiKeyRetrieveApiKeyParams.none()) + + /** @see retrieveApiKey */ + fun retrieveApiKey( + params: ApiKeyRetrieveApiKeyParams = ApiKeyRetrieveApiKeyParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<ApiKeyGetResponse>>> + + /** @see retrieveApiKey */ + fun retrieveApiKey( + params: ApiKeyRetrieveApiKeyParams = ApiKeyRetrieveApiKeyParams.none() + ): CompletableFuture<HttpResponseFor<List<ApiKeyGetResponse>>> = + retrieveApiKey(params, RequestOptions.none()) + + /** @see retrieveApiKey */ + fun retrieveApiKey( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<ApiKeyGetResponse>>> = + retrieveApiKey(ApiKeyRetrieveApiKeyParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ApiKeyServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ApiKeyServiceAsyncImpl.kt new file mode 100644 index 00000000..ff723e0c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ApiKeyServiceAsyncImpl.kt @@ -0,0 +1,181 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.apikey.ApiKeyApiKeyParams +import com.langsmith_api.api.models.api.v1.apikey.ApiKeyDeleteParams +import com.langsmith_api.api.models.api.v1.apikey.ApiKeyRetrieveApiKeyParams +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyCreateResponse +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyGetResponse +import com.langsmith_api.api.services.async.api.v1.apikey.CurrentServiceAsync +import com.langsmith_api.api.services.async.api.v1.apikey.CurrentServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ApiKeyServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ApiKeyServiceAsync { + + private val withRawResponse: ApiKeyServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val current: CurrentServiceAsync by lazy { CurrentServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): ApiKeyServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): ApiKeyServiceAsync = + ApiKeyServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun current(): CurrentServiceAsync = current + + override fun delete( + params: ApiKeyDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<ApiKeyGetResponse> = + // delete /api/v1/api-key/{api_key_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + override fun apiKey( + params: ApiKeyApiKeyParams, + requestOptions: RequestOptions, + ): CompletableFuture<ApiKeyCreateResponse> = + // post /api/v1/api-key + withRawResponse().apiKey(params, requestOptions).thenApply { it.parse() } + + override fun retrieveApiKey( + params: ApiKeyRetrieveApiKeyParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<ApiKeyGetResponse>> = + // get /api/v1/api-key + withRawResponse().retrieveApiKey(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ApiKeyServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val current: CurrentServiceAsync.WithRawResponse by lazy { + CurrentServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ApiKeyServiceAsync.WithRawResponse = + ApiKeyServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun current(): CurrentServiceAsync.WithRawResponse = current + + private val deleteHandler: Handler<ApiKeyGetResponse> = + jsonHandler<ApiKeyGetResponse>(clientOptions.jsonMapper) + + override fun delete( + params: ApiKeyDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ApiKeyGetResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("apiKeyId", params.apiKeyId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "api-key", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val apiKeyHandler: Handler<ApiKeyCreateResponse> = + jsonHandler<ApiKeyCreateResponse>(clientOptions.jsonMapper) + + override fun apiKey( + params: ApiKeyApiKeyParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ApiKeyCreateResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "api-key") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { apiKeyHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveApiKeyHandler: Handler<List<ApiKeyGetResponse>> = + jsonHandler<List<ApiKeyGetResponse>>(clientOptions.jsonMapper) + + override fun retrieveApiKey( + params: ApiKeyRetrieveApiKeyParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<ApiKeyGetResponse>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "api-key") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveApiKeyHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/BulkExportServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/BulkExportServiceAsync.kt new file mode 100644 index 00000000..f2b66dbe --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/BulkExportServiceAsync.kt @@ -0,0 +1,274 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.bulkexports.BulkExport +import com.langsmith_api.api.models.api.v1.bulkexports.BulkExportBulkExportsParams +import com.langsmith_api.api.models.api.v1.bulkexports.BulkExportRetrieveBulkExportsParams +import com.langsmith_api.api.models.api.v1.bulkexports.BulkExportRetrieveParams +import com.langsmith_api.api.models.api.v1.bulkexports.BulkExportUpdateParams +import com.langsmith_api.api.services.async.api.v1.bulkexports.DestinationServiceAsync +import com.langsmith_api.api.services.async.api.v1.bulkexports.RunServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface BulkExportServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): BulkExportServiceAsync + + fun destinations(): DestinationServiceAsync + + fun runs(): RunServiceAsync + + /** Get a single bulk export by ID */ + fun retrieve(bulkExportId: String): CompletableFuture<BulkExport> = + retrieve(bulkExportId, BulkExportRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + bulkExportId: String, + params: BulkExportRetrieveParams = BulkExportRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<BulkExport> = + retrieve(params.toBuilder().bulkExportId(bulkExportId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + bulkExportId: String, + params: BulkExportRetrieveParams = BulkExportRetrieveParams.none(), + ): CompletableFuture<BulkExport> = retrieve(bulkExportId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: BulkExportRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<BulkExport> + + /** @see retrieve */ + fun retrieve(params: BulkExportRetrieveParams): CompletableFuture<BulkExport> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + bulkExportId: String, + requestOptions: RequestOptions, + ): CompletableFuture<BulkExport> = + retrieve(bulkExportId, BulkExportRetrieveParams.none(), requestOptions) + + /** Cancel a bulk export by ID */ + fun update(bulkExportId: String): CompletableFuture<BulkExport> = + update(bulkExportId, BulkExportUpdateParams.none()) + + /** @see update */ + fun update( + bulkExportId: String, + params: BulkExportUpdateParams = BulkExportUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<BulkExport> = + update(params.toBuilder().bulkExportId(bulkExportId).build(), requestOptions) + + /** @see update */ + fun update( + bulkExportId: String, + params: BulkExportUpdateParams = BulkExportUpdateParams.none(), + ): CompletableFuture<BulkExport> = update(bulkExportId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: BulkExportUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<BulkExport> + + /** @see update */ + fun update(params: BulkExportUpdateParams): CompletableFuture<BulkExport> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + bulkExportId: String, + requestOptions: RequestOptions, + ): CompletableFuture<BulkExport> = + update(bulkExportId, BulkExportUpdateParams.none(), requestOptions) + + /** Create a new bulk export */ + fun bulkExports(params: BulkExportBulkExportsParams): CompletableFuture<BulkExport> = + bulkExports(params, RequestOptions.none()) + + /** @see bulkExports */ + fun bulkExports( + params: BulkExportBulkExportsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<BulkExport> + + /** Get the current workspace's bulk exports */ + fun retrieveBulkExports(): CompletableFuture<List<BulkExport>> = + retrieveBulkExports(BulkExportRetrieveBulkExportsParams.none()) + + /** @see retrieveBulkExports */ + fun retrieveBulkExports( + params: BulkExportRetrieveBulkExportsParams = BulkExportRetrieveBulkExportsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<BulkExport>> + + /** @see retrieveBulkExports */ + fun retrieveBulkExports( + params: BulkExportRetrieveBulkExportsParams = BulkExportRetrieveBulkExportsParams.none() + ): CompletableFuture<List<BulkExport>> = retrieveBulkExports(params, RequestOptions.none()) + + /** @see retrieveBulkExports */ + fun retrieveBulkExports(requestOptions: RequestOptions): CompletableFuture<List<BulkExport>> = + retrieveBulkExports(BulkExportRetrieveBulkExportsParams.none(), requestOptions) + + /** + * A view of [BulkExportServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): BulkExportServiceAsync.WithRawResponse + + fun destinations(): DestinationServiceAsync.WithRawResponse + + fun runs(): RunServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/bulk-exports/{bulk_export_id}`, but is + * otherwise the same as [BulkExportServiceAsync.retrieve]. + */ + fun retrieve(bulkExportId: String): CompletableFuture<HttpResponseFor<BulkExport>> = + retrieve(bulkExportId, BulkExportRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + bulkExportId: String, + params: BulkExportRetrieveParams = BulkExportRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<BulkExport>> = + retrieve(params.toBuilder().bulkExportId(bulkExportId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + bulkExportId: String, + params: BulkExportRetrieveParams = BulkExportRetrieveParams.none(), + ): CompletableFuture<HttpResponseFor<BulkExport>> = + retrieve(bulkExportId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: BulkExportRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<BulkExport>> + + /** @see retrieve */ + fun retrieve( + params: BulkExportRetrieveParams + ): CompletableFuture<HttpResponseFor<BulkExport>> = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + bulkExportId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<BulkExport>> = + retrieve(bulkExportId, BulkExportRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `patch /api/v1/bulk-exports/{bulk_export_id}`, but is + * otherwise the same as [BulkExportServiceAsync.update]. + */ + fun update(bulkExportId: String): CompletableFuture<HttpResponseFor<BulkExport>> = + update(bulkExportId, BulkExportUpdateParams.none()) + + /** @see update */ + fun update( + bulkExportId: String, + params: BulkExportUpdateParams = BulkExportUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<BulkExport>> = + update(params.toBuilder().bulkExportId(bulkExportId).build(), requestOptions) + + /** @see update */ + fun update( + bulkExportId: String, + params: BulkExportUpdateParams = BulkExportUpdateParams.none(), + ): CompletableFuture<HttpResponseFor<BulkExport>> = + update(bulkExportId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: BulkExportUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<BulkExport>> + + /** @see update */ + fun update(params: BulkExportUpdateParams): CompletableFuture<HttpResponseFor<BulkExport>> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + bulkExportId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<BulkExport>> = + update(bulkExportId, BulkExportUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/bulk-exports`, but is otherwise the same as + * [BulkExportServiceAsync.bulkExports]. + */ + fun bulkExports( + params: BulkExportBulkExportsParams + ): CompletableFuture<HttpResponseFor<BulkExport>> = + bulkExports(params, RequestOptions.none()) + + /** @see bulkExports */ + fun bulkExports( + params: BulkExportBulkExportsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<BulkExport>> + + /** + * Returns a raw HTTP response for `get /api/v1/bulk-exports`, but is otherwise the same as + * [BulkExportServiceAsync.retrieveBulkExports]. + */ + fun retrieveBulkExports(): CompletableFuture<HttpResponseFor<List<BulkExport>>> = + retrieveBulkExports(BulkExportRetrieveBulkExportsParams.none()) + + /** @see retrieveBulkExports */ + fun retrieveBulkExports( + params: BulkExportRetrieveBulkExportsParams = + BulkExportRetrieveBulkExportsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<BulkExport>>> + + /** @see retrieveBulkExports */ + fun retrieveBulkExports( + params: BulkExportRetrieveBulkExportsParams = BulkExportRetrieveBulkExportsParams.none() + ): CompletableFuture<HttpResponseFor<List<BulkExport>>> = + retrieveBulkExports(params, RequestOptions.none()) + + /** @see retrieveBulkExports */ + fun retrieveBulkExports( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<BulkExport>>> = + retrieveBulkExports(BulkExportRetrieveBulkExportsParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/BulkExportServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/BulkExportServiceAsyncImpl.kt new file mode 100644 index 00000000..8b8b0462 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/BulkExportServiceAsyncImpl.kt @@ -0,0 +1,235 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.bulkexports.BulkExport +import com.langsmith_api.api.models.api.v1.bulkexports.BulkExportBulkExportsParams +import com.langsmith_api.api.models.api.v1.bulkexports.BulkExportRetrieveBulkExportsParams +import com.langsmith_api.api.models.api.v1.bulkexports.BulkExportRetrieveParams +import com.langsmith_api.api.models.api.v1.bulkexports.BulkExportUpdateParams +import com.langsmith_api.api.services.async.api.v1.bulkexports.DestinationServiceAsync +import com.langsmith_api.api.services.async.api.v1.bulkexports.DestinationServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.bulkexports.RunServiceAsync +import com.langsmith_api.api.services.async.api.v1.bulkexports.RunServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class BulkExportServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + BulkExportServiceAsync { + + private val withRawResponse: BulkExportServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val destinations: DestinationServiceAsync by lazy { + DestinationServiceAsyncImpl(clientOptions) + } + + private val runs: RunServiceAsync by lazy { RunServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): BulkExportServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): BulkExportServiceAsync = + BulkExportServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun destinations(): DestinationServiceAsync = destinations + + override fun runs(): RunServiceAsync = runs + + override fun retrieve( + params: BulkExportRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<BulkExport> = + // get /api/v1/bulk-exports/{bulk_export_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: BulkExportUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<BulkExport> = + // patch /api/v1/bulk-exports/{bulk_export_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun bulkExports( + params: BulkExportBulkExportsParams, + requestOptions: RequestOptions, + ): CompletableFuture<BulkExport> = + // post /api/v1/bulk-exports + withRawResponse().bulkExports(params, requestOptions).thenApply { it.parse() } + + override fun retrieveBulkExports( + params: BulkExportRetrieveBulkExportsParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<BulkExport>> = + // get /api/v1/bulk-exports + withRawResponse().retrieveBulkExports(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BulkExportServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val destinations: DestinationServiceAsync.WithRawResponse by lazy { + DestinationServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val runs: RunServiceAsync.WithRawResponse by lazy { + RunServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): BulkExportServiceAsync.WithRawResponse = + BulkExportServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun destinations(): DestinationServiceAsync.WithRawResponse = destinations + + override fun runs(): RunServiceAsync.WithRawResponse = runs + + private val retrieveHandler: Handler<BulkExport> = + jsonHandler<BulkExport>(clientOptions.jsonMapper) + + override fun retrieve( + params: BulkExportRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<BulkExport>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("bulkExportId", params.bulkExportId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "bulk-exports", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler<BulkExport> = + jsonHandler<BulkExport>(clientOptions.jsonMapper) + + override fun update( + params: BulkExportUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<BulkExport>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("bulkExportId", params.bulkExportId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "bulk-exports", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val bulkExportsHandler: Handler<BulkExport> = + jsonHandler<BulkExport>(clientOptions.jsonMapper) + + override fun bulkExports( + params: BulkExportBulkExportsParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<BulkExport>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "bulk-exports") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { bulkExportsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveBulkExportsHandler: Handler<List<BulkExport>> = + jsonHandler<List<BulkExport>>(clientOptions.jsonMapper) + + override fun retrieveBulkExports( + params: BulkExportRetrieveBulkExportsParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<BulkExport>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "bulk-exports") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveBulkExportsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ChartServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ChartServiceAsync.kt new file mode 100644 index 00000000..4d635e53 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ChartServiceAsync.kt @@ -0,0 +1,295 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.charts.ChartCreateParams +import com.langsmith_api.api.models.api.v1.charts.ChartDeleteParams +import com.langsmith_api.api.models.api.v1.charts.ChartDeleteResponse +import com.langsmith_api.api.models.api.v1.charts.ChartPreviewParams +import com.langsmith_api.api.models.api.v1.charts.ChartUpdateParams +import com.langsmith_api.api.models.api.v1.charts.CustomChartCreate +import com.langsmith_api.api.models.api.v1.charts.CustomChartPreviewRequest +import com.langsmith_api.api.models.api.v1.charts.CustomChartResponse +import com.langsmith_api.api.models.api.v1.charts.SingleCustomChartResponseBase +import com.langsmith_api.api.services.async.api.v1.charts.SectionServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface ChartServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ChartServiceAsync + + fun section(): SectionServiceAsync + + /** Create a new chart. */ + fun create(params: ChartCreateParams): CompletableFuture<CustomChartResponse> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: ChartCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CustomChartResponse> + + /** @see create */ + fun create( + customChartCreate: CustomChartCreate, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CustomChartResponse> = + create( + ChartCreateParams.builder().customChartCreate(customChartCreate).build(), + requestOptions, + ) + + /** @see create */ + fun create(customChartCreate: CustomChartCreate): CompletableFuture<CustomChartResponse> = + create(customChartCreate, RequestOptions.none()) + + /** Update a chart. */ + fun update(chartId: String, params: ChartUpdateParams): CompletableFuture<CustomChartResponse> = + update(chartId, params, RequestOptions.none()) + + /** @see update */ + fun update( + chartId: String, + params: ChartUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CustomChartResponse> = + update(params.toBuilder().chartId(chartId).build(), requestOptions) + + /** @see update */ + fun update(params: ChartUpdateParams): CompletableFuture<CustomChartResponse> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: ChartUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CustomChartResponse> + + /** Delete a chart. */ + fun delete(chartId: String): CompletableFuture<ChartDeleteResponse> = + delete(chartId, ChartDeleteParams.none()) + + /** @see delete */ + fun delete( + chartId: String, + params: ChartDeleteParams = ChartDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ChartDeleteResponse> = + delete(params.toBuilder().chartId(chartId).build(), requestOptions) + + /** @see delete */ + fun delete( + chartId: String, + params: ChartDeleteParams = ChartDeleteParams.none(), + ): CompletableFuture<ChartDeleteResponse> = delete(chartId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ChartDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ChartDeleteResponse> + + /** @see delete */ + fun delete(params: ChartDeleteParams): CompletableFuture<ChartDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + chartId: String, + requestOptions: RequestOptions, + ): CompletableFuture<ChartDeleteResponse> = + delete(chartId, ChartDeleteParams.none(), requestOptions) + + /** Get a preview for a chart without actually creating it. */ + fun preview(params: ChartPreviewParams): CompletableFuture<SingleCustomChartResponseBase> = + preview(params, RequestOptions.none()) + + /** @see preview */ + fun preview( + params: ChartPreviewParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<SingleCustomChartResponseBase> + + /** @see preview */ + fun preview( + customChartPreviewRequest: CustomChartPreviewRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<SingleCustomChartResponseBase> = + preview( + ChartPreviewParams.builder() + .customChartPreviewRequest(customChartPreviewRequest) + .build(), + requestOptions, + ) + + /** @see preview */ + fun preview( + customChartPreviewRequest: CustomChartPreviewRequest + ): CompletableFuture<SingleCustomChartResponseBase> = + preview(customChartPreviewRequest, RequestOptions.none()) + + /** A view of [ChartServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ChartServiceAsync.WithRawResponse + + fun section(): SectionServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/charts/create`, but is otherwise the same + * as [ChartServiceAsync.create]. + */ + fun create( + params: ChartCreateParams + ): CompletableFuture<HttpResponseFor<CustomChartResponse>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: ChartCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CustomChartResponse>> + + /** @see create */ + fun create( + customChartCreate: CustomChartCreate, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CustomChartResponse>> = + create( + ChartCreateParams.builder().customChartCreate(customChartCreate).build(), + requestOptions, + ) + + /** @see create */ + fun create( + customChartCreate: CustomChartCreate + ): CompletableFuture<HttpResponseFor<CustomChartResponse>> = + create(customChartCreate, RequestOptions.none()) + + /** + * Returns a raw HTTP response for `patch /api/v1/charts/{chart_id}`, but is otherwise the + * same as [ChartServiceAsync.update]. + */ + fun update( + chartId: String, + params: ChartUpdateParams, + ): CompletableFuture<HttpResponseFor<CustomChartResponse>> = + update(chartId, params, RequestOptions.none()) + + /** @see update */ + fun update( + chartId: String, + params: ChartUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CustomChartResponse>> = + update(params.toBuilder().chartId(chartId).build(), requestOptions) + + /** @see update */ + fun update( + params: ChartUpdateParams + ): CompletableFuture<HttpResponseFor<CustomChartResponse>> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: ChartUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CustomChartResponse>> + + /** + * Returns a raw HTTP response for `delete /api/v1/charts/{chart_id}`, but is otherwise the + * same as [ChartServiceAsync.delete]. + */ + fun delete(chartId: String): CompletableFuture<HttpResponseFor<ChartDeleteResponse>> = + delete(chartId, ChartDeleteParams.none()) + + /** @see delete */ + fun delete( + chartId: String, + params: ChartDeleteParams = ChartDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ChartDeleteResponse>> = + delete(params.toBuilder().chartId(chartId).build(), requestOptions) + + /** @see delete */ + fun delete( + chartId: String, + params: ChartDeleteParams = ChartDeleteParams.none(), + ): CompletableFuture<HttpResponseFor<ChartDeleteResponse>> = + delete(chartId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ChartDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ChartDeleteResponse>> + + /** @see delete */ + fun delete( + params: ChartDeleteParams + ): CompletableFuture<HttpResponseFor<ChartDeleteResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + chartId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ChartDeleteResponse>> = + delete(chartId, ChartDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/charts/preview`, but is otherwise the same + * as [ChartServiceAsync.preview]. + */ + fun preview( + params: ChartPreviewParams + ): CompletableFuture<HttpResponseFor<SingleCustomChartResponseBase>> = + preview(params, RequestOptions.none()) + + /** @see preview */ + fun preview( + params: ChartPreviewParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<SingleCustomChartResponseBase>> + + /** @see preview */ + fun preview( + customChartPreviewRequest: CustomChartPreviewRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<SingleCustomChartResponseBase>> = + preview( + ChartPreviewParams.builder() + .customChartPreviewRequest(customChartPreviewRequest) + .build(), + requestOptions, + ) + + /** @see preview */ + fun preview( + customChartPreviewRequest: CustomChartPreviewRequest + ): CompletableFuture<HttpResponseFor<SingleCustomChartResponseBase>> = + preview(customChartPreviewRequest, RequestOptions.none()) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ChartServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ChartServiceAsyncImpl.kt new file mode 100644 index 00000000..7671a223 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ChartServiceAsyncImpl.kt @@ -0,0 +1,225 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.charts.ChartCreateParams +import com.langsmith_api.api.models.api.v1.charts.ChartDeleteParams +import com.langsmith_api.api.models.api.v1.charts.ChartDeleteResponse +import com.langsmith_api.api.models.api.v1.charts.ChartPreviewParams +import com.langsmith_api.api.models.api.v1.charts.ChartUpdateParams +import com.langsmith_api.api.models.api.v1.charts.CustomChartResponse +import com.langsmith_api.api.models.api.v1.charts.SingleCustomChartResponseBase +import com.langsmith_api.api.services.async.api.v1.charts.SectionServiceAsync +import com.langsmith_api.api.services.async.api.v1.charts.SectionServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ChartServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ChartServiceAsync { + + private val withRawResponse: ChartServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val section: SectionServiceAsync by lazy { SectionServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): ChartServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): ChartServiceAsync = + ChartServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun section(): SectionServiceAsync = section + + override fun create( + params: ChartCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<CustomChartResponse> = + // post /api/v1/charts/create + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: ChartUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<CustomChartResponse> = + // patch /api/v1/charts/{chart_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: ChartDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<ChartDeleteResponse> = + // delete /api/v1/charts/{chart_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + override fun preview( + params: ChartPreviewParams, + requestOptions: RequestOptions, + ): CompletableFuture<SingleCustomChartResponseBase> = + // post /api/v1/charts/preview + withRawResponse().preview(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ChartServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val section: SectionServiceAsync.WithRawResponse by lazy { + SectionServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ChartServiceAsync.WithRawResponse = + ChartServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun section(): SectionServiceAsync.WithRawResponse = section + + private val createHandler: Handler<CustomChartResponse> = + jsonHandler<CustomChartResponse>(clientOptions.jsonMapper) + + override fun create( + params: ChartCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<CustomChartResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "charts", "create") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler<CustomChartResponse> = + jsonHandler<CustomChartResponse>(clientOptions.jsonMapper) + + override fun update( + params: ChartUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<CustomChartResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("chartId", params.chartId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "charts", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val deleteHandler: Handler<ChartDeleteResponse> = + jsonHandler<ChartDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: ChartDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ChartDeleteResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("chartId", params.chartId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "charts", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val previewHandler: Handler<SingleCustomChartResponseBase> = + jsonHandler<SingleCustomChartResponseBase>(clientOptions.jsonMapper) + + override fun preview( + params: ChartPreviewParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<SingleCustomChartResponseBase>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "charts", "preview") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { previewHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/CommentServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/CommentServiceAsync.kt new file mode 100644 index 00000000..f960cac7 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/CommentServiceAsync.kt @@ -0,0 +1,155 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.comments.Comment +import com.langsmith_api.api.models.api.v1.comments.CommentRetrieveParams +import com.langsmith_api.api.models.api.v1.comments.CommentUpdateParams +import com.langsmith_api.api.models.api.v1.comments.ListCommentsResponse +import com.langsmith_api.api.services.async.api.v1.comments.LikeServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface CommentServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): CommentServiceAsync + + fun like(): LikeServiceAsync + + /** Get Sub Comments */ + fun retrieve( + parentCommentId: String, + params: CommentRetrieveParams, + ): CompletableFuture<ListCommentsResponse> = + retrieve(parentCommentId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + parentCommentId: String, + params: CommentRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ListCommentsResponse> = + retrieve(params.toBuilder().parentCommentId(parentCommentId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: CommentRetrieveParams): CompletableFuture<ListCommentsResponse> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: CommentRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ListCommentsResponse> + + /** Create Sub Comment */ + fun update(parentCommentId: String, params: CommentUpdateParams): CompletableFuture<Comment> = + update(parentCommentId, params, RequestOptions.none()) + + /** @see update */ + fun update( + parentCommentId: String, + params: CommentUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<Comment> = + update(params.toBuilder().parentCommentId(parentCommentId).build(), requestOptions) + + /** @see update */ + fun update(params: CommentUpdateParams): CompletableFuture<Comment> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: CommentUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<Comment> + + /** + * A view of [CommentServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): CommentServiceAsync.WithRawResponse + + fun like(): LikeServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get + * /api/v1/comments/{owner}/{repo}/{parent_comment_id}`, but is otherwise the same as + * [CommentServiceAsync.retrieve]. + */ + fun retrieve( + parentCommentId: String, + params: CommentRetrieveParams, + ): CompletableFuture<HttpResponseFor<ListCommentsResponse>> = + retrieve(parentCommentId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + parentCommentId: String, + params: CommentRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ListCommentsResponse>> = + retrieve(params.toBuilder().parentCommentId(parentCommentId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + params: CommentRetrieveParams + ): CompletableFuture<HttpResponseFor<ListCommentsResponse>> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: CommentRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ListCommentsResponse>> + + /** + * Returns a raw HTTP response for `post + * /api/v1/comments/{owner}/{repo}/{parent_comment_id}`, but is otherwise the same as + * [CommentServiceAsync.update]. + */ + fun update( + parentCommentId: String, + params: CommentUpdateParams, + ): CompletableFuture<HttpResponseFor<Comment>> = + update(parentCommentId, params, RequestOptions.none()) + + /** @see update */ + fun update( + parentCommentId: String, + params: CommentUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<Comment>> = + update(params.toBuilder().parentCommentId(parentCommentId).build(), requestOptions) + + /** @see update */ + fun update(params: CommentUpdateParams): CompletableFuture<HttpResponseFor<Comment>> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: CommentUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<Comment>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/CommentServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/CommentServiceAsyncImpl.kt new file mode 100644 index 00000000..fdfcd027 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/CommentServiceAsyncImpl.kt @@ -0,0 +1,158 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.comments.Comment +import com.langsmith_api.api.models.api.v1.comments.CommentRetrieveParams +import com.langsmith_api.api.models.api.v1.comments.CommentUpdateParams +import com.langsmith_api.api.models.api.v1.comments.ListCommentsResponse +import com.langsmith_api.api.services.async.api.v1.comments.LikeServiceAsync +import com.langsmith_api.api.services.async.api.v1.comments.LikeServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class CommentServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + CommentServiceAsync { + + private val withRawResponse: CommentServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val like: LikeServiceAsync by lazy { LikeServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): CommentServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): CommentServiceAsync = + CommentServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun like(): LikeServiceAsync = like + + override fun retrieve( + params: CommentRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<ListCommentsResponse> = + // get /api/v1/comments/{owner}/{repo}/{parent_comment_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: CommentUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<Comment> = + // post /api/v1/comments/{owner}/{repo}/{parent_comment_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CommentServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val like: LikeServiceAsync.WithRawResponse by lazy { + LikeServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): CommentServiceAsync.WithRawResponse = + CommentServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun like(): LikeServiceAsync.WithRawResponse = like + + private val retrieveHandler: Handler<ListCommentsResponse> = + jsonHandler<ListCommentsResponse>(clientOptions.jsonMapper) + + override fun retrieve( + params: CommentRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ListCommentsResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("parentCommentId", params.parentCommentId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "comments", + params._pathParam(0), + params._pathParam(1), + params._pathParam(2), + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler<Comment> = jsonHandler<Comment>(clientOptions.jsonMapper) + + override fun update( + params: CommentUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<Comment>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("parentCommentId", params.parentCommentId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "comments", + params._pathParam(0), + params._pathParam(1), + params._pathParam(2), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/CommitServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/CommitServiceAsync.kt new file mode 100644 index 00000000..92f99e25 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/CommitServiceAsync.kt @@ -0,0 +1,149 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.commits.CommitManifestResponse +import com.langsmith_api.api.models.api.v1.commits.CommitRetrieveParams +import com.langsmith_api.api.models.api.v1.commits.CommitUpdateParams +import com.langsmith_api.api.models.api.v1.commits.CommitUpdateResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface CommitServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): CommitServiceAsync + + /** Download a repo. */ + fun retrieve( + commit: String, + params: CommitRetrieveParams, + ): CompletableFuture<CommitManifestResponse> = retrieve(commit, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + commit: String, + params: CommitRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CommitManifestResponse> = + retrieve(params.toBuilder().commit(commit).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: CommitRetrieveParams): CompletableFuture<CommitManifestResponse> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: CommitRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CommitManifestResponse> + + /** Upload a repo. */ + fun update(repo: String, params: CommitUpdateParams): CompletableFuture<CommitUpdateResponse> = + update(repo, params, RequestOptions.none()) + + /** @see update */ + fun update( + repo: String, + params: CommitUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CommitUpdateResponse> = + update(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see update */ + fun update(params: CommitUpdateParams): CompletableFuture<CommitUpdateResponse> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: CommitUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CommitUpdateResponse> + + /** + * A view of [CommitServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): CommitServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/commits/{owner}/{repo}/{commit}`, but is + * otherwise the same as [CommitServiceAsync.retrieve]. + */ + fun retrieve( + commit: String, + params: CommitRetrieveParams, + ): CompletableFuture<HttpResponseFor<CommitManifestResponse>> = + retrieve(commit, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + commit: String, + params: CommitRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CommitManifestResponse>> = + retrieve(params.toBuilder().commit(commit).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + params: CommitRetrieveParams + ): CompletableFuture<HttpResponseFor<CommitManifestResponse>> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: CommitRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CommitManifestResponse>> + + /** + * Returns a raw HTTP response for `post /api/v1/commits/{owner}/{repo}`, but is otherwise + * the same as [CommitServiceAsync.update]. + */ + fun update( + repo: String, + params: CommitUpdateParams, + ): CompletableFuture<HttpResponseFor<CommitUpdateResponse>> = + update(repo, params, RequestOptions.none()) + + /** @see update */ + fun update( + repo: String, + params: CommitUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CommitUpdateResponse>> = + update(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see update */ + fun update( + params: CommitUpdateParams + ): CompletableFuture<HttpResponseFor<CommitUpdateResponse>> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: CommitUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CommitUpdateResponse>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/CommitServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/CommitServiceAsyncImpl.kt new file mode 100644 index 00000000..3c69a25d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/CommitServiceAsyncImpl.kt @@ -0,0 +1,146 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.commits.CommitManifestResponse +import com.langsmith_api.api.models.api.v1.commits.CommitRetrieveParams +import com.langsmith_api.api.models.api.v1.commits.CommitUpdateParams +import com.langsmith_api.api.models.api.v1.commits.CommitUpdateResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class CommitServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + CommitServiceAsync { + + private val withRawResponse: CommitServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): CommitServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): CommitServiceAsync = + CommitServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: CommitRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<CommitManifestResponse> = + // get /api/v1/commits/{owner}/{repo}/{commit} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: CommitUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<CommitUpdateResponse> = + // post /api/v1/commits/{owner}/{repo} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CommitServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): CommitServiceAsync.WithRawResponse = + CommitServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler<CommitManifestResponse> = + jsonHandler<CommitManifestResponse>(clientOptions.jsonMapper) + + override fun retrieve( + params: CommitRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<CommitManifestResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("commit", params.commit().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "commits", + params._pathParam(0), + params._pathParam(1), + params._pathParam(2), + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler<CommitUpdateResponse> = + jsonHandler<CommitUpdateResponse>(clientOptions.jsonMapper) + + override fun update( + params: CommitUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<CommitUpdateResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("repo", params.repo().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "commits", + params._pathParam(0), + params._pathParam(1), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/DatasetServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/DatasetServiceAsync.kt new file mode 100644 index 00000000..127dab85 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/DatasetServiceAsync.kt @@ -0,0 +1,1066 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.datasets.Dataset +import com.langsmith_api.api.models.api.v1.datasets.DatasetCloneParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetCloneResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetCreateParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetDeleteParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetDeleteResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetGenerateParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetGenerateResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetListParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveCsvParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveCsvResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveJsonlParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveJsonlResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveOpenAIFtParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveOpenAIFtResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveOpenAIParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveOpenAIResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveVersionParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetSearchParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetSearchResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetStudioExperimentParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetStudioExperimentResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetUpdateParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetUpdateResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetUpdateTagsParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetUploadExperimentParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetUploadExperimentResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetUploadParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetVersion +import com.langsmith_api.api.services.async.api.v1.datasets.ComparativeServiceAsync +import com.langsmith_api.api.services.async.api.v1.datasets.ExperimentServiceAsync +import com.langsmith_api.api.services.async.api.v1.datasets.GroupServiceAsync +import com.langsmith_api.api.services.async.api.v1.datasets.IndexServiceAsync +import com.langsmith_api.api.services.async.api.v1.datasets.PlaygroundExperimentServiceAsync +import com.langsmith_api.api.services.async.api.v1.datasets.RunServiceAsync +import com.langsmith_api.api.services.async.api.v1.datasets.ShareServiceAsync +import com.langsmith_api.api.services.async.api.v1.datasets.SplitServiceAsync +import com.langsmith_api.api.services.async.api.v1.datasets.VersionServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface DatasetServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): DatasetServiceAsync + + fun versions(): VersionServiceAsync + + fun runs(): RunServiceAsync + + fun group(): GroupServiceAsync + + fun experiments(): ExperimentServiceAsync + + fun share(): ShareServiceAsync + + fun comparative(): ComparativeServiceAsync + + fun splits(): SplitServiceAsync + + fun index(): IndexServiceAsync + + fun playgroundExperiment(): PlaygroundExperimentServiceAsync + + /** Create a new dataset. */ + fun create(params: DatasetCreateParams): CompletableFuture<Dataset> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: DatasetCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<Dataset> + + /** Get a specific dataset. */ + fun retrieve(datasetId: String): CompletableFuture<Dataset> = + retrieve(datasetId, DatasetRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + datasetId: String, + params: DatasetRetrieveParams = DatasetRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<Dataset> = + retrieve(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + datasetId: String, + params: DatasetRetrieveParams = DatasetRetrieveParams.none(), + ): CompletableFuture<Dataset> = retrieve(datasetId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: DatasetRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<Dataset> + + /** @see retrieve */ + fun retrieve(params: DatasetRetrieveParams): CompletableFuture<Dataset> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(datasetId: String, requestOptions: RequestOptions): CompletableFuture<Dataset> = + retrieve(datasetId, DatasetRetrieveParams.none(), requestOptions) + + /** Update a specific dataset. */ + fun update(datasetId: String): CompletableFuture<DatasetUpdateResponse> = + update(datasetId, DatasetUpdateParams.none()) + + /** @see update */ + fun update( + datasetId: String, + params: DatasetUpdateParams = DatasetUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<DatasetUpdateResponse> = + update(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see update */ + fun update( + datasetId: String, + params: DatasetUpdateParams = DatasetUpdateParams.none(), + ): CompletableFuture<DatasetUpdateResponse> = update(datasetId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: DatasetUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<DatasetUpdateResponse> + + /** @see update */ + fun update(params: DatasetUpdateParams): CompletableFuture<DatasetUpdateResponse> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + datasetId: String, + requestOptions: RequestOptions, + ): CompletableFuture<DatasetUpdateResponse> = + update(datasetId, DatasetUpdateParams.none(), requestOptions) + + /** Get all datasets by query params and owner. */ + fun list(): CompletableFuture<List<Dataset>> = list(DatasetListParams.none()) + + /** @see list */ + fun list( + params: DatasetListParams = DatasetListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<Dataset>> + + /** @see list */ + fun list( + params: DatasetListParams = DatasetListParams.none() + ): CompletableFuture<List<Dataset>> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture<List<Dataset>> = + list(DatasetListParams.none(), requestOptions) + + /** Delete a specific dataset. */ + fun delete(datasetId: String): CompletableFuture<DatasetDeleteResponse> = + delete(datasetId, DatasetDeleteParams.none()) + + /** @see delete */ + fun delete( + datasetId: String, + params: DatasetDeleteParams = DatasetDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<DatasetDeleteResponse> = + delete(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see delete */ + fun delete( + datasetId: String, + params: DatasetDeleteParams = DatasetDeleteParams.none(), + ): CompletableFuture<DatasetDeleteResponse> = delete(datasetId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: DatasetDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<DatasetDeleteResponse> + + /** @see delete */ + fun delete(params: DatasetDeleteParams): CompletableFuture<DatasetDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + datasetId: String, + requestOptions: RequestOptions, + ): CompletableFuture<DatasetDeleteResponse> = + delete(datasetId, DatasetDeleteParams.none(), requestOptions) + + /** Clone a dataset. */ + fun clone(params: DatasetCloneParams): CompletableFuture<List<DatasetCloneResponse>> = + clone(params, RequestOptions.none()) + + /** @see clone */ + fun clone( + params: DatasetCloneParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<DatasetCloneResponse>> + + /** Generate synthetic examples for a dataset. */ + fun generate( + datasetId: String, + params: DatasetGenerateParams, + ): CompletableFuture<DatasetGenerateResponse> = + generate(datasetId, params, RequestOptions.none()) + + /** @see generate */ + fun generate( + datasetId: String, + params: DatasetGenerateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<DatasetGenerateResponse> = + generate(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see generate */ + fun generate(params: DatasetGenerateParams): CompletableFuture<DatasetGenerateResponse> = + generate(params, RequestOptions.none()) + + /** @see generate */ + fun generate( + params: DatasetGenerateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<DatasetGenerateResponse> + + /** Download a dataset as CSV format. */ + fun retrieveCsv(datasetId: String): CompletableFuture<DatasetRetrieveCsvResponse> = + retrieveCsv(datasetId, DatasetRetrieveCsvParams.none()) + + /** @see retrieveCsv */ + fun retrieveCsv( + datasetId: String, + params: DatasetRetrieveCsvParams = DatasetRetrieveCsvParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<DatasetRetrieveCsvResponse> = + retrieveCsv(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see retrieveCsv */ + fun retrieveCsv( + datasetId: String, + params: DatasetRetrieveCsvParams = DatasetRetrieveCsvParams.none(), + ): CompletableFuture<DatasetRetrieveCsvResponse> = + retrieveCsv(datasetId, params, RequestOptions.none()) + + /** @see retrieveCsv */ + fun retrieveCsv( + params: DatasetRetrieveCsvParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<DatasetRetrieveCsvResponse> + + /** @see retrieveCsv */ + fun retrieveCsv( + params: DatasetRetrieveCsvParams + ): CompletableFuture<DatasetRetrieveCsvResponse> = retrieveCsv(params, RequestOptions.none()) + + /** @see retrieveCsv */ + fun retrieveCsv( + datasetId: String, + requestOptions: RequestOptions, + ): CompletableFuture<DatasetRetrieveCsvResponse> = + retrieveCsv(datasetId, DatasetRetrieveCsvParams.none(), requestOptions) + + /** Download a dataset as CSV format. */ + fun retrieveJsonl(datasetId: String): CompletableFuture<DatasetRetrieveJsonlResponse> = + retrieveJsonl(datasetId, DatasetRetrieveJsonlParams.none()) + + /** @see retrieveJsonl */ + fun retrieveJsonl( + datasetId: String, + params: DatasetRetrieveJsonlParams = DatasetRetrieveJsonlParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<DatasetRetrieveJsonlResponse> = + retrieveJsonl(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see retrieveJsonl */ + fun retrieveJsonl( + datasetId: String, + params: DatasetRetrieveJsonlParams = DatasetRetrieveJsonlParams.none(), + ): CompletableFuture<DatasetRetrieveJsonlResponse> = + retrieveJsonl(datasetId, params, RequestOptions.none()) + + /** @see retrieveJsonl */ + fun retrieveJsonl( + params: DatasetRetrieveJsonlParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<DatasetRetrieveJsonlResponse> + + /** @see retrieveJsonl */ + fun retrieveJsonl( + params: DatasetRetrieveJsonlParams + ): CompletableFuture<DatasetRetrieveJsonlResponse> = + retrieveJsonl(params, RequestOptions.none()) + + /** @see retrieveJsonl */ + fun retrieveJsonl( + datasetId: String, + requestOptions: RequestOptions, + ): CompletableFuture<DatasetRetrieveJsonlResponse> = + retrieveJsonl(datasetId, DatasetRetrieveJsonlParams.none(), requestOptions) + + /** Download a dataset as OpenAI Evals Jsonl format. */ + fun retrieveOpenAI(datasetId: String): CompletableFuture<DatasetRetrieveOpenAIResponse> = + retrieveOpenAI(datasetId, DatasetRetrieveOpenAIParams.none()) + + /** @see retrieveOpenAI */ + fun retrieveOpenAI( + datasetId: String, + params: DatasetRetrieveOpenAIParams = DatasetRetrieveOpenAIParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<DatasetRetrieveOpenAIResponse> = + retrieveOpenAI(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see retrieveOpenAI */ + fun retrieveOpenAI( + datasetId: String, + params: DatasetRetrieveOpenAIParams = DatasetRetrieveOpenAIParams.none(), + ): CompletableFuture<DatasetRetrieveOpenAIResponse> = + retrieveOpenAI(datasetId, params, RequestOptions.none()) + + /** @see retrieveOpenAI */ + fun retrieveOpenAI( + params: DatasetRetrieveOpenAIParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<DatasetRetrieveOpenAIResponse> + + /** @see retrieveOpenAI */ + fun retrieveOpenAI( + params: DatasetRetrieveOpenAIParams + ): CompletableFuture<DatasetRetrieveOpenAIResponse> = + retrieveOpenAI(params, RequestOptions.none()) + + /** @see retrieveOpenAI */ + fun retrieveOpenAI( + datasetId: String, + requestOptions: RequestOptions, + ): CompletableFuture<DatasetRetrieveOpenAIResponse> = + retrieveOpenAI(datasetId, DatasetRetrieveOpenAIParams.none(), requestOptions) + + /** Download a dataset as OpenAI Jsonl format. */ + fun retrieveOpenAIFt(datasetId: String): CompletableFuture<DatasetRetrieveOpenAIFtResponse> = + retrieveOpenAIFt(datasetId, DatasetRetrieveOpenAIFtParams.none()) + + /** @see retrieveOpenAIFt */ + fun retrieveOpenAIFt( + datasetId: String, + params: DatasetRetrieveOpenAIFtParams = DatasetRetrieveOpenAIFtParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<DatasetRetrieveOpenAIFtResponse> = + retrieveOpenAIFt(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see retrieveOpenAIFt */ + fun retrieveOpenAIFt( + datasetId: String, + params: DatasetRetrieveOpenAIFtParams = DatasetRetrieveOpenAIFtParams.none(), + ): CompletableFuture<DatasetRetrieveOpenAIFtResponse> = + retrieveOpenAIFt(datasetId, params, RequestOptions.none()) + + /** @see retrieveOpenAIFt */ + fun retrieveOpenAIFt( + params: DatasetRetrieveOpenAIFtParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<DatasetRetrieveOpenAIFtResponse> + + /** @see retrieveOpenAIFt */ + fun retrieveOpenAIFt( + params: DatasetRetrieveOpenAIFtParams + ): CompletableFuture<DatasetRetrieveOpenAIFtResponse> = + retrieveOpenAIFt(params, RequestOptions.none()) + + /** @see retrieveOpenAIFt */ + fun retrieveOpenAIFt( + datasetId: String, + requestOptions: RequestOptions, + ): CompletableFuture<DatasetRetrieveOpenAIFtResponse> = + retrieveOpenAIFt(datasetId, DatasetRetrieveOpenAIFtParams.none(), requestOptions) + + /** Get dataset version by as_of or exact tag. */ + fun retrieveVersion(datasetId: String): CompletableFuture<DatasetVersion> = + retrieveVersion(datasetId, DatasetRetrieveVersionParams.none()) + + /** @see retrieveVersion */ + fun retrieveVersion( + datasetId: String, + params: DatasetRetrieveVersionParams = DatasetRetrieveVersionParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<DatasetVersion> = + retrieveVersion(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see retrieveVersion */ + fun retrieveVersion( + datasetId: String, + params: DatasetRetrieveVersionParams = DatasetRetrieveVersionParams.none(), + ): CompletableFuture<DatasetVersion> = retrieveVersion(datasetId, params, RequestOptions.none()) + + /** @see retrieveVersion */ + fun retrieveVersion( + params: DatasetRetrieveVersionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<DatasetVersion> + + /** @see retrieveVersion */ + fun retrieveVersion(params: DatasetRetrieveVersionParams): CompletableFuture<DatasetVersion> = + retrieveVersion(params, RequestOptions.none()) + + /** @see retrieveVersion */ + fun retrieveVersion( + datasetId: String, + requestOptions: RequestOptions, + ): CompletableFuture<DatasetVersion> = + retrieveVersion(datasetId, DatasetRetrieveVersionParams.none(), requestOptions) + + /** Search a dataset. */ + fun search( + datasetId: String, + params: DatasetSearchParams, + ): CompletableFuture<DatasetSearchResponse> = search(datasetId, params, RequestOptions.none()) + + /** @see search */ + fun search( + datasetId: String, + params: DatasetSearchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<DatasetSearchResponse> = + search(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see search */ + fun search(params: DatasetSearchParams): CompletableFuture<DatasetSearchResponse> = + search(params, RequestOptions.none()) + + /** @see search */ + fun search( + params: DatasetSearchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<DatasetSearchResponse> + + /** Studio Experiment */ + fun studioExperiment( + params: DatasetStudioExperimentParams + ): CompletableFuture<DatasetStudioExperimentResponse> = + studioExperiment(params, RequestOptions.none()) + + /** @see studioExperiment */ + fun studioExperiment( + params: DatasetStudioExperimentParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<DatasetStudioExperimentResponse> + + /** Set a tag on a dataset version. */ + fun updateTags( + datasetId: String, + params: DatasetUpdateTagsParams, + ): CompletableFuture<DatasetVersion> = updateTags(datasetId, params, RequestOptions.none()) + + /** @see updateTags */ + fun updateTags( + datasetId: String, + params: DatasetUpdateTagsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<DatasetVersion> = + updateTags(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see updateTags */ + fun updateTags(params: DatasetUpdateTagsParams): CompletableFuture<DatasetVersion> = + updateTags(params, RequestOptions.none()) + + /** @see updateTags */ + fun updateTags( + params: DatasetUpdateTagsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<DatasetVersion> + + /** Create a new dataset from a CSV file. */ + fun upload(params: DatasetUploadParams): CompletableFuture<Dataset> = + upload(params, RequestOptions.none()) + + /** @see upload */ + fun upload( + params: DatasetUploadParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<Dataset> + + /** Upload an experiment that has already been run. */ + fun uploadExperiment( + params: DatasetUploadExperimentParams + ): CompletableFuture<DatasetUploadExperimentResponse> = + uploadExperiment(params, RequestOptions.none()) + + /** @see uploadExperiment */ + fun uploadExperiment( + params: DatasetUploadExperimentParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<DatasetUploadExperimentResponse> + + /** + * A view of [DatasetServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): DatasetServiceAsync.WithRawResponse + + fun versions(): VersionServiceAsync.WithRawResponse + + fun runs(): RunServiceAsync.WithRawResponse + + fun group(): GroupServiceAsync.WithRawResponse + + fun experiments(): ExperimentServiceAsync.WithRawResponse + + fun share(): ShareServiceAsync.WithRawResponse + + fun comparative(): ComparativeServiceAsync.WithRawResponse + + fun splits(): SplitServiceAsync.WithRawResponse + + fun index(): IndexServiceAsync.WithRawResponse + + fun playgroundExperiment(): PlaygroundExperimentServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/datasets`, but is otherwise the same as + * [DatasetServiceAsync.create]. + */ + fun create(params: DatasetCreateParams): CompletableFuture<HttpResponseFor<Dataset>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: DatasetCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<Dataset>> + + /** + * Returns a raw HTTP response for `get /api/v1/datasets/{dataset_id}`, but is otherwise the + * same as [DatasetServiceAsync.retrieve]. + */ + fun retrieve(datasetId: String): CompletableFuture<HttpResponseFor<Dataset>> = + retrieve(datasetId, DatasetRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + datasetId: String, + params: DatasetRetrieveParams = DatasetRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<Dataset>> = + retrieve(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + datasetId: String, + params: DatasetRetrieveParams = DatasetRetrieveParams.none(), + ): CompletableFuture<HttpResponseFor<Dataset>> = + retrieve(datasetId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: DatasetRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<Dataset>> + + /** @see retrieve */ + fun retrieve(params: DatasetRetrieveParams): CompletableFuture<HttpResponseFor<Dataset>> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + datasetId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<Dataset>> = + retrieve(datasetId, DatasetRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `patch /api/v1/datasets/{dataset_id}`, but is otherwise + * the same as [DatasetServiceAsync.update]. + */ + fun update(datasetId: String): CompletableFuture<HttpResponseFor<DatasetUpdateResponse>> = + update(datasetId, DatasetUpdateParams.none()) + + /** @see update */ + fun update( + datasetId: String, + params: DatasetUpdateParams = DatasetUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<DatasetUpdateResponse>> = + update(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see update */ + fun update( + datasetId: String, + params: DatasetUpdateParams = DatasetUpdateParams.none(), + ): CompletableFuture<HttpResponseFor<DatasetUpdateResponse>> = + update(datasetId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: DatasetUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<DatasetUpdateResponse>> + + /** @see update */ + fun update( + params: DatasetUpdateParams + ): CompletableFuture<HttpResponseFor<DatasetUpdateResponse>> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + datasetId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<DatasetUpdateResponse>> = + update(datasetId, DatasetUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/datasets`, but is otherwise the same as + * [DatasetServiceAsync.list]. + */ + fun list(): CompletableFuture<HttpResponseFor<List<Dataset>>> = + list(DatasetListParams.none()) + + /** @see list */ + fun list( + params: DatasetListParams = DatasetListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<Dataset>>> + + /** @see list */ + fun list( + params: DatasetListParams = DatasetListParams.none() + ): CompletableFuture<HttpResponseFor<List<Dataset>>> = list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<Dataset>>> = + list(DatasetListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/datasets/{dataset_id}`, but is otherwise + * the same as [DatasetServiceAsync.delete]. + */ + fun delete(datasetId: String): CompletableFuture<HttpResponseFor<DatasetDeleteResponse>> = + delete(datasetId, DatasetDeleteParams.none()) + + /** @see delete */ + fun delete( + datasetId: String, + params: DatasetDeleteParams = DatasetDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<DatasetDeleteResponse>> = + delete(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see delete */ + fun delete( + datasetId: String, + params: DatasetDeleteParams = DatasetDeleteParams.none(), + ): CompletableFuture<HttpResponseFor<DatasetDeleteResponse>> = + delete(datasetId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: DatasetDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<DatasetDeleteResponse>> + + /** @see delete */ + fun delete( + params: DatasetDeleteParams + ): CompletableFuture<HttpResponseFor<DatasetDeleteResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + datasetId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<DatasetDeleteResponse>> = + delete(datasetId, DatasetDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/datasets/clone`, but is otherwise the same + * as [DatasetServiceAsync.clone]. + */ + fun clone( + params: DatasetCloneParams + ): CompletableFuture<HttpResponseFor<List<DatasetCloneResponse>>> = + clone(params, RequestOptions.none()) + + /** @see clone */ + fun clone( + params: DatasetCloneParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<DatasetCloneResponse>>> + + /** + * Returns a raw HTTP response for `post /api/v1/datasets/{dataset_id}/generate`, but is + * otherwise the same as [DatasetServiceAsync.generate]. + */ + fun generate( + datasetId: String, + params: DatasetGenerateParams, + ): CompletableFuture<HttpResponseFor<DatasetGenerateResponse>> = + generate(datasetId, params, RequestOptions.none()) + + /** @see generate */ + fun generate( + datasetId: String, + params: DatasetGenerateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<DatasetGenerateResponse>> = + generate(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see generate */ + fun generate( + params: DatasetGenerateParams + ): CompletableFuture<HttpResponseFor<DatasetGenerateResponse>> = + generate(params, RequestOptions.none()) + + /** @see generate */ + fun generate( + params: DatasetGenerateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<DatasetGenerateResponse>> + + /** + * Returns a raw HTTP response for `get /api/v1/datasets/{dataset_id}/csv`, but is otherwise + * the same as [DatasetServiceAsync.retrieveCsv]. + */ + fun retrieveCsv( + datasetId: String + ): CompletableFuture<HttpResponseFor<DatasetRetrieveCsvResponse>> = + retrieveCsv(datasetId, DatasetRetrieveCsvParams.none()) + + /** @see retrieveCsv */ + fun retrieveCsv( + datasetId: String, + params: DatasetRetrieveCsvParams = DatasetRetrieveCsvParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<DatasetRetrieveCsvResponse>> = + retrieveCsv(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see retrieveCsv */ + fun retrieveCsv( + datasetId: String, + params: DatasetRetrieveCsvParams = DatasetRetrieveCsvParams.none(), + ): CompletableFuture<HttpResponseFor<DatasetRetrieveCsvResponse>> = + retrieveCsv(datasetId, params, RequestOptions.none()) + + /** @see retrieveCsv */ + fun retrieveCsv( + params: DatasetRetrieveCsvParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<DatasetRetrieveCsvResponse>> + + /** @see retrieveCsv */ + fun retrieveCsv( + params: DatasetRetrieveCsvParams + ): CompletableFuture<HttpResponseFor<DatasetRetrieveCsvResponse>> = + retrieveCsv(params, RequestOptions.none()) + + /** @see retrieveCsv */ + fun retrieveCsv( + datasetId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<DatasetRetrieveCsvResponse>> = + retrieveCsv(datasetId, DatasetRetrieveCsvParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/datasets/{dataset_id}/jsonl`, but is + * otherwise the same as [DatasetServiceAsync.retrieveJsonl]. + */ + fun retrieveJsonl( + datasetId: String + ): CompletableFuture<HttpResponseFor<DatasetRetrieveJsonlResponse>> = + retrieveJsonl(datasetId, DatasetRetrieveJsonlParams.none()) + + /** @see retrieveJsonl */ + fun retrieveJsonl( + datasetId: String, + params: DatasetRetrieveJsonlParams = DatasetRetrieveJsonlParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<DatasetRetrieveJsonlResponse>> = + retrieveJsonl(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see retrieveJsonl */ + fun retrieveJsonl( + datasetId: String, + params: DatasetRetrieveJsonlParams = DatasetRetrieveJsonlParams.none(), + ): CompletableFuture<HttpResponseFor<DatasetRetrieveJsonlResponse>> = + retrieveJsonl(datasetId, params, RequestOptions.none()) + + /** @see retrieveJsonl */ + fun retrieveJsonl( + params: DatasetRetrieveJsonlParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<DatasetRetrieveJsonlResponse>> + + /** @see retrieveJsonl */ + fun retrieveJsonl( + params: DatasetRetrieveJsonlParams + ): CompletableFuture<HttpResponseFor<DatasetRetrieveJsonlResponse>> = + retrieveJsonl(params, RequestOptions.none()) + + /** @see retrieveJsonl */ + fun retrieveJsonl( + datasetId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<DatasetRetrieveJsonlResponse>> = + retrieveJsonl(datasetId, DatasetRetrieveJsonlParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/datasets/{dataset_id}/openai`, but is + * otherwise the same as [DatasetServiceAsync.retrieveOpenAI]. + */ + fun retrieveOpenAI( + datasetId: String + ): CompletableFuture<HttpResponseFor<DatasetRetrieveOpenAIResponse>> = + retrieveOpenAI(datasetId, DatasetRetrieveOpenAIParams.none()) + + /** @see retrieveOpenAI */ + fun retrieveOpenAI( + datasetId: String, + params: DatasetRetrieveOpenAIParams = DatasetRetrieveOpenAIParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<DatasetRetrieveOpenAIResponse>> = + retrieveOpenAI(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see retrieveOpenAI */ + fun retrieveOpenAI( + datasetId: String, + params: DatasetRetrieveOpenAIParams = DatasetRetrieveOpenAIParams.none(), + ): CompletableFuture<HttpResponseFor<DatasetRetrieveOpenAIResponse>> = + retrieveOpenAI(datasetId, params, RequestOptions.none()) + + /** @see retrieveOpenAI */ + fun retrieveOpenAI( + params: DatasetRetrieveOpenAIParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<DatasetRetrieveOpenAIResponse>> + + /** @see retrieveOpenAI */ + fun retrieveOpenAI( + params: DatasetRetrieveOpenAIParams + ): CompletableFuture<HttpResponseFor<DatasetRetrieveOpenAIResponse>> = + retrieveOpenAI(params, RequestOptions.none()) + + /** @see retrieveOpenAI */ + fun retrieveOpenAI( + datasetId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<DatasetRetrieveOpenAIResponse>> = + retrieveOpenAI(datasetId, DatasetRetrieveOpenAIParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/datasets/{dataset_id}/openai_ft`, but is + * otherwise the same as [DatasetServiceAsync.retrieveOpenAIFt]. + */ + fun retrieveOpenAIFt( + datasetId: String + ): CompletableFuture<HttpResponseFor<DatasetRetrieveOpenAIFtResponse>> = + retrieveOpenAIFt(datasetId, DatasetRetrieveOpenAIFtParams.none()) + + /** @see retrieveOpenAIFt */ + fun retrieveOpenAIFt( + datasetId: String, + params: DatasetRetrieveOpenAIFtParams = DatasetRetrieveOpenAIFtParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<DatasetRetrieveOpenAIFtResponse>> = + retrieveOpenAIFt(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see retrieveOpenAIFt */ + fun retrieveOpenAIFt( + datasetId: String, + params: DatasetRetrieveOpenAIFtParams = DatasetRetrieveOpenAIFtParams.none(), + ): CompletableFuture<HttpResponseFor<DatasetRetrieveOpenAIFtResponse>> = + retrieveOpenAIFt(datasetId, params, RequestOptions.none()) + + /** @see retrieveOpenAIFt */ + fun retrieveOpenAIFt( + params: DatasetRetrieveOpenAIFtParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<DatasetRetrieveOpenAIFtResponse>> + + /** @see retrieveOpenAIFt */ + fun retrieveOpenAIFt( + params: DatasetRetrieveOpenAIFtParams + ): CompletableFuture<HttpResponseFor<DatasetRetrieveOpenAIFtResponse>> = + retrieveOpenAIFt(params, RequestOptions.none()) + + /** @see retrieveOpenAIFt */ + fun retrieveOpenAIFt( + datasetId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<DatasetRetrieveOpenAIFtResponse>> = + retrieveOpenAIFt(datasetId, DatasetRetrieveOpenAIFtParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/datasets/{dataset_id}/version`, but is + * otherwise the same as [DatasetServiceAsync.retrieveVersion]. + */ + fun retrieveVersion(datasetId: String): CompletableFuture<HttpResponseFor<DatasetVersion>> = + retrieveVersion(datasetId, DatasetRetrieveVersionParams.none()) + + /** @see retrieveVersion */ + fun retrieveVersion( + datasetId: String, + params: DatasetRetrieveVersionParams = DatasetRetrieveVersionParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<DatasetVersion>> = + retrieveVersion(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see retrieveVersion */ + fun retrieveVersion( + datasetId: String, + params: DatasetRetrieveVersionParams = DatasetRetrieveVersionParams.none(), + ): CompletableFuture<HttpResponseFor<DatasetVersion>> = + retrieveVersion(datasetId, params, RequestOptions.none()) + + /** @see retrieveVersion */ + fun retrieveVersion( + params: DatasetRetrieveVersionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<DatasetVersion>> + + /** @see retrieveVersion */ + fun retrieveVersion( + params: DatasetRetrieveVersionParams + ): CompletableFuture<HttpResponseFor<DatasetVersion>> = + retrieveVersion(params, RequestOptions.none()) + + /** @see retrieveVersion */ + fun retrieveVersion( + datasetId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<DatasetVersion>> = + retrieveVersion(datasetId, DatasetRetrieveVersionParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/datasets/{dataset_id}/search`, but is + * otherwise the same as [DatasetServiceAsync.search]. + */ + fun search( + datasetId: String, + params: DatasetSearchParams, + ): CompletableFuture<HttpResponseFor<DatasetSearchResponse>> = + search(datasetId, params, RequestOptions.none()) + + /** @see search */ + fun search( + datasetId: String, + params: DatasetSearchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<DatasetSearchResponse>> = + search(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see search */ + fun search( + params: DatasetSearchParams + ): CompletableFuture<HttpResponseFor<DatasetSearchResponse>> = + search(params, RequestOptions.none()) + + /** @see search */ + fun search( + params: DatasetSearchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<DatasetSearchResponse>> + + /** + * Returns a raw HTTP response for `post /api/v1/datasets/studio_experiment`, but is + * otherwise the same as [DatasetServiceAsync.studioExperiment]. + */ + fun studioExperiment( + params: DatasetStudioExperimentParams + ): CompletableFuture<HttpResponseFor<DatasetStudioExperimentResponse>> = + studioExperiment(params, RequestOptions.none()) + + /** @see studioExperiment */ + fun studioExperiment( + params: DatasetStudioExperimentParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<DatasetStudioExperimentResponse>> + + /** + * Returns a raw HTTP response for `put /api/v1/datasets/{dataset_id}/tags`, but is + * otherwise the same as [DatasetServiceAsync.updateTags]. + */ + fun updateTags( + datasetId: String, + params: DatasetUpdateTagsParams, + ): CompletableFuture<HttpResponseFor<DatasetVersion>> = + updateTags(datasetId, params, RequestOptions.none()) + + /** @see updateTags */ + fun updateTags( + datasetId: String, + params: DatasetUpdateTagsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<DatasetVersion>> = + updateTags(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see updateTags */ + fun updateTags( + params: DatasetUpdateTagsParams + ): CompletableFuture<HttpResponseFor<DatasetVersion>> = + updateTags(params, RequestOptions.none()) + + /** @see updateTags */ + fun updateTags( + params: DatasetUpdateTagsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<DatasetVersion>> + + /** + * Returns a raw HTTP response for `post /api/v1/datasets/upload`, but is otherwise the same + * as [DatasetServiceAsync.upload]. + */ + fun upload(params: DatasetUploadParams): CompletableFuture<HttpResponseFor<Dataset>> = + upload(params, RequestOptions.none()) + + /** @see upload */ + fun upload( + params: DatasetUploadParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<Dataset>> + + /** + * Returns a raw HTTP response for `post /api/v1/datasets/upload-experiment`, but is + * otherwise the same as [DatasetServiceAsync.uploadExperiment]. + */ + fun uploadExperiment( + params: DatasetUploadExperimentParams + ): CompletableFuture<HttpResponseFor<DatasetUploadExperimentResponse>> = + uploadExperiment(params, RequestOptions.none()) + + /** @see uploadExperiment */ + fun uploadExperiment( + params: DatasetUploadExperimentParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<DatasetUploadExperimentResponse>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/DatasetServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/DatasetServiceAsyncImpl.kt new file mode 100644 index 00000000..5d416f3e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/DatasetServiceAsyncImpl.kt @@ -0,0 +1,864 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.multipartFormData +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.datasets.Dataset +import com.langsmith_api.api.models.api.v1.datasets.DatasetCloneParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetCloneResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetCreateParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetDeleteParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetDeleteResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetGenerateParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetGenerateResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetListParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveCsvParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveCsvResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveJsonlParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveJsonlResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveOpenAIFtParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveOpenAIFtResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveOpenAIParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveOpenAIResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveVersionParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetSearchParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetSearchResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetStudioExperimentParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetStudioExperimentResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetUpdateParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetUpdateResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetUpdateTagsParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetUploadExperimentParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetUploadExperimentResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetUploadParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetVersion +import com.langsmith_api.api.services.async.api.v1.datasets.ComparativeServiceAsync +import com.langsmith_api.api.services.async.api.v1.datasets.ComparativeServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.datasets.ExperimentServiceAsync +import com.langsmith_api.api.services.async.api.v1.datasets.ExperimentServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.datasets.GroupServiceAsync +import com.langsmith_api.api.services.async.api.v1.datasets.GroupServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.datasets.IndexServiceAsync +import com.langsmith_api.api.services.async.api.v1.datasets.IndexServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.datasets.PlaygroundExperimentServiceAsync +import com.langsmith_api.api.services.async.api.v1.datasets.PlaygroundExperimentServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.datasets.RunServiceAsync +import com.langsmith_api.api.services.async.api.v1.datasets.RunServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.datasets.ShareServiceAsync +import com.langsmith_api.api.services.async.api.v1.datasets.ShareServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.datasets.SplitServiceAsync +import com.langsmith_api.api.services.async.api.v1.datasets.SplitServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.datasets.VersionServiceAsync +import com.langsmith_api.api.services.async.api.v1.datasets.VersionServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class DatasetServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + DatasetServiceAsync { + + private val withRawResponse: DatasetServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val versions: VersionServiceAsync by lazy { VersionServiceAsyncImpl(clientOptions) } + + private val runs: RunServiceAsync by lazy { RunServiceAsyncImpl(clientOptions) } + + private val group: GroupServiceAsync by lazy { GroupServiceAsyncImpl(clientOptions) } + + private val experiments: ExperimentServiceAsync by lazy { + ExperimentServiceAsyncImpl(clientOptions) + } + + private val share: ShareServiceAsync by lazy { ShareServiceAsyncImpl(clientOptions) } + + private val comparative: ComparativeServiceAsync by lazy { + ComparativeServiceAsyncImpl(clientOptions) + } + + private val splits: SplitServiceAsync by lazy { SplitServiceAsyncImpl(clientOptions) } + + private val index: IndexServiceAsync by lazy { IndexServiceAsyncImpl(clientOptions) } + + private val playgroundExperiment: PlaygroundExperimentServiceAsync by lazy { + PlaygroundExperimentServiceAsyncImpl(clientOptions) + } + + override fun withRawResponse(): DatasetServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): DatasetServiceAsync = + DatasetServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun versions(): VersionServiceAsync = versions + + override fun runs(): RunServiceAsync = runs + + override fun group(): GroupServiceAsync = group + + override fun experiments(): ExperimentServiceAsync = experiments + + override fun share(): ShareServiceAsync = share + + override fun comparative(): ComparativeServiceAsync = comparative + + override fun splits(): SplitServiceAsync = splits + + override fun index(): IndexServiceAsync = index + + override fun playgroundExperiment(): PlaygroundExperimentServiceAsync = playgroundExperiment + + override fun create( + params: DatasetCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<Dataset> = + // post /api/v1/datasets + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun retrieve( + params: DatasetRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<Dataset> = + // get /api/v1/datasets/{dataset_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: DatasetUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<DatasetUpdateResponse> = + // patch /api/v1/datasets/{dataset_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: DatasetListParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<Dataset>> = + // get /api/v1/datasets + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: DatasetDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<DatasetDeleteResponse> = + // delete /api/v1/datasets/{dataset_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + override fun clone( + params: DatasetCloneParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<DatasetCloneResponse>> = + // post /api/v1/datasets/clone + withRawResponse().clone(params, requestOptions).thenApply { it.parse() } + + override fun generate( + params: DatasetGenerateParams, + requestOptions: RequestOptions, + ): CompletableFuture<DatasetGenerateResponse> = + // post /api/v1/datasets/{dataset_id}/generate + withRawResponse().generate(params, requestOptions).thenApply { it.parse() } + + override fun retrieveCsv( + params: DatasetRetrieveCsvParams, + requestOptions: RequestOptions, + ): CompletableFuture<DatasetRetrieveCsvResponse> = + // get /api/v1/datasets/{dataset_id}/csv + withRawResponse().retrieveCsv(params, requestOptions).thenApply { it.parse() } + + override fun retrieveJsonl( + params: DatasetRetrieveJsonlParams, + requestOptions: RequestOptions, + ): CompletableFuture<DatasetRetrieveJsonlResponse> = + // get /api/v1/datasets/{dataset_id}/jsonl + withRawResponse().retrieveJsonl(params, requestOptions).thenApply { it.parse() } + + override fun retrieveOpenAI( + params: DatasetRetrieveOpenAIParams, + requestOptions: RequestOptions, + ): CompletableFuture<DatasetRetrieveOpenAIResponse> = + // get /api/v1/datasets/{dataset_id}/openai + withRawResponse().retrieveOpenAI(params, requestOptions).thenApply { it.parse() } + + override fun retrieveOpenAIFt( + params: DatasetRetrieveOpenAIFtParams, + requestOptions: RequestOptions, + ): CompletableFuture<DatasetRetrieveOpenAIFtResponse> = + // get /api/v1/datasets/{dataset_id}/openai_ft + withRawResponse().retrieveOpenAIFt(params, requestOptions).thenApply { it.parse() } + + override fun retrieveVersion( + params: DatasetRetrieveVersionParams, + requestOptions: RequestOptions, + ): CompletableFuture<DatasetVersion> = + // get /api/v1/datasets/{dataset_id}/version + withRawResponse().retrieveVersion(params, requestOptions).thenApply { it.parse() } + + override fun search( + params: DatasetSearchParams, + requestOptions: RequestOptions, + ): CompletableFuture<DatasetSearchResponse> = + // post /api/v1/datasets/{dataset_id}/search + withRawResponse().search(params, requestOptions).thenApply { it.parse() } + + override fun studioExperiment( + params: DatasetStudioExperimentParams, + requestOptions: RequestOptions, + ): CompletableFuture<DatasetStudioExperimentResponse> = + // post /api/v1/datasets/studio_experiment + withRawResponse().studioExperiment(params, requestOptions).thenApply { it.parse() } + + override fun updateTags( + params: DatasetUpdateTagsParams, + requestOptions: RequestOptions, + ): CompletableFuture<DatasetVersion> = + // put /api/v1/datasets/{dataset_id}/tags + withRawResponse().updateTags(params, requestOptions).thenApply { it.parse() } + + override fun upload( + params: DatasetUploadParams, + requestOptions: RequestOptions, + ): CompletableFuture<Dataset> = + // post /api/v1/datasets/upload + withRawResponse().upload(params, requestOptions).thenApply { it.parse() } + + override fun uploadExperiment( + params: DatasetUploadExperimentParams, + requestOptions: RequestOptions, + ): CompletableFuture<DatasetUploadExperimentResponse> = + // post /api/v1/datasets/upload-experiment + withRawResponse().uploadExperiment(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + DatasetServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val versions: VersionServiceAsync.WithRawResponse by lazy { + VersionServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val runs: RunServiceAsync.WithRawResponse by lazy { + RunServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val group: GroupServiceAsync.WithRawResponse by lazy { + GroupServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val experiments: ExperimentServiceAsync.WithRawResponse by lazy { + ExperimentServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val share: ShareServiceAsync.WithRawResponse by lazy { + ShareServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val comparative: ComparativeServiceAsync.WithRawResponse by lazy { + ComparativeServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val splits: SplitServiceAsync.WithRawResponse by lazy { + SplitServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val index: IndexServiceAsync.WithRawResponse by lazy { + IndexServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val playgroundExperiment: PlaygroundExperimentServiceAsync.WithRawResponse by lazy { + PlaygroundExperimentServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): DatasetServiceAsync.WithRawResponse = + DatasetServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun versions(): VersionServiceAsync.WithRawResponse = versions + + override fun runs(): RunServiceAsync.WithRawResponse = runs + + override fun group(): GroupServiceAsync.WithRawResponse = group + + override fun experiments(): ExperimentServiceAsync.WithRawResponse = experiments + + override fun share(): ShareServiceAsync.WithRawResponse = share + + override fun comparative(): ComparativeServiceAsync.WithRawResponse = comparative + + override fun splits(): SplitServiceAsync.WithRawResponse = splits + + override fun index(): IndexServiceAsync.WithRawResponse = index + + override fun playgroundExperiment(): PlaygroundExperimentServiceAsync.WithRawResponse = + playgroundExperiment + + private val createHandler: Handler<Dataset> = jsonHandler<Dataset>(clientOptions.jsonMapper) + + override fun create( + params: DatasetCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<Dataset>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler<Dataset> = + jsonHandler<Dataset>(clientOptions.jsonMapper) + + override fun retrieve( + params: DatasetRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<Dataset>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler<DatasetUpdateResponse> = + jsonHandler<DatasetUpdateResponse>(clientOptions.jsonMapper) + + override fun update( + params: DatasetUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<DatasetUpdateResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler<List<Dataset>> = + jsonHandler<List<Dataset>>(clientOptions.jsonMapper) + + override fun list( + params: DatasetListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<Dataset>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val deleteHandler: Handler<DatasetDeleteResponse> = + jsonHandler<DatasetDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: DatasetDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<DatasetDeleteResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val cloneHandler: Handler<List<DatasetCloneResponse>> = + jsonHandler<List<DatasetCloneResponse>>(clientOptions.jsonMapper) + + override fun clone( + params: DatasetCloneParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<DatasetCloneResponse>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", "clone") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { cloneHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val generateHandler: Handler<DatasetGenerateResponse> = + jsonHandler<DatasetGenerateResponse>(clientOptions.jsonMapper) + + override fun generate( + params: DatasetGenerateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<DatasetGenerateResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "generate") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { generateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveCsvHandler: Handler<DatasetRetrieveCsvResponse> = + jsonHandler<DatasetRetrieveCsvResponse>(clientOptions.jsonMapper) + + override fun retrieveCsv( + params: DatasetRetrieveCsvParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<DatasetRetrieveCsvResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "csv") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveCsvHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveJsonlHandler: Handler<DatasetRetrieveJsonlResponse> = + jsonHandler<DatasetRetrieveJsonlResponse>(clientOptions.jsonMapper) + + override fun retrieveJsonl( + params: DatasetRetrieveJsonlParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<DatasetRetrieveJsonlResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "jsonl") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveJsonlHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveOpenAIHandler: Handler<DatasetRetrieveOpenAIResponse> = + jsonHandler<DatasetRetrieveOpenAIResponse>(clientOptions.jsonMapper) + + override fun retrieveOpenAI( + params: DatasetRetrieveOpenAIParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<DatasetRetrieveOpenAIResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "openai") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveOpenAIHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveOpenAIFtHandler: Handler<DatasetRetrieveOpenAIFtResponse> = + jsonHandler<DatasetRetrieveOpenAIFtResponse>(clientOptions.jsonMapper) + + override fun retrieveOpenAIFt( + params: DatasetRetrieveOpenAIFtParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<DatasetRetrieveOpenAIFtResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "openai_ft") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveOpenAIFtHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveVersionHandler: Handler<DatasetVersion> = + jsonHandler<DatasetVersion>(clientOptions.jsonMapper) + + override fun retrieveVersion( + params: DatasetRetrieveVersionParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<DatasetVersion>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "version") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveVersionHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val searchHandler: Handler<DatasetSearchResponse> = + jsonHandler<DatasetSearchResponse>(clientOptions.jsonMapper) + + override fun search( + params: DatasetSearchParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<DatasetSearchResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "search") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { searchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val studioExperimentHandler: Handler<DatasetStudioExperimentResponse> = + jsonHandler<DatasetStudioExperimentResponse>(clientOptions.jsonMapper) + + override fun studioExperiment( + params: DatasetStudioExperimentParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<DatasetStudioExperimentResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", "studio_experiment") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { studioExperimentHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateTagsHandler: Handler<DatasetVersion> = + jsonHandler<DatasetVersion>(clientOptions.jsonMapper) + + override fun updateTags( + params: DatasetUpdateTagsParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<DatasetVersion>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "tags") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateTagsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val uploadHandler: Handler<Dataset> = jsonHandler<Dataset>(clientOptions.jsonMapper) + + override fun upload( + params: DatasetUploadParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<Dataset>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", "upload") + .body(multipartFormData(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { uploadHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val uploadExperimentHandler: Handler<DatasetUploadExperimentResponse> = + jsonHandler<DatasetUploadExperimentResponse>(clientOptions.jsonMapper) + + override fun uploadExperiment( + params: DatasetUploadExperimentParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<DatasetUploadExperimentResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", "upload-experiment") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { uploadExperimentHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ExampleServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ExampleServiceAsync.kt new file mode 100644 index 00000000..e0bf7420 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ExampleServiceAsync.kt @@ -0,0 +1,410 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.examples.Example +import com.langsmith_api.api.models.api.v1.examples.ExampleCreateParams +import com.langsmith_api.api.models.api.v1.examples.ExampleDeleteAllParams +import com.langsmith_api.api.models.api.v1.examples.ExampleDeleteAllResponse +import com.langsmith_api.api.models.api.v1.examples.ExampleDeleteParams +import com.langsmith_api.api.models.api.v1.examples.ExampleDeleteResponse +import com.langsmith_api.api.models.api.v1.examples.ExampleListParams +import com.langsmith_api.api.models.api.v1.examples.ExampleRetrieveCountParams +import com.langsmith_api.api.models.api.v1.examples.ExampleRetrieveParams +import com.langsmith_api.api.models.api.v1.examples.ExampleUpdateParams +import com.langsmith_api.api.services.async.api.v1.examples.BulkServiceAsync +import com.langsmith_api.api.services.async.api.v1.examples.ValidateServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface ExampleServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ExampleServiceAsync + + fun bulk(): BulkServiceAsync + + fun validate(): ValidateServiceAsync + + /** Create a new example. */ + fun create(): CompletableFuture<Example> = create(ExampleCreateParams.none()) + + /** @see create */ + fun create( + params: ExampleCreateParams = ExampleCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<Example> + + /** @see create */ + fun create( + params: ExampleCreateParams = ExampleCreateParams.none() + ): CompletableFuture<Example> = create(params, RequestOptions.none()) + + /** @see create */ + fun create(requestOptions: RequestOptions): CompletableFuture<Example> = + create(ExampleCreateParams.none(), requestOptions) + + /** Get a specific example. */ + fun retrieve(exampleId: String): CompletableFuture<Example> = + retrieve(exampleId, ExampleRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + exampleId: String, + params: ExampleRetrieveParams = ExampleRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<Example> = + retrieve(params.toBuilder().exampleId(exampleId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + exampleId: String, + params: ExampleRetrieveParams = ExampleRetrieveParams.none(), + ): CompletableFuture<Example> = retrieve(exampleId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: ExampleRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<Example> + + /** @see retrieve */ + fun retrieve(params: ExampleRetrieveParams): CompletableFuture<Example> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(exampleId: String, requestOptions: RequestOptions): CompletableFuture<Example> = + retrieve(exampleId, ExampleRetrieveParams.none(), requestOptions) + + /** + * Upload examples from a CSV file. + * + * Note: For non-csv upload, please use the POST /v1/platform/datasets/{dataset_id}/examples + * endpoint which provides more efficient upload. + */ + fun update(datasetId: String, params: ExampleUpdateParams): CompletableFuture<List<Example>> = + update(datasetId, params, RequestOptions.none()) + + /** @see update */ + fun update( + datasetId: String, + params: ExampleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<Example>> = + update(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see update */ + fun update(params: ExampleUpdateParams): CompletableFuture<List<Example>> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: ExampleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<Example>> + + /** Get all examples by query params */ + fun list(): CompletableFuture<List<Example>> = list(ExampleListParams.none()) + + /** @see list */ + fun list( + params: ExampleListParams = ExampleListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<Example>> + + /** @see list */ + fun list( + params: ExampleListParams = ExampleListParams.none() + ): CompletableFuture<List<Example>> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture<List<Example>> = + list(ExampleListParams.none(), requestOptions) + + /** Soft delete an example. Only deletes the example in the 'latest' version of the dataset. */ + fun delete(exampleId: String): CompletableFuture<ExampleDeleteResponse> = + delete(exampleId, ExampleDeleteParams.none()) + + /** @see delete */ + fun delete( + exampleId: String, + params: ExampleDeleteParams = ExampleDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ExampleDeleteResponse> = + delete(params.toBuilder().exampleId(exampleId).build(), requestOptions) + + /** @see delete */ + fun delete( + exampleId: String, + params: ExampleDeleteParams = ExampleDeleteParams.none(), + ): CompletableFuture<ExampleDeleteResponse> = delete(exampleId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ExampleDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ExampleDeleteResponse> + + /** @see delete */ + fun delete(params: ExampleDeleteParams): CompletableFuture<ExampleDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + exampleId: String, + requestOptions: RequestOptions, + ): CompletableFuture<ExampleDeleteResponse> = + delete(exampleId, ExampleDeleteParams.none(), requestOptions) + + /** Soft delete examples. Only deletes the examples in the 'latest' version of the dataset. */ + fun deleteAll(params: ExampleDeleteAllParams): CompletableFuture<ExampleDeleteAllResponse> = + deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + params: ExampleDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ExampleDeleteAllResponse> + + /** Count all examples by query params */ + fun retrieveCount(): CompletableFuture<Long> = retrieveCount(ExampleRetrieveCountParams.none()) + + /** @see retrieveCount */ + fun retrieveCount( + params: ExampleRetrieveCountParams = ExampleRetrieveCountParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<Long> + + /** @see retrieveCount */ + fun retrieveCount( + params: ExampleRetrieveCountParams = ExampleRetrieveCountParams.none() + ): CompletableFuture<Long> = retrieveCount(params, RequestOptions.none()) + + /** @see retrieveCount */ + fun retrieveCount(requestOptions: RequestOptions): CompletableFuture<Long> = + retrieveCount(ExampleRetrieveCountParams.none(), requestOptions) + + /** + * A view of [ExampleServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ExampleServiceAsync.WithRawResponse + + fun bulk(): BulkServiceAsync.WithRawResponse + + fun validate(): ValidateServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/examples`, but is otherwise the same as + * [ExampleServiceAsync.create]. + */ + fun create(): CompletableFuture<HttpResponseFor<Example>> = + create(ExampleCreateParams.none()) + + /** @see create */ + fun create( + params: ExampleCreateParams = ExampleCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<Example>> + + /** @see create */ + fun create( + params: ExampleCreateParams = ExampleCreateParams.none() + ): CompletableFuture<HttpResponseFor<Example>> = create(params, RequestOptions.none()) + + /** @see create */ + fun create(requestOptions: RequestOptions): CompletableFuture<HttpResponseFor<Example>> = + create(ExampleCreateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/examples/{example_id}`, but is otherwise the + * same as [ExampleServiceAsync.retrieve]. + */ + fun retrieve(exampleId: String): CompletableFuture<HttpResponseFor<Example>> = + retrieve(exampleId, ExampleRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + exampleId: String, + params: ExampleRetrieveParams = ExampleRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<Example>> = + retrieve(params.toBuilder().exampleId(exampleId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + exampleId: String, + params: ExampleRetrieveParams = ExampleRetrieveParams.none(), + ): CompletableFuture<HttpResponseFor<Example>> = + retrieve(exampleId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: ExampleRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<Example>> + + /** @see retrieve */ + fun retrieve(params: ExampleRetrieveParams): CompletableFuture<HttpResponseFor<Example>> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + exampleId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<Example>> = + retrieve(exampleId, ExampleRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/examples/upload/{dataset_id}`, but is + * otherwise the same as [ExampleServiceAsync.update]. + */ + fun update( + datasetId: String, + params: ExampleUpdateParams, + ): CompletableFuture<HttpResponseFor<List<Example>>> = + update(datasetId, params, RequestOptions.none()) + + /** @see update */ + fun update( + datasetId: String, + params: ExampleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<Example>>> = + update(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see update */ + fun update(params: ExampleUpdateParams): CompletableFuture<HttpResponseFor<List<Example>>> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: ExampleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<Example>>> + + /** + * Returns a raw HTTP response for `get /api/v1/examples`, but is otherwise the same as + * [ExampleServiceAsync.list]. + */ + fun list(): CompletableFuture<HttpResponseFor<List<Example>>> = + list(ExampleListParams.none()) + + /** @see list */ + fun list( + params: ExampleListParams = ExampleListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<Example>>> + + /** @see list */ + fun list( + params: ExampleListParams = ExampleListParams.none() + ): CompletableFuture<HttpResponseFor<List<Example>>> = list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<Example>>> = + list(ExampleListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/examples/{example_id}`, but is otherwise + * the same as [ExampleServiceAsync.delete]. + */ + fun delete(exampleId: String): CompletableFuture<HttpResponseFor<ExampleDeleteResponse>> = + delete(exampleId, ExampleDeleteParams.none()) + + /** @see delete */ + fun delete( + exampleId: String, + params: ExampleDeleteParams = ExampleDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ExampleDeleteResponse>> = + delete(params.toBuilder().exampleId(exampleId).build(), requestOptions) + + /** @see delete */ + fun delete( + exampleId: String, + params: ExampleDeleteParams = ExampleDeleteParams.none(), + ): CompletableFuture<HttpResponseFor<ExampleDeleteResponse>> = + delete(exampleId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ExampleDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ExampleDeleteResponse>> + + /** @see delete */ + fun delete( + params: ExampleDeleteParams + ): CompletableFuture<HttpResponseFor<ExampleDeleteResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + exampleId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ExampleDeleteResponse>> = + delete(exampleId, ExampleDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/examples`, but is otherwise the same as + * [ExampleServiceAsync.deleteAll]. + */ + fun deleteAll( + params: ExampleDeleteAllParams + ): CompletableFuture<HttpResponseFor<ExampleDeleteAllResponse>> = + deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + params: ExampleDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ExampleDeleteAllResponse>> + + /** + * Returns a raw HTTP response for `get /api/v1/examples/count`, but is otherwise the same + * as [ExampleServiceAsync.retrieveCount]. + */ + fun retrieveCount(): CompletableFuture<HttpResponseFor<Long>> = + retrieveCount(ExampleRetrieveCountParams.none()) + + /** @see retrieveCount */ + fun retrieveCount( + params: ExampleRetrieveCountParams = ExampleRetrieveCountParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<Long>> + + /** @see retrieveCount */ + fun retrieveCount( + params: ExampleRetrieveCountParams = ExampleRetrieveCountParams.none() + ): CompletableFuture<HttpResponseFor<Long>> = retrieveCount(params, RequestOptions.none()) + + /** @see retrieveCount */ + fun retrieveCount( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<Long>> = + retrieveCount(ExampleRetrieveCountParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ExampleServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ExampleServiceAsyncImpl.kt new file mode 100644 index 00000000..9aa76027 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ExampleServiceAsyncImpl.kt @@ -0,0 +1,348 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.multipartFormData +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.examples.Example +import com.langsmith_api.api.models.api.v1.examples.ExampleCreateParams +import com.langsmith_api.api.models.api.v1.examples.ExampleDeleteAllParams +import com.langsmith_api.api.models.api.v1.examples.ExampleDeleteAllResponse +import com.langsmith_api.api.models.api.v1.examples.ExampleDeleteParams +import com.langsmith_api.api.models.api.v1.examples.ExampleDeleteResponse +import com.langsmith_api.api.models.api.v1.examples.ExampleListParams +import com.langsmith_api.api.models.api.v1.examples.ExampleRetrieveCountParams +import com.langsmith_api.api.models.api.v1.examples.ExampleRetrieveParams +import com.langsmith_api.api.models.api.v1.examples.ExampleUpdateParams +import com.langsmith_api.api.services.async.api.v1.examples.BulkServiceAsync +import com.langsmith_api.api.services.async.api.v1.examples.BulkServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.examples.ValidateServiceAsync +import com.langsmith_api.api.services.async.api.v1.examples.ValidateServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ExampleServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ExampleServiceAsync { + + private val withRawResponse: ExampleServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val bulk: BulkServiceAsync by lazy { BulkServiceAsyncImpl(clientOptions) } + + private val validate: ValidateServiceAsync by lazy { ValidateServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): ExampleServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): ExampleServiceAsync = + ExampleServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun bulk(): BulkServiceAsync = bulk + + override fun validate(): ValidateServiceAsync = validate + + override fun create( + params: ExampleCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<Example> = + // post /api/v1/examples + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun retrieve( + params: ExampleRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<Example> = + // get /api/v1/examples/{example_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: ExampleUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<Example>> = + // post /api/v1/examples/upload/{dataset_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: ExampleListParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<Example>> = + // get /api/v1/examples + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: ExampleDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<ExampleDeleteResponse> = + // delete /api/v1/examples/{example_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + override fun deleteAll( + params: ExampleDeleteAllParams, + requestOptions: RequestOptions, + ): CompletableFuture<ExampleDeleteAllResponse> = + // delete /api/v1/examples + withRawResponse().deleteAll(params, requestOptions).thenApply { it.parse() } + + override fun retrieveCount( + params: ExampleRetrieveCountParams, + requestOptions: RequestOptions, + ): CompletableFuture<Long> = + // get /api/v1/examples/count + withRawResponse().retrieveCount(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ExampleServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val bulk: BulkServiceAsync.WithRawResponse by lazy { + BulkServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val validate: ValidateServiceAsync.WithRawResponse by lazy { + ValidateServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ExampleServiceAsync.WithRawResponse = + ExampleServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun bulk(): BulkServiceAsync.WithRawResponse = bulk + + override fun validate(): ValidateServiceAsync.WithRawResponse = validate + + private val createHandler: Handler<Example> = jsonHandler<Example>(clientOptions.jsonMapper) + + override fun create( + params: ExampleCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<Example>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "examples") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler<Example> = + jsonHandler<Example>(clientOptions.jsonMapper) + + override fun retrieve( + params: ExampleRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<Example>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("exampleId", params.exampleId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "examples", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler<List<Example>> = + jsonHandler<List<Example>>(clientOptions.jsonMapper) + + override fun update( + params: ExampleUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<Example>>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "examples", "upload", params._pathParam(0)) + .body(multipartFormData(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val listHandler: Handler<List<Example>> = + jsonHandler<List<Example>>(clientOptions.jsonMapper) + + override fun list( + params: ExampleListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<Example>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "examples") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val deleteHandler: Handler<ExampleDeleteResponse> = + jsonHandler<ExampleDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: ExampleDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ExampleDeleteResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("exampleId", params.exampleId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "examples", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val deleteAllHandler: Handler<ExampleDeleteAllResponse> = + jsonHandler<ExampleDeleteAllResponse>(clientOptions.jsonMapper) + + override fun deleteAll( + params: ExampleDeleteAllParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ExampleDeleteAllResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "examples") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteAllHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveCountHandler: Handler<Long> = + jsonHandler<Long>(clientOptions.jsonMapper) + + override fun retrieveCount( + params: ExampleRetrieveCountParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<Long>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "examples", "count") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { retrieveCountHandler.handle(it) } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/FeedbackConfigServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/FeedbackConfigServiceAsync.kt new file mode 100644 index 00000000..c41fe046 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/FeedbackConfigServiceAsync.kt @@ -0,0 +1,152 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfigFeedbackConfigsParams +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfigRetrieveFeedbackConfigsParams +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfigSchema +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfigUpdateFeedbackConfigsParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface FeedbackConfigServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): FeedbackConfigServiceAsync + + /** Create Feedback Config Endpoint */ + fun feedbackConfigs( + params: FeedbackConfigFeedbackConfigsParams + ): CompletableFuture<FeedbackConfigSchema> = feedbackConfigs(params, RequestOptions.none()) + + /** @see feedbackConfigs */ + fun feedbackConfigs( + params: FeedbackConfigFeedbackConfigsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<FeedbackConfigSchema> + + /** List Feedback Configs Endpoint */ + fun retrieveFeedbackConfigs(): CompletableFuture<List<FeedbackConfigSchema>> = + retrieveFeedbackConfigs(FeedbackConfigRetrieveFeedbackConfigsParams.none()) + + /** @see retrieveFeedbackConfigs */ + fun retrieveFeedbackConfigs( + params: FeedbackConfigRetrieveFeedbackConfigsParams = + FeedbackConfigRetrieveFeedbackConfigsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<FeedbackConfigSchema>> + + /** @see retrieveFeedbackConfigs */ + fun retrieveFeedbackConfigs( + params: FeedbackConfigRetrieveFeedbackConfigsParams = + FeedbackConfigRetrieveFeedbackConfigsParams.none() + ): CompletableFuture<List<FeedbackConfigSchema>> = + retrieveFeedbackConfigs(params, RequestOptions.none()) + + /** @see retrieveFeedbackConfigs */ + fun retrieveFeedbackConfigs( + requestOptions: RequestOptions + ): CompletableFuture<List<FeedbackConfigSchema>> = + retrieveFeedbackConfigs(FeedbackConfigRetrieveFeedbackConfigsParams.none(), requestOptions) + + /** Update Feedback Config Endpoint */ + fun updateFeedbackConfigs( + params: FeedbackConfigUpdateFeedbackConfigsParams + ): CompletableFuture<FeedbackConfigSchema> = + updateFeedbackConfigs(params, RequestOptions.none()) + + /** @see updateFeedbackConfigs */ + fun updateFeedbackConfigs( + params: FeedbackConfigUpdateFeedbackConfigsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<FeedbackConfigSchema> + + /** + * A view of [FeedbackConfigServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): FeedbackConfigServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/feedback-configs`, but is otherwise the + * same as [FeedbackConfigServiceAsync.feedbackConfigs]. + */ + fun feedbackConfigs( + params: FeedbackConfigFeedbackConfigsParams + ): CompletableFuture<HttpResponseFor<FeedbackConfigSchema>> = + feedbackConfigs(params, RequestOptions.none()) + + /** @see feedbackConfigs */ + fun feedbackConfigs( + params: FeedbackConfigFeedbackConfigsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<FeedbackConfigSchema>> + + /** + * Returns a raw HTTP response for `get /api/v1/feedback-configs`, but is otherwise the same + * as [FeedbackConfigServiceAsync.retrieveFeedbackConfigs]. + */ + fun retrieveFeedbackConfigs(): + CompletableFuture<HttpResponseFor<List<FeedbackConfigSchema>>> = + retrieveFeedbackConfigs(FeedbackConfigRetrieveFeedbackConfigsParams.none()) + + /** @see retrieveFeedbackConfigs */ + fun retrieveFeedbackConfigs( + params: FeedbackConfigRetrieveFeedbackConfigsParams = + FeedbackConfigRetrieveFeedbackConfigsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<FeedbackConfigSchema>>> + + /** @see retrieveFeedbackConfigs */ + fun retrieveFeedbackConfigs( + params: FeedbackConfigRetrieveFeedbackConfigsParams = + FeedbackConfigRetrieveFeedbackConfigsParams.none() + ): CompletableFuture<HttpResponseFor<List<FeedbackConfigSchema>>> = + retrieveFeedbackConfigs(params, RequestOptions.none()) + + /** @see retrieveFeedbackConfigs */ + fun retrieveFeedbackConfigs( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<FeedbackConfigSchema>>> = + retrieveFeedbackConfigs( + FeedbackConfigRetrieveFeedbackConfigsParams.none(), + requestOptions, + ) + + /** + * Returns a raw HTTP response for `patch /api/v1/feedback-configs`, but is otherwise the + * same as [FeedbackConfigServiceAsync.updateFeedbackConfigs]. + */ + fun updateFeedbackConfigs( + params: FeedbackConfigUpdateFeedbackConfigsParams + ): CompletableFuture<HttpResponseFor<FeedbackConfigSchema>> = + updateFeedbackConfigs(params, RequestOptions.none()) + + /** @see updateFeedbackConfigs */ + fun updateFeedbackConfigs( + params: FeedbackConfigUpdateFeedbackConfigsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<FeedbackConfigSchema>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/FeedbackConfigServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/FeedbackConfigServiceAsyncImpl.kt new file mode 100644 index 00000000..c686f603 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/FeedbackConfigServiceAsyncImpl.kt @@ -0,0 +1,165 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfigFeedbackConfigsParams +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfigRetrieveFeedbackConfigsParams +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfigSchema +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfigUpdateFeedbackConfigsParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class FeedbackConfigServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : FeedbackConfigServiceAsync { + + private val withRawResponse: FeedbackConfigServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): FeedbackConfigServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): FeedbackConfigServiceAsync = + FeedbackConfigServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun feedbackConfigs( + params: FeedbackConfigFeedbackConfigsParams, + requestOptions: RequestOptions, + ): CompletableFuture<FeedbackConfigSchema> = + // post /api/v1/feedback-configs + withRawResponse().feedbackConfigs(params, requestOptions).thenApply { it.parse() } + + override fun retrieveFeedbackConfigs( + params: FeedbackConfigRetrieveFeedbackConfigsParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<FeedbackConfigSchema>> = + // get /api/v1/feedback-configs + withRawResponse().retrieveFeedbackConfigs(params, requestOptions).thenApply { it.parse() } + + override fun updateFeedbackConfigs( + params: FeedbackConfigUpdateFeedbackConfigsParams, + requestOptions: RequestOptions, + ): CompletableFuture<FeedbackConfigSchema> = + // patch /api/v1/feedback-configs + withRawResponse().updateFeedbackConfigs(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + FeedbackConfigServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): FeedbackConfigServiceAsync.WithRawResponse = + FeedbackConfigServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val feedbackConfigsHandler: Handler<FeedbackConfigSchema> = + jsonHandler<FeedbackConfigSchema>(clientOptions.jsonMapper) + + override fun feedbackConfigs( + params: FeedbackConfigFeedbackConfigsParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<FeedbackConfigSchema>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "feedback-configs") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { feedbackConfigsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveFeedbackConfigsHandler: Handler<List<FeedbackConfigSchema>> = + jsonHandler<List<FeedbackConfigSchema>>(clientOptions.jsonMapper) + + override fun retrieveFeedbackConfigs( + params: FeedbackConfigRetrieveFeedbackConfigsParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<FeedbackConfigSchema>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "feedback-configs") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveFeedbackConfigsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val updateFeedbackConfigsHandler: Handler<FeedbackConfigSchema> = + jsonHandler<FeedbackConfigSchema>(clientOptions.jsonMapper) + + override fun updateFeedbackConfigs( + params: FeedbackConfigUpdateFeedbackConfigsParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<FeedbackConfigSchema>> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "feedback-configs") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateFeedbackConfigsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/FeedbackServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/FeedbackServiceAsync.kt new file mode 100644 index 00000000..8658d4fb --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/FeedbackServiceAsync.kt @@ -0,0 +1,442 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.feedback.FeedbackCreateParams +import com.langsmith_api.api.models.api.v1.feedback.FeedbackCreateSchema +import com.langsmith_api.api.models.api.v1.feedback.FeedbackDeleteParams +import com.langsmith_api.api.models.api.v1.feedback.FeedbackDeleteResponse +import com.langsmith_api.api.models.api.v1.feedback.FeedbackEagerParams +import com.langsmith_api.api.models.api.v1.feedback.FeedbackListParams +import com.langsmith_api.api.models.api.v1.feedback.FeedbackRetrieveParams +import com.langsmith_api.api.models.api.v1.feedback.FeedbackSchema +import com.langsmith_api.api.models.api.v1.feedback.FeedbackUpdateParams +import com.langsmith_api.api.services.async.api.v1.feedback.FormulaServiceAsync +import com.langsmith_api.api.services.async.api.v1.feedback.TokenServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface FeedbackServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): FeedbackServiceAsync + + fun formulas(): FormulaServiceAsync + + fun tokens(): TokenServiceAsync + + /** Create a new feedback. */ + fun create(params: FeedbackCreateParams): CompletableFuture<FeedbackSchema> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: FeedbackCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<FeedbackSchema> + + /** @see create */ + fun create( + feedbackCreateSchema: FeedbackCreateSchema, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<FeedbackSchema> = + create( + FeedbackCreateParams.builder().feedbackCreateSchema(feedbackCreateSchema).build(), + requestOptions, + ) + + /** @see create */ + fun create(feedbackCreateSchema: FeedbackCreateSchema): CompletableFuture<FeedbackSchema> = + create(feedbackCreateSchema, RequestOptions.none()) + + /** Get a specific feedback. */ + fun retrieve(feedbackId: String): CompletableFuture<FeedbackSchema> = + retrieve(feedbackId, FeedbackRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + feedbackId: String, + params: FeedbackRetrieveParams = FeedbackRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<FeedbackSchema> = + retrieve(params.toBuilder().feedbackId(feedbackId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + feedbackId: String, + params: FeedbackRetrieveParams = FeedbackRetrieveParams.none(), + ): CompletableFuture<FeedbackSchema> = retrieve(feedbackId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: FeedbackRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<FeedbackSchema> + + /** @see retrieve */ + fun retrieve(params: FeedbackRetrieveParams): CompletableFuture<FeedbackSchema> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + feedbackId: String, + requestOptions: RequestOptions, + ): CompletableFuture<FeedbackSchema> = + retrieve(feedbackId, FeedbackRetrieveParams.none(), requestOptions) + + /** Replace an existing feedback entry with a new, modified entry. */ + fun update(feedbackId: String): CompletableFuture<FeedbackSchema> = + update(feedbackId, FeedbackUpdateParams.none()) + + /** @see update */ + fun update( + feedbackId: String, + params: FeedbackUpdateParams = FeedbackUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<FeedbackSchema> = + update(params.toBuilder().feedbackId(feedbackId).build(), requestOptions) + + /** @see update */ + fun update( + feedbackId: String, + params: FeedbackUpdateParams = FeedbackUpdateParams.none(), + ): CompletableFuture<FeedbackSchema> = update(feedbackId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: FeedbackUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<FeedbackSchema> + + /** @see update */ + fun update(params: FeedbackUpdateParams): CompletableFuture<FeedbackSchema> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + feedbackId: String, + requestOptions: RequestOptions, + ): CompletableFuture<FeedbackSchema> = + update(feedbackId, FeedbackUpdateParams.none(), requestOptions) + + /** List all Feedback by query params. */ + fun list(): CompletableFuture<List<FeedbackSchema>> = list(FeedbackListParams.none()) + + /** @see list */ + fun list( + params: FeedbackListParams = FeedbackListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<FeedbackSchema>> + + /** @see list */ + fun list( + params: FeedbackListParams = FeedbackListParams.none() + ): CompletableFuture<List<FeedbackSchema>> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture<List<FeedbackSchema>> = + list(FeedbackListParams.none(), requestOptions) + + /** Delete a feedback. */ + fun delete(feedbackId: String): CompletableFuture<FeedbackDeleteResponse> = + delete(feedbackId, FeedbackDeleteParams.none()) + + /** @see delete */ + fun delete( + feedbackId: String, + params: FeedbackDeleteParams = FeedbackDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<FeedbackDeleteResponse> = + delete(params.toBuilder().feedbackId(feedbackId).build(), requestOptions) + + /** @see delete */ + fun delete( + feedbackId: String, + params: FeedbackDeleteParams = FeedbackDeleteParams.none(), + ): CompletableFuture<FeedbackDeleteResponse> = delete(feedbackId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: FeedbackDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<FeedbackDeleteResponse> + + /** @see delete */ + fun delete(params: FeedbackDeleteParams): CompletableFuture<FeedbackDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + feedbackId: String, + requestOptions: RequestOptions, + ): CompletableFuture<FeedbackDeleteResponse> = + delete(feedbackId, FeedbackDeleteParams.none(), requestOptions) + + /** + * Create a new feedback. + * + * This method is invoked under the assumption that the run is already visible in the app, thus + * already present in DB + */ + fun eager(params: FeedbackEagerParams): CompletableFuture<FeedbackSchema> = + eager(params, RequestOptions.none()) + + /** @see eager */ + fun eager( + params: FeedbackEagerParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<FeedbackSchema> + + /** @see eager */ + fun eager( + feedbackCreateSchema: FeedbackCreateSchema, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<FeedbackSchema> = + eager( + FeedbackEagerParams.builder().feedbackCreateSchema(feedbackCreateSchema).build(), + requestOptions, + ) + + /** @see eager */ + fun eager(feedbackCreateSchema: FeedbackCreateSchema): CompletableFuture<FeedbackSchema> = + eager(feedbackCreateSchema, RequestOptions.none()) + + /** + * A view of [FeedbackServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): FeedbackServiceAsync.WithRawResponse + + fun formulas(): FormulaServiceAsync.WithRawResponse + + fun tokens(): TokenServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/feedback`, but is otherwise the same as + * [FeedbackServiceAsync.create]. + */ + fun create( + params: FeedbackCreateParams + ): CompletableFuture<HttpResponseFor<FeedbackSchema>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: FeedbackCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<FeedbackSchema>> + + /** @see create */ + fun create( + feedbackCreateSchema: FeedbackCreateSchema, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<FeedbackSchema>> = + create( + FeedbackCreateParams.builder().feedbackCreateSchema(feedbackCreateSchema).build(), + requestOptions, + ) + + /** @see create */ + fun create( + feedbackCreateSchema: FeedbackCreateSchema + ): CompletableFuture<HttpResponseFor<FeedbackSchema>> = + create(feedbackCreateSchema, RequestOptions.none()) + + /** + * Returns a raw HTTP response for `get /api/v1/feedback/{feedback_id}`, but is otherwise + * the same as [FeedbackServiceAsync.retrieve]. + */ + fun retrieve(feedbackId: String): CompletableFuture<HttpResponseFor<FeedbackSchema>> = + retrieve(feedbackId, FeedbackRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + feedbackId: String, + params: FeedbackRetrieveParams = FeedbackRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<FeedbackSchema>> = + retrieve(params.toBuilder().feedbackId(feedbackId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + feedbackId: String, + params: FeedbackRetrieveParams = FeedbackRetrieveParams.none(), + ): CompletableFuture<HttpResponseFor<FeedbackSchema>> = + retrieve(feedbackId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: FeedbackRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<FeedbackSchema>> + + /** @see retrieve */ + fun retrieve( + params: FeedbackRetrieveParams + ): CompletableFuture<HttpResponseFor<FeedbackSchema>> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + feedbackId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<FeedbackSchema>> = + retrieve(feedbackId, FeedbackRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `patch /api/v1/feedback/{feedback_id}`, but is otherwise + * the same as [FeedbackServiceAsync.update]. + */ + fun update(feedbackId: String): CompletableFuture<HttpResponseFor<FeedbackSchema>> = + update(feedbackId, FeedbackUpdateParams.none()) + + /** @see update */ + fun update( + feedbackId: String, + params: FeedbackUpdateParams = FeedbackUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<FeedbackSchema>> = + update(params.toBuilder().feedbackId(feedbackId).build(), requestOptions) + + /** @see update */ + fun update( + feedbackId: String, + params: FeedbackUpdateParams = FeedbackUpdateParams.none(), + ): CompletableFuture<HttpResponseFor<FeedbackSchema>> = + update(feedbackId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: FeedbackUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<FeedbackSchema>> + + /** @see update */ + fun update( + params: FeedbackUpdateParams + ): CompletableFuture<HttpResponseFor<FeedbackSchema>> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + feedbackId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<FeedbackSchema>> = + update(feedbackId, FeedbackUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/feedback`, but is otherwise the same as + * [FeedbackServiceAsync.list]. + */ + fun list(): CompletableFuture<HttpResponseFor<List<FeedbackSchema>>> = + list(FeedbackListParams.none()) + + /** @see list */ + fun list( + params: FeedbackListParams = FeedbackListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<FeedbackSchema>>> + + /** @see list */ + fun list( + params: FeedbackListParams = FeedbackListParams.none() + ): CompletableFuture<HttpResponseFor<List<FeedbackSchema>>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<FeedbackSchema>>> = + list(FeedbackListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/feedback/{feedback_id}`, but is otherwise + * the same as [FeedbackServiceAsync.delete]. + */ + fun delete(feedbackId: String): CompletableFuture<HttpResponseFor<FeedbackDeleteResponse>> = + delete(feedbackId, FeedbackDeleteParams.none()) + + /** @see delete */ + fun delete( + feedbackId: String, + params: FeedbackDeleteParams = FeedbackDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<FeedbackDeleteResponse>> = + delete(params.toBuilder().feedbackId(feedbackId).build(), requestOptions) + + /** @see delete */ + fun delete( + feedbackId: String, + params: FeedbackDeleteParams = FeedbackDeleteParams.none(), + ): CompletableFuture<HttpResponseFor<FeedbackDeleteResponse>> = + delete(feedbackId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: FeedbackDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<FeedbackDeleteResponse>> + + /** @see delete */ + fun delete( + params: FeedbackDeleteParams + ): CompletableFuture<HttpResponseFor<FeedbackDeleteResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + feedbackId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<FeedbackDeleteResponse>> = + delete(feedbackId, FeedbackDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/feedback/eager`, but is otherwise the same + * as [FeedbackServiceAsync.eager]. + */ + fun eager(params: FeedbackEagerParams): CompletableFuture<HttpResponseFor<FeedbackSchema>> = + eager(params, RequestOptions.none()) + + /** @see eager */ + fun eager( + params: FeedbackEagerParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<FeedbackSchema>> + + /** @see eager */ + fun eager( + feedbackCreateSchema: FeedbackCreateSchema, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<FeedbackSchema>> = + eager( + FeedbackEagerParams.builder().feedbackCreateSchema(feedbackCreateSchema).build(), + requestOptions, + ) + + /** @see eager */ + fun eager( + feedbackCreateSchema: FeedbackCreateSchema + ): CompletableFuture<HttpResponseFor<FeedbackSchema>> = + eager(feedbackCreateSchema, RequestOptions.none()) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/FeedbackServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/FeedbackServiceAsyncImpl.kt new file mode 100644 index 00000000..ebff68bc --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/FeedbackServiceAsyncImpl.kt @@ -0,0 +1,315 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.feedback.FeedbackCreateParams +import com.langsmith_api.api.models.api.v1.feedback.FeedbackDeleteParams +import com.langsmith_api.api.models.api.v1.feedback.FeedbackDeleteResponse +import com.langsmith_api.api.models.api.v1.feedback.FeedbackEagerParams +import com.langsmith_api.api.models.api.v1.feedback.FeedbackListParams +import com.langsmith_api.api.models.api.v1.feedback.FeedbackRetrieveParams +import com.langsmith_api.api.models.api.v1.feedback.FeedbackSchema +import com.langsmith_api.api.models.api.v1.feedback.FeedbackUpdateParams +import com.langsmith_api.api.services.async.api.v1.feedback.FormulaServiceAsync +import com.langsmith_api.api.services.async.api.v1.feedback.FormulaServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.feedback.TokenServiceAsync +import com.langsmith_api.api.services.async.api.v1.feedback.TokenServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class FeedbackServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + FeedbackServiceAsync { + + private val withRawResponse: FeedbackServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val formulas: FormulaServiceAsync by lazy { FormulaServiceAsyncImpl(clientOptions) } + + private val tokens: TokenServiceAsync by lazy { TokenServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): FeedbackServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): FeedbackServiceAsync = + FeedbackServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun formulas(): FormulaServiceAsync = formulas + + override fun tokens(): TokenServiceAsync = tokens + + override fun create( + params: FeedbackCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<FeedbackSchema> = + // post /api/v1/feedback + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun retrieve( + params: FeedbackRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<FeedbackSchema> = + // get /api/v1/feedback/{feedback_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: FeedbackUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<FeedbackSchema> = + // patch /api/v1/feedback/{feedback_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: FeedbackListParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<FeedbackSchema>> = + // get /api/v1/feedback + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: FeedbackDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<FeedbackDeleteResponse> = + // delete /api/v1/feedback/{feedback_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + override fun eager( + params: FeedbackEagerParams, + requestOptions: RequestOptions, + ): CompletableFuture<FeedbackSchema> = + // post /api/v1/feedback/eager + withRawResponse().eager(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + FeedbackServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val formulas: FormulaServiceAsync.WithRawResponse by lazy { + FormulaServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val tokens: TokenServiceAsync.WithRawResponse by lazy { + TokenServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): FeedbackServiceAsync.WithRawResponse = + FeedbackServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun formulas(): FormulaServiceAsync.WithRawResponse = formulas + + override fun tokens(): TokenServiceAsync.WithRawResponse = tokens + + private val createHandler: Handler<FeedbackSchema> = + jsonHandler<FeedbackSchema>(clientOptions.jsonMapper) + + override fun create( + params: FeedbackCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<FeedbackSchema>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "feedback") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler<FeedbackSchema> = + jsonHandler<FeedbackSchema>(clientOptions.jsonMapper) + + override fun retrieve( + params: FeedbackRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<FeedbackSchema>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("feedbackId", params.feedbackId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "feedback", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler<FeedbackSchema> = + jsonHandler<FeedbackSchema>(clientOptions.jsonMapper) + + override fun update( + params: FeedbackUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<FeedbackSchema>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("feedbackId", params.feedbackId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "feedback", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler<List<FeedbackSchema>> = + jsonHandler<List<FeedbackSchema>>(clientOptions.jsonMapper) + + override fun list( + params: FeedbackListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<FeedbackSchema>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "feedback") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val deleteHandler: Handler<FeedbackDeleteResponse> = + jsonHandler<FeedbackDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: FeedbackDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<FeedbackDeleteResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("feedbackId", params.feedbackId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "feedback", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val eagerHandler: Handler<FeedbackSchema> = + jsonHandler<FeedbackSchema>(clientOptions.jsonMapper) + + override fun eager( + params: FeedbackEagerParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<FeedbackSchema>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "feedback", "eager") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { eagerHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/InfoServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/InfoServiceAsync.kt new file mode 100644 index 00000000..6d506302 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/InfoServiceAsync.kt @@ -0,0 +1,127 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.info.InfoListParams +import com.langsmith_api.api.models.api.v1.info.InfoListResponse +import com.langsmith_api.api.models.api.v1.info.InfoRetrieveHealthParams +import com.langsmith_api.api.models.api.v1.info.InfoRetrieveHealthResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface InfoServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): InfoServiceAsync + + /** Get information about the current deployment of LangSmith. */ + fun list(): CompletableFuture<InfoListResponse> = list(InfoListParams.none()) + + /** @see list */ + fun list( + params: InfoListParams = InfoListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<InfoListResponse> + + /** @see list */ + fun list(params: InfoListParams = InfoListParams.none()): CompletableFuture<InfoListResponse> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture<InfoListResponse> = + list(InfoListParams.none(), requestOptions) + + /** Get health information about the current deployment of LangSmith. */ + fun retrieveHealth(): CompletableFuture<InfoRetrieveHealthResponse> = + retrieveHealth(InfoRetrieveHealthParams.none()) + + /** @see retrieveHealth */ + fun retrieveHealth( + params: InfoRetrieveHealthParams = InfoRetrieveHealthParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<InfoRetrieveHealthResponse> + + /** @see retrieveHealth */ + fun retrieveHealth( + params: InfoRetrieveHealthParams = InfoRetrieveHealthParams.none() + ): CompletableFuture<InfoRetrieveHealthResponse> = retrieveHealth(params, RequestOptions.none()) + + /** @see retrieveHealth */ + fun retrieveHealth( + requestOptions: RequestOptions + ): CompletableFuture<InfoRetrieveHealthResponse> = + retrieveHealth(InfoRetrieveHealthParams.none(), requestOptions) + + /** A view of [InfoServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): InfoServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/info`, but is otherwise the same as + * [InfoServiceAsync.list]. + */ + fun list(): CompletableFuture<HttpResponseFor<InfoListResponse>> = + list(InfoListParams.none()) + + /** @see list */ + fun list( + params: InfoListParams = InfoListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<InfoListResponse>> + + /** @see list */ + fun list( + params: InfoListParams = InfoListParams.none() + ): CompletableFuture<HttpResponseFor<InfoListResponse>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<InfoListResponse>> = + list(InfoListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/info/health`, but is otherwise the same as + * [InfoServiceAsync.retrieveHealth]. + */ + fun retrieveHealth(): CompletableFuture<HttpResponseFor<InfoRetrieveHealthResponse>> = + retrieveHealth(InfoRetrieveHealthParams.none()) + + /** @see retrieveHealth */ + fun retrieveHealth( + params: InfoRetrieveHealthParams = InfoRetrieveHealthParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<InfoRetrieveHealthResponse>> + + /** @see retrieveHealth */ + fun retrieveHealth( + params: InfoRetrieveHealthParams = InfoRetrieveHealthParams.none() + ): CompletableFuture<HttpResponseFor<InfoRetrieveHealthResponse>> = + retrieveHealth(params, RequestOptions.none()) + + /** @see retrieveHealth */ + fun retrieveHealth( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<InfoRetrieveHealthResponse>> = + retrieveHealth(InfoRetrieveHealthParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/InfoServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/InfoServiceAsyncImpl.kt new file mode 100644 index 00000000..23c72f18 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/InfoServiceAsyncImpl.kt @@ -0,0 +1,123 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.info.InfoListParams +import com.langsmith_api.api.models.api.v1.info.InfoListResponse +import com.langsmith_api.api.models.api.v1.info.InfoRetrieveHealthParams +import com.langsmith_api.api.models.api.v1.info.InfoRetrieveHealthResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class InfoServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + InfoServiceAsync { + + private val withRawResponse: InfoServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): InfoServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): InfoServiceAsync = + InfoServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: InfoListParams, + requestOptions: RequestOptions, + ): CompletableFuture<InfoListResponse> = + // get /api/v1/info + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun retrieveHealth( + params: InfoRetrieveHealthParams, + requestOptions: RequestOptions, + ): CompletableFuture<InfoRetrieveHealthResponse> = + // get /api/v1/info/health + withRawResponse().retrieveHealth(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + InfoServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): InfoServiceAsync.WithRawResponse = + InfoServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler<InfoListResponse> = + jsonHandler<InfoListResponse>(clientOptions.jsonMapper) + + override fun list( + params: InfoListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<InfoListResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "info") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHealthHandler: Handler<InfoRetrieveHealthResponse> = + jsonHandler<InfoRetrieveHealthResponse>(clientOptions.jsonMapper) + + override fun retrieveHealth( + params: InfoRetrieveHealthParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<InfoRetrieveHealthResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "info", "health") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHealthHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/MeServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/MeServiceAsync.kt new file mode 100644 index 00000000..845c5fb6 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/MeServiceAsync.kt @@ -0,0 +1,85 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.me.MeRetrieveLsUserIdParams +import com.langsmith_api.api.services.async.api.v1.me.OnboardingStateServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface MeServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): MeServiceAsync + + fun onboardingState(): OnboardingStateServiceAsync + + /** Get the LangSmith user ID for the current user. */ + fun retrieveLsUserId(): CompletableFuture<String> = + retrieveLsUserId(MeRetrieveLsUserIdParams.none()) + + /** @see retrieveLsUserId */ + fun retrieveLsUserId( + params: MeRetrieveLsUserIdParams = MeRetrieveLsUserIdParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<String> + + /** @see retrieveLsUserId */ + fun retrieveLsUserId( + params: MeRetrieveLsUserIdParams = MeRetrieveLsUserIdParams.none() + ): CompletableFuture<String> = retrieveLsUserId(params, RequestOptions.none()) + + /** @see retrieveLsUserId */ + fun retrieveLsUserId(requestOptions: RequestOptions): CompletableFuture<String> = + retrieveLsUserId(MeRetrieveLsUserIdParams.none(), requestOptions) + + /** A view of [MeServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): MeServiceAsync.WithRawResponse + + fun onboardingState(): OnboardingStateServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/me/ls_user_id`, but is otherwise the same as + * [MeServiceAsync.retrieveLsUserId]. + */ + fun retrieveLsUserId(): CompletableFuture<HttpResponseFor<String>> = + retrieveLsUserId(MeRetrieveLsUserIdParams.none()) + + /** @see retrieveLsUserId */ + fun retrieveLsUserId( + params: MeRetrieveLsUserIdParams = MeRetrieveLsUserIdParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<String>> + + /** @see retrieveLsUserId */ + fun retrieveLsUserId( + params: MeRetrieveLsUserIdParams = MeRetrieveLsUserIdParams.none() + ): CompletableFuture<HttpResponseFor<String>> = + retrieveLsUserId(params, RequestOptions.none()) + + /** @see retrieveLsUserId */ + fun retrieveLsUserId( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<String>> = + retrieveLsUserId(MeRetrieveLsUserIdParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/MeServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/MeServiceAsyncImpl.kt new file mode 100644 index 00000000..25159403 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/MeServiceAsyncImpl.kt @@ -0,0 +1,91 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.stringHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.me.MeRetrieveLsUserIdParams +import com.langsmith_api.api.services.async.api.v1.me.OnboardingStateServiceAsync +import com.langsmith_api.api.services.async.api.v1.me.OnboardingStateServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class MeServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + MeServiceAsync { + + private val withRawResponse: MeServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val onboardingState: OnboardingStateServiceAsync by lazy { + OnboardingStateServiceAsyncImpl(clientOptions) + } + + override fun withRawResponse(): MeServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): MeServiceAsync = + MeServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun onboardingState(): OnboardingStateServiceAsync = onboardingState + + override fun retrieveLsUserId( + params: MeRetrieveLsUserIdParams, + requestOptions: RequestOptions, + ): CompletableFuture<String> = + // get /api/v1/me/ls_user_id + withRawResponse().retrieveLsUserId(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + MeServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val onboardingState: OnboardingStateServiceAsync.WithRawResponse by lazy { + OnboardingStateServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): MeServiceAsync.WithRawResponse = + MeServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun onboardingState(): OnboardingStateServiceAsync.WithRawResponse = + onboardingState + + private val retrieveLsUserIdHandler: Handler<String> = stringHandler() + + override fun retrieveLsUserId( + params: MeRetrieveLsUserIdParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<String>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "me", "ls_user_id") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { retrieveLsUserIdHandler.handle(it) } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ModelPriceMapServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ModelPriceMapServiceAsync.kt new file mode 100644 index 00000000..a781173b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ModelPriceMapServiceAsync.kt @@ -0,0 +1,257 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.modelpricemap.ModelPriceMapDeleteParams +import com.langsmith_api.api.models.api.v1.modelpricemap.ModelPriceMapDeleteResponse +import com.langsmith_api.api.models.api.v1.modelpricemap.ModelPriceMapModelPriceMapParams +import com.langsmith_api.api.models.api.v1.modelpricemap.ModelPriceMapModelPriceMapResponse +import com.langsmith_api.api.models.api.v1.modelpricemap.ModelPriceMapRetrieveModelPriceMapParams +import com.langsmith_api.api.models.api.v1.modelpricemap.ModelPriceMapRetrieveModelPriceMapResponse +import com.langsmith_api.api.models.api.v1.modelpricemap.ModelPriceMapUpdateParams +import com.langsmith_api.api.models.api.v1.modelpricemap.ModelPriceMapUpdateResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface ModelPriceMapServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ModelPriceMapServiceAsync + + /** Update Model Price */ + fun update( + id: String, + params: ModelPriceMapUpdateParams, + ): CompletableFuture<ModelPriceMapUpdateResponse> = update(id, params, RequestOptions.none()) + + /** @see update */ + fun update( + id: String, + params: ModelPriceMapUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ModelPriceMapUpdateResponse> = + update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + fun update(params: ModelPriceMapUpdateParams): CompletableFuture<ModelPriceMapUpdateResponse> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: ModelPriceMapUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ModelPriceMapUpdateResponse> + + /** Delete Model Price */ + fun delete(id: String): CompletableFuture<ModelPriceMapDeleteResponse> = + delete(id, ModelPriceMapDeleteParams.none()) + + /** @see delete */ + fun delete( + id: String, + params: ModelPriceMapDeleteParams = ModelPriceMapDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ModelPriceMapDeleteResponse> = + delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + fun delete( + id: String, + params: ModelPriceMapDeleteParams = ModelPriceMapDeleteParams.none(), + ): CompletableFuture<ModelPriceMapDeleteResponse> = delete(id, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ModelPriceMapDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ModelPriceMapDeleteResponse> + + /** @see delete */ + fun delete(params: ModelPriceMapDeleteParams): CompletableFuture<ModelPriceMapDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture<ModelPriceMapDeleteResponse> = + delete(id, ModelPriceMapDeleteParams.none(), requestOptions) + + /** Create New Model Price */ + fun modelPriceMap( + params: ModelPriceMapModelPriceMapParams + ): CompletableFuture<ModelPriceMapModelPriceMapResponse> = + modelPriceMap(params, RequestOptions.none()) + + /** @see modelPriceMap */ + fun modelPriceMap( + params: ModelPriceMapModelPriceMapParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ModelPriceMapModelPriceMapResponse> + + /** Read Model Price Map */ + fun retrieveModelPriceMap(): CompletableFuture<ModelPriceMapRetrieveModelPriceMapResponse> = + retrieveModelPriceMap(ModelPriceMapRetrieveModelPriceMapParams.none()) + + /** @see retrieveModelPriceMap */ + fun retrieveModelPriceMap( + params: ModelPriceMapRetrieveModelPriceMapParams = + ModelPriceMapRetrieveModelPriceMapParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ModelPriceMapRetrieveModelPriceMapResponse> + + /** @see retrieveModelPriceMap */ + fun retrieveModelPriceMap( + params: ModelPriceMapRetrieveModelPriceMapParams = + ModelPriceMapRetrieveModelPriceMapParams.none() + ): CompletableFuture<ModelPriceMapRetrieveModelPriceMapResponse> = + retrieveModelPriceMap(params, RequestOptions.none()) + + /** @see retrieveModelPriceMap */ + fun retrieveModelPriceMap( + requestOptions: RequestOptions + ): CompletableFuture<ModelPriceMapRetrieveModelPriceMapResponse> = + retrieveModelPriceMap(ModelPriceMapRetrieveModelPriceMapParams.none(), requestOptions) + + /** + * A view of [ModelPriceMapServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ModelPriceMapServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `put /api/v1/model-price-map/{id}`, but is otherwise the + * same as [ModelPriceMapServiceAsync.update]. + */ + fun update( + id: String, + params: ModelPriceMapUpdateParams, + ): CompletableFuture<HttpResponseFor<ModelPriceMapUpdateResponse>> = + update(id, params, RequestOptions.none()) + + /** @see update */ + fun update( + id: String, + params: ModelPriceMapUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ModelPriceMapUpdateResponse>> = + update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + fun update( + params: ModelPriceMapUpdateParams + ): CompletableFuture<HttpResponseFor<ModelPriceMapUpdateResponse>> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: ModelPriceMapUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ModelPriceMapUpdateResponse>> + + /** + * Returns a raw HTTP response for `delete /api/v1/model-price-map/{id}`, but is otherwise + * the same as [ModelPriceMapServiceAsync.delete]. + */ + fun delete(id: String): CompletableFuture<HttpResponseFor<ModelPriceMapDeleteResponse>> = + delete(id, ModelPriceMapDeleteParams.none()) + + /** @see delete */ + fun delete( + id: String, + params: ModelPriceMapDeleteParams = ModelPriceMapDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ModelPriceMapDeleteResponse>> = + delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + fun delete( + id: String, + params: ModelPriceMapDeleteParams = ModelPriceMapDeleteParams.none(), + ): CompletableFuture<HttpResponseFor<ModelPriceMapDeleteResponse>> = + delete(id, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ModelPriceMapDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ModelPriceMapDeleteResponse>> + + /** @see delete */ + fun delete( + params: ModelPriceMapDeleteParams + ): CompletableFuture<HttpResponseFor<ModelPriceMapDeleteResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ModelPriceMapDeleteResponse>> = + delete(id, ModelPriceMapDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/model-price-map`, but is otherwise the same + * as [ModelPriceMapServiceAsync.modelPriceMap]. + */ + fun modelPriceMap( + params: ModelPriceMapModelPriceMapParams + ): CompletableFuture<HttpResponseFor<ModelPriceMapModelPriceMapResponse>> = + modelPriceMap(params, RequestOptions.none()) + + /** @see modelPriceMap */ + fun modelPriceMap( + params: ModelPriceMapModelPriceMapParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ModelPriceMapModelPriceMapResponse>> + + /** + * Returns a raw HTTP response for `get /api/v1/model-price-map`, but is otherwise the same + * as [ModelPriceMapServiceAsync.retrieveModelPriceMap]. + */ + fun retrieveModelPriceMap(): + CompletableFuture<HttpResponseFor<ModelPriceMapRetrieveModelPriceMapResponse>> = + retrieveModelPriceMap(ModelPriceMapRetrieveModelPriceMapParams.none()) + + /** @see retrieveModelPriceMap */ + fun retrieveModelPriceMap( + params: ModelPriceMapRetrieveModelPriceMapParams = + ModelPriceMapRetrieveModelPriceMapParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ModelPriceMapRetrieveModelPriceMapResponse>> + + /** @see retrieveModelPriceMap */ + fun retrieveModelPriceMap( + params: ModelPriceMapRetrieveModelPriceMapParams = + ModelPriceMapRetrieveModelPriceMapParams.none() + ): CompletableFuture<HttpResponseFor<ModelPriceMapRetrieveModelPriceMapResponse>> = + retrieveModelPriceMap(params, RequestOptions.none()) + + /** @see retrieveModelPriceMap */ + fun retrieveModelPriceMap( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<ModelPriceMapRetrieveModelPriceMapResponse>> = + retrieveModelPriceMap(ModelPriceMapRetrieveModelPriceMapParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ModelPriceMapServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ModelPriceMapServiceAsyncImpl.kt new file mode 100644 index 00000000..89f29d39 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ModelPriceMapServiceAsyncImpl.kt @@ -0,0 +1,214 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.modelpricemap.ModelPriceMapDeleteParams +import com.langsmith_api.api.models.api.v1.modelpricemap.ModelPriceMapDeleteResponse +import com.langsmith_api.api.models.api.v1.modelpricemap.ModelPriceMapModelPriceMapParams +import com.langsmith_api.api.models.api.v1.modelpricemap.ModelPriceMapModelPriceMapResponse +import com.langsmith_api.api.models.api.v1.modelpricemap.ModelPriceMapRetrieveModelPriceMapParams +import com.langsmith_api.api.models.api.v1.modelpricemap.ModelPriceMapRetrieveModelPriceMapResponse +import com.langsmith_api.api.models.api.v1.modelpricemap.ModelPriceMapUpdateParams +import com.langsmith_api.api.models.api.v1.modelpricemap.ModelPriceMapUpdateResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ModelPriceMapServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ModelPriceMapServiceAsync { + + private val withRawResponse: ModelPriceMapServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ModelPriceMapServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): ModelPriceMapServiceAsync = + ModelPriceMapServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun update( + params: ModelPriceMapUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<ModelPriceMapUpdateResponse> = + // put /api/v1/model-price-map/{id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: ModelPriceMapDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<ModelPriceMapDeleteResponse> = + // delete /api/v1/model-price-map/{id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + override fun modelPriceMap( + params: ModelPriceMapModelPriceMapParams, + requestOptions: RequestOptions, + ): CompletableFuture<ModelPriceMapModelPriceMapResponse> = + // post /api/v1/model-price-map + withRawResponse().modelPriceMap(params, requestOptions).thenApply { it.parse() } + + override fun retrieveModelPriceMap( + params: ModelPriceMapRetrieveModelPriceMapParams, + requestOptions: RequestOptions, + ): CompletableFuture<ModelPriceMapRetrieveModelPriceMapResponse> = + // get /api/v1/model-price-map + withRawResponse().retrieveModelPriceMap(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ModelPriceMapServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ModelPriceMapServiceAsync.WithRawResponse = + ModelPriceMapServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val updateHandler: Handler<ModelPriceMapUpdateResponse> = + jsonHandler<ModelPriceMapUpdateResponse>(clientOptions.jsonMapper) + + override fun update( + params: ModelPriceMapUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ModelPriceMapUpdateResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "model-price-map", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val deleteHandler: Handler<ModelPriceMapDeleteResponse> = + jsonHandler<ModelPriceMapDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: ModelPriceMapDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ModelPriceMapDeleteResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "model-price-map", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val modelPriceMapHandler: Handler<ModelPriceMapModelPriceMapResponse> = + jsonHandler<ModelPriceMapModelPriceMapResponse>(clientOptions.jsonMapper) + + override fun modelPriceMap( + params: ModelPriceMapModelPriceMapParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ModelPriceMapModelPriceMapResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "model-price-map") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { modelPriceMapHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveModelPriceMapHandler: + Handler<ModelPriceMapRetrieveModelPriceMapResponse> = + jsonHandler<ModelPriceMapRetrieveModelPriceMapResponse>(clientOptions.jsonMapper) + + override fun retrieveModelPriceMap( + params: ModelPriceMapRetrieveModelPriceMapParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ModelPriceMapRetrieveModelPriceMapResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "model-price-map") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveModelPriceMapHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/OAuthServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/OAuthServiceAsync.kt new file mode 100644 index 00000000..1797f903 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/OAuthServiceAsync.kt @@ -0,0 +1,371 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.oauth.OAuthProvider +import com.langsmith_api.api.models.api.v1.oauth.OAuthRetrieveCallbackParams +import com.langsmith_api.api.models.api.v1.oauth.OAuthRetrieveCallbackResponse +import com.langsmith_api.api.models.api.v1.oauth.OAuthRetrieveCurrentUserParams +import com.langsmith_api.api.models.api.v1.oauth.OAuthRetrieveCurrentUserResponse +import com.langsmith_api.api.models.api.v1.oauth.OAuthRetrieveLogoutParams +import com.langsmith_api.api.models.api.v1.oauth.OAuthRetrieveLogoutResponse +import com.langsmith_api.api.models.api.v1.oauth.OAuthRetrieveParams +import com.langsmith_api.api.models.api.v1.oauth.OAuthRetrieveResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface OAuthServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): OAuthServiceAsync + + /** Oauth Provider Auth */ + fun retrieve(provider: OAuthProvider): CompletableFuture<OAuthRetrieveResponse> = + retrieve(provider, OAuthRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + provider: OAuthProvider, + params: OAuthRetrieveParams = OAuthRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<OAuthRetrieveResponse> = + retrieve(params.toBuilder().provider(provider).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + provider: OAuthProvider, + params: OAuthRetrieveParams = OAuthRetrieveParams.none(), + ): CompletableFuture<OAuthRetrieveResponse> = retrieve(provider, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: OAuthRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<OAuthRetrieveResponse> + + /** @see retrieve */ + fun retrieve(params: OAuthRetrieveParams): CompletableFuture<OAuthRetrieveResponse> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + provider: OAuthProvider, + requestOptions: RequestOptions, + ): CompletableFuture<OAuthRetrieveResponse> = + retrieve(provider, OAuthRetrieveParams.none(), requestOptions) + + /** Oauth Provider Callback */ + fun retrieveCallback( + provider: OAuthProvider + ): CompletableFuture<OAuthRetrieveCallbackResponse> = + retrieveCallback(provider, OAuthRetrieveCallbackParams.none()) + + /** @see retrieveCallback */ + fun retrieveCallback( + provider: OAuthProvider, + params: OAuthRetrieveCallbackParams = OAuthRetrieveCallbackParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<OAuthRetrieveCallbackResponse> = + retrieveCallback(params.toBuilder().provider(provider).build(), requestOptions) + + /** @see retrieveCallback */ + fun retrieveCallback( + provider: OAuthProvider, + params: OAuthRetrieveCallbackParams = OAuthRetrieveCallbackParams.none(), + ): CompletableFuture<OAuthRetrieveCallbackResponse> = + retrieveCallback(provider, params, RequestOptions.none()) + + /** @see retrieveCallback */ + fun retrieveCallback( + params: OAuthRetrieveCallbackParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<OAuthRetrieveCallbackResponse> + + /** @see retrieveCallback */ + fun retrieveCallback( + params: OAuthRetrieveCallbackParams + ): CompletableFuture<OAuthRetrieveCallbackResponse> = + retrieveCallback(params, RequestOptions.none()) + + /** @see retrieveCallback */ + fun retrieveCallback( + provider: OAuthProvider, + requestOptions: RequestOptions, + ): CompletableFuture<OAuthRetrieveCallbackResponse> = + retrieveCallback(provider, OAuthRetrieveCallbackParams.none(), requestOptions) + + /** Oauth Provider Current User */ + fun retrieveCurrentUser( + provider: OAuthProvider + ): CompletableFuture<OAuthRetrieveCurrentUserResponse> = + retrieveCurrentUser(provider, OAuthRetrieveCurrentUserParams.none()) + + /** @see retrieveCurrentUser */ + fun retrieveCurrentUser( + provider: OAuthProvider, + params: OAuthRetrieveCurrentUserParams = OAuthRetrieveCurrentUserParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<OAuthRetrieveCurrentUserResponse> = + retrieveCurrentUser(params.toBuilder().provider(provider).build(), requestOptions) + + /** @see retrieveCurrentUser */ + fun retrieveCurrentUser( + provider: OAuthProvider, + params: OAuthRetrieveCurrentUserParams = OAuthRetrieveCurrentUserParams.none(), + ): CompletableFuture<OAuthRetrieveCurrentUserResponse> = + retrieveCurrentUser(provider, params, RequestOptions.none()) + + /** @see retrieveCurrentUser */ + fun retrieveCurrentUser( + params: OAuthRetrieveCurrentUserParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<OAuthRetrieveCurrentUserResponse> + + /** @see retrieveCurrentUser */ + fun retrieveCurrentUser( + params: OAuthRetrieveCurrentUserParams + ): CompletableFuture<OAuthRetrieveCurrentUserResponse> = + retrieveCurrentUser(params, RequestOptions.none()) + + /** @see retrieveCurrentUser */ + fun retrieveCurrentUser( + provider: OAuthProvider, + requestOptions: RequestOptions, + ): CompletableFuture<OAuthRetrieveCurrentUserResponse> = + retrieveCurrentUser(provider, OAuthRetrieveCurrentUserParams.none(), requestOptions) + + /** Oauth Provider Logout */ + fun retrieveLogout(provider: OAuthProvider): CompletableFuture<OAuthRetrieveLogoutResponse> = + retrieveLogout(provider, OAuthRetrieveLogoutParams.none()) + + /** @see retrieveLogout */ + fun retrieveLogout( + provider: OAuthProvider, + params: OAuthRetrieveLogoutParams = OAuthRetrieveLogoutParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<OAuthRetrieveLogoutResponse> = + retrieveLogout(params.toBuilder().provider(provider).build(), requestOptions) + + /** @see retrieveLogout */ + fun retrieveLogout( + provider: OAuthProvider, + params: OAuthRetrieveLogoutParams = OAuthRetrieveLogoutParams.none(), + ): CompletableFuture<OAuthRetrieveLogoutResponse> = + retrieveLogout(provider, params, RequestOptions.none()) + + /** @see retrieveLogout */ + fun retrieveLogout( + params: OAuthRetrieveLogoutParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<OAuthRetrieveLogoutResponse> + + /** @see retrieveLogout */ + fun retrieveLogout( + params: OAuthRetrieveLogoutParams + ): CompletableFuture<OAuthRetrieveLogoutResponse> = + retrieveLogout(params, RequestOptions.none()) + + /** @see retrieveLogout */ + fun retrieveLogout( + provider: OAuthProvider, + requestOptions: RequestOptions, + ): CompletableFuture<OAuthRetrieveLogoutResponse> = + retrieveLogout(provider, OAuthRetrieveLogoutParams.none(), requestOptions) + + /** A view of [OAuthServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): OAuthServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/oauth/{provider}`, but is otherwise the same + * as [OAuthServiceAsync.retrieve]. + */ + fun retrieve( + provider: OAuthProvider + ): CompletableFuture<HttpResponseFor<OAuthRetrieveResponse>> = + retrieve(provider, OAuthRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + provider: OAuthProvider, + params: OAuthRetrieveParams = OAuthRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<OAuthRetrieveResponse>> = + retrieve(params.toBuilder().provider(provider).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + provider: OAuthProvider, + params: OAuthRetrieveParams = OAuthRetrieveParams.none(), + ): CompletableFuture<HttpResponseFor<OAuthRetrieveResponse>> = + retrieve(provider, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: OAuthRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<OAuthRetrieveResponse>> + + /** @see retrieve */ + fun retrieve( + params: OAuthRetrieveParams + ): CompletableFuture<HttpResponseFor<OAuthRetrieveResponse>> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + provider: OAuthProvider, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<OAuthRetrieveResponse>> = + retrieve(provider, OAuthRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/oauth/{provider}/callback`, but is otherwise + * the same as [OAuthServiceAsync.retrieveCallback]. + */ + fun retrieveCallback( + provider: OAuthProvider + ): CompletableFuture<HttpResponseFor<OAuthRetrieveCallbackResponse>> = + retrieveCallback(provider, OAuthRetrieveCallbackParams.none()) + + /** @see retrieveCallback */ + fun retrieveCallback( + provider: OAuthProvider, + params: OAuthRetrieveCallbackParams = OAuthRetrieveCallbackParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<OAuthRetrieveCallbackResponse>> = + retrieveCallback(params.toBuilder().provider(provider).build(), requestOptions) + + /** @see retrieveCallback */ + fun retrieveCallback( + provider: OAuthProvider, + params: OAuthRetrieveCallbackParams = OAuthRetrieveCallbackParams.none(), + ): CompletableFuture<HttpResponseFor<OAuthRetrieveCallbackResponse>> = + retrieveCallback(provider, params, RequestOptions.none()) + + /** @see retrieveCallback */ + fun retrieveCallback( + params: OAuthRetrieveCallbackParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<OAuthRetrieveCallbackResponse>> + + /** @see retrieveCallback */ + fun retrieveCallback( + params: OAuthRetrieveCallbackParams + ): CompletableFuture<HttpResponseFor<OAuthRetrieveCallbackResponse>> = + retrieveCallback(params, RequestOptions.none()) + + /** @see retrieveCallback */ + fun retrieveCallback( + provider: OAuthProvider, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<OAuthRetrieveCallbackResponse>> = + retrieveCallback(provider, OAuthRetrieveCallbackParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/oauth/{provider}/current-user`, but is + * otherwise the same as [OAuthServiceAsync.retrieveCurrentUser]. + */ + fun retrieveCurrentUser( + provider: OAuthProvider + ): CompletableFuture<HttpResponseFor<OAuthRetrieveCurrentUserResponse>> = + retrieveCurrentUser(provider, OAuthRetrieveCurrentUserParams.none()) + + /** @see retrieveCurrentUser */ + fun retrieveCurrentUser( + provider: OAuthProvider, + params: OAuthRetrieveCurrentUserParams = OAuthRetrieveCurrentUserParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<OAuthRetrieveCurrentUserResponse>> = + retrieveCurrentUser(params.toBuilder().provider(provider).build(), requestOptions) + + /** @see retrieveCurrentUser */ + fun retrieveCurrentUser( + provider: OAuthProvider, + params: OAuthRetrieveCurrentUserParams = OAuthRetrieveCurrentUserParams.none(), + ): CompletableFuture<HttpResponseFor<OAuthRetrieveCurrentUserResponse>> = + retrieveCurrentUser(provider, params, RequestOptions.none()) + + /** @see retrieveCurrentUser */ + fun retrieveCurrentUser( + params: OAuthRetrieveCurrentUserParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<OAuthRetrieveCurrentUserResponse>> + + /** @see retrieveCurrentUser */ + fun retrieveCurrentUser( + params: OAuthRetrieveCurrentUserParams + ): CompletableFuture<HttpResponseFor<OAuthRetrieveCurrentUserResponse>> = + retrieveCurrentUser(params, RequestOptions.none()) + + /** @see retrieveCurrentUser */ + fun retrieveCurrentUser( + provider: OAuthProvider, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<OAuthRetrieveCurrentUserResponse>> = + retrieveCurrentUser(provider, OAuthRetrieveCurrentUserParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/oauth/{provider}/logout`, but is otherwise + * the same as [OAuthServiceAsync.retrieveLogout]. + */ + fun retrieveLogout( + provider: OAuthProvider + ): CompletableFuture<HttpResponseFor<OAuthRetrieveLogoutResponse>> = + retrieveLogout(provider, OAuthRetrieveLogoutParams.none()) + + /** @see retrieveLogout */ + fun retrieveLogout( + provider: OAuthProvider, + params: OAuthRetrieveLogoutParams = OAuthRetrieveLogoutParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<OAuthRetrieveLogoutResponse>> = + retrieveLogout(params.toBuilder().provider(provider).build(), requestOptions) + + /** @see retrieveLogout */ + fun retrieveLogout( + provider: OAuthProvider, + params: OAuthRetrieveLogoutParams = OAuthRetrieveLogoutParams.none(), + ): CompletableFuture<HttpResponseFor<OAuthRetrieveLogoutResponse>> = + retrieveLogout(provider, params, RequestOptions.none()) + + /** @see retrieveLogout */ + fun retrieveLogout( + params: OAuthRetrieveLogoutParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<OAuthRetrieveLogoutResponse>> + + /** @see retrieveLogout */ + fun retrieveLogout( + params: OAuthRetrieveLogoutParams + ): CompletableFuture<HttpResponseFor<OAuthRetrieveLogoutResponse>> = + retrieveLogout(params, RequestOptions.none()) + + /** @see retrieveLogout */ + fun retrieveLogout( + provider: OAuthProvider, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<OAuthRetrieveLogoutResponse>> = + retrieveLogout(provider, OAuthRetrieveLogoutParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/OAuthServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/OAuthServiceAsyncImpl.kt new file mode 100644 index 00000000..b26c4e34 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/OAuthServiceAsyncImpl.kt @@ -0,0 +1,215 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.oauth.OAuthRetrieveCallbackParams +import com.langsmith_api.api.models.api.v1.oauth.OAuthRetrieveCallbackResponse +import com.langsmith_api.api.models.api.v1.oauth.OAuthRetrieveCurrentUserParams +import com.langsmith_api.api.models.api.v1.oauth.OAuthRetrieveCurrentUserResponse +import com.langsmith_api.api.models.api.v1.oauth.OAuthRetrieveLogoutParams +import com.langsmith_api.api.models.api.v1.oauth.OAuthRetrieveLogoutResponse +import com.langsmith_api.api.models.api.v1.oauth.OAuthRetrieveParams +import com.langsmith_api.api.models.api.v1.oauth.OAuthRetrieveResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class OAuthServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + OAuthServiceAsync { + + private val withRawResponse: OAuthServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): OAuthServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): OAuthServiceAsync = + OAuthServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: OAuthRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<OAuthRetrieveResponse> = + // get /api/v1/oauth/{provider} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun retrieveCallback( + params: OAuthRetrieveCallbackParams, + requestOptions: RequestOptions, + ): CompletableFuture<OAuthRetrieveCallbackResponse> = + // get /api/v1/oauth/{provider}/callback + withRawResponse().retrieveCallback(params, requestOptions).thenApply { it.parse() } + + override fun retrieveCurrentUser( + params: OAuthRetrieveCurrentUserParams, + requestOptions: RequestOptions, + ): CompletableFuture<OAuthRetrieveCurrentUserResponse> = + // get /api/v1/oauth/{provider}/current-user + withRawResponse().retrieveCurrentUser(params, requestOptions).thenApply { it.parse() } + + override fun retrieveLogout( + params: OAuthRetrieveLogoutParams, + requestOptions: RequestOptions, + ): CompletableFuture<OAuthRetrieveLogoutResponse> = + // get /api/v1/oauth/{provider}/logout + withRawResponse().retrieveLogout(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + OAuthServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): OAuthServiceAsync.WithRawResponse = + OAuthServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler<OAuthRetrieveResponse> = + jsonHandler<OAuthRetrieveResponse>(clientOptions.jsonMapper) + + override fun retrieve( + params: OAuthRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<OAuthRetrieveResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("provider", params.provider().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "oauth", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveCallbackHandler: Handler<OAuthRetrieveCallbackResponse> = + jsonHandler<OAuthRetrieveCallbackResponse>(clientOptions.jsonMapper) + + override fun retrieveCallback( + params: OAuthRetrieveCallbackParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<OAuthRetrieveCallbackResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("provider", params.provider().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "oauth", params._pathParam(0), "callback") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveCallbackHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveCurrentUserHandler: Handler<OAuthRetrieveCurrentUserResponse> = + jsonHandler<OAuthRetrieveCurrentUserResponse>(clientOptions.jsonMapper) + + override fun retrieveCurrentUser( + params: OAuthRetrieveCurrentUserParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<OAuthRetrieveCurrentUserResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("provider", params.provider().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "oauth", params._pathParam(0), "current-user") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveCurrentUserHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveLogoutHandler: Handler<OAuthRetrieveLogoutResponse> = + jsonHandler<OAuthRetrieveLogoutResponse>(clientOptions.jsonMapper) + + override fun retrieveLogout( + params: OAuthRetrieveLogoutParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<OAuthRetrieveLogoutResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("provider", params.provider().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "oauth", params._pathParam(0), "logout") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveLogoutHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/OrgChartServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/OrgChartServiceAsync.kt new file mode 100644 index 00000000..1c354f6d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/OrgChartServiceAsync.kt @@ -0,0 +1,359 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.charts.CustomChartCreate +import com.langsmith_api.api.models.api.v1.charts.CustomChartPreviewRequest +import com.langsmith_api.api.models.api.v1.charts.CustomChartResponse +import com.langsmith_api.api.models.api.v1.charts.CustomChartsRequest +import com.langsmith_api.api.models.api.v1.charts.CustomChartsResponse +import com.langsmith_api.api.models.api.v1.charts.SingleCustomChartResponseBase +import com.langsmith_api.api.models.api.v1.orgcharts.OrgChartCreateParams +import com.langsmith_api.api.models.api.v1.orgcharts.OrgChartDeleteParams +import com.langsmith_api.api.models.api.v1.orgcharts.OrgChartDeleteResponse +import com.langsmith_api.api.models.api.v1.orgcharts.OrgChartOrgChartsParams +import com.langsmith_api.api.models.api.v1.orgcharts.OrgChartPreviewParams +import com.langsmith_api.api.models.api.v1.orgcharts.OrgChartUpdateParams +import com.langsmith_api.api.services.async.api.v1.orgcharts.SectionServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface OrgChartServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): OrgChartServiceAsync + + fun section(): SectionServiceAsync + + /** Create a new chart. */ + fun create(params: OrgChartCreateParams): CompletableFuture<CustomChartResponse> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: OrgChartCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CustomChartResponse> + + /** @see create */ + fun create( + customChartCreate: CustomChartCreate, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CustomChartResponse> = + create( + OrgChartCreateParams.builder().customChartCreate(customChartCreate).build(), + requestOptions, + ) + + /** @see create */ + fun create(customChartCreate: CustomChartCreate): CompletableFuture<CustomChartResponse> = + create(customChartCreate, RequestOptions.none()) + + /** Update a chart. */ + fun update( + chartId: String, + params: OrgChartUpdateParams, + ): CompletableFuture<CustomChartResponse> = update(chartId, params, RequestOptions.none()) + + /** @see update */ + fun update( + chartId: String, + params: OrgChartUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CustomChartResponse> = + update(params.toBuilder().chartId(chartId).build(), requestOptions) + + /** @see update */ + fun update(params: OrgChartUpdateParams): CompletableFuture<CustomChartResponse> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: OrgChartUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CustomChartResponse> + + /** Delete a chart. */ + fun delete(chartId: String): CompletableFuture<OrgChartDeleteResponse> = + delete(chartId, OrgChartDeleteParams.none()) + + /** @see delete */ + fun delete( + chartId: String, + params: OrgChartDeleteParams = OrgChartDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<OrgChartDeleteResponse> = + delete(params.toBuilder().chartId(chartId).build(), requestOptions) + + /** @see delete */ + fun delete( + chartId: String, + params: OrgChartDeleteParams = OrgChartDeleteParams.none(), + ): CompletableFuture<OrgChartDeleteResponse> = delete(chartId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: OrgChartDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<OrgChartDeleteResponse> + + /** @see delete */ + fun delete(params: OrgChartDeleteParams): CompletableFuture<OrgChartDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + chartId: String, + requestOptions: RequestOptions, + ): CompletableFuture<OrgChartDeleteResponse> = + delete(chartId, OrgChartDeleteParams.none(), requestOptions) + + /** Get all charts for the tenant. */ + fun orgCharts(params: OrgChartOrgChartsParams): CompletableFuture<CustomChartsResponse> = + orgCharts(params, RequestOptions.none()) + + /** @see orgCharts */ + fun orgCharts( + params: OrgChartOrgChartsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CustomChartsResponse> + + /** @see orgCharts */ + fun orgCharts( + customChartsRequest: CustomChartsRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CustomChartsResponse> = + orgCharts( + OrgChartOrgChartsParams.builder().customChartsRequest(customChartsRequest).build(), + requestOptions, + ) + + /** @see orgCharts */ + fun orgCharts( + customChartsRequest: CustomChartsRequest + ): CompletableFuture<CustomChartsResponse> = + orgCharts(customChartsRequest, RequestOptions.none()) + + /** Get a preview for a chart without actually creating it. */ + fun preview(params: OrgChartPreviewParams): CompletableFuture<SingleCustomChartResponseBase> = + preview(params, RequestOptions.none()) + + /** @see preview */ + fun preview( + params: OrgChartPreviewParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<SingleCustomChartResponseBase> + + /** @see preview */ + fun preview( + customChartPreviewRequest: CustomChartPreviewRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<SingleCustomChartResponseBase> = + preview( + OrgChartPreviewParams.builder() + .customChartPreviewRequest(customChartPreviewRequest) + .build(), + requestOptions, + ) + + /** @see preview */ + fun preview( + customChartPreviewRequest: CustomChartPreviewRequest + ): CompletableFuture<SingleCustomChartResponseBase> = + preview(customChartPreviewRequest, RequestOptions.none()) + + /** + * A view of [OrgChartServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): OrgChartServiceAsync.WithRawResponse + + fun section(): SectionServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/org-charts/create`, but is otherwise the + * same as [OrgChartServiceAsync.create]. + */ + fun create( + params: OrgChartCreateParams + ): CompletableFuture<HttpResponseFor<CustomChartResponse>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: OrgChartCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CustomChartResponse>> + + /** @see create */ + fun create( + customChartCreate: CustomChartCreate, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CustomChartResponse>> = + create( + OrgChartCreateParams.builder().customChartCreate(customChartCreate).build(), + requestOptions, + ) + + /** @see create */ + fun create( + customChartCreate: CustomChartCreate + ): CompletableFuture<HttpResponseFor<CustomChartResponse>> = + create(customChartCreate, RequestOptions.none()) + + /** + * Returns a raw HTTP response for `patch /api/v1/org-charts/{chart_id}`, but is otherwise + * the same as [OrgChartServiceAsync.update]. + */ + fun update( + chartId: String, + params: OrgChartUpdateParams, + ): CompletableFuture<HttpResponseFor<CustomChartResponse>> = + update(chartId, params, RequestOptions.none()) + + /** @see update */ + fun update( + chartId: String, + params: OrgChartUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CustomChartResponse>> = + update(params.toBuilder().chartId(chartId).build(), requestOptions) + + /** @see update */ + fun update( + params: OrgChartUpdateParams + ): CompletableFuture<HttpResponseFor<CustomChartResponse>> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: OrgChartUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CustomChartResponse>> + + /** + * Returns a raw HTTP response for `delete /api/v1/org-charts/{chart_id}`, but is otherwise + * the same as [OrgChartServiceAsync.delete]. + */ + fun delete(chartId: String): CompletableFuture<HttpResponseFor<OrgChartDeleteResponse>> = + delete(chartId, OrgChartDeleteParams.none()) + + /** @see delete */ + fun delete( + chartId: String, + params: OrgChartDeleteParams = OrgChartDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<OrgChartDeleteResponse>> = + delete(params.toBuilder().chartId(chartId).build(), requestOptions) + + /** @see delete */ + fun delete( + chartId: String, + params: OrgChartDeleteParams = OrgChartDeleteParams.none(), + ): CompletableFuture<HttpResponseFor<OrgChartDeleteResponse>> = + delete(chartId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: OrgChartDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<OrgChartDeleteResponse>> + + /** @see delete */ + fun delete( + params: OrgChartDeleteParams + ): CompletableFuture<HttpResponseFor<OrgChartDeleteResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + chartId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<OrgChartDeleteResponse>> = + delete(chartId, OrgChartDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/org-charts`, but is otherwise the same as + * [OrgChartServiceAsync.orgCharts]. + */ + fun orgCharts( + params: OrgChartOrgChartsParams + ): CompletableFuture<HttpResponseFor<CustomChartsResponse>> = + orgCharts(params, RequestOptions.none()) + + /** @see orgCharts */ + fun orgCharts( + params: OrgChartOrgChartsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CustomChartsResponse>> + + /** @see orgCharts */ + fun orgCharts( + customChartsRequest: CustomChartsRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CustomChartsResponse>> = + orgCharts( + OrgChartOrgChartsParams.builder().customChartsRequest(customChartsRequest).build(), + requestOptions, + ) + + /** @see orgCharts */ + fun orgCharts( + customChartsRequest: CustomChartsRequest + ): CompletableFuture<HttpResponseFor<CustomChartsResponse>> = + orgCharts(customChartsRequest, RequestOptions.none()) + + /** + * Returns a raw HTTP response for `post /api/v1/org-charts/preview`, but is otherwise the + * same as [OrgChartServiceAsync.preview]. + */ + fun preview( + params: OrgChartPreviewParams + ): CompletableFuture<HttpResponseFor<SingleCustomChartResponseBase>> = + preview(params, RequestOptions.none()) + + /** @see preview */ + fun preview( + params: OrgChartPreviewParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<SingleCustomChartResponseBase>> + + /** @see preview */ + fun preview( + customChartPreviewRequest: CustomChartPreviewRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<SingleCustomChartResponseBase>> = + preview( + OrgChartPreviewParams.builder() + .customChartPreviewRequest(customChartPreviewRequest) + .build(), + requestOptions, + ) + + /** @see preview */ + fun preview( + customChartPreviewRequest: CustomChartPreviewRequest + ): CompletableFuture<HttpResponseFor<SingleCustomChartResponseBase>> = + preview(customChartPreviewRequest, RequestOptions.none()) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/OrgChartServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/OrgChartServiceAsyncImpl.kt new file mode 100644 index 00000000..9ce16126 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/OrgChartServiceAsyncImpl.kt @@ -0,0 +1,265 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.charts.CustomChartResponse +import com.langsmith_api.api.models.api.v1.charts.CustomChartsResponse +import com.langsmith_api.api.models.api.v1.charts.SingleCustomChartResponseBase +import com.langsmith_api.api.models.api.v1.orgcharts.OrgChartCreateParams +import com.langsmith_api.api.models.api.v1.orgcharts.OrgChartDeleteParams +import com.langsmith_api.api.models.api.v1.orgcharts.OrgChartDeleteResponse +import com.langsmith_api.api.models.api.v1.orgcharts.OrgChartOrgChartsParams +import com.langsmith_api.api.models.api.v1.orgcharts.OrgChartPreviewParams +import com.langsmith_api.api.models.api.v1.orgcharts.OrgChartUpdateParams +import com.langsmith_api.api.services.async.api.v1.orgcharts.SectionServiceAsync +import com.langsmith_api.api.services.async.api.v1.orgcharts.SectionServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class OrgChartServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + OrgChartServiceAsync { + + private val withRawResponse: OrgChartServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val section: SectionServiceAsync by lazy { SectionServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): OrgChartServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): OrgChartServiceAsync = + OrgChartServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun section(): SectionServiceAsync = section + + override fun create( + params: OrgChartCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<CustomChartResponse> = + // post /api/v1/org-charts/create + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: OrgChartUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<CustomChartResponse> = + // patch /api/v1/org-charts/{chart_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: OrgChartDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<OrgChartDeleteResponse> = + // delete /api/v1/org-charts/{chart_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + override fun orgCharts( + params: OrgChartOrgChartsParams, + requestOptions: RequestOptions, + ): CompletableFuture<CustomChartsResponse> = + // post /api/v1/org-charts + withRawResponse().orgCharts(params, requestOptions).thenApply { it.parse() } + + override fun preview( + params: OrgChartPreviewParams, + requestOptions: RequestOptions, + ): CompletableFuture<SingleCustomChartResponseBase> = + // post /api/v1/org-charts/preview + withRawResponse().preview(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + OrgChartServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val section: SectionServiceAsync.WithRawResponse by lazy { + SectionServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): OrgChartServiceAsync.WithRawResponse = + OrgChartServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun section(): SectionServiceAsync.WithRawResponse = section + + private val createHandler: Handler<CustomChartResponse> = + jsonHandler<CustomChartResponse>(clientOptions.jsonMapper) + + override fun create( + params: OrgChartCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<CustomChartResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "org-charts", "create") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler<CustomChartResponse> = + jsonHandler<CustomChartResponse>(clientOptions.jsonMapper) + + override fun update( + params: OrgChartUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<CustomChartResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("chartId", params.chartId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "org-charts", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val deleteHandler: Handler<OrgChartDeleteResponse> = + jsonHandler<OrgChartDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: OrgChartDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<OrgChartDeleteResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("chartId", params.chartId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "org-charts", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val orgChartsHandler: Handler<CustomChartsResponse> = + jsonHandler<CustomChartsResponse>(clientOptions.jsonMapper) + + override fun orgCharts( + params: OrgChartOrgChartsParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<CustomChartsResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "org-charts") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { orgChartsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val previewHandler: Handler<SingleCustomChartResponseBase> = + jsonHandler<SingleCustomChartResponseBase>(clientOptions.jsonMapper) + + override fun preview( + params: OrgChartPreviewParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<SingleCustomChartResponseBase>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "org-charts", "preview") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { previewHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/OrgServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/OrgServiceAsync.kt new file mode 100644 index 00000000..fc4e7ac5 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/OrgServiceAsync.kt @@ -0,0 +1,176 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.orgs.OrgCreateParams +import com.langsmith_api.api.models.api.v1.orgs.OrgListParams +import com.langsmith_api.api.models.api.v1.orgs.OrgRetrievePermissionsParams +import com.langsmith_api.api.models.api.v1.orgs.OrgRetrievePermissionsResponse +import com.langsmith_api.api.models.api.v1.orgs.OrganizationPgSchemaSlim +import com.langsmith_api.api.services.async.api.v1.orgs.CurrentServiceAsync +import com.langsmith_api.api.services.async.api.v1.orgs.MemberServiceAsync +import com.langsmith_api.api.services.async.api.v1.orgs.PendingServiceAsync +import com.langsmith_api.api.services.async.api.v1.orgs.TtlSettingServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface OrgServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): OrgServiceAsync + + fun current(): CurrentServiceAsync + + fun pending(): PendingServiceAsync + + fun members(): MemberServiceAsync + + fun ttlSettings(): TtlSettingServiceAsync + + /** Create Organization */ + fun create(params: OrgCreateParams): CompletableFuture<OrganizationPgSchemaSlim> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: OrgCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<OrganizationPgSchemaSlim> + + /** Get all orgs visible to this auth */ + fun list(): CompletableFuture<List<OrganizationPgSchemaSlim>> = list(OrgListParams.none()) + + /** @see list */ + fun list( + params: OrgListParams = OrgListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<OrganizationPgSchemaSlim>> + + /** @see list */ + fun list( + params: OrgListParams = OrgListParams.none() + ): CompletableFuture<List<OrganizationPgSchemaSlim>> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture<List<OrganizationPgSchemaSlim>> = + list(OrgListParams.none(), requestOptions) + + /** List Permissions */ + fun retrievePermissions(): CompletableFuture<List<OrgRetrievePermissionsResponse>> = + retrievePermissions(OrgRetrievePermissionsParams.none()) + + /** @see retrievePermissions */ + fun retrievePermissions( + params: OrgRetrievePermissionsParams = OrgRetrievePermissionsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<OrgRetrievePermissionsResponse>> + + /** @see retrievePermissions */ + fun retrievePermissions( + params: OrgRetrievePermissionsParams = OrgRetrievePermissionsParams.none() + ): CompletableFuture<List<OrgRetrievePermissionsResponse>> = + retrievePermissions(params, RequestOptions.none()) + + /** @see retrievePermissions */ + fun retrievePermissions( + requestOptions: RequestOptions + ): CompletableFuture<List<OrgRetrievePermissionsResponse>> = + retrievePermissions(OrgRetrievePermissionsParams.none(), requestOptions) + + /** A view of [OrgServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): OrgServiceAsync.WithRawResponse + + fun current(): CurrentServiceAsync.WithRawResponse + + fun pending(): PendingServiceAsync.WithRawResponse + + fun members(): MemberServiceAsync.WithRawResponse + + fun ttlSettings(): TtlSettingServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/orgs`, but is otherwise the same as + * [OrgServiceAsync.create]. + */ + fun create( + params: OrgCreateParams + ): CompletableFuture<HttpResponseFor<OrganizationPgSchemaSlim>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: OrgCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<OrganizationPgSchemaSlim>> + + /** + * Returns a raw HTTP response for `get /api/v1/orgs`, but is otherwise the same as + * [OrgServiceAsync.list]. + */ + fun list(): CompletableFuture<HttpResponseFor<List<OrganizationPgSchemaSlim>>> = + list(OrgListParams.none()) + + /** @see list */ + fun list( + params: OrgListParams = OrgListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<OrganizationPgSchemaSlim>>> + + /** @see list */ + fun list( + params: OrgListParams = OrgListParams.none() + ): CompletableFuture<HttpResponseFor<List<OrganizationPgSchemaSlim>>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<OrganizationPgSchemaSlim>>> = + list(OrgListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/orgs/permissions`, but is otherwise the same + * as [OrgServiceAsync.retrievePermissions]. + */ + fun retrievePermissions(): + CompletableFuture<HttpResponseFor<List<OrgRetrievePermissionsResponse>>> = + retrievePermissions(OrgRetrievePermissionsParams.none()) + + /** @see retrievePermissions */ + fun retrievePermissions( + params: OrgRetrievePermissionsParams = OrgRetrievePermissionsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<OrgRetrievePermissionsResponse>>> + + /** @see retrievePermissions */ + fun retrievePermissions( + params: OrgRetrievePermissionsParams = OrgRetrievePermissionsParams.none() + ): CompletableFuture<HttpResponseFor<List<OrgRetrievePermissionsResponse>>> = + retrievePermissions(params, RequestOptions.none()) + + /** @see retrievePermissions */ + fun retrievePermissions( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<OrgRetrievePermissionsResponse>>> = + retrievePermissions(OrgRetrievePermissionsParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/OrgServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/OrgServiceAsyncImpl.kt new file mode 100644 index 00000000..ff4804a8 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/OrgServiceAsyncImpl.kt @@ -0,0 +1,213 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.orgs.OrgCreateParams +import com.langsmith_api.api.models.api.v1.orgs.OrgListParams +import com.langsmith_api.api.models.api.v1.orgs.OrgRetrievePermissionsParams +import com.langsmith_api.api.models.api.v1.orgs.OrgRetrievePermissionsResponse +import com.langsmith_api.api.models.api.v1.orgs.OrganizationPgSchemaSlim +import com.langsmith_api.api.services.async.api.v1.orgs.CurrentServiceAsync +import com.langsmith_api.api.services.async.api.v1.orgs.CurrentServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.orgs.MemberServiceAsync +import com.langsmith_api.api.services.async.api.v1.orgs.MemberServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.orgs.PendingServiceAsync +import com.langsmith_api.api.services.async.api.v1.orgs.PendingServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.orgs.TtlSettingServiceAsync +import com.langsmith_api.api.services.async.api.v1.orgs.TtlSettingServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class OrgServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + OrgServiceAsync { + + private val withRawResponse: OrgServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val current: CurrentServiceAsync by lazy { CurrentServiceAsyncImpl(clientOptions) } + + private val pending: PendingServiceAsync by lazy { PendingServiceAsyncImpl(clientOptions) } + + private val members: MemberServiceAsync by lazy { MemberServiceAsyncImpl(clientOptions) } + + private val ttlSettings: TtlSettingServiceAsync by lazy { + TtlSettingServiceAsyncImpl(clientOptions) + } + + override fun withRawResponse(): OrgServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): OrgServiceAsync = + OrgServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun current(): CurrentServiceAsync = current + + override fun pending(): PendingServiceAsync = pending + + override fun members(): MemberServiceAsync = members + + override fun ttlSettings(): TtlSettingServiceAsync = ttlSettings + + override fun create( + params: OrgCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<OrganizationPgSchemaSlim> = + // post /api/v1/orgs + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: OrgListParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<OrganizationPgSchemaSlim>> = + // get /api/v1/orgs + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun retrievePermissions( + params: OrgRetrievePermissionsParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<OrgRetrievePermissionsResponse>> = + // get /api/v1/orgs/permissions + withRawResponse().retrievePermissions(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + OrgServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val current: CurrentServiceAsync.WithRawResponse by lazy { + CurrentServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val pending: PendingServiceAsync.WithRawResponse by lazy { + PendingServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val members: MemberServiceAsync.WithRawResponse by lazy { + MemberServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val ttlSettings: TtlSettingServiceAsync.WithRawResponse by lazy { + TtlSettingServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): OrgServiceAsync.WithRawResponse = + OrgServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun current(): CurrentServiceAsync.WithRawResponse = current + + override fun pending(): PendingServiceAsync.WithRawResponse = pending + + override fun members(): MemberServiceAsync.WithRawResponse = members + + override fun ttlSettings(): TtlSettingServiceAsync.WithRawResponse = ttlSettings + + private val createHandler: Handler<OrganizationPgSchemaSlim> = + jsonHandler<OrganizationPgSchemaSlim>(clientOptions.jsonMapper) + + override fun create( + params: OrgCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<OrganizationPgSchemaSlim>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler<List<OrganizationPgSchemaSlim>> = + jsonHandler<List<OrganizationPgSchemaSlim>>(clientOptions.jsonMapper) + + override fun list( + params: OrgListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<OrganizationPgSchemaSlim>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val retrievePermissionsHandler: Handler<List<OrgRetrievePermissionsResponse>> = + jsonHandler<List<OrgRetrievePermissionsResponse>>(clientOptions.jsonMapper) + + override fun retrievePermissions( + params: OrgRetrievePermissionsParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<OrgRetrievePermissionsResponse>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "permissions") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrievePermissionsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/PlaygroundSettingServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/PlaygroundSettingServiceAsync.kt new file mode 100644 index 00000000..dbb2769a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/PlaygroundSettingServiceAsync.kt @@ -0,0 +1,305 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.playgroundsettings.PlaygroundSettingDeleteParams +import com.langsmith_api.api.models.api.v1.playgroundsettings.PlaygroundSettingDeleteResponse +import com.langsmith_api.api.models.api.v1.playgroundsettings.PlaygroundSettingPlaygroundSettingsParams +import com.langsmith_api.api.models.api.v1.playgroundsettings.PlaygroundSettingRetrievePlaygroundSettingsParams +import com.langsmith_api.api.models.api.v1.playgroundsettings.PlaygroundSettingUpdateParams +import com.langsmith_api.api.models.api.v1.playgroundsettings.PlaygroundSettingsResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface PlaygroundSettingServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): PlaygroundSettingServiceAsync + + /** Update playground settings. */ + fun update(playgroundSettingsId: String): CompletableFuture<PlaygroundSettingsResponse> = + update(playgroundSettingsId, PlaygroundSettingUpdateParams.none()) + + /** @see update */ + fun update( + playgroundSettingsId: String, + params: PlaygroundSettingUpdateParams = PlaygroundSettingUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<PlaygroundSettingsResponse> = + update( + params.toBuilder().playgroundSettingsId(playgroundSettingsId).build(), + requestOptions, + ) + + /** @see update */ + fun update( + playgroundSettingsId: String, + params: PlaygroundSettingUpdateParams = PlaygroundSettingUpdateParams.none(), + ): CompletableFuture<PlaygroundSettingsResponse> = + update(playgroundSettingsId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: PlaygroundSettingUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<PlaygroundSettingsResponse> + + /** @see update */ + fun update( + params: PlaygroundSettingUpdateParams + ): CompletableFuture<PlaygroundSettingsResponse> = update(params, RequestOptions.none()) + + /** @see update */ + fun update( + playgroundSettingsId: String, + requestOptions: RequestOptions, + ): CompletableFuture<PlaygroundSettingsResponse> = + update(playgroundSettingsId, PlaygroundSettingUpdateParams.none(), requestOptions) + + /** Delete playground settings. */ + fun delete(playgroundSettingsId: String): CompletableFuture<PlaygroundSettingDeleteResponse> = + delete(playgroundSettingsId, PlaygroundSettingDeleteParams.none()) + + /** @see delete */ + fun delete( + playgroundSettingsId: String, + params: PlaygroundSettingDeleteParams = PlaygroundSettingDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<PlaygroundSettingDeleteResponse> = + delete( + params.toBuilder().playgroundSettingsId(playgroundSettingsId).build(), + requestOptions, + ) + + /** @see delete */ + fun delete( + playgroundSettingsId: String, + params: PlaygroundSettingDeleteParams = PlaygroundSettingDeleteParams.none(), + ): CompletableFuture<PlaygroundSettingDeleteResponse> = + delete(playgroundSettingsId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: PlaygroundSettingDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<PlaygroundSettingDeleteResponse> + + /** @see delete */ + fun delete( + params: PlaygroundSettingDeleteParams + ): CompletableFuture<PlaygroundSettingDeleteResponse> = delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + playgroundSettingsId: String, + requestOptions: RequestOptions, + ): CompletableFuture<PlaygroundSettingDeleteResponse> = + delete(playgroundSettingsId, PlaygroundSettingDeleteParams.none(), requestOptions) + + /** Create playground settings. */ + fun playgroundSettings( + params: PlaygroundSettingPlaygroundSettingsParams + ): CompletableFuture<PlaygroundSettingsResponse> = + playgroundSettings(params, RequestOptions.none()) + + /** @see playgroundSettings */ + fun playgroundSettings( + params: PlaygroundSettingPlaygroundSettingsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<PlaygroundSettingsResponse> + + /** Get all playground settings for this tenant id. */ + fun retrievePlaygroundSettings(): CompletableFuture<List<PlaygroundSettingsResponse>> = + retrievePlaygroundSettings(PlaygroundSettingRetrievePlaygroundSettingsParams.none()) + + /** @see retrievePlaygroundSettings */ + fun retrievePlaygroundSettings( + params: PlaygroundSettingRetrievePlaygroundSettingsParams = + PlaygroundSettingRetrievePlaygroundSettingsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<PlaygroundSettingsResponse>> + + /** @see retrievePlaygroundSettings */ + fun retrievePlaygroundSettings( + params: PlaygroundSettingRetrievePlaygroundSettingsParams = + PlaygroundSettingRetrievePlaygroundSettingsParams.none() + ): CompletableFuture<List<PlaygroundSettingsResponse>> = + retrievePlaygroundSettings(params, RequestOptions.none()) + + /** @see retrievePlaygroundSettings */ + fun retrievePlaygroundSettings( + requestOptions: RequestOptions + ): CompletableFuture<List<PlaygroundSettingsResponse>> = + retrievePlaygroundSettings( + PlaygroundSettingRetrievePlaygroundSettingsParams.none(), + requestOptions, + ) + + /** + * A view of [PlaygroundSettingServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PlaygroundSettingServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `patch + * /api/v1/playground-settings/{playground_settings_id}`, but is otherwise the same as + * [PlaygroundSettingServiceAsync.update]. + */ + fun update( + playgroundSettingsId: String + ): CompletableFuture<HttpResponseFor<PlaygroundSettingsResponse>> = + update(playgroundSettingsId, PlaygroundSettingUpdateParams.none()) + + /** @see update */ + fun update( + playgroundSettingsId: String, + params: PlaygroundSettingUpdateParams = PlaygroundSettingUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<PlaygroundSettingsResponse>> = + update( + params.toBuilder().playgroundSettingsId(playgroundSettingsId).build(), + requestOptions, + ) + + /** @see update */ + fun update( + playgroundSettingsId: String, + params: PlaygroundSettingUpdateParams = PlaygroundSettingUpdateParams.none(), + ): CompletableFuture<HttpResponseFor<PlaygroundSettingsResponse>> = + update(playgroundSettingsId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: PlaygroundSettingUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<PlaygroundSettingsResponse>> + + /** @see update */ + fun update( + params: PlaygroundSettingUpdateParams + ): CompletableFuture<HttpResponseFor<PlaygroundSettingsResponse>> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + playgroundSettingsId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<PlaygroundSettingsResponse>> = + update(playgroundSettingsId, PlaygroundSettingUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete + * /api/v1/playground-settings/{playground_settings_id}`, but is otherwise the same as + * [PlaygroundSettingServiceAsync.delete]. + */ + fun delete( + playgroundSettingsId: String + ): CompletableFuture<HttpResponseFor<PlaygroundSettingDeleteResponse>> = + delete(playgroundSettingsId, PlaygroundSettingDeleteParams.none()) + + /** @see delete */ + fun delete( + playgroundSettingsId: String, + params: PlaygroundSettingDeleteParams = PlaygroundSettingDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<PlaygroundSettingDeleteResponse>> = + delete( + params.toBuilder().playgroundSettingsId(playgroundSettingsId).build(), + requestOptions, + ) + + /** @see delete */ + fun delete( + playgroundSettingsId: String, + params: PlaygroundSettingDeleteParams = PlaygroundSettingDeleteParams.none(), + ): CompletableFuture<HttpResponseFor<PlaygroundSettingDeleteResponse>> = + delete(playgroundSettingsId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: PlaygroundSettingDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<PlaygroundSettingDeleteResponse>> + + /** @see delete */ + fun delete( + params: PlaygroundSettingDeleteParams + ): CompletableFuture<HttpResponseFor<PlaygroundSettingDeleteResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + playgroundSettingsId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<PlaygroundSettingDeleteResponse>> = + delete(playgroundSettingsId, PlaygroundSettingDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/playground-settings`, but is otherwise the + * same as [PlaygroundSettingServiceAsync.playgroundSettings]. + */ + fun playgroundSettings( + params: PlaygroundSettingPlaygroundSettingsParams + ): CompletableFuture<HttpResponseFor<PlaygroundSettingsResponse>> = + playgroundSettings(params, RequestOptions.none()) + + /** @see playgroundSettings */ + fun playgroundSettings( + params: PlaygroundSettingPlaygroundSettingsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<PlaygroundSettingsResponse>> + + /** + * Returns a raw HTTP response for `get /api/v1/playground-settings`, but is otherwise the + * same as [PlaygroundSettingServiceAsync.retrievePlaygroundSettings]. + */ + fun retrievePlaygroundSettings(): + CompletableFuture<HttpResponseFor<List<PlaygroundSettingsResponse>>> = + retrievePlaygroundSettings(PlaygroundSettingRetrievePlaygroundSettingsParams.none()) + + /** @see retrievePlaygroundSettings */ + fun retrievePlaygroundSettings( + params: PlaygroundSettingRetrievePlaygroundSettingsParams = + PlaygroundSettingRetrievePlaygroundSettingsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<PlaygroundSettingsResponse>>> + + /** @see retrievePlaygroundSettings */ + fun retrievePlaygroundSettings( + params: PlaygroundSettingRetrievePlaygroundSettingsParams = + PlaygroundSettingRetrievePlaygroundSettingsParams.none() + ): CompletableFuture<HttpResponseFor<List<PlaygroundSettingsResponse>>> = + retrievePlaygroundSettings(params, RequestOptions.none()) + + /** @see retrievePlaygroundSettings */ + fun retrievePlaygroundSettings( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<PlaygroundSettingsResponse>>> = + retrievePlaygroundSettings( + PlaygroundSettingRetrievePlaygroundSettingsParams.none(), + requestOptions, + ) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/PlaygroundSettingServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/PlaygroundSettingServiceAsyncImpl.kt new file mode 100644 index 00000000..77e63343 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/PlaygroundSettingServiceAsyncImpl.kt @@ -0,0 +1,215 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.playgroundsettings.PlaygroundSettingDeleteParams +import com.langsmith_api.api.models.api.v1.playgroundsettings.PlaygroundSettingDeleteResponse +import com.langsmith_api.api.models.api.v1.playgroundsettings.PlaygroundSettingPlaygroundSettingsParams +import com.langsmith_api.api.models.api.v1.playgroundsettings.PlaygroundSettingRetrievePlaygroundSettingsParams +import com.langsmith_api.api.models.api.v1.playgroundsettings.PlaygroundSettingUpdateParams +import com.langsmith_api.api.models.api.v1.playgroundsettings.PlaygroundSettingsResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class PlaygroundSettingServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : PlaygroundSettingServiceAsync { + + private val withRawResponse: PlaygroundSettingServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): PlaygroundSettingServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PlaygroundSettingServiceAsync = + PlaygroundSettingServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun update( + params: PlaygroundSettingUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<PlaygroundSettingsResponse> = + // patch /api/v1/playground-settings/{playground_settings_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: PlaygroundSettingDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<PlaygroundSettingDeleteResponse> = + // delete /api/v1/playground-settings/{playground_settings_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + override fun playgroundSettings( + params: PlaygroundSettingPlaygroundSettingsParams, + requestOptions: RequestOptions, + ): CompletableFuture<PlaygroundSettingsResponse> = + // post /api/v1/playground-settings + withRawResponse().playgroundSettings(params, requestOptions).thenApply { it.parse() } + + override fun retrievePlaygroundSettings( + params: PlaygroundSettingRetrievePlaygroundSettingsParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<PlaygroundSettingsResponse>> = + // get /api/v1/playground-settings + withRawResponse().retrievePlaygroundSettings(params, requestOptions).thenApply { + it.parse() + } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + PlaygroundSettingServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PlaygroundSettingServiceAsync.WithRawResponse = + PlaygroundSettingServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val updateHandler: Handler<PlaygroundSettingsResponse> = + jsonHandler<PlaygroundSettingsResponse>(clientOptions.jsonMapper) + + override fun update( + params: PlaygroundSettingUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<PlaygroundSettingsResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("playgroundSettingsId", params.playgroundSettingsId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "playground-settings", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val deleteHandler: Handler<PlaygroundSettingDeleteResponse> = + jsonHandler<PlaygroundSettingDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: PlaygroundSettingDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<PlaygroundSettingDeleteResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("playgroundSettingsId", params.playgroundSettingsId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "playground-settings", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val playgroundSettingsHandler: Handler<PlaygroundSettingsResponse> = + jsonHandler<PlaygroundSettingsResponse>(clientOptions.jsonMapper) + + override fun playgroundSettings( + params: PlaygroundSettingPlaygroundSettingsParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<PlaygroundSettingsResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "playground-settings") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { playgroundSettingsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrievePlaygroundSettingsHandler: Handler<List<PlaygroundSettingsResponse>> = + jsonHandler<List<PlaygroundSettingsResponse>>(clientOptions.jsonMapper) + + override fun retrievePlaygroundSettings( + params: PlaygroundSettingRetrievePlaygroundSettingsParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<PlaygroundSettingsResponse>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "playground-settings") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrievePlaygroundSettingsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/PromptServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/PromptServiceAsync.kt new file mode 100644 index 00000000..99f6386d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/PromptServiceAsync.kt @@ -0,0 +1,94 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.prompts.PromptCanvasParams +import com.langsmith_api.api.models.api.v1.prompts.PromptCanvasResponse +import com.langsmith_api.api.models.api.v1.prompts.PromptInvokePromptParams +import com.langsmith_api.api.models.api.v1.prompts.PromptInvokePromptResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface PromptServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): PromptServiceAsync + + /** Prompt Canvas */ + fun canvas(params: PromptCanvasParams): CompletableFuture<PromptCanvasResponse> = + canvas(params, RequestOptions.none()) + + /** @see canvas */ + fun canvas( + params: PromptCanvasParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<PromptCanvasResponse> + + /** Invoke Prompt */ + fun invokePrompt( + params: PromptInvokePromptParams + ): CompletableFuture<PromptInvokePromptResponse> = invokePrompt(params, RequestOptions.none()) + + /** @see invokePrompt */ + fun invokePrompt( + params: PromptInvokePromptParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<PromptInvokePromptResponse> + + /** + * A view of [PromptServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PromptServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/prompts/canvas`, but is otherwise the same + * as [PromptServiceAsync.canvas]. + */ + fun canvas( + params: PromptCanvasParams + ): CompletableFuture<HttpResponseFor<PromptCanvasResponse>> = + canvas(params, RequestOptions.none()) + + /** @see canvas */ + fun canvas( + params: PromptCanvasParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<PromptCanvasResponse>> + + /** + * Returns a raw HTTP response for `post /api/v1/prompts/invoke_prompt`, but is otherwise + * the same as [PromptServiceAsync.invokePrompt]. + */ + fun invokePrompt( + params: PromptInvokePromptParams + ): CompletableFuture<HttpResponseFor<PromptInvokePromptResponse>> = + invokePrompt(params, RequestOptions.none()) + + /** @see invokePrompt */ + fun invokePrompt( + params: PromptInvokePromptParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<PromptInvokePromptResponse>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/PromptServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/PromptServiceAsyncImpl.kt new file mode 100644 index 00000000..2ce1b2b3 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/PromptServiceAsyncImpl.kt @@ -0,0 +1,126 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.prompts.PromptCanvasParams +import com.langsmith_api.api.models.api.v1.prompts.PromptCanvasResponse +import com.langsmith_api.api.models.api.v1.prompts.PromptInvokePromptParams +import com.langsmith_api.api.models.api.v1.prompts.PromptInvokePromptResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class PromptServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + PromptServiceAsync { + + private val withRawResponse: PromptServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): PromptServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): PromptServiceAsync = + PromptServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun canvas( + params: PromptCanvasParams, + requestOptions: RequestOptions, + ): CompletableFuture<PromptCanvasResponse> = + // post /api/v1/prompts/canvas + withRawResponse().canvas(params, requestOptions).thenApply { it.parse() } + + override fun invokePrompt( + params: PromptInvokePromptParams, + requestOptions: RequestOptions, + ): CompletableFuture<PromptInvokePromptResponse> = + // post /api/v1/prompts/invoke_prompt + withRawResponse().invokePrompt(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + PromptServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PromptServiceAsync.WithRawResponse = + PromptServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val canvasHandler: Handler<PromptCanvasResponse> = + jsonHandler<PromptCanvasResponse>(clientOptions.jsonMapper) + + override fun canvas( + params: PromptCanvasParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<PromptCanvasResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "prompts", "canvas") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { canvasHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val invokePromptHandler: Handler<PromptInvokePromptResponse> = + jsonHandler<PromptInvokePromptResponse>(clientOptions.jsonMapper) + + override fun invokePrompt( + params: PromptInvokePromptParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<PromptInvokePromptResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "prompts", "invoke_prompt") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { invokePromptHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/PromptWebhookServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/PromptWebhookServiceAsync.kt new file mode 100644 index 00000000..f55a43b9 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/PromptWebhookServiceAsync.kt @@ -0,0 +1,381 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhook +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhookDeleteParams +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhookDeleteResponse +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhookPromptWebhooksParams +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhookRetrieveParams +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhookRetrievePromptWebhooksParams +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhookTestParams +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhookTestResponse +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhookUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface PromptWebhookServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): PromptWebhookServiceAsync + + /** Get a specific prompt webhook. */ + fun retrieve(webhookId: String): CompletableFuture<PromptWebhook> = + retrieve(webhookId, PromptWebhookRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + webhookId: String, + params: PromptWebhookRetrieveParams = PromptWebhookRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<PromptWebhook> = + retrieve(params.toBuilder().webhookId(webhookId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + webhookId: String, + params: PromptWebhookRetrieveParams = PromptWebhookRetrieveParams.none(), + ): CompletableFuture<PromptWebhook> = retrieve(webhookId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: PromptWebhookRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<PromptWebhook> + + /** @see retrieve */ + fun retrieve(params: PromptWebhookRetrieveParams): CompletableFuture<PromptWebhook> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + webhookId: String, + requestOptions: RequestOptions, + ): CompletableFuture<PromptWebhook> = + retrieve(webhookId, PromptWebhookRetrieveParams.none(), requestOptions) + + /** Update a specific prompt webhook. */ + fun update(webhookId: String): CompletableFuture<PromptWebhook> = + update(webhookId, PromptWebhookUpdateParams.none()) + + /** @see update */ + fun update( + webhookId: String, + params: PromptWebhookUpdateParams = PromptWebhookUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<PromptWebhook> = + update(params.toBuilder().webhookId(webhookId).build(), requestOptions) + + /** @see update */ + fun update( + webhookId: String, + params: PromptWebhookUpdateParams = PromptWebhookUpdateParams.none(), + ): CompletableFuture<PromptWebhook> = update(webhookId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: PromptWebhookUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<PromptWebhook> + + /** @see update */ + fun update(params: PromptWebhookUpdateParams): CompletableFuture<PromptWebhook> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + webhookId: String, + requestOptions: RequestOptions, + ): CompletableFuture<PromptWebhook> = + update(webhookId, PromptWebhookUpdateParams.none(), requestOptions) + + /** Delete a specific prompt webhook. */ + fun delete(webhookId: String): CompletableFuture<PromptWebhookDeleteResponse> = + delete(webhookId, PromptWebhookDeleteParams.none()) + + /** @see delete */ + fun delete( + webhookId: String, + params: PromptWebhookDeleteParams = PromptWebhookDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<PromptWebhookDeleteResponse> = + delete(params.toBuilder().webhookId(webhookId).build(), requestOptions) + + /** @see delete */ + fun delete( + webhookId: String, + params: PromptWebhookDeleteParams = PromptWebhookDeleteParams.none(), + ): CompletableFuture<PromptWebhookDeleteResponse> = + delete(webhookId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: PromptWebhookDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<PromptWebhookDeleteResponse> + + /** @see delete */ + fun delete(params: PromptWebhookDeleteParams): CompletableFuture<PromptWebhookDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + webhookId: String, + requestOptions: RequestOptions, + ): CompletableFuture<PromptWebhookDeleteResponse> = + delete(webhookId, PromptWebhookDeleteParams.none(), requestOptions) + + /** Create a new prompt webhook. */ + fun promptWebhooks( + params: PromptWebhookPromptWebhooksParams + ): CompletableFuture<PromptWebhook> = promptWebhooks(params, RequestOptions.none()) + + /** @see promptWebhooks */ + fun promptWebhooks( + params: PromptWebhookPromptWebhooksParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<PromptWebhook> + + /** List all prompt webhooks for the current tenant. */ + fun retrievePromptWebhooks(): CompletableFuture<List<PromptWebhook>> = + retrievePromptWebhooks(PromptWebhookRetrievePromptWebhooksParams.none()) + + /** @see retrievePromptWebhooks */ + fun retrievePromptWebhooks( + params: PromptWebhookRetrievePromptWebhooksParams = + PromptWebhookRetrievePromptWebhooksParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<PromptWebhook>> + + /** @see retrievePromptWebhooks */ + fun retrievePromptWebhooks( + params: PromptWebhookRetrievePromptWebhooksParams = + PromptWebhookRetrievePromptWebhooksParams.none() + ): CompletableFuture<List<PromptWebhook>> = + retrievePromptWebhooks(params, RequestOptions.none()) + + /** @see retrievePromptWebhooks */ + fun retrievePromptWebhooks( + requestOptions: RequestOptions + ): CompletableFuture<List<PromptWebhook>> = + retrievePromptWebhooks(PromptWebhookRetrievePromptWebhooksParams.none(), requestOptions) + + /** Test a specific prompt webhook. */ + fun test(params: PromptWebhookTestParams): CompletableFuture<PromptWebhookTestResponse> = + test(params, RequestOptions.none()) + + /** @see test */ + fun test( + params: PromptWebhookTestParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<PromptWebhookTestResponse> + + /** + * A view of [PromptWebhookServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PromptWebhookServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/prompt-webhooks/{webhook_id}`, but is + * otherwise the same as [PromptWebhookServiceAsync.retrieve]. + */ + fun retrieve(webhookId: String): CompletableFuture<HttpResponseFor<PromptWebhook>> = + retrieve(webhookId, PromptWebhookRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + webhookId: String, + params: PromptWebhookRetrieveParams = PromptWebhookRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<PromptWebhook>> = + retrieve(params.toBuilder().webhookId(webhookId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + webhookId: String, + params: PromptWebhookRetrieveParams = PromptWebhookRetrieveParams.none(), + ): CompletableFuture<HttpResponseFor<PromptWebhook>> = + retrieve(webhookId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: PromptWebhookRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<PromptWebhook>> + + /** @see retrieve */ + fun retrieve( + params: PromptWebhookRetrieveParams + ): CompletableFuture<HttpResponseFor<PromptWebhook>> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + webhookId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<PromptWebhook>> = + retrieve(webhookId, PromptWebhookRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `patch /api/v1/prompt-webhooks/{webhook_id}`, but is + * otherwise the same as [PromptWebhookServiceAsync.update]. + */ + fun update(webhookId: String): CompletableFuture<HttpResponseFor<PromptWebhook>> = + update(webhookId, PromptWebhookUpdateParams.none()) + + /** @see update */ + fun update( + webhookId: String, + params: PromptWebhookUpdateParams = PromptWebhookUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<PromptWebhook>> = + update(params.toBuilder().webhookId(webhookId).build(), requestOptions) + + /** @see update */ + fun update( + webhookId: String, + params: PromptWebhookUpdateParams = PromptWebhookUpdateParams.none(), + ): CompletableFuture<HttpResponseFor<PromptWebhook>> = + update(webhookId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: PromptWebhookUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<PromptWebhook>> + + /** @see update */ + fun update( + params: PromptWebhookUpdateParams + ): CompletableFuture<HttpResponseFor<PromptWebhook>> = update(params, RequestOptions.none()) + + /** @see update */ + fun update( + webhookId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<PromptWebhook>> = + update(webhookId, PromptWebhookUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/prompt-webhooks/{webhook_id}`, but is + * otherwise the same as [PromptWebhookServiceAsync.delete]. + */ + fun delete( + webhookId: String + ): CompletableFuture<HttpResponseFor<PromptWebhookDeleteResponse>> = + delete(webhookId, PromptWebhookDeleteParams.none()) + + /** @see delete */ + fun delete( + webhookId: String, + params: PromptWebhookDeleteParams = PromptWebhookDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<PromptWebhookDeleteResponse>> = + delete(params.toBuilder().webhookId(webhookId).build(), requestOptions) + + /** @see delete */ + fun delete( + webhookId: String, + params: PromptWebhookDeleteParams = PromptWebhookDeleteParams.none(), + ): CompletableFuture<HttpResponseFor<PromptWebhookDeleteResponse>> = + delete(webhookId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: PromptWebhookDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<PromptWebhookDeleteResponse>> + + /** @see delete */ + fun delete( + params: PromptWebhookDeleteParams + ): CompletableFuture<HttpResponseFor<PromptWebhookDeleteResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + webhookId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<PromptWebhookDeleteResponse>> = + delete(webhookId, PromptWebhookDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/prompt-webhooks`, but is otherwise the same + * as [PromptWebhookServiceAsync.promptWebhooks]. + */ + fun promptWebhooks( + params: PromptWebhookPromptWebhooksParams + ): CompletableFuture<HttpResponseFor<PromptWebhook>> = + promptWebhooks(params, RequestOptions.none()) + + /** @see promptWebhooks */ + fun promptWebhooks( + params: PromptWebhookPromptWebhooksParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<PromptWebhook>> + + /** + * Returns a raw HTTP response for `get /api/v1/prompt-webhooks`, but is otherwise the same + * as [PromptWebhookServiceAsync.retrievePromptWebhooks]. + */ + fun retrievePromptWebhooks(): CompletableFuture<HttpResponseFor<List<PromptWebhook>>> = + retrievePromptWebhooks(PromptWebhookRetrievePromptWebhooksParams.none()) + + /** @see retrievePromptWebhooks */ + fun retrievePromptWebhooks( + params: PromptWebhookRetrievePromptWebhooksParams = + PromptWebhookRetrievePromptWebhooksParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<PromptWebhook>>> + + /** @see retrievePromptWebhooks */ + fun retrievePromptWebhooks( + params: PromptWebhookRetrievePromptWebhooksParams = + PromptWebhookRetrievePromptWebhooksParams.none() + ): CompletableFuture<HttpResponseFor<List<PromptWebhook>>> = + retrievePromptWebhooks(params, RequestOptions.none()) + + /** @see retrievePromptWebhooks */ + fun retrievePromptWebhooks( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<PromptWebhook>>> = + retrievePromptWebhooks(PromptWebhookRetrievePromptWebhooksParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/prompt-webhooks/test`, but is otherwise the + * same as [PromptWebhookServiceAsync.test]. + */ + fun test( + params: PromptWebhookTestParams + ): CompletableFuture<HttpResponseFor<PromptWebhookTestResponse>> = + test(params, RequestOptions.none()) + + /** @see test */ + fun test( + params: PromptWebhookTestParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<PromptWebhookTestResponse>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/PromptWebhookServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/PromptWebhookServiceAsyncImpl.kt new file mode 100644 index 00000000..3f20b571 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/PromptWebhookServiceAsyncImpl.kt @@ -0,0 +1,292 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhook +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhookDeleteParams +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhookDeleteResponse +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhookPromptWebhooksParams +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhookRetrieveParams +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhookRetrievePromptWebhooksParams +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhookTestParams +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhookTestResponse +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhookUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class PromptWebhookServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + PromptWebhookServiceAsync { + + private val withRawResponse: PromptWebhookServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): PromptWebhookServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): PromptWebhookServiceAsync = + PromptWebhookServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: PromptWebhookRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<PromptWebhook> = + // get /api/v1/prompt-webhooks/{webhook_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: PromptWebhookUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<PromptWebhook> = + // patch /api/v1/prompt-webhooks/{webhook_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: PromptWebhookDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<PromptWebhookDeleteResponse> = + // delete /api/v1/prompt-webhooks/{webhook_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + override fun promptWebhooks( + params: PromptWebhookPromptWebhooksParams, + requestOptions: RequestOptions, + ): CompletableFuture<PromptWebhook> = + // post /api/v1/prompt-webhooks + withRawResponse().promptWebhooks(params, requestOptions).thenApply { it.parse() } + + override fun retrievePromptWebhooks( + params: PromptWebhookRetrievePromptWebhooksParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<PromptWebhook>> = + // get /api/v1/prompt-webhooks + withRawResponse().retrievePromptWebhooks(params, requestOptions).thenApply { it.parse() } + + override fun test( + params: PromptWebhookTestParams, + requestOptions: RequestOptions, + ): CompletableFuture<PromptWebhookTestResponse> = + // post /api/v1/prompt-webhooks/test + withRawResponse().test(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + PromptWebhookServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PromptWebhookServiceAsync.WithRawResponse = + PromptWebhookServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler<PromptWebhook> = + jsonHandler<PromptWebhook>(clientOptions.jsonMapper) + + override fun retrieve( + params: PromptWebhookRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<PromptWebhook>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("webhookId", params.webhookId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "prompt-webhooks", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler<PromptWebhook> = + jsonHandler<PromptWebhook>(clientOptions.jsonMapper) + + override fun update( + params: PromptWebhookUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<PromptWebhook>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("webhookId", params.webhookId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "prompt-webhooks", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val deleteHandler: Handler<PromptWebhookDeleteResponse> = + jsonHandler<PromptWebhookDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: PromptWebhookDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<PromptWebhookDeleteResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("webhookId", params.webhookId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "prompt-webhooks", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val promptWebhooksHandler: Handler<PromptWebhook> = + jsonHandler<PromptWebhook>(clientOptions.jsonMapper) + + override fun promptWebhooks( + params: PromptWebhookPromptWebhooksParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<PromptWebhook>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "prompt-webhooks") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { promptWebhooksHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrievePromptWebhooksHandler: Handler<List<PromptWebhook>> = + jsonHandler<List<PromptWebhook>>(clientOptions.jsonMapper) + + override fun retrievePromptWebhooks( + params: PromptWebhookRetrievePromptWebhooksParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<PromptWebhook>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "prompt-webhooks") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrievePromptWebhooksHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val testHandler: Handler<PromptWebhookTestResponse> = + jsonHandler<PromptWebhookTestResponse>(clientOptions.jsonMapper) + + override fun test( + params: PromptWebhookTestParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<PromptWebhookTestResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "prompt-webhooks", "test") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { testHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/PublicServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/PublicServiceAsync.kt new file mode 100644 index 00000000..12939183 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/PublicServiceAsync.kt @@ -0,0 +1,141 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.feedback.FeedbackSchema +import com.langsmith_api.api.models.api.v1.public_.PublicRetrieveFeedbacksParams +import com.langsmith_api.api.services.async.api.v1.public_.DatasetServiceAsync +import com.langsmith_api.api.services.async.api.v1.public_.ExampleServiceAsync +import com.langsmith_api.api.services.async.api.v1.public_.RunServiceAsync +import com.langsmith_api.api.services.async.api.v1.public_.SchemaServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface PublicServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): PublicServiceAsync + + fun datasets(): DatasetServiceAsync + + fun examples(): ExampleServiceAsync + + fun schemas(): SchemaServiceAsync + + fun runs(): RunServiceAsync + + /** Read Shared Feedbacks */ + fun retrieveFeedbacks(shareToken: String): CompletableFuture<List<FeedbackSchema>> = + retrieveFeedbacks(shareToken, PublicRetrieveFeedbacksParams.none()) + + /** @see retrieveFeedbacks */ + fun retrieveFeedbacks( + shareToken: String, + params: PublicRetrieveFeedbacksParams = PublicRetrieveFeedbacksParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<FeedbackSchema>> = + retrieveFeedbacks(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see retrieveFeedbacks */ + fun retrieveFeedbacks( + shareToken: String, + params: PublicRetrieveFeedbacksParams = PublicRetrieveFeedbacksParams.none(), + ): CompletableFuture<List<FeedbackSchema>> = + retrieveFeedbacks(shareToken, params, RequestOptions.none()) + + /** @see retrieveFeedbacks */ + fun retrieveFeedbacks( + params: PublicRetrieveFeedbacksParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<FeedbackSchema>> + + /** @see retrieveFeedbacks */ + fun retrieveFeedbacks( + params: PublicRetrieveFeedbacksParams + ): CompletableFuture<List<FeedbackSchema>> = retrieveFeedbacks(params, RequestOptions.none()) + + /** @see retrieveFeedbacks */ + fun retrieveFeedbacks( + shareToken: String, + requestOptions: RequestOptions, + ): CompletableFuture<List<FeedbackSchema>> = + retrieveFeedbacks(shareToken, PublicRetrieveFeedbacksParams.none(), requestOptions) + + /** + * A view of [PublicServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PublicServiceAsync.WithRawResponse + + fun datasets(): DatasetServiceAsync.WithRawResponse + + fun examples(): ExampleServiceAsync.WithRawResponse + + fun schemas(): SchemaServiceAsync.WithRawResponse + + fun runs(): RunServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/public/{share_token}/feedbacks`, but is + * otherwise the same as [PublicServiceAsync.retrieveFeedbacks]. + */ + fun retrieveFeedbacks( + shareToken: String + ): CompletableFuture<HttpResponseFor<List<FeedbackSchema>>> = + retrieveFeedbacks(shareToken, PublicRetrieveFeedbacksParams.none()) + + /** @see retrieveFeedbacks */ + fun retrieveFeedbacks( + shareToken: String, + params: PublicRetrieveFeedbacksParams = PublicRetrieveFeedbacksParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<FeedbackSchema>>> = + retrieveFeedbacks(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see retrieveFeedbacks */ + fun retrieveFeedbacks( + shareToken: String, + params: PublicRetrieveFeedbacksParams = PublicRetrieveFeedbacksParams.none(), + ): CompletableFuture<HttpResponseFor<List<FeedbackSchema>>> = + retrieveFeedbacks(shareToken, params, RequestOptions.none()) + + /** @see retrieveFeedbacks */ + fun retrieveFeedbacks( + params: PublicRetrieveFeedbacksParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<FeedbackSchema>>> + + /** @see retrieveFeedbacks */ + fun retrieveFeedbacks( + params: PublicRetrieveFeedbacksParams + ): CompletableFuture<HttpResponseFor<List<FeedbackSchema>>> = + retrieveFeedbacks(params, RequestOptions.none()) + + /** @see retrieveFeedbacks */ + fun retrieveFeedbacks( + shareToken: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<FeedbackSchema>>> = + retrieveFeedbacks(shareToken, PublicRetrieveFeedbacksParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/PublicServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/PublicServiceAsyncImpl.kt new file mode 100644 index 00000000..01ec2a0c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/PublicServiceAsyncImpl.kt @@ -0,0 +1,137 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.feedback.FeedbackSchema +import com.langsmith_api.api.models.api.v1.public_.PublicRetrieveFeedbacksParams +import com.langsmith_api.api.services.async.api.v1.public_.DatasetServiceAsync +import com.langsmith_api.api.services.async.api.v1.public_.DatasetServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.public_.ExampleServiceAsync +import com.langsmith_api.api.services.async.api.v1.public_.ExampleServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.public_.RunServiceAsync +import com.langsmith_api.api.services.async.api.v1.public_.RunServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.public_.SchemaServiceAsync +import com.langsmith_api.api.services.async.api.v1.public_.SchemaServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class PublicServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + PublicServiceAsync { + + private val withRawResponse: PublicServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val datasets: DatasetServiceAsync by lazy { DatasetServiceAsyncImpl(clientOptions) } + + private val examples: ExampleServiceAsync by lazy { ExampleServiceAsyncImpl(clientOptions) } + + private val schemas: SchemaServiceAsync by lazy { SchemaServiceAsyncImpl(clientOptions) } + + private val runs: RunServiceAsync by lazy { RunServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): PublicServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): PublicServiceAsync = + PublicServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun datasets(): DatasetServiceAsync = datasets + + override fun examples(): ExampleServiceAsync = examples + + override fun schemas(): SchemaServiceAsync = schemas + + override fun runs(): RunServiceAsync = runs + + override fun retrieveFeedbacks( + params: PublicRetrieveFeedbacksParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<FeedbackSchema>> = + // get /api/v1/public/{share_token}/feedbacks + withRawResponse().retrieveFeedbacks(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + PublicServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val datasets: DatasetServiceAsync.WithRawResponse by lazy { + DatasetServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val examples: ExampleServiceAsync.WithRawResponse by lazy { + ExampleServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val schemas: SchemaServiceAsync.WithRawResponse by lazy { + SchemaServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val runs: RunServiceAsync.WithRawResponse by lazy { + RunServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PublicServiceAsync.WithRawResponse = + PublicServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun datasets(): DatasetServiceAsync.WithRawResponse = datasets + + override fun examples(): ExampleServiceAsync.WithRawResponse = examples + + override fun schemas(): SchemaServiceAsync.WithRawResponse = schemas + + override fun runs(): RunServiceAsync.WithRawResponse = runs + + private val retrieveFeedbacksHandler: Handler<List<FeedbackSchema>> = + jsonHandler<List<FeedbackSchema>>(clientOptions.jsonMapper) + + override fun retrieveFeedbacks( + params: PublicRetrieveFeedbacksParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<FeedbackSchema>>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("shareToken", params.shareToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "public", params._pathParam(0), "feedbacks") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveFeedbacksHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/RepoServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/RepoServiceAsync.kt new file mode 100644 index 00000000..18934423 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/RepoServiceAsync.kt @@ -0,0 +1,355 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.repos.CreateRepoResponse +import com.langsmith_api.api.models.api.v1.repos.GetRepoResponse +import com.langsmith_api.api.models.api.v1.repos.RepoCreateParams +import com.langsmith_api.api.models.api.v1.repos.RepoDeleteParams +import com.langsmith_api.api.models.api.v1.repos.RepoDeleteResponse +import com.langsmith_api.api.models.api.v1.repos.RepoForkParams +import com.langsmith_api.api.models.api.v1.repos.RepoListParams +import com.langsmith_api.api.models.api.v1.repos.RepoListResponse +import com.langsmith_api.api.models.api.v1.repos.RepoOptimizeJobParams +import com.langsmith_api.api.models.api.v1.repos.RepoOptimizeJobResponse +import com.langsmith_api.api.models.api.v1.repos.RepoRetrieveParams +import com.langsmith_api.api.models.api.v1.repos.RepoUpdateParams +import com.langsmith_api.api.services.async.api.v1.repos.OptimizationJobServiceAsync +import com.langsmith_api.api.services.async.api.v1.repos.TagServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface RepoServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RepoServiceAsync + + fun tags(): TagServiceAsync + + fun optimizationJobs(): OptimizationJobServiceAsync + + /** Create a repo. */ + fun create(params: RepoCreateParams): CompletableFuture<CreateRepoResponse> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: RepoCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CreateRepoResponse> + + /** Get a repo. */ + fun retrieve(repo: String, params: RepoRetrieveParams): CompletableFuture<GetRepoResponse> = + retrieve(repo, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + repo: String, + params: RepoRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<GetRepoResponse> = + retrieve(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: RepoRetrieveParams): CompletableFuture<GetRepoResponse> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: RepoRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<GetRepoResponse> + + /** Update a repo. */ + fun update(repo: String, params: RepoUpdateParams): CompletableFuture<CreateRepoResponse> = + update(repo, params, RequestOptions.none()) + + /** @see update */ + fun update( + repo: String, + params: RepoUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CreateRepoResponse> = + update(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see update */ + fun update(params: RepoUpdateParams): CompletableFuture<CreateRepoResponse> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: RepoUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CreateRepoResponse> + + /** Get all repos. */ + fun list(): CompletableFuture<RepoListResponse> = list(RepoListParams.none()) + + /** @see list */ + fun list( + params: RepoListParams = RepoListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RepoListResponse> + + /** @see list */ + fun list(params: RepoListParams = RepoListParams.none()): CompletableFuture<RepoListResponse> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture<RepoListResponse> = + list(RepoListParams.none(), requestOptions) + + /** Delete a repo. */ + fun delete(repo: String, params: RepoDeleteParams): CompletableFuture<RepoDeleteResponse> = + delete(repo, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + repo: String, + params: RepoDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RepoDeleteResponse> = + delete(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see delete */ + fun delete(params: RepoDeleteParams): CompletableFuture<RepoDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: RepoDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RepoDeleteResponse> + + /** Fork a repo. */ + fun fork(repo: String, params: RepoForkParams): CompletableFuture<GetRepoResponse> = + fork(repo, params, RequestOptions.none()) + + /** @see fork */ + fun fork( + repo: String, + params: RepoForkParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<GetRepoResponse> = + fork(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see fork */ + fun fork(params: RepoForkParams): CompletableFuture<GetRepoResponse> = + fork(params, RequestOptions.none()) + + /** @see fork */ + fun fork( + params: RepoForkParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<GetRepoResponse> + + /** Optimize prompt */ + fun optimizeJob(params: RepoOptimizeJobParams): CompletableFuture<RepoOptimizeJobResponse> = + optimizeJob(params, RequestOptions.none()) + + /** @see optimizeJob */ + fun optimizeJob( + params: RepoOptimizeJobParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RepoOptimizeJobResponse> + + /** A view of [RepoServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RepoServiceAsync.WithRawResponse + + fun tags(): TagServiceAsync.WithRawResponse + + fun optimizationJobs(): OptimizationJobServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/repos`, but is otherwise the same as + * [RepoServiceAsync.create]. + */ + fun create( + params: RepoCreateParams + ): CompletableFuture<HttpResponseFor<CreateRepoResponse>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: RepoCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CreateRepoResponse>> + + /** + * Returns a raw HTTP response for `get /api/v1/repos/{owner}/{repo}`, but is otherwise the + * same as [RepoServiceAsync.retrieve]. + */ + fun retrieve( + repo: String, + params: RepoRetrieveParams, + ): CompletableFuture<HttpResponseFor<GetRepoResponse>> = + retrieve(repo, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + repo: String, + params: RepoRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<GetRepoResponse>> = + retrieve(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + params: RepoRetrieveParams + ): CompletableFuture<HttpResponseFor<GetRepoResponse>> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: RepoRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<GetRepoResponse>> + + /** + * Returns a raw HTTP response for `patch /api/v1/repos/{owner}/{repo}`, but is otherwise + * the same as [RepoServiceAsync.update]. + */ + fun update( + repo: String, + params: RepoUpdateParams, + ): CompletableFuture<HttpResponseFor<CreateRepoResponse>> = + update(repo, params, RequestOptions.none()) + + /** @see update */ + fun update( + repo: String, + params: RepoUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CreateRepoResponse>> = + update(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see update */ + fun update( + params: RepoUpdateParams + ): CompletableFuture<HttpResponseFor<CreateRepoResponse>> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: RepoUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CreateRepoResponse>> + + /** + * Returns a raw HTTP response for `get /api/v1/repos`, but is otherwise the same as + * [RepoServiceAsync.list]. + */ + fun list(): CompletableFuture<HttpResponseFor<RepoListResponse>> = + list(RepoListParams.none()) + + /** @see list */ + fun list( + params: RepoListParams = RepoListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RepoListResponse>> + + /** @see list */ + fun list( + params: RepoListParams = RepoListParams.none() + ): CompletableFuture<HttpResponseFor<RepoListResponse>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<RepoListResponse>> = + list(RepoListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/repos/{owner}/{repo}`, but is otherwise + * the same as [RepoServiceAsync.delete]. + */ + fun delete( + repo: String, + params: RepoDeleteParams, + ): CompletableFuture<HttpResponseFor<RepoDeleteResponse>> = + delete(repo, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + repo: String, + params: RepoDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RepoDeleteResponse>> = + delete(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see delete */ + fun delete( + params: RepoDeleteParams + ): CompletableFuture<HttpResponseFor<RepoDeleteResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: RepoDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RepoDeleteResponse>> + + /** + * Returns a raw HTTP response for `post /api/v1/repos/{owner}/{repo}/fork`, but is + * otherwise the same as [RepoServiceAsync.fork]. + */ + fun fork( + repo: String, + params: RepoForkParams, + ): CompletableFuture<HttpResponseFor<GetRepoResponse>> = + fork(repo, params, RequestOptions.none()) + + /** @see fork */ + fun fork( + repo: String, + params: RepoForkParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<GetRepoResponse>> = + fork(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see fork */ + fun fork(params: RepoForkParams): CompletableFuture<HttpResponseFor<GetRepoResponse>> = + fork(params, RequestOptions.none()) + + /** @see fork */ + fun fork( + params: RepoForkParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<GetRepoResponse>> + + /** + * Returns a raw HTTP response for `post /api/v1/repos/optimize-job`, but is otherwise the + * same as [RepoServiceAsync.optimizeJob]. + */ + fun optimizeJob( + params: RepoOptimizeJobParams + ): CompletableFuture<HttpResponseFor<RepoOptimizeJobResponse>> = + optimizeJob(params, RequestOptions.none()) + + /** @see optimizeJob */ + fun optimizeJob( + params: RepoOptimizeJobParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RepoOptimizeJobResponse>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/RepoServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/RepoServiceAsyncImpl.kt new file mode 100644 index 00000000..ac525c23 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/RepoServiceAsyncImpl.kt @@ -0,0 +1,388 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.repos.CreateRepoResponse +import com.langsmith_api.api.models.api.v1.repos.GetRepoResponse +import com.langsmith_api.api.models.api.v1.repos.RepoCreateParams +import com.langsmith_api.api.models.api.v1.repos.RepoDeleteParams +import com.langsmith_api.api.models.api.v1.repos.RepoDeleteResponse +import com.langsmith_api.api.models.api.v1.repos.RepoForkParams +import com.langsmith_api.api.models.api.v1.repos.RepoListParams +import com.langsmith_api.api.models.api.v1.repos.RepoListResponse +import com.langsmith_api.api.models.api.v1.repos.RepoOptimizeJobParams +import com.langsmith_api.api.models.api.v1.repos.RepoOptimizeJobResponse +import com.langsmith_api.api.models.api.v1.repos.RepoRetrieveParams +import com.langsmith_api.api.models.api.v1.repos.RepoUpdateParams +import com.langsmith_api.api.services.async.api.v1.repos.OptimizationJobServiceAsync +import com.langsmith_api.api.services.async.api.v1.repos.OptimizationJobServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.repos.TagServiceAsync +import com.langsmith_api.api.services.async.api.v1.repos.TagServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class RepoServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + RepoServiceAsync { + + private val withRawResponse: RepoServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val tags: TagServiceAsync by lazy { TagServiceAsyncImpl(clientOptions) } + + private val optimizationJobs: OptimizationJobServiceAsync by lazy { + OptimizationJobServiceAsyncImpl(clientOptions) + } + + override fun withRawResponse(): RepoServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): RepoServiceAsync = + RepoServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun tags(): TagServiceAsync = tags + + override fun optimizationJobs(): OptimizationJobServiceAsync = optimizationJobs + + override fun create( + params: RepoCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<CreateRepoResponse> = + // post /api/v1/repos + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun retrieve( + params: RepoRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<GetRepoResponse> = + // get /api/v1/repos/{owner}/{repo} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: RepoUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<CreateRepoResponse> = + // patch /api/v1/repos/{owner}/{repo} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: RepoListParams, + requestOptions: RequestOptions, + ): CompletableFuture<RepoListResponse> = + // get /api/v1/repos + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: RepoDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<RepoDeleteResponse> = + // delete /api/v1/repos/{owner}/{repo} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + override fun fork( + params: RepoForkParams, + requestOptions: RequestOptions, + ): CompletableFuture<GetRepoResponse> = + // post /api/v1/repos/{owner}/{repo}/fork + withRawResponse().fork(params, requestOptions).thenApply { it.parse() } + + override fun optimizeJob( + params: RepoOptimizeJobParams, + requestOptions: RequestOptions, + ): CompletableFuture<RepoOptimizeJobResponse> = + // post /api/v1/repos/optimize-job + withRawResponse().optimizeJob(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RepoServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val tags: TagServiceAsync.WithRawResponse by lazy { + TagServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val optimizationJobs: OptimizationJobServiceAsync.WithRawResponse by lazy { + OptimizationJobServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): RepoServiceAsync.WithRawResponse = + RepoServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun tags(): TagServiceAsync.WithRawResponse = tags + + override fun optimizationJobs(): OptimizationJobServiceAsync.WithRawResponse = + optimizationJobs + + private val createHandler: Handler<CreateRepoResponse> = + jsonHandler<CreateRepoResponse>(clientOptions.jsonMapper) + + override fun create( + params: RepoCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<CreateRepoResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "repos") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler<GetRepoResponse> = + jsonHandler<GetRepoResponse>(clientOptions.jsonMapper) + + override fun retrieve( + params: RepoRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<GetRepoResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("repo", params.repo().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "repos", + params._pathParam(0), + params._pathParam(1), + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler<CreateRepoResponse> = + jsonHandler<CreateRepoResponse>(clientOptions.jsonMapper) + + override fun update( + params: RepoUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<CreateRepoResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("repo", params.repo().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "repos", + params._pathParam(0), + params._pathParam(1), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler<RepoListResponse> = + jsonHandler<RepoListResponse>(clientOptions.jsonMapper) + + override fun list( + params: RepoListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<RepoListResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "repos") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val deleteHandler: Handler<RepoDeleteResponse> = + jsonHandler<RepoDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: RepoDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<RepoDeleteResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("repo", params.repo().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "repos", + params._pathParam(0), + params._pathParam(1), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val forkHandler: Handler<GetRepoResponse> = + jsonHandler<GetRepoResponse>(clientOptions.jsonMapper) + + override fun fork( + params: RepoForkParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<GetRepoResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("repo", params.repo().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "repos", + params._pathParam(0), + params._pathParam(1), + "fork", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { forkHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val optimizeJobHandler: Handler<RepoOptimizeJobResponse> = + jsonHandler<RepoOptimizeJobResponse>(clientOptions.jsonMapper) + + override fun optimizeJob( + params: RepoOptimizeJobParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<RepoOptimizeJobResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "repos", "optimize-job") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { optimizeJobHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/RunServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/RunServiceAsync.kt new file mode 100644 index 00000000..673b3741 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/RunServiceAsync.kt @@ -0,0 +1,421 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.runs.BodyParamsForRunSchema +import com.langsmith_api.api.models.api.v1.runs.RequestBodyForRunsGenerateQuery +import com.langsmith_api.api.models.api.v1.runs.ResponseBodyForRunsGenerateQuery +import com.langsmith_api.api.models.api.v1.runs.RunDeleteParams +import com.langsmith_api.api.models.api.v1.runs.RunDeleteResponse +import com.langsmith_api.api.models.api.v1.runs.RunGenerateQueryParams +import com.langsmith_api.api.models.api.v1.runs.RunQueryParams +import com.langsmith_api.api.models.api.v1.runs.RunQueryResponse +import com.langsmith_api.api.models.api.v1.runs.RunRetrieveParams +import com.langsmith_api.api.models.api.v1.runs.RunSchema +import com.langsmith_api.api.models.api.v1.runs.RunStatsParams +import com.langsmith_api.api.models.api.v1.runs.RunStatsQueryParams +import com.langsmith_api.api.models.api.v1.runs.RunStatsResponse +import com.langsmith_api.api.models.api.v1.runs.RunUpdateParams +import com.langsmith_api.api.models.api.v1.runs.RunUpdateResponse +import com.langsmith_api.api.services.async.api.v1.runs.GroupServiceAsync +import com.langsmith_api.api.services.async.api.v1.runs.RuleServiceAsync +import com.langsmith_api.api.services.async.api.v1.runs.ShareServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface RunServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunServiceAsync + + fun rules(): RuleServiceAsync + + fun share(): ShareServiceAsync + + fun group(): GroupServiceAsync + + /** Get a specific run. */ + fun retrieve(runId: String): CompletableFuture<RunSchema> = + retrieve(runId, RunRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + runId: String, + params: RunRetrieveParams = RunRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RunSchema> = + retrieve(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + runId: String, + params: RunRetrieveParams = RunRetrieveParams.none(), + ): CompletableFuture<RunSchema> = retrieve(runId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: RunRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RunSchema> + + /** @see retrieve */ + fun retrieve(params: RunRetrieveParams): CompletableFuture<RunSchema> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(runId: String, requestOptions: RequestOptions): CompletableFuture<RunSchema> = + retrieve(runId, RunRetrieveParams.none(), requestOptions) + + /** Update a run. */ + fun update(runId: String): CompletableFuture<RunUpdateResponse> = + update(runId, RunUpdateParams.none()) + + /** @see update */ + fun update( + runId: String, + params: RunUpdateParams = RunUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RunUpdateResponse> = + update(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see update */ + fun update( + runId: String, + params: RunUpdateParams = RunUpdateParams.none(), + ): CompletableFuture<RunUpdateResponse> = update(runId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: RunUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RunUpdateResponse> + + /** @see update */ + fun update(params: RunUpdateParams): CompletableFuture<RunUpdateResponse> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + runId: String, + requestOptions: RequestOptions, + ): CompletableFuture<RunUpdateResponse> = update(runId, RunUpdateParams.none(), requestOptions) + + /** Delete specific runs by trace IDs or metadata key-value pairs. */ + fun delete(): CompletableFuture<RunDeleteResponse> = delete(RunDeleteParams.none()) + + /** @see delete */ + fun delete( + params: RunDeleteParams = RunDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RunDeleteResponse> + + /** @see delete */ + fun delete( + params: RunDeleteParams = RunDeleteParams.none() + ): CompletableFuture<RunDeleteResponse> = delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(requestOptions: RequestOptions): CompletableFuture<RunDeleteResponse> = + delete(RunDeleteParams.none(), requestOptions) + + /** Get runs filter expression query for a given natural language query. */ + fun generateQuery( + params: RunGenerateQueryParams + ): CompletableFuture<ResponseBodyForRunsGenerateQuery> = + generateQuery(params, RequestOptions.none()) + + /** @see generateQuery */ + fun generateQuery( + params: RunGenerateQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ResponseBodyForRunsGenerateQuery> + + /** @see generateQuery */ + fun generateQuery( + requestBodyForRunsGenerateQuery: RequestBodyForRunsGenerateQuery, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ResponseBodyForRunsGenerateQuery> = + generateQuery( + RunGenerateQueryParams.builder() + .requestBodyForRunsGenerateQuery(requestBodyForRunsGenerateQuery) + .build(), + requestOptions, + ) + + /** @see generateQuery */ + fun generateQuery( + requestBodyForRunsGenerateQuery: RequestBodyForRunsGenerateQuery + ): CompletableFuture<ResponseBodyForRunsGenerateQuery> = + generateQuery(requestBodyForRunsGenerateQuery, RequestOptions.none()) + + /** Query Runs */ + fun query(params: RunQueryParams): CompletableFuture<RunQueryResponse> = + query(params, RequestOptions.none()) + + /** @see query */ + fun query( + params: RunQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RunQueryResponse> + + /** @see query */ + fun query( + bodyParamsForRunSchema: BodyParamsForRunSchema, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RunQueryResponse> = + query( + RunQueryParams.builder().bodyParamsForRunSchema(bodyParamsForRunSchema).build(), + requestOptions, + ) + + /** @see query */ + fun query(bodyParamsForRunSchema: BodyParamsForRunSchema): CompletableFuture<RunQueryResponse> = + query(bodyParamsForRunSchema, RequestOptions.none()) + + /** Get all runs by query in body payload. */ + fun stats(params: RunStatsParams): CompletableFuture<RunStatsResponse> = + stats(params, RequestOptions.none()) + + /** @see stats */ + fun stats( + params: RunStatsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RunStatsResponse> + + /** @see stats */ + fun stats( + runStatsQueryParams: RunStatsQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RunStatsResponse> = + stats( + RunStatsParams.builder().runStatsQueryParams(runStatsQueryParams).build(), + requestOptions, + ) + + /** @see stats */ + fun stats(runStatsQueryParams: RunStatsQueryParams): CompletableFuture<RunStatsResponse> = + stats(runStatsQueryParams, RequestOptions.none()) + + /** A view of [RunServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunServiceAsync.WithRawResponse + + fun rules(): RuleServiceAsync.WithRawResponse + + fun share(): ShareServiceAsync.WithRawResponse + + fun group(): GroupServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/runs/{run_id}`, but is otherwise the same as + * [RunServiceAsync.retrieve]. + */ + fun retrieve(runId: String): CompletableFuture<HttpResponseFor<RunSchema>> = + retrieve(runId, RunRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + runId: String, + params: RunRetrieveParams = RunRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RunSchema>> = + retrieve(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + runId: String, + params: RunRetrieveParams = RunRetrieveParams.none(), + ): CompletableFuture<HttpResponseFor<RunSchema>> = + retrieve(runId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: RunRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RunSchema>> + + /** @see retrieve */ + fun retrieve(params: RunRetrieveParams): CompletableFuture<HttpResponseFor<RunSchema>> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + runId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<RunSchema>> = + retrieve(runId, RunRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `patch /api/v1/runs/{run_id}`, but is otherwise the same + * as [RunServiceAsync.update]. + */ + fun update(runId: String): CompletableFuture<HttpResponseFor<RunUpdateResponse>> = + update(runId, RunUpdateParams.none()) + + /** @see update */ + fun update( + runId: String, + params: RunUpdateParams = RunUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RunUpdateResponse>> = + update(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see update */ + fun update( + runId: String, + params: RunUpdateParams = RunUpdateParams.none(), + ): CompletableFuture<HttpResponseFor<RunUpdateResponse>> = + update(runId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: RunUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RunUpdateResponse>> + + /** @see update */ + fun update(params: RunUpdateParams): CompletableFuture<HttpResponseFor<RunUpdateResponse>> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + runId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<RunUpdateResponse>> = + update(runId, RunUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/runs/delete`, but is otherwise the same as + * [RunServiceAsync.delete]. + */ + fun delete(): CompletableFuture<HttpResponseFor<RunDeleteResponse>> = + delete(RunDeleteParams.none()) + + /** @see delete */ + fun delete( + params: RunDeleteParams = RunDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RunDeleteResponse>> + + /** @see delete */ + fun delete( + params: RunDeleteParams = RunDeleteParams.none() + ): CompletableFuture<HttpResponseFor<RunDeleteResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<RunDeleteResponse>> = + delete(RunDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/runs/generate-query`, but is otherwise the + * same as [RunServiceAsync.generateQuery]. + */ + fun generateQuery( + params: RunGenerateQueryParams + ): CompletableFuture<HttpResponseFor<ResponseBodyForRunsGenerateQuery>> = + generateQuery(params, RequestOptions.none()) + + /** @see generateQuery */ + fun generateQuery( + params: RunGenerateQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ResponseBodyForRunsGenerateQuery>> + + /** @see generateQuery */ + fun generateQuery( + requestBodyForRunsGenerateQuery: RequestBodyForRunsGenerateQuery, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ResponseBodyForRunsGenerateQuery>> = + generateQuery( + RunGenerateQueryParams.builder() + .requestBodyForRunsGenerateQuery(requestBodyForRunsGenerateQuery) + .build(), + requestOptions, + ) + + /** @see generateQuery */ + fun generateQuery( + requestBodyForRunsGenerateQuery: RequestBodyForRunsGenerateQuery + ): CompletableFuture<HttpResponseFor<ResponseBodyForRunsGenerateQuery>> = + generateQuery(requestBodyForRunsGenerateQuery, RequestOptions.none()) + + /** + * Returns a raw HTTP response for `post /api/v1/runs/query`, but is otherwise the same as + * [RunServiceAsync.query]. + */ + fun query(params: RunQueryParams): CompletableFuture<HttpResponseFor<RunQueryResponse>> = + query(params, RequestOptions.none()) + + /** @see query */ + fun query( + params: RunQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RunQueryResponse>> + + /** @see query */ + fun query( + bodyParamsForRunSchema: BodyParamsForRunSchema, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RunQueryResponse>> = + query( + RunQueryParams.builder().bodyParamsForRunSchema(bodyParamsForRunSchema).build(), + requestOptions, + ) + + /** @see query */ + fun query( + bodyParamsForRunSchema: BodyParamsForRunSchema + ): CompletableFuture<HttpResponseFor<RunQueryResponse>> = + query(bodyParamsForRunSchema, RequestOptions.none()) + + /** + * Returns a raw HTTP response for `post /api/v1/runs/stats`, but is otherwise the same as + * [RunServiceAsync.stats]. + */ + fun stats(params: RunStatsParams): CompletableFuture<HttpResponseFor<RunStatsResponse>> = + stats(params, RequestOptions.none()) + + /** @see stats */ + fun stats( + params: RunStatsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RunStatsResponse>> + + /** @see stats */ + fun stats( + runStatsQueryParams: RunStatsQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RunStatsResponse>> = + stats( + RunStatsParams.builder().runStatsQueryParams(runStatsQueryParams).build(), + requestOptions, + ) + + /** @see stats */ + fun stats( + runStatsQueryParams: RunStatsQueryParams + ): CompletableFuture<HttpResponseFor<RunStatsResponse>> = + stats(runStatsQueryParams, RequestOptions.none()) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/RunServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/RunServiceAsyncImpl.kt new file mode 100644 index 00000000..9d3436de --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/RunServiceAsyncImpl.kt @@ -0,0 +1,329 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.runs.ResponseBodyForRunsGenerateQuery +import com.langsmith_api.api.models.api.v1.runs.RunDeleteParams +import com.langsmith_api.api.models.api.v1.runs.RunDeleteResponse +import com.langsmith_api.api.models.api.v1.runs.RunGenerateQueryParams +import com.langsmith_api.api.models.api.v1.runs.RunQueryParams +import com.langsmith_api.api.models.api.v1.runs.RunQueryResponse +import com.langsmith_api.api.models.api.v1.runs.RunRetrieveParams +import com.langsmith_api.api.models.api.v1.runs.RunSchema +import com.langsmith_api.api.models.api.v1.runs.RunStatsParams +import com.langsmith_api.api.models.api.v1.runs.RunStatsResponse +import com.langsmith_api.api.models.api.v1.runs.RunUpdateParams +import com.langsmith_api.api.models.api.v1.runs.RunUpdateResponse +import com.langsmith_api.api.services.async.api.v1.runs.GroupServiceAsync +import com.langsmith_api.api.services.async.api.v1.runs.GroupServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.runs.RuleServiceAsync +import com.langsmith_api.api.services.async.api.v1.runs.RuleServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.runs.ShareServiceAsync +import com.langsmith_api.api.services.async.api.v1.runs.ShareServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class RunServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + RunServiceAsync { + + private val withRawResponse: RunServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val rules: RuleServiceAsync by lazy { RuleServiceAsyncImpl(clientOptions) } + + private val share: ShareServiceAsync by lazy { ShareServiceAsyncImpl(clientOptions) } + + private val group: GroupServiceAsync by lazy { GroupServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): RunServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunServiceAsync = + RunServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun rules(): RuleServiceAsync = rules + + override fun share(): ShareServiceAsync = share + + override fun group(): GroupServiceAsync = group + + override fun retrieve( + params: RunRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<RunSchema> = + // get /api/v1/runs/{run_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: RunUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<RunUpdateResponse> = + // patch /api/v1/runs/{run_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: RunDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<RunDeleteResponse> = + // post /api/v1/runs/delete + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + override fun generateQuery( + params: RunGenerateQueryParams, + requestOptions: RequestOptions, + ): CompletableFuture<ResponseBodyForRunsGenerateQuery> = + // post /api/v1/runs/generate-query + withRawResponse().generateQuery(params, requestOptions).thenApply { it.parse() } + + override fun query( + params: RunQueryParams, + requestOptions: RequestOptions, + ): CompletableFuture<RunQueryResponse> = + // post /api/v1/runs/query + withRawResponse().query(params, requestOptions).thenApply { it.parse() } + + override fun stats( + params: RunStatsParams, + requestOptions: RequestOptions, + ): CompletableFuture<RunStatsResponse> = + // post /api/v1/runs/stats + withRawResponse().stats(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RunServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val rules: RuleServiceAsync.WithRawResponse by lazy { + RuleServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val share: ShareServiceAsync.WithRawResponse by lazy { + ShareServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val group: GroupServiceAsync.WithRawResponse by lazy { + GroupServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): RunServiceAsync.WithRawResponse = + RunServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun rules(): RuleServiceAsync.WithRawResponse = rules + + override fun share(): ShareServiceAsync.WithRawResponse = share + + override fun group(): GroupServiceAsync.WithRawResponse = group + + private val retrieveHandler: Handler<RunSchema> = + jsonHandler<RunSchema>(clientOptions.jsonMapper) + + override fun retrieve( + params: RunRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<RunSchema>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("runId", params.runId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler<RunUpdateResponse> = + jsonHandler<RunUpdateResponse>(clientOptions.jsonMapper) + + override fun update( + params: RunUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<RunUpdateResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("runId", params.runId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val deleteHandler: Handler<RunDeleteResponse> = + jsonHandler<RunDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: RunDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<RunDeleteResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", "delete") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val generateQueryHandler: Handler<ResponseBodyForRunsGenerateQuery> = + jsonHandler<ResponseBodyForRunsGenerateQuery>(clientOptions.jsonMapper) + + override fun generateQuery( + params: RunGenerateQueryParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ResponseBodyForRunsGenerateQuery>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", "generate-query") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { generateQueryHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val queryHandler: Handler<RunQueryResponse> = + jsonHandler<RunQueryResponse>(clientOptions.jsonMapper) + + override fun query( + params: RunQueryParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<RunQueryResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", "query") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { queryHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val statsHandler: Handler<RunStatsResponse> = + jsonHandler<RunStatsResponse>(clientOptions.jsonMapper) + + override fun stats( + params: RunStatsParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<RunStatsResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", "stats") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { statsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ServiceAccountServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ServiceAccountServiceAsync.kt new file mode 100644 index 00000000..a397c9a2 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ServiceAccountServiceAsync.kt @@ -0,0 +1,210 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.serviceaccounts.ServiceAccountDeleteParams +import com.langsmith_api.api.models.api.v1.serviceaccounts.ServiceAccountDeleteResponse +import com.langsmith_api.api.models.api.v1.serviceaccounts.ServiceAccountRetrieveServiceAccountsParams +import com.langsmith_api.api.models.api.v1.serviceaccounts.ServiceAccountRetrieveServiceAccountsResponse +import com.langsmith_api.api.models.api.v1.serviceaccounts.ServiceAccountServiceAccountsParams +import com.langsmith_api.api.models.api.v1.serviceaccounts.ServiceAccountServiceAccountsResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface ServiceAccountServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ServiceAccountServiceAsync + + /** Delete a service account */ + fun delete(serviceAccountId: String): CompletableFuture<ServiceAccountDeleteResponse> = + delete(serviceAccountId, ServiceAccountDeleteParams.none()) + + /** @see delete */ + fun delete( + serviceAccountId: String, + params: ServiceAccountDeleteParams = ServiceAccountDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ServiceAccountDeleteResponse> = + delete(params.toBuilder().serviceAccountId(serviceAccountId).build(), requestOptions) + + /** @see delete */ + fun delete( + serviceAccountId: String, + params: ServiceAccountDeleteParams = ServiceAccountDeleteParams.none(), + ): CompletableFuture<ServiceAccountDeleteResponse> = + delete(serviceAccountId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ServiceAccountDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ServiceAccountDeleteResponse> + + /** @see delete */ + fun delete( + params: ServiceAccountDeleteParams + ): CompletableFuture<ServiceAccountDeleteResponse> = delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + serviceAccountId: String, + requestOptions: RequestOptions, + ): CompletableFuture<ServiceAccountDeleteResponse> = + delete(serviceAccountId, ServiceAccountDeleteParams.none(), requestOptions) + + /** Get the current organization's service accounts. */ + fun retrieveServiceAccounts(): + CompletableFuture<List<ServiceAccountRetrieveServiceAccountsResponse>> = + retrieveServiceAccounts(ServiceAccountRetrieveServiceAccountsParams.none()) + + /** @see retrieveServiceAccounts */ + fun retrieveServiceAccounts( + params: ServiceAccountRetrieveServiceAccountsParams = + ServiceAccountRetrieveServiceAccountsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<ServiceAccountRetrieveServiceAccountsResponse>> + + /** @see retrieveServiceAccounts */ + fun retrieveServiceAccounts( + params: ServiceAccountRetrieveServiceAccountsParams = + ServiceAccountRetrieveServiceAccountsParams.none() + ): CompletableFuture<List<ServiceAccountRetrieveServiceAccountsResponse>> = + retrieveServiceAccounts(params, RequestOptions.none()) + + /** @see retrieveServiceAccounts */ + fun retrieveServiceAccounts( + requestOptions: RequestOptions + ): CompletableFuture<List<ServiceAccountRetrieveServiceAccountsResponse>> = + retrieveServiceAccounts(ServiceAccountRetrieveServiceAccountsParams.none(), requestOptions) + + /** Create a service account */ + fun serviceAccounts( + params: ServiceAccountServiceAccountsParams + ): CompletableFuture<ServiceAccountServiceAccountsResponse> = + serviceAccounts(params, RequestOptions.none()) + + /** @see serviceAccounts */ + fun serviceAccounts( + params: ServiceAccountServiceAccountsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ServiceAccountServiceAccountsResponse> + + /** + * A view of [ServiceAccountServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ServiceAccountServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `delete /api/v1/service-accounts/{service_account_id}`, + * but is otherwise the same as [ServiceAccountServiceAsync.delete]. + */ + fun delete( + serviceAccountId: String + ): CompletableFuture<HttpResponseFor<ServiceAccountDeleteResponse>> = + delete(serviceAccountId, ServiceAccountDeleteParams.none()) + + /** @see delete */ + fun delete( + serviceAccountId: String, + params: ServiceAccountDeleteParams = ServiceAccountDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ServiceAccountDeleteResponse>> = + delete(params.toBuilder().serviceAccountId(serviceAccountId).build(), requestOptions) + + /** @see delete */ + fun delete( + serviceAccountId: String, + params: ServiceAccountDeleteParams = ServiceAccountDeleteParams.none(), + ): CompletableFuture<HttpResponseFor<ServiceAccountDeleteResponse>> = + delete(serviceAccountId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ServiceAccountDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ServiceAccountDeleteResponse>> + + /** @see delete */ + fun delete( + params: ServiceAccountDeleteParams + ): CompletableFuture<HttpResponseFor<ServiceAccountDeleteResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + serviceAccountId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ServiceAccountDeleteResponse>> = + delete(serviceAccountId, ServiceAccountDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/service-accounts`, but is otherwise the same + * as [ServiceAccountServiceAsync.retrieveServiceAccounts]. + */ + fun retrieveServiceAccounts(): + CompletableFuture< + HttpResponseFor<List<ServiceAccountRetrieveServiceAccountsResponse>> + > = retrieveServiceAccounts(ServiceAccountRetrieveServiceAccountsParams.none()) + + /** @see retrieveServiceAccounts */ + fun retrieveServiceAccounts( + params: ServiceAccountRetrieveServiceAccountsParams = + ServiceAccountRetrieveServiceAccountsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<ServiceAccountRetrieveServiceAccountsResponse>>> + + /** @see retrieveServiceAccounts */ + fun retrieveServiceAccounts( + params: ServiceAccountRetrieveServiceAccountsParams = + ServiceAccountRetrieveServiceAccountsParams.none() + ): CompletableFuture<HttpResponseFor<List<ServiceAccountRetrieveServiceAccountsResponse>>> = + retrieveServiceAccounts(params, RequestOptions.none()) + + /** @see retrieveServiceAccounts */ + fun retrieveServiceAccounts( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<ServiceAccountRetrieveServiceAccountsResponse>>> = + retrieveServiceAccounts( + ServiceAccountRetrieveServiceAccountsParams.none(), + requestOptions, + ) + + /** + * Returns a raw HTTP response for `post /api/v1/service-accounts`, but is otherwise the + * same as [ServiceAccountServiceAsync.serviceAccounts]. + */ + fun serviceAccounts( + params: ServiceAccountServiceAccountsParams + ): CompletableFuture<HttpResponseFor<ServiceAccountServiceAccountsResponse>> = + serviceAccounts(params, RequestOptions.none()) + + /** @see serviceAccounts */ + fun serviceAccounts( + params: ServiceAccountServiceAccountsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ServiceAccountServiceAccountsResponse>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ServiceAccountServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ServiceAccountServiceAsyncImpl.kt new file mode 100644 index 00000000..f3ddc05a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/ServiceAccountServiceAsyncImpl.kt @@ -0,0 +1,175 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.serviceaccounts.ServiceAccountDeleteParams +import com.langsmith_api.api.models.api.v1.serviceaccounts.ServiceAccountDeleteResponse +import com.langsmith_api.api.models.api.v1.serviceaccounts.ServiceAccountRetrieveServiceAccountsParams +import com.langsmith_api.api.models.api.v1.serviceaccounts.ServiceAccountRetrieveServiceAccountsResponse +import com.langsmith_api.api.models.api.v1.serviceaccounts.ServiceAccountServiceAccountsParams +import com.langsmith_api.api.models.api.v1.serviceaccounts.ServiceAccountServiceAccountsResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ServiceAccountServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : ServiceAccountServiceAsync { + + private val withRawResponse: ServiceAccountServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ServiceAccountServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ServiceAccountServiceAsync = + ServiceAccountServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun delete( + params: ServiceAccountDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<ServiceAccountDeleteResponse> = + // delete /api/v1/service-accounts/{service_account_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + override fun retrieveServiceAccounts( + params: ServiceAccountRetrieveServiceAccountsParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<ServiceAccountRetrieveServiceAccountsResponse>> = + // get /api/v1/service-accounts + withRawResponse().retrieveServiceAccounts(params, requestOptions).thenApply { it.parse() } + + override fun serviceAccounts( + params: ServiceAccountServiceAccountsParams, + requestOptions: RequestOptions, + ): CompletableFuture<ServiceAccountServiceAccountsResponse> = + // post /api/v1/service-accounts + withRawResponse().serviceAccounts(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ServiceAccountServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ServiceAccountServiceAsync.WithRawResponse = + ServiceAccountServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val deleteHandler: Handler<ServiceAccountDeleteResponse> = + jsonHandler<ServiceAccountDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: ServiceAccountDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ServiceAccountDeleteResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("serviceAccountId", params.serviceAccountId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "service-accounts", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveServiceAccountsHandler: + Handler<List<ServiceAccountRetrieveServiceAccountsResponse>> = + jsonHandler<List<ServiceAccountRetrieveServiceAccountsResponse>>( + clientOptions.jsonMapper + ) + + override fun retrieveServiceAccounts( + params: ServiceAccountRetrieveServiceAccountsParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<ServiceAccountRetrieveServiceAccountsResponse>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "service-accounts") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveServiceAccountsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val serviceAccountsHandler: Handler<ServiceAccountServiceAccountsResponse> = + jsonHandler<ServiceAccountServiceAccountsResponse>(clientOptions.jsonMapper) + + override fun serviceAccounts( + params: ServiceAccountServiceAccountsParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ServiceAccountServiceAccountsResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "service-accounts") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { serviceAccountsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/SessionServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/SessionServiceAsync.kt new file mode 100644 index 00000000..525459ac --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/SessionServiceAsync.kt @@ -0,0 +1,546 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.sessions.CustomChartsSection +import com.langsmith_api.api.models.api.v1.sessions.SessionCreateParams +import com.langsmith_api.api.models.api.v1.sessions.SessionDashboardParams +import com.langsmith_api.api.models.api.v1.sessions.SessionDeleteAllParams +import com.langsmith_api.api.models.api.v1.sessions.SessionDeleteAllResponse +import com.langsmith_api.api.models.api.v1.sessions.SessionDeleteParams +import com.langsmith_api.api.models.api.v1.sessions.SessionDeleteResponse +import com.langsmith_api.api.models.api.v1.sessions.SessionListParams +import com.langsmith_api.api.models.api.v1.sessions.SessionRetrieveMetadataParams +import com.langsmith_api.api.models.api.v1.sessions.SessionRetrieveMetadataResponse +import com.langsmith_api.api.models.api.v1.sessions.SessionRetrieveParams +import com.langsmith_api.api.models.api.v1.sessions.SessionUpdateParams +import com.langsmith_api.api.models.api.v1.sessions.TracerSession +import com.langsmith_api.api.models.api.v1.sessions.TracerSessionWithoutVirtualFields +import com.langsmith_api.api.services.async.api.v1.sessions.InsightServiceAsync +import com.langsmith_api.api.services.async.api.v1.sessions.ViewServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface SessionServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): SessionServiceAsync + + fun views(): ViewServiceAsync + + fun insights(): InsightServiceAsync + + /** Create a new session. */ + fun create(): CompletableFuture<TracerSessionWithoutVirtualFields> = + create(SessionCreateParams.none()) + + /** @see create */ + fun create( + params: SessionCreateParams = SessionCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<TracerSessionWithoutVirtualFields> + + /** @see create */ + fun create( + params: SessionCreateParams = SessionCreateParams.none() + ): CompletableFuture<TracerSessionWithoutVirtualFields> = create(params, RequestOptions.none()) + + /** @see create */ + fun create( + requestOptions: RequestOptions + ): CompletableFuture<TracerSessionWithoutVirtualFields> = + create(SessionCreateParams.none(), requestOptions) + + /** Get a specific session. */ + fun retrieve(sessionId: String): CompletableFuture<TracerSession> = + retrieve(sessionId, SessionRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + sessionId: String, + params: SessionRetrieveParams = SessionRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<TracerSession> = + retrieve(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + sessionId: String, + params: SessionRetrieveParams = SessionRetrieveParams.none(), + ): CompletableFuture<TracerSession> = retrieve(sessionId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: SessionRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<TracerSession> + + /** @see retrieve */ + fun retrieve(params: SessionRetrieveParams): CompletableFuture<TracerSession> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + sessionId: String, + requestOptions: RequestOptions, + ): CompletableFuture<TracerSession> = + retrieve(sessionId, SessionRetrieveParams.none(), requestOptions) + + /** Create a new session. */ + fun update(sessionId: String): CompletableFuture<TracerSessionWithoutVirtualFields> = + update(sessionId, SessionUpdateParams.none()) + + /** @see update */ + fun update( + sessionId: String, + params: SessionUpdateParams = SessionUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<TracerSessionWithoutVirtualFields> = + update(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see update */ + fun update( + sessionId: String, + params: SessionUpdateParams = SessionUpdateParams.none(), + ): CompletableFuture<TracerSessionWithoutVirtualFields> = + update(sessionId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: SessionUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<TracerSessionWithoutVirtualFields> + + /** @see update */ + fun update(params: SessionUpdateParams): CompletableFuture<TracerSessionWithoutVirtualFields> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + sessionId: String, + requestOptions: RequestOptions, + ): CompletableFuture<TracerSessionWithoutVirtualFields> = + update(sessionId, SessionUpdateParams.none(), requestOptions) + + /** Get all sessions. */ + fun list(): CompletableFuture<List<TracerSession>> = list(SessionListParams.none()) + + /** @see list */ + fun list( + params: SessionListParams = SessionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<TracerSession>> + + /** @see list */ + fun list( + params: SessionListParams = SessionListParams.none() + ): CompletableFuture<List<TracerSession>> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture<List<TracerSession>> = + list(SessionListParams.none(), requestOptions) + + /** Delete a specific session. */ + fun delete(sessionId: String): CompletableFuture<SessionDeleteResponse> = + delete(sessionId, SessionDeleteParams.none()) + + /** @see delete */ + fun delete( + sessionId: String, + params: SessionDeleteParams = SessionDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<SessionDeleteResponse> = + delete(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see delete */ + fun delete( + sessionId: String, + params: SessionDeleteParams = SessionDeleteParams.none(), + ): CompletableFuture<SessionDeleteResponse> = delete(sessionId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: SessionDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<SessionDeleteResponse> + + /** @see delete */ + fun delete(params: SessionDeleteParams): CompletableFuture<SessionDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + sessionId: String, + requestOptions: RequestOptions, + ): CompletableFuture<SessionDeleteResponse> = + delete(sessionId, SessionDeleteParams.none(), requestOptions) + + /** Get a prebuilt dashboard for a tracing project. */ + fun dashboard( + sessionId: String, + params: SessionDashboardParams, + ): CompletableFuture<CustomChartsSection> = dashboard(sessionId, params, RequestOptions.none()) + + /** @see dashboard */ + fun dashboard( + sessionId: String, + params: SessionDashboardParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CustomChartsSection> = + dashboard(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see dashboard */ + fun dashboard(params: SessionDashboardParams): CompletableFuture<CustomChartsSection> = + dashboard(params, RequestOptions.none()) + + /** @see dashboard */ + fun dashboard( + params: SessionDashboardParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CustomChartsSection> + + /** Delete a specific session. */ + fun deleteAll(params: SessionDeleteAllParams): CompletableFuture<SessionDeleteAllResponse> = + deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + params: SessionDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<SessionDeleteAllResponse> + + /** + * Given a session, a number K, and (optionally) a list of metadata keys, return the top K + * values for each key. + */ + fun retrieveMetadata(sessionId: String): CompletableFuture<SessionRetrieveMetadataResponse> = + retrieveMetadata(sessionId, SessionRetrieveMetadataParams.none()) + + /** @see retrieveMetadata */ + fun retrieveMetadata( + sessionId: String, + params: SessionRetrieveMetadataParams = SessionRetrieveMetadataParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<SessionRetrieveMetadataResponse> = + retrieveMetadata(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see retrieveMetadata */ + fun retrieveMetadata( + sessionId: String, + params: SessionRetrieveMetadataParams = SessionRetrieveMetadataParams.none(), + ): CompletableFuture<SessionRetrieveMetadataResponse> = + retrieveMetadata(sessionId, params, RequestOptions.none()) + + /** @see retrieveMetadata */ + fun retrieveMetadata( + params: SessionRetrieveMetadataParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<SessionRetrieveMetadataResponse> + + /** @see retrieveMetadata */ + fun retrieveMetadata( + params: SessionRetrieveMetadataParams + ): CompletableFuture<SessionRetrieveMetadataResponse> = + retrieveMetadata(params, RequestOptions.none()) + + /** @see retrieveMetadata */ + fun retrieveMetadata( + sessionId: String, + requestOptions: RequestOptions, + ): CompletableFuture<SessionRetrieveMetadataResponse> = + retrieveMetadata(sessionId, SessionRetrieveMetadataParams.none(), requestOptions) + + /** + * A view of [SessionServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): SessionServiceAsync.WithRawResponse + + fun views(): ViewServiceAsync.WithRawResponse + + fun insights(): InsightServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/sessions`, but is otherwise the same as + * [SessionServiceAsync.create]. + */ + fun create(): CompletableFuture<HttpResponseFor<TracerSessionWithoutVirtualFields>> = + create(SessionCreateParams.none()) + + /** @see create */ + fun create( + params: SessionCreateParams = SessionCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<TracerSessionWithoutVirtualFields>> + + /** @see create */ + fun create( + params: SessionCreateParams = SessionCreateParams.none() + ): CompletableFuture<HttpResponseFor<TracerSessionWithoutVirtualFields>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<TracerSessionWithoutVirtualFields>> = + create(SessionCreateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/sessions/{session_id}`, but is otherwise the + * same as [SessionServiceAsync.retrieve]. + */ + fun retrieve(sessionId: String): CompletableFuture<HttpResponseFor<TracerSession>> = + retrieve(sessionId, SessionRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + sessionId: String, + params: SessionRetrieveParams = SessionRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<TracerSession>> = + retrieve(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + sessionId: String, + params: SessionRetrieveParams = SessionRetrieveParams.none(), + ): CompletableFuture<HttpResponseFor<TracerSession>> = + retrieve(sessionId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: SessionRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<TracerSession>> + + /** @see retrieve */ + fun retrieve( + params: SessionRetrieveParams + ): CompletableFuture<HttpResponseFor<TracerSession>> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + sessionId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<TracerSession>> = + retrieve(sessionId, SessionRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `patch /api/v1/sessions/{session_id}`, but is otherwise + * the same as [SessionServiceAsync.update]. + */ + fun update( + sessionId: String + ): CompletableFuture<HttpResponseFor<TracerSessionWithoutVirtualFields>> = + update(sessionId, SessionUpdateParams.none()) + + /** @see update */ + fun update( + sessionId: String, + params: SessionUpdateParams = SessionUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<TracerSessionWithoutVirtualFields>> = + update(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see update */ + fun update( + sessionId: String, + params: SessionUpdateParams = SessionUpdateParams.none(), + ): CompletableFuture<HttpResponseFor<TracerSessionWithoutVirtualFields>> = + update(sessionId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: SessionUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<TracerSessionWithoutVirtualFields>> + + /** @see update */ + fun update( + params: SessionUpdateParams + ): CompletableFuture<HttpResponseFor<TracerSessionWithoutVirtualFields>> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + sessionId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<TracerSessionWithoutVirtualFields>> = + update(sessionId, SessionUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/sessions`, but is otherwise the same as + * [SessionServiceAsync.list]. + */ + fun list(): CompletableFuture<HttpResponseFor<List<TracerSession>>> = + list(SessionListParams.none()) + + /** @see list */ + fun list( + params: SessionListParams = SessionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<TracerSession>>> + + /** @see list */ + fun list( + params: SessionListParams = SessionListParams.none() + ): CompletableFuture<HttpResponseFor<List<TracerSession>>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<TracerSession>>> = + list(SessionListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/sessions/{session_id}`, but is otherwise + * the same as [SessionServiceAsync.delete]. + */ + fun delete(sessionId: String): CompletableFuture<HttpResponseFor<SessionDeleteResponse>> = + delete(sessionId, SessionDeleteParams.none()) + + /** @see delete */ + fun delete( + sessionId: String, + params: SessionDeleteParams = SessionDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<SessionDeleteResponse>> = + delete(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see delete */ + fun delete( + sessionId: String, + params: SessionDeleteParams = SessionDeleteParams.none(), + ): CompletableFuture<HttpResponseFor<SessionDeleteResponse>> = + delete(sessionId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: SessionDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<SessionDeleteResponse>> + + /** @see delete */ + fun delete( + params: SessionDeleteParams + ): CompletableFuture<HttpResponseFor<SessionDeleteResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + sessionId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<SessionDeleteResponse>> = + delete(sessionId, SessionDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/sessions/{session_id}/dashboard`, but is + * otherwise the same as [SessionServiceAsync.dashboard]. + */ + fun dashboard( + sessionId: String, + params: SessionDashboardParams, + ): CompletableFuture<HttpResponseFor<CustomChartsSection>> = + dashboard(sessionId, params, RequestOptions.none()) + + /** @see dashboard */ + fun dashboard( + sessionId: String, + params: SessionDashboardParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CustomChartsSection>> = + dashboard(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see dashboard */ + fun dashboard( + params: SessionDashboardParams + ): CompletableFuture<HttpResponseFor<CustomChartsSection>> = + dashboard(params, RequestOptions.none()) + + /** @see dashboard */ + fun dashboard( + params: SessionDashboardParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CustomChartsSection>> + + /** + * Returns a raw HTTP response for `delete /api/v1/sessions`, but is otherwise the same as + * [SessionServiceAsync.deleteAll]. + */ + fun deleteAll( + params: SessionDeleteAllParams + ): CompletableFuture<HttpResponseFor<SessionDeleteAllResponse>> = + deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + params: SessionDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<SessionDeleteAllResponse>> + + /** + * Returns a raw HTTP response for `get /api/v1/sessions/{session_id}/metadata`, but is + * otherwise the same as [SessionServiceAsync.retrieveMetadata]. + */ + fun retrieveMetadata( + sessionId: String + ): CompletableFuture<HttpResponseFor<SessionRetrieveMetadataResponse>> = + retrieveMetadata(sessionId, SessionRetrieveMetadataParams.none()) + + /** @see retrieveMetadata */ + fun retrieveMetadata( + sessionId: String, + params: SessionRetrieveMetadataParams = SessionRetrieveMetadataParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<SessionRetrieveMetadataResponse>> = + retrieveMetadata(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see retrieveMetadata */ + fun retrieveMetadata( + sessionId: String, + params: SessionRetrieveMetadataParams = SessionRetrieveMetadataParams.none(), + ): CompletableFuture<HttpResponseFor<SessionRetrieveMetadataResponse>> = + retrieveMetadata(sessionId, params, RequestOptions.none()) + + /** @see retrieveMetadata */ + fun retrieveMetadata( + params: SessionRetrieveMetadataParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<SessionRetrieveMetadataResponse>> + + /** @see retrieveMetadata */ + fun retrieveMetadata( + params: SessionRetrieveMetadataParams + ): CompletableFuture<HttpResponseFor<SessionRetrieveMetadataResponse>> = + retrieveMetadata(params, RequestOptions.none()) + + /** @see retrieveMetadata */ + fun retrieveMetadata( + sessionId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<SessionRetrieveMetadataResponse>> = + retrieveMetadata(sessionId, SessionRetrieveMetadataParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/SessionServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/SessionServiceAsyncImpl.kt new file mode 100644 index 00000000..b0c75d30 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/SessionServiceAsyncImpl.kt @@ -0,0 +1,402 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.sessions.CustomChartsSection +import com.langsmith_api.api.models.api.v1.sessions.SessionCreateParams +import com.langsmith_api.api.models.api.v1.sessions.SessionDashboardParams +import com.langsmith_api.api.models.api.v1.sessions.SessionDeleteAllParams +import com.langsmith_api.api.models.api.v1.sessions.SessionDeleteAllResponse +import com.langsmith_api.api.models.api.v1.sessions.SessionDeleteParams +import com.langsmith_api.api.models.api.v1.sessions.SessionDeleteResponse +import com.langsmith_api.api.models.api.v1.sessions.SessionListParams +import com.langsmith_api.api.models.api.v1.sessions.SessionRetrieveMetadataParams +import com.langsmith_api.api.models.api.v1.sessions.SessionRetrieveMetadataResponse +import com.langsmith_api.api.models.api.v1.sessions.SessionRetrieveParams +import com.langsmith_api.api.models.api.v1.sessions.SessionUpdateParams +import com.langsmith_api.api.models.api.v1.sessions.TracerSession +import com.langsmith_api.api.models.api.v1.sessions.TracerSessionWithoutVirtualFields +import com.langsmith_api.api.services.async.api.v1.sessions.InsightServiceAsync +import com.langsmith_api.api.services.async.api.v1.sessions.InsightServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.sessions.ViewServiceAsync +import com.langsmith_api.api.services.async.api.v1.sessions.ViewServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class SessionServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + SessionServiceAsync { + + private val withRawResponse: SessionServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val views: ViewServiceAsync by lazy { ViewServiceAsyncImpl(clientOptions) } + + private val insights: InsightServiceAsync by lazy { InsightServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): SessionServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): SessionServiceAsync = + SessionServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun views(): ViewServiceAsync = views + + override fun insights(): InsightServiceAsync = insights + + override fun create( + params: SessionCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<TracerSessionWithoutVirtualFields> = + // post /api/v1/sessions + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun retrieve( + params: SessionRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<TracerSession> = + // get /api/v1/sessions/{session_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: SessionUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<TracerSessionWithoutVirtualFields> = + // patch /api/v1/sessions/{session_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: SessionListParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<TracerSession>> = + // get /api/v1/sessions + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: SessionDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<SessionDeleteResponse> = + // delete /api/v1/sessions/{session_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + override fun dashboard( + params: SessionDashboardParams, + requestOptions: RequestOptions, + ): CompletableFuture<CustomChartsSection> = + // post /api/v1/sessions/{session_id}/dashboard + withRawResponse().dashboard(params, requestOptions).thenApply { it.parse() } + + override fun deleteAll( + params: SessionDeleteAllParams, + requestOptions: RequestOptions, + ): CompletableFuture<SessionDeleteAllResponse> = + // delete /api/v1/sessions + withRawResponse().deleteAll(params, requestOptions).thenApply { it.parse() } + + override fun retrieveMetadata( + params: SessionRetrieveMetadataParams, + requestOptions: RequestOptions, + ): CompletableFuture<SessionRetrieveMetadataResponse> = + // get /api/v1/sessions/{session_id}/metadata + withRawResponse().retrieveMetadata(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SessionServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val views: ViewServiceAsync.WithRawResponse by lazy { + ViewServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val insights: InsightServiceAsync.WithRawResponse by lazy { + InsightServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): SessionServiceAsync.WithRawResponse = + SessionServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun views(): ViewServiceAsync.WithRawResponse = views + + override fun insights(): InsightServiceAsync.WithRawResponse = insights + + private val createHandler: Handler<TracerSessionWithoutVirtualFields> = + jsonHandler<TracerSessionWithoutVirtualFields>(clientOptions.jsonMapper) + + override fun create( + params: SessionCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<TracerSessionWithoutVirtualFields>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "sessions") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler<TracerSession> = + jsonHandler<TracerSession>(clientOptions.jsonMapper) + + override fun retrieve( + params: SessionRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<TracerSession>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("sessionId", params.sessionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "sessions", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler<TracerSessionWithoutVirtualFields> = + jsonHandler<TracerSessionWithoutVirtualFields>(clientOptions.jsonMapper) + + override fun update( + params: SessionUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<TracerSessionWithoutVirtualFields>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("sessionId", params.sessionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "sessions", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler<List<TracerSession>> = + jsonHandler<List<TracerSession>>(clientOptions.jsonMapper) + + override fun list( + params: SessionListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<TracerSession>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "sessions") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val deleteHandler: Handler<SessionDeleteResponse> = + jsonHandler<SessionDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: SessionDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<SessionDeleteResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("sessionId", params.sessionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "sessions", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val dashboardHandler: Handler<CustomChartsSection> = + jsonHandler<CustomChartsSection>(clientOptions.jsonMapper) + + override fun dashboard( + params: SessionDashboardParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<CustomChartsSection>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("sessionId", params.sessionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "sessions", params._pathParam(0), "dashboard") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { dashboardHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val deleteAllHandler: Handler<SessionDeleteAllResponse> = + jsonHandler<SessionDeleteAllResponse>(clientOptions.jsonMapper) + + override fun deleteAll( + params: SessionDeleteAllParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<SessionDeleteAllResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "sessions") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteAllHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveMetadataHandler: Handler<SessionRetrieveMetadataResponse> = + jsonHandler<SessionRetrieveMetadataResponse>(clientOptions.jsonMapper) + + override fun retrieveMetadata( + params: SessionRetrieveMetadataParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<SessionRetrieveMetadataResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("sessionId", params.sessionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "sessions", params._pathParam(0), "metadata") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveMetadataHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/SettingServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/SettingServiceAsync.kt new file mode 100644 index 00000000..8e4920d1 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/SettingServiceAsync.kt @@ -0,0 +1,110 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.settings.AppHubCrudTenantsTenant +import com.langsmith_api.api.models.api.v1.settings.SettingHandleParams +import com.langsmith_api.api.models.api.v1.settings.SettingListParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface SettingServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): SettingServiceAsync + + /** Get settings. */ + fun list(): CompletableFuture<AppHubCrudTenantsTenant> = list(SettingListParams.none()) + + /** @see list */ + fun list( + params: SettingListParams = SettingListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<AppHubCrudTenantsTenant> + + /** @see list */ + fun list( + params: SettingListParams = SettingListParams.none() + ): CompletableFuture<AppHubCrudTenantsTenant> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture<AppHubCrudTenantsTenant> = + list(SettingListParams.none(), requestOptions) + + /** Set tenant handle. */ + fun handle(params: SettingHandleParams): CompletableFuture<AppHubCrudTenantsTenant> = + handle(params, RequestOptions.none()) + + /** @see handle */ + fun handle( + params: SettingHandleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<AppHubCrudTenantsTenant> + + /** + * A view of [SettingServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): SettingServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/settings`, but is otherwise the same as + * [SettingServiceAsync.list]. + */ + fun list(): CompletableFuture<HttpResponseFor<AppHubCrudTenantsTenant>> = + list(SettingListParams.none()) + + /** @see list */ + fun list( + params: SettingListParams = SettingListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<AppHubCrudTenantsTenant>> + + /** @see list */ + fun list( + params: SettingListParams = SettingListParams.none() + ): CompletableFuture<HttpResponseFor<AppHubCrudTenantsTenant>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<AppHubCrudTenantsTenant>> = + list(SettingListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/settings/handle`, but is otherwise the same + * as [SettingServiceAsync.handle]. + */ + fun handle( + params: SettingHandleParams + ): CompletableFuture<HttpResponseFor<AppHubCrudTenantsTenant>> = + handle(params, RequestOptions.none()) + + /** @see handle */ + fun handle( + params: SettingHandleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<AppHubCrudTenantsTenant>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/SettingServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/SettingServiceAsyncImpl.kt new file mode 100644 index 00000000..77d8a4f1 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/SettingServiceAsyncImpl.kt @@ -0,0 +1,124 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.settings.AppHubCrudTenantsTenant +import com.langsmith_api.api.models.api.v1.settings.SettingHandleParams +import com.langsmith_api.api.models.api.v1.settings.SettingListParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class SettingServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + SettingServiceAsync { + + private val withRawResponse: SettingServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): SettingServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): SettingServiceAsync = + SettingServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: SettingListParams, + requestOptions: RequestOptions, + ): CompletableFuture<AppHubCrudTenantsTenant> = + // get /api/v1/settings + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun handle( + params: SettingHandleParams, + requestOptions: RequestOptions, + ): CompletableFuture<AppHubCrudTenantsTenant> = + // post /api/v1/settings/handle + withRawResponse().handle(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SettingServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): SettingServiceAsync.WithRawResponse = + SettingServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler<AppHubCrudTenantsTenant> = + jsonHandler<AppHubCrudTenantsTenant>(clientOptions.jsonMapper) + + override fun list( + params: SettingListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<AppHubCrudTenantsTenant>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "settings") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val handleHandler: Handler<AppHubCrudTenantsTenant> = + jsonHandler<AppHubCrudTenantsTenant>(clientOptions.jsonMapper) + + override fun handle( + params: SettingHandleParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<AppHubCrudTenantsTenant>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "settings", "handle") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { handleHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/SsoServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/SsoServiceAsync.kt new file mode 100644 index 00000000..f3d45bdf --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/SsoServiceAsync.kt @@ -0,0 +1,121 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.sso.SsoRetrieveParams +import com.langsmith_api.api.models.api.v1.sso.SsoRetrieveResponse +import com.langsmith_api.api.services.async.api.v1.sso.EmailVerificationServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface SsoServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): SsoServiceAsync + + fun emailVerification(): EmailVerificationServiceAsync + + /** Get SSO provider settings from login slug. */ + fun retrieve(ssoLoginSlug: String): CompletableFuture<List<SsoRetrieveResponse>> = + retrieve(ssoLoginSlug, SsoRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + ssoLoginSlug: String, + params: SsoRetrieveParams = SsoRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<SsoRetrieveResponse>> = + retrieve(params.toBuilder().ssoLoginSlug(ssoLoginSlug).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + ssoLoginSlug: String, + params: SsoRetrieveParams = SsoRetrieveParams.none(), + ): CompletableFuture<List<SsoRetrieveResponse>> = + retrieve(ssoLoginSlug, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: SsoRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<SsoRetrieveResponse>> + + /** @see retrieve */ + fun retrieve(params: SsoRetrieveParams): CompletableFuture<List<SsoRetrieveResponse>> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + ssoLoginSlug: String, + requestOptions: RequestOptions, + ): CompletableFuture<List<SsoRetrieveResponse>> = + retrieve(ssoLoginSlug, SsoRetrieveParams.none(), requestOptions) + + /** A view of [SsoServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): SsoServiceAsync.WithRawResponse + + fun emailVerification(): EmailVerificationServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/sso/settings/{sso_login_slug}`, but is + * otherwise the same as [SsoServiceAsync.retrieve]. + */ + fun retrieve( + ssoLoginSlug: String + ): CompletableFuture<HttpResponseFor<List<SsoRetrieveResponse>>> = + retrieve(ssoLoginSlug, SsoRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + ssoLoginSlug: String, + params: SsoRetrieveParams = SsoRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<SsoRetrieveResponse>>> = + retrieve(params.toBuilder().ssoLoginSlug(ssoLoginSlug).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + ssoLoginSlug: String, + params: SsoRetrieveParams = SsoRetrieveParams.none(), + ): CompletableFuture<HttpResponseFor<List<SsoRetrieveResponse>>> = + retrieve(ssoLoginSlug, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: SsoRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<SsoRetrieveResponse>>> + + /** @see retrieve */ + fun retrieve( + params: SsoRetrieveParams + ): CompletableFuture<HttpResponseFor<List<SsoRetrieveResponse>>> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + ssoLoginSlug: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<SsoRetrieveResponse>>> = + retrieve(ssoLoginSlug, SsoRetrieveParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/SsoServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/SsoServiceAsyncImpl.kt new file mode 100644 index 00000000..eaf39117 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/SsoServiceAsyncImpl.kt @@ -0,0 +1,104 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.sso.SsoRetrieveParams +import com.langsmith_api.api.models.api.v1.sso.SsoRetrieveResponse +import com.langsmith_api.api.services.async.api.v1.sso.EmailVerificationServiceAsync +import com.langsmith_api.api.services.async.api.v1.sso.EmailVerificationServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class SsoServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + SsoServiceAsync { + + private val withRawResponse: SsoServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val emailVerification: EmailVerificationServiceAsync by lazy { + EmailVerificationServiceAsyncImpl(clientOptions) + } + + override fun withRawResponse(): SsoServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): SsoServiceAsync = + SsoServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun emailVerification(): EmailVerificationServiceAsync = emailVerification + + override fun retrieve( + params: SsoRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<SsoRetrieveResponse>> = + // get /api/v1/sso/settings/{sso_login_slug} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SsoServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val emailVerification: EmailVerificationServiceAsync.WithRawResponse by lazy { + EmailVerificationServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): SsoServiceAsync.WithRawResponse = + SsoServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun emailVerification(): EmailVerificationServiceAsync.WithRawResponse = + emailVerification + + private val retrieveHandler: Handler<List<SsoRetrieveResponse>> = + jsonHandler<List<SsoRetrieveResponse>>(clientOptions.jsonMapper) + + override fun retrieve( + params: SsoRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<SsoRetrieveResponse>>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("ssoLoginSlug", params.ssoLoginSlug().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "sso", "settings", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/TenantServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/TenantServiceAsync.kt new file mode 100644 index 00000000..018ccbc8 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/TenantServiceAsync.kt @@ -0,0 +1,111 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.tenants.AppSchemasTenant +import com.langsmith_api.api.models.api.v1.tenants.TenantCreateParams +import com.langsmith_api.api.models.api.v1.tenants.TenantForUser +import com.langsmith_api.api.models.api.v1.tenants.TenantListParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface TenantServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): TenantServiceAsync + + /** Create a new organization and corresponding workspace. */ + fun create(params: TenantCreateParams): CompletableFuture<AppSchemasTenant> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: TenantCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<AppSchemasTenant> + + /** Get all tenants visible to this auth */ + fun list(): CompletableFuture<List<TenantForUser>> = list(TenantListParams.none()) + + /** @see list */ + fun list( + params: TenantListParams = TenantListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<TenantForUser>> + + /** @see list */ + fun list( + params: TenantListParams = TenantListParams.none() + ): CompletableFuture<List<TenantForUser>> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture<List<TenantForUser>> = + list(TenantListParams.none(), requestOptions) + + /** + * A view of [TenantServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): TenantServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/tenants`, but is otherwise the same as + * [TenantServiceAsync.create]. + */ + fun create( + params: TenantCreateParams + ): CompletableFuture<HttpResponseFor<AppSchemasTenant>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: TenantCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<AppSchemasTenant>> + + /** + * Returns a raw HTTP response for `get /api/v1/tenants`, but is otherwise the same as + * [TenantServiceAsync.list]. + */ + fun list(): CompletableFuture<HttpResponseFor<List<TenantForUser>>> = + list(TenantListParams.none()) + + /** @see list */ + fun list( + params: TenantListParams = TenantListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<TenantForUser>>> + + /** @see list */ + fun list( + params: TenantListParams = TenantListParams.none() + ): CompletableFuture<HttpResponseFor<List<TenantForUser>>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<TenantForUser>>> = + list(TenantListParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/TenantServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/TenantServiceAsyncImpl.kt new file mode 100644 index 00000000..93e653fa --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/TenantServiceAsyncImpl.kt @@ -0,0 +1,125 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.tenants.AppSchemasTenant +import com.langsmith_api.api.models.api.v1.tenants.TenantCreateParams +import com.langsmith_api.api.models.api.v1.tenants.TenantForUser +import com.langsmith_api.api.models.api.v1.tenants.TenantListParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class TenantServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + TenantServiceAsync { + + private val withRawResponse: TenantServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): TenantServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): TenantServiceAsync = + TenantServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: TenantCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<AppSchemasTenant> = + // post /api/v1/tenants + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: TenantListParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<TenantForUser>> = + // get /api/v1/tenants + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TenantServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): TenantServiceAsync.WithRawResponse = + TenantServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<AppSchemasTenant> = + jsonHandler<AppSchemasTenant>(clientOptions.jsonMapper) + + override fun create( + params: TenantCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<AppSchemasTenant>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "tenants") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler<List<TenantForUser>> = + jsonHandler<List<TenantForUser>>(clientOptions.jsonMapper) + + override fun list( + params: TenantListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<TenantForUser>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "tenants") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/TtlSettingServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/TtlSettingServiceAsync.kt new file mode 100644 index 00000000..83c9f380 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/TtlSettingServiceAsync.kt @@ -0,0 +1,151 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TtlSettings +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.UpsertTtlSettingsRequest +import com.langsmith_api.api.models.api.v1.ttlsettings.TtlSettingRetrieveTtlSettingsParams +import com.langsmith_api.api.models.api.v1.ttlsettings.TtlSettingUpdateTtlSettingsParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface TtlSettingServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): TtlSettingServiceAsync + + /** List out the configured TTL settings for a given tenant. */ + fun retrieveTtlSettings(): CompletableFuture<List<TtlSettings>> = + retrieveTtlSettings(TtlSettingRetrieveTtlSettingsParams.none()) + + /** @see retrieveTtlSettings */ + fun retrieveTtlSettings( + params: TtlSettingRetrieveTtlSettingsParams = TtlSettingRetrieveTtlSettingsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<TtlSettings>> + + /** @see retrieveTtlSettings */ + fun retrieveTtlSettings( + params: TtlSettingRetrieveTtlSettingsParams = TtlSettingRetrieveTtlSettingsParams.none() + ): CompletableFuture<List<TtlSettings>> = retrieveTtlSettings(params, RequestOptions.none()) + + /** @see retrieveTtlSettings */ + fun retrieveTtlSettings(requestOptions: RequestOptions): CompletableFuture<List<TtlSettings>> = + retrieveTtlSettings(TtlSettingRetrieveTtlSettingsParams.none(), requestOptions) + + /** Upsert Ttl Settings */ + fun updateTtlSettings( + params: TtlSettingUpdateTtlSettingsParams + ): CompletableFuture<TtlSettings> = updateTtlSettings(params, RequestOptions.none()) + + /** @see updateTtlSettings */ + fun updateTtlSettings( + params: TtlSettingUpdateTtlSettingsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<TtlSettings> + + /** @see updateTtlSettings */ + fun updateTtlSettings( + upsertTtlSettingsRequest: UpsertTtlSettingsRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<TtlSettings> = + updateTtlSettings( + TtlSettingUpdateTtlSettingsParams.builder() + .upsertTtlSettingsRequest(upsertTtlSettingsRequest) + .build(), + requestOptions, + ) + + /** @see updateTtlSettings */ + fun updateTtlSettings( + upsertTtlSettingsRequest: UpsertTtlSettingsRequest + ): CompletableFuture<TtlSettings> = + updateTtlSettings(upsertTtlSettingsRequest, RequestOptions.none()) + + /** + * A view of [TtlSettingServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): TtlSettingServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/ttl-settings`, but is otherwise the same as + * [TtlSettingServiceAsync.retrieveTtlSettings]. + */ + fun retrieveTtlSettings(): CompletableFuture<HttpResponseFor<List<TtlSettings>>> = + retrieveTtlSettings(TtlSettingRetrieveTtlSettingsParams.none()) + + /** @see retrieveTtlSettings */ + fun retrieveTtlSettings( + params: TtlSettingRetrieveTtlSettingsParams = + TtlSettingRetrieveTtlSettingsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<TtlSettings>>> + + /** @see retrieveTtlSettings */ + fun retrieveTtlSettings( + params: TtlSettingRetrieveTtlSettingsParams = TtlSettingRetrieveTtlSettingsParams.none() + ): CompletableFuture<HttpResponseFor<List<TtlSettings>>> = + retrieveTtlSettings(params, RequestOptions.none()) + + /** @see retrieveTtlSettings */ + fun retrieveTtlSettings( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<TtlSettings>>> = + retrieveTtlSettings(TtlSettingRetrieveTtlSettingsParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `put /api/v1/ttl-settings`, but is otherwise the same as + * [TtlSettingServiceAsync.updateTtlSettings]. + */ + fun updateTtlSettings( + params: TtlSettingUpdateTtlSettingsParams + ): CompletableFuture<HttpResponseFor<TtlSettings>> = + updateTtlSettings(params, RequestOptions.none()) + + /** @see updateTtlSettings */ + fun updateTtlSettings( + params: TtlSettingUpdateTtlSettingsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<TtlSettings>> + + /** @see updateTtlSettings */ + fun updateTtlSettings( + upsertTtlSettingsRequest: UpsertTtlSettingsRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<TtlSettings>> = + updateTtlSettings( + TtlSettingUpdateTtlSettingsParams.builder() + .upsertTtlSettingsRequest(upsertTtlSettingsRequest) + .build(), + requestOptions, + ) + + /** @see updateTtlSettings */ + fun updateTtlSettings( + upsertTtlSettingsRequest: UpsertTtlSettingsRequest + ): CompletableFuture<HttpResponseFor<TtlSettings>> = + updateTtlSettings(upsertTtlSettingsRequest, RequestOptions.none()) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/TtlSettingServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/TtlSettingServiceAsyncImpl.kt new file mode 100644 index 00000000..220f235f --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/TtlSettingServiceAsyncImpl.kt @@ -0,0 +1,124 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TtlSettings +import com.langsmith_api.api.models.api.v1.ttlsettings.TtlSettingRetrieveTtlSettingsParams +import com.langsmith_api.api.models.api.v1.ttlsettings.TtlSettingUpdateTtlSettingsParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class TtlSettingServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + TtlSettingServiceAsync { + + private val withRawResponse: TtlSettingServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): TtlSettingServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): TtlSettingServiceAsync = + TtlSettingServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieveTtlSettings( + params: TtlSettingRetrieveTtlSettingsParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<TtlSettings>> = + // get /api/v1/ttl-settings + withRawResponse().retrieveTtlSettings(params, requestOptions).thenApply { it.parse() } + + override fun updateTtlSettings( + params: TtlSettingUpdateTtlSettingsParams, + requestOptions: RequestOptions, + ): CompletableFuture<TtlSettings> = + // put /api/v1/ttl-settings + withRawResponse().updateTtlSettings(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TtlSettingServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): TtlSettingServiceAsync.WithRawResponse = + TtlSettingServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveTtlSettingsHandler: Handler<List<TtlSettings>> = + jsonHandler<List<TtlSettings>>(clientOptions.jsonMapper) + + override fun retrieveTtlSettings( + params: TtlSettingRetrieveTtlSettingsParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<TtlSettings>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "ttl-settings") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveTtlSettingsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val updateTtlSettingsHandler: Handler<TtlSettings> = + jsonHandler<TtlSettings>(clientOptions.jsonMapper) + + override fun updateTtlSettings( + params: TtlSettingUpdateTtlSettingsParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<TtlSettings>> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "ttl-settings") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateTtlSettingsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/UsageLimitServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/UsageLimitServiceAsync.kt new file mode 100644 index 00000000..529ffc47 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/UsageLimitServiceAsync.kt @@ -0,0 +1,240 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.usagelimits.UsageLimit +import com.langsmith_api.api.models.api.v1.usagelimits.UsageLimitDeleteParams +import com.langsmith_api.api.models.api.v1.usagelimits.UsageLimitDeleteResponse +import com.langsmith_api.api.models.api.v1.usagelimits.UsageLimitRetrieveOrgParams +import com.langsmith_api.api.models.api.v1.usagelimits.UsageLimitRetrieveUsageLimitsParams +import com.langsmith_api.api.models.api.v1.usagelimits.UsageLimitUpdateUsageLimitsParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface UsageLimitServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): UsageLimitServiceAsync + + /** Delete a specific usage limit. */ + fun delete(usageLimitId: String): CompletableFuture<UsageLimitDeleteResponse> = + delete(usageLimitId, UsageLimitDeleteParams.none()) + + /** @see delete */ + fun delete( + usageLimitId: String, + params: UsageLimitDeleteParams = UsageLimitDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<UsageLimitDeleteResponse> = + delete(params.toBuilder().usageLimitId(usageLimitId).build(), requestOptions) + + /** @see delete */ + fun delete( + usageLimitId: String, + params: UsageLimitDeleteParams = UsageLimitDeleteParams.none(), + ): CompletableFuture<UsageLimitDeleteResponse> = + delete(usageLimitId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: UsageLimitDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<UsageLimitDeleteResponse> + + /** @see delete */ + fun delete(params: UsageLimitDeleteParams): CompletableFuture<UsageLimitDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + usageLimitId: String, + requestOptions: RequestOptions, + ): CompletableFuture<UsageLimitDeleteResponse> = + delete(usageLimitId, UsageLimitDeleteParams.none(), requestOptions) + + /** List out the configured usage limits for a given organization. */ + fun retrieveOrg(): CompletableFuture<List<UsageLimit>> = + retrieveOrg(UsageLimitRetrieveOrgParams.none()) + + /** @see retrieveOrg */ + fun retrieveOrg( + params: UsageLimitRetrieveOrgParams = UsageLimitRetrieveOrgParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<UsageLimit>> + + /** @see retrieveOrg */ + fun retrieveOrg( + params: UsageLimitRetrieveOrgParams = UsageLimitRetrieveOrgParams.none() + ): CompletableFuture<List<UsageLimit>> = retrieveOrg(params, RequestOptions.none()) + + /** @see retrieveOrg */ + fun retrieveOrg(requestOptions: RequestOptions): CompletableFuture<List<UsageLimit>> = + retrieveOrg(UsageLimitRetrieveOrgParams.none(), requestOptions) + + /** List out the configured usage limits for a given tenant. */ + fun retrieveUsageLimits(): CompletableFuture<List<UsageLimit>> = + retrieveUsageLimits(UsageLimitRetrieveUsageLimitsParams.none()) + + /** @see retrieveUsageLimits */ + fun retrieveUsageLimits( + params: UsageLimitRetrieveUsageLimitsParams = UsageLimitRetrieveUsageLimitsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<UsageLimit>> + + /** @see retrieveUsageLimits */ + fun retrieveUsageLimits( + params: UsageLimitRetrieveUsageLimitsParams = UsageLimitRetrieveUsageLimitsParams.none() + ): CompletableFuture<List<UsageLimit>> = retrieveUsageLimits(params, RequestOptions.none()) + + /** @see retrieveUsageLimits */ + fun retrieveUsageLimits(requestOptions: RequestOptions): CompletableFuture<List<UsageLimit>> = + retrieveUsageLimits(UsageLimitRetrieveUsageLimitsParams.none(), requestOptions) + + /** Create a new usage limit. */ + fun updateUsageLimits( + params: UsageLimitUpdateUsageLimitsParams + ): CompletableFuture<UsageLimit> = updateUsageLimits(params, RequestOptions.none()) + + /** @see updateUsageLimits */ + fun updateUsageLimits( + params: UsageLimitUpdateUsageLimitsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<UsageLimit> + + /** + * A view of [UsageLimitServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): UsageLimitServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `delete /api/v1/usage-limits/{usage_limit_id}`, but is + * otherwise the same as [UsageLimitServiceAsync.delete]. + */ + fun delete( + usageLimitId: String + ): CompletableFuture<HttpResponseFor<UsageLimitDeleteResponse>> = + delete(usageLimitId, UsageLimitDeleteParams.none()) + + /** @see delete */ + fun delete( + usageLimitId: String, + params: UsageLimitDeleteParams = UsageLimitDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<UsageLimitDeleteResponse>> = + delete(params.toBuilder().usageLimitId(usageLimitId).build(), requestOptions) + + /** @see delete */ + fun delete( + usageLimitId: String, + params: UsageLimitDeleteParams = UsageLimitDeleteParams.none(), + ): CompletableFuture<HttpResponseFor<UsageLimitDeleteResponse>> = + delete(usageLimitId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: UsageLimitDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<UsageLimitDeleteResponse>> + + /** @see delete */ + fun delete( + params: UsageLimitDeleteParams + ): CompletableFuture<HttpResponseFor<UsageLimitDeleteResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + usageLimitId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<UsageLimitDeleteResponse>> = + delete(usageLimitId, UsageLimitDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/usage-limits/org`, but is otherwise the same + * as [UsageLimitServiceAsync.retrieveOrg]. + */ + fun retrieveOrg(): CompletableFuture<HttpResponseFor<List<UsageLimit>>> = + retrieveOrg(UsageLimitRetrieveOrgParams.none()) + + /** @see retrieveOrg */ + fun retrieveOrg( + params: UsageLimitRetrieveOrgParams = UsageLimitRetrieveOrgParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<UsageLimit>>> + + /** @see retrieveOrg */ + fun retrieveOrg( + params: UsageLimitRetrieveOrgParams = UsageLimitRetrieveOrgParams.none() + ): CompletableFuture<HttpResponseFor<List<UsageLimit>>> = + retrieveOrg(params, RequestOptions.none()) + + /** @see retrieveOrg */ + fun retrieveOrg( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<UsageLimit>>> = + retrieveOrg(UsageLimitRetrieveOrgParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/usage-limits`, but is otherwise the same as + * [UsageLimitServiceAsync.retrieveUsageLimits]. + */ + fun retrieveUsageLimits(): CompletableFuture<HttpResponseFor<List<UsageLimit>>> = + retrieveUsageLimits(UsageLimitRetrieveUsageLimitsParams.none()) + + /** @see retrieveUsageLimits */ + fun retrieveUsageLimits( + params: UsageLimitRetrieveUsageLimitsParams = + UsageLimitRetrieveUsageLimitsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<UsageLimit>>> + + /** @see retrieveUsageLimits */ + fun retrieveUsageLimits( + params: UsageLimitRetrieveUsageLimitsParams = UsageLimitRetrieveUsageLimitsParams.none() + ): CompletableFuture<HttpResponseFor<List<UsageLimit>>> = + retrieveUsageLimits(params, RequestOptions.none()) + + /** @see retrieveUsageLimits */ + fun retrieveUsageLimits( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<UsageLimit>>> = + retrieveUsageLimits(UsageLimitRetrieveUsageLimitsParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `put /api/v1/usage-limits`, but is otherwise the same as + * [UsageLimitServiceAsync.updateUsageLimits]. + */ + fun updateUsageLimits( + params: UsageLimitUpdateUsageLimitsParams + ): CompletableFuture<HttpResponseFor<UsageLimit>> = + updateUsageLimits(params, RequestOptions.none()) + + /** @see updateUsageLimits */ + fun updateUsageLimits( + params: UsageLimitUpdateUsageLimitsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<UsageLimit>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/UsageLimitServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/UsageLimitServiceAsyncImpl.kt new file mode 100644 index 00000000..600c6546 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/UsageLimitServiceAsyncImpl.kt @@ -0,0 +1,207 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.usagelimits.UsageLimit +import com.langsmith_api.api.models.api.v1.usagelimits.UsageLimitDeleteParams +import com.langsmith_api.api.models.api.v1.usagelimits.UsageLimitDeleteResponse +import com.langsmith_api.api.models.api.v1.usagelimits.UsageLimitRetrieveOrgParams +import com.langsmith_api.api.models.api.v1.usagelimits.UsageLimitRetrieveUsageLimitsParams +import com.langsmith_api.api.models.api.v1.usagelimits.UsageLimitUpdateUsageLimitsParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class UsageLimitServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + UsageLimitServiceAsync { + + private val withRawResponse: UsageLimitServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): UsageLimitServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): UsageLimitServiceAsync = + UsageLimitServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun delete( + params: UsageLimitDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<UsageLimitDeleteResponse> = + // delete /api/v1/usage-limits/{usage_limit_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + override fun retrieveOrg( + params: UsageLimitRetrieveOrgParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<UsageLimit>> = + // get /api/v1/usage-limits/org + withRawResponse().retrieveOrg(params, requestOptions).thenApply { it.parse() } + + override fun retrieveUsageLimits( + params: UsageLimitRetrieveUsageLimitsParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<UsageLimit>> = + // get /api/v1/usage-limits + withRawResponse().retrieveUsageLimits(params, requestOptions).thenApply { it.parse() } + + override fun updateUsageLimits( + params: UsageLimitUpdateUsageLimitsParams, + requestOptions: RequestOptions, + ): CompletableFuture<UsageLimit> = + // put /api/v1/usage-limits + withRawResponse().updateUsageLimits(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + UsageLimitServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): UsageLimitServiceAsync.WithRawResponse = + UsageLimitServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val deleteHandler: Handler<UsageLimitDeleteResponse> = + jsonHandler<UsageLimitDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: UsageLimitDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<UsageLimitDeleteResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("usageLimitId", params.usageLimitId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "usage-limits", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveOrgHandler: Handler<List<UsageLimit>> = + jsonHandler<List<UsageLimit>>(clientOptions.jsonMapper) + + override fun retrieveOrg( + params: UsageLimitRetrieveOrgParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<UsageLimit>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "usage-limits", "org") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveOrgHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val retrieveUsageLimitsHandler: Handler<List<UsageLimit>> = + jsonHandler<List<UsageLimit>>(clientOptions.jsonMapper) + + override fun retrieveUsageLimits( + params: UsageLimitRetrieveUsageLimitsParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<UsageLimit>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "usage-limits") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveUsageLimitsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val updateUsageLimitsHandler: Handler<UsageLimit> = + jsonHandler<UsageLimit>(clientOptions.jsonMapper) + + override fun updateUsageLimits( + params: UsageLimitUpdateUsageLimitsParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<UsageLimit>> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "usage-limits") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateUsageLimitsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/WorkspaceServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/WorkspaceServiceAsync.kt new file mode 100644 index 00000000..d3fa408a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/WorkspaceServiceAsync.kt @@ -0,0 +1,260 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.tenants.AppSchemasTenant +import com.langsmith_api.api.models.api.v1.tenants.TenantForUser +import com.langsmith_api.api.models.api.v1.workspaces.WorkspaceCreateParams +import com.langsmith_api.api.models.api.v1.workspaces.WorkspaceDeleteParams +import com.langsmith_api.api.models.api.v1.workspaces.WorkspaceDeleteResponse +import com.langsmith_api.api.models.api.v1.workspaces.WorkspaceListParams +import com.langsmith_api.api.models.api.v1.workspaces.WorkspaceUpdateParams +import com.langsmith_api.api.services.async.api.v1.workspaces.CurrentServiceAsync +import com.langsmith_api.api.services.async.api.v1.workspaces.PendingServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface WorkspaceServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): WorkspaceServiceAsync + + fun pending(): PendingServiceAsync + + fun current(): CurrentServiceAsync + + /** Create a new workspace. */ + fun create(params: WorkspaceCreateParams): CompletableFuture<AppSchemasTenant> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: WorkspaceCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<AppSchemasTenant> + + /** Patch Workspace */ + fun update( + workspaceId: String, + params: WorkspaceUpdateParams, + ): CompletableFuture<AppSchemasTenant> = update(workspaceId, params, RequestOptions.none()) + + /** @see update */ + fun update( + workspaceId: String, + params: WorkspaceUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<AppSchemasTenant> = + update(params.toBuilder().workspaceId(workspaceId).build(), requestOptions) + + /** @see update */ + fun update(params: WorkspaceUpdateParams): CompletableFuture<AppSchemasTenant> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: WorkspaceUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<AppSchemasTenant> + + /** + * Get all workspaces visible to this auth in the current org. Does not create a new + * workspace/org. + */ + fun list(): CompletableFuture<List<TenantForUser>> = list(WorkspaceListParams.none()) + + /** @see list */ + fun list( + params: WorkspaceListParams = WorkspaceListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<TenantForUser>> + + /** @see list */ + fun list( + params: WorkspaceListParams = WorkspaceListParams.none() + ): CompletableFuture<List<TenantForUser>> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture<List<TenantForUser>> = + list(WorkspaceListParams.none(), requestOptions) + + /** Delete Workspace */ + fun delete(workspaceId: String): CompletableFuture<WorkspaceDeleteResponse> = + delete(workspaceId, WorkspaceDeleteParams.none()) + + /** @see delete */ + fun delete( + workspaceId: String, + params: WorkspaceDeleteParams = WorkspaceDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<WorkspaceDeleteResponse> = + delete(params.toBuilder().workspaceId(workspaceId).build(), requestOptions) + + /** @see delete */ + fun delete( + workspaceId: String, + params: WorkspaceDeleteParams = WorkspaceDeleteParams.none(), + ): CompletableFuture<WorkspaceDeleteResponse> = + delete(workspaceId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: WorkspaceDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<WorkspaceDeleteResponse> + + /** @see delete */ + fun delete(params: WorkspaceDeleteParams): CompletableFuture<WorkspaceDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + workspaceId: String, + requestOptions: RequestOptions, + ): CompletableFuture<WorkspaceDeleteResponse> = + delete(workspaceId, WorkspaceDeleteParams.none(), requestOptions) + + /** + * A view of [WorkspaceServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): WorkspaceServiceAsync.WithRawResponse + + fun pending(): PendingServiceAsync.WithRawResponse + + fun current(): CurrentServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/workspaces`, but is otherwise the same as + * [WorkspaceServiceAsync.create]. + */ + fun create( + params: WorkspaceCreateParams + ): CompletableFuture<HttpResponseFor<AppSchemasTenant>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: WorkspaceCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<AppSchemasTenant>> + + /** + * Returns a raw HTTP response for `patch /api/v1/workspaces/{workspace_id}`, but is + * otherwise the same as [WorkspaceServiceAsync.update]. + */ + fun update( + workspaceId: String, + params: WorkspaceUpdateParams, + ): CompletableFuture<HttpResponseFor<AppSchemasTenant>> = + update(workspaceId, params, RequestOptions.none()) + + /** @see update */ + fun update( + workspaceId: String, + params: WorkspaceUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<AppSchemasTenant>> = + update(params.toBuilder().workspaceId(workspaceId).build(), requestOptions) + + /** @see update */ + fun update( + params: WorkspaceUpdateParams + ): CompletableFuture<HttpResponseFor<AppSchemasTenant>> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: WorkspaceUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<AppSchemasTenant>> + + /** + * Returns a raw HTTP response for `get /api/v1/workspaces`, but is otherwise the same as + * [WorkspaceServiceAsync.list]. + */ + fun list(): CompletableFuture<HttpResponseFor<List<TenantForUser>>> = + list(WorkspaceListParams.none()) + + /** @see list */ + fun list( + params: WorkspaceListParams = WorkspaceListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<TenantForUser>>> + + /** @see list */ + fun list( + params: WorkspaceListParams = WorkspaceListParams.none() + ): CompletableFuture<HttpResponseFor<List<TenantForUser>>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<TenantForUser>>> = + list(WorkspaceListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/workspaces/{workspace_id}`, but is + * otherwise the same as [WorkspaceServiceAsync.delete]. + */ + fun delete( + workspaceId: String + ): CompletableFuture<HttpResponseFor<WorkspaceDeleteResponse>> = + delete(workspaceId, WorkspaceDeleteParams.none()) + + /** @see delete */ + fun delete( + workspaceId: String, + params: WorkspaceDeleteParams = WorkspaceDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<WorkspaceDeleteResponse>> = + delete(params.toBuilder().workspaceId(workspaceId).build(), requestOptions) + + /** @see delete */ + fun delete( + workspaceId: String, + params: WorkspaceDeleteParams = WorkspaceDeleteParams.none(), + ): CompletableFuture<HttpResponseFor<WorkspaceDeleteResponse>> = + delete(workspaceId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: WorkspaceDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<WorkspaceDeleteResponse>> + + /** @see delete */ + fun delete( + params: WorkspaceDeleteParams + ): CompletableFuture<HttpResponseFor<WorkspaceDeleteResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + workspaceId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<WorkspaceDeleteResponse>> = + delete(workspaceId, WorkspaceDeleteParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/WorkspaceServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/WorkspaceServiceAsyncImpl.kt new file mode 100644 index 00000000..b15e2df8 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/WorkspaceServiceAsyncImpl.kt @@ -0,0 +1,236 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.tenants.AppSchemasTenant +import com.langsmith_api.api.models.api.v1.tenants.TenantForUser +import com.langsmith_api.api.models.api.v1.workspaces.WorkspaceCreateParams +import com.langsmith_api.api.models.api.v1.workspaces.WorkspaceDeleteParams +import com.langsmith_api.api.models.api.v1.workspaces.WorkspaceDeleteResponse +import com.langsmith_api.api.models.api.v1.workspaces.WorkspaceListParams +import com.langsmith_api.api.models.api.v1.workspaces.WorkspaceUpdateParams +import com.langsmith_api.api.services.async.api.v1.workspaces.CurrentServiceAsync +import com.langsmith_api.api.services.async.api.v1.workspaces.CurrentServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.workspaces.PendingServiceAsync +import com.langsmith_api.api.services.async.api.v1.workspaces.PendingServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class WorkspaceServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + WorkspaceServiceAsync { + + private val withRawResponse: WorkspaceServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val pending: PendingServiceAsync by lazy { PendingServiceAsyncImpl(clientOptions) } + + private val current: CurrentServiceAsync by lazy { CurrentServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): WorkspaceServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): WorkspaceServiceAsync = + WorkspaceServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun pending(): PendingServiceAsync = pending + + override fun current(): CurrentServiceAsync = current + + override fun create( + params: WorkspaceCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<AppSchemasTenant> = + // post /api/v1/workspaces + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: WorkspaceUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<AppSchemasTenant> = + // patch /api/v1/workspaces/{workspace_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: WorkspaceListParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<TenantForUser>> = + // get /api/v1/workspaces + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: WorkspaceDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<WorkspaceDeleteResponse> = + // delete /api/v1/workspaces/{workspace_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + WorkspaceServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val pending: PendingServiceAsync.WithRawResponse by lazy { + PendingServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val current: CurrentServiceAsync.WithRawResponse by lazy { + CurrentServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): WorkspaceServiceAsync.WithRawResponse = + WorkspaceServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun pending(): PendingServiceAsync.WithRawResponse = pending + + override fun current(): CurrentServiceAsync.WithRawResponse = current + + private val createHandler: Handler<AppSchemasTenant> = + jsonHandler<AppSchemasTenant>(clientOptions.jsonMapper) + + override fun create( + params: WorkspaceCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<AppSchemasTenant>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler<AppSchemasTenant> = + jsonHandler<AppSchemasTenant>(clientOptions.jsonMapper) + + override fun update( + params: WorkspaceUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<AppSchemasTenant>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("workspaceId", params.workspaceId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler<List<TenantForUser>> = + jsonHandler<List<TenantForUser>>(clientOptions.jsonMapper) + + override fun list( + params: WorkspaceListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<TenantForUser>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val deleteHandler: Handler<WorkspaceDeleteResponse> = + jsonHandler<WorkspaceDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: WorkspaceDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<WorkspaceDeleteResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("workspaceId", params.workspaceId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/annotationqueues/RunServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/annotationqueues/RunServiceAsync.kt new file mode 100644 index 00000000..c3a247e4 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/annotationqueues/RunServiceAsync.kt @@ -0,0 +1,301 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.annotationqueues + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.annotationqueues.RunSchemaWithAnnotationQueueInfo +import com.langsmith_api.api.models.api.v1.annotationqueues.runs.RunCreateParams +import com.langsmith_api.api.models.api.v1.annotationqueues.runs.RunCreateResponse +import com.langsmith_api.api.models.api.v1.annotationqueues.runs.RunDeleteParams +import com.langsmith_api.api.models.api.v1.annotationqueues.runs.RunDeleteResponse +import com.langsmith_api.api.models.api.v1.annotationqueues.runs.RunListParams +import com.langsmith_api.api.models.api.v1.annotationqueues.runs.RunUpdateParams +import com.langsmith_api.api.models.api.v1.annotationqueues.runs.RunUpdateResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface RunServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunServiceAsync + + /** Add Runs To Annotation Queue */ + fun create( + queueId: String, + params: RunCreateParams, + ): CompletableFuture<List<RunCreateResponse>> = create(queueId, params, RequestOptions.none()) + + /** @see create */ + fun create( + queueId: String, + params: RunCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<RunCreateResponse>> = + create(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see create */ + fun create(params: RunCreateParams): CompletableFuture<List<RunCreateResponse>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: RunCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<RunCreateResponse>> + + /** Update Run In Annotation Queue */ + fun update(queueRunId: String, params: RunUpdateParams): CompletableFuture<RunUpdateResponse> = + update(queueRunId, params, RequestOptions.none()) + + /** @see update */ + fun update( + queueRunId: String, + params: RunUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RunUpdateResponse> = + update(params.toBuilder().queueRunId(queueRunId).build(), requestOptions) + + /** @see update */ + fun update(params: RunUpdateParams): CompletableFuture<RunUpdateResponse> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: RunUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RunUpdateResponse> + + /** Get Runs From Annotation Queue */ + fun list(queueId: String): CompletableFuture<List<RunSchemaWithAnnotationQueueInfo>> = + list(queueId, RunListParams.none()) + + /** @see list */ + fun list( + queueId: String, + params: RunListParams = RunListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<RunSchemaWithAnnotationQueueInfo>> = + list(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see list */ + fun list( + queueId: String, + params: RunListParams = RunListParams.none(), + ): CompletableFuture<List<RunSchemaWithAnnotationQueueInfo>> = + list(queueId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: RunListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<RunSchemaWithAnnotationQueueInfo>> + + /** @see list */ + fun list(params: RunListParams): CompletableFuture<List<RunSchemaWithAnnotationQueueInfo>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + queueId: String, + requestOptions: RequestOptions, + ): CompletableFuture<List<RunSchemaWithAnnotationQueueInfo>> = + list(queueId, RunListParams.none(), requestOptions) + + /** Delete Runs From Annotation Queue */ + fun delete(queueId: String): CompletableFuture<RunDeleteResponse> = + delete(queueId, RunDeleteParams.none()) + + /** @see delete */ + fun delete( + queueId: String, + params: RunDeleteParams = RunDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RunDeleteResponse> = + delete(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see delete */ + fun delete( + queueId: String, + params: RunDeleteParams = RunDeleteParams.none(), + ): CompletableFuture<RunDeleteResponse> = delete(queueId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: RunDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RunDeleteResponse> + + /** @see delete */ + fun delete(params: RunDeleteParams): CompletableFuture<RunDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + queueId: String, + requestOptions: RequestOptions, + ): CompletableFuture<RunDeleteResponse> = + delete(queueId, RunDeleteParams.none(), requestOptions) + + /** A view of [RunServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/annotation-queues/{queue_id}/runs`, but is + * otherwise the same as [RunServiceAsync.create]. + */ + fun create( + queueId: String, + params: RunCreateParams, + ): CompletableFuture<HttpResponseFor<List<RunCreateResponse>>> = + create(queueId, params, RequestOptions.none()) + + /** @see create */ + fun create( + queueId: String, + params: RunCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<RunCreateResponse>>> = + create(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see create */ + fun create( + params: RunCreateParams + ): CompletableFuture<HttpResponseFor<List<RunCreateResponse>>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: RunCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<RunCreateResponse>>> + + /** + * Returns a raw HTTP response for `patch + * /api/v1/annotation-queues/{queue_id}/runs/{queue_run_id}`, but is otherwise the same as + * [RunServiceAsync.update]. + */ + fun update( + queueRunId: String, + params: RunUpdateParams, + ): CompletableFuture<HttpResponseFor<RunUpdateResponse>> = + update(queueRunId, params, RequestOptions.none()) + + /** @see update */ + fun update( + queueRunId: String, + params: RunUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RunUpdateResponse>> = + update(params.toBuilder().queueRunId(queueRunId).build(), requestOptions) + + /** @see update */ + fun update(params: RunUpdateParams): CompletableFuture<HttpResponseFor<RunUpdateResponse>> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: RunUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RunUpdateResponse>> + + /** + * Returns a raw HTTP response for `get /api/v1/annotation-queues/{queue_id}/runs`, but is + * otherwise the same as [RunServiceAsync.list]. + */ + fun list( + queueId: String + ): CompletableFuture<HttpResponseFor<List<RunSchemaWithAnnotationQueueInfo>>> = + list(queueId, RunListParams.none()) + + /** @see list */ + fun list( + queueId: String, + params: RunListParams = RunListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<RunSchemaWithAnnotationQueueInfo>>> = + list(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see list */ + fun list( + queueId: String, + params: RunListParams = RunListParams.none(), + ): CompletableFuture<HttpResponseFor<List<RunSchemaWithAnnotationQueueInfo>>> = + list(queueId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: RunListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<RunSchemaWithAnnotationQueueInfo>>> + + /** @see list */ + fun list( + params: RunListParams + ): CompletableFuture<HttpResponseFor<List<RunSchemaWithAnnotationQueueInfo>>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + queueId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<RunSchemaWithAnnotationQueueInfo>>> = + list(queueId, RunListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/annotation-queues/{queue_id}/runs/delete`, + * but is otherwise the same as [RunServiceAsync.delete]. + */ + fun delete(queueId: String): CompletableFuture<HttpResponseFor<RunDeleteResponse>> = + delete(queueId, RunDeleteParams.none()) + + /** @see delete */ + fun delete( + queueId: String, + params: RunDeleteParams = RunDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RunDeleteResponse>> = + delete(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see delete */ + fun delete( + queueId: String, + params: RunDeleteParams = RunDeleteParams.none(), + ): CompletableFuture<HttpResponseFor<RunDeleteResponse>> = + delete(queueId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: RunDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RunDeleteResponse>> + + /** @see delete */ + fun delete(params: RunDeleteParams): CompletableFuture<HttpResponseFor<RunDeleteResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + queueId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<RunDeleteResponse>> = + delete(queueId, RunDeleteParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/annotationqueues/RunServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/annotationqueues/RunServiceAsyncImpl.kt new file mode 100644 index 00000000..a8de2cf2 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/annotationqueues/RunServiceAsyncImpl.kt @@ -0,0 +1,233 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.annotationqueues + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.annotationqueues.RunSchemaWithAnnotationQueueInfo +import com.langsmith_api.api.models.api.v1.annotationqueues.runs.RunCreateParams +import com.langsmith_api.api.models.api.v1.annotationqueues.runs.RunCreateResponse +import com.langsmith_api.api.models.api.v1.annotationqueues.runs.RunDeleteParams +import com.langsmith_api.api.models.api.v1.annotationqueues.runs.RunDeleteResponse +import com.langsmith_api.api.models.api.v1.annotationqueues.runs.RunListParams +import com.langsmith_api.api.models.api.v1.annotationqueues.runs.RunUpdateParams +import com.langsmith_api.api.models.api.v1.annotationqueues.runs.RunUpdateResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class RunServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + RunServiceAsync { + + private val withRawResponse: RunServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): RunServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunServiceAsync = + RunServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: RunCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<RunCreateResponse>> = + // post /api/v1/annotation-queues/{queue_id}/runs + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: RunUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<RunUpdateResponse> = + // patch /api/v1/annotation-queues/{queue_id}/runs/{queue_run_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: RunListParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<RunSchemaWithAnnotationQueueInfo>> = + // get /api/v1/annotation-queues/{queue_id}/runs + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: RunDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<RunDeleteResponse> = + // post /api/v1/annotation-queues/{queue_id}/runs/delete + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RunServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): RunServiceAsync.WithRawResponse = + RunServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<List<RunCreateResponse>> = + jsonHandler<List<RunCreateResponse>>(clientOptions.jsonMapper) + + override fun create( + params: RunCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<RunCreateResponse>>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("queueId", params.queueId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "annotation-queues", params._pathParam(0), "runs") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val updateHandler: Handler<RunUpdateResponse> = + jsonHandler<RunUpdateResponse>(clientOptions.jsonMapper) + + override fun update( + params: RunUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<RunUpdateResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("queueRunId", params.queueRunId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "annotation-queues", + params._pathParam(0), + "runs", + params._pathParam(1), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler<List<RunSchemaWithAnnotationQueueInfo>> = + jsonHandler<List<RunSchemaWithAnnotationQueueInfo>>(clientOptions.jsonMapper) + + override fun list( + params: RunListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<RunSchemaWithAnnotationQueueInfo>>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("queueId", params.queueId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "annotation-queues", params._pathParam(0), "runs") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val deleteHandler: Handler<RunDeleteResponse> = + jsonHandler<RunDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: RunDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<RunDeleteResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("queueId", params.queueId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "annotation-queues", + params._pathParam(0), + "runs", + "delete", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/apikey/CurrentServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/apikey/CurrentServiceAsync.kt new file mode 100644 index 00000000..de6a5907 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/apikey/CurrentServiceAsync.kt @@ -0,0 +1,257 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.apikey + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.apikey.current.CurrentCreateParams +import com.langsmith_api.api.models.api.v1.apikey.current.CurrentDeleteParams +import com.langsmith_api.api.models.api.v1.apikey.current.CurrentListParams +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyCreateRequest +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyCreateResponse +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyGetResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface CurrentServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): CurrentServiceAsync + + /** DEPRECATED: Use /orgs/current/personal-access-tokens instead */ + fun create(): CompletableFuture<ApiKeyCreateResponse> = create(CurrentCreateParams.none()) + + /** @see create */ + fun create( + params: CurrentCreateParams = CurrentCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ApiKeyCreateResponse> + + /** @see create */ + fun create( + params: CurrentCreateParams = CurrentCreateParams.none() + ): CompletableFuture<ApiKeyCreateResponse> = create(params, RequestOptions.none()) + + /** @see create */ + fun create( + apiKeyCreateRequest: ApiKeyCreateRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ApiKeyCreateResponse> = + create( + CurrentCreateParams.builder().apiKeyCreateRequest(apiKeyCreateRequest).build(), + requestOptions, + ) + + /** @see create */ + fun create(apiKeyCreateRequest: ApiKeyCreateRequest): CompletableFuture<ApiKeyCreateResponse> = + create(apiKeyCreateRequest, RequestOptions.none()) + + /** @see create */ + fun create(requestOptions: RequestOptions): CompletableFuture<ApiKeyCreateResponse> = + create(CurrentCreateParams.none(), requestOptions) + + /** DEPRECATED: Use /orgs/current/personal-access-tokens instead */ + @Deprecated("deprecated") + fun list(): CompletableFuture<List<ApiKeyGetResponse>> = list(CurrentListParams.none()) + + /** @see list */ + @Deprecated("deprecated") + fun list( + params: CurrentListParams = CurrentListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<ApiKeyGetResponse>> + + /** @see list */ + @Deprecated("deprecated") + fun list( + params: CurrentListParams = CurrentListParams.none() + ): CompletableFuture<List<ApiKeyGetResponse>> = list(params, RequestOptions.none()) + + /** @see list */ + @Deprecated("deprecated") + fun list(requestOptions: RequestOptions): CompletableFuture<List<ApiKeyGetResponse>> = + list(CurrentListParams.none(), requestOptions) + + /** DEPRECATED: Use /orgs/current/personal-access-tokens/{pat_id} instead */ + @Deprecated("deprecated") + fun delete(patId: String): CompletableFuture<ApiKeyGetResponse> = + delete(patId, CurrentDeleteParams.none()) + + /** @see delete */ + @Deprecated("deprecated") + fun delete( + patId: String, + params: CurrentDeleteParams = CurrentDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ApiKeyGetResponse> = + delete(params.toBuilder().patId(patId).build(), requestOptions) + + /** @see delete */ + @Deprecated("deprecated") + fun delete( + patId: String, + params: CurrentDeleteParams = CurrentDeleteParams.none(), + ): CompletableFuture<ApiKeyGetResponse> = delete(patId, params, RequestOptions.none()) + + /** @see delete */ + @Deprecated("deprecated") + fun delete( + params: CurrentDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ApiKeyGetResponse> + + /** @see delete */ + @Deprecated("deprecated") + fun delete(params: CurrentDeleteParams): CompletableFuture<ApiKeyGetResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + @Deprecated("deprecated") + fun delete( + patId: String, + requestOptions: RequestOptions, + ): CompletableFuture<ApiKeyGetResponse> = + delete(patId, CurrentDeleteParams.none(), requestOptions) + + /** + * A view of [CurrentServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): CurrentServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/api-key/current`, but is otherwise the same + * as [CurrentServiceAsync.create]. + */ + fun create(): CompletableFuture<HttpResponseFor<ApiKeyCreateResponse>> = + create(CurrentCreateParams.none()) + + /** @see create */ + fun create( + params: CurrentCreateParams = CurrentCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ApiKeyCreateResponse>> + + /** @see create */ + fun create( + params: CurrentCreateParams = CurrentCreateParams.none() + ): CompletableFuture<HttpResponseFor<ApiKeyCreateResponse>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + apiKeyCreateRequest: ApiKeyCreateRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ApiKeyCreateResponse>> = + create( + CurrentCreateParams.builder().apiKeyCreateRequest(apiKeyCreateRequest).build(), + requestOptions, + ) + + /** @see create */ + fun create( + apiKeyCreateRequest: ApiKeyCreateRequest + ): CompletableFuture<HttpResponseFor<ApiKeyCreateResponse>> = + create(apiKeyCreateRequest, RequestOptions.none()) + + /** @see create */ + fun create( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<ApiKeyCreateResponse>> = + create(CurrentCreateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/api-key/current`, but is otherwise the same + * as [CurrentServiceAsync.list]. + */ + @Deprecated("deprecated") + fun list(): CompletableFuture<HttpResponseFor<List<ApiKeyGetResponse>>> = + list(CurrentListParams.none()) + + /** @see list */ + @Deprecated("deprecated") + fun list( + params: CurrentListParams = CurrentListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<ApiKeyGetResponse>>> + + /** @see list */ + @Deprecated("deprecated") + fun list( + params: CurrentListParams = CurrentListParams.none() + ): CompletableFuture<HttpResponseFor<List<ApiKeyGetResponse>>> = + list(params, RequestOptions.none()) + + /** @see list */ + @Deprecated("deprecated") + fun list( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<ApiKeyGetResponse>>> = + list(CurrentListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/api-key/current/{pat_id}`, but is + * otherwise the same as [CurrentServiceAsync.delete]. + */ + @Deprecated("deprecated") + fun delete(patId: String): CompletableFuture<HttpResponseFor<ApiKeyGetResponse>> = + delete(patId, CurrentDeleteParams.none()) + + /** @see delete */ + @Deprecated("deprecated") + fun delete( + patId: String, + params: CurrentDeleteParams = CurrentDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ApiKeyGetResponse>> = + delete(params.toBuilder().patId(patId).build(), requestOptions) + + /** @see delete */ + @Deprecated("deprecated") + fun delete( + patId: String, + params: CurrentDeleteParams = CurrentDeleteParams.none(), + ): CompletableFuture<HttpResponseFor<ApiKeyGetResponse>> = + delete(patId, params, RequestOptions.none()) + + /** @see delete */ + @Deprecated("deprecated") + fun delete( + params: CurrentDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ApiKeyGetResponse>> + + /** @see delete */ + @Deprecated("deprecated") + fun delete( + params: CurrentDeleteParams + ): CompletableFuture<HttpResponseFor<ApiKeyGetResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + @Deprecated("deprecated") + fun delete( + patId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ApiKeyGetResponse>> = + delete(patId, CurrentDeleteParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/apikey/CurrentServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/apikey/CurrentServiceAsyncImpl.kt new file mode 100644 index 00000000..29236449 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/apikey/CurrentServiceAsyncImpl.kt @@ -0,0 +1,173 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.apikey + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.apikey.current.CurrentCreateParams +import com.langsmith_api.api.models.api.v1.apikey.current.CurrentDeleteParams +import com.langsmith_api.api.models.api.v1.apikey.current.CurrentListParams +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyCreateResponse +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyGetResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class CurrentServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + CurrentServiceAsync { + + private val withRawResponse: CurrentServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): CurrentServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): CurrentServiceAsync = + CurrentServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: CurrentCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<ApiKeyCreateResponse> = + // post /api/v1/api-key/current + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + @Deprecated("deprecated") + override fun list( + params: CurrentListParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<ApiKeyGetResponse>> = + // get /api/v1/api-key/current + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + @Deprecated("deprecated") + override fun delete( + params: CurrentDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<ApiKeyGetResponse> = + // delete /api/v1/api-key/current/{pat_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CurrentServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): CurrentServiceAsync.WithRawResponse = + CurrentServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<ApiKeyCreateResponse> = + jsonHandler<ApiKeyCreateResponse>(clientOptions.jsonMapper) + + override fun create( + params: CurrentCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ApiKeyCreateResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "api-key", "current") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler<List<ApiKeyGetResponse>> = + jsonHandler<List<ApiKeyGetResponse>>(clientOptions.jsonMapper) + + @Deprecated("deprecated") + override fun list( + params: CurrentListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<ApiKeyGetResponse>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "api-key", "current") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val deleteHandler: Handler<ApiKeyGetResponse> = + jsonHandler<ApiKeyGetResponse>(clientOptions.jsonMapper) + + @Deprecated("deprecated") + override fun delete( + params: CurrentDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ApiKeyGetResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("patId", params.patId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "api-key", "current", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/bulkexports/DestinationServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/bulkexports/DestinationServiceAsync.kt new file mode 100644 index 00000000..bb3e7608 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/bulkexports/DestinationServiceAsync.kt @@ -0,0 +1,191 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.bulkexports + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.bulkexports.destinations.BulkExportDestination +import com.langsmith_api.api.models.api.v1.bulkexports.destinations.DestinationCreateParams +import com.langsmith_api.api.models.api.v1.bulkexports.destinations.DestinationListParams +import com.langsmith_api.api.models.api.v1.bulkexports.destinations.DestinationRetrieveParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface DestinationServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): DestinationServiceAsync + + /** Create a new bulk export destination */ + fun create(params: DestinationCreateParams): CompletableFuture<BulkExportDestination> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: DestinationCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<BulkExportDestination> + + /** Get a single bulk export destination by ID */ + fun retrieve(destinationId: String): CompletableFuture<BulkExportDestination> = + retrieve(destinationId, DestinationRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + destinationId: String, + params: DestinationRetrieveParams = DestinationRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<BulkExportDestination> = + retrieve(params.toBuilder().destinationId(destinationId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + destinationId: String, + params: DestinationRetrieveParams = DestinationRetrieveParams.none(), + ): CompletableFuture<BulkExportDestination> = + retrieve(destinationId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: DestinationRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<BulkExportDestination> + + /** @see retrieve */ + fun retrieve(params: DestinationRetrieveParams): CompletableFuture<BulkExportDestination> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + destinationId: String, + requestOptions: RequestOptions, + ): CompletableFuture<BulkExportDestination> = + retrieve(destinationId, DestinationRetrieveParams.none(), requestOptions) + + /** Get the current workspace's bulk export destinations */ + fun list(): CompletableFuture<List<BulkExportDestination>> = list(DestinationListParams.none()) + + /** @see list */ + fun list( + params: DestinationListParams = DestinationListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<BulkExportDestination>> + + /** @see list */ + fun list( + params: DestinationListParams = DestinationListParams.none() + ): CompletableFuture<List<BulkExportDestination>> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture<List<BulkExportDestination>> = + list(DestinationListParams.none(), requestOptions) + + /** + * A view of [DestinationServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): DestinationServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/bulk-exports/destinations`, but is + * otherwise the same as [DestinationServiceAsync.create]. + */ + fun create( + params: DestinationCreateParams + ): CompletableFuture<HttpResponseFor<BulkExportDestination>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: DestinationCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<BulkExportDestination>> + + /** + * Returns a raw HTTP response for `get /api/v1/bulk-exports/destinations/{destination_id}`, + * but is otherwise the same as [DestinationServiceAsync.retrieve]. + */ + fun retrieve( + destinationId: String + ): CompletableFuture<HttpResponseFor<BulkExportDestination>> = + retrieve(destinationId, DestinationRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + destinationId: String, + params: DestinationRetrieveParams = DestinationRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<BulkExportDestination>> = + retrieve(params.toBuilder().destinationId(destinationId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + destinationId: String, + params: DestinationRetrieveParams = DestinationRetrieveParams.none(), + ): CompletableFuture<HttpResponseFor<BulkExportDestination>> = + retrieve(destinationId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: DestinationRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<BulkExportDestination>> + + /** @see retrieve */ + fun retrieve( + params: DestinationRetrieveParams + ): CompletableFuture<HttpResponseFor<BulkExportDestination>> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + destinationId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<BulkExportDestination>> = + retrieve(destinationId, DestinationRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/bulk-exports/destinations`, but is otherwise + * the same as [DestinationServiceAsync.list]. + */ + fun list(): CompletableFuture<HttpResponseFor<List<BulkExportDestination>>> = + list(DestinationListParams.none()) + + /** @see list */ + fun list( + params: DestinationListParams = DestinationListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<BulkExportDestination>>> + + /** @see list */ + fun list( + params: DestinationListParams = DestinationListParams.none() + ): CompletableFuture<HttpResponseFor<List<BulkExportDestination>>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<BulkExportDestination>>> = + list(DestinationListParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/bulkexports/DestinationServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/bulkexports/DestinationServiceAsyncImpl.kt new file mode 100644 index 00000000..cef323d0 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/bulkexports/DestinationServiceAsyncImpl.kt @@ -0,0 +1,173 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.bulkexports + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.bulkexports.destinations.BulkExportDestination +import com.langsmith_api.api.models.api.v1.bulkexports.destinations.DestinationCreateParams +import com.langsmith_api.api.models.api.v1.bulkexports.destinations.DestinationListParams +import com.langsmith_api.api.models.api.v1.bulkexports.destinations.DestinationRetrieveParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class DestinationServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + DestinationServiceAsync { + + private val withRawResponse: DestinationServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): DestinationServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): DestinationServiceAsync = + DestinationServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: DestinationCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<BulkExportDestination> = + // post /api/v1/bulk-exports/destinations + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun retrieve( + params: DestinationRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<BulkExportDestination> = + // get /api/v1/bulk-exports/destinations/{destination_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: DestinationListParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<BulkExportDestination>> = + // get /api/v1/bulk-exports/destinations + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + DestinationServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): DestinationServiceAsync.WithRawResponse = + DestinationServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<BulkExportDestination> = + jsonHandler<BulkExportDestination>(clientOptions.jsonMapper) + + override fun create( + params: DestinationCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<BulkExportDestination>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "bulk-exports", "destinations") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler<BulkExportDestination> = + jsonHandler<BulkExportDestination>(clientOptions.jsonMapper) + + override fun retrieve( + params: DestinationRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<BulkExportDestination>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("destinationId", params.destinationId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "bulk-exports", + "destinations", + params._pathParam(0), + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler<List<BulkExportDestination>> = + jsonHandler<List<BulkExportDestination>>(clientOptions.jsonMapper) + + override fun list( + params: DestinationListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<BulkExportDestination>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "bulk-exports", "destinations") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/bulkexports/RunServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/bulkexports/RunServiceAsync.kt new file mode 100644 index 00000000..d21075ba --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/bulkexports/RunServiceAsync.kt @@ -0,0 +1,163 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.bulkexports + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.bulkexports.runs.BulkExportRun +import com.langsmith_api.api.models.api.v1.bulkexports.runs.RunListParams +import com.langsmith_api.api.models.api.v1.bulkexports.runs.RunRetrieveParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface RunServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunServiceAsync + + /** Get a single bulk export's run by ID */ + fun retrieve(runId: String, params: RunRetrieveParams): CompletableFuture<BulkExportRun> = + retrieve(runId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + runId: String, + params: RunRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<BulkExportRun> = + retrieve(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: RunRetrieveParams): CompletableFuture<BulkExportRun> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: RunRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<BulkExportRun> + + /** Get a bulk export's runs */ + fun list(bulkExportId: String): CompletableFuture<List<BulkExportRun>> = + list(bulkExportId, RunListParams.none()) + + /** @see list */ + fun list( + bulkExportId: String, + params: RunListParams = RunListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<BulkExportRun>> = + list(params.toBuilder().bulkExportId(bulkExportId).build(), requestOptions) + + /** @see list */ + fun list( + bulkExportId: String, + params: RunListParams = RunListParams.none(), + ): CompletableFuture<List<BulkExportRun>> = list(bulkExportId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: RunListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<BulkExportRun>> + + /** @see list */ + fun list(params: RunListParams): CompletableFuture<List<BulkExportRun>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + bulkExportId: String, + requestOptions: RequestOptions, + ): CompletableFuture<List<BulkExportRun>> = + list(bulkExportId, RunListParams.none(), requestOptions) + + /** A view of [RunServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get + * /api/v1/bulk-exports/{bulk_export_id}/runs/{run_id}`, but is otherwise the same as + * [RunServiceAsync.retrieve]. + */ + fun retrieve( + runId: String, + params: RunRetrieveParams, + ): CompletableFuture<HttpResponseFor<BulkExportRun>> = + retrieve(runId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + runId: String, + params: RunRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<BulkExportRun>> = + retrieve(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: RunRetrieveParams): CompletableFuture<HttpResponseFor<BulkExportRun>> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: RunRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<BulkExportRun>> + + /** + * Returns a raw HTTP response for `get /api/v1/bulk-exports/{bulk_export_id}/runs`, but is + * otherwise the same as [RunServiceAsync.list]. + */ + fun list(bulkExportId: String): CompletableFuture<HttpResponseFor<List<BulkExportRun>>> = + list(bulkExportId, RunListParams.none()) + + /** @see list */ + fun list( + bulkExportId: String, + params: RunListParams = RunListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<BulkExportRun>>> = + list(params.toBuilder().bulkExportId(bulkExportId).build(), requestOptions) + + /** @see list */ + fun list( + bulkExportId: String, + params: RunListParams = RunListParams.none(), + ): CompletableFuture<HttpResponseFor<List<BulkExportRun>>> = + list(bulkExportId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: RunListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<BulkExportRun>>> + + /** @see list */ + fun list(params: RunListParams): CompletableFuture<HttpResponseFor<List<BulkExportRun>>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + bulkExportId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<BulkExportRun>>> = + list(bulkExportId, RunListParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/bulkexports/RunServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/bulkexports/RunServiceAsyncImpl.kt new file mode 100644 index 00000000..415d061d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/bulkexports/RunServiceAsyncImpl.kt @@ -0,0 +1,137 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.bulkexports + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.bulkexports.runs.BulkExportRun +import com.langsmith_api.api.models.api.v1.bulkexports.runs.RunListParams +import com.langsmith_api.api.models.api.v1.bulkexports.runs.RunRetrieveParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class RunServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + RunServiceAsync { + + private val withRawResponse: RunServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): RunServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunServiceAsync = + RunServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: RunRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<BulkExportRun> = + // get /api/v1/bulk-exports/{bulk_export_id}/runs/{run_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: RunListParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<BulkExportRun>> = + // get /api/v1/bulk-exports/{bulk_export_id}/runs + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RunServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): RunServiceAsync.WithRawResponse = + RunServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler<BulkExportRun> = + jsonHandler<BulkExportRun>(clientOptions.jsonMapper) + + override fun retrieve( + params: RunRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<BulkExportRun>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("runId", params.runId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "bulk-exports", + params._pathParam(0), + "runs", + params._pathParam(1), + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler<List<BulkExportRun>> = + jsonHandler<List<BulkExportRun>>(clientOptions.jsonMapper) + + override fun list( + params: RunListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<BulkExportRun>>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("bulkExportId", params.bulkExportId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "bulk-exports", params._pathParam(0), "runs") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/charts/SectionServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/charts/SectionServiceAsync.kt new file mode 100644 index 00000000..50757e6e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/charts/SectionServiceAsync.kt @@ -0,0 +1,326 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.charts + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.charts.section.CustomChartsSectionCreate +import com.langsmith_api.api.models.api.v1.charts.section.CustomChartsSectionResponse +import com.langsmith_api.api.models.api.v1.charts.section.SectionCloneParams +import com.langsmith_api.api.models.api.v1.charts.section.SectionCreateParams +import com.langsmith_api.api.models.api.v1.charts.section.SectionDeleteParams +import com.langsmith_api.api.models.api.v1.charts.section.SectionDeleteResponse +import com.langsmith_api.api.models.api.v1.charts.section.SectionListParams +import com.langsmith_api.api.models.api.v1.charts.section.SectionUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface SectionServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): SectionServiceAsync + + /** Create a new section. */ + fun create(params: SectionCreateParams): CompletableFuture<CustomChartsSectionResponse> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: SectionCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CustomChartsSectionResponse> + + /** @see create */ + fun create( + customChartsSectionCreate: CustomChartsSectionCreate, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CustomChartsSectionResponse> = + create( + SectionCreateParams.builder() + .customChartsSectionCreate(customChartsSectionCreate) + .build(), + requestOptions, + ) + + /** @see create */ + fun create( + customChartsSectionCreate: CustomChartsSectionCreate + ): CompletableFuture<CustomChartsSectionResponse> = + create(customChartsSectionCreate, RequestOptions.none()) + + /** Update a section. */ + fun update( + sectionId: String, + params: SectionUpdateParams, + ): CompletableFuture<CustomChartsSectionResponse> = + update(sectionId, params, RequestOptions.none()) + + /** @see update */ + fun update( + sectionId: String, + params: SectionUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CustomChartsSectionResponse> = + update(params.toBuilder().sectionId(sectionId).build(), requestOptions) + + /** @see update */ + fun update(params: SectionUpdateParams): CompletableFuture<CustomChartsSectionResponse> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: SectionUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CustomChartsSectionResponse> + + /** Get all sections for the tenant. */ + fun list(): CompletableFuture<List<CustomChartsSectionResponse>> = + list(SectionListParams.none()) + + /** @see list */ + fun list( + params: SectionListParams = SectionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<CustomChartsSectionResponse>> + + /** @see list */ + fun list( + params: SectionListParams = SectionListParams.none() + ): CompletableFuture<List<CustomChartsSectionResponse>> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture<List<CustomChartsSectionResponse>> = + list(SectionListParams.none(), requestOptions) + + /** Delete a section. */ + fun delete(sectionId: String): CompletableFuture<SectionDeleteResponse> = + delete(sectionId, SectionDeleteParams.none()) + + /** @see delete */ + fun delete( + sectionId: String, + params: SectionDeleteParams = SectionDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<SectionDeleteResponse> = + delete(params.toBuilder().sectionId(sectionId).build(), requestOptions) + + /** @see delete */ + fun delete( + sectionId: String, + params: SectionDeleteParams = SectionDeleteParams.none(), + ): CompletableFuture<SectionDeleteResponse> = delete(sectionId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: SectionDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<SectionDeleteResponse> + + /** @see delete */ + fun delete(params: SectionDeleteParams): CompletableFuture<SectionDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + sectionId: String, + requestOptions: RequestOptions, + ): CompletableFuture<SectionDeleteResponse> = + delete(sectionId, SectionDeleteParams.none(), requestOptions) + + /** Clone a dashboard. */ + fun clone(): CompletableFuture<CustomChartsSectionResponse> = clone(SectionCloneParams.none()) + + /** @see clone */ + fun clone( + params: SectionCloneParams = SectionCloneParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CustomChartsSectionResponse> + + /** @see clone */ + fun clone( + params: SectionCloneParams = SectionCloneParams.none() + ): CompletableFuture<CustomChartsSectionResponse> = clone(params, RequestOptions.none()) + + /** @see clone */ + fun clone(requestOptions: RequestOptions): CompletableFuture<CustomChartsSectionResponse> = + clone(SectionCloneParams.none(), requestOptions) + + /** + * A view of [SectionServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): SectionServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/charts/section`, but is otherwise the same + * as [SectionServiceAsync.create]. + */ + fun create( + params: SectionCreateParams + ): CompletableFuture<HttpResponseFor<CustomChartsSectionResponse>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: SectionCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CustomChartsSectionResponse>> + + /** @see create */ + fun create( + customChartsSectionCreate: CustomChartsSectionCreate, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CustomChartsSectionResponse>> = + create( + SectionCreateParams.builder() + .customChartsSectionCreate(customChartsSectionCreate) + .build(), + requestOptions, + ) + + /** @see create */ + fun create( + customChartsSectionCreate: CustomChartsSectionCreate + ): CompletableFuture<HttpResponseFor<CustomChartsSectionResponse>> = + create(customChartsSectionCreate, RequestOptions.none()) + + /** + * Returns a raw HTTP response for `patch /api/v1/charts/section/{section_id}`, but is + * otherwise the same as [SectionServiceAsync.update]. + */ + fun update( + sectionId: String, + params: SectionUpdateParams, + ): CompletableFuture<HttpResponseFor<CustomChartsSectionResponse>> = + update(sectionId, params, RequestOptions.none()) + + /** @see update */ + fun update( + sectionId: String, + params: SectionUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CustomChartsSectionResponse>> = + update(params.toBuilder().sectionId(sectionId).build(), requestOptions) + + /** @see update */ + fun update( + params: SectionUpdateParams + ): CompletableFuture<HttpResponseFor<CustomChartsSectionResponse>> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: SectionUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CustomChartsSectionResponse>> + + /** + * Returns a raw HTTP response for `get /api/v1/charts/section`, but is otherwise the same + * as [SectionServiceAsync.list]. + */ + fun list(): CompletableFuture<HttpResponseFor<List<CustomChartsSectionResponse>>> = + list(SectionListParams.none()) + + /** @see list */ + fun list( + params: SectionListParams = SectionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<CustomChartsSectionResponse>>> + + /** @see list */ + fun list( + params: SectionListParams = SectionListParams.none() + ): CompletableFuture<HttpResponseFor<List<CustomChartsSectionResponse>>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<CustomChartsSectionResponse>>> = + list(SectionListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/charts/section/{section_id}`, but is + * otherwise the same as [SectionServiceAsync.delete]. + */ + fun delete(sectionId: String): CompletableFuture<HttpResponseFor<SectionDeleteResponse>> = + delete(sectionId, SectionDeleteParams.none()) + + /** @see delete */ + fun delete( + sectionId: String, + params: SectionDeleteParams = SectionDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<SectionDeleteResponse>> = + delete(params.toBuilder().sectionId(sectionId).build(), requestOptions) + + /** @see delete */ + fun delete( + sectionId: String, + params: SectionDeleteParams = SectionDeleteParams.none(), + ): CompletableFuture<HttpResponseFor<SectionDeleteResponse>> = + delete(sectionId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: SectionDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<SectionDeleteResponse>> + + /** @see delete */ + fun delete( + params: SectionDeleteParams + ): CompletableFuture<HttpResponseFor<SectionDeleteResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + sectionId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<SectionDeleteResponse>> = + delete(sectionId, SectionDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/charts/section/clone`, but is otherwise the + * same as [SectionServiceAsync.clone]. + */ + fun clone(): CompletableFuture<HttpResponseFor<CustomChartsSectionResponse>> = + clone(SectionCloneParams.none()) + + /** @see clone */ + fun clone( + params: SectionCloneParams = SectionCloneParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CustomChartsSectionResponse>> + + /** @see clone */ + fun clone( + params: SectionCloneParams = SectionCloneParams.none() + ): CompletableFuture<HttpResponseFor<CustomChartsSectionResponse>> = + clone(params, RequestOptions.none()) + + /** @see clone */ + fun clone( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<CustomChartsSectionResponse>> = + clone(SectionCloneParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/charts/SectionServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/charts/SectionServiceAsyncImpl.kt new file mode 100644 index 00000000..5162850d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/charts/SectionServiceAsyncImpl.kt @@ -0,0 +1,250 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.charts + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.charts.section.CustomChartsSectionResponse +import com.langsmith_api.api.models.api.v1.charts.section.SectionCloneParams +import com.langsmith_api.api.models.api.v1.charts.section.SectionCreateParams +import com.langsmith_api.api.models.api.v1.charts.section.SectionDeleteParams +import com.langsmith_api.api.models.api.v1.charts.section.SectionDeleteResponse +import com.langsmith_api.api.models.api.v1.charts.section.SectionListParams +import com.langsmith_api.api.models.api.v1.charts.section.SectionUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class SectionServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + SectionServiceAsync { + + private val withRawResponse: SectionServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): SectionServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): SectionServiceAsync = + SectionServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: SectionCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<CustomChartsSectionResponse> = + // post /api/v1/charts/section + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: SectionUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<CustomChartsSectionResponse> = + // patch /api/v1/charts/section/{section_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: SectionListParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<CustomChartsSectionResponse>> = + // get /api/v1/charts/section + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: SectionDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<SectionDeleteResponse> = + // delete /api/v1/charts/section/{section_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + override fun clone( + params: SectionCloneParams, + requestOptions: RequestOptions, + ): CompletableFuture<CustomChartsSectionResponse> = + // post /api/v1/charts/section/clone + withRawResponse().clone(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SectionServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): SectionServiceAsync.WithRawResponse = + SectionServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<CustomChartsSectionResponse> = + jsonHandler<CustomChartsSectionResponse>(clientOptions.jsonMapper) + + override fun create( + params: SectionCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<CustomChartsSectionResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "charts", "section") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler<CustomChartsSectionResponse> = + jsonHandler<CustomChartsSectionResponse>(clientOptions.jsonMapper) + + override fun update( + params: SectionUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<CustomChartsSectionResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("sectionId", params.sectionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "charts", "section", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler<List<CustomChartsSectionResponse>> = + jsonHandler<List<CustomChartsSectionResponse>>(clientOptions.jsonMapper) + + override fun list( + params: SectionListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<CustomChartsSectionResponse>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "charts", "section") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val deleteHandler: Handler<SectionDeleteResponse> = + jsonHandler<SectionDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: SectionDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<SectionDeleteResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("sectionId", params.sectionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "charts", "section", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val cloneHandler: Handler<CustomChartsSectionResponse> = + jsonHandler<CustomChartsSectionResponse>(clientOptions.jsonMapper) + + override fun clone( + params: SectionCloneParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<CustomChartsSectionResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "charts", "section", "clone") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { cloneHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/comments/LikeServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/comments/LikeServiceAsync.kt new file mode 100644 index 00000000..70007223 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/comments/LikeServiceAsync.kt @@ -0,0 +1,151 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.comments + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.comments.like.LikeCreateParams +import com.langsmith_api.api.models.api.v1.comments.like.LikeCreateResponse +import com.langsmith_api.api.models.api.v1.comments.like.LikeDeleteAllParams +import com.langsmith_api.api.models.api.v1.comments.like.LikeDeleteAllResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface LikeServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): LikeServiceAsync + + /** Like Comment */ + fun create( + parentCommentId: String, + params: LikeCreateParams, + ): CompletableFuture<LikeCreateResponse> = + create(parentCommentId, params, RequestOptions.none()) + + /** @see create */ + fun create( + parentCommentId: String, + params: LikeCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<LikeCreateResponse> = + create(params.toBuilder().parentCommentId(parentCommentId).build(), requestOptions) + + /** @see create */ + fun create(params: LikeCreateParams): CompletableFuture<LikeCreateResponse> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: LikeCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<LikeCreateResponse> + + /** Unlike Comment */ + fun deleteAll( + parentCommentId: String, + params: LikeDeleteAllParams, + ): CompletableFuture<LikeDeleteAllResponse> = + deleteAll(parentCommentId, params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + parentCommentId: String, + params: LikeDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<LikeDeleteAllResponse> = + deleteAll(params.toBuilder().parentCommentId(parentCommentId).build(), requestOptions) + + /** @see deleteAll */ + fun deleteAll(params: LikeDeleteAllParams): CompletableFuture<LikeDeleteAllResponse> = + deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + params: LikeDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<LikeDeleteAllResponse> + + /** A view of [LikeServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): LikeServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post + * /api/v1/comments/{owner}/{repo}/{parent_comment_id}/like`, but is otherwise the same as + * [LikeServiceAsync.create]. + */ + fun create( + parentCommentId: String, + params: LikeCreateParams, + ): CompletableFuture<HttpResponseFor<LikeCreateResponse>> = + create(parentCommentId, params, RequestOptions.none()) + + /** @see create */ + fun create( + parentCommentId: String, + params: LikeCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<LikeCreateResponse>> = + create(params.toBuilder().parentCommentId(parentCommentId).build(), requestOptions) + + /** @see create */ + fun create( + params: LikeCreateParams + ): CompletableFuture<HttpResponseFor<LikeCreateResponse>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: LikeCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<LikeCreateResponse>> + + /** + * Returns a raw HTTP response for `delete + * /api/v1/comments/{owner}/{repo}/{parent_comment_id}/like`, but is otherwise the same as + * [LikeServiceAsync.deleteAll]. + */ + fun deleteAll( + parentCommentId: String, + params: LikeDeleteAllParams, + ): CompletableFuture<HttpResponseFor<LikeDeleteAllResponse>> = + deleteAll(parentCommentId, params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + parentCommentId: String, + params: LikeDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<LikeDeleteAllResponse>> = + deleteAll(params.toBuilder().parentCommentId(parentCommentId).build(), requestOptions) + + /** @see deleteAll */ + fun deleteAll( + params: LikeDeleteAllParams + ): CompletableFuture<HttpResponseFor<LikeDeleteAllResponse>> = + deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + params: LikeDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<LikeDeleteAllResponse>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/comments/LikeServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/comments/LikeServiceAsyncImpl.kt new file mode 100644 index 00000000..ad6b7e65 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/comments/LikeServiceAsyncImpl.kt @@ -0,0 +1,150 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.comments + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.comments.like.LikeCreateParams +import com.langsmith_api.api.models.api.v1.comments.like.LikeCreateResponse +import com.langsmith_api.api.models.api.v1.comments.like.LikeDeleteAllParams +import com.langsmith_api.api.models.api.v1.comments.like.LikeDeleteAllResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class LikeServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + LikeServiceAsync { + + private val withRawResponse: LikeServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): LikeServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): LikeServiceAsync = + LikeServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: LikeCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<LikeCreateResponse> = + // post /api/v1/comments/{owner}/{repo}/{parent_comment_id}/like + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun deleteAll( + params: LikeDeleteAllParams, + requestOptions: RequestOptions, + ): CompletableFuture<LikeDeleteAllResponse> = + // delete /api/v1/comments/{owner}/{repo}/{parent_comment_id}/like + withRawResponse().deleteAll(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + LikeServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): LikeServiceAsync.WithRawResponse = + LikeServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<LikeCreateResponse> = + jsonHandler<LikeCreateResponse>(clientOptions.jsonMapper) + + override fun create( + params: LikeCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<LikeCreateResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("parentCommentId", params.parentCommentId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "comments", + params._pathParam(0), + params._pathParam(1), + params._pathParam(2), + "like", + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val deleteAllHandler: Handler<LikeDeleteAllResponse> = + jsonHandler<LikeDeleteAllResponse>(clientOptions.jsonMapper) + + override fun deleteAll( + params: LikeDeleteAllParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<LikeDeleteAllResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("parentCommentId", params.parentCommentId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "comments", + params._pathParam(0), + params._pathParam(1), + params._pathParam(2), + "like", + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteAllHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/ComparativeServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/ComparativeServiceAsync.kt new file mode 100644 index 00000000..9de22df4 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/ComparativeServiceAsync.kt @@ -0,0 +1,236 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.datasets + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.datasets.comparative.ComparativeCreateParams +import com.langsmith_api.api.models.api.v1.datasets.comparative.ComparativeCreateResponse +import com.langsmith_api.api.models.api.v1.datasets.comparative.ComparativeDeleteParams +import com.langsmith_api.api.models.api.v1.datasets.comparative.ComparativeDeleteResponse +import com.langsmith_api.api.models.api.v1.datasets.comparative.ComparativeListParams +import com.langsmith_api.api.models.api.v1.datasets.comparative.ComparativeListResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface ComparativeServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ComparativeServiceAsync + + /** Create a comparative experiment. */ + fun create(params: ComparativeCreateParams): CompletableFuture<ComparativeCreateResponse> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: ComparativeCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ComparativeCreateResponse> + + /** Get all comparative experiments for a given dataset. */ + fun list(datasetId: String): CompletableFuture<List<ComparativeListResponse>> = + list(datasetId, ComparativeListParams.none()) + + /** @see list */ + fun list( + datasetId: String, + params: ComparativeListParams = ComparativeListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<ComparativeListResponse>> = + list(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see list */ + fun list( + datasetId: String, + params: ComparativeListParams = ComparativeListParams.none(), + ): CompletableFuture<List<ComparativeListResponse>> = + list(datasetId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: ComparativeListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<ComparativeListResponse>> + + /** @see list */ + fun list(params: ComparativeListParams): CompletableFuture<List<ComparativeListResponse>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + datasetId: String, + requestOptions: RequestOptions, + ): CompletableFuture<List<ComparativeListResponse>> = + list(datasetId, ComparativeListParams.none(), requestOptions) + + /** Delete a specific comparative experiment. */ + fun delete(comparativeExperimentId: String): CompletableFuture<ComparativeDeleteResponse> = + delete(comparativeExperimentId, ComparativeDeleteParams.none()) + + /** @see delete */ + fun delete( + comparativeExperimentId: String, + params: ComparativeDeleteParams = ComparativeDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ComparativeDeleteResponse> = + delete( + params.toBuilder().comparativeExperimentId(comparativeExperimentId).build(), + requestOptions, + ) + + /** @see delete */ + fun delete( + comparativeExperimentId: String, + params: ComparativeDeleteParams = ComparativeDeleteParams.none(), + ): CompletableFuture<ComparativeDeleteResponse> = + delete(comparativeExperimentId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ComparativeDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ComparativeDeleteResponse> + + /** @see delete */ + fun delete(params: ComparativeDeleteParams): CompletableFuture<ComparativeDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + comparativeExperimentId: String, + requestOptions: RequestOptions, + ): CompletableFuture<ComparativeDeleteResponse> = + delete(comparativeExperimentId, ComparativeDeleteParams.none(), requestOptions) + + /** + * A view of [ComparativeServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ComparativeServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/datasets/comparative`, but is otherwise the + * same as [ComparativeServiceAsync.create]. + */ + fun create( + params: ComparativeCreateParams + ): CompletableFuture<HttpResponseFor<ComparativeCreateResponse>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: ComparativeCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ComparativeCreateResponse>> + + /** + * Returns a raw HTTP response for `get /api/v1/datasets/{dataset_id}/comparative`, but is + * otherwise the same as [ComparativeServiceAsync.list]. + */ + fun list( + datasetId: String + ): CompletableFuture<HttpResponseFor<List<ComparativeListResponse>>> = + list(datasetId, ComparativeListParams.none()) + + /** @see list */ + fun list( + datasetId: String, + params: ComparativeListParams = ComparativeListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<ComparativeListResponse>>> = + list(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see list */ + fun list( + datasetId: String, + params: ComparativeListParams = ComparativeListParams.none(), + ): CompletableFuture<HttpResponseFor<List<ComparativeListResponse>>> = + list(datasetId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: ComparativeListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<ComparativeListResponse>>> + + /** @see list */ + fun list( + params: ComparativeListParams + ): CompletableFuture<HttpResponseFor<List<ComparativeListResponse>>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + datasetId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<ComparativeListResponse>>> = + list(datasetId, ComparativeListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete + * /api/v1/datasets/comparative/{comparative_experiment_id}`, but is otherwise the same as + * [ComparativeServiceAsync.delete]. + */ + fun delete( + comparativeExperimentId: String + ): CompletableFuture<HttpResponseFor<ComparativeDeleteResponse>> = + delete(comparativeExperimentId, ComparativeDeleteParams.none()) + + /** @see delete */ + fun delete( + comparativeExperimentId: String, + params: ComparativeDeleteParams = ComparativeDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ComparativeDeleteResponse>> = + delete( + params.toBuilder().comparativeExperimentId(comparativeExperimentId).build(), + requestOptions, + ) + + /** @see delete */ + fun delete( + comparativeExperimentId: String, + params: ComparativeDeleteParams = ComparativeDeleteParams.none(), + ): CompletableFuture<HttpResponseFor<ComparativeDeleteResponse>> = + delete(comparativeExperimentId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ComparativeDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ComparativeDeleteResponse>> + + /** @see delete */ + fun delete( + params: ComparativeDeleteParams + ): CompletableFuture<HttpResponseFor<ComparativeDeleteResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + comparativeExperimentId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ComparativeDeleteResponse>> = + delete(comparativeExperimentId, ComparativeDeleteParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/ComparativeServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/ComparativeServiceAsyncImpl.kt new file mode 100644 index 00000000..405b176d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/ComparativeServiceAsyncImpl.kt @@ -0,0 +1,173 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.datasets + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.datasets.comparative.ComparativeCreateParams +import com.langsmith_api.api.models.api.v1.datasets.comparative.ComparativeCreateResponse +import com.langsmith_api.api.models.api.v1.datasets.comparative.ComparativeDeleteParams +import com.langsmith_api.api.models.api.v1.datasets.comparative.ComparativeDeleteResponse +import com.langsmith_api.api.models.api.v1.datasets.comparative.ComparativeListParams +import com.langsmith_api.api.models.api.v1.datasets.comparative.ComparativeListResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ComparativeServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ComparativeServiceAsync { + + private val withRawResponse: ComparativeServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ComparativeServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): ComparativeServiceAsync = + ComparativeServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: ComparativeCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<ComparativeCreateResponse> = + // post /api/v1/datasets/comparative + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: ComparativeListParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<ComparativeListResponse>> = + // get /api/v1/datasets/{dataset_id}/comparative + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: ComparativeDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<ComparativeDeleteResponse> = + // delete /api/v1/datasets/comparative/{comparative_experiment_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ComparativeServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ComparativeServiceAsync.WithRawResponse = + ComparativeServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<ComparativeCreateResponse> = + jsonHandler<ComparativeCreateResponse>(clientOptions.jsonMapper) + + override fun create( + params: ComparativeCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ComparativeCreateResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", "comparative") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler<List<ComparativeListResponse>> = + jsonHandler<List<ComparativeListResponse>>(clientOptions.jsonMapper) + + override fun list( + params: ComparativeListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<ComparativeListResponse>>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "comparative") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val deleteHandler: Handler<ComparativeDeleteResponse> = + jsonHandler<ComparativeDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: ComparativeDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ComparativeDeleteResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("comparativeExperimentId", params.comparativeExperimentId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", "comparative", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/ExperimentServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/ExperimentServiceAsync.kt new file mode 100644 index 00000000..7538a5d6 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/ExperimentServiceAsync.kt @@ -0,0 +1,97 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.datasets + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.datasets.experiments.ExperimentGroupedParams +import com.langsmith_api.api.models.api.v1.datasets.experiments.ExperimentGroupedResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface ExperimentServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ExperimentServiceAsync + + /** Stream grouped and aggregated experiments. */ + fun grouped( + datasetId: String, + params: ExperimentGroupedParams, + ): CompletableFuture<ExperimentGroupedResponse> = + grouped(datasetId, params, RequestOptions.none()) + + /** @see grouped */ + fun grouped( + datasetId: String, + params: ExperimentGroupedParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ExperimentGroupedResponse> = + grouped(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see grouped */ + fun grouped(params: ExperimentGroupedParams): CompletableFuture<ExperimentGroupedResponse> = + grouped(params, RequestOptions.none()) + + /** @see grouped */ + fun grouped( + params: ExperimentGroupedParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ExperimentGroupedResponse> + + /** + * A view of [ExperimentServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ExperimentServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/datasets/{dataset_id}/experiments/grouped`, + * but is otherwise the same as [ExperimentServiceAsync.grouped]. + */ + fun grouped( + datasetId: String, + params: ExperimentGroupedParams, + ): CompletableFuture<HttpResponseFor<ExperimentGroupedResponse>> = + grouped(datasetId, params, RequestOptions.none()) + + /** @see grouped */ + fun grouped( + datasetId: String, + params: ExperimentGroupedParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ExperimentGroupedResponse>> = + grouped(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see grouped */ + fun grouped( + params: ExperimentGroupedParams + ): CompletableFuture<HttpResponseFor<ExperimentGroupedResponse>> = + grouped(params, RequestOptions.none()) + + /** @see grouped */ + fun grouped( + params: ExperimentGroupedParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ExperimentGroupedResponse>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/ExperimentServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/ExperimentServiceAsyncImpl.kt new file mode 100644 index 00000000..cd1eefcc --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/ExperimentServiceAsyncImpl.kt @@ -0,0 +1,98 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.datasets + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.datasets.experiments.ExperimentGroupedParams +import com.langsmith_api.api.models.api.v1.datasets.experiments.ExperimentGroupedResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ExperimentServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ExperimentServiceAsync { + + private val withRawResponse: ExperimentServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ExperimentServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): ExperimentServiceAsync = + ExperimentServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun grouped( + params: ExperimentGroupedParams, + requestOptions: RequestOptions, + ): CompletableFuture<ExperimentGroupedResponse> = + // post /api/v1/datasets/{dataset_id}/experiments/grouped + withRawResponse().grouped(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ExperimentServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ExperimentServiceAsync.WithRawResponse = + ExperimentServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val groupedHandler: Handler<ExperimentGroupedResponse> = + jsonHandler<ExperimentGroupedResponse>(clientOptions.jsonMapper) + + override fun grouped( + params: ExperimentGroupedParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ExperimentGroupedResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "datasets", + params._pathParam(0), + "experiments", + "grouped", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { groupedHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/GroupServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/GroupServiceAsync.kt new file mode 100644 index 00000000..844b42c3 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/GroupServiceAsync.kt @@ -0,0 +1,92 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.datasets + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.datasets.group.GroupRunsParams +import com.langsmith_api.api.models.api.v1.datasets.group.GroupRunsResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface GroupServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): GroupServiceAsync + + /** + * Fetch examples for a dataset, and fetch the runs for each example if they are associated with + * the given session_ids. + */ + fun runs(datasetId: String, params: GroupRunsParams): CompletableFuture<GroupRunsResponse> = + runs(datasetId, params, RequestOptions.none()) + + /** @see runs */ + fun runs( + datasetId: String, + params: GroupRunsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<GroupRunsResponse> = + runs(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see runs */ + fun runs(params: GroupRunsParams): CompletableFuture<GroupRunsResponse> = + runs(params, RequestOptions.none()) + + /** @see runs */ + fun runs( + params: GroupRunsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<GroupRunsResponse> + + /** A view of [GroupServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): GroupServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/datasets/{dataset_id}/group/runs`, but is + * otherwise the same as [GroupServiceAsync.runs]. + */ + fun runs( + datasetId: String, + params: GroupRunsParams, + ): CompletableFuture<HttpResponseFor<GroupRunsResponse>> = + runs(datasetId, params, RequestOptions.none()) + + /** @see runs */ + fun runs( + datasetId: String, + params: GroupRunsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<GroupRunsResponse>> = + runs(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see runs */ + fun runs(params: GroupRunsParams): CompletableFuture<HttpResponseFor<GroupRunsResponse>> = + runs(params, RequestOptions.none()) + + /** @see runs */ + fun runs( + params: GroupRunsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<GroupRunsResponse>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/GroupServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/GroupServiceAsyncImpl.kt new file mode 100644 index 00000000..b699ebc7 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/GroupServiceAsyncImpl.kt @@ -0,0 +1,91 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.datasets + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.datasets.group.GroupRunsParams +import com.langsmith_api.api.models.api.v1.datasets.group.GroupRunsResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class GroupServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + GroupServiceAsync { + + private val withRawResponse: GroupServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): GroupServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): GroupServiceAsync = + GroupServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun runs( + params: GroupRunsParams, + requestOptions: RequestOptions, + ): CompletableFuture<GroupRunsResponse> = + // post /api/v1/datasets/{dataset_id}/group/runs + withRawResponse().runs(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + GroupServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): GroupServiceAsync.WithRawResponse = + GroupServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val runsHandler: Handler<GroupRunsResponse> = + jsonHandler<GroupRunsResponse>(clientOptions.jsonMapper) + + override fun runs( + params: GroupRunsParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<GroupRunsResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "group", "runs") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { runsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/IndexServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/IndexServiceAsync.kt new file mode 100644 index 00000000..26229cb1 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/IndexServiceAsync.kt @@ -0,0 +1,348 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.datasets + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.datasets.index.IndexCreateParams +import com.langsmith_api.api.models.api.v1.datasets.index.IndexCreateResponse +import com.langsmith_api.api.models.api.v1.datasets.index.IndexDeleteAllParams +import com.langsmith_api.api.models.api.v1.datasets.index.IndexDeleteAllResponse +import com.langsmith_api.api.models.api.v1.datasets.index.IndexListParams +import com.langsmith_api.api.models.api.v1.datasets.index.IndexListResponse +import com.langsmith_api.api.models.api.v1.datasets.index.IndexSyncParams +import com.langsmith_api.api.models.api.v1.datasets.index.IndexSyncResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface IndexServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): IndexServiceAsync + + /** Index a dataset. */ + fun create(datasetId: String): CompletableFuture<IndexCreateResponse> = + create(datasetId, IndexCreateParams.none()) + + /** @see create */ + fun create( + datasetId: String, + params: IndexCreateParams = IndexCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<IndexCreateResponse> = + create(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see create */ + fun create( + datasetId: String, + params: IndexCreateParams = IndexCreateParams.none(), + ): CompletableFuture<IndexCreateResponse> = create(datasetId, params, RequestOptions.none()) + + /** @see create */ + fun create( + params: IndexCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<IndexCreateResponse> + + /** @see create */ + fun create(params: IndexCreateParams): CompletableFuture<IndexCreateResponse> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + datasetId: String, + requestOptions: RequestOptions, + ): CompletableFuture<IndexCreateResponse> = + create(datasetId, IndexCreateParams.none(), requestOptions) + + /** Get index info. */ + fun list(datasetId: String): CompletableFuture<IndexListResponse> = + list(datasetId, IndexListParams.none()) + + /** @see list */ + fun list( + datasetId: String, + params: IndexListParams = IndexListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<IndexListResponse> = + list(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see list */ + fun list( + datasetId: String, + params: IndexListParams = IndexListParams.none(), + ): CompletableFuture<IndexListResponse> = list(datasetId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: IndexListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<IndexListResponse> + + /** @see list */ + fun list(params: IndexListParams): CompletableFuture<IndexListResponse> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + datasetId: String, + requestOptions: RequestOptions, + ): CompletableFuture<IndexListResponse> = + list(datasetId, IndexListParams.none(), requestOptions) + + /** Remove an index for a dataset. */ + fun deleteAll(datasetId: String): CompletableFuture<IndexDeleteAllResponse> = + deleteAll(datasetId, IndexDeleteAllParams.none()) + + /** @see deleteAll */ + fun deleteAll( + datasetId: String, + params: IndexDeleteAllParams = IndexDeleteAllParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<IndexDeleteAllResponse> = + deleteAll(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see deleteAll */ + fun deleteAll( + datasetId: String, + params: IndexDeleteAllParams = IndexDeleteAllParams.none(), + ): CompletableFuture<IndexDeleteAllResponse> = + deleteAll(datasetId, params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + params: IndexDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<IndexDeleteAllResponse> + + /** @see deleteAll */ + fun deleteAll(params: IndexDeleteAllParams): CompletableFuture<IndexDeleteAllResponse> = + deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + datasetId: String, + requestOptions: RequestOptions, + ): CompletableFuture<IndexDeleteAllResponse> = + deleteAll(datasetId, IndexDeleteAllParams.none(), requestOptions) + + /** Sync an index for a dataset. */ + fun sync(datasetId: String): CompletableFuture<IndexSyncResponse> = + sync(datasetId, IndexSyncParams.none()) + + /** @see sync */ + fun sync( + datasetId: String, + params: IndexSyncParams = IndexSyncParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<IndexSyncResponse> = + sync(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see sync */ + fun sync( + datasetId: String, + params: IndexSyncParams = IndexSyncParams.none(), + ): CompletableFuture<IndexSyncResponse> = sync(datasetId, params, RequestOptions.none()) + + /** @see sync */ + fun sync( + params: IndexSyncParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<IndexSyncResponse> + + /** @see sync */ + fun sync(params: IndexSyncParams): CompletableFuture<IndexSyncResponse> = + sync(params, RequestOptions.none()) + + /** @see sync */ + fun sync( + datasetId: String, + requestOptions: RequestOptions, + ): CompletableFuture<IndexSyncResponse> = + sync(datasetId, IndexSyncParams.none(), requestOptions) + + /** A view of [IndexServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): IndexServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/datasets/{dataset_id}/index`, but is + * otherwise the same as [IndexServiceAsync.create]. + */ + fun create(datasetId: String): CompletableFuture<HttpResponseFor<IndexCreateResponse>> = + create(datasetId, IndexCreateParams.none()) + + /** @see create */ + fun create( + datasetId: String, + params: IndexCreateParams = IndexCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<IndexCreateResponse>> = + create(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see create */ + fun create( + datasetId: String, + params: IndexCreateParams = IndexCreateParams.none(), + ): CompletableFuture<HttpResponseFor<IndexCreateResponse>> = + create(datasetId, params, RequestOptions.none()) + + /** @see create */ + fun create( + params: IndexCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<IndexCreateResponse>> + + /** @see create */ + fun create( + params: IndexCreateParams + ): CompletableFuture<HttpResponseFor<IndexCreateResponse>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + datasetId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<IndexCreateResponse>> = + create(datasetId, IndexCreateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/datasets/{dataset_id}/index`, but is + * otherwise the same as [IndexServiceAsync.list]. + */ + fun list(datasetId: String): CompletableFuture<HttpResponseFor<IndexListResponse>> = + list(datasetId, IndexListParams.none()) + + /** @see list */ + fun list( + datasetId: String, + params: IndexListParams = IndexListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<IndexListResponse>> = + list(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see list */ + fun list( + datasetId: String, + params: IndexListParams = IndexListParams.none(), + ): CompletableFuture<HttpResponseFor<IndexListResponse>> = + list(datasetId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: IndexListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<IndexListResponse>> + + /** @see list */ + fun list(params: IndexListParams): CompletableFuture<HttpResponseFor<IndexListResponse>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + datasetId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<IndexListResponse>> = + list(datasetId, IndexListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/datasets/{dataset_id}/index`, but is + * otherwise the same as [IndexServiceAsync.deleteAll]. + */ + fun deleteAll( + datasetId: String + ): CompletableFuture<HttpResponseFor<IndexDeleteAllResponse>> = + deleteAll(datasetId, IndexDeleteAllParams.none()) + + /** @see deleteAll */ + fun deleteAll( + datasetId: String, + params: IndexDeleteAllParams = IndexDeleteAllParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<IndexDeleteAllResponse>> = + deleteAll(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see deleteAll */ + fun deleteAll( + datasetId: String, + params: IndexDeleteAllParams = IndexDeleteAllParams.none(), + ): CompletableFuture<HttpResponseFor<IndexDeleteAllResponse>> = + deleteAll(datasetId, params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + params: IndexDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<IndexDeleteAllResponse>> + + /** @see deleteAll */ + fun deleteAll( + params: IndexDeleteAllParams + ): CompletableFuture<HttpResponseFor<IndexDeleteAllResponse>> = + deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + datasetId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<IndexDeleteAllResponse>> = + deleteAll(datasetId, IndexDeleteAllParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/datasets/{dataset_id}/index/sync`, but is + * otherwise the same as [IndexServiceAsync.sync]. + */ + fun sync(datasetId: String): CompletableFuture<HttpResponseFor<IndexSyncResponse>> = + sync(datasetId, IndexSyncParams.none()) + + /** @see sync */ + fun sync( + datasetId: String, + params: IndexSyncParams = IndexSyncParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<IndexSyncResponse>> = + sync(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see sync */ + fun sync( + datasetId: String, + params: IndexSyncParams = IndexSyncParams.none(), + ): CompletableFuture<HttpResponseFor<IndexSyncResponse>> = + sync(datasetId, params, RequestOptions.none()) + + /** @see sync */ + fun sync( + params: IndexSyncParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<IndexSyncResponse>> + + /** @see sync */ + fun sync(params: IndexSyncParams): CompletableFuture<HttpResponseFor<IndexSyncResponse>> = + sync(params, RequestOptions.none()) + + /** @see sync */ + fun sync( + datasetId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<IndexSyncResponse>> = + sync(datasetId, IndexSyncParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/IndexServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/IndexServiceAsyncImpl.kt new file mode 100644 index 00000000..c7598c96 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/IndexServiceAsyncImpl.kt @@ -0,0 +1,219 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.datasets + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.datasets.index.IndexCreateParams +import com.langsmith_api.api.models.api.v1.datasets.index.IndexCreateResponse +import com.langsmith_api.api.models.api.v1.datasets.index.IndexDeleteAllParams +import com.langsmith_api.api.models.api.v1.datasets.index.IndexDeleteAllResponse +import com.langsmith_api.api.models.api.v1.datasets.index.IndexListParams +import com.langsmith_api.api.models.api.v1.datasets.index.IndexListResponse +import com.langsmith_api.api.models.api.v1.datasets.index.IndexSyncParams +import com.langsmith_api.api.models.api.v1.datasets.index.IndexSyncResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class IndexServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + IndexServiceAsync { + + private val withRawResponse: IndexServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): IndexServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): IndexServiceAsync = + IndexServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: IndexCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<IndexCreateResponse> = + // post /api/v1/datasets/{dataset_id}/index + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: IndexListParams, + requestOptions: RequestOptions, + ): CompletableFuture<IndexListResponse> = + // get /api/v1/datasets/{dataset_id}/index + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun deleteAll( + params: IndexDeleteAllParams, + requestOptions: RequestOptions, + ): CompletableFuture<IndexDeleteAllResponse> = + // delete /api/v1/datasets/{dataset_id}/index + withRawResponse().deleteAll(params, requestOptions).thenApply { it.parse() } + + override fun sync( + params: IndexSyncParams, + requestOptions: RequestOptions, + ): CompletableFuture<IndexSyncResponse> = + // post /api/v1/datasets/{dataset_id}/index/sync + withRawResponse().sync(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + IndexServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): IndexServiceAsync.WithRawResponse = + IndexServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<IndexCreateResponse> = + jsonHandler<IndexCreateResponse>(clientOptions.jsonMapper) + + override fun create( + params: IndexCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<IndexCreateResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "index") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler<IndexListResponse> = + jsonHandler<IndexListResponse>(clientOptions.jsonMapper) + + override fun list( + params: IndexListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<IndexListResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "index") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val deleteAllHandler: Handler<IndexDeleteAllResponse> = + jsonHandler<IndexDeleteAllResponse>(clientOptions.jsonMapper) + + override fun deleteAll( + params: IndexDeleteAllParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<IndexDeleteAllResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "index") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteAllHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val syncHandler: Handler<IndexSyncResponse> = + jsonHandler<IndexSyncResponse>(clientOptions.jsonMapper) + + override fun sync( + params: IndexSyncParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<IndexSyncResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "index", "sync") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { syncHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/PlaygroundExperimentServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/PlaygroundExperimentServiceAsync.kt new file mode 100644 index 00000000..95e8c1b0 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/PlaygroundExperimentServiceAsync.kt @@ -0,0 +1,96 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.datasets + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.datasets.playgroundexperiment.PlaygroundExperimentBatchParams +import com.langsmith_api.api.models.api.v1.datasets.playgroundexperiment.PlaygroundExperimentBatchResponse +import com.langsmith_api.api.models.api.v1.datasets.playgroundexperiment.PlaygroundExperimentStreamParams +import com.langsmith_api.api.models.api.v1.datasets.playgroundexperiment.PlaygroundExperimentStreamResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface PlaygroundExperimentServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): PlaygroundExperimentServiceAsync + + /** Dataset Handler */ + fun batch( + params: PlaygroundExperimentBatchParams + ): CompletableFuture<PlaygroundExperimentBatchResponse> = batch(params, RequestOptions.none()) + + /** @see batch */ + fun batch( + params: PlaygroundExperimentBatchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<PlaygroundExperimentBatchResponse> + + /** Stream Dataset Handler */ + fun stream( + params: PlaygroundExperimentStreamParams + ): CompletableFuture<PlaygroundExperimentStreamResponse> = stream(params, RequestOptions.none()) + + /** @see stream */ + fun stream( + params: PlaygroundExperimentStreamParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<PlaygroundExperimentStreamResponse> + + /** + * A view of [PlaygroundExperimentServiceAsync] that provides access to raw HTTP responses for + * each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PlaygroundExperimentServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/datasets/playground_experiment/batch`, but + * is otherwise the same as [PlaygroundExperimentServiceAsync.batch]. + */ + fun batch( + params: PlaygroundExperimentBatchParams + ): CompletableFuture<HttpResponseFor<PlaygroundExperimentBatchResponse>> = + batch(params, RequestOptions.none()) + + /** @see batch */ + fun batch( + params: PlaygroundExperimentBatchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<PlaygroundExperimentBatchResponse>> + + /** + * Returns a raw HTTP response for `post /api/v1/datasets/playground_experiment/stream`, but + * is otherwise the same as [PlaygroundExperimentServiceAsync.stream]. + */ + fun stream( + params: PlaygroundExperimentStreamParams + ): CompletableFuture<HttpResponseFor<PlaygroundExperimentStreamResponse>> = + stream(params, RequestOptions.none()) + + /** @see stream */ + fun stream( + params: PlaygroundExperimentStreamParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<PlaygroundExperimentStreamResponse>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/PlaygroundExperimentServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/PlaygroundExperimentServiceAsyncImpl.kt new file mode 100644 index 00000000..be1fdc60 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/PlaygroundExperimentServiceAsyncImpl.kt @@ -0,0 +1,131 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.datasets + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.datasets.playgroundexperiment.PlaygroundExperimentBatchParams +import com.langsmith_api.api.models.api.v1.datasets.playgroundexperiment.PlaygroundExperimentBatchResponse +import com.langsmith_api.api.models.api.v1.datasets.playgroundexperiment.PlaygroundExperimentStreamParams +import com.langsmith_api.api.models.api.v1.datasets.playgroundexperiment.PlaygroundExperimentStreamResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class PlaygroundExperimentServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : PlaygroundExperimentServiceAsync { + + private val withRawResponse: PlaygroundExperimentServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): PlaygroundExperimentServiceAsync.WithRawResponse = + withRawResponse + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PlaygroundExperimentServiceAsync = + PlaygroundExperimentServiceAsyncImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun batch( + params: PlaygroundExperimentBatchParams, + requestOptions: RequestOptions, + ): CompletableFuture<PlaygroundExperimentBatchResponse> = + // post /api/v1/datasets/playground_experiment/batch + withRawResponse().batch(params, requestOptions).thenApply { it.parse() } + + override fun stream( + params: PlaygroundExperimentStreamParams, + requestOptions: RequestOptions, + ): CompletableFuture<PlaygroundExperimentStreamResponse> = + // post /api/v1/datasets/playground_experiment/stream + withRawResponse().stream(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + PlaygroundExperimentServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PlaygroundExperimentServiceAsync.WithRawResponse = + PlaygroundExperimentServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val batchHandler: Handler<PlaygroundExperimentBatchResponse> = + jsonHandler<PlaygroundExperimentBatchResponse>(clientOptions.jsonMapper) + + override fun batch( + params: PlaygroundExperimentBatchParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<PlaygroundExperimentBatchResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", "playground_experiment", "batch") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { batchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val streamHandler: Handler<PlaygroundExperimentStreamResponse> = + jsonHandler<PlaygroundExperimentStreamResponse>(clientOptions.jsonMapper) + + override fun stream( + params: PlaygroundExperimentStreamParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<PlaygroundExperimentStreamResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", "playground_experiment", "stream") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { streamHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/RunServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/RunServiceAsync.kt new file mode 100644 index 00000000..d9eabbad --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/RunServiceAsync.kt @@ -0,0 +1,153 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.datasets + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.datasets.runs.RunCreateParams +import com.langsmith_api.api.models.api.v1.datasets.runs.RunCreateResponse +import com.langsmith_api.api.models.api.v1.datasets.runs.RunDeltaParams +import com.langsmith_api.api.models.api.v1.datasets.runs.SessionFeedbackDelta +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface RunServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunServiceAsync + + /** + * Fetch examples for a dataset, and fetch the runs for each example if they are associated with + * the given session_ids. + */ + fun create( + datasetId: String, + params: RunCreateParams, + ): CompletableFuture<Optional<RunCreateResponse>> = + create(datasetId, params, RequestOptions.none()) + + /** @see create */ + fun create( + datasetId: String, + params: RunCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<Optional<RunCreateResponse>> = + create(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see create */ + fun create(params: RunCreateParams): CompletableFuture<Optional<RunCreateResponse>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: RunCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<Optional<RunCreateResponse>> + + /** + * Fetch the number of regressions/improvements for each example in a dataset, between + * sessions[0] and sessions[1]. + */ + fun delta(datasetId: String, params: RunDeltaParams): CompletableFuture<SessionFeedbackDelta> = + delta(datasetId, params, RequestOptions.none()) + + /** @see delta */ + fun delta( + datasetId: String, + params: RunDeltaParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<SessionFeedbackDelta> = + delta(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see delta */ + fun delta(params: RunDeltaParams): CompletableFuture<SessionFeedbackDelta> = + delta(params, RequestOptions.none()) + + /** @see delta */ + fun delta( + params: RunDeltaParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<SessionFeedbackDelta> + + /** A view of [RunServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/datasets/{dataset_id}/runs`, but is + * otherwise the same as [RunServiceAsync.create]. + */ + fun create( + datasetId: String, + params: RunCreateParams, + ): CompletableFuture<HttpResponseFor<Optional<RunCreateResponse>>> = + create(datasetId, params, RequestOptions.none()) + + /** @see create */ + fun create( + datasetId: String, + params: RunCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<Optional<RunCreateResponse>>> = + create(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see create */ + fun create( + params: RunCreateParams + ): CompletableFuture<HttpResponseFor<Optional<RunCreateResponse>>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: RunCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<Optional<RunCreateResponse>>> + + /** + * Returns a raw HTTP response for `post /api/v1/datasets/{dataset_id}/runs/delta`, but is + * otherwise the same as [RunServiceAsync.delta]. + */ + fun delta( + datasetId: String, + params: RunDeltaParams, + ): CompletableFuture<HttpResponseFor<SessionFeedbackDelta>> = + delta(datasetId, params, RequestOptions.none()) + + /** @see delta */ + fun delta( + datasetId: String, + params: RunDeltaParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<SessionFeedbackDelta>> = + delta(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see delta */ + fun delta( + params: RunDeltaParams + ): CompletableFuture<HttpResponseFor<SessionFeedbackDelta>> = + delta(params, RequestOptions.none()) + + /** @see delta */ + fun delta( + params: RunDeltaParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<SessionFeedbackDelta>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/RunServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/RunServiceAsyncImpl.kt new file mode 100644 index 00000000..3b001cd7 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/RunServiceAsyncImpl.kt @@ -0,0 +1,135 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.datasets + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.datasets.runs.RunCreateParams +import com.langsmith_api.api.models.api.v1.datasets.runs.RunCreateResponse +import com.langsmith_api.api.models.api.v1.datasets.runs.RunDeltaParams +import com.langsmith_api.api.models.api.v1.datasets.runs.SessionFeedbackDelta +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class RunServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + RunServiceAsync { + + private val withRawResponse: RunServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): RunServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunServiceAsync = + RunServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: RunCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<Optional<RunCreateResponse>> = + // post /api/v1/datasets/{dataset_id}/runs + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun delta( + params: RunDeltaParams, + requestOptions: RequestOptions, + ): CompletableFuture<SessionFeedbackDelta> = + // post /api/v1/datasets/{dataset_id}/runs/delta + withRawResponse().delta(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RunServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): RunServiceAsync.WithRawResponse = + RunServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<Optional<RunCreateResponse>> = + jsonHandler<Optional<RunCreateResponse>>(clientOptions.jsonMapper) + + override fun create( + params: RunCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<Optional<RunCreateResponse>>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "runs") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.ifPresent { it.validate() } + } + } + } + } + } + + private val deltaHandler: Handler<SessionFeedbackDelta> = + jsonHandler<SessionFeedbackDelta>(clientOptions.jsonMapper) + + override fun delta( + params: RunDeltaParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<SessionFeedbackDelta>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "runs", "delta") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deltaHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/ShareServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/ShareServiceAsync.kt new file mode 100644 index 00000000..cdfd1cb0 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/ShareServiceAsync.kt @@ -0,0 +1,277 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.datasets + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.datasets.share.DatasetShareSchema +import com.langsmith_api.api.models.api.v1.datasets.share.ShareCreateParams +import com.langsmith_api.api.models.api.v1.datasets.share.ShareDeleteAllParams +import com.langsmith_api.api.models.api.v1.datasets.share.ShareDeleteAllResponse +import com.langsmith_api.api.models.api.v1.datasets.share.ShareListParams +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface ShareServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ShareServiceAsync + + /** Share a dataset. */ + fun create(datasetId: String): CompletableFuture<DatasetShareSchema> = + create(datasetId, ShareCreateParams.none()) + + /** @see create */ + fun create( + datasetId: String, + params: ShareCreateParams = ShareCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<DatasetShareSchema> = + create(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see create */ + fun create( + datasetId: String, + params: ShareCreateParams = ShareCreateParams.none(), + ): CompletableFuture<DatasetShareSchema> = create(datasetId, params, RequestOptions.none()) + + /** @see create */ + fun create( + params: ShareCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<DatasetShareSchema> + + /** @see create */ + fun create(params: ShareCreateParams): CompletableFuture<DatasetShareSchema> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + datasetId: String, + requestOptions: RequestOptions, + ): CompletableFuture<DatasetShareSchema> = + create(datasetId, ShareCreateParams.none(), requestOptions) + + /** Get the state of sharing a dataset */ + fun list(datasetId: String): CompletableFuture<Optional<DatasetShareSchema>> = + list(datasetId, ShareListParams.none()) + + /** @see list */ + fun list( + datasetId: String, + params: ShareListParams = ShareListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<Optional<DatasetShareSchema>> = + list(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see list */ + fun list( + datasetId: String, + params: ShareListParams = ShareListParams.none(), + ): CompletableFuture<Optional<DatasetShareSchema>> = + list(datasetId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: ShareListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<Optional<DatasetShareSchema>> + + /** @see list */ + fun list(params: ShareListParams): CompletableFuture<Optional<DatasetShareSchema>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + datasetId: String, + requestOptions: RequestOptions, + ): CompletableFuture<Optional<DatasetShareSchema>> = + list(datasetId, ShareListParams.none(), requestOptions) + + /** Unshare a dataset. */ + fun deleteAll(datasetId: String): CompletableFuture<ShareDeleteAllResponse> = + deleteAll(datasetId, ShareDeleteAllParams.none()) + + /** @see deleteAll */ + fun deleteAll( + datasetId: String, + params: ShareDeleteAllParams = ShareDeleteAllParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ShareDeleteAllResponse> = + deleteAll(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see deleteAll */ + fun deleteAll( + datasetId: String, + params: ShareDeleteAllParams = ShareDeleteAllParams.none(), + ): CompletableFuture<ShareDeleteAllResponse> = + deleteAll(datasetId, params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + params: ShareDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ShareDeleteAllResponse> + + /** @see deleteAll */ + fun deleteAll(params: ShareDeleteAllParams): CompletableFuture<ShareDeleteAllResponse> = + deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + datasetId: String, + requestOptions: RequestOptions, + ): CompletableFuture<ShareDeleteAllResponse> = + deleteAll(datasetId, ShareDeleteAllParams.none(), requestOptions) + + /** A view of [ShareServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ShareServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `put /api/v1/datasets/{dataset_id}/share`, but is + * otherwise the same as [ShareServiceAsync.create]. + */ + fun create(datasetId: String): CompletableFuture<HttpResponseFor<DatasetShareSchema>> = + create(datasetId, ShareCreateParams.none()) + + /** @see create */ + fun create( + datasetId: String, + params: ShareCreateParams = ShareCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<DatasetShareSchema>> = + create(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see create */ + fun create( + datasetId: String, + params: ShareCreateParams = ShareCreateParams.none(), + ): CompletableFuture<HttpResponseFor<DatasetShareSchema>> = + create(datasetId, params, RequestOptions.none()) + + /** @see create */ + fun create( + params: ShareCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<DatasetShareSchema>> + + /** @see create */ + fun create( + params: ShareCreateParams + ): CompletableFuture<HttpResponseFor<DatasetShareSchema>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + datasetId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<DatasetShareSchema>> = + create(datasetId, ShareCreateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/datasets/{dataset_id}/share`, but is + * otherwise the same as [ShareServiceAsync.list]. + */ + fun list( + datasetId: String + ): CompletableFuture<HttpResponseFor<Optional<DatasetShareSchema>>> = + list(datasetId, ShareListParams.none()) + + /** @see list */ + fun list( + datasetId: String, + params: ShareListParams = ShareListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<Optional<DatasetShareSchema>>> = + list(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see list */ + fun list( + datasetId: String, + params: ShareListParams = ShareListParams.none(), + ): CompletableFuture<HttpResponseFor<Optional<DatasetShareSchema>>> = + list(datasetId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: ShareListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<Optional<DatasetShareSchema>>> + + /** @see list */ + fun list( + params: ShareListParams + ): CompletableFuture<HttpResponseFor<Optional<DatasetShareSchema>>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + datasetId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<Optional<DatasetShareSchema>>> = + list(datasetId, ShareListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/datasets/{dataset_id}/share`, but is + * otherwise the same as [ShareServiceAsync.deleteAll]. + */ + fun deleteAll( + datasetId: String + ): CompletableFuture<HttpResponseFor<ShareDeleteAllResponse>> = + deleteAll(datasetId, ShareDeleteAllParams.none()) + + /** @see deleteAll */ + fun deleteAll( + datasetId: String, + params: ShareDeleteAllParams = ShareDeleteAllParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ShareDeleteAllResponse>> = + deleteAll(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see deleteAll */ + fun deleteAll( + datasetId: String, + params: ShareDeleteAllParams = ShareDeleteAllParams.none(), + ): CompletableFuture<HttpResponseFor<ShareDeleteAllResponse>> = + deleteAll(datasetId, params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + params: ShareDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ShareDeleteAllResponse>> + + /** @see deleteAll */ + fun deleteAll( + params: ShareDeleteAllParams + ): CompletableFuture<HttpResponseFor<ShareDeleteAllResponse>> = + deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + datasetId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ShareDeleteAllResponse>> = + deleteAll(datasetId, ShareDeleteAllParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/ShareServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/ShareServiceAsyncImpl.kt new file mode 100644 index 00000000..dd8a3de9 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/ShareServiceAsyncImpl.kt @@ -0,0 +1,176 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.datasets + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.datasets.share.DatasetShareSchema +import com.langsmith_api.api.models.api.v1.datasets.share.ShareCreateParams +import com.langsmith_api.api.models.api.v1.datasets.share.ShareDeleteAllParams +import com.langsmith_api.api.models.api.v1.datasets.share.ShareDeleteAllResponse +import com.langsmith_api.api.models.api.v1.datasets.share.ShareListParams +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ShareServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ShareServiceAsync { + + private val withRawResponse: ShareServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ShareServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): ShareServiceAsync = + ShareServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: ShareCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<DatasetShareSchema> = + // put /api/v1/datasets/{dataset_id}/share + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: ShareListParams, + requestOptions: RequestOptions, + ): CompletableFuture<Optional<DatasetShareSchema>> = + // get /api/v1/datasets/{dataset_id}/share + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun deleteAll( + params: ShareDeleteAllParams, + requestOptions: RequestOptions, + ): CompletableFuture<ShareDeleteAllResponse> = + // delete /api/v1/datasets/{dataset_id}/share + withRawResponse().deleteAll(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ShareServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ShareServiceAsync.WithRawResponse = + ShareServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<DatasetShareSchema> = + jsonHandler<DatasetShareSchema>(clientOptions.jsonMapper) + + override fun create( + params: ShareCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<DatasetShareSchema>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "share") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler<Optional<DatasetShareSchema>> = + jsonHandler<Optional<DatasetShareSchema>>(clientOptions.jsonMapper) + + override fun list( + params: ShareListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<Optional<DatasetShareSchema>>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "share") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.ifPresent { it.validate() } + } + } + } + } + } + + private val deleteAllHandler: Handler<ShareDeleteAllResponse> = + jsonHandler<ShareDeleteAllResponse>(clientOptions.jsonMapper) + + override fun deleteAll( + params: ShareDeleteAllParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ShareDeleteAllResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "share") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteAllHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/SplitServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/SplitServiceAsync.kt new file mode 100644 index 00000000..9016a7eb --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/SplitServiceAsync.kt @@ -0,0 +1,160 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.datasets + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.datasets.splits.SplitCreateParams +import com.langsmith_api.api.models.api.v1.datasets.splits.SplitListParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface SplitServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): SplitServiceAsync + + /** Update Dataset Splits */ + fun create(datasetId: String, params: SplitCreateParams): CompletableFuture<List<String>> = + create(datasetId, params, RequestOptions.none()) + + /** @see create */ + fun create( + datasetId: String, + params: SplitCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<String>> = + create(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see create */ + fun create(params: SplitCreateParams): CompletableFuture<List<String>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: SplitCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<String>> + + /** Get Dataset Splits */ + fun list(datasetId: String): CompletableFuture<List<String>> = + list(datasetId, SplitListParams.none()) + + /** @see list */ + fun list( + datasetId: String, + params: SplitListParams = SplitListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<String>> = + list(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see list */ + fun list( + datasetId: String, + params: SplitListParams = SplitListParams.none(), + ): CompletableFuture<List<String>> = list(datasetId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: SplitListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<String>> + + /** @see list */ + fun list(params: SplitListParams): CompletableFuture<List<String>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(datasetId: String, requestOptions: RequestOptions): CompletableFuture<List<String>> = + list(datasetId, SplitListParams.none(), requestOptions) + + /** A view of [SplitServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): SplitServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `put /api/v1/datasets/{dataset_id}/splits`, but is + * otherwise the same as [SplitServiceAsync.create]. + */ + fun create( + datasetId: String, + params: SplitCreateParams, + ): CompletableFuture<HttpResponseFor<List<String>>> = + create(datasetId, params, RequestOptions.none()) + + /** @see create */ + fun create( + datasetId: String, + params: SplitCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<String>>> = + create(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see create */ + fun create(params: SplitCreateParams): CompletableFuture<HttpResponseFor<List<String>>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: SplitCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<String>>> + + /** + * Returns a raw HTTP response for `get /api/v1/datasets/{dataset_id}/splits`, but is + * otherwise the same as [SplitServiceAsync.list]. + */ + fun list(datasetId: String): CompletableFuture<HttpResponseFor<List<String>>> = + list(datasetId, SplitListParams.none()) + + /** @see list */ + fun list( + datasetId: String, + params: SplitListParams = SplitListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<String>>> = + list(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see list */ + fun list( + datasetId: String, + params: SplitListParams = SplitListParams.none(), + ): CompletableFuture<HttpResponseFor<List<String>>> = + list(datasetId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: SplitListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<String>>> + + /** @see list */ + fun list(params: SplitListParams): CompletableFuture<HttpResponseFor<List<String>>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + datasetId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<String>>> = + list(datasetId, SplitListParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/SplitServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/SplitServiceAsyncImpl.kt new file mode 100644 index 00000000..f26262c4 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/SplitServiceAsyncImpl.kt @@ -0,0 +1,119 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.datasets + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.datasets.splits.SplitCreateParams +import com.langsmith_api.api.models.api.v1.datasets.splits.SplitListParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class SplitServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + SplitServiceAsync { + + private val withRawResponse: SplitServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): SplitServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): SplitServiceAsync = + SplitServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: SplitCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<String>> = + // put /api/v1/datasets/{dataset_id}/splits + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: SplitListParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<String>> = + // get /api/v1/datasets/{dataset_id}/splits + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SplitServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): SplitServiceAsync.WithRawResponse = + SplitServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<List<String>> = + jsonHandler<List<String>>(clientOptions.jsonMapper) + + override fun create( + params: SplitCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<String>>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "splits") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { createHandler.handle(it) } + } + } + } + + private val listHandler: Handler<List<String>> = + jsonHandler<List<String>>(clientOptions.jsonMapper) + + override fun list( + params: SplitListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<String>>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "splits") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { listHandler.handle(it) } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/VersionServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/VersionServiceAsync.kt new file mode 100644 index 00000000..8d03ecf7 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/VersionServiceAsync.kt @@ -0,0 +1,175 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.datasets + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.datasets.DatasetVersion +import com.langsmith_api.api.models.api.v1.datasets.versions.VersionListParams +import com.langsmith_api.api.models.api.v1.datasets.versions.VersionRetrieveDiffParams +import com.langsmith_api.api.models.api.v1.datasets.versions.VersionRetrieveDiffResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface VersionServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): VersionServiceAsync + + /** Get dataset versions. */ + fun list(datasetId: String): CompletableFuture<List<DatasetVersion>> = + list(datasetId, VersionListParams.none()) + + /** @see list */ + fun list( + datasetId: String, + params: VersionListParams = VersionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<DatasetVersion>> = + list(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see list */ + fun list( + datasetId: String, + params: VersionListParams = VersionListParams.none(), + ): CompletableFuture<List<DatasetVersion>> = list(datasetId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: VersionListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<DatasetVersion>> + + /** @see list */ + fun list(params: VersionListParams): CompletableFuture<List<DatasetVersion>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + datasetId: String, + requestOptions: RequestOptions, + ): CompletableFuture<List<DatasetVersion>> = + list(datasetId, VersionListParams.none(), requestOptions) + + /** Get diff between two dataset versions. */ + fun retrieveDiff( + datasetId: String, + params: VersionRetrieveDiffParams, + ): CompletableFuture<VersionRetrieveDiffResponse> = + retrieveDiff(datasetId, params, RequestOptions.none()) + + /** @see retrieveDiff */ + fun retrieveDiff( + datasetId: String, + params: VersionRetrieveDiffParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<VersionRetrieveDiffResponse> = + retrieveDiff(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see retrieveDiff */ + fun retrieveDiff( + params: VersionRetrieveDiffParams + ): CompletableFuture<VersionRetrieveDiffResponse> = retrieveDiff(params, RequestOptions.none()) + + /** @see retrieveDiff */ + fun retrieveDiff( + params: VersionRetrieveDiffParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<VersionRetrieveDiffResponse> + + /** + * A view of [VersionServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): VersionServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/datasets/{dataset_id}/versions`, but is + * otherwise the same as [VersionServiceAsync.list]. + */ + fun list(datasetId: String): CompletableFuture<HttpResponseFor<List<DatasetVersion>>> = + list(datasetId, VersionListParams.none()) + + /** @see list */ + fun list( + datasetId: String, + params: VersionListParams = VersionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<DatasetVersion>>> = + list(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see list */ + fun list( + datasetId: String, + params: VersionListParams = VersionListParams.none(), + ): CompletableFuture<HttpResponseFor<List<DatasetVersion>>> = + list(datasetId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: VersionListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<DatasetVersion>>> + + /** @see list */ + fun list( + params: VersionListParams + ): CompletableFuture<HttpResponseFor<List<DatasetVersion>>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + datasetId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<DatasetVersion>>> = + list(datasetId, VersionListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/datasets/{dataset_id}/versions/diff`, but is + * otherwise the same as [VersionServiceAsync.retrieveDiff]. + */ + fun retrieveDiff( + datasetId: String, + params: VersionRetrieveDiffParams, + ): CompletableFuture<HttpResponseFor<VersionRetrieveDiffResponse>> = + retrieveDiff(datasetId, params, RequestOptions.none()) + + /** @see retrieveDiff */ + fun retrieveDiff( + datasetId: String, + params: VersionRetrieveDiffParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<VersionRetrieveDiffResponse>> = + retrieveDiff(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see retrieveDiff */ + fun retrieveDiff( + params: VersionRetrieveDiffParams + ): CompletableFuture<HttpResponseFor<VersionRetrieveDiffResponse>> = + retrieveDiff(params, RequestOptions.none()) + + /** @see retrieveDiff */ + fun retrieveDiff( + params: VersionRetrieveDiffParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<VersionRetrieveDiffResponse>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/VersionServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/VersionServiceAsyncImpl.kt new file mode 100644 index 00000000..465d351d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/VersionServiceAsyncImpl.kt @@ -0,0 +1,138 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.datasets + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.datasets.DatasetVersion +import com.langsmith_api.api.models.api.v1.datasets.versions.VersionListParams +import com.langsmith_api.api.models.api.v1.datasets.versions.VersionRetrieveDiffParams +import com.langsmith_api.api.models.api.v1.datasets.versions.VersionRetrieveDiffResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class VersionServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + VersionServiceAsync { + + private val withRawResponse: VersionServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): VersionServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): VersionServiceAsync = + VersionServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: VersionListParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<DatasetVersion>> = + // get /api/v1/datasets/{dataset_id}/versions + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun retrieveDiff( + params: VersionRetrieveDiffParams, + requestOptions: RequestOptions, + ): CompletableFuture<VersionRetrieveDiffResponse> = + // get /api/v1/datasets/{dataset_id}/versions/diff + withRawResponse().retrieveDiff(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + VersionServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): VersionServiceAsync.WithRawResponse = + VersionServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler<List<DatasetVersion>> = + jsonHandler<List<DatasetVersion>>(clientOptions.jsonMapper) + + override fun list( + params: VersionListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<DatasetVersion>>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "versions") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val retrieveDiffHandler: Handler<VersionRetrieveDiffResponse> = + jsonHandler<VersionRetrieveDiffResponse>(clientOptions.jsonMapper) + + override fun retrieveDiff( + params: VersionRetrieveDiffParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<VersionRetrieveDiffResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "datasets", + params._pathParam(0), + "versions", + "diff", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveDiffHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/examples/BulkServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/examples/BulkServiceAsync.kt new file mode 100644 index 00000000..f5775830 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/examples/BulkServiceAsync.kt @@ -0,0 +1,110 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.examples + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.examples.bulk.BulkCreateParams +import com.langsmith_api.api.models.api.v1.examples.bulk.BulkCreateResponse +import com.langsmith_api.api.models.api.v1.examples.bulk.BulkPatchAllParams +import com.langsmith_api.api.models.api.v1.examples.bulk.BulkPatchAllResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface BulkServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): BulkServiceAsync + + /** Create a new example. */ + fun create(): CompletableFuture<BulkCreateResponse> = create(BulkCreateParams.none()) + + /** @see create */ + fun create( + params: BulkCreateParams = BulkCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<BulkCreateResponse> + + /** @see create */ + fun create( + params: BulkCreateParams = BulkCreateParams.none() + ): CompletableFuture<BulkCreateResponse> = create(params, RequestOptions.none()) + + /** @see create */ + fun create(requestOptions: RequestOptions): CompletableFuture<BulkCreateResponse> = + create(BulkCreateParams.none(), requestOptions) + + /** + * Legacy update examples in bulk. For update involving attachments, use PATCH + * /v1/platform/datasets/{dataset_id}/examples instead. + */ + fun patchAll(params: BulkPatchAllParams): CompletableFuture<BulkPatchAllResponse> = + patchAll(params, RequestOptions.none()) + + /** @see patchAll */ + fun patchAll( + params: BulkPatchAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<BulkPatchAllResponse> + + /** A view of [BulkServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): BulkServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/examples/bulk`, but is otherwise the same + * as [BulkServiceAsync.create]. + */ + fun create(): CompletableFuture<HttpResponseFor<BulkCreateResponse>> = + create(BulkCreateParams.none()) + + /** @see create */ + fun create( + params: BulkCreateParams = BulkCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<BulkCreateResponse>> + + /** @see create */ + fun create( + params: BulkCreateParams = BulkCreateParams.none() + ): CompletableFuture<HttpResponseFor<BulkCreateResponse>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<BulkCreateResponse>> = + create(BulkCreateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `patch /api/v1/examples/bulk`, but is otherwise the same + * as [BulkServiceAsync.patchAll]. + */ + fun patchAll( + params: BulkPatchAllParams + ): CompletableFuture<HttpResponseFor<BulkPatchAllResponse>> = + patchAll(params, RequestOptions.none()) + + /** @see patchAll */ + fun patchAll( + params: BulkPatchAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<BulkPatchAllResponse>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/examples/BulkServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/examples/BulkServiceAsyncImpl.kt new file mode 100644 index 00000000..4a80e9a1 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/examples/BulkServiceAsyncImpl.kt @@ -0,0 +1,126 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.examples + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.examples.bulk.BulkCreateParams +import com.langsmith_api.api.models.api.v1.examples.bulk.BulkCreateResponse +import com.langsmith_api.api.models.api.v1.examples.bulk.BulkPatchAllParams +import com.langsmith_api.api.models.api.v1.examples.bulk.BulkPatchAllResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class BulkServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + BulkServiceAsync { + + private val withRawResponse: BulkServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): BulkServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): BulkServiceAsync = + BulkServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: BulkCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<BulkCreateResponse> = + // post /api/v1/examples/bulk + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun patchAll( + params: BulkPatchAllParams, + requestOptions: RequestOptions, + ): CompletableFuture<BulkPatchAllResponse> = + // patch /api/v1/examples/bulk + withRawResponse().patchAll(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BulkServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): BulkServiceAsync.WithRawResponse = + BulkServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<BulkCreateResponse> = + jsonHandler<BulkCreateResponse>(clientOptions.jsonMapper) + + override fun create( + params: BulkCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<BulkCreateResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "examples", "bulk") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val patchAllHandler: Handler<BulkPatchAllResponse> = + jsonHandler<BulkPatchAllResponse>(clientOptions.jsonMapper) + + override fun patchAll( + params: BulkPatchAllParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<BulkPatchAllResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "examples", "bulk") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { patchAllHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/examples/ValidateServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/examples/ValidateServiceAsync.kt new file mode 100644 index 00000000..aeb99713 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/examples/ValidateServiceAsync.kt @@ -0,0 +1,128 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.examples + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.examples.validate.ExampleValidationResult +import com.langsmith_api.api.models.api.v1.examples.validate.ValidateBulkParams +import com.langsmith_api.api.models.api.v1.examples.validate.ValidateCreateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface ValidateServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ValidateServiceAsync + + /** Validate an example. */ + fun create(): CompletableFuture<ExampleValidationResult> = create(ValidateCreateParams.none()) + + /** @see create */ + fun create( + params: ValidateCreateParams = ValidateCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ExampleValidationResult> + + /** @see create */ + fun create( + params: ValidateCreateParams = ValidateCreateParams.none() + ): CompletableFuture<ExampleValidationResult> = create(params, RequestOptions.none()) + + /** @see create */ + fun create(requestOptions: RequestOptions): CompletableFuture<ExampleValidationResult> = + create(ValidateCreateParams.none(), requestOptions) + + /** Validate an example. */ + fun bulk(): CompletableFuture<List<ExampleValidationResult>> = bulk(ValidateBulkParams.none()) + + /** @see bulk */ + fun bulk( + params: ValidateBulkParams = ValidateBulkParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<ExampleValidationResult>> + + /** @see bulk */ + fun bulk( + params: ValidateBulkParams = ValidateBulkParams.none() + ): CompletableFuture<List<ExampleValidationResult>> = bulk(params, RequestOptions.none()) + + /** @see bulk */ + fun bulk(requestOptions: RequestOptions): CompletableFuture<List<ExampleValidationResult>> = + bulk(ValidateBulkParams.none(), requestOptions) + + /** + * A view of [ValidateServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ValidateServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/examples/validate`, but is otherwise the + * same as [ValidateServiceAsync.create]. + */ + fun create(): CompletableFuture<HttpResponseFor<ExampleValidationResult>> = + create(ValidateCreateParams.none()) + + /** @see create */ + fun create( + params: ValidateCreateParams = ValidateCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ExampleValidationResult>> + + /** @see create */ + fun create( + params: ValidateCreateParams = ValidateCreateParams.none() + ): CompletableFuture<HttpResponseFor<ExampleValidationResult>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<ExampleValidationResult>> = + create(ValidateCreateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/examples/validate/bulk`, but is otherwise + * the same as [ValidateServiceAsync.bulk]. + */ + fun bulk(): CompletableFuture<HttpResponseFor<List<ExampleValidationResult>>> = + bulk(ValidateBulkParams.none()) + + /** @see bulk */ + fun bulk( + params: ValidateBulkParams = ValidateBulkParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<ExampleValidationResult>>> + + /** @see bulk */ + fun bulk( + params: ValidateBulkParams = ValidateBulkParams.none() + ): CompletableFuture<HttpResponseFor<List<ExampleValidationResult>>> = + bulk(params, RequestOptions.none()) + + /** @see bulk */ + fun bulk( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<ExampleValidationResult>>> = + bulk(ValidateBulkParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/examples/ValidateServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/examples/ValidateServiceAsyncImpl.kt new file mode 100644 index 00000000..52b40553 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/examples/ValidateServiceAsyncImpl.kt @@ -0,0 +1,125 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.examples + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.examples.validate.ExampleValidationResult +import com.langsmith_api.api.models.api.v1.examples.validate.ValidateBulkParams +import com.langsmith_api.api.models.api.v1.examples.validate.ValidateCreateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class ValidateServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ValidateServiceAsync { + + private val withRawResponse: ValidateServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ValidateServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): ValidateServiceAsync = + ValidateServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: ValidateCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<ExampleValidationResult> = + // post /api/v1/examples/validate + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun bulk( + params: ValidateBulkParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<ExampleValidationResult>> = + // post /api/v1/examples/validate/bulk + withRawResponse().bulk(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ValidateServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ValidateServiceAsync.WithRawResponse = + ValidateServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<ExampleValidationResult> = + jsonHandler<ExampleValidationResult>(clientOptions.jsonMapper) + + override fun create( + params: ValidateCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ExampleValidationResult>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "examples", "validate") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val bulkHandler: Handler<List<ExampleValidationResult>> = + jsonHandler<List<ExampleValidationResult>>(clientOptions.jsonMapper) + + override fun bulk( + params: ValidateBulkParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<ExampleValidationResult>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "examples", "validate", "bulk") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { bulkHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/feedback/FormulaServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/feedback/FormulaServiceAsync.kt new file mode 100644 index 00000000..89016f20 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/feedback/FormulaServiceAsync.kt @@ -0,0 +1,329 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.feedback + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.feedback.formulas.FeedbackFormula +import com.langsmith_api.api.models.api.v1.feedback.formulas.FormulaCreateParams +import com.langsmith_api.api.models.api.v1.feedback.formulas.FormulaDeleteParams +import com.langsmith_api.api.models.api.v1.feedback.formulas.FormulaDeleteResponse +import com.langsmith_api.api.models.api.v1.feedback.formulas.FormulaListParams +import com.langsmith_api.api.models.api.v1.feedback.formulas.FormulaRetrieveParams +import com.langsmith_api.api.models.api.v1.feedback.formulas.FormulaUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface FormulaServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): FormulaServiceAsync + + /** Create Feedback Formula Ep */ + fun create(params: FormulaCreateParams): CompletableFuture<FeedbackFormula> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: FormulaCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<FeedbackFormula> + + /** Get Feedback Formula Ep */ + fun retrieve(feedbackFormulaId: String): CompletableFuture<FeedbackFormula> = + retrieve(feedbackFormulaId, FormulaRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + feedbackFormulaId: String, + params: FormulaRetrieveParams = FormulaRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<FeedbackFormula> = + retrieve(params.toBuilder().feedbackFormulaId(feedbackFormulaId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + feedbackFormulaId: String, + params: FormulaRetrieveParams = FormulaRetrieveParams.none(), + ): CompletableFuture<FeedbackFormula> = + retrieve(feedbackFormulaId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: FormulaRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<FeedbackFormula> + + /** @see retrieve */ + fun retrieve(params: FormulaRetrieveParams): CompletableFuture<FeedbackFormula> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + feedbackFormulaId: String, + requestOptions: RequestOptions, + ): CompletableFuture<FeedbackFormula> = + retrieve(feedbackFormulaId, FormulaRetrieveParams.none(), requestOptions) + + /** Update Feedback Formula Ep */ + fun update( + feedbackFormulaId: String, + params: FormulaUpdateParams, + ): CompletableFuture<FeedbackFormula> = update(feedbackFormulaId, params, RequestOptions.none()) + + /** @see update */ + fun update( + feedbackFormulaId: String, + params: FormulaUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<FeedbackFormula> = + update(params.toBuilder().feedbackFormulaId(feedbackFormulaId).build(), requestOptions) + + /** @see update */ + fun update(params: FormulaUpdateParams): CompletableFuture<FeedbackFormula> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: FormulaUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<FeedbackFormula> + + /** List Feedback Formula Ep */ + fun list(): CompletableFuture<List<FeedbackFormula>> = list(FormulaListParams.none()) + + /** @see list */ + fun list( + params: FormulaListParams = FormulaListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<FeedbackFormula>> + + /** @see list */ + fun list( + params: FormulaListParams = FormulaListParams.none() + ): CompletableFuture<List<FeedbackFormula>> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture<List<FeedbackFormula>> = + list(FormulaListParams.none(), requestOptions) + + /** Delete Feedback Formula Endpoint */ + fun delete(feedbackFormulaId: String): CompletableFuture<FormulaDeleteResponse> = + delete(feedbackFormulaId, FormulaDeleteParams.none()) + + /** @see delete */ + fun delete( + feedbackFormulaId: String, + params: FormulaDeleteParams = FormulaDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<FormulaDeleteResponse> = + delete(params.toBuilder().feedbackFormulaId(feedbackFormulaId).build(), requestOptions) + + /** @see delete */ + fun delete( + feedbackFormulaId: String, + params: FormulaDeleteParams = FormulaDeleteParams.none(), + ): CompletableFuture<FormulaDeleteResponse> = + delete(feedbackFormulaId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: FormulaDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<FormulaDeleteResponse> + + /** @see delete */ + fun delete(params: FormulaDeleteParams): CompletableFuture<FormulaDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + feedbackFormulaId: String, + requestOptions: RequestOptions, + ): CompletableFuture<FormulaDeleteResponse> = + delete(feedbackFormulaId, FormulaDeleteParams.none(), requestOptions) + + /** + * A view of [FormulaServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): FormulaServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/feedback/formulas`, but is otherwise the + * same as [FormulaServiceAsync.create]. + */ + fun create( + params: FormulaCreateParams + ): CompletableFuture<HttpResponseFor<FeedbackFormula>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: FormulaCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<FeedbackFormula>> + + /** + * Returns a raw HTTP response for `get /api/v1/feedback/formulas/{feedback_formula_id}`, + * but is otherwise the same as [FormulaServiceAsync.retrieve]. + */ + fun retrieve( + feedbackFormulaId: String + ): CompletableFuture<HttpResponseFor<FeedbackFormula>> = + retrieve(feedbackFormulaId, FormulaRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + feedbackFormulaId: String, + params: FormulaRetrieveParams = FormulaRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<FeedbackFormula>> = + retrieve( + params.toBuilder().feedbackFormulaId(feedbackFormulaId).build(), + requestOptions, + ) + + /** @see retrieve */ + fun retrieve( + feedbackFormulaId: String, + params: FormulaRetrieveParams = FormulaRetrieveParams.none(), + ): CompletableFuture<HttpResponseFor<FeedbackFormula>> = + retrieve(feedbackFormulaId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: FormulaRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<FeedbackFormula>> + + /** @see retrieve */ + fun retrieve( + params: FormulaRetrieveParams + ): CompletableFuture<HttpResponseFor<FeedbackFormula>> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + feedbackFormulaId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<FeedbackFormula>> = + retrieve(feedbackFormulaId, FormulaRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `put /api/v1/feedback/formulas/{feedback_formula_id}`, + * but is otherwise the same as [FormulaServiceAsync.update]. + */ + fun update( + feedbackFormulaId: String, + params: FormulaUpdateParams, + ): CompletableFuture<HttpResponseFor<FeedbackFormula>> = + update(feedbackFormulaId, params, RequestOptions.none()) + + /** @see update */ + fun update( + feedbackFormulaId: String, + params: FormulaUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<FeedbackFormula>> = + update(params.toBuilder().feedbackFormulaId(feedbackFormulaId).build(), requestOptions) + + /** @see update */ + fun update( + params: FormulaUpdateParams + ): CompletableFuture<HttpResponseFor<FeedbackFormula>> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: FormulaUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<FeedbackFormula>> + + /** + * Returns a raw HTTP response for `get /api/v1/feedback/formulas`, but is otherwise the + * same as [FormulaServiceAsync.list]. + */ + fun list(): CompletableFuture<HttpResponseFor<List<FeedbackFormula>>> = + list(FormulaListParams.none()) + + /** @see list */ + fun list( + params: FormulaListParams = FormulaListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<FeedbackFormula>>> + + /** @see list */ + fun list( + params: FormulaListParams = FormulaListParams.none() + ): CompletableFuture<HttpResponseFor<List<FeedbackFormula>>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<FeedbackFormula>>> = + list(FormulaListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/feedback/formulas/{feedback_formula_id}`, + * but is otherwise the same as [FormulaServiceAsync.delete]. + */ + fun delete( + feedbackFormulaId: String + ): CompletableFuture<HttpResponseFor<FormulaDeleteResponse>> = + delete(feedbackFormulaId, FormulaDeleteParams.none()) + + /** @see delete */ + fun delete( + feedbackFormulaId: String, + params: FormulaDeleteParams = FormulaDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<FormulaDeleteResponse>> = + delete(params.toBuilder().feedbackFormulaId(feedbackFormulaId).build(), requestOptions) + + /** @see delete */ + fun delete( + feedbackFormulaId: String, + params: FormulaDeleteParams = FormulaDeleteParams.none(), + ): CompletableFuture<HttpResponseFor<FormulaDeleteResponse>> = + delete(feedbackFormulaId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: FormulaDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<FormulaDeleteResponse>> + + /** @see delete */ + fun delete( + params: FormulaDeleteParams + ): CompletableFuture<HttpResponseFor<FormulaDeleteResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + feedbackFormulaId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<FormulaDeleteResponse>> = + delete(feedbackFormulaId, FormulaDeleteParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/feedback/FormulaServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/feedback/FormulaServiceAsyncImpl.kt new file mode 100644 index 00000000..d347e1e5 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/feedback/FormulaServiceAsyncImpl.kt @@ -0,0 +1,252 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.feedback + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.feedback.formulas.FeedbackFormula +import com.langsmith_api.api.models.api.v1.feedback.formulas.FormulaCreateParams +import com.langsmith_api.api.models.api.v1.feedback.formulas.FormulaDeleteParams +import com.langsmith_api.api.models.api.v1.feedback.formulas.FormulaDeleteResponse +import com.langsmith_api.api.models.api.v1.feedback.formulas.FormulaListParams +import com.langsmith_api.api.models.api.v1.feedback.formulas.FormulaRetrieveParams +import com.langsmith_api.api.models.api.v1.feedback.formulas.FormulaUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class FormulaServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + FormulaServiceAsync { + + private val withRawResponse: FormulaServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): FormulaServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): FormulaServiceAsync = + FormulaServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: FormulaCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<FeedbackFormula> = + // post /api/v1/feedback/formulas + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun retrieve( + params: FormulaRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<FeedbackFormula> = + // get /api/v1/feedback/formulas/{feedback_formula_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: FormulaUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<FeedbackFormula> = + // put /api/v1/feedback/formulas/{feedback_formula_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: FormulaListParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<FeedbackFormula>> = + // get /api/v1/feedback/formulas + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: FormulaDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<FormulaDeleteResponse> = + // delete /api/v1/feedback/formulas/{feedback_formula_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + FormulaServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): FormulaServiceAsync.WithRawResponse = + FormulaServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<FeedbackFormula> = + jsonHandler<FeedbackFormula>(clientOptions.jsonMapper) + + override fun create( + params: FormulaCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<FeedbackFormula>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "feedback", "formulas") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler<FeedbackFormula> = + jsonHandler<FeedbackFormula>(clientOptions.jsonMapper) + + override fun retrieve( + params: FormulaRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<FeedbackFormula>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("feedbackFormulaId", params.feedbackFormulaId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "feedback", "formulas", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler<FeedbackFormula> = + jsonHandler<FeedbackFormula>(clientOptions.jsonMapper) + + override fun update( + params: FormulaUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<FeedbackFormula>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("feedbackFormulaId", params.feedbackFormulaId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "feedback", "formulas", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler<List<FeedbackFormula>> = + jsonHandler<List<FeedbackFormula>>(clientOptions.jsonMapper) + + override fun list( + params: FormulaListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<FeedbackFormula>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "feedback", "formulas") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val deleteHandler: Handler<FormulaDeleteResponse> = + jsonHandler<FormulaDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: FormulaDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<FormulaDeleteResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("feedbackFormulaId", params.feedbackFormulaId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "feedback", "formulas", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/feedback/TokenServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/feedback/TokenServiceAsync.kt new file mode 100644 index 00000000..8cf82b55 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/feedback/TokenServiceAsync.kt @@ -0,0 +1,247 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.feedback + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.feedback.tokens.FeedbackIngestTokenSchema +import com.langsmith_api.api.models.api.v1.feedback.tokens.TokenCreateParams +import com.langsmith_api.api.models.api.v1.feedback.tokens.TokenCreateResponse +import com.langsmith_api.api.models.api.v1.feedback.tokens.TokenListParams +import com.langsmith_api.api.models.api.v1.feedback.tokens.TokenRetrieveParams +import com.langsmith_api.api.models.api.v1.feedback.tokens.TokenRetrieveResponse +import com.langsmith_api.api.models.api.v1.feedback.tokens.TokenUpdateParams +import com.langsmith_api.api.models.api.v1.feedback.tokens.TokenUpdateResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface TokenServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): TokenServiceAsync + + /** Create a new feedback ingest token. */ + fun create(params: TokenCreateParams): CompletableFuture<TokenCreateResponse> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: TokenCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<TokenCreateResponse> + + /** Create a new feedback with a token. */ + fun retrieve(token: String): CompletableFuture<TokenRetrieveResponse> = + retrieve(token, TokenRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + token: String, + params: TokenRetrieveParams = TokenRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<TokenRetrieveResponse> = + retrieve(params.toBuilder().token(token).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + token: String, + params: TokenRetrieveParams = TokenRetrieveParams.none(), + ): CompletableFuture<TokenRetrieveResponse> = retrieve(token, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: TokenRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<TokenRetrieveResponse> + + /** @see retrieve */ + fun retrieve(params: TokenRetrieveParams): CompletableFuture<TokenRetrieveResponse> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + token: String, + requestOptions: RequestOptions, + ): CompletableFuture<TokenRetrieveResponse> = + retrieve(token, TokenRetrieveParams.none(), requestOptions) + + /** Create a new feedback with a token. */ + fun update(token: String): CompletableFuture<TokenUpdateResponse> = + update(token, TokenUpdateParams.none()) + + /** @see update */ + fun update( + token: String, + params: TokenUpdateParams = TokenUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<TokenUpdateResponse> = + update(params.toBuilder().token(token).build(), requestOptions) + + /** @see update */ + fun update( + token: String, + params: TokenUpdateParams = TokenUpdateParams.none(), + ): CompletableFuture<TokenUpdateResponse> = update(token, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: TokenUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<TokenUpdateResponse> + + /** @see update */ + fun update(params: TokenUpdateParams): CompletableFuture<TokenUpdateResponse> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + token: String, + requestOptions: RequestOptions, + ): CompletableFuture<TokenUpdateResponse> = + update(token, TokenUpdateParams.none(), requestOptions) + + /** List all feedback ingest tokens for a run. */ + fun list(params: TokenListParams): CompletableFuture<List<FeedbackIngestTokenSchema>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: TokenListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<FeedbackIngestTokenSchema>> + + /** A view of [TokenServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): TokenServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/feedback/tokens`, but is otherwise the same + * as [TokenServiceAsync.create]. + */ + fun create( + params: TokenCreateParams + ): CompletableFuture<HttpResponseFor<TokenCreateResponse>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: TokenCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<TokenCreateResponse>> + + /** + * Returns a raw HTTP response for `get /api/v1/feedback/tokens/{token}`, but is otherwise + * the same as [TokenServiceAsync.retrieve]. + */ + fun retrieve(token: String): CompletableFuture<HttpResponseFor<TokenRetrieveResponse>> = + retrieve(token, TokenRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + token: String, + params: TokenRetrieveParams = TokenRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<TokenRetrieveResponse>> = + retrieve(params.toBuilder().token(token).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + token: String, + params: TokenRetrieveParams = TokenRetrieveParams.none(), + ): CompletableFuture<HttpResponseFor<TokenRetrieveResponse>> = + retrieve(token, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: TokenRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<TokenRetrieveResponse>> + + /** @see retrieve */ + fun retrieve( + params: TokenRetrieveParams + ): CompletableFuture<HttpResponseFor<TokenRetrieveResponse>> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + token: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<TokenRetrieveResponse>> = + retrieve(token, TokenRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/feedback/tokens/{token}`, but is otherwise + * the same as [TokenServiceAsync.update]. + */ + fun update(token: String): CompletableFuture<HttpResponseFor<TokenUpdateResponse>> = + update(token, TokenUpdateParams.none()) + + /** @see update */ + fun update( + token: String, + params: TokenUpdateParams = TokenUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<TokenUpdateResponse>> = + update(params.toBuilder().token(token).build(), requestOptions) + + /** @see update */ + fun update( + token: String, + params: TokenUpdateParams = TokenUpdateParams.none(), + ): CompletableFuture<HttpResponseFor<TokenUpdateResponse>> = + update(token, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: TokenUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<TokenUpdateResponse>> + + /** @see update */ + fun update( + params: TokenUpdateParams + ): CompletableFuture<HttpResponseFor<TokenUpdateResponse>> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + token: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<TokenUpdateResponse>> = + update(token, TokenUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/feedback/tokens`, but is otherwise the same + * as [TokenServiceAsync.list]. + */ + fun list( + params: TokenListParams + ): CompletableFuture<HttpResponseFor<List<FeedbackIngestTokenSchema>>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: TokenListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<FeedbackIngestTokenSchema>>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/feedback/TokenServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/feedback/TokenServiceAsyncImpl.kt new file mode 100644 index 00000000..cc98fbb8 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/feedback/TokenServiceAsyncImpl.kt @@ -0,0 +1,212 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.feedback + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.feedback.tokens.FeedbackIngestTokenSchema +import com.langsmith_api.api.models.api.v1.feedback.tokens.TokenCreateParams +import com.langsmith_api.api.models.api.v1.feedback.tokens.TokenCreateResponse +import com.langsmith_api.api.models.api.v1.feedback.tokens.TokenListParams +import com.langsmith_api.api.models.api.v1.feedback.tokens.TokenRetrieveParams +import com.langsmith_api.api.models.api.v1.feedback.tokens.TokenRetrieveResponse +import com.langsmith_api.api.models.api.v1.feedback.tokens.TokenUpdateParams +import com.langsmith_api.api.models.api.v1.feedback.tokens.TokenUpdateResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class TokenServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + TokenServiceAsync { + + private val withRawResponse: TokenServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): TokenServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): TokenServiceAsync = + TokenServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: TokenCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<TokenCreateResponse> = + // post /api/v1/feedback/tokens + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun retrieve( + params: TokenRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<TokenRetrieveResponse> = + // get /api/v1/feedback/tokens/{token} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: TokenUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<TokenUpdateResponse> = + // post /api/v1/feedback/tokens/{token} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: TokenListParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<FeedbackIngestTokenSchema>> = + // get /api/v1/feedback/tokens + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TokenServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): TokenServiceAsync.WithRawResponse = + TokenServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<TokenCreateResponse> = + jsonHandler<TokenCreateResponse>(clientOptions.jsonMapper) + + override fun create( + params: TokenCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<TokenCreateResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "feedback", "tokens") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler<TokenRetrieveResponse> = + jsonHandler<TokenRetrieveResponse>(clientOptions.jsonMapper) + + override fun retrieve( + params: TokenRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<TokenRetrieveResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("token", params.token().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "feedback", "tokens", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler<TokenUpdateResponse> = + jsonHandler<TokenUpdateResponse>(clientOptions.jsonMapper) + + override fun update( + params: TokenUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<TokenUpdateResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("token", params.token().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "feedback", "tokens", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler<List<FeedbackIngestTokenSchema>> = + jsonHandler<List<FeedbackIngestTokenSchema>>(clientOptions.jsonMapper) + + override fun list( + params: TokenListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<FeedbackIngestTokenSchema>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "feedback", "tokens") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/me/OnboardingStateServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/me/OnboardingStateServiceAsync.kt new file mode 100644 index 00000000..89f91f61 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/me/OnboardingStateServiceAsync.kt @@ -0,0 +1,218 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.me + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.me.onboardingstate.OnboardingStateCreateParams +import com.langsmith_api.api.models.api.v1.me.onboardingstate.OnboardingStateListParams +import com.langsmith_api.api.models.api.v1.me.onboardingstate.OnboardingStateUpdateParams +import com.langsmith_api.api.models.api.v1.me.onboardingstate.UserOnboardingStateResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface OnboardingStateServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): OnboardingStateServiceAsync + + /** Initialize onboarding state for the current user. */ + fun create(): CompletableFuture<UserOnboardingStateResponse> = + create(OnboardingStateCreateParams.none()) + + /** @see create */ + fun create( + params: OnboardingStateCreateParams = OnboardingStateCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<UserOnboardingStateResponse> + + /** @see create */ + fun create( + params: OnboardingStateCreateParams = OnboardingStateCreateParams.none() + ): CompletableFuture<UserOnboardingStateResponse> = create(params, RequestOptions.none()) + + /** @see create */ + fun create(requestOptions: RequestOptions): CompletableFuture<UserOnboardingStateResponse> = + create(OnboardingStateCreateParams.none(), requestOptions) + + /** + * Update a specific onboarding completion field for the current user. + * + * Valid fields: + * - tracing_completed_at + * - lgstudio_completed_at + * - playground_completed_at + * - evaluation_completed_at + * - success_viewed_at + */ + fun update(field: String): CompletableFuture<UserOnboardingStateResponse> = + update(field, OnboardingStateUpdateParams.none()) + + /** @see update */ + fun update( + field: String, + params: OnboardingStateUpdateParams = OnboardingStateUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<UserOnboardingStateResponse> = + update(params.toBuilder().field(field).build(), requestOptions) + + /** @see update */ + fun update( + field: String, + params: OnboardingStateUpdateParams = OnboardingStateUpdateParams.none(), + ): CompletableFuture<UserOnboardingStateResponse> = update(field, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: OnboardingStateUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<UserOnboardingStateResponse> + + /** @see update */ + fun update( + params: OnboardingStateUpdateParams + ): CompletableFuture<UserOnboardingStateResponse> = update(params, RequestOptions.none()) + + /** @see update */ + fun update( + field: String, + requestOptions: RequestOptions, + ): CompletableFuture<UserOnboardingStateResponse> = + update(field, OnboardingStateUpdateParams.none(), requestOptions) + + /** Get onboarding state for the current user. */ + fun list(): CompletableFuture<UserOnboardingStateResponse> = + list(OnboardingStateListParams.none()) + + /** @see list */ + fun list( + params: OnboardingStateListParams = OnboardingStateListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<UserOnboardingStateResponse> + + /** @see list */ + fun list( + params: OnboardingStateListParams = OnboardingStateListParams.none() + ): CompletableFuture<UserOnboardingStateResponse> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture<UserOnboardingStateResponse> = + list(OnboardingStateListParams.none(), requestOptions) + + /** + * A view of [OnboardingStateServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): OnboardingStateServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/me/onboarding_state`, but is otherwise the + * same as [OnboardingStateServiceAsync.create]. + */ + fun create(): CompletableFuture<HttpResponseFor<UserOnboardingStateResponse>> = + create(OnboardingStateCreateParams.none()) + + /** @see create */ + fun create( + params: OnboardingStateCreateParams = OnboardingStateCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<UserOnboardingStateResponse>> + + /** @see create */ + fun create( + params: OnboardingStateCreateParams = OnboardingStateCreateParams.none() + ): CompletableFuture<HttpResponseFor<UserOnboardingStateResponse>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<UserOnboardingStateResponse>> = + create(OnboardingStateCreateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `put /api/v1/me/onboarding_state/{field}`, but is + * otherwise the same as [OnboardingStateServiceAsync.update]. + */ + fun update(field: String): CompletableFuture<HttpResponseFor<UserOnboardingStateResponse>> = + update(field, OnboardingStateUpdateParams.none()) + + /** @see update */ + fun update( + field: String, + params: OnboardingStateUpdateParams = OnboardingStateUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<UserOnboardingStateResponse>> = + update(params.toBuilder().field(field).build(), requestOptions) + + /** @see update */ + fun update( + field: String, + params: OnboardingStateUpdateParams = OnboardingStateUpdateParams.none(), + ): CompletableFuture<HttpResponseFor<UserOnboardingStateResponse>> = + update(field, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: OnboardingStateUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<UserOnboardingStateResponse>> + + /** @see update */ + fun update( + params: OnboardingStateUpdateParams + ): CompletableFuture<HttpResponseFor<UserOnboardingStateResponse>> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + field: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<UserOnboardingStateResponse>> = + update(field, OnboardingStateUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/me/onboarding_state`, but is otherwise the + * same as [OnboardingStateServiceAsync.list]. + */ + fun list(): CompletableFuture<HttpResponseFor<UserOnboardingStateResponse>> = + list(OnboardingStateListParams.none()) + + /** @see list */ + fun list( + params: OnboardingStateListParams = OnboardingStateListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<UserOnboardingStateResponse>> + + /** @see list */ + fun list( + params: OnboardingStateListParams = OnboardingStateListParams.none() + ): CompletableFuture<HttpResponseFor<UserOnboardingStateResponse>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<UserOnboardingStateResponse>> = + list(OnboardingStateListParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/me/OnboardingStateServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/me/OnboardingStateServiceAsyncImpl.kt new file mode 100644 index 00000000..27019388 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/me/OnboardingStateServiceAsyncImpl.kt @@ -0,0 +1,170 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.me + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.me.onboardingstate.OnboardingStateCreateParams +import com.langsmith_api.api.models.api.v1.me.onboardingstate.OnboardingStateListParams +import com.langsmith_api.api.models.api.v1.me.onboardingstate.OnboardingStateUpdateParams +import com.langsmith_api.api.models.api.v1.me.onboardingstate.UserOnboardingStateResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class OnboardingStateServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : OnboardingStateServiceAsync { + + private val withRawResponse: OnboardingStateServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): OnboardingStateServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): OnboardingStateServiceAsync = + OnboardingStateServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: OnboardingStateCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<UserOnboardingStateResponse> = + // post /api/v1/me/onboarding_state + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: OnboardingStateUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<UserOnboardingStateResponse> = + // put /api/v1/me/onboarding_state/{field} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: OnboardingStateListParams, + requestOptions: RequestOptions, + ): CompletableFuture<UserOnboardingStateResponse> = + // get /api/v1/me/onboarding_state + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + OnboardingStateServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): OnboardingStateServiceAsync.WithRawResponse = + OnboardingStateServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<UserOnboardingStateResponse> = + jsonHandler<UserOnboardingStateResponse>(clientOptions.jsonMapper) + + override fun create( + params: OnboardingStateCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<UserOnboardingStateResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "me", "onboarding_state") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler<UserOnboardingStateResponse> = + jsonHandler<UserOnboardingStateResponse>(clientOptions.jsonMapper) + + override fun update( + params: OnboardingStateUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<UserOnboardingStateResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("field", params.field().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "me", "onboarding_state", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler<UserOnboardingStateResponse> = + jsonHandler<UserOnboardingStateResponse>(clientOptions.jsonMapper) + + override fun list( + params: OnboardingStateListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<UserOnboardingStateResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "me", "onboarding_state") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgcharts/SectionServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgcharts/SectionServiceAsync.kt new file mode 100644 index 00000000..978b82b6 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgcharts/SectionServiceAsync.kt @@ -0,0 +1,282 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgcharts + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.charts.section.CustomChartsSectionCreate +import com.langsmith_api.api.models.api.v1.charts.section.CustomChartsSectionResponse +import com.langsmith_api.api.models.api.v1.orgcharts.section.SectionCreateParams +import com.langsmith_api.api.models.api.v1.orgcharts.section.SectionDeleteParams +import com.langsmith_api.api.models.api.v1.orgcharts.section.SectionDeleteResponse +import com.langsmith_api.api.models.api.v1.orgcharts.section.SectionListParams +import com.langsmith_api.api.models.api.v1.orgcharts.section.SectionUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface SectionServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): SectionServiceAsync + + /** Create a new section. */ + fun create(params: SectionCreateParams): CompletableFuture<CustomChartsSectionResponse> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: SectionCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CustomChartsSectionResponse> + + /** @see create */ + fun create( + customChartsSectionCreate: CustomChartsSectionCreate, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CustomChartsSectionResponse> = + create( + SectionCreateParams.builder() + .customChartsSectionCreate(customChartsSectionCreate) + .build(), + requestOptions, + ) + + /** @see create */ + fun create( + customChartsSectionCreate: CustomChartsSectionCreate + ): CompletableFuture<CustomChartsSectionResponse> = + create(customChartsSectionCreate, RequestOptions.none()) + + /** Update a section. */ + fun update( + sectionId: String, + params: SectionUpdateParams, + ): CompletableFuture<CustomChartsSectionResponse> = + update(sectionId, params, RequestOptions.none()) + + /** @see update */ + fun update( + sectionId: String, + params: SectionUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CustomChartsSectionResponse> = + update(params.toBuilder().sectionId(sectionId).build(), requestOptions) + + /** @see update */ + fun update(params: SectionUpdateParams): CompletableFuture<CustomChartsSectionResponse> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: SectionUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CustomChartsSectionResponse> + + /** Get all sections for the tenant. */ + fun list(): CompletableFuture<List<CustomChartsSectionResponse>> = + list(SectionListParams.none()) + + /** @see list */ + fun list( + params: SectionListParams = SectionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<CustomChartsSectionResponse>> + + /** @see list */ + fun list( + params: SectionListParams = SectionListParams.none() + ): CompletableFuture<List<CustomChartsSectionResponse>> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture<List<CustomChartsSectionResponse>> = + list(SectionListParams.none(), requestOptions) + + /** Delete a section. */ + fun delete(sectionId: String): CompletableFuture<SectionDeleteResponse> = + delete(sectionId, SectionDeleteParams.none()) + + /** @see delete */ + fun delete( + sectionId: String, + params: SectionDeleteParams = SectionDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<SectionDeleteResponse> = + delete(params.toBuilder().sectionId(sectionId).build(), requestOptions) + + /** @see delete */ + fun delete( + sectionId: String, + params: SectionDeleteParams = SectionDeleteParams.none(), + ): CompletableFuture<SectionDeleteResponse> = delete(sectionId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: SectionDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<SectionDeleteResponse> + + /** @see delete */ + fun delete(params: SectionDeleteParams): CompletableFuture<SectionDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + sectionId: String, + requestOptions: RequestOptions, + ): CompletableFuture<SectionDeleteResponse> = + delete(sectionId, SectionDeleteParams.none(), requestOptions) + + /** + * A view of [SectionServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): SectionServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/org-charts/section`, but is otherwise the + * same as [SectionServiceAsync.create]. + */ + fun create( + params: SectionCreateParams + ): CompletableFuture<HttpResponseFor<CustomChartsSectionResponse>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: SectionCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CustomChartsSectionResponse>> + + /** @see create */ + fun create( + customChartsSectionCreate: CustomChartsSectionCreate, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CustomChartsSectionResponse>> = + create( + SectionCreateParams.builder() + .customChartsSectionCreate(customChartsSectionCreate) + .build(), + requestOptions, + ) + + /** @see create */ + fun create( + customChartsSectionCreate: CustomChartsSectionCreate + ): CompletableFuture<HttpResponseFor<CustomChartsSectionResponse>> = + create(customChartsSectionCreate, RequestOptions.none()) + + /** + * Returns a raw HTTP response for `patch /api/v1/org-charts/section/{section_id}`, but is + * otherwise the same as [SectionServiceAsync.update]. + */ + fun update( + sectionId: String, + params: SectionUpdateParams, + ): CompletableFuture<HttpResponseFor<CustomChartsSectionResponse>> = + update(sectionId, params, RequestOptions.none()) + + /** @see update */ + fun update( + sectionId: String, + params: SectionUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CustomChartsSectionResponse>> = + update(params.toBuilder().sectionId(sectionId).build(), requestOptions) + + /** @see update */ + fun update( + params: SectionUpdateParams + ): CompletableFuture<HttpResponseFor<CustomChartsSectionResponse>> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: SectionUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CustomChartsSectionResponse>> + + /** + * Returns a raw HTTP response for `get /api/v1/org-charts/section`, but is otherwise the + * same as [SectionServiceAsync.list]. + */ + fun list(): CompletableFuture<HttpResponseFor<List<CustomChartsSectionResponse>>> = + list(SectionListParams.none()) + + /** @see list */ + fun list( + params: SectionListParams = SectionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<CustomChartsSectionResponse>>> + + /** @see list */ + fun list( + params: SectionListParams = SectionListParams.none() + ): CompletableFuture<HttpResponseFor<List<CustomChartsSectionResponse>>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<CustomChartsSectionResponse>>> = + list(SectionListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/org-charts/section/{section_id}`, but is + * otherwise the same as [SectionServiceAsync.delete]. + */ + fun delete(sectionId: String): CompletableFuture<HttpResponseFor<SectionDeleteResponse>> = + delete(sectionId, SectionDeleteParams.none()) + + /** @see delete */ + fun delete( + sectionId: String, + params: SectionDeleteParams = SectionDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<SectionDeleteResponse>> = + delete(params.toBuilder().sectionId(sectionId).build(), requestOptions) + + /** @see delete */ + fun delete( + sectionId: String, + params: SectionDeleteParams = SectionDeleteParams.none(), + ): CompletableFuture<HttpResponseFor<SectionDeleteResponse>> = + delete(sectionId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: SectionDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<SectionDeleteResponse>> + + /** @see delete */ + fun delete( + params: SectionDeleteParams + ): CompletableFuture<HttpResponseFor<SectionDeleteResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + sectionId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<SectionDeleteResponse>> = + delete(sectionId, SectionDeleteParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgcharts/SectionServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgcharts/SectionServiceAsyncImpl.kt new file mode 100644 index 00000000..62b6b55f --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgcharts/SectionServiceAsyncImpl.kt @@ -0,0 +1,211 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgcharts + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.charts.section.CustomChartsSectionResponse +import com.langsmith_api.api.models.api.v1.orgcharts.section.SectionCreateParams +import com.langsmith_api.api.models.api.v1.orgcharts.section.SectionDeleteParams +import com.langsmith_api.api.models.api.v1.orgcharts.section.SectionDeleteResponse +import com.langsmith_api.api.models.api.v1.orgcharts.section.SectionListParams +import com.langsmith_api.api.models.api.v1.orgcharts.section.SectionUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class SectionServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + SectionServiceAsync { + + private val withRawResponse: SectionServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): SectionServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): SectionServiceAsync = + SectionServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: SectionCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<CustomChartsSectionResponse> = + // post /api/v1/org-charts/section + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: SectionUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<CustomChartsSectionResponse> = + // patch /api/v1/org-charts/section/{section_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: SectionListParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<CustomChartsSectionResponse>> = + // get /api/v1/org-charts/section + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: SectionDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<SectionDeleteResponse> = + // delete /api/v1/org-charts/section/{section_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SectionServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): SectionServiceAsync.WithRawResponse = + SectionServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<CustomChartsSectionResponse> = + jsonHandler<CustomChartsSectionResponse>(clientOptions.jsonMapper) + + override fun create( + params: SectionCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<CustomChartsSectionResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "org-charts", "section") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler<CustomChartsSectionResponse> = + jsonHandler<CustomChartsSectionResponse>(clientOptions.jsonMapper) + + override fun update( + params: SectionUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<CustomChartsSectionResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("sectionId", params.sectionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "org-charts", "section", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler<List<CustomChartsSectionResponse>> = + jsonHandler<List<CustomChartsSectionResponse>>(clientOptions.jsonMapper) + + override fun list( + params: SectionListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<CustomChartsSectionResponse>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "org-charts", "section") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val deleteHandler: Handler<SectionDeleteResponse> = + jsonHandler<SectionDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: SectionDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<SectionDeleteResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("sectionId", params.sectionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "org-charts", "section", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/CurrentServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/CurrentServiceAsync.kt new file mode 100644 index 00000000..729039e6 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/CurrentServiceAsync.kt @@ -0,0 +1,429 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentConfirmCheckoutSessionCompletionParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentConfirmCheckoutSessionCompletionResponse +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentListParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentListResponse +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentPaymentMethodParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentPaymentMethodResponse +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentPlanParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentPlanResponse +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentRetrieveDashboardParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentRetrieveDashboardResponse +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentSetDefaultSsoProvisionParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentSetDefaultSsoProvisionResponse +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentSetupParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentSetupResponse +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentStripeAccountLinksParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentStripeAccountLinksResponse +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentStripeCheckoutSessionParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentStripeCheckoutSessionResponse +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentUpdateLoginMethodsParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentUpdateLoginMethodsResponse +import com.langsmith_api.api.services.async.api.v1.orgs.current.BillingServiceAsync +import com.langsmith_api.api.services.async.api.v1.orgs.current.BusinessInfoServiceAsync +import com.langsmith_api.api.services.async.api.v1.orgs.current.InfoServiceAsync +import com.langsmith_api.api.services.async.api.v1.orgs.current.MemberServiceAsync +import com.langsmith_api.api.services.async.api.v1.orgs.current.PersonalAccessTokenServiceAsync +import com.langsmith_api.api.services.async.api.v1.orgs.current.RoleServiceAsync +import com.langsmith_api.api.services.async.api.v1.orgs.current.ServiceKeyServiceAsync +import com.langsmith_api.api.services.async.api.v1.orgs.current.SsoSettingServiceAsync +import com.langsmith_api.api.services.async.api.v1.orgs.current.UserServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface CurrentServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): CurrentServiceAsync + + fun info(): InfoServiceAsync + + fun billing(): BillingServiceAsync + + fun businessInfo(): BusinessInfoServiceAsync + + fun roles(): RoleServiceAsync + + fun members(): MemberServiceAsync + + fun ssoSettings(): SsoSettingServiceAsync + + fun user(): UserServiceAsync + + fun serviceKeys(): ServiceKeyServiceAsync + + fun personalAccessTokens(): PersonalAccessTokenServiceAsync + + /** Get Organization Info */ + fun list(): CompletableFuture<CurrentListResponse> = list(CurrentListParams.none()) + + /** @see list */ + fun list( + params: CurrentListParams = CurrentListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CurrentListResponse> + + /** @see list */ + fun list( + params: CurrentListParams = CurrentListParams.none() + ): CompletableFuture<CurrentListResponse> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture<CurrentListResponse> = + list(CurrentListParams.none(), requestOptions) + + /** Complete a Stripe checkout session flow. */ + fun confirmCheckoutSessionCompletion( + params: CurrentConfirmCheckoutSessionCompletionParams + ): CompletableFuture<CurrentConfirmCheckoutSessionCompletionResponse> = + confirmCheckoutSessionCompletion(params, RequestOptions.none()) + + /** @see confirmCheckoutSessionCompletion */ + fun confirmCheckoutSessionCompletion( + params: CurrentConfirmCheckoutSessionCompletionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CurrentConfirmCheckoutSessionCompletionResponse> + + /** On Payment Method Created */ + fun paymentMethod( + params: CurrentPaymentMethodParams + ): CompletableFuture<CurrentPaymentMethodResponse> = + paymentMethod(params, RequestOptions.none()) + + /** @see paymentMethod */ + fun paymentMethod( + params: CurrentPaymentMethodParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CurrentPaymentMethodResponse> + + /** Change Payment Plan */ + fun plan(params: CurrentPlanParams): CompletableFuture<CurrentPlanResponse> = + plan(params, RequestOptions.none()) + + /** @see plan */ + fun plan( + params: CurrentPlanParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CurrentPlanResponse> + + /** Get Dashboard */ + fun retrieveDashboard( + params: CurrentRetrieveDashboardParams + ): CompletableFuture<CurrentRetrieveDashboardResponse> = + retrieveDashboard(params, RequestOptions.none()) + + /** @see retrieveDashboard */ + fun retrieveDashboard( + params: CurrentRetrieveDashboardParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CurrentRetrieveDashboardResponse> + + /** + * Set the current organization as the default for SSO provisioning in self-hosted environments. + */ + fun setDefaultSsoProvision(): CompletableFuture<CurrentSetDefaultSsoProvisionResponse> = + setDefaultSsoProvision(CurrentSetDefaultSsoProvisionParams.none()) + + /** @see setDefaultSsoProvision */ + fun setDefaultSsoProvision( + params: CurrentSetDefaultSsoProvisionParams = CurrentSetDefaultSsoProvisionParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CurrentSetDefaultSsoProvisionResponse> + + /** @see setDefaultSsoProvision */ + fun setDefaultSsoProvision( + params: CurrentSetDefaultSsoProvisionParams = CurrentSetDefaultSsoProvisionParams.none() + ): CompletableFuture<CurrentSetDefaultSsoProvisionResponse> = + setDefaultSsoProvision(params, RequestOptions.none()) + + /** @see setDefaultSsoProvision */ + fun setDefaultSsoProvision( + requestOptions: RequestOptions + ): CompletableFuture<CurrentSetDefaultSsoProvisionResponse> = + setDefaultSsoProvision(CurrentSetDefaultSsoProvisionParams.none(), requestOptions) + + /** Create Customers And Get Stripe Setup Intent */ + fun setup(): CompletableFuture<CurrentSetupResponse> = setup(CurrentSetupParams.none()) + + /** @see setup */ + fun setup( + params: CurrentSetupParams = CurrentSetupParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CurrentSetupResponse> + + /** @see setup */ + fun setup( + params: CurrentSetupParams = CurrentSetupParams.none() + ): CompletableFuture<CurrentSetupResponse> = setup(params, RequestOptions.none()) + + /** @see setup */ + fun setup(requestOptions: RequestOptions): CompletableFuture<CurrentSetupResponse> = + setup(CurrentSetupParams.none(), requestOptions) + + /** Kick off a Stripe account link flow. */ + fun stripeAccountLinks( + params: CurrentStripeAccountLinksParams + ): CompletableFuture<CurrentStripeAccountLinksResponse> = + stripeAccountLinks(params, RequestOptions.none()) + + /** @see stripeAccountLinks */ + fun stripeAccountLinks( + params: CurrentStripeAccountLinksParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CurrentStripeAccountLinksResponse> + + /** Kick off a Stripe checkout session flow. */ + fun stripeCheckoutSession( + params: CurrentStripeCheckoutSessionParams + ): CompletableFuture<CurrentStripeCheckoutSessionResponse> = + stripeCheckoutSession(params, RequestOptions.none()) + + /** @see stripeCheckoutSession */ + fun stripeCheckoutSession( + params: CurrentStripeCheckoutSessionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CurrentStripeCheckoutSessionResponse> + + /** Update allowed login methods for the current organization. */ + fun updateLoginMethods( + params: CurrentUpdateLoginMethodsParams + ): CompletableFuture<CurrentUpdateLoginMethodsResponse> = + updateLoginMethods(params, RequestOptions.none()) + + /** @see updateLoginMethods */ + fun updateLoginMethods( + params: CurrentUpdateLoginMethodsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CurrentUpdateLoginMethodsResponse> + + /** + * A view of [CurrentServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): CurrentServiceAsync.WithRawResponse + + fun info(): InfoServiceAsync.WithRawResponse + + fun billing(): BillingServiceAsync.WithRawResponse + + fun businessInfo(): BusinessInfoServiceAsync.WithRawResponse + + fun roles(): RoleServiceAsync.WithRawResponse + + fun members(): MemberServiceAsync.WithRawResponse + + fun ssoSettings(): SsoSettingServiceAsync.WithRawResponse + + fun user(): UserServiceAsync.WithRawResponse + + fun serviceKeys(): ServiceKeyServiceAsync.WithRawResponse + + fun personalAccessTokens(): PersonalAccessTokenServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/orgs/current`, but is otherwise the same as + * [CurrentServiceAsync.list]. + */ + fun list(): CompletableFuture<HttpResponseFor<CurrentListResponse>> = + list(CurrentListParams.none()) + + /** @see list */ + fun list( + params: CurrentListParams = CurrentListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CurrentListResponse>> + + /** @see list */ + fun list( + params: CurrentListParams = CurrentListParams.none() + ): CompletableFuture<HttpResponseFor<CurrentListResponse>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<CurrentListResponse>> = + list(CurrentListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post + * /api/v1/orgs/current/confirm_checkout_session_completion`, but is otherwise the same as + * [CurrentServiceAsync.confirmCheckoutSessionCompletion]. + */ + fun confirmCheckoutSessionCompletion( + params: CurrentConfirmCheckoutSessionCompletionParams + ): CompletableFuture<HttpResponseFor<CurrentConfirmCheckoutSessionCompletionResponse>> = + confirmCheckoutSessionCompletion(params, RequestOptions.none()) + + /** @see confirmCheckoutSessionCompletion */ + fun confirmCheckoutSessionCompletion( + params: CurrentConfirmCheckoutSessionCompletionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CurrentConfirmCheckoutSessionCompletionResponse>> + + /** + * Returns a raw HTTP response for `post /api/v1/orgs/current/payment-method`, but is + * otherwise the same as [CurrentServiceAsync.paymentMethod]. + */ + fun paymentMethod( + params: CurrentPaymentMethodParams + ): CompletableFuture<HttpResponseFor<CurrentPaymentMethodResponse>> = + paymentMethod(params, RequestOptions.none()) + + /** @see paymentMethod */ + fun paymentMethod( + params: CurrentPaymentMethodParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CurrentPaymentMethodResponse>> + + /** + * Returns a raw HTTP response for `post /api/v1/orgs/current/plan`, but is otherwise the + * same as [CurrentServiceAsync.plan]. + */ + fun plan( + params: CurrentPlanParams + ): CompletableFuture<HttpResponseFor<CurrentPlanResponse>> = + plan(params, RequestOptions.none()) + + /** @see plan */ + fun plan( + params: CurrentPlanParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CurrentPlanResponse>> + + /** + * Returns a raw HTTP response for `get /api/v1/orgs/current/dashboard`, but is otherwise + * the same as [CurrentServiceAsync.retrieveDashboard]. + */ + fun retrieveDashboard( + params: CurrentRetrieveDashboardParams + ): CompletableFuture<HttpResponseFor<CurrentRetrieveDashboardResponse>> = + retrieveDashboard(params, RequestOptions.none()) + + /** @see retrieveDashboard */ + fun retrieveDashboard( + params: CurrentRetrieveDashboardParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CurrentRetrieveDashboardResponse>> + + /** + * Returns a raw HTTP response for `post /api/v1/orgs/current/set-default-sso-provision`, + * but is otherwise the same as [CurrentServiceAsync.setDefaultSsoProvision]. + */ + fun setDefaultSsoProvision(): + CompletableFuture<HttpResponseFor<CurrentSetDefaultSsoProvisionResponse>> = + setDefaultSsoProvision(CurrentSetDefaultSsoProvisionParams.none()) + + /** @see setDefaultSsoProvision */ + fun setDefaultSsoProvision( + params: CurrentSetDefaultSsoProvisionParams = + CurrentSetDefaultSsoProvisionParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CurrentSetDefaultSsoProvisionResponse>> + + /** @see setDefaultSsoProvision */ + fun setDefaultSsoProvision( + params: CurrentSetDefaultSsoProvisionParams = CurrentSetDefaultSsoProvisionParams.none() + ): CompletableFuture<HttpResponseFor<CurrentSetDefaultSsoProvisionResponse>> = + setDefaultSsoProvision(params, RequestOptions.none()) + + /** @see setDefaultSsoProvision */ + fun setDefaultSsoProvision( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<CurrentSetDefaultSsoProvisionResponse>> = + setDefaultSsoProvision(CurrentSetDefaultSsoProvisionParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/orgs/current/setup`, but is otherwise the + * same as [CurrentServiceAsync.setup]. + */ + fun setup(): CompletableFuture<HttpResponseFor<CurrentSetupResponse>> = + setup(CurrentSetupParams.none()) + + /** @see setup */ + fun setup( + params: CurrentSetupParams = CurrentSetupParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CurrentSetupResponse>> + + /** @see setup */ + fun setup( + params: CurrentSetupParams = CurrentSetupParams.none() + ): CompletableFuture<HttpResponseFor<CurrentSetupResponse>> = + setup(params, RequestOptions.none()) + + /** @see setup */ + fun setup( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<CurrentSetupResponse>> = + setup(CurrentSetupParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/orgs/current/stripe_account_links`, but is + * otherwise the same as [CurrentServiceAsync.stripeAccountLinks]. + */ + fun stripeAccountLinks( + params: CurrentStripeAccountLinksParams + ): CompletableFuture<HttpResponseFor<CurrentStripeAccountLinksResponse>> = + stripeAccountLinks(params, RequestOptions.none()) + + /** @see stripeAccountLinks */ + fun stripeAccountLinks( + params: CurrentStripeAccountLinksParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CurrentStripeAccountLinksResponse>> + + /** + * Returns a raw HTTP response for `post /api/v1/orgs/current/stripe_checkout_session`, but + * is otherwise the same as [CurrentServiceAsync.stripeCheckoutSession]. + */ + fun stripeCheckoutSession( + params: CurrentStripeCheckoutSessionParams + ): CompletableFuture<HttpResponseFor<CurrentStripeCheckoutSessionResponse>> = + stripeCheckoutSession(params, RequestOptions.none()) + + /** @see stripeCheckoutSession */ + fun stripeCheckoutSession( + params: CurrentStripeCheckoutSessionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CurrentStripeCheckoutSessionResponse>> + + /** + * Returns a raw HTTP response for `patch /api/v1/orgs/current/login-methods`, but is + * otherwise the same as [CurrentServiceAsync.updateLoginMethods]. + */ + fun updateLoginMethods( + params: CurrentUpdateLoginMethodsParams + ): CompletableFuture<HttpResponseFor<CurrentUpdateLoginMethodsResponse>> = + updateLoginMethods(params, RequestOptions.none()) + + /** @see updateLoginMethods */ + fun updateLoginMethods( + params: CurrentUpdateLoginMethodsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CurrentUpdateLoginMethodsResponse>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/CurrentServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/CurrentServiceAsyncImpl.kt new file mode 100644 index 00000000..e9dae120 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/CurrentServiceAsyncImpl.kt @@ -0,0 +1,570 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentConfirmCheckoutSessionCompletionParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentConfirmCheckoutSessionCompletionResponse +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentListParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentListResponse +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentPaymentMethodParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentPaymentMethodResponse +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentPlanParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentPlanResponse +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentRetrieveDashboardParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentRetrieveDashboardResponse +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentSetDefaultSsoProvisionParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentSetDefaultSsoProvisionResponse +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentSetupParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentSetupResponse +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentStripeAccountLinksParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentStripeAccountLinksResponse +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentStripeCheckoutSessionParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentStripeCheckoutSessionResponse +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentUpdateLoginMethodsParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentUpdateLoginMethodsResponse +import com.langsmith_api.api.services.async.api.v1.orgs.current.BillingServiceAsync +import com.langsmith_api.api.services.async.api.v1.orgs.current.BillingServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.orgs.current.BusinessInfoServiceAsync +import com.langsmith_api.api.services.async.api.v1.orgs.current.BusinessInfoServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.orgs.current.InfoServiceAsync +import com.langsmith_api.api.services.async.api.v1.orgs.current.InfoServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.orgs.current.MemberServiceAsync +import com.langsmith_api.api.services.async.api.v1.orgs.current.MemberServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.orgs.current.PersonalAccessTokenServiceAsync +import com.langsmith_api.api.services.async.api.v1.orgs.current.PersonalAccessTokenServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.orgs.current.RoleServiceAsync +import com.langsmith_api.api.services.async.api.v1.orgs.current.RoleServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.orgs.current.ServiceKeyServiceAsync +import com.langsmith_api.api.services.async.api.v1.orgs.current.ServiceKeyServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.orgs.current.SsoSettingServiceAsync +import com.langsmith_api.api.services.async.api.v1.orgs.current.SsoSettingServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.orgs.current.UserServiceAsync +import com.langsmith_api.api.services.async.api.v1.orgs.current.UserServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class CurrentServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + CurrentServiceAsync { + + private val withRawResponse: CurrentServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val info: InfoServiceAsync by lazy { InfoServiceAsyncImpl(clientOptions) } + + private val billing: BillingServiceAsync by lazy { BillingServiceAsyncImpl(clientOptions) } + + private val businessInfo: BusinessInfoServiceAsync by lazy { + BusinessInfoServiceAsyncImpl(clientOptions) + } + + private val roles: RoleServiceAsync by lazy { RoleServiceAsyncImpl(clientOptions) } + + private val members: MemberServiceAsync by lazy { MemberServiceAsyncImpl(clientOptions) } + + private val ssoSettings: SsoSettingServiceAsync by lazy { + SsoSettingServiceAsyncImpl(clientOptions) + } + + private val user: UserServiceAsync by lazy { UserServiceAsyncImpl(clientOptions) } + + private val serviceKeys: ServiceKeyServiceAsync by lazy { + ServiceKeyServiceAsyncImpl(clientOptions) + } + + private val personalAccessTokens: PersonalAccessTokenServiceAsync by lazy { + PersonalAccessTokenServiceAsyncImpl(clientOptions) + } + + override fun withRawResponse(): CurrentServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): CurrentServiceAsync = + CurrentServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun info(): InfoServiceAsync = info + + override fun billing(): BillingServiceAsync = billing + + override fun businessInfo(): BusinessInfoServiceAsync = businessInfo + + override fun roles(): RoleServiceAsync = roles + + override fun members(): MemberServiceAsync = members + + override fun ssoSettings(): SsoSettingServiceAsync = ssoSettings + + override fun user(): UserServiceAsync = user + + override fun serviceKeys(): ServiceKeyServiceAsync = serviceKeys + + override fun personalAccessTokens(): PersonalAccessTokenServiceAsync = personalAccessTokens + + override fun list( + params: CurrentListParams, + requestOptions: RequestOptions, + ): CompletableFuture<CurrentListResponse> = + // get /api/v1/orgs/current + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun confirmCheckoutSessionCompletion( + params: CurrentConfirmCheckoutSessionCompletionParams, + requestOptions: RequestOptions, + ): CompletableFuture<CurrentConfirmCheckoutSessionCompletionResponse> = + // post /api/v1/orgs/current/confirm_checkout_session_completion + withRawResponse().confirmCheckoutSessionCompletion(params, requestOptions).thenApply { + it.parse() + } + + override fun paymentMethod( + params: CurrentPaymentMethodParams, + requestOptions: RequestOptions, + ): CompletableFuture<CurrentPaymentMethodResponse> = + // post /api/v1/orgs/current/payment-method + withRawResponse().paymentMethod(params, requestOptions).thenApply { it.parse() } + + override fun plan( + params: CurrentPlanParams, + requestOptions: RequestOptions, + ): CompletableFuture<CurrentPlanResponse> = + // post /api/v1/orgs/current/plan + withRawResponse().plan(params, requestOptions).thenApply { it.parse() } + + override fun retrieveDashboard( + params: CurrentRetrieveDashboardParams, + requestOptions: RequestOptions, + ): CompletableFuture<CurrentRetrieveDashboardResponse> = + // get /api/v1/orgs/current/dashboard + withRawResponse().retrieveDashboard(params, requestOptions).thenApply { it.parse() } + + override fun setDefaultSsoProvision( + params: CurrentSetDefaultSsoProvisionParams, + requestOptions: RequestOptions, + ): CompletableFuture<CurrentSetDefaultSsoProvisionResponse> = + // post /api/v1/orgs/current/set-default-sso-provision + withRawResponse().setDefaultSsoProvision(params, requestOptions).thenApply { it.parse() } + + override fun setup( + params: CurrentSetupParams, + requestOptions: RequestOptions, + ): CompletableFuture<CurrentSetupResponse> = + // post /api/v1/orgs/current/setup + withRawResponse().setup(params, requestOptions).thenApply { it.parse() } + + override fun stripeAccountLinks( + params: CurrentStripeAccountLinksParams, + requestOptions: RequestOptions, + ): CompletableFuture<CurrentStripeAccountLinksResponse> = + // post /api/v1/orgs/current/stripe_account_links + withRawResponse().stripeAccountLinks(params, requestOptions).thenApply { it.parse() } + + override fun stripeCheckoutSession( + params: CurrentStripeCheckoutSessionParams, + requestOptions: RequestOptions, + ): CompletableFuture<CurrentStripeCheckoutSessionResponse> = + // post /api/v1/orgs/current/stripe_checkout_session + withRawResponse().stripeCheckoutSession(params, requestOptions).thenApply { it.parse() } + + override fun updateLoginMethods( + params: CurrentUpdateLoginMethodsParams, + requestOptions: RequestOptions, + ): CompletableFuture<CurrentUpdateLoginMethodsResponse> = + // patch /api/v1/orgs/current/login-methods + withRawResponse().updateLoginMethods(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CurrentServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val info: InfoServiceAsync.WithRawResponse by lazy { + InfoServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val billing: BillingServiceAsync.WithRawResponse by lazy { + BillingServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val businessInfo: BusinessInfoServiceAsync.WithRawResponse by lazy { + BusinessInfoServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val roles: RoleServiceAsync.WithRawResponse by lazy { + RoleServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val members: MemberServiceAsync.WithRawResponse by lazy { + MemberServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val ssoSettings: SsoSettingServiceAsync.WithRawResponse by lazy { + SsoSettingServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val user: UserServiceAsync.WithRawResponse by lazy { + UserServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val serviceKeys: ServiceKeyServiceAsync.WithRawResponse by lazy { + ServiceKeyServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val personalAccessTokens: PersonalAccessTokenServiceAsync.WithRawResponse by lazy { + PersonalAccessTokenServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): CurrentServiceAsync.WithRawResponse = + CurrentServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun info(): InfoServiceAsync.WithRawResponse = info + + override fun billing(): BillingServiceAsync.WithRawResponse = billing + + override fun businessInfo(): BusinessInfoServiceAsync.WithRawResponse = businessInfo + + override fun roles(): RoleServiceAsync.WithRawResponse = roles + + override fun members(): MemberServiceAsync.WithRawResponse = members + + override fun ssoSettings(): SsoSettingServiceAsync.WithRawResponse = ssoSettings + + override fun user(): UserServiceAsync.WithRawResponse = user + + override fun serviceKeys(): ServiceKeyServiceAsync.WithRawResponse = serviceKeys + + override fun personalAccessTokens(): PersonalAccessTokenServiceAsync.WithRawResponse = + personalAccessTokens + + private val listHandler: Handler<CurrentListResponse> = + jsonHandler<CurrentListResponse>(clientOptions.jsonMapper) + + override fun list( + params: CurrentListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<CurrentListResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val confirmCheckoutSessionCompletionHandler: + Handler<CurrentConfirmCheckoutSessionCompletionResponse> = + jsonHandler<CurrentConfirmCheckoutSessionCompletionResponse>(clientOptions.jsonMapper) + + override fun confirmCheckoutSessionCompletion( + params: CurrentConfirmCheckoutSessionCompletionParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<CurrentConfirmCheckoutSessionCompletionResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "orgs", + "current", + "confirm_checkout_session_completion", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { confirmCheckoutSessionCompletionHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val paymentMethodHandler: Handler<CurrentPaymentMethodResponse> = + jsonHandler<CurrentPaymentMethodResponse>(clientOptions.jsonMapper) + + override fun paymentMethod( + params: CurrentPaymentMethodParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<CurrentPaymentMethodResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "payment-method") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { paymentMethodHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val planHandler: Handler<CurrentPlanResponse> = + jsonHandler<CurrentPlanResponse>(clientOptions.jsonMapper) + + override fun plan( + params: CurrentPlanParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<CurrentPlanResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "plan") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { planHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveDashboardHandler: Handler<CurrentRetrieveDashboardResponse> = + jsonHandler<CurrentRetrieveDashboardResponse>(clientOptions.jsonMapper) + + override fun retrieveDashboard( + params: CurrentRetrieveDashboardParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<CurrentRetrieveDashboardResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "dashboard") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveDashboardHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val setDefaultSsoProvisionHandler: Handler<CurrentSetDefaultSsoProvisionResponse> = + jsonHandler<CurrentSetDefaultSsoProvisionResponse>(clientOptions.jsonMapper) + + override fun setDefaultSsoProvision( + params: CurrentSetDefaultSsoProvisionParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<CurrentSetDefaultSsoProvisionResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "set-default-sso-provision") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { setDefaultSsoProvisionHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val setupHandler: Handler<CurrentSetupResponse> = + jsonHandler<CurrentSetupResponse>(clientOptions.jsonMapper) + + override fun setup( + params: CurrentSetupParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<CurrentSetupResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "setup") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { setupHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val stripeAccountLinksHandler: Handler<CurrentStripeAccountLinksResponse> = + jsonHandler<CurrentStripeAccountLinksResponse>(clientOptions.jsonMapper) + + override fun stripeAccountLinks( + params: CurrentStripeAccountLinksParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<CurrentStripeAccountLinksResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "stripe_account_links") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { stripeAccountLinksHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val stripeCheckoutSessionHandler: Handler<CurrentStripeCheckoutSessionResponse> = + jsonHandler<CurrentStripeCheckoutSessionResponse>(clientOptions.jsonMapper) + + override fun stripeCheckoutSession( + params: CurrentStripeCheckoutSessionParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<CurrentStripeCheckoutSessionResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "stripe_checkout_session") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { stripeCheckoutSessionHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateLoginMethodsHandler: Handler<CurrentUpdateLoginMethodsResponse> = + jsonHandler<CurrentUpdateLoginMethodsResponse>(clientOptions.jsonMapper) + + override fun updateLoginMethods( + params: CurrentUpdateLoginMethodsParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<CurrentUpdateLoginMethodsResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "login-methods") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateLoginMethodsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/MemberServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/MemberServiceAsync.kt new file mode 100644 index 00000000..196f5aa8 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/MemberServiceAsync.kt @@ -0,0 +1,85 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.orgs.members.MemberUpdateBasicParams +import com.langsmith_api.api.models.api.v1.orgs.members.MemberUpdateBasicResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface MemberServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): MemberServiceAsync + + /** Update a user's full_name/password (basic auth only) */ + fun updateBasic(): CompletableFuture<MemberUpdateBasicResponse> = + updateBasic(MemberUpdateBasicParams.none()) + + /** @see updateBasic */ + fun updateBasic( + params: MemberUpdateBasicParams = MemberUpdateBasicParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<MemberUpdateBasicResponse> + + /** @see updateBasic */ + fun updateBasic( + params: MemberUpdateBasicParams = MemberUpdateBasicParams.none() + ): CompletableFuture<MemberUpdateBasicResponse> = updateBasic(params, RequestOptions.none()) + + /** @see updateBasic */ + fun updateBasic(requestOptions: RequestOptions): CompletableFuture<MemberUpdateBasicResponse> = + updateBasic(MemberUpdateBasicParams.none(), requestOptions) + + /** + * A view of [MemberServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): MemberServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `patch /api/v1/orgs/members/basic`, but is otherwise the + * same as [MemberServiceAsync.updateBasic]. + */ + fun updateBasic(): CompletableFuture<HttpResponseFor<MemberUpdateBasicResponse>> = + updateBasic(MemberUpdateBasicParams.none()) + + /** @see updateBasic */ + fun updateBasic( + params: MemberUpdateBasicParams = MemberUpdateBasicParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<MemberUpdateBasicResponse>> + + /** @see updateBasic */ + fun updateBasic( + params: MemberUpdateBasicParams = MemberUpdateBasicParams.none() + ): CompletableFuture<HttpResponseFor<MemberUpdateBasicResponse>> = + updateBasic(params, RequestOptions.none()) + + /** @see updateBasic */ + fun updateBasic( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<MemberUpdateBasicResponse>> = + updateBasic(MemberUpdateBasicParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/MemberServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/MemberServiceAsyncImpl.kt new file mode 100644 index 00000000..99788677 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/MemberServiceAsyncImpl.kt @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.orgs.members.MemberUpdateBasicParams +import com.langsmith_api.api.models.api.v1.orgs.members.MemberUpdateBasicResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class MemberServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + MemberServiceAsync { + + private val withRawResponse: MemberServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): MemberServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): MemberServiceAsync = + MemberServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun updateBasic( + params: MemberUpdateBasicParams, + requestOptions: RequestOptions, + ): CompletableFuture<MemberUpdateBasicResponse> = + // patch /api/v1/orgs/members/basic + withRawResponse().updateBasic(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + MemberServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): MemberServiceAsync.WithRawResponse = + MemberServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val updateBasicHandler: Handler<MemberUpdateBasicResponse> = + jsonHandler<MemberUpdateBasicResponse>(clientOptions.jsonMapper) + + override fun updateBasic( + params: MemberUpdateBasicParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<MemberUpdateBasicResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "members", "basic") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateBasicHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/PendingServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/PendingServiceAsync.kt new file mode 100644 index 00000000..afc6f55d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/PendingServiceAsync.kt @@ -0,0 +1,238 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.orgs.OrganizationPgSchemaSlim +import com.langsmith_api.api.models.api.v1.orgs.pending.Identity +import com.langsmith_api.api.models.api.v1.orgs.pending.PendingClaimParams +import com.langsmith_api.api.models.api.v1.orgs.pending.PendingDeleteParams +import com.langsmith_api.api.models.api.v1.orgs.pending.PendingDeleteResponse +import com.langsmith_api.api.models.api.v1.orgs.pending.PendingListParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface PendingServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): PendingServiceAsync + + /** Get all pending orgs visible to this auth */ + fun list(): CompletableFuture<List<OrganizationPgSchemaSlim>> = list(PendingListParams.none()) + + /** @see list */ + fun list( + params: PendingListParams = PendingListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<OrganizationPgSchemaSlim>> + + /** @see list */ + fun list( + params: PendingListParams = PendingListParams.none() + ): CompletableFuture<List<OrganizationPgSchemaSlim>> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture<List<OrganizationPgSchemaSlim>> = + list(PendingListParams.none(), requestOptions) + + /** Delete Pending Organization Invite */ + fun delete(organizationId: String): CompletableFuture<PendingDeleteResponse> = + delete(organizationId, PendingDeleteParams.none()) + + /** @see delete */ + fun delete( + organizationId: String, + params: PendingDeleteParams = PendingDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<PendingDeleteResponse> = + delete(params.toBuilder().organizationId(organizationId).build(), requestOptions) + + /** @see delete */ + fun delete( + organizationId: String, + params: PendingDeleteParams = PendingDeleteParams.none(), + ): CompletableFuture<PendingDeleteResponse> = + delete(organizationId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: PendingDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<PendingDeleteResponse> + + /** @see delete */ + fun delete(params: PendingDeleteParams): CompletableFuture<PendingDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + organizationId: String, + requestOptions: RequestOptions, + ): CompletableFuture<PendingDeleteResponse> = + delete(organizationId, PendingDeleteParams.none(), requestOptions) + + /** Claim Pending Organization Invite */ + fun claim(organizationId: String): CompletableFuture<Identity> = + claim(organizationId, PendingClaimParams.none()) + + /** @see claim */ + fun claim( + organizationId: String, + params: PendingClaimParams = PendingClaimParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<Identity> = + claim(params.toBuilder().organizationId(organizationId).build(), requestOptions) + + /** @see claim */ + fun claim( + organizationId: String, + params: PendingClaimParams = PendingClaimParams.none(), + ): CompletableFuture<Identity> = claim(organizationId, params, RequestOptions.none()) + + /** @see claim */ + fun claim( + params: PendingClaimParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<Identity> + + /** @see claim */ + fun claim(params: PendingClaimParams): CompletableFuture<Identity> = + claim(params, RequestOptions.none()) + + /** @see claim */ + fun claim(organizationId: String, requestOptions: RequestOptions): CompletableFuture<Identity> = + claim(organizationId, PendingClaimParams.none(), requestOptions) + + /** + * A view of [PendingServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PendingServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/orgs/pending`, but is otherwise the same as + * [PendingServiceAsync.list]. + */ + fun list(): CompletableFuture<HttpResponseFor<List<OrganizationPgSchemaSlim>>> = + list(PendingListParams.none()) + + /** @see list */ + fun list( + params: PendingListParams = PendingListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<OrganizationPgSchemaSlim>>> + + /** @see list */ + fun list( + params: PendingListParams = PendingListParams.none() + ): CompletableFuture<HttpResponseFor<List<OrganizationPgSchemaSlim>>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<OrganizationPgSchemaSlim>>> = + list(PendingListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/orgs/pending/{organization_id}`, but is + * otherwise the same as [PendingServiceAsync.delete]. + */ + fun delete( + organizationId: String + ): CompletableFuture<HttpResponseFor<PendingDeleteResponse>> = + delete(organizationId, PendingDeleteParams.none()) + + /** @see delete */ + fun delete( + organizationId: String, + params: PendingDeleteParams = PendingDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<PendingDeleteResponse>> = + delete(params.toBuilder().organizationId(organizationId).build(), requestOptions) + + /** @see delete */ + fun delete( + organizationId: String, + params: PendingDeleteParams = PendingDeleteParams.none(), + ): CompletableFuture<HttpResponseFor<PendingDeleteResponse>> = + delete(organizationId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: PendingDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<PendingDeleteResponse>> + + /** @see delete */ + fun delete( + params: PendingDeleteParams + ): CompletableFuture<HttpResponseFor<PendingDeleteResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + organizationId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<PendingDeleteResponse>> = + delete(organizationId, PendingDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/orgs/pending/{organization_id}/claim`, but + * is otherwise the same as [PendingServiceAsync.claim]. + */ + fun claim(organizationId: String): CompletableFuture<HttpResponseFor<Identity>> = + claim(organizationId, PendingClaimParams.none()) + + /** @see claim */ + fun claim( + organizationId: String, + params: PendingClaimParams = PendingClaimParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<Identity>> = + claim(params.toBuilder().organizationId(organizationId).build(), requestOptions) + + /** @see claim */ + fun claim( + organizationId: String, + params: PendingClaimParams = PendingClaimParams.none(), + ): CompletableFuture<HttpResponseFor<Identity>> = + claim(organizationId, params, RequestOptions.none()) + + /** @see claim */ + fun claim( + params: PendingClaimParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<Identity>> + + /** @see claim */ + fun claim(params: PendingClaimParams): CompletableFuture<HttpResponseFor<Identity>> = + claim(params, RequestOptions.none()) + + /** @see claim */ + fun claim( + organizationId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<Identity>> = + claim(organizationId, PendingClaimParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/PendingServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/PendingServiceAsyncImpl.kt new file mode 100644 index 00000000..2c4a6aae --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/PendingServiceAsyncImpl.kt @@ -0,0 +1,173 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.orgs.OrganizationPgSchemaSlim +import com.langsmith_api.api.models.api.v1.orgs.pending.Identity +import com.langsmith_api.api.models.api.v1.orgs.pending.PendingClaimParams +import com.langsmith_api.api.models.api.v1.orgs.pending.PendingDeleteParams +import com.langsmith_api.api.models.api.v1.orgs.pending.PendingDeleteResponse +import com.langsmith_api.api.models.api.v1.orgs.pending.PendingListParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class PendingServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + PendingServiceAsync { + + private val withRawResponse: PendingServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): PendingServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): PendingServiceAsync = + PendingServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: PendingListParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<OrganizationPgSchemaSlim>> = + // get /api/v1/orgs/pending + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: PendingDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<PendingDeleteResponse> = + // delete /api/v1/orgs/pending/{organization_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + override fun claim( + params: PendingClaimParams, + requestOptions: RequestOptions, + ): CompletableFuture<Identity> = + // post /api/v1/orgs/pending/{organization_id}/claim + withRawResponse().claim(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + PendingServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PendingServiceAsync.WithRawResponse = + PendingServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler<List<OrganizationPgSchemaSlim>> = + jsonHandler<List<OrganizationPgSchemaSlim>>(clientOptions.jsonMapper) + + override fun list( + params: PendingListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<OrganizationPgSchemaSlim>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "pending") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val deleteHandler: Handler<PendingDeleteResponse> = + jsonHandler<PendingDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: PendingDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<PendingDeleteResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("organizationId", params.organizationId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "pending", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val claimHandler: Handler<Identity> = + jsonHandler<Identity>(clientOptions.jsonMapper) + + override fun claim( + params: PendingClaimParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<Identity>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("organizationId", params.organizationId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "pending", params._pathParam(0), "claim") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { claimHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/TtlSettingServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/TtlSettingServiceAsync.kt new file mode 100644 index 00000000..ee888d21 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/TtlSettingServiceAsync.kt @@ -0,0 +1,151 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TtlSettingRetrieveTtlSettingsParams +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TtlSettingUpdateTtlSettingsParams +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TtlSettings +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.UpsertTtlSettingsRequest +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface TtlSettingServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): TtlSettingServiceAsync + + /** List out the configured TTL settings for a given org (org-level and tenant-level). */ + fun retrieveTtlSettings(): CompletableFuture<List<TtlSettings>> = + retrieveTtlSettings(TtlSettingRetrieveTtlSettingsParams.none()) + + /** @see retrieveTtlSettings */ + fun retrieveTtlSettings( + params: TtlSettingRetrieveTtlSettingsParams = TtlSettingRetrieveTtlSettingsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<TtlSettings>> + + /** @see retrieveTtlSettings */ + fun retrieveTtlSettings( + params: TtlSettingRetrieveTtlSettingsParams = TtlSettingRetrieveTtlSettingsParams.none() + ): CompletableFuture<List<TtlSettings>> = retrieveTtlSettings(params, RequestOptions.none()) + + /** @see retrieveTtlSettings */ + fun retrieveTtlSettings(requestOptions: RequestOptions): CompletableFuture<List<TtlSettings>> = + retrieveTtlSettings(TtlSettingRetrieveTtlSettingsParams.none(), requestOptions) + + /** Upsert Ttl Settings */ + fun updateTtlSettings( + params: TtlSettingUpdateTtlSettingsParams + ): CompletableFuture<TtlSettings> = updateTtlSettings(params, RequestOptions.none()) + + /** @see updateTtlSettings */ + fun updateTtlSettings( + params: TtlSettingUpdateTtlSettingsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<TtlSettings> + + /** @see updateTtlSettings */ + fun updateTtlSettings( + upsertTtlSettingsRequest: UpsertTtlSettingsRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<TtlSettings> = + updateTtlSettings( + TtlSettingUpdateTtlSettingsParams.builder() + .upsertTtlSettingsRequest(upsertTtlSettingsRequest) + .build(), + requestOptions, + ) + + /** @see updateTtlSettings */ + fun updateTtlSettings( + upsertTtlSettingsRequest: UpsertTtlSettingsRequest + ): CompletableFuture<TtlSettings> = + updateTtlSettings(upsertTtlSettingsRequest, RequestOptions.none()) + + /** + * A view of [TtlSettingServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): TtlSettingServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/orgs/ttl-settings`, but is otherwise the + * same as [TtlSettingServiceAsync.retrieveTtlSettings]. + */ + fun retrieveTtlSettings(): CompletableFuture<HttpResponseFor<List<TtlSettings>>> = + retrieveTtlSettings(TtlSettingRetrieveTtlSettingsParams.none()) + + /** @see retrieveTtlSettings */ + fun retrieveTtlSettings( + params: TtlSettingRetrieveTtlSettingsParams = + TtlSettingRetrieveTtlSettingsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<TtlSettings>>> + + /** @see retrieveTtlSettings */ + fun retrieveTtlSettings( + params: TtlSettingRetrieveTtlSettingsParams = TtlSettingRetrieveTtlSettingsParams.none() + ): CompletableFuture<HttpResponseFor<List<TtlSettings>>> = + retrieveTtlSettings(params, RequestOptions.none()) + + /** @see retrieveTtlSettings */ + fun retrieveTtlSettings( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<TtlSettings>>> = + retrieveTtlSettings(TtlSettingRetrieveTtlSettingsParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `put /api/v1/orgs/ttl-settings`, but is otherwise the + * same as [TtlSettingServiceAsync.updateTtlSettings]. + */ + fun updateTtlSettings( + params: TtlSettingUpdateTtlSettingsParams + ): CompletableFuture<HttpResponseFor<TtlSettings>> = + updateTtlSettings(params, RequestOptions.none()) + + /** @see updateTtlSettings */ + fun updateTtlSettings( + params: TtlSettingUpdateTtlSettingsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<TtlSettings>> + + /** @see updateTtlSettings */ + fun updateTtlSettings( + upsertTtlSettingsRequest: UpsertTtlSettingsRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<TtlSettings>> = + updateTtlSettings( + TtlSettingUpdateTtlSettingsParams.builder() + .upsertTtlSettingsRequest(upsertTtlSettingsRequest) + .build(), + requestOptions, + ) + + /** @see updateTtlSettings */ + fun updateTtlSettings( + upsertTtlSettingsRequest: UpsertTtlSettingsRequest + ): CompletableFuture<HttpResponseFor<TtlSettings>> = + updateTtlSettings(upsertTtlSettingsRequest, RequestOptions.none()) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/TtlSettingServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/TtlSettingServiceAsyncImpl.kt new file mode 100644 index 00000000..16f83239 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/TtlSettingServiceAsyncImpl.kt @@ -0,0 +1,124 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TtlSettingRetrieveTtlSettingsParams +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TtlSettingUpdateTtlSettingsParams +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TtlSettings +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class TtlSettingServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + TtlSettingServiceAsync { + + private val withRawResponse: TtlSettingServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): TtlSettingServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): TtlSettingServiceAsync = + TtlSettingServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieveTtlSettings( + params: TtlSettingRetrieveTtlSettingsParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<TtlSettings>> = + // get /api/v1/orgs/ttl-settings + withRawResponse().retrieveTtlSettings(params, requestOptions).thenApply { it.parse() } + + override fun updateTtlSettings( + params: TtlSettingUpdateTtlSettingsParams, + requestOptions: RequestOptions, + ): CompletableFuture<TtlSettings> = + // put /api/v1/orgs/ttl-settings + withRawResponse().updateTtlSettings(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TtlSettingServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): TtlSettingServiceAsync.WithRawResponse = + TtlSettingServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveTtlSettingsHandler: Handler<List<TtlSettings>> = + jsonHandler<List<TtlSettings>>(clientOptions.jsonMapper) + + override fun retrieveTtlSettings( + params: TtlSettingRetrieveTtlSettingsParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<TtlSettings>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "ttl-settings") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveTtlSettingsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val updateTtlSettingsHandler: Handler<TtlSettings> = + jsonHandler<TtlSettings>(clientOptions.jsonMapper) + + override fun updateTtlSettings( + params: TtlSettingUpdateTtlSettingsParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<TtlSettings>> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "ttl-settings") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateTtlSettingsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/BillingServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/BillingServiceAsync.kt new file mode 100644 index 00000000..fd9dd390 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/BillingServiceAsync.kt @@ -0,0 +1,113 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.orgs.current.billing.BillingListParams +import com.langsmith_api.api.models.api.v1.orgs.current.billing.BillingListResponse +import com.langsmith_api.api.models.api.v1.orgs.current.billing.BillingRetrieveUsageParams +import com.langsmith_api.api.models.api.v1.orgs.current.billing.BillingRetrieveUsageResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface BillingServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): BillingServiceAsync + + /** Get Organization Billing Info */ + fun list(): CompletableFuture<BillingListResponse> = list(BillingListParams.none()) + + /** @see list */ + fun list( + params: BillingListParams = BillingListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<BillingListResponse> + + /** @see list */ + fun list( + params: BillingListParams = BillingListParams.none() + ): CompletableFuture<BillingListResponse> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture<BillingListResponse> = + list(BillingListParams.none(), requestOptions) + + /** Get Org Usage */ + fun retrieveUsage( + params: BillingRetrieveUsageParams + ): CompletableFuture<List<BillingRetrieveUsageResponse>> = + retrieveUsage(params, RequestOptions.none()) + + /** @see retrieveUsage */ + fun retrieveUsage( + params: BillingRetrieveUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<BillingRetrieveUsageResponse>> + + /** + * A view of [BillingServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): BillingServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/orgs/current/billing`, but is otherwise the + * same as [BillingServiceAsync.list]. + */ + fun list(): CompletableFuture<HttpResponseFor<BillingListResponse>> = + list(BillingListParams.none()) + + /** @see list */ + fun list( + params: BillingListParams = BillingListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<BillingListResponse>> + + /** @see list */ + fun list( + params: BillingListParams = BillingListParams.none() + ): CompletableFuture<HttpResponseFor<BillingListResponse>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<BillingListResponse>> = + list(BillingListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/orgs/current/billing/usage`, but is + * otherwise the same as [BillingServiceAsync.retrieveUsage]. + */ + fun retrieveUsage( + params: BillingRetrieveUsageParams + ): CompletableFuture<HttpResponseFor<List<BillingRetrieveUsageResponse>>> = + retrieveUsage(params, RequestOptions.none()) + + /** @see retrieveUsage */ + fun retrieveUsage( + params: BillingRetrieveUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<BillingRetrieveUsageResponse>>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/BillingServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/BillingServiceAsyncImpl.kt new file mode 100644 index 00000000..5533c1dc --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/BillingServiceAsyncImpl.kt @@ -0,0 +1,123 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.orgs.current.billing.BillingListParams +import com.langsmith_api.api.models.api.v1.orgs.current.billing.BillingListResponse +import com.langsmith_api.api.models.api.v1.orgs.current.billing.BillingRetrieveUsageParams +import com.langsmith_api.api.models.api.v1.orgs.current.billing.BillingRetrieveUsageResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class BillingServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + BillingServiceAsync { + + private val withRawResponse: BillingServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): BillingServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): BillingServiceAsync = + BillingServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: BillingListParams, + requestOptions: RequestOptions, + ): CompletableFuture<BillingListResponse> = + // get /api/v1/orgs/current/billing + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun retrieveUsage( + params: BillingRetrieveUsageParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<BillingRetrieveUsageResponse>> = + // get /api/v1/orgs/current/billing/usage + withRawResponse().retrieveUsage(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BillingServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): BillingServiceAsync.WithRawResponse = + BillingServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler<BillingListResponse> = + jsonHandler<BillingListResponse>(clientOptions.jsonMapper) + + override fun list( + params: BillingListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<BillingListResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "billing") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveUsageHandler: Handler<List<BillingRetrieveUsageResponse>> = + jsonHandler<List<BillingRetrieveUsageResponse>>(clientOptions.jsonMapper) + + override fun retrieveUsage( + params: BillingRetrieveUsageParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<BillingRetrieveUsageResponse>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "billing", "usage") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveUsageHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/BusinessInfoServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/BusinessInfoServiceAsync.kt new file mode 100644 index 00000000..16d80860 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/BusinessInfoServiceAsync.kt @@ -0,0 +1,143 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.orgs.current.businessinfo.BusinessInfoBusinessInfoParams +import com.langsmith_api.api.models.api.v1.orgs.current.businessinfo.BusinessInfoBusinessInfoResponse +import com.langsmith_api.api.models.api.v1.orgs.current.businessinfo.BusinessInfoRetrieveBusinessInfoParams +import com.langsmith_api.api.models.api.v1.orgs.current.businessinfo.BusinessInfoRetrieveBusinessInfoResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface BusinessInfoServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): BusinessInfoServiceAsync + + /** Set Company Info */ + fun businessInfo(): CompletableFuture<BusinessInfoBusinessInfoResponse> = + businessInfo(BusinessInfoBusinessInfoParams.none()) + + /** @see businessInfo */ + fun businessInfo( + params: BusinessInfoBusinessInfoParams = BusinessInfoBusinessInfoParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<BusinessInfoBusinessInfoResponse> + + /** @see businessInfo */ + fun businessInfo( + params: BusinessInfoBusinessInfoParams = BusinessInfoBusinessInfoParams.none() + ): CompletableFuture<BusinessInfoBusinessInfoResponse> = + businessInfo(params, RequestOptions.none()) + + /** @see businessInfo */ + fun businessInfo( + requestOptions: RequestOptions + ): CompletableFuture<BusinessInfoBusinessInfoResponse> = + businessInfo(BusinessInfoBusinessInfoParams.none(), requestOptions) + + /** Get Company Info */ + fun retrieveBusinessInfo(): CompletableFuture<BusinessInfoRetrieveBusinessInfoResponse> = + retrieveBusinessInfo(BusinessInfoRetrieveBusinessInfoParams.none()) + + /** @see retrieveBusinessInfo */ + fun retrieveBusinessInfo( + params: BusinessInfoRetrieveBusinessInfoParams = + BusinessInfoRetrieveBusinessInfoParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<BusinessInfoRetrieveBusinessInfoResponse> + + /** @see retrieveBusinessInfo */ + fun retrieveBusinessInfo( + params: BusinessInfoRetrieveBusinessInfoParams = + BusinessInfoRetrieveBusinessInfoParams.none() + ): CompletableFuture<BusinessInfoRetrieveBusinessInfoResponse> = + retrieveBusinessInfo(params, RequestOptions.none()) + + /** @see retrieveBusinessInfo */ + fun retrieveBusinessInfo( + requestOptions: RequestOptions + ): CompletableFuture<BusinessInfoRetrieveBusinessInfoResponse> = + retrieveBusinessInfo(BusinessInfoRetrieveBusinessInfoParams.none(), requestOptions) + + /** + * A view of [BusinessInfoServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): BusinessInfoServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/orgs/current/business-info`, but is + * otherwise the same as [BusinessInfoServiceAsync.businessInfo]. + */ + fun businessInfo(): CompletableFuture<HttpResponseFor<BusinessInfoBusinessInfoResponse>> = + businessInfo(BusinessInfoBusinessInfoParams.none()) + + /** @see businessInfo */ + fun businessInfo( + params: BusinessInfoBusinessInfoParams = BusinessInfoBusinessInfoParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<BusinessInfoBusinessInfoResponse>> + + /** @see businessInfo */ + fun businessInfo( + params: BusinessInfoBusinessInfoParams = BusinessInfoBusinessInfoParams.none() + ): CompletableFuture<HttpResponseFor<BusinessInfoBusinessInfoResponse>> = + businessInfo(params, RequestOptions.none()) + + /** @see businessInfo */ + fun businessInfo( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<BusinessInfoBusinessInfoResponse>> = + businessInfo(BusinessInfoBusinessInfoParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/orgs/current/business-info`, but is + * otherwise the same as [BusinessInfoServiceAsync.retrieveBusinessInfo]. + */ + fun retrieveBusinessInfo(): + CompletableFuture<HttpResponseFor<BusinessInfoRetrieveBusinessInfoResponse>> = + retrieveBusinessInfo(BusinessInfoRetrieveBusinessInfoParams.none()) + + /** @see retrieveBusinessInfo */ + fun retrieveBusinessInfo( + params: BusinessInfoRetrieveBusinessInfoParams = + BusinessInfoRetrieveBusinessInfoParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<BusinessInfoRetrieveBusinessInfoResponse>> + + /** @see retrieveBusinessInfo */ + fun retrieveBusinessInfo( + params: BusinessInfoRetrieveBusinessInfoParams = + BusinessInfoRetrieveBusinessInfoParams.none() + ): CompletableFuture<HttpResponseFor<BusinessInfoRetrieveBusinessInfoResponse>> = + retrieveBusinessInfo(params, RequestOptions.none()) + + /** @see retrieveBusinessInfo */ + fun retrieveBusinessInfo( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<BusinessInfoRetrieveBusinessInfoResponse>> = + retrieveBusinessInfo(BusinessInfoRetrieveBusinessInfoParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/BusinessInfoServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/BusinessInfoServiceAsyncImpl.kt new file mode 100644 index 00000000..382cf58f --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/BusinessInfoServiceAsyncImpl.kt @@ -0,0 +1,125 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.orgs.current.businessinfo.BusinessInfoBusinessInfoParams +import com.langsmith_api.api.models.api.v1.orgs.current.businessinfo.BusinessInfoBusinessInfoResponse +import com.langsmith_api.api.models.api.v1.orgs.current.businessinfo.BusinessInfoRetrieveBusinessInfoParams +import com.langsmith_api.api.models.api.v1.orgs.current.businessinfo.BusinessInfoRetrieveBusinessInfoResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class BusinessInfoServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + BusinessInfoServiceAsync { + + private val withRawResponse: BusinessInfoServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): BusinessInfoServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): BusinessInfoServiceAsync = + BusinessInfoServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun businessInfo( + params: BusinessInfoBusinessInfoParams, + requestOptions: RequestOptions, + ): CompletableFuture<BusinessInfoBusinessInfoResponse> = + // post /api/v1/orgs/current/business-info + withRawResponse().businessInfo(params, requestOptions).thenApply { it.parse() } + + override fun retrieveBusinessInfo( + params: BusinessInfoRetrieveBusinessInfoParams, + requestOptions: RequestOptions, + ): CompletableFuture<BusinessInfoRetrieveBusinessInfoResponse> = + // get /api/v1/orgs/current/business-info + withRawResponse().retrieveBusinessInfo(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BusinessInfoServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): BusinessInfoServiceAsync.WithRawResponse = + BusinessInfoServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val businessInfoHandler: Handler<BusinessInfoBusinessInfoResponse> = + jsonHandler<BusinessInfoBusinessInfoResponse>(clientOptions.jsonMapper) + + override fun businessInfo( + params: BusinessInfoBusinessInfoParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<BusinessInfoBusinessInfoResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "business-info") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { businessInfoHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveBusinessInfoHandler: Handler<BusinessInfoRetrieveBusinessInfoResponse> = + jsonHandler<BusinessInfoRetrieveBusinessInfoResponse>(clientOptions.jsonMapper) + + override fun retrieveBusinessInfo( + params: BusinessInfoRetrieveBusinessInfoParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<BusinessInfoRetrieveBusinessInfoResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "business-info") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveBusinessInfoHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/InfoServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/InfoServiceAsync.kt new file mode 100644 index 00000000..c0e60384 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/InfoServiceAsync.kt @@ -0,0 +1,123 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.orgs.current.info.InfoListParams +import com.langsmith_api.api.models.api.v1.orgs.current.info.InfoPatchAllParams +import com.langsmith_api.api.models.api.v1.orgs.current.info.OrganizationInfo +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface InfoServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): InfoServiceAsync + + /** Get Current Organization Info */ + fun list(): CompletableFuture<OrganizationInfo> = list(InfoListParams.none()) + + /** @see list */ + fun list( + params: InfoListParams = InfoListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<OrganizationInfo> + + /** @see list */ + fun list(params: InfoListParams = InfoListParams.none()): CompletableFuture<OrganizationInfo> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture<OrganizationInfo> = + list(InfoListParams.none(), requestOptions) + + /** Update Current Organization Info */ + fun patchAll(): CompletableFuture<OrganizationInfo> = patchAll(InfoPatchAllParams.none()) + + /** @see patchAll */ + fun patchAll( + params: InfoPatchAllParams = InfoPatchAllParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<OrganizationInfo> + + /** @see patchAll */ + fun patchAll( + params: InfoPatchAllParams = InfoPatchAllParams.none() + ): CompletableFuture<OrganizationInfo> = patchAll(params, RequestOptions.none()) + + /** @see patchAll */ + fun patchAll(requestOptions: RequestOptions): CompletableFuture<OrganizationInfo> = + patchAll(InfoPatchAllParams.none(), requestOptions) + + /** A view of [InfoServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): InfoServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/orgs/current/info`, but is otherwise the + * same as [InfoServiceAsync.list]. + */ + fun list(): CompletableFuture<HttpResponseFor<OrganizationInfo>> = + list(InfoListParams.none()) + + /** @see list */ + fun list( + params: InfoListParams = InfoListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<OrganizationInfo>> + + /** @see list */ + fun list( + params: InfoListParams = InfoListParams.none() + ): CompletableFuture<HttpResponseFor<OrganizationInfo>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<OrganizationInfo>> = + list(InfoListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `patch /api/v1/orgs/current/info`, but is otherwise the + * same as [InfoServiceAsync.patchAll]. + */ + fun patchAll(): CompletableFuture<HttpResponseFor<OrganizationInfo>> = + patchAll(InfoPatchAllParams.none()) + + /** @see patchAll */ + fun patchAll( + params: InfoPatchAllParams = InfoPatchAllParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<OrganizationInfo>> + + /** @see patchAll */ + fun patchAll( + params: InfoPatchAllParams = InfoPatchAllParams.none() + ): CompletableFuture<HttpResponseFor<OrganizationInfo>> = + patchAll(params, RequestOptions.none()) + + /** @see patchAll */ + fun patchAll( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<OrganizationInfo>> = + patchAll(InfoPatchAllParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/InfoServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/InfoServiceAsyncImpl.kt new file mode 100644 index 00000000..715cd7ab --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/InfoServiceAsyncImpl.kt @@ -0,0 +1,124 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.orgs.current.info.InfoListParams +import com.langsmith_api.api.models.api.v1.orgs.current.info.InfoPatchAllParams +import com.langsmith_api.api.models.api.v1.orgs.current.info.OrganizationInfo +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class InfoServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + InfoServiceAsync { + + private val withRawResponse: InfoServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): InfoServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): InfoServiceAsync = + InfoServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: InfoListParams, + requestOptions: RequestOptions, + ): CompletableFuture<OrganizationInfo> = + // get /api/v1/orgs/current/info + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun patchAll( + params: InfoPatchAllParams, + requestOptions: RequestOptions, + ): CompletableFuture<OrganizationInfo> = + // patch /api/v1/orgs/current/info + withRawResponse().patchAll(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + InfoServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): InfoServiceAsync.WithRawResponse = + InfoServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler<OrganizationInfo> = + jsonHandler<OrganizationInfo>(clientOptions.jsonMapper) + + override fun list( + params: InfoListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<OrganizationInfo>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "info") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val patchAllHandler: Handler<OrganizationInfo> = + jsonHandler<OrganizationInfo>(clientOptions.jsonMapper) + + override fun patchAll( + params: InfoPatchAllParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<OrganizationInfo>> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "info") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { patchAllHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/MemberServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/MemberServiceAsync.kt new file mode 100644 index 00000000..72e48630 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/MemberServiceAsync.kt @@ -0,0 +1,382 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberBatchParams +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberCreateParams +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberDeleteParams +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberDeleteResponse +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberListParams +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberListResponse +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberRetrieveActiveParams +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberUpdateParams +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberUpdateResponse +import com.langsmith_api.api.models.api.v1.orgs.current.members.OrgMemberIdentity +import com.langsmith_api.api.models.api.v1.orgs.current.members.PendingIdentity +import com.langsmith_api.api.models.api.v1.orgs.current.members.PendingIdentityCreate +import com.langsmith_api.api.services.async.api.v1.orgs.current.members.BasicServiceAsync +import com.langsmith_api.api.services.async.api.v1.orgs.current.members.PendingServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface MemberServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): MemberServiceAsync + + fun pending(): PendingServiceAsync + + fun basic(): BasicServiceAsync + + /** Add Member To Current Org */ + fun create(params: MemberCreateParams): CompletableFuture<PendingIdentity> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: MemberCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<PendingIdentity> + + /** @see create */ + fun create( + pendingIdentityCreate: PendingIdentityCreate, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<PendingIdentity> = + create( + MemberCreateParams.builder().pendingIdentityCreate(pendingIdentityCreate).build(), + requestOptions, + ) + + /** @see create */ + fun create(pendingIdentityCreate: PendingIdentityCreate): CompletableFuture<PendingIdentity> = + create(pendingIdentityCreate, RequestOptions.none()) + + /** + * This is used for updating a user's role (all auth modes) or full_name/password (basic auth) + */ + fun update(identityId: String): CompletableFuture<MemberUpdateResponse> = + update(identityId, MemberUpdateParams.none()) + + /** @see update */ + fun update( + identityId: String, + params: MemberUpdateParams = MemberUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<MemberUpdateResponse> = + update(params.toBuilder().identityId(identityId).build(), requestOptions) + + /** @see update */ + fun update( + identityId: String, + params: MemberUpdateParams = MemberUpdateParams.none(), + ): CompletableFuture<MemberUpdateResponse> = update(identityId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: MemberUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<MemberUpdateResponse> + + /** @see update */ + fun update(params: MemberUpdateParams): CompletableFuture<MemberUpdateResponse> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + identityId: String, + requestOptions: RequestOptions, + ): CompletableFuture<MemberUpdateResponse> = + update(identityId, MemberUpdateParams.none(), requestOptions) + + /** Get Current Org Members */ + fun list(): CompletableFuture<MemberListResponse> = list(MemberListParams.none()) + + /** @see list */ + fun list( + params: MemberListParams = MemberListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<MemberListResponse> + + /** @see list */ + fun list( + params: MemberListParams = MemberListParams.none() + ): CompletableFuture<MemberListResponse> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture<MemberListResponse> = + list(MemberListParams.none(), requestOptions) + + /** Remove a user from the current organization. */ + fun delete(identityId: String): CompletableFuture<MemberDeleteResponse> = + delete(identityId, MemberDeleteParams.none()) + + /** @see delete */ + fun delete( + identityId: String, + params: MemberDeleteParams = MemberDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<MemberDeleteResponse> = + delete(params.toBuilder().identityId(identityId).build(), requestOptions) + + /** @see delete */ + fun delete( + identityId: String, + params: MemberDeleteParams = MemberDeleteParams.none(), + ): CompletableFuture<MemberDeleteResponse> = delete(identityId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: MemberDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<MemberDeleteResponse> + + /** @see delete */ + fun delete(params: MemberDeleteParams): CompletableFuture<MemberDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + identityId: String, + requestOptions: RequestOptions, + ): CompletableFuture<MemberDeleteResponse> = + delete(identityId, MemberDeleteParams.none(), requestOptions) + + /** Batch invite up to 500 users to the current org. */ + fun batch(params: MemberBatchParams): CompletableFuture<List<PendingIdentity>> = + batch(params, RequestOptions.none()) + + /** @see batch */ + fun batch( + params: MemberBatchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<PendingIdentity>> + + /** Get Current Active Org Members */ + fun retrieveActive(): CompletableFuture<List<OrgMemberIdentity>> = + retrieveActive(MemberRetrieveActiveParams.none()) + + /** @see retrieveActive */ + fun retrieveActive( + params: MemberRetrieveActiveParams = MemberRetrieveActiveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<OrgMemberIdentity>> + + /** @see retrieveActive */ + fun retrieveActive( + params: MemberRetrieveActiveParams = MemberRetrieveActiveParams.none() + ): CompletableFuture<List<OrgMemberIdentity>> = retrieveActive(params, RequestOptions.none()) + + /** @see retrieveActive */ + fun retrieveActive(requestOptions: RequestOptions): CompletableFuture<List<OrgMemberIdentity>> = + retrieveActive(MemberRetrieveActiveParams.none(), requestOptions) + + /** + * A view of [MemberServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): MemberServiceAsync.WithRawResponse + + fun pending(): PendingServiceAsync.WithRawResponse + + fun basic(): BasicServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/orgs/current/members`, but is otherwise the + * same as [MemberServiceAsync.create]. + */ + fun create( + params: MemberCreateParams + ): CompletableFuture<HttpResponseFor<PendingIdentity>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: MemberCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<PendingIdentity>> + + /** @see create */ + fun create( + pendingIdentityCreate: PendingIdentityCreate, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<PendingIdentity>> = + create( + MemberCreateParams.builder().pendingIdentityCreate(pendingIdentityCreate).build(), + requestOptions, + ) + + /** @see create */ + fun create( + pendingIdentityCreate: PendingIdentityCreate + ): CompletableFuture<HttpResponseFor<PendingIdentity>> = + create(pendingIdentityCreate, RequestOptions.none()) + + /** + * Returns a raw HTTP response for `patch /api/v1/orgs/current/members/{identity_id}`, but + * is otherwise the same as [MemberServiceAsync.update]. + */ + fun update(identityId: String): CompletableFuture<HttpResponseFor<MemberUpdateResponse>> = + update(identityId, MemberUpdateParams.none()) + + /** @see update */ + fun update( + identityId: String, + params: MemberUpdateParams = MemberUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<MemberUpdateResponse>> = + update(params.toBuilder().identityId(identityId).build(), requestOptions) + + /** @see update */ + fun update( + identityId: String, + params: MemberUpdateParams = MemberUpdateParams.none(), + ): CompletableFuture<HttpResponseFor<MemberUpdateResponse>> = + update(identityId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: MemberUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<MemberUpdateResponse>> + + /** @see update */ + fun update( + params: MemberUpdateParams + ): CompletableFuture<HttpResponseFor<MemberUpdateResponse>> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + identityId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<MemberUpdateResponse>> = + update(identityId, MemberUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/orgs/current/members`, but is otherwise the + * same as [MemberServiceAsync.list]. + */ + fun list(): CompletableFuture<HttpResponseFor<MemberListResponse>> = + list(MemberListParams.none()) + + /** @see list */ + fun list( + params: MemberListParams = MemberListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<MemberListResponse>> + + /** @see list */ + fun list( + params: MemberListParams = MemberListParams.none() + ): CompletableFuture<HttpResponseFor<MemberListResponse>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<MemberListResponse>> = + list(MemberListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/orgs/current/members/{identity_id}`, but + * is otherwise the same as [MemberServiceAsync.delete]. + */ + fun delete(identityId: String): CompletableFuture<HttpResponseFor<MemberDeleteResponse>> = + delete(identityId, MemberDeleteParams.none()) + + /** @see delete */ + fun delete( + identityId: String, + params: MemberDeleteParams = MemberDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<MemberDeleteResponse>> = + delete(params.toBuilder().identityId(identityId).build(), requestOptions) + + /** @see delete */ + fun delete( + identityId: String, + params: MemberDeleteParams = MemberDeleteParams.none(), + ): CompletableFuture<HttpResponseFor<MemberDeleteResponse>> = + delete(identityId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: MemberDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<MemberDeleteResponse>> + + /** @see delete */ + fun delete( + params: MemberDeleteParams + ): CompletableFuture<HttpResponseFor<MemberDeleteResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + identityId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<MemberDeleteResponse>> = + delete(identityId, MemberDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/orgs/current/members/batch`, but is + * otherwise the same as [MemberServiceAsync.batch]. + */ + fun batch( + params: MemberBatchParams + ): CompletableFuture<HttpResponseFor<List<PendingIdentity>>> = + batch(params, RequestOptions.none()) + + /** @see batch */ + fun batch( + params: MemberBatchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<PendingIdentity>>> + + /** + * Returns a raw HTTP response for `get /api/v1/orgs/current/members/active`, but is + * otherwise the same as [MemberServiceAsync.retrieveActive]. + */ + fun retrieveActive(): CompletableFuture<HttpResponseFor<List<OrgMemberIdentity>>> = + retrieveActive(MemberRetrieveActiveParams.none()) + + /** @see retrieveActive */ + fun retrieveActive( + params: MemberRetrieveActiveParams = MemberRetrieveActiveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<OrgMemberIdentity>>> + + /** @see retrieveActive */ + fun retrieveActive( + params: MemberRetrieveActiveParams = MemberRetrieveActiveParams.none() + ): CompletableFuture<HttpResponseFor<List<OrgMemberIdentity>>> = + retrieveActive(params, RequestOptions.none()) + + /** @see retrieveActive */ + fun retrieveActive( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<OrgMemberIdentity>>> = + retrieveActive(MemberRetrieveActiveParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/MemberServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/MemberServiceAsyncImpl.kt new file mode 100644 index 00000000..38eec24b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/MemberServiceAsyncImpl.kt @@ -0,0 +1,329 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberBatchParams +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberCreateParams +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberDeleteParams +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberDeleteResponse +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberListParams +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberListResponse +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberRetrieveActiveParams +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberUpdateParams +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberUpdateResponse +import com.langsmith_api.api.models.api.v1.orgs.current.members.OrgMemberIdentity +import com.langsmith_api.api.models.api.v1.orgs.current.members.PendingIdentity +import com.langsmith_api.api.services.async.api.v1.orgs.current.members.BasicServiceAsync +import com.langsmith_api.api.services.async.api.v1.orgs.current.members.BasicServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.orgs.current.members.PendingServiceAsync +import com.langsmith_api.api.services.async.api.v1.orgs.current.members.PendingServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class MemberServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + MemberServiceAsync { + + private val withRawResponse: MemberServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val pending: PendingServiceAsync by lazy { PendingServiceAsyncImpl(clientOptions) } + + private val basic: BasicServiceAsync by lazy { BasicServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): MemberServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): MemberServiceAsync = + MemberServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun pending(): PendingServiceAsync = pending + + override fun basic(): BasicServiceAsync = basic + + override fun create( + params: MemberCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<PendingIdentity> = + // post /api/v1/orgs/current/members + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: MemberUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<MemberUpdateResponse> = + // patch /api/v1/orgs/current/members/{identity_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: MemberListParams, + requestOptions: RequestOptions, + ): CompletableFuture<MemberListResponse> = + // get /api/v1/orgs/current/members + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: MemberDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<MemberDeleteResponse> = + // delete /api/v1/orgs/current/members/{identity_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + override fun batch( + params: MemberBatchParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<PendingIdentity>> = + // post /api/v1/orgs/current/members/batch + withRawResponse().batch(params, requestOptions).thenApply { it.parse() } + + override fun retrieveActive( + params: MemberRetrieveActiveParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<OrgMemberIdentity>> = + // get /api/v1/orgs/current/members/active + withRawResponse().retrieveActive(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + MemberServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val pending: PendingServiceAsync.WithRawResponse by lazy { + PendingServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val basic: BasicServiceAsync.WithRawResponse by lazy { + BasicServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): MemberServiceAsync.WithRawResponse = + MemberServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun pending(): PendingServiceAsync.WithRawResponse = pending + + override fun basic(): BasicServiceAsync.WithRawResponse = basic + + private val createHandler: Handler<PendingIdentity> = + jsonHandler<PendingIdentity>(clientOptions.jsonMapper) + + override fun create( + params: MemberCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<PendingIdentity>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "members") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler<MemberUpdateResponse> = + jsonHandler<MemberUpdateResponse>(clientOptions.jsonMapper) + + override fun update( + params: MemberUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<MemberUpdateResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("identityId", params.identityId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "orgs", + "current", + "members", + params._pathParam(0), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler<MemberListResponse> = + jsonHandler<MemberListResponse>(clientOptions.jsonMapper) + + override fun list( + params: MemberListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<MemberListResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "members") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val deleteHandler: Handler<MemberDeleteResponse> = + jsonHandler<MemberDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: MemberDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<MemberDeleteResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("identityId", params.identityId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "orgs", + "current", + "members", + params._pathParam(0), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val batchHandler: Handler<List<PendingIdentity>> = + jsonHandler<List<PendingIdentity>>(clientOptions.jsonMapper) + + override fun batch( + params: MemberBatchParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<PendingIdentity>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "members", "batch") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { batchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val retrieveActiveHandler: Handler<List<OrgMemberIdentity>> = + jsonHandler<List<OrgMemberIdentity>>(clientOptions.jsonMapper) + + override fun retrieveActive( + params: MemberRetrieveActiveParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<OrgMemberIdentity>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "members", "active") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveActiveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/PersonalAccessTokenServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/PersonalAccessTokenServiceAsync.kt new file mode 100644 index 00000000..e5e7b8fe --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/PersonalAccessTokenServiceAsync.kt @@ -0,0 +1,245 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.orgs.current.personalaccesstokens.PersonalAccessTokenDeleteParams +import com.langsmith_api.api.models.api.v1.orgs.current.personalaccesstokens.PersonalAccessTokenPersonalAccessTokensParams +import com.langsmith_api.api.models.api.v1.orgs.current.personalaccesstokens.PersonalAccessTokenRetrievePersonalAccessTokensParams +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyCreateRequest +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyCreateResponse +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyGetResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface PersonalAccessTokenServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): PersonalAccessTokenServiceAsync + + /** Delete Org Personal Access Token */ + fun delete(patId: String): CompletableFuture<ApiKeyGetResponse> = + delete(patId, PersonalAccessTokenDeleteParams.none()) + + /** @see delete */ + fun delete( + patId: String, + params: PersonalAccessTokenDeleteParams = PersonalAccessTokenDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ApiKeyGetResponse> = + delete(params.toBuilder().patId(patId).build(), requestOptions) + + /** @see delete */ + fun delete( + patId: String, + params: PersonalAccessTokenDeleteParams = PersonalAccessTokenDeleteParams.none(), + ): CompletableFuture<ApiKeyGetResponse> = delete(patId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: PersonalAccessTokenDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ApiKeyGetResponse> + + /** @see delete */ + fun delete(params: PersonalAccessTokenDeleteParams): CompletableFuture<ApiKeyGetResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + patId: String, + requestOptions: RequestOptions, + ): CompletableFuture<ApiKeyGetResponse> = + delete(patId, PersonalAccessTokenDeleteParams.none(), requestOptions) + + /** Create Org Personal Access Token */ + fun personalAccessTokens( + params: PersonalAccessTokenPersonalAccessTokensParams + ): CompletableFuture<ApiKeyCreateResponse> = personalAccessTokens(params, RequestOptions.none()) + + /** @see personalAccessTokens */ + fun personalAccessTokens( + params: PersonalAccessTokenPersonalAccessTokensParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ApiKeyCreateResponse> + + /** @see personalAccessTokens */ + fun personalAccessTokens( + apiKeyCreateRequest: ApiKeyCreateRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ApiKeyCreateResponse> = + personalAccessTokens( + PersonalAccessTokenPersonalAccessTokensParams.builder() + .apiKeyCreateRequest(apiKeyCreateRequest) + .build(), + requestOptions, + ) + + /** @see personalAccessTokens */ + fun personalAccessTokens( + apiKeyCreateRequest: ApiKeyCreateRequest + ): CompletableFuture<ApiKeyCreateResponse> = + personalAccessTokens(apiKeyCreateRequest, RequestOptions.none()) + + /** List Org Personal Access Tokens */ + fun retrievePersonalAccessTokens(): CompletableFuture<List<ApiKeyGetResponse>> = + retrievePersonalAccessTokens(PersonalAccessTokenRetrievePersonalAccessTokensParams.none()) + + /** @see retrievePersonalAccessTokens */ + fun retrievePersonalAccessTokens( + params: PersonalAccessTokenRetrievePersonalAccessTokensParams = + PersonalAccessTokenRetrievePersonalAccessTokensParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<ApiKeyGetResponse>> + + /** @see retrievePersonalAccessTokens */ + fun retrievePersonalAccessTokens( + params: PersonalAccessTokenRetrievePersonalAccessTokensParams = + PersonalAccessTokenRetrievePersonalAccessTokensParams.none() + ): CompletableFuture<List<ApiKeyGetResponse>> = + retrievePersonalAccessTokens(params, RequestOptions.none()) + + /** @see retrievePersonalAccessTokens */ + fun retrievePersonalAccessTokens( + requestOptions: RequestOptions + ): CompletableFuture<List<ApiKeyGetResponse>> = + retrievePersonalAccessTokens( + PersonalAccessTokenRetrievePersonalAccessTokensParams.none(), + requestOptions, + ) + + /** + * A view of [PersonalAccessTokenServiceAsync] that provides access to raw HTTP responses for + * each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PersonalAccessTokenServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `delete + * /api/v1/orgs/current/personal-access-tokens/{pat_id}`, but is otherwise the same as + * [PersonalAccessTokenServiceAsync.delete]. + */ + fun delete(patId: String): CompletableFuture<HttpResponseFor<ApiKeyGetResponse>> = + delete(patId, PersonalAccessTokenDeleteParams.none()) + + /** @see delete */ + fun delete( + patId: String, + params: PersonalAccessTokenDeleteParams = PersonalAccessTokenDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ApiKeyGetResponse>> = + delete(params.toBuilder().patId(patId).build(), requestOptions) + + /** @see delete */ + fun delete( + patId: String, + params: PersonalAccessTokenDeleteParams = PersonalAccessTokenDeleteParams.none(), + ): CompletableFuture<HttpResponseFor<ApiKeyGetResponse>> = + delete(patId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: PersonalAccessTokenDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ApiKeyGetResponse>> + + /** @see delete */ + fun delete( + params: PersonalAccessTokenDeleteParams + ): CompletableFuture<HttpResponseFor<ApiKeyGetResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + patId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ApiKeyGetResponse>> = + delete(patId, PersonalAccessTokenDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/orgs/current/personal-access-tokens`, but + * is otherwise the same as [PersonalAccessTokenServiceAsync.personalAccessTokens]. + */ + fun personalAccessTokens( + params: PersonalAccessTokenPersonalAccessTokensParams + ): CompletableFuture<HttpResponseFor<ApiKeyCreateResponse>> = + personalAccessTokens(params, RequestOptions.none()) + + /** @see personalAccessTokens */ + fun personalAccessTokens( + params: PersonalAccessTokenPersonalAccessTokensParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ApiKeyCreateResponse>> + + /** @see personalAccessTokens */ + fun personalAccessTokens( + apiKeyCreateRequest: ApiKeyCreateRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ApiKeyCreateResponse>> = + personalAccessTokens( + PersonalAccessTokenPersonalAccessTokensParams.builder() + .apiKeyCreateRequest(apiKeyCreateRequest) + .build(), + requestOptions, + ) + + /** @see personalAccessTokens */ + fun personalAccessTokens( + apiKeyCreateRequest: ApiKeyCreateRequest + ): CompletableFuture<HttpResponseFor<ApiKeyCreateResponse>> = + personalAccessTokens(apiKeyCreateRequest, RequestOptions.none()) + + /** + * Returns a raw HTTP response for `get /api/v1/orgs/current/personal-access-tokens`, but is + * otherwise the same as [PersonalAccessTokenServiceAsync.retrievePersonalAccessTokens]. + */ + fun retrievePersonalAccessTokens(): + CompletableFuture<HttpResponseFor<List<ApiKeyGetResponse>>> = + retrievePersonalAccessTokens( + PersonalAccessTokenRetrievePersonalAccessTokensParams.none() + ) + + /** @see retrievePersonalAccessTokens */ + fun retrievePersonalAccessTokens( + params: PersonalAccessTokenRetrievePersonalAccessTokensParams = + PersonalAccessTokenRetrievePersonalAccessTokensParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<ApiKeyGetResponse>>> + + /** @see retrievePersonalAccessTokens */ + fun retrievePersonalAccessTokens( + params: PersonalAccessTokenRetrievePersonalAccessTokensParams = + PersonalAccessTokenRetrievePersonalAccessTokensParams.none() + ): CompletableFuture<HttpResponseFor<List<ApiKeyGetResponse>>> = + retrievePersonalAccessTokens(params, RequestOptions.none()) + + /** @see retrievePersonalAccessTokens */ + fun retrievePersonalAccessTokens( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<ApiKeyGetResponse>>> = + retrievePersonalAccessTokens( + PersonalAccessTokenRetrievePersonalAccessTokensParams.none(), + requestOptions, + ) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/PersonalAccessTokenServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/PersonalAccessTokenServiceAsyncImpl.kt new file mode 100644 index 00000000..f0dad552 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/PersonalAccessTokenServiceAsyncImpl.kt @@ -0,0 +1,183 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.orgs.current.personalaccesstokens.PersonalAccessTokenDeleteParams +import com.langsmith_api.api.models.api.v1.orgs.current.personalaccesstokens.PersonalAccessTokenPersonalAccessTokensParams +import com.langsmith_api.api.models.api.v1.orgs.current.personalaccesstokens.PersonalAccessTokenRetrievePersonalAccessTokensParams +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyCreateResponse +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyGetResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class PersonalAccessTokenServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : PersonalAccessTokenServiceAsync { + + private val withRawResponse: PersonalAccessTokenServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): PersonalAccessTokenServiceAsync.WithRawResponse = + withRawResponse + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PersonalAccessTokenServiceAsync = + PersonalAccessTokenServiceAsyncImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun delete( + params: PersonalAccessTokenDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<ApiKeyGetResponse> = + // delete /api/v1/orgs/current/personal-access-tokens/{pat_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + override fun personalAccessTokens( + params: PersonalAccessTokenPersonalAccessTokensParams, + requestOptions: RequestOptions, + ): CompletableFuture<ApiKeyCreateResponse> = + // post /api/v1/orgs/current/personal-access-tokens + withRawResponse().personalAccessTokens(params, requestOptions).thenApply { it.parse() } + + override fun retrievePersonalAccessTokens( + params: PersonalAccessTokenRetrievePersonalAccessTokensParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<ApiKeyGetResponse>> = + // get /api/v1/orgs/current/personal-access-tokens + withRawResponse().retrievePersonalAccessTokens(params, requestOptions).thenApply { + it.parse() + } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + PersonalAccessTokenServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PersonalAccessTokenServiceAsync.WithRawResponse = + PersonalAccessTokenServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val deleteHandler: Handler<ApiKeyGetResponse> = + jsonHandler<ApiKeyGetResponse>(clientOptions.jsonMapper) + + override fun delete( + params: PersonalAccessTokenDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ApiKeyGetResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("patId", params.patId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "orgs", + "current", + "personal-access-tokens", + params._pathParam(0), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val personalAccessTokensHandler: Handler<ApiKeyCreateResponse> = + jsonHandler<ApiKeyCreateResponse>(clientOptions.jsonMapper) + + override fun personalAccessTokens( + params: PersonalAccessTokenPersonalAccessTokensParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ApiKeyCreateResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "personal-access-tokens") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { personalAccessTokensHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrievePersonalAccessTokensHandler: Handler<List<ApiKeyGetResponse>> = + jsonHandler<List<ApiKeyGetResponse>>(clientOptions.jsonMapper) + + override fun retrievePersonalAccessTokens( + params: PersonalAccessTokenRetrievePersonalAccessTokensParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<ApiKeyGetResponse>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "personal-access-tokens") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrievePersonalAccessTokensHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/RoleServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/RoleServiceAsync.kt new file mode 100644 index 00000000..7f3c2f77 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/RoleServiceAsync.kt @@ -0,0 +1,217 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.orgs.current.roles.Role +import com.langsmith_api.api.models.api.v1.orgs.current.roles.RoleCreateParams +import com.langsmith_api.api.models.api.v1.orgs.current.roles.RoleDeleteParams +import com.langsmith_api.api.models.api.v1.orgs.current.roles.RoleListParams +import com.langsmith_api.api.models.api.v1.orgs.current.roles.RoleUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface RoleServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RoleServiceAsync + + /** Create Organization Roles */ + fun create(params: RoleCreateParams): CompletableFuture<Role> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: RoleCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<Role> + + /** Update Organization Roles */ + fun update(roleId: String, params: RoleUpdateParams): CompletableFuture<Role> = + update(roleId, params, RequestOptions.none()) + + /** @see update */ + fun update( + roleId: String, + params: RoleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<Role> = update(params.toBuilder().roleId(roleId).build(), requestOptions) + + /** @see update */ + fun update(params: RoleUpdateParams): CompletableFuture<Role> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: RoleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<Role> + + /** List Organization Roles */ + fun list(): CompletableFuture<List<Role>> = list(RoleListParams.none()) + + /** @see list */ + fun list( + params: RoleListParams = RoleListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<Role>> + + /** @see list */ + fun list(params: RoleListParams = RoleListParams.none()): CompletableFuture<List<Role>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture<List<Role>> = + list(RoleListParams.none(), requestOptions) + + /** Delete Organization Roles */ + fun delete(roleId: String): CompletableFuture<Role> = delete(roleId, RoleDeleteParams.none()) + + /** @see delete */ + fun delete( + roleId: String, + params: RoleDeleteParams = RoleDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<Role> = delete(params.toBuilder().roleId(roleId).build(), requestOptions) + + /** @see delete */ + fun delete( + roleId: String, + params: RoleDeleteParams = RoleDeleteParams.none(), + ): CompletableFuture<Role> = delete(roleId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: RoleDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<Role> + + /** @see delete */ + fun delete(params: RoleDeleteParams): CompletableFuture<Role> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(roleId: String, requestOptions: RequestOptions): CompletableFuture<Role> = + delete(roleId, RoleDeleteParams.none(), requestOptions) + + /** A view of [RoleServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RoleServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/orgs/current/roles`, but is otherwise the + * same as [RoleServiceAsync.create]. + */ + fun create(params: RoleCreateParams): CompletableFuture<HttpResponseFor<Role>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: RoleCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<Role>> + + /** + * Returns a raw HTTP response for `patch /api/v1/orgs/current/roles/{role_id}`, but is + * otherwise the same as [RoleServiceAsync.update]. + */ + fun update( + roleId: String, + params: RoleUpdateParams, + ): CompletableFuture<HttpResponseFor<Role>> = update(roleId, params, RequestOptions.none()) + + /** @see update */ + fun update( + roleId: String, + params: RoleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<Role>> = + update(params.toBuilder().roleId(roleId).build(), requestOptions) + + /** @see update */ + fun update(params: RoleUpdateParams): CompletableFuture<HttpResponseFor<Role>> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: RoleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<Role>> + + /** + * Returns a raw HTTP response for `get /api/v1/orgs/current/roles`, but is otherwise the + * same as [RoleServiceAsync.list]. + */ + fun list(): CompletableFuture<HttpResponseFor<List<Role>>> = list(RoleListParams.none()) + + /** @see list */ + fun list( + params: RoleListParams = RoleListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<Role>>> + + /** @see list */ + fun list( + params: RoleListParams = RoleListParams.none() + ): CompletableFuture<HttpResponseFor<List<Role>>> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture<HttpResponseFor<List<Role>>> = + list(RoleListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/orgs/current/roles/{role_id}`, but is + * otherwise the same as [RoleServiceAsync.delete]. + */ + fun delete(roleId: String): CompletableFuture<HttpResponseFor<Role>> = + delete(roleId, RoleDeleteParams.none()) + + /** @see delete */ + fun delete( + roleId: String, + params: RoleDeleteParams = RoleDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<Role>> = + delete(params.toBuilder().roleId(roleId).build(), requestOptions) + + /** @see delete */ + fun delete( + roleId: String, + params: RoleDeleteParams = RoleDeleteParams.none(), + ): CompletableFuture<HttpResponseFor<Role>> = delete(roleId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: RoleDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<Role>> + + /** @see delete */ + fun delete(params: RoleDeleteParams): CompletableFuture<HttpResponseFor<Role>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + roleId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<Role>> = + delete(roleId, RoleDeleteParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/RoleServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/RoleServiceAsyncImpl.kt new file mode 100644 index 00000000..0fbebe9e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/RoleServiceAsyncImpl.kt @@ -0,0 +1,207 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.orgs.current.roles.Role +import com.langsmith_api.api.models.api.v1.orgs.current.roles.RoleCreateParams +import com.langsmith_api.api.models.api.v1.orgs.current.roles.RoleDeleteParams +import com.langsmith_api.api.models.api.v1.orgs.current.roles.RoleListParams +import com.langsmith_api.api.models.api.v1.orgs.current.roles.RoleUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class RoleServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + RoleServiceAsync { + + private val withRawResponse: RoleServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): RoleServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): RoleServiceAsync = + RoleServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: RoleCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<Role> = + // post /api/v1/orgs/current/roles + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: RoleUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<Role> = + // patch /api/v1/orgs/current/roles/{role_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: RoleListParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<Role>> = + // get /api/v1/orgs/current/roles + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: RoleDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<Role> = + // delete /api/v1/orgs/current/roles/{role_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RoleServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): RoleServiceAsync.WithRawResponse = + RoleServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<Role> = jsonHandler<Role>(clientOptions.jsonMapper) + + override fun create( + params: RoleCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<Role>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "roles") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler<Role> = jsonHandler<Role>(clientOptions.jsonMapper) + + override fun update( + params: RoleUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<Role>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("roleId", params.roleId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "roles", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler<List<Role>> = + jsonHandler<List<Role>>(clientOptions.jsonMapper) + + override fun list( + params: RoleListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<Role>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "roles") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val deleteHandler: Handler<Role> = jsonHandler<Role>(clientOptions.jsonMapper) + + override fun delete( + params: RoleDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<Role>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("roleId", params.roleId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "roles", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/ServiceKeyServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/ServiceKeyServiceAsync.kt new file mode 100644 index 00000000..9ad01420 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/ServiceKeyServiceAsync.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyCreateRequest +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyCreateResponse +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyGetResponse +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ServiceKeyDeleteParams +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ServiceKeyRetrieveServiceKeysParams +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ServiceKeyServiceKeysParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface ServiceKeyServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ServiceKeyServiceAsync + + /** Delete Org Service Key */ + fun delete(apiKeyId: String): CompletableFuture<ApiKeyGetResponse> = + delete(apiKeyId, ServiceKeyDeleteParams.none()) + + /** @see delete */ + fun delete( + apiKeyId: String, + params: ServiceKeyDeleteParams = ServiceKeyDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ApiKeyGetResponse> = + delete(params.toBuilder().apiKeyId(apiKeyId).build(), requestOptions) + + /** @see delete */ + fun delete( + apiKeyId: String, + params: ServiceKeyDeleteParams = ServiceKeyDeleteParams.none(), + ): CompletableFuture<ApiKeyGetResponse> = delete(apiKeyId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ServiceKeyDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ApiKeyGetResponse> + + /** @see delete */ + fun delete(params: ServiceKeyDeleteParams): CompletableFuture<ApiKeyGetResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + apiKeyId: String, + requestOptions: RequestOptions, + ): CompletableFuture<ApiKeyGetResponse> = + delete(apiKeyId, ServiceKeyDeleteParams.none(), requestOptions) + + /** List Org Service Keys */ + fun retrieveServiceKeys(): CompletableFuture<List<ApiKeyGetResponse>> = + retrieveServiceKeys(ServiceKeyRetrieveServiceKeysParams.none()) + + /** @see retrieveServiceKeys */ + fun retrieveServiceKeys( + params: ServiceKeyRetrieveServiceKeysParams = ServiceKeyRetrieveServiceKeysParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<ApiKeyGetResponse>> + + /** @see retrieveServiceKeys */ + fun retrieveServiceKeys( + params: ServiceKeyRetrieveServiceKeysParams = ServiceKeyRetrieveServiceKeysParams.none() + ): CompletableFuture<List<ApiKeyGetResponse>> = + retrieveServiceKeys(params, RequestOptions.none()) + + /** @see retrieveServiceKeys */ + fun retrieveServiceKeys( + requestOptions: RequestOptions + ): CompletableFuture<List<ApiKeyGetResponse>> = + retrieveServiceKeys(ServiceKeyRetrieveServiceKeysParams.none(), requestOptions) + + /** Create org-scoped service key. If workspaces is None, key is org-wide. */ + fun serviceKeys(params: ServiceKeyServiceKeysParams): CompletableFuture<ApiKeyCreateResponse> = + serviceKeys(params, RequestOptions.none()) + + /** @see serviceKeys */ + fun serviceKeys( + params: ServiceKeyServiceKeysParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ApiKeyCreateResponse> + + /** @see serviceKeys */ + fun serviceKeys( + apiKeyCreateRequest: ApiKeyCreateRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ApiKeyCreateResponse> = + serviceKeys( + ServiceKeyServiceKeysParams.builder().apiKeyCreateRequest(apiKeyCreateRequest).build(), + requestOptions, + ) + + /** @see serviceKeys */ + fun serviceKeys( + apiKeyCreateRequest: ApiKeyCreateRequest + ): CompletableFuture<ApiKeyCreateResponse> = + serviceKeys(apiKeyCreateRequest, RequestOptions.none()) + + /** + * A view of [ServiceKeyServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ServiceKeyServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `delete /api/v1/orgs/current/service-keys/{api_key_id}`, + * but is otherwise the same as [ServiceKeyServiceAsync.delete]. + */ + fun delete(apiKeyId: String): CompletableFuture<HttpResponseFor<ApiKeyGetResponse>> = + delete(apiKeyId, ServiceKeyDeleteParams.none()) + + /** @see delete */ + fun delete( + apiKeyId: String, + params: ServiceKeyDeleteParams = ServiceKeyDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ApiKeyGetResponse>> = + delete(params.toBuilder().apiKeyId(apiKeyId).build(), requestOptions) + + /** @see delete */ + fun delete( + apiKeyId: String, + params: ServiceKeyDeleteParams = ServiceKeyDeleteParams.none(), + ): CompletableFuture<HttpResponseFor<ApiKeyGetResponse>> = + delete(apiKeyId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ServiceKeyDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ApiKeyGetResponse>> + + /** @see delete */ + fun delete( + params: ServiceKeyDeleteParams + ): CompletableFuture<HttpResponseFor<ApiKeyGetResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + apiKeyId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ApiKeyGetResponse>> = + delete(apiKeyId, ServiceKeyDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/orgs/current/service-keys`, but is otherwise + * the same as [ServiceKeyServiceAsync.retrieveServiceKeys]. + */ + fun retrieveServiceKeys(): CompletableFuture<HttpResponseFor<List<ApiKeyGetResponse>>> = + retrieveServiceKeys(ServiceKeyRetrieveServiceKeysParams.none()) + + /** @see retrieveServiceKeys */ + fun retrieveServiceKeys( + params: ServiceKeyRetrieveServiceKeysParams = + ServiceKeyRetrieveServiceKeysParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<ApiKeyGetResponse>>> + + /** @see retrieveServiceKeys */ + fun retrieveServiceKeys( + params: ServiceKeyRetrieveServiceKeysParams = ServiceKeyRetrieveServiceKeysParams.none() + ): CompletableFuture<HttpResponseFor<List<ApiKeyGetResponse>>> = + retrieveServiceKeys(params, RequestOptions.none()) + + /** @see retrieveServiceKeys */ + fun retrieveServiceKeys( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<ApiKeyGetResponse>>> = + retrieveServiceKeys(ServiceKeyRetrieveServiceKeysParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/orgs/current/service-keys`, but is + * otherwise the same as [ServiceKeyServiceAsync.serviceKeys]. + */ + fun serviceKeys( + params: ServiceKeyServiceKeysParams + ): CompletableFuture<HttpResponseFor<ApiKeyCreateResponse>> = + serviceKeys(params, RequestOptions.none()) + + /** @see serviceKeys */ + fun serviceKeys( + params: ServiceKeyServiceKeysParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ApiKeyCreateResponse>> + + /** @see serviceKeys */ + fun serviceKeys( + apiKeyCreateRequest: ApiKeyCreateRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ApiKeyCreateResponse>> = + serviceKeys( + ServiceKeyServiceKeysParams.builder() + .apiKeyCreateRequest(apiKeyCreateRequest) + .build(), + requestOptions, + ) + + /** @see serviceKeys */ + fun serviceKeys( + apiKeyCreateRequest: ApiKeyCreateRequest + ): CompletableFuture<HttpResponseFor<ApiKeyCreateResponse>> = + serviceKeys(apiKeyCreateRequest, RequestOptions.none()) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/ServiceKeyServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/ServiceKeyServiceAsyncImpl.kt new file mode 100644 index 00000000..11b142a3 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/ServiceKeyServiceAsyncImpl.kt @@ -0,0 +1,176 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyCreateResponse +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyGetResponse +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ServiceKeyDeleteParams +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ServiceKeyRetrieveServiceKeysParams +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ServiceKeyServiceKeysParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ServiceKeyServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ServiceKeyServiceAsync { + + private val withRawResponse: ServiceKeyServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ServiceKeyServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): ServiceKeyServiceAsync = + ServiceKeyServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun delete( + params: ServiceKeyDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<ApiKeyGetResponse> = + // delete /api/v1/orgs/current/service-keys/{api_key_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + override fun retrieveServiceKeys( + params: ServiceKeyRetrieveServiceKeysParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<ApiKeyGetResponse>> = + // get /api/v1/orgs/current/service-keys + withRawResponse().retrieveServiceKeys(params, requestOptions).thenApply { it.parse() } + + override fun serviceKeys( + params: ServiceKeyServiceKeysParams, + requestOptions: RequestOptions, + ): CompletableFuture<ApiKeyCreateResponse> = + // post /api/v1/orgs/current/service-keys + withRawResponse().serviceKeys(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ServiceKeyServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ServiceKeyServiceAsync.WithRawResponse = + ServiceKeyServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val deleteHandler: Handler<ApiKeyGetResponse> = + jsonHandler<ApiKeyGetResponse>(clientOptions.jsonMapper) + + override fun delete( + params: ServiceKeyDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ApiKeyGetResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("apiKeyId", params.apiKeyId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "orgs", + "current", + "service-keys", + params._pathParam(0), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveServiceKeysHandler: Handler<List<ApiKeyGetResponse>> = + jsonHandler<List<ApiKeyGetResponse>>(clientOptions.jsonMapper) + + override fun retrieveServiceKeys( + params: ServiceKeyRetrieveServiceKeysParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<ApiKeyGetResponse>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "service-keys") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveServiceKeysHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val serviceKeysHandler: Handler<ApiKeyCreateResponse> = + jsonHandler<ApiKeyCreateResponse>(clientOptions.jsonMapper) + + override fun serviceKeys( + params: ServiceKeyServiceKeysParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ApiKeyCreateResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "service-keys") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { serviceKeysHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/SsoSettingServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/SsoSettingServiceAsync.kt new file mode 100644 index 00000000..d0a0de59 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/SsoSettingServiceAsync.kt @@ -0,0 +1,257 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.orgs.current.ssosettings.SsoProvider +import com.langsmith_api.api.models.api.v1.orgs.current.ssosettings.SsoSettingDeleteParams +import com.langsmith_api.api.models.api.v1.orgs.current.ssosettings.SsoSettingRetrieveSsoSettingsParams +import com.langsmith_api.api.models.api.v1.orgs.current.ssosettings.SsoSettingSsoSettingsParams +import com.langsmith_api.api.models.api.v1.orgs.current.ssosettings.SsoSettingUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface SsoSettingServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): SsoSettingServiceAsync + + /** Update SSO provider settings defaults for the current organization. */ + fun update(id: String): CompletableFuture<SsoProvider> = + update(id, SsoSettingUpdateParams.none()) + + /** @see update */ + fun update( + id: String, + params: SsoSettingUpdateParams = SsoSettingUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<SsoProvider> = update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + fun update( + id: String, + params: SsoSettingUpdateParams = SsoSettingUpdateParams.none(), + ): CompletableFuture<SsoProvider> = update(id, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: SsoSettingUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<SsoProvider> + + /** @see update */ + fun update(params: SsoSettingUpdateParams): CompletableFuture<SsoProvider> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update(id: String, requestOptions: RequestOptions): CompletableFuture<SsoProvider> = + update(id, SsoSettingUpdateParams.none(), requestOptions) + + /** Delete SSO provider settings for the current organization. */ + fun delete(id: String): CompletableFuture<SsoProvider> = + delete(id, SsoSettingDeleteParams.none()) + + /** @see delete */ + fun delete( + id: String, + params: SsoSettingDeleteParams = SsoSettingDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<SsoProvider> = delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + fun delete( + id: String, + params: SsoSettingDeleteParams = SsoSettingDeleteParams.none(), + ): CompletableFuture<SsoProvider> = delete(id, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: SsoSettingDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<SsoProvider> + + /** @see delete */ + fun delete(params: SsoSettingDeleteParams): CompletableFuture<SsoProvider> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(id: String, requestOptions: RequestOptions): CompletableFuture<SsoProvider> = + delete(id, SsoSettingDeleteParams.none(), requestOptions) + + /** Get SSO provider settings for the current organization. */ + fun retrieveSsoSettings(): CompletableFuture<List<SsoProvider>> = + retrieveSsoSettings(SsoSettingRetrieveSsoSettingsParams.none()) + + /** @see retrieveSsoSettings */ + fun retrieveSsoSettings( + params: SsoSettingRetrieveSsoSettingsParams = SsoSettingRetrieveSsoSettingsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<SsoProvider>> + + /** @see retrieveSsoSettings */ + fun retrieveSsoSettings( + params: SsoSettingRetrieveSsoSettingsParams = SsoSettingRetrieveSsoSettingsParams.none() + ): CompletableFuture<List<SsoProvider>> = retrieveSsoSettings(params, RequestOptions.none()) + + /** @see retrieveSsoSettings */ + fun retrieveSsoSettings(requestOptions: RequestOptions): CompletableFuture<List<SsoProvider>> = + retrieveSsoSettings(SsoSettingRetrieveSsoSettingsParams.none(), requestOptions) + + /** Create SSO provider settings for the current organization. */ + fun ssoSettings(params: SsoSettingSsoSettingsParams): CompletableFuture<SsoProvider> = + ssoSettings(params, RequestOptions.none()) + + /** @see ssoSettings */ + fun ssoSettings( + params: SsoSettingSsoSettingsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<SsoProvider> + + /** + * A view of [SsoSettingServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): SsoSettingServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `patch /api/v1/orgs/current/sso-settings/{id}`, but is + * otherwise the same as [SsoSettingServiceAsync.update]. + */ + fun update(id: String): CompletableFuture<HttpResponseFor<SsoProvider>> = + update(id, SsoSettingUpdateParams.none()) + + /** @see update */ + fun update( + id: String, + params: SsoSettingUpdateParams = SsoSettingUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<SsoProvider>> = + update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + fun update( + id: String, + params: SsoSettingUpdateParams = SsoSettingUpdateParams.none(), + ): CompletableFuture<HttpResponseFor<SsoProvider>> = + update(id, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: SsoSettingUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<SsoProvider>> + + /** @see update */ + fun update( + params: SsoSettingUpdateParams + ): CompletableFuture<HttpResponseFor<SsoProvider>> = update(params, RequestOptions.none()) + + /** @see update */ + fun update( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<SsoProvider>> = + update(id, SsoSettingUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/orgs/current/sso-settings/{id}`, but is + * otherwise the same as [SsoSettingServiceAsync.delete]. + */ + fun delete(id: String): CompletableFuture<HttpResponseFor<SsoProvider>> = + delete(id, SsoSettingDeleteParams.none()) + + /** @see delete */ + fun delete( + id: String, + params: SsoSettingDeleteParams = SsoSettingDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<SsoProvider>> = + delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + fun delete( + id: String, + params: SsoSettingDeleteParams = SsoSettingDeleteParams.none(), + ): CompletableFuture<HttpResponseFor<SsoProvider>> = + delete(id, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: SsoSettingDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<SsoProvider>> + + /** @see delete */ + fun delete( + params: SsoSettingDeleteParams + ): CompletableFuture<HttpResponseFor<SsoProvider>> = delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<SsoProvider>> = + delete(id, SsoSettingDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/orgs/current/sso-settings`, but is otherwise + * the same as [SsoSettingServiceAsync.retrieveSsoSettings]. + */ + fun retrieveSsoSettings(): CompletableFuture<HttpResponseFor<List<SsoProvider>>> = + retrieveSsoSettings(SsoSettingRetrieveSsoSettingsParams.none()) + + /** @see retrieveSsoSettings */ + fun retrieveSsoSettings( + params: SsoSettingRetrieveSsoSettingsParams = + SsoSettingRetrieveSsoSettingsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<SsoProvider>>> + + /** @see retrieveSsoSettings */ + fun retrieveSsoSettings( + params: SsoSettingRetrieveSsoSettingsParams = SsoSettingRetrieveSsoSettingsParams.none() + ): CompletableFuture<HttpResponseFor<List<SsoProvider>>> = + retrieveSsoSettings(params, RequestOptions.none()) + + /** @see retrieveSsoSettings */ + fun retrieveSsoSettings( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<SsoProvider>>> = + retrieveSsoSettings(SsoSettingRetrieveSsoSettingsParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/orgs/current/sso-settings`, but is + * otherwise the same as [SsoSettingServiceAsync.ssoSettings]. + */ + fun ssoSettings( + params: SsoSettingSsoSettingsParams + ): CompletableFuture<HttpResponseFor<SsoProvider>> = + ssoSettings(params, RequestOptions.none()) + + /** @see ssoSettings */ + fun ssoSettings( + params: SsoSettingSsoSettingsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<SsoProvider>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/SsoSettingServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/SsoSettingServiceAsyncImpl.kt new file mode 100644 index 00000000..8cad5261 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/SsoSettingServiceAsyncImpl.kt @@ -0,0 +1,224 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.orgs.current.ssosettings.SsoProvider +import com.langsmith_api.api.models.api.v1.orgs.current.ssosettings.SsoSettingDeleteParams +import com.langsmith_api.api.models.api.v1.orgs.current.ssosettings.SsoSettingRetrieveSsoSettingsParams +import com.langsmith_api.api.models.api.v1.orgs.current.ssosettings.SsoSettingSsoSettingsParams +import com.langsmith_api.api.models.api.v1.orgs.current.ssosettings.SsoSettingUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class SsoSettingServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + SsoSettingServiceAsync { + + private val withRawResponse: SsoSettingServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): SsoSettingServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): SsoSettingServiceAsync = + SsoSettingServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun update( + params: SsoSettingUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<SsoProvider> = + // patch /api/v1/orgs/current/sso-settings/{id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: SsoSettingDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<SsoProvider> = + // delete /api/v1/orgs/current/sso-settings/{id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + override fun retrieveSsoSettings( + params: SsoSettingRetrieveSsoSettingsParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<SsoProvider>> = + // get /api/v1/orgs/current/sso-settings + withRawResponse().retrieveSsoSettings(params, requestOptions).thenApply { it.parse() } + + override fun ssoSettings( + params: SsoSettingSsoSettingsParams, + requestOptions: RequestOptions, + ): CompletableFuture<SsoProvider> = + // post /api/v1/orgs/current/sso-settings + withRawResponse().ssoSettings(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SsoSettingServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): SsoSettingServiceAsync.WithRawResponse = + SsoSettingServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val updateHandler: Handler<SsoProvider> = + jsonHandler<SsoProvider>(clientOptions.jsonMapper) + + override fun update( + params: SsoSettingUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<SsoProvider>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "orgs", + "current", + "sso-settings", + params._pathParam(0), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val deleteHandler: Handler<SsoProvider> = + jsonHandler<SsoProvider>(clientOptions.jsonMapper) + + override fun delete( + params: SsoSettingDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<SsoProvider>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "orgs", + "current", + "sso-settings", + params._pathParam(0), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveSsoSettingsHandler: Handler<List<SsoProvider>> = + jsonHandler<List<SsoProvider>>(clientOptions.jsonMapper) + + override fun retrieveSsoSettings( + params: SsoSettingRetrieveSsoSettingsParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<SsoProvider>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "sso-settings") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveSsoSettingsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val ssoSettingsHandler: Handler<SsoProvider> = + jsonHandler<SsoProvider>(clientOptions.jsonMapper) + + override fun ssoSettings( + params: SsoSettingSsoSettingsParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<SsoProvider>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "sso-settings") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { ssoSettingsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/UserServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/UserServiceAsync.kt new file mode 100644 index 00000000..93214f07 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/UserServiceAsync.kt @@ -0,0 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.orgs.current.user.ProviderUserSlim +import com.langsmith_api.api.models.api.v1.orgs.current.user.UserRetrieveLoginMethodsParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface UserServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): UserServiceAsync + + /** Get login methods for the current user. */ + fun retrieveLoginMethods(): CompletableFuture<List<ProviderUserSlim>> = + retrieveLoginMethods(UserRetrieveLoginMethodsParams.none()) + + /** @see retrieveLoginMethods */ + fun retrieveLoginMethods( + params: UserRetrieveLoginMethodsParams = UserRetrieveLoginMethodsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<ProviderUserSlim>> + + /** @see retrieveLoginMethods */ + fun retrieveLoginMethods( + params: UserRetrieveLoginMethodsParams = UserRetrieveLoginMethodsParams.none() + ): CompletableFuture<List<ProviderUserSlim>> = + retrieveLoginMethods(params, RequestOptions.none()) + + /** @see retrieveLoginMethods */ + fun retrieveLoginMethods( + requestOptions: RequestOptions + ): CompletableFuture<List<ProviderUserSlim>> = + retrieveLoginMethods(UserRetrieveLoginMethodsParams.none(), requestOptions) + + /** A view of [UserServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): UserServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/orgs/current/user/login-methods`, but is + * otherwise the same as [UserServiceAsync.retrieveLoginMethods]. + */ + fun retrieveLoginMethods(): CompletableFuture<HttpResponseFor<List<ProviderUserSlim>>> = + retrieveLoginMethods(UserRetrieveLoginMethodsParams.none()) + + /** @see retrieveLoginMethods */ + fun retrieveLoginMethods( + params: UserRetrieveLoginMethodsParams = UserRetrieveLoginMethodsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<ProviderUserSlim>>> + + /** @see retrieveLoginMethods */ + fun retrieveLoginMethods( + params: UserRetrieveLoginMethodsParams = UserRetrieveLoginMethodsParams.none() + ): CompletableFuture<HttpResponseFor<List<ProviderUserSlim>>> = + retrieveLoginMethods(params, RequestOptions.none()) + + /** @see retrieveLoginMethods */ + fun retrieveLoginMethods( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<ProviderUserSlim>>> = + retrieveLoginMethods(UserRetrieveLoginMethodsParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/UserServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/UserServiceAsyncImpl.kt new file mode 100644 index 00000000..158ea956 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/UserServiceAsyncImpl.kt @@ -0,0 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.orgs.current.user.ProviderUserSlim +import com.langsmith_api.api.models.api.v1.orgs.current.user.UserRetrieveLoginMethodsParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class UserServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + UserServiceAsync { + + private val withRawResponse: UserServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): UserServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): UserServiceAsync = + UserServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieveLoginMethods( + params: UserRetrieveLoginMethodsParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<ProviderUserSlim>> = + // get /api/v1/orgs/current/user/login-methods + withRawResponse().retrieveLoginMethods(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + UserServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): UserServiceAsync.WithRawResponse = + UserServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveLoginMethodsHandler: Handler<List<ProviderUserSlim>> = + jsonHandler<List<ProviderUserSlim>>(clientOptions.jsonMapper) + + override fun retrieveLoginMethods( + params: UserRetrieveLoginMethodsParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<ProviderUserSlim>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "user", "login-methods") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveLoginMethodsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/members/BasicServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/members/BasicServiceAsync.kt new file mode 100644 index 00000000..61b47d88 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/members/BasicServiceAsync.kt @@ -0,0 +1,64 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs.current.members + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.orgs.current.members.basic.BasicBatchParams +import com.langsmith_api.api.models.api.v1.orgs.current.members.basic.BasicBatchResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface BasicServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): BasicServiceAsync + + /** Batch add up to 500 users to the org and specified workspaces in basic auth mode. */ + fun batch(params: BasicBatchParams): CompletableFuture<List<BasicBatchResponse>> = + batch(params, RequestOptions.none()) + + /** @see batch */ + fun batch( + params: BasicBatchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<BasicBatchResponse>> + + /** A view of [BasicServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): BasicServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/orgs/current/members/basic/batch`, but is + * otherwise the same as [BasicServiceAsync.batch]. + */ + fun batch( + params: BasicBatchParams + ): CompletableFuture<HttpResponseFor<List<BasicBatchResponse>>> = + batch(params, RequestOptions.none()) + + /** @see batch */ + fun batch( + params: BasicBatchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<BasicBatchResponse>>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/members/BasicServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/members/BasicServiceAsyncImpl.kt new file mode 100644 index 00000000..7ac2c340 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/members/BasicServiceAsyncImpl.kt @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs.current.members + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.orgs.current.members.basic.BasicBatchParams +import com.langsmith_api.api.models.api.v1.orgs.current.members.basic.BasicBatchResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class BasicServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + BasicServiceAsync { + + private val withRawResponse: BasicServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): BasicServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): BasicServiceAsync = + BasicServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun batch( + params: BasicBatchParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<BasicBatchResponse>> = + // post /api/v1/orgs/current/members/basic/batch + withRawResponse().batch(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BasicServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): BasicServiceAsync.WithRawResponse = + BasicServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val batchHandler: Handler<List<BasicBatchResponse>> = + jsonHandler<List<BasicBatchResponse>>(clientOptions.jsonMapper) + + override fun batch( + params: BasicBatchParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<BasicBatchResponse>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "members", "basic", "batch") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { batchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/members/PendingServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/members/PendingServiceAsync.kt new file mode 100644 index 00000000..a2e91e91 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/members/PendingServiceAsync.kt @@ -0,0 +1,166 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs.current.members + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.orgs.current.members.pending.OrgPendingIdentity +import com.langsmith_api.api.models.api.v1.orgs.current.members.pending.PendingDeleteAllParams +import com.langsmith_api.api.models.api.v1.orgs.current.members.pending.PendingDeleteAllResponse +import com.langsmith_api.api.models.api.v1.orgs.current.members.pending.PendingListParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface PendingServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): PendingServiceAsync + + /** Get Current Pending Org Members */ + fun list(): CompletableFuture<List<OrgPendingIdentity>> = list(PendingListParams.none()) + + /** @see list */ + fun list( + params: PendingListParams = PendingListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<OrgPendingIdentity>> + + /** @see list */ + fun list( + params: PendingListParams = PendingListParams.none() + ): CompletableFuture<List<OrgPendingIdentity>> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture<List<OrgPendingIdentity>> = + list(PendingListParams.none(), requestOptions) + + /** When an admin deletes a pending member invite. */ + fun deleteAll(identityId: String): CompletableFuture<PendingDeleteAllResponse> = + deleteAll(identityId, PendingDeleteAllParams.none()) + + /** @see deleteAll */ + fun deleteAll( + identityId: String, + params: PendingDeleteAllParams = PendingDeleteAllParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<PendingDeleteAllResponse> = + deleteAll(params.toBuilder().identityId(identityId).build(), requestOptions) + + /** @see deleteAll */ + fun deleteAll( + identityId: String, + params: PendingDeleteAllParams = PendingDeleteAllParams.none(), + ): CompletableFuture<PendingDeleteAllResponse> = + deleteAll(identityId, params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + params: PendingDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<PendingDeleteAllResponse> + + /** @see deleteAll */ + fun deleteAll(params: PendingDeleteAllParams): CompletableFuture<PendingDeleteAllResponse> = + deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + identityId: String, + requestOptions: RequestOptions, + ): CompletableFuture<PendingDeleteAllResponse> = + deleteAll(identityId, PendingDeleteAllParams.none(), requestOptions) + + /** + * A view of [PendingServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PendingServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/orgs/current/members/pending`, but is + * otherwise the same as [PendingServiceAsync.list]. + */ + fun list(): CompletableFuture<HttpResponseFor<List<OrgPendingIdentity>>> = + list(PendingListParams.none()) + + /** @see list */ + fun list( + params: PendingListParams = PendingListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<OrgPendingIdentity>>> + + /** @see list */ + fun list( + params: PendingListParams = PendingListParams.none() + ): CompletableFuture<HttpResponseFor<List<OrgPendingIdentity>>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<OrgPendingIdentity>>> = + list(PendingListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete + * /api/v1/orgs/current/members/{identity_id}/pending`, but is otherwise the same as + * [PendingServiceAsync.deleteAll]. + */ + fun deleteAll( + identityId: String + ): CompletableFuture<HttpResponseFor<PendingDeleteAllResponse>> = + deleteAll(identityId, PendingDeleteAllParams.none()) + + /** @see deleteAll */ + fun deleteAll( + identityId: String, + params: PendingDeleteAllParams = PendingDeleteAllParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<PendingDeleteAllResponse>> = + deleteAll(params.toBuilder().identityId(identityId).build(), requestOptions) + + /** @see deleteAll */ + fun deleteAll( + identityId: String, + params: PendingDeleteAllParams = PendingDeleteAllParams.none(), + ): CompletableFuture<HttpResponseFor<PendingDeleteAllResponse>> = + deleteAll(identityId, params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + params: PendingDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<PendingDeleteAllResponse>> + + /** @see deleteAll */ + fun deleteAll( + params: PendingDeleteAllParams + ): CompletableFuture<HttpResponseFor<PendingDeleteAllResponse>> = + deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + identityId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<PendingDeleteAllResponse>> = + deleteAll(identityId, PendingDeleteAllParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/members/PendingServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/members/PendingServiceAsyncImpl.kt new file mode 100644 index 00000000..a4166a55 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/members/PendingServiceAsyncImpl.kt @@ -0,0 +1,138 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs.current.members + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.orgs.current.members.pending.OrgPendingIdentity +import com.langsmith_api.api.models.api.v1.orgs.current.members.pending.PendingDeleteAllParams +import com.langsmith_api.api.models.api.v1.orgs.current.members.pending.PendingDeleteAllResponse +import com.langsmith_api.api.models.api.v1.orgs.current.members.pending.PendingListParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class PendingServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + PendingServiceAsync { + + private val withRawResponse: PendingServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): PendingServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): PendingServiceAsync = + PendingServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: PendingListParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<OrgPendingIdentity>> = + // get /api/v1/orgs/current/members/pending + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun deleteAll( + params: PendingDeleteAllParams, + requestOptions: RequestOptions, + ): CompletableFuture<PendingDeleteAllResponse> = + // delete /api/v1/orgs/current/members/{identity_id}/pending + withRawResponse().deleteAll(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + PendingServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PendingServiceAsync.WithRawResponse = + PendingServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler<List<OrgPendingIdentity>> = + jsonHandler<List<OrgPendingIdentity>>(clientOptions.jsonMapper) + + override fun list( + params: PendingListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<OrgPendingIdentity>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "members", "pending") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val deleteAllHandler: Handler<PendingDeleteAllResponse> = + jsonHandler<PendingDeleteAllResponse>(clientOptions.jsonMapper) + + override fun deleteAll( + params: PendingDeleteAllParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<PendingDeleteAllResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("identityId", params.identityId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "orgs", + "current", + "members", + params._pathParam(0), + "pending", + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteAllHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/DatasetServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/DatasetServiceAsync.kt new file mode 100644 index 00000000..f228731d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/DatasetServiceAsync.kt @@ -0,0 +1,398 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.public_ + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.feedback.FeedbackSchema +import com.langsmith_api.api.models.api.v1.public_.datasets.DatasetListParams +import com.langsmith_api.api.models.api.v1.public_.datasets.DatasetListResponse +import com.langsmith_api.api.models.api.v1.public_.datasets.DatasetRetrieveComparativeParams +import com.langsmith_api.api.models.api.v1.public_.datasets.DatasetRetrieveComparativeResponse +import com.langsmith_api.api.models.api.v1.public_.datasets.DatasetRetrieveFeedbackParams +import com.langsmith_api.api.models.api.v1.public_.datasets.DatasetRetrieveSessionsBulkParams +import com.langsmith_api.api.models.api.v1.public_.datasets.DatasetRetrieveSessionsParams +import com.langsmith_api.api.models.api.v1.sessions.TracerSession +import com.langsmith_api.api.services.async.api.v1.public_.datasets.RunServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface DatasetServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): DatasetServiceAsync + + fun runs(): RunServiceAsync + + /** Get dataset by ids or the shared dataset if not specifed. */ + fun list(shareToken: String): CompletableFuture<DatasetListResponse> = + list(shareToken, DatasetListParams.none()) + + /** @see list */ + fun list( + shareToken: String, + params: DatasetListParams = DatasetListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<DatasetListResponse> = + list(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see list */ + fun list( + shareToken: String, + params: DatasetListParams = DatasetListParams.none(), + ): CompletableFuture<DatasetListResponse> = list(shareToken, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: DatasetListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<DatasetListResponse> + + /** @see list */ + fun list(params: DatasetListParams): CompletableFuture<DatasetListResponse> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + shareToken: String, + requestOptions: RequestOptions, + ): CompletableFuture<DatasetListResponse> = + list(shareToken, DatasetListParams.none(), requestOptions) + + /** Get all comparative experiments for a given dataset. */ + fun retrieveComparative( + shareToken: String + ): CompletableFuture<List<DatasetRetrieveComparativeResponse>> = + retrieveComparative(shareToken, DatasetRetrieveComparativeParams.none()) + + /** @see retrieveComparative */ + fun retrieveComparative( + shareToken: String, + params: DatasetRetrieveComparativeParams = DatasetRetrieveComparativeParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<DatasetRetrieveComparativeResponse>> = + retrieveComparative(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see retrieveComparative */ + fun retrieveComparative( + shareToken: String, + params: DatasetRetrieveComparativeParams = DatasetRetrieveComparativeParams.none(), + ): CompletableFuture<List<DatasetRetrieveComparativeResponse>> = + retrieveComparative(shareToken, params, RequestOptions.none()) + + /** @see retrieveComparative */ + fun retrieveComparative( + params: DatasetRetrieveComparativeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<DatasetRetrieveComparativeResponse>> + + /** @see retrieveComparative */ + fun retrieveComparative( + params: DatasetRetrieveComparativeParams + ): CompletableFuture<List<DatasetRetrieveComparativeResponse>> = + retrieveComparative(params, RequestOptions.none()) + + /** @see retrieveComparative */ + fun retrieveComparative( + shareToken: String, + requestOptions: RequestOptions, + ): CompletableFuture<List<DatasetRetrieveComparativeResponse>> = + retrieveComparative(shareToken, DatasetRetrieveComparativeParams.none(), requestOptions) + + /** Get feedback for runs in projects run over a dataset that has been shared. */ + fun retrieveFeedback(shareToken: String): CompletableFuture<List<FeedbackSchema>> = + retrieveFeedback(shareToken, DatasetRetrieveFeedbackParams.none()) + + /** @see retrieveFeedback */ + fun retrieveFeedback( + shareToken: String, + params: DatasetRetrieveFeedbackParams = DatasetRetrieveFeedbackParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<FeedbackSchema>> = + retrieveFeedback(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see retrieveFeedback */ + fun retrieveFeedback( + shareToken: String, + params: DatasetRetrieveFeedbackParams = DatasetRetrieveFeedbackParams.none(), + ): CompletableFuture<List<FeedbackSchema>> = + retrieveFeedback(shareToken, params, RequestOptions.none()) + + /** @see retrieveFeedback */ + fun retrieveFeedback( + params: DatasetRetrieveFeedbackParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<FeedbackSchema>> + + /** @see retrieveFeedback */ + fun retrieveFeedback( + params: DatasetRetrieveFeedbackParams + ): CompletableFuture<List<FeedbackSchema>> = retrieveFeedback(params, RequestOptions.none()) + + /** @see retrieveFeedback */ + fun retrieveFeedback( + shareToken: String, + requestOptions: RequestOptions, + ): CompletableFuture<List<FeedbackSchema>> = + retrieveFeedback(shareToken, DatasetRetrieveFeedbackParams.none(), requestOptions) + + /** Get projects run on a dataset that has been shared. */ + fun retrieveSessions(shareToken: String): CompletableFuture<List<TracerSession>> = + retrieveSessions(shareToken, DatasetRetrieveSessionsParams.none()) + + /** @see retrieveSessions */ + fun retrieveSessions( + shareToken: String, + params: DatasetRetrieveSessionsParams = DatasetRetrieveSessionsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<TracerSession>> = + retrieveSessions(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see retrieveSessions */ + fun retrieveSessions( + shareToken: String, + params: DatasetRetrieveSessionsParams = DatasetRetrieveSessionsParams.none(), + ): CompletableFuture<List<TracerSession>> = + retrieveSessions(shareToken, params, RequestOptions.none()) + + /** @see retrieveSessions */ + fun retrieveSessions( + params: DatasetRetrieveSessionsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<TracerSession>> + + /** @see retrieveSessions */ + fun retrieveSessions( + params: DatasetRetrieveSessionsParams + ): CompletableFuture<List<TracerSession>> = retrieveSessions(params, RequestOptions.none()) + + /** @see retrieveSessions */ + fun retrieveSessions( + shareToken: String, + requestOptions: RequestOptions, + ): CompletableFuture<List<TracerSession>> = + retrieveSessions(shareToken, DatasetRetrieveSessionsParams.none(), requestOptions) + + /** Get sessions from multiple datasets using share tokens. */ + fun retrieveSessionsBulk( + params: DatasetRetrieveSessionsBulkParams + ): CompletableFuture<List<TracerSession>> = retrieveSessionsBulk(params, RequestOptions.none()) + + /** @see retrieveSessionsBulk */ + fun retrieveSessionsBulk( + params: DatasetRetrieveSessionsBulkParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<TracerSession>> + + /** + * A view of [DatasetServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): DatasetServiceAsync.WithRawResponse + + fun runs(): RunServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/public/{share_token}/datasets`, but is + * otherwise the same as [DatasetServiceAsync.list]. + */ + fun list(shareToken: String): CompletableFuture<HttpResponseFor<DatasetListResponse>> = + list(shareToken, DatasetListParams.none()) + + /** @see list */ + fun list( + shareToken: String, + params: DatasetListParams = DatasetListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<DatasetListResponse>> = + list(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see list */ + fun list( + shareToken: String, + params: DatasetListParams = DatasetListParams.none(), + ): CompletableFuture<HttpResponseFor<DatasetListResponse>> = + list(shareToken, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: DatasetListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<DatasetListResponse>> + + /** @see list */ + fun list( + params: DatasetListParams + ): CompletableFuture<HttpResponseFor<DatasetListResponse>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + shareToken: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<DatasetListResponse>> = + list(shareToken, DatasetListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/public/{share_token}/datasets/comparative`, + * but is otherwise the same as [DatasetServiceAsync.retrieveComparative]. + */ + fun retrieveComparative( + shareToken: String + ): CompletableFuture<HttpResponseFor<List<DatasetRetrieveComparativeResponse>>> = + retrieveComparative(shareToken, DatasetRetrieveComparativeParams.none()) + + /** @see retrieveComparative */ + fun retrieveComparative( + shareToken: String, + params: DatasetRetrieveComparativeParams = DatasetRetrieveComparativeParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<DatasetRetrieveComparativeResponse>>> = + retrieveComparative(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see retrieveComparative */ + fun retrieveComparative( + shareToken: String, + params: DatasetRetrieveComparativeParams = DatasetRetrieveComparativeParams.none(), + ): CompletableFuture<HttpResponseFor<List<DatasetRetrieveComparativeResponse>>> = + retrieveComparative(shareToken, params, RequestOptions.none()) + + /** @see retrieveComparative */ + fun retrieveComparative( + params: DatasetRetrieveComparativeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<DatasetRetrieveComparativeResponse>>> + + /** @see retrieveComparative */ + fun retrieveComparative( + params: DatasetRetrieveComparativeParams + ): CompletableFuture<HttpResponseFor<List<DatasetRetrieveComparativeResponse>>> = + retrieveComparative(params, RequestOptions.none()) + + /** @see retrieveComparative */ + fun retrieveComparative( + shareToken: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<DatasetRetrieveComparativeResponse>>> = + retrieveComparative(shareToken, DatasetRetrieveComparativeParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/public/{share_token}/datasets/feedback`, but + * is otherwise the same as [DatasetServiceAsync.retrieveFeedback]. + */ + fun retrieveFeedback( + shareToken: String + ): CompletableFuture<HttpResponseFor<List<FeedbackSchema>>> = + retrieveFeedback(shareToken, DatasetRetrieveFeedbackParams.none()) + + /** @see retrieveFeedback */ + fun retrieveFeedback( + shareToken: String, + params: DatasetRetrieveFeedbackParams = DatasetRetrieveFeedbackParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<FeedbackSchema>>> = + retrieveFeedback(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see retrieveFeedback */ + fun retrieveFeedback( + shareToken: String, + params: DatasetRetrieveFeedbackParams = DatasetRetrieveFeedbackParams.none(), + ): CompletableFuture<HttpResponseFor<List<FeedbackSchema>>> = + retrieveFeedback(shareToken, params, RequestOptions.none()) + + /** @see retrieveFeedback */ + fun retrieveFeedback( + params: DatasetRetrieveFeedbackParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<FeedbackSchema>>> + + /** @see retrieveFeedback */ + fun retrieveFeedback( + params: DatasetRetrieveFeedbackParams + ): CompletableFuture<HttpResponseFor<List<FeedbackSchema>>> = + retrieveFeedback(params, RequestOptions.none()) + + /** @see retrieveFeedback */ + fun retrieveFeedback( + shareToken: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<FeedbackSchema>>> = + retrieveFeedback(shareToken, DatasetRetrieveFeedbackParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/public/{share_token}/datasets/sessions`, but + * is otherwise the same as [DatasetServiceAsync.retrieveSessions]. + */ + fun retrieveSessions( + shareToken: String + ): CompletableFuture<HttpResponseFor<List<TracerSession>>> = + retrieveSessions(shareToken, DatasetRetrieveSessionsParams.none()) + + /** @see retrieveSessions */ + fun retrieveSessions( + shareToken: String, + params: DatasetRetrieveSessionsParams = DatasetRetrieveSessionsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<TracerSession>>> = + retrieveSessions(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see retrieveSessions */ + fun retrieveSessions( + shareToken: String, + params: DatasetRetrieveSessionsParams = DatasetRetrieveSessionsParams.none(), + ): CompletableFuture<HttpResponseFor<List<TracerSession>>> = + retrieveSessions(shareToken, params, RequestOptions.none()) + + /** @see retrieveSessions */ + fun retrieveSessions( + params: DatasetRetrieveSessionsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<TracerSession>>> + + /** @see retrieveSessions */ + fun retrieveSessions( + params: DatasetRetrieveSessionsParams + ): CompletableFuture<HttpResponseFor<List<TracerSession>>> = + retrieveSessions(params, RequestOptions.none()) + + /** @see retrieveSessions */ + fun retrieveSessions( + shareToken: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<TracerSession>>> = + retrieveSessions(shareToken, DatasetRetrieveSessionsParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/public/datasets/sessions-bulk`, but is + * otherwise the same as [DatasetServiceAsync.retrieveSessionsBulk]. + */ + fun retrieveSessionsBulk( + params: DatasetRetrieveSessionsBulkParams + ): CompletableFuture<HttpResponseFor<List<TracerSession>>> = + retrieveSessionsBulk(params, RequestOptions.none()) + + /** @see retrieveSessionsBulk */ + fun retrieveSessionsBulk( + params: DatasetRetrieveSessionsBulkParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<TracerSession>>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/DatasetServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/DatasetServiceAsyncImpl.kt new file mode 100644 index 00000000..d732b78a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/DatasetServiceAsyncImpl.kt @@ -0,0 +1,286 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.public_ + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.feedback.FeedbackSchema +import com.langsmith_api.api.models.api.v1.public_.datasets.DatasetListParams +import com.langsmith_api.api.models.api.v1.public_.datasets.DatasetListResponse +import com.langsmith_api.api.models.api.v1.public_.datasets.DatasetRetrieveComparativeParams +import com.langsmith_api.api.models.api.v1.public_.datasets.DatasetRetrieveComparativeResponse +import com.langsmith_api.api.models.api.v1.public_.datasets.DatasetRetrieveFeedbackParams +import com.langsmith_api.api.models.api.v1.public_.datasets.DatasetRetrieveSessionsBulkParams +import com.langsmith_api.api.models.api.v1.public_.datasets.DatasetRetrieveSessionsParams +import com.langsmith_api.api.models.api.v1.sessions.TracerSession +import com.langsmith_api.api.services.async.api.v1.public_.datasets.RunServiceAsync +import com.langsmith_api.api.services.async.api.v1.public_.datasets.RunServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class DatasetServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + DatasetServiceAsync { + + private val withRawResponse: DatasetServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val runs: RunServiceAsync by lazy { RunServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): DatasetServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): DatasetServiceAsync = + DatasetServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun runs(): RunServiceAsync = runs + + override fun list( + params: DatasetListParams, + requestOptions: RequestOptions, + ): CompletableFuture<DatasetListResponse> = + // get /api/v1/public/{share_token}/datasets + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun retrieveComparative( + params: DatasetRetrieveComparativeParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<DatasetRetrieveComparativeResponse>> = + // get /api/v1/public/{share_token}/datasets/comparative + withRawResponse().retrieveComparative(params, requestOptions).thenApply { it.parse() } + + override fun retrieveFeedback( + params: DatasetRetrieveFeedbackParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<FeedbackSchema>> = + // get /api/v1/public/{share_token}/datasets/feedback + withRawResponse().retrieveFeedback(params, requestOptions).thenApply { it.parse() } + + override fun retrieveSessions( + params: DatasetRetrieveSessionsParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<TracerSession>> = + // get /api/v1/public/{share_token}/datasets/sessions + withRawResponse().retrieveSessions(params, requestOptions).thenApply { it.parse() } + + override fun retrieveSessionsBulk( + params: DatasetRetrieveSessionsBulkParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<TracerSession>> = + // get /api/v1/public/datasets/sessions-bulk + withRawResponse().retrieveSessionsBulk(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + DatasetServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val runs: RunServiceAsync.WithRawResponse by lazy { + RunServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): DatasetServiceAsync.WithRawResponse = + DatasetServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun runs(): RunServiceAsync.WithRawResponse = runs + + private val listHandler: Handler<DatasetListResponse> = + jsonHandler<DatasetListResponse>(clientOptions.jsonMapper) + + override fun list( + params: DatasetListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<DatasetListResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("shareToken", params.shareToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "public", params._pathParam(0), "datasets") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveComparativeHandler: Handler<List<DatasetRetrieveComparativeResponse>> = + jsonHandler<List<DatasetRetrieveComparativeResponse>>(clientOptions.jsonMapper) + + override fun retrieveComparative( + params: DatasetRetrieveComparativeParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<DatasetRetrieveComparativeResponse>>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("shareToken", params.shareToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "public", + params._pathParam(0), + "datasets", + "comparative", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveComparativeHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val retrieveFeedbackHandler: Handler<List<FeedbackSchema>> = + jsonHandler<List<FeedbackSchema>>(clientOptions.jsonMapper) + + override fun retrieveFeedback( + params: DatasetRetrieveFeedbackParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<FeedbackSchema>>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("shareToken", params.shareToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "public", + params._pathParam(0), + "datasets", + "feedback", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveFeedbackHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val retrieveSessionsHandler: Handler<List<TracerSession>> = + jsonHandler<List<TracerSession>>(clientOptions.jsonMapper) + + override fun retrieveSessions( + params: DatasetRetrieveSessionsParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<TracerSession>>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("shareToken", params.shareToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "public", + params._pathParam(0), + "datasets", + "sessions", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveSessionsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val retrieveSessionsBulkHandler: Handler<List<TracerSession>> = + jsonHandler<List<TracerSession>>(clientOptions.jsonMapper) + + override fun retrieveSessionsBulk( + params: DatasetRetrieveSessionsBulkParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<TracerSession>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "public", "datasets", "sessions-bulk") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveSessionsBulkHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/ExampleServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/ExampleServiceAsync.kt new file mode 100644 index 00000000..7f07578a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/ExampleServiceAsync.kt @@ -0,0 +1,241 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.public_ + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.examples.Example +import com.langsmith_api.api.models.api.v1.public_.examples.ExampleListParams +import com.langsmith_api.api.models.api.v1.public_.examples.ExampleRetrieveCountParams +import com.langsmith_api.api.models.api.v1.public_.examples.ExampleRunsParams +import com.langsmith_api.api.models.api.v1.public_.examples.ExampleRunsResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface ExampleServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ExampleServiceAsync + + /** Get example by ids or the shared example if not specifed. */ + fun list(shareToken: String): CompletableFuture<List<Example>> = + list(shareToken, ExampleListParams.none()) + + /** @see list */ + fun list( + shareToken: String, + params: ExampleListParams = ExampleListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<Example>> = + list(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see list */ + fun list( + shareToken: String, + params: ExampleListParams = ExampleListParams.none(), + ): CompletableFuture<List<Example>> = list(shareToken, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: ExampleListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<Example>> + + /** @see list */ + fun list(params: ExampleListParams): CompletableFuture<List<Example>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(shareToken: String, requestOptions: RequestOptions): CompletableFuture<List<Example>> = + list(shareToken, ExampleListParams.none(), requestOptions) + + /** Count all examples by query params */ + fun retrieveCount(shareToken: String): CompletableFuture<Long> = + retrieveCount(shareToken, ExampleRetrieveCountParams.none()) + + /** @see retrieveCount */ + fun retrieveCount( + shareToken: String, + params: ExampleRetrieveCountParams = ExampleRetrieveCountParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<Long> = + retrieveCount(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see retrieveCount */ + fun retrieveCount( + shareToken: String, + params: ExampleRetrieveCountParams = ExampleRetrieveCountParams.none(), + ): CompletableFuture<Long> = retrieveCount(shareToken, params, RequestOptions.none()) + + /** @see retrieveCount */ + fun retrieveCount( + params: ExampleRetrieveCountParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<Long> + + /** @see retrieveCount */ + fun retrieveCount(params: ExampleRetrieveCountParams): CompletableFuture<Long> = + retrieveCount(params, RequestOptions.none()) + + /** @see retrieveCount */ + fun retrieveCount(shareToken: String, requestOptions: RequestOptions): CompletableFuture<Long> = + retrieveCount(shareToken, ExampleRetrieveCountParams.none(), requestOptions) + + /** Get examples with associated runs from sessions in a dataset that has been shared. */ + fun runs( + shareToken: String, + params: ExampleRunsParams, + ): CompletableFuture<ExampleRunsResponse> = runs(shareToken, params, RequestOptions.none()) + + /** @see runs */ + fun runs( + shareToken: String, + params: ExampleRunsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ExampleRunsResponse> = + runs(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see runs */ + fun runs(params: ExampleRunsParams): CompletableFuture<ExampleRunsResponse> = + runs(params, RequestOptions.none()) + + /** @see runs */ + fun runs( + params: ExampleRunsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ExampleRunsResponse> + + /** + * A view of [ExampleServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ExampleServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/public/{share_token}/examples`, but is + * otherwise the same as [ExampleServiceAsync.list]. + */ + fun list(shareToken: String): CompletableFuture<HttpResponseFor<List<Example>>> = + list(shareToken, ExampleListParams.none()) + + /** @see list */ + fun list( + shareToken: String, + params: ExampleListParams = ExampleListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<Example>>> = + list(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see list */ + fun list( + shareToken: String, + params: ExampleListParams = ExampleListParams.none(), + ): CompletableFuture<HttpResponseFor<List<Example>>> = + list(shareToken, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: ExampleListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<Example>>> + + /** @see list */ + fun list(params: ExampleListParams): CompletableFuture<HttpResponseFor<List<Example>>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + shareToken: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<Example>>> = + list(shareToken, ExampleListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/public/{share_token}/examples/count`, but is + * otherwise the same as [ExampleServiceAsync.retrieveCount]. + */ + fun retrieveCount(shareToken: String): CompletableFuture<HttpResponseFor<Long>> = + retrieveCount(shareToken, ExampleRetrieveCountParams.none()) + + /** @see retrieveCount */ + fun retrieveCount( + shareToken: String, + params: ExampleRetrieveCountParams = ExampleRetrieveCountParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<Long>> = + retrieveCount(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see retrieveCount */ + fun retrieveCount( + shareToken: String, + params: ExampleRetrieveCountParams = ExampleRetrieveCountParams.none(), + ): CompletableFuture<HttpResponseFor<Long>> = + retrieveCount(shareToken, params, RequestOptions.none()) + + /** @see retrieveCount */ + fun retrieveCount( + params: ExampleRetrieveCountParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<Long>> + + /** @see retrieveCount */ + fun retrieveCount( + params: ExampleRetrieveCountParams + ): CompletableFuture<HttpResponseFor<Long>> = retrieveCount(params, RequestOptions.none()) + + /** @see retrieveCount */ + fun retrieveCount( + shareToken: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<Long>> = + retrieveCount(shareToken, ExampleRetrieveCountParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/public/{share_token}/examples/runs`, but is + * otherwise the same as [ExampleServiceAsync.runs]. + */ + fun runs( + shareToken: String, + params: ExampleRunsParams, + ): CompletableFuture<HttpResponseFor<ExampleRunsResponse>> = + runs(shareToken, params, RequestOptions.none()) + + /** @see runs */ + fun runs( + shareToken: String, + params: ExampleRunsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ExampleRunsResponse>> = + runs(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see runs */ + fun runs( + params: ExampleRunsParams + ): CompletableFuture<HttpResponseFor<ExampleRunsResponse>> = + runs(params, RequestOptions.none()) + + /** @see runs */ + fun runs( + params: ExampleRunsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ExampleRunsResponse>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/ExampleServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/ExampleServiceAsyncImpl.kt new file mode 100644 index 00000000..7baa4b73 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/ExampleServiceAsyncImpl.kt @@ -0,0 +1,182 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.public_ + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.examples.Example +import com.langsmith_api.api.models.api.v1.public_.examples.ExampleListParams +import com.langsmith_api.api.models.api.v1.public_.examples.ExampleRetrieveCountParams +import com.langsmith_api.api.models.api.v1.public_.examples.ExampleRunsParams +import com.langsmith_api.api.models.api.v1.public_.examples.ExampleRunsResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ExampleServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ExampleServiceAsync { + + private val withRawResponse: ExampleServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ExampleServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): ExampleServiceAsync = + ExampleServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: ExampleListParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<Example>> = + // get /api/v1/public/{share_token}/examples + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun retrieveCount( + params: ExampleRetrieveCountParams, + requestOptions: RequestOptions, + ): CompletableFuture<Long> = + // get /api/v1/public/{share_token}/examples/count + withRawResponse().retrieveCount(params, requestOptions).thenApply { it.parse() } + + override fun runs( + params: ExampleRunsParams, + requestOptions: RequestOptions, + ): CompletableFuture<ExampleRunsResponse> = + // post /api/v1/public/{share_token}/examples/runs + withRawResponse().runs(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ExampleServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ExampleServiceAsync.WithRawResponse = + ExampleServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler<List<Example>> = + jsonHandler<List<Example>>(clientOptions.jsonMapper) + + override fun list( + params: ExampleListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<Example>>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("shareToken", params.shareToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "public", params._pathParam(0), "examples") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val retrieveCountHandler: Handler<Long> = + jsonHandler<Long>(clientOptions.jsonMapper) + + override fun retrieveCount( + params: ExampleRetrieveCountParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<Long>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("shareToken", params.shareToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "public", + params._pathParam(0), + "examples", + "count", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { retrieveCountHandler.handle(it) } + } + } + } + + private val runsHandler: Handler<ExampleRunsResponse> = + jsonHandler<ExampleRunsResponse>(clientOptions.jsonMapper) + + override fun runs( + params: ExampleRunsParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ExampleRunsResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("shareToken", params.shareToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "public", + params._pathParam(0), + "examples", + "runs", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { runsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/RunServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/RunServiceAsync.kt new file mode 100644 index 00000000..d09ff558 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/RunServiceAsync.kt @@ -0,0 +1,239 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.public_ + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.public_.runs.RunListParams +import com.langsmith_api.api.models.api.v1.public_.runs.RunPublicSchema +import com.langsmith_api.api.models.api.v1.public_.runs.RunQueryParams +import com.langsmith_api.api.models.api.v1.public_.runs.RunQueryResponse +import com.langsmith_api.api.models.api.v1.public_.runs.RunRetrieveParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface RunServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunServiceAsync + + /** Get the shared run. */ + fun retrieve(id: String, params: RunRetrieveParams): CompletableFuture<RunPublicSchema> = + retrieve(id, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + id: String, + params: RunRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RunPublicSchema> = + retrieve(params.toBuilder().id(id).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: RunRetrieveParams): CompletableFuture<RunPublicSchema> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: RunRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RunPublicSchema> + + /** Get the shared run. */ + fun list(shareToken: String): CompletableFuture<RunPublicSchema> = + list(shareToken, RunListParams.none()) + + /** @see list */ + fun list( + shareToken: String, + params: RunListParams = RunListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RunPublicSchema> = + list(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see list */ + fun list( + shareToken: String, + params: RunListParams = RunListParams.none(), + ): CompletableFuture<RunPublicSchema> = list(shareToken, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: RunListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RunPublicSchema> + + /** @see list */ + fun list(params: RunListParams): CompletableFuture<RunPublicSchema> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + shareToken: String, + requestOptions: RequestOptions, + ): CompletableFuture<RunPublicSchema> = list(shareToken, RunListParams.none(), requestOptions) + + /** Get run by ids or the shared run if not specifed. */ + fun query(shareToken: String): CompletableFuture<RunQueryResponse> = + query(shareToken, RunQueryParams.none()) + + /** @see query */ + fun query( + shareToken: String, + params: RunQueryParams = RunQueryParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RunQueryResponse> = + query(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see query */ + fun query( + shareToken: String, + params: RunQueryParams = RunQueryParams.none(), + ): CompletableFuture<RunQueryResponse> = query(shareToken, params, RequestOptions.none()) + + /** @see query */ + fun query( + params: RunQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RunQueryResponse> + + /** @see query */ + fun query(params: RunQueryParams): CompletableFuture<RunQueryResponse> = + query(params, RequestOptions.none()) + + /** @see query */ + fun query( + shareToken: String, + requestOptions: RequestOptions, + ): CompletableFuture<RunQueryResponse> = + query(shareToken, RunQueryParams.none(), requestOptions) + + /** A view of [RunServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/public/{share_token}/run/{id}`, but is + * otherwise the same as [RunServiceAsync.retrieve]. + */ + fun retrieve( + id: String, + params: RunRetrieveParams, + ): CompletableFuture<HttpResponseFor<RunPublicSchema>> = + retrieve(id, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + id: String, + params: RunRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RunPublicSchema>> = + retrieve(params.toBuilder().id(id).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + params: RunRetrieveParams + ): CompletableFuture<HttpResponseFor<RunPublicSchema>> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: RunRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RunPublicSchema>> + + /** + * Returns a raw HTTP response for `get /api/v1/public/{share_token}/run`, but is otherwise + * the same as [RunServiceAsync.list]. + */ + fun list(shareToken: String): CompletableFuture<HttpResponseFor<RunPublicSchema>> = + list(shareToken, RunListParams.none()) + + /** @see list */ + fun list( + shareToken: String, + params: RunListParams = RunListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RunPublicSchema>> = + list(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see list */ + fun list( + shareToken: String, + params: RunListParams = RunListParams.none(), + ): CompletableFuture<HttpResponseFor<RunPublicSchema>> = + list(shareToken, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: RunListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RunPublicSchema>> + + /** @see list */ + fun list(params: RunListParams): CompletableFuture<HttpResponseFor<RunPublicSchema>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + shareToken: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<RunPublicSchema>> = + list(shareToken, RunListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/public/{share_token}/runs/query`, but is + * otherwise the same as [RunServiceAsync.query]. + */ + fun query(shareToken: String): CompletableFuture<HttpResponseFor<RunQueryResponse>> = + query(shareToken, RunQueryParams.none()) + + /** @see query */ + fun query( + shareToken: String, + params: RunQueryParams = RunQueryParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RunQueryResponse>> = + query(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see query */ + fun query( + shareToken: String, + params: RunQueryParams = RunQueryParams.none(), + ): CompletableFuture<HttpResponseFor<RunQueryResponse>> = + query(shareToken, params, RequestOptions.none()) + + /** @see query */ + fun query( + params: RunQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RunQueryResponse>> + + /** @see query */ + fun query(params: RunQueryParams): CompletableFuture<HttpResponseFor<RunQueryResponse>> = + query(params, RequestOptions.none()) + + /** @see query */ + fun query( + shareToken: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<RunQueryResponse>> = + query(shareToken, RunQueryParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/RunServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/RunServiceAsyncImpl.kt new file mode 100644 index 00000000..121b3c11 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/RunServiceAsyncImpl.kt @@ -0,0 +1,181 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.public_ + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.public_.runs.RunListParams +import com.langsmith_api.api.models.api.v1.public_.runs.RunPublicSchema +import com.langsmith_api.api.models.api.v1.public_.runs.RunQueryParams +import com.langsmith_api.api.models.api.v1.public_.runs.RunQueryResponse +import com.langsmith_api.api.models.api.v1.public_.runs.RunRetrieveParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class RunServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + RunServiceAsync { + + private val withRawResponse: RunServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): RunServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunServiceAsync = + RunServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: RunRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<RunPublicSchema> = + // get /api/v1/public/{share_token}/run/{id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: RunListParams, + requestOptions: RequestOptions, + ): CompletableFuture<RunPublicSchema> = + // get /api/v1/public/{share_token}/run + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun query( + params: RunQueryParams, + requestOptions: RequestOptions, + ): CompletableFuture<RunQueryResponse> = + // post /api/v1/public/{share_token}/runs/query + withRawResponse().query(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RunServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): RunServiceAsync.WithRawResponse = + RunServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler<RunPublicSchema> = + jsonHandler<RunPublicSchema>(clientOptions.jsonMapper) + + override fun retrieve( + params: RunRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<RunPublicSchema>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "public", + params._pathParam(0), + "run", + params._pathParam(1), + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler<RunPublicSchema> = + jsonHandler<RunPublicSchema>(clientOptions.jsonMapper) + + override fun list( + params: RunListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<RunPublicSchema>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("shareToken", params.shareToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "public", params._pathParam(0), "run") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val queryHandler: Handler<RunQueryResponse> = + jsonHandler<RunQueryResponse>(clientOptions.jsonMapper) + + override fun query( + params: RunQueryParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<RunQueryResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("shareToken", params.shareToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "public", params._pathParam(0), "runs", "query") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { queryHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/SchemaServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/SchemaServiceAsync.kt new file mode 100644 index 00000000..00c80571 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/SchemaServiceAsync.kt @@ -0,0 +1,205 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.public_ + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.public_.schemas.SchemaRetrieveMessageJsonParams +import com.langsmith_api.api.models.api.v1.public_.schemas.SchemaRetrieveMessageJsonResponse +import com.langsmith_api.api.models.api.v1.public_.schemas.SchemaRetrieveTooldefJsonParams +import com.langsmith_api.api.models.api.v1.public_.schemas.SchemaRetrieveTooldefJsonResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface SchemaServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): SchemaServiceAsync + + /** Get Message Json Schema */ + fun retrieveMessageJson(version: String): CompletableFuture<SchemaRetrieveMessageJsonResponse> = + retrieveMessageJson(version, SchemaRetrieveMessageJsonParams.none()) + + /** @see retrieveMessageJson */ + fun retrieveMessageJson( + version: String, + params: SchemaRetrieveMessageJsonParams = SchemaRetrieveMessageJsonParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<SchemaRetrieveMessageJsonResponse> = + retrieveMessageJson(params.toBuilder().version(version).build(), requestOptions) + + /** @see retrieveMessageJson */ + fun retrieveMessageJson( + version: String, + params: SchemaRetrieveMessageJsonParams = SchemaRetrieveMessageJsonParams.none(), + ): CompletableFuture<SchemaRetrieveMessageJsonResponse> = + retrieveMessageJson(version, params, RequestOptions.none()) + + /** @see retrieveMessageJson */ + fun retrieveMessageJson( + params: SchemaRetrieveMessageJsonParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<SchemaRetrieveMessageJsonResponse> + + /** @see retrieveMessageJson */ + fun retrieveMessageJson( + params: SchemaRetrieveMessageJsonParams + ): CompletableFuture<SchemaRetrieveMessageJsonResponse> = + retrieveMessageJson(params, RequestOptions.none()) + + /** @see retrieveMessageJson */ + fun retrieveMessageJson( + version: String, + requestOptions: RequestOptions, + ): CompletableFuture<SchemaRetrieveMessageJsonResponse> = + retrieveMessageJson(version, SchemaRetrieveMessageJsonParams.none(), requestOptions) + + /** Get Tool Def Json Schema */ + fun retrieveTooldefJson(version: String): CompletableFuture<SchemaRetrieveTooldefJsonResponse> = + retrieveTooldefJson(version, SchemaRetrieveTooldefJsonParams.none()) + + /** @see retrieveTooldefJson */ + fun retrieveTooldefJson( + version: String, + params: SchemaRetrieveTooldefJsonParams = SchemaRetrieveTooldefJsonParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<SchemaRetrieveTooldefJsonResponse> = + retrieveTooldefJson(params.toBuilder().version(version).build(), requestOptions) + + /** @see retrieveTooldefJson */ + fun retrieveTooldefJson( + version: String, + params: SchemaRetrieveTooldefJsonParams = SchemaRetrieveTooldefJsonParams.none(), + ): CompletableFuture<SchemaRetrieveTooldefJsonResponse> = + retrieveTooldefJson(version, params, RequestOptions.none()) + + /** @see retrieveTooldefJson */ + fun retrieveTooldefJson( + params: SchemaRetrieveTooldefJsonParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<SchemaRetrieveTooldefJsonResponse> + + /** @see retrieveTooldefJson */ + fun retrieveTooldefJson( + params: SchemaRetrieveTooldefJsonParams + ): CompletableFuture<SchemaRetrieveTooldefJsonResponse> = + retrieveTooldefJson(params, RequestOptions.none()) + + /** @see retrieveTooldefJson */ + fun retrieveTooldefJson( + version: String, + requestOptions: RequestOptions, + ): CompletableFuture<SchemaRetrieveTooldefJsonResponse> = + retrieveTooldefJson(version, SchemaRetrieveTooldefJsonParams.none(), requestOptions) + + /** + * A view of [SchemaServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): SchemaServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/public/schemas/{version}/message.json`, but + * is otherwise the same as [SchemaServiceAsync.retrieveMessageJson]. + */ + fun retrieveMessageJson( + version: String + ): CompletableFuture<HttpResponseFor<SchemaRetrieveMessageJsonResponse>> = + retrieveMessageJson(version, SchemaRetrieveMessageJsonParams.none()) + + /** @see retrieveMessageJson */ + fun retrieveMessageJson( + version: String, + params: SchemaRetrieveMessageJsonParams = SchemaRetrieveMessageJsonParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<SchemaRetrieveMessageJsonResponse>> = + retrieveMessageJson(params.toBuilder().version(version).build(), requestOptions) + + /** @see retrieveMessageJson */ + fun retrieveMessageJson( + version: String, + params: SchemaRetrieveMessageJsonParams = SchemaRetrieveMessageJsonParams.none(), + ): CompletableFuture<HttpResponseFor<SchemaRetrieveMessageJsonResponse>> = + retrieveMessageJson(version, params, RequestOptions.none()) + + /** @see retrieveMessageJson */ + fun retrieveMessageJson( + params: SchemaRetrieveMessageJsonParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<SchemaRetrieveMessageJsonResponse>> + + /** @see retrieveMessageJson */ + fun retrieveMessageJson( + params: SchemaRetrieveMessageJsonParams + ): CompletableFuture<HttpResponseFor<SchemaRetrieveMessageJsonResponse>> = + retrieveMessageJson(params, RequestOptions.none()) + + /** @see retrieveMessageJson */ + fun retrieveMessageJson( + version: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<SchemaRetrieveMessageJsonResponse>> = + retrieveMessageJson(version, SchemaRetrieveMessageJsonParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/public/schemas/{version}/tooldef.json`, but + * is otherwise the same as [SchemaServiceAsync.retrieveTooldefJson]. + */ + fun retrieveTooldefJson( + version: String + ): CompletableFuture<HttpResponseFor<SchemaRetrieveTooldefJsonResponse>> = + retrieveTooldefJson(version, SchemaRetrieveTooldefJsonParams.none()) + + /** @see retrieveTooldefJson */ + fun retrieveTooldefJson( + version: String, + params: SchemaRetrieveTooldefJsonParams = SchemaRetrieveTooldefJsonParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<SchemaRetrieveTooldefJsonResponse>> = + retrieveTooldefJson(params.toBuilder().version(version).build(), requestOptions) + + /** @see retrieveTooldefJson */ + fun retrieveTooldefJson( + version: String, + params: SchemaRetrieveTooldefJsonParams = SchemaRetrieveTooldefJsonParams.none(), + ): CompletableFuture<HttpResponseFor<SchemaRetrieveTooldefJsonResponse>> = + retrieveTooldefJson(version, params, RequestOptions.none()) + + /** @see retrieveTooldefJson */ + fun retrieveTooldefJson( + params: SchemaRetrieveTooldefJsonParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<SchemaRetrieveTooldefJsonResponse>> + + /** @see retrieveTooldefJson */ + fun retrieveTooldefJson( + params: SchemaRetrieveTooldefJsonParams + ): CompletableFuture<HttpResponseFor<SchemaRetrieveTooldefJsonResponse>> = + retrieveTooldefJson(params, RequestOptions.none()) + + /** @see retrieveTooldefJson */ + fun retrieveTooldefJson( + version: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<SchemaRetrieveTooldefJsonResponse>> = + retrieveTooldefJson(version, SchemaRetrieveTooldefJsonParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/SchemaServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/SchemaServiceAsyncImpl.kt new file mode 100644 index 00000000..dc840c18 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/SchemaServiceAsyncImpl.kt @@ -0,0 +1,145 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.public_ + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.public_.schemas.SchemaRetrieveMessageJsonParams +import com.langsmith_api.api.models.api.v1.public_.schemas.SchemaRetrieveMessageJsonResponse +import com.langsmith_api.api.models.api.v1.public_.schemas.SchemaRetrieveTooldefJsonParams +import com.langsmith_api.api.models.api.v1.public_.schemas.SchemaRetrieveTooldefJsonResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class SchemaServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + SchemaServiceAsync { + + private val withRawResponse: SchemaServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): SchemaServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): SchemaServiceAsync = + SchemaServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieveMessageJson( + params: SchemaRetrieveMessageJsonParams, + requestOptions: RequestOptions, + ): CompletableFuture<SchemaRetrieveMessageJsonResponse> = + // get /api/v1/public/schemas/{version}/message.json + withRawResponse().retrieveMessageJson(params, requestOptions).thenApply { it.parse() } + + override fun retrieveTooldefJson( + params: SchemaRetrieveTooldefJsonParams, + requestOptions: RequestOptions, + ): CompletableFuture<SchemaRetrieveTooldefJsonResponse> = + // get /api/v1/public/schemas/{version}/tooldef.json + withRawResponse().retrieveTooldefJson(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SchemaServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): SchemaServiceAsync.WithRawResponse = + SchemaServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveMessageJsonHandler: Handler<SchemaRetrieveMessageJsonResponse> = + jsonHandler<SchemaRetrieveMessageJsonResponse>(clientOptions.jsonMapper) + + override fun retrieveMessageJson( + params: SchemaRetrieveMessageJsonParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<SchemaRetrieveMessageJsonResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("version", params.version().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "public", + "schemas", + params._pathParam(0), + "message.json", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveMessageJsonHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveTooldefJsonHandler: Handler<SchemaRetrieveTooldefJsonResponse> = + jsonHandler<SchemaRetrieveTooldefJsonResponse>(clientOptions.jsonMapper) + + override fun retrieveTooldefJson( + params: SchemaRetrieveTooldefJsonParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<SchemaRetrieveTooldefJsonResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("version", params.version().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "public", + "schemas", + params._pathParam(0), + "tooldef.json", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveTooldefJsonHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/datasets/RunServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/datasets/RunServiceAsync.kt new file mode 100644 index 00000000..3ab02655 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/datasets/RunServiceAsync.kt @@ -0,0 +1,313 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.public_.datasets + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.datasets.runs.SessionFeedbackDelta +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunDeltaParams +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunGenerateQueryParams +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunPublicDatasetSchema +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunQueryParams +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunQueryResponse +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunRetrieveParams +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunStats +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunStatsParams +import com.langsmith_api.api.models.api.v1.runs.ResponseBodyForRunsGenerateQuery +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface RunServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunServiceAsync + + /** Get runs in projects run over a dataset that has been shared. */ + fun retrieve( + runId: String, + params: RunRetrieveParams, + ): CompletableFuture<RunPublicDatasetSchema> = retrieve(runId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + runId: String, + params: RunRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RunPublicDatasetSchema> = + retrieve(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: RunRetrieveParams): CompletableFuture<RunPublicDatasetSchema> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: RunRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RunPublicDatasetSchema> + + /** + * Fetch the number of regressions/improvements for each example in a dataset, between + * sessions[0] and sessions[1]. + */ + fun delta(shareToken: String, params: RunDeltaParams): CompletableFuture<SessionFeedbackDelta> = + delta(shareToken, params, RequestOptions.none()) + + /** @see delta */ + fun delta( + shareToken: String, + params: RunDeltaParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<SessionFeedbackDelta> = + delta(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see delta */ + fun delta(params: RunDeltaParams): CompletableFuture<SessionFeedbackDelta> = + delta(params, RequestOptions.none()) + + /** @see delta */ + fun delta( + params: RunDeltaParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<SessionFeedbackDelta> + + /** Get runs in projects run over a dataset that has been shared. */ + fun generateQuery( + shareToken: String, + params: RunGenerateQueryParams, + ): CompletableFuture<ResponseBodyForRunsGenerateQuery> = + generateQuery(shareToken, params, RequestOptions.none()) + + /** @see generateQuery */ + fun generateQuery( + shareToken: String, + params: RunGenerateQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ResponseBodyForRunsGenerateQuery> = + generateQuery(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see generateQuery */ + fun generateQuery( + params: RunGenerateQueryParams + ): CompletableFuture<ResponseBodyForRunsGenerateQuery> = + generateQuery(params, RequestOptions.none()) + + /** @see generateQuery */ + fun generateQuery( + params: RunGenerateQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ResponseBodyForRunsGenerateQuery> + + /** Get runs in projects run over a dataset that has been shared. */ + fun query(shareToken: String, params: RunQueryParams): CompletableFuture<RunQueryResponse> = + query(shareToken, params, RequestOptions.none()) + + /** @see query */ + fun query( + shareToken: String, + params: RunQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RunQueryResponse> = + query(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see query */ + fun query(params: RunQueryParams): CompletableFuture<RunQueryResponse> = + query(params, RequestOptions.none()) + + /** @see query */ + fun query( + params: RunQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RunQueryResponse> + + /** Get run stats in projects run over a dataset that has been shared. */ + fun stats(shareToken: String, params: RunStatsParams): CompletableFuture<RunStats> = + stats(shareToken, params, RequestOptions.none()) + + /** @see stats */ + fun stats( + shareToken: String, + params: RunStatsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RunStats> = + stats(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see stats */ + fun stats(params: RunStatsParams): CompletableFuture<RunStats> = + stats(params, RequestOptions.none()) + + /** @see stats */ + fun stats( + params: RunStatsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RunStats> + + /** A view of [RunServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get + * /api/v1/public/{share_token}/datasets/runs/{run_id}`, but is otherwise the same as + * [RunServiceAsync.retrieve]. + */ + fun retrieve( + runId: String, + params: RunRetrieveParams, + ): CompletableFuture<HttpResponseFor<RunPublicDatasetSchema>> = + retrieve(runId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + runId: String, + params: RunRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RunPublicDatasetSchema>> = + retrieve(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + params: RunRetrieveParams + ): CompletableFuture<HttpResponseFor<RunPublicDatasetSchema>> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: RunRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RunPublicDatasetSchema>> + + /** + * Returns a raw HTTP response for `post /api/v1/public/{share_token}/datasets/runs/delta`, + * but is otherwise the same as [RunServiceAsync.delta]. + */ + fun delta( + shareToken: String, + params: RunDeltaParams, + ): CompletableFuture<HttpResponseFor<SessionFeedbackDelta>> = + delta(shareToken, params, RequestOptions.none()) + + /** @see delta */ + fun delta( + shareToken: String, + params: RunDeltaParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<SessionFeedbackDelta>> = + delta(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see delta */ + fun delta( + params: RunDeltaParams + ): CompletableFuture<HttpResponseFor<SessionFeedbackDelta>> = + delta(params, RequestOptions.none()) + + /** @see delta */ + fun delta( + params: RunDeltaParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<SessionFeedbackDelta>> + + /** + * Returns a raw HTTP response for `post + * /api/v1/public/{share_token}/datasets/runs/generate-query`, but is otherwise the same as + * [RunServiceAsync.generateQuery]. + */ + fun generateQuery( + shareToken: String, + params: RunGenerateQueryParams, + ): CompletableFuture<HttpResponseFor<ResponseBodyForRunsGenerateQuery>> = + generateQuery(shareToken, params, RequestOptions.none()) + + /** @see generateQuery */ + fun generateQuery( + shareToken: String, + params: RunGenerateQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ResponseBodyForRunsGenerateQuery>> = + generateQuery(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see generateQuery */ + fun generateQuery( + params: RunGenerateQueryParams + ): CompletableFuture<HttpResponseFor<ResponseBodyForRunsGenerateQuery>> = + generateQuery(params, RequestOptions.none()) + + /** @see generateQuery */ + fun generateQuery( + params: RunGenerateQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ResponseBodyForRunsGenerateQuery>> + + /** + * Returns a raw HTTP response for `post /api/v1/public/{share_token}/datasets/runs/query`, + * but is otherwise the same as [RunServiceAsync.query]. + */ + fun query( + shareToken: String, + params: RunQueryParams, + ): CompletableFuture<HttpResponseFor<RunQueryResponse>> = + query(shareToken, params, RequestOptions.none()) + + /** @see query */ + fun query( + shareToken: String, + params: RunQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RunQueryResponse>> = + query(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see query */ + fun query(params: RunQueryParams): CompletableFuture<HttpResponseFor<RunQueryResponse>> = + query(params, RequestOptions.none()) + + /** @see query */ + fun query( + params: RunQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RunQueryResponse>> + + /** + * Returns a raw HTTP response for `post /api/v1/public/{share_token}/datasets/runs/stats`, + * but is otherwise the same as [RunServiceAsync.stats]. + */ + fun stats( + shareToken: String, + params: RunStatsParams, + ): CompletableFuture<HttpResponseFor<RunStats>> = + stats(shareToken, params, RequestOptions.none()) + + /** @see stats */ + fun stats( + shareToken: String, + params: RunStatsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RunStats>> = + stats(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see stats */ + fun stats(params: RunStatsParams): CompletableFuture<HttpResponseFor<RunStats>> = + stats(params, RequestOptions.none()) + + /** @see stats */ + fun stats( + params: RunStatsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RunStats>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/datasets/RunServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/datasets/RunServiceAsyncImpl.kt new file mode 100644 index 00000000..e357b3ab --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/public_/datasets/RunServiceAsyncImpl.kt @@ -0,0 +1,302 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.public_.datasets + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.datasets.runs.SessionFeedbackDelta +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunDeltaParams +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunGenerateQueryParams +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunPublicDatasetSchema +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunQueryParams +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunQueryResponse +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunRetrieveParams +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunStats +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunStatsParams +import com.langsmith_api.api.models.api.v1.runs.ResponseBodyForRunsGenerateQuery +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class RunServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + RunServiceAsync { + + private val withRawResponse: RunServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): RunServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunServiceAsync = + RunServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: RunRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<RunPublicDatasetSchema> = + // get /api/v1/public/{share_token}/datasets/runs/{run_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun delta( + params: RunDeltaParams, + requestOptions: RequestOptions, + ): CompletableFuture<SessionFeedbackDelta> = + // post /api/v1/public/{share_token}/datasets/runs/delta + withRawResponse().delta(params, requestOptions).thenApply { it.parse() } + + override fun generateQuery( + params: RunGenerateQueryParams, + requestOptions: RequestOptions, + ): CompletableFuture<ResponseBodyForRunsGenerateQuery> = + // post /api/v1/public/{share_token}/datasets/runs/generate-query + withRawResponse().generateQuery(params, requestOptions).thenApply { it.parse() } + + override fun query( + params: RunQueryParams, + requestOptions: RequestOptions, + ): CompletableFuture<RunQueryResponse> = + // post /api/v1/public/{share_token}/datasets/runs/query + withRawResponse().query(params, requestOptions).thenApply { it.parse() } + + override fun stats( + params: RunStatsParams, + requestOptions: RequestOptions, + ): CompletableFuture<RunStats> = + // post /api/v1/public/{share_token}/datasets/runs/stats + withRawResponse().stats(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RunServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): RunServiceAsync.WithRawResponse = + RunServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler<RunPublicDatasetSchema> = + jsonHandler<RunPublicDatasetSchema>(clientOptions.jsonMapper) + + override fun retrieve( + params: RunRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<RunPublicDatasetSchema>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("runId", params.runId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "public", + params._pathParam(0), + "datasets", + "runs", + params._pathParam(1), + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val deltaHandler: Handler<SessionFeedbackDelta> = + jsonHandler<SessionFeedbackDelta>(clientOptions.jsonMapper) + + override fun delta( + params: RunDeltaParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<SessionFeedbackDelta>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("shareToken", params.shareToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "public", + params._pathParam(0), + "datasets", + "runs", + "delta", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deltaHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val generateQueryHandler: Handler<ResponseBodyForRunsGenerateQuery> = + jsonHandler<ResponseBodyForRunsGenerateQuery>(clientOptions.jsonMapper) + + override fun generateQuery( + params: RunGenerateQueryParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ResponseBodyForRunsGenerateQuery>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("shareToken", params.shareToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "public", + params._pathParam(0), + "datasets", + "runs", + "generate-query", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { generateQueryHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val queryHandler: Handler<RunQueryResponse> = + jsonHandler<RunQueryResponse>(clientOptions.jsonMapper) + + override fun query( + params: RunQueryParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<RunQueryResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("shareToken", params.shareToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "public", + params._pathParam(0), + "datasets", + "runs", + "query", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { queryHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val statsHandler: Handler<RunStats> = + jsonHandler<RunStats>(clientOptions.jsonMapper) + + override fun stats( + params: RunStatsParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<RunStats>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("shareToken", params.shareToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "public", + params._pathParam(0), + "datasets", + "runs", + "stats", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { statsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/repos/OptimizationJobServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/repos/OptimizationJobServiceAsync.kt new file mode 100644 index 00000000..157fc812 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/repos/OptimizationJobServiceAsync.kt @@ -0,0 +1,335 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.repos + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.OptimizationJobDeleteParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.OptimizationJobDeleteResponse +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.OptimizationJobOptimizationJobsParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.OptimizationJobRetrieveOptimizationJobsParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.OptimizationJobRetrieveParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.OptimizationJobRetrieveResponse +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.OptimizationJobUpdateParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.PromptOptimizationJob +import com.langsmith_api.api.services.async.api.v1.repos.optimizationjobs.LogServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface OptimizationJobServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): OptimizationJobServiceAsync + + fun logs(): LogServiceAsync + + /** Get a specific optimization job. */ + fun retrieve( + jobId: String, + params: OptimizationJobRetrieveParams, + ): CompletableFuture<OptimizationJobRetrieveResponse> = + retrieve(jobId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + jobId: String, + params: OptimizationJobRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<OptimizationJobRetrieveResponse> = + retrieve(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + params: OptimizationJobRetrieveParams + ): CompletableFuture<OptimizationJobRetrieveResponse> = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: OptimizationJobRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<OptimizationJobRetrieveResponse> + + /** Replace an existing prompt optimization job with a new, modified job. */ + fun update( + jobId: String, + params: OptimizationJobUpdateParams, + ): CompletableFuture<PromptOptimizationJob> = update(jobId, params, RequestOptions.none()) + + /** @see update */ + fun update( + jobId: String, + params: OptimizationJobUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<PromptOptimizationJob> = + update(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see update */ + fun update(params: OptimizationJobUpdateParams): CompletableFuture<PromptOptimizationJob> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: OptimizationJobUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<PromptOptimizationJob> + + /** Delete a prompt optimization job. */ + fun delete( + jobId: String, + params: OptimizationJobDeleteParams, + ): CompletableFuture<OptimizationJobDeleteResponse> = + delete(jobId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + jobId: String, + params: OptimizationJobDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<OptimizationJobDeleteResponse> = + delete(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see delete */ + fun delete( + params: OptimizationJobDeleteParams + ): CompletableFuture<OptimizationJobDeleteResponse> = delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: OptimizationJobDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<OptimizationJobDeleteResponse> + + /** Create a new prompt optimization job. */ + fun optimizationJobs( + repo: String, + params: OptimizationJobOptimizationJobsParams, + ): CompletableFuture<PromptOptimizationJob> = + optimizationJobs(repo, params, RequestOptions.none()) + + /** @see optimizationJobs */ + fun optimizationJobs( + repo: String, + params: OptimizationJobOptimizationJobsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<PromptOptimizationJob> = + optimizationJobs(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see optimizationJobs */ + fun optimizationJobs( + params: OptimizationJobOptimizationJobsParams + ): CompletableFuture<PromptOptimizationJob> = optimizationJobs(params, RequestOptions.none()) + + /** @see optimizationJobs */ + fun optimizationJobs( + params: OptimizationJobOptimizationJobsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<PromptOptimizationJob> + + /** List all prompt optimization jobs. */ + fun retrieveOptimizationJobs( + repo: String, + params: OptimizationJobRetrieveOptimizationJobsParams, + ): CompletableFuture<List<PromptOptimizationJob>> = + retrieveOptimizationJobs(repo, params, RequestOptions.none()) + + /** @see retrieveOptimizationJobs */ + fun retrieveOptimizationJobs( + repo: String, + params: OptimizationJobRetrieveOptimizationJobsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<PromptOptimizationJob>> = + retrieveOptimizationJobs(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see retrieveOptimizationJobs */ + fun retrieveOptimizationJobs( + params: OptimizationJobRetrieveOptimizationJobsParams + ): CompletableFuture<List<PromptOptimizationJob>> = + retrieveOptimizationJobs(params, RequestOptions.none()) + + /** @see retrieveOptimizationJobs */ + fun retrieveOptimizationJobs( + params: OptimizationJobRetrieveOptimizationJobsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<PromptOptimizationJob>> + + /** + * A view of [OptimizationJobServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): OptimizationJobServiceAsync.WithRawResponse + + fun logs(): LogServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get + * /api/v1/repos/{owner}/{repo}/optimization-jobs/{job_id}`, but is otherwise the same as + * [OptimizationJobServiceAsync.retrieve]. + */ + fun retrieve( + jobId: String, + params: OptimizationJobRetrieveParams, + ): CompletableFuture<HttpResponseFor<OptimizationJobRetrieveResponse>> = + retrieve(jobId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + jobId: String, + params: OptimizationJobRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<OptimizationJobRetrieveResponse>> = + retrieve(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + params: OptimizationJobRetrieveParams + ): CompletableFuture<HttpResponseFor<OptimizationJobRetrieveResponse>> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: OptimizationJobRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<OptimizationJobRetrieveResponse>> + + /** + * Returns a raw HTTP response for `patch + * /api/v1/repos/{owner}/{repo}/optimization-jobs/{job_id}`, but is otherwise the same as + * [OptimizationJobServiceAsync.update]. + */ + fun update( + jobId: String, + params: OptimizationJobUpdateParams, + ): CompletableFuture<HttpResponseFor<PromptOptimizationJob>> = + update(jobId, params, RequestOptions.none()) + + /** @see update */ + fun update( + jobId: String, + params: OptimizationJobUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<PromptOptimizationJob>> = + update(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see update */ + fun update( + params: OptimizationJobUpdateParams + ): CompletableFuture<HttpResponseFor<PromptOptimizationJob>> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: OptimizationJobUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<PromptOptimizationJob>> + + /** + * Returns a raw HTTP response for `delete + * /api/v1/repos/{owner}/{repo}/optimization-jobs/{job_id}`, but is otherwise the same as + * [OptimizationJobServiceAsync.delete]. + */ + fun delete( + jobId: String, + params: OptimizationJobDeleteParams, + ): CompletableFuture<HttpResponseFor<OptimizationJobDeleteResponse>> = + delete(jobId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + jobId: String, + params: OptimizationJobDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<OptimizationJobDeleteResponse>> = + delete(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see delete */ + fun delete( + params: OptimizationJobDeleteParams + ): CompletableFuture<HttpResponseFor<OptimizationJobDeleteResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: OptimizationJobDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<OptimizationJobDeleteResponse>> + + /** + * Returns a raw HTTP response for `post /api/v1/repos/{owner}/{repo}/optimization-jobs`, + * but is otherwise the same as [OptimizationJobServiceAsync.optimizationJobs]. + */ + fun optimizationJobs( + repo: String, + params: OptimizationJobOptimizationJobsParams, + ): CompletableFuture<HttpResponseFor<PromptOptimizationJob>> = + optimizationJobs(repo, params, RequestOptions.none()) + + /** @see optimizationJobs */ + fun optimizationJobs( + repo: String, + params: OptimizationJobOptimizationJobsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<PromptOptimizationJob>> = + optimizationJobs(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see optimizationJobs */ + fun optimizationJobs( + params: OptimizationJobOptimizationJobsParams + ): CompletableFuture<HttpResponseFor<PromptOptimizationJob>> = + optimizationJobs(params, RequestOptions.none()) + + /** @see optimizationJobs */ + fun optimizationJobs( + params: OptimizationJobOptimizationJobsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<PromptOptimizationJob>> + + /** + * Returns a raw HTTP response for `get /api/v1/repos/{owner}/{repo}/optimization-jobs`, but + * is otherwise the same as [OptimizationJobServiceAsync.retrieveOptimizationJobs]. + */ + fun retrieveOptimizationJobs( + repo: String, + params: OptimizationJobRetrieveOptimizationJobsParams, + ): CompletableFuture<HttpResponseFor<List<PromptOptimizationJob>>> = + retrieveOptimizationJobs(repo, params, RequestOptions.none()) + + /** @see retrieveOptimizationJobs */ + fun retrieveOptimizationJobs( + repo: String, + params: OptimizationJobRetrieveOptimizationJobsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<PromptOptimizationJob>>> = + retrieveOptimizationJobs(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see retrieveOptimizationJobs */ + fun retrieveOptimizationJobs( + params: OptimizationJobRetrieveOptimizationJobsParams + ): CompletableFuture<HttpResponseFor<List<PromptOptimizationJob>>> = + retrieveOptimizationJobs(params, RequestOptions.none()) + + /** @see retrieveOptimizationJobs */ + fun retrieveOptimizationJobs( + params: OptimizationJobRetrieveOptimizationJobsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<PromptOptimizationJob>>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/repos/OptimizationJobServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/repos/OptimizationJobServiceAsyncImpl.kt new file mode 100644 index 00000000..b5d2ee04 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/repos/OptimizationJobServiceAsyncImpl.kt @@ -0,0 +1,311 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.repos + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.OptimizationJobDeleteParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.OptimizationJobDeleteResponse +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.OptimizationJobOptimizationJobsParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.OptimizationJobRetrieveOptimizationJobsParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.OptimizationJobRetrieveParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.OptimizationJobRetrieveResponse +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.OptimizationJobUpdateParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.PromptOptimizationJob +import com.langsmith_api.api.services.async.api.v1.repos.optimizationjobs.LogServiceAsync +import com.langsmith_api.api.services.async.api.v1.repos.optimizationjobs.LogServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class OptimizationJobServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : OptimizationJobServiceAsync { + + private val withRawResponse: OptimizationJobServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val logs: LogServiceAsync by lazy { LogServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): OptimizationJobServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): OptimizationJobServiceAsync = + OptimizationJobServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun logs(): LogServiceAsync = logs + + override fun retrieve( + params: OptimizationJobRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<OptimizationJobRetrieveResponse> = + // get /api/v1/repos/{owner}/{repo}/optimization-jobs/{job_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: OptimizationJobUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<PromptOptimizationJob> = + // patch /api/v1/repos/{owner}/{repo}/optimization-jobs/{job_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: OptimizationJobDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<OptimizationJobDeleteResponse> = + // delete /api/v1/repos/{owner}/{repo}/optimization-jobs/{job_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + override fun optimizationJobs( + params: OptimizationJobOptimizationJobsParams, + requestOptions: RequestOptions, + ): CompletableFuture<PromptOptimizationJob> = + // post /api/v1/repos/{owner}/{repo}/optimization-jobs + withRawResponse().optimizationJobs(params, requestOptions).thenApply { it.parse() } + + override fun retrieveOptimizationJobs( + params: OptimizationJobRetrieveOptimizationJobsParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<PromptOptimizationJob>> = + // get /api/v1/repos/{owner}/{repo}/optimization-jobs + withRawResponse().retrieveOptimizationJobs(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + OptimizationJobServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val logs: LogServiceAsync.WithRawResponse by lazy { + LogServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): OptimizationJobServiceAsync.WithRawResponse = + OptimizationJobServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun logs(): LogServiceAsync.WithRawResponse = logs + + private val retrieveHandler: Handler<OptimizationJobRetrieveResponse> = + jsonHandler<OptimizationJobRetrieveResponse>(clientOptions.jsonMapper) + + override fun retrieve( + params: OptimizationJobRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<OptimizationJobRetrieveResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("jobId", params.jobId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "repos", + params._pathParam(0), + params._pathParam(1), + "optimization-jobs", + params._pathParam(2), + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler<PromptOptimizationJob> = + jsonHandler<PromptOptimizationJob>(clientOptions.jsonMapper) + + override fun update( + params: OptimizationJobUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<PromptOptimizationJob>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("jobId", params.jobId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "repos", + params._pathParam(0), + params._pathParam(1), + "optimization-jobs", + params._pathParam(2), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val deleteHandler: Handler<OptimizationJobDeleteResponse> = + jsonHandler<OptimizationJobDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: OptimizationJobDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<OptimizationJobDeleteResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("jobId", params.jobId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "repos", + params._pathParam(0), + params._pathParam(1), + "optimization-jobs", + params._pathParam(2), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val optimizationJobsHandler: Handler<PromptOptimizationJob> = + jsonHandler<PromptOptimizationJob>(clientOptions.jsonMapper) + + override fun optimizationJobs( + params: OptimizationJobOptimizationJobsParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<PromptOptimizationJob>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("repo", params.repo().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "repos", + params._pathParam(0), + params._pathParam(1), + "optimization-jobs", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { optimizationJobsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveOptimizationJobsHandler: Handler<List<PromptOptimizationJob>> = + jsonHandler<List<PromptOptimizationJob>>(clientOptions.jsonMapper) + + override fun retrieveOptimizationJobs( + params: OptimizationJobRetrieveOptimizationJobsParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<PromptOptimizationJob>>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("repo", params.repo().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "repos", + params._pathParam(0), + params._pathParam(1), + "optimization-jobs", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveOptimizationJobsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/repos/TagServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/repos/TagServiceAsync.kt new file mode 100644 index 00000000..a18f3cc2 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/repos/TagServiceAsync.kt @@ -0,0 +1,290 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.repos + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.repos.tags.RepoTag +import com.langsmith_api.api.models.api.v1.repos.tags.TagCreateParams +import com.langsmith_api.api.models.api.v1.repos.tags.TagDeleteParams +import com.langsmith_api.api.models.api.v1.repos.tags.TagDeleteResponse +import com.langsmith_api.api.models.api.v1.repos.tags.TagListParams +import com.langsmith_api.api.models.api.v1.repos.tags.TagRetrieveParams +import com.langsmith_api.api.models.api.v1.repos.tags.TagUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface TagServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): TagServiceAsync + + /** Create Tag */ + fun create(repo: String, params: TagCreateParams): CompletableFuture<RepoTag> = + create(repo, params, RequestOptions.none()) + + /** @see create */ + fun create( + repo: String, + params: TagCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RepoTag> = create(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see create */ + fun create(params: TagCreateParams): CompletableFuture<RepoTag> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: TagCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RepoTag> + + /** Get Tag */ + fun retrieve(tagName: String, params: TagRetrieveParams): CompletableFuture<RepoTag> = + retrieve(tagName, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + tagName: String, + params: TagRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RepoTag> = + retrieve(params.toBuilder().tagName(tagName).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: TagRetrieveParams): CompletableFuture<RepoTag> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: TagRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RepoTag> + + /** Update Tag */ + fun update(tagName: String, params: TagUpdateParams): CompletableFuture<RepoTag> = + update(tagName, params, RequestOptions.none()) + + /** @see update */ + fun update( + tagName: String, + params: TagUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RepoTag> = + update(params.toBuilder().tagName(tagName).build(), requestOptions) + + /** @see update */ + fun update(params: TagUpdateParams): CompletableFuture<RepoTag> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: TagUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RepoTag> + + /** Get Tags */ + fun list(repo: String, params: TagListParams): CompletableFuture<List<RepoTag>> = + list(repo, params, RequestOptions.none()) + + /** @see list */ + fun list( + repo: String, + params: TagListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<RepoTag>> = + list(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see list */ + fun list(params: TagListParams): CompletableFuture<List<RepoTag>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: TagListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<RepoTag>> + + /** Delete Tag */ + fun delete(tagName: String, params: TagDeleteParams): CompletableFuture<TagDeleteResponse> = + delete(tagName, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + tagName: String, + params: TagDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<TagDeleteResponse> = + delete(params.toBuilder().tagName(tagName).build(), requestOptions) + + /** @see delete */ + fun delete(params: TagDeleteParams): CompletableFuture<TagDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: TagDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<TagDeleteResponse> + + /** A view of [TagServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): TagServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/repos/{owner}/{repo}/tags`, but is + * otherwise the same as [TagServiceAsync.create]. + */ + fun create( + repo: String, + params: TagCreateParams, + ): CompletableFuture<HttpResponseFor<RepoTag>> = create(repo, params, RequestOptions.none()) + + /** @see create */ + fun create( + repo: String, + params: TagCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RepoTag>> = + create(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see create */ + fun create(params: TagCreateParams): CompletableFuture<HttpResponseFor<RepoTag>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: TagCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RepoTag>> + + /** + * Returns a raw HTTP response for `get /api/v1/repos/{owner}/{repo}/tags/{tag_name}`, but + * is otherwise the same as [TagServiceAsync.retrieve]. + */ + fun retrieve( + tagName: String, + params: TagRetrieveParams, + ): CompletableFuture<HttpResponseFor<RepoTag>> = + retrieve(tagName, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + tagName: String, + params: TagRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RepoTag>> = + retrieve(params.toBuilder().tagName(tagName).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: TagRetrieveParams): CompletableFuture<HttpResponseFor<RepoTag>> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: TagRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RepoTag>> + + /** + * Returns a raw HTTP response for `patch /api/v1/repos/{owner}/{repo}/tags/{tag_name}`, but + * is otherwise the same as [TagServiceAsync.update]. + */ + fun update( + tagName: String, + params: TagUpdateParams, + ): CompletableFuture<HttpResponseFor<RepoTag>> = + update(tagName, params, RequestOptions.none()) + + /** @see update */ + fun update( + tagName: String, + params: TagUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RepoTag>> = + update(params.toBuilder().tagName(tagName).build(), requestOptions) + + /** @see update */ + fun update(params: TagUpdateParams): CompletableFuture<HttpResponseFor<RepoTag>> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: TagUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RepoTag>> + + /** + * Returns a raw HTTP response for `get /api/v1/repos/{owner}/{repo}/tags`, but is otherwise + * the same as [TagServiceAsync.list]. + */ + fun list( + repo: String, + params: TagListParams, + ): CompletableFuture<HttpResponseFor<List<RepoTag>>> = + list(repo, params, RequestOptions.none()) + + /** @see list */ + fun list( + repo: String, + params: TagListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<RepoTag>>> = + list(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see list */ + fun list(params: TagListParams): CompletableFuture<HttpResponseFor<List<RepoTag>>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: TagListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<RepoTag>>> + + /** + * Returns a raw HTTP response for `delete /api/v1/repos/{owner}/{repo}/tags/{tag_name}`, + * but is otherwise the same as [TagServiceAsync.delete]. + */ + fun delete( + tagName: String, + params: TagDeleteParams, + ): CompletableFuture<HttpResponseFor<TagDeleteResponse>> = + delete(tagName, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + tagName: String, + params: TagDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<TagDeleteResponse>> = + delete(params.toBuilder().tagName(tagName).build(), requestOptions) + + /** @see delete */ + fun delete(params: TagDeleteParams): CompletableFuture<HttpResponseFor<TagDeleteResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: TagDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<TagDeleteResponse>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/repos/TagServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/repos/TagServiceAsyncImpl.kt new file mode 100644 index 00000000..188c1b40 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/repos/TagServiceAsyncImpl.kt @@ -0,0 +1,294 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.repos + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.repos.tags.RepoTag +import com.langsmith_api.api.models.api.v1.repos.tags.TagCreateParams +import com.langsmith_api.api.models.api.v1.repos.tags.TagDeleteParams +import com.langsmith_api.api.models.api.v1.repos.tags.TagDeleteResponse +import com.langsmith_api.api.models.api.v1.repos.tags.TagListParams +import com.langsmith_api.api.models.api.v1.repos.tags.TagRetrieveParams +import com.langsmith_api.api.models.api.v1.repos.tags.TagUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class TagServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + TagServiceAsync { + + private val withRawResponse: TagServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): TagServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): TagServiceAsync = + TagServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: TagCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<RepoTag> = + // post /api/v1/repos/{owner}/{repo}/tags + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun retrieve( + params: TagRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<RepoTag> = + // get /api/v1/repos/{owner}/{repo}/tags/{tag_name} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: TagUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<RepoTag> = + // patch /api/v1/repos/{owner}/{repo}/tags/{tag_name} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: TagListParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<RepoTag>> = + // get /api/v1/repos/{owner}/{repo}/tags + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: TagDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<TagDeleteResponse> = + // delete /api/v1/repos/{owner}/{repo}/tags/{tag_name} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TagServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): TagServiceAsync.WithRawResponse = + TagServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<RepoTag> = jsonHandler<RepoTag>(clientOptions.jsonMapper) + + override fun create( + params: TagCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<RepoTag>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("repo", params.repo().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "repos", + params._pathParam(0), + params._pathParam(1), + "tags", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler<RepoTag> = + jsonHandler<RepoTag>(clientOptions.jsonMapper) + + override fun retrieve( + params: TagRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<RepoTag>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tagName", params.tagName().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "repos", + params._pathParam(0), + params._pathParam(1), + "tags", + params._pathParam(2), + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler<RepoTag> = jsonHandler<RepoTag>(clientOptions.jsonMapper) + + override fun update( + params: TagUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<RepoTag>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tagName", params.tagName().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "repos", + params._pathParam(0), + params._pathParam(1), + "tags", + params._pathParam(2), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler<List<RepoTag>> = + jsonHandler<List<RepoTag>>(clientOptions.jsonMapper) + + override fun list( + params: TagListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<RepoTag>>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("repo", params.repo().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "repos", + params._pathParam(0), + params._pathParam(1), + "tags", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val deleteHandler: Handler<TagDeleteResponse> = + jsonHandler<TagDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: TagDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<TagDeleteResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tagName", params.tagName().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "repos", + params._pathParam(0), + params._pathParam(1), + "tags", + params._pathParam(2), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/repos/optimizationjobs/LogServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/repos/optimizationjobs/LogServiceAsync.kt new file mode 100644 index 00000000..089d79a9 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/repos/optimizationjobs/LogServiceAsync.kt @@ -0,0 +1,258 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.repos.optimizationjobs + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs.LogCreateParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs.LogDeleteParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs.LogDeleteResponse +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs.LogListParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs.LogRetrieveParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs.PromptOptimizationJobLog +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface LogServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): LogServiceAsync + + /** Create a new log entry for a prompt optimization job. */ + fun create( + jobId: String, + params: LogCreateParams, + ): CompletableFuture<PromptOptimizationJobLog> = create(jobId, params, RequestOptions.none()) + + /** @see create */ + fun create( + jobId: String, + params: LogCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<PromptOptimizationJobLog> = + create(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see create */ + fun create(params: LogCreateParams): CompletableFuture<PromptOptimizationJobLog> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: LogCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<PromptOptimizationJobLog> + + /** Get a specific prompt optimization job log. */ + fun retrieve( + logId: String, + params: LogRetrieveParams, + ): CompletableFuture<PromptOptimizationJobLog> = retrieve(logId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + logId: String, + params: LogRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<PromptOptimizationJobLog> = + retrieve(params.toBuilder().logId(logId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: LogRetrieveParams): CompletableFuture<PromptOptimizationJobLog> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: LogRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<PromptOptimizationJobLog> + + /** List all logs for a specific prompt optimization job. */ + fun list( + jobId: String, + params: LogListParams, + ): CompletableFuture<List<PromptOptimizationJobLog>> = + list(jobId, params, RequestOptions.none()) + + /** @see list */ + fun list( + jobId: String, + params: LogListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<PromptOptimizationJobLog>> = + list(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see list */ + fun list(params: LogListParams): CompletableFuture<List<PromptOptimizationJobLog>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: LogListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<PromptOptimizationJobLog>> + + /** Delete a prompt optimization job log. */ + fun delete(logId: String, params: LogDeleteParams): CompletableFuture<LogDeleteResponse> = + delete(logId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + logId: String, + params: LogDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<LogDeleteResponse> = + delete(params.toBuilder().logId(logId).build(), requestOptions) + + /** @see delete */ + fun delete(params: LogDeleteParams): CompletableFuture<LogDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: LogDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<LogDeleteResponse> + + /** A view of [LogServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): LogServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post + * /api/v1/repos/{owner}/{repo}/optimization-jobs/{job_id}/logs`, but is otherwise the same + * as [LogServiceAsync.create]. + */ + fun create( + jobId: String, + params: LogCreateParams, + ): CompletableFuture<HttpResponseFor<PromptOptimizationJobLog>> = + create(jobId, params, RequestOptions.none()) + + /** @see create */ + fun create( + jobId: String, + params: LogCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<PromptOptimizationJobLog>> = + create(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see create */ + fun create( + params: LogCreateParams + ): CompletableFuture<HttpResponseFor<PromptOptimizationJobLog>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: LogCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<PromptOptimizationJobLog>> + + /** + * Returns a raw HTTP response for `get + * /api/v1/repos/{owner}/{repo}/optimization-jobs/{job_id}/logs/{log_id}`, but is otherwise + * the same as [LogServiceAsync.retrieve]. + */ + fun retrieve( + logId: String, + params: LogRetrieveParams, + ): CompletableFuture<HttpResponseFor<PromptOptimizationJobLog>> = + retrieve(logId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + logId: String, + params: LogRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<PromptOptimizationJobLog>> = + retrieve(params.toBuilder().logId(logId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + params: LogRetrieveParams + ): CompletableFuture<HttpResponseFor<PromptOptimizationJobLog>> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: LogRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<PromptOptimizationJobLog>> + + /** + * Returns a raw HTTP response for `get + * /api/v1/repos/{owner}/{repo}/optimization-jobs/{job_id}/logs`, but is otherwise the same + * as [LogServiceAsync.list]. + */ + fun list( + jobId: String, + params: LogListParams, + ): CompletableFuture<HttpResponseFor<List<PromptOptimizationJobLog>>> = + list(jobId, params, RequestOptions.none()) + + /** @see list */ + fun list( + jobId: String, + params: LogListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<PromptOptimizationJobLog>>> = + list(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see list */ + fun list( + params: LogListParams + ): CompletableFuture<HttpResponseFor<List<PromptOptimizationJobLog>>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: LogListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<PromptOptimizationJobLog>>> + + /** + * Returns a raw HTTP response for `delete + * /api/v1/repos/{owner}/{repo}/optimization-jobs/{job_id}/logs/{log_id}`, but is otherwise + * the same as [LogServiceAsync.delete]. + */ + fun delete( + logId: String, + params: LogDeleteParams, + ): CompletableFuture<HttpResponseFor<LogDeleteResponse>> = + delete(logId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + logId: String, + params: LogDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<LogDeleteResponse>> = + delete(params.toBuilder().logId(logId).build(), requestOptions) + + /** @see delete */ + fun delete(params: LogDeleteParams): CompletableFuture<HttpResponseFor<LogDeleteResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: LogDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<LogDeleteResponse>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/repos/optimizationjobs/LogServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/repos/optimizationjobs/LogServiceAsyncImpl.kt new file mode 100644 index 00000000..1816b9ff --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/repos/optimizationjobs/LogServiceAsyncImpl.kt @@ -0,0 +1,254 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.repos.optimizationjobs + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs.LogCreateParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs.LogDeleteParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs.LogDeleteResponse +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs.LogListParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs.LogRetrieveParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs.PromptOptimizationJobLog +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class LogServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + LogServiceAsync { + + private val withRawResponse: LogServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): LogServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): LogServiceAsync = + LogServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: LogCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<PromptOptimizationJobLog> = + // post /api/v1/repos/{owner}/{repo}/optimization-jobs/{job_id}/logs + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun retrieve( + params: LogRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<PromptOptimizationJobLog> = + // get /api/v1/repos/{owner}/{repo}/optimization-jobs/{job_id}/logs/{log_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: LogListParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<PromptOptimizationJobLog>> = + // get /api/v1/repos/{owner}/{repo}/optimization-jobs/{job_id}/logs + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: LogDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<LogDeleteResponse> = + // delete /api/v1/repos/{owner}/{repo}/optimization-jobs/{job_id}/logs/{log_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + LogServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): LogServiceAsync.WithRawResponse = + LogServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<PromptOptimizationJobLog> = + jsonHandler<PromptOptimizationJobLog>(clientOptions.jsonMapper) + + override fun create( + params: LogCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<PromptOptimizationJobLog>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("jobId", params.jobId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "repos", + params._pathParam(0), + params._pathParam(1), + "optimization-jobs", + params._pathParam(2), + "logs", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler<PromptOptimizationJobLog> = + jsonHandler<PromptOptimizationJobLog>(clientOptions.jsonMapper) + + override fun retrieve( + params: LogRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<PromptOptimizationJobLog>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("logId", params.logId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "repos", + params._pathParam(0), + params._pathParam(1), + "optimization-jobs", + params._pathParam(2), + "logs", + params._pathParam(3), + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler<List<PromptOptimizationJobLog>> = + jsonHandler<List<PromptOptimizationJobLog>>(clientOptions.jsonMapper) + + override fun list( + params: LogListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<PromptOptimizationJobLog>>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("jobId", params.jobId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "repos", + params._pathParam(0), + params._pathParam(1), + "optimization-jobs", + params._pathParam(2), + "logs", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val deleteHandler: Handler<LogDeleteResponse> = + jsonHandler<LogDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: LogDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<LogDeleteResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("logId", params.logId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "repos", + params._pathParam(0), + params._pathParam(1), + "optimization-jobs", + params._pathParam(2), + "logs", + params._pathParam(3), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/runs/GroupServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/runs/GroupServiceAsync.kt new file mode 100644 index 00000000..72cf33e6 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/runs/GroupServiceAsync.kt @@ -0,0 +1,146 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.runs + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.runs.group.GroupCreateParams +import com.langsmith_api.api.models.api.v1.runs.group.GroupCreateResponse +import com.langsmith_api.api.models.api.v1.runs.group.GroupStatsParams +import com.langsmith_api.api.models.api.v1.runs.group.GroupStatsResponse +import com.langsmith_api.api.models.api.v1.runs.group.RunGroupRequest +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface GroupServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): GroupServiceAsync + + /** Get runs grouped by an expression */ + fun create(params: GroupCreateParams): CompletableFuture<GroupCreateResponse> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: GroupCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<GroupCreateResponse> + + /** @see create */ + fun create( + runGroupRequest: RunGroupRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<GroupCreateResponse> = + create(GroupCreateParams.builder().runGroupRequest(runGroupRequest).build(), requestOptions) + + /** @see create */ + fun create(runGroupRequest: RunGroupRequest): CompletableFuture<GroupCreateResponse> = + create(runGroupRequest, RequestOptions.none()) + + /** Get stats for the grouped runs. */ + fun stats(params: GroupStatsParams): CompletableFuture<GroupStatsResponse> = + stats(params, RequestOptions.none()) + + /** @see stats */ + fun stats( + params: GroupStatsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<GroupStatsResponse> + + /** @see stats */ + fun stats( + runGroupRequest: RunGroupRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<GroupStatsResponse> = + stats(GroupStatsParams.builder().runGroupRequest(runGroupRequest).build(), requestOptions) + + /** @see stats */ + fun stats(runGroupRequest: RunGroupRequest): CompletableFuture<GroupStatsResponse> = + stats(runGroupRequest, RequestOptions.none()) + + /** A view of [GroupServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): GroupServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/runs/group`, but is otherwise the same as + * [GroupServiceAsync.create]. + */ + fun create( + params: GroupCreateParams + ): CompletableFuture<HttpResponseFor<GroupCreateResponse>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: GroupCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<GroupCreateResponse>> + + /** @see create */ + fun create( + runGroupRequest: RunGroupRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<GroupCreateResponse>> = + create( + GroupCreateParams.builder().runGroupRequest(runGroupRequest).build(), + requestOptions, + ) + + /** @see create */ + fun create( + runGroupRequest: RunGroupRequest + ): CompletableFuture<HttpResponseFor<GroupCreateResponse>> = + create(runGroupRequest, RequestOptions.none()) + + /** + * Returns a raw HTTP response for `post /api/v1/runs/group/stats`, but is otherwise the + * same as [GroupServiceAsync.stats]. + */ + fun stats( + params: GroupStatsParams + ): CompletableFuture<HttpResponseFor<GroupStatsResponse>> = + stats(params, RequestOptions.none()) + + /** @see stats */ + fun stats( + params: GroupStatsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<GroupStatsResponse>> + + /** @see stats */ + fun stats( + runGroupRequest: RunGroupRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<GroupStatsResponse>> = + stats( + GroupStatsParams.builder().runGroupRequest(runGroupRequest).build(), + requestOptions, + ) + + /** @see stats */ + fun stats( + runGroupRequest: RunGroupRequest + ): CompletableFuture<HttpResponseFor<GroupStatsResponse>> = + stats(runGroupRequest, RequestOptions.none()) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/runs/GroupServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/runs/GroupServiceAsyncImpl.kt new file mode 100644 index 00000000..1ca36ec4 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/runs/GroupServiceAsyncImpl.kt @@ -0,0 +1,126 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.runs + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.runs.group.GroupCreateParams +import com.langsmith_api.api.models.api.v1.runs.group.GroupCreateResponse +import com.langsmith_api.api.models.api.v1.runs.group.GroupStatsParams +import com.langsmith_api.api.models.api.v1.runs.group.GroupStatsResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class GroupServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + GroupServiceAsync { + + private val withRawResponse: GroupServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): GroupServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): GroupServiceAsync = + GroupServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: GroupCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<GroupCreateResponse> = + // post /api/v1/runs/group + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun stats( + params: GroupStatsParams, + requestOptions: RequestOptions, + ): CompletableFuture<GroupStatsResponse> = + // post /api/v1/runs/group/stats + withRawResponse().stats(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + GroupServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): GroupServiceAsync.WithRawResponse = + GroupServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<GroupCreateResponse> = + jsonHandler<GroupCreateResponse>(clientOptions.jsonMapper) + + override fun create( + params: GroupCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<GroupCreateResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", "group") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val statsHandler: Handler<GroupStatsResponse> = + jsonHandler<GroupStatsResponse>(clientOptions.jsonMapper) + + override fun stats( + params: GroupStatsParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<GroupStatsResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", "group", "stats") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { statsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/runs/RuleServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/runs/RuleServiceAsync.kt new file mode 100644 index 00000000..0a6f9323 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/runs/RuleServiceAsync.kt @@ -0,0 +1,394 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.runs + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.runs.rules.RuleCreateParams +import com.langsmith_api.api.models.api.v1.runs.rules.RuleDeleteParams +import com.langsmith_api.api.models.api.v1.runs.rules.RuleDeleteResponse +import com.langsmith_api.api.models.api.v1.runs.rules.RuleListParams +import com.langsmith_api.api.models.api.v1.runs.rules.RuleLogSchema +import com.langsmith_api.api.models.api.v1.runs.rules.RuleRetrieveLastAppliedParams +import com.langsmith_api.api.models.api.v1.runs.rules.RuleRetrieveLogsParams +import com.langsmith_api.api.models.api.v1.runs.rules.RuleUpdateParams +import com.langsmith_api.api.models.api.v1.runs.rules.RunRulesSchema +import com.langsmith_api.api.services.async.api.v1.runs.rules.TriggerServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface RuleServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RuleServiceAsync + + fun trigger(): TriggerServiceAsync + + /** Create a new run rule. */ + fun create(params: RuleCreateParams): CompletableFuture<RunRulesSchema> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: RuleCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RunRulesSchema> + + /** Update a run rule. */ + fun update(ruleId: String, params: RuleUpdateParams): CompletableFuture<RunRulesSchema> = + update(ruleId, params, RequestOptions.none()) + + /** @see update */ + fun update( + ruleId: String, + params: RuleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RunRulesSchema> = + update(params.toBuilder().ruleId(ruleId).build(), requestOptions) + + /** @see update */ + fun update(params: RuleUpdateParams): CompletableFuture<RunRulesSchema> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: RuleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RunRulesSchema> + + /** List all run rules. */ + fun list(): CompletableFuture<List<RunRulesSchema>> = list(RuleListParams.none()) + + /** @see list */ + fun list( + params: RuleListParams = RuleListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<RunRulesSchema>> + + /** @see list */ + fun list( + params: RuleListParams = RuleListParams.none() + ): CompletableFuture<List<RunRulesSchema>> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture<List<RunRulesSchema>> = + list(RuleListParams.none(), requestOptions) + + /** Delete a run rule. */ + fun delete(ruleId: String): CompletableFuture<RuleDeleteResponse> = + delete(ruleId, RuleDeleteParams.none()) + + /** @see delete */ + fun delete( + ruleId: String, + params: RuleDeleteParams = RuleDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RuleDeleteResponse> = + delete(params.toBuilder().ruleId(ruleId).build(), requestOptions) + + /** @see delete */ + fun delete( + ruleId: String, + params: RuleDeleteParams = RuleDeleteParams.none(), + ): CompletableFuture<RuleDeleteResponse> = delete(ruleId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: RuleDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RuleDeleteResponse> + + /** @see delete */ + fun delete(params: RuleDeleteParams): CompletableFuture<RuleDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + ruleId: String, + requestOptions: RequestOptions, + ): CompletableFuture<RuleDeleteResponse> = + delete(ruleId, RuleDeleteParams.none(), requestOptions) + + /** Get the last applied rule. */ + fun retrieveLastApplied(ruleId: String): CompletableFuture<RuleLogSchema> = + retrieveLastApplied(ruleId, RuleRetrieveLastAppliedParams.none()) + + /** @see retrieveLastApplied */ + fun retrieveLastApplied( + ruleId: String, + params: RuleRetrieveLastAppliedParams = RuleRetrieveLastAppliedParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RuleLogSchema> = + retrieveLastApplied(params.toBuilder().ruleId(ruleId).build(), requestOptions) + + /** @see retrieveLastApplied */ + fun retrieveLastApplied( + ruleId: String, + params: RuleRetrieveLastAppliedParams = RuleRetrieveLastAppliedParams.none(), + ): CompletableFuture<RuleLogSchema> = retrieveLastApplied(ruleId, params, RequestOptions.none()) + + /** @see retrieveLastApplied */ + fun retrieveLastApplied( + params: RuleRetrieveLastAppliedParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RuleLogSchema> + + /** @see retrieveLastApplied */ + fun retrieveLastApplied( + params: RuleRetrieveLastAppliedParams + ): CompletableFuture<RuleLogSchema> = retrieveLastApplied(params, RequestOptions.none()) + + /** @see retrieveLastApplied */ + fun retrieveLastApplied( + ruleId: String, + requestOptions: RequestOptions, + ): CompletableFuture<RuleLogSchema> = + retrieveLastApplied(ruleId, RuleRetrieveLastAppliedParams.none(), requestOptions) + + /** List logs for a particular rule */ + fun retrieveLogs(ruleId: String): CompletableFuture<List<RuleLogSchema>> = + retrieveLogs(ruleId, RuleRetrieveLogsParams.none()) + + /** @see retrieveLogs */ + fun retrieveLogs( + ruleId: String, + params: RuleRetrieveLogsParams = RuleRetrieveLogsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<RuleLogSchema>> = + retrieveLogs(params.toBuilder().ruleId(ruleId).build(), requestOptions) + + /** @see retrieveLogs */ + fun retrieveLogs( + ruleId: String, + params: RuleRetrieveLogsParams = RuleRetrieveLogsParams.none(), + ): CompletableFuture<List<RuleLogSchema>> = retrieveLogs(ruleId, params, RequestOptions.none()) + + /** @see retrieveLogs */ + fun retrieveLogs( + params: RuleRetrieveLogsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<RuleLogSchema>> + + /** @see retrieveLogs */ + fun retrieveLogs(params: RuleRetrieveLogsParams): CompletableFuture<List<RuleLogSchema>> = + retrieveLogs(params, RequestOptions.none()) + + /** @see retrieveLogs */ + fun retrieveLogs( + ruleId: String, + requestOptions: RequestOptions, + ): CompletableFuture<List<RuleLogSchema>> = + retrieveLogs(ruleId, RuleRetrieveLogsParams.none(), requestOptions) + + /** A view of [RuleServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RuleServiceAsync.WithRawResponse + + fun trigger(): TriggerServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/runs/rules`, but is otherwise the same as + * [RuleServiceAsync.create]. + */ + fun create(params: RuleCreateParams): CompletableFuture<HttpResponseFor<RunRulesSchema>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: RuleCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RunRulesSchema>> + + /** + * Returns a raw HTTP response for `patch /api/v1/runs/rules/{rule_id}`, but is otherwise + * the same as [RuleServiceAsync.update]. + */ + fun update( + ruleId: String, + params: RuleUpdateParams, + ): CompletableFuture<HttpResponseFor<RunRulesSchema>> = + update(ruleId, params, RequestOptions.none()) + + /** @see update */ + fun update( + ruleId: String, + params: RuleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RunRulesSchema>> = + update(params.toBuilder().ruleId(ruleId).build(), requestOptions) + + /** @see update */ + fun update(params: RuleUpdateParams): CompletableFuture<HttpResponseFor<RunRulesSchema>> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: RuleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RunRulesSchema>> + + /** + * Returns a raw HTTP response for `get /api/v1/runs/rules`, but is otherwise the same as + * [RuleServiceAsync.list]. + */ + fun list(): CompletableFuture<HttpResponseFor<List<RunRulesSchema>>> = + list(RuleListParams.none()) + + /** @see list */ + fun list( + params: RuleListParams = RuleListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<RunRulesSchema>>> + + /** @see list */ + fun list( + params: RuleListParams = RuleListParams.none() + ): CompletableFuture<HttpResponseFor<List<RunRulesSchema>>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<RunRulesSchema>>> = + list(RuleListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/runs/rules/{rule_id}`, but is otherwise + * the same as [RuleServiceAsync.delete]. + */ + fun delete(ruleId: String): CompletableFuture<HttpResponseFor<RuleDeleteResponse>> = + delete(ruleId, RuleDeleteParams.none()) + + /** @see delete */ + fun delete( + ruleId: String, + params: RuleDeleteParams = RuleDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RuleDeleteResponse>> = + delete(params.toBuilder().ruleId(ruleId).build(), requestOptions) + + /** @see delete */ + fun delete( + ruleId: String, + params: RuleDeleteParams = RuleDeleteParams.none(), + ): CompletableFuture<HttpResponseFor<RuleDeleteResponse>> = + delete(ruleId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: RuleDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RuleDeleteResponse>> + + /** @see delete */ + fun delete( + params: RuleDeleteParams + ): CompletableFuture<HttpResponseFor<RuleDeleteResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + ruleId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<RuleDeleteResponse>> = + delete(ruleId, RuleDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/runs/rules/{rule_id}/last_applied`, but is + * otherwise the same as [RuleServiceAsync.retrieveLastApplied]. + */ + fun retrieveLastApplied(ruleId: String): CompletableFuture<HttpResponseFor<RuleLogSchema>> = + retrieveLastApplied(ruleId, RuleRetrieveLastAppliedParams.none()) + + /** @see retrieveLastApplied */ + fun retrieveLastApplied( + ruleId: String, + params: RuleRetrieveLastAppliedParams = RuleRetrieveLastAppliedParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RuleLogSchema>> = + retrieveLastApplied(params.toBuilder().ruleId(ruleId).build(), requestOptions) + + /** @see retrieveLastApplied */ + fun retrieveLastApplied( + ruleId: String, + params: RuleRetrieveLastAppliedParams = RuleRetrieveLastAppliedParams.none(), + ): CompletableFuture<HttpResponseFor<RuleLogSchema>> = + retrieveLastApplied(ruleId, params, RequestOptions.none()) + + /** @see retrieveLastApplied */ + fun retrieveLastApplied( + params: RuleRetrieveLastAppliedParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RuleLogSchema>> + + /** @see retrieveLastApplied */ + fun retrieveLastApplied( + params: RuleRetrieveLastAppliedParams + ): CompletableFuture<HttpResponseFor<RuleLogSchema>> = + retrieveLastApplied(params, RequestOptions.none()) + + /** @see retrieveLastApplied */ + fun retrieveLastApplied( + ruleId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<RuleLogSchema>> = + retrieveLastApplied(ruleId, RuleRetrieveLastAppliedParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/runs/rules/{rule_id}/logs`, but is otherwise + * the same as [RuleServiceAsync.retrieveLogs]. + */ + fun retrieveLogs(ruleId: String): CompletableFuture<HttpResponseFor<List<RuleLogSchema>>> = + retrieveLogs(ruleId, RuleRetrieveLogsParams.none()) + + /** @see retrieveLogs */ + fun retrieveLogs( + ruleId: String, + params: RuleRetrieveLogsParams = RuleRetrieveLogsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<RuleLogSchema>>> = + retrieveLogs(params.toBuilder().ruleId(ruleId).build(), requestOptions) + + /** @see retrieveLogs */ + fun retrieveLogs( + ruleId: String, + params: RuleRetrieveLogsParams = RuleRetrieveLogsParams.none(), + ): CompletableFuture<HttpResponseFor<List<RuleLogSchema>>> = + retrieveLogs(ruleId, params, RequestOptions.none()) + + /** @see retrieveLogs */ + fun retrieveLogs( + params: RuleRetrieveLogsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<RuleLogSchema>>> + + /** @see retrieveLogs */ + fun retrieveLogs( + params: RuleRetrieveLogsParams + ): CompletableFuture<HttpResponseFor<List<RuleLogSchema>>> = + retrieveLogs(params, RequestOptions.none()) + + /** @see retrieveLogs */ + fun retrieveLogs( + ruleId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<RuleLogSchema>>> = + retrieveLogs(ruleId, RuleRetrieveLogsParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/runs/RuleServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/runs/RuleServiceAsyncImpl.kt new file mode 100644 index 00000000..97c27756 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/runs/RuleServiceAsyncImpl.kt @@ -0,0 +1,313 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.runs + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.runs.rules.RuleCreateParams +import com.langsmith_api.api.models.api.v1.runs.rules.RuleDeleteParams +import com.langsmith_api.api.models.api.v1.runs.rules.RuleDeleteResponse +import com.langsmith_api.api.models.api.v1.runs.rules.RuleListParams +import com.langsmith_api.api.models.api.v1.runs.rules.RuleLogSchema +import com.langsmith_api.api.models.api.v1.runs.rules.RuleRetrieveLastAppliedParams +import com.langsmith_api.api.models.api.v1.runs.rules.RuleRetrieveLogsParams +import com.langsmith_api.api.models.api.v1.runs.rules.RuleUpdateParams +import com.langsmith_api.api.models.api.v1.runs.rules.RunRulesSchema +import com.langsmith_api.api.services.async.api.v1.runs.rules.TriggerServiceAsync +import com.langsmith_api.api.services.async.api.v1.runs.rules.TriggerServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class RuleServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + RuleServiceAsync { + + private val withRawResponse: RuleServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val trigger: TriggerServiceAsync by lazy { TriggerServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): RuleServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): RuleServiceAsync = + RuleServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun trigger(): TriggerServiceAsync = trigger + + override fun create( + params: RuleCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<RunRulesSchema> = + // post /api/v1/runs/rules + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: RuleUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<RunRulesSchema> = + // patch /api/v1/runs/rules/{rule_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: RuleListParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<RunRulesSchema>> = + // get /api/v1/runs/rules + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: RuleDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<RuleDeleteResponse> = + // delete /api/v1/runs/rules/{rule_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + override fun retrieveLastApplied( + params: RuleRetrieveLastAppliedParams, + requestOptions: RequestOptions, + ): CompletableFuture<RuleLogSchema> = + // get /api/v1/runs/rules/{rule_id}/last_applied + withRawResponse().retrieveLastApplied(params, requestOptions).thenApply { it.parse() } + + override fun retrieveLogs( + params: RuleRetrieveLogsParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<RuleLogSchema>> = + // get /api/v1/runs/rules/{rule_id}/logs + withRawResponse().retrieveLogs(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RuleServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val trigger: TriggerServiceAsync.WithRawResponse by lazy { + TriggerServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): RuleServiceAsync.WithRawResponse = + RuleServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun trigger(): TriggerServiceAsync.WithRawResponse = trigger + + private val createHandler: Handler<RunRulesSchema> = + jsonHandler<RunRulesSchema>(clientOptions.jsonMapper) + + override fun create( + params: RuleCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<RunRulesSchema>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", "rules") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler<RunRulesSchema> = + jsonHandler<RunRulesSchema>(clientOptions.jsonMapper) + + override fun update( + params: RuleUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<RunRulesSchema>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("ruleId", params.ruleId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", "rules", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler<List<RunRulesSchema>> = + jsonHandler<List<RunRulesSchema>>(clientOptions.jsonMapper) + + override fun list( + params: RuleListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<RunRulesSchema>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", "rules") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val deleteHandler: Handler<RuleDeleteResponse> = + jsonHandler<RuleDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: RuleDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<RuleDeleteResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("ruleId", params.ruleId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", "rules", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveLastAppliedHandler: Handler<RuleLogSchema> = + jsonHandler<RuleLogSchema>(clientOptions.jsonMapper) + + override fun retrieveLastApplied( + params: RuleRetrieveLastAppliedParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<RuleLogSchema>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("ruleId", params.ruleId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "runs", + "rules", + params._pathParam(0), + "last_applied", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveLastAppliedHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveLogsHandler: Handler<List<RuleLogSchema>> = + jsonHandler<List<RuleLogSchema>>(clientOptions.jsonMapper) + + override fun retrieveLogs( + params: RuleRetrieveLogsParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<RuleLogSchema>>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("ruleId", params.ruleId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", "rules", params._pathParam(0), "logs") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveLogsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/runs/ShareServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/runs/ShareServiceAsync.kt new file mode 100644 index 00000000..58e4b017 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/runs/ShareServiceAsync.kt @@ -0,0 +1,266 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.runs + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.runs.share.RunShareSchema +import com.langsmith_api.api.models.api.v1.runs.share.ShareCreateParams +import com.langsmith_api.api.models.api.v1.runs.share.ShareDeleteAllParams +import com.langsmith_api.api.models.api.v1.runs.share.ShareDeleteAllResponse +import com.langsmith_api.api.models.api.v1.runs.share.ShareListParams +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface ShareServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ShareServiceAsync + + /** Share a run. */ + fun create(runId: String): CompletableFuture<RunShareSchema> = + create(runId, ShareCreateParams.none()) + + /** @see create */ + fun create( + runId: String, + params: ShareCreateParams = ShareCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RunShareSchema> = + create(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see create */ + fun create( + runId: String, + params: ShareCreateParams = ShareCreateParams.none(), + ): CompletableFuture<RunShareSchema> = create(runId, params, RequestOptions.none()) + + /** @see create */ + fun create( + params: ShareCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<RunShareSchema> + + /** @see create */ + fun create(params: ShareCreateParams): CompletableFuture<RunShareSchema> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create(runId: String, requestOptions: RequestOptions): CompletableFuture<RunShareSchema> = + create(runId, ShareCreateParams.none(), requestOptions) + + /** Get the state of sharing of a run. */ + fun list(runId: String): CompletableFuture<Optional<RunShareSchema>> = + list(runId, ShareListParams.none()) + + /** @see list */ + fun list( + runId: String, + params: ShareListParams = ShareListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<Optional<RunShareSchema>> = + list(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see list */ + fun list( + runId: String, + params: ShareListParams = ShareListParams.none(), + ): CompletableFuture<Optional<RunShareSchema>> = list(runId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: ShareListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<Optional<RunShareSchema>> + + /** @see list */ + fun list(params: ShareListParams): CompletableFuture<Optional<RunShareSchema>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + runId: String, + requestOptions: RequestOptions, + ): CompletableFuture<Optional<RunShareSchema>> = + list(runId, ShareListParams.none(), requestOptions) + + /** Unshare a run. */ + fun deleteAll(runId: String): CompletableFuture<ShareDeleteAllResponse> = + deleteAll(runId, ShareDeleteAllParams.none()) + + /** @see deleteAll */ + fun deleteAll( + runId: String, + params: ShareDeleteAllParams = ShareDeleteAllParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ShareDeleteAllResponse> = + deleteAll(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see deleteAll */ + fun deleteAll( + runId: String, + params: ShareDeleteAllParams = ShareDeleteAllParams.none(), + ): CompletableFuture<ShareDeleteAllResponse> = deleteAll(runId, params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + params: ShareDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ShareDeleteAllResponse> + + /** @see deleteAll */ + fun deleteAll(params: ShareDeleteAllParams): CompletableFuture<ShareDeleteAllResponse> = + deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + runId: String, + requestOptions: RequestOptions, + ): CompletableFuture<ShareDeleteAllResponse> = + deleteAll(runId, ShareDeleteAllParams.none(), requestOptions) + + /** A view of [ShareServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ShareServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `put /api/v1/runs/{run_id}/share`, but is otherwise the + * same as [ShareServiceAsync.create]. + */ + fun create(runId: String): CompletableFuture<HttpResponseFor<RunShareSchema>> = + create(runId, ShareCreateParams.none()) + + /** @see create */ + fun create( + runId: String, + params: ShareCreateParams = ShareCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RunShareSchema>> = + create(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see create */ + fun create( + runId: String, + params: ShareCreateParams = ShareCreateParams.none(), + ): CompletableFuture<HttpResponseFor<RunShareSchema>> = + create(runId, params, RequestOptions.none()) + + /** @see create */ + fun create( + params: ShareCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<RunShareSchema>> + + /** @see create */ + fun create(params: ShareCreateParams): CompletableFuture<HttpResponseFor<RunShareSchema>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + runId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<RunShareSchema>> = + create(runId, ShareCreateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/runs/{run_id}/share`, but is otherwise the + * same as [ShareServiceAsync.list]. + */ + fun list(runId: String): CompletableFuture<HttpResponseFor<Optional<RunShareSchema>>> = + list(runId, ShareListParams.none()) + + /** @see list */ + fun list( + runId: String, + params: ShareListParams = ShareListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<Optional<RunShareSchema>>> = + list(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see list */ + fun list( + runId: String, + params: ShareListParams = ShareListParams.none(), + ): CompletableFuture<HttpResponseFor<Optional<RunShareSchema>>> = + list(runId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: ShareListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<Optional<RunShareSchema>>> + + /** @see list */ + fun list( + params: ShareListParams + ): CompletableFuture<HttpResponseFor<Optional<RunShareSchema>>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + runId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<Optional<RunShareSchema>>> = + list(runId, ShareListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/runs/{run_id}/share`, but is otherwise + * the same as [ShareServiceAsync.deleteAll]. + */ + fun deleteAll(runId: String): CompletableFuture<HttpResponseFor<ShareDeleteAllResponse>> = + deleteAll(runId, ShareDeleteAllParams.none()) + + /** @see deleteAll */ + fun deleteAll( + runId: String, + params: ShareDeleteAllParams = ShareDeleteAllParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ShareDeleteAllResponse>> = + deleteAll(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see deleteAll */ + fun deleteAll( + runId: String, + params: ShareDeleteAllParams = ShareDeleteAllParams.none(), + ): CompletableFuture<HttpResponseFor<ShareDeleteAllResponse>> = + deleteAll(runId, params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + params: ShareDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ShareDeleteAllResponse>> + + /** @see deleteAll */ + fun deleteAll( + params: ShareDeleteAllParams + ): CompletableFuture<HttpResponseFor<ShareDeleteAllResponse>> = + deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + runId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ShareDeleteAllResponse>> = + deleteAll(runId, ShareDeleteAllParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/runs/ShareServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/runs/ShareServiceAsyncImpl.kt new file mode 100644 index 00000000..2b7a41f7 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/runs/ShareServiceAsyncImpl.kt @@ -0,0 +1,176 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.runs + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.runs.share.RunShareSchema +import com.langsmith_api.api.models.api.v1.runs.share.ShareCreateParams +import com.langsmith_api.api.models.api.v1.runs.share.ShareDeleteAllParams +import com.langsmith_api.api.models.api.v1.runs.share.ShareDeleteAllResponse +import com.langsmith_api.api.models.api.v1.runs.share.ShareListParams +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ShareServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ShareServiceAsync { + + private val withRawResponse: ShareServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ShareServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): ShareServiceAsync = + ShareServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: ShareCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<RunShareSchema> = + // put /api/v1/runs/{run_id}/share + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: ShareListParams, + requestOptions: RequestOptions, + ): CompletableFuture<Optional<RunShareSchema>> = + // get /api/v1/runs/{run_id}/share + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun deleteAll( + params: ShareDeleteAllParams, + requestOptions: RequestOptions, + ): CompletableFuture<ShareDeleteAllResponse> = + // delete /api/v1/runs/{run_id}/share + withRawResponse().deleteAll(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ShareServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ShareServiceAsync.WithRawResponse = + ShareServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<RunShareSchema> = + jsonHandler<RunShareSchema>(clientOptions.jsonMapper) + + override fun create( + params: ShareCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<RunShareSchema>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("runId", params.runId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", params._pathParam(0), "share") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler<Optional<RunShareSchema>> = + jsonHandler<Optional<RunShareSchema>>(clientOptions.jsonMapper) + + override fun list( + params: ShareListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<Optional<RunShareSchema>>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("runId", params.runId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", params._pathParam(0), "share") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.ifPresent { it.validate() } + } + } + } + } + } + + private val deleteAllHandler: Handler<ShareDeleteAllResponse> = + jsonHandler<ShareDeleteAllResponse>(clientOptions.jsonMapper) + + override fun deleteAll( + params: ShareDeleteAllParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ShareDeleteAllResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("runId", params.runId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", params._pathParam(0), "share") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteAllHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/runs/rules/TriggerServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/runs/rules/TriggerServiceAsync.kt new file mode 100644 index 00000000..b257b198 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/runs/rules/TriggerServiceAsync.kt @@ -0,0 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.runs.rules + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.runs.rules.trigger.TriggerCreateParams +import com.langsmith_api.api.models.api.v1.runs.rules.trigger.TriggerCreateResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface TriggerServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): TriggerServiceAsync + + /** Trigger an array of run rules manually. */ + fun create(): CompletableFuture<TriggerCreateResponse> = create(TriggerCreateParams.none()) + + /** @see create */ + fun create( + params: TriggerCreateParams = TriggerCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<TriggerCreateResponse> + + /** @see create */ + fun create( + params: TriggerCreateParams = TriggerCreateParams.none() + ): CompletableFuture<TriggerCreateResponse> = create(params, RequestOptions.none()) + + /** @see create */ + fun create(requestOptions: RequestOptions): CompletableFuture<TriggerCreateResponse> = + create(TriggerCreateParams.none(), requestOptions) + + /** + * A view of [TriggerServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): TriggerServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/runs/rules/trigger`, but is otherwise the + * same as [TriggerServiceAsync.create]. + */ + fun create(): CompletableFuture<HttpResponseFor<TriggerCreateResponse>> = + create(TriggerCreateParams.none()) + + /** @see create */ + fun create( + params: TriggerCreateParams = TriggerCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<TriggerCreateResponse>> + + /** @see create */ + fun create( + params: TriggerCreateParams = TriggerCreateParams.none() + ): CompletableFuture<HttpResponseFor<TriggerCreateResponse>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<TriggerCreateResponse>> = + create(TriggerCreateParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/runs/rules/TriggerServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/runs/rules/TriggerServiceAsyncImpl.kt new file mode 100644 index 00000000..bee9ca1c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/runs/rules/TriggerServiceAsyncImpl.kt @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.runs.rules + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.runs.rules.trigger.TriggerCreateParams +import com.langsmith_api.api.models.api.v1.runs.rules.trigger.TriggerCreateResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class TriggerServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + TriggerServiceAsync { + + private val withRawResponse: TriggerServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): TriggerServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): TriggerServiceAsync = + TriggerServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: TriggerCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<TriggerCreateResponse> = + // post /api/v1/runs/rules/trigger + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TriggerServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): TriggerServiceAsync.WithRawResponse = + TriggerServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<TriggerCreateResponse> = + jsonHandler<TriggerCreateResponse>(clientOptions.jsonMapper) + + override fun create( + params: TriggerCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<TriggerCreateResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", "rules", "trigger") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/sessions/InsightServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/sessions/InsightServiceAsync.kt new file mode 100644 index 00000000..46c781c0 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/sessions/InsightServiceAsync.kt @@ -0,0 +1,407 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.sessions + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightCreateParams +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightCreateResponse +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightDeleteParams +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightDeleteResponse +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightListParams +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightListResponse +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightRetrieveParams +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightRetrieveResponse +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightRetrieveRunsParams +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightRetrieveRunsResponse +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightUpdateParams +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightUpdateResponse +import com.langsmith_api.api.services.async.api.v1.sessions.insights.ConfigServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface InsightServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): InsightServiceAsync + + fun configs(): ConfigServiceAsync + + /** Create an insights job. */ + fun create( + sessionId: String, + params: InsightCreateParams, + ): CompletableFuture<InsightCreateResponse> = create(sessionId, params, RequestOptions.none()) + + /** @see create */ + fun create( + sessionId: String, + params: InsightCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<InsightCreateResponse> = + create(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see create */ + fun create(params: InsightCreateParams): CompletableFuture<InsightCreateResponse> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: InsightCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<InsightCreateResponse> + + /** Get a specific cluster for a session. */ + fun retrieve( + clusterId: String, + params: InsightRetrieveParams, + ): CompletableFuture<InsightRetrieveResponse> = + retrieve(clusterId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + clusterId: String, + params: InsightRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<InsightRetrieveResponse> = + retrieve(params.toBuilder().clusterId(clusterId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: InsightRetrieveParams): CompletableFuture<InsightRetrieveResponse> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: InsightRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<InsightRetrieveResponse> + + /** Update a session cluster job. */ + fun update( + jobId: String, + params: InsightUpdateParams, + ): CompletableFuture<InsightUpdateResponse> = update(jobId, params, RequestOptions.none()) + + /** @see update */ + fun update( + jobId: String, + params: InsightUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<InsightUpdateResponse> = + update(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see update */ + fun update(params: InsightUpdateParams): CompletableFuture<InsightUpdateResponse> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: InsightUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<InsightUpdateResponse> + + /** Get all clusters for a session. */ + fun list(sessionId: String): CompletableFuture<InsightListResponse> = + list(sessionId, InsightListParams.none()) + + /** @see list */ + fun list( + sessionId: String, + params: InsightListParams = InsightListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<InsightListResponse> = + list(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see list */ + fun list( + sessionId: String, + params: InsightListParams = InsightListParams.none(), + ): CompletableFuture<InsightListResponse> = list(sessionId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: InsightListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<InsightListResponse> + + /** @see list */ + fun list(params: InsightListParams): CompletableFuture<InsightListResponse> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + sessionId: String, + requestOptions: RequestOptions, + ): CompletableFuture<InsightListResponse> = + list(sessionId, InsightListParams.none(), requestOptions) + + /** Delete a session cluster job. */ + fun delete( + jobId: String, + params: InsightDeleteParams, + ): CompletableFuture<InsightDeleteResponse> = delete(jobId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + jobId: String, + params: InsightDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<InsightDeleteResponse> = + delete(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see delete */ + fun delete(params: InsightDeleteParams): CompletableFuture<InsightDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: InsightDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<InsightDeleteResponse> + + /** Get all runs for a cluster job, optionally filtered by cluster. */ + fun retrieveRuns( + jobId: String, + params: InsightRetrieveRunsParams, + ): CompletableFuture<InsightRetrieveRunsResponse> = + retrieveRuns(jobId, params, RequestOptions.none()) + + /** @see retrieveRuns */ + fun retrieveRuns( + jobId: String, + params: InsightRetrieveRunsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<InsightRetrieveRunsResponse> = + retrieveRuns(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see retrieveRuns */ + fun retrieveRuns( + params: InsightRetrieveRunsParams + ): CompletableFuture<InsightRetrieveRunsResponse> = retrieveRuns(params, RequestOptions.none()) + + /** @see retrieveRuns */ + fun retrieveRuns( + params: InsightRetrieveRunsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<InsightRetrieveRunsResponse> + + /** + * A view of [InsightServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): InsightServiceAsync.WithRawResponse + + fun configs(): ConfigServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/sessions/{session_id}/insights`, but is + * otherwise the same as [InsightServiceAsync.create]. + */ + fun create( + sessionId: String, + params: InsightCreateParams, + ): CompletableFuture<HttpResponseFor<InsightCreateResponse>> = + create(sessionId, params, RequestOptions.none()) + + /** @see create */ + fun create( + sessionId: String, + params: InsightCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<InsightCreateResponse>> = + create(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see create */ + fun create( + params: InsightCreateParams + ): CompletableFuture<HttpResponseFor<InsightCreateResponse>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: InsightCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<InsightCreateResponse>> + + /** + * Returns a raw HTTP response for `get + * /api/v1/sessions/{session_id}/insights/{job_id}/clusters/{cluster_id}`, but is otherwise + * the same as [InsightServiceAsync.retrieve]. + */ + fun retrieve( + clusterId: String, + params: InsightRetrieveParams, + ): CompletableFuture<HttpResponseFor<InsightRetrieveResponse>> = + retrieve(clusterId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + clusterId: String, + params: InsightRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<InsightRetrieveResponse>> = + retrieve(params.toBuilder().clusterId(clusterId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + params: InsightRetrieveParams + ): CompletableFuture<HttpResponseFor<InsightRetrieveResponse>> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: InsightRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<InsightRetrieveResponse>> + + /** + * Returns a raw HTTP response for `patch /api/v1/sessions/{session_id}/insights/{job_id}`, + * but is otherwise the same as [InsightServiceAsync.update]. + */ + fun update( + jobId: String, + params: InsightUpdateParams, + ): CompletableFuture<HttpResponseFor<InsightUpdateResponse>> = + update(jobId, params, RequestOptions.none()) + + /** @see update */ + fun update( + jobId: String, + params: InsightUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<InsightUpdateResponse>> = + update(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see update */ + fun update( + params: InsightUpdateParams + ): CompletableFuture<HttpResponseFor<InsightUpdateResponse>> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: InsightUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<InsightUpdateResponse>> + + /** + * Returns a raw HTTP response for `get /api/v1/sessions/{session_id}/insights`, but is + * otherwise the same as [InsightServiceAsync.list]. + */ + fun list(sessionId: String): CompletableFuture<HttpResponseFor<InsightListResponse>> = + list(sessionId, InsightListParams.none()) + + /** @see list */ + fun list( + sessionId: String, + params: InsightListParams = InsightListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<InsightListResponse>> = + list(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see list */ + fun list( + sessionId: String, + params: InsightListParams = InsightListParams.none(), + ): CompletableFuture<HttpResponseFor<InsightListResponse>> = + list(sessionId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: InsightListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<InsightListResponse>> + + /** @see list */ + fun list( + params: InsightListParams + ): CompletableFuture<HttpResponseFor<InsightListResponse>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + sessionId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<InsightListResponse>> = + list(sessionId, InsightListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/sessions/{session_id}/insights/{job_id}`, + * but is otherwise the same as [InsightServiceAsync.delete]. + */ + fun delete( + jobId: String, + params: InsightDeleteParams, + ): CompletableFuture<HttpResponseFor<InsightDeleteResponse>> = + delete(jobId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + jobId: String, + params: InsightDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<InsightDeleteResponse>> = + delete(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see delete */ + fun delete( + params: InsightDeleteParams + ): CompletableFuture<HttpResponseFor<InsightDeleteResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: InsightDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<InsightDeleteResponse>> + + /** + * Returns a raw HTTP response for `get + * /api/v1/sessions/{session_id}/insights/{job_id}/runs`, but is otherwise the same as + * [InsightServiceAsync.retrieveRuns]. + */ + fun retrieveRuns( + jobId: String, + params: InsightRetrieveRunsParams, + ): CompletableFuture<HttpResponseFor<InsightRetrieveRunsResponse>> = + retrieveRuns(jobId, params, RequestOptions.none()) + + /** @see retrieveRuns */ + fun retrieveRuns( + jobId: String, + params: InsightRetrieveRunsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<InsightRetrieveRunsResponse>> = + retrieveRuns(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see retrieveRuns */ + fun retrieveRuns( + params: InsightRetrieveRunsParams + ): CompletableFuture<HttpResponseFor<InsightRetrieveRunsResponse>> = + retrieveRuns(params, RequestOptions.none()) + + /** @see retrieveRuns */ + fun retrieveRuns( + params: InsightRetrieveRunsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<InsightRetrieveRunsResponse>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/sessions/InsightServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/sessions/InsightServiceAsyncImpl.kt new file mode 100644 index 00000000..9d393ae0 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/sessions/InsightServiceAsyncImpl.kt @@ -0,0 +1,346 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.sessions + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightCreateParams +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightCreateResponse +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightDeleteParams +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightDeleteResponse +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightListParams +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightListResponse +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightRetrieveParams +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightRetrieveResponse +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightRetrieveRunsParams +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightRetrieveRunsResponse +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightUpdateParams +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightUpdateResponse +import com.langsmith_api.api.services.async.api.v1.sessions.insights.ConfigServiceAsync +import com.langsmith_api.api.services.async.api.v1.sessions.insights.ConfigServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class InsightServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + InsightServiceAsync { + + private val withRawResponse: InsightServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val configs: ConfigServiceAsync by lazy { ConfigServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): InsightServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): InsightServiceAsync = + InsightServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun configs(): ConfigServiceAsync = configs + + override fun create( + params: InsightCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<InsightCreateResponse> = + // post /api/v1/sessions/{session_id}/insights + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun retrieve( + params: InsightRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<InsightRetrieveResponse> = + // get /api/v1/sessions/{session_id}/insights/{job_id}/clusters/{cluster_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: InsightUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<InsightUpdateResponse> = + // patch /api/v1/sessions/{session_id}/insights/{job_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: InsightListParams, + requestOptions: RequestOptions, + ): CompletableFuture<InsightListResponse> = + // get /api/v1/sessions/{session_id}/insights + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: InsightDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<InsightDeleteResponse> = + // delete /api/v1/sessions/{session_id}/insights/{job_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + override fun retrieveRuns( + params: InsightRetrieveRunsParams, + requestOptions: RequestOptions, + ): CompletableFuture<InsightRetrieveRunsResponse> = + // get /api/v1/sessions/{session_id}/insights/{job_id}/runs + withRawResponse().retrieveRuns(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + InsightServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val configs: ConfigServiceAsync.WithRawResponse by lazy { + ConfigServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): InsightServiceAsync.WithRawResponse = + InsightServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun configs(): ConfigServiceAsync.WithRawResponse = configs + + private val createHandler: Handler<InsightCreateResponse> = + jsonHandler<InsightCreateResponse>(clientOptions.jsonMapper) + + override fun create( + params: InsightCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<InsightCreateResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("sessionId", params.sessionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "sessions", params._pathParam(0), "insights") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler<InsightRetrieveResponse> = + jsonHandler<InsightRetrieveResponse>(clientOptions.jsonMapper) + + override fun retrieve( + params: InsightRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<InsightRetrieveResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("clusterId", params.clusterId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "sessions", + params._pathParam(0), + "insights", + params._pathParam(1), + "clusters", + params._pathParam(2), + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler<InsightUpdateResponse> = + jsonHandler<InsightUpdateResponse>(clientOptions.jsonMapper) + + override fun update( + params: InsightUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<InsightUpdateResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("jobId", params.jobId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "sessions", + params._pathParam(0), + "insights", + params._pathParam(1), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler<InsightListResponse> = + jsonHandler<InsightListResponse>(clientOptions.jsonMapper) + + override fun list( + params: InsightListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<InsightListResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("sessionId", params.sessionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "sessions", params._pathParam(0), "insights") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val deleteHandler: Handler<InsightDeleteResponse> = + jsonHandler<InsightDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: InsightDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<InsightDeleteResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("jobId", params.jobId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "sessions", + params._pathParam(0), + "insights", + params._pathParam(1), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveRunsHandler: Handler<InsightRetrieveRunsResponse> = + jsonHandler<InsightRetrieveRunsResponse>(clientOptions.jsonMapper) + + override fun retrieveRuns( + params: InsightRetrieveRunsParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<InsightRetrieveRunsResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("jobId", params.jobId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "sessions", + params._pathParam(0), + "insights", + params._pathParam(1), + "runs", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveRunsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/sessions/ViewServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/sessions/ViewServiceAsync.kt new file mode 100644 index 00000000..ed231e4f --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/sessions/ViewServiceAsync.kt @@ -0,0 +1,317 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.sessions + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.sessions.views.FilterView +import com.langsmith_api.api.models.api.v1.sessions.views.ViewCreateParams +import com.langsmith_api.api.models.api.v1.sessions.views.ViewDeleteParams +import com.langsmith_api.api.models.api.v1.sessions.views.ViewDeleteResponse +import com.langsmith_api.api.models.api.v1.sessions.views.ViewListParams +import com.langsmith_api.api.models.api.v1.sessions.views.ViewRetrieveParams +import com.langsmith_api.api.models.api.v1.sessions.views.ViewUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface ViewServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ViewServiceAsync + + /** Create a new filter view. */ + fun create(sessionId: String, params: ViewCreateParams): CompletableFuture<FilterView> = + create(sessionId, params, RequestOptions.none()) + + /** @see create */ + fun create( + sessionId: String, + params: ViewCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<FilterView> = + create(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see create */ + fun create(params: ViewCreateParams): CompletableFuture<FilterView> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: ViewCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<FilterView> + + /** Get a specific filter view. */ + fun retrieve(viewId: String, params: ViewRetrieveParams): CompletableFuture<FilterView> = + retrieve(viewId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + viewId: String, + params: ViewRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<FilterView> = + retrieve(params.toBuilder().viewId(viewId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: ViewRetrieveParams): CompletableFuture<FilterView> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: ViewRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<FilterView> + + /** Update a filter view. */ + fun update(viewId: String, params: ViewUpdateParams): CompletableFuture<FilterView> = + update(viewId, params, RequestOptions.none()) + + /** @see update */ + fun update( + viewId: String, + params: ViewUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<FilterView> = + update(params.toBuilder().viewId(viewId).build(), requestOptions) + + /** @see update */ + fun update(params: ViewUpdateParams): CompletableFuture<FilterView> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: ViewUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<FilterView> + + /** Get all filter views for a session. */ + fun list(sessionId: String): CompletableFuture<List<FilterView>> = + list(sessionId, ViewListParams.none()) + + /** @see list */ + fun list( + sessionId: String, + params: ViewListParams = ViewListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<FilterView>> = + list(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see list */ + fun list( + sessionId: String, + params: ViewListParams = ViewListParams.none(), + ): CompletableFuture<List<FilterView>> = list(sessionId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: ViewListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<FilterView>> + + /** @see list */ + fun list(params: ViewListParams): CompletableFuture<List<FilterView>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + sessionId: String, + requestOptions: RequestOptions, + ): CompletableFuture<List<FilterView>> = list(sessionId, ViewListParams.none(), requestOptions) + + /** Delete a specific filter view. */ + fun delete(viewId: String, params: ViewDeleteParams): CompletableFuture<ViewDeleteResponse> = + delete(viewId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + viewId: String, + params: ViewDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ViewDeleteResponse> = + delete(params.toBuilder().viewId(viewId).build(), requestOptions) + + /** @see delete */ + fun delete(params: ViewDeleteParams): CompletableFuture<ViewDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ViewDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ViewDeleteResponse> + + /** A view of [ViewServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ViewServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/sessions/{session_id}/views`, but is + * otherwise the same as [ViewServiceAsync.create]. + */ + fun create( + sessionId: String, + params: ViewCreateParams, + ): CompletableFuture<HttpResponseFor<FilterView>> = + create(sessionId, params, RequestOptions.none()) + + /** @see create */ + fun create( + sessionId: String, + params: ViewCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<FilterView>> = + create(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see create */ + fun create(params: ViewCreateParams): CompletableFuture<HttpResponseFor<FilterView>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: ViewCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<FilterView>> + + /** + * Returns a raw HTTP response for `get /api/v1/sessions/{session_id}/views/{view_id}`, but + * is otherwise the same as [ViewServiceAsync.retrieve]. + */ + fun retrieve( + viewId: String, + params: ViewRetrieveParams, + ): CompletableFuture<HttpResponseFor<FilterView>> = + retrieve(viewId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + viewId: String, + params: ViewRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<FilterView>> = + retrieve(params.toBuilder().viewId(viewId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: ViewRetrieveParams): CompletableFuture<HttpResponseFor<FilterView>> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: ViewRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<FilterView>> + + /** + * Returns a raw HTTP response for `patch /api/v1/sessions/{session_id}/views/{view_id}`, + * but is otherwise the same as [ViewServiceAsync.update]. + */ + fun update( + viewId: String, + params: ViewUpdateParams, + ): CompletableFuture<HttpResponseFor<FilterView>> = + update(viewId, params, RequestOptions.none()) + + /** @see update */ + fun update( + viewId: String, + params: ViewUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<FilterView>> = + update(params.toBuilder().viewId(viewId).build(), requestOptions) + + /** @see update */ + fun update(params: ViewUpdateParams): CompletableFuture<HttpResponseFor<FilterView>> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: ViewUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<FilterView>> + + /** + * Returns a raw HTTP response for `get /api/v1/sessions/{session_id}/views`, but is + * otherwise the same as [ViewServiceAsync.list]. + */ + fun list(sessionId: String): CompletableFuture<HttpResponseFor<List<FilterView>>> = + list(sessionId, ViewListParams.none()) + + /** @see list */ + fun list( + sessionId: String, + params: ViewListParams = ViewListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<FilterView>>> = + list(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see list */ + fun list( + sessionId: String, + params: ViewListParams = ViewListParams.none(), + ): CompletableFuture<HttpResponseFor<List<FilterView>>> = + list(sessionId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: ViewListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<FilterView>>> + + /** @see list */ + fun list(params: ViewListParams): CompletableFuture<HttpResponseFor<List<FilterView>>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + sessionId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<FilterView>>> = + list(sessionId, ViewListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/sessions/{session_id}/views/{view_id}`, + * but is otherwise the same as [ViewServiceAsync.delete]. + */ + fun delete( + viewId: String, + params: ViewDeleteParams, + ): CompletableFuture<HttpResponseFor<ViewDeleteResponse>> = + delete(viewId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + viewId: String, + params: ViewDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ViewDeleteResponse>> = + delete(params.toBuilder().viewId(viewId).build(), requestOptions) + + /** @see delete */ + fun delete( + params: ViewDeleteParams + ): CompletableFuture<HttpResponseFor<ViewDeleteResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ViewDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ViewDeleteResponse>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/sessions/ViewServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/sessions/ViewServiceAsyncImpl.kt new file mode 100644 index 00000000..8c9eec60 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/sessions/ViewServiceAsyncImpl.kt @@ -0,0 +1,279 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.sessions + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.sessions.views.FilterView +import com.langsmith_api.api.models.api.v1.sessions.views.ViewCreateParams +import com.langsmith_api.api.models.api.v1.sessions.views.ViewDeleteParams +import com.langsmith_api.api.models.api.v1.sessions.views.ViewDeleteResponse +import com.langsmith_api.api.models.api.v1.sessions.views.ViewListParams +import com.langsmith_api.api.models.api.v1.sessions.views.ViewRetrieveParams +import com.langsmith_api.api.models.api.v1.sessions.views.ViewUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ViewServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ViewServiceAsync { + + private val withRawResponse: ViewServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ViewServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): ViewServiceAsync = + ViewServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: ViewCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<FilterView> = + // post /api/v1/sessions/{session_id}/views + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun retrieve( + params: ViewRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<FilterView> = + // get /api/v1/sessions/{session_id}/views/{view_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: ViewUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<FilterView> = + // patch /api/v1/sessions/{session_id}/views/{view_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: ViewListParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<FilterView>> = + // get /api/v1/sessions/{session_id}/views + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: ViewDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<ViewDeleteResponse> = + // delete /api/v1/sessions/{session_id}/views/{view_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ViewServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ViewServiceAsync.WithRawResponse = + ViewServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<FilterView> = + jsonHandler<FilterView>(clientOptions.jsonMapper) + + override fun create( + params: ViewCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<FilterView>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("sessionId", params.sessionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "sessions", params._pathParam(0), "views") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler<FilterView> = + jsonHandler<FilterView>(clientOptions.jsonMapper) + + override fun retrieve( + params: ViewRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<FilterView>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("viewId", params.viewId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "sessions", + params._pathParam(0), + "views", + params._pathParam(1), + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler<FilterView> = + jsonHandler<FilterView>(clientOptions.jsonMapper) + + override fun update( + params: ViewUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<FilterView>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("viewId", params.viewId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "sessions", + params._pathParam(0), + "views", + params._pathParam(1), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler<List<FilterView>> = + jsonHandler<List<FilterView>>(clientOptions.jsonMapper) + + override fun list( + params: ViewListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<FilterView>>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("sessionId", params.sessionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "sessions", params._pathParam(0), "views") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val deleteHandler: Handler<ViewDeleteResponse> = + jsonHandler<ViewDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: ViewDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ViewDeleteResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("viewId", params.viewId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "sessions", + params._pathParam(0), + "views", + params._pathParam(1), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/sessions/insights/ConfigServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/sessions/insights/ConfigServiceAsync.kt new file mode 100644 index 00000000..a8ae372c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/sessions/insights/ConfigServiceAsync.kt @@ -0,0 +1,344 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.sessions.insights + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigCreateParams +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigDeleteParams +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigDeleteResponse +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigGenerateParams +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigGenerateResponse +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigListParams +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigListResponse +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigUpdateParams +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.CreateClusteringJobConfigResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface ConfigServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ConfigServiceAsync + + /** Save an insights job config. */ + fun create( + sessionId: String, + params: ConfigCreateParams, + ): CompletableFuture<CreateClusteringJobConfigResponse> = + create(sessionId, params, RequestOptions.none()) + + /** @see create */ + fun create( + sessionId: String, + params: ConfigCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CreateClusteringJobConfigResponse> = + create(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see create */ + fun create(params: ConfigCreateParams): CompletableFuture<CreateClusteringJobConfigResponse> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: ConfigCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CreateClusteringJobConfigResponse> + + /** Update an insights job config. */ + fun update( + configId: String, + params: ConfigUpdateParams, + ): CompletableFuture<CreateClusteringJobConfigResponse> = + update(configId, params, RequestOptions.none()) + + /** @see update */ + fun update( + configId: String, + params: ConfigUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CreateClusteringJobConfigResponse> = + update(params.toBuilder().configId(configId).build(), requestOptions) + + /** @see update */ + fun update(params: ConfigUpdateParams): CompletableFuture<CreateClusteringJobConfigResponse> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: ConfigUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CreateClusteringJobConfigResponse> + + /** Get all insights job configs for a session. */ + fun list(sessionId: String): CompletableFuture<ConfigListResponse> = + list(sessionId, ConfigListParams.none()) + + /** @see list */ + fun list( + sessionId: String, + params: ConfigListParams = ConfigListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ConfigListResponse> = + list(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see list */ + fun list( + sessionId: String, + params: ConfigListParams = ConfigListParams.none(), + ): CompletableFuture<ConfigListResponse> = list(sessionId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: ConfigListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ConfigListResponse> + + /** @see list */ + fun list(params: ConfigListParams): CompletableFuture<ConfigListResponse> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + sessionId: String, + requestOptions: RequestOptions, + ): CompletableFuture<ConfigListResponse> = + list(sessionId, ConfigListParams.none(), requestOptions) + + /** Delete an insights job config. */ + fun delete( + configId: String, + params: ConfigDeleteParams, + ): CompletableFuture<ConfigDeleteResponse> = delete(configId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + configId: String, + params: ConfigDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ConfigDeleteResponse> = + delete(params.toBuilder().configId(configId).build(), requestOptions) + + /** @see delete */ + fun delete(params: ConfigDeleteParams): CompletableFuture<ConfigDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ConfigDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ConfigDeleteResponse> + + /** Auto-generate an insights job config. */ + fun generate( + sessionId: String, + params: ConfigGenerateParams, + ): CompletableFuture<ConfigGenerateResponse> = + generate(sessionId, params, RequestOptions.none()) + + /** @see generate */ + fun generate( + sessionId: String, + params: ConfigGenerateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ConfigGenerateResponse> = + generate(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see generate */ + fun generate(params: ConfigGenerateParams): CompletableFuture<ConfigGenerateResponse> = + generate(params, RequestOptions.none()) + + /** @see generate */ + fun generate( + params: ConfigGenerateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ConfigGenerateResponse> + + /** + * A view of [ConfigServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ConfigServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/sessions/{session_id}/insights/configs`, + * but is otherwise the same as [ConfigServiceAsync.create]. + */ + fun create( + sessionId: String, + params: ConfigCreateParams, + ): CompletableFuture<HttpResponseFor<CreateClusteringJobConfigResponse>> = + create(sessionId, params, RequestOptions.none()) + + /** @see create */ + fun create( + sessionId: String, + params: ConfigCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CreateClusteringJobConfigResponse>> = + create(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see create */ + fun create( + params: ConfigCreateParams + ): CompletableFuture<HttpResponseFor<CreateClusteringJobConfigResponse>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: ConfigCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CreateClusteringJobConfigResponse>> + + /** + * Returns a raw HTTP response for `patch + * /api/v1/sessions/{session_id}/insights/configs/{config_id}`, but is otherwise the same as + * [ConfigServiceAsync.update]. + */ + fun update( + configId: String, + params: ConfigUpdateParams, + ): CompletableFuture<HttpResponseFor<CreateClusteringJobConfigResponse>> = + update(configId, params, RequestOptions.none()) + + /** @see update */ + fun update( + configId: String, + params: ConfigUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CreateClusteringJobConfigResponse>> = + update(params.toBuilder().configId(configId).build(), requestOptions) + + /** @see update */ + fun update( + params: ConfigUpdateParams + ): CompletableFuture<HttpResponseFor<CreateClusteringJobConfigResponse>> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: ConfigUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CreateClusteringJobConfigResponse>> + + /** + * Returns a raw HTTP response for `get /api/v1/sessions/{session_id}/insights/configs`, but + * is otherwise the same as [ConfigServiceAsync.list]. + */ + fun list(sessionId: String): CompletableFuture<HttpResponseFor<ConfigListResponse>> = + list(sessionId, ConfigListParams.none()) + + /** @see list */ + fun list( + sessionId: String, + params: ConfigListParams = ConfigListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ConfigListResponse>> = + list(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see list */ + fun list( + sessionId: String, + params: ConfigListParams = ConfigListParams.none(), + ): CompletableFuture<HttpResponseFor<ConfigListResponse>> = + list(sessionId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: ConfigListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ConfigListResponse>> + + /** @see list */ + fun list(params: ConfigListParams): CompletableFuture<HttpResponseFor<ConfigListResponse>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + sessionId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ConfigListResponse>> = + list(sessionId, ConfigListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete + * /api/v1/sessions/{session_id}/insights/configs/{config_id}`, but is otherwise the same as + * [ConfigServiceAsync.delete]. + */ + fun delete( + configId: String, + params: ConfigDeleteParams, + ): CompletableFuture<HttpResponseFor<ConfigDeleteResponse>> = + delete(configId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + configId: String, + params: ConfigDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ConfigDeleteResponse>> = + delete(params.toBuilder().configId(configId).build(), requestOptions) + + /** @see delete */ + fun delete( + params: ConfigDeleteParams + ): CompletableFuture<HttpResponseFor<ConfigDeleteResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ConfigDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ConfigDeleteResponse>> + + /** + * Returns a raw HTTP response for `post + * /api/v1/sessions/{session_id}/insights/configs/generate`, but is otherwise the same as + * [ConfigServiceAsync.generate]. + */ + fun generate( + sessionId: String, + params: ConfigGenerateParams, + ): CompletableFuture<HttpResponseFor<ConfigGenerateResponse>> = + generate(sessionId, params, RequestOptions.none()) + + /** @see generate */ + fun generate( + sessionId: String, + params: ConfigGenerateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ConfigGenerateResponse>> = + generate(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see generate */ + fun generate( + params: ConfigGenerateParams + ): CompletableFuture<HttpResponseFor<ConfigGenerateResponse>> = + generate(params, RequestOptions.none()) + + /** @see generate */ + fun generate( + params: ConfigGenerateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ConfigGenerateResponse>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/sessions/insights/ConfigServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/sessions/insights/ConfigServiceAsyncImpl.kt new file mode 100644 index 00000000..9428cee7 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/sessions/insights/ConfigServiceAsyncImpl.kt @@ -0,0 +1,299 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.sessions.insights + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigCreateParams +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigDeleteParams +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigDeleteResponse +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigGenerateParams +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigGenerateResponse +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigListParams +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigListResponse +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigUpdateParams +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.CreateClusteringJobConfigResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ConfigServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ConfigServiceAsync { + + private val withRawResponse: ConfigServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ConfigServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): ConfigServiceAsync = + ConfigServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: ConfigCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<CreateClusteringJobConfigResponse> = + // post /api/v1/sessions/{session_id}/insights/configs + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: ConfigUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<CreateClusteringJobConfigResponse> = + // patch /api/v1/sessions/{session_id}/insights/configs/{config_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: ConfigListParams, + requestOptions: RequestOptions, + ): CompletableFuture<ConfigListResponse> = + // get /api/v1/sessions/{session_id}/insights/configs + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: ConfigDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<ConfigDeleteResponse> = + // delete /api/v1/sessions/{session_id}/insights/configs/{config_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + override fun generate( + params: ConfigGenerateParams, + requestOptions: RequestOptions, + ): CompletableFuture<ConfigGenerateResponse> = + // post /api/v1/sessions/{session_id}/insights/configs/generate + withRawResponse().generate(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ConfigServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ConfigServiceAsync.WithRawResponse = + ConfigServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<CreateClusteringJobConfigResponse> = + jsonHandler<CreateClusteringJobConfigResponse>(clientOptions.jsonMapper) + + override fun create( + params: ConfigCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<CreateClusteringJobConfigResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("sessionId", params.sessionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "sessions", + params._pathParam(0), + "insights", + "configs", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler<CreateClusteringJobConfigResponse> = + jsonHandler<CreateClusteringJobConfigResponse>(clientOptions.jsonMapper) + + override fun update( + params: ConfigUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<CreateClusteringJobConfigResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("configId", params.configId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "sessions", + params._pathParam(0), + "insights", + "configs", + params._pathParam(1), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler<ConfigListResponse> = + jsonHandler<ConfigListResponse>(clientOptions.jsonMapper) + + override fun list( + params: ConfigListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ConfigListResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("sessionId", params.sessionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "sessions", + params._pathParam(0), + "insights", + "configs", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val deleteHandler: Handler<ConfigDeleteResponse> = + jsonHandler<ConfigDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: ConfigDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ConfigDeleteResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("configId", params.configId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "sessions", + params._pathParam(0), + "insights", + "configs", + params._pathParam(1), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val generateHandler: Handler<ConfigGenerateResponse> = + jsonHandler<ConfigGenerateResponse>(clientOptions.jsonMapper) + + override fun generate( + params: ConfigGenerateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ConfigGenerateResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("sessionId", params.sessionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "sessions", + params._pathParam(0), + "insights", + "configs", + "generate", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { generateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/sso/EmailVerificationServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/sso/EmailVerificationServiceAsync.kt new file mode 100644 index 00000000..7b414c7d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/sso/EmailVerificationServiceAsync.kt @@ -0,0 +1,124 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.sso + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.sso.emailverification.EmailVerificationConfirmParams +import com.langsmith_api.api.models.api.v1.sso.emailverification.EmailVerificationConfirmResponse +import com.langsmith_api.api.models.api.v1.sso.emailverification.EmailVerificationSendParams +import com.langsmith_api.api.models.api.v1.sso.emailverification.EmailVerificationSendResponse +import com.langsmith_api.api.models.api.v1.sso.emailverification.EmailVerificationStatusParams +import com.langsmith_api.api.models.api.v1.sso.emailverification.EmailVerificationStatusResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface EmailVerificationServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): EmailVerificationServiceAsync + + /** Confirm the email of an SSO user. */ + fun confirm( + params: EmailVerificationConfirmParams + ): CompletableFuture<EmailVerificationConfirmResponse> = confirm(params, RequestOptions.none()) + + /** @see confirm */ + fun confirm( + params: EmailVerificationConfirmParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<EmailVerificationConfirmResponse> + + /** Send an email to confirm the email address for an SSO user. */ + fun send( + params: EmailVerificationSendParams + ): CompletableFuture<EmailVerificationSendResponse> = send(params, RequestOptions.none()) + + /** @see send */ + fun send( + params: EmailVerificationSendParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<EmailVerificationSendResponse> + + /** Retrieve the email verification status of an SSO user. */ + fun status( + params: EmailVerificationStatusParams + ): CompletableFuture<EmailVerificationStatusResponse> = status(params, RequestOptions.none()) + + /** @see status */ + fun status( + params: EmailVerificationStatusParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<EmailVerificationStatusResponse> + + /** + * A view of [EmailVerificationServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): EmailVerificationServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/sso/email-verification/confirm`, but is + * otherwise the same as [EmailVerificationServiceAsync.confirm]. + */ + fun confirm( + params: EmailVerificationConfirmParams + ): CompletableFuture<HttpResponseFor<EmailVerificationConfirmResponse>> = + confirm(params, RequestOptions.none()) + + /** @see confirm */ + fun confirm( + params: EmailVerificationConfirmParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<EmailVerificationConfirmResponse>> + + /** + * Returns a raw HTTP response for `post /api/v1/sso/email-verification/send`, but is + * otherwise the same as [EmailVerificationServiceAsync.send]. + */ + fun send( + params: EmailVerificationSendParams + ): CompletableFuture<HttpResponseFor<EmailVerificationSendResponse>> = + send(params, RequestOptions.none()) + + /** @see send */ + fun send( + params: EmailVerificationSendParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<EmailVerificationSendResponse>> + + /** + * Returns a raw HTTP response for `post /api/v1/sso/email-verification/status`, but is + * otherwise the same as [EmailVerificationServiceAsync.status]. + */ + fun status( + params: EmailVerificationStatusParams + ): CompletableFuture<HttpResponseFor<EmailVerificationStatusResponse>> = + status(params, RequestOptions.none()) + + /** @see status */ + fun status( + params: EmailVerificationStatusParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<EmailVerificationStatusResponse>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/sso/EmailVerificationServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/sso/EmailVerificationServiceAsyncImpl.kt new file mode 100644 index 00000000..65118919 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/sso/EmailVerificationServiceAsyncImpl.kt @@ -0,0 +1,168 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.sso + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.sso.emailverification.EmailVerificationConfirmParams +import com.langsmith_api.api.models.api.v1.sso.emailverification.EmailVerificationConfirmResponse +import com.langsmith_api.api.models.api.v1.sso.emailverification.EmailVerificationSendParams +import com.langsmith_api.api.models.api.v1.sso.emailverification.EmailVerificationSendResponse +import com.langsmith_api.api.models.api.v1.sso.emailverification.EmailVerificationStatusParams +import com.langsmith_api.api.models.api.v1.sso.emailverification.EmailVerificationStatusResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class EmailVerificationServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : EmailVerificationServiceAsync { + + private val withRawResponse: EmailVerificationServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): EmailVerificationServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): EmailVerificationServiceAsync = + EmailVerificationServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun confirm( + params: EmailVerificationConfirmParams, + requestOptions: RequestOptions, + ): CompletableFuture<EmailVerificationConfirmResponse> = + // post /api/v1/sso/email-verification/confirm + withRawResponse().confirm(params, requestOptions).thenApply { it.parse() } + + override fun send( + params: EmailVerificationSendParams, + requestOptions: RequestOptions, + ): CompletableFuture<EmailVerificationSendResponse> = + // post /api/v1/sso/email-verification/send + withRawResponse().send(params, requestOptions).thenApply { it.parse() } + + override fun status( + params: EmailVerificationStatusParams, + requestOptions: RequestOptions, + ): CompletableFuture<EmailVerificationStatusResponse> = + // post /api/v1/sso/email-verification/status + withRawResponse().status(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + EmailVerificationServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): EmailVerificationServiceAsync.WithRawResponse = + EmailVerificationServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val confirmHandler: Handler<EmailVerificationConfirmResponse> = + jsonHandler<EmailVerificationConfirmResponse>(clientOptions.jsonMapper) + + override fun confirm( + params: EmailVerificationConfirmParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<EmailVerificationConfirmResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "sso", "email-verification", "confirm") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { confirmHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val sendHandler: Handler<EmailVerificationSendResponse> = + jsonHandler<EmailVerificationSendResponse>(clientOptions.jsonMapper) + + override fun send( + params: EmailVerificationSendParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<EmailVerificationSendResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "sso", "email-verification", "send") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { sendHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val statusHandler: Handler<EmailVerificationStatusResponse> = + jsonHandler<EmailVerificationStatusResponse>(clientOptions.jsonMapper) + + override fun status( + params: EmailVerificationStatusParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<EmailVerificationStatusResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "sso", "email-verification", "status") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { statusHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/CurrentServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/CurrentServiceAsync.kt new file mode 100644 index 00000000..28e9f03a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/CurrentServiceAsync.kt @@ -0,0 +1,168 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.workspaces + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.workspaces.current.CurrentRetrieveStatsParams +import com.langsmith_api.api.models.api.v1.workspaces.current.CurrentRetrieveStatsResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.CurrentRetrieveUsageLimitsParams +import com.langsmith_api.api.models.api.v1.workspaces.current.CurrentRetrieveUsageLimitsResponse +import com.langsmith_api.api.services.async.api.v1.workspaces.current.MemberServiceAsync +import com.langsmith_api.api.services.async.api.v1.workspaces.current.SecretServiceAsync +import com.langsmith_api.api.services.async.api.v1.workspaces.current.SharedServiceAsync +import com.langsmith_api.api.services.async.api.v1.workspaces.current.TagKeyServiceAsync +import com.langsmith_api.api.services.async.api.v1.workspaces.current.TagServiceAsync +import com.langsmith_api.api.services.async.api.v1.workspaces.current.TaggingServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface CurrentServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): CurrentServiceAsync + + fun members(): MemberServiceAsync + + fun shared(): SharedServiceAsync + + fun secrets(): SecretServiceAsync + + fun tagKeys(): TagKeyServiceAsync + + fun taggings(): TaggingServiceAsync + + fun tags(): TagServiceAsync + + /** Get Current Workspace Stats */ + fun retrieveStats(): CompletableFuture<CurrentRetrieveStatsResponse> = + retrieveStats(CurrentRetrieveStatsParams.none()) + + /** @see retrieveStats */ + fun retrieveStats( + params: CurrentRetrieveStatsParams = CurrentRetrieveStatsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CurrentRetrieveStatsResponse> + + /** @see retrieveStats */ + fun retrieveStats( + params: CurrentRetrieveStatsParams = CurrentRetrieveStatsParams.none() + ): CompletableFuture<CurrentRetrieveStatsResponse> = + retrieveStats(params, RequestOptions.none()) + + /** @see retrieveStats */ + fun retrieveStats( + requestOptions: RequestOptions + ): CompletableFuture<CurrentRetrieveStatsResponse> = + retrieveStats(CurrentRetrieveStatsParams.none(), requestOptions) + + /** Get Current Workspace Usage Limits Info */ + fun retrieveUsageLimits(): CompletableFuture<CurrentRetrieveUsageLimitsResponse> = + retrieveUsageLimits(CurrentRetrieveUsageLimitsParams.none()) + + /** @see retrieveUsageLimits */ + fun retrieveUsageLimits( + params: CurrentRetrieveUsageLimitsParams = CurrentRetrieveUsageLimitsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<CurrentRetrieveUsageLimitsResponse> + + /** @see retrieveUsageLimits */ + fun retrieveUsageLimits( + params: CurrentRetrieveUsageLimitsParams = CurrentRetrieveUsageLimitsParams.none() + ): CompletableFuture<CurrentRetrieveUsageLimitsResponse> = + retrieveUsageLimits(params, RequestOptions.none()) + + /** @see retrieveUsageLimits */ + fun retrieveUsageLimits( + requestOptions: RequestOptions + ): CompletableFuture<CurrentRetrieveUsageLimitsResponse> = + retrieveUsageLimits(CurrentRetrieveUsageLimitsParams.none(), requestOptions) + + /** + * A view of [CurrentServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): CurrentServiceAsync.WithRawResponse + + fun members(): MemberServiceAsync.WithRawResponse + + fun shared(): SharedServiceAsync.WithRawResponse + + fun secrets(): SecretServiceAsync.WithRawResponse + + fun tagKeys(): TagKeyServiceAsync.WithRawResponse + + fun taggings(): TaggingServiceAsync.WithRawResponse + + fun tags(): TagServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/workspaces/current/stats`, but is otherwise + * the same as [CurrentServiceAsync.retrieveStats]. + */ + fun retrieveStats(): CompletableFuture<HttpResponseFor<CurrentRetrieveStatsResponse>> = + retrieveStats(CurrentRetrieveStatsParams.none()) + + /** @see retrieveStats */ + fun retrieveStats( + params: CurrentRetrieveStatsParams = CurrentRetrieveStatsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CurrentRetrieveStatsResponse>> + + /** @see retrieveStats */ + fun retrieveStats( + params: CurrentRetrieveStatsParams = CurrentRetrieveStatsParams.none() + ): CompletableFuture<HttpResponseFor<CurrentRetrieveStatsResponse>> = + retrieveStats(params, RequestOptions.none()) + + /** @see retrieveStats */ + fun retrieveStats( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<CurrentRetrieveStatsResponse>> = + retrieveStats(CurrentRetrieveStatsParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/workspaces/current/usage_limits`, but is + * otherwise the same as [CurrentServiceAsync.retrieveUsageLimits]. + */ + fun retrieveUsageLimits(): + CompletableFuture<HttpResponseFor<CurrentRetrieveUsageLimitsResponse>> = + retrieveUsageLimits(CurrentRetrieveUsageLimitsParams.none()) + + /** @see retrieveUsageLimits */ + fun retrieveUsageLimits( + params: CurrentRetrieveUsageLimitsParams = CurrentRetrieveUsageLimitsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<CurrentRetrieveUsageLimitsResponse>> + + /** @see retrieveUsageLimits */ + fun retrieveUsageLimits( + params: CurrentRetrieveUsageLimitsParams = CurrentRetrieveUsageLimitsParams.none() + ): CompletableFuture<HttpResponseFor<CurrentRetrieveUsageLimitsResponse>> = + retrieveUsageLimits(params, RequestOptions.none()) + + /** @see retrieveUsageLimits */ + fun retrieveUsageLimits( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<CurrentRetrieveUsageLimitsResponse>> = + retrieveUsageLimits(CurrentRetrieveUsageLimitsParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/CurrentServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/CurrentServiceAsyncImpl.kt new file mode 100644 index 00000000..6e407b73 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/CurrentServiceAsyncImpl.kt @@ -0,0 +1,195 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.workspaces + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.workspaces.current.CurrentRetrieveStatsParams +import com.langsmith_api.api.models.api.v1.workspaces.current.CurrentRetrieveStatsResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.CurrentRetrieveUsageLimitsParams +import com.langsmith_api.api.models.api.v1.workspaces.current.CurrentRetrieveUsageLimitsResponse +import com.langsmith_api.api.services.async.api.v1.workspaces.current.MemberServiceAsync +import com.langsmith_api.api.services.async.api.v1.workspaces.current.MemberServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.workspaces.current.SecretServiceAsync +import com.langsmith_api.api.services.async.api.v1.workspaces.current.SecretServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.workspaces.current.SharedServiceAsync +import com.langsmith_api.api.services.async.api.v1.workspaces.current.SharedServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.workspaces.current.TagKeyServiceAsync +import com.langsmith_api.api.services.async.api.v1.workspaces.current.TagKeyServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.workspaces.current.TagServiceAsync +import com.langsmith_api.api.services.async.api.v1.workspaces.current.TagServiceAsyncImpl +import com.langsmith_api.api.services.async.api.v1.workspaces.current.TaggingServiceAsync +import com.langsmith_api.api.services.async.api.v1.workspaces.current.TaggingServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class CurrentServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + CurrentServiceAsync { + + private val withRawResponse: CurrentServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val members: MemberServiceAsync by lazy { MemberServiceAsyncImpl(clientOptions) } + + private val shared: SharedServiceAsync by lazy { SharedServiceAsyncImpl(clientOptions) } + + private val secrets: SecretServiceAsync by lazy { SecretServiceAsyncImpl(clientOptions) } + + private val tagKeys: TagKeyServiceAsync by lazy { TagKeyServiceAsyncImpl(clientOptions) } + + private val taggings: TaggingServiceAsync by lazy { TaggingServiceAsyncImpl(clientOptions) } + + private val tags: TagServiceAsync by lazy { TagServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): CurrentServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): CurrentServiceAsync = + CurrentServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun members(): MemberServiceAsync = members + + override fun shared(): SharedServiceAsync = shared + + override fun secrets(): SecretServiceAsync = secrets + + override fun tagKeys(): TagKeyServiceAsync = tagKeys + + override fun taggings(): TaggingServiceAsync = taggings + + override fun tags(): TagServiceAsync = tags + + override fun retrieveStats( + params: CurrentRetrieveStatsParams, + requestOptions: RequestOptions, + ): CompletableFuture<CurrentRetrieveStatsResponse> = + // get /api/v1/workspaces/current/stats + withRawResponse().retrieveStats(params, requestOptions).thenApply { it.parse() } + + override fun retrieveUsageLimits( + params: CurrentRetrieveUsageLimitsParams, + requestOptions: RequestOptions, + ): CompletableFuture<CurrentRetrieveUsageLimitsResponse> = + // get /api/v1/workspaces/current/usage_limits + withRawResponse().retrieveUsageLimits(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CurrentServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val members: MemberServiceAsync.WithRawResponse by lazy { + MemberServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val shared: SharedServiceAsync.WithRawResponse by lazy { + SharedServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val secrets: SecretServiceAsync.WithRawResponse by lazy { + SecretServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val tagKeys: TagKeyServiceAsync.WithRawResponse by lazy { + TagKeyServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val taggings: TaggingServiceAsync.WithRawResponse by lazy { + TaggingServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val tags: TagServiceAsync.WithRawResponse by lazy { + TagServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): CurrentServiceAsync.WithRawResponse = + CurrentServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun members(): MemberServiceAsync.WithRawResponse = members + + override fun shared(): SharedServiceAsync.WithRawResponse = shared + + override fun secrets(): SecretServiceAsync.WithRawResponse = secrets + + override fun tagKeys(): TagKeyServiceAsync.WithRawResponse = tagKeys + + override fun taggings(): TaggingServiceAsync.WithRawResponse = taggings + + override fun tags(): TagServiceAsync.WithRawResponse = tags + + private val retrieveStatsHandler: Handler<CurrentRetrieveStatsResponse> = + jsonHandler<CurrentRetrieveStatsResponse>(clientOptions.jsonMapper) + + override fun retrieveStats( + params: CurrentRetrieveStatsParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<CurrentRetrieveStatsResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "current", "stats") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveStatsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveUsageLimitsHandler: Handler<CurrentRetrieveUsageLimitsResponse> = + jsonHandler<CurrentRetrieveUsageLimitsResponse>(clientOptions.jsonMapper) + + override fun retrieveUsageLimits( + params: CurrentRetrieveUsageLimitsParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<CurrentRetrieveUsageLimitsResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "current", "usage_limits") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveUsageLimitsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/PendingServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/PendingServiceAsync.kt new file mode 100644 index 00000000..91a86bcb --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/PendingServiceAsync.kt @@ -0,0 +1,252 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.workspaces + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.tenants.AppSchemasTenant +import com.langsmith_api.api.models.api.v1.workspaces.pending.PendingClaimParams +import com.langsmith_api.api.models.api.v1.workspaces.pending.PendingClaimResponse +import com.langsmith_api.api.models.api.v1.workspaces.pending.PendingDeleteParams +import com.langsmith_api.api.models.api.v1.workspaces.pending.PendingDeleteResponse +import com.langsmith_api.api.models.api.v1.workspaces.pending.PendingListParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface PendingServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): PendingServiceAsync + + /** Get all workspaces visible to this auth */ + fun list(): CompletableFuture<List<AppSchemasTenant>> = list(PendingListParams.none()) + + /** @see list */ + fun list( + params: PendingListParams = PendingListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<AppSchemasTenant>> + + /** @see list */ + fun list( + params: PendingListParams = PendingListParams.none() + ): CompletableFuture<List<AppSchemasTenant>> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture<List<AppSchemasTenant>> = + list(PendingListParams.none(), requestOptions) + + /** Delete Pending Workspace Invite */ + fun delete(id: String): CompletableFuture<PendingDeleteResponse> = + delete(id, PendingDeleteParams.none()) + + /** @see delete */ + fun delete( + id: String, + params: PendingDeleteParams = PendingDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<PendingDeleteResponse> = + delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + fun delete( + id: String, + params: PendingDeleteParams = PendingDeleteParams.none(), + ): CompletableFuture<PendingDeleteResponse> = delete(id, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: PendingDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<PendingDeleteResponse> + + /** @see delete */ + fun delete(params: PendingDeleteParams): CompletableFuture<PendingDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture<PendingDeleteResponse> = + delete(id, PendingDeleteParams.none(), requestOptions) + + /** Claim Pending Workspace Invite */ + @Deprecated("deprecated") + fun claim(workspaceId: String): CompletableFuture<PendingClaimResponse> = + claim(workspaceId, PendingClaimParams.none()) + + /** @see claim */ + @Deprecated("deprecated") + fun claim( + workspaceId: String, + params: PendingClaimParams = PendingClaimParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<PendingClaimResponse> = + claim(params.toBuilder().workspaceId(workspaceId).build(), requestOptions) + + /** @see claim */ + @Deprecated("deprecated") + fun claim( + workspaceId: String, + params: PendingClaimParams = PendingClaimParams.none(), + ): CompletableFuture<PendingClaimResponse> = claim(workspaceId, params, RequestOptions.none()) + + /** @see claim */ + @Deprecated("deprecated") + fun claim( + params: PendingClaimParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<PendingClaimResponse> + + /** @see claim */ + @Deprecated("deprecated") + fun claim(params: PendingClaimParams): CompletableFuture<PendingClaimResponse> = + claim(params, RequestOptions.none()) + + /** @see claim */ + @Deprecated("deprecated") + fun claim( + workspaceId: String, + requestOptions: RequestOptions, + ): CompletableFuture<PendingClaimResponse> = + claim(workspaceId, PendingClaimParams.none(), requestOptions) + + /** + * A view of [PendingServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PendingServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/workspaces/pending`, but is otherwise the + * same as [PendingServiceAsync.list]. + */ + fun list(): CompletableFuture<HttpResponseFor<List<AppSchemasTenant>>> = + list(PendingListParams.none()) + + /** @see list */ + fun list( + params: PendingListParams = PendingListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<AppSchemasTenant>>> + + /** @see list */ + fun list( + params: PendingListParams = PendingListParams.none() + ): CompletableFuture<HttpResponseFor<List<AppSchemasTenant>>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<AppSchemasTenant>>> = + list(PendingListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/workspaces/pending/{id}`, but is + * otherwise the same as [PendingServiceAsync.delete]. + */ + fun delete(id: String): CompletableFuture<HttpResponseFor<PendingDeleteResponse>> = + delete(id, PendingDeleteParams.none()) + + /** @see delete */ + fun delete( + id: String, + params: PendingDeleteParams = PendingDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<PendingDeleteResponse>> = + delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + fun delete( + id: String, + params: PendingDeleteParams = PendingDeleteParams.none(), + ): CompletableFuture<HttpResponseFor<PendingDeleteResponse>> = + delete(id, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: PendingDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<PendingDeleteResponse>> + + /** @see delete */ + fun delete( + params: PendingDeleteParams + ): CompletableFuture<HttpResponseFor<PendingDeleteResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<PendingDeleteResponse>> = + delete(id, PendingDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/workspaces/pending/{workspace_id}/claim`, + * but is otherwise the same as [PendingServiceAsync.claim]. + */ + @Deprecated("deprecated") + fun claim(workspaceId: String): CompletableFuture<HttpResponseFor<PendingClaimResponse>> = + claim(workspaceId, PendingClaimParams.none()) + + /** @see claim */ + @Deprecated("deprecated") + fun claim( + workspaceId: String, + params: PendingClaimParams = PendingClaimParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<PendingClaimResponse>> = + claim(params.toBuilder().workspaceId(workspaceId).build(), requestOptions) + + /** @see claim */ + @Deprecated("deprecated") + fun claim( + workspaceId: String, + params: PendingClaimParams = PendingClaimParams.none(), + ): CompletableFuture<HttpResponseFor<PendingClaimResponse>> = + claim(workspaceId, params, RequestOptions.none()) + + /** @see claim */ + @Deprecated("deprecated") + fun claim( + params: PendingClaimParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<PendingClaimResponse>> + + /** @see claim */ + @Deprecated("deprecated") + fun claim( + params: PendingClaimParams + ): CompletableFuture<HttpResponseFor<PendingClaimResponse>> = + claim(params, RequestOptions.none()) + + /** @see claim */ + @Deprecated("deprecated") + fun claim( + workspaceId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<PendingClaimResponse>> = + claim(workspaceId, PendingClaimParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/PendingServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/PendingServiceAsyncImpl.kt new file mode 100644 index 00000000..0b3e33c0 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/PendingServiceAsyncImpl.kt @@ -0,0 +1,182 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.workspaces + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.tenants.AppSchemasTenant +import com.langsmith_api.api.models.api.v1.workspaces.pending.PendingClaimParams +import com.langsmith_api.api.models.api.v1.workspaces.pending.PendingClaimResponse +import com.langsmith_api.api.models.api.v1.workspaces.pending.PendingDeleteParams +import com.langsmith_api.api.models.api.v1.workspaces.pending.PendingDeleteResponse +import com.langsmith_api.api.models.api.v1.workspaces.pending.PendingListParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class PendingServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + PendingServiceAsync { + + private val withRawResponse: PendingServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): PendingServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): PendingServiceAsync = + PendingServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: PendingListParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<AppSchemasTenant>> = + // get /api/v1/workspaces/pending + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: PendingDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<PendingDeleteResponse> = + // delete /api/v1/workspaces/pending/{id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + @Deprecated("deprecated") + override fun claim( + params: PendingClaimParams, + requestOptions: RequestOptions, + ): CompletableFuture<PendingClaimResponse> = + // post /api/v1/workspaces/pending/{workspace_id}/claim + withRawResponse().claim(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + PendingServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PendingServiceAsync.WithRawResponse = + PendingServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler<List<AppSchemasTenant>> = + jsonHandler<List<AppSchemasTenant>>(clientOptions.jsonMapper) + + override fun list( + params: PendingListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<AppSchemasTenant>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "pending") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val deleteHandler: Handler<PendingDeleteResponse> = + jsonHandler<PendingDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: PendingDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<PendingDeleteResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "pending", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val claimHandler: Handler<PendingClaimResponse> = + jsonHandler<PendingClaimResponse>(clientOptions.jsonMapper) + + @Deprecated("deprecated") + override fun claim( + params: PendingClaimParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<PendingClaimResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("workspaceId", params.workspaceId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "workspaces", + "pending", + params._pathParam(0), + "claim", + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { claimHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/MemberServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/MemberServiceAsync.kt new file mode 100644 index 00000000..b34ba71b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/MemberServiceAsync.kt @@ -0,0 +1,339 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.workspaces.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.orgs.current.members.PendingIdentity +import com.langsmith_api.api.models.api.v1.orgs.pending.Identity +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberBatchParams +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberCreateParams +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberDeleteParams +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberDeleteResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberIdentity +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberListParams +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberListResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberRetrieveActiveParams +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberUpdateParams +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberUpdateResponse +import com.langsmith_api.api.services.async.api.v1.workspaces.current.members.PendingServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface MemberServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): MemberServiceAsync + + fun pending(): PendingServiceAsync + + /** Add an existing organization member to the current workspace. */ + fun create(): CompletableFuture<Identity> = create(MemberCreateParams.none()) + + /** @see create */ + fun create( + params: MemberCreateParams = MemberCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<Identity> + + /** @see create */ + fun create( + params: MemberCreateParams = MemberCreateParams.none() + ): CompletableFuture<Identity> = create(params, RequestOptions.none()) + + /** @see create */ + fun create(requestOptions: RequestOptions): CompletableFuture<Identity> = + create(MemberCreateParams.none(), requestOptions) + + /** Patch Current Workspace Member */ + fun update( + identityId: String, + params: MemberUpdateParams, + ): CompletableFuture<MemberUpdateResponse> = update(identityId, params, RequestOptions.none()) + + /** @see update */ + fun update( + identityId: String, + params: MemberUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<MemberUpdateResponse> = + update(params.toBuilder().identityId(identityId).build(), requestOptions) + + /** @see update */ + fun update(params: MemberUpdateParams): CompletableFuture<MemberUpdateResponse> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: MemberUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<MemberUpdateResponse> + + /** Get Current Workspace Members */ + fun list(): CompletableFuture<MemberListResponse> = list(MemberListParams.none()) + + /** @see list */ + fun list( + params: MemberListParams = MemberListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<MemberListResponse> + + /** @see list */ + fun list( + params: MemberListParams = MemberListParams.none() + ): CompletableFuture<MemberListResponse> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture<MemberListResponse> = + list(MemberListParams.none(), requestOptions) + + /** Delete Current Workspace Member */ + fun delete(identityId: String): CompletableFuture<MemberDeleteResponse> = + delete(identityId, MemberDeleteParams.none()) + + /** @see delete */ + fun delete( + identityId: String, + params: MemberDeleteParams = MemberDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<MemberDeleteResponse> = + delete(params.toBuilder().identityId(identityId).build(), requestOptions) + + /** @see delete */ + fun delete( + identityId: String, + params: MemberDeleteParams = MemberDeleteParams.none(), + ): CompletableFuture<MemberDeleteResponse> = delete(identityId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: MemberDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<MemberDeleteResponse> + + /** @see delete */ + fun delete(params: MemberDeleteParams): CompletableFuture<MemberDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + identityId: String, + requestOptions: RequestOptions, + ): CompletableFuture<MemberDeleteResponse> = + delete(identityId, MemberDeleteParams.none(), requestOptions) + + /** Batch invite up to 500 users to the current workspace and organization. */ + fun batch(params: MemberBatchParams): CompletableFuture<List<PendingIdentity>> = + batch(params, RequestOptions.none()) + + /** @see batch */ + fun batch( + params: MemberBatchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<PendingIdentity>> + + /** Get Current Active Workspace Members */ + fun retrieveActive(): CompletableFuture<List<MemberIdentity>> = + retrieveActive(MemberRetrieveActiveParams.none()) + + /** @see retrieveActive */ + fun retrieveActive( + params: MemberRetrieveActiveParams = MemberRetrieveActiveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<MemberIdentity>> + + /** @see retrieveActive */ + fun retrieveActive( + params: MemberRetrieveActiveParams = MemberRetrieveActiveParams.none() + ): CompletableFuture<List<MemberIdentity>> = retrieveActive(params, RequestOptions.none()) + + /** @see retrieveActive */ + fun retrieveActive(requestOptions: RequestOptions): CompletableFuture<List<MemberIdentity>> = + retrieveActive(MemberRetrieveActiveParams.none(), requestOptions) + + /** + * A view of [MemberServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): MemberServiceAsync.WithRawResponse + + fun pending(): PendingServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/workspaces/current/members`, but is + * otherwise the same as [MemberServiceAsync.create]. + */ + fun create(): CompletableFuture<HttpResponseFor<Identity>> = + create(MemberCreateParams.none()) + + /** @see create */ + fun create( + params: MemberCreateParams = MemberCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<Identity>> + + /** @see create */ + fun create( + params: MemberCreateParams = MemberCreateParams.none() + ): CompletableFuture<HttpResponseFor<Identity>> = create(params, RequestOptions.none()) + + /** @see create */ + fun create(requestOptions: RequestOptions): CompletableFuture<HttpResponseFor<Identity>> = + create(MemberCreateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `patch /api/v1/workspaces/current/members/{identity_id}`, + * but is otherwise the same as [MemberServiceAsync.update]. + */ + fun update( + identityId: String, + params: MemberUpdateParams, + ): CompletableFuture<HttpResponseFor<MemberUpdateResponse>> = + update(identityId, params, RequestOptions.none()) + + /** @see update */ + fun update( + identityId: String, + params: MemberUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<MemberUpdateResponse>> = + update(params.toBuilder().identityId(identityId).build(), requestOptions) + + /** @see update */ + fun update( + params: MemberUpdateParams + ): CompletableFuture<HttpResponseFor<MemberUpdateResponse>> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: MemberUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<MemberUpdateResponse>> + + /** + * Returns a raw HTTP response for `get /api/v1/workspaces/current/members`, but is + * otherwise the same as [MemberServiceAsync.list]. + */ + fun list(): CompletableFuture<HttpResponseFor<MemberListResponse>> = + list(MemberListParams.none()) + + /** @see list */ + fun list( + params: MemberListParams = MemberListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<MemberListResponse>> + + /** @see list */ + fun list( + params: MemberListParams = MemberListParams.none() + ): CompletableFuture<HttpResponseFor<MemberListResponse>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<MemberListResponse>> = + list(MemberListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete + * /api/v1/workspaces/current/members/{identity_id}`, but is otherwise the same as + * [MemberServiceAsync.delete]. + */ + fun delete(identityId: String): CompletableFuture<HttpResponseFor<MemberDeleteResponse>> = + delete(identityId, MemberDeleteParams.none()) + + /** @see delete */ + fun delete( + identityId: String, + params: MemberDeleteParams = MemberDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<MemberDeleteResponse>> = + delete(params.toBuilder().identityId(identityId).build(), requestOptions) + + /** @see delete */ + fun delete( + identityId: String, + params: MemberDeleteParams = MemberDeleteParams.none(), + ): CompletableFuture<HttpResponseFor<MemberDeleteResponse>> = + delete(identityId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: MemberDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<MemberDeleteResponse>> + + /** @see delete */ + fun delete( + params: MemberDeleteParams + ): CompletableFuture<HttpResponseFor<MemberDeleteResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + identityId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<MemberDeleteResponse>> = + delete(identityId, MemberDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/workspaces/current/members/batch`, but is + * otherwise the same as [MemberServiceAsync.batch]. + */ + fun batch( + params: MemberBatchParams + ): CompletableFuture<HttpResponseFor<List<PendingIdentity>>> = + batch(params, RequestOptions.none()) + + /** @see batch */ + fun batch( + params: MemberBatchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<PendingIdentity>>> + + /** + * Returns a raw HTTP response for `get /api/v1/workspaces/current/members/active`, but is + * otherwise the same as [MemberServiceAsync.retrieveActive]. + */ + fun retrieveActive(): CompletableFuture<HttpResponseFor<List<MemberIdentity>>> = + retrieveActive(MemberRetrieveActiveParams.none()) + + /** @see retrieveActive */ + fun retrieveActive( + params: MemberRetrieveActiveParams = MemberRetrieveActiveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<MemberIdentity>>> + + /** @see retrieveActive */ + fun retrieveActive( + params: MemberRetrieveActiveParams = MemberRetrieveActiveParams.none() + ): CompletableFuture<HttpResponseFor<List<MemberIdentity>>> = + retrieveActive(params, RequestOptions.none()) + + /** @see retrieveActive */ + fun retrieveActive( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<MemberIdentity>>> = + retrieveActive(MemberRetrieveActiveParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/MemberServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/MemberServiceAsyncImpl.kt new file mode 100644 index 00000000..1577be54 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/MemberServiceAsyncImpl.kt @@ -0,0 +1,318 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.workspaces.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.orgs.current.members.PendingIdentity +import com.langsmith_api.api.models.api.v1.orgs.pending.Identity +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberBatchParams +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberCreateParams +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberDeleteParams +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberDeleteResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberIdentity +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberListParams +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberListResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberRetrieveActiveParams +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberUpdateParams +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberUpdateResponse +import com.langsmith_api.api.services.async.api.v1.workspaces.current.members.PendingServiceAsync +import com.langsmith_api.api.services.async.api.v1.workspaces.current.members.PendingServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class MemberServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + MemberServiceAsync { + + private val withRawResponse: MemberServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val pending: PendingServiceAsync by lazy { PendingServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): MemberServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): MemberServiceAsync = + MemberServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun pending(): PendingServiceAsync = pending + + override fun create( + params: MemberCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<Identity> = + // post /api/v1/workspaces/current/members + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: MemberUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<MemberUpdateResponse> = + // patch /api/v1/workspaces/current/members/{identity_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: MemberListParams, + requestOptions: RequestOptions, + ): CompletableFuture<MemberListResponse> = + // get /api/v1/workspaces/current/members + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: MemberDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<MemberDeleteResponse> = + // delete /api/v1/workspaces/current/members/{identity_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + override fun batch( + params: MemberBatchParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<PendingIdentity>> = + // post /api/v1/workspaces/current/members/batch + withRawResponse().batch(params, requestOptions).thenApply { it.parse() } + + override fun retrieveActive( + params: MemberRetrieveActiveParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<MemberIdentity>> = + // get /api/v1/workspaces/current/members/active + withRawResponse().retrieveActive(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + MemberServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val pending: PendingServiceAsync.WithRawResponse by lazy { + PendingServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): MemberServiceAsync.WithRawResponse = + MemberServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun pending(): PendingServiceAsync.WithRawResponse = pending + + private val createHandler: Handler<Identity> = + jsonHandler<Identity>(clientOptions.jsonMapper) + + override fun create( + params: MemberCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<Identity>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "current", "members") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler<MemberUpdateResponse> = + jsonHandler<MemberUpdateResponse>(clientOptions.jsonMapper) + + override fun update( + params: MemberUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<MemberUpdateResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("identityId", params.identityId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "workspaces", + "current", + "members", + params._pathParam(0), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler<MemberListResponse> = + jsonHandler<MemberListResponse>(clientOptions.jsonMapper) + + override fun list( + params: MemberListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<MemberListResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "current", "members") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val deleteHandler: Handler<MemberDeleteResponse> = + jsonHandler<MemberDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: MemberDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<MemberDeleteResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("identityId", params.identityId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "workspaces", + "current", + "members", + params._pathParam(0), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val batchHandler: Handler<List<PendingIdentity>> = + jsonHandler<List<PendingIdentity>>(clientOptions.jsonMapper) + + override fun batch( + params: MemberBatchParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<PendingIdentity>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "current", "members", "batch") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { batchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val retrieveActiveHandler: Handler<List<MemberIdentity>> = + jsonHandler<List<MemberIdentity>>(clientOptions.jsonMapper) + + override fun retrieveActive( + params: MemberRetrieveActiveParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<MemberIdentity>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "current", "members", "active") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveActiveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/SecretServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/SecretServiceAsync.kt new file mode 100644 index 00000000..8c9843fb --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/SecretServiceAsync.kt @@ -0,0 +1,140 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.workspaces.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.workspaces.current.secrets.SecretCreateParams +import com.langsmith_api.api.models.api.v1.workspaces.current.secrets.SecretCreateResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.secrets.SecretListParams +import com.langsmith_api.api.models.api.v1.workspaces.current.secrets.SecretListResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.secrets.SecretRetrieveEncryptedParams +import com.langsmith_api.api.models.api.v1.workspaces.current.secrets.SecretRetrieveEncryptedResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface SecretServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): SecretServiceAsync + + /** Upsert Current Workspace Secrets */ + fun create(params: SecretCreateParams): CompletableFuture<SecretCreateResponse> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: SecretCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<SecretCreateResponse> + + /** List Current Workspace Secrets */ + fun list(): CompletableFuture<List<SecretListResponse>> = list(SecretListParams.none()) + + /** @see list */ + fun list( + params: SecretListParams = SecretListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<SecretListResponse>> + + /** @see list */ + fun list( + params: SecretListParams = SecretListParams.none() + ): CompletableFuture<List<SecretListResponse>> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture<List<SecretListResponse>> = + list(SecretListParams.none(), requestOptions) + + /** Get encrypted workspace secrets for use with Agent Builder and external services. */ + fun retrieveEncrypted( + params: SecretRetrieveEncryptedParams + ): CompletableFuture<SecretRetrieveEncryptedResponse> = + retrieveEncrypted(params, RequestOptions.none()) + + /** @see retrieveEncrypted */ + fun retrieveEncrypted( + params: SecretRetrieveEncryptedParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<SecretRetrieveEncryptedResponse> + + /** + * A view of [SecretServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): SecretServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/workspaces/current/secrets`, but is + * otherwise the same as [SecretServiceAsync.create]. + */ + fun create( + params: SecretCreateParams + ): CompletableFuture<HttpResponseFor<SecretCreateResponse>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: SecretCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<SecretCreateResponse>> + + /** + * Returns a raw HTTP response for `get /api/v1/workspaces/current/secrets`, but is + * otherwise the same as [SecretServiceAsync.list]. + */ + fun list(): CompletableFuture<HttpResponseFor<List<SecretListResponse>>> = + list(SecretListParams.none()) + + /** @see list */ + fun list( + params: SecretListParams = SecretListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<SecretListResponse>>> + + /** @see list */ + fun list( + params: SecretListParams = SecretListParams.none() + ): CompletableFuture<HttpResponseFor<List<SecretListResponse>>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<SecretListResponse>>> = + list(SecretListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/workspaces/current/secrets/encrypted`, but + * is otherwise the same as [SecretServiceAsync.retrieveEncrypted]. + */ + fun retrieveEncrypted( + params: SecretRetrieveEncryptedParams + ): CompletableFuture<HttpResponseFor<SecretRetrieveEncryptedResponse>> = + retrieveEncrypted(params, RequestOptions.none()) + + /** @see retrieveEncrypted */ + fun retrieveEncrypted( + params: SecretRetrieveEncryptedParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<SecretRetrieveEncryptedResponse>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/SecretServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/SecretServiceAsyncImpl.kt new file mode 100644 index 00000000..534bdf42 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/SecretServiceAsyncImpl.kt @@ -0,0 +1,164 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.workspaces.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.workspaces.current.secrets.SecretCreateParams +import com.langsmith_api.api.models.api.v1.workspaces.current.secrets.SecretCreateResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.secrets.SecretListParams +import com.langsmith_api.api.models.api.v1.workspaces.current.secrets.SecretListResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.secrets.SecretRetrieveEncryptedParams +import com.langsmith_api.api.models.api.v1.workspaces.current.secrets.SecretRetrieveEncryptedResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class SecretServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + SecretServiceAsync { + + private val withRawResponse: SecretServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): SecretServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): SecretServiceAsync = + SecretServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: SecretCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<SecretCreateResponse> = + // post /api/v1/workspaces/current/secrets + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: SecretListParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<SecretListResponse>> = + // get /api/v1/workspaces/current/secrets + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun retrieveEncrypted( + params: SecretRetrieveEncryptedParams, + requestOptions: RequestOptions, + ): CompletableFuture<SecretRetrieveEncryptedResponse> = + // get /api/v1/workspaces/current/secrets/encrypted + withRawResponse().retrieveEncrypted(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SecretServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): SecretServiceAsync.WithRawResponse = + SecretServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<SecretCreateResponse> = + jsonHandler<SecretCreateResponse>(clientOptions.jsonMapper) + + override fun create( + params: SecretCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<SecretCreateResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "current", "secrets") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler<List<SecretListResponse>> = + jsonHandler<List<SecretListResponse>>(clientOptions.jsonMapper) + + override fun list( + params: SecretListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<SecretListResponse>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "current", "secrets") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val retrieveEncryptedHandler: Handler<SecretRetrieveEncryptedResponse> = + jsonHandler<SecretRetrieveEncryptedResponse>(clientOptions.jsonMapper) + + override fun retrieveEncrypted( + params: SecretRetrieveEncryptedParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<SecretRetrieveEncryptedResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "current", "secrets", "encrypted") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveEncryptedHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/SharedServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/SharedServiceAsync.kt new file mode 100644 index 00000000..e44f22ee --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/SharedServiceAsync.kt @@ -0,0 +1,130 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.workspaces.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.workspaces.current.shared.SharedDeleteAllParams +import com.langsmith_api.api.models.api.v1.workspaces.current.shared.SharedDeleteAllResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.shared.SharedListParams +import com.langsmith_api.api.models.api.v1.workspaces.current.shared.SharedListResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface SharedServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): SharedServiceAsync + + /** List all shared entities and their tokens by the workspace. */ + fun list(): CompletableFuture<SharedListResponse> = list(SharedListParams.none()) + + /** @see list */ + fun list( + params: SharedListParams = SharedListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<SharedListResponse> + + /** @see list */ + fun list( + params: SharedListParams = SharedListParams.none() + ): CompletableFuture<SharedListResponse> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture<SharedListResponse> = + list(SharedListParams.none(), requestOptions) + + /** Bulk unshare entities by share tokens for the workspace. */ + fun deleteAll(): CompletableFuture<SharedDeleteAllResponse> = + deleteAll(SharedDeleteAllParams.none()) + + /** @see deleteAll */ + fun deleteAll( + params: SharedDeleteAllParams = SharedDeleteAllParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<SharedDeleteAllResponse> + + /** @see deleteAll */ + fun deleteAll( + params: SharedDeleteAllParams = SharedDeleteAllParams.none() + ): CompletableFuture<SharedDeleteAllResponse> = deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll(requestOptions: RequestOptions): CompletableFuture<SharedDeleteAllResponse> = + deleteAll(SharedDeleteAllParams.none(), requestOptions) + + /** + * A view of [SharedServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): SharedServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/workspaces/current/shared`, but is otherwise + * the same as [SharedServiceAsync.list]. + */ + fun list(): CompletableFuture<HttpResponseFor<SharedListResponse>> = + list(SharedListParams.none()) + + /** @see list */ + fun list( + params: SharedListParams = SharedListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<SharedListResponse>> + + /** @see list */ + fun list( + params: SharedListParams = SharedListParams.none() + ): CompletableFuture<HttpResponseFor<SharedListResponse>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<SharedListResponse>> = + list(SharedListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/workspaces/current/shared`, but is + * otherwise the same as [SharedServiceAsync.deleteAll]. + */ + fun deleteAll(): CompletableFuture<HttpResponseFor<SharedDeleteAllResponse>> = + deleteAll(SharedDeleteAllParams.none()) + + /** @see deleteAll */ + fun deleteAll( + params: SharedDeleteAllParams = SharedDeleteAllParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<SharedDeleteAllResponse>> + + /** @see deleteAll */ + fun deleteAll( + params: SharedDeleteAllParams = SharedDeleteAllParams.none() + ): CompletableFuture<HttpResponseFor<SharedDeleteAllResponse>> = + deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<SharedDeleteAllResponse>> = + deleteAll(SharedDeleteAllParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/SharedServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/SharedServiceAsyncImpl.kt new file mode 100644 index 00000000..fe0e6d02 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/SharedServiceAsyncImpl.kt @@ -0,0 +1,125 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.workspaces.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.workspaces.current.shared.SharedDeleteAllParams +import com.langsmith_api.api.models.api.v1.workspaces.current.shared.SharedDeleteAllResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.shared.SharedListParams +import com.langsmith_api.api.models.api.v1.workspaces.current.shared.SharedListResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class SharedServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + SharedServiceAsync { + + private val withRawResponse: SharedServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): SharedServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): SharedServiceAsync = + SharedServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: SharedListParams, + requestOptions: RequestOptions, + ): CompletableFuture<SharedListResponse> = + // get /api/v1/workspaces/current/shared + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun deleteAll( + params: SharedDeleteAllParams, + requestOptions: RequestOptions, + ): CompletableFuture<SharedDeleteAllResponse> = + // delete /api/v1/workspaces/current/shared + withRawResponse().deleteAll(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SharedServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): SharedServiceAsync.WithRawResponse = + SharedServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler<SharedListResponse> = + jsonHandler<SharedListResponse>(clientOptions.jsonMapper) + + override fun list( + params: SharedListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<SharedListResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "current", "shared") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val deleteAllHandler: Handler<SharedDeleteAllResponse> = + jsonHandler<SharedDeleteAllResponse>(clientOptions.jsonMapper) + + override fun deleteAll( + params: SharedDeleteAllParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<SharedDeleteAllResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "current", "shared") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteAllHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/TagKeyServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/TagKeyServiceAsync.kt new file mode 100644 index 00000000..2eee74be --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/TagKeyServiceAsync.kt @@ -0,0 +1,337 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.workspaces.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.TagKey +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.TagKeyDeleteParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.TagKeyDeleteResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.TagKeyRetrieveParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.TagKeyRetrieveTagKeysParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.TagKeyTagKeysParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.TagKeyUpdateParams +import com.langsmith_api.api.services.async.api.v1.workspaces.current.tagkeys.TagValueServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface TagKeyServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): TagKeyServiceAsync + + fun tagValues(): TagValueServiceAsync + + /** Get Tag Key */ + fun retrieve(tagKeyId: String): CompletableFuture<TagKey> = + retrieve(tagKeyId, TagKeyRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + tagKeyId: String, + params: TagKeyRetrieveParams = TagKeyRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<TagKey> = + retrieve(params.toBuilder().tagKeyId(tagKeyId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + tagKeyId: String, + params: TagKeyRetrieveParams = TagKeyRetrieveParams.none(), + ): CompletableFuture<TagKey> = retrieve(tagKeyId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: TagKeyRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<TagKey> + + /** @see retrieve */ + fun retrieve(params: TagKeyRetrieveParams): CompletableFuture<TagKey> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(tagKeyId: String, requestOptions: RequestOptions): CompletableFuture<TagKey> = + retrieve(tagKeyId, TagKeyRetrieveParams.none(), requestOptions) + + /** Update Tag Key */ + fun update(tagKeyId: String): CompletableFuture<TagKey> = + update(tagKeyId, TagKeyUpdateParams.none()) + + /** @see update */ + fun update( + tagKeyId: String, + params: TagKeyUpdateParams = TagKeyUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<TagKey> = + update(params.toBuilder().tagKeyId(tagKeyId).build(), requestOptions) + + /** @see update */ + fun update( + tagKeyId: String, + params: TagKeyUpdateParams = TagKeyUpdateParams.none(), + ): CompletableFuture<TagKey> = update(tagKeyId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: TagKeyUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<TagKey> + + /** @see update */ + fun update(params: TagKeyUpdateParams): CompletableFuture<TagKey> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update(tagKeyId: String, requestOptions: RequestOptions): CompletableFuture<TagKey> = + update(tagKeyId, TagKeyUpdateParams.none(), requestOptions) + + /** Delete Tag Key */ + fun delete(tagKeyId: String): CompletableFuture<TagKeyDeleteResponse> = + delete(tagKeyId, TagKeyDeleteParams.none()) + + /** @see delete */ + fun delete( + tagKeyId: String, + params: TagKeyDeleteParams = TagKeyDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<TagKeyDeleteResponse> = + delete(params.toBuilder().tagKeyId(tagKeyId).build(), requestOptions) + + /** @see delete */ + fun delete( + tagKeyId: String, + params: TagKeyDeleteParams = TagKeyDeleteParams.none(), + ): CompletableFuture<TagKeyDeleteResponse> = delete(tagKeyId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: TagKeyDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<TagKeyDeleteResponse> + + /** @see delete */ + fun delete(params: TagKeyDeleteParams): CompletableFuture<TagKeyDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + tagKeyId: String, + requestOptions: RequestOptions, + ): CompletableFuture<TagKeyDeleteResponse> = + delete(tagKeyId, TagKeyDeleteParams.none(), requestOptions) + + /** List Tag Keys */ + fun retrieveTagKeys(): CompletableFuture<List<TagKey>> = + retrieveTagKeys(TagKeyRetrieveTagKeysParams.none()) + + /** @see retrieveTagKeys */ + fun retrieveTagKeys( + params: TagKeyRetrieveTagKeysParams = TagKeyRetrieveTagKeysParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<TagKey>> + + /** @see retrieveTagKeys */ + fun retrieveTagKeys( + params: TagKeyRetrieveTagKeysParams = TagKeyRetrieveTagKeysParams.none() + ): CompletableFuture<List<TagKey>> = retrieveTagKeys(params, RequestOptions.none()) + + /** @see retrieveTagKeys */ + fun retrieveTagKeys(requestOptions: RequestOptions): CompletableFuture<List<TagKey>> = + retrieveTagKeys(TagKeyRetrieveTagKeysParams.none(), requestOptions) + + /** Create Tag Key */ + fun tagKeys(params: TagKeyTagKeysParams): CompletableFuture<TagKey> = + tagKeys(params, RequestOptions.none()) + + /** @see tagKeys */ + fun tagKeys( + params: TagKeyTagKeysParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<TagKey> + + /** + * A view of [TagKeyServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): TagKeyServiceAsync.WithRawResponse + + fun tagValues(): TagValueServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/workspaces/current/tag-keys/{tag_key_id}`, + * but is otherwise the same as [TagKeyServiceAsync.retrieve]. + */ + fun retrieve(tagKeyId: String): CompletableFuture<HttpResponseFor<TagKey>> = + retrieve(tagKeyId, TagKeyRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + tagKeyId: String, + params: TagKeyRetrieveParams = TagKeyRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<TagKey>> = + retrieve(params.toBuilder().tagKeyId(tagKeyId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + tagKeyId: String, + params: TagKeyRetrieveParams = TagKeyRetrieveParams.none(), + ): CompletableFuture<HttpResponseFor<TagKey>> = + retrieve(tagKeyId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: TagKeyRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<TagKey>> + + /** @see retrieve */ + fun retrieve(params: TagKeyRetrieveParams): CompletableFuture<HttpResponseFor<TagKey>> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + tagKeyId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<TagKey>> = + retrieve(tagKeyId, TagKeyRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `patch /api/v1/workspaces/current/tag-keys/{tag_key_id}`, + * but is otherwise the same as [TagKeyServiceAsync.update]. + */ + fun update(tagKeyId: String): CompletableFuture<HttpResponseFor<TagKey>> = + update(tagKeyId, TagKeyUpdateParams.none()) + + /** @see update */ + fun update( + tagKeyId: String, + params: TagKeyUpdateParams = TagKeyUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<TagKey>> = + update(params.toBuilder().tagKeyId(tagKeyId).build(), requestOptions) + + /** @see update */ + fun update( + tagKeyId: String, + params: TagKeyUpdateParams = TagKeyUpdateParams.none(), + ): CompletableFuture<HttpResponseFor<TagKey>> = + update(tagKeyId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: TagKeyUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<TagKey>> + + /** @see update */ + fun update(params: TagKeyUpdateParams): CompletableFuture<HttpResponseFor<TagKey>> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + tagKeyId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<TagKey>> = + update(tagKeyId, TagKeyUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete + * /api/v1/workspaces/current/tag-keys/{tag_key_id}`, but is otherwise the same as + * [TagKeyServiceAsync.delete]. + */ + fun delete(tagKeyId: String): CompletableFuture<HttpResponseFor<TagKeyDeleteResponse>> = + delete(tagKeyId, TagKeyDeleteParams.none()) + + /** @see delete */ + fun delete( + tagKeyId: String, + params: TagKeyDeleteParams = TagKeyDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<TagKeyDeleteResponse>> = + delete(params.toBuilder().tagKeyId(tagKeyId).build(), requestOptions) + + /** @see delete */ + fun delete( + tagKeyId: String, + params: TagKeyDeleteParams = TagKeyDeleteParams.none(), + ): CompletableFuture<HttpResponseFor<TagKeyDeleteResponse>> = + delete(tagKeyId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: TagKeyDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<TagKeyDeleteResponse>> + + /** @see delete */ + fun delete( + params: TagKeyDeleteParams + ): CompletableFuture<HttpResponseFor<TagKeyDeleteResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + tagKeyId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<TagKeyDeleteResponse>> = + delete(tagKeyId, TagKeyDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/workspaces/current/tag-keys`, but is + * otherwise the same as [TagKeyServiceAsync.retrieveTagKeys]. + */ + fun retrieveTagKeys(): CompletableFuture<HttpResponseFor<List<TagKey>>> = + retrieveTagKeys(TagKeyRetrieveTagKeysParams.none()) + + /** @see retrieveTagKeys */ + fun retrieveTagKeys( + params: TagKeyRetrieveTagKeysParams = TagKeyRetrieveTagKeysParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<TagKey>>> + + /** @see retrieveTagKeys */ + fun retrieveTagKeys( + params: TagKeyRetrieveTagKeysParams = TagKeyRetrieveTagKeysParams.none() + ): CompletableFuture<HttpResponseFor<List<TagKey>>> = + retrieveTagKeys(params, RequestOptions.none()) + + /** @see retrieveTagKeys */ + fun retrieveTagKeys( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<TagKey>>> = + retrieveTagKeys(TagKeyRetrieveTagKeysParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/workspaces/current/tag-keys`, but is + * otherwise the same as [TagKeyServiceAsync.tagKeys]. + */ + fun tagKeys(params: TagKeyTagKeysParams): CompletableFuture<HttpResponseFor<TagKey>> = + tagKeys(params, RequestOptions.none()) + + /** @see tagKeys */ + fun tagKeys( + params: TagKeyTagKeysParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<TagKey>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/TagKeyServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/TagKeyServiceAsyncImpl.kt new file mode 100644 index 00000000..63f8979c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/TagKeyServiceAsyncImpl.kt @@ -0,0 +1,282 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.workspaces.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.TagKey +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.TagKeyDeleteParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.TagKeyDeleteResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.TagKeyRetrieveParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.TagKeyRetrieveTagKeysParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.TagKeyTagKeysParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.TagKeyUpdateParams +import com.langsmith_api.api.services.async.api.v1.workspaces.current.tagkeys.TagValueServiceAsync +import com.langsmith_api.api.services.async.api.v1.workspaces.current.tagkeys.TagValueServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class TagKeyServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + TagKeyServiceAsync { + + private val withRawResponse: TagKeyServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val tagValues: TagValueServiceAsync by lazy { TagValueServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): TagKeyServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): TagKeyServiceAsync = + TagKeyServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun tagValues(): TagValueServiceAsync = tagValues + + override fun retrieve( + params: TagKeyRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<TagKey> = + // get /api/v1/workspaces/current/tag-keys/{tag_key_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: TagKeyUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<TagKey> = + // patch /api/v1/workspaces/current/tag-keys/{tag_key_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: TagKeyDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<TagKeyDeleteResponse> = + // delete /api/v1/workspaces/current/tag-keys/{tag_key_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + override fun retrieveTagKeys( + params: TagKeyRetrieveTagKeysParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<TagKey>> = + // get /api/v1/workspaces/current/tag-keys + withRawResponse().retrieveTagKeys(params, requestOptions).thenApply { it.parse() } + + override fun tagKeys( + params: TagKeyTagKeysParams, + requestOptions: RequestOptions, + ): CompletableFuture<TagKey> = + // post /api/v1/workspaces/current/tag-keys + withRawResponse().tagKeys(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TagKeyServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val tagValues: TagValueServiceAsync.WithRawResponse by lazy { + TagValueServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): TagKeyServiceAsync.WithRawResponse = + TagKeyServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun tagValues(): TagValueServiceAsync.WithRawResponse = tagValues + + private val retrieveHandler: Handler<TagKey> = jsonHandler<TagKey>(clientOptions.jsonMapper) + + override fun retrieve( + params: TagKeyRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<TagKey>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tagKeyId", params.tagKeyId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "workspaces", + "current", + "tag-keys", + params._pathParam(0), + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler<TagKey> = jsonHandler<TagKey>(clientOptions.jsonMapper) + + override fun update( + params: TagKeyUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<TagKey>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tagKeyId", params.tagKeyId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "workspaces", + "current", + "tag-keys", + params._pathParam(0), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val deleteHandler: Handler<TagKeyDeleteResponse> = + jsonHandler<TagKeyDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: TagKeyDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<TagKeyDeleteResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tagKeyId", params.tagKeyId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "workspaces", + "current", + "tag-keys", + params._pathParam(0), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveTagKeysHandler: Handler<List<TagKey>> = + jsonHandler<List<TagKey>>(clientOptions.jsonMapper) + + override fun retrieveTagKeys( + params: TagKeyRetrieveTagKeysParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<TagKey>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "current", "tag-keys") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveTagKeysHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val tagKeysHandler: Handler<TagKey> = jsonHandler<TagKey>(clientOptions.jsonMapper) + + override fun tagKeys( + params: TagKeyTagKeysParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<TagKey>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "current", "tag-keys") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { tagKeysHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/TagServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/TagServiceAsync.kt new file mode 100644 index 00000000..1c93f205 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/TagServiceAsync.kt @@ -0,0 +1,136 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.workspaces.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.workspaces.current.tags.TagListParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tags.TagListResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.tags.TagResourcesParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tags.TagResourcesResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.tags.TagRetrieveResourceParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tags.TagRetrieveResourceResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface TagServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): TagServiceAsync + + /** List Tags */ + fun list(): CompletableFuture<List<TagListResponse>> = list(TagListParams.none()) + + /** @see list */ + fun list( + params: TagListParams = TagListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<TagListResponse>> + + /** @see list */ + fun list( + params: TagListParams = TagListParams.none() + ): CompletableFuture<List<TagListResponse>> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture<List<TagListResponse>> = + list(TagListParams.none(), requestOptions) + + /** List Tags For Resources */ + fun resources(params: TagResourcesParams): CompletableFuture<TagResourcesResponse> = + resources(params, RequestOptions.none()) + + /** @see resources */ + fun resources( + params: TagResourcesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<TagResourcesResponse> + + /** List Tags For Resource */ + fun retrieveResource( + params: TagRetrieveResourceParams + ): CompletableFuture<List<TagRetrieveResourceResponse>> = + retrieveResource(params, RequestOptions.none()) + + /** @see retrieveResource */ + fun retrieveResource( + params: TagRetrieveResourceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<TagRetrieveResourceResponse>> + + /** A view of [TagServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): TagServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/workspaces/current/tags`, but is otherwise + * the same as [TagServiceAsync.list]. + */ + fun list(): CompletableFuture<HttpResponseFor<List<TagListResponse>>> = + list(TagListParams.none()) + + /** @see list */ + fun list( + params: TagListParams = TagListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<TagListResponse>>> + + /** @see list */ + fun list( + params: TagListParams = TagListParams.none() + ): CompletableFuture<HttpResponseFor<List<TagListResponse>>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<TagListResponse>>> = + list(TagListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/workspaces/current/tags/resources`, but is + * otherwise the same as [TagServiceAsync.resources]. + */ + fun resources( + params: TagResourcesParams + ): CompletableFuture<HttpResponseFor<TagResourcesResponse>> = + resources(params, RequestOptions.none()) + + /** @see resources */ + fun resources( + params: TagResourcesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<TagResourcesResponse>> + + /** + * Returns a raw HTTP response for `get /api/v1/workspaces/current/tags/resource`, but is + * otherwise the same as [TagServiceAsync.retrieveResource]. + */ + fun retrieveResource( + params: TagRetrieveResourceParams + ): CompletableFuture<HttpResponseFor<List<TagRetrieveResourceResponse>>> = + retrieveResource(params, RequestOptions.none()) + + /** @see retrieveResource */ + fun retrieveResource( + params: TagRetrieveResourceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<TagRetrieveResourceResponse>>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/TagServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/TagServiceAsyncImpl.kt new file mode 100644 index 00000000..a3d52e50 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/TagServiceAsyncImpl.kt @@ -0,0 +1,164 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.workspaces.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.workspaces.current.tags.TagListParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tags.TagListResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.tags.TagResourcesParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tags.TagResourcesResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.tags.TagRetrieveResourceParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tags.TagRetrieveResourceResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class TagServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + TagServiceAsync { + + private val withRawResponse: TagServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): TagServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): TagServiceAsync = + TagServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: TagListParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<TagListResponse>> = + // get /api/v1/workspaces/current/tags + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun resources( + params: TagResourcesParams, + requestOptions: RequestOptions, + ): CompletableFuture<TagResourcesResponse> = + // post /api/v1/workspaces/current/tags/resources + withRawResponse().resources(params, requestOptions).thenApply { it.parse() } + + override fun retrieveResource( + params: TagRetrieveResourceParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<TagRetrieveResourceResponse>> = + // get /api/v1/workspaces/current/tags/resource + withRawResponse().retrieveResource(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TagServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): TagServiceAsync.WithRawResponse = + TagServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler<List<TagListResponse>> = + jsonHandler<List<TagListResponse>>(clientOptions.jsonMapper) + + override fun list( + params: TagListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<TagListResponse>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "current", "tags") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val resourcesHandler: Handler<TagResourcesResponse> = + jsonHandler<TagResourcesResponse>(clientOptions.jsonMapper) + + override fun resources( + params: TagResourcesParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<TagResourcesResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "current", "tags", "resources") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { resourcesHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveResourceHandler: Handler<List<TagRetrieveResourceResponse>> = + jsonHandler<List<TagRetrieveResourceResponse>>(clientOptions.jsonMapper) + + override fun retrieveResource( + params: TagRetrieveResourceParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<TagRetrieveResourceResponse>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "current", "tags", "resource") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveResourceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/TaggingServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/TaggingServiceAsync.kt new file mode 100644 index 00000000..b23b4cbc --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/TaggingServiceAsync.kt @@ -0,0 +1,188 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.workspaces.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.workspaces.current.taggings.Tagging +import com.langsmith_api.api.models.api.v1.workspaces.current.taggings.TaggingCreateParams +import com.langsmith_api.api.models.api.v1.workspaces.current.taggings.TaggingDeleteParams +import com.langsmith_api.api.models.api.v1.workspaces.current.taggings.TaggingDeleteResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.taggings.TaggingListParams +import com.langsmith_api.api.models.api.v1.workspaces.current.taggings.TaggingListResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface TaggingServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): TaggingServiceAsync + + /** Create Tagging */ + fun create(params: TaggingCreateParams): CompletableFuture<Tagging> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: TaggingCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<Tagging> + + /** List Taggings */ + fun list(): CompletableFuture<List<TaggingListResponse>> = list(TaggingListParams.none()) + + /** @see list */ + fun list( + params: TaggingListParams = TaggingListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<TaggingListResponse>> + + /** @see list */ + fun list( + params: TaggingListParams = TaggingListParams.none() + ): CompletableFuture<List<TaggingListResponse>> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture<List<TaggingListResponse>> = + list(TaggingListParams.none(), requestOptions) + + /** Delete Tagging */ + fun delete(taggingId: String): CompletableFuture<TaggingDeleteResponse> = + delete(taggingId, TaggingDeleteParams.none()) + + /** @see delete */ + fun delete( + taggingId: String, + params: TaggingDeleteParams = TaggingDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<TaggingDeleteResponse> = + delete(params.toBuilder().taggingId(taggingId).build(), requestOptions) + + /** @see delete */ + fun delete( + taggingId: String, + params: TaggingDeleteParams = TaggingDeleteParams.none(), + ): CompletableFuture<TaggingDeleteResponse> = delete(taggingId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: TaggingDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<TaggingDeleteResponse> + + /** @see delete */ + fun delete(params: TaggingDeleteParams): CompletableFuture<TaggingDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + taggingId: String, + requestOptions: RequestOptions, + ): CompletableFuture<TaggingDeleteResponse> = + delete(taggingId, TaggingDeleteParams.none(), requestOptions) + + /** + * A view of [TaggingServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): TaggingServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/workspaces/current/taggings`, but is + * otherwise the same as [TaggingServiceAsync.create]. + */ + fun create(params: TaggingCreateParams): CompletableFuture<HttpResponseFor<Tagging>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: TaggingCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<Tagging>> + + /** + * Returns a raw HTTP response for `get /api/v1/workspaces/current/taggings`, but is + * otherwise the same as [TaggingServiceAsync.list]. + */ + fun list(): CompletableFuture<HttpResponseFor<List<TaggingListResponse>>> = + list(TaggingListParams.none()) + + /** @see list */ + fun list( + params: TaggingListParams = TaggingListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<TaggingListResponse>>> + + /** @see list */ + fun list( + params: TaggingListParams = TaggingListParams.none() + ): CompletableFuture<HttpResponseFor<List<TaggingListResponse>>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<TaggingListResponse>>> = + list(TaggingListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete + * /api/v1/workspaces/current/taggings/{tagging_id}`, but is otherwise the same as + * [TaggingServiceAsync.delete]. + */ + fun delete(taggingId: String): CompletableFuture<HttpResponseFor<TaggingDeleteResponse>> = + delete(taggingId, TaggingDeleteParams.none()) + + /** @see delete */ + fun delete( + taggingId: String, + params: TaggingDeleteParams = TaggingDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<TaggingDeleteResponse>> = + delete(params.toBuilder().taggingId(taggingId).build(), requestOptions) + + /** @see delete */ + fun delete( + taggingId: String, + params: TaggingDeleteParams = TaggingDeleteParams.none(), + ): CompletableFuture<HttpResponseFor<TaggingDeleteResponse>> = + delete(taggingId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: TaggingDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<TaggingDeleteResponse>> + + /** @see delete */ + fun delete( + params: TaggingDeleteParams + ): CompletableFuture<HttpResponseFor<TaggingDeleteResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + taggingId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<TaggingDeleteResponse>> = + delete(taggingId, TaggingDeleteParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/TaggingServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/TaggingServiceAsyncImpl.kt new file mode 100644 index 00000000..5c3526dc --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/TaggingServiceAsyncImpl.kt @@ -0,0 +1,176 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.workspaces.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.workspaces.current.taggings.Tagging +import com.langsmith_api.api.models.api.v1.workspaces.current.taggings.TaggingCreateParams +import com.langsmith_api.api.models.api.v1.workspaces.current.taggings.TaggingDeleteParams +import com.langsmith_api.api.models.api.v1.workspaces.current.taggings.TaggingDeleteResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.taggings.TaggingListParams +import com.langsmith_api.api.models.api.v1.workspaces.current.taggings.TaggingListResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class TaggingServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + TaggingServiceAsync { + + private val withRawResponse: TaggingServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): TaggingServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): TaggingServiceAsync = + TaggingServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: TaggingCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<Tagging> = + // post /api/v1/workspaces/current/taggings + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: TaggingListParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<TaggingListResponse>> = + // get /api/v1/workspaces/current/taggings + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: TaggingDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<TaggingDeleteResponse> = + // delete /api/v1/workspaces/current/taggings/{tagging_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TaggingServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): TaggingServiceAsync.WithRawResponse = + TaggingServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<Tagging> = jsonHandler<Tagging>(clientOptions.jsonMapper) + + override fun create( + params: TaggingCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<Tagging>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "current", "taggings") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler<List<TaggingListResponse>> = + jsonHandler<List<TaggingListResponse>>(clientOptions.jsonMapper) + + override fun list( + params: TaggingListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<TaggingListResponse>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "current", "taggings") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val deleteHandler: Handler<TaggingDeleteResponse> = + jsonHandler<TaggingDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: TaggingDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<TaggingDeleteResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("taggingId", params.taggingId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "workspaces", + "current", + "taggings", + params._pathParam(0), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/members/PendingServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/members/PendingServiceAsync.kt new file mode 100644 index 00000000..1bbb34c8 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/members/PendingServiceAsync.kt @@ -0,0 +1,166 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.workspaces.current.members + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.orgs.current.members.PendingIdentity +import com.langsmith_api.api.models.api.v1.workspaces.current.members.pending.PendingDeleteAllParams +import com.langsmith_api.api.models.api.v1.workspaces.current.members.pending.PendingDeleteAllResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.members.pending.PendingListParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface PendingServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): PendingServiceAsync + + /** Get Current Pending Workspace Members */ + fun list(): CompletableFuture<List<PendingIdentity>> = list(PendingListParams.none()) + + /** @see list */ + fun list( + params: PendingListParams = PendingListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<PendingIdentity>> + + /** @see list */ + fun list( + params: PendingListParams = PendingListParams.none() + ): CompletableFuture<List<PendingIdentity>> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture<List<PendingIdentity>> = + list(PendingListParams.none(), requestOptions) + + /** Delete Current Workspace Pending Member */ + fun deleteAll(identityId: String): CompletableFuture<PendingDeleteAllResponse> = + deleteAll(identityId, PendingDeleteAllParams.none()) + + /** @see deleteAll */ + fun deleteAll( + identityId: String, + params: PendingDeleteAllParams = PendingDeleteAllParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<PendingDeleteAllResponse> = + deleteAll(params.toBuilder().identityId(identityId).build(), requestOptions) + + /** @see deleteAll */ + fun deleteAll( + identityId: String, + params: PendingDeleteAllParams = PendingDeleteAllParams.none(), + ): CompletableFuture<PendingDeleteAllResponse> = + deleteAll(identityId, params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + params: PendingDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<PendingDeleteAllResponse> + + /** @see deleteAll */ + fun deleteAll(params: PendingDeleteAllParams): CompletableFuture<PendingDeleteAllResponse> = + deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + identityId: String, + requestOptions: RequestOptions, + ): CompletableFuture<PendingDeleteAllResponse> = + deleteAll(identityId, PendingDeleteAllParams.none(), requestOptions) + + /** + * A view of [PendingServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PendingServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/workspaces/current/members/pending`, but is + * otherwise the same as [PendingServiceAsync.list]. + */ + fun list(): CompletableFuture<HttpResponseFor<List<PendingIdentity>>> = + list(PendingListParams.none()) + + /** @see list */ + fun list( + params: PendingListParams = PendingListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<PendingIdentity>>> + + /** @see list */ + fun list( + params: PendingListParams = PendingListParams.none() + ): CompletableFuture<HttpResponseFor<List<PendingIdentity>>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<List<PendingIdentity>>> = + list(PendingListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete + * /api/v1/workspaces/current/members/{identity_id}/pending`, but is otherwise the same as + * [PendingServiceAsync.deleteAll]. + */ + fun deleteAll( + identityId: String + ): CompletableFuture<HttpResponseFor<PendingDeleteAllResponse>> = + deleteAll(identityId, PendingDeleteAllParams.none()) + + /** @see deleteAll */ + fun deleteAll( + identityId: String, + params: PendingDeleteAllParams = PendingDeleteAllParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<PendingDeleteAllResponse>> = + deleteAll(params.toBuilder().identityId(identityId).build(), requestOptions) + + /** @see deleteAll */ + fun deleteAll( + identityId: String, + params: PendingDeleteAllParams = PendingDeleteAllParams.none(), + ): CompletableFuture<HttpResponseFor<PendingDeleteAllResponse>> = + deleteAll(identityId, params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + params: PendingDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<PendingDeleteAllResponse>> + + /** @see deleteAll */ + fun deleteAll( + params: PendingDeleteAllParams + ): CompletableFuture<HttpResponseFor<PendingDeleteAllResponse>> = + deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + identityId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<PendingDeleteAllResponse>> = + deleteAll(identityId, PendingDeleteAllParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/members/PendingServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/members/PendingServiceAsyncImpl.kt new file mode 100644 index 00000000..51ed77a2 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/members/PendingServiceAsyncImpl.kt @@ -0,0 +1,138 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.workspaces.current.members + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.orgs.current.members.PendingIdentity +import com.langsmith_api.api.models.api.v1.workspaces.current.members.pending.PendingDeleteAllParams +import com.langsmith_api.api.models.api.v1.workspaces.current.members.pending.PendingDeleteAllResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.members.pending.PendingListParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class PendingServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + PendingServiceAsync { + + private val withRawResponse: PendingServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): PendingServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): PendingServiceAsync = + PendingServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: PendingListParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<PendingIdentity>> = + // get /api/v1/workspaces/current/members/pending + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun deleteAll( + params: PendingDeleteAllParams, + requestOptions: RequestOptions, + ): CompletableFuture<PendingDeleteAllResponse> = + // delete /api/v1/workspaces/current/members/{identity_id}/pending + withRawResponse().deleteAll(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + PendingServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PendingServiceAsync.WithRawResponse = + PendingServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler<List<PendingIdentity>> = + jsonHandler<List<PendingIdentity>>(clientOptions.jsonMapper) + + override fun list( + params: PendingListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<PendingIdentity>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "current", "members", "pending") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val deleteAllHandler: Handler<PendingDeleteAllResponse> = + jsonHandler<PendingDeleteAllResponse>(clientOptions.jsonMapper) + + override fun deleteAll( + params: PendingDeleteAllParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<PendingDeleteAllResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("identityId", params.identityId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "workspaces", + "current", + "members", + params._pathParam(0), + "pending", + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteAllHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/tagkeys/TagValueServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/tagkeys/TagValueServiceAsync.kt new file mode 100644 index 00000000..95161d28 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/tagkeys/TagValueServiceAsync.kt @@ -0,0 +1,336 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.workspaces.current.tagkeys + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues.TagValue +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues.TagValueDeleteParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues.TagValueDeleteResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues.TagValueRetrieveParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues.TagValueRetrieveTagValuesParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues.TagValueTagValuesParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues.TagValueUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface TagValueServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): TagValueServiceAsync + + /** Get Tag Value */ + fun retrieve(tagValueId: String, params: TagValueRetrieveParams): CompletableFuture<TagValue> = + retrieve(tagValueId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + tagValueId: String, + params: TagValueRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<TagValue> = + retrieve(params.toBuilder().tagValueId(tagValueId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: TagValueRetrieveParams): CompletableFuture<TagValue> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: TagValueRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<TagValue> + + /** Update Tag Value */ + fun update(tagValueId: String, params: TagValueUpdateParams): CompletableFuture<TagValue> = + update(tagValueId, params, RequestOptions.none()) + + /** @see update */ + fun update( + tagValueId: String, + params: TagValueUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<TagValue> = + update(params.toBuilder().tagValueId(tagValueId).build(), requestOptions) + + /** @see update */ + fun update(params: TagValueUpdateParams): CompletableFuture<TagValue> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: TagValueUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<TagValue> + + /** Delete Tag Value */ + fun delete( + tagValueId: String, + params: TagValueDeleteParams, + ): CompletableFuture<TagValueDeleteResponse> = delete(tagValueId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + tagValueId: String, + params: TagValueDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<TagValueDeleteResponse> = + delete(params.toBuilder().tagValueId(tagValueId).build(), requestOptions) + + /** @see delete */ + fun delete(params: TagValueDeleteParams): CompletableFuture<TagValueDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: TagValueDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<TagValueDeleteResponse> + + /** List Tag Values */ + fun retrieveTagValues(tagKeyId: String): CompletableFuture<List<TagValue>> = + retrieveTagValues(tagKeyId, TagValueRetrieveTagValuesParams.none()) + + /** @see retrieveTagValues */ + fun retrieveTagValues( + tagKeyId: String, + params: TagValueRetrieveTagValuesParams = TagValueRetrieveTagValuesParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<TagValue>> = + retrieveTagValues(params.toBuilder().tagKeyId(tagKeyId).build(), requestOptions) + + /** @see retrieveTagValues */ + fun retrieveTagValues( + tagKeyId: String, + params: TagValueRetrieveTagValuesParams = TagValueRetrieveTagValuesParams.none(), + ): CompletableFuture<List<TagValue>> = + retrieveTagValues(tagKeyId, params, RequestOptions.none()) + + /** @see retrieveTagValues */ + fun retrieveTagValues( + params: TagValueRetrieveTagValuesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<TagValue>> + + /** @see retrieveTagValues */ + fun retrieveTagValues( + params: TagValueRetrieveTagValuesParams + ): CompletableFuture<List<TagValue>> = retrieveTagValues(params, RequestOptions.none()) + + /** @see retrieveTagValues */ + fun retrieveTagValues( + tagKeyId: String, + requestOptions: RequestOptions, + ): CompletableFuture<List<TagValue>> = + retrieveTagValues(tagKeyId, TagValueRetrieveTagValuesParams.none(), requestOptions) + + /** Create Tag Value */ + fun tagValues(tagKeyId: String, params: TagValueTagValuesParams): CompletableFuture<TagValue> = + tagValues(tagKeyId, params, RequestOptions.none()) + + /** @see tagValues */ + fun tagValues( + tagKeyId: String, + params: TagValueTagValuesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<TagValue> = + tagValues(params.toBuilder().tagKeyId(tagKeyId).build(), requestOptions) + + /** @see tagValues */ + fun tagValues(params: TagValueTagValuesParams): CompletableFuture<TagValue> = + tagValues(params, RequestOptions.none()) + + /** @see tagValues */ + fun tagValues( + params: TagValueTagValuesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<TagValue> + + /** + * A view of [TagValueServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): TagValueServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get + * /api/v1/workspaces/current/tag-keys/{tag_key_id}/tag-values/{tag_value_id}`, but is + * otherwise the same as [TagValueServiceAsync.retrieve]. + */ + fun retrieve( + tagValueId: String, + params: TagValueRetrieveParams, + ): CompletableFuture<HttpResponseFor<TagValue>> = + retrieve(tagValueId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + tagValueId: String, + params: TagValueRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<TagValue>> = + retrieve(params.toBuilder().tagValueId(tagValueId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: TagValueRetrieveParams): CompletableFuture<HttpResponseFor<TagValue>> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: TagValueRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<TagValue>> + + /** + * Returns a raw HTTP response for `patch + * /api/v1/workspaces/current/tag-keys/{tag_key_id}/tag-values/{tag_value_id}`, but is + * otherwise the same as [TagValueServiceAsync.update]. + */ + fun update( + tagValueId: String, + params: TagValueUpdateParams, + ): CompletableFuture<HttpResponseFor<TagValue>> = + update(tagValueId, params, RequestOptions.none()) + + /** @see update */ + fun update( + tagValueId: String, + params: TagValueUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<TagValue>> = + update(params.toBuilder().tagValueId(tagValueId).build(), requestOptions) + + /** @see update */ + fun update(params: TagValueUpdateParams): CompletableFuture<HttpResponseFor<TagValue>> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: TagValueUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<TagValue>> + + /** + * Returns a raw HTTP response for `delete + * /api/v1/workspaces/current/tag-keys/{tag_key_id}/tag-values/{tag_value_id}`, but is + * otherwise the same as [TagValueServiceAsync.delete]. + */ + fun delete( + tagValueId: String, + params: TagValueDeleteParams, + ): CompletableFuture<HttpResponseFor<TagValueDeleteResponse>> = + delete(tagValueId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + tagValueId: String, + params: TagValueDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<TagValueDeleteResponse>> = + delete(params.toBuilder().tagValueId(tagValueId).build(), requestOptions) + + /** @see delete */ + fun delete( + params: TagValueDeleteParams + ): CompletableFuture<HttpResponseFor<TagValueDeleteResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: TagValueDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<TagValueDeleteResponse>> + + /** + * Returns a raw HTTP response for `get + * /api/v1/workspaces/current/tag-keys/{tag_key_id}/tag-values`, but is otherwise the same + * as [TagValueServiceAsync.retrieveTagValues]. + */ + fun retrieveTagValues( + tagKeyId: String + ): CompletableFuture<HttpResponseFor<List<TagValue>>> = + retrieveTagValues(tagKeyId, TagValueRetrieveTagValuesParams.none()) + + /** @see retrieveTagValues */ + fun retrieveTagValues( + tagKeyId: String, + params: TagValueRetrieveTagValuesParams = TagValueRetrieveTagValuesParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<TagValue>>> = + retrieveTagValues(params.toBuilder().tagKeyId(tagKeyId).build(), requestOptions) + + /** @see retrieveTagValues */ + fun retrieveTagValues( + tagKeyId: String, + params: TagValueRetrieveTagValuesParams = TagValueRetrieveTagValuesParams.none(), + ): CompletableFuture<HttpResponseFor<List<TagValue>>> = + retrieveTagValues(tagKeyId, params, RequestOptions.none()) + + /** @see retrieveTagValues */ + fun retrieveTagValues( + params: TagValueRetrieveTagValuesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<TagValue>>> + + /** @see retrieveTagValues */ + fun retrieveTagValues( + params: TagValueRetrieveTagValuesParams + ): CompletableFuture<HttpResponseFor<List<TagValue>>> = + retrieveTagValues(params, RequestOptions.none()) + + /** @see retrieveTagValues */ + fun retrieveTagValues( + tagKeyId: String, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<TagValue>>> = + retrieveTagValues(tagKeyId, TagValueRetrieveTagValuesParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post + * /api/v1/workspaces/current/tag-keys/{tag_key_id}/tag-values`, but is otherwise the same + * as [TagValueServiceAsync.tagValues]. + */ + fun tagValues( + tagKeyId: String, + params: TagValueTagValuesParams, + ): CompletableFuture<HttpResponseFor<TagValue>> = + tagValues(tagKeyId, params, RequestOptions.none()) + + /** @see tagValues */ + fun tagValues( + tagKeyId: String, + params: TagValueTagValuesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<TagValue>> = + tagValues(params.toBuilder().tagKeyId(tagKeyId).build(), requestOptions) + + /** @see tagValues */ + fun tagValues( + params: TagValueTagValuesParams + ): CompletableFuture<HttpResponseFor<TagValue>> = tagValues(params, RequestOptions.none()) + + /** @see tagValues */ + fun tagValues( + params: TagValueTagValuesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<TagValue>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/tagkeys/TagValueServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/tagkeys/TagValueServiceAsyncImpl.kt new file mode 100644 index 00000000..46841879 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/tagkeys/TagValueServiceAsyncImpl.kt @@ -0,0 +1,301 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.workspaces.current.tagkeys + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues.TagValue +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues.TagValueDeleteParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues.TagValueDeleteResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues.TagValueRetrieveParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues.TagValueRetrieveTagValuesParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues.TagValueTagValuesParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues.TagValueUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class TagValueServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + TagValueServiceAsync { + + private val withRawResponse: TagValueServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): TagValueServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): TagValueServiceAsync = + TagValueServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: TagValueRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<TagValue> = + // get /api/v1/workspaces/current/tag-keys/{tag_key_id}/tag-values/{tag_value_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: TagValueUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<TagValue> = + // patch /api/v1/workspaces/current/tag-keys/{tag_key_id}/tag-values/{tag_value_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: TagValueDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<TagValueDeleteResponse> = + // delete /api/v1/workspaces/current/tag-keys/{tag_key_id}/tag-values/{tag_value_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + override fun retrieveTagValues( + params: TagValueRetrieveTagValuesParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<TagValue>> = + // get /api/v1/workspaces/current/tag-keys/{tag_key_id}/tag-values + withRawResponse().retrieveTagValues(params, requestOptions).thenApply { it.parse() } + + override fun tagValues( + params: TagValueTagValuesParams, + requestOptions: RequestOptions, + ): CompletableFuture<TagValue> = + // post /api/v1/workspaces/current/tag-keys/{tag_key_id}/tag-values + withRawResponse().tagValues(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TagValueServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): TagValueServiceAsync.WithRawResponse = + TagValueServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler<TagValue> = + jsonHandler<TagValue>(clientOptions.jsonMapper) + + override fun retrieve( + params: TagValueRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<TagValue>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tagValueId", params.tagValueId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "workspaces", + "current", + "tag-keys", + params._pathParam(0), + "tag-values", + params._pathParam(1), + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler<TagValue> = + jsonHandler<TagValue>(clientOptions.jsonMapper) + + override fun update( + params: TagValueUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<TagValue>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tagValueId", params.tagValueId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "workspaces", + "current", + "tag-keys", + params._pathParam(0), + "tag-values", + params._pathParam(1), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val deleteHandler: Handler<TagValueDeleteResponse> = + jsonHandler<TagValueDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: TagValueDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<TagValueDeleteResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tagValueId", params.tagValueId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "workspaces", + "current", + "tag-keys", + params._pathParam(0), + "tag-values", + params._pathParam(1), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveTagValuesHandler: Handler<List<TagValue>> = + jsonHandler<List<TagValue>>(clientOptions.jsonMapper) + + override fun retrieveTagValues( + params: TagValueRetrieveTagValuesParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<TagValue>>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tagKeyId", params.tagKeyId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "workspaces", + "current", + "tag-keys", + params._pathParam(0), + "tag-values", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveTagValuesHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val tagValuesHandler: Handler<TagValue> = + jsonHandler<TagValue>(clientOptions.jsonMapper) + + override fun tagValues( + params: TagValueTagValuesParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<TagValue>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tagKeyId", params.tagKeyId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "workspaces", + "current", + "tag-keys", + params._pathParam(0), + "tag-values", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { tagValuesHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/datasets/ExperimentViewOverrideServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/datasets/ExperimentViewOverrideServiceAsync.kt new file mode 100644 index 00000000..bc1d615e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/datasets/ExperimentViewOverrideServiceAsync.kt @@ -0,0 +1,417 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.datasets + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.datasets.experimentviewoverrides.ExperimentViewOverride +import com.langsmith_api.api.models.datasets.experimentviewoverrides.ExperimentViewOverrideCreateParams +import com.langsmith_api.api.models.datasets.experimentviewoverrides.ExperimentViewOverrideDeleteParams +import com.langsmith_api.api.models.datasets.experimentviewoverrides.ExperimentViewOverrideListParams +import com.langsmith_api.api.models.datasets.experimentviewoverrides.ExperimentViewOverrideRetrieveParams +import com.langsmith_api.api.models.datasets.experimentviewoverrides.ExperimentViewOverrideUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface ExperimentViewOverrideServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ExperimentViewOverrideServiceAsync + + /** + * Creates a new experiment view override configuration for a dataset with column display + * settings. This endpoint allows you to customize how experiment results are displayed by + * configuring column-specific overrides including colors, precision, and visibility. + * + * The request must include a 'column_overrides' array with at least one override configuration. + * Each column override can specify: + * - column: Required field name (must start with inputs, outputs, reference_outputs, feedback, + * metrics, attachments, or metadata) + * - color_gradient: Optional array of [number, color] tuples for numeric data visualization + * - precision: Optional number (1-6) for decimal places in numeric columns + * - hide: Optional boolean to control column visibility + * + * Example request body: { "column_overrides": + * [ { "column": "outputs.accuracy", "color_gradient": [[0.0, "#ff0000"], [0.5, "#ffff00"], + * [1.0, "#00ff00"]], "precision": 3 }, { "column": "inputs.model_type", "hide": false } ] } + * + * This operation fails if an override already exists for the dataset (use PATCH to update). + */ + fun create( + datasetId: JsonValue, + params: ExperimentViewOverrideCreateParams, + ): CompletableFuture<ExperimentViewOverride> = create(datasetId, params, RequestOptions.none()) + + /** @see create */ + fun create( + datasetId: JsonValue, + params: ExperimentViewOverrideCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ExperimentViewOverride> = + create(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see create */ + fun create( + params: ExperimentViewOverrideCreateParams + ): CompletableFuture<ExperimentViewOverride> = create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: ExperimentViewOverrideCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ExperimentViewOverride> + + /** + * Retrieves a specific experiment view override configuration using both dataset ID and + * override ID. This endpoint provides more precise access to experiment view overrides when you + * have the specific override ID, useful for direct links or cached references. + * + * The response includes the same column override information as the dataset-level endpoint: + * - Column identifiers with validation prefixes + * - Color gradient settings for numeric data visualization + * - Numeric precision configurations + * - Column visibility controls + * + * Both the dataset and override must exist and be accessible by the authenticated user. + */ + fun retrieve( + id: JsonValue, + params: ExperimentViewOverrideRetrieveParams, + ): CompletableFuture<ExperimentViewOverride> = retrieve(id, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + id: JsonValue, + params: ExperimentViewOverrideRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ExperimentViewOverride> = + retrieve(params.toBuilder().id(id).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + params: ExperimentViewOverrideRetrieveParams + ): CompletableFuture<ExperimentViewOverride> = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: ExperimentViewOverrideRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ExperimentViewOverride> + + /** + * Updates an existing experiment view override configuration by completely replacing the column + * overrides for the specified dataset and override ID. + * + * This endpoint performs a complete replacement of the column overrides configuration. All + * existing column overrides will be replaced with the new configuration provided in the request + * body. To add or modify individual columns, include the complete desired configuration in the + * request. + * + * The request format is identical to the create endpoint: + * - column_overrides: Required array with at least one override configuration + * - Each override can specify color gradients, precision, and visibility + * + * Example request body: { "column_overrides": + * [ { "column": "metrics.f1_score", "color_gradient": [[0.0, "#ff4444"], [0.8, "#44ff44"]], + * "precision": 4 }, { "column": "feedback.rating", "hide": false } ] } + * + * Both the dataset and override must exist and be accessible by the authenticated user. + */ + fun update( + id: JsonValue, + params: ExperimentViewOverrideUpdateParams, + ): CompletableFuture<ExperimentViewOverride> = update(id, params, RequestOptions.none()) + + /** @see update */ + fun update( + id: JsonValue, + params: ExperimentViewOverrideUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ExperimentViewOverride> = + update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + fun update( + params: ExperimentViewOverrideUpdateParams + ): CompletableFuture<ExperimentViewOverride> = update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: ExperimentViewOverrideUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ExperimentViewOverride> + + /** + * Retrieves all experiment view override configurations for a specific dataset. This endpoint + * returns column display overrides including color gradients, precision settings, and column + * visibility configurations that customize how experiment results are displayed in the UI. + * + * The response includes all column overrides with their display settings: + * - Column identifiers (must start with inputs, outputs, reference_outputs, feedback, metrics, + * attachments, or metadata) + * - Color gradients for numeric data visualization + * - Precision settings for numeric columns (1-6 decimal places) + * - Hide flags to control column visibility + */ + fun list(datasetId: JsonValue): CompletableFuture<List<ExperimentViewOverride>> = + list(datasetId, ExperimentViewOverrideListParams.none()) + + /** @see list */ + fun list( + datasetId: JsonValue, + params: ExperimentViewOverrideListParams = ExperimentViewOverrideListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<ExperimentViewOverride>> = + list(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see list */ + fun list( + datasetId: JsonValue, + params: ExperimentViewOverrideListParams = ExperimentViewOverrideListParams.none(), + ): CompletableFuture<List<ExperimentViewOverride>> = + list(datasetId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: ExperimentViewOverrideListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<List<ExperimentViewOverride>> + + /** @see list */ + fun list( + params: ExperimentViewOverrideListParams + ): CompletableFuture<List<ExperimentViewOverride>> = list(params, RequestOptions.none()) + + /** @see list */ + fun list( + datasetId: JsonValue, + requestOptions: RequestOptions, + ): CompletableFuture<List<ExperimentViewOverride>> = + list(datasetId, ExperimentViewOverrideListParams.none(), requestOptions) + + /** + * Permanently deletes an experiment view override configuration for a dataset. This operation + * removes all column override settings including color gradients, precision configurations, and + * visibility settings. + * + * After deletion, the experiment view will revert to default column display settings. This + * action cannot be undone - you will need to recreate the override configuration if you want to + * restore custom column settings. + * + * Both the dataset and override must exist and be accessible by the authenticated user. The + * operation will fail if the override doesn't exist or if the user doesn't have appropriate + * permissions for the dataset. + */ + fun delete( + id: JsonValue, + params: ExperimentViewOverrideDeleteParams, + ): CompletableFuture<Void?> = delete(id, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + id: JsonValue, + params: ExperimentViewOverrideDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<Void?> = delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + fun delete(params: ExperimentViewOverrideDeleteParams): CompletableFuture<Void?> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ExperimentViewOverrideDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<Void?> + + /** + * A view of [ExperimentViewOverrideServiceAsync] that provides access to raw HTTP responses for + * each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ExperimentViewOverrideServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /datasets/{dataset_id}/experiment-view-overrides`, + * but is otherwise the same as [ExperimentViewOverrideServiceAsync.create]. + */ + fun create( + datasetId: JsonValue, + params: ExperimentViewOverrideCreateParams, + ): CompletableFuture<HttpResponseFor<ExperimentViewOverride>> = + create(datasetId, params, RequestOptions.none()) + + /** @see create */ + fun create( + datasetId: JsonValue, + params: ExperimentViewOverrideCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ExperimentViewOverride>> = + create(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see create */ + fun create( + params: ExperimentViewOverrideCreateParams + ): CompletableFuture<HttpResponseFor<ExperimentViewOverride>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: ExperimentViewOverrideCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ExperimentViewOverride>> + + /** + * Returns a raw HTTP response for `get + * /datasets/{dataset_id}/experiment-view-overrides/{id}`, but is otherwise the same as + * [ExperimentViewOverrideServiceAsync.retrieve]. + */ + fun retrieve( + id: JsonValue, + params: ExperimentViewOverrideRetrieveParams, + ): CompletableFuture<HttpResponseFor<ExperimentViewOverride>> = + retrieve(id, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + id: JsonValue, + params: ExperimentViewOverrideRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ExperimentViewOverride>> = + retrieve(params.toBuilder().id(id).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + params: ExperimentViewOverrideRetrieveParams + ): CompletableFuture<HttpResponseFor<ExperimentViewOverride>> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: ExperimentViewOverrideRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ExperimentViewOverride>> + + /** + * Returns a raw HTTP response for `patch + * /datasets/{dataset_id}/experiment-view-overrides/{id}`, but is otherwise the same as + * [ExperimentViewOverrideServiceAsync.update]. + */ + fun update( + id: JsonValue, + params: ExperimentViewOverrideUpdateParams, + ): CompletableFuture<HttpResponseFor<ExperimentViewOverride>> = + update(id, params, RequestOptions.none()) + + /** @see update */ + fun update( + id: JsonValue, + params: ExperimentViewOverrideUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ExperimentViewOverride>> = + update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + fun update( + params: ExperimentViewOverrideUpdateParams + ): CompletableFuture<HttpResponseFor<ExperimentViewOverride>> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: ExperimentViewOverrideUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ExperimentViewOverride>> + + /** + * Returns a raw HTTP response for `get /datasets/{dataset_id}/experiment-view-overrides`, + * but is otherwise the same as [ExperimentViewOverrideServiceAsync.list]. + */ + fun list( + datasetId: JsonValue + ): CompletableFuture<HttpResponseFor<List<ExperimentViewOverride>>> = + list(datasetId, ExperimentViewOverrideListParams.none()) + + /** @see list */ + fun list( + datasetId: JsonValue, + params: ExperimentViewOverrideListParams = ExperimentViewOverrideListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<ExperimentViewOverride>>> = + list(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see list */ + fun list( + datasetId: JsonValue, + params: ExperimentViewOverrideListParams = ExperimentViewOverrideListParams.none(), + ): CompletableFuture<HttpResponseFor<List<ExperimentViewOverride>>> = + list(datasetId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: ExperimentViewOverrideListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<List<ExperimentViewOverride>>> + + /** @see list */ + fun list( + params: ExperimentViewOverrideListParams + ): CompletableFuture<HttpResponseFor<List<ExperimentViewOverride>>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + datasetId: JsonValue, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<ExperimentViewOverride>>> = + list(datasetId, ExperimentViewOverrideListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete + * /datasets/{dataset_id}/experiment-view-overrides/{id}`, but is otherwise the same as + * [ExperimentViewOverrideServiceAsync.delete]. + */ + fun delete( + id: JsonValue, + params: ExperimentViewOverrideDeleteParams, + ): CompletableFuture<HttpResponse> = delete(id, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + id: JsonValue, + params: ExperimentViewOverrideDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponse> = + delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + fun delete(params: ExperimentViewOverrideDeleteParams): CompletableFuture<HttpResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ExperimentViewOverrideDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponse> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/datasets/ExperimentViewOverrideServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/datasets/ExperimentViewOverrideServiceAsyncImpl.kt new file mode 100644 index 00000000..009a7edf --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/datasets/ExperimentViewOverrideServiceAsyncImpl.kt @@ -0,0 +1,255 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.datasets + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.emptyHandler +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.datasets.experimentviewoverrides.ExperimentViewOverride +import com.langsmith_api.api.models.datasets.experimentviewoverrides.ExperimentViewOverrideCreateParams +import com.langsmith_api.api.models.datasets.experimentviewoverrides.ExperimentViewOverrideDeleteParams +import com.langsmith_api.api.models.datasets.experimentviewoverrides.ExperimentViewOverrideListParams +import com.langsmith_api.api.models.datasets.experimentviewoverrides.ExperimentViewOverrideRetrieveParams +import com.langsmith_api.api.models.datasets.experimentviewoverrides.ExperimentViewOverrideUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class ExperimentViewOverrideServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : + ExperimentViewOverrideServiceAsync { + + private val withRawResponse: ExperimentViewOverrideServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ExperimentViewOverrideServiceAsync.WithRawResponse = + withRawResponse + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ExperimentViewOverrideServiceAsync = + ExperimentViewOverrideServiceAsyncImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun create( + params: ExperimentViewOverrideCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<ExperimentViewOverride> = + // post /datasets/{dataset_id}/experiment-view-overrides + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun retrieve( + params: ExperimentViewOverrideRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<ExperimentViewOverride> = + // get /datasets/{dataset_id}/experiment-view-overrides/{id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: ExperimentViewOverrideUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<ExperimentViewOverride> = + // patch /datasets/{dataset_id}/experiment-view-overrides/{id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: ExperimentViewOverrideListParams, + requestOptions: RequestOptions, + ): CompletableFuture<List<ExperimentViewOverride>> = + // get /datasets/{dataset_id}/experiment-view-overrides + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: ExperimentViewOverrideDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<Void?> = + // delete /datasets/{dataset_id}/experiment-view-overrides/{id} + withRawResponse().delete(params, requestOptions).thenAccept {} + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ExperimentViewOverrideServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ExperimentViewOverrideServiceAsync.WithRawResponse = + ExperimentViewOverrideServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<ExperimentViewOverride> = + jsonHandler<ExperimentViewOverride>(clientOptions.jsonMapper) + + override fun create( + params: ExperimentViewOverrideCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ExperimentViewOverride>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("datasets", params._pathParam(0), "experiment-view-overrides") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler<ExperimentViewOverride> = + jsonHandler<ExperimentViewOverride>(clientOptions.jsonMapper) + + override fun retrieve( + params: ExperimentViewOverrideRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ExperimentViewOverride>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "datasets", + params._pathParam(0), + "experiment-view-overrides", + params._pathParam(1), + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler<ExperimentViewOverride> = + jsonHandler<ExperimentViewOverride>(clientOptions.jsonMapper) + + override fun update( + params: ExperimentViewOverrideUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ExperimentViewOverride>> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "datasets", + params._pathParam(0), + "experiment-view-overrides", + params._pathParam(1), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler<List<ExperimentViewOverride>> = + jsonHandler<List<ExperimentViewOverride>>(clientOptions.jsonMapper) + + override fun list( + params: ExperimentViewOverrideListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<List<ExperimentViewOverride>>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("datasets", params._pathParam(0), "experiment-view-overrides") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val deleteHandler: Handler<Void?> = emptyHandler() + + override fun delete( + params: ExperimentViewOverrideDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "datasets", + params._pathParam(0), + "experiment-view-overrides", + params._pathParam(1), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { deleteHandler.handle(it) } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/AlertServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/AlertServiceAsync.kt new file mode 100644 index 00000000..082f0db5 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/AlertServiceAsync.kt @@ -0,0 +1,344 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.platform + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.platform.alerts.AlertCreateParams +import com.langsmith_api.api.models.platform.alerts.AlertDeleteParams +import com.langsmith_api.api.models.platform.alerts.AlertDeleteResponse +import com.langsmith_api.api.models.platform.alerts.AlertRetrieveParams +import com.langsmith_api.api.models.platform.alerts.AlertRuleResponse +import com.langsmith_api.api.models.platform.alerts.AlertTestParams +import com.langsmith_api.api.models.platform.alerts.AlertTestResponse +import com.langsmith_api.api.models.platform.alerts.AlertUpdateParams +import com.langsmith_api.api.models.platform.alerts.AlertUpdateResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface AlertServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): AlertServiceAsync + + /** + * Creates a new alert rule. The request body must be a JSON-encoded alert rule object that + * follows the CreateAlertRuleRequest schema. + */ + fun create( + sessionId: JsonValue, + params: AlertCreateParams, + ): CompletableFuture<AlertRuleResponse> = create(sessionId, params, RequestOptions.none()) + + /** @see create */ + fun create( + sessionId: JsonValue, + params: AlertCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<AlertRuleResponse> = + create(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see create */ + fun create(params: AlertCreateParams): CompletableFuture<AlertRuleResponse> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: AlertCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<AlertRuleResponse> + + /** Gets an alert rule. */ + fun retrieve( + alertRuleId: JsonValue, + params: AlertRetrieveParams, + ): CompletableFuture<AlertRuleResponse> = retrieve(alertRuleId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + alertRuleId: JsonValue, + params: AlertRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<AlertRuleResponse> = + retrieve(params.toBuilder().alertRuleId(alertRuleId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: AlertRetrieveParams): CompletableFuture<AlertRuleResponse> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: AlertRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<AlertRuleResponse> + + /** Updates an alert rule. */ + fun update( + alertRuleId: JsonValue, + params: AlertUpdateParams, + ): CompletableFuture<AlertUpdateResponse> = update(alertRuleId, params, RequestOptions.none()) + + /** @see update */ + fun update( + alertRuleId: JsonValue, + params: AlertUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<AlertUpdateResponse> = + update(params.toBuilder().alertRuleId(alertRuleId).build(), requestOptions) + + /** @see update */ + fun update(params: AlertUpdateParams): CompletableFuture<AlertUpdateResponse> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: AlertUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<AlertUpdateResponse> + + /** Deletes an alert rule */ + fun delete( + alertRuleId: JsonValue, + params: AlertDeleteParams, + ): CompletableFuture<AlertDeleteResponse> = delete(alertRuleId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + alertRuleId: JsonValue, + params: AlertDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<AlertDeleteResponse> = + delete(params.toBuilder().alertRuleId(alertRuleId).build(), requestOptions) + + /** @see delete */ + fun delete(params: AlertDeleteParams): CompletableFuture<AlertDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: AlertDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<AlertDeleteResponse> + + /** + * Tests an alert action which will fire a notification to all configured recipients if the + * configuration is valid. + */ + fun test(sessionId: JsonValue): CompletableFuture<AlertTestResponse> = + test(sessionId, AlertTestParams.none()) + + /** @see test */ + fun test( + sessionId: JsonValue, + params: AlertTestParams = AlertTestParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<AlertTestResponse> = + test(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see test */ + fun test( + sessionId: JsonValue, + params: AlertTestParams = AlertTestParams.none(), + ): CompletableFuture<AlertTestResponse> = test(sessionId, params, RequestOptions.none()) + + /** @see test */ + fun test( + params: AlertTestParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<AlertTestResponse> + + /** @see test */ + fun test(params: AlertTestParams): CompletableFuture<AlertTestResponse> = + test(params, RequestOptions.none()) + + /** @see test */ + fun test( + sessionId: JsonValue, + requestOptions: RequestOptions, + ): CompletableFuture<AlertTestResponse> = + test(sessionId, AlertTestParams.none(), requestOptions) + + /** A view of [AlertServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): AlertServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/platform/alerts/{session_id}`, but is otherwise + * the same as [AlertServiceAsync.create]. + */ + fun create( + sessionId: JsonValue, + params: AlertCreateParams, + ): CompletableFuture<HttpResponseFor<AlertRuleResponse>> = + create(sessionId, params, RequestOptions.none()) + + /** @see create */ + fun create( + sessionId: JsonValue, + params: AlertCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<AlertRuleResponse>> = + create(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see create */ + fun create( + params: AlertCreateParams + ): CompletableFuture<HttpResponseFor<AlertRuleResponse>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: AlertCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<AlertRuleResponse>> + + /** + * Returns a raw HTTP response for `get /v1/platform/alerts/{session_id}/{alert_rule_id}`, + * but is otherwise the same as [AlertServiceAsync.retrieve]. + */ + fun retrieve( + alertRuleId: JsonValue, + params: AlertRetrieveParams, + ): CompletableFuture<HttpResponseFor<AlertRuleResponse>> = + retrieve(alertRuleId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + alertRuleId: JsonValue, + params: AlertRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<AlertRuleResponse>> = + retrieve(params.toBuilder().alertRuleId(alertRuleId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + params: AlertRetrieveParams + ): CompletableFuture<HttpResponseFor<AlertRuleResponse>> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: AlertRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<AlertRuleResponse>> + + /** + * Returns a raw HTTP response for `patch /v1/platform/alerts/{session_id}/{alert_rule_id}`, + * but is otherwise the same as [AlertServiceAsync.update]. + */ + fun update( + alertRuleId: JsonValue, + params: AlertUpdateParams, + ): CompletableFuture<HttpResponseFor<AlertUpdateResponse>> = + update(alertRuleId, params, RequestOptions.none()) + + /** @see update */ + fun update( + alertRuleId: JsonValue, + params: AlertUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<AlertUpdateResponse>> = + update(params.toBuilder().alertRuleId(alertRuleId).build(), requestOptions) + + /** @see update */ + fun update( + params: AlertUpdateParams + ): CompletableFuture<HttpResponseFor<AlertUpdateResponse>> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: AlertUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<AlertUpdateResponse>> + + /** + * Returns a raw HTTP response for `delete + * /v1/platform/alerts/{session_id}/{alert_rule_id}`, but is otherwise the same as + * [AlertServiceAsync.delete]. + */ + fun delete( + alertRuleId: JsonValue, + params: AlertDeleteParams, + ): CompletableFuture<HttpResponseFor<AlertDeleteResponse>> = + delete(alertRuleId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + alertRuleId: JsonValue, + params: AlertDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<AlertDeleteResponse>> = + delete(params.toBuilder().alertRuleId(alertRuleId).build(), requestOptions) + + /** @see delete */ + fun delete( + params: AlertDeleteParams + ): CompletableFuture<HttpResponseFor<AlertDeleteResponse>> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: AlertDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<AlertDeleteResponse>> + + /** + * Returns a raw HTTP response for `post /v1/platform/alerts/{session_id}/test`, but is + * otherwise the same as [AlertServiceAsync.test]. + */ + fun test(sessionId: JsonValue): CompletableFuture<HttpResponseFor<AlertTestResponse>> = + test(sessionId, AlertTestParams.none()) + + /** @see test */ + fun test( + sessionId: JsonValue, + params: AlertTestParams = AlertTestParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<AlertTestResponse>> = + test(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see test */ + fun test( + sessionId: JsonValue, + params: AlertTestParams = AlertTestParams.none(), + ): CompletableFuture<HttpResponseFor<AlertTestResponse>> = + test(sessionId, params, RequestOptions.none()) + + /** @see test */ + fun test( + params: AlertTestParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<AlertTestResponse>> + + /** @see test */ + fun test(params: AlertTestParams): CompletableFuture<HttpResponseFor<AlertTestResponse>> = + test(params, RequestOptions.none()) + + /** @see test */ + fun test( + sessionId: JsonValue, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<AlertTestResponse>> = + test(sessionId, AlertTestParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/AlertServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/AlertServiceAsyncImpl.kt new file mode 100644 index 00000000..8b9df6fe --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/AlertServiceAsyncImpl.kt @@ -0,0 +1,262 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.platform + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.platform.alerts.AlertCreateParams +import com.langsmith_api.api.models.platform.alerts.AlertDeleteParams +import com.langsmith_api.api.models.platform.alerts.AlertDeleteResponse +import com.langsmith_api.api.models.platform.alerts.AlertRetrieveParams +import com.langsmith_api.api.models.platform.alerts.AlertRuleResponse +import com.langsmith_api.api.models.platform.alerts.AlertTestParams +import com.langsmith_api.api.models.platform.alerts.AlertTestResponse +import com.langsmith_api.api.models.platform.alerts.AlertUpdateParams +import com.langsmith_api.api.models.platform.alerts.AlertUpdateResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class AlertServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + AlertServiceAsync { + + private val withRawResponse: AlertServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): AlertServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): AlertServiceAsync = + AlertServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: AlertCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<AlertRuleResponse> = + // post /v1/platform/alerts/{session_id} + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun retrieve( + params: AlertRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<AlertRuleResponse> = + // get /v1/platform/alerts/{session_id}/{alert_rule_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: AlertUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<AlertUpdateResponse> = + // patch /v1/platform/alerts/{session_id}/{alert_rule_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: AlertDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<AlertDeleteResponse> = + // delete /v1/platform/alerts/{session_id}/{alert_rule_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + override fun test( + params: AlertTestParams, + requestOptions: RequestOptions, + ): CompletableFuture<AlertTestResponse> = + // post /v1/platform/alerts/{session_id}/test + withRawResponse().test(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AlertServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): AlertServiceAsync.WithRawResponse = + AlertServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<AlertRuleResponse> = + jsonHandler<AlertRuleResponse>(clientOptions.jsonMapper) + + override fun create( + params: AlertCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<AlertRuleResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "platform", "alerts", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler<AlertRuleResponse> = + jsonHandler<AlertRuleResponse>(clientOptions.jsonMapper) + + override fun retrieve( + params: AlertRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<AlertRuleResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "v1", + "platform", + "alerts", + params._pathParam(0), + params._pathParam(1), + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler<AlertUpdateResponse> = + jsonHandler<AlertUpdateResponse>(clientOptions.jsonMapper) + + override fun update( + params: AlertUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<AlertUpdateResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "v1", + "platform", + "alerts", + params._pathParam(0), + params._pathParam(1), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val deleteHandler: Handler<AlertDeleteResponse> = + jsonHandler<AlertDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: AlertDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<AlertDeleteResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "v1", + "platform", + "alerts", + params._pathParam(0), + params._pathParam(1), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val testHandler: Handler<AlertTestResponse> = + jsonHandler<AlertTestResponse>(clientOptions.jsonMapper) + + override fun test( + params: AlertTestParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<AlertTestResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "platform", "alerts", params._pathParam(0), "test") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { testHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/DatasetServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/DatasetServiceAsync.kt new file mode 100644 index 00000000..42a4ce16 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/DatasetServiceAsync.kt @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.platform + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.services.async.platform.datasets.ExampleServiceAsync +import java.util.function.Consumer + +interface DatasetServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): DatasetServiceAsync + + fun examples(): ExampleServiceAsync + + /** + * A view of [DatasetServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): DatasetServiceAsync.WithRawResponse + + fun examples(): ExampleServiceAsync.WithRawResponse + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/DatasetServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/DatasetServiceAsyncImpl.kt new file mode 100644 index 00000000..c96af513 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/DatasetServiceAsyncImpl.kt @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.platform + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.services.async.platform.datasets.ExampleServiceAsync +import com.langsmith_api.api.services.async.platform.datasets.ExampleServiceAsyncImpl +import java.util.function.Consumer + +class DatasetServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + DatasetServiceAsync { + + private val withRawResponse: DatasetServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val examples: ExampleServiceAsync by lazy { ExampleServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): DatasetServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): DatasetServiceAsync = + DatasetServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun examples(): ExampleServiceAsync = examples + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + DatasetServiceAsync.WithRawResponse { + + private val examples: ExampleServiceAsync.WithRawResponse by lazy { + ExampleServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): DatasetServiceAsync.WithRawResponse = + DatasetServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun examples(): ExampleServiceAsync.WithRawResponse = examples + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/OrgServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/OrgServiceAsync.kt new file mode 100644 index 00000000..9b8f2ed0 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/OrgServiceAsync.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.platform + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.services.async.platform.orgs.CurrentServiceAsync +import java.util.function.Consumer + +interface OrgServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): OrgServiceAsync + + fun current(): CurrentServiceAsync + + /** A view of [OrgServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): OrgServiceAsync.WithRawResponse + + fun current(): CurrentServiceAsync.WithRawResponse + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/OrgServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/OrgServiceAsyncImpl.kt new file mode 100644 index 00000000..a00ff7aa --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/OrgServiceAsyncImpl.kt @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.platform + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.services.async.platform.orgs.CurrentServiceAsync +import com.langsmith_api.api.services.async.platform.orgs.CurrentServiceAsyncImpl +import java.util.function.Consumer + +class OrgServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + OrgServiceAsync { + + private val withRawResponse: OrgServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val current: CurrentServiceAsync by lazy { CurrentServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): OrgServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): OrgServiceAsync = + OrgServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun current(): CurrentServiceAsync = current + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + OrgServiceAsync.WithRawResponse { + + private val current: CurrentServiceAsync.WithRawResponse by lazy { + CurrentServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): OrgServiceAsync.WithRawResponse = + OrgServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun current(): CurrentServiceAsync.WithRawResponse = current + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/datasets/ExampleServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/datasets/ExampleServiceAsync.kt new file mode 100644 index 00000000..b4852ed5 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/datasets/ExampleServiceAsync.kt @@ -0,0 +1,192 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.platform.datasets + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.platform.datasets.examples.ExampleHardDeleteParams +import com.langsmith_api.api.models.platform.datasets.examples.ExampleHardDeleteResponse +import com.langsmith_api.api.models.platform.datasets.examples.ExampleUpdateParams +import com.langsmith_api.api.models.platform.datasets.examples.ExampleUpdateResponse +import com.langsmith_api.api.models.platform.datasets.examples.ExampleUploadParams +import com.langsmith_api.api.models.platform.datasets.examples.ExampleUploadResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface ExampleServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ExampleServiceAsync + + /** + * This endpoint allows clients to update existing examples in a specified dataset by sending a + * multipart/form-data PATCH request. Each form part contains either JSON-encoded data or binary + * attachment files to update an example. + */ + fun update( + datasetId: JsonValue, + params: ExampleUpdateParams, + ): CompletableFuture<ExampleUpdateResponse> = update(datasetId, params, RequestOptions.none()) + + /** @see update */ + fun update( + datasetId: JsonValue, + params: ExampleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ExampleUpdateResponse> = + update(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see update */ + fun update(params: ExampleUpdateParams): CompletableFuture<ExampleUpdateResponse> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: ExampleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ExampleUpdateResponse> + + /** + * This endpoint hard deletes *all* versions of a dataset example(s). Deletion is performed by + * setting inputs, outputs, and metadata to null and deleting attachment files while keeping the + * example ID, dataset ID, and creation timestamp. IMPORTANT: attachment files can take up to 7 + * days to be deleted. inputs, outputs and metadata are nullified immediately. + */ + fun hardDelete(params: ExampleHardDeleteParams): CompletableFuture<ExampleHardDeleteResponse> = + hardDelete(params, RequestOptions.none()) + + /** @see hardDelete */ + fun hardDelete( + params: ExampleHardDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ExampleHardDeleteResponse> + + /** + * This endpoint allows clients to upload examples to a specified dataset by sending a + * multipart/form-data POST request. Each form part contains either JSON-encoded data or binary + * attachment files associated with an example. + */ + fun upload( + datasetId: JsonValue, + params: ExampleUploadParams, + ): CompletableFuture<ExampleUploadResponse> = upload(datasetId, params, RequestOptions.none()) + + /** @see upload */ + fun upload( + datasetId: JsonValue, + params: ExampleUploadParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ExampleUploadResponse> = + upload(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see upload */ + fun upload(params: ExampleUploadParams): CompletableFuture<ExampleUploadResponse> = + upload(params, RequestOptions.none()) + + /** @see upload */ + fun upload( + params: ExampleUploadParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<ExampleUploadResponse> + + /** + * A view of [ExampleServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ExampleServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `patch /v1/platform/datasets/{dataset_id}/examples`, but + * is otherwise the same as [ExampleServiceAsync.update]. + */ + fun update( + datasetId: JsonValue, + params: ExampleUpdateParams, + ): CompletableFuture<HttpResponseFor<ExampleUpdateResponse>> = + update(datasetId, params, RequestOptions.none()) + + /** @see update */ + fun update( + datasetId: JsonValue, + params: ExampleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ExampleUpdateResponse>> = + update(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see update */ + fun update( + params: ExampleUpdateParams + ): CompletableFuture<HttpResponseFor<ExampleUpdateResponse>> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: ExampleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ExampleUpdateResponse>> + + /** + * Returns a raw HTTP response for `post /v1/platform/datasets/examples/delete`, but is + * otherwise the same as [ExampleServiceAsync.hardDelete]. + */ + fun hardDelete( + params: ExampleHardDeleteParams + ): CompletableFuture<HttpResponseFor<ExampleHardDeleteResponse>> = + hardDelete(params, RequestOptions.none()) + + /** @see hardDelete */ + fun hardDelete( + params: ExampleHardDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ExampleHardDeleteResponse>> + + /** + * Returns a raw HTTP response for `post /v1/platform/datasets/{dataset_id}/examples`, but + * is otherwise the same as [ExampleServiceAsync.upload]. + */ + fun upload( + datasetId: JsonValue, + params: ExampleUploadParams, + ): CompletableFuture<HttpResponseFor<ExampleUploadResponse>> = + upload(datasetId, params, RequestOptions.none()) + + /** @see upload */ + fun upload( + datasetId: JsonValue, + params: ExampleUploadParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ExampleUploadResponse>> = + upload(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see upload */ + fun upload( + params: ExampleUploadParams + ): CompletableFuture<HttpResponseFor<ExampleUploadResponse>> = + upload(params, RequestOptions.none()) + + /** @see upload */ + fun upload( + params: ExampleUploadParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<ExampleUploadResponse>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/datasets/ExampleServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/datasets/ExampleServiceAsyncImpl.kt new file mode 100644 index 00000000..4168a30c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/datasets/ExampleServiceAsyncImpl.kt @@ -0,0 +1,167 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.platform.datasets + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.multipartFormData +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.platform.datasets.examples.ExampleHardDeleteParams +import com.langsmith_api.api.models.platform.datasets.examples.ExampleHardDeleteResponse +import com.langsmith_api.api.models.platform.datasets.examples.ExampleUpdateParams +import com.langsmith_api.api.models.platform.datasets.examples.ExampleUpdateResponse +import com.langsmith_api.api.models.platform.datasets.examples.ExampleUploadParams +import com.langsmith_api.api.models.platform.datasets.examples.ExampleUploadResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class ExampleServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ExampleServiceAsync { + + private val withRawResponse: ExampleServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ExampleServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): ExampleServiceAsync = + ExampleServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun update( + params: ExampleUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<ExampleUpdateResponse> = + // patch /v1/platform/datasets/{dataset_id}/examples + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun hardDelete( + params: ExampleHardDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<ExampleHardDeleteResponse> = + // post /v1/platform/datasets/examples/delete + withRawResponse().hardDelete(params, requestOptions).thenApply { it.parse() } + + override fun upload( + params: ExampleUploadParams, + requestOptions: RequestOptions, + ): CompletableFuture<ExampleUploadResponse> = + // post /v1/platform/datasets/{dataset_id}/examples + withRawResponse().upload(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ExampleServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ExampleServiceAsync.WithRawResponse = + ExampleServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val updateHandler: Handler<ExampleUpdateResponse> = + jsonHandler<ExampleUpdateResponse>(clientOptions.jsonMapper) + + override fun update( + params: ExampleUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ExampleUpdateResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "platform", "datasets", params._pathParam(0), "examples") + .body(multipartFormData(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val hardDeleteHandler: Handler<ExampleHardDeleteResponse> = + jsonHandler<ExampleHardDeleteResponse>(clientOptions.jsonMapper) + + override fun hardDelete( + params: ExampleHardDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ExampleHardDeleteResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "platform", "datasets", "examples", "delete") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { hardDeleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val uploadHandler: Handler<ExampleUploadResponse> = + jsonHandler<ExampleUploadResponse>(clientOptions.jsonMapper) + + override fun upload( + params: ExampleUploadParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<ExampleUploadResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "platform", "datasets", params._pathParam(0), "examples") + .body(multipartFormData(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { uploadHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/orgs/CurrentServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/orgs/CurrentServiceAsync.kt new file mode 100644 index 00000000..c77945a3 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/orgs/CurrentServiceAsync.kt @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.platform.orgs + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.services.async.platform.orgs.current.AccessPolicyServiceAsync +import java.util.function.Consumer + +interface CurrentServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): CurrentServiceAsync + + fun accessPolicies(): AccessPolicyServiceAsync + + /** + * A view of [CurrentServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): CurrentServiceAsync.WithRawResponse + + fun accessPolicies(): AccessPolicyServiceAsync.WithRawResponse + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/orgs/CurrentServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/orgs/CurrentServiceAsyncImpl.kt new file mode 100644 index 00000000..0c3312cc --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/orgs/CurrentServiceAsyncImpl.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.platform.orgs + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.services.async.platform.orgs.current.AccessPolicyServiceAsync +import com.langsmith_api.api.services.async.platform.orgs.current.AccessPolicyServiceAsyncImpl +import java.util.function.Consumer + +class CurrentServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + CurrentServiceAsync { + + private val withRawResponse: CurrentServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val accessPolicies: AccessPolicyServiceAsync by lazy { + AccessPolicyServiceAsyncImpl(clientOptions) + } + + override fun withRawResponse(): CurrentServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): CurrentServiceAsync = + CurrentServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun accessPolicies(): AccessPolicyServiceAsync = accessPolicies + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CurrentServiceAsync.WithRawResponse { + + private val accessPolicies: AccessPolicyServiceAsync.WithRawResponse by lazy { + AccessPolicyServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): CurrentServiceAsync.WithRawResponse = + CurrentServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun accessPolicies(): AccessPolicyServiceAsync.WithRawResponse = accessPolicies + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/orgs/current/AccessPolicyServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/orgs/current/AccessPolicyServiceAsync.kt new file mode 100644 index 00000000..e3b59177 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/orgs/current/AccessPolicyServiceAsync.kt @@ -0,0 +1,295 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.platform.orgs.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.platform.orgs.current.accesspolicies.AccessPolicy +import com.langsmith_api.api.models.platform.orgs.current.accesspolicies.AccessPolicyCreateParams +import com.langsmith_api.api.models.platform.orgs.current.accesspolicies.AccessPolicyCreateResponse +import com.langsmith_api.api.models.platform.orgs.current.accesspolicies.AccessPolicyDeleteParams +import com.langsmith_api.api.models.platform.orgs.current.accesspolicies.AccessPolicyListParams +import com.langsmith_api.api.models.platform.orgs.current.accesspolicies.AccessPolicyListResponse +import com.langsmith_api.api.models.platform.orgs.current.accesspolicies.AccessPolicyRetrieveParams +import com.langsmith_api.api.services.async.platform.orgs.current.accesspolicies.RoleServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface AccessPolicyServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): AccessPolicyServiceAsync + + fun roles(): RoleServiceAsync + + /** + * Creates a new access policy. The request body must be a JSON-encoded access policy object + * that follows the CreateAccessPolicyRequest schema. + */ + fun create(): CompletableFuture<AccessPolicyCreateResponse> = + create(AccessPolicyCreateParams.none()) + + /** @see create */ + fun create( + params: AccessPolicyCreateParams = AccessPolicyCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<AccessPolicyCreateResponse> + + /** @see create */ + fun create( + params: AccessPolicyCreateParams = AccessPolicyCreateParams.none() + ): CompletableFuture<AccessPolicyCreateResponse> = create(params, RequestOptions.none()) + + /** @see create */ + fun create(requestOptions: RequestOptions): CompletableFuture<AccessPolicyCreateResponse> = + create(AccessPolicyCreateParams.none(), requestOptions) + + /** Gets a specific access policy by ID. */ + fun retrieve(accessPolicyId: JsonValue): CompletableFuture<AccessPolicy> = + retrieve(accessPolicyId, AccessPolicyRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + accessPolicyId: JsonValue, + params: AccessPolicyRetrieveParams = AccessPolicyRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<AccessPolicy> = + retrieve(params.toBuilder().accessPolicyId(accessPolicyId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + accessPolicyId: JsonValue, + params: AccessPolicyRetrieveParams = AccessPolicyRetrieveParams.none(), + ): CompletableFuture<AccessPolicy> = retrieve(accessPolicyId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: AccessPolicyRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<AccessPolicy> + + /** @see retrieve */ + fun retrieve(params: AccessPolicyRetrieveParams): CompletableFuture<AccessPolicy> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + accessPolicyId: JsonValue, + requestOptions: RequestOptions, + ): CompletableFuture<AccessPolicy> = + retrieve(accessPolicyId, AccessPolicyRetrieveParams.none(), requestOptions) + + /** Lists all access policies for the organization. */ + fun list(): CompletableFuture<AccessPolicyListResponse> = list(AccessPolicyListParams.none()) + + /** @see list */ + fun list( + params: AccessPolicyListParams = AccessPolicyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<AccessPolicyListResponse> + + /** @see list */ + fun list( + params: AccessPolicyListParams = AccessPolicyListParams.none() + ): CompletableFuture<AccessPolicyListResponse> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture<AccessPolicyListResponse> = + list(AccessPolicyListParams.none(), requestOptions) + + /** Deletes a specific access policy by ID. */ + fun delete(accessPolicyId: JsonValue): CompletableFuture<Void?> = + delete(accessPolicyId, AccessPolicyDeleteParams.none()) + + /** @see delete */ + fun delete( + accessPolicyId: JsonValue, + params: AccessPolicyDeleteParams = AccessPolicyDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<Void?> = + delete(params.toBuilder().accessPolicyId(accessPolicyId).build(), requestOptions) + + /** @see delete */ + fun delete( + accessPolicyId: JsonValue, + params: AccessPolicyDeleteParams = AccessPolicyDeleteParams.none(), + ): CompletableFuture<Void?> = delete(accessPolicyId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: AccessPolicyDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<Void?> + + /** @see delete */ + fun delete(params: AccessPolicyDeleteParams): CompletableFuture<Void?> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + accessPolicyId: JsonValue, + requestOptions: RequestOptions, + ): CompletableFuture<Void?> = + delete(accessPolicyId, AccessPolicyDeleteParams.none(), requestOptions) + + /** + * A view of [AccessPolicyServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): AccessPolicyServiceAsync.WithRawResponse + + fun roles(): RoleServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/platform/orgs/current/access-policies`, but is + * otherwise the same as [AccessPolicyServiceAsync.create]. + */ + fun create(): CompletableFuture<HttpResponseFor<AccessPolicyCreateResponse>> = + create(AccessPolicyCreateParams.none()) + + /** @see create */ + fun create( + params: AccessPolicyCreateParams = AccessPolicyCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<AccessPolicyCreateResponse>> + + /** @see create */ + fun create( + params: AccessPolicyCreateParams = AccessPolicyCreateParams.none() + ): CompletableFuture<HttpResponseFor<AccessPolicyCreateResponse>> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<AccessPolicyCreateResponse>> = + create(AccessPolicyCreateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get + * /v1/platform/orgs/current/access-policies/{access_policy_id}`, but is otherwise the same + * as [AccessPolicyServiceAsync.retrieve]. + */ + fun retrieve(accessPolicyId: JsonValue): CompletableFuture<HttpResponseFor<AccessPolicy>> = + retrieve(accessPolicyId, AccessPolicyRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + accessPolicyId: JsonValue, + params: AccessPolicyRetrieveParams = AccessPolicyRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<AccessPolicy>> = + retrieve(params.toBuilder().accessPolicyId(accessPolicyId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + accessPolicyId: JsonValue, + params: AccessPolicyRetrieveParams = AccessPolicyRetrieveParams.none(), + ): CompletableFuture<HttpResponseFor<AccessPolicy>> = + retrieve(accessPolicyId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: AccessPolicyRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<AccessPolicy>> + + /** @see retrieve */ + fun retrieve( + params: AccessPolicyRetrieveParams + ): CompletableFuture<HttpResponseFor<AccessPolicy>> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + accessPolicyId: JsonValue, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<AccessPolicy>> = + retrieve(accessPolicyId, AccessPolicyRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /v1/platform/orgs/current/access-policies`, but is + * otherwise the same as [AccessPolicyServiceAsync.list]. + */ + fun list(): CompletableFuture<HttpResponseFor<AccessPolicyListResponse>> = + list(AccessPolicyListParams.none()) + + /** @see list */ + fun list( + params: AccessPolicyListParams = AccessPolicyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponseFor<AccessPolicyListResponse>> + + /** @see list */ + fun list( + params: AccessPolicyListParams = AccessPolicyListParams.none() + ): CompletableFuture<HttpResponseFor<AccessPolicyListResponse>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture<HttpResponseFor<AccessPolicyListResponse>> = + list(AccessPolicyListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete + * /v1/platform/orgs/current/access-policies/{access_policy_id}`, but is otherwise the same + * as [AccessPolicyServiceAsync.delete]. + */ + fun delete(accessPolicyId: JsonValue): CompletableFuture<HttpResponse> = + delete(accessPolicyId, AccessPolicyDeleteParams.none()) + + /** @see delete */ + fun delete( + accessPolicyId: JsonValue, + params: AccessPolicyDeleteParams = AccessPolicyDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponse> = + delete(params.toBuilder().accessPolicyId(accessPolicyId).build(), requestOptions) + + /** @see delete */ + fun delete( + accessPolicyId: JsonValue, + params: AccessPolicyDeleteParams = AccessPolicyDeleteParams.none(), + ): CompletableFuture<HttpResponse> = delete(accessPolicyId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: AccessPolicyDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponse> + + /** @see delete */ + fun delete(params: AccessPolicyDeleteParams): CompletableFuture<HttpResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + accessPolicyId: JsonValue, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponse> = + delete(accessPolicyId, AccessPolicyDeleteParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/orgs/current/AccessPolicyServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/orgs/current/AccessPolicyServiceAsyncImpl.kt new file mode 100644 index 00000000..fe849fd7 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/orgs/current/AccessPolicyServiceAsyncImpl.kt @@ -0,0 +1,223 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.platform.orgs.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.emptyHandler +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.platform.orgs.current.accesspolicies.AccessPolicy +import com.langsmith_api.api.models.platform.orgs.current.accesspolicies.AccessPolicyCreateParams +import com.langsmith_api.api.models.platform.orgs.current.accesspolicies.AccessPolicyCreateResponse +import com.langsmith_api.api.models.platform.orgs.current.accesspolicies.AccessPolicyDeleteParams +import com.langsmith_api.api.models.platform.orgs.current.accesspolicies.AccessPolicyListParams +import com.langsmith_api.api.models.platform.orgs.current.accesspolicies.AccessPolicyListResponse +import com.langsmith_api.api.models.platform.orgs.current.accesspolicies.AccessPolicyRetrieveParams +import com.langsmith_api.api.services.async.platform.orgs.current.accesspolicies.RoleServiceAsync +import com.langsmith_api.api.services.async.platform.orgs.current.accesspolicies.RoleServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class AccessPolicyServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + AccessPolicyServiceAsync { + + private val withRawResponse: AccessPolicyServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val roles: RoleServiceAsync by lazy { RoleServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): AccessPolicyServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): AccessPolicyServiceAsync = + AccessPolicyServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun roles(): RoleServiceAsync = roles + + override fun create( + params: AccessPolicyCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<AccessPolicyCreateResponse> = + // post /v1/platform/orgs/current/access-policies + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun retrieve( + params: AccessPolicyRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<AccessPolicy> = + // get /v1/platform/orgs/current/access-policies/{access_policy_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: AccessPolicyListParams, + requestOptions: RequestOptions, + ): CompletableFuture<AccessPolicyListResponse> = + // get /v1/platform/orgs/current/access-policies + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: AccessPolicyDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<Void?> = + // delete /v1/platform/orgs/current/access-policies/{access_policy_id} + withRawResponse().delete(params, requestOptions).thenAccept {} + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AccessPolicyServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val roles: RoleServiceAsync.WithRawResponse by lazy { + RoleServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): AccessPolicyServiceAsync.WithRawResponse = + AccessPolicyServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun roles(): RoleServiceAsync.WithRawResponse = roles + + private val createHandler: Handler<AccessPolicyCreateResponse> = + jsonHandler<AccessPolicyCreateResponse>(clientOptions.jsonMapper) + + override fun create( + params: AccessPolicyCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<AccessPolicyCreateResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "platform", "orgs", "current", "access-policies") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler<AccessPolicy> = + jsonHandler<AccessPolicy>(clientOptions.jsonMapper) + + override fun retrieve( + params: AccessPolicyRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<AccessPolicy>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "v1", + "platform", + "orgs", + "current", + "access-policies", + params._pathParam(0), + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler<AccessPolicyListResponse> = + jsonHandler<AccessPolicyListResponse>(clientOptions.jsonMapper) + + override fun list( + params: AccessPolicyListParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponseFor<AccessPolicyListResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "platform", "orgs", "current", "access-policies") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val deleteHandler: Handler<Void?> = emptyHandler() + + override fun delete( + params: AccessPolicyDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "v1", + "platform", + "orgs", + "current", + "access-policies", + params._pathParam(0), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { deleteHandler.handle(it) } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/orgs/current/accesspolicies/RoleServiceAsync.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/orgs/current/accesspolicies/RoleServiceAsync.kt new file mode 100644 index 00000000..a6e12dcb --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/orgs/current/accesspolicies/RoleServiceAsync.kt @@ -0,0 +1,109 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.platform.orgs.current.accesspolicies + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.models.platform.orgs.current.accesspolicies.roles.RoleAttachParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface RoleServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RoleServiceAsync + + /** + * Attaches one or more access policies to a specific role. The request body must contain an + * array of access policy IDs. + */ + fun attach(roleId: JsonValue): CompletableFuture<Void?> = + attach(roleId, RoleAttachParams.none()) + + /** @see attach */ + fun attach( + roleId: JsonValue, + params: RoleAttachParams = RoleAttachParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<Void?> = attach(params.toBuilder().roleId(roleId).build(), requestOptions) + + /** @see attach */ + fun attach( + roleId: JsonValue, + params: RoleAttachParams = RoleAttachParams.none(), + ): CompletableFuture<Void?> = attach(roleId, params, RequestOptions.none()) + + /** @see attach */ + fun attach( + params: RoleAttachParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<Void?> + + /** @see attach */ + fun attach(params: RoleAttachParams): CompletableFuture<Void?> = + attach(params, RequestOptions.none()) + + /** @see attach */ + fun attach(roleId: JsonValue, requestOptions: RequestOptions): CompletableFuture<Void?> = + attach(roleId, RoleAttachParams.none(), requestOptions) + + /** A view of [RoleServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RoleServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post + * /v1/platform/orgs/current/access-policies/roles/{role_id}/access-policies`, but is + * otherwise the same as [RoleServiceAsync.attach]. + */ + fun attach(roleId: JsonValue): CompletableFuture<HttpResponse> = + attach(roleId, RoleAttachParams.none()) + + /** @see attach */ + fun attach( + roleId: JsonValue, + params: RoleAttachParams = RoleAttachParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponse> = + attach(params.toBuilder().roleId(roleId).build(), requestOptions) + + /** @see attach */ + fun attach( + roleId: JsonValue, + params: RoleAttachParams = RoleAttachParams.none(), + ): CompletableFuture<HttpResponse> = attach(roleId, params, RequestOptions.none()) + + /** @see attach */ + fun attach( + params: RoleAttachParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture<HttpResponse> + + /** @see attach */ + fun attach(params: RoleAttachParams): CompletableFuture<HttpResponse> = + attach(params, RequestOptions.none()) + + /** @see attach */ + fun attach( + roleId: JsonValue, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponse> = attach(roleId, RoleAttachParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/orgs/current/accesspolicies/RoleServiceAsyncImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/orgs/current/accesspolicies/RoleServiceAsyncImpl.kt new file mode 100644 index 00000000..9eca4197 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/async/platform/orgs/current/accesspolicies/RoleServiceAsyncImpl.kt @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.platform.orgs.current.accesspolicies + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.emptyHandler +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepareAsync +import com.langsmith_api.api.models.platform.orgs.current.accesspolicies.roles.RoleAttachParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class RoleServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + RoleServiceAsync { + + private val withRawResponse: RoleServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): RoleServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): RoleServiceAsync = + RoleServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun attach( + params: RoleAttachParams, + requestOptions: RequestOptions, + ): CompletableFuture<Void?> = + // post /v1/platform/orgs/current/access-policies/roles/{role_id}/access-policies + withRawResponse().attach(params, requestOptions).thenAccept {} + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RoleServiceAsync.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): RoleServiceAsync.WithRawResponse = + RoleServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val attachHandler: Handler<Void?> = emptyHandler() + + override fun attach( + params: RoleAttachParams, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "v1", + "platform", + "orgs", + "current", + "access-policies", + "roles", + params._pathParam(0), + "access-policies", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { attachHandler.handle(it) } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/ApiService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/ApiService.kt new file mode 100644 index 00000000..85982f48 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/ApiService.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.services.blocking.api.V1Service +import java.util.function.Consumer + +interface ApiService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ApiService + + fun v1(): V1Service + + /** A view of [ApiService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ApiService.WithRawResponse + + fun v1(): V1Service.WithRawResponse + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/ApiServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/ApiServiceImpl.kt new file mode 100644 index 00000000..6fd8b0f4 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/ApiServiceImpl.kt @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.services.blocking.api.V1Service +import com.langsmith_api.api.services.blocking.api.V1ServiceImpl +import java.util.function.Consumer + +class ApiServiceImpl internal constructor(private val clientOptions: ClientOptions) : ApiService { + + private val withRawResponse: ApiService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val v1: V1Service by lazy { V1ServiceImpl(clientOptions) } + + override fun withRawResponse(): ApiService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): ApiService = + ApiServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun v1(): V1Service = v1 + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ApiService.WithRawResponse { + + private val v1: V1Service.WithRawResponse by lazy { + V1ServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ApiService.WithRawResponse = + ApiServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun v1(): V1Service.WithRawResponse = v1 + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/DatasetService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/DatasetService.kt new file mode 100644 index 00000000..275413f3 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/DatasetService.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.services.blocking.datasets.ExperimentViewOverrideService +import java.util.function.Consumer + +interface DatasetService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): DatasetService + + fun experimentViewOverrides(): ExperimentViewOverrideService + + /** A view of [DatasetService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): DatasetService.WithRawResponse + + fun experimentViewOverrides(): ExperimentViewOverrideService.WithRawResponse + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/DatasetServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/DatasetServiceImpl.kt new file mode 100644 index 00000000..6aea9e29 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/DatasetServiceImpl.kt @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.services.blocking.datasets.ExperimentViewOverrideService +import com.langsmith_api.api.services.blocking.datasets.ExperimentViewOverrideServiceImpl +import java.util.function.Consumer + +class DatasetServiceImpl internal constructor(private val clientOptions: ClientOptions) : + DatasetService { + + private val withRawResponse: DatasetService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val experimentViewOverrides: ExperimentViewOverrideService by lazy { + ExperimentViewOverrideServiceImpl(clientOptions) + } + + override fun withRawResponse(): DatasetService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): DatasetService = + DatasetServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun experimentViewOverrides(): ExperimentViewOverrideService = experimentViewOverrides + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + DatasetService.WithRawResponse { + + private val experimentViewOverrides: ExperimentViewOverrideService.WithRawResponse by lazy { + ExperimentViewOverrideServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): DatasetService.WithRawResponse = + DatasetServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun experimentViewOverrides(): ExperimentViewOverrideService.WithRawResponse = + experimentViewOverrides + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/FeedbackService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/FeedbackService.kt new file mode 100644 index 00000000..dc64f766 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/FeedbackService.kt @@ -0,0 +1,63 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.feedback.FeedbackIngestBatchParams +import com.langsmith_api.api.models.feedback.FeedbackIngestBatchResponse +import java.util.function.Consumer + +interface FeedbackService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): FeedbackService + + /** Ingests a batch of feedback objects in a single JSON array payload. */ + fun ingestBatch(params: FeedbackIngestBatchParams): FeedbackIngestBatchResponse = + ingestBatch(params, RequestOptions.none()) + + /** @see ingestBatch */ + fun ingestBatch( + params: FeedbackIngestBatchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FeedbackIngestBatchResponse + + /** A view of [FeedbackService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): FeedbackService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /feedback/batch`, but is otherwise the same as + * [FeedbackService.ingestBatch]. + */ + @MustBeClosed + fun ingestBatch( + params: FeedbackIngestBatchParams + ): HttpResponseFor<FeedbackIngestBatchResponse> = ingestBatch(params, RequestOptions.none()) + + /** @see ingestBatch */ + @MustBeClosed + fun ingestBatch( + params: FeedbackIngestBatchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<FeedbackIngestBatchResponse> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/FeedbackServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/FeedbackServiceImpl.kt new file mode 100644 index 00000000..e6487263 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/FeedbackServiceImpl.kt @@ -0,0 +1,82 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.feedback.FeedbackIngestBatchParams +import com.langsmith_api.api.models.feedback.FeedbackIngestBatchResponse +import java.util.function.Consumer + +class FeedbackServiceImpl internal constructor(private val clientOptions: ClientOptions) : + FeedbackService { + + private val withRawResponse: FeedbackService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): FeedbackService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): FeedbackService = + FeedbackServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun ingestBatch( + params: FeedbackIngestBatchParams, + requestOptions: RequestOptions, + ): FeedbackIngestBatchResponse = + // post /feedback/batch + withRawResponse().ingestBatch(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + FeedbackService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): FeedbackService.WithRawResponse = + FeedbackServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val ingestBatchHandler: Handler<FeedbackIngestBatchResponse> = + jsonHandler<FeedbackIngestBatchResponse>(clientOptions.jsonMapper) + + override fun ingestBatch( + params: FeedbackIngestBatchParams, + requestOptions: RequestOptions, + ): HttpResponseFor<FeedbackIngestBatchResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("feedback", "batch") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { ingestBatchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/PlatformService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/PlatformService.kt new file mode 100644 index 00000000..9b2d50c5 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/PlatformService.kt @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.services.blocking.platform.AlertService +import com.langsmith_api.api.services.blocking.platform.DatasetService +import com.langsmith_api.api.services.blocking.platform.OrgService +import java.util.function.Consumer + +interface PlatformService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): PlatformService + + fun alerts(): AlertService + + fun datasets(): DatasetService + + fun orgs(): OrgService + + /** A view of [PlatformService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): PlatformService.WithRawResponse + + fun alerts(): AlertService.WithRawResponse + + fun datasets(): DatasetService.WithRawResponse + + fun orgs(): OrgService.WithRawResponse + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/PlatformServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/PlatformServiceImpl.kt new file mode 100644 index 00000000..6abea0ec --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/PlatformServiceImpl.kt @@ -0,0 +1,66 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.services.blocking.platform.AlertService +import com.langsmith_api.api.services.blocking.platform.AlertServiceImpl +import com.langsmith_api.api.services.blocking.platform.DatasetService +import com.langsmith_api.api.services.blocking.platform.DatasetServiceImpl +import com.langsmith_api.api.services.blocking.platform.OrgService +import com.langsmith_api.api.services.blocking.platform.OrgServiceImpl +import java.util.function.Consumer + +class PlatformServiceImpl internal constructor(private val clientOptions: ClientOptions) : + PlatformService { + + private val withRawResponse: PlatformService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val alerts: AlertService by lazy { AlertServiceImpl(clientOptions) } + + private val datasets: DatasetService by lazy { DatasetServiceImpl(clientOptions) } + + private val orgs: OrgService by lazy { OrgServiceImpl(clientOptions) } + + override fun withRawResponse(): PlatformService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): PlatformService = + PlatformServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun alerts(): AlertService = alerts + + override fun datasets(): DatasetService = datasets + + override fun orgs(): OrgService = orgs + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + PlatformService.WithRawResponse { + + private val alerts: AlertService.WithRawResponse by lazy { + AlertServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val datasets: DatasetService.WithRawResponse by lazy { + DatasetServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val orgs: OrgService.WithRawResponse by lazy { + OrgServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PlatformService.WithRawResponse = + PlatformServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun alerts(): AlertService.WithRawResponse = alerts + + override fun datasets(): DatasetService.WithRawResponse = datasets + + override fun orgs(): OrgService.WithRawResponse = orgs + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/RunService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/RunService.kt new file mode 100644 index 00000000..1ce0b47a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/RunService.kt @@ -0,0 +1,256 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.runs.Run +import com.langsmith_api.api.models.runs.RunCreateParams +import com.langsmith_api.api.models.runs.RunCreateResponse +import com.langsmith_api.api.models.runs.RunIngestBatchParams +import com.langsmith_api.api.models.runs.RunIngestBatchResponse +import com.langsmith_api.api.models.runs.RunIngestMultipartParams +import com.langsmith_api.api.models.runs.RunIngestMultipartResponse +import com.langsmith_api.api.models.runs.RunUpdateParams +import com.langsmith_api.api.models.runs.RunUpdateResponse +import java.util.function.Consumer + +interface RunService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunService + + /** + * Queues a single run for ingestion. The request body must be a JSON-encoded run object that + * follows the Run schema. + */ + fun create(params: RunCreateParams): RunCreateResponse = create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: RunCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RunCreateResponse + + /** @see create */ + fun create( + run: Run, + requestOptions: RequestOptions = RequestOptions.none(), + ): RunCreateResponse = create(RunCreateParams.builder().run(run).build(), requestOptions) + + /** @see create */ + fun create(run: Run): RunCreateResponse = create(run, RequestOptions.none()) + + /** + * Updates a run identified by its ID. The body should contain only the fields to be changed; + * unknown fields are ignored. + */ + fun update(runId: JsonValue, params: RunUpdateParams): RunUpdateResponse = + update(runId, params, RequestOptions.none()) + + /** @see update */ + fun update( + runId: JsonValue, + params: RunUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RunUpdateResponse = update(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see update */ + fun update(params: RunUpdateParams): RunUpdateResponse = update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: RunUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RunUpdateResponse + + /** + * Ingests a batch of runs in a single JSON payload. The payload must have `post` and/or `patch` + * arrays containing run objects. Prefer this endpoint over single‑run ingestion when + * submitting hundreds of runs, but `/runs/multipart` offers better handling for very large + * fields and attachments. + */ + fun ingestBatch(): RunIngestBatchResponse = ingestBatch(RunIngestBatchParams.none()) + + /** @see ingestBatch */ + fun ingestBatch( + params: RunIngestBatchParams = RunIngestBatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): RunIngestBatchResponse + + /** @see ingestBatch */ + fun ingestBatch( + params: RunIngestBatchParams = RunIngestBatchParams.none() + ): RunIngestBatchResponse = ingestBatch(params, RequestOptions.none()) + + /** @see ingestBatch */ + fun ingestBatch(requestOptions: RequestOptions): RunIngestBatchResponse = + ingestBatch(RunIngestBatchParams.none(), requestOptions) + + /** + * Ingests multiple runs, feedback objects, and binary attachments in a single + * `multipart/form-data` request. **Part‑name pattern**: `<event>.<run_id>[.<field>]` where + * `event` ∈ {`post`, `patch`, `feedback`, `attachment`}. + * * `post|patch.<run_id>` – JSON run payload. + * * `post|patch.<run_id>.<field>` – out‑of‑band run data (`inputs`, `outputs`, `events`, + * `error`, `extra`, `serialized`). + * * `feedback.<run_id>` – JSON feedback payload (must include `trace_id`). + * * `attachment.<run_id>.<filename>` – arbitrary binary attachment stored in S3. **Headers**: + * every part must set `Content-Type` **and** either a `Content-Length` header or `length` + * parameter. Per‑part `Content-Encoding` is **not** allowed; the top‑level request may be + * `Content-Encoding: gzip` or `Content-Encoding: zstd`. **Best performance** for + * high‑volume ingestion. + */ + fun ingestMultipart(): RunIngestMultipartResponse = + ingestMultipart(RunIngestMultipartParams.none()) + + /** @see ingestMultipart */ + fun ingestMultipart( + params: RunIngestMultipartParams = RunIngestMultipartParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): RunIngestMultipartResponse + + /** @see ingestMultipart */ + fun ingestMultipart( + params: RunIngestMultipartParams = RunIngestMultipartParams.none() + ): RunIngestMultipartResponse = ingestMultipart(params, RequestOptions.none()) + + /** @see ingestMultipart */ + fun ingestMultipart(requestOptions: RequestOptions): RunIngestMultipartResponse = + ingestMultipart(RunIngestMultipartParams.none(), requestOptions) + + /** A view of [RunService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /runs`, but is otherwise the same as + * [RunService.create]. + */ + @MustBeClosed + fun create(params: RunCreateParams): HttpResponseFor<RunCreateResponse> = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: RunCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RunCreateResponse> + + /** @see create */ + @MustBeClosed + fun create( + run: Run, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RunCreateResponse> = + create(RunCreateParams.builder().run(run).build(), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(run: Run): HttpResponseFor<RunCreateResponse> = + create(run, RequestOptions.none()) + + /** + * Returns a raw HTTP response for `patch /runs/{run_id}`, but is otherwise the same as + * [RunService.update]. + */ + @MustBeClosed + fun update(runId: JsonValue, params: RunUpdateParams): HttpResponseFor<RunUpdateResponse> = + update(runId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + runId: JsonValue, + params: RunUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RunUpdateResponse> = + update(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(params: RunUpdateParams): HttpResponseFor<RunUpdateResponse> = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: RunUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RunUpdateResponse> + + /** + * Returns a raw HTTP response for `post /runs/batch`, but is otherwise the same as + * [RunService.ingestBatch]. + */ + @MustBeClosed + fun ingestBatch(): HttpResponseFor<RunIngestBatchResponse> = + ingestBatch(RunIngestBatchParams.none()) + + /** @see ingestBatch */ + @MustBeClosed + fun ingestBatch( + params: RunIngestBatchParams = RunIngestBatchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RunIngestBatchResponse> + + /** @see ingestBatch */ + @MustBeClosed + fun ingestBatch( + params: RunIngestBatchParams = RunIngestBatchParams.none() + ): HttpResponseFor<RunIngestBatchResponse> = ingestBatch(params, RequestOptions.none()) + + /** @see ingestBatch */ + @MustBeClosed + fun ingestBatch(requestOptions: RequestOptions): HttpResponseFor<RunIngestBatchResponse> = + ingestBatch(RunIngestBatchParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /runs/multipart`, but is otherwise the same as + * [RunService.ingestMultipart]. + */ + @MustBeClosed + fun ingestMultipart(): HttpResponseFor<RunIngestMultipartResponse> = + ingestMultipart(RunIngestMultipartParams.none()) + + /** @see ingestMultipart */ + @MustBeClosed + fun ingestMultipart( + params: RunIngestMultipartParams = RunIngestMultipartParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RunIngestMultipartResponse> + + /** @see ingestMultipart */ + @MustBeClosed + fun ingestMultipart( + params: RunIngestMultipartParams = RunIngestMultipartParams.none() + ): HttpResponseFor<RunIngestMultipartResponse> = + ingestMultipart(params, RequestOptions.none()) + + /** @see ingestMultipart */ + @MustBeClosed + fun ingestMultipart( + requestOptions: RequestOptions + ): HttpResponseFor<RunIngestMultipartResponse> = + ingestMultipart(RunIngestMultipartParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/RunServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/RunServiceImpl.kt new file mode 100644 index 00000000..5036c856 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/RunServiceImpl.kt @@ -0,0 +1,193 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.multipartFormData +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.runs.RunCreateParams +import com.langsmith_api.api.models.runs.RunCreateResponse +import com.langsmith_api.api.models.runs.RunIngestBatchParams +import com.langsmith_api.api.models.runs.RunIngestBatchResponse +import com.langsmith_api.api.models.runs.RunIngestMultipartParams +import com.langsmith_api.api.models.runs.RunIngestMultipartResponse +import com.langsmith_api.api.models.runs.RunUpdateParams +import com.langsmith_api.api.models.runs.RunUpdateResponse +import java.util.function.Consumer + +class RunServiceImpl internal constructor(private val clientOptions: ClientOptions) : RunService { + + private val withRawResponse: RunService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): RunService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunService = + RunServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: RunCreateParams, + requestOptions: RequestOptions, + ): RunCreateResponse = + // post /runs + withRawResponse().create(params, requestOptions).parse() + + override fun update( + params: RunUpdateParams, + requestOptions: RequestOptions, + ): RunUpdateResponse = + // patch /runs/{run_id} + withRawResponse().update(params, requestOptions).parse() + + override fun ingestBatch( + params: RunIngestBatchParams, + requestOptions: RequestOptions, + ): RunIngestBatchResponse = + // post /runs/batch + withRawResponse().ingestBatch(params, requestOptions).parse() + + override fun ingestMultipart( + params: RunIngestMultipartParams, + requestOptions: RequestOptions, + ): RunIngestMultipartResponse = + // post /runs/multipart + withRawResponse().ingestMultipart(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RunService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): RunService.WithRawResponse = + RunServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<RunCreateResponse> = + jsonHandler<RunCreateResponse>(clientOptions.jsonMapper) + + override fun create( + params: RunCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<RunCreateResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("runs") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler<RunUpdateResponse> = + jsonHandler<RunUpdateResponse>(clientOptions.jsonMapper) + + override fun update( + params: RunUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<RunUpdateResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("runs", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val ingestBatchHandler: Handler<RunIngestBatchResponse> = + jsonHandler<RunIngestBatchResponse>(clientOptions.jsonMapper) + + override fun ingestBatch( + params: RunIngestBatchParams, + requestOptions: RequestOptions, + ): HttpResponseFor<RunIngestBatchResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("runs", "batch") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { ingestBatchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val ingestMultipartHandler: Handler<RunIngestMultipartResponse> = + jsonHandler<RunIngestMultipartResponse>(clientOptions.jsonMapper) + + override fun ingestMultipart( + params: RunIngestMultipartParams, + requestOptions: RequestOptions, + ): HttpResponseFor<RunIngestMultipartResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("runs", "multipart") + .body(multipartFormData(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { ingestMultipartHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/V1Service.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/V1Service.kt new file mode 100644 index 00000000..a7ef813e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/V1Service.kt @@ -0,0 +1,354 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.V1EventsParams +import com.langsmith_api.api.models.api.v1.V1EventsResponse +import com.langsmith_api.api.models.api.v1.V1LoginParams +import com.langsmith_api.api.models.api.v1.V1LoginResponse +import com.langsmith_api.api.models.api.v1.V1RetrieveOkParams +import com.langsmith_api.api.models.api.v1.V1RetrieveOkResponse +import com.langsmith_api.api.models.api.v1.V1UpdateParams +import com.langsmith_api.api.models.api.v1.V1UpdateResponse +import com.langsmith_api.api.services.blocking.api.v1.AceService +import com.langsmith_api.api.services.blocking.api.v1.AnnotationQueueService +import com.langsmith_api.api.services.blocking.api.v1.ApiKeyService +import com.langsmith_api.api.services.blocking.api.v1.BulkExportService +import com.langsmith_api.api.services.blocking.api.v1.ChartService +import com.langsmith_api.api.services.blocking.api.v1.CommentService +import com.langsmith_api.api.services.blocking.api.v1.CommitService +import com.langsmith_api.api.services.blocking.api.v1.DatasetService +import com.langsmith_api.api.services.blocking.api.v1.ExampleService +import com.langsmith_api.api.services.blocking.api.v1.FeedbackConfigService +import com.langsmith_api.api.services.blocking.api.v1.FeedbackService +import com.langsmith_api.api.services.blocking.api.v1.InfoService +import com.langsmith_api.api.services.blocking.api.v1.MeService +import com.langsmith_api.api.services.blocking.api.v1.ModelPriceMapService +import com.langsmith_api.api.services.blocking.api.v1.OAuthService +import com.langsmith_api.api.services.blocking.api.v1.OrgChartService +import com.langsmith_api.api.services.blocking.api.v1.OrgService +import com.langsmith_api.api.services.blocking.api.v1.PlaygroundSettingService +import com.langsmith_api.api.services.blocking.api.v1.PromptService +import com.langsmith_api.api.services.blocking.api.v1.PromptWebhookService +import com.langsmith_api.api.services.blocking.api.v1.PublicService +import com.langsmith_api.api.services.blocking.api.v1.RepoService +import com.langsmith_api.api.services.blocking.api.v1.RunService +import com.langsmith_api.api.services.blocking.api.v1.ServiceAccountService +import com.langsmith_api.api.services.blocking.api.v1.SessionService +import com.langsmith_api.api.services.blocking.api.v1.SettingService +import com.langsmith_api.api.services.blocking.api.v1.SsoService +import com.langsmith_api.api.services.blocking.api.v1.TenantService +import com.langsmith_api.api.services.blocking.api.v1.TtlSettingService +import com.langsmith_api.api.services.blocking.api.v1.UsageLimitService +import com.langsmith_api.api.services.blocking.api.v1.WorkspaceService +import java.util.function.Consumer + +interface V1Service { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): V1Service + + fun sessions(): SessionService + + fun orgs(): OrgService + + fun oauth(): OAuthService + + fun sso(): SsoService + + fun apiKey(): ApiKeyService + + fun examples(): ExampleService + + fun datasets(): DatasetService + + fun runs(): RunService + + fun feedback(): FeedbackService + + fun public_(): PublicService + + fun annotationQueues(): AnnotationQueueService + + fun ace(): AceService + + fun bulkExports(): BulkExportService + + fun tenants(): TenantService + + fun info(): InfoService + + fun feedbackConfigs(): FeedbackConfigService + + fun modelPriceMap(): ModelPriceMapService + + fun usageLimits(): UsageLimitService + + fun ttlSettings(): TtlSettingService + + fun prompts(): PromptService + + fun promptWebhooks(): PromptWebhookService + + fun workspaces(): WorkspaceService + + fun playgroundSettings(): PlaygroundSettingService + + fun me(): MeService + + fun serviceAccounts(): ServiceAccountService + + fun charts(): ChartService + + fun orgCharts(): OrgChartService + + fun repos(): RepoService + + fun commits(): CommitService + + fun settings(): SettingService + + fun comments(): CommentService + + /** Like a repo. */ + fun update(repo: String, params: V1UpdateParams): V1UpdateResponse = + update(repo, params, RequestOptions.none()) + + /** @see update */ + fun update( + repo: String, + params: V1UpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): V1UpdateResponse = update(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see update */ + fun update(params: V1UpdateParams): V1UpdateResponse = update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: V1UpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): V1UpdateResponse + + /** Create Event */ + fun events(params: V1EventsParams): V1EventsResponse = events(params, RequestOptions.none()) + + /** @see events */ + fun events( + params: V1EventsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): V1EventsResponse + + /** Login */ + fun login(): V1LoginResponse = login(V1LoginParams.none()) + + /** @see login */ + fun login( + params: V1LoginParams = V1LoginParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): V1LoginResponse + + /** @see login */ + fun login(params: V1LoginParams = V1LoginParams.none()): V1LoginResponse = + login(params, RequestOptions.none()) + + /** @see login */ + fun login(requestOptions: RequestOptions): V1LoginResponse = + login(V1LoginParams.none(), requestOptions) + + /** Ok */ + fun retrieveOk(): V1RetrieveOkResponse = retrieveOk(V1RetrieveOkParams.none()) + + /** @see retrieveOk */ + fun retrieveOk( + params: V1RetrieveOkParams = V1RetrieveOkParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): V1RetrieveOkResponse + + /** @see retrieveOk */ + fun retrieveOk(params: V1RetrieveOkParams = V1RetrieveOkParams.none()): V1RetrieveOkResponse = + retrieveOk(params, RequestOptions.none()) + + /** @see retrieveOk */ + fun retrieveOk(requestOptions: RequestOptions): V1RetrieveOkResponse = + retrieveOk(V1RetrieveOkParams.none(), requestOptions) + + /** A view of [V1Service] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): V1Service.WithRawResponse + + fun sessions(): SessionService.WithRawResponse + + fun orgs(): OrgService.WithRawResponse + + fun oauth(): OAuthService.WithRawResponse + + fun sso(): SsoService.WithRawResponse + + fun apiKey(): ApiKeyService.WithRawResponse + + fun examples(): ExampleService.WithRawResponse + + fun datasets(): DatasetService.WithRawResponse + + fun runs(): RunService.WithRawResponse + + fun feedback(): FeedbackService.WithRawResponse + + fun public_(): PublicService.WithRawResponse + + fun annotationQueues(): AnnotationQueueService.WithRawResponse + + fun ace(): AceService.WithRawResponse + + fun bulkExports(): BulkExportService.WithRawResponse + + fun tenants(): TenantService.WithRawResponse + + fun info(): InfoService.WithRawResponse + + fun feedbackConfigs(): FeedbackConfigService.WithRawResponse + + fun modelPriceMap(): ModelPriceMapService.WithRawResponse + + fun usageLimits(): UsageLimitService.WithRawResponse + + fun ttlSettings(): TtlSettingService.WithRawResponse + + fun prompts(): PromptService.WithRawResponse + + fun promptWebhooks(): PromptWebhookService.WithRawResponse + + fun workspaces(): WorkspaceService.WithRawResponse + + fun playgroundSettings(): PlaygroundSettingService.WithRawResponse + + fun me(): MeService.WithRawResponse + + fun serviceAccounts(): ServiceAccountService.WithRawResponse + + fun charts(): ChartService.WithRawResponse + + fun orgCharts(): OrgChartService.WithRawResponse + + fun repos(): RepoService.WithRawResponse + + fun commits(): CommitService.WithRawResponse + + fun settings(): SettingService.WithRawResponse + + fun comments(): CommentService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/likes/{owner}/{repo}`, but is otherwise the + * same as [V1Service.update]. + */ + @MustBeClosed + fun update(repo: String, params: V1UpdateParams): HttpResponseFor<V1UpdateResponse> = + update(repo, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + repo: String, + params: V1UpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<V1UpdateResponse> = + update(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(params: V1UpdateParams): HttpResponseFor<V1UpdateResponse> = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: V1UpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<V1UpdateResponse> + + /** + * Returns a raw HTTP response for `post /api/v1/events`, but is otherwise the same as + * [V1Service.events]. + */ + @MustBeClosed + fun events(params: V1EventsParams): HttpResponseFor<V1EventsResponse> = + events(params, RequestOptions.none()) + + /** @see events */ + @MustBeClosed + fun events( + params: V1EventsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<V1EventsResponse> + + /** + * Returns a raw HTTP response for `post /api/v1/login`, but is otherwise the same as + * [V1Service.login]. + */ + @MustBeClosed fun login(): HttpResponseFor<V1LoginResponse> = login(V1LoginParams.none()) + + /** @see login */ + @MustBeClosed + fun login( + params: V1LoginParams = V1LoginParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<V1LoginResponse> + + /** @see login */ + @MustBeClosed + fun login(params: V1LoginParams = V1LoginParams.none()): HttpResponseFor<V1LoginResponse> = + login(params, RequestOptions.none()) + + /** @see login */ + @MustBeClosed + fun login(requestOptions: RequestOptions): HttpResponseFor<V1LoginResponse> = + login(V1LoginParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/ok`, but is otherwise the same as + * [V1Service.retrieveOk]. + */ + @MustBeClosed + fun retrieveOk(): HttpResponseFor<V1RetrieveOkResponse> = + retrieveOk(V1RetrieveOkParams.none()) + + /** @see retrieveOk */ + @MustBeClosed + fun retrieveOk( + params: V1RetrieveOkParams = V1RetrieveOkParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<V1RetrieveOkResponse> + + /** @see retrieveOk */ + @MustBeClosed + fun retrieveOk( + params: V1RetrieveOkParams = V1RetrieveOkParams.none() + ): HttpResponseFor<V1RetrieveOkResponse> = retrieveOk(params, RequestOptions.none()) + + /** @see retrieveOk */ + @MustBeClosed + fun retrieveOk(requestOptions: RequestOptions): HttpResponseFor<V1RetrieveOkResponse> = + retrieveOk(V1RetrieveOkParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/V1ServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/V1ServiceImpl.kt new file mode 100644 index 00000000..1a76c2f9 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/V1ServiceImpl.kt @@ -0,0 +1,578 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.V1EventsParams +import com.langsmith_api.api.models.api.v1.V1EventsResponse +import com.langsmith_api.api.models.api.v1.V1LoginParams +import com.langsmith_api.api.models.api.v1.V1LoginResponse +import com.langsmith_api.api.models.api.v1.V1RetrieveOkParams +import com.langsmith_api.api.models.api.v1.V1RetrieveOkResponse +import com.langsmith_api.api.models.api.v1.V1UpdateParams +import com.langsmith_api.api.models.api.v1.V1UpdateResponse +import com.langsmith_api.api.services.blocking.api.v1.AceService +import com.langsmith_api.api.services.blocking.api.v1.AceServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.AnnotationQueueService +import com.langsmith_api.api.services.blocking.api.v1.AnnotationQueueServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.ApiKeyService +import com.langsmith_api.api.services.blocking.api.v1.ApiKeyServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.BulkExportService +import com.langsmith_api.api.services.blocking.api.v1.BulkExportServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.ChartService +import com.langsmith_api.api.services.blocking.api.v1.ChartServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.CommentService +import com.langsmith_api.api.services.blocking.api.v1.CommentServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.CommitService +import com.langsmith_api.api.services.blocking.api.v1.CommitServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.DatasetService +import com.langsmith_api.api.services.blocking.api.v1.DatasetServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.ExampleService +import com.langsmith_api.api.services.blocking.api.v1.ExampleServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.FeedbackConfigService +import com.langsmith_api.api.services.blocking.api.v1.FeedbackConfigServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.FeedbackService +import com.langsmith_api.api.services.blocking.api.v1.FeedbackServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.InfoService +import com.langsmith_api.api.services.blocking.api.v1.InfoServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.MeService +import com.langsmith_api.api.services.blocking.api.v1.MeServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.ModelPriceMapService +import com.langsmith_api.api.services.blocking.api.v1.ModelPriceMapServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.OAuthService +import com.langsmith_api.api.services.blocking.api.v1.OAuthServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.OrgChartService +import com.langsmith_api.api.services.blocking.api.v1.OrgChartServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.OrgService +import com.langsmith_api.api.services.blocking.api.v1.OrgServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.PlaygroundSettingService +import com.langsmith_api.api.services.blocking.api.v1.PlaygroundSettingServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.PromptService +import com.langsmith_api.api.services.blocking.api.v1.PromptServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.PromptWebhookService +import com.langsmith_api.api.services.blocking.api.v1.PromptWebhookServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.PublicService +import com.langsmith_api.api.services.blocking.api.v1.PublicServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.RepoService +import com.langsmith_api.api.services.blocking.api.v1.RepoServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.RunService +import com.langsmith_api.api.services.blocking.api.v1.RunServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.ServiceAccountService +import com.langsmith_api.api.services.blocking.api.v1.ServiceAccountServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.SessionService +import com.langsmith_api.api.services.blocking.api.v1.SessionServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.SettingService +import com.langsmith_api.api.services.blocking.api.v1.SettingServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.SsoService +import com.langsmith_api.api.services.blocking.api.v1.SsoServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.TenantService +import com.langsmith_api.api.services.blocking.api.v1.TenantServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.TtlSettingService +import com.langsmith_api.api.services.blocking.api.v1.TtlSettingServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.UsageLimitService +import com.langsmith_api.api.services.blocking.api.v1.UsageLimitServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.WorkspaceService +import com.langsmith_api.api.services.blocking.api.v1.WorkspaceServiceImpl +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class V1ServiceImpl internal constructor(private val clientOptions: ClientOptions) : V1Service { + + private val withRawResponse: V1Service.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val sessions: SessionService by lazy { SessionServiceImpl(clientOptions) } + + private val orgs: OrgService by lazy { OrgServiceImpl(clientOptions) } + + private val oauth: OAuthService by lazy { OAuthServiceImpl(clientOptions) } + + private val sso: SsoService by lazy { SsoServiceImpl(clientOptions) } + + private val apiKey: ApiKeyService by lazy { ApiKeyServiceImpl(clientOptions) } + + private val examples: ExampleService by lazy { ExampleServiceImpl(clientOptions) } + + private val datasets: DatasetService by lazy { DatasetServiceImpl(clientOptions) } + + private val runs: RunService by lazy { RunServiceImpl(clientOptions) } + + private val feedback: FeedbackService by lazy { FeedbackServiceImpl(clientOptions) } + + private val public_: PublicService by lazy { PublicServiceImpl(clientOptions) } + + private val annotationQueues: AnnotationQueueService by lazy { + AnnotationQueueServiceImpl(clientOptions) + } + + private val ace: AceService by lazy { AceServiceImpl(clientOptions) } + + private val bulkExports: BulkExportService by lazy { BulkExportServiceImpl(clientOptions) } + + private val tenants: TenantService by lazy { TenantServiceImpl(clientOptions) } + + private val info: InfoService by lazy { InfoServiceImpl(clientOptions) } + + private val feedbackConfigs: FeedbackConfigService by lazy { + FeedbackConfigServiceImpl(clientOptions) + } + + private val modelPriceMap: ModelPriceMapService by lazy { + ModelPriceMapServiceImpl(clientOptions) + } + + private val usageLimits: UsageLimitService by lazy { UsageLimitServiceImpl(clientOptions) } + + private val ttlSettings: TtlSettingService by lazy { TtlSettingServiceImpl(clientOptions) } + + private val prompts: PromptService by lazy { PromptServiceImpl(clientOptions) } + + private val promptWebhooks: PromptWebhookService by lazy { + PromptWebhookServiceImpl(clientOptions) + } + + private val workspaces: WorkspaceService by lazy { WorkspaceServiceImpl(clientOptions) } + + private val playgroundSettings: PlaygroundSettingService by lazy { + PlaygroundSettingServiceImpl(clientOptions) + } + + private val me: MeService by lazy { MeServiceImpl(clientOptions) } + + private val serviceAccounts: ServiceAccountService by lazy { + ServiceAccountServiceImpl(clientOptions) + } + + private val charts: ChartService by lazy { ChartServiceImpl(clientOptions) } + + private val orgCharts: OrgChartService by lazy { OrgChartServiceImpl(clientOptions) } + + private val repos: RepoService by lazy { RepoServiceImpl(clientOptions) } + + private val commits: CommitService by lazy { CommitServiceImpl(clientOptions) } + + private val settings: SettingService by lazy { SettingServiceImpl(clientOptions) } + + private val comments: CommentService by lazy { CommentServiceImpl(clientOptions) } + + override fun withRawResponse(): V1Service.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): V1Service = + V1ServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun sessions(): SessionService = sessions + + override fun orgs(): OrgService = orgs + + override fun oauth(): OAuthService = oauth + + override fun sso(): SsoService = sso + + override fun apiKey(): ApiKeyService = apiKey + + override fun examples(): ExampleService = examples + + override fun datasets(): DatasetService = datasets + + override fun runs(): RunService = runs + + override fun feedback(): FeedbackService = feedback + + override fun public_(): PublicService = public_ + + override fun annotationQueues(): AnnotationQueueService = annotationQueues + + override fun ace(): AceService = ace + + override fun bulkExports(): BulkExportService = bulkExports + + override fun tenants(): TenantService = tenants + + override fun info(): InfoService = info + + override fun feedbackConfigs(): FeedbackConfigService = feedbackConfigs + + override fun modelPriceMap(): ModelPriceMapService = modelPriceMap + + override fun usageLimits(): UsageLimitService = usageLimits + + override fun ttlSettings(): TtlSettingService = ttlSettings + + override fun prompts(): PromptService = prompts + + override fun promptWebhooks(): PromptWebhookService = promptWebhooks + + override fun workspaces(): WorkspaceService = workspaces + + override fun playgroundSettings(): PlaygroundSettingService = playgroundSettings + + override fun me(): MeService = me + + override fun serviceAccounts(): ServiceAccountService = serviceAccounts + + override fun charts(): ChartService = charts + + override fun orgCharts(): OrgChartService = orgCharts + + override fun repos(): RepoService = repos + + override fun commits(): CommitService = commits + + override fun settings(): SettingService = settings + + override fun comments(): CommentService = comments + + override fun update(params: V1UpdateParams, requestOptions: RequestOptions): V1UpdateResponse = + // post /api/v1/likes/{owner}/{repo} + withRawResponse().update(params, requestOptions).parse() + + override fun events(params: V1EventsParams, requestOptions: RequestOptions): V1EventsResponse = + // post /api/v1/events + withRawResponse().events(params, requestOptions).parse() + + override fun login(params: V1LoginParams, requestOptions: RequestOptions): V1LoginResponse = + // post /api/v1/login + withRawResponse().login(params, requestOptions).parse() + + override fun retrieveOk( + params: V1RetrieveOkParams, + requestOptions: RequestOptions, + ): V1RetrieveOkResponse = + // get /api/v1/ok + withRawResponse().retrieveOk(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + V1Service.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val sessions: SessionService.WithRawResponse by lazy { + SessionServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val orgs: OrgService.WithRawResponse by lazy { + OrgServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val oauth: OAuthService.WithRawResponse by lazy { + OAuthServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val sso: SsoService.WithRawResponse by lazy { + SsoServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val apiKey: ApiKeyService.WithRawResponse by lazy { + ApiKeyServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val examples: ExampleService.WithRawResponse by lazy { + ExampleServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val datasets: DatasetService.WithRawResponse by lazy { + DatasetServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val runs: RunService.WithRawResponse by lazy { + RunServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val feedback: FeedbackService.WithRawResponse by lazy { + FeedbackServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val public_: PublicService.WithRawResponse by lazy { + PublicServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val annotationQueues: AnnotationQueueService.WithRawResponse by lazy { + AnnotationQueueServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val ace: AceService.WithRawResponse by lazy { + AceServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val bulkExports: BulkExportService.WithRawResponse by lazy { + BulkExportServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val tenants: TenantService.WithRawResponse by lazy { + TenantServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val info: InfoService.WithRawResponse by lazy { + InfoServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val feedbackConfigs: FeedbackConfigService.WithRawResponse by lazy { + FeedbackConfigServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val modelPriceMap: ModelPriceMapService.WithRawResponse by lazy { + ModelPriceMapServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val usageLimits: UsageLimitService.WithRawResponse by lazy { + UsageLimitServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val ttlSettings: TtlSettingService.WithRawResponse by lazy { + TtlSettingServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val prompts: PromptService.WithRawResponse by lazy { + PromptServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val promptWebhooks: PromptWebhookService.WithRawResponse by lazy { + PromptWebhookServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val workspaces: WorkspaceService.WithRawResponse by lazy { + WorkspaceServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val playgroundSettings: PlaygroundSettingService.WithRawResponse by lazy { + PlaygroundSettingServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val me: MeService.WithRawResponse by lazy { + MeServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val serviceAccounts: ServiceAccountService.WithRawResponse by lazy { + ServiceAccountServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val charts: ChartService.WithRawResponse by lazy { + ChartServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val orgCharts: OrgChartService.WithRawResponse by lazy { + OrgChartServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val repos: RepoService.WithRawResponse by lazy { + RepoServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val commits: CommitService.WithRawResponse by lazy { + CommitServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val settings: SettingService.WithRawResponse by lazy { + SettingServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val comments: CommentService.WithRawResponse by lazy { + CommentServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): V1Service.WithRawResponse = + V1ServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun sessions(): SessionService.WithRawResponse = sessions + + override fun orgs(): OrgService.WithRawResponse = orgs + + override fun oauth(): OAuthService.WithRawResponse = oauth + + override fun sso(): SsoService.WithRawResponse = sso + + override fun apiKey(): ApiKeyService.WithRawResponse = apiKey + + override fun examples(): ExampleService.WithRawResponse = examples + + override fun datasets(): DatasetService.WithRawResponse = datasets + + override fun runs(): RunService.WithRawResponse = runs + + override fun feedback(): FeedbackService.WithRawResponse = feedback + + override fun public_(): PublicService.WithRawResponse = public_ + + override fun annotationQueues(): AnnotationQueueService.WithRawResponse = annotationQueues + + override fun ace(): AceService.WithRawResponse = ace + + override fun bulkExports(): BulkExportService.WithRawResponse = bulkExports + + override fun tenants(): TenantService.WithRawResponse = tenants + + override fun info(): InfoService.WithRawResponse = info + + override fun feedbackConfigs(): FeedbackConfigService.WithRawResponse = feedbackConfigs + + override fun modelPriceMap(): ModelPriceMapService.WithRawResponse = modelPriceMap + + override fun usageLimits(): UsageLimitService.WithRawResponse = usageLimits + + override fun ttlSettings(): TtlSettingService.WithRawResponse = ttlSettings + + override fun prompts(): PromptService.WithRawResponse = prompts + + override fun promptWebhooks(): PromptWebhookService.WithRawResponse = promptWebhooks + + override fun workspaces(): WorkspaceService.WithRawResponse = workspaces + + override fun playgroundSettings(): PlaygroundSettingService.WithRawResponse = + playgroundSettings + + override fun me(): MeService.WithRawResponse = me + + override fun serviceAccounts(): ServiceAccountService.WithRawResponse = serviceAccounts + + override fun charts(): ChartService.WithRawResponse = charts + + override fun orgCharts(): OrgChartService.WithRawResponse = orgCharts + + override fun repos(): RepoService.WithRawResponse = repos + + override fun commits(): CommitService.WithRawResponse = commits + + override fun settings(): SettingService.WithRawResponse = settings + + override fun comments(): CommentService.WithRawResponse = comments + + private val updateHandler: Handler<V1UpdateResponse> = + jsonHandler<V1UpdateResponse>(clientOptions.jsonMapper) + + override fun update( + params: V1UpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<V1UpdateResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("repo", params.repo().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "likes", + params._pathParam(0), + params._pathParam(1), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val eventsHandler: Handler<V1EventsResponse> = + jsonHandler<V1EventsResponse>(clientOptions.jsonMapper) + + override fun events( + params: V1EventsParams, + requestOptions: RequestOptions, + ): HttpResponseFor<V1EventsResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "events") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { eventsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val loginHandler: Handler<V1LoginResponse> = + jsonHandler<V1LoginResponse>(clientOptions.jsonMapper) + + override fun login( + params: V1LoginParams, + requestOptions: RequestOptions, + ): HttpResponseFor<V1LoginResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "login") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { loginHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveOkHandler: Handler<V1RetrieveOkResponse> = + jsonHandler<V1RetrieveOkResponse>(clientOptions.jsonMapper) + + override fun retrieveOk( + params: V1RetrieveOkParams, + requestOptions: RequestOptions, + ): HttpResponseFor<V1RetrieveOkResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "ok") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveOkHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/AceService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/AceService.kt new file mode 100644 index 00000000..d1299c04 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/AceService.kt @@ -0,0 +1,62 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.ace.AceExecuteParams +import com.langsmith_api.api.models.api.v1.ace.AceExecuteResponse +import java.util.function.Consumer + +interface AceService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): AceService + + /** Execute some custom code for testing purposes. */ + fun execute(params: AceExecuteParams): AceExecuteResponse = + execute(params, RequestOptions.none()) + + /** @see execute */ + fun execute( + params: AceExecuteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AceExecuteResponse + + /** A view of [AceService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): AceService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/ace/execute`, but is otherwise the same as + * [AceService.execute]. + */ + @MustBeClosed + fun execute(params: AceExecuteParams): HttpResponseFor<AceExecuteResponse> = + execute(params, RequestOptions.none()) + + /** @see execute */ + @MustBeClosed + fun execute( + params: AceExecuteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<AceExecuteResponse> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/AceServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/AceServiceImpl.kt new file mode 100644 index 00000000..d2a393c6 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/AceServiceImpl.kt @@ -0,0 +1,81 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.ace.AceExecuteParams +import com.langsmith_api.api.models.api.v1.ace.AceExecuteResponse +import java.util.function.Consumer + +class AceServiceImpl internal constructor(private val clientOptions: ClientOptions) : AceService { + + private val withRawResponse: AceService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): AceService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): AceService = + AceServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun execute( + params: AceExecuteParams, + requestOptions: RequestOptions, + ): AceExecuteResponse = + // post /api/v1/ace/execute + withRawResponse().execute(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AceService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): AceService.WithRawResponse = + AceServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val executeHandler: Handler<AceExecuteResponse> = + jsonHandler<AceExecuteResponse>(clientOptions.jsonMapper) + + override fun execute( + params: AceExecuteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<AceExecuteResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "ace", "execute") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { executeHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/AnnotationQueueService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/AnnotationQueueService.kt new file mode 100644 index 00000000..49ae2495 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/AnnotationQueueService.kt @@ -0,0 +1,826 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueAnnotationQueuesParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueDeleteParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueDeleteResponse +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueExportParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueExportResponse +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueuePopulateParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueuePopulateResponse +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueRetrieveAnnotationQueuesParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueRetrieveAnnotationQueuesResponse +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueRetrieveParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueRetrieveQueuesParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueRetrieveSizeParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueRetrieveTotalArchivedParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueRetrieveTotalSizeParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueSchema +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueSizeSchema +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueUpdateParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueUpdateResponse +import com.langsmith_api.api.models.api.v1.annotationqueues.RunSchemaWithAnnotationQueueInfo +import com.langsmith_api.api.services.blocking.api.v1.annotationqueues.RunService +import java.util.function.Consumer + +interface AnnotationQueueService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): AnnotationQueueService + + fun runs(): RunService + + /** Get a run from an annotation queue */ + fun retrieve( + index: Long, + params: AnnotationQueueRetrieveParams, + ): RunSchemaWithAnnotationQueueInfo = retrieve(index, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + index: Long, + params: AnnotationQueueRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RunSchemaWithAnnotationQueueInfo = + retrieve(params.toBuilder().index(index).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: AnnotationQueueRetrieveParams): RunSchemaWithAnnotationQueueInfo = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: AnnotationQueueRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RunSchemaWithAnnotationQueueInfo + + /** Create Identity Annotation Queue Run Status */ + fun update(annotationQueueRunId: String): AnnotationQueueUpdateResponse = + update(annotationQueueRunId, AnnotationQueueUpdateParams.none()) + + /** @see update */ + fun update( + annotationQueueRunId: String, + params: AnnotationQueueUpdateParams = AnnotationQueueUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AnnotationQueueUpdateResponse = + update( + params.toBuilder().annotationQueueRunId(annotationQueueRunId).build(), + requestOptions, + ) + + /** @see update */ + fun update( + annotationQueueRunId: String, + params: AnnotationQueueUpdateParams = AnnotationQueueUpdateParams.none(), + ): AnnotationQueueUpdateResponse = update(annotationQueueRunId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: AnnotationQueueUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AnnotationQueueUpdateResponse + + /** @see update */ + fun update(params: AnnotationQueueUpdateParams): AnnotationQueueUpdateResponse = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + annotationQueueRunId: String, + requestOptions: RequestOptions, + ): AnnotationQueueUpdateResponse = + update(annotationQueueRunId, AnnotationQueueUpdateParams.none(), requestOptions) + + /** Delete Annotation Queue */ + fun delete(queueId: String): AnnotationQueueDeleteResponse = + delete(queueId, AnnotationQueueDeleteParams.none()) + + /** @see delete */ + fun delete( + queueId: String, + params: AnnotationQueueDeleteParams = AnnotationQueueDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AnnotationQueueDeleteResponse = + delete(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see delete */ + fun delete( + queueId: String, + params: AnnotationQueueDeleteParams = AnnotationQueueDeleteParams.none(), + ): AnnotationQueueDeleteResponse = delete(queueId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: AnnotationQueueDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AnnotationQueueDeleteResponse + + /** @see delete */ + fun delete(params: AnnotationQueueDeleteParams): AnnotationQueueDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(queueId: String, requestOptions: RequestOptions): AnnotationQueueDeleteResponse = + delete(queueId, AnnotationQueueDeleteParams.none(), requestOptions) + + /** Create Annotation Queue */ + fun annotationQueues(params: AnnotationQueueAnnotationQueuesParams): AnnotationQueueSchema = + annotationQueues(params, RequestOptions.none()) + + /** @see annotationQueues */ + fun annotationQueues( + params: AnnotationQueueAnnotationQueuesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AnnotationQueueSchema + + /** Export Annotation Queue Archived Runs */ + fun export(queueId: String): AnnotationQueueExportResponse = + export(queueId, AnnotationQueueExportParams.none()) + + /** @see export */ + fun export( + queueId: String, + params: AnnotationQueueExportParams = AnnotationQueueExportParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AnnotationQueueExportResponse = + export(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see export */ + fun export( + queueId: String, + params: AnnotationQueueExportParams = AnnotationQueueExportParams.none(), + ): AnnotationQueueExportResponse = export(queueId, params, RequestOptions.none()) + + /** @see export */ + fun export( + params: AnnotationQueueExportParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AnnotationQueueExportResponse + + /** @see export */ + fun export(params: AnnotationQueueExportParams): AnnotationQueueExportResponse = + export(params, RequestOptions.none()) + + /** @see export */ + fun export(queueId: String, requestOptions: RequestOptions): AnnotationQueueExportResponse = + export(queueId, AnnotationQueueExportParams.none(), requestOptions) + + /** Populate annotation queue with runs from an experiment. */ + fun populate(params: AnnotationQueuePopulateParams): AnnotationQueuePopulateResponse = + populate(params, RequestOptions.none()) + + /** @see populate */ + fun populate( + params: AnnotationQueuePopulateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AnnotationQueuePopulateResponse + + /** Get Annotation Queues */ + fun retrieveAnnotationQueues(): List<AnnotationQueueRetrieveAnnotationQueuesResponse> = + retrieveAnnotationQueues(AnnotationQueueRetrieveAnnotationQueuesParams.none()) + + /** @see retrieveAnnotationQueues */ + fun retrieveAnnotationQueues( + params: AnnotationQueueRetrieveAnnotationQueuesParams = + AnnotationQueueRetrieveAnnotationQueuesParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<AnnotationQueueRetrieveAnnotationQueuesResponse> + + /** @see retrieveAnnotationQueues */ + fun retrieveAnnotationQueues( + params: AnnotationQueueRetrieveAnnotationQueuesParams = + AnnotationQueueRetrieveAnnotationQueuesParams.none() + ): List<AnnotationQueueRetrieveAnnotationQueuesResponse> = + retrieveAnnotationQueues(params, RequestOptions.none()) + + /** @see retrieveAnnotationQueues */ + fun retrieveAnnotationQueues( + requestOptions: RequestOptions + ): List<AnnotationQueueRetrieveAnnotationQueuesResponse> = + retrieveAnnotationQueues( + AnnotationQueueRetrieveAnnotationQueuesParams.none(), + requestOptions, + ) + + /** Get Annotation Queues For Run */ + fun retrieveQueues(runId: String): List<AnnotationQueueSchema> = + retrieveQueues(runId, AnnotationQueueRetrieveQueuesParams.none()) + + /** @see retrieveQueues */ + fun retrieveQueues( + runId: String, + params: AnnotationQueueRetrieveQueuesParams = AnnotationQueueRetrieveQueuesParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<AnnotationQueueSchema> = + retrieveQueues(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see retrieveQueues */ + fun retrieveQueues( + runId: String, + params: AnnotationQueueRetrieveQueuesParams = AnnotationQueueRetrieveQueuesParams.none(), + ): List<AnnotationQueueSchema> = retrieveQueues(runId, params, RequestOptions.none()) + + /** @see retrieveQueues */ + fun retrieveQueues( + params: AnnotationQueueRetrieveQueuesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List<AnnotationQueueSchema> + + /** @see retrieveQueues */ + fun retrieveQueues(params: AnnotationQueueRetrieveQueuesParams): List<AnnotationQueueSchema> = + retrieveQueues(params, RequestOptions.none()) + + /** @see retrieveQueues */ + fun retrieveQueues(runId: String, requestOptions: RequestOptions): List<AnnotationQueueSchema> = + retrieveQueues(runId, AnnotationQueueRetrieveQueuesParams.none(), requestOptions) + + /** Get Size From Annotation Queue */ + fun retrieveSize(queueId: String): AnnotationQueueSizeSchema = + retrieveSize(queueId, AnnotationQueueRetrieveSizeParams.none()) + + /** @see retrieveSize */ + fun retrieveSize( + queueId: String, + params: AnnotationQueueRetrieveSizeParams = AnnotationQueueRetrieveSizeParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AnnotationQueueSizeSchema = + retrieveSize(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see retrieveSize */ + fun retrieveSize( + queueId: String, + params: AnnotationQueueRetrieveSizeParams = AnnotationQueueRetrieveSizeParams.none(), + ): AnnotationQueueSizeSchema = retrieveSize(queueId, params, RequestOptions.none()) + + /** @see retrieveSize */ + fun retrieveSize( + params: AnnotationQueueRetrieveSizeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AnnotationQueueSizeSchema + + /** @see retrieveSize */ + fun retrieveSize(params: AnnotationQueueRetrieveSizeParams): AnnotationQueueSizeSchema = + retrieveSize(params, RequestOptions.none()) + + /** @see retrieveSize */ + fun retrieveSize(queueId: String, requestOptions: RequestOptions): AnnotationQueueSizeSchema = + retrieveSize(queueId, AnnotationQueueRetrieveSizeParams.none(), requestOptions) + + /** Get Total Archived From Annotation Queue */ + fun retrieveTotalArchived(queueId: String): AnnotationQueueSizeSchema = + retrieveTotalArchived(queueId, AnnotationQueueRetrieveTotalArchivedParams.none()) + + /** @see retrieveTotalArchived */ + fun retrieveTotalArchived( + queueId: String, + params: AnnotationQueueRetrieveTotalArchivedParams = + AnnotationQueueRetrieveTotalArchivedParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AnnotationQueueSizeSchema = + retrieveTotalArchived(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see retrieveTotalArchived */ + fun retrieveTotalArchived( + queueId: String, + params: AnnotationQueueRetrieveTotalArchivedParams = + AnnotationQueueRetrieveTotalArchivedParams.none(), + ): AnnotationQueueSizeSchema = retrieveTotalArchived(queueId, params, RequestOptions.none()) + + /** @see retrieveTotalArchived */ + fun retrieveTotalArchived( + params: AnnotationQueueRetrieveTotalArchivedParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AnnotationQueueSizeSchema + + /** @see retrieveTotalArchived */ + fun retrieveTotalArchived( + params: AnnotationQueueRetrieveTotalArchivedParams + ): AnnotationQueueSizeSchema = retrieveTotalArchived(params, RequestOptions.none()) + + /** @see retrieveTotalArchived */ + fun retrieveTotalArchived( + queueId: String, + requestOptions: RequestOptions, + ): AnnotationQueueSizeSchema = + retrieveTotalArchived( + queueId, + AnnotationQueueRetrieveTotalArchivedParams.none(), + requestOptions, + ) + + /** Get Total Size From Annotation Queue */ + fun retrieveTotalSize(queueId: String): AnnotationQueueSizeSchema = + retrieveTotalSize(queueId, AnnotationQueueRetrieveTotalSizeParams.none()) + + /** @see retrieveTotalSize */ + fun retrieveTotalSize( + queueId: String, + params: AnnotationQueueRetrieveTotalSizeParams = + AnnotationQueueRetrieveTotalSizeParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AnnotationQueueSizeSchema = + retrieveTotalSize(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see retrieveTotalSize */ + fun retrieveTotalSize( + queueId: String, + params: AnnotationQueueRetrieveTotalSizeParams = + AnnotationQueueRetrieveTotalSizeParams.none(), + ): AnnotationQueueSizeSchema = retrieveTotalSize(queueId, params, RequestOptions.none()) + + /** @see retrieveTotalSize */ + fun retrieveTotalSize( + params: AnnotationQueueRetrieveTotalSizeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AnnotationQueueSizeSchema + + /** @see retrieveTotalSize */ + fun retrieveTotalSize( + params: AnnotationQueueRetrieveTotalSizeParams + ): AnnotationQueueSizeSchema = retrieveTotalSize(params, RequestOptions.none()) + + /** @see retrieveTotalSize */ + fun retrieveTotalSize( + queueId: String, + requestOptions: RequestOptions, + ): AnnotationQueueSizeSchema = + retrieveTotalSize(queueId, AnnotationQueueRetrieveTotalSizeParams.none(), requestOptions) + + /** + * A view of [AnnotationQueueService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): AnnotationQueueService.WithRawResponse + + fun runs(): RunService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/annotation-queues/{queue_id}/run/{index}`, + * but is otherwise the same as [AnnotationQueueService.retrieve]. + */ + @MustBeClosed + fun retrieve( + index: Long, + params: AnnotationQueueRetrieveParams, + ): HttpResponseFor<RunSchemaWithAnnotationQueueInfo> = + retrieve(index, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + index: Long, + params: AnnotationQueueRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RunSchemaWithAnnotationQueueInfo> = + retrieve(params.toBuilder().index(index).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: AnnotationQueueRetrieveParams + ): HttpResponseFor<RunSchemaWithAnnotationQueueInfo> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: AnnotationQueueRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RunSchemaWithAnnotationQueueInfo> + + /** + * Returns a raw HTTP response for `post + * /api/v1/annotation-queues/status/{annotation_queue_run_id}`, but is otherwise the same as + * [AnnotationQueueService.update]. + */ + @MustBeClosed + fun update(annotationQueueRunId: String): HttpResponseFor<AnnotationQueueUpdateResponse> = + update(annotationQueueRunId, AnnotationQueueUpdateParams.none()) + + /** @see update */ + @MustBeClosed + fun update( + annotationQueueRunId: String, + params: AnnotationQueueUpdateParams = AnnotationQueueUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<AnnotationQueueUpdateResponse> = + update( + params.toBuilder().annotationQueueRunId(annotationQueueRunId).build(), + requestOptions, + ) + + /** @see update */ + @MustBeClosed + fun update( + annotationQueueRunId: String, + params: AnnotationQueueUpdateParams = AnnotationQueueUpdateParams.none(), + ): HttpResponseFor<AnnotationQueueUpdateResponse> = + update(annotationQueueRunId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: AnnotationQueueUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<AnnotationQueueUpdateResponse> + + /** @see update */ + @MustBeClosed + fun update( + params: AnnotationQueueUpdateParams + ): HttpResponseFor<AnnotationQueueUpdateResponse> = update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + annotationQueueRunId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<AnnotationQueueUpdateResponse> = + update(annotationQueueRunId, AnnotationQueueUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/annotation-queues/{queue_id}`, but is + * otherwise the same as [AnnotationQueueService.delete]. + */ + @MustBeClosed + fun delete(queueId: String): HttpResponseFor<AnnotationQueueDeleteResponse> = + delete(queueId, AnnotationQueueDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + queueId: String, + params: AnnotationQueueDeleteParams = AnnotationQueueDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<AnnotationQueueDeleteResponse> = + delete(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + queueId: String, + params: AnnotationQueueDeleteParams = AnnotationQueueDeleteParams.none(), + ): HttpResponseFor<AnnotationQueueDeleteResponse> = + delete(queueId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: AnnotationQueueDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<AnnotationQueueDeleteResponse> + + /** @see delete */ + @MustBeClosed + fun delete( + params: AnnotationQueueDeleteParams + ): HttpResponseFor<AnnotationQueueDeleteResponse> = delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + queueId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<AnnotationQueueDeleteResponse> = + delete(queueId, AnnotationQueueDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/annotation-queues`, but is otherwise the + * same as [AnnotationQueueService.annotationQueues]. + */ + @MustBeClosed + fun annotationQueues( + params: AnnotationQueueAnnotationQueuesParams + ): HttpResponseFor<AnnotationQueueSchema> = annotationQueues(params, RequestOptions.none()) + + /** @see annotationQueues */ + @MustBeClosed + fun annotationQueues( + params: AnnotationQueueAnnotationQueuesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<AnnotationQueueSchema> + + /** + * Returns a raw HTTP response for `post /api/v1/annotation-queues/{queue_id}/export`, but + * is otherwise the same as [AnnotationQueueService.export]. + */ + @MustBeClosed + fun export(queueId: String): HttpResponseFor<AnnotationQueueExportResponse> = + export(queueId, AnnotationQueueExportParams.none()) + + /** @see export */ + @MustBeClosed + fun export( + queueId: String, + params: AnnotationQueueExportParams = AnnotationQueueExportParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<AnnotationQueueExportResponse> = + export(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see export */ + @MustBeClosed + fun export( + queueId: String, + params: AnnotationQueueExportParams = AnnotationQueueExportParams.none(), + ): HttpResponseFor<AnnotationQueueExportResponse> = + export(queueId, params, RequestOptions.none()) + + /** @see export */ + @MustBeClosed + fun export( + params: AnnotationQueueExportParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<AnnotationQueueExportResponse> + + /** @see export */ + @MustBeClosed + fun export( + params: AnnotationQueueExportParams + ): HttpResponseFor<AnnotationQueueExportResponse> = export(params, RequestOptions.none()) + + /** @see export */ + @MustBeClosed + fun export( + queueId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<AnnotationQueueExportResponse> = + export(queueId, AnnotationQueueExportParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/annotation-queues/populate`, but is + * otherwise the same as [AnnotationQueueService.populate]. + */ + @MustBeClosed + fun populate( + params: AnnotationQueuePopulateParams + ): HttpResponseFor<AnnotationQueuePopulateResponse> = + populate(params, RequestOptions.none()) + + /** @see populate */ + @MustBeClosed + fun populate( + params: AnnotationQueuePopulateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<AnnotationQueuePopulateResponse> + + /** + * Returns a raw HTTP response for `get /api/v1/annotation-queues`, but is otherwise the + * same as [AnnotationQueueService.retrieveAnnotationQueues]. + */ + @MustBeClosed + fun retrieveAnnotationQueues(): + HttpResponseFor<List<AnnotationQueueRetrieveAnnotationQueuesResponse>> = + retrieveAnnotationQueues(AnnotationQueueRetrieveAnnotationQueuesParams.none()) + + /** @see retrieveAnnotationQueues */ + @MustBeClosed + fun retrieveAnnotationQueues( + params: AnnotationQueueRetrieveAnnotationQueuesParams = + AnnotationQueueRetrieveAnnotationQueuesParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<AnnotationQueueRetrieveAnnotationQueuesResponse>> + + /** @see retrieveAnnotationQueues */ + @MustBeClosed + fun retrieveAnnotationQueues( + params: AnnotationQueueRetrieveAnnotationQueuesParams = + AnnotationQueueRetrieveAnnotationQueuesParams.none() + ): HttpResponseFor<List<AnnotationQueueRetrieveAnnotationQueuesResponse>> = + retrieveAnnotationQueues(params, RequestOptions.none()) + + /** @see retrieveAnnotationQueues */ + @MustBeClosed + fun retrieveAnnotationQueues( + requestOptions: RequestOptions + ): HttpResponseFor<List<AnnotationQueueRetrieveAnnotationQueuesResponse>> = + retrieveAnnotationQueues( + AnnotationQueueRetrieveAnnotationQueuesParams.none(), + requestOptions, + ) + + /** + * Returns a raw HTTP response for `get /api/v1/annotation-queues/{run_id}/queues`, but is + * otherwise the same as [AnnotationQueueService.retrieveQueues]. + */ + @MustBeClosed + fun retrieveQueues(runId: String): HttpResponseFor<List<AnnotationQueueSchema>> = + retrieveQueues(runId, AnnotationQueueRetrieveQueuesParams.none()) + + /** @see retrieveQueues */ + @MustBeClosed + fun retrieveQueues( + runId: String, + params: AnnotationQueueRetrieveQueuesParams = + AnnotationQueueRetrieveQueuesParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<AnnotationQueueSchema>> = + retrieveQueues(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see retrieveQueues */ + @MustBeClosed + fun retrieveQueues( + runId: String, + params: AnnotationQueueRetrieveQueuesParams = AnnotationQueueRetrieveQueuesParams.none(), + ): HttpResponseFor<List<AnnotationQueueSchema>> = + retrieveQueues(runId, params, RequestOptions.none()) + + /** @see retrieveQueues */ + @MustBeClosed + fun retrieveQueues( + params: AnnotationQueueRetrieveQueuesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<AnnotationQueueSchema>> + + /** @see retrieveQueues */ + @MustBeClosed + fun retrieveQueues( + params: AnnotationQueueRetrieveQueuesParams + ): HttpResponseFor<List<AnnotationQueueSchema>> = + retrieveQueues(params, RequestOptions.none()) + + /** @see retrieveQueues */ + @MustBeClosed + fun retrieveQueues( + runId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<List<AnnotationQueueSchema>> = + retrieveQueues(runId, AnnotationQueueRetrieveQueuesParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/annotation-queues/{queue_id}/size`, but is + * otherwise the same as [AnnotationQueueService.retrieveSize]. + */ + @MustBeClosed + fun retrieveSize(queueId: String): HttpResponseFor<AnnotationQueueSizeSchema> = + retrieveSize(queueId, AnnotationQueueRetrieveSizeParams.none()) + + /** @see retrieveSize */ + @MustBeClosed + fun retrieveSize( + queueId: String, + params: AnnotationQueueRetrieveSizeParams = AnnotationQueueRetrieveSizeParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<AnnotationQueueSizeSchema> = + retrieveSize(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see retrieveSize */ + @MustBeClosed + fun retrieveSize( + queueId: String, + params: AnnotationQueueRetrieveSizeParams = AnnotationQueueRetrieveSizeParams.none(), + ): HttpResponseFor<AnnotationQueueSizeSchema> = + retrieveSize(queueId, params, RequestOptions.none()) + + /** @see retrieveSize */ + @MustBeClosed + fun retrieveSize( + params: AnnotationQueueRetrieveSizeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<AnnotationQueueSizeSchema> + + /** @see retrieveSize */ + @MustBeClosed + fun retrieveSize( + params: AnnotationQueueRetrieveSizeParams + ): HttpResponseFor<AnnotationQueueSizeSchema> = retrieveSize(params, RequestOptions.none()) + + /** @see retrieveSize */ + @MustBeClosed + fun retrieveSize( + queueId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<AnnotationQueueSizeSchema> = + retrieveSize(queueId, AnnotationQueueRetrieveSizeParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get + * /api/v1/annotation-queues/{queue_id}/total_archived`, but is otherwise the same as + * [AnnotationQueueService.retrieveTotalArchived]. + */ + @MustBeClosed + fun retrieveTotalArchived(queueId: String): HttpResponseFor<AnnotationQueueSizeSchema> = + retrieveTotalArchived(queueId, AnnotationQueueRetrieveTotalArchivedParams.none()) + + /** @see retrieveTotalArchived */ + @MustBeClosed + fun retrieveTotalArchived( + queueId: String, + params: AnnotationQueueRetrieveTotalArchivedParams = + AnnotationQueueRetrieveTotalArchivedParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<AnnotationQueueSizeSchema> = + retrieveTotalArchived(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see retrieveTotalArchived */ + @MustBeClosed + fun retrieveTotalArchived( + queueId: String, + params: AnnotationQueueRetrieveTotalArchivedParams = + AnnotationQueueRetrieveTotalArchivedParams.none(), + ): HttpResponseFor<AnnotationQueueSizeSchema> = + retrieveTotalArchived(queueId, params, RequestOptions.none()) + + /** @see retrieveTotalArchived */ + @MustBeClosed + fun retrieveTotalArchived( + params: AnnotationQueueRetrieveTotalArchivedParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<AnnotationQueueSizeSchema> + + /** @see retrieveTotalArchived */ + @MustBeClosed + fun retrieveTotalArchived( + params: AnnotationQueueRetrieveTotalArchivedParams + ): HttpResponseFor<AnnotationQueueSizeSchema> = + retrieveTotalArchived(params, RequestOptions.none()) + + /** @see retrieveTotalArchived */ + @MustBeClosed + fun retrieveTotalArchived( + queueId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<AnnotationQueueSizeSchema> = + retrieveTotalArchived( + queueId, + AnnotationQueueRetrieveTotalArchivedParams.none(), + requestOptions, + ) + + /** + * Returns a raw HTTP response for `get /api/v1/annotation-queues/{queue_id}/total_size`, + * but is otherwise the same as [AnnotationQueueService.retrieveTotalSize]. + */ + @MustBeClosed + fun retrieveTotalSize(queueId: String): HttpResponseFor<AnnotationQueueSizeSchema> = + retrieveTotalSize(queueId, AnnotationQueueRetrieveTotalSizeParams.none()) + + /** @see retrieveTotalSize */ + @MustBeClosed + fun retrieveTotalSize( + queueId: String, + params: AnnotationQueueRetrieveTotalSizeParams = + AnnotationQueueRetrieveTotalSizeParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<AnnotationQueueSizeSchema> = + retrieveTotalSize(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see retrieveTotalSize */ + @MustBeClosed + fun retrieveTotalSize( + queueId: String, + params: AnnotationQueueRetrieveTotalSizeParams = + AnnotationQueueRetrieveTotalSizeParams.none(), + ): HttpResponseFor<AnnotationQueueSizeSchema> = + retrieveTotalSize(queueId, params, RequestOptions.none()) + + /** @see retrieveTotalSize */ + @MustBeClosed + fun retrieveTotalSize( + params: AnnotationQueueRetrieveTotalSizeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<AnnotationQueueSizeSchema> + + /** @see retrieveTotalSize */ + @MustBeClosed + fun retrieveTotalSize( + params: AnnotationQueueRetrieveTotalSizeParams + ): HttpResponseFor<AnnotationQueueSizeSchema> = + retrieveTotalSize(params, RequestOptions.none()) + + /** @see retrieveTotalSize */ + @MustBeClosed + fun retrieveTotalSize( + queueId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<AnnotationQueueSizeSchema> = + retrieveTotalSize( + queueId, + AnnotationQueueRetrieveTotalSizeParams.none(), + requestOptions, + ) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/AnnotationQueueServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/AnnotationQueueServiceImpl.kt new file mode 100644 index 00000000..79847589 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/AnnotationQueueServiceImpl.kt @@ -0,0 +1,521 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueAnnotationQueuesParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueDeleteParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueDeleteResponse +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueExportParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueExportResponse +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueuePopulateParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueuePopulateResponse +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueRetrieveAnnotationQueuesParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueRetrieveAnnotationQueuesResponse +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueRetrieveParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueRetrieveQueuesParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueRetrieveSizeParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueRetrieveTotalArchivedParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueRetrieveTotalSizeParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueSchema +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueSizeSchema +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueUpdateParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueUpdateResponse +import com.langsmith_api.api.models.api.v1.annotationqueues.RunSchemaWithAnnotationQueueInfo +import com.langsmith_api.api.services.blocking.api.v1.annotationqueues.RunService +import com.langsmith_api.api.services.blocking.api.v1.annotationqueues.RunServiceImpl +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class AnnotationQueueServiceImpl internal constructor(private val clientOptions: ClientOptions) : + AnnotationQueueService { + + private val withRawResponse: AnnotationQueueService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val runs: RunService by lazy { RunServiceImpl(clientOptions) } + + override fun withRawResponse(): AnnotationQueueService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): AnnotationQueueService = + AnnotationQueueServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun runs(): RunService = runs + + override fun retrieve( + params: AnnotationQueueRetrieveParams, + requestOptions: RequestOptions, + ): RunSchemaWithAnnotationQueueInfo = + // get /api/v1/annotation-queues/{queue_id}/run/{index} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update( + params: AnnotationQueueUpdateParams, + requestOptions: RequestOptions, + ): AnnotationQueueUpdateResponse = + // post /api/v1/annotation-queues/status/{annotation_queue_run_id} + withRawResponse().update(params, requestOptions).parse() + + override fun delete( + params: AnnotationQueueDeleteParams, + requestOptions: RequestOptions, + ): AnnotationQueueDeleteResponse = + // delete /api/v1/annotation-queues/{queue_id} + withRawResponse().delete(params, requestOptions).parse() + + override fun annotationQueues( + params: AnnotationQueueAnnotationQueuesParams, + requestOptions: RequestOptions, + ): AnnotationQueueSchema = + // post /api/v1/annotation-queues + withRawResponse().annotationQueues(params, requestOptions).parse() + + override fun export( + params: AnnotationQueueExportParams, + requestOptions: RequestOptions, + ): AnnotationQueueExportResponse = + // post /api/v1/annotation-queues/{queue_id}/export + withRawResponse().export(params, requestOptions).parse() + + override fun populate( + params: AnnotationQueuePopulateParams, + requestOptions: RequestOptions, + ): AnnotationQueuePopulateResponse = + // post /api/v1/annotation-queues/populate + withRawResponse().populate(params, requestOptions).parse() + + override fun retrieveAnnotationQueues( + params: AnnotationQueueRetrieveAnnotationQueuesParams, + requestOptions: RequestOptions, + ): List<AnnotationQueueRetrieveAnnotationQueuesResponse> = + // get /api/v1/annotation-queues + withRawResponse().retrieveAnnotationQueues(params, requestOptions).parse() + + override fun retrieveQueues( + params: AnnotationQueueRetrieveQueuesParams, + requestOptions: RequestOptions, + ): List<AnnotationQueueSchema> = + // get /api/v1/annotation-queues/{run_id}/queues + withRawResponse().retrieveQueues(params, requestOptions).parse() + + override fun retrieveSize( + params: AnnotationQueueRetrieveSizeParams, + requestOptions: RequestOptions, + ): AnnotationQueueSizeSchema = + // get /api/v1/annotation-queues/{queue_id}/size + withRawResponse().retrieveSize(params, requestOptions).parse() + + override fun retrieveTotalArchived( + params: AnnotationQueueRetrieveTotalArchivedParams, + requestOptions: RequestOptions, + ): AnnotationQueueSizeSchema = + // get /api/v1/annotation-queues/{queue_id}/total_archived + withRawResponse().retrieveTotalArchived(params, requestOptions).parse() + + override fun retrieveTotalSize( + params: AnnotationQueueRetrieveTotalSizeParams, + requestOptions: RequestOptions, + ): AnnotationQueueSizeSchema = + // get /api/v1/annotation-queues/{queue_id}/total_size + withRawResponse().retrieveTotalSize(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AnnotationQueueService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val runs: RunService.WithRawResponse by lazy { + RunServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): AnnotationQueueService.WithRawResponse = + AnnotationQueueServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun runs(): RunService.WithRawResponse = runs + + private val retrieveHandler: Handler<RunSchemaWithAnnotationQueueInfo> = + jsonHandler<RunSchemaWithAnnotationQueueInfo>(clientOptions.jsonMapper) + + override fun retrieve( + params: AnnotationQueueRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor<RunSchemaWithAnnotationQueueInfo> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("index", params.index().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "annotation-queues", + params._pathParam(0), + "run", + params._pathParam(1), + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler<AnnotationQueueUpdateResponse> = + jsonHandler<AnnotationQueueUpdateResponse>(clientOptions.jsonMapper) + + override fun update( + params: AnnotationQueueUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<AnnotationQueueUpdateResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("annotationQueueRunId", params.annotationQueueRunId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "annotation-queues", + "status", + params._pathParam(0), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val deleteHandler: Handler<AnnotationQueueDeleteResponse> = + jsonHandler<AnnotationQueueDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: AnnotationQueueDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<AnnotationQueueDeleteResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("queueId", params.queueId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "annotation-queues", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val annotationQueuesHandler: Handler<AnnotationQueueSchema> = + jsonHandler<AnnotationQueueSchema>(clientOptions.jsonMapper) + + override fun annotationQueues( + params: AnnotationQueueAnnotationQueuesParams, + requestOptions: RequestOptions, + ): HttpResponseFor<AnnotationQueueSchema> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "annotation-queues") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { annotationQueuesHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val exportHandler: Handler<AnnotationQueueExportResponse> = + jsonHandler<AnnotationQueueExportResponse>(clientOptions.jsonMapper) + + override fun export( + params: AnnotationQueueExportParams, + requestOptions: RequestOptions, + ): HttpResponseFor<AnnotationQueueExportResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("queueId", params.queueId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "annotation-queues", + params._pathParam(0), + "export", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { exportHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val populateHandler: Handler<AnnotationQueuePopulateResponse> = + jsonHandler<AnnotationQueuePopulateResponse>(clientOptions.jsonMapper) + + override fun populate( + params: AnnotationQueuePopulateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<AnnotationQueuePopulateResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "annotation-queues", "populate") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { populateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveAnnotationQueuesHandler: + Handler<List<AnnotationQueueRetrieveAnnotationQueuesResponse>> = + jsonHandler<List<AnnotationQueueRetrieveAnnotationQueuesResponse>>( + clientOptions.jsonMapper + ) + + override fun retrieveAnnotationQueues( + params: AnnotationQueueRetrieveAnnotationQueuesParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<AnnotationQueueRetrieveAnnotationQueuesResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "annotation-queues") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveAnnotationQueuesHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val retrieveQueuesHandler: Handler<List<AnnotationQueueSchema>> = + jsonHandler<List<AnnotationQueueSchema>>(clientOptions.jsonMapper) + + override fun retrieveQueues( + params: AnnotationQueueRetrieveQueuesParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<AnnotationQueueSchema>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("runId", params.runId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "annotation-queues", + params._pathParam(0), + "queues", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveQueuesHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val retrieveSizeHandler: Handler<AnnotationQueueSizeSchema> = + jsonHandler<AnnotationQueueSizeSchema>(clientOptions.jsonMapper) + + override fun retrieveSize( + params: AnnotationQueueRetrieveSizeParams, + requestOptions: RequestOptions, + ): HttpResponseFor<AnnotationQueueSizeSchema> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("queueId", params.queueId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "annotation-queues", params._pathParam(0), "size") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveSizeHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveTotalArchivedHandler: Handler<AnnotationQueueSizeSchema> = + jsonHandler<AnnotationQueueSizeSchema>(clientOptions.jsonMapper) + + override fun retrieveTotalArchived( + params: AnnotationQueueRetrieveTotalArchivedParams, + requestOptions: RequestOptions, + ): HttpResponseFor<AnnotationQueueSizeSchema> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("queueId", params.queueId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "annotation-queues", + params._pathParam(0), + "total_archived", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveTotalArchivedHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveTotalSizeHandler: Handler<AnnotationQueueSizeSchema> = + jsonHandler<AnnotationQueueSizeSchema>(clientOptions.jsonMapper) + + override fun retrieveTotalSize( + params: AnnotationQueueRetrieveTotalSizeParams, + requestOptions: RequestOptions, + ): HttpResponseFor<AnnotationQueueSizeSchema> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("queueId", params.queueId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "annotation-queues", + params._pathParam(0), + "total_size", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveTotalSizeHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ApiKeyService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ApiKeyService.kt new file mode 100644 index 00000000..5c7e66b1 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ApiKeyService.kt @@ -0,0 +1,241 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.apikey.ApiKeyApiKeyParams +import com.langsmith_api.api.models.api.v1.apikey.ApiKeyDeleteParams +import com.langsmith_api.api.models.api.v1.apikey.ApiKeyRetrieveApiKeyParams +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyCreateRequest +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyCreateResponse +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyGetResponse +import com.langsmith_api.api.services.blocking.api.v1.apikey.CurrentService +import java.util.function.Consumer + +interface ApiKeyService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ApiKeyService + + fun current(): CurrentService + + /** Delete an api key for the user */ + fun delete(apiKeyId: String): ApiKeyGetResponse = delete(apiKeyId, ApiKeyDeleteParams.none()) + + /** @see delete */ + fun delete( + apiKeyId: String, + params: ApiKeyDeleteParams = ApiKeyDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ApiKeyGetResponse = delete(params.toBuilder().apiKeyId(apiKeyId).build(), requestOptions) + + /** @see delete */ + fun delete( + apiKeyId: String, + params: ApiKeyDeleteParams = ApiKeyDeleteParams.none(), + ): ApiKeyGetResponse = delete(apiKeyId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ApiKeyDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ApiKeyGetResponse + + /** @see delete */ + fun delete(params: ApiKeyDeleteParams): ApiKeyGetResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(apiKeyId: String, requestOptions: RequestOptions): ApiKeyGetResponse = + delete(apiKeyId, ApiKeyDeleteParams.none(), requestOptions) + + /** Generate an api key for the user */ + fun apiKey(): ApiKeyCreateResponse = apiKey(ApiKeyApiKeyParams.none()) + + /** @see apiKey */ + fun apiKey( + params: ApiKeyApiKeyParams = ApiKeyApiKeyParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ApiKeyCreateResponse + + /** @see apiKey */ + fun apiKey(params: ApiKeyApiKeyParams = ApiKeyApiKeyParams.none()): ApiKeyCreateResponse = + apiKey(params, RequestOptions.none()) + + /** @see apiKey */ + fun apiKey( + apiKeyCreateRequest: ApiKeyCreateRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): ApiKeyCreateResponse = + apiKey( + ApiKeyApiKeyParams.builder().apiKeyCreateRequest(apiKeyCreateRequest).build(), + requestOptions, + ) + + /** @see apiKey */ + fun apiKey(apiKeyCreateRequest: ApiKeyCreateRequest): ApiKeyCreateResponse = + apiKey(apiKeyCreateRequest, RequestOptions.none()) + + /** @see apiKey */ + fun apiKey(requestOptions: RequestOptions): ApiKeyCreateResponse = + apiKey(ApiKeyApiKeyParams.none(), requestOptions) + + /** Get the current tenant's API keys */ + fun retrieveApiKey(): List<ApiKeyGetResponse> = + retrieveApiKey(ApiKeyRetrieveApiKeyParams.none()) + + /** @see retrieveApiKey */ + fun retrieveApiKey( + params: ApiKeyRetrieveApiKeyParams = ApiKeyRetrieveApiKeyParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<ApiKeyGetResponse> + + /** @see retrieveApiKey */ + fun retrieveApiKey( + params: ApiKeyRetrieveApiKeyParams = ApiKeyRetrieveApiKeyParams.none() + ): List<ApiKeyGetResponse> = retrieveApiKey(params, RequestOptions.none()) + + /** @see retrieveApiKey */ + fun retrieveApiKey(requestOptions: RequestOptions): List<ApiKeyGetResponse> = + retrieveApiKey(ApiKeyRetrieveApiKeyParams.none(), requestOptions) + + /** A view of [ApiKeyService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ApiKeyService.WithRawResponse + + fun current(): CurrentService.WithRawResponse + + /** + * Returns a raw HTTP response for `delete /api/v1/api-key/{api_key_id}`, but is otherwise + * the same as [ApiKeyService.delete]. + */ + @MustBeClosed + fun delete(apiKeyId: String): HttpResponseFor<ApiKeyGetResponse> = + delete(apiKeyId, ApiKeyDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + apiKeyId: String, + params: ApiKeyDeleteParams = ApiKeyDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ApiKeyGetResponse> = + delete(params.toBuilder().apiKeyId(apiKeyId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + apiKeyId: String, + params: ApiKeyDeleteParams = ApiKeyDeleteParams.none(), + ): HttpResponseFor<ApiKeyGetResponse> = delete(apiKeyId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: ApiKeyDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ApiKeyGetResponse> + + /** @see delete */ + @MustBeClosed + fun delete(params: ApiKeyDeleteParams): HttpResponseFor<ApiKeyGetResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + apiKeyId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<ApiKeyGetResponse> = + delete(apiKeyId, ApiKeyDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/api-key`, but is otherwise the same as + * [ApiKeyService.apiKey]. + */ + @MustBeClosed + fun apiKey(): HttpResponseFor<ApiKeyCreateResponse> = apiKey(ApiKeyApiKeyParams.none()) + + /** @see apiKey */ + @MustBeClosed + fun apiKey( + params: ApiKeyApiKeyParams = ApiKeyApiKeyParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ApiKeyCreateResponse> + + /** @see apiKey */ + @MustBeClosed + fun apiKey( + params: ApiKeyApiKeyParams = ApiKeyApiKeyParams.none() + ): HttpResponseFor<ApiKeyCreateResponse> = apiKey(params, RequestOptions.none()) + + /** @see apiKey */ + @MustBeClosed + fun apiKey( + apiKeyCreateRequest: ApiKeyCreateRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ApiKeyCreateResponse> = + apiKey( + ApiKeyApiKeyParams.builder().apiKeyCreateRequest(apiKeyCreateRequest).build(), + requestOptions, + ) + + /** @see apiKey */ + @MustBeClosed + fun apiKey( + apiKeyCreateRequest: ApiKeyCreateRequest + ): HttpResponseFor<ApiKeyCreateResponse> = + apiKey(apiKeyCreateRequest, RequestOptions.none()) + + /** @see apiKey */ + @MustBeClosed + fun apiKey(requestOptions: RequestOptions): HttpResponseFor<ApiKeyCreateResponse> = + apiKey(ApiKeyApiKeyParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/api-key`, but is otherwise the same as + * [ApiKeyService.retrieveApiKey]. + */ + @MustBeClosed + fun retrieveApiKey(): HttpResponseFor<List<ApiKeyGetResponse>> = + retrieveApiKey(ApiKeyRetrieveApiKeyParams.none()) + + /** @see retrieveApiKey */ + @MustBeClosed + fun retrieveApiKey( + params: ApiKeyRetrieveApiKeyParams = ApiKeyRetrieveApiKeyParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<ApiKeyGetResponse>> + + /** @see retrieveApiKey */ + @MustBeClosed + fun retrieveApiKey( + params: ApiKeyRetrieveApiKeyParams = ApiKeyRetrieveApiKeyParams.none() + ): HttpResponseFor<List<ApiKeyGetResponse>> = retrieveApiKey(params, RequestOptions.none()) + + /** @see retrieveApiKey */ + @MustBeClosed + fun retrieveApiKey( + requestOptions: RequestOptions + ): HttpResponseFor<List<ApiKeyGetResponse>> = + retrieveApiKey(ApiKeyRetrieveApiKeyParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ApiKeyServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ApiKeyServiceImpl.kt new file mode 100644 index 00000000..73a4560f --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ApiKeyServiceImpl.kt @@ -0,0 +1,171 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.apikey.ApiKeyApiKeyParams +import com.langsmith_api.api.models.api.v1.apikey.ApiKeyDeleteParams +import com.langsmith_api.api.models.api.v1.apikey.ApiKeyRetrieveApiKeyParams +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyCreateResponse +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyGetResponse +import com.langsmith_api.api.services.blocking.api.v1.apikey.CurrentService +import com.langsmith_api.api.services.blocking.api.v1.apikey.CurrentServiceImpl +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ApiKeyServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ApiKeyService { + + private val withRawResponse: ApiKeyService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val current: CurrentService by lazy { CurrentServiceImpl(clientOptions) } + + override fun withRawResponse(): ApiKeyService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): ApiKeyService = + ApiKeyServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun current(): CurrentService = current + + override fun delete( + params: ApiKeyDeleteParams, + requestOptions: RequestOptions, + ): ApiKeyGetResponse = + // delete /api/v1/api-key/{api_key_id} + withRawResponse().delete(params, requestOptions).parse() + + override fun apiKey( + params: ApiKeyApiKeyParams, + requestOptions: RequestOptions, + ): ApiKeyCreateResponse = + // post /api/v1/api-key + withRawResponse().apiKey(params, requestOptions).parse() + + override fun retrieveApiKey( + params: ApiKeyRetrieveApiKeyParams, + requestOptions: RequestOptions, + ): List<ApiKeyGetResponse> = + // get /api/v1/api-key + withRawResponse().retrieveApiKey(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ApiKeyService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val current: CurrentService.WithRawResponse by lazy { + CurrentServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ApiKeyService.WithRawResponse = + ApiKeyServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun current(): CurrentService.WithRawResponse = current + + private val deleteHandler: Handler<ApiKeyGetResponse> = + jsonHandler<ApiKeyGetResponse>(clientOptions.jsonMapper) + + override fun delete( + params: ApiKeyDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<ApiKeyGetResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("apiKeyId", params.apiKeyId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "api-key", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val apiKeyHandler: Handler<ApiKeyCreateResponse> = + jsonHandler<ApiKeyCreateResponse>(clientOptions.jsonMapper) + + override fun apiKey( + params: ApiKeyApiKeyParams, + requestOptions: RequestOptions, + ): HttpResponseFor<ApiKeyCreateResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "api-key") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { apiKeyHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveApiKeyHandler: Handler<List<ApiKeyGetResponse>> = + jsonHandler<List<ApiKeyGetResponse>>(clientOptions.jsonMapper) + + override fun retrieveApiKey( + params: ApiKeyRetrieveApiKeyParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<ApiKeyGetResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "api-key") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveApiKeyHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/BulkExportService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/BulkExportService.kt new file mode 100644 index 00000000..1a73199e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/BulkExportService.kt @@ -0,0 +1,272 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.bulkexports.BulkExport +import com.langsmith_api.api.models.api.v1.bulkexports.BulkExportBulkExportsParams +import com.langsmith_api.api.models.api.v1.bulkexports.BulkExportRetrieveBulkExportsParams +import com.langsmith_api.api.models.api.v1.bulkexports.BulkExportRetrieveParams +import com.langsmith_api.api.models.api.v1.bulkexports.BulkExportUpdateParams +import com.langsmith_api.api.services.blocking.api.v1.bulkexports.DestinationService +import com.langsmith_api.api.services.blocking.api.v1.bulkexports.RunService +import java.util.function.Consumer + +interface BulkExportService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): BulkExportService + + fun destinations(): DestinationService + + fun runs(): RunService + + /** Get a single bulk export by ID */ + fun retrieve(bulkExportId: String): BulkExport = + retrieve(bulkExportId, BulkExportRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + bulkExportId: String, + params: BulkExportRetrieveParams = BulkExportRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): BulkExport = retrieve(params.toBuilder().bulkExportId(bulkExportId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + bulkExportId: String, + params: BulkExportRetrieveParams = BulkExportRetrieveParams.none(), + ): BulkExport = retrieve(bulkExportId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: BulkExportRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): BulkExport + + /** @see retrieve */ + fun retrieve(params: BulkExportRetrieveParams): BulkExport = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(bulkExportId: String, requestOptions: RequestOptions): BulkExport = + retrieve(bulkExportId, BulkExportRetrieveParams.none(), requestOptions) + + /** Cancel a bulk export by ID */ + fun update(bulkExportId: String): BulkExport = + update(bulkExportId, BulkExportUpdateParams.none()) + + /** @see update */ + fun update( + bulkExportId: String, + params: BulkExportUpdateParams = BulkExportUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): BulkExport = update(params.toBuilder().bulkExportId(bulkExportId).build(), requestOptions) + + /** @see update */ + fun update( + bulkExportId: String, + params: BulkExportUpdateParams = BulkExportUpdateParams.none(), + ): BulkExport = update(bulkExportId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: BulkExportUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): BulkExport + + /** @see update */ + fun update(params: BulkExportUpdateParams): BulkExport = update(params, RequestOptions.none()) + + /** @see update */ + fun update(bulkExportId: String, requestOptions: RequestOptions): BulkExport = + update(bulkExportId, BulkExportUpdateParams.none(), requestOptions) + + /** Create a new bulk export */ + fun bulkExports(params: BulkExportBulkExportsParams): BulkExport = + bulkExports(params, RequestOptions.none()) + + /** @see bulkExports */ + fun bulkExports( + params: BulkExportBulkExportsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): BulkExport + + /** Get the current workspace's bulk exports */ + fun retrieveBulkExports(): List<BulkExport> = + retrieveBulkExports(BulkExportRetrieveBulkExportsParams.none()) + + /** @see retrieveBulkExports */ + fun retrieveBulkExports( + params: BulkExportRetrieveBulkExportsParams = BulkExportRetrieveBulkExportsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<BulkExport> + + /** @see retrieveBulkExports */ + fun retrieveBulkExports( + params: BulkExportRetrieveBulkExportsParams = BulkExportRetrieveBulkExportsParams.none() + ): List<BulkExport> = retrieveBulkExports(params, RequestOptions.none()) + + /** @see retrieveBulkExports */ + fun retrieveBulkExports(requestOptions: RequestOptions): List<BulkExport> = + retrieveBulkExports(BulkExportRetrieveBulkExportsParams.none(), requestOptions) + + /** A view of [BulkExportService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): BulkExportService.WithRawResponse + + fun destinations(): DestinationService.WithRawResponse + + fun runs(): RunService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/bulk-exports/{bulk_export_id}`, but is + * otherwise the same as [BulkExportService.retrieve]. + */ + @MustBeClosed + fun retrieve(bulkExportId: String): HttpResponseFor<BulkExport> = + retrieve(bulkExportId, BulkExportRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + bulkExportId: String, + params: BulkExportRetrieveParams = BulkExportRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<BulkExport> = + retrieve(params.toBuilder().bulkExportId(bulkExportId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + bulkExportId: String, + params: BulkExportRetrieveParams = BulkExportRetrieveParams.none(), + ): HttpResponseFor<BulkExport> = retrieve(bulkExportId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: BulkExportRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<BulkExport> + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: BulkExportRetrieveParams): HttpResponseFor<BulkExport> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + bulkExportId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<BulkExport> = + retrieve(bulkExportId, BulkExportRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `patch /api/v1/bulk-exports/{bulk_export_id}`, but is + * otherwise the same as [BulkExportService.update]. + */ + @MustBeClosed + fun update(bulkExportId: String): HttpResponseFor<BulkExport> = + update(bulkExportId, BulkExportUpdateParams.none()) + + /** @see update */ + @MustBeClosed + fun update( + bulkExportId: String, + params: BulkExportUpdateParams = BulkExportUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<BulkExport> = + update(params.toBuilder().bulkExportId(bulkExportId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update( + bulkExportId: String, + params: BulkExportUpdateParams = BulkExportUpdateParams.none(), + ): HttpResponseFor<BulkExport> = update(bulkExportId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: BulkExportUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<BulkExport> + + /** @see update */ + @MustBeClosed + fun update(params: BulkExportUpdateParams): HttpResponseFor<BulkExport> = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + bulkExportId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<BulkExport> = + update(bulkExportId, BulkExportUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/bulk-exports`, but is otherwise the same as + * [BulkExportService.bulkExports]. + */ + @MustBeClosed + fun bulkExports(params: BulkExportBulkExportsParams): HttpResponseFor<BulkExport> = + bulkExports(params, RequestOptions.none()) + + /** @see bulkExports */ + @MustBeClosed + fun bulkExports( + params: BulkExportBulkExportsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<BulkExport> + + /** + * Returns a raw HTTP response for `get /api/v1/bulk-exports`, but is otherwise the same as + * [BulkExportService.retrieveBulkExports]. + */ + @MustBeClosed + fun retrieveBulkExports(): HttpResponseFor<List<BulkExport>> = + retrieveBulkExports(BulkExportRetrieveBulkExportsParams.none()) + + /** @see retrieveBulkExports */ + @MustBeClosed + fun retrieveBulkExports( + params: BulkExportRetrieveBulkExportsParams = + BulkExportRetrieveBulkExportsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<BulkExport>> + + /** @see retrieveBulkExports */ + @MustBeClosed + fun retrieveBulkExports( + params: BulkExportRetrieveBulkExportsParams = BulkExportRetrieveBulkExportsParams.none() + ): HttpResponseFor<List<BulkExport>> = retrieveBulkExports(params, RequestOptions.none()) + + /** @see retrieveBulkExports */ + @MustBeClosed + fun retrieveBulkExports(requestOptions: RequestOptions): HttpResponseFor<List<BulkExport>> = + retrieveBulkExports(BulkExportRetrieveBulkExportsParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/BulkExportServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/BulkExportServiceImpl.kt new file mode 100644 index 00000000..b2bcc2b3 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/BulkExportServiceImpl.kt @@ -0,0 +1,220 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.bulkexports.BulkExport +import com.langsmith_api.api.models.api.v1.bulkexports.BulkExportBulkExportsParams +import com.langsmith_api.api.models.api.v1.bulkexports.BulkExportRetrieveBulkExportsParams +import com.langsmith_api.api.models.api.v1.bulkexports.BulkExportRetrieveParams +import com.langsmith_api.api.models.api.v1.bulkexports.BulkExportUpdateParams +import com.langsmith_api.api.services.blocking.api.v1.bulkexports.DestinationService +import com.langsmith_api.api.services.blocking.api.v1.bulkexports.DestinationServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.bulkexports.RunService +import com.langsmith_api.api.services.blocking.api.v1.bulkexports.RunServiceImpl +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class BulkExportServiceImpl internal constructor(private val clientOptions: ClientOptions) : + BulkExportService { + + private val withRawResponse: BulkExportService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val destinations: DestinationService by lazy { DestinationServiceImpl(clientOptions) } + + private val runs: RunService by lazy { RunServiceImpl(clientOptions) } + + override fun withRawResponse(): BulkExportService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): BulkExportService = + BulkExportServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun destinations(): DestinationService = destinations + + override fun runs(): RunService = runs + + override fun retrieve( + params: BulkExportRetrieveParams, + requestOptions: RequestOptions, + ): BulkExport = + // get /api/v1/bulk-exports/{bulk_export_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update( + params: BulkExportUpdateParams, + requestOptions: RequestOptions, + ): BulkExport = + // patch /api/v1/bulk-exports/{bulk_export_id} + withRawResponse().update(params, requestOptions).parse() + + override fun bulkExports( + params: BulkExportBulkExportsParams, + requestOptions: RequestOptions, + ): BulkExport = + // post /api/v1/bulk-exports + withRawResponse().bulkExports(params, requestOptions).parse() + + override fun retrieveBulkExports( + params: BulkExportRetrieveBulkExportsParams, + requestOptions: RequestOptions, + ): List<BulkExport> = + // get /api/v1/bulk-exports + withRawResponse().retrieveBulkExports(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BulkExportService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val destinations: DestinationService.WithRawResponse by lazy { + DestinationServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val runs: RunService.WithRawResponse by lazy { + RunServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): BulkExportService.WithRawResponse = + BulkExportServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun destinations(): DestinationService.WithRawResponse = destinations + + override fun runs(): RunService.WithRawResponse = runs + + private val retrieveHandler: Handler<BulkExport> = + jsonHandler<BulkExport>(clientOptions.jsonMapper) + + override fun retrieve( + params: BulkExportRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor<BulkExport> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("bulkExportId", params.bulkExportId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "bulk-exports", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler<BulkExport> = + jsonHandler<BulkExport>(clientOptions.jsonMapper) + + override fun update( + params: BulkExportUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<BulkExport> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("bulkExportId", params.bulkExportId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "bulk-exports", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val bulkExportsHandler: Handler<BulkExport> = + jsonHandler<BulkExport>(clientOptions.jsonMapper) + + override fun bulkExports( + params: BulkExportBulkExportsParams, + requestOptions: RequestOptions, + ): HttpResponseFor<BulkExport> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "bulk-exports") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { bulkExportsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveBulkExportsHandler: Handler<List<BulkExport>> = + jsonHandler<List<BulkExport>>(clientOptions.jsonMapper) + + override fun retrieveBulkExports( + params: BulkExportRetrieveBulkExportsParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<BulkExport>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "bulk-exports") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveBulkExportsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ChartService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ChartService.kt new file mode 100644 index 00000000..912fec58 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ChartService.kt @@ -0,0 +1,292 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.charts.ChartCreateParams +import com.langsmith_api.api.models.api.v1.charts.ChartDeleteParams +import com.langsmith_api.api.models.api.v1.charts.ChartDeleteResponse +import com.langsmith_api.api.models.api.v1.charts.ChartPreviewParams +import com.langsmith_api.api.models.api.v1.charts.ChartUpdateParams +import com.langsmith_api.api.models.api.v1.charts.CustomChartCreate +import com.langsmith_api.api.models.api.v1.charts.CustomChartPreviewRequest +import com.langsmith_api.api.models.api.v1.charts.CustomChartResponse +import com.langsmith_api.api.models.api.v1.charts.SingleCustomChartResponseBase +import com.langsmith_api.api.services.blocking.api.v1.charts.SectionService +import java.util.function.Consumer + +interface ChartService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ChartService + + fun section(): SectionService + + /** Create a new chart. */ + fun create(params: ChartCreateParams): CustomChartResponse = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: ChartCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomChartResponse + + /** @see create */ + fun create( + customChartCreate: CustomChartCreate, + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomChartResponse = + create( + ChartCreateParams.builder().customChartCreate(customChartCreate).build(), + requestOptions, + ) + + /** @see create */ + fun create(customChartCreate: CustomChartCreate): CustomChartResponse = + create(customChartCreate, RequestOptions.none()) + + /** Update a chart. */ + fun update(chartId: String, params: ChartUpdateParams): CustomChartResponse = + update(chartId, params, RequestOptions.none()) + + /** @see update */ + fun update( + chartId: String, + params: ChartUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomChartResponse = update(params.toBuilder().chartId(chartId).build(), requestOptions) + + /** @see update */ + fun update(params: ChartUpdateParams): CustomChartResponse = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: ChartUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomChartResponse + + /** Delete a chart. */ + fun delete(chartId: String): ChartDeleteResponse = delete(chartId, ChartDeleteParams.none()) + + /** @see delete */ + fun delete( + chartId: String, + params: ChartDeleteParams = ChartDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ChartDeleteResponse = delete(params.toBuilder().chartId(chartId).build(), requestOptions) + + /** @see delete */ + fun delete( + chartId: String, + params: ChartDeleteParams = ChartDeleteParams.none(), + ): ChartDeleteResponse = delete(chartId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ChartDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ChartDeleteResponse + + /** @see delete */ + fun delete(params: ChartDeleteParams): ChartDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(chartId: String, requestOptions: RequestOptions): ChartDeleteResponse = + delete(chartId, ChartDeleteParams.none(), requestOptions) + + /** Get a preview for a chart without actually creating it. */ + fun preview(params: ChartPreviewParams): SingleCustomChartResponseBase = + preview(params, RequestOptions.none()) + + /** @see preview */ + fun preview( + params: ChartPreviewParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SingleCustomChartResponseBase + + /** @see preview */ + fun preview( + customChartPreviewRequest: CustomChartPreviewRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): SingleCustomChartResponseBase = + preview( + ChartPreviewParams.builder() + .customChartPreviewRequest(customChartPreviewRequest) + .build(), + requestOptions, + ) + + /** @see preview */ + fun preview( + customChartPreviewRequest: CustomChartPreviewRequest + ): SingleCustomChartResponseBase = preview(customChartPreviewRequest, RequestOptions.none()) + + /** A view of [ChartService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ChartService.WithRawResponse + + fun section(): SectionService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/charts/create`, but is otherwise the same + * as [ChartService.create]. + */ + @MustBeClosed + fun create(params: ChartCreateParams): HttpResponseFor<CustomChartResponse> = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: ChartCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CustomChartResponse> + + /** @see create */ + @MustBeClosed + fun create( + customChartCreate: CustomChartCreate, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CustomChartResponse> = + create( + ChartCreateParams.builder().customChartCreate(customChartCreate).build(), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create(customChartCreate: CustomChartCreate): HttpResponseFor<CustomChartResponse> = + create(customChartCreate, RequestOptions.none()) + + /** + * Returns a raw HTTP response for `patch /api/v1/charts/{chart_id}`, but is otherwise the + * same as [ChartService.update]. + */ + @MustBeClosed + fun update( + chartId: String, + params: ChartUpdateParams, + ): HttpResponseFor<CustomChartResponse> = update(chartId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + chartId: String, + params: ChartUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CustomChartResponse> = + update(params.toBuilder().chartId(chartId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(params: ChartUpdateParams): HttpResponseFor<CustomChartResponse> = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: ChartUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CustomChartResponse> + + /** + * Returns a raw HTTP response for `delete /api/v1/charts/{chart_id}`, but is otherwise the + * same as [ChartService.delete]. + */ + @MustBeClosed + fun delete(chartId: String): HttpResponseFor<ChartDeleteResponse> = + delete(chartId, ChartDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + chartId: String, + params: ChartDeleteParams = ChartDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ChartDeleteResponse> = + delete(params.toBuilder().chartId(chartId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + chartId: String, + params: ChartDeleteParams = ChartDeleteParams.none(), + ): HttpResponseFor<ChartDeleteResponse> = delete(chartId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: ChartDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ChartDeleteResponse> + + /** @see delete */ + @MustBeClosed + fun delete(params: ChartDeleteParams): HttpResponseFor<ChartDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + chartId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<ChartDeleteResponse> = + delete(chartId, ChartDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/charts/preview`, but is otherwise the same + * as [ChartService.preview]. + */ + @MustBeClosed + fun preview(params: ChartPreviewParams): HttpResponseFor<SingleCustomChartResponseBase> = + preview(params, RequestOptions.none()) + + /** @see preview */ + @MustBeClosed + fun preview( + params: ChartPreviewParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<SingleCustomChartResponseBase> + + /** @see preview */ + @MustBeClosed + fun preview( + customChartPreviewRequest: CustomChartPreviewRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<SingleCustomChartResponseBase> = + preview( + ChartPreviewParams.builder() + .customChartPreviewRequest(customChartPreviewRequest) + .build(), + requestOptions, + ) + + /** @see preview */ + @MustBeClosed + fun preview( + customChartPreviewRequest: CustomChartPreviewRequest + ): HttpResponseFor<SingleCustomChartResponseBase> = + preview(customChartPreviewRequest, RequestOptions.none()) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ChartServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ChartServiceImpl.kt new file mode 100644 index 00000000..eae021b7 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ChartServiceImpl.kt @@ -0,0 +1,212 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.charts.ChartCreateParams +import com.langsmith_api.api.models.api.v1.charts.ChartDeleteParams +import com.langsmith_api.api.models.api.v1.charts.ChartDeleteResponse +import com.langsmith_api.api.models.api.v1.charts.ChartPreviewParams +import com.langsmith_api.api.models.api.v1.charts.ChartUpdateParams +import com.langsmith_api.api.models.api.v1.charts.CustomChartResponse +import com.langsmith_api.api.models.api.v1.charts.SingleCustomChartResponseBase +import com.langsmith_api.api.services.blocking.api.v1.charts.SectionService +import com.langsmith_api.api.services.blocking.api.v1.charts.SectionServiceImpl +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ChartServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ChartService { + + private val withRawResponse: ChartService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val section: SectionService by lazy { SectionServiceImpl(clientOptions) } + + override fun withRawResponse(): ChartService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): ChartService = + ChartServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun section(): SectionService = section + + override fun create( + params: ChartCreateParams, + requestOptions: RequestOptions, + ): CustomChartResponse = + // post /api/v1/charts/create + withRawResponse().create(params, requestOptions).parse() + + override fun update( + params: ChartUpdateParams, + requestOptions: RequestOptions, + ): CustomChartResponse = + // patch /api/v1/charts/{chart_id} + withRawResponse().update(params, requestOptions).parse() + + override fun delete( + params: ChartDeleteParams, + requestOptions: RequestOptions, + ): ChartDeleteResponse = + // delete /api/v1/charts/{chart_id} + withRawResponse().delete(params, requestOptions).parse() + + override fun preview( + params: ChartPreviewParams, + requestOptions: RequestOptions, + ): SingleCustomChartResponseBase = + // post /api/v1/charts/preview + withRawResponse().preview(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ChartService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val section: SectionService.WithRawResponse by lazy { + SectionServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ChartService.WithRawResponse = + ChartServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun section(): SectionService.WithRawResponse = section + + private val createHandler: Handler<CustomChartResponse> = + jsonHandler<CustomChartResponse>(clientOptions.jsonMapper) + + override fun create( + params: ChartCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<CustomChartResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "charts", "create") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler<CustomChartResponse> = + jsonHandler<CustomChartResponse>(clientOptions.jsonMapper) + + override fun update( + params: ChartUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<CustomChartResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("chartId", params.chartId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "charts", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val deleteHandler: Handler<ChartDeleteResponse> = + jsonHandler<ChartDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: ChartDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<ChartDeleteResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("chartId", params.chartId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "charts", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val previewHandler: Handler<SingleCustomChartResponseBase> = + jsonHandler<SingleCustomChartResponseBase>(clientOptions.jsonMapper) + + override fun preview( + params: ChartPreviewParams, + requestOptions: RequestOptions, + ): HttpResponseFor<SingleCustomChartResponseBase> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "charts", "preview") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { previewHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/CommentService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/CommentService.kt new file mode 100644 index 00000000..74303bb2 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/CommentService.kt @@ -0,0 +1,149 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.comments.Comment +import com.langsmith_api.api.models.api.v1.comments.CommentRetrieveParams +import com.langsmith_api.api.models.api.v1.comments.CommentUpdateParams +import com.langsmith_api.api.models.api.v1.comments.ListCommentsResponse +import com.langsmith_api.api.services.blocking.api.v1.comments.LikeService +import java.util.function.Consumer + +interface CommentService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): CommentService + + fun like(): LikeService + + /** Get Sub Comments */ + fun retrieve(parentCommentId: String, params: CommentRetrieveParams): ListCommentsResponse = + retrieve(parentCommentId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + parentCommentId: String, + params: CommentRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ListCommentsResponse = + retrieve(params.toBuilder().parentCommentId(parentCommentId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: CommentRetrieveParams): ListCommentsResponse = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: CommentRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ListCommentsResponse + + /** Create Sub Comment */ + fun update(parentCommentId: String, params: CommentUpdateParams): Comment = + update(parentCommentId, params, RequestOptions.none()) + + /** @see update */ + fun update( + parentCommentId: String, + params: CommentUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Comment = update(params.toBuilder().parentCommentId(parentCommentId).build(), requestOptions) + + /** @see update */ + fun update(params: CommentUpdateParams): Comment = update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: CommentUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Comment + + /** A view of [CommentService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): CommentService.WithRawResponse + + fun like(): LikeService.WithRawResponse + + /** + * Returns a raw HTTP response for `get + * /api/v1/comments/{owner}/{repo}/{parent_comment_id}`, but is otherwise the same as + * [CommentService.retrieve]. + */ + @MustBeClosed + fun retrieve( + parentCommentId: String, + params: CommentRetrieveParams, + ): HttpResponseFor<ListCommentsResponse> = + retrieve(parentCommentId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + parentCommentId: String, + params: CommentRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ListCommentsResponse> = + retrieve(params.toBuilder().parentCommentId(parentCommentId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: CommentRetrieveParams): HttpResponseFor<ListCommentsResponse> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: CommentRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ListCommentsResponse> + + /** + * Returns a raw HTTP response for `post + * /api/v1/comments/{owner}/{repo}/{parent_comment_id}`, but is otherwise the same as + * [CommentService.update]. + */ + @MustBeClosed + fun update(parentCommentId: String, params: CommentUpdateParams): HttpResponseFor<Comment> = + update(parentCommentId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + parentCommentId: String, + params: CommentUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<Comment> = + update(params.toBuilder().parentCommentId(parentCommentId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(params: CommentUpdateParams): HttpResponseFor<Comment> = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: CommentUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<Comment> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/CommentServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/CommentServiceImpl.kt new file mode 100644 index 00000000..23969a8b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/CommentServiceImpl.kt @@ -0,0 +1,148 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.comments.Comment +import com.langsmith_api.api.models.api.v1.comments.CommentRetrieveParams +import com.langsmith_api.api.models.api.v1.comments.CommentUpdateParams +import com.langsmith_api.api.models.api.v1.comments.ListCommentsResponse +import com.langsmith_api.api.services.blocking.api.v1.comments.LikeService +import com.langsmith_api.api.services.blocking.api.v1.comments.LikeServiceImpl +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class CommentServiceImpl internal constructor(private val clientOptions: ClientOptions) : + CommentService { + + private val withRawResponse: CommentService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val like: LikeService by lazy { LikeServiceImpl(clientOptions) } + + override fun withRawResponse(): CommentService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): CommentService = + CommentServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun like(): LikeService = like + + override fun retrieve( + params: CommentRetrieveParams, + requestOptions: RequestOptions, + ): ListCommentsResponse = + // get /api/v1/comments/{owner}/{repo}/{parent_comment_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update(params: CommentUpdateParams, requestOptions: RequestOptions): Comment = + // post /api/v1/comments/{owner}/{repo}/{parent_comment_id} + withRawResponse().update(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CommentService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val like: LikeService.WithRawResponse by lazy { + LikeServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): CommentService.WithRawResponse = + CommentServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun like(): LikeService.WithRawResponse = like + + private val retrieveHandler: Handler<ListCommentsResponse> = + jsonHandler<ListCommentsResponse>(clientOptions.jsonMapper) + + override fun retrieve( + params: CommentRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor<ListCommentsResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("parentCommentId", params.parentCommentId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "comments", + params._pathParam(0), + params._pathParam(1), + params._pathParam(2), + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler<Comment> = jsonHandler<Comment>(clientOptions.jsonMapper) + + override fun update( + params: CommentUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<Comment> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("parentCommentId", params.parentCommentId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "comments", + params._pathParam(0), + params._pathParam(1), + params._pathParam(2), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/CommitService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/CommitService.kt new file mode 100644 index 00000000..338c55a9 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/CommitService.kt @@ -0,0 +1,143 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.commits.CommitManifestResponse +import com.langsmith_api.api.models.api.v1.commits.CommitRetrieveParams +import com.langsmith_api.api.models.api.v1.commits.CommitUpdateParams +import com.langsmith_api.api.models.api.v1.commits.CommitUpdateResponse +import java.util.function.Consumer + +interface CommitService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): CommitService + + /** Download a repo. */ + fun retrieve(commit: String, params: CommitRetrieveParams): CommitManifestResponse = + retrieve(commit, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + commit: String, + params: CommitRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CommitManifestResponse = retrieve(params.toBuilder().commit(commit).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: CommitRetrieveParams): CommitManifestResponse = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: CommitRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CommitManifestResponse + + /** Upload a repo. */ + fun update(repo: String, params: CommitUpdateParams): CommitUpdateResponse = + update(repo, params, RequestOptions.none()) + + /** @see update */ + fun update( + repo: String, + params: CommitUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CommitUpdateResponse = update(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see update */ + fun update(params: CommitUpdateParams): CommitUpdateResponse = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: CommitUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CommitUpdateResponse + + /** A view of [CommitService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): CommitService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/commits/{owner}/{repo}/{commit}`, but is + * otherwise the same as [CommitService.retrieve]. + */ + @MustBeClosed + fun retrieve( + commit: String, + params: CommitRetrieveParams, + ): HttpResponseFor<CommitManifestResponse> = retrieve(commit, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + commit: String, + params: CommitRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CommitManifestResponse> = + retrieve(params.toBuilder().commit(commit).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: CommitRetrieveParams): HttpResponseFor<CommitManifestResponse> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: CommitRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CommitManifestResponse> + + /** + * Returns a raw HTTP response for `post /api/v1/commits/{owner}/{repo}`, but is otherwise + * the same as [CommitService.update]. + */ + @MustBeClosed + fun update( + repo: String, + params: CommitUpdateParams, + ): HttpResponseFor<CommitUpdateResponse> = update(repo, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + repo: String, + params: CommitUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CommitUpdateResponse> = + update(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(params: CommitUpdateParams): HttpResponseFor<CommitUpdateResponse> = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: CommitUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CommitUpdateResponse> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/CommitServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/CommitServiceImpl.kt new file mode 100644 index 00000000..cb95d844 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/CommitServiceImpl.kt @@ -0,0 +1,139 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.commits.CommitManifestResponse +import com.langsmith_api.api.models.api.v1.commits.CommitRetrieveParams +import com.langsmith_api.api.models.api.v1.commits.CommitUpdateParams +import com.langsmith_api.api.models.api.v1.commits.CommitUpdateResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class CommitServiceImpl internal constructor(private val clientOptions: ClientOptions) : + CommitService { + + private val withRawResponse: CommitService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): CommitService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): CommitService = + CommitServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: CommitRetrieveParams, + requestOptions: RequestOptions, + ): CommitManifestResponse = + // get /api/v1/commits/{owner}/{repo}/{commit} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update( + params: CommitUpdateParams, + requestOptions: RequestOptions, + ): CommitUpdateResponse = + // post /api/v1/commits/{owner}/{repo} + withRawResponse().update(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CommitService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): CommitService.WithRawResponse = + CommitServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler<CommitManifestResponse> = + jsonHandler<CommitManifestResponse>(clientOptions.jsonMapper) + + override fun retrieve( + params: CommitRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor<CommitManifestResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("commit", params.commit().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "commits", + params._pathParam(0), + params._pathParam(1), + params._pathParam(2), + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler<CommitUpdateResponse> = + jsonHandler<CommitUpdateResponse>(clientOptions.jsonMapper) + + override fun update( + params: CommitUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<CommitUpdateResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("repo", params.repo().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "commits", + params._pathParam(0), + params._pathParam(1), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/DatasetService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/DatasetService.kt new file mode 100644 index 00000000..20d4f24f --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/DatasetService.kt @@ -0,0 +1,1060 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.datasets.Dataset +import com.langsmith_api.api.models.api.v1.datasets.DatasetCloneParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetCloneResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetCreateParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetDeleteParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetDeleteResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetGenerateParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetGenerateResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetListParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveCsvParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveCsvResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveJsonlParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveJsonlResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveOpenAIFtParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveOpenAIFtResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveOpenAIParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveOpenAIResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveVersionParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetSearchParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetSearchResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetStudioExperimentParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetStudioExperimentResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetUpdateParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetUpdateResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetUpdateTagsParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetUploadExperimentParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetUploadExperimentResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetUploadParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetVersion +import com.langsmith_api.api.services.blocking.api.v1.datasets.ComparativeService +import com.langsmith_api.api.services.blocking.api.v1.datasets.ExperimentService +import com.langsmith_api.api.services.blocking.api.v1.datasets.GroupService +import com.langsmith_api.api.services.blocking.api.v1.datasets.IndexService +import com.langsmith_api.api.services.blocking.api.v1.datasets.PlaygroundExperimentService +import com.langsmith_api.api.services.blocking.api.v1.datasets.RunService +import com.langsmith_api.api.services.blocking.api.v1.datasets.ShareService +import com.langsmith_api.api.services.blocking.api.v1.datasets.SplitService +import com.langsmith_api.api.services.blocking.api.v1.datasets.VersionService +import java.util.function.Consumer + +interface DatasetService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): DatasetService + + fun versions(): VersionService + + fun runs(): RunService + + fun group(): GroupService + + fun experiments(): ExperimentService + + fun share(): ShareService + + fun comparative(): ComparativeService + + fun splits(): SplitService + + fun index(): IndexService + + fun playgroundExperiment(): PlaygroundExperimentService + + /** Create a new dataset. */ + fun create(params: DatasetCreateParams): Dataset = create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: DatasetCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Dataset + + /** Get a specific dataset. */ + fun retrieve(datasetId: String): Dataset = retrieve(datasetId, DatasetRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + datasetId: String, + params: DatasetRetrieveParams = DatasetRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Dataset = retrieve(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + datasetId: String, + params: DatasetRetrieveParams = DatasetRetrieveParams.none(), + ): Dataset = retrieve(datasetId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: DatasetRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Dataset + + /** @see retrieve */ + fun retrieve(params: DatasetRetrieveParams): Dataset = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(datasetId: String, requestOptions: RequestOptions): Dataset = + retrieve(datasetId, DatasetRetrieveParams.none(), requestOptions) + + /** Update a specific dataset. */ + fun update(datasetId: String): DatasetUpdateResponse = + update(datasetId, DatasetUpdateParams.none()) + + /** @see update */ + fun update( + datasetId: String, + params: DatasetUpdateParams = DatasetUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): DatasetUpdateResponse = + update(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see update */ + fun update( + datasetId: String, + params: DatasetUpdateParams = DatasetUpdateParams.none(), + ): DatasetUpdateResponse = update(datasetId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: DatasetUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): DatasetUpdateResponse + + /** @see update */ + fun update(params: DatasetUpdateParams): DatasetUpdateResponse = + update(params, RequestOptions.none()) + + /** @see update */ + fun update(datasetId: String, requestOptions: RequestOptions): DatasetUpdateResponse = + update(datasetId, DatasetUpdateParams.none(), requestOptions) + + /** Get all datasets by query params and owner. */ + fun list(): List<Dataset> = list(DatasetListParams.none()) + + /** @see list */ + fun list( + params: DatasetListParams = DatasetListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<Dataset> + + /** @see list */ + fun list(params: DatasetListParams = DatasetListParams.none()): List<Dataset> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): List<Dataset> = + list(DatasetListParams.none(), requestOptions) + + /** Delete a specific dataset. */ + fun delete(datasetId: String): DatasetDeleteResponse = + delete(datasetId, DatasetDeleteParams.none()) + + /** @see delete */ + fun delete( + datasetId: String, + params: DatasetDeleteParams = DatasetDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): DatasetDeleteResponse = + delete(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see delete */ + fun delete( + datasetId: String, + params: DatasetDeleteParams = DatasetDeleteParams.none(), + ): DatasetDeleteResponse = delete(datasetId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: DatasetDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): DatasetDeleteResponse + + /** @see delete */ + fun delete(params: DatasetDeleteParams): DatasetDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(datasetId: String, requestOptions: RequestOptions): DatasetDeleteResponse = + delete(datasetId, DatasetDeleteParams.none(), requestOptions) + + /** Clone a dataset. */ + fun clone(params: DatasetCloneParams): List<DatasetCloneResponse> = + clone(params, RequestOptions.none()) + + /** @see clone */ + fun clone( + params: DatasetCloneParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List<DatasetCloneResponse> + + /** Generate synthetic examples for a dataset. */ + fun generate(datasetId: String, params: DatasetGenerateParams): DatasetGenerateResponse = + generate(datasetId, params, RequestOptions.none()) + + /** @see generate */ + fun generate( + datasetId: String, + params: DatasetGenerateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): DatasetGenerateResponse = + generate(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see generate */ + fun generate(params: DatasetGenerateParams): DatasetGenerateResponse = + generate(params, RequestOptions.none()) + + /** @see generate */ + fun generate( + params: DatasetGenerateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): DatasetGenerateResponse + + /** Download a dataset as CSV format. */ + fun retrieveCsv(datasetId: String): DatasetRetrieveCsvResponse = + retrieveCsv(datasetId, DatasetRetrieveCsvParams.none()) + + /** @see retrieveCsv */ + fun retrieveCsv( + datasetId: String, + params: DatasetRetrieveCsvParams = DatasetRetrieveCsvParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): DatasetRetrieveCsvResponse = + retrieveCsv(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see retrieveCsv */ + fun retrieveCsv( + datasetId: String, + params: DatasetRetrieveCsvParams = DatasetRetrieveCsvParams.none(), + ): DatasetRetrieveCsvResponse = retrieveCsv(datasetId, params, RequestOptions.none()) + + /** @see retrieveCsv */ + fun retrieveCsv( + params: DatasetRetrieveCsvParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): DatasetRetrieveCsvResponse + + /** @see retrieveCsv */ + fun retrieveCsv(params: DatasetRetrieveCsvParams): DatasetRetrieveCsvResponse = + retrieveCsv(params, RequestOptions.none()) + + /** @see retrieveCsv */ + fun retrieveCsv(datasetId: String, requestOptions: RequestOptions): DatasetRetrieveCsvResponse = + retrieveCsv(datasetId, DatasetRetrieveCsvParams.none(), requestOptions) + + /** Download a dataset as CSV format. */ + fun retrieveJsonl(datasetId: String): DatasetRetrieveJsonlResponse = + retrieveJsonl(datasetId, DatasetRetrieveJsonlParams.none()) + + /** @see retrieveJsonl */ + fun retrieveJsonl( + datasetId: String, + params: DatasetRetrieveJsonlParams = DatasetRetrieveJsonlParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): DatasetRetrieveJsonlResponse = + retrieveJsonl(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see retrieveJsonl */ + fun retrieveJsonl( + datasetId: String, + params: DatasetRetrieveJsonlParams = DatasetRetrieveJsonlParams.none(), + ): DatasetRetrieveJsonlResponse = retrieveJsonl(datasetId, params, RequestOptions.none()) + + /** @see retrieveJsonl */ + fun retrieveJsonl( + params: DatasetRetrieveJsonlParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): DatasetRetrieveJsonlResponse + + /** @see retrieveJsonl */ + fun retrieveJsonl(params: DatasetRetrieveJsonlParams): DatasetRetrieveJsonlResponse = + retrieveJsonl(params, RequestOptions.none()) + + /** @see retrieveJsonl */ + fun retrieveJsonl( + datasetId: String, + requestOptions: RequestOptions, + ): DatasetRetrieveJsonlResponse = + retrieveJsonl(datasetId, DatasetRetrieveJsonlParams.none(), requestOptions) + + /** Download a dataset as OpenAI Evals Jsonl format. */ + fun retrieveOpenAI(datasetId: String): DatasetRetrieveOpenAIResponse = + retrieveOpenAI(datasetId, DatasetRetrieveOpenAIParams.none()) + + /** @see retrieveOpenAI */ + fun retrieveOpenAI( + datasetId: String, + params: DatasetRetrieveOpenAIParams = DatasetRetrieveOpenAIParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): DatasetRetrieveOpenAIResponse = + retrieveOpenAI(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see retrieveOpenAI */ + fun retrieveOpenAI( + datasetId: String, + params: DatasetRetrieveOpenAIParams = DatasetRetrieveOpenAIParams.none(), + ): DatasetRetrieveOpenAIResponse = retrieveOpenAI(datasetId, params, RequestOptions.none()) + + /** @see retrieveOpenAI */ + fun retrieveOpenAI( + params: DatasetRetrieveOpenAIParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): DatasetRetrieveOpenAIResponse + + /** @see retrieveOpenAI */ + fun retrieveOpenAI(params: DatasetRetrieveOpenAIParams): DatasetRetrieveOpenAIResponse = + retrieveOpenAI(params, RequestOptions.none()) + + /** @see retrieveOpenAI */ + fun retrieveOpenAI( + datasetId: String, + requestOptions: RequestOptions, + ): DatasetRetrieveOpenAIResponse = + retrieveOpenAI(datasetId, DatasetRetrieveOpenAIParams.none(), requestOptions) + + /** Download a dataset as OpenAI Jsonl format. */ + fun retrieveOpenAIFt(datasetId: String): DatasetRetrieveOpenAIFtResponse = + retrieveOpenAIFt(datasetId, DatasetRetrieveOpenAIFtParams.none()) + + /** @see retrieveOpenAIFt */ + fun retrieveOpenAIFt( + datasetId: String, + params: DatasetRetrieveOpenAIFtParams = DatasetRetrieveOpenAIFtParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): DatasetRetrieveOpenAIFtResponse = + retrieveOpenAIFt(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see retrieveOpenAIFt */ + fun retrieveOpenAIFt( + datasetId: String, + params: DatasetRetrieveOpenAIFtParams = DatasetRetrieveOpenAIFtParams.none(), + ): DatasetRetrieveOpenAIFtResponse = retrieveOpenAIFt(datasetId, params, RequestOptions.none()) + + /** @see retrieveOpenAIFt */ + fun retrieveOpenAIFt( + params: DatasetRetrieveOpenAIFtParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): DatasetRetrieveOpenAIFtResponse + + /** @see retrieveOpenAIFt */ + fun retrieveOpenAIFt(params: DatasetRetrieveOpenAIFtParams): DatasetRetrieveOpenAIFtResponse = + retrieveOpenAIFt(params, RequestOptions.none()) + + /** @see retrieveOpenAIFt */ + fun retrieveOpenAIFt( + datasetId: String, + requestOptions: RequestOptions, + ): DatasetRetrieveOpenAIFtResponse = + retrieveOpenAIFt(datasetId, DatasetRetrieveOpenAIFtParams.none(), requestOptions) + + /** Get dataset version by as_of or exact tag. */ + fun retrieveVersion(datasetId: String): DatasetVersion = + retrieveVersion(datasetId, DatasetRetrieveVersionParams.none()) + + /** @see retrieveVersion */ + fun retrieveVersion( + datasetId: String, + params: DatasetRetrieveVersionParams = DatasetRetrieveVersionParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): DatasetVersion = + retrieveVersion(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see retrieveVersion */ + fun retrieveVersion( + datasetId: String, + params: DatasetRetrieveVersionParams = DatasetRetrieveVersionParams.none(), + ): DatasetVersion = retrieveVersion(datasetId, params, RequestOptions.none()) + + /** @see retrieveVersion */ + fun retrieveVersion( + params: DatasetRetrieveVersionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): DatasetVersion + + /** @see retrieveVersion */ + fun retrieveVersion(params: DatasetRetrieveVersionParams): DatasetVersion = + retrieveVersion(params, RequestOptions.none()) + + /** @see retrieveVersion */ + fun retrieveVersion(datasetId: String, requestOptions: RequestOptions): DatasetVersion = + retrieveVersion(datasetId, DatasetRetrieveVersionParams.none(), requestOptions) + + /** Search a dataset. */ + fun search(datasetId: String, params: DatasetSearchParams): DatasetSearchResponse = + search(datasetId, params, RequestOptions.none()) + + /** @see search */ + fun search( + datasetId: String, + params: DatasetSearchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): DatasetSearchResponse = + search(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see search */ + fun search(params: DatasetSearchParams): DatasetSearchResponse = + search(params, RequestOptions.none()) + + /** @see search */ + fun search( + params: DatasetSearchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): DatasetSearchResponse + + /** Studio Experiment */ + fun studioExperiment(params: DatasetStudioExperimentParams): DatasetStudioExperimentResponse = + studioExperiment(params, RequestOptions.none()) + + /** @see studioExperiment */ + fun studioExperiment( + params: DatasetStudioExperimentParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): DatasetStudioExperimentResponse + + /** Set a tag on a dataset version. */ + fun updateTags(datasetId: String, params: DatasetUpdateTagsParams): DatasetVersion = + updateTags(datasetId, params, RequestOptions.none()) + + /** @see updateTags */ + fun updateTags( + datasetId: String, + params: DatasetUpdateTagsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): DatasetVersion = updateTags(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see updateTags */ + fun updateTags(params: DatasetUpdateTagsParams): DatasetVersion = + updateTags(params, RequestOptions.none()) + + /** @see updateTags */ + fun updateTags( + params: DatasetUpdateTagsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): DatasetVersion + + /** Create a new dataset from a CSV file. */ + fun upload(params: DatasetUploadParams): Dataset = upload(params, RequestOptions.none()) + + /** @see upload */ + fun upload( + params: DatasetUploadParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Dataset + + /** Upload an experiment that has already been run. */ + fun uploadExperiment(params: DatasetUploadExperimentParams): DatasetUploadExperimentResponse = + uploadExperiment(params, RequestOptions.none()) + + /** @see uploadExperiment */ + fun uploadExperiment( + params: DatasetUploadExperimentParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): DatasetUploadExperimentResponse + + /** A view of [DatasetService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): DatasetService.WithRawResponse + + fun versions(): VersionService.WithRawResponse + + fun runs(): RunService.WithRawResponse + + fun group(): GroupService.WithRawResponse + + fun experiments(): ExperimentService.WithRawResponse + + fun share(): ShareService.WithRawResponse + + fun comparative(): ComparativeService.WithRawResponse + + fun splits(): SplitService.WithRawResponse + + fun index(): IndexService.WithRawResponse + + fun playgroundExperiment(): PlaygroundExperimentService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/datasets`, but is otherwise the same as + * [DatasetService.create]. + */ + @MustBeClosed + fun create(params: DatasetCreateParams): HttpResponseFor<Dataset> = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: DatasetCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<Dataset> + + /** + * Returns a raw HTTP response for `get /api/v1/datasets/{dataset_id}`, but is otherwise the + * same as [DatasetService.retrieve]. + */ + @MustBeClosed + fun retrieve(datasetId: String): HttpResponseFor<Dataset> = + retrieve(datasetId, DatasetRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + datasetId: String, + params: DatasetRetrieveParams = DatasetRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<Dataset> = + retrieve(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + datasetId: String, + params: DatasetRetrieveParams = DatasetRetrieveParams.none(), + ): HttpResponseFor<Dataset> = retrieve(datasetId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: DatasetRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<Dataset> + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: DatasetRetrieveParams): HttpResponseFor<Dataset> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve(datasetId: String, requestOptions: RequestOptions): HttpResponseFor<Dataset> = + retrieve(datasetId, DatasetRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `patch /api/v1/datasets/{dataset_id}`, but is otherwise + * the same as [DatasetService.update]. + */ + @MustBeClosed + fun update(datasetId: String): HttpResponseFor<DatasetUpdateResponse> = + update(datasetId, DatasetUpdateParams.none()) + + /** @see update */ + @MustBeClosed + fun update( + datasetId: String, + params: DatasetUpdateParams = DatasetUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<DatasetUpdateResponse> = + update(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update( + datasetId: String, + params: DatasetUpdateParams = DatasetUpdateParams.none(), + ): HttpResponseFor<DatasetUpdateResponse> = update(datasetId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: DatasetUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<DatasetUpdateResponse> + + /** @see update */ + @MustBeClosed + fun update(params: DatasetUpdateParams): HttpResponseFor<DatasetUpdateResponse> = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + datasetId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<DatasetUpdateResponse> = + update(datasetId, DatasetUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/datasets`, but is otherwise the same as + * [DatasetService.list]. + */ + @MustBeClosed fun list(): HttpResponseFor<List<Dataset>> = list(DatasetListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: DatasetListParams = DatasetListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<Dataset>> + + /** @see list */ + @MustBeClosed + fun list( + params: DatasetListParams = DatasetListParams.none() + ): HttpResponseFor<List<Dataset>> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor<List<Dataset>> = + list(DatasetListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/datasets/{dataset_id}`, but is otherwise + * the same as [DatasetService.delete]. + */ + @MustBeClosed + fun delete(datasetId: String): HttpResponseFor<DatasetDeleteResponse> = + delete(datasetId, DatasetDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + datasetId: String, + params: DatasetDeleteParams = DatasetDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<DatasetDeleteResponse> = + delete(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + datasetId: String, + params: DatasetDeleteParams = DatasetDeleteParams.none(), + ): HttpResponseFor<DatasetDeleteResponse> = delete(datasetId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: DatasetDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<DatasetDeleteResponse> + + /** @see delete */ + @MustBeClosed + fun delete(params: DatasetDeleteParams): HttpResponseFor<DatasetDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + datasetId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<DatasetDeleteResponse> = + delete(datasetId, DatasetDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/datasets/clone`, but is otherwise the same + * as [DatasetService.clone]. + */ + @MustBeClosed + fun clone(params: DatasetCloneParams): HttpResponseFor<List<DatasetCloneResponse>> = + clone(params, RequestOptions.none()) + + /** @see clone */ + @MustBeClosed + fun clone( + params: DatasetCloneParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<DatasetCloneResponse>> + + /** + * Returns a raw HTTP response for `post /api/v1/datasets/{dataset_id}/generate`, but is + * otherwise the same as [DatasetService.generate]. + */ + @MustBeClosed + fun generate( + datasetId: String, + params: DatasetGenerateParams, + ): HttpResponseFor<DatasetGenerateResponse> = + generate(datasetId, params, RequestOptions.none()) + + /** @see generate */ + @MustBeClosed + fun generate( + datasetId: String, + params: DatasetGenerateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<DatasetGenerateResponse> = + generate(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see generate */ + @MustBeClosed + fun generate(params: DatasetGenerateParams): HttpResponseFor<DatasetGenerateResponse> = + generate(params, RequestOptions.none()) + + /** @see generate */ + @MustBeClosed + fun generate( + params: DatasetGenerateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<DatasetGenerateResponse> + + /** + * Returns a raw HTTP response for `get /api/v1/datasets/{dataset_id}/csv`, but is otherwise + * the same as [DatasetService.retrieveCsv]. + */ + @MustBeClosed + fun retrieveCsv(datasetId: String): HttpResponseFor<DatasetRetrieveCsvResponse> = + retrieveCsv(datasetId, DatasetRetrieveCsvParams.none()) + + /** @see retrieveCsv */ + @MustBeClosed + fun retrieveCsv( + datasetId: String, + params: DatasetRetrieveCsvParams = DatasetRetrieveCsvParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<DatasetRetrieveCsvResponse> = + retrieveCsv(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see retrieveCsv */ + @MustBeClosed + fun retrieveCsv( + datasetId: String, + params: DatasetRetrieveCsvParams = DatasetRetrieveCsvParams.none(), + ): HttpResponseFor<DatasetRetrieveCsvResponse> = + retrieveCsv(datasetId, params, RequestOptions.none()) + + /** @see retrieveCsv */ + @MustBeClosed + fun retrieveCsv( + params: DatasetRetrieveCsvParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<DatasetRetrieveCsvResponse> + + /** @see retrieveCsv */ + @MustBeClosed + fun retrieveCsv( + params: DatasetRetrieveCsvParams + ): HttpResponseFor<DatasetRetrieveCsvResponse> = retrieveCsv(params, RequestOptions.none()) + + /** @see retrieveCsv */ + @MustBeClosed + fun retrieveCsv( + datasetId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<DatasetRetrieveCsvResponse> = + retrieveCsv(datasetId, DatasetRetrieveCsvParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/datasets/{dataset_id}/jsonl`, but is + * otherwise the same as [DatasetService.retrieveJsonl]. + */ + @MustBeClosed + fun retrieveJsonl(datasetId: String): HttpResponseFor<DatasetRetrieveJsonlResponse> = + retrieveJsonl(datasetId, DatasetRetrieveJsonlParams.none()) + + /** @see retrieveJsonl */ + @MustBeClosed + fun retrieveJsonl( + datasetId: String, + params: DatasetRetrieveJsonlParams = DatasetRetrieveJsonlParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<DatasetRetrieveJsonlResponse> = + retrieveJsonl(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see retrieveJsonl */ + @MustBeClosed + fun retrieveJsonl( + datasetId: String, + params: DatasetRetrieveJsonlParams = DatasetRetrieveJsonlParams.none(), + ): HttpResponseFor<DatasetRetrieveJsonlResponse> = + retrieveJsonl(datasetId, params, RequestOptions.none()) + + /** @see retrieveJsonl */ + @MustBeClosed + fun retrieveJsonl( + params: DatasetRetrieveJsonlParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<DatasetRetrieveJsonlResponse> + + /** @see retrieveJsonl */ + @MustBeClosed + fun retrieveJsonl( + params: DatasetRetrieveJsonlParams + ): HttpResponseFor<DatasetRetrieveJsonlResponse> = + retrieveJsonl(params, RequestOptions.none()) + + /** @see retrieveJsonl */ + @MustBeClosed + fun retrieveJsonl( + datasetId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<DatasetRetrieveJsonlResponse> = + retrieveJsonl(datasetId, DatasetRetrieveJsonlParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/datasets/{dataset_id}/openai`, but is + * otherwise the same as [DatasetService.retrieveOpenAI]. + */ + @MustBeClosed + fun retrieveOpenAI(datasetId: String): HttpResponseFor<DatasetRetrieveOpenAIResponse> = + retrieveOpenAI(datasetId, DatasetRetrieveOpenAIParams.none()) + + /** @see retrieveOpenAI */ + @MustBeClosed + fun retrieveOpenAI( + datasetId: String, + params: DatasetRetrieveOpenAIParams = DatasetRetrieveOpenAIParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<DatasetRetrieveOpenAIResponse> = + retrieveOpenAI(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see retrieveOpenAI */ + @MustBeClosed + fun retrieveOpenAI( + datasetId: String, + params: DatasetRetrieveOpenAIParams = DatasetRetrieveOpenAIParams.none(), + ): HttpResponseFor<DatasetRetrieveOpenAIResponse> = + retrieveOpenAI(datasetId, params, RequestOptions.none()) + + /** @see retrieveOpenAI */ + @MustBeClosed + fun retrieveOpenAI( + params: DatasetRetrieveOpenAIParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<DatasetRetrieveOpenAIResponse> + + /** @see retrieveOpenAI */ + @MustBeClosed + fun retrieveOpenAI( + params: DatasetRetrieveOpenAIParams + ): HttpResponseFor<DatasetRetrieveOpenAIResponse> = + retrieveOpenAI(params, RequestOptions.none()) + + /** @see retrieveOpenAI */ + @MustBeClosed + fun retrieveOpenAI( + datasetId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<DatasetRetrieveOpenAIResponse> = + retrieveOpenAI(datasetId, DatasetRetrieveOpenAIParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/datasets/{dataset_id}/openai_ft`, but is + * otherwise the same as [DatasetService.retrieveOpenAIFt]. + */ + @MustBeClosed + fun retrieveOpenAIFt(datasetId: String): HttpResponseFor<DatasetRetrieveOpenAIFtResponse> = + retrieveOpenAIFt(datasetId, DatasetRetrieveOpenAIFtParams.none()) + + /** @see retrieveOpenAIFt */ + @MustBeClosed + fun retrieveOpenAIFt( + datasetId: String, + params: DatasetRetrieveOpenAIFtParams = DatasetRetrieveOpenAIFtParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<DatasetRetrieveOpenAIFtResponse> = + retrieveOpenAIFt(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see retrieveOpenAIFt */ + @MustBeClosed + fun retrieveOpenAIFt( + datasetId: String, + params: DatasetRetrieveOpenAIFtParams = DatasetRetrieveOpenAIFtParams.none(), + ): HttpResponseFor<DatasetRetrieveOpenAIFtResponse> = + retrieveOpenAIFt(datasetId, params, RequestOptions.none()) + + /** @see retrieveOpenAIFt */ + @MustBeClosed + fun retrieveOpenAIFt( + params: DatasetRetrieveOpenAIFtParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<DatasetRetrieveOpenAIFtResponse> + + /** @see retrieveOpenAIFt */ + @MustBeClosed + fun retrieveOpenAIFt( + params: DatasetRetrieveOpenAIFtParams + ): HttpResponseFor<DatasetRetrieveOpenAIFtResponse> = + retrieveOpenAIFt(params, RequestOptions.none()) + + /** @see retrieveOpenAIFt */ + @MustBeClosed + fun retrieveOpenAIFt( + datasetId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<DatasetRetrieveOpenAIFtResponse> = + retrieveOpenAIFt(datasetId, DatasetRetrieveOpenAIFtParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/datasets/{dataset_id}/version`, but is + * otherwise the same as [DatasetService.retrieveVersion]. + */ + @MustBeClosed + fun retrieveVersion(datasetId: String): HttpResponseFor<DatasetVersion> = + retrieveVersion(datasetId, DatasetRetrieveVersionParams.none()) + + /** @see retrieveVersion */ + @MustBeClosed + fun retrieveVersion( + datasetId: String, + params: DatasetRetrieveVersionParams = DatasetRetrieveVersionParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<DatasetVersion> = + retrieveVersion(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see retrieveVersion */ + @MustBeClosed + fun retrieveVersion( + datasetId: String, + params: DatasetRetrieveVersionParams = DatasetRetrieveVersionParams.none(), + ): HttpResponseFor<DatasetVersion> = + retrieveVersion(datasetId, params, RequestOptions.none()) + + /** @see retrieveVersion */ + @MustBeClosed + fun retrieveVersion( + params: DatasetRetrieveVersionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<DatasetVersion> + + /** @see retrieveVersion */ + @MustBeClosed + fun retrieveVersion(params: DatasetRetrieveVersionParams): HttpResponseFor<DatasetVersion> = + retrieveVersion(params, RequestOptions.none()) + + /** @see retrieveVersion */ + @MustBeClosed + fun retrieveVersion( + datasetId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<DatasetVersion> = + retrieveVersion(datasetId, DatasetRetrieveVersionParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/datasets/{dataset_id}/search`, but is + * otherwise the same as [DatasetService.search]. + */ + @MustBeClosed + fun search( + datasetId: String, + params: DatasetSearchParams, + ): HttpResponseFor<DatasetSearchResponse> = search(datasetId, params, RequestOptions.none()) + + /** @see search */ + @MustBeClosed + fun search( + datasetId: String, + params: DatasetSearchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<DatasetSearchResponse> = + search(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see search */ + @MustBeClosed + fun search(params: DatasetSearchParams): HttpResponseFor<DatasetSearchResponse> = + search(params, RequestOptions.none()) + + /** @see search */ + @MustBeClosed + fun search( + params: DatasetSearchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<DatasetSearchResponse> + + /** + * Returns a raw HTTP response for `post /api/v1/datasets/studio_experiment`, but is + * otherwise the same as [DatasetService.studioExperiment]. + */ + @MustBeClosed + fun studioExperiment( + params: DatasetStudioExperimentParams + ): HttpResponseFor<DatasetStudioExperimentResponse> = + studioExperiment(params, RequestOptions.none()) + + /** @see studioExperiment */ + @MustBeClosed + fun studioExperiment( + params: DatasetStudioExperimentParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<DatasetStudioExperimentResponse> + + /** + * Returns a raw HTTP response for `put /api/v1/datasets/{dataset_id}/tags`, but is + * otherwise the same as [DatasetService.updateTags]. + */ + @MustBeClosed + fun updateTags( + datasetId: String, + params: DatasetUpdateTagsParams, + ): HttpResponseFor<DatasetVersion> = updateTags(datasetId, params, RequestOptions.none()) + + /** @see updateTags */ + @MustBeClosed + fun updateTags( + datasetId: String, + params: DatasetUpdateTagsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<DatasetVersion> = + updateTags(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see updateTags */ + @MustBeClosed + fun updateTags(params: DatasetUpdateTagsParams): HttpResponseFor<DatasetVersion> = + updateTags(params, RequestOptions.none()) + + /** @see updateTags */ + @MustBeClosed + fun updateTags( + params: DatasetUpdateTagsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<DatasetVersion> + + /** + * Returns a raw HTTP response for `post /api/v1/datasets/upload`, but is otherwise the same + * as [DatasetService.upload]. + */ + @MustBeClosed + fun upload(params: DatasetUploadParams): HttpResponseFor<Dataset> = + upload(params, RequestOptions.none()) + + /** @see upload */ + @MustBeClosed + fun upload( + params: DatasetUploadParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<Dataset> + + /** + * Returns a raw HTTP response for `post /api/v1/datasets/upload-experiment`, but is + * otherwise the same as [DatasetService.uploadExperiment]. + */ + @MustBeClosed + fun uploadExperiment( + params: DatasetUploadExperimentParams + ): HttpResponseFor<DatasetUploadExperimentResponse> = + uploadExperiment(params, RequestOptions.none()) + + /** @see uploadExperiment */ + @MustBeClosed + fun uploadExperiment( + params: DatasetUploadExperimentParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<DatasetUploadExperimentResponse> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/DatasetServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/DatasetServiceImpl.kt new file mode 100644 index 00000000..bb6d88ec --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/DatasetServiceImpl.kt @@ -0,0 +1,796 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.multipartFormData +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.datasets.Dataset +import com.langsmith_api.api.models.api.v1.datasets.DatasetCloneParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetCloneResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetCreateParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetDeleteParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetDeleteResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetGenerateParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetGenerateResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetListParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveCsvParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveCsvResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveJsonlParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveJsonlResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveOpenAIFtParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveOpenAIFtResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveOpenAIParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveOpenAIResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveVersionParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetSearchParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetSearchResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetStudioExperimentParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetStudioExperimentResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetUpdateParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetUpdateResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetUpdateTagsParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetUploadExperimentParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetUploadExperimentResponse +import com.langsmith_api.api.models.api.v1.datasets.DatasetUploadParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetVersion +import com.langsmith_api.api.services.blocking.api.v1.datasets.ComparativeService +import com.langsmith_api.api.services.blocking.api.v1.datasets.ComparativeServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.datasets.ExperimentService +import com.langsmith_api.api.services.blocking.api.v1.datasets.ExperimentServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.datasets.GroupService +import com.langsmith_api.api.services.blocking.api.v1.datasets.GroupServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.datasets.IndexService +import com.langsmith_api.api.services.blocking.api.v1.datasets.IndexServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.datasets.PlaygroundExperimentService +import com.langsmith_api.api.services.blocking.api.v1.datasets.PlaygroundExperimentServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.datasets.RunService +import com.langsmith_api.api.services.blocking.api.v1.datasets.RunServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.datasets.ShareService +import com.langsmith_api.api.services.blocking.api.v1.datasets.ShareServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.datasets.SplitService +import com.langsmith_api.api.services.blocking.api.v1.datasets.SplitServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.datasets.VersionService +import com.langsmith_api.api.services.blocking.api.v1.datasets.VersionServiceImpl +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class DatasetServiceImpl internal constructor(private val clientOptions: ClientOptions) : + DatasetService { + + private val withRawResponse: DatasetService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val versions: VersionService by lazy { VersionServiceImpl(clientOptions) } + + private val runs: RunService by lazy { RunServiceImpl(clientOptions) } + + private val group: GroupService by lazy { GroupServiceImpl(clientOptions) } + + private val experiments: ExperimentService by lazy { ExperimentServiceImpl(clientOptions) } + + private val share: ShareService by lazy { ShareServiceImpl(clientOptions) } + + private val comparative: ComparativeService by lazy { ComparativeServiceImpl(clientOptions) } + + private val splits: SplitService by lazy { SplitServiceImpl(clientOptions) } + + private val index: IndexService by lazy { IndexServiceImpl(clientOptions) } + + private val playgroundExperiment: PlaygroundExperimentService by lazy { + PlaygroundExperimentServiceImpl(clientOptions) + } + + override fun withRawResponse(): DatasetService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): DatasetService = + DatasetServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun versions(): VersionService = versions + + override fun runs(): RunService = runs + + override fun group(): GroupService = group + + override fun experiments(): ExperimentService = experiments + + override fun share(): ShareService = share + + override fun comparative(): ComparativeService = comparative + + override fun splits(): SplitService = splits + + override fun index(): IndexService = index + + override fun playgroundExperiment(): PlaygroundExperimentService = playgroundExperiment + + override fun create(params: DatasetCreateParams, requestOptions: RequestOptions): Dataset = + // post /api/v1/datasets + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve(params: DatasetRetrieveParams, requestOptions: RequestOptions): Dataset = + // get /api/v1/datasets/{dataset_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update( + params: DatasetUpdateParams, + requestOptions: RequestOptions, + ): DatasetUpdateResponse = + // patch /api/v1/datasets/{dataset_id} + withRawResponse().update(params, requestOptions).parse() + + override fun list(params: DatasetListParams, requestOptions: RequestOptions): List<Dataset> = + // get /api/v1/datasets + withRawResponse().list(params, requestOptions).parse() + + override fun delete( + params: DatasetDeleteParams, + requestOptions: RequestOptions, + ): DatasetDeleteResponse = + // delete /api/v1/datasets/{dataset_id} + withRawResponse().delete(params, requestOptions).parse() + + override fun clone( + params: DatasetCloneParams, + requestOptions: RequestOptions, + ): List<DatasetCloneResponse> = + // post /api/v1/datasets/clone + withRawResponse().clone(params, requestOptions).parse() + + override fun generate( + params: DatasetGenerateParams, + requestOptions: RequestOptions, + ): DatasetGenerateResponse = + // post /api/v1/datasets/{dataset_id}/generate + withRawResponse().generate(params, requestOptions).parse() + + override fun retrieveCsv( + params: DatasetRetrieveCsvParams, + requestOptions: RequestOptions, + ): DatasetRetrieveCsvResponse = + // get /api/v1/datasets/{dataset_id}/csv + withRawResponse().retrieveCsv(params, requestOptions).parse() + + override fun retrieveJsonl( + params: DatasetRetrieveJsonlParams, + requestOptions: RequestOptions, + ): DatasetRetrieveJsonlResponse = + // get /api/v1/datasets/{dataset_id}/jsonl + withRawResponse().retrieveJsonl(params, requestOptions).parse() + + override fun retrieveOpenAI( + params: DatasetRetrieveOpenAIParams, + requestOptions: RequestOptions, + ): DatasetRetrieveOpenAIResponse = + // get /api/v1/datasets/{dataset_id}/openai + withRawResponse().retrieveOpenAI(params, requestOptions).parse() + + override fun retrieveOpenAIFt( + params: DatasetRetrieveOpenAIFtParams, + requestOptions: RequestOptions, + ): DatasetRetrieveOpenAIFtResponse = + // get /api/v1/datasets/{dataset_id}/openai_ft + withRawResponse().retrieveOpenAIFt(params, requestOptions).parse() + + override fun retrieveVersion( + params: DatasetRetrieveVersionParams, + requestOptions: RequestOptions, + ): DatasetVersion = + // get /api/v1/datasets/{dataset_id}/version + withRawResponse().retrieveVersion(params, requestOptions).parse() + + override fun search( + params: DatasetSearchParams, + requestOptions: RequestOptions, + ): DatasetSearchResponse = + // post /api/v1/datasets/{dataset_id}/search + withRawResponse().search(params, requestOptions).parse() + + override fun studioExperiment( + params: DatasetStudioExperimentParams, + requestOptions: RequestOptions, + ): DatasetStudioExperimentResponse = + // post /api/v1/datasets/studio_experiment + withRawResponse().studioExperiment(params, requestOptions).parse() + + override fun updateTags( + params: DatasetUpdateTagsParams, + requestOptions: RequestOptions, + ): DatasetVersion = + // put /api/v1/datasets/{dataset_id}/tags + withRawResponse().updateTags(params, requestOptions).parse() + + override fun upload(params: DatasetUploadParams, requestOptions: RequestOptions): Dataset = + // post /api/v1/datasets/upload + withRawResponse().upload(params, requestOptions).parse() + + override fun uploadExperiment( + params: DatasetUploadExperimentParams, + requestOptions: RequestOptions, + ): DatasetUploadExperimentResponse = + // post /api/v1/datasets/upload-experiment + withRawResponse().uploadExperiment(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + DatasetService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val versions: VersionService.WithRawResponse by lazy { + VersionServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val runs: RunService.WithRawResponse by lazy { + RunServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val group: GroupService.WithRawResponse by lazy { + GroupServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val experiments: ExperimentService.WithRawResponse by lazy { + ExperimentServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val share: ShareService.WithRawResponse by lazy { + ShareServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val comparative: ComparativeService.WithRawResponse by lazy { + ComparativeServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val splits: SplitService.WithRawResponse by lazy { + SplitServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val index: IndexService.WithRawResponse by lazy { + IndexServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val playgroundExperiment: PlaygroundExperimentService.WithRawResponse by lazy { + PlaygroundExperimentServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): DatasetService.WithRawResponse = + DatasetServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun versions(): VersionService.WithRawResponse = versions + + override fun runs(): RunService.WithRawResponse = runs + + override fun group(): GroupService.WithRawResponse = group + + override fun experiments(): ExperimentService.WithRawResponse = experiments + + override fun share(): ShareService.WithRawResponse = share + + override fun comparative(): ComparativeService.WithRawResponse = comparative + + override fun splits(): SplitService.WithRawResponse = splits + + override fun index(): IndexService.WithRawResponse = index + + override fun playgroundExperiment(): PlaygroundExperimentService.WithRawResponse = + playgroundExperiment + + private val createHandler: Handler<Dataset> = jsonHandler<Dataset>(clientOptions.jsonMapper) + + override fun create( + params: DatasetCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<Dataset> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler<Dataset> = + jsonHandler<Dataset>(clientOptions.jsonMapper) + + override fun retrieve( + params: DatasetRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor<Dataset> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler<DatasetUpdateResponse> = + jsonHandler<DatasetUpdateResponse>(clientOptions.jsonMapper) + + override fun update( + params: DatasetUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<DatasetUpdateResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler<List<Dataset>> = + jsonHandler<List<Dataset>>(clientOptions.jsonMapper) + + override fun list( + params: DatasetListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<Dataset>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val deleteHandler: Handler<DatasetDeleteResponse> = + jsonHandler<DatasetDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: DatasetDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<DatasetDeleteResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val cloneHandler: Handler<List<DatasetCloneResponse>> = + jsonHandler<List<DatasetCloneResponse>>(clientOptions.jsonMapper) + + override fun clone( + params: DatasetCloneParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<DatasetCloneResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", "clone") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { cloneHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val generateHandler: Handler<DatasetGenerateResponse> = + jsonHandler<DatasetGenerateResponse>(clientOptions.jsonMapper) + + override fun generate( + params: DatasetGenerateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<DatasetGenerateResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "generate") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { generateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveCsvHandler: Handler<DatasetRetrieveCsvResponse> = + jsonHandler<DatasetRetrieveCsvResponse>(clientOptions.jsonMapper) + + override fun retrieveCsv( + params: DatasetRetrieveCsvParams, + requestOptions: RequestOptions, + ): HttpResponseFor<DatasetRetrieveCsvResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "csv") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveCsvHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveJsonlHandler: Handler<DatasetRetrieveJsonlResponse> = + jsonHandler<DatasetRetrieveJsonlResponse>(clientOptions.jsonMapper) + + override fun retrieveJsonl( + params: DatasetRetrieveJsonlParams, + requestOptions: RequestOptions, + ): HttpResponseFor<DatasetRetrieveJsonlResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "jsonl") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveJsonlHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveOpenAIHandler: Handler<DatasetRetrieveOpenAIResponse> = + jsonHandler<DatasetRetrieveOpenAIResponse>(clientOptions.jsonMapper) + + override fun retrieveOpenAI( + params: DatasetRetrieveOpenAIParams, + requestOptions: RequestOptions, + ): HttpResponseFor<DatasetRetrieveOpenAIResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "openai") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveOpenAIHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveOpenAIFtHandler: Handler<DatasetRetrieveOpenAIFtResponse> = + jsonHandler<DatasetRetrieveOpenAIFtResponse>(clientOptions.jsonMapper) + + override fun retrieveOpenAIFt( + params: DatasetRetrieveOpenAIFtParams, + requestOptions: RequestOptions, + ): HttpResponseFor<DatasetRetrieveOpenAIFtResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "openai_ft") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveOpenAIFtHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveVersionHandler: Handler<DatasetVersion> = + jsonHandler<DatasetVersion>(clientOptions.jsonMapper) + + override fun retrieveVersion( + params: DatasetRetrieveVersionParams, + requestOptions: RequestOptions, + ): HttpResponseFor<DatasetVersion> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "version") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveVersionHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val searchHandler: Handler<DatasetSearchResponse> = + jsonHandler<DatasetSearchResponse>(clientOptions.jsonMapper) + + override fun search( + params: DatasetSearchParams, + requestOptions: RequestOptions, + ): HttpResponseFor<DatasetSearchResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "search") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { searchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val studioExperimentHandler: Handler<DatasetStudioExperimentResponse> = + jsonHandler<DatasetStudioExperimentResponse>(clientOptions.jsonMapper) + + override fun studioExperiment( + params: DatasetStudioExperimentParams, + requestOptions: RequestOptions, + ): HttpResponseFor<DatasetStudioExperimentResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", "studio_experiment") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { studioExperimentHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateTagsHandler: Handler<DatasetVersion> = + jsonHandler<DatasetVersion>(clientOptions.jsonMapper) + + override fun updateTags( + params: DatasetUpdateTagsParams, + requestOptions: RequestOptions, + ): HttpResponseFor<DatasetVersion> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "tags") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateTagsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val uploadHandler: Handler<Dataset> = jsonHandler<Dataset>(clientOptions.jsonMapper) + + override fun upload( + params: DatasetUploadParams, + requestOptions: RequestOptions, + ): HttpResponseFor<Dataset> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", "upload") + .body(multipartFormData(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { uploadHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val uploadExperimentHandler: Handler<DatasetUploadExperimentResponse> = + jsonHandler<DatasetUploadExperimentResponse>(clientOptions.jsonMapper) + + override fun uploadExperiment( + params: DatasetUploadExperimentParams, + requestOptions: RequestOptions, + ): HttpResponseFor<DatasetUploadExperimentResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", "upload-experiment") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { uploadExperimentHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ExampleService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ExampleService.kt new file mode 100644 index 00000000..f5eaf040 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ExampleService.kt @@ -0,0 +1,406 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.examples.Example +import com.langsmith_api.api.models.api.v1.examples.ExampleCreateParams +import com.langsmith_api.api.models.api.v1.examples.ExampleDeleteAllParams +import com.langsmith_api.api.models.api.v1.examples.ExampleDeleteAllResponse +import com.langsmith_api.api.models.api.v1.examples.ExampleDeleteParams +import com.langsmith_api.api.models.api.v1.examples.ExampleDeleteResponse +import com.langsmith_api.api.models.api.v1.examples.ExampleListParams +import com.langsmith_api.api.models.api.v1.examples.ExampleRetrieveCountParams +import com.langsmith_api.api.models.api.v1.examples.ExampleRetrieveParams +import com.langsmith_api.api.models.api.v1.examples.ExampleUpdateParams +import com.langsmith_api.api.services.blocking.api.v1.examples.BulkService +import com.langsmith_api.api.services.blocking.api.v1.examples.ValidateService +import java.util.function.Consumer + +interface ExampleService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ExampleService + + fun bulk(): BulkService + + fun validate(): ValidateService + + /** Create a new example. */ + fun create(): Example = create(ExampleCreateParams.none()) + + /** @see create */ + fun create( + params: ExampleCreateParams = ExampleCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Example + + /** @see create */ + fun create(params: ExampleCreateParams = ExampleCreateParams.none()): Example = + create(params, RequestOptions.none()) + + /** @see create */ + fun create(requestOptions: RequestOptions): Example = + create(ExampleCreateParams.none(), requestOptions) + + /** Get a specific example. */ + fun retrieve(exampleId: String): Example = retrieve(exampleId, ExampleRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + exampleId: String, + params: ExampleRetrieveParams = ExampleRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Example = retrieve(params.toBuilder().exampleId(exampleId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + exampleId: String, + params: ExampleRetrieveParams = ExampleRetrieveParams.none(), + ): Example = retrieve(exampleId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: ExampleRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Example + + /** @see retrieve */ + fun retrieve(params: ExampleRetrieveParams): Example = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(exampleId: String, requestOptions: RequestOptions): Example = + retrieve(exampleId, ExampleRetrieveParams.none(), requestOptions) + + /** + * Upload examples from a CSV file. + * + * Note: For non-csv upload, please use the POST /v1/platform/datasets/{dataset_id}/examples + * endpoint which provides more efficient upload. + */ + fun update(datasetId: String, params: ExampleUpdateParams): List<Example> = + update(datasetId, params, RequestOptions.none()) + + /** @see update */ + fun update( + datasetId: String, + params: ExampleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List<Example> = update(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see update */ + fun update(params: ExampleUpdateParams): List<Example> = update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: ExampleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List<Example> + + /** Get all examples by query params */ + fun list(): List<Example> = list(ExampleListParams.none()) + + /** @see list */ + fun list( + params: ExampleListParams = ExampleListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<Example> + + /** @see list */ + fun list(params: ExampleListParams = ExampleListParams.none()): List<Example> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): List<Example> = + list(ExampleListParams.none(), requestOptions) + + /** Soft delete an example. Only deletes the example in the 'latest' version of the dataset. */ + fun delete(exampleId: String): ExampleDeleteResponse = + delete(exampleId, ExampleDeleteParams.none()) + + /** @see delete */ + fun delete( + exampleId: String, + params: ExampleDeleteParams = ExampleDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ExampleDeleteResponse = + delete(params.toBuilder().exampleId(exampleId).build(), requestOptions) + + /** @see delete */ + fun delete( + exampleId: String, + params: ExampleDeleteParams = ExampleDeleteParams.none(), + ): ExampleDeleteResponse = delete(exampleId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ExampleDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ExampleDeleteResponse + + /** @see delete */ + fun delete(params: ExampleDeleteParams): ExampleDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(exampleId: String, requestOptions: RequestOptions): ExampleDeleteResponse = + delete(exampleId, ExampleDeleteParams.none(), requestOptions) + + /** Soft delete examples. Only deletes the examples in the 'latest' version of the dataset. */ + fun deleteAll(params: ExampleDeleteAllParams): ExampleDeleteAllResponse = + deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + params: ExampleDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ExampleDeleteAllResponse + + /** Count all examples by query params */ + fun retrieveCount(): Long = retrieveCount(ExampleRetrieveCountParams.none()) + + /** @see retrieveCount */ + fun retrieveCount( + params: ExampleRetrieveCountParams = ExampleRetrieveCountParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Long + + /** @see retrieveCount */ + fun retrieveCount( + params: ExampleRetrieveCountParams = ExampleRetrieveCountParams.none() + ): Long = retrieveCount(params, RequestOptions.none()) + + /** @see retrieveCount */ + fun retrieveCount(requestOptions: RequestOptions): Long = + retrieveCount(ExampleRetrieveCountParams.none(), requestOptions) + + /** A view of [ExampleService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ExampleService.WithRawResponse + + fun bulk(): BulkService.WithRawResponse + + fun validate(): ValidateService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/examples`, but is otherwise the same as + * [ExampleService.create]. + */ + @MustBeClosed fun create(): HttpResponseFor<Example> = create(ExampleCreateParams.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: ExampleCreateParams = ExampleCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<Example> + + /** @see create */ + @MustBeClosed + fun create( + params: ExampleCreateParams = ExampleCreateParams.none() + ): HttpResponseFor<Example> = create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create(requestOptions: RequestOptions): HttpResponseFor<Example> = + create(ExampleCreateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/examples/{example_id}`, but is otherwise the + * same as [ExampleService.retrieve]. + */ + @MustBeClosed + fun retrieve(exampleId: String): HttpResponseFor<Example> = + retrieve(exampleId, ExampleRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + exampleId: String, + params: ExampleRetrieveParams = ExampleRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<Example> = + retrieve(params.toBuilder().exampleId(exampleId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + exampleId: String, + params: ExampleRetrieveParams = ExampleRetrieveParams.none(), + ): HttpResponseFor<Example> = retrieve(exampleId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: ExampleRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<Example> + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: ExampleRetrieveParams): HttpResponseFor<Example> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve(exampleId: String, requestOptions: RequestOptions): HttpResponseFor<Example> = + retrieve(exampleId, ExampleRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/examples/upload/{dataset_id}`, but is + * otherwise the same as [ExampleService.update]. + */ + @MustBeClosed + fun update(datasetId: String, params: ExampleUpdateParams): HttpResponseFor<List<Example>> = + update(datasetId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + datasetId: String, + params: ExampleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<Example>> = + update(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(params: ExampleUpdateParams): HttpResponseFor<List<Example>> = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: ExampleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<Example>> + + /** + * Returns a raw HTTP response for `get /api/v1/examples`, but is otherwise the same as + * [ExampleService.list]. + */ + @MustBeClosed fun list(): HttpResponseFor<List<Example>> = list(ExampleListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: ExampleListParams = ExampleListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<Example>> + + /** @see list */ + @MustBeClosed + fun list( + params: ExampleListParams = ExampleListParams.none() + ): HttpResponseFor<List<Example>> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor<List<Example>> = + list(ExampleListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/examples/{example_id}`, but is otherwise + * the same as [ExampleService.delete]. + */ + @MustBeClosed + fun delete(exampleId: String): HttpResponseFor<ExampleDeleteResponse> = + delete(exampleId, ExampleDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + exampleId: String, + params: ExampleDeleteParams = ExampleDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ExampleDeleteResponse> = + delete(params.toBuilder().exampleId(exampleId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + exampleId: String, + params: ExampleDeleteParams = ExampleDeleteParams.none(), + ): HttpResponseFor<ExampleDeleteResponse> = delete(exampleId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: ExampleDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ExampleDeleteResponse> + + /** @see delete */ + @MustBeClosed + fun delete(params: ExampleDeleteParams): HttpResponseFor<ExampleDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + exampleId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<ExampleDeleteResponse> = + delete(exampleId, ExampleDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/examples`, but is otherwise the same as + * [ExampleService.deleteAll]. + */ + @MustBeClosed + fun deleteAll(params: ExampleDeleteAllParams): HttpResponseFor<ExampleDeleteAllResponse> = + deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + @MustBeClosed + fun deleteAll( + params: ExampleDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ExampleDeleteAllResponse> + + /** + * Returns a raw HTTP response for `get /api/v1/examples/count`, but is otherwise the same + * as [ExampleService.retrieveCount]. + */ + @MustBeClosed + fun retrieveCount(): HttpResponseFor<Long> = + retrieveCount(ExampleRetrieveCountParams.none()) + + /** @see retrieveCount */ + @MustBeClosed + fun retrieveCount( + params: ExampleRetrieveCountParams = ExampleRetrieveCountParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<Long> + + /** @see retrieveCount */ + @MustBeClosed + fun retrieveCount( + params: ExampleRetrieveCountParams = ExampleRetrieveCountParams.none() + ): HttpResponseFor<Long> = retrieveCount(params, RequestOptions.none()) + + /** @see retrieveCount */ + @MustBeClosed + fun retrieveCount(requestOptions: RequestOptions): HttpResponseFor<Long> = + retrieveCount(ExampleRetrieveCountParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ExampleServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ExampleServiceImpl.kt new file mode 100644 index 00000000..bd390ccf --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ExampleServiceImpl.kt @@ -0,0 +1,317 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.multipartFormData +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.examples.Example +import com.langsmith_api.api.models.api.v1.examples.ExampleCreateParams +import com.langsmith_api.api.models.api.v1.examples.ExampleDeleteAllParams +import com.langsmith_api.api.models.api.v1.examples.ExampleDeleteAllResponse +import com.langsmith_api.api.models.api.v1.examples.ExampleDeleteParams +import com.langsmith_api.api.models.api.v1.examples.ExampleDeleteResponse +import com.langsmith_api.api.models.api.v1.examples.ExampleListParams +import com.langsmith_api.api.models.api.v1.examples.ExampleRetrieveCountParams +import com.langsmith_api.api.models.api.v1.examples.ExampleRetrieveParams +import com.langsmith_api.api.models.api.v1.examples.ExampleUpdateParams +import com.langsmith_api.api.services.blocking.api.v1.examples.BulkService +import com.langsmith_api.api.services.blocking.api.v1.examples.BulkServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.examples.ValidateService +import com.langsmith_api.api.services.blocking.api.v1.examples.ValidateServiceImpl +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ExampleServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ExampleService { + + private val withRawResponse: ExampleService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val bulk: BulkService by lazy { BulkServiceImpl(clientOptions) } + + private val validate: ValidateService by lazy { ValidateServiceImpl(clientOptions) } + + override fun withRawResponse(): ExampleService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): ExampleService = + ExampleServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun bulk(): BulkService = bulk + + override fun validate(): ValidateService = validate + + override fun create(params: ExampleCreateParams, requestOptions: RequestOptions): Example = + // post /api/v1/examples + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve(params: ExampleRetrieveParams, requestOptions: RequestOptions): Example = + // get /api/v1/examples/{example_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update( + params: ExampleUpdateParams, + requestOptions: RequestOptions, + ): List<Example> = + // post /api/v1/examples/upload/{dataset_id} + withRawResponse().update(params, requestOptions).parse() + + override fun list(params: ExampleListParams, requestOptions: RequestOptions): List<Example> = + // get /api/v1/examples + withRawResponse().list(params, requestOptions).parse() + + override fun delete( + params: ExampleDeleteParams, + requestOptions: RequestOptions, + ): ExampleDeleteResponse = + // delete /api/v1/examples/{example_id} + withRawResponse().delete(params, requestOptions).parse() + + override fun deleteAll( + params: ExampleDeleteAllParams, + requestOptions: RequestOptions, + ): ExampleDeleteAllResponse = + // delete /api/v1/examples + withRawResponse().deleteAll(params, requestOptions).parse() + + override fun retrieveCount( + params: ExampleRetrieveCountParams, + requestOptions: RequestOptions, + ): Long = + // get /api/v1/examples/count + withRawResponse().retrieveCount(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ExampleService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val bulk: BulkService.WithRawResponse by lazy { + BulkServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val validate: ValidateService.WithRawResponse by lazy { + ValidateServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ExampleService.WithRawResponse = + ExampleServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun bulk(): BulkService.WithRawResponse = bulk + + override fun validate(): ValidateService.WithRawResponse = validate + + private val createHandler: Handler<Example> = jsonHandler<Example>(clientOptions.jsonMapper) + + override fun create( + params: ExampleCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<Example> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "examples") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler<Example> = + jsonHandler<Example>(clientOptions.jsonMapper) + + override fun retrieve( + params: ExampleRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor<Example> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("exampleId", params.exampleId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "examples", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler<List<Example>> = + jsonHandler<List<Example>>(clientOptions.jsonMapper) + + override fun update( + params: ExampleUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<Example>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "examples", "upload", params._pathParam(0)) + .body(multipartFormData(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val listHandler: Handler<List<Example>> = + jsonHandler<List<Example>>(clientOptions.jsonMapper) + + override fun list( + params: ExampleListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<Example>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "examples") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val deleteHandler: Handler<ExampleDeleteResponse> = + jsonHandler<ExampleDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: ExampleDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<ExampleDeleteResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("exampleId", params.exampleId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "examples", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val deleteAllHandler: Handler<ExampleDeleteAllResponse> = + jsonHandler<ExampleDeleteAllResponse>(clientOptions.jsonMapper) + + override fun deleteAll( + params: ExampleDeleteAllParams, + requestOptions: RequestOptions, + ): HttpResponseFor<ExampleDeleteAllResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "examples") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteAllHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveCountHandler: Handler<Long> = + jsonHandler<Long>(clientOptions.jsonMapper) + + override fun retrieveCount( + params: ExampleRetrieveCountParams, + requestOptions: RequestOptions, + ): HttpResponseFor<Long> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "examples", "count") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { retrieveCountHandler.handle(it) } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/FeedbackConfigService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/FeedbackConfigService.kt new file mode 100644 index 00000000..09327da0 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/FeedbackConfigService.kt @@ -0,0 +1,152 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfigFeedbackConfigsParams +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfigRetrieveFeedbackConfigsParams +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfigSchema +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfigUpdateFeedbackConfigsParams +import java.util.function.Consumer + +interface FeedbackConfigService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): FeedbackConfigService + + /** Create Feedback Config Endpoint */ + fun feedbackConfigs(params: FeedbackConfigFeedbackConfigsParams): FeedbackConfigSchema = + feedbackConfigs(params, RequestOptions.none()) + + /** @see feedbackConfigs */ + fun feedbackConfigs( + params: FeedbackConfigFeedbackConfigsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FeedbackConfigSchema + + /** List Feedback Configs Endpoint */ + fun retrieveFeedbackConfigs(): List<FeedbackConfigSchema> = + retrieveFeedbackConfigs(FeedbackConfigRetrieveFeedbackConfigsParams.none()) + + /** @see retrieveFeedbackConfigs */ + fun retrieveFeedbackConfigs( + params: FeedbackConfigRetrieveFeedbackConfigsParams = + FeedbackConfigRetrieveFeedbackConfigsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<FeedbackConfigSchema> + + /** @see retrieveFeedbackConfigs */ + fun retrieveFeedbackConfigs( + params: FeedbackConfigRetrieveFeedbackConfigsParams = + FeedbackConfigRetrieveFeedbackConfigsParams.none() + ): List<FeedbackConfigSchema> = retrieveFeedbackConfigs(params, RequestOptions.none()) + + /** @see retrieveFeedbackConfigs */ + fun retrieveFeedbackConfigs(requestOptions: RequestOptions): List<FeedbackConfigSchema> = + retrieveFeedbackConfigs(FeedbackConfigRetrieveFeedbackConfigsParams.none(), requestOptions) + + /** Update Feedback Config Endpoint */ + fun updateFeedbackConfigs( + params: FeedbackConfigUpdateFeedbackConfigsParams + ): FeedbackConfigSchema = updateFeedbackConfigs(params, RequestOptions.none()) + + /** @see updateFeedbackConfigs */ + fun updateFeedbackConfigs( + params: FeedbackConfigUpdateFeedbackConfigsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FeedbackConfigSchema + + /** + * A view of [FeedbackConfigService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): FeedbackConfigService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/feedback-configs`, but is otherwise the + * same as [FeedbackConfigService.feedbackConfigs]. + */ + @MustBeClosed + fun feedbackConfigs( + params: FeedbackConfigFeedbackConfigsParams + ): HttpResponseFor<FeedbackConfigSchema> = feedbackConfigs(params, RequestOptions.none()) + + /** @see feedbackConfigs */ + @MustBeClosed + fun feedbackConfigs( + params: FeedbackConfigFeedbackConfigsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<FeedbackConfigSchema> + + /** + * Returns a raw HTTP response for `get /api/v1/feedback-configs`, but is otherwise the same + * as [FeedbackConfigService.retrieveFeedbackConfigs]. + */ + @MustBeClosed + fun retrieveFeedbackConfigs(): HttpResponseFor<List<FeedbackConfigSchema>> = + retrieveFeedbackConfigs(FeedbackConfigRetrieveFeedbackConfigsParams.none()) + + /** @see retrieveFeedbackConfigs */ + @MustBeClosed + fun retrieveFeedbackConfigs( + params: FeedbackConfigRetrieveFeedbackConfigsParams = + FeedbackConfigRetrieveFeedbackConfigsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<FeedbackConfigSchema>> + + /** @see retrieveFeedbackConfigs */ + @MustBeClosed + fun retrieveFeedbackConfigs( + params: FeedbackConfigRetrieveFeedbackConfigsParams = + FeedbackConfigRetrieveFeedbackConfigsParams.none() + ): HttpResponseFor<List<FeedbackConfigSchema>> = + retrieveFeedbackConfigs(params, RequestOptions.none()) + + /** @see retrieveFeedbackConfigs */ + @MustBeClosed + fun retrieveFeedbackConfigs( + requestOptions: RequestOptions + ): HttpResponseFor<List<FeedbackConfigSchema>> = + retrieveFeedbackConfigs( + FeedbackConfigRetrieveFeedbackConfigsParams.none(), + requestOptions, + ) + + /** + * Returns a raw HTTP response for `patch /api/v1/feedback-configs`, but is otherwise the + * same as [FeedbackConfigService.updateFeedbackConfigs]. + */ + @MustBeClosed + fun updateFeedbackConfigs( + params: FeedbackConfigUpdateFeedbackConfigsParams + ): HttpResponseFor<FeedbackConfigSchema> = + updateFeedbackConfigs(params, RequestOptions.none()) + + /** @see updateFeedbackConfigs */ + @MustBeClosed + fun updateFeedbackConfigs( + params: FeedbackConfigUpdateFeedbackConfigsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<FeedbackConfigSchema> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/FeedbackConfigServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/FeedbackConfigServiceImpl.kt new file mode 100644 index 00000000..41d7a0ca --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/FeedbackConfigServiceImpl.kt @@ -0,0 +1,153 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfigFeedbackConfigsParams +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfigRetrieveFeedbackConfigsParams +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfigSchema +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfigUpdateFeedbackConfigsParams +import java.util.function.Consumer + +class FeedbackConfigServiceImpl internal constructor(private val clientOptions: ClientOptions) : + FeedbackConfigService { + + private val withRawResponse: FeedbackConfigService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): FeedbackConfigService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): FeedbackConfigService = + FeedbackConfigServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun feedbackConfigs( + params: FeedbackConfigFeedbackConfigsParams, + requestOptions: RequestOptions, + ): FeedbackConfigSchema = + // post /api/v1/feedback-configs + withRawResponse().feedbackConfigs(params, requestOptions).parse() + + override fun retrieveFeedbackConfigs( + params: FeedbackConfigRetrieveFeedbackConfigsParams, + requestOptions: RequestOptions, + ): List<FeedbackConfigSchema> = + // get /api/v1/feedback-configs + withRawResponse().retrieveFeedbackConfigs(params, requestOptions).parse() + + override fun updateFeedbackConfigs( + params: FeedbackConfigUpdateFeedbackConfigsParams, + requestOptions: RequestOptions, + ): FeedbackConfigSchema = + // patch /api/v1/feedback-configs + withRawResponse().updateFeedbackConfigs(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + FeedbackConfigService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): FeedbackConfigService.WithRawResponse = + FeedbackConfigServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val feedbackConfigsHandler: Handler<FeedbackConfigSchema> = + jsonHandler<FeedbackConfigSchema>(clientOptions.jsonMapper) + + override fun feedbackConfigs( + params: FeedbackConfigFeedbackConfigsParams, + requestOptions: RequestOptions, + ): HttpResponseFor<FeedbackConfigSchema> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "feedback-configs") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { feedbackConfigsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveFeedbackConfigsHandler: Handler<List<FeedbackConfigSchema>> = + jsonHandler<List<FeedbackConfigSchema>>(clientOptions.jsonMapper) + + override fun retrieveFeedbackConfigs( + params: FeedbackConfigRetrieveFeedbackConfigsParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<FeedbackConfigSchema>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "feedback-configs") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveFeedbackConfigsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val updateFeedbackConfigsHandler: Handler<FeedbackConfigSchema> = + jsonHandler<FeedbackConfigSchema>(clientOptions.jsonMapper) + + override fun updateFeedbackConfigs( + params: FeedbackConfigUpdateFeedbackConfigsParams, + requestOptions: RequestOptions, + ): HttpResponseFor<FeedbackConfigSchema> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "feedback-configs") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateFeedbackConfigsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/FeedbackService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/FeedbackService.kt new file mode 100644 index 00000000..a6b3f802 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/FeedbackService.kt @@ -0,0 +1,434 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.feedback.FeedbackCreateParams +import com.langsmith_api.api.models.api.v1.feedback.FeedbackCreateSchema +import com.langsmith_api.api.models.api.v1.feedback.FeedbackDeleteParams +import com.langsmith_api.api.models.api.v1.feedback.FeedbackDeleteResponse +import com.langsmith_api.api.models.api.v1.feedback.FeedbackEagerParams +import com.langsmith_api.api.models.api.v1.feedback.FeedbackListParams +import com.langsmith_api.api.models.api.v1.feedback.FeedbackRetrieveParams +import com.langsmith_api.api.models.api.v1.feedback.FeedbackSchema +import com.langsmith_api.api.models.api.v1.feedback.FeedbackUpdateParams +import com.langsmith_api.api.services.blocking.api.v1.feedback.FormulaService +import com.langsmith_api.api.services.blocking.api.v1.feedback.TokenService +import java.util.function.Consumer + +interface FeedbackService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): FeedbackService + + fun formulas(): FormulaService + + fun tokens(): TokenService + + /** Create a new feedback. */ + fun create(params: FeedbackCreateParams): FeedbackSchema = create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: FeedbackCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FeedbackSchema + + /** @see create */ + fun create( + feedbackCreateSchema: FeedbackCreateSchema, + requestOptions: RequestOptions = RequestOptions.none(), + ): FeedbackSchema = + create( + FeedbackCreateParams.builder().feedbackCreateSchema(feedbackCreateSchema).build(), + requestOptions, + ) + + /** @see create */ + fun create(feedbackCreateSchema: FeedbackCreateSchema): FeedbackSchema = + create(feedbackCreateSchema, RequestOptions.none()) + + /** Get a specific feedback. */ + fun retrieve(feedbackId: String): FeedbackSchema = + retrieve(feedbackId, FeedbackRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + feedbackId: String, + params: FeedbackRetrieveParams = FeedbackRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): FeedbackSchema = retrieve(params.toBuilder().feedbackId(feedbackId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + feedbackId: String, + params: FeedbackRetrieveParams = FeedbackRetrieveParams.none(), + ): FeedbackSchema = retrieve(feedbackId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: FeedbackRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FeedbackSchema + + /** @see retrieve */ + fun retrieve(params: FeedbackRetrieveParams): FeedbackSchema = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(feedbackId: String, requestOptions: RequestOptions): FeedbackSchema = + retrieve(feedbackId, FeedbackRetrieveParams.none(), requestOptions) + + /** Replace an existing feedback entry with a new, modified entry. */ + fun update(feedbackId: String): FeedbackSchema = update(feedbackId, FeedbackUpdateParams.none()) + + /** @see update */ + fun update( + feedbackId: String, + params: FeedbackUpdateParams = FeedbackUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): FeedbackSchema = update(params.toBuilder().feedbackId(feedbackId).build(), requestOptions) + + /** @see update */ + fun update( + feedbackId: String, + params: FeedbackUpdateParams = FeedbackUpdateParams.none(), + ): FeedbackSchema = update(feedbackId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: FeedbackUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FeedbackSchema + + /** @see update */ + fun update(params: FeedbackUpdateParams): FeedbackSchema = update(params, RequestOptions.none()) + + /** @see update */ + fun update(feedbackId: String, requestOptions: RequestOptions): FeedbackSchema = + update(feedbackId, FeedbackUpdateParams.none(), requestOptions) + + /** List all Feedback by query params. */ + fun list(): List<FeedbackSchema> = list(FeedbackListParams.none()) + + /** @see list */ + fun list( + params: FeedbackListParams = FeedbackListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<FeedbackSchema> + + /** @see list */ + fun list(params: FeedbackListParams = FeedbackListParams.none()): List<FeedbackSchema> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): List<FeedbackSchema> = + list(FeedbackListParams.none(), requestOptions) + + /** Delete a feedback. */ + fun delete(feedbackId: String): FeedbackDeleteResponse = + delete(feedbackId, FeedbackDeleteParams.none()) + + /** @see delete */ + fun delete( + feedbackId: String, + params: FeedbackDeleteParams = FeedbackDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): FeedbackDeleteResponse = + delete(params.toBuilder().feedbackId(feedbackId).build(), requestOptions) + + /** @see delete */ + fun delete( + feedbackId: String, + params: FeedbackDeleteParams = FeedbackDeleteParams.none(), + ): FeedbackDeleteResponse = delete(feedbackId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: FeedbackDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FeedbackDeleteResponse + + /** @see delete */ + fun delete(params: FeedbackDeleteParams): FeedbackDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(feedbackId: String, requestOptions: RequestOptions): FeedbackDeleteResponse = + delete(feedbackId, FeedbackDeleteParams.none(), requestOptions) + + /** + * Create a new feedback. + * + * This method is invoked under the assumption that the run is already visible in the app, thus + * already present in DB + */ + fun eager(params: FeedbackEagerParams): FeedbackSchema = eager(params, RequestOptions.none()) + + /** @see eager */ + fun eager( + params: FeedbackEagerParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FeedbackSchema + + /** @see eager */ + fun eager( + feedbackCreateSchema: FeedbackCreateSchema, + requestOptions: RequestOptions = RequestOptions.none(), + ): FeedbackSchema = + eager( + FeedbackEagerParams.builder().feedbackCreateSchema(feedbackCreateSchema).build(), + requestOptions, + ) + + /** @see eager */ + fun eager(feedbackCreateSchema: FeedbackCreateSchema): FeedbackSchema = + eager(feedbackCreateSchema, RequestOptions.none()) + + /** A view of [FeedbackService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): FeedbackService.WithRawResponse + + fun formulas(): FormulaService.WithRawResponse + + fun tokens(): TokenService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/feedback`, but is otherwise the same as + * [FeedbackService.create]. + */ + @MustBeClosed + fun create(params: FeedbackCreateParams): HttpResponseFor<FeedbackSchema> = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: FeedbackCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<FeedbackSchema> + + /** @see create */ + @MustBeClosed + fun create( + feedbackCreateSchema: FeedbackCreateSchema, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<FeedbackSchema> = + create( + FeedbackCreateParams.builder().feedbackCreateSchema(feedbackCreateSchema).build(), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create(feedbackCreateSchema: FeedbackCreateSchema): HttpResponseFor<FeedbackSchema> = + create(feedbackCreateSchema, RequestOptions.none()) + + /** + * Returns a raw HTTP response for `get /api/v1/feedback/{feedback_id}`, but is otherwise + * the same as [FeedbackService.retrieve]. + */ + @MustBeClosed + fun retrieve(feedbackId: String): HttpResponseFor<FeedbackSchema> = + retrieve(feedbackId, FeedbackRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + feedbackId: String, + params: FeedbackRetrieveParams = FeedbackRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<FeedbackSchema> = + retrieve(params.toBuilder().feedbackId(feedbackId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + feedbackId: String, + params: FeedbackRetrieveParams = FeedbackRetrieveParams.none(), + ): HttpResponseFor<FeedbackSchema> = retrieve(feedbackId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: FeedbackRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<FeedbackSchema> + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: FeedbackRetrieveParams): HttpResponseFor<FeedbackSchema> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + feedbackId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<FeedbackSchema> = + retrieve(feedbackId, FeedbackRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `patch /api/v1/feedback/{feedback_id}`, but is otherwise + * the same as [FeedbackService.update]. + */ + @MustBeClosed + fun update(feedbackId: String): HttpResponseFor<FeedbackSchema> = + update(feedbackId, FeedbackUpdateParams.none()) + + /** @see update */ + @MustBeClosed + fun update( + feedbackId: String, + params: FeedbackUpdateParams = FeedbackUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<FeedbackSchema> = + update(params.toBuilder().feedbackId(feedbackId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update( + feedbackId: String, + params: FeedbackUpdateParams = FeedbackUpdateParams.none(), + ): HttpResponseFor<FeedbackSchema> = update(feedbackId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: FeedbackUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<FeedbackSchema> + + /** @see update */ + @MustBeClosed + fun update(params: FeedbackUpdateParams): HttpResponseFor<FeedbackSchema> = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + feedbackId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<FeedbackSchema> = + update(feedbackId, FeedbackUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/feedback`, but is otherwise the same as + * [FeedbackService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor<List<FeedbackSchema>> = list(FeedbackListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: FeedbackListParams = FeedbackListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<FeedbackSchema>> + + /** @see list */ + @MustBeClosed + fun list( + params: FeedbackListParams = FeedbackListParams.none() + ): HttpResponseFor<List<FeedbackSchema>> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor<List<FeedbackSchema>> = + list(FeedbackListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/feedback/{feedback_id}`, but is otherwise + * the same as [FeedbackService.delete]. + */ + @MustBeClosed + fun delete(feedbackId: String): HttpResponseFor<FeedbackDeleteResponse> = + delete(feedbackId, FeedbackDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + feedbackId: String, + params: FeedbackDeleteParams = FeedbackDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<FeedbackDeleteResponse> = + delete(params.toBuilder().feedbackId(feedbackId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + feedbackId: String, + params: FeedbackDeleteParams = FeedbackDeleteParams.none(), + ): HttpResponseFor<FeedbackDeleteResponse> = + delete(feedbackId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: FeedbackDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<FeedbackDeleteResponse> + + /** @see delete */ + @MustBeClosed + fun delete(params: FeedbackDeleteParams): HttpResponseFor<FeedbackDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + feedbackId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<FeedbackDeleteResponse> = + delete(feedbackId, FeedbackDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/feedback/eager`, but is otherwise the same + * as [FeedbackService.eager]. + */ + @MustBeClosed + fun eager(params: FeedbackEagerParams): HttpResponseFor<FeedbackSchema> = + eager(params, RequestOptions.none()) + + /** @see eager */ + @MustBeClosed + fun eager( + params: FeedbackEagerParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<FeedbackSchema> + + /** @see eager */ + @MustBeClosed + fun eager( + feedbackCreateSchema: FeedbackCreateSchema, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<FeedbackSchema> = + eager( + FeedbackEagerParams.builder().feedbackCreateSchema(feedbackCreateSchema).build(), + requestOptions, + ) + + /** @see eager */ + @MustBeClosed + fun eager(feedbackCreateSchema: FeedbackCreateSchema): HttpResponseFor<FeedbackSchema> = + eager(feedbackCreateSchema, RequestOptions.none()) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/FeedbackServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/FeedbackServiceImpl.kt new file mode 100644 index 00000000..eaea1c43 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/FeedbackServiceImpl.kt @@ -0,0 +1,296 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.feedback.FeedbackCreateParams +import com.langsmith_api.api.models.api.v1.feedback.FeedbackDeleteParams +import com.langsmith_api.api.models.api.v1.feedback.FeedbackDeleteResponse +import com.langsmith_api.api.models.api.v1.feedback.FeedbackEagerParams +import com.langsmith_api.api.models.api.v1.feedback.FeedbackListParams +import com.langsmith_api.api.models.api.v1.feedback.FeedbackRetrieveParams +import com.langsmith_api.api.models.api.v1.feedback.FeedbackSchema +import com.langsmith_api.api.models.api.v1.feedback.FeedbackUpdateParams +import com.langsmith_api.api.services.blocking.api.v1.feedback.FormulaService +import com.langsmith_api.api.services.blocking.api.v1.feedback.FormulaServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.feedback.TokenService +import com.langsmith_api.api.services.blocking.api.v1.feedback.TokenServiceImpl +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class FeedbackServiceImpl internal constructor(private val clientOptions: ClientOptions) : + FeedbackService { + + private val withRawResponse: FeedbackService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val formulas: FormulaService by lazy { FormulaServiceImpl(clientOptions) } + + private val tokens: TokenService by lazy { TokenServiceImpl(clientOptions) } + + override fun withRawResponse(): FeedbackService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): FeedbackService = + FeedbackServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun formulas(): FormulaService = formulas + + override fun tokens(): TokenService = tokens + + override fun create( + params: FeedbackCreateParams, + requestOptions: RequestOptions, + ): FeedbackSchema = + // post /api/v1/feedback + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve( + params: FeedbackRetrieveParams, + requestOptions: RequestOptions, + ): FeedbackSchema = + // get /api/v1/feedback/{feedback_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update( + params: FeedbackUpdateParams, + requestOptions: RequestOptions, + ): FeedbackSchema = + // patch /api/v1/feedback/{feedback_id} + withRawResponse().update(params, requestOptions).parse() + + override fun list( + params: FeedbackListParams, + requestOptions: RequestOptions, + ): List<FeedbackSchema> = + // get /api/v1/feedback + withRawResponse().list(params, requestOptions).parse() + + override fun delete( + params: FeedbackDeleteParams, + requestOptions: RequestOptions, + ): FeedbackDeleteResponse = + // delete /api/v1/feedback/{feedback_id} + withRawResponse().delete(params, requestOptions).parse() + + override fun eager( + params: FeedbackEagerParams, + requestOptions: RequestOptions, + ): FeedbackSchema = + // post /api/v1/feedback/eager + withRawResponse().eager(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + FeedbackService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val formulas: FormulaService.WithRawResponse by lazy { + FormulaServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val tokens: TokenService.WithRawResponse by lazy { + TokenServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): FeedbackService.WithRawResponse = + FeedbackServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun formulas(): FormulaService.WithRawResponse = formulas + + override fun tokens(): TokenService.WithRawResponse = tokens + + private val createHandler: Handler<FeedbackSchema> = + jsonHandler<FeedbackSchema>(clientOptions.jsonMapper) + + override fun create( + params: FeedbackCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<FeedbackSchema> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "feedback") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler<FeedbackSchema> = + jsonHandler<FeedbackSchema>(clientOptions.jsonMapper) + + override fun retrieve( + params: FeedbackRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor<FeedbackSchema> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("feedbackId", params.feedbackId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "feedback", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler<FeedbackSchema> = + jsonHandler<FeedbackSchema>(clientOptions.jsonMapper) + + override fun update( + params: FeedbackUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<FeedbackSchema> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("feedbackId", params.feedbackId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "feedback", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler<List<FeedbackSchema>> = + jsonHandler<List<FeedbackSchema>>(clientOptions.jsonMapper) + + override fun list( + params: FeedbackListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<FeedbackSchema>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "feedback") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val deleteHandler: Handler<FeedbackDeleteResponse> = + jsonHandler<FeedbackDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: FeedbackDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<FeedbackDeleteResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("feedbackId", params.feedbackId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "feedback", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val eagerHandler: Handler<FeedbackSchema> = + jsonHandler<FeedbackSchema>(clientOptions.jsonMapper) + + override fun eager( + params: FeedbackEagerParams, + requestOptions: RequestOptions, + ): HttpResponseFor<FeedbackSchema> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "feedback", "eager") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { eagerHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/InfoService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/InfoService.kt new file mode 100644 index 00000000..87fe4276 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/InfoService.kt @@ -0,0 +1,128 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.info.InfoListParams +import com.langsmith_api.api.models.api.v1.info.InfoListResponse +import com.langsmith_api.api.models.api.v1.info.InfoRetrieveHealthParams +import com.langsmith_api.api.models.api.v1.info.InfoRetrieveHealthResponse +import java.util.function.Consumer + +interface InfoService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): InfoService + + /** Get information about the current deployment of LangSmith. */ + fun list(): InfoListResponse = list(InfoListParams.none()) + + /** @see list */ + fun list( + params: InfoListParams = InfoListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): InfoListResponse + + /** @see list */ + fun list(params: InfoListParams = InfoListParams.none()): InfoListResponse = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): InfoListResponse = + list(InfoListParams.none(), requestOptions) + + /** Get health information about the current deployment of LangSmith. */ + fun retrieveHealth(): InfoRetrieveHealthResponse = + retrieveHealth(InfoRetrieveHealthParams.none()) + + /** @see retrieveHealth */ + fun retrieveHealth( + params: InfoRetrieveHealthParams = InfoRetrieveHealthParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): InfoRetrieveHealthResponse + + /** @see retrieveHealth */ + fun retrieveHealth( + params: InfoRetrieveHealthParams = InfoRetrieveHealthParams.none() + ): InfoRetrieveHealthResponse = retrieveHealth(params, RequestOptions.none()) + + /** @see retrieveHealth */ + fun retrieveHealth(requestOptions: RequestOptions): InfoRetrieveHealthResponse = + retrieveHealth(InfoRetrieveHealthParams.none(), requestOptions) + + /** A view of [InfoService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): InfoService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/info`, but is otherwise the same as + * [InfoService.list]. + */ + @MustBeClosed fun list(): HttpResponseFor<InfoListResponse> = list(InfoListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: InfoListParams = InfoListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<InfoListResponse> + + /** @see list */ + @MustBeClosed + fun list( + params: InfoListParams = InfoListParams.none() + ): HttpResponseFor<InfoListResponse> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor<InfoListResponse> = + list(InfoListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/info/health`, but is otherwise the same as + * [InfoService.retrieveHealth]. + */ + @MustBeClosed + fun retrieveHealth(): HttpResponseFor<InfoRetrieveHealthResponse> = + retrieveHealth(InfoRetrieveHealthParams.none()) + + /** @see retrieveHealth */ + @MustBeClosed + fun retrieveHealth( + params: InfoRetrieveHealthParams = InfoRetrieveHealthParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<InfoRetrieveHealthResponse> + + /** @see retrieveHealth */ + @MustBeClosed + fun retrieveHealth( + params: InfoRetrieveHealthParams = InfoRetrieveHealthParams.none() + ): HttpResponseFor<InfoRetrieveHealthResponse> = + retrieveHealth(params, RequestOptions.none()) + + /** @see retrieveHealth */ + @MustBeClosed + fun retrieveHealth( + requestOptions: RequestOptions + ): HttpResponseFor<InfoRetrieveHealthResponse> = + retrieveHealth(InfoRetrieveHealthParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/InfoServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/InfoServiceImpl.kt new file mode 100644 index 00000000..6848dd93 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/InfoServiceImpl.kt @@ -0,0 +1,112 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.info.InfoListParams +import com.langsmith_api.api.models.api.v1.info.InfoListResponse +import com.langsmith_api.api.models.api.v1.info.InfoRetrieveHealthParams +import com.langsmith_api.api.models.api.v1.info.InfoRetrieveHealthResponse +import java.util.function.Consumer + +class InfoServiceImpl internal constructor(private val clientOptions: ClientOptions) : InfoService { + + private val withRawResponse: InfoService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): InfoService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): InfoService = + InfoServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list(params: InfoListParams, requestOptions: RequestOptions): InfoListResponse = + // get /api/v1/info + withRawResponse().list(params, requestOptions).parse() + + override fun retrieveHealth( + params: InfoRetrieveHealthParams, + requestOptions: RequestOptions, + ): InfoRetrieveHealthResponse = + // get /api/v1/info/health + withRawResponse().retrieveHealth(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + InfoService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): InfoService.WithRawResponse = + InfoServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler<InfoListResponse> = + jsonHandler<InfoListResponse>(clientOptions.jsonMapper) + + override fun list( + params: InfoListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<InfoListResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "info") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHealthHandler: Handler<InfoRetrieveHealthResponse> = + jsonHandler<InfoRetrieveHealthResponse>(clientOptions.jsonMapper) + + override fun retrieveHealth( + params: InfoRetrieveHealthParams, + requestOptions: RequestOptions, + ): HttpResponseFor<InfoRetrieveHealthResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "info", "health") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHealthHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/MeService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/MeService.kt new file mode 100644 index 00000000..0e46fa8c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/MeService.kt @@ -0,0 +1,85 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.me.MeRetrieveLsUserIdParams +import com.langsmith_api.api.services.blocking.api.v1.me.OnboardingStateService +import java.util.function.Consumer + +interface MeService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): MeService + + fun onboardingState(): OnboardingStateService + + /** Get the LangSmith user ID for the current user. */ + fun retrieveLsUserId(): String = retrieveLsUserId(MeRetrieveLsUserIdParams.none()) + + /** @see retrieveLsUserId */ + fun retrieveLsUserId( + params: MeRetrieveLsUserIdParams = MeRetrieveLsUserIdParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): String + + /** @see retrieveLsUserId */ + fun retrieveLsUserId( + params: MeRetrieveLsUserIdParams = MeRetrieveLsUserIdParams.none() + ): String = retrieveLsUserId(params, RequestOptions.none()) + + /** @see retrieveLsUserId */ + fun retrieveLsUserId(requestOptions: RequestOptions): String = + retrieveLsUserId(MeRetrieveLsUserIdParams.none(), requestOptions) + + /** A view of [MeService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): MeService.WithRawResponse + + fun onboardingState(): OnboardingStateService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/me/ls_user_id`, but is otherwise the same as + * [MeService.retrieveLsUserId]. + */ + @MustBeClosed + fun retrieveLsUserId(): HttpResponseFor<String> = + retrieveLsUserId(MeRetrieveLsUserIdParams.none()) + + /** @see retrieveLsUserId */ + @MustBeClosed + fun retrieveLsUserId( + params: MeRetrieveLsUserIdParams = MeRetrieveLsUserIdParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<String> + + /** @see retrieveLsUserId */ + @MustBeClosed + fun retrieveLsUserId( + params: MeRetrieveLsUserIdParams = MeRetrieveLsUserIdParams.none() + ): HttpResponseFor<String> = retrieveLsUserId(params, RequestOptions.none()) + + /** @see retrieveLsUserId */ + @MustBeClosed + fun retrieveLsUserId(requestOptions: RequestOptions): HttpResponseFor<String> = + retrieveLsUserId(MeRetrieveLsUserIdParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/MeServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/MeServiceImpl.kt new file mode 100644 index 00000000..d913c5b2 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/MeServiceImpl.kt @@ -0,0 +1,85 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.stringHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.me.MeRetrieveLsUserIdParams +import com.langsmith_api.api.services.blocking.api.v1.me.OnboardingStateService +import com.langsmith_api.api.services.blocking.api.v1.me.OnboardingStateServiceImpl +import java.util.function.Consumer + +class MeServiceImpl internal constructor(private val clientOptions: ClientOptions) : MeService { + + private val withRawResponse: MeService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val onboardingState: OnboardingStateService by lazy { + OnboardingStateServiceImpl(clientOptions) + } + + override fun withRawResponse(): MeService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): MeService = + MeServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun onboardingState(): OnboardingStateService = onboardingState + + override fun retrieveLsUserId( + params: MeRetrieveLsUserIdParams, + requestOptions: RequestOptions, + ): String = + // get /api/v1/me/ls_user_id + withRawResponse().retrieveLsUserId(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + MeService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val onboardingState: OnboardingStateService.WithRawResponse by lazy { + OnboardingStateServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): MeService.WithRawResponse = + MeServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun onboardingState(): OnboardingStateService.WithRawResponse = onboardingState + + private val retrieveLsUserIdHandler: Handler<String> = stringHandler() + + override fun retrieveLsUserId( + params: MeRetrieveLsUserIdParams, + requestOptions: RequestOptions, + ): HttpResponseFor<String> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "me", "ls_user_id") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { retrieveLsUserIdHandler.handle(it) } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ModelPriceMapService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ModelPriceMapService.kt new file mode 100644 index 00000000..f7910f90 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ModelPriceMapService.kt @@ -0,0 +1,259 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.modelpricemap.ModelPriceMapDeleteParams +import com.langsmith_api.api.models.api.v1.modelpricemap.ModelPriceMapDeleteResponse +import com.langsmith_api.api.models.api.v1.modelpricemap.ModelPriceMapModelPriceMapParams +import com.langsmith_api.api.models.api.v1.modelpricemap.ModelPriceMapModelPriceMapResponse +import com.langsmith_api.api.models.api.v1.modelpricemap.ModelPriceMapRetrieveModelPriceMapParams +import com.langsmith_api.api.models.api.v1.modelpricemap.ModelPriceMapRetrieveModelPriceMapResponse +import com.langsmith_api.api.models.api.v1.modelpricemap.ModelPriceMapUpdateParams +import com.langsmith_api.api.models.api.v1.modelpricemap.ModelPriceMapUpdateResponse +import java.util.function.Consumer + +interface ModelPriceMapService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ModelPriceMapService + + /** Update Model Price */ + fun update(id: String, params: ModelPriceMapUpdateParams): ModelPriceMapUpdateResponse = + update(id, params, RequestOptions.none()) + + /** @see update */ + fun update( + id: String, + params: ModelPriceMapUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ModelPriceMapUpdateResponse = update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + fun update(params: ModelPriceMapUpdateParams): ModelPriceMapUpdateResponse = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: ModelPriceMapUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ModelPriceMapUpdateResponse + + /** Delete Model Price */ + fun delete(id: String): ModelPriceMapDeleteResponse = + delete(id, ModelPriceMapDeleteParams.none()) + + /** @see delete */ + fun delete( + id: String, + params: ModelPriceMapDeleteParams = ModelPriceMapDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ModelPriceMapDeleteResponse = delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + fun delete( + id: String, + params: ModelPriceMapDeleteParams = ModelPriceMapDeleteParams.none(), + ): ModelPriceMapDeleteResponse = delete(id, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ModelPriceMapDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ModelPriceMapDeleteResponse + + /** @see delete */ + fun delete(params: ModelPriceMapDeleteParams): ModelPriceMapDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(id: String, requestOptions: RequestOptions): ModelPriceMapDeleteResponse = + delete(id, ModelPriceMapDeleteParams.none(), requestOptions) + + /** Create New Model Price */ + fun modelPriceMap( + params: ModelPriceMapModelPriceMapParams + ): ModelPriceMapModelPriceMapResponse = modelPriceMap(params, RequestOptions.none()) + + /** @see modelPriceMap */ + fun modelPriceMap( + params: ModelPriceMapModelPriceMapParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ModelPriceMapModelPriceMapResponse + + /** Read Model Price Map */ + fun retrieveModelPriceMap(): ModelPriceMapRetrieveModelPriceMapResponse = + retrieveModelPriceMap(ModelPriceMapRetrieveModelPriceMapParams.none()) + + /** @see retrieveModelPriceMap */ + fun retrieveModelPriceMap( + params: ModelPriceMapRetrieveModelPriceMapParams = + ModelPriceMapRetrieveModelPriceMapParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ModelPriceMapRetrieveModelPriceMapResponse + + /** @see retrieveModelPriceMap */ + fun retrieveModelPriceMap( + params: ModelPriceMapRetrieveModelPriceMapParams = + ModelPriceMapRetrieveModelPriceMapParams.none() + ): ModelPriceMapRetrieveModelPriceMapResponse = + retrieveModelPriceMap(params, RequestOptions.none()) + + /** @see retrieveModelPriceMap */ + fun retrieveModelPriceMap( + requestOptions: RequestOptions + ): ModelPriceMapRetrieveModelPriceMapResponse = + retrieveModelPriceMap(ModelPriceMapRetrieveModelPriceMapParams.none(), requestOptions) + + /** + * A view of [ModelPriceMapService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ModelPriceMapService.WithRawResponse + + /** + * Returns a raw HTTP response for `put /api/v1/model-price-map/{id}`, but is otherwise the + * same as [ModelPriceMapService.update]. + */ + @MustBeClosed + fun update( + id: String, + params: ModelPriceMapUpdateParams, + ): HttpResponseFor<ModelPriceMapUpdateResponse> = update(id, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + id: String, + params: ModelPriceMapUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ModelPriceMapUpdateResponse> = + update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update( + params: ModelPriceMapUpdateParams + ): HttpResponseFor<ModelPriceMapUpdateResponse> = update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: ModelPriceMapUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ModelPriceMapUpdateResponse> + + /** + * Returns a raw HTTP response for `delete /api/v1/model-price-map/{id}`, but is otherwise + * the same as [ModelPriceMapService.delete]. + */ + @MustBeClosed + fun delete(id: String): HttpResponseFor<ModelPriceMapDeleteResponse> = + delete(id, ModelPriceMapDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + id: String, + params: ModelPriceMapDeleteParams = ModelPriceMapDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ModelPriceMapDeleteResponse> = + delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + id: String, + params: ModelPriceMapDeleteParams = ModelPriceMapDeleteParams.none(), + ): HttpResponseFor<ModelPriceMapDeleteResponse> = delete(id, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: ModelPriceMapDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ModelPriceMapDeleteResponse> + + /** @see delete */ + @MustBeClosed + fun delete( + params: ModelPriceMapDeleteParams + ): HttpResponseFor<ModelPriceMapDeleteResponse> = delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + id: String, + requestOptions: RequestOptions, + ): HttpResponseFor<ModelPriceMapDeleteResponse> = + delete(id, ModelPriceMapDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/model-price-map`, but is otherwise the same + * as [ModelPriceMapService.modelPriceMap]. + */ + @MustBeClosed + fun modelPriceMap( + params: ModelPriceMapModelPriceMapParams + ): HttpResponseFor<ModelPriceMapModelPriceMapResponse> = + modelPriceMap(params, RequestOptions.none()) + + /** @see modelPriceMap */ + @MustBeClosed + fun modelPriceMap( + params: ModelPriceMapModelPriceMapParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ModelPriceMapModelPriceMapResponse> + + /** + * Returns a raw HTTP response for `get /api/v1/model-price-map`, but is otherwise the same + * as [ModelPriceMapService.retrieveModelPriceMap]. + */ + @MustBeClosed + fun retrieveModelPriceMap(): HttpResponseFor<ModelPriceMapRetrieveModelPriceMapResponse> = + retrieveModelPriceMap(ModelPriceMapRetrieveModelPriceMapParams.none()) + + /** @see retrieveModelPriceMap */ + @MustBeClosed + fun retrieveModelPriceMap( + params: ModelPriceMapRetrieveModelPriceMapParams = + ModelPriceMapRetrieveModelPriceMapParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ModelPriceMapRetrieveModelPriceMapResponse> + + /** @see retrieveModelPriceMap */ + @MustBeClosed + fun retrieveModelPriceMap( + params: ModelPriceMapRetrieveModelPriceMapParams = + ModelPriceMapRetrieveModelPriceMapParams.none() + ): HttpResponseFor<ModelPriceMapRetrieveModelPriceMapResponse> = + retrieveModelPriceMap(params, RequestOptions.none()) + + /** @see retrieveModelPriceMap */ + @MustBeClosed + fun retrieveModelPriceMap( + requestOptions: RequestOptions + ): HttpResponseFor<ModelPriceMapRetrieveModelPriceMapResponse> = + retrieveModelPriceMap(ModelPriceMapRetrieveModelPriceMapParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ModelPriceMapServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ModelPriceMapServiceImpl.kt new file mode 100644 index 00000000..86fdb406 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ModelPriceMapServiceImpl.kt @@ -0,0 +1,201 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.modelpricemap.ModelPriceMapDeleteParams +import com.langsmith_api.api.models.api.v1.modelpricemap.ModelPriceMapDeleteResponse +import com.langsmith_api.api.models.api.v1.modelpricemap.ModelPriceMapModelPriceMapParams +import com.langsmith_api.api.models.api.v1.modelpricemap.ModelPriceMapModelPriceMapResponse +import com.langsmith_api.api.models.api.v1.modelpricemap.ModelPriceMapRetrieveModelPriceMapParams +import com.langsmith_api.api.models.api.v1.modelpricemap.ModelPriceMapRetrieveModelPriceMapResponse +import com.langsmith_api.api.models.api.v1.modelpricemap.ModelPriceMapUpdateParams +import com.langsmith_api.api.models.api.v1.modelpricemap.ModelPriceMapUpdateResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ModelPriceMapServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ModelPriceMapService { + + private val withRawResponse: ModelPriceMapService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ModelPriceMapService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): ModelPriceMapService = + ModelPriceMapServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun update( + params: ModelPriceMapUpdateParams, + requestOptions: RequestOptions, + ): ModelPriceMapUpdateResponse = + // put /api/v1/model-price-map/{id} + withRawResponse().update(params, requestOptions).parse() + + override fun delete( + params: ModelPriceMapDeleteParams, + requestOptions: RequestOptions, + ): ModelPriceMapDeleteResponse = + // delete /api/v1/model-price-map/{id} + withRawResponse().delete(params, requestOptions).parse() + + override fun modelPriceMap( + params: ModelPriceMapModelPriceMapParams, + requestOptions: RequestOptions, + ): ModelPriceMapModelPriceMapResponse = + // post /api/v1/model-price-map + withRawResponse().modelPriceMap(params, requestOptions).parse() + + override fun retrieveModelPriceMap( + params: ModelPriceMapRetrieveModelPriceMapParams, + requestOptions: RequestOptions, + ): ModelPriceMapRetrieveModelPriceMapResponse = + // get /api/v1/model-price-map + withRawResponse().retrieveModelPriceMap(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ModelPriceMapService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ModelPriceMapService.WithRawResponse = + ModelPriceMapServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val updateHandler: Handler<ModelPriceMapUpdateResponse> = + jsonHandler<ModelPriceMapUpdateResponse>(clientOptions.jsonMapper) + + override fun update( + params: ModelPriceMapUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<ModelPriceMapUpdateResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "model-price-map", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val deleteHandler: Handler<ModelPriceMapDeleteResponse> = + jsonHandler<ModelPriceMapDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: ModelPriceMapDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<ModelPriceMapDeleteResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "model-price-map", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val modelPriceMapHandler: Handler<ModelPriceMapModelPriceMapResponse> = + jsonHandler<ModelPriceMapModelPriceMapResponse>(clientOptions.jsonMapper) + + override fun modelPriceMap( + params: ModelPriceMapModelPriceMapParams, + requestOptions: RequestOptions, + ): HttpResponseFor<ModelPriceMapModelPriceMapResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "model-price-map") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { modelPriceMapHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveModelPriceMapHandler: + Handler<ModelPriceMapRetrieveModelPriceMapResponse> = + jsonHandler<ModelPriceMapRetrieveModelPriceMapResponse>(clientOptions.jsonMapper) + + override fun retrieveModelPriceMap( + params: ModelPriceMapRetrieveModelPriceMapParams, + requestOptions: RequestOptions, + ): HttpResponseFor<ModelPriceMapRetrieveModelPriceMapResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "model-price-map") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveModelPriceMapHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/OAuthService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/OAuthService.kt new file mode 100644 index 00000000..4cf8384b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/OAuthService.kt @@ -0,0 +1,373 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.oauth.OAuthProvider +import com.langsmith_api.api.models.api.v1.oauth.OAuthRetrieveCallbackParams +import com.langsmith_api.api.models.api.v1.oauth.OAuthRetrieveCallbackResponse +import com.langsmith_api.api.models.api.v1.oauth.OAuthRetrieveCurrentUserParams +import com.langsmith_api.api.models.api.v1.oauth.OAuthRetrieveCurrentUserResponse +import com.langsmith_api.api.models.api.v1.oauth.OAuthRetrieveLogoutParams +import com.langsmith_api.api.models.api.v1.oauth.OAuthRetrieveLogoutResponse +import com.langsmith_api.api.models.api.v1.oauth.OAuthRetrieveParams +import com.langsmith_api.api.models.api.v1.oauth.OAuthRetrieveResponse +import java.util.function.Consumer + +interface OAuthService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): OAuthService + + /** Oauth Provider Auth */ + fun retrieve(provider: OAuthProvider): OAuthRetrieveResponse = + retrieve(provider, OAuthRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + provider: OAuthProvider, + params: OAuthRetrieveParams = OAuthRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): OAuthRetrieveResponse = + retrieve(params.toBuilder().provider(provider).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + provider: OAuthProvider, + params: OAuthRetrieveParams = OAuthRetrieveParams.none(), + ): OAuthRetrieveResponse = retrieve(provider, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: OAuthRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): OAuthRetrieveResponse + + /** @see retrieve */ + fun retrieve(params: OAuthRetrieveParams): OAuthRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(provider: OAuthProvider, requestOptions: RequestOptions): OAuthRetrieveResponse = + retrieve(provider, OAuthRetrieveParams.none(), requestOptions) + + /** Oauth Provider Callback */ + fun retrieveCallback(provider: OAuthProvider): OAuthRetrieveCallbackResponse = + retrieveCallback(provider, OAuthRetrieveCallbackParams.none()) + + /** @see retrieveCallback */ + fun retrieveCallback( + provider: OAuthProvider, + params: OAuthRetrieveCallbackParams = OAuthRetrieveCallbackParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): OAuthRetrieveCallbackResponse = + retrieveCallback(params.toBuilder().provider(provider).build(), requestOptions) + + /** @see retrieveCallback */ + fun retrieveCallback( + provider: OAuthProvider, + params: OAuthRetrieveCallbackParams = OAuthRetrieveCallbackParams.none(), + ): OAuthRetrieveCallbackResponse = retrieveCallback(provider, params, RequestOptions.none()) + + /** @see retrieveCallback */ + fun retrieveCallback( + params: OAuthRetrieveCallbackParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): OAuthRetrieveCallbackResponse + + /** @see retrieveCallback */ + fun retrieveCallback(params: OAuthRetrieveCallbackParams): OAuthRetrieveCallbackResponse = + retrieveCallback(params, RequestOptions.none()) + + /** @see retrieveCallback */ + fun retrieveCallback( + provider: OAuthProvider, + requestOptions: RequestOptions, + ): OAuthRetrieveCallbackResponse = + retrieveCallback(provider, OAuthRetrieveCallbackParams.none(), requestOptions) + + /** Oauth Provider Current User */ + fun retrieveCurrentUser(provider: OAuthProvider): OAuthRetrieveCurrentUserResponse = + retrieveCurrentUser(provider, OAuthRetrieveCurrentUserParams.none()) + + /** @see retrieveCurrentUser */ + fun retrieveCurrentUser( + provider: OAuthProvider, + params: OAuthRetrieveCurrentUserParams = OAuthRetrieveCurrentUserParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): OAuthRetrieveCurrentUserResponse = + retrieveCurrentUser(params.toBuilder().provider(provider).build(), requestOptions) + + /** @see retrieveCurrentUser */ + fun retrieveCurrentUser( + provider: OAuthProvider, + params: OAuthRetrieveCurrentUserParams = OAuthRetrieveCurrentUserParams.none(), + ): OAuthRetrieveCurrentUserResponse = + retrieveCurrentUser(provider, params, RequestOptions.none()) + + /** @see retrieveCurrentUser */ + fun retrieveCurrentUser( + params: OAuthRetrieveCurrentUserParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): OAuthRetrieveCurrentUserResponse + + /** @see retrieveCurrentUser */ + fun retrieveCurrentUser( + params: OAuthRetrieveCurrentUserParams + ): OAuthRetrieveCurrentUserResponse = retrieveCurrentUser(params, RequestOptions.none()) + + /** @see retrieveCurrentUser */ + fun retrieveCurrentUser( + provider: OAuthProvider, + requestOptions: RequestOptions, + ): OAuthRetrieveCurrentUserResponse = + retrieveCurrentUser(provider, OAuthRetrieveCurrentUserParams.none(), requestOptions) + + /** Oauth Provider Logout */ + fun retrieveLogout(provider: OAuthProvider): OAuthRetrieveLogoutResponse = + retrieveLogout(provider, OAuthRetrieveLogoutParams.none()) + + /** @see retrieveLogout */ + fun retrieveLogout( + provider: OAuthProvider, + params: OAuthRetrieveLogoutParams = OAuthRetrieveLogoutParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): OAuthRetrieveLogoutResponse = + retrieveLogout(params.toBuilder().provider(provider).build(), requestOptions) + + /** @see retrieveLogout */ + fun retrieveLogout( + provider: OAuthProvider, + params: OAuthRetrieveLogoutParams = OAuthRetrieveLogoutParams.none(), + ): OAuthRetrieveLogoutResponse = retrieveLogout(provider, params, RequestOptions.none()) + + /** @see retrieveLogout */ + fun retrieveLogout( + params: OAuthRetrieveLogoutParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): OAuthRetrieveLogoutResponse + + /** @see retrieveLogout */ + fun retrieveLogout(params: OAuthRetrieveLogoutParams): OAuthRetrieveLogoutResponse = + retrieveLogout(params, RequestOptions.none()) + + /** @see retrieveLogout */ + fun retrieveLogout( + provider: OAuthProvider, + requestOptions: RequestOptions, + ): OAuthRetrieveLogoutResponse = + retrieveLogout(provider, OAuthRetrieveLogoutParams.none(), requestOptions) + + /** A view of [OAuthService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): OAuthService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/oauth/{provider}`, but is otherwise the same + * as [OAuthService.retrieve]. + */ + @MustBeClosed + fun retrieve(provider: OAuthProvider): HttpResponseFor<OAuthRetrieveResponse> = + retrieve(provider, OAuthRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + provider: OAuthProvider, + params: OAuthRetrieveParams = OAuthRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<OAuthRetrieveResponse> = + retrieve(params.toBuilder().provider(provider).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + provider: OAuthProvider, + params: OAuthRetrieveParams = OAuthRetrieveParams.none(), + ): HttpResponseFor<OAuthRetrieveResponse> = + retrieve(provider, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: OAuthRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<OAuthRetrieveResponse> + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: OAuthRetrieveParams): HttpResponseFor<OAuthRetrieveResponse> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + provider: OAuthProvider, + requestOptions: RequestOptions, + ): HttpResponseFor<OAuthRetrieveResponse> = + retrieve(provider, OAuthRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/oauth/{provider}/callback`, but is otherwise + * the same as [OAuthService.retrieveCallback]. + */ + @MustBeClosed + fun retrieveCallback( + provider: OAuthProvider + ): HttpResponseFor<OAuthRetrieveCallbackResponse> = + retrieveCallback(provider, OAuthRetrieveCallbackParams.none()) + + /** @see retrieveCallback */ + @MustBeClosed + fun retrieveCallback( + provider: OAuthProvider, + params: OAuthRetrieveCallbackParams = OAuthRetrieveCallbackParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<OAuthRetrieveCallbackResponse> = + retrieveCallback(params.toBuilder().provider(provider).build(), requestOptions) + + /** @see retrieveCallback */ + @MustBeClosed + fun retrieveCallback( + provider: OAuthProvider, + params: OAuthRetrieveCallbackParams = OAuthRetrieveCallbackParams.none(), + ): HttpResponseFor<OAuthRetrieveCallbackResponse> = + retrieveCallback(provider, params, RequestOptions.none()) + + /** @see retrieveCallback */ + @MustBeClosed + fun retrieveCallback( + params: OAuthRetrieveCallbackParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<OAuthRetrieveCallbackResponse> + + /** @see retrieveCallback */ + @MustBeClosed + fun retrieveCallback( + params: OAuthRetrieveCallbackParams + ): HttpResponseFor<OAuthRetrieveCallbackResponse> = + retrieveCallback(params, RequestOptions.none()) + + /** @see retrieveCallback */ + @MustBeClosed + fun retrieveCallback( + provider: OAuthProvider, + requestOptions: RequestOptions, + ): HttpResponseFor<OAuthRetrieveCallbackResponse> = + retrieveCallback(provider, OAuthRetrieveCallbackParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/oauth/{provider}/current-user`, but is + * otherwise the same as [OAuthService.retrieveCurrentUser]. + */ + @MustBeClosed + fun retrieveCurrentUser( + provider: OAuthProvider + ): HttpResponseFor<OAuthRetrieveCurrentUserResponse> = + retrieveCurrentUser(provider, OAuthRetrieveCurrentUserParams.none()) + + /** @see retrieveCurrentUser */ + @MustBeClosed + fun retrieveCurrentUser( + provider: OAuthProvider, + params: OAuthRetrieveCurrentUserParams = OAuthRetrieveCurrentUserParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<OAuthRetrieveCurrentUserResponse> = + retrieveCurrentUser(params.toBuilder().provider(provider).build(), requestOptions) + + /** @see retrieveCurrentUser */ + @MustBeClosed + fun retrieveCurrentUser( + provider: OAuthProvider, + params: OAuthRetrieveCurrentUserParams = OAuthRetrieveCurrentUserParams.none(), + ): HttpResponseFor<OAuthRetrieveCurrentUserResponse> = + retrieveCurrentUser(provider, params, RequestOptions.none()) + + /** @see retrieveCurrentUser */ + @MustBeClosed + fun retrieveCurrentUser( + params: OAuthRetrieveCurrentUserParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<OAuthRetrieveCurrentUserResponse> + + /** @see retrieveCurrentUser */ + @MustBeClosed + fun retrieveCurrentUser( + params: OAuthRetrieveCurrentUserParams + ): HttpResponseFor<OAuthRetrieveCurrentUserResponse> = + retrieveCurrentUser(params, RequestOptions.none()) + + /** @see retrieveCurrentUser */ + @MustBeClosed + fun retrieveCurrentUser( + provider: OAuthProvider, + requestOptions: RequestOptions, + ): HttpResponseFor<OAuthRetrieveCurrentUserResponse> = + retrieveCurrentUser(provider, OAuthRetrieveCurrentUserParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/oauth/{provider}/logout`, but is otherwise + * the same as [OAuthService.retrieveLogout]. + */ + @MustBeClosed + fun retrieveLogout(provider: OAuthProvider): HttpResponseFor<OAuthRetrieveLogoutResponse> = + retrieveLogout(provider, OAuthRetrieveLogoutParams.none()) + + /** @see retrieveLogout */ + @MustBeClosed + fun retrieveLogout( + provider: OAuthProvider, + params: OAuthRetrieveLogoutParams = OAuthRetrieveLogoutParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<OAuthRetrieveLogoutResponse> = + retrieveLogout(params.toBuilder().provider(provider).build(), requestOptions) + + /** @see retrieveLogout */ + @MustBeClosed + fun retrieveLogout( + provider: OAuthProvider, + params: OAuthRetrieveLogoutParams = OAuthRetrieveLogoutParams.none(), + ): HttpResponseFor<OAuthRetrieveLogoutResponse> = + retrieveLogout(provider, params, RequestOptions.none()) + + /** @see retrieveLogout */ + @MustBeClosed + fun retrieveLogout( + params: OAuthRetrieveLogoutParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<OAuthRetrieveLogoutResponse> + + /** @see retrieveLogout */ + @MustBeClosed + fun retrieveLogout( + params: OAuthRetrieveLogoutParams + ): HttpResponseFor<OAuthRetrieveLogoutResponse> = + retrieveLogout(params, RequestOptions.none()) + + /** @see retrieveLogout */ + @MustBeClosed + fun retrieveLogout( + provider: OAuthProvider, + requestOptions: RequestOptions, + ): HttpResponseFor<OAuthRetrieveLogoutResponse> = + retrieveLogout(provider, OAuthRetrieveLogoutParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/OAuthServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/OAuthServiceImpl.kt new file mode 100644 index 00000000..a0c322e3 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/OAuthServiceImpl.kt @@ -0,0 +1,202 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.oauth.OAuthRetrieveCallbackParams +import com.langsmith_api.api.models.api.v1.oauth.OAuthRetrieveCallbackResponse +import com.langsmith_api.api.models.api.v1.oauth.OAuthRetrieveCurrentUserParams +import com.langsmith_api.api.models.api.v1.oauth.OAuthRetrieveCurrentUserResponse +import com.langsmith_api.api.models.api.v1.oauth.OAuthRetrieveLogoutParams +import com.langsmith_api.api.models.api.v1.oauth.OAuthRetrieveLogoutResponse +import com.langsmith_api.api.models.api.v1.oauth.OAuthRetrieveParams +import com.langsmith_api.api.models.api.v1.oauth.OAuthRetrieveResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class OAuthServiceImpl internal constructor(private val clientOptions: ClientOptions) : + OAuthService { + + private val withRawResponse: OAuthService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): OAuthService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): OAuthService = + OAuthServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: OAuthRetrieveParams, + requestOptions: RequestOptions, + ): OAuthRetrieveResponse = + // get /api/v1/oauth/{provider} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun retrieveCallback( + params: OAuthRetrieveCallbackParams, + requestOptions: RequestOptions, + ): OAuthRetrieveCallbackResponse = + // get /api/v1/oauth/{provider}/callback + withRawResponse().retrieveCallback(params, requestOptions).parse() + + override fun retrieveCurrentUser( + params: OAuthRetrieveCurrentUserParams, + requestOptions: RequestOptions, + ): OAuthRetrieveCurrentUserResponse = + // get /api/v1/oauth/{provider}/current-user + withRawResponse().retrieveCurrentUser(params, requestOptions).parse() + + override fun retrieveLogout( + params: OAuthRetrieveLogoutParams, + requestOptions: RequestOptions, + ): OAuthRetrieveLogoutResponse = + // get /api/v1/oauth/{provider}/logout + withRawResponse().retrieveLogout(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + OAuthService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): OAuthService.WithRawResponse = + OAuthServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler<OAuthRetrieveResponse> = + jsonHandler<OAuthRetrieveResponse>(clientOptions.jsonMapper) + + override fun retrieve( + params: OAuthRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor<OAuthRetrieveResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("provider", params.provider().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "oauth", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveCallbackHandler: Handler<OAuthRetrieveCallbackResponse> = + jsonHandler<OAuthRetrieveCallbackResponse>(clientOptions.jsonMapper) + + override fun retrieveCallback( + params: OAuthRetrieveCallbackParams, + requestOptions: RequestOptions, + ): HttpResponseFor<OAuthRetrieveCallbackResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("provider", params.provider().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "oauth", params._pathParam(0), "callback") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveCallbackHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveCurrentUserHandler: Handler<OAuthRetrieveCurrentUserResponse> = + jsonHandler<OAuthRetrieveCurrentUserResponse>(clientOptions.jsonMapper) + + override fun retrieveCurrentUser( + params: OAuthRetrieveCurrentUserParams, + requestOptions: RequestOptions, + ): HttpResponseFor<OAuthRetrieveCurrentUserResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("provider", params.provider().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "oauth", params._pathParam(0), "current-user") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveCurrentUserHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveLogoutHandler: Handler<OAuthRetrieveLogoutResponse> = + jsonHandler<OAuthRetrieveLogoutResponse>(clientOptions.jsonMapper) + + override fun retrieveLogout( + params: OAuthRetrieveLogoutParams, + requestOptions: RequestOptions, + ): HttpResponseFor<OAuthRetrieveLogoutResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("provider", params.provider().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "oauth", params._pathParam(0), "logout") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveLogoutHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/OrgChartService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/OrgChartService.kt new file mode 100644 index 00000000..913cf306 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/OrgChartService.kt @@ -0,0 +1,353 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.charts.CustomChartCreate +import com.langsmith_api.api.models.api.v1.charts.CustomChartPreviewRequest +import com.langsmith_api.api.models.api.v1.charts.CustomChartResponse +import com.langsmith_api.api.models.api.v1.charts.CustomChartsRequest +import com.langsmith_api.api.models.api.v1.charts.CustomChartsResponse +import com.langsmith_api.api.models.api.v1.charts.SingleCustomChartResponseBase +import com.langsmith_api.api.models.api.v1.orgcharts.OrgChartCreateParams +import com.langsmith_api.api.models.api.v1.orgcharts.OrgChartDeleteParams +import com.langsmith_api.api.models.api.v1.orgcharts.OrgChartDeleteResponse +import com.langsmith_api.api.models.api.v1.orgcharts.OrgChartOrgChartsParams +import com.langsmith_api.api.models.api.v1.orgcharts.OrgChartPreviewParams +import com.langsmith_api.api.models.api.v1.orgcharts.OrgChartUpdateParams +import com.langsmith_api.api.services.blocking.api.v1.orgcharts.SectionService +import java.util.function.Consumer + +interface OrgChartService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): OrgChartService + + fun section(): SectionService + + /** Create a new chart. */ + fun create(params: OrgChartCreateParams): CustomChartResponse = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: OrgChartCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomChartResponse + + /** @see create */ + fun create( + customChartCreate: CustomChartCreate, + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomChartResponse = + create( + OrgChartCreateParams.builder().customChartCreate(customChartCreate).build(), + requestOptions, + ) + + /** @see create */ + fun create(customChartCreate: CustomChartCreate): CustomChartResponse = + create(customChartCreate, RequestOptions.none()) + + /** Update a chart. */ + fun update(chartId: String, params: OrgChartUpdateParams): CustomChartResponse = + update(chartId, params, RequestOptions.none()) + + /** @see update */ + fun update( + chartId: String, + params: OrgChartUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomChartResponse = update(params.toBuilder().chartId(chartId).build(), requestOptions) + + /** @see update */ + fun update(params: OrgChartUpdateParams): CustomChartResponse = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: OrgChartUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomChartResponse + + /** Delete a chart. */ + fun delete(chartId: String): OrgChartDeleteResponse = + delete(chartId, OrgChartDeleteParams.none()) + + /** @see delete */ + fun delete( + chartId: String, + params: OrgChartDeleteParams = OrgChartDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): OrgChartDeleteResponse = delete(params.toBuilder().chartId(chartId).build(), requestOptions) + + /** @see delete */ + fun delete( + chartId: String, + params: OrgChartDeleteParams = OrgChartDeleteParams.none(), + ): OrgChartDeleteResponse = delete(chartId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: OrgChartDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): OrgChartDeleteResponse + + /** @see delete */ + fun delete(params: OrgChartDeleteParams): OrgChartDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(chartId: String, requestOptions: RequestOptions): OrgChartDeleteResponse = + delete(chartId, OrgChartDeleteParams.none(), requestOptions) + + /** Get all charts for the tenant. */ + fun orgCharts(params: OrgChartOrgChartsParams): CustomChartsResponse = + orgCharts(params, RequestOptions.none()) + + /** @see orgCharts */ + fun orgCharts( + params: OrgChartOrgChartsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomChartsResponse + + /** @see orgCharts */ + fun orgCharts( + customChartsRequest: CustomChartsRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomChartsResponse = + orgCharts( + OrgChartOrgChartsParams.builder().customChartsRequest(customChartsRequest).build(), + requestOptions, + ) + + /** @see orgCharts */ + fun orgCharts(customChartsRequest: CustomChartsRequest): CustomChartsResponse = + orgCharts(customChartsRequest, RequestOptions.none()) + + /** Get a preview for a chart without actually creating it. */ + fun preview(params: OrgChartPreviewParams): SingleCustomChartResponseBase = + preview(params, RequestOptions.none()) + + /** @see preview */ + fun preview( + params: OrgChartPreviewParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SingleCustomChartResponseBase + + /** @see preview */ + fun preview( + customChartPreviewRequest: CustomChartPreviewRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): SingleCustomChartResponseBase = + preview( + OrgChartPreviewParams.builder() + .customChartPreviewRequest(customChartPreviewRequest) + .build(), + requestOptions, + ) + + /** @see preview */ + fun preview( + customChartPreviewRequest: CustomChartPreviewRequest + ): SingleCustomChartResponseBase = preview(customChartPreviewRequest, RequestOptions.none()) + + /** A view of [OrgChartService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): OrgChartService.WithRawResponse + + fun section(): SectionService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/org-charts/create`, but is otherwise the + * same as [OrgChartService.create]. + */ + @MustBeClosed + fun create(params: OrgChartCreateParams): HttpResponseFor<CustomChartResponse> = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: OrgChartCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CustomChartResponse> + + /** @see create */ + @MustBeClosed + fun create( + customChartCreate: CustomChartCreate, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CustomChartResponse> = + create( + OrgChartCreateParams.builder().customChartCreate(customChartCreate).build(), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create(customChartCreate: CustomChartCreate): HttpResponseFor<CustomChartResponse> = + create(customChartCreate, RequestOptions.none()) + + /** + * Returns a raw HTTP response for `patch /api/v1/org-charts/{chart_id}`, but is otherwise + * the same as [OrgChartService.update]. + */ + @MustBeClosed + fun update( + chartId: String, + params: OrgChartUpdateParams, + ): HttpResponseFor<CustomChartResponse> = update(chartId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + chartId: String, + params: OrgChartUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CustomChartResponse> = + update(params.toBuilder().chartId(chartId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(params: OrgChartUpdateParams): HttpResponseFor<CustomChartResponse> = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: OrgChartUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CustomChartResponse> + + /** + * Returns a raw HTTP response for `delete /api/v1/org-charts/{chart_id}`, but is otherwise + * the same as [OrgChartService.delete]. + */ + @MustBeClosed + fun delete(chartId: String): HttpResponseFor<OrgChartDeleteResponse> = + delete(chartId, OrgChartDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + chartId: String, + params: OrgChartDeleteParams = OrgChartDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<OrgChartDeleteResponse> = + delete(params.toBuilder().chartId(chartId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + chartId: String, + params: OrgChartDeleteParams = OrgChartDeleteParams.none(), + ): HttpResponseFor<OrgChartDeleteResponse> = delete(chartId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: OrgChartDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<OrgChartDeleteResponse> + + /** @see delete */ + @MustBeClosed + fun delete(params: OrgChartDeleteParams): HttpResponseFor<OrgChartDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + chartId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<OrgChartDeleteResponse> = + delete(chartId, OrgChartDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/org-charts`, but is otherwise the same as + * [OrgChartService.orgCharts]. + */ + @MustBeClosed + fun orgCharts(params: OrgChartOrgChartsParams): HttpResponseFor<CustomChartsResponse> = + orgCharts(params, RequestOptions.none()) + + /** @see orgCharts */ + @MustBeClosed + fun orgCharts( + params: OrgChartOrgChartsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CustomChartsResponse> + + /** @see orgCharts */ + @MustBeClosed + fun orgCharts( + customChartsRequest: CustomChartsRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CustomChartsResponse> = + orgCharts( + OrgChartOrgChartsParams.builder().customChartsRequest(customChartsRequest).build(), + requestOptions, + ) + + /** @see orgCharts */ + @MustBeClosed + fun orgCharts( + customChartsRequest: CustomChartsRequest + ): HttpResponseFor<CustomChartsResponse> = + orgCharts(customChartsRequest, RequestOptions.none()) + + /** + * Returns a raw HTTP response for `post /api/v1/org-charts/preview`, but is otherwise the + * same as [OrgChartService.preview]. + */ + @MustBeClosed + fun preview(params: OrgChartPreviewParams): HttpResponseFor<SingleCustomChartResponseBase> = + preview(params, RequestOptions.none()) + + /** @see preview */ + @MustBeClosed + fun preview( + params: OrgChartPreviewParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<SingleCustomChartResponseBase> + + /** @see preview */ + @MustBeClosed + fun preview( + customChartPreviewRequest: CustomChartPreviewRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<SingleCustomChartResponseBase> = + preview( + OrgChartPreviewParams.builder() + .customChartPreviewRequest(customChartPreviewRequest) + .build(), + requestOptions, + ) + + /** @see preview */ + @MustBeClosed + fun preview( + customChartPreviewRequest: CustomChartPreviewRequest + ): HttpResponseFor<SingleCustomChartResponseBase> = + preview(customChartPreviewRequest, RequestOptions.none()) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/OrgChartServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/OrgChartServiceImpl.kt new file mode 100644 index 00000000..67842239 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/OrgChartServiceImpl.kt @@ -0,0 +1,249 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.charts.CustomChartResponse +import com.langsmith_api.api.models.api.v1.charts.CustomChartsResponse +import com.langsmith_api.api.models.api.v1.charts.SingleCustomChartResponseBase +import com.langsmith_api.api.models.api.v1.orgcharts.OrgChartCreateParams +import com.langsmith_api.api.models.api.v1.orgcharts.OrgChartDeleteParams +import com.langsmith_api.api.models.api.v1.orgcharts.OrgChartDeleteResponse +import com.langsmith_api.api.models.api.v1.orgcharts.OrgChartOrgChartsParams +import com.langsmith_api.api.models.api.v1.orgcharts.OrgChartPreviewParams +import com.langsmith_api.api.models.api.v1.orgcharts.OrgChartUpdateParams +import com.langsmith_api.api.services.blocking.api.v1.orgcharts.SectionService +import com.langsmith_api.api.services.blocking.api.v1.orgcharts.SectionServiceImpl +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class OrgChartServiceImpl internal constructor(private val clientOptions: ClientOptions) : + OrgChartService { + + private val withRawResponse: OrgChartService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val section: SectionService by lazy { SectionServiceImpl(clientOptions) } + + override fun withRawResponse(): OrgChartService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): OrgChartService = + OrgChartServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun section(): SectionService = section + + override fun create( + params: OrgChartCreateParams, + requestOptions: RequestOptions, + ): CustomChartResponse = + // post /api/v1/org-charts/create + withRawResponse().create(params, requestOptions).parse() + + override fun update( + params: OrgChartUpdateParams, + requestOptions: RequestOptions, + ): CustomChartResponse = + // patch /api/v1/org-charts/{chart_id} + withRawResponse().update(params, requestOptions).parse() + + override fun delete( + params: OrgChartDeleteParams, + requestOptions: RequestOptions, + ): OrgChartDeleteResponse = + // delete /api/v1/org-charts/{chart_id} + withRawResponse().delete(params, requestOptions).parse() + + override fun orgCharts( + params: OrgChartOrgChartsParams, + requestOptions: RequestOptions, + ): CustomChartsResponse = + // post /api/v1/org-charts + withRawResponse().orgCharts(params, requestOptions).parse() + + override fun preview( + params: OrgChartPreviewParams, + requestOptions: RequestOptions, + ): SingleCustomChartResponseBase = + // post /api/v1/org-charts/preview + withRawResponse().preview(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + OrgChartService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val section: SectionService.WithRawResponse by lazy { + SectionServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): OrgChartService.WithRawResponse = + OrgChartServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun section(): SectionService.WithRawResponse = section + + private val createHandler: Handler<CustomChartResponse> = + jsonHandler<CustomChartResponse>(clientOptions.jsonMapper) + + override fun create( + params: OrgChartCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<CustomChartResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "org-charts", "create") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler<CustomChartResponse> = + jsonHandler<CustomChartResponse>(clientOptions.jsonMapper) + + override fun update( + params: OrgChartUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<CustomChartResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("chartId", params.chartId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "org-charts", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val deleteHandler: Handler<OrgChartDeleteResponse> = + jsonHandler<OrgChartDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: OrgChartDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<OrgChartDeleteResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("chartId", params.chartId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "org-charts", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val orgChartsHandler: Handler<CustomChartsResponse> = + jsonHandler<CustomChartsResponse>(clientOptions.jsonMapper) + + override fun orgCharts( + params: OrgChartOrgChartsParams, + requestOptions: RequestOptions, + ): HttpResponseFor<CustomChartsResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "org-charts") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { orgChartsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val previewHandler: Handler<SingleCustomChartResponseBase> = + jsonHandler<SingleCustomChartResponseBase>(clientOptions.jsonMapper) + + override fun preview( + params: OrgChartPreviewParams, + requestOptions: RequestOptions, + ): HttpResponseFor<SingleCustomChartResponseBase> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "org-charts", "preview") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { previewHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/OrgService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/OrgService.kt new file mode 100644 index 00000000..15b665de --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/OrgService.kt @@ -0,0 +1,175 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.orgs.OrgCreateParams +import com.langsmith_api.api.models.api.v1.orgs.OrgListParams +import com.langsmith_api.api.models.api.v1.orgs.OrgRetrievePermissionsParams +import com.langsmith_api.api.models.api.v1.orgs.OrgRetrievePermissionsResponse +import com.langsmith_api.api.models.api.v1.orgs.OrganizationPgSchemaSlim +import com.langsmith_api.api.services.blocking.api.v1.orgs.CurrentService +import com.langsmith_api.api.services.blocking.api.v1.orgs.MemberService +import com.langsmith_api.api.services.blocking.api.v1.orgs.PendingService +import com.langsmith_api.api.services.blocking.api.v1.orgs.TtlSettingService +import java.util.function.Consumer + +interface OrgService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): OrgService + + fun current(): CurrentService + + fun pending(): PendingService + + fun members(): MemberService + + fun ttlSettings(): TtlSettingService + + /** Create Organization */ + fun create(params: OrgCreateParams): OrganizationPgSchemaSlim = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: OrgCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): OrganizationPgSchemaSlim + + /** Get all orgs visible to this auth */ + fun list(): List<OrganizationPgSchemaSlim> = list(OrgListParams.none()) + + /** @see list */ + fun list( + params: OrgListParams = OrgListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<OrganizationPgSchemaSlim> + + /** @see list */ + fun list(params: OrgListParams = OrgListParams.none()): List<OrganizationPgSchemaSlim> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): List<OrganizationPgSchemaSlim> = + list(OrgListParams.none(), requestOptions) + + /** List Permissions */ + fun retrievePermissions(): List<OrgRetrievePermissionsResponse> = + retrievePermissions(OrgRetrievePermissionsParams.none()) + + /** @see retrievePermissions */ + fun retrievePermissions( + params: OrgRetrievePermissionsParams = OrgRetrievePermissionsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<OrgRetrievePermissionsResponse> + + /** @see retrievePermissions */ + fun retrievePermissions( + params: OrgRetrievePermissionsParams = OrgRetrievePermissionsParams.none() + ): List<OrgRetrievePermissionsResponse> = retrievePermissions(params, RequestOptions.none()) + + /** @see retrievePermissions */ + fun retrievePermissions(requestOptions: RequestOptions): List<OrgRetrievePermissionsResponse> = + retrievePermissions(OrgRetrievePermissionsParams.none(), requestOptions) + + /** A view of [OrgService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): OrgService.WithRawResponse + + fun current(): CurrentService.WithRawResponse + + fun pending(): PendingService.WithRawResponse + + fun members(): MemberService.WithRawResponse + + fun ttlSettings(): TtlSettingService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/orgs`, but is otherwise the same as + * [OrgService.create]. + */ + @MustBeClosed + fun create(params: OrgCreateParams): HttpResponseFor<OrganizationPgSchemaSlim> = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: OrgCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<OrganizationPgSchemaSlim> + + /** + * Returns a raw HTTP response for `get /api/v1/orgs`, but is otherwise the same as + * [OrgService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor<List<OrganizationPgSchemaSlim>> = list(OrgListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: OrgListParams = OrgListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<OrganizationPgSchemaSlim>> + + /** @see list */ + @MustBeClosed + fun list( + params: OrgListParams = OrgListParams.none() + ): HttpResponseFor<List<OrganizationPgSchemaSlim>> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor<List<OrganizationPgSchemaSlim>> = + list(OrgListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/orgs/permissions`, but is otherwise the same + * as [OrgService.retrievePermissions]. + */ + @MustBeClosed + fun retrievePermissions(): HttpResponseFor<List<OrgRetrievePermissionsResponse>> = + retrievePermissions(OrgRetrievePermissionsParams.none()) + + /** @see retrievePermissions */ + @MustBeClosed + fun retrievePermissions( + params: OrgRetrievePermissionsParams = OrgRetrievePermissionsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<OrgRetrievePermissionsResponse>> + + /** @see retrievePermissions */ + @MustBeClosed + fun retrievePermissions( + params: OrgRetrievePermissionsParams = OrgRetrievePermissionsParams.none() + ): HttpResponseFor<List<OrgRetrievePermissionsResponse>> = + retrievePermissions(params, RequestOptions.none()) + + /** @see retrievePermissions */ + @MustBeClosed + fun retrievePermissions( + requestOptions: RequestOptions + ): HttpResponseFor<List<OrgRetrievePermissionsResponse>> = + retrievePermissions(OrgRetrievePermissionsParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/OrgServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/OrgServiceImpl.kt new file mode 100644 index 00000000..17e08214 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/OrgServiceImpl.kt @@ -0,0 +1,200 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.orgs.OrgCreateParams +import com.langsmith_api.api.models.api.v1.orgs.OrgListParams +import com.langsmith_api.api.models.api.v1.orgs.OrgRetrievePermissionsParams +import com.langsmith_api.api.models.api.v1.orgs.OrgRetrievePermissionsResponse +import com.langsmith_api.api.models.api.v1.orgs.OrganizationPgSchemaSlim +import com.langsmith_api.api.services.blocking.api.v1.orgs.CurrentService +import com.langsmith_api.api.services.blocking.api.v1.orgs.CurrentServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.orgs.MemberService +import com.langsmith_api.api.services.blocking.api.v1.orgs.MemberServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.orgs.PendingService +import com.langsmith_api.api.services.blocking.api.v1.orgs.PendingServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.orgs.TtlSettingService +import com.langsmith_api.api.services.blocking.api.v1.orgs.TtlSettingServiceImpl +import java.util.function.Consumer + +class OrgServiceImpl internal constructor(private val clientOptions: ClientOptions) : OrgService { + + private val withRawResponse: OrgService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val current: CurrentService by lazy { CurrentServiceImpl(clientOptions) } + + private val pending: PendingService by lazy { PendingServiceImpl(clientOptions) } + + private val members: MemberService by lazy { MemberServiceImpl(clientOptions) } + + private val ttlSettings: TtlSettingService by lazy { TtlSettingServiceImpl(clientOptions) } + + override fun withRawResponse(): OrgService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): OrgService = + OrgServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun current(): CurrentService = current + + override fun pending(): PendingService = pending + + override fun members(): MemberService = members + + override fun ttlSettings(): TtlSettingService = ttlSettings + + override fun create( + params: OrgCreateParams, + requestOptions: RequestOptions, + ): OrganizationPgSchemaSlim = + // post /api/v1/orgs + withRawResponse().create(params, requestOptions).parse() + + override fun list( + params: OrgListParams, + requestOptions: RequestOptions, + ): List<OrganizationPgSchemaSlim> = + // get /api/v1/orgs + withRawResponse().list(params, requestOptions).parse() + + override fun retrievePermissions( + params: OrgRetrievePermissionsParams, + requestOptions: RequestOptions, + ): List<OrgRetrievePermissionsResponse> = + // get /api/v1/orgs/permissions + withRawResponse().retrievePermissions(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + OrgService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val current: CurrentService.WithRawResponse by lazy { + CurrentServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val pending: PendingService.WithRawResponse by lazy { + PendingServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val members: MemberService.WithRawResponse by lazy { + MemberServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val ttlSettings: TtlSettingService.WithRawResponse by lazy { + TtlSettingServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): OrgService.WithRawResponse = + OrgServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun current(): CurrentService.WithRawResponse = current + + override fun pending(): PendingService.WithRawResponse = pending + + override fun members(): MemberService.WithRawResponse = members + + override fun ttlSettings(): TtlSettingService.WithRawResponse = ttlSettings + + private val createHandler: Handler<OrganizationPgSchemaSlim> = + jsonHandler<OrganizationPgSchemaSlim>(clientOptions.jsonMapper) + + override fun create( + params: OrgCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<OrganizationPgSchemaSlim> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler<List<OrganizationPgSchemaSlim>> = + jsonHandler<List<OrganizationPgSchemaSlim>>(clientOptions.jsonMapper) + + override fun list( + params: OrgListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<OrganizationPgSchemaSlim>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val retrievePermissionsHandler: Handler<List<OrgRetrievePermissionsResponse>> = + jsonHandler<List<OrgRetrievePermissionsResponse>>(clientOptions.jsonMapper) + + override fun retrievePermissions( + params: OrgRetrievePermissionsParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<OrgRetrievePermissionsResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "permissions") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrievePermissionsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/PlaygroundSettingService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/PlaygroundSettingService.kt new file mode 100644 index 00000000..7036053a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/PlaygroundSettingService.kt @@ -0,0 +1,310 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.playgroundsettings.PlaygroundSettingDeleteParams +import com.langsmith_api.api.models.api.v1.playgroundsettings.PlaygroundSettingDeleteResponse +import com.langsmith_api.api.models.api.v1.playgroundsettings.PlaygroundSettingPlaygroundSettingsParams +import com.langsmith_api.api.models.api.v1.playgroundsettings.PlaygroundSettingRetrievePlaygroundSettingsParams +import com.langsmith_api.api.models.api.v1.playgroundsettings.PlaygroundSettingUpdateParams +import com.langsmith_api.api.models.api.v1.playgroundsettings.PlaygroundSettingsResponse +import java.util.function.Consumer + +interface PlaygroundSettingService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): PlaygroundSettingService + + /** Update playground settings. */ + fun update(playgroundSettingsId: String): PlaygroundSettingsResponse = + update(playgroundSettingsId, PlaygroundSettingUpdateParams.none()) + + /** @see update */ + fun update( + playgroundSettingsId: String, + params: PlaygroundSettingUpdateParams = PlaygroundSettingUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): PlaygroundSettingsResponse = + update( + params.toBuilder().playgroundSettingsId(playgroundSettingsId).build(), + requestOptions, + ) + + /** @see update */ + fun update( + playgroundSettingsId: String, + params: PlaygroundSettingUpdateParams = PlaygroundSettingUpdateParams.none(), + ): PlaygroundSettingsResponse = update(playgroundSettingsId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: PlaygroundSettingUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): PlaygroundSettingsResponse + + /** @see update */ + fun update(params: PlaygroundSettingUpdateParams): PlaygroundSettingsResponse = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + playgroundSettingsId: String, + requestOptions: RequestOptions, + ): PlaygroundSettingsResponse = + update(playgroundSettingsId, PlaygroundSettingUpdateParams.none(), requestOptions) + + /** Delete playground settings. */ + fun delete(playgroundSettingsId: String): PlaygroundSettingDeleteResponse = + delete(playgroundSettingsId, PlaygroundSettingDeleteParams.none()) + + /** @see delete */ + fun delete( + playgroundSettingsId: String, + params: PlaygroundSettingDeleteParams = PlaygroundSettingDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): PlaygroundSettingDeleteResponse = + delete( + params.toBuilder().playgroundSettingsId(playgroundSettingsId).build(), + requestOptions, + ) + + /** @see delete */ + fun delete( + playgroundSettingsId: String, + params: PlaygroundSettingDeleteParams = PlaygroundSettingDeleteParams.none(), + ): PlaygroundSettingDeleteResponse = delete(playgroundSettingsId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: PlaygroundSettingDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): PlaygroundSettingDeleteResponse + + /** @see delete */ + fun delete(params: PlaygroundSettingDeleteParams): PlaygroundSettingDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + playgroundSettingsId: String, + requestOptions: RequestOptions, + ): PlaygroundSettingDeleteResponse = + delete(playgroundSettingsId, PlaygroundSettingDeleteParams.none(), requestOptions) + + /** Create playground settings. */ + fun playgroundSettings( + params: PlaygroundSettingPlaygroundSettingsParams + ): PlaygroundSettingsResponse = playgroundSettings(params, RequestOptions.none()) + + /** @see playgroundSettings */ + fun playgroundSettings( + params: PlaygroundSettingPlaygroundSettingsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): PlaygroundSettingsResponse + + /** Get all playground settings for this tenant id. */ + fun retrievePlaygroundSettings(): List<PlaygroundSettingsResponse> = + retrievePlaygroundSettings(PlaygroundSettingRetrievePlaygroundSettingsParams.none()) + + /** @see retrievePlaygroundSettings */ + fun retrievePlaygroundSettings( + params: PlaygroundSettingRetrievePlaygroundSettingsParams = + PlaygroundSettingRetrievePlaygroundSettingsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<PlaygroundSettingsResponse> + + /** @see retrievePlaygroundSettings */ + fun retrievePlaygroundSettings( + params: PlaygroundSettingRetrievePlaygroundSettingsParams = + PlaygroundSettingRetrievePlaygroundSettingsParams.none() + ): List<PlaygroundSettingsResponse> = retrievePlaygroundSettings(params, RequestOptions.none()) + + /** @see retrievePlaygroundSettings */ + fun retrievePlaygroundSettings( + requestOptions: RequestOptions + ): List<PlaygroundSettingsResponse> = + retrievePlaygroundSettings( + PlaygroundSettingRetrievePlaygroundSettingsParams.none(), + requestOptions, + ) + + /** + * A view of [PlaygroundSettingService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PlaygroundSettingService.WithRawResponse + + /** + * Returns a raw HTTP response for `patch + * /api/v1/playground-settings/{playground_settings_id}`, but is otherwise the same as + * [PlaygroundSettingService.update]. + */ + @MustBeClosed + fun update(playgroundSettingsId: String): HttpResponseFor<PlaygroundSettingsResponse> = + update(playgroundSettingsId, PlaygroundSettingUpdateParams.none()) + + /** @see update */ + @MustBeClosed + fun update( + playgroundSettingsId: String, + params: PlaygroundSettingUpdateParams = PlaygroundSettingUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<PlaygroundSettingsResponse> = + update( + params.toBuilder().playgroundSettingsId(playgroundSettingsId).build(), + requestOptions, + ) + + /** @see update */ + @MustBeClosed + fun update( + playgroundSettingsId: String, + params: PlaygroundSettingUpdateParams = PlaygroundSettingUpdateParams.none(), + ): HttpResponseFor<PlaygroundSettingsResponse> = + update(playgroundSettingsId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: PlaygroundSettingUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<PlaygroundSettingsResponse> + + /** @see update */ + @MustBeClosed + fun update( + params: PlaygroundSettingUpdateParams + ): HttpResponseFor<PlaygroundSettingsResponse> = update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + playgroundSettingsId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<PlaygroundSettingsResponse> = + update(playgroundSettingsId, PlaygroundSettingUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete + * /api/v1/playground-settings/{playground_settings_id}`, but is otherwise the same as + * [PlaygroundSettingService.delete]. + */ + @MustBeClosed + fun delete(playgroundSettingsId: String): HttpResponseFor<PlaygroundSettingDeleteResponse> = + delete(playgroundSettingsId, PlaygroundSettingDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + playgroundSettingsId: String, + params: PlaygroundSettingDeleteParams = PlaygroundSettingDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<PlaygroundSettingDeleteResponse> = + delete( + params.toBuilder().playgroundSettingsId(playgroundSettingsId).build(), + requestOptions, + ) + + /** @see delete */ + @MustBeClosed + fun delete( + playgroundSettingsId: String, + params: PlaygroundSettingDeleteParams = PlaygroundSettingDeleteParams.none(), + ): HttpResponseFor<PlaygroundSettingDeleteResponse> = + delete(playgroundSettingsId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: PlaygroundSettingDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<PlaygroundSettingDeleteResponse> + + /** @see delete */ + @MustBeClosed + fun delete( + params: PlaygroundSettingDeleteParams + ): HttpResponseFor<PlaygroundSettingDeleteResponse> = delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + playgroundSettingsId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<PlaygroundSettingDeleteResponse> = + delete(playgroundSettingsId, PlaygroundSettingDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/playground-settings`, but is otherwise the + * same as [PlaygroundSettingService.playgroundSettings]. + */ + @MustBeClosed + fun playgroundSettings( + params: PlaygroundSettingPlaygroundSettingsParams + ): HttpResponseFor<PlaygroundSettingsResponse> = + playgroundSettings(params, RequestOptions.none()) + + /** @see playgroundSettings */ + @MustBeClosed + fun playgroundSettings( + params: PlaygroundSettingPlaygroundSettingsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<PlaygroundSettingsResponse> + + /** + * Returns a raw HTTP response for `get /api/v1/playground-settings`, but is otherwise the + * same as [PlaygroundSettingService.retrievePlaygroundSettings]. + */ + @MustBeClosed + fun retrievePlaygroundSettings(): HttpResponseFor<List<PlaygroundSettingsResponse>> = + retrievePlaygroundSettings(PlaygroundSettingRetrievePlaygroundSettingsParams.none()) + + /** @see retrievePlaygroundSettings */ + @MustBeClosed + fun retrievePlaygroundSettings( + params: PlaygroundSettingRetrievePlaygroundSettingsParams = + PlaygroundSettingRetrievePlaygroundSettingsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<PlaygroundSettingsResponse>> + + /** @see retrievePlaygroundSettings */ + @MustBeClosed + fun retrievePlaygroundSettings( + params: PlaygroundSettingRetrievePlaygroundSettingsParams = + PlaygroundSettingRetrievePlaygroundSettingsParams.none() + ): HttpResponseFor<List<PlaygroundSettingsResponse>> = + retrievePlaygroundSettings(params, RequestOptions.none()) + + /** @see retrievePlaygroundSettings */ + @MustBeClosed + fun retrievePlaygroundSettings( + requestOptions: RequestOptions + ): HttpResponseFor<List<PlaygroundSettingsResponse>> = + retrievePlaygroundSettings( + PlaygroundSettingRetrievePlaygroundSettingsParams.none(), + requestOptions, + ) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/PlaygroundSettingServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/PlaygroundSettingServiceImpl.kt new file mode 100644 index 00000000..cdcbd74b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/PlaygroundSettingServiceImpl.kt @@ -0,0 +1,198 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.playgroundsettings.PlaygroundSettingDeleteParams +import com.langsmith_api.api.models.api.v1.playgroundsettings.PlaygroundSettingDeleteResponse +import com.langsmith_api.api.models.api.v1.playgroundsettings.PlaygroundSettingPlaygroundSettingsParams +import com.langsmith_api.api.models.api.v1.playgroundsettings.PlaygroundSettingRetrievePlaygroundSettingsParams +import com.langsmith_api.api.models.api.v1.playgroundsettings.PlaygroundSettingUpdateParams +import com.langsmith_api.api.models.api.v1.playgroundsettings.PlaygroundSettingsResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class PlaygroundSettingServiceImpl internal constructor(private val clientOptions: ClientOptions) : + PlaygroundSettingService { + + private val withRawResponse: PlaygroundSettingService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): PlaygroundSettingService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): PlaygroundSettingService = + PlaygroundSettingServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun update( + params: PlaygroundSettingUpdateParams, + requestOptions: RequestOptions, + ): PlaygroundSettingsResponse = + // patch /api/v1/playground-settings/{playground_settings_id} + withRawResponse().update(params, requestOptions).parse() + + override fun delete( + params: PlaygroundSettingDeleteParams, + requestOptions: RequestOptions, + ): PlaygroundSettingDeleteResponse = + // delete /api/v1/playground-settings/{playground_settings_id} + withRawResponse().delete(params, requestOptions).parse() + + override fun playgroundSettings( + params: PlaygroundSettingPlaygroundSettingsParams, + requestOptions: RequestOptions, + ): PlaygroundSettingsResponse = + // post /api/v1/playground-settings + withRawResponse().playgroundSettings(params, requestOptions).parse() + + override fun retrievePlaygroundSettings( + params: PlaygroundSettingRetrievePlaygroundSettingsParams, + requestOptions: RequestOptions, + ): List<PlaygroundSettingsResponse> = + // get /api/v1/playground-settings + withRawResponse().retrievePlaygroundSettings(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + PlaygroundSettingService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PlaygroundSettingService.WithRawResponse = + PlaygroundSettingServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val updateHandler: Handler<PlaygroundSettingsResponse> = + jsonHandler<PlaygroundSettingsResponse>(clientOptions.jsonMapper) + + override fun update( + params: PlaygroundSettingUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<PlaygroundSettingsResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("playgroundSettingsId", params.playgroundSettingsId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "playground-settings", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val deleteHandler: Handler<PlaygroundSettingDeleteResponse> = + jsonHandler<PlaygroundSettingDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: PlaygroundSettingDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<PlaygroundSettingDeleteResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("playgroundSettingsId", params.playgroundSettingsId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "playground-settings", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val playgroundSettingsHandler: Handler<PlaygroundSettingsResponse> = + jsonHandler<PlaygroundSettingsResponse>(clientOptions.jsonMapper) + + override fun playgroundSettings( + params: PlaygroundSettingPlaygroundSettingsParams, + requestOptions: RequestOptions, + ): HttpResponseFor<PlaygroundSettingsResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "playground-settings") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { playgroundSettingsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrievePlaygroundSettingsHandler: Handler<List<PlaygroundSettingsResponse>> = + jsonHandler<List<PlaygroundSettingsResponse>>(clientOptions.jsonMapper) + + override fun retrievePlaygroundSettings( + params: PlaygroundSettingRetrievePlaygroundSettingsParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<PlaygroundSettingsResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "playground-settings") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrievePlaygroundSettingsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/PromptService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/PromptService.kt new file mode 100644 index 00000000..5092db4c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/PromptService.kt @@ -0,0 +1,90 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.prompts.PromptCanvasParams +import com.langsmith_api.api.models.api.v1.prompts.PromptCanvasResponse +import com.langsmith_api.api.models.api.v1.prompts.PromptInvokePromptParams +import com.langsmith_api.api.models.api.v1.prompts.PromptInvokePromptResponse +import java.util.function.Consumer + +interface PromptService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): PromptService + + /** Prompt Canvas */ + fun canvas(params: PromptCanvasParams): PromptCanvasResponse = + canvas(params, RequestOptions.none()) + + /** @see canvas */ + fun canvas( + params: PromptCanvasParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): PromptCanvasResponse + + /** Invoke Prompt */ + fun invokePrompt(params: PromptInvokePromptParams): PromptInvokePromptResponse = + invokePrompt(params, RequestOptions.none()) + + /** @see invokePrompt */ + fun invokePrompt( + params: PromptInvokePromptParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): PromptInvokePromptResponse + + /** A view of [PromptService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): PromptService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/prompts/canvas`, but is otherwise the same + * as [PromptService.canvas]. + */ + @MustBeClosed + fun canvas(params: PromptCanvasParams): HttpResponseFor<PromptCanvasResponse> = + canvas(params, RequestOptions.none()) + + /** @see canvas */ + @MustBeClosed + fun canvas( + params: PromptCanvasParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<PromptCanvasResponse> + + /** + * Returns a raw HTTP response for `post /api/v1/prompts/invoke_prompt`, but is otherwise + * the same as [PromptService.invokePrompt]. + */ + @MustBeClosed + fun invokePrompt( + params: PromptInvokePromptParams + ): HttpResponseFor<PromptInvokePromptResponse> = invokePrompt(params, RequestOptions.none()) + + /** @see invokePrompt */ + @MustBeClosed + fun invokePrompt( + params: PromptInvokePromptParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<PromptInvokePromptResponse> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/PromptServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/PromptServiceImpl.kt new file mode 100644 index 00000000..c53dd6bd --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/PromptServiceImpl.kt @@ -0,0 +1,119 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.prompts.PromptCanvasParams +import com.langsmith_api.api.models.api.v1.prompts.PromptCanvasResponse +import com.langsmith_api.api.models.api.v1.prompts.PromptInvokePromptParams +import com.langsmith_api.api.models.api.v1.prompts.PromptInvokePromptResponse +import java.util.function.Consumer + +class PromptServiceImpl internal constructor(private val clientOptions: ClientOptions) : + PromptService { + + private val withRawResponse: PromptService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): PromptService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): PromptService = + PromptServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun canvas( + params: PromptCanvasParams, + requestOptions: RequestOptions, + ): PromptCanvasResponse = + // post /api/v1/prompts/canvas + withRawResponse().canvas(params, requestOptions).parse() + + override fun invokePrompt( + params: PromptInvokePromptParams, + requestOptions: RequestOptions, + ): PromptInvokePromptResponse = + // post /api/v1/prompts/invoke_prompt + withRawResponse().invokePrompt(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + PromptService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PromptService.WithRawResponse = + PromptServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val canvasHandler: Handler<PromptCanvasResponse> = + jsonHandler<PromptCanvasResponse>(clientOptions.jsonMapper) + + override fun canvas( + params: PromptCanvasParams, + requestOptions: RequestOptions, + ): HttpResponseFor<PromptCanvasResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "prompts", "canvas") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { canvasHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val invokePromptHandler: Handler<PromptInvokePromptResponse> = + jsonHandler<PromptInvokePromptResponse>(clientOptions.jsonMapper) + + override fun invokePrompt( + params: PromptInvokePromptParams, + requestOptions: RequestOptions, + ): HttpResponseFor<PromptInvokePromptResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "prompts", "invoke_prompt") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { invokePromptHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/PromptWebhookService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/PromptWebhookService.kt new file mode 100644 index 00000000..7a3aeb7f --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/PromptWebhookService.kt @@ -0,0 +1,379 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhook +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhookDeleteParams +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhookDeleteResponse +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhookPromptWebhooksParams +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhookRetrieveParams +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhookRetrievePromptWebhooksParams +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhookTestParams +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhookTestResponse +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhookUpdateParams +import java.util.function.Consumer + +interface PromptWebhookService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): PromptWebhookService + + /** Get a specific prompt webhook. */ + fun retrieve(webhookId: String): PromptWebhook = + retrieve(webhookId, PromptWebhookRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + webhookId: String, + params: PromptWebhookRetrieveParams = PromptWebhookRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): PromptWebhook = retrieve(params.toBuilder().webhookId(webhookId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + webhookId: String, + params: PromptWebhookRetrieveParams = PromptWebhookRetrieveParams.none(), + ): PromptWebhook = retrieve(webhookId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: PromptWebhookRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): PromptWebhook + + /** @see retrieve */ + fun retrieve(params: PromptWebhookRetrieveParams): PromptWebhook = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(webhookId: String, requestOptions: RequestOptions): PromptWebhook = + retrieve(webhookId, PromptWebhookRetrieveParams.none(), requestOptions) + + /** Update a specific prompt webhook. */ + fun update(webhookId: String): PromptWebhook = + update(webhookId, PromptWebhookUpdateParams.none()) + + /** @see update */ + fun update( + webhookId: String, + params: PromptWebhookUpdateParams = PromptWebhookUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): PromptWebhook = update(params.toBuilder().webhookId(webhookId).build(), requestOptions) + + /** @see update */ + fun update( + webhookId: String, + params: PromptWebhookUpdateParams = PromptWebhookUpdateParams.none(), + ): PromptWebhook = update(webhookId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: PromptWebhookUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): PromptWebhook + + /** @see update */ + fun update(params: PromptWebhookUpdateParams): PromptWebhook = + update(params, RequestOptions.none()) + + /** @see update */ + fun update(webhookId: String, requestOptions: RequestOptions): PromptWebhook = + update(webhookId, PromptWebhookUpdateParams.none(), requestOptions) + + /** Delete a specific prompt webhook. */ + fun delete(webhookId: String): PromptWebhookDeleteResponse = + delete(webhookId, PromptWebhookDeleteParams.none()) + + /** @see delete */ + fun delete( + webhookId: String, + params: PromptWebhookDeleteParams = PromptWebhookDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): PromptWebhookDeleteResponse = + delete(params.toBuilder().webhookId(webhookId).build(), requestOptions) + + /** @see delete */ + fun delete( + webhookId: String, + params: PromptWebhookDeleteParams = PromptWebhookDeleteParams.none(), + ): PromptWebhookDeleteResponse = delete(webhookId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: PromptWebhookDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): PromptWebhookDeleteResponse + + /** @see delete */ + fun delete(params: PromptWebhookDeleteParams): PromptWebhookDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(webhookId: String, requestOptions: RequestOptions): PromptWebhookDeleteResponse = + delete(webhookId, PromptWebhookDeleteParams.none(), requestOptions) + + /** Create a new prompt webhook. */ + fun promptWebhooks(params: PromptWebhookPromptWebhooksParams): PromptWebhook = + promptWebhooks(params, RequestOptions.none()) + + /** @see promptWebhooks */ + fun promptWebhooks( + params: PromptWebhookPromptWebhooksParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): PromptWebhook + + /** List all prompt webhooks for the current tenant. */ + fun retrievePromptWebhooks(): List<PromptWebhook> = + retrievePromptWebhooks(PromptWebhookRetrievePromptWebhooksParams.none()) + + /** @see retrievePromptWebhooks */ + fun retrievePromptWebhooks( + params: PromptWebhookRetrievePromptWebhooksParams = + PromptWebhookRetrievePromptWebhooksParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<PromptWebhook> + + /** @see retrievePromptWebhooks */ + fun retrievePromptWebhooks( + params: PromptWebhookRetrievePromptWebhooksParams = + PromptWebhookRetrievePromptWebhooksParams.none() + ): List<PromptWebhook> = retrievePromptWebhooks(params, RequestOptions.none()) + + /** @see retrievePromptWebhooks */ + fun retrievePromptWebhooks(requestOptions: RequestOptions): List<PromptWebhook> = + retrievePromptWebhooks(PromptWebhookRetrievePromptWebhooksParams.none(), requestOptions) + + /** Test a specific prompt webhook. */ + fun test(params: PromptWebhookTestParams): PromptWebhookTestResponse = + test(params, RequestOptions.none()) + + /** @see test */ + fun test( + params: PromptWebhookTestParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): PromptWebhookTestResponse + + /** + * A view of [PromptWebhookService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PromptWebhookService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/prompt-webhooks/{webhook_id}`, but is + * otherwise the same as [PromptWebhookService.retrieve]. + */ + @MustBeClosed + fun retrieve(webhookId: String): HttpResponseFor<PromptWebhook> = + retrieve(webhookId, PromptWebhookRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + webhookId: String, + params: PromptWebhookRetrieveParams = PromptWebhookRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<PromptWebhook> = + retrieve(params.toBuilder().webhookId(webhookId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + webhookId: String, + params: PromptWebhookRetrieveParams = PromptWebhookRetrieveParams.none(), + ): HttpResponseFor<PromptWebhook> = retrieve(webhookId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: PromptWebhookRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<PromptWebhook> + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: PromptWebhookRetrieveParams): HttpResponseFor<PromptWebhook> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + webhookId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<PromptWebhook> = + retrieve(webhookId, PromptWebhookRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `patch /api/v1/prompt-webhooks/{webhook_id}`, but is + * otherwise the same as [PromptWebhookService.update]. + */ + @MustBeClosed + fun update(webhookId: String): HttpResponseFor<PromptWebhook> = + update(webhookId, PromptWebhookUpdateParams.none()) + + /** @see update */ + @MustBeClosed + fun update( + webhookId: String, + params: PromptWebhookUpdateParams = PromptWebhookUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<PromptWebhook> = + update(params.toBuilder().webhookId(webhookId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update( + webhookId: String, + params: PromptWebhookUpdateParams = PromptWebhookUpdateParams.none(), + ): HttpResponseFor<PromptWebhook> = update(webhookId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: PromptWebhookUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<PromptWebhook> + + /** @see update */ + @MustBeClosed + fun update(params: PromptWebhookUpdateParams): HttpResponseFor<PromptWebhook> = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + webhookId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<PromptWebhook> = + update(webhookId, PromptWebhookUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/prompt-webhooks/{webhook_id}`, but is + * otherwise the same as [PromptWebhookService.delete]. + */ + @MustBeClosed + fun delete(webhookId: String): HttpResponseFor<PromptWebhookDeleteResponse> = + delete(webhookId, PromptWebhookDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + webhookId: String, + params: PromptWebhookDeleteParams = PromptWebhookDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<PromptWebhookDeleteResponse> = + delete(params.toBuilder().webhookId(webhookId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + webhookId: String, + params: PromptWebhookDeleteParams = PromptWebhookDeleteParams.none(), + ): HttpResponseFor<PromptWebhookDeleteResponse> = + delete(webhookId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: PromptWebhookDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<PromptWebhookDeleteResponse> + + /** @see delete */ + @MustBeClosed + fun delete( + params: PromptWebhookDeleteParams + ): HttpResponseFor<PromptWebhookDeleteResponse> = delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + webhookId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<PromptWebhookDeleteResponse> = + delete(webhookId, PromptWebhookDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/prompt-webhooks`, but is otherwise the same + * as [PromptWebhookService.promptWebhooks]. + */ + @MustBeClosed + fun promptWebhooks( + params: PromptWebhookPromptWebhooksParams + ): HttpResponseFor<PromptWebhook> = promptWebhooks(params, RequestOptions.none()) + + /** @see promptWebhooks */ + @MustBeClosed + fun promptWebhooks( + params: PromptWebhookPromptWebhooksParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<PromptWebhook> + + /** + * Returns a raw HTTP response for `get /api/v1/prompt-webhooks`, but is otherwise the same + * as [PromptWebhookService.retrievePromptWebhooks]. + */ + @MustBeClosed + fun retrievePromptWebhooks(): HttpResponseFor<List<PromptWebhook>> = + retrievePromptWebhooks(PromptWebhookRetrievePromptWebhooksParams.none()) + + /** @see retrievePromptWebhooks */ + @MustBeClosed + fun retrievePromptWebhooks( + params: PromptWebhookRetrievePromptWebhooksParams = + PromptWebhookRetrievePromptWebhooksParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<PromptWebhook>> + + /** @see retrievePromptWebhooks */ + @MustBeClosed + fun retrievePromptWebhooks( + params: PromptWebhookRetrievePromptWebhooksParams = + PromptWebhookRetrievePromptWebhooksParams.none() + ): HttpResponseFor<List<PromptWebhook>> = + retrievePromptWebhooks(params, RequestOptions.none()) + + /** @see retrievePromptWebhooks */ + @MustBeClosed + fun retrievePromptWebhooks( + requestOptions: RequestOptions + ): HttpResponseFor<List<PromptWebhook>> = + retrievePromptWebhooks(PromptWebhookRetrievePromptWebhooksParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/prompt-webhooks/test`, but is otherwise the + * same as [PromptWebhookService.test]. + */ + @MustBeClosed + fun test(params: PromptWebhookTestParams): HttpResponseFor<PromptWebhookTestResponse> = + test(params, RequestOptions.none()) + + /** @see test */ + @MustBeClosed + fun test( + params: PromptWebhookTestParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<PromptWebhookTestResponse> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/PromptWebhookServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/PromptWebhookServiceImpl.kt new file mode 100644 index 00000000..df21f8f4 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/PromptWebhookServiceImpl.kt @@ -0,0 +1,273 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhook +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhookDeleteParams +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhookDeleteResponse +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhookPromptWebhooksParams +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhookRetrieveParams +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhookRetrievePromptWebhooksParams +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhookTestParams +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhookTestResponse +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhookUpdateParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class PromptWebhookServiceImpl internal constructor(private val clientOptions: ClientOptions) : + PromptWebhookService { + + private val withRawResponse: PromptWebhookService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): PromptWebhookService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): PromptWebhookService = + PromptWebhookServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: PromptWebhookRetrieveParams, + requestOptions: RequestOptions, + ): PromptWebhook = + // get /api/v1/prompt-webhooks/{webhook_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update( + params: PromptWebhookUpdateParams, + requestOptions: RequestOptions, + ): PromptWebhook = + // patch /api/v1/prompt-webhooks/{webhook_id} + withRawResponse().update(params, requestOptions).parse() + + override fun delete( + params: PromptWebhookDeleteParams, + requestOptions: RequestOptions, + ): PromptWebhookDeleteResponse = + // delete /api/v1/prompt-webhooks/{webhook_id} + withRawResponse().delete(params, requestOptions).parse() + + override fun promptWebhooks( + params: PromptWebhookPromptWebhooksParams, + requestOptions: RequestOptions, + ): PromptWebhook = + // post /api/v1/prompt-webhooks + withRawResponse().promptWebhooks(params, requestOptions).parse() + + override fun retrievePromptWebhooks( + params: PromptWebhookRetrievePromptWebhooksParams, + requestOptions: RequestOptions, + ): List<PromptWebhook> = + // get /api/v1/prompt-webhooks + withRawResponse().retrievePromptWebhooks(params, requestOptions).parse() + + override fun test( + params: PromptWebhookTestParams, + requestOptions: RequestOptions, + ): PromptWebhookTestResponse = + // post /api/v1/prompt-webhooks/test + withRawResponse().test(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + PromptWebhookService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PromptWebhookService.WithRawResponse = + PromptWebhookServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler<PromptWebhook> = + jsonHandler<PromptWebhook>(clientOptions.jsonMapper) + + override fun retrieve( + params: PromptWebhookRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor<PromptWebhook> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("webhookId", params.webhookId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "prompt-webhooks", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler<PromptWebhook> = + jsonHandler<PromptWebhook>(clientOptions.jsonMapper) + + override fun update( + params: PromptWebhookUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<PromptWebhook> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("webhookId", params.webhookId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "prompt-webhooks", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val deleteHandler: Handler<PromptWebhookDeleteResponse> = + jsonHandler<PromptWebhookDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: PromptWebhookDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<PromptWebhookDeleteResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("webhookId", params.webhookId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "prompt-webhooks", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val promptWebhooksHandler: Handler<PromptWebhook> = + jsonHandler<PromptWebhook>(clientOptions.jsonMapper) + + override fun promptWebhooks( + params: PromptWebhookPromptWebhooksParams, + requestOptions: RequestOptions, + ): HttpResponseFor<PromptWebhook> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "prompt-webhooks") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { promptWebhooksHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrievePromptWebhooksHandler: Handler<List<PromptWebhook>> = + jsonHandler<List<PromptWebhook>>(clientOptions.jsonMapper) + + override fun retrievePromptWebhooks( + params: PromptWebhookRetrievePromptWebhooksParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<PromptWebhook>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "prompt-webhooks") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrievePromptWebhooksHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val testHandler: Handler<PromptWebhookTestResponse> = + jsonHandler<PromptWebhookTestResponse>(clientOptions.jsonMapper) + + override fun test( + params: PromptWebhookTestParams, + requestOptions: RequestOptions, + ): HttpResponseFor<PromptWebhookTestResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "prompt-webhooks", "test") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { testHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/PublicService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/PublicService.kt new file mode 100644 index 00000000..4d063cdb --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/PublicService.kt @@ -0,0 +1,138 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.feedback.FeedbackSchema +import com.langsmith_api.api.models.api.v1.public_.PublicRetrieveFeedbacksParams +import com.langsmith_api.api.services.blocking.api.v1.public_.DatasetService +import com.langsmith_api.api.services.blocking.api.v1.public_.ExampleService +import com.langsmith_api.api.services.blocking.api.v1.public_.RunService +import com.langsmith_api.api.services.blocking.api.v1.public_.SchemaService +import java.util.function.Consumer + +interface PublicService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): PublicService + + fun datasets(): DatasetService + + fun examples(): ExampleService + + fun schemas(): SchemaService + + fun runs(): RunService + + /** Read Shared Feedbacks */ + fun retrieveFeedbacks(shareToken: String): List<FeedbackSchema> = + retrieveFeedbacks(shareToken, PublicRetrieveFeedbacksParams.none()) + + /** @see retrieveFeedbacks */ + fun retrieveFeedbacks( + shareToken: String, + params: PublicRetrieveFeedbacksParams = PublicRetrieveFeedbacksParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<FeedbackSchema> = + retrieveFeedbacks(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see retrieveFeedbacks */ + fun retrieveFeedbacks( + shareToken: String, + params: PublicRetrieveFeedbacksParams = PublicRetrieveFeedbacksParams.none(), + ): List<FeedbackSchema> = retrieveFeedbacks(shareToken, params, RequestOptions.none()) + + /** @see retrieveFeedbacks */ + fun retrieveFeedbacks( + params: PublicRetrieveFeedbacksParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List<FeedbackSchema> + + /** @see retrieveFeedbacks */ + fun retrieveFeedbacks(params: PublicRetrieveFeedbacksParams): List<FeedbackSchema> = + retrieveFeedbacks(params, RequestOptions.none()) + + /** @see retrieveFeedbacks */ + fun retrieveFeedbacks( + shareToken: String, + requestOptions: RequestOptions, + ): List<FeedbackSchema> = + retrieveFeedbacks(shareToken, PublicRetrieveFeedbacksParams.none(), requestOptions) + + /** A view of [PublicService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): PublicService.WithRawResponse + + fun datasets(): DatasetService.WithRawResponse + + fun examples(): ExampleService.WithRawResponse + + fun schemas(): SchemaService.WithRawResponse + + fun runs(): RunService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/public/{share_token}/feedbacks`, but is + * otherwise the same as [PublicService.retrieveFeedbacks]. + */ + @MustBeClosed + fun retrieveFeedbacks(shareToken: String): HttpResponseFor<List<FeedbackSchema>> = + retrieveFeedbacks(shareToken, PublicRetrieveFeedbacksParams.none()) + + /** @see retrieveFeedbacks */ + @MustBeClosed + fun retrieveFeedbacks( + shareToken: String, + params: PublicRetrieveFeedbacksParams = PublicRetrieveFeedbacksParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<FeedbackSchema>> = + retrieveFeedbacks(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see retrieveFeedbacks */ + @MustBeClosed + fun retrieveFeedbacks( + shareToken: String, + params: PublicRetrieveFeedbacksParams = PublicRetrieveFeedbacksParams.none(), + ): HttpResponseFor<List<FeedbackSchema>> = + retrieveFeedbacks(shareToken, params, RequestOptions.none()) + + /** @see retrieveFeedbacks */ + @MustBeClosed + fun retrieveFeedbacks( + params: PublicRetrieveFeedbacksParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<FeedbackSchema>> + + /** @see retrieveFeedbacks */ + @MustBeClosed + fun retrieveFeedbacks( + params: PublicRetrieveFeedbacksParams + ): HttpResponseFor<List<FeedbackSchema>> = retrieveFeedbacks(params, RequestOptions.none()) + + /** @see retrieveFeedbacks */ + @MustBeClosed + fun retrieveFeedbacks( + shareToken: String, + requestOptions: RequestOptions, + ): HttpResponseFor<List<FeedbackSchema>> = + retrieveFeedbacks(shareToken, PublicRetrieveFeedbacksParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/PublicServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/PublicServiceImpl.kt new file mode 100644 index 00000000..7aaeba0b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/PublicServiceImpl.kt @@ -0,0 +1,133 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.feedback.FeedbackSchema +import com.langsmith_api.api.models.api.v1.public_.PublicRetrieveFeedbacksParams +import com.langsmith_api.api.services.blocking.api.v1.public_.DatasetService +import com.langsmith_api.api.services.blocking.api.v1.public_.DatasetServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.public_.ExampleService +import com.langsmith_api.api.services.blocking.api.v1.public_.ExampleServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.public_.RunService +import com.langsmith_api.api.services.blocking.api.v1.public_.RunServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.public_.SchemaService +import com.langsmith_api.api.services.blocking.api.v1.public_.SchemaServiceImpl +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class PublicServiceImpl internal constructor(private val clientOptions: ClientOptions) : + PublicService { + + private val withRawResponse: PublicService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val datasets: DatasetService by lazy { DatasetServiceImpl(clientOptions) } + + private val examples: ExampleService by lazy { ExampleServiceImpl(clientOptions) } + + private val schemas: SchemaService by lazy { SchemaServiceImpl(clientOptions) } + + private val runs: RunService by lazy { RunServiceImpl(clientOptions) } + + override fun withRawResponse(): PublicService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): PublicService = + PublicServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun datasets(): DatasetService = datasets + + override fun examples(): ExampleService = examples + + override fun schemas(): SchemaService = schemas + + override fun runs(): RunService = runs + + override fun retrieveFeedbacks( + params: PublicRetrieveFeedbacksParams, + requestOptions: RequestOptions, + ): List<FeedbackSchema> = + // get /api/v1/public/{share_token}/feedbacks + withRawResponse().retrieveFeedbacks(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + PublicService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val datasets: DatasetService.WithRawResponse by lazy { + DatasetServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val examples: ExampleService.WithRawResponse by lazy { + ExampleServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val schemas: SchemaService.WithRawResponse by lazy { + SchemaServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val runs: RunService.WithRawResponse by lazy { + RunServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PublicService.WithRawResponse = + PublicServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun datasets(): DatasetService.WithRawResponse = datasets + + override fun examples(): ExampleService.WithRawResponse = examples + + override fun schemas(): SchemaService.WithRawResponse = schemas + + override fun runs(): RunService.WithRawResponse = runs + + private val retrieveFeedbacksHandler: Handler<List<FeedbackSchema>> = + jsonHandler<List<FeedbackSchema>>(clientOptions.jsonMapper) + + override fun retrieveFeedbacks( + params: PublicRetrieveFeedbacksParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<FeedbackSchema>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("shareToken", params.shareToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "public", params._pathParam(0), "feedbacks") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveFeedbacksHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/RepoService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/RepoService.kt new file mode 100644 index 00000000..1fd90c45 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/RepoService.kt @@ -0,0 +1,344 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.repos.CreateRepoResponse +import com.langsmith_api.api.models.api.v1.repos.GetRepoResponse +import com.langsmith_api.api.models.api.v1.repos.RepoCreateParams +import com.langsmith_api.api.models.api.v1.repos.RepoDeleteParams +import com.langsmith_api.api.models.api.v1.repos.RepoDeleteResponse +import com.langsmith_api.api.models.api.v1.repos.RepoForkParams +import com.langsmith_api.api.models.api.v1.repos.RepoListParams +import com.langsmith_api.api.models.api.v1.repos.RepoListResponse +import com.langsmith_api.api.models.api.v1.repos.RepoOptimizeJobParams +import com.langsmith_api.api.models.api.v1.repos.RepoOptimizeJobResponse +import com.langsmith_api.api.models.api.v1.repos.RepoRetrieveParams +import com.langsmith_api.api.models.api.v1.repos.RepoUpdateParams +import com.langsmith_api.api.services.blocking.api.v1.repos.OptimizationJobService +import com.langsmith_api.api.services.blocking.api.v1.repos.TagService +import java.util.function.Consumer + +interface RepoService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RepoService + + fun tags(): TagService + + fun optimizationJobs(): OptimizationJobService + + /** Create a repo. */ + fun create(params: RepoCreateParams): CreateRepoResponse = create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: RepoCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CreateRepoResponse + + /** Get a repo. */ + fun retrieve(repo: String, params: RepoRetrieveParams): GetRepoResponse = + retrieve(repo, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + repo: String, + params: RepoRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): GetRepoResponse = retrieve(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: RepoRetrieveParams): GetRepoResponse = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: RepoRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): GetRepoResponse + + /** Update a repo. */ + fun update(repo: String, params: RepoUpdateParams): CreateRepoResponse = + update(repo, params, RequestOptions.none()) + + /** @see update */ + fun update( + repo: String, + params: RepoUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CreateRepoResponse = update(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see update */ + fun update(params: RepoUpdateParams): CreateRepoResponse = update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: RepoUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CreateRepoResponse + + /** Get all repos. */ + fun list(): RepoListResponse = list(RepoListParams.none()) + + /** @see list */ + fun list( + params: RepoListParams = RepoListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): RepoListResponse + + /** @see list */ + fun list(params: RepoListParams = RepoListParams.none()): RepoListResponse = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): RepoListResponse = + list(RepoListParams.none(), requestOptions) + + /** Delete a repo. */ + fun delete(repo: String, params: RepoDeleteParams): RepoDeleteResponse = + delete(repo, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + repo: String, + params: RepoDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RepoDeleteResponse = delete(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see delete */ + fun delete(params: RepoDeleteParams): RepoDeleteResponse = delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: RepoDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RepoDeleteResponse + + /** Fork a repo. */ + fun fork(repo: String, params: RepoForkParams): GetRepoResponse = + fork(repo, params, RequestOptions.none()) + + /** @see fork */ + fun fork( + repo: String, + params: RepoForkParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): GetRepoResponse = fork(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see fork */ + fun fork(params: RepoForkParams): GetRepoResponse = fork(params, RequestOptions.none()) + + /** @see fork */ + fun fork( + params: RepoForkParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): GetRepoResponse + + /** Optimize prompt */ + fun optimizeJob(params: RepoOptimizeJobParams): RepoOptimizeJobResponse = + optimizeJob(params, RequestOptions.none()) + + /** @see optimizeJob */ + fun optimizeJob( + params: RepoOptimizeJobParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RepoOptimizeJobResponse + + /** A view of [RepoService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RepoService.WithRawResponse + + fun tags(): TagService.WithRawResponse + + fun optimizationJobs(): OptimizationJobService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/repos`, but is otherwise the same as + * [RepoService.create]. + */ + @MustBeClosed + fun create(params: RepoCreateParams): HttpResponseFor<CreateRepoResponse> = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: RepoCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CreateRepoResponse> + + /** + * Returns a raw HTTP response for `get /api/v1/repos/{owner}/{repo}`, but is otherwise the + * same as [RepoService.retrieve]. + */ + @MustBeClosed + fun retrieve(repo: String, params: RepoRetrieveParams): HttpResponseFor<GetRepoResponse> = + retrieve(repo, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + repo: String, + params: RepoRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<GetRepoResponse> = + retrieve(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: RepoRetrieveParams): HttpResponseFor<GetRepoResponse> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: RepoRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<GetRepoResponse> + + /** + * Returns a raw HTTP response for `patch /api/v1/repos/{owner}/{repo}`, but is otherwise + * the same as [RepoService.update]. + */ + @MustBeClosed + fun update(repo: String, params: RepoUpdateParams): HttpResponseFor<CreateRepoResponse> = + update(repo, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + repo: String, + params: RepoUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CreateRepoResponse> = + update(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(params: RepoUpdateParams): HttpResponseFor<CreateRepoResponse> = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: RepoUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CreateRepoResponse> + + /** + * Returns a raw HTTP response for `get /api/v1/repos`, but is otherwise the same as + * [RepoService.list]. + */ + @MustBeClosed fun list(): HttpResponseFor<RepoListResponse> = list(RepoListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: RepoListParams = RepoListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RepoListResponse> + + /** @see list */ + @MustBeClosed + fun list( + params: RepoListParams = RepoListParams.none() + ): HttpResponseFor<RepoListResponse> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor<RepoListResponse> = + list(RepoListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/repos/{owner}/{repo}`, but is otherwise + * the same as [RepoService.delete]. + */ + @MustBeClosed + fun delete(repo: String, params: RepoDeleteParams): HttpResponseFor<RepoDeleteResponse> = + delete(repo, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + repo: String, + params: RepoDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RepoDeleteResponse> = + delete(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete(params: RepoDeleteParams): HttpResponseFor<RepoDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: RepoDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RepoDeleteResponse> + + /** + * Returns a raw HTTP response for `post /api/v1/repos/{owner}/{repo}/fork`, but is + * otherwise the same as [RepoService.fork]. + */ + @MustBeClosed + fun fork(repo: String, params: RepoForkParams): HttpResponseFor<GetRepoResponse> = + fork(repo, params, RequestOptions.none()) + + /** @see fork */ + @MustBeClosed + fun fork( + repo: String, + params: RepoForkParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<GetRepoResponse> = + fork(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see fork */ + @MustBeClosed + fun fork(params: RepoForkParams): HttpResponseFor<GetRepoResponse> = + fork(params, RequestOptions.none()) + + /** @see fork */ + @MustBeClosed + fun fork( + params: RepoForkParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<GetRepoResponse> + + /** + * Returns a raw HTTP response for `post /api/v1/repos/optimize-job`, but is otherwise the + * same as [RepoService.optimizeJob]. + */ + @MustBeClosed + fun optimizeJob(params: RepoOptimizeJobParams): HttpResponseFor<RepoOptimizeJobResponse> = + optimizeJob(params, RequestOptions.none()) + + /** @see optimizeJob */ + @MustBeClosed + fun optimizeJob( + params: RepoOptimizeJobParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RepoOptimizeJobResponse> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/RepoServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/RepoServiceImpl.kt new file mode 100644 index 00000000..580c241b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/RepoServiceImpl.kt @@ -0,0 +1,358 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.repos.CreateRepoResponse +import com.langsmith_api.api.models.api.v1.repos.GetRepoResponse +import com.langsmith_api.api.models.api.v1.repos.RepoCreateParams +import com.langsmith_api.api.models.api.v1.repos.RepoDeleteParams +import com.langsmith_api.api.models.api.v1.repos.RepoDeleteResponse +import com.langsmith_api.api.models.api.v1.repos.RepoForkParams +import com.langsmith_api.api.models.api.v1.repos.RepoListParams +import com.langsmith_api.api.models.api.v1.repos.RepoListResponse +import com.langsmith_api.api.models.api.v1.repos.RepoOptimizeJobParams +import com.langsmith_api.api.models.api.v1.repos.RepoOptimizeJobResponse +import com.langsmith_api.api.models.api.v1.repos.RepoRetrieveParams +import com.langsmith_api.api.models.api.v1.repos.RepoUpdateParams +import com.langsmith_api.api.services.blocking.api.v1.repos.OptimizationJobService +import com.langsmith_api.api.services.blocking.api.v1.repos.OptimizationJobServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.repos.TagService +import com.langsmith_api.api.services.blocking.api.v1.repos.TagServiceImpl +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class RepoServiceImpl internal constructor(private val clientOptions: ClientOptions) : RepoService { + + private val withRawResponse: RepoService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val tags: TagService by lazy { TagServiceImpl(clientOptions) } + + private val optimizationJobs: OptimizationJobService by lazy { + OptimizationJobServiceImpl(clientOptions) + } + + override fun withRawResponse(): RepoService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): RepoService = + RepoServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun tags(): TagService = tags + + override fun optimizationJobs(): OptimizationJobService = optimizationJobs + + override fun create( + params: RepoCreateParams, + requestOptions: RequestOptions, + ): CreateRepoResponse = + // post /api/v1/repos + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve( + params: RepoRetrieveParams, + requestOptions: RequestOptions, + ): GetRepoResponse = + // get /api/v1/repos/{owner}/{repo} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update( + params: RepoUpdateParams, + requestOptions: RequestOptions, + ): CreateRepoResponse = + // patch /api/v1/repos/{owner}/{repo} + withRawResponse().update(params, requestOptions).parse() + + override fun list(params: RepoListParams, requestOptions: RequestOptions): RepoListResponse = + // get /api/v1/repos + withRawResponse().list(params, requestOptions).parse() + + override fun delete( + params: RepoDeleteParams, + requestOptions: RequestOptions, + ): RepoDeleteResponse = + // delete /api/v1/repos/{owner}/{repo} + withRawResponse().delete(params, requestOptions).parse() + + override fun fork(params: RepoForkParams, requestOptions: RequestOptions): GetRepoResponse = + // post /api/v1/repos/{owner}/{repo}/fork + withRawResponse().fork(params, requestOptions).parse() + + override fun optimizeJob( + params: RepoOptimizeJobParams, + requestOptions: RequestOptions, + ): RepoOptimizeJobResponse = + // post /api/v1/repos/optimize-job + withRawResponse().optimizeJob(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RepoService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val tags: TagService.WithRawResponse by lazy { + TagServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val optimizationJobs: OptimizationJobService.WithRawResponse by lazy { + OptimizationJobServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): RepoService.WithRawResponse = + RepoServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun tags(): TagService.WithRawResponse = tags + + override fun optimizationJobs(): OptimizationJobService.WithRawResponse = optimizationJobs + + private val createHandler: Handler<CreateRepoResponse> = + jsonHandler<CreateRepoResponse>(clientOptions.jsonMapper) + + override fun create( + params: RepoCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<CreateRepoResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "repos") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler<GetRepoResponse> = + jsonHandler<GetRepoResponse>(clientOptions.jsonMapper) + + override fun retrieve( + params: RepoRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor<GetRepoResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("repo", params.repo().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "repos", + params._pathParam(0), + params._pathParam(1), + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler<CreateRepoResponse> = + jsonHandler<CreateRepoResponse>(clientOptions.jsonMapper) + + override fun update( + params: RepoUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<CreateRepoResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("repo", params.repo().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "repos", + params._pathParam(0), + params._pathParam(1), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler<RepoListResponse> = + jsonHandler<RepoListResponse>(clientOptions.jsonMapper) + + override fun list( + params: RepoListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<RepoListResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "repos") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val deleteHandler: Handler<RepoDeleteResponse> = + jsonHandler<RepoDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: RepoDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<RepoDeleteResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("repo", params.repo().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "repos", + params._pathParam(0), + params._pathParam(1), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val forkHandler: Handler<GetRepoResponse> = + jsonHandler<GetRepoResponse>(clientOptions.jsonMapper) + + override fun fork( + params: RepoForkParams, + requestOptions: RequestOptions, + ): HttpResponseFor<GetRepoResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("repo", params.repo().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "repos", + params._pathParam(0), + params._pathParam(1), + "fork", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { forkHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val optimizeJobHandler: Handler<RepoOptimizeJobResponse> = + jsonHandler<RepoOptimizeJobResponse>(clientOptions.jsonMapper) + + override fun optimizeJob( + params: RepoOptimizeJobParams, + requestOptions: RequestOptions, + ): HttpResponseFor<RepoOptimizeJobResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "repos", "optimize-job") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { optimizeJobHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/RunService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/RunService.kt new file mode 100644 index 00000000..8cf295c7 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/RunService.kt @@ -0,0 +1,420 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.runs.BodyParamsForRunSchema +import com.langsmith_api.api.models.api.v1.runs.RequestBodyForRunsGenerateQuery +import com.langsmith_api.api.models.api.v1.runs.ResponseBodyForRunsGenerateQuery +import com.langsmith_api.api.models.api.v1.runs.RunDeleteParams +import com.langsmith_api.api.models.api.v1.runs.RunDeleteResponse +import com.langsmith_api.api.models.api.v1.runs.RunGenerateQueryParams +import com.langsmith_api.api.models.api.v1.runs.RunQueryParams +import com.langsmith_api.api.models.api.v1.runs.RunQueryResponse +import com.langsmith_api.api.models.api.v1.runs.RunRetrieveParams +import com.langsmith_api.api.models.api.v1.runs.RunSchema +import com.langsmith_api.api.models.api.v1.runs.RunStatsParams +import com.langsmith_api.api.models.api.v1.runs.RunStatsQueryParams +import com.langsmith_api.api.models.api.v1.runs.RunStatsResponse +import com.langsmith_api.api.models.api.v1.runs.RunUpdateParams +import com.langsmith_api.api.models.api.v1.runs.RunUpdateResponse +import com.langsmith_api.api.services.blocking.api.v1.runs.GroupService +import com.langsmith_api.api.services.blocking.api.v1.runs.RuleService +import com.langsmith_api.api.services.blocking.api.v1.runs.ShareService +import java.util.function.Consumer + +interface RunService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunService + + fun rules(): RuleService + + fun share(): ShareService + + fun group(): GroupService + + /** Get a specific run. */ + fun retrieve(runId: String): RunSchema = retrieve(runId, RunRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + runId: String, + params: RunRetrieveParams = RunRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): RunSchema = retrieve(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(runId: String, params: RunRetrieveParams = RunRetrieveParams.none()): RunSchema = + retrieve(runId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: RunRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RunSchema + + /** @see retrieve */ + fun retrieve(params: RunRetrieveParams): RunSchema = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(runId: String, requestOptions: RequestOptions): RunSchema = + retrieve(runId, RunRetrieveParams.none(), requestOptions) + + /** Update a run. */ + fun update(runId: String): RunUpdateResponse = update(runId, RunUpdateParams.none()) + + /** @see update */ + fun update( + runId: String, + params: RunUpdateParams = RunUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): RunUpdateResponse = update(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see update */ + fun update(runId: String, params: RunUpdateParams = RunUpdateParams.none()): RunUpdateResponse = + update(runId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: RunUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RunUpdateResponse + + /** @see update */ + fun update(params: RunUpdateParams): RunUpdateResponse = update(params, RequestOptions.none()) + + /** @see update */ + fun update(runId: String, requestOptions: RequestOptions): RunUpdateResponse = + update(runId, RunUpdateParams.none(), requestOptions) + + /** Delete specific runs by trace IDs or metadata key-value pairs. */ + fun delete(): RunDeleteResponse = delete(RunDeleteParams.none()) + + /** @see delete */ + fun delete( + params: RunDeleteParams = RunDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): RunDeleteResponse + + /** @see delete */ + fun delete(params: RunDeleteParams = RunDeleteParams.none()): RunDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(requestOptions: RequestOptions): RunDeleteResponse = + delete(RunDeleteParams.none(), requestOptions) + + /** Get runs filter expression query for a given natural language query. */ + fun generateQuery(params: RunGenerateQueryParams): ResponseBodyForRunsGenerateQuery = + generateQuery(params, RequestOptions.none()) + + /** @see generateQuery */ + fun generateQuery( + params: RunGenerateQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ResponseBodyForRunsGenerateQuery + + /** @see generateQuery */ + fun generateQuery( + requestBodyForRunsGenerateQuery: RequestBodyForRunsGenerateQuery, + requestOptions: RequestOptions = RequestOptions.none(), + ): ResponseBodyForRunsGenerateQuery = + generateQuery( + RunGenerateQueryParams.builder() + .requestBodyForRunsGenerateQuery(requestBodyForRunsGenerateQuery) + .build(), + requestOptions, + ) + + /** @see generateQuery */ + fun generateQuery( + requestBodyForRunsGenerateQuery: RequestBodyForRunsGenerateQuery + ): ResponseBodyForRunsGenerateQuery = + generateQuery(requestBodyForRunsGenerateQuery, RequestOptions.none()) + + /** Query Runs */ + fun query(params: RunQueryParams): RunQueryResponse = query(params, RequestOptions.none()) + + /** @see query */ + fun query( + params: RunQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RunQueryResponse + + /** @see query */ + fun query( + bodyParamsForRunSchema: BodyParamsForRunSchema, + requestOptions: RequestOptions = RequestOptions.none(), + ): RunQueryResponse = + query( + RunQueryParams.builder().bodyParamsForRunSchema(bodyParamsForRunSchema).build(), + requestOptions, + ) + + /** @see query */ + fun query(bodyParamsForRunSchema: BodyParamsForRunSchema): RunQueryResponse = + query(bodyParamsForRunSchema, RequestOptions.none()) + + /** Get all runs by query in body payload. */ + fun stats(params: RunStatsParams): RunStatsResponse = stats(params, RequestOptions.none()) + + /** @see stats */ + fun stats( + params: RunStatsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RunStatsResponse + + /** @see stats */ + fun stats( + runStatsQueryParams: RunStatsQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RunStatsResponse = + stats( + RunStatsParams.builder().runStatsQueryParams(runStatsQueryParams).build(), + requestOptions, + ) + + /** @see stats */ + fun stats(runStatsQueryParams: RunStatsQueryParams): RunStatsResponse = + stats(runStatsQueryParams, RequestOptions.none()) + + /** A view of [RunService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunService.WithRawResponse + + fun rules(): RuleService.WithRawResponse + + fun share(): ShareService.WithRawResponse + + fun group(): GroupService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/runs/{run_id}`, but is otherwise the same as + * [RunService.retrieve]. + */ + @MustBeClosed + fun retrieve(runId: String): HttpResponseFor<RunSchema> = + retrieve(runId, RunRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + runId: String, + params: RunRetrieveParams = RunRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RunSchema> = + retrieve(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + runId: String, + params: RunRetrieveParams = RunRetrieveParams.none(), + ): HttpResponseFor<RunSchema> = retrieve(runId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: RunRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RunSchema> + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: RunRetrieveParams): HttpResponseFor<RunSchema> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve(runId: String, requestOptions: RequestOptions): HttpResponseFor<RunSchema> = + retrieve(runId, RunRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `patch /api/v1/runs/{run_id}`, but is otherwise the same + * as [RunService.update]. + */ + @MustBeClosed + fun update(runId: String): HttpResponseFor<RunUpdateResponse> = + update(runId, RunUpdateParams.none()) + + /** @see update */ + @MustBeClosed + fun update( + runId: String, + params: RunUpdateParams = RunUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RunUpdateResponse> = + update(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update( + runId: String, + params: RunUpdateParams = RunUpdateParams.none(), + ): HttpResponseFor<RunUpdateResponse> = update(runId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: RunUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RunUpdateResponse> + + /** @see update */ + @MustBeClosed + fun update(params: RunUpdateParams): HttpResponseFor<RunUpdateResponse> = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + runId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<RunUpdateResponse> = + update(runId, RunUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/runs/delete`, but is otherwise the same as + * [RunService.delete]. + */ + @MustBeClosed + fun delete(): HttpResponseFor<RunDeleteResponse> = delete(RunDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: RunDeleteParams = RunDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RunDeleteResponse> + + /** @see delete */ + @MustBeClosed + fun delete( + params: RunDeleteParams = RunDeleteParams.none() + ): HttpResponseFor<RunDeleteResponse> = delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete(requestOptions: RequestOptions): HttpResponseFor<RunDeleteResponse> = + delete(RunDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/runs/generate-query`, but is otherwise the + * same as [RunService.generateQuery]. + */ + @MustBeClosed + fun generateQuery( + params: RunGenerateQueryParams + ): HttpResponseFor<ResponseBodyForRunsGenerateQuery> = + generateQuery(params, RequestOptions.none()) + + /** @see generateQuery */ + @MustBeClosed + fun generateQuery( + params: RunGenerateQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ResponseBodyForRunsGenerateQuery> + + /** @see generateQuery */ + @MustBeClosed + fun generateQuery( + requestBodyForRunsGenerateQuery: RequestBodyForRunsGenerateQuery, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ResponseBodyForRunsGenerateQuery> = + generateQuery( + RunGenerateQueryParams.builder() + .requestBodyForRunsGenerateQuery(requestBodyForRunsGenerateQuery) + .build(), + requestOptions, + ) + + /** @see generateQuery */ + @MustBeClosed + fun generateQuery( + requestBodyForRunsGenerateQuery: RequestBodyForRunsGenerateQuery + ): HttpResponseFor<ResponseBodyForRunsGenerateQuery> = + generateQuery(requestBodyForRunsGenerateQuery, RequestOptions.none()) + + /** + * Returns a raw HTTP response for `post /api/v1/runs/query`, but is otherwise the same as + * [RunService.query]. + */ + @MustBeClosed + fun query(params: RunQueryParams): HttpResponseFor<RunQueryResponse> = + query(params, RequestOptions.none()) + + /** @see query */ + @MustBeClosed + fun query( + params: RunQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RunQueryResponse> + + /** @see query */ + @MustBeClosed + fun query( + bodyParamsForRunSchema: BodyParamsForRunSchema, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RunQueryResponse> = + query( + RunQueryParams.builder().bodyParamsForRunSchema(bodyParamsForRunSchema).build(), + requestOptions, + ) + + /** @see query */ + @MustBeClosed + fun query( + bodyParamsForRunSchema: BodyParamsForRunSchema + ): HttpResponseFor<RunQueryResponse> = query(bodyParamsForRunSchema, RequestOptions.none()) + + /** + * Returns a raw HTTP response for `post /api/v1/runs/stats`, but is otherwise the same as + * [RunService.stats]. + */ + @MustBeClosed + fun stats(params: RunStatsParams): HttpResponseFor<RunStatsResponse> = + stats(params, RequestOptions.none()) + + /** @see stats */ + @MustBeClosed + fun stats( + params: RunStatsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RunStatsResponse> + + /** @see stats */ + @MustBeClosed + fun stats( + runStatsQueryParams: RunStatsQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RunStatsResponse> = + stats( + RunStatsParams.builder().runStatsQueryParams(runStatsQueryParams).build(), + requestOptions, + ) + + /** @see stats */ + @MustBeClosed + fun stats(runStatsQueryParams: RunStatsQueryParams): HttpResponseFor<RunStatsResponse> = + stats(runStatsQueryParams, RequestOptions.none()) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/RunServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/RunServiceImpl.kt new file mode 100644 index 00000000..798ae41b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/RunServiceImpl.kt @@ -0,0 +1,300 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.runs.ResponseBodyForRunsGenerateQuery +import com.langsmith_api.api.models.api.v1.runs.RunDeleteParams +import com.langsmith_api.api.models.api.v1.runs.RunDeleteResponse +import com.langsmith_api.api.models.api.v1.runs.RunGenerateQueryParams +import com.langsmith_api.api.models.api.v1.runs.RunQueryParams +import com.langsmith_api.api.models.api.v1.runs.RunQueryResponse +import com.langsmith_api.api.models.api.v1.runs.RunRetrieveParams +import com.langsmith_api.api.models.api.v1.runs.RunSchema +import com.langsmith_api.api.models.api.v1.runs.RunStatsParams +import com.langsmith_api.api.models.api.v1.runs.RunStatsResponse +import com.langsmith_api.api.models.api.v1.runs.RunUpdateParams +import com.langsmith_api.api.models.api.v1.runs.RunUpdateResponse +import com.langsmith_api.api.services.blocking.api.v1.runs.GroupService +import com.langsmith_api.api.services.blocking.api.v1.runs.GroupServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.runs.RuleService +import com.langsmith_api.api.services.blocking.api.v1.runs.RuleServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.runs.ShareService +import com.langsmith_api.api.services.blocking.api.v1.runs.ShareServiceImpl +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class RunServiceImpl internal constructor(private val clientOptions: ClientOptions) : RunService { + + private val withRawResponse: RunService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val rules: RuleService by lazy { RuleServiceImpl(clientOptions) } + + private val share: ShareService by lazy { ShareServiceImpl(clientOptions) } + + private val group: GroupService by lazy { GroupServiceImpl(clientOptions) } + + override fun withRawResponse(): RunService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunService = + RunServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun rules(): RuleService = rules + + override fun share(): ShareService = share + + override fun group(): GroupService = group + + override fun retrieve(params: RunRetrieveParams, requestOptions: RequestOptions): RunSchema = + // get /api/v1/runs/{run_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update( + params: RunUpdateParams, + requestOptions: RequestOptions, + ): RunUpdateResponse = + // patch /api/v1/runs/{run_id} + withRawResponse().update(params, requestOptions).parse() + + override fun delete( + params: RunDeleteParams, + requestOptions: RequestOptions, + ): RunDeleteResponse = + // post /api/v1/runs/delete + withRawResponse().delete(params, requestOptions).parse() + + override fun generateQuery( + params: RunGenerateQueryParams, + requestOptions: RequestOptions, + ): ResponseBodyForRunsGenerateQuery = + // post /api/v1/runs/generate-query + withRawResponse().generateQuery(params, requestOptions).parse() + + override fun query(params: RunQueryParams, requestOptions: RequestOptions): RunQueryResponse = + // post /api/v1/runs/query + withRawResponse().query(params, requestOptions).parse() + + override fun stats(params: RunStatsParams, requestOptions: RequestOptions): RunStatsResponse = + // post /api/v1/runs/stats + withRawResponse().stats(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RunService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val rules: RuleService.WithRawResponse by lazy { + RuleServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val share: ShareService.WithRawResponse by lazy { + ShareServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val group: GroupService.WithRawResponse by lazy { + GroupServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): RunService.WithRawResponse = + RunServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun rules(): RuleService.WithRawResponse = rules + + override fun share(): ShareService.WithRawResponse = share + + override fun group(): GroupService.WithRawResponse = group + + private val retrieveHandler: Handler<RunSchema> = + jsonHandler<RunSchema>(clientOptions.jsonMapper) + + override fun retrieve( + params: RunRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor<RunSchema> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("runId", params.runId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler<RunUpdateResponse> = + jsonHandler<RunUpdateResponse>(clientOptions.jsonMapper) + + override fun update( + params: RunUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<RunUpdateResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("runId", params.runId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val deleteHandler: Handler<RunDeleteResponse> = + jsonHandler<RunDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: RunDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<RunDeleteResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", "delete") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val generateQueryHandler: Handler<ResponseBodyForRunsGenerateQuery> = + jsonHandler<ResponseBodyForRunsGenerateQuery>(clientOptions.jsonMapper) + + override fun generateQuery( + params: RunGenerateQueryParams, + requestOptions: RequestOptions, + ): HttpResponseFor<ResponseBodyForRunsGenerateQuery> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", "generate-query") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { generateQueryHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val queryHandler: Handler<RunQueryResponse> = + jsonHandler<RunQueryResponse>(clientOptions.jsonMapper) + + override fun query( + params: RunQueryParams, + requestOptions: RequestOptions, + ): HttpResponseFor<RunQueryResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", "query") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { queryHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val statsHandler: Handler<RunStatsResponse> = + jsonHandler<RunStatsResponse>(clientOptions.jsonMapper) + + override fun stats( + params: RunStatsParams, + requestOptions: RequestOptions, + ): HttpResponseFor<RunStatsResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", "stats") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { statsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ServiceAccountService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ServiceAccountService.kt new file mode 100644 index 00000000..6eecce8a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ServiceAccountService.kt @@ -0,0 +1,213 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.serviceaccounts.ServiceAccountDeleteParams +import com.langsmith_api.api.models.api.v1.serviceaccounts.ServiceAccountDeleteResponse +import com.langsmith_api.api.models.api.v1.serviceaccounts.ServiceAccountRetrieveServiceAccountsParams +import com.langsmith_api.api.models.api.v1.serviceaccounts.ServiceAccountRetrieveServiceAccountsResponse +import com.langsmith_api.api.models.api.v1.serviceaccounts.ServiceAccountServiceAccountsParams +import com.langsmith_api.api.models.api.v1.serviceaccounts.ServiceAccountServiceAccountsResponse +import java.util.function.Consumer + +interface ServiceAccountService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ServiceAccountService + + /** Delete a service account */ + fun delete(serviceAccountId: String): ServiceAccountDeleteResponse = + delete(serviceAccountId, ServiceAccountDeleteParams.none()) + + /** @see delete */ + fun delete( + serviceAccountId: String, + params: ServiceAccountDeleteParams = ServiceAccountDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ServiceAccountDeleteResponse = + delete(params.toBuilder().serviceAccountId(serviceAccountId).build(), requestOptions) + + /** @see delete */ + fun delete( + serviceAccountId: String, + params: ServiceAccountDeleteParams = ServiceAccountDeleteParams.none(), + ): ServiceAccountDeleteResponse = delete(serviceAccountId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ServiceAccountDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ServiceAccountDeleteResponse + + /** @see delete */ + fun delete(params: ServiceAccountDeleteParams): ServiceAccountDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + serviceAccountId: String, + requestOptions: RequestOptions, + ): ServiceAccountDeleteResponse = + delete(serviceAccountId, ServiceAccountDeleteParams.none(), requestOptions) + + /** Get the current organization's service accounts. */ + fun retrieveServiceAccounts(): List<ServiceAccountRetrieveServiceAccountsResponse> = + retrieveServiceAccounts(ServiceAccountRetrieveServiceAccountsParams.none()) + + /** @see retrieveServiceAccounts */ + fun retrieveServiceAccounts( + params: ServiceAccountRetrieveServiceAccountsParams = + ServiceAccountRetrieveServiceAccountsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<ServiceAccountRetrieveServiceAccountsResponse> + + /** @see retrieveServiceAccounts */ + fun retrieveServiceAccounts( + params: ServiceAccountRetrieveServiceAccountsParams = + ServiceAccountRetrieveServiceAccountsParams.none() + ): List<ServiceAccountRetrieveServiceAccountsResponse> = + retrieveServiceAccounts(params, RequestOptions.none()) + + /** @see retrieveServiceAccounts */ + fun retrieveServiceAccounts( + requestOptions: RequestOptions + ): List<ServiceAccountRetrieveServiceAccountsResponse> = + retrieveServiceAccounts(ServiceAccountRetrieveServiceAccountsParams.none(), requestOptions) + + /** Create a service account */ + fun serviceAccounts( + params: ServiceAccountServiceAccountsParams + ): ServiceAccountServiceAccountsResponse = serviceAccounts(params, RequestOptions.none()) + + /** @see serviceAccounts */ + fun serviceAccounts( + params: ServiceAccountServiceAccountsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ServiceAccountServiceAccountsResponse + + /** + * A view of [ServiceAccountService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ServiceAccountService.WithRawResponse + + /** + * Returns a raw HTTP response for `delete /api/v1/service-accounts/{service_account_id}`, + * but is otherwise the same as [ServiceAccountService.delete]. + */ + @MustBeClosed + fun delete(serviceAccountId: String): HttpResponseFor<ServiceAccountDeleteResponse> = + delete(serviceAccountId, ServiceAccountDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + serviceAccountId: String, + params: ServiceAccountDeleteParams = ServiceAccountDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ServiceAccountDeleteResponse> = + delete(params.toBuilder().serviceAccountId(serviceAccountId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + serviceAccountId: String, + params: ServiceAccountDeleteParams = ServiceAccountDeleteParams.none(), + ): HttpResponseFor<ServiceAccountDeleteResponse> = + delete(serviceAccountId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: ServiceAccountDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ServiceAccountDeleteResponse> + + /** @see delete */ + @MustBeClosed + fun delete( + params: ServiceAccountDeleteParams + ): HttpResponseFor<ServiceAccountDeleteResponse> = delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + serviceAccountId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<ServiceAccountDeleteResponse> = + delete(serviceAccountId, ServiceAccountDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/service-accounts`, but is otherwise the same + * as [ServiceAccountService.retrieveServiceAccounts]. + */ + @MustBeClosed + fun retrieveServiceAccounts(): + HttpResponseFor<List<ServiceAccountRetrieveServiceAccountsResponse>> = + retrieveServiceAccounts(ServiceAccountRetrieveServiceAccountsParams.none()) + + /** @see retrieveServiceAccounts */ + @MustBeClosed + fun retrieveServiceAccounts( + params: ServiceAccountRetrieveServiceAccountsParams = + ServiceAccountRetrieveServiceAccountsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<ServiceAccountRetrieveServiceAccountsResponse>> + + /** @see retrieveServiceAccounts */ + @MustBeClosed + fun retrieveServiceAccounts( + params: ServiceAccountRetrieveServiceAccountsParams = + ServiceAccountRetrieveServiceAccountsParams.none() + ): HttpResponseFor<List<ServiceAccountRetrieveServiceAccountsResponse>> = + retrieveServiceAccounts(params, RequestOptions.none()) + + /** @see retrieveServiceAccounts */ + @MustBeClosed + fun retrieveServiceAccounts( + requestOptions: RequestOptions + ): HttpResponseFor<List<ServiceAccountRetrieveServiceAccountsResponse>> = + retrieveServiceAccounts( + ServiceAccountRetrieveServiceAccountsParams.none(), + requestOptions, + ) + + /** + * Returns a raw HTTP response for `post /api/v1/service-accounts`, but is otherwise the + * same as [ServiceAccountService.serviceAccounts]. + */ + @MustBeClosed + fun serviceAccounts( + params: ServiceAccountServiceAccountsParams + ): HttpResponseFor<ServiceAccountServiceAccountsResponse> = + serviceAccounts(params, RequestOptions.none()) + + /** @see serviceAccounts */ + @MustBeClosed + fun serviceAccounts( + params: ServiceAccountServiceAccountsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ServiceAccountServiceAccountsResponse> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ServiceAccountServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ServiceAccountServiceImpl.kt new file mode 100644 index 00000000..45da7609 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/ServiceAccountServiceImpl.kt @@ -0,0 +1,163 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.serviceaccounts.ServiceAccountDeleteParams +import com.langsmith_api.api.models.api.v1.serviceaccounts.ServiceAccountDeleteResponse +import com.langsmith_api.api.models.api.v1.serviceaccounts.ServiceAccountRetrieveServiceAccountsParams +import com.langsmith_api.api.models.api.v1.serviceaccounts.ServiceAccountRetrieveServiceAccountsResponse +import com.langsmith_api.api.models.api.v1.serviceaccounts.ServiceAccountServiceAccountsParams +import com.langsmith_api.api.models.api.v1.serviceaccounts.ServiceAccountServiceAccountsResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ServiceAccountServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ServiceAccountService { + + private val withRawResponse: ServiceAccountService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ServiceAccountService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): ServiceAccountService = + ServiceAccountServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun delete( + params: ServiceAccountDeleteParams, + requestOptions: RequestOptions, + ): ServiceAccountDeleteResponse = + // delete /api/v1/service-accounts/{service_account_id} + withRawResponse().delete(params, requestOptions).parse() + + override fun retrieveServiceAccounts( + params: ServiceAccountRetrieveServiceAccountsParams, + requestOptions: RequestOptions, + ): List<ServiceAccountRetrieveServiceAccountsResponse> = + // get /api/v1/service-accounts + withRawResponse().retrieveServiceAccounts(params, requestOptions).parse() + + override fun serviceAccounts( + params: ServiceAccountServiceAccountsParams, + requestOptions: RequestOptions, + ): ServiceAccountServiceAccountsResponse = + // post /api/v1/service-accounts + withRawResponse().serviceAccounts(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ServiceAccountService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ServiceAccountService.WithRawResponse = + ServiceAccountServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val deleteHandler: Handler<ServiceAccountDeleteResponse> = + jsonHandler<ServiceAccountDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: ServiceAccountDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<ServiceAccountDeleteResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("serviceAccountId", params.serviceAccountId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "service-accounts", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveServiceAccountsHandler: + Handler<List<ServiceAccountRetrieveServiceAccountsResponse>> = + jsonHandler<List<ServiceAccountRetrieveServiceAccountsResponse>>( + clientOptions.jsonMapper + ) + + override fun retrieveServiceAccounts( + params: ServiceAccountRetrieveServiceAccountsParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<ServiceAccountRetrieveServiceAccountsResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "service-accounts") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveServiceAccountsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val serviceAccountsHandler: Handler<ServiceAccountServiceAccountsResponse> = + jsonHandler<ServiceAccountServiceAccountsResponse>(clientOptions.jsonMapper) + + override fun serviceAccounts( + params: ServiceAccountServiceAccountsParams, + requestOptions: RequestOptions, + ): HttpResponseFor<ServiceAccountServiceAccountsResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "service-accounts") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { serviceAccountsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/SessionService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/SessionService.kt new file mode 100644 index 00000000..c2b463cb --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/SessionService.kt @@ -0,0 +1,545 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.sessions.CustomChartsSection +import com.langsmith_api.api.models.api.v1.sessions.SessionCreateParams +import com.langsmith_api.api.models.api.v1.sessions.SessionDashboardParams +import com.langsmith_api.api.models.api.v1.sessions.SessionDeleteAllParams +import com.langsmith_api.api.models.api.v1.sessions.SessionDeleteAllResponse +import com.langsmith_api.api.models.api.v1.sessions.SessionDeleteParams +import com.langsmith_api.api.models.api.v1.sessions.SessionDeleteResponse +import com.langsmith_api.api.models.api.v1.sessions.SessionListParams +import com.langsmith_api.api.models.api.v1.sessions.SessionRetrieveMetadataParams +import com.langsmith_api.api.models.api.v1.sessions.SessionRetrieveMetadataResponse +import com.langsmith_api.api.models.api.v1.sessions.SessionRetrieveParams +import com.langsmith_api.api.models.api.v1.sessions.SessionUpdateParams +import com.langsmith_api.api.models.api.v1.sessions.TracerSession +import com.langsmith_api.api.models.api.v1.sessions.TracerSessionWithoutVirtualFields +import com.langsmith_api.api.services.blocking.api.v1.sessions.InsightService +import com.langsmith_api.api.services.blocking.api.v1.sessions.ViewService +import java.util.function.Consumer + +interface SessionService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): SessionService + + fun views(): ViewService + + fun insights(): InsightService + + /** Create a new session. */ + fun create(): TracerSessionWithoutVirtualFields = create(SessionCreateParams.none()) + + /** @see create */ + fun create( + params: SessionCreateParams = SessionCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): TracerSessionWithoutVirtualFields + + /** @see create */ + fun create( + params: SessionCreateParams = SessionCreateParams.none() + ): TracerSessionWithoutVirtualFields = create(params, RequestOptions.none()) + + /** @see create */ + fun create(requestOptions: RequestOptions): TracerSessionWithoutVirtualFields = + create(SessionCreateParams.none(), requestOptions) + + /** Get a specific session. */ + fun retrieve(sessionId: String): TracerSession = + retrieve(sessionId, SessionRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + sessionId: String, + params: SessionRetrieveParams = SessionRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): TracerSession = retrieve(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + sessionId: String, + params: SessionRetrieveParams = SessionRetrieveParams.none(), + ): TracerSession = retrieve(sessionId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: SessionRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): TracerSession + + /** @see retrieve */ + fun retrieve(params: SessionRetrieveParams): TracerSession = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(sessionId: String, requestOptions: RequestOptions): TracerSession = + retrieve(sessionId, SessionRetrieveParams.none(), requestOptions) + + /** Create a new session. */ + fun update(sessionId: String): TracerSessionWithoutVirtualFields = + update(sessionId, SessionUpdateParams.none()) + + /** @see update */ + fun update( + sessionId: String, + params: SessionUpdateParams = SessionUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): TracerSessionWithoutVirtualFields = + update(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see update */ + fun update( + sessionId: String, + params: SessionUpdateParams = SessionUpdateParams.none(), + ): TracerSessionWithoutVirtualFields = update(sessionId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: SessionUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): TracerSessionWithoutVirtualFields + + /** @see update */ + fun update(params: SessionUpdateParams): TracerSessionWithoutVirtualFields = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + sessionId: String, + requestOptions: RequestOptions, + ): TracerSessionWithoutVirtualFields = + update(sessionId, SessionUpdateParams.none(), requestOptions) + + /** Get all sessions. */ + fun list(): List<TracerSession> = list(SessionListParams.none()) + + /** @see list */ + fun list( + params: SessionListParams = SessionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<TracerSession> + + /** @see list */ + fun list(params: SessionListParams = SessionListParams.none()): List<TracerSession> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): List<TracerSession> = + list(SessionListParams.none(), requestOptions) + + /** Delete a specific session. */ + fun delete(sessionId: String): SessionDeleteResponse = + delete(sessionId, SessionDeleteParams.none()) + + /** @see delete */ + fun delete( + sessionId: String, + params: SessionDeleteParams = SessionDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): SessionDeleteResponse = + delete(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see delete */ + fun delete( + sessionId: String, + params: SessionDeleteParams = SessionDeleteParams.none(), + ): SessionDeleteResponse = delete(sessionId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: SessionDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SessionDeleteResponse + + /** @see delete */ + fun delete(params: SessionDeleteParams): SessionDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(sessionId: String, requestOptions: RequestOptions): SessionDeleteResponse = + delete(sessionId, SessionDeleteParams.none(), requestOptions) + + /** Get a prebuilt dashboard for a tracing project. */ + fun dashboard(sessionId: String, params: SessionDashboardParams): CustomChartsSection = + dashboard(sessionId, params, RequestOptions.none()) + + /** @see dashboard */ + fun dashboard( + sessionId: String, + params: SessionDashboardParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomChartsSection = + dashboard(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see dashboard */ + fun dashboard(params: SessionDashboardParams): CustomChartsSection = + dashboard(params, RequestOptions.none()) + + /** @see dashboard */ + fun dashboard( + params: SessionDashboardParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomChartsSection + + /** Delete a specific session. */ + fun deleteAll(params: SessionDeleteAllParams): SessionDeleteAllResponse = + deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + params: SessionDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SessionDeleteAllResponse + + /** + * Given a session, a number K, and (optionally) a list of metadata keys, return the top K + * values for each key. + */ + fun retrieveMetadata(sessionId: String): SessionRetrieveMetadataResponse = + retrieveMetadata(sessionId, SessionRetrieveMetadataParams.none()) + + /** @see retrieveMetadata */ + fun retrieveMetadata( + sessionId: String, + params: SessionRetrieveMetadataParams = SessionRetrieveMetadataParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): SessionRetrieveMetadataResponse = + retrieveMetadata(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see retrieveMetadata */ + fun retrieveMetadata( + sessionId: String, + params: SessionRetrieveMetadataParams = SessionRetrieveMetadataParams.none(), + ): SessionRetrieveMetadataResponse = retrieveMetadata(sessionId, params, RequestOptions.none()) + + /** @see retrieveMetadata */ + fun retrieveMetadata( + params: SessionRetrieveMetadataParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SessionRetrieveMetadataResponse + + /** @see retrieveMetadata */ + fun retrieveMetadata(params: SessionRetrieveMetadataParams): SessionRetrieveMetadataResponse = + retrieveMetadata(params, RequestOptions.none()) + + /** @see retrieveMetadata */ + fun retrieveMetadata( + sessionId: String, + requestOptions: RequestOptions, + ): SessionRetrieveMetadataResponse = + retrieveMetadata(sessionId, SessionRetrieveMetadataParams.none(), requestOptions) + + /** A view of [SessionService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): SessionService.WithRawResponse + + fun views(): ViewService.WithRawResponse + + fun insights(): InsightService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/sessions`, but is otherwise the same as + * [SessionService.create]. + */ + @MustBeClosed + fun create(): HttpResponseFor<TracerSessionWithoutVirtualFields> = + create(SessionCreateParams.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: SessionCreateParams = SessionCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<TracerSessionWithoutVirtualFields> + + /** @see create */ + @MustBeClosed + fun create( + params: SessionCreateParams = SessionCreateParams.none() + ): HttpResponseFor<TracerSessionWithoutVirtualFields> = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + requestOptions: RequestOptions + ): HttpResponseFor<TracerSessionWithoutVirtualFields> = + create(SessionCreateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/sessions/{session_id}`, but is otherwise the + * same as [SessionService.retrieve]. + */ + @MustBeClosed + fun retrieve(sessionId: String): HttpResponseFor<TracerSession> = + retrieve(sessionId, SessionRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + sessionId: String, + params: SessionRetrieveParams = SessionRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<TracerSession> = + retrieve(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + sessionId: String, + params: SessionRetrieveParams = SessionRetrieveParams.none(), + ): HttpResponseFor<TracerSession> = retrieve(sessionId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: SessionRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<TracerSession> + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: SessionRetrieveParams): HttpResponseFor<TracerSession> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + sessionId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<TracerSession> = + retrieve(sessionId, SessionRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `patch /api/v1/sessions/{session_id}`, but is otherwise + * the same as [SessionService.update]. + */ + @MustBeClosed + fun update(sessionId: String): HttpResponseFor<TracerSessionWithoutVirtualFields> = + update(sessionId, SessionUpdateParams.none()) + + /** @see update */ + @MustBeClosed + fun update( + sessionId: String, + params: SessionUpdateParams = SessionUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<TracerSessionWithoutVirtualFields> = + update(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update( + sessionId: String, + params: SessionUpdateParams = SessionUpdateParams.none(), + ): HttpResponseFor<TracerSessionWithoutVirtualFields> = + update(sessionId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: SessionUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<TracerSessionWithoutVirtualFields> + + /** @see update */ + @MustBeClosed + fun update( + params: SessionUpdateParams + ): HttpResponseFor<TracerSessionWithoutVirtualFields> = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + sessionId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<TracerSessionWithoutVirtualFields> = + update(sessionId, SessionUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/sessions`, but is otherwise the same as + * [SessionService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor<List<TracerSession>> = list(SessionListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: SessionListParams = SessionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<TracerSession>> + + /** @see list */ + @MustBeClosed + fun list( + params: SessionListParams = SessionListParams.none() + ): HttpResponseFor<List<TracerSession>> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor<List<TracerSession>> = + list(SessionListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/sessions/{session_id}`, but is otherwise + * the same as [SessionService.delete]. + */ + @MustBeClosed + fun delete(sessionId: String): HttpResponseFor<SessionDeleteResponse> = + delete(sessionId, SessionDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + sessionId: String, + params: SessionDeleteParams = SessionDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<SessionDeleteResponse> = + delete(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + sessionId: String, + params: SessionDeleteParams = SessionDeleteParams.none(), + ): HttpResponseFor<SessionDeleteResponse> = delete(sessionId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: SessionDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<SessionDeleteResponse> + + /** @see delete */ + @MustBeClosed + fun delete(params: SessionDeleteParams): HttpResponseFor<SessionDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + sessionId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<SessionDeleteResponse> = + delete(sessionId, SessionDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/sessions/{session_id}/dashboard`, but is + * otherwise the same as [SessionService.dashboard]. + */ + @MustBeClosed + fun dashboard( + sessionId: String, + params: SessionDashboardParams, + ): HttpResponseFor<CustomChartsSection> = + dashboard(sessionId, params, RequestOptions.none()) + + /** @see dashboard */ + @MustBeClosed + fun dashboard( + sessionId: String, + params: SessionDashboardParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CustomChartsSection> = + dashboard(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see dashboard */ + @MustBeClosed + fun dashboard(params: SessionDashboardParams): HttpResponseFor<CustomChartsSection> = + dashboard(params, RequestOptions.none()) + + /** @see dashboard */ + @MustBeClosed + fun dashboard( + params: SessionDashboardParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CustomChartsSection> + + /** + * Returns a raw HTTP response for `delete /api/v1/sessions`, but is otherwise the same as + * [SessionService.deleteAll]. + */ + @MustBeClosed + fun deleteAll(params: SessionDeleteAllParams): HttpResponseFor<SessionDeleteAllResponse> = + deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + @MustBeClosed + fun deleteAll( + params: SessionDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<SessionDeleteAllResponse> + + /** + * Returns a raw HTTP response for `get /api/v1/sessions/{session_id}/metadata`, but is + * otherwise the same as [SessionService.retrieveMetadata]. + */ + @MustBeClosed + fun retrieveMetadata(sessionId: String): HttpResponseFor<SessionRetrieveMetadataResponse> = + retrieveMetadata(sessionId, SessionRetrieveMetadataParams.none()) + + /** @see retrieveMetadata */ + @MustBeClosed + fun retrieveMetadata( + sessionId: String, + params: SessionRetrieveMetadataParams = SessionRetrieveMetadataParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<SessionRetrieveMetadataResponse> = + retrieveMetadata(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see retrieveMetadata */ + @MustBeClosed + fun retrieveMetadata( + sessionId: String, + params: SessionRetrieveMetadataParams = SessionRetrieveMetadataParams.none(), + ): HttpResponseFor<SessionRetrieveMetadataResponse> = + retrieveMetadata(sessionId, params, RequestOptions.none()) + + /** @see retrieveMetadata */ + @MustBeClosed + fun retrieveMetadata( + params: SessionRetrieveMetadataParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<SessionRetrieveMetadataResponse> + + /** @see retrieveMetadata */ + @MustBeClosed + fun retrieveMetadata( + params: SessionRetrieveMetadataParams + ): HttpResponseFor<SessionRetrieveMetadataResponse> = + retrieveMetadata(params, RequestOptions.none()) + + /** @see retrieveMetadata */ + @MustBeClosed + fun retrieveMetadata( + sessionId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<SessionRetrieveMetadataResponse> = + retrieveMetadata(sessionId, SessionRetrieveMetadataParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/SessionServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/SessionServiceImpl.kt new file mode 100644 index 00000000..51c4a088 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/SessionServiceImpl.kt @@ -0,0 +1,377 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.sessions.CustomChartsSection +import com.langsmith_api.api.models.api.v1.sessions.SessionCreateParams +import com.langsmith_api.api.models.api.v1.sessions.SessionDashboardParams +import com.langsmith_api.api.models.api.v1.sessions.SessionDeleteAllParams +import com.langsmith_api.api.models.api.v1.sessions.SessionDeleteAllResponse +import com.langsmith_api.api.models.api.v1.sessions.SessionDeleteParams +import com.langsmith_api.api.models.api.v1.sessions.SessionDeleteResponse +import com.langsmith_api.api.models.api.v1.sessions.SessionListParams +import com.langsmith_api.api.models.api.v1.sessions.SessionRetrieveMetadataParams +import com.langsmith_api.api.models.api.v1.sessions.SessionRetrieveMetadataResponse +import com.langsmith_api.api.models.api.v1.sessions.SessionRetrieveParams +import com.langsmith_api.api.models.api.v1.sessions.SessionUpdateParams +import com.langsmith_api.api.models.api.v1.sessions.TracerSession +import com.langsmith_api.api.models.api.v1.sessions.TracerSessionWithoutVirtualFields +import com.langsmith_api.api.services.blocking.api.v1.sessions.InsightService +import com.langsmith_api.api.services.blocking.api.v1.sessions.InsightServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.sessions.ViewService +import com.langsmith_api.api.services.blocking.api.v1.sessions.ViewServiceImpl +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class SessionServiceImpl internal constructor(private val clientOptions: ClientOptions) : + SessionService { + + private val withRawResponse: SessionService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val views: ViewService by lazy { ViewServiceImpl(clientOptions) } + + private val insights: InsightService by lazy { InsightServiceImpl(clientOptions) } + + override fun withRawResponse(): SessionService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): SessionService = + SessionServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun views(): ViewService = views + + override fun insights(): InsightService = insights + + override fun create( + params: SessionCreateParams, + requestOptions: RequestOptions, + ): TracerSessionWithoutVirtualFields = + // post /api/v1/sessions + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve( + params: SessionRetrieveParams, + requestOptions: RequestOptions, + ): TracerSession = + // get /api/v1/sessions/{session_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update( + params: SessionUpdateParams, + requestOptions: RequestOptions, + ): TracerSessionWithoutVirtualFields = + // patch /api/v1/sessions/{session_id} + withRawResponse().update(params, requestOptions).parse() + + override fun list( + params: SessionListParams, + requestOptions: RequestOptions, + ): List<TracerSession> = + // get /api/v1/sessions + withRawResponse().list(params, requestOptions).parse() + + override fun delete( + params: SessionDeleteParams, + requestOptions: RequestOptions, + ): SessionDeleteResponse = + // delete /api/v1/sessions/{session_id} + withRawResponse().delete(params, requestOptions).parse() + + override fun dashboard( + params: SessionDashboardParams, + requestOptions: RequestOptions, + ): CustomChartsSection = + // post /api/v1/sessions/{session_id}/dashboard + withRawResponse().dashboard(params, requestOptions).parse() + + override fun deleteAll( + params: SessionDeleteAllParams, + requestOptions: RequestOptions, + ): SessionDeleteAllResponse = + // delete /api/v1/sessions + withRawResponse().deleteAll(params, requestOptions).parse() + + override fun retrieveMetadata( + params: SessionRetrieveMetadataParams, + requestOptions: RequestOptions, + ): SessionRetrieveMetadataResponse = + // get /api/v1/sessions/{session_id}/metadata + withRawResponse().retrieveMetadata(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SessionService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val views: ViewService.WithRawResponse by lazy { + ViewServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val insights: InsightService.WithRawResponse by lazy { + InsightServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): SessionService.WithRawResponse = + SessionServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun views(): ViewService.WithRawResponse = views + + override fun insights(): InsightService.WithRawResponse = insights + + private val createHandler: Handler<TracerSessionWithoutVirtualFields> = + jsonHandler<TracerSessionWithoutVirtualFields>(clientOptions.jsonMapper) + + override fun create( + params: SessionCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<TracerSessionWithoutVirtualFields> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "sessions") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler<TracerSession> = + jsonHandler<TracerSession>(clientOptions.jsonMapper) + + override fun retrieve( + params: SessionRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor<TracerSession> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("sessionId", params.sessionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "sessions", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler<TracerSessionWithoutVirtualFields> = + jsonHandler<TracerSessionWithoutVirtualFields>(clientOptions.jsonMapper) + + override fun update( + params: SessionUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<TracerSessionWithoutVirtualFields> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("sessionId", params.sessionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "sessions", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler<List<TracerSession>> = + jsonHandler<List<TracerSession>>(clientOptions.jsonMapper) + + override fun list( + params: SessionListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<TracerSession>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "sessions") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val deleteHandler: Handler<SessionDeleteResponse> = + jsonHandler<SessionDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: SessionDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<SessionDeleteResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("sessionId", params.sessionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "sessions", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val dashboardHandler: Handler<CustomChartsSection> = + jsonHandler<CustomChartsSection>(clientOptions.jsonMapper) + + override fun dashboard( + params: SessionDashboardParams, + requestOptions: RequestOptions, + ): HttpResponseFor<CustomChartsSection> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("sessionId", params.sessionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "sessions", params._pathParam(0), "dashboard") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { dashboardHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val deleteAllHandler: Handler<SessionDeleteAllResponse> = + jsonHandler<SessionDeleteAllResponse>(clientOptions.jsonMapper) + + override fun deleteAll( + params: SessionDeleteAllParams, + requestOptions: RequestOptions, + ): HttpResponseFor<SessionDeleteAllResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "sessions") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteAllHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveMetadataHandler: Handler<SessionRetrieveMetadataResponse> = + jsonHandler<SessionRetrieveMetadataResponse>(clientOptions.jsonMapper) + + override fun retrieveMetadata( + params: SessionRetrieveMetadataParams, + requestOptions: RequestOptions, + ): HttpResponseFor<SessionRetrieveMetadataResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("sessionId", params.sessionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "sessions", params._pathParam(0), "metadata") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveMetadataHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/SettingService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/SettingService.kt new file mode 100644 index 00000000..5a66d0a4 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/SettingService.kt @@ -0,0 +1,105 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.settings.AppHubCrudTenantsTenant +import com.langsmith_api.api.models.api.v1.settings.SettingHandleParams +import com.langsmith_api.api.models.api.v1.settings.SettingListParams +import java.util.function.Consumer + +interface SettingService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): SettingService + + /** Get settings. */ + fun list(): AppHubCrudTenantsTenant = list(SettingListParams.none()) + + /** @see list */ + fun list( + params: SettingListParams = SettingListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AppHubCrudTenantsTenant + + /** @see list */ + fun list(params: SettingListParams = SettingListParams.none()): AppHubCrudTenantsTenant = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): AppHubCrudTenantsTenant = + list(SettingListParams.none(), requestOptions) + + /** Set tenant handle. */ + fun handle(params: SettingHandleParams): AppHubCrudTenantsTenant = + handle(params, RequestOptions.none()) + + /** @see handle */ + fun handle( + params: SettingHandleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AppHubCrudTenantsTenant + + /** A view of [SettingService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): SettingService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/settings`, but is otherwise the same as + * [SettingService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor<AppHubCrudTenantsTenant> = list(SettingListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: SettingListParams = SettingListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<AppHubCrudTenantsTenant> + + /** @see list */ + @MustBeClosed + fun list( + params: SettingListParams = SettingListParams.none() + ): HttpResponseFor<AppHubCrudTenantsTenant> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor<AppHubCrudTenantsTenant> = + list(SettingListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/settings/handle`, but is otherwise the same + * as [SettingService.handle]. + */ + @MustBeClosed + fun handle(params: SettingHandleParams): HttpResponseFor<AppHubCrudTenantsTenant> = + handle(params, RequestOptions.none()) + + /** @see handle */ + @MustBeClosed + fun handle( + params: SettingHandleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<AppHubCrudTenantsTenant> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/SettingServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/SettingServiceImpl.kt new file mode 100644 index 00000000..f313621e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/SettingServiceImpl.kt @@ -0,0 +1,117 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.settings.AppHubCrudTenantsTenant +import com.langsmith_api.api.models.api.v1.settings.SettingHandleParams +import com.langsmith_api.api.models.api.v1.settings.SettingListParams +import java.util.function.Consumer + +class SettingServiceImpl internal constructor(private val clientOptions: ClientOptions) : + SettingService { + + private val withRawResponse: SettingService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): SettingService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): SettingService = + SettingServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: SettingListParams, + requestOptions: RequestOptions, + ): AppHubCrudTenantsTenant = + // get /api/v1/settings + withRawResponse().list(params, requestOptions).parse() + + override fun handle( + params: SettingHandleParams, + requestOptions: RequestOptions, + ): AppHubCrudTenantsTenant = + // post /api/v1/settings/handle + withRawResponse().handle(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SettingService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): SettingService.WithRawResponse = + SettingServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler<AppHubCrudTenantsTenant> = + jsonHandler<AppHubCrudTenantsTenant>(clientOptions.jsonMapper) + + override fun list( + params: SettingListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<AppHubCrudTenantsTenant> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "settings") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val handleHandler: Handler<AppHubCrudTenantsTenant> = + jsonHandler<AppHubCrudTenantsTenant>(clientOptions.jsonMapper) + + override fun handle( + params: SettingHandleParams, + requestOptions: RequestOptions, + ): HttpResponseFor<AppHubCrudTenantsTenant> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "settings", "handle") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { handleHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/SsoService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/SsoService.kt new file mode 100644 index 00000000..0cea7495 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/SsoService.kt @@ -0,0 +1,119 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.sso.SsoRetrieveParams +import com.langsmith_api.api.models.api.v1.sso.SsoRetrieveResponse +import com.langsmith_api.api.services.blocking.api.v1.sso.EmailVerificationService +import java.util.function.Consumer + +interface SsoService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): SsoService + + fun emailVerification(): EmailVerificationService + + /** Get SSO provider settings from login slug. */ + fun retrieve(ssoLoginSlug: String): List<SsoRetrieveResponse> = + retrieve(ssoLoginSlug, SsoRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + ssoLoginSlug: String, + params: SsoRetrieveParams = SsoRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<SsoRetrieveResponse> = + retrieve(params.toBuilder().ssoLoginSlug(ssoLoginSlug).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + ssoLoginSlug: String, + params: SsoRetrieveParams = SsoRetrieveParams.none(), + ): List<SsoRetrieveResponse> = retrieve(ssoLoginSlug, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: SsoRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List<SsoRetrieveResponse> + + /** @see retrieve */ + fun retrieve(params: SsoRetrieveParams): List<SsoRetrieveResponse> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(ssoLoginSlug: String, requestOptions: RequestOptions): List<SsoRetrieveResponse> = + retrieve(ssoLoginSlug, SsoRetrieveParams.none(), requestOptions) + + /** A view of [SsoService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): SsoService.WithRawResponse + + fun emailVerification(): EmailVerificationService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/sso/settings/{sso_login_slug}`, but is + * otherwise the same as [SsoService.retrieve]. + */ + @MustBeClosed + fun retrieve(ssoLoginSlug: String): HttpResponseFor<List<SsoRetrieveResponse>> = + retrieve(ssoLoginSlug, SsoRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + ssoLoginSlug: String, + params: SsoRetrieveParams = SsoRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<SsoRetrieveResponse>> = + retrieve(params.toBuilder().ssoLoginSlug(ssoLoginSlug).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + ssoLoginSlug: String, + params: SsoRetrieveParams = SsoRetrieveParams.none(), + ): HttpResponseFor<List<SsoRetrieveResponse>> = + retrieve(ssoLoginSlug, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: SsoRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<SsoRetrieveResponse>> + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: SsoRetrieveParams): HttpResponseFor<List<SsoRetrieveResponse>> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + ssoLoginSlug: String, + requestOptions: RequestOptions, + ): HttpResponseFor<List<SsoRetrieveResponse>> = + retrieve(ssoLoginSlug, SsoRetrieveParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/SsoServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/SsoServiceImpl.kt new file mode 100644 index 00000000..14ddfe51 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/SsoServiceImpl.kt @@ -0,0 +1,99 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.sso.SsoRetrieveParams +import com.langsmith_api.api.models.api.v1.sso.SsoRetrieveResponse +import com.langsmith_api.api.services.blocking.api.v1.sso.EmailVerificationService +import com.langsmith_api.api.services.blocking.api.v1.sso.EmailVerificationServiceImpl +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class SsoServiceImpl internal constructor(private val clientOptions: ClientOptions) : SsoService { + + private val withRawResponse: SsoService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val emailVerification: EmailVerificationService by lazy { + EmailVerificationServiceImpl(clientOptions) + } + + override fun withRawResponse(): SsoService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): SsoService = + SsoServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun emailVerification(): EmailVerificationService = emailVerification + + override fun retrieve( + params: SsoRetrieveParams, + requestOptions: RequestOptions, + ): List<SsoRetrieveResponse> = + // get /api/v1/sso/settings/{sso_login_slug} + withRawResponse().retrieve(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SsoService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val emailVerification: EmailVerificationService.WithRawResponse by lazy { + EmailVerificationServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): SsoService.WithRawResponse = + SsoServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun emailVerification(): EmailVerificationService.WithRawResponse = + emailVerification + + private val retrieveHandler: Handler<List<SsoRetrieveResponse>> = + jsonHandler<List<SsoRetrieveResponse>>(clientOptions.jsonMapper) + + override fun retrieve( + params: SsoRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<SsoRetrieveResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("ssoLoginSlug", params.ssoLoginSlug().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "sso", "settings", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/TenantService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/TenantService.kt new file mode 100644 index 00000000..8d709347 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/TenantService.kt @@ -0,0 +1,105 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.tenants.AppSchemasTenant +import com.langsmith_api.api.models.api.v1.tenants.TenantCreateParams +import com.langsmith_api.api.models.api.v1.tenants.TenantForUser +import com.langsmith_api.api.models.api.v1.tenants.TenantListParams +import java.util.function.Consumer + +interface TenantService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): TenantService + + /** Create a new organization and corresponding workspace. */ + fun create(params: TenantCreateParams): AppSchemasTenant = create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: TenantCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AppSchemasTenant + + /** Get all tenants visible to this auth */ + fun list(): List<TenantForUser> = list(TenantListParams.none()) + + /** @see list */ + fun list( + params: TenantListParams = TenantListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<TenantForUser> + + /** @see list */ + fun list(params: TenantListParams = TenantListParams.none()): List<TenantForUser> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): List<TenantForUser> = + list(TenantListParams.none(), requestOptions) + + /** A view of [TenantService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): TenantService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/tenants`, but is otherwise the same as + * [TenantService.create]. + */ + @MustBeClosed + fun create(params: TenantCreateParams): HttpResponseFor<AppSchemasTenant> = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: TenantCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<AppSchemasTenant> + + /** + * Returns a raw HTTP response for `get /api/v1/tenants`, but is otherwise the same as + * [TenantService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor<List<TenantForUser>> = list(TenantListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: TenantListParams = TenantListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<TenantForUser>> + + /** @see list */ + @MustBeClosed + fun list( + params: TenantListParams = TenantListParams.none() + ): HttpResponseFor<List<TenantForUser>> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor<List<TenantForUser>> = + list(TenantListParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/TenantServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/TenantServiceImpl.kt new file mode 100644 index 00000000..b69b5b98 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/TenantServiceImpl.kt @@ -0,0 +1,118 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.tenants.AppSchemasTenant +import com.langsmith_api.api.models.api.v1.tenants.TenantCreateParams +import com.langsmith_api.api.models.api.v1.tenants.TenantForUser +import com.langsmith_api.api.models.api.v1.tenants.TenantListParams +import java.util.function.Consumer + +class TenantServiceImpl internal constructor(private val clientOptions: ClientOptions) : + TenantService { + + private val withRawResponse: TenantService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): TenantService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): TenantService = + TenantServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: TenantCreateParams, + requestOptions: RequestOptions, + ): AppSchemasTenant = + // post /api/v1/tenants + withRawResponse().create(params, requestOptions).parse() + + override fun list( + params: TenantListParams, + requestOptions: RequestOptions, + ): List<TenantForUser> = + // get /api/v1/tenants + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TenantService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): TenantService.WithRawResponse = + TenantServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<AppSchemasTenant> = + jsonHandler<AppSchemasTenant>(clientOptions.jsonMapper) + + override fun create( + params: TenantCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<AppSchemasTenant> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "tenants") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler<List<TenantForUser>> = + jsonHandler<List<TenantForUser>>(clientOptions.jsonMapper) + + override fun list( + params: TenantListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<TenantForUser>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "tenants") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/TtlSettingService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/TtlSettingService.kt new file mode 100644 index 00000000..01cf6883 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/TtlSettingService.kt @@ -0,0 +1,151 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TtlSettings +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.UpsertTtlSettingsRequest +import com.langsmith_api.api.models.api.v1.ttlsettings.TtlSettingRetrieveTtlSettingsParams +import com.langsmith_api.api.models.api.v1.ttlsettings.TtlSettingUpdateTtlSettingsParams +import java.util.function.Consumer + +interface TtlSettingService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): TtlSettingService + + /** List out the configured TTL settings for a given tenant. */ + fun retrieveTtlSettings(): List<TtlSettings> = + retrieveTtlSettings(TtlSettingRetrieveTtlSettingsParams.none()) + + /** @see retrieveTtlSettings */ + fun retrieveTtlSettings( + params: TtlSettingRetrieveTtlSettingsParams = TtlSettingRetrieveTtlSettingsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<TtlSettings> + + /** @see retrieveTtlSettings */ + fun retrieveTtlSettings( + params: TtlSettingRetrieveTtlSettingsParams = TtlSettingRetrieveTtlSettingsParams.none() + ): List<TtlSettings> = retrieveTtlSettings(params, RequestOptions.none()) + + /** @see retrieveTtlSettings */ + fun retrieveTtlSettings(requestOptions: RequestOptions): List<TtlSettings> = + retrieveTtlSettings(TtlSettingRetrieveTtlSettingsParams.none(), requestOptions) + + /** Upsert Ttl Settings */ + fun updateTtlSettings(params: TtlSettingUpdateTtlSettingsParams): TtlSettings = + updateTtlSettings(params, RequestOptions.none()) + + /** @see updateTtlSettings */ + fun updateTtlSettings( + params: TtlSettingUpdateTtlSettingsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): TtlSettings + + /** @see updateTtlSettings */ + fun updateTtlSettings( + upsertTtlSettingsRequest: UpsertTtlSettingsRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): TtlSettings = + updateTtlSettings( + TtlSettingUpdateTtlSettingsParams.builder() + .upsertTtlSettingsRequest(upsertTtlSettingsRequest) + .build(), + requestOptions, + ) + + /** @see updateTtlSettings */ + fun updateTtlSettings(upsertTtlSettingsRequest: UpsertTtlSettingsRequest): TtlSettings = + updateTtlSettings(upsertTtlSettingsRequest, RequestOptions.none()) + + /** A view of [TtlSettingService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): TtlSettingService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/ttl-settings`, but is otherwise the same as + * [TtlSettingService.retrieveTtlSettings]. + */ + @MustBeClosed + fun retrieveTtlSettings(): HttpResponseFor<List<TtlSettings>> = + retrieveTtlSettings(TtlSettingRetrieveTtlSettingsParams.none()) + + /** @see retrieveTtlSettings */ + @MustBeClosed + fun retrieveTtlSettings( + params: TtlSettingRetrieveTtlSettingsParams = + TtlSettingRetrieveTtlSettingsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<TtlSettings>> + + /** @see retrieveTtlSettings */ + @MustBeClosed + fun retrieveTtlSettings( + params: TtlSettingRetrieveTtlSettingsParams = TtlSettingRetrieveTtlSettingsParams.none() + ): HttpResponseFor<List<TtlSettings>> = retrieveTtlSettings(params, RequestOptions.none()) + + /** @see retrieveTtlSettings */ + @MustBeClosed + fun retrieveTtlSettings( + requestOptions: RequestOptions + ): HttpResponseFor<List<TtlSettings>> = + retrieveTtlSettings(TtlSettingRetrieveTtlSettingsParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `put /api/v1/ttl-settings`, but is otherwise the same as + * [TtlSettingService.updateTtlSettings]. + */ + @MustBeClosed + fun updateTtlSettings( + params: TtlSettingUpdateTtlSettingsParams + ): HttpResponseFor<TtlSettings> = updateTtlSettings(params, RequestOptions.none()) + + /** @see updateTtlSettings */ + @MustBeClosed + fun updateTtlSettings( + params: TtlSettingUpdateTtlSettingsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<TtlSettings> + + /** @see updateTtlSettings */ + @MustBeClosed + fun updateTtlSettings( + upsertTtlSettingsRequest: UpsertTtlSettingsRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<TtlSettings> = + updateTtlSettings( + TtlSettingUpdateTtlSettingsParams.builder() + .upsertTtlSettingsRequest(upsertTtlSettingsRequest) + .build(), + requestOptions, + ) + + /** @see updateTtlSettings */ + @MustBeClosed + fun updateTtlSettings( + upsertTtlSettingsRequest: UpsertTtlSettingsRequest + ): HttpResponseFor<TtlSettings> = + updateTtlSettings(upsertTtlSettingsRequest, RequestOptions.none()) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/TtlSettingServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/TtlSettingServiceImpl.kt new file mode 100644 index 00000000..cf389d5c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/TtlSettingServiceImpl.kt @@ -0,0 +1,117 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TtlSettings +import com.langsmith_api.api.models.api.v1.ttlsettings.TtlSettingRetrieveTtlSettingsParams +import com.langsmith_api.api.models.api.v1.ttlsettings.TtlSettingUpdateTtlSettingsParams +import java.util.function.Consumer + +class TtlSettingServiceImpl internal constructor(private val clientOptions: ClientOptions) : + TtlSettingService { + + private val withRawResponse: TtlSettingService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): TtlSettingService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): TtlSettingService = + TtlSettingServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieveTtlSettings( + params: TtlSettingRetrieveTtlSettingsParams, + requestOptions: RequestOptions, + ): List<TtlSettings> = + // get /api/v1/ttl-settings + withRawResponse().retrieveTtlSettings(params, requestOptions).parse() + + override fun updateTtlSettings( + params: TtlSettingUpdateTtlSettingsParams, + requestOptions: RequestOptions, + ): TtlSettings = + // put /api/v1/ttl-settings + withRawResponse().updateTtlSettings(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TtlSettingService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): TtlSettingService.WithRawResponse = + TtlSettingServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveTtlSettingsHandler: Handler<List<TtlSettings>> = + jsonHandler<List<TtlSettings>>(clientOptions.jsonMapper) + + override fun retrieveTtlSettings( + params: TtlSettingRetrieveTtlSettingsParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<TtlSettings>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "ttl-settings") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveTtlSettingsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val updateTtlSettingsHandler: Handler<TtlSettings> = + jsonHandler<TtlSettings>(clientOptions.jsonMapper) + + override fun updateTtlSettings( + params: TtlSettingUpdateTtlSettingsParams, + requestOptions: RequestOptions, + ): HttpResponseFor<TtlSettings> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "ttl-settings") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateTtlSettingsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/UsageLimitService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/UsageLimitService.kt new file mode 100644 index 00000000..4e44380a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/UsageLimitService.kt @@ -0,0 +1,236 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.usagelimits.UsageLimit +import com.langsmith_api.api.models.api.v1.usagelimits.UsageLimitDeleteParams +import com.langsmith_api.api.models.api.v1.usagelimits.UsageLimitDeleteResponse +import com.langsmith_api.api.models.api.v1.usagelimits.UsageLimitRetrieveOrgParams +import com.langsmith_api.api.models.api.v1.usagelimits.UsageLimitRetrieveUsageLimitsParams +import com.langsmith_api.api.models.api.v1.usagelimits.UsageLimitUpdateUsageLimitsParams +import java.util.function.Consumer + +interface UsageLimitService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): UsageLimitService + + /** Delete a specific usage limit. */ + fun delete(usageLimitId: String): UsageLimitDeleteResponse = + delete(usageLimitId, UsageLimitDeleteParams.none()) + + /** @see delete */ + fun delete( + usageLimitId: String, + params: UsageLimitDeleteParams = UsageLimitDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): UsageLimitDeleteResponse = + delete(params.toBuilder().usageLimitId(usageLimitId).build(), requestOptions) + + /** @see delete */ + fun delete( + usageLimitId: String, + params: UsageLimitDeleteParams = UsageLimitDeleteParams.none(), + ): UsageLimitDeleteResponse = delete(usageLimitId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: UsageLimitDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): UsageLimitDeleteResponse + + /** @see delete */ + fun delete(params: UsageLimitDeleteParams): UsageLimitDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(usageLimitId: String, requestOptions: RequestOptions): UsageLimitDeleteResponse = + delete(usageLimitId, UsageLimitDeleteParams.none(), requestOptions) + + /** List out the configured usage limits for a given organization. */ + fun retrieveOrg(): List<UsageLimit> = retrieveOrg(UsageLimitRetrieveOrgParams.none()) + + /** @see retrieveOrg */ + fun retrieveOrg( + params: UsageLimitRetrieveOrgParams = UsageLimitRetrieveOrgParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<UsageLimit> + + /** @see retrieveOrg */ + fun retrieveOrg( + params: UsageLimitRetrieveOrgParams = UsageLimitRetrieveOrgParams.none() + ): List<UsageLimit> = retrieveOrg(params, RequestOptions.none()) + + /** @see retrieveOrg */ + fun retrieveOrg(requestOptions: RequestOptions): List<UsageLimit> = + retrieveOrg(UsageLimitRetrieveOrgParams.none(), requestOptions) + + /** List out the configured usage limits for a given tenant. */ + fun retrieveUsageLimits(): List<UsageLimit> = + retrieveUsageLimits(UsageLimitRetrieveUsageLimitsParams.none()) + + /** @see retrieveUsageLimits */ + fun retrieveUsageLimits( + params: UsageLimitRetrieveUsageLimitsParams = UsageLimitRetrieveUsageLimitsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<UsageLimit> + + /** @see retrieveUsageLimits */ + fun retrieveUsageLimits( + params: UsageLimitRetrieveUsageLimitsParams = UsageLimitRetrieveUsageLimitsParams.none() + ): List<UsageLimit> = retrieveUsageLimits(params, RequestOptions.none()) + + /** @see retrieveUsageLimits */ + fun retrieveUsageLimits(requestOptions: RequestOptions): List<UsageLimit> = + retrieveUsageLimits(UsageLimitRetrieveUsageLimitsParams.none(), requestOptions) + + /** Create a new usage limit. */ + fun updateUsageLimits(params: UsageLimitUpdateUsageLimitsParams): UsageLimit = + updateUsageLimits(params, RequestOptions.none()) + + /** @see updateUsageLimits */ + fun updateUsageLimits( + params: UsageLimitUpdateUsageLimitsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): UsageLimit + + /** A view of [UsageLimitService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): UsageLimitService.WithRawResponse + + /** + * Returns a raw HTTP response for `delete /api/v1/usage-limits/{usage_limit_id}`, but is + * otherwise the same as [UsageLimitService.delete]. + */ + @MustBeClosed + fun delete(usageLimitId: String): HttpResponseFor<UsageLimitDeleteResponse> = + delete(usageLimitId, UsageLimitDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + usageLimitId: String, + params: UsageLimitDeleteParams = UsageLimitDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<UsageLimitDeleteResponse> = + delete(params.toBuilder().usageLimitId(usageLimitId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + usageLimitId: String, + params: UsageLimitDeleteParams = UsageLimitDeleteParams.none(), + ): HttpResponseFor<UsageLimitDeleteResponse> = + delete(usageLimitId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: UsageLimitDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<UsageLimitDeleteResponse> + + /** @see delete */ + @MustBeClosed + fun delete(params: UsageLimitDeleteParams): HttpResponseFor<UsageLimitDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + usageLimitId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<UsageLimitDeleteResponse> = + delete(usageLimitId, UsageLimitDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/usage-limits/org`, but is otherwise the same + * as [UsageLimitService.retrieveOrg]. + */ + @MustBeClosed + fun retrieveOrg(): HttpResponseFor<List<UsageLimit>> = + retrieveOrg(UsageLimitRetrieveOrgParams.none()) + + /** @see retrieveOrg */ + @MustBeClosed + fun retrieveOrg( + params: UsageLimitRetrieveOrgParams = UsageLimitRetrieveOrgParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<UsageLimit>> + + /** @see retrieveOrg */ + @MustBeClosed + fun retrieveOrg( + params: UsageLimitRetrieveOrgParams = UsageLimitRetrieveOrgParams.none() + ): HttpResponseFor<List<UsageLimit>> = retrieveOrg(params, RequestOptions.none()) + + /** @see retrieveOrg */ + @MustBeClosed + fun retrieveOrg(requestOptions: RequestOptions): HttpResponseFor<List<UsageLimit>> = + retrieveOrg(UsageLimitRetrieveOrgParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/usage-limits`, but is otherwise the same as + * [UsageLimitService.retrieveUsageLimits]. + */ + @MustBeClosed + fun retrieveUsageLimits(): HttpResponseFor<List<UsageLimit>> = + retrieveUsageLimits(UsageLimitRetrieveUsageLimitsParams.none()) + + /** @see retrieveUsageLimits */ + @MustBeClosed + fun retrieveUsageLimits( + params: UsageLimitRetrieveUsageLimitsParams = + UsageLimitRetrieveUsageLimitsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<UsageLimit>> + + /** @see retrieveUsageLimits */ + @MustBeClosed + fun retrieveUsageLimits( + params: UsageLimitRetrieveUsageLimitsParams = UsageLimitRetrieveUsageLimitsParams.none() + ): HttpResponseFor<List<UsageLimit>> = retrieveUsageLimits(params, RequestOptions.none()) + + /** @see retrieveUsageLimits */ + @MustBeClosed + fun retrieveUsageLimits(requestOptions: RequestOptions): HttpResponseFor<List<UsageLimit>> = + retrieveUsageLimits(UsageLimitRetrieveUsageLimitsParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `put /api/v1/usage-limits`, but is otherwise the same as + * [UsageLimitService.updateUsageLimits]. + */ + @MustBeClosed + fun updateUsageLimits( + params: UsageLimitUpdateUsageLimitsParams + ): HttpResponseFor<UsageLimit> = updateUsageLimits(params, RequestOptions.none()) + + /** @see updateUsageLimits */ + @MustBeClosed + fun updateUsageLimits( + params: UsageLimitUpdateUsageLimitsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<UsageLimit> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/UsageLimitServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/UsageLimitServiceImpl.kt new file mode 100644 index 00000000..bc77fba3 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/UsageLimitServiceImpl.kt @@ -0,0 +1,194 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.usagelimits.UsageLimit +import com.langsmith_api.api.models.api.v1.usagelimits.UsageLimitDeleteParams +import com.langsmith_api.api.models.api.v1.usagelimits.UsageLimitDeleteResponse +import com.langsmith_api.api.models.api.v1.usagelimits.UsageLimitRetrieveOrgParams +import com.langsmith_api.api.models.api.v1.usagelimits.UsageLimitRetrieveUsageLimitsParams +import com.langsmith_api.api.models.api.v1.usagelimits.UsageLimitUpdateUsageLimitsParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class UsageLimitServiceImpl internal constructor(private val clientOptions: ClientOptions) : + UsageLimitService { + + private val withRawResponse: UsageLimitService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): UsageLimitService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): UsageLimitService = + UsageLimitServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun delete( + params: UsageLimitDeleteParams, + requestOptions: RequestOptions, + ): UsageLimitDeleteResponse = + // delete /api/v1/usage-limits/{usage_limit_id} + withRawResponse().delete(params, requestOptions).parse() + + override fun retrieveOrg( + params: UsageLimitRetrieveOrgParams, + requestOptions: RequestOptions, + ): List<UsageLimit> = + // get /api/v1/usage-limits/org + withRawResponse().retrieveOrg(params, requestOptions).parse() + + override fun retrieveUsageLimits( + params: UsageLimitRetrieveUsageLimitsParams, + requestOptions: RequestOptions, + ): List<UsageLimit> = + // get /api/v1/usage-limits + withRawResponse().retrieveUsageLimits(params, requestOptions).parse() + + override fun updateUsageLimits( + params: UsageLimitUpdateUsageLimitsParams, + requestOptions: RequestOptions, + ): UsageLimit = + // put /api/v1/usage-limits + withRawResponse().updateUsageLimits(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + UsageLimitService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): UsageLimitService.WithRawResponse = + UsageLimitServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val deleteHandler: Handler<UsageLimitDeleteResponse> = + jsonHandler<UsageLimitDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: UsageLimitDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<UsageLimitDeleteResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("usageLimitId", params.usageLimitId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "usage-limits", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveOrgHandler: Handler<List<UsageLimit>> = + jsonHandler<List<UsageLimit>>(clientOptions.jsonMapper) + + override fun retrieveOrg( + params: UsageLimitRetrieveOrgParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<UsageLimit>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "usage-limits", "org") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveOrgHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val retrieveUsageLimitsHandler: Handler<List<UsageLimit>> = + jsonHandler<List<UsageLimit>>(clientOptions.jsonMapper) + + override fun retrieveUsageLimits( + params: UsageLimitRetrieveUsageLimitsParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<UsageLimit>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "usage-limits") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveUsageLimitsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val updateUsageLimitsHandler: Handler<UsageLimit> = + jsonHandler<UsageLimit>(clientOptions.jsonMapper) + + override fun updateUsageLimits( + params: UsageLimitUpdateUsageLimitsParams, + requestOptions: RequestOptions, + ): HttpResponseFor<UsageLimit> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "usage-limits") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateUsageLimitsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/WorkspaceService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/WorkspaceService.kt new file mode 100644 index 00000000..8f542227 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/WorkspaceService.kt @@ -0,0 +1,252 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.tenants.AppSchemasTenant +import com.langsmith_api.api.models.api.v1.tenants.TenantForUser +import com.langsmith_api.api.models.api.v1.workspaces.WorkspaceCreateParams +import com.langsmith_api.api.models.api.v1.workspaces.WorkspaceDeleteParams +import com.langsmith_api.api.models.api.v1.workspaces.WorkspaceDeleteResponse +import com.langsmith_api.api.models.api.v1.workspaces.WorkspaceListParams +import com.langsmith_api.api.models.api.v1.workspaces.WorkspaceUpdateParams +import com.langsmith_api.api.services.blocking.api.v1.workspaces.CurrentService +import com.langsmith_api.api.services.blocking.api.v1.workspaces.PendingService +import java.util.function.Consumer + +interface WorkspaceService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): WorkspaceService + + fun pending(): PendingService + + fun current(): CurrentService + + /** Create a new workspace. */ + fun create(params: WorkspaceCreateParams): AppSchemasTenant = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: WorkspaceCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AppSchemasTenant + + /** Patch Workspace */ + fun update(workspaceId: String, params: WorkspaceUpdateParams): AppSchemasTenant = + update(workspaceId, params, RequestOptions.none()) + + /** @see update */ + fun update( + workspaceId: String, + params: WorkspaceUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AppSchemasTenant = + update(params.toBuilder().workspaceId(workspaceId).build(), requestOptions) + + /** @see update */ + fun update(params: WorkspaceUpdateParams): AppSchemasTenant = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: WorkspaceUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AppSchemasTenant + + /** + * Get all workspaces visible to this auth in the current org. Does not create a new + * workspace/org. + */ + fun list(): List<TenantForUser> = list(WorkspaceListParams.none()) + + /** @see list */ + fun list( + params: WorkspaceListParams = WorkspaceListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<TenantForUser> + + /** @see list */ + fun list(params: WorkspaceListParams = WorkspaceListParams.none()): List<TenantForUser> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): List<TenantForUser> = + list(WorkspaceListParams.none(), requestOptions) + + /** Delete Workspace */ + fun delete(workspaceId: String): WorkspaceDeleteResponse = + delete(workspaceId, WorkspaceDeleteParams.none()) + + /** @see delete */ + fun delete( + workspaceId: String, + params: WorkspaceDeleteParams = WorkspaceDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): WorkspaceDeleteResponse = + delete(params.toBuilder().workspaceId(workspaceId).build(), requestOptions) + + /** @see delete */ + fun delete( + workspaceId: String, + params: WorkspaceDeleteParams = WorkspaceDeleteParams.none(), + ): WorkspaceDeleteResponse = delete(workspaceId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: WorkspaceDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): WorkspaceDeleteResponse + + /** @see delete */ + fun delete(params: WorkspaceDeleteParams): WorkspaceDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(workspaceId: String, requestOptions: RequestOptions): WorkspaceDeleteResponse = + delete(workspaceId, WorkspaceDeleteParams.none(), requestOptions) + + /** A view of [WorkspaceService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): WorkspaceService.WithRawResponse + + fun pending(): PendingService.WithRawResponse + + fun current(): CurrentService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/workspaces`, but is otherwise the same as + * [WorkspaceService.create]. + */ + @MustBeClosed + fun create(params: WorkspaceCreateParams): HttpResponseFor<AppSchemasTenant> = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: WorkspaceCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<AppSchemasTenant> + + /** + * Returns a raw HTTP response for `patch /api/v1/workspaces/{workspace_id}`, but is + * otherwise the same as [WorkspaceService.update]. + */ + @MustBeClosed + fun update( + workspaceId: String, + params: WorkspaceUpdateParams, + ): HttpResponseFor<AppSchemasTenant> = update(workspaceId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + workspaceId: String, + params: WorkspaceUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<AppSchemasTenant> = + update(params.toBuilder().workspaceId(workspaceId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(params: WorkspaceUpdateParams): HttpResponseFor<AppSchemasTenant> = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: WorkspaceUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<AppSchemasTenant> + + /** + * Returns a raw HTTP response for `get /api/v1/workspaces`, but is otherwise the same as + * [WorkspaceService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor<List<TenantForUser>> = list(WorkspaceListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: WorkspaceListParams = WorkspaceListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<TenantForUser>> + + /** @see list */ + @MustBeClosed + fun list( + params: WorkspaceListParams = WorkspaceListParams.none() + ): HttpResponseFor<List<TenantForUser>> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor<List<TenantForUser>> = + list(WorkspaceListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/workspaces/{workspace_id}`, but is + * otherwise the same as [WorkspaceService.delete]. + */ + @MustBeClosed + fun delete(workspaceId: String): HttpResponseFor<WorkspaceDeleteResponse> = + delete(workspaceId, WorkspaceDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + workspaceId: String, + params: WorkspaceDeleteParams = WorkspaceDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<WorkspaceDeleteResponse> = + delete(params.toBuilder().workspaceId(workspaceId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + workspaceId: String, + params: WorkspaceDeleteParams = WorkspaceDeleteParams.none(), + ): HttpResponseFor<WorkspaceDeleteResponse> = + delete(workspaceId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: WorkspaceDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<WorkspaceDeleteResponse> + + /** @see delete */ + @MustBeClosed + fun delete(params: WorkspaceDeleteParams): HttpResponseFor<WorkspaceDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + workspaceId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<WorkspaceDeleteResponse> = + delete(workspaceId, WorkspaceDeleteParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/WorkspaceServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/WorkspaceServiceImpl.kt new file mode 100644 index 00000000..6ff85a78 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/WorkspaceServiceImpl.kt @@ -0,0 +1,223 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.tenants.AppSchemasTenant +import com.langsmith_api.api.models.api.v1.tenants.TenantForUser +import com.langsmith_api.api.models.api.v1.workspaces.WorkspaceCreateParams +import com.langsmith_api.api.models.api.v1.workspaces.WorkspaceDeleteParams +import com.langsmith_api.api.models.api.v1.workspaces.WorkspaceDeleteResponse +import com.langsmith_api.api.models.api.v1.workspaces.WorkspaceListParams +import com.langsmith_api.api.models.api.v1.workspaces.WorkspaceUpdateParams +import com.langsmith_api.api.services.blocking.api.v1.workspaces.CurrentService +import com.langsmith_api.api.services.blocking.api.v1.workspaces.CurrentServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.workspaces.PendingService +import com.langsmith_api.api.services.blocking.api.v1.workspaces.PendingServiceImpl +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class WorkspaceServiceImpl internal constructor(private val clientOptions: ClientOptions) : + WorkspaceService { + + private val withRawResponse: WorkspaceService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val pending: PendingService by lazy { PendingServiceImpl(clientOptions) } + + private val current: CurrentService by lazy { CurrentServiceImpl(clientOptions) } + + override fun withRawResponse(): WorkspaceService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): WorkspaceService = + WorkspaceServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun pending(): PendingService = pending + + override fun current(): CurrentService = current + + override fun create( + params: WorkspaceCreateParams, + requestOptions: RequestOptions, + ): AppSchemasTenant = + // post /api/v1/workspaces + withRawResponse().create(params, requestOptions).parse() + + override fun update( + params: WorkspaceUpdateParams, + requestOptions: RequestOptions, + ): AppSchemasTenant = + // patch /api/v1/workspaces/{workspace_id} + withRawResponse().update(params, requestOptions).parse() + + override fun list( + params: WorkspaceListParams, + requestOptions: RequestOptions, + ): List<TenantForUser> = + // get /api/v1/workspaces + withRawResponse().list(params, requestOptions).parse() + + override fun delete( + params: WorkspaceDeleteParams, + requestOptions: RequestOptions, + ): WorkspaceDeleteResponse = + // delete /api/v1/workspaces/{workspace_id} + withRawResponse().delete(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + WorkspaceService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val pending: PendingService.WithRawResponse by lazy { + PendingServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val current: CurrentService.WithRawResponse by lazy { + CurrentServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): WorkspaceService.WithRawResponse = + WorkspaceServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun pending(): PendingService.WithRawResponse = pending + + override fun current(): CurrentService.WithRawResponse = current + + private val createHandler: Handler<AppSchemasTenant> = + jsonHandler<AppSchemasTenant>(clientOptions.jsonMapper) + + override fun create( + params: WorkspaceCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<AppSchemasTenant> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler<AppSchemasTenant> = + jsonHandler<AppSchemasTenant>(clientOptions.jsonMapper) + + override fun update( + params: WorkspaceUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<AppSchemasTenant> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("workspaceId", params.workspaceId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler<List<TenantForUser>> = + jsonHandler<List<TenantForUser>>(clientOptions.jsonMapper) + + override fun list( + params: WorkspaceListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<TenantForUser>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val deleteHandler: Handler<WorkspaceDeleteResponse> = + jsonHandler<WorkspaceDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: WorkspaceDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<WorkspaceDeleteResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("workspaceId", params.workspaceId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/annotationqueues/RunService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/annotationqueues/RunService.kt new file mode 100644 index 00000000..51152eb1 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/annotationqueues/RunService.kt @@ -0,0 +1,299 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.annotationqueues + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.annotationqueues.RunSchemaWithAnnotationQueueInfo +import com.langsmith_api.api.models.api.v1.annotationqueues.runs.RunCreateParams +import com.langsmith_api.api.models.api.v1.annotationqueues.runs.RunCreateResponse +import com.langsmith_api.api.models.api.v1.annotationqueues.runs.RunDeleteParams +import com.langsmith_api.api.models.api.v1.annotationqueues.runs.RunDeleteResponse +import com.langsmith_api.api.models.api.v1.annotationqueues.runs.RunListParams +import com.langsmith_api.api.models.api.v1.annotationqueues.runs.RunUpdateParams +import com.langsmith_api.api.models.api.v1.annotationqueues.runs.RunUpdateResponse +import java.util.function.Consumer + +interface RunService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunService + + /** Add Runs To Annotation Queue */ + fun create(queueId: String, params: RunCreateParams): List<RunCreateResponse> = + create(queueId, params, RequestOptions.none()) + + /** @see create */ + fun create( + queueId: String, + params: RunCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List<RunCreateResponse> = create(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see create */ + fun create(params: RunCreateParams): List<RunCreateResponse> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: RunCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List<RunCreateResponse> + + /** Update Run In Annotation Queue */ + fun update(queueRunId: String, params: RunUpdateParams): RunUpdateResponse = + update(queueRunId, params, RequestOptions.none()) + + /** @see update */ + fun update( + queueRunId: String, + params: RunUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RunUpdateResponse = update(params.toBuilder().queueRunId(queueRunId).build(), requestOptions) + + /** @see update */ + fun update(params: RunUpdateParams): RunUpdateResponse = update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: RunUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RunUpdateResponse + + /** Get Runs From Annotation Queue */ + fun list(queueId: String): List<RunSchemaWithAnnotationQueueInfo> = + list(queueId, RunListParams.none()) + + /** @see list */ + fun list( + queueId: String, + params: RunListParams = RunListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<RunSchemaWithAnnotationQueueInfo> = + list(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see list */ + fun list( + queueId: String, + params: RunListParams = RunListParams.none(), + ): List<RunSchemaWithAnnotationQueueInfo> = list(queueId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: RunListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List<RunSchemaWithAnnotationQueueInfo> + + /** @see list */ + fun list(params: RunListParams): List<RunSchemaWithAnnotationQueueInfo> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + queueId: String, + requestOptions: RequestOptions, + ): List<RunSchemaWithAnnotationQueueInfo> = list(queueId, RunListParams.none(), requestOptions) + + /** Delete Runs From Annotation Queue */ + fun delete(queueId: String): RunDeleteResponse = delete(queueId, RunDeleteParams.none()) + + /** @see delete */ + fun delete( + queueId: String, + params: RunDeleteParams = RunDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): RunDeleteResponse = delete(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see delete */ + fun delete( + queueId: String, + params: RunDeleteParams = RunDeleteParams.none(), + ): RunDeleteResponse = delete(queueId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: RunDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RunDeleteResponse + + /** @see delete */ + fun delete(params: RunDeleteParams): RunDeleteResponse = delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(queueId: String, requestOptions: RequestOptions): RunDeleteResponse = + delete(queueId, RunDeleteParams.none(), requestOptions) + + /** A view of [RunService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/annotation-queues/{queue_id}/runs`, but is + * otherwise the same as [RunService.create]. + */ + @MustBeClosed + fun create( + queueId: String, + params: RunCreateParams, + ): HttpResponseFor<List<RunCreateResponse>> = create(queueId, params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + queueId: String, + params: RunCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<RunCreateResponse>> = + create(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(params: RunCreateParams): HttpResponseFor<List<RunCreateResponse>> = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: RunCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<RunCreateResponse>> + + /** + * Returns a raw HTTP response for `patch + * /api/v1/annotation-queues/{queue_id}/runs/{queue_run_id}`, but is otherwise the same as + * [RunService.update]. + */ + @MustBeClosed + fun update( + queueRunId: String, + params: RunUpdateParams, + ): HttpResponseFor<RunUpdateResponse> = update(queueRunId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + queueRunId: String, + params: RunUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RunUpdateResponse> = + update(params.toBuilder().queueRunId(queueRunId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(params: RunUpdateParams): HttpResponseFor<RunUpdateResponse> = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: RunUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RunUpdateResponse> + + /** + * Returns a raw HTTP response for `get /api/v1/annotation-queues/{queue_id}/runs`, but is + * otherwise the same as [RunService.list]. + */ + @MustBeClosed + fun list(queueId: String): HttpResponseFor<List<RunSchemaWithAnnotationQueueInfo>> = + list(queueId, RunListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + queueId: String, + params: RunListParams = RunListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<RunSchemaWithAnnotationQueueInfo>> = + list(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see list */ + @MustBeClosed + fun list( + queueId: String, + params: RunListParams = RunListParams.none(), + ): HttpResponseFor<List<RunSchemaWithAnnotationQueueInfo>> = + list(queueId, params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: RunListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<RunSchemaWithAnnotationQueueInfo>> + + /** @see list */ + @MustBeClosed + fun list(params: RunListParams): HttpResponseFor<List<RunSchemaWithAnnotationQueueInfo>> = + list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + queueId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<List<RunSchemaWithAnnotationQueueInfo>> = + list(queueId, RunListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/annotation-queues/{queue_id}/runs/delete`, + * but is otherwise the same as [RunService.delete]. + */ + @MustBeClosed + fun delete(queueId: String): HttpResponseFor<RunDeleteResponse> = + delete(queueId, RunDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + queueId: String, + params: RunDeleteParams = RunDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RunDeleteResponse> = + delete(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + queueId: String, + params: RunDeleteParams = RunDeleteParams.none(), + ): HttpResponseFor<RunDeleteResponse> = delete(queueId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: RunDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RunDeleteResponse> + + /** @see delete */ + @MustBeClosed + fun delete(params: RunDeleteParams): HttpResponseFor<RunDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + queueId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<RunDeleteResponse> = + delete(queueId, RunDeleteParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/annotationqueues/RunServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/annotationqueues/RunServiceImpl.kt new file mode 100644 index 00000000..fb87b43f --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/annotationqueues/RunServiceImpl.kt @@ -0,0 +1,219 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.annotationqueues + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.annotationqueues.RunSchemaWithAnnotationQueueInfo +import com.langsmith_api.api.models.api.v1.annotationqueues.runs.RunCreateParams +import com.langsmith_api.api.models.api.v1.annotationqueues.runs.RunCreateResponse +import com.langsmith_api.api.models.api.v1.annotationqueues.runs.RunDeleteParams +import com.langsmith_api.api.models.api.v1.annotationqueues.runs.RunDeleteResponse +import com.langsmith_api.api.models.api.v1.annotationqueues.runs.RunListParams +import com.langsmith_api.api.models.api.v1.annotationqueues.runs.RunUpdateParams +import com.langsmith_api.api.models.api.v1.annotationqueues.runs.RunUpdateResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class RunServiceImpl internal constructor(private val clientOptions: ClientOptions) : RunService { + + private val withRawResponse: RunService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): RunService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunService = + RunServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: RunCreateParams, + requestOptions: RequestOptions, + ): List<RunCreateResponse> = + // post /api/v1/annotation-queues/{queue_id}/runs + withRawResponse().create(params, requestOptions).parse() + + override fun update( + params: RunUpdateParams, + requestOptions: RequestOptions, + ): RunUpdateResponse = + // patch /api/v1/annotation-queues/{queue_id}/runs/{queue_run_id} + withRawResponse().update(params, requestOptions).parse() + + override fun list( + params: RunListParams, + requestOptions: RequestOptions, + ): List<RunSchemaWithAnnotationQueueInfo> = + // get /api/v1/annotation-queues/{queue_id}/runs + withRawResponse().list(params, requestOptions).parse() + + override fun delete( + params: RunDeleteParams, + requestOptions: RequestOptions, + ): RunDeleteResponse = + // post /api/v1/annotation-queues/{queue_id}/runs/delete + withRawResponse().delete(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RunService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): RunService.WithRawResponse = + RunServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<List<RunCreateResponse>> = + jsonHandler<List<RunCreateResponse>>(clientOptions.jsonMapper) + + override fun create( + params: RunCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<RunCreateResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("queueId", params.queueId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "annotation-queues", params._pathParam(0), "runs") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val updateHandler: Handler<RunUpdateResponse> = + jsonHandler<RunUpdateResponse>(clientOptions.jsonMapper) + + override fun update( + params: RunUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<RunUpdateResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("queueRunId", params.queueRunId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "annotation-queues", + params._pathParam(0), + "runs", + params._pathParam(1), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler<List<RunSchemaWithAnnotationQueueInfo>> = + jsonHandler<List<RunSchemaWithAnnotationQueueInfo>>(clientOptions.jsonMapper) + + override fun list( + params: RunListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<RunSchemaWithAnnotationQueueInfo>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("queueId", params.queueId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "annotation-queues", params._pathParam(0), "runs") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val deleteHandler: Handler<RunDeleteResponse> = + jsonHandler<RunDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: RunDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<RunDeleteResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("queueId", params.queueId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "annotation-queues", + params._pathParam(0), + "runs", + "delete", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/apikey/CurrentService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/apikey/CurrentService.kt new file mode 100644 index 00000000..41eab750 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/apikey/CurrentService.kt @@ -0,0 +1,250 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.apikey + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.apikey.current.CurrentCreateParams +import com.langsmith_api.api.models.api.v1.apikey.current.CurrentDeleteParams +import com.langsmith_api.api.models.api.v1.apikey.current.CurrentListParams +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyCreateRequest +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyCreateResponse +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyGetResponse +import java.util.function.Consumer + +interface CurrentService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): CurrentService + + /** DEPRECATED: Use /orgs/current/personal-access-tokens instead */ + fun create(): ApiKeyCreateResponse = create(CurrentCreateParams.none()) + + /** @see create */ + fun create( + params: CurrentCreateParams = CurrentCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ApiKeyCreateResponse + + /** @see create */ + fun create(params: CurrentCreateParams = CurrentCreateParams.none()): ApiKeyCreateResponse = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + apiKeyCreateRequest: ApiKeyCreateRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): ApiKeyCreateResponse = + create( + CurrentCreateParams.builder().apiKeyCreateRequest(apiKeyCreateRequest).build(), + requestOptions, + ) + + /** @see create */ + fun create(apiKeyCreateRequest: ApiKeyCreateRequest): ApiKeyCreateResponse = + create(apiKeyCreateRequest, RequestOptions.none()) + + /** @see create */ + fun create(requestOptions: RequestOptions): ApiKeyCreateResponse = + create(CurrentCreateParams.none(), requestOptions) + + /** DEPRECATED: Use /orgs/current/personal-access-tokens instead */ + @Deprecated("deprecated") fun list(): List<ApiKeyGetResponse> = list(CurrentListParams.none()) + + /** @see list */ + @Deprecated("deprecated") + fun list( + params: CurrentListParams = CurrentListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<ApiKeyGetResponse> + + /** @see list */ + @Deprecated("deprecated") + fun list(params: CurrentListParams = CurrentListParams.none()): List<ApiKeyGetResponse> = + list(params, RequestOptions.none()) + + /** @see list */ + @Deprecated("deprecated") + fun list(requestOptions: RequestOptions): List<ApiKeyGetResponse> = + list(CurrentListParams.none(), requestOptions) + + /** DEPRECATED: Use /orgs/current/personal-access-tokens/{pat_id} instead */ + @Deprecated("deprecated") + fun delete(patId: String): ApiKeyGetResponse = delete(patId, CurrentDeleteParams.none()) + + /** @see delete */ + @Deprecated("deprecated") + fun delete( + patId: String, + params: CurrentDeleteParams = CurrentDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ApiKeyGetResponse = delete(params.toBuilder().patId(patId).build(), requestOptions) + + /** @see delete */ + @Deprecated("deprecated") + fun delete( + patId: String, + params: CurrentDeleteParams = CurrentDeleteParams.none(), + ): ApiKeyGetResponse = delete(patId, params, RequestOptions.none()) + + /** @see delete */ + @Deprecated("deprecated") + fun delete( + params: CurrentDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ApiKeyGetResponse + + /** @see delete */ + @Deprecated("deprecated") + fun delete(params: CurrentDeleteParams): ApiKeyGetResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + @Deprecated("deprecated") + fun delete(patId: String, requestOptions: RequestOptions): ApiKeyGetResponse = + delete(patId, CurrentDeleteParams.none(), requestOptions) + + /** A view of [CurrentService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): CurrentService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/api-key/current`, but is otherwise the same + * as [CurrentService.create]. + */ + @MustBeClosed + fun create(): HttpResponseFor<ApiKeyCreateResponse> = create(CurrentCreateParams.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: CurrentCreateParams = CurrentCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ApiKeyCreateResponse> + + /** @see create */ + @MustBeClosed + fun create( + params: CurrentCreateParams = CurrentCreateParams.none() + ): HttpResponseFor<ApiKeyCreateResponse> = create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + apiKeyCreateRequest: ApiKeyCreateRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ApiKeyCreateResponse> = + create( + CurrentCreateParams.builder().apiKeyCreateRequest(apiKeyCreateRequest).build(), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + apiKeyCreateRequest: ApiKeyCreateRequest + ): HttpResponseFor<ApiKeyCreateResponse> = + create(apiKeyCreateRequest, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create(requestOptions: RequestOptions): HttpResponseFor<ApiKeyCreateResponse> = + create(CurrentCreateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/api-key/current`, but is otherwise the same + * as [CurrentService.list]. + */ + @Deprecated("deprecated") + @MustBeClosed + fun list(): HttpResponseFor<List<ApiKeyGetResponse>> = list(CurrentListParams.none()) + + /** @see list */ + @Deprecated("deprecated") + @MustBeClosed + fun list( + params: CurrentListParams = CurrentListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<ApiKeyGetResponse>> + + /** @see list */ + @Deprecated("deprecated") + @MustBeClosed + fun list( + params: CurrentListParams = CurrentListParams.none() + ): HttpResponseFor<List<ApiKeyGetResponse>> = list(params, RequestOptions.none()) + + /** @see list */ + @Deprecated("deprecated") + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor<List<ApiKeyGetResponse>> = + list(CurrentListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/api-key/current/{pat_id}`, but is + * otherwise the same as [CurrentService.delete]. + */ + @Deprecated("deprecated") + @MustBeClosed + fun delete(patId: String): HttpResponseFor<ApiKeyGetResponse> = + delete(patId, CurrentDeleteParams.none()) + + /** @see delete */ + @Deprecated("deprecated") + @MustBeClosed + fun delete( + patId: String, + params: CurrentDeleteParams = CurrentDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ApiKeyGetResponse> = + delete(params.toBuilder().patId(patId).build(), requestOptions) + + /** @see delete */ + @Deprecated("deprecated") + @MustBeClosed + fun delete( + patId: String, + params: CurrentDeleteParams = CurrentDeleteParams.none(), + ): HttpResponseFor<ApiKeyGetResponse> = delete(patId, params, RequestOptions.none()) + + /** @see delete */ + @Deprecated("deprecated") + @MustBeClosed + fun delete( + params: CurrentDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ApiKeyGetResponse> + + /** @see delete */ + @Deprecated("deprecated") + @MustBeClosed + fun delete(params: CurrentDeleteParams): HttpResponseFor<ApiKeyGetResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + @Deprecated("deprecated") + @MustBeClosed + fun delete( + patId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<ApiKeyGetResponse> = + delete(patId, CurrentDeleteParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/apikey/CurrentServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/apikey/CurrentServiceImpl.kt new file mode 100644 index 00000000..d9f836fe --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/apikey/CurrentServiceImpl.kt @@ -0,0 +1,163 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.apikey + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.apikey.current.CurrentCreateParams +import com.langsmith_api.api.models.api.v1.apikey.current.CurrentDeleteParams +import com.langsmith_api.api.models.api.v1.apikey.current.CurrentListParams +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyCreateResponse +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyGetResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class CurrentServiceImpl internal constructor(private val clientOptions: ClientOptions) : + CurrentService { + + private val withRawResponse: CurrentService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): CurrentService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): CurrentService = + CurrentServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: CurrentCreateParams, + requestOptions: RequestOptions, + ): ApiKeyCreateResponse = + // post /api/v1/api-key/current + withRawResponse().create(params, requestOptions).parse() + + @Deprecated("deprecated") + override fun list( + params: CurrentListParams, + requestOptions: RequestOptions, + ): List<ApiKeyGetResponse> = + // get /api/v1/api-key/current + withRawResponse().list(params, requestOptions).parse() + + @Deprecated("deprecated") + override fun delete( + params: CurrentDeleteParams, + requestOptions: RequestOptions, + ): ApiKeyGetResponse = + // delete /api/v1/api-key/current/{pat_id} + withRawResponse().delete(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CurrentService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): CurrentService.WithRawResponse = + CurrentServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<ApiKeyCreateResponse> = + jsonHandler<ApiKeyCreateResponse>(clientOptions.jsonMapper) + + override fun create( + params: CurrentCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<ApiKeyCreateResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "api-key", "current") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler<List<ApiKeyGetResponse>> = + jsonHandler<List<ApiKeyGetResponse>>(clientOptions.jsonMapper) + + @Deprecated("deprecated") + override fun list( + params: CurrentListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<ApiKeyGetResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "api-key", "current") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val deleteHandler: Handler<ApiKeyGetResponse> = + jsonHandler<ApiKeyGetResponse>(clientOptions.jsonMapper) + + @Deprecated("deprecated") + override fun delete( + params: CurrentDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<ApiKeyGetResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("patId", params.patId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "api-key", "current", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/bulkexports/DestinationService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/bulkexports/DestinationService.kt new file mode 100644 index 00000000..f0b7f98d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/bulkexports/DestinationService.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.bulkexports + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.bulkexports.destinations.BulkExportDestination +import com.langsmith_api.api.models.api.v1.bulkexports.destinations.DestinationCreateParams +import com.langsmith_api.api.models.api.v1.bulkexports.destinations.DestinationListParams +import com.langsmith_api.api.models.api.v1.bulkexports.destinations.DestinationRetrieveParams +import java.util.function.Consumer + +interface DestinationService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): DestinationService + + /** Create a new bulk export destination */ + fun create(params: DestinationCreateParams): BulkExportDestination = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: DestinationCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): BulkExportDestination + + /** Get a single bulk export destination by ID */ + fun retrieve(destinationId: String): BulkExportDestination = + retrieve(destinationId, DestinationRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + destinationId: String, + params: DestinationRetrieveParams = DestinationRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): BulkExportDestination = + retrieve(params.toBuilder().destinationId(destinationId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + destinationId: String, + params: DestinationRetrieveParams = DestinationRetrieveParams.none(), + ): BulkExportDestination = retrieve(destinationId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: DestinationRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): BulkExportDestination + + /** @see retrieve */ + fun retrieve(params: DestinationRetrieveParams): BulkExportDestination = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(destinationId: String, requestOptions: RequestOptions): BulkExportDestination = + retrieve(destinationId, DestinationRetrieveParams.none(), requestOptions) + + /** Get the current workspace's bulk export destinations */ + fun list(): List<BulkExportDestination> = list(DestinationListParams.none()) + + /** @see list */ + fun list( + params: DestinationListParams = DestinationListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<BulkExportDestination> + + /** @see list */ + fun list( + params: DestinationListParams = DestinationListParams.none() + ): List<BulkExportDestination> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): List<BulkExportDestination> = + list(DestinationListParams.none(), requestOptions) + + /** + * A view of [DestinationService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): DestinationService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/bulk-exports/destinations`, but is + * otherwise the same as [DestinationService.create]. + */ + @MustBeClosed + fun create(params: DestinationCreateParams): HttpResponseFor<BulkExportDestination> = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: DestinationCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<BulkExportDestination> + + /** + * Returns a raw HTTP response for `get /api/v1/bulk-exports/destinations/{destination_id}`, + * but is otherwise the same as [DestinationService.retrieve]. + */ + @MustBeClosed + fun retrieve(destinationId: String): HttpResponseFor<BulkExportDestination> = + retrieve(destinationId, DestinationRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + destinationId: String, + params: DestinationRetrieveParams = DestinationRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<BulkExportDestination> = + retrieve(params.toBuilder().destinationId(destinationId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + destinationId: String, + params: DestinationRetrieveParams = DestinationRetrieveParams.none(), + ): HttpResponseFor<BulkExportDestination> = + retrieve(destinationId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: DestinationRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<BulkExportDestination> + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: DestinationRetrieveParams): HttpResponseFor<BulkExportDestination> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + destinationId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<BulkExportDestination> = + retrieve(destinationId, DestinationRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/bulk-exports/destinations`, but is otherwise + * the same as [DestinationService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor<List<BulkExportDestination>> = + list(DestinationListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: DestinationListParams = DestinationListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<BulkExportDestination>> + + /** @see list */ + @MustBeClosed + fun list( + params: DestinationListParams = DestinationListParams.none() + ): HttpResponseFor<List<BulkExportDestination>> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor<List<BulkExportDestination>> = + list(DestinationListParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/bulkexports/DestinationServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/bulkexports/DestinationServiceImpl.kt new file mode 100644 index 00000000..91628ffa --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/bulkexports/DestinationServiceImpl.kt @@ -0,0 +1,163 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.bulkexports + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.bulkexports.destinations.BulkExportDestination +import com.langsmith_api.api.models.api.v1.bulkexports.destinations.DestinationCreateParams +import com.langsmith_api.api.models.api.v1.bulkexports.destinations.DestinationListParams +import com.langsmith_api.api.models.api.v1.bulkexports.destinations.DestinationRetrieveParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class DestinationServiceImpl internal constructor(private val clientOptions: ClientOptions) : + DestinationService { + + private val withRawResponse: DestinationService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): DestinationService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): DestinationService = + DestinationServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: DestinationCreateParams, + requestOptions: RequestOptions, + ): BulkExportDestination = + // post /api/v1/bulk-exports/destinations + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve( + params: DestinationRetrieveParams, + requestOptions: RequestOptions, + ): BulkExportDestination = + // get /api/v1/bulk-exports/destinations/{destination_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun list( + params: DestinationListParams, + requestOptions: RequestOptions, + ): List<BulkExportDestination> = + // get /api/v1/bulk-exports/destinations + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + DestinationService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): DestinationService.WithRawResponse = + DestinationServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<BulkExportDestination> = + jsonHandler<BulkExportDestination>(clientOptions.jsonMapper) + + override fun create( + params: DestinationCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<BulkExportDestination> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "bulk-exports", "destinations") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler<BulkExportDestination> = + jsonHandler<BulkExportDestination>(clientOptions.jsonMapper) + + override fun retrieve( + params: DestinationRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor<BulkExportDestination> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("destinationId", params.destinationId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "bulk-exports", + "destinations", + params._pathParam(0), + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler<List<BulkExportDestination>> = + jsonHandler<List<BulkExportDestination>>(clientOptions.jsonMapper) + + override fun list( + params: DestinationListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<BulkExportDestination>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "bulk-exports", "destinations") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/bulkexports/RunService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/bulkexports/RunService.kt new file mode 100644 index 00000000..927e0941 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/bulkexports/RunService.kt @@ -0,0 +1,162 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.bulkexports + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.bulkexports.runs.BulkExportRun +import com.langsmith_api.api.models.api.v1.bulkexports.runs.RunListParams +import com.langsmith_api.api.models.api.v1.bulkexports.runs.RunRetrieveParams +import java.util.function.Consumer + +interface RunService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunService + + /** Get a single bulk export's run by ID */ + fun retrieve(runId: String, params: RunRetrieveParams): BulkExportRun = + retrieve(runId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + runId: String, + params: RunRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): BulkExportRun = retrieve(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: RunRetrieveParams): BulkExportRun = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: RunRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): BulkExportRun + + /** Get a bulk export's runs */ + fun list(bulkExportId: String): List<BulkExportRun> = list(bulkExportId, RunListParams.none()) + + /** @see list */ + fun list( + bulkExportId: String, + params: RunListParams = RunListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<BulkExportRun> = + list(params.toBuilder().bulkExportId(bulkExportId).build(), requestOptions) + + /** @see list */ + fun list( + bulkExportId: String, + params: RunListParams = RunListParams.none(), + ): List<BulkExportRun> = list(bulkExportId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: RunListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List<BulkExportRun> + + /** @see list */ + fun list(params: RunListParams): List<BulkExportRun> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(bulkExportId: String, requestOptions: RequestOptions): List<BulkExportRun> = + list(bulkExportId, RunListParams.none(), requestOptions) + + /** A view of [RunService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunService.WithRawResponse + + /** + * Returns a raw HTTP response for `get + * /api/v1/bulk-exports/{bulk_export_id}/runs/{run_id}`, but is otherwise the same as + * [RunService.retrieve]. + */ + @MustBeClosed + fun retrieve(runId: String, params: RunRetrieveParams): HttpResponseFor<BulkExportRun> = + retrieve(runId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + runId: String, + params: RunRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<BulkExportRun> = + retrieve(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: RunRetrieveParams): HttpResponseFor<BulkExportRun> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: RunRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<BulkExportRun> + + /** + * Returns a raw HTTP response for `get /api/v1/bulk-exports/{bulk_export_id}/runs`, but is + * otherwise the same as [RunService.list]. + */ + @MustBeClosed + fun list(bulkExportId: String): HttpResponseFor<List<BulkExportRun>> = + list(bulkExportId, RunListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + bulkExportId: String, + params: RunListParams = RunListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<BulkExportRun>> = + list(params.toBuilder().bulkExportId(bulkExportId).build(), requestOptions) + + /** @see list */ + @MustBeClosed + fun list( + bulkExportId: String, + params: RunListParams = RunListParams.none(), + ): HttpResponseFor<List<BulkExportRun>> = list(bulkExportId, params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: RunListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<BulkExportRun>> + + /** @see list */ + @MustBeClosed + fun list(params: RunListParams): HttpResponseFor<List<BulkExportRun>> = + list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + bulkExportId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<List<BulkExportRun>> = + list(bulkExportId, RunListParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/bulkexports/RunServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/bulkexports/RunServiceImpl.kt new file mode 100644 index 00000000..a0f425a5 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/bulkexports/RunServiceImpl.kt @@ -0,0 +1,126 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.bulkexports + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.bulkexports.runs.BulkExportRun +import com.langsmith_api.api.models.api.v1.bulkexports.runs.RunListParams +import com.langsmith_api.api.models.api.v1.bulkexports.runs.RunRetrieveParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class RunServiceImpl internal constructor(private val clientOptions: ClientOptions) : RunService { + + private val withRawResponse: RunService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): RunService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunService = + RunServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: RunRetrieveParams, + requestOptions: RequestOptions, + ): BulkExportRun = + // get /api/v1/bulk-exports/{bulk_export_id}/runs/{run_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun list(params: RunListParams, requestOptions: RequestOptions): List<BulkExportRun> = + // get /api/v1/bulk-exports/{bulk_export_id}/runs + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RunService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): RunService.WithRawResponse = + RunServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler<BulkExportRun> = + jsonHandler<BulkExportRun>(clientOptions.jsonMapper) + + override fun retrieve( + params: RunRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor<BulkExportRun> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("runId", params.runId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "bulk-exports", + params._pathParam(0), + "runs", + params._pathParam(1), + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler<List<BulkExportRun>> = + jsonHandler<List<BulkExportRun>>(clientOptions.jsonMapper) + + override fun list( + params: RunListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<BulkExportRun>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("bulkExportId", params.bulkExportId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "bulk-exports", params._pathParam(0), "runs") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/charts/SectionService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/charts/SectionService.kt new file mode 100644 index 00000000..0bf93302 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/charts/SectionService.kt @@ -0,0 +1,322 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.charts + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.charts.section.CustomChartsSectionCreate +import com.langsmith_api.api.models.api.v1.charts.section.CustomChartsSectionResponse +import com.langsmith_api.api.models.api.v1.charts.section.SectionCloneParams +import com.langsmith_api.api.models.api.v1.charts.section.SectionCreateParams +import com.langsmith_api.api.models.api.v1.charts.section.SectionDeleteParams +import com.langsmith_api.api.models.api.v1.charts.section.SectionDeleteResponse +import com.langsmith_api.api.models.api.v1.charts.section.SectionListParams +import com.langsmith_api.api.models.api.v1.charts.section.SectionUpdateParams +import java.util.function.Consumer + +interface SectionService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): SectionService + + /** Create a new section. */ + fun create(params: SectionCreateParams): CustomChartsSectionResponse = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: SectionCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomChartsSectionResponse + + /** @see create */ + fun create( + customChartsSectionCreate: CustomChartsSectionCreate, + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomChartsSectionResponse = + create( + SectionCreateParams.builder() + .customChartsSectionCreate(customChartsSectionCreate) + .build(), + requestOptions, + ) + + /** @see create */ + fun create(customChartsSectionCreate: CustomChartsSectionCreate): CustomChartsSectionResponse = + create(customChartsSectionCreate, RequestOptions.none()) + + /** Update a section. */ + fun update(sectionId: String, params: SectionUpdateParams): CustomChartsSectionResponse = + update(sectionId, params, RequestOptions.none()) + + /** @see update */ + fun update( + sectionId: String, + params: SectionUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomChartsSectionResponse = + update(params.toBuilder().sectionId(sectionId).build(), requestOptions) + + /** @see update */ + fun update(params: SectionUpdateParams): CustomChartsSectionResponse = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: SectionUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomChartsSectionResponse + + /** Get all sections for the tenant. */ + fun list(): List<CustomChartsSectionResponse> = list(SectionListParams.none()) + + /** @see list */ + fun list( + params: SectionListParams = SectionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<CustomChartsSectionResponse> + + /** @see list */ + fun list( + params: SectionListParams = SectionListParams.none() + ): List<CustomChartsSectionResponse> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): List<CustomChartsSectionResponse> = + list(SectionListParams.none(), requestOptions) + + /** Delete a section. */ + fun delete(sectionId: String): SectionDeleteResponse = + delete(sectionId, SectionDeleteParams.none()) + + /** @see delete */ + fun delete( + sectionId: String, + params: SectionDeleteParams = SectionDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): SectionDeleteResponse = + delete(params.toBuilder().sectionId(sectionId).build(), requestOptions) + + /** @see delete */ + fun delete( + sectionId: String, + params: SectionDeleteParams = SectionDeleteParams.none(), + ): SectionDeleteResponse = delete(sectionId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: SectionDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SectionDeleteResponse + + /** @see delete */ + fun delete(params: SectionDeleteParams): SectionDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(sectionId: String, requestOptions: RequestOptions): SectionDeleteResponse = + delete(sectionId, SectionDeleteParams.none(), requestOptions) + + /** Clone a dashboard. */ + fun clone(): CustomChartsSectionResponse = clone(SectionCloneParams.none()) + + /** @see clone */ + fun clone( + params: SectionCloneParams = SectionCloneParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomChartsSectionResponse + + /** @see clone */ + fun clone(params: SectionCloneParams = SectionCloneParams.none()): CustomChartsSectionResponse = + clone(params, RequestOptions.none()) + + /** @see clone */ + fun clone(requestOptions: RequestOptions): CustomChartsSectionResponse = + clone(SectionCloneParams.none(), requestOptions) + + /** A view of [SectionService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): SectionService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/charts/section`, but is otherwise the same + * as [SectionService.create]. + */ + @MustBeClosed + fun create(params: SectionCreateParams): HttpResponseFor<CustomChartsSectionResponse> = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: SectionCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CustomChartsSectionResponse> + + /** @see create */ + @MustBeClosed + fun create( + customChartsSectionCreate: CustomChartsSectionCreate, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CustomChartsSectionResponse> = + create( + SectionCreateParams.builder() + .customChartsSectionCreate(customChartsSectionCreate) + .build(), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + customChartsSectionCreate: CustomChartsSectionCreate + ): HttpResponseFor<CustomChartsSectionResponse> = + create(customChartsSectionCreate, RequestOptions.none()) + + /** + * Returns a raw HTTP response for `patch /api/v1/charts/section/{section_id}`, but is + * otherwise the same as [SectionService.update]. + */ + @MustBeClosed + fun update( + sectionId: String, + params: SectionUpdateParams, + ): HttpResponseFor<CustomChartsSectionResponse> = + update(sectionId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + sectionId: String, + params: SectionUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CustomChartsSectionResponse> = + update(params.toBuilder().sectionId(sectionId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(params: SectionUpdateParams): HttpResponseFor<CustomChartsSectionResponse> = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: SectionUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CustomChartsSectionResponse> + + /** + * Returns a raw HTTP response for `get /api/v1/charts/section`, but is otherwise the same + * as [SectionService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor<List<CustomChartsSectionResponse>> = + list(SectionListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: SectionListParams = SectionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<CustomChartsSectionResponse>> + + /** @see list */ + @MustBeClosed + fun list( + params: SectionListParams = SectionListParams.none() + ): HttpResponseFor<List<CustomChartsSectionResponse>> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + requestOptions: RequestOptions + ): HttpResponseFor<List<CustomChartsSectionResponse>> = + list(SectionListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/charts/section/{section_id}`, but is + * otherwise the same as [SectionService.delete]. + */ + @MustBeClosed + fun delete(sectionId: String): HttpResponseFor<SectionDeleteResponse> = + delete(sectionId, SectionDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + sectionId: String, + params: SectionDeleteParams = SectionDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<SectionDeleteResponse> = + delete(params.toBuilder().sectionId(sectionId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + sectionId: String, + params: SectionDeleteParams = SectionDeleteParams.none(), + ): HttpResponseFor<SectionDeleteResponse> = delete(sectionId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: SectionDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<SectionDeleteResponse> + + /** @see delete */ + @MustBeClosed + fun delete(params: SectionDeleteParams): HttpResponseFor<SectionDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + sectionId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<SectionDeleteResponse> = + delete(sectionId, SectionDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/charts/section/clone`, but is otherwise the + * same as [SectionService.clone]. + */ + @MustBeClosed + fun clone(): HttpResponseFor<CustomChartsSectionResponse> = clone(SectionCloneParams.none()) + + /** @see clone */ + @MustBeClosed + fun clone( + params: SectionCloneParams = SectionCloneParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CustomChartsSectionResponse> + + /** @see clone */ + @MustBeClosed + fun clone( + params: SectionCloneParams = SectionCloneParams.none() + ): HttpResponseFor<CustomChartsSectionResponse> = clone(params, RequestOptions.none()) + + /** @see clone */ + @MustBeClosed + fun clone(requestOptions: RequestOptions): HttpResponseFor<CustomChartsSectionResponse> = + clone(SectionCloneParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/charts/SectionServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/charts/SectionServiceImpl.kt new file mode 100644 index 00000000..b326e984 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/charts/SectionServiceImpl.kt @@ -0,0 +1,234 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.charts + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.charts.section.CustomChartsSectionResponse +import com.langsmith_api.api.models.api.v1.charts.section.SectionCloneParams +import com.langsmith_api.api.models.api.v1.charts.section.SectionCreateParams +import com.langsmith_api.api.models.api.v1.charts.section.SectionDeleteParams +import com.langsmith_api.api.models.api.v1.charts.section.SectionDeleteResponse +import com.langsmith_api.api.models.api.v1.charts.section.SectionListParams +import com.langsmith_api.api.models.api.v1.charts.section.SectionUpdateParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class SectionServiceImpl internal constructor(private val clientOptions: ClientOptions) : + SectionService { + + private val withRawResponse: SectionService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): SectionService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): SectionService = + SectionServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: SectionCreateParams, + requestOptions: RequestOptions, + ): CustomChartsSectionResponse = + // post /api/v1/charts/section + withRawResponse().create(params, requestOptions).parse() + + override fun update( + params: SectionUpdateParams, + requestOptions: RequestOptions, + ): CustomChartsSectionResponse = + // patch /api/v1/charts/section/{section_id} + withRawResponse().update(params, requestOptions).parse() + + override fun list( + params: SectionListParams, + requestOptions: RequestOptions, + ): List<CustomChartsSectionResponse> = + // get /api/v1/charts/section + withRawResponse().list(params, requestOptions).parse() + + override fun delete( + params: SectionDeleteParams, + requestOptions: RequestOptions, + ): SectionDeleteResponse = + // delete /api/v1/charts/section/{section_id} + withRawResponse().delete(params, requestOptions).parse() + + override fun clone( + params: SectionCloneParams, + requestOptions: RequestOptions, + ): CustomChartsSectionResponse = + // post /api/v1/charts/section/clone + withRawResponse().clone(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SectionService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): SectionService.WithRawResponse = + SectionServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<CustomChartsSectionResponse> = + jsonHandler<CustomChartsSectionResponse>(clientOptions.jsonMapper) + + override fun create( + params: SectionCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<CustomChartsSectionResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "charts", "section") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler<CustomChartsSectionResponse> = + jsonHandler<CustomChartsSectionResponse>(clientOptions.jsonMapper) + + override fun update( + params: SectionUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<CustomChartsSectionResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("sectionId", params.sectionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "charts", "section", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler<List<CustomChartsSectionResponse>> = + jsonHandler<List<CustomChartsSectionResponse>>(clientOptions.jsonMapper) + + override fun list( + params: SectionListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<CustomChartsSectionResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "charts", "section") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val deleteHandler: Handler<SectionDeleteResponse> = + jsonHandler<SectionDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: SectionDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<SectionDeleteResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("sectionId", params.sectionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "charts", "section", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val cloneHandler: Handler<CustomChartsSectionResponse> = + jsonHandler<CustomChartsSectionResponse>(clientOptions.jsonMapper) + + override fun clone( + params: SectionCloneParams, + requestOptions: RequestOptions, + ): HttpResponseFor<CustomChartsSectionResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "charts", "section", "clone") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { cloneHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/comments/LikeService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/comments/LikeService.kt new file mode 100644 index 00000000..6f38ed9f --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/comments/LikeService.kt @@ -0,0 +1,148 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.comments + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.comments.like.LikeCreateParams +import com.langsmith_api.api.models.api.v1.comments.like.LikeCreateResponse +import com.langsmith_api.api.models.api.v1.comments.like.LikeDeleteAllParams +import com.langsmith_api.api.models.api.v1.comments.like.LikeDeleteAllResponse +import java.util.function.Consumer + +interface LikeService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): LikeService + + /** Like Comment */ + fun create(parentCommentId: String, params: LikeCreateParams): LikeCreateResponse = + create(parentCommentId, params, RequestOptions.none()) + + /** @see create */ + fun create( + parentCommentId: String, + params: LikeCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LikeCreateResponse = + create(params.toBuilder().parentCommentId(parentCommentId).build(), requestOptions) + + /** @see create */ + fun create(params: LikeCreateParams): LikeCreateResponse = create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: LikeCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LikeCreateResponse + + /** Unlike Comment */ + fun deleteAll(parentCommentId: String, params: LikeDeleteAllParams): LikeDeleteAllResponse = + deleteAll(parentCommentId, params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + parentCommentId: String, + params: LikeDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LikeDeleteAllResponse = + deleteAll(params.toBuilder().parentCommentId(parentCommentId).build(), requestOptions) + + /** @see deleteAll */ + fun deleteAll(params: LikeDeleteAllParams): LikeDeleteAllResponse = + deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + params: LikeDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LikeDeleteAllResponse + + /** A view of [LikeService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): LikeService.WithRawResponse + + /** + * Returns a raw HTTP response for `post + * /api/v1/comments/{owner}/{repo}/{parent_comment_id}/like`, but is otherwise the same as + * [LikeService.create]. + */ + @MustBeClosed + fun create( + parentCommentId: String, + params: LikeCreateParams, + ): HttpResponseFor<LikeCreateResponse> = + create(parentCommentId, params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + parentCommentId: String, + params: LikeCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<LikeCreateResponse> = + create(params.toBuilder().parentCommentId(parentCommentId).build(), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(params: LikeCreateParams): HttpResponseFor<LikeCreateResponse> = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: LikeCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<LikeCreateResponse> + + /** + * Returns a raw HTTP response for `delete + * /api/v1/comments/{owner}/{repo}/{parent_comment_id}/like`, but is otherwise the same as + * [LikeService.deleteAll]. + */ + @MustBeClosed + fun deleteAll( + parentCommentId: String, + params: LikeDeleteAllParams, + ): HttpResponseFor<LikeDeleteAllResponse> = + deleteAll(parentCommentId, params, RequestOptions.none()) + + /** @see deleteAll */ + @MustBeClosed + fun deleteAll( + parentCommentId: String, + params: LikeDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<LikeDeleteAllResponse> = + deleteAll(params.toBuilder().parentCommentId(parentCommentId).build(), requestOptions) + + /** @see deleteAll */ + @MustBeClosed + fun deleteAll(params: LikeDeleteAllParams): HttpResponseFor<LikeDeleteAllResponse> = + deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + @MustBeClosed + fun deleteAll( + params: LikeDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<LikeDeleteAllResponse> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/comments/LikeServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/comments/LikeServiceImpl.kt new file mode 100644 index 00000000..600b45d0 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/comments/LikeServiceImpl.kt @@ -0,0 +1,142 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.comments + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.comments.like.LikeCreateParams +import com.langsmith_api.api.models.api.v1.comments.like.LikeCreateResponse +import com.langsmith_api.api.models.api.v1.comments.like.LikeDeleteAllParams +import com.langsmith_api.api.models.api.v1.comments.like.LikeDeleteAllResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class LikeServiceImpl internal constructor(private val clientOptions: ClientOptions) : LikeService { + + private val withRawResponse: LikeService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): LikeService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): LikeService = + LikeServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: LikeCreateParams, + requestOptions: RequestOptions, + ): LikeCreateResponse = + // post /api/v1/comments/{owner}/{repo}/{parent_comment_id}/like + withRawResponse().create(params, requestOptions).parse() + + override fun deleteAll( + params: LikeDeleteAllParams, + requestOptions: RequestOptions, + ): LikeDeleteAllResponse = + // delete /api/v1/comments/{owner}/{repo}/{parent_comment_id}/like + withRawResponse().deleteAll(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + LikeService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): LikeService.WithRawResponse = + LikeServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<LikeCreateResponse> = + jsonHandler<LikeCreateResponse>(clientOptions.jsonMapper) + + override fun create( + params: LikeCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<LikeCreateResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("parentCommentId", params.parentCommentId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "comments", + params._pathParam(0), + params._pathParam(1), + params._pathParam(2), + "like", + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val deleteAllHandler: Handler<LikeDeleteAllResponse> = + jsonHandler<LikeDeleteAllResponse>(clientOptions.jsonMapper) + + override fun deleteAll( + params: LikeDeleteAllParams, + requestOptions: RequestOptions, + ): HttpResponseFor<LikeDeleteAllResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("parentCommentId", params.parentCommentId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "comments", + params._pathParam(0), + params._pathParam(1), + params._pathParam(2), + "like", + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteAllHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/ComparativeService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/ComparativeService.kt new file mode 100644 index 00000000..adda8cdd --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/ComparativeService.kt @@ -0,0 +1,234 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.datasets + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.datasets.comparative.ComparativeCreateParams +import com.langsmith_api.api.models.api.v1.datasets.comparative.ComparativeCreateResponse +import com.langsmith_api.api.models.api.v1.datasets.comparative.ComparativeDeleteParams +import com.langsmith_api.api.models.api.v1.datasets.comparative.ComparativeDeleteResponse +import com.langsmith_api.api.models.api.v1.datasets.comparative.ComparativeListParams +import com.langsmith_api.api.models.api.v1.datasets.comparative.ComparativeListResponse +import java.util.function.Consumer + +interface ComparativeService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ComparativeService + + /** Create a comparative experiment. */ + fun create(params: ComparativeCreateParams): ComparativeCreateResponse = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: ComparativeCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ComparativeCreateResponse + + /** Get all comparative experiments for a given dataset. */ + fun list(datasetId: String): List<ComparativeListResponse> = + list(datasetId, ComparativeListParams.none()) + + /** @see list */ + fun list( + datasetId: String, + params: ComparativeListParams = ComparativeListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<ComparativeListResponse> = + list(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see list */ + fun list( + datasetId: String, + params: ComparativeListParams = ComparativeListParams.none(), + ): List<ComparativeListResponse> = list(datasetId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: ComparativeListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List<ComparativeListResponse> + + /** @see list */ + fun list(params: ComparativeListParams): List<ComparativeListResponse> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(datasetId: String, requestOptions: RequestOptions): List<ComparativeListResponse> = + list(datasetId, ComparativeListParams.none(), requestOptions) + + /** Delete a specific comparative experiment. */ + fun delete(comparativeExperimentId: String): ComparativeDeleteResponse = + delete(comparativeExperimentId, ComparativeDeleteParams.none()) + + /** @see delete */ + fun delete( + comparativeExperimentId: String, + params: ComparativeDeleteParams = ComparativeDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ComparativeDeleteResponse = + delete( + params.toBuilder().comparativeExperimentId(comparativeExperimentId).build(), + requestOptions, + ) + + /** @see delete */ + fun delete( + comparativeExperimentId: String, + params: ComparativeDeleteParams = ComparativeDeleteParams.none(), + ): ComparativeDeleteResponse = delete(comparativeExperimentId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ComparativeDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ComparativeDeleteResponse + + /** @see delete */ + fun delete(params: ComparativeDeleteParams): ComparativeDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + comparativeExperimentId: String, + requestOptions: RequestOptions, + ): ComparativeDeleteResponse = + delete(comparativeExperimentId, ComparativeDeleteParams.none(), requestOptions) + + /** + * A view of [ComparativeService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ComparativeService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/datasets/comparative`, but is otherwise the + * same as [ComparativeService.create]. + */ + @MustBeClosed + fun create(params: ComparativeCreateParams): HttpResponseFor<ComparativeCreateResponse> = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: ComparativeCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ComparativeCreateResponse> + + /** + * Returns a raw HTTP response for `get /api/v1/datasets/{dataset_id}/comparative`, but is + * otherwise the same as [ComparativeService.list]. + */ + @MustBeClosed + fun list(datasetId: String): HttpResponseFor<List<ComparativeListResponse>> = + list(datasetId, ComparativeListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + datasetId: String, + params: ComparativeListParams = ComparativeListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<ComparativeListResponse>> = + list(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see list */ + @MustBeClosed + fun list( + datasetId: String, + params: ComparativeListParams = ComparativeListParams.none(), + ): HttpResponseFor<List<ComparativeListResponse>> = + list(datasetId, params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: ComparativeListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<ComparativeListResponse>> + + /** @see list */ + @MustBeClosed + fun list(params: ComparativeListParams): HttpResponseFor<List<ComparativeListResponse>> = + list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + datasetId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<List<ComparativeListResponse>> = + list(datasetId, ComparativeListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete + * /api/v1/datasets/comparative/{comparative_experiment_id}`, but is otherwise the same as + * [ComparativeService.delete]. + */ + @MustBeClosed + fun delete(comparativeExperimentId: String): HttpResponseFor<ComparativeDeleteResponse> = + delete(comparativeExperimentId, ComparativeDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + comparativeExperimentId: String, + params: ComparativeDeleteParams = ComparativeDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ComparativeDeleteResponse> = + delete( + params.toBuilder().comparativeExperimentId(comparativeExperimentId).build(), + requestOptions, + ) + + /** @see delete */ + @MustBeClosed + fun delete( + comparativeExperimentId: String, + params: ComparativeDeleteParams = ComparativeDeleteParams.none(), + ): HttpResponseFor<ComparativeDeleteResponse> = + delete(comparativeExperimentId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: ComparativeDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ComparativeDeleteResponse> + + /** @see delete */ + @MustBeClosed + fun delete(params: ComparativeDeleteParams): HttpResponseFor<ComparativeDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + comparativeExperimentId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<ComparativeDeleteResponse> = + delete(comparativeExperimentId, ComparativeDeleteParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/ComparativeServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/ComparativeServiceImpl.kt new file mode 100644 index 00000000..d58449a0 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/ComparativeServiceImpl.kt @@ -0,0 +1,163 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.datasets + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.datasets.comparative.ComparativeCreateParams +import com.langsmith_api.api.models.api.v1.datasets.comparative.ComparativeCreateResponse +import com.langsmith_api.api.models.api.v1.datasets.comparative.ComparativeDeleteParams +import com.langsmith_api.api.models.api.v1.datasets.comparative.ComparativeDeleteResponse +import com.langsmith_api.api.models.api.v1.datasets.comparative.ComparativeListParams +import com.langsmith_api.api.models.api.v1.datasets.comparative.ComparativeListResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ComparativeServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ComparativeService { + + private val withRawResponse: ComparativeService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ComparativeService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): ComparativeService = + ComparativeServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: ComparativeCreateParams, + requestOptions: RequestOptions, + ): ComparativeCreateResponse = + // post /api/v1/datasets/comparative + withRawResponse().create(params, requestOptions).parse() + + override fun list( + params: ComparativeListParams, + requestOptions: RequestOptions, + ): List<ComparativeListResponse> = + // get /api/v1/datasets/{dataset_id}/comparative + withRawResponse().list(params, requestOptions).parse() + + override fun delete( + params: ComparativeDeleteParams, + requestOptions: RequestOptions, + ): ComparativeDeleteResponse = + // delete /api/v1/datasets/comparative/{comparative_experiment_id} + withRawResponse().delete(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ComparativeService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ComparativeService.WithRawResponse = + ComparativeServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<ComparativeCreateResponse> = + jsonHandler<ComparativeCreateResponse>(clientOptions.jsonMapper) + + override fun create( + params: ComparativeCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<ComparativeCreateResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", "comparative") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler<List<ComparativeListResponse>> = + jsonHandler<List<ComparativeListResponse>>(clientOptions.jsonMapper) + + override fun list( + params: ComparativeListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<ComparativeListResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "comparative") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val deleteHandler: Handler<ComparativeDeleteResponse> = + jsonHandler<ComparativeDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: ComparativeDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<ComparativeDeleteResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("comparativeExperimentId", params.comparativeExperimentId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", "comparative", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/ExperimentService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/ExperimentService.kt new file mode 100644 index 00000000..781e3438 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/ExperimentService.kt @@ -0,0 +1,93 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.datasets + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.datasets.experiments.ExperimentGroupedParams +import com.langsmith_api.api.models.api.v1.datasets.experiments.ExperimentGroupedResponse +import java.util.function.Consumer + +interface ExperimentService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ExperimentService + + /** Stream grouped and aggregated experiments. */ + fun grouped(datasetId: String, params: ExperimentGroupedParams): ExperimentGroupedResponse = + grouped(datasetId, params, RequestOptions.none()) + + /** @see grouped */ + fun grouped( + datasetId: String, + params: ExperimentGroupedParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ExperimentGroupedResponse = + grouped(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see grouped */ + fun grouped(params: ExperimentGroupedParams): ExperimentGroupedResponse = + grouped(params, RequestOptions.none()) + + /** @see grouped */ + fun grouped( + params: ExperimentGroupedParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ExperimentGroupedResponse + + /** A view of [ExperimentService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ExperimentService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/datasets/{dataset_id}/experiments/grouped`, + * but is otherwise the same as [ExperimentService.grouped]. + */ + @MustBeClosed + fun grouped( + datasetId: String, + params: ExperimentGroupedParams, + ): HttpResponseFor<ExperimentGroupedResponse> = + grouped(datasetId, params, RequestOptions.none()) + + /** @see grouped */ + @MustBeClosed + fun grouped( + datasetId: String, + params: ExperimentGroupedParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ExperimentGroupedResponse> = + grouped(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see grouped */ + @MustBeClosed + fun grouped(params: ExperimentGroupedParams): HttpResponseFor<ExperimentGroupedResponse> = + grouped(params, RequestOptions.none()) + + /** @see grouped */ + @MustBeClosed + fun grouped( + params: ExperimentGroupedParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ExperimentGroupedResponse> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/ExperimentServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/ExperimentServiceImpl.kt new file mode 100644 index 00000000..b26b4b60 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/ExperimentServiceImpl.kt @@ -0,0 +1,94 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.datasets + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.datasets.experiments.ExperimentGroupedParams +import com.langsmith_api.api.models.api.v1.datasets.experiments.ExperimentGroupedResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ExperimentServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ExperimentService { + + private val withRawResponse: ExperimentService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ExperimentService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): ExperimentService = + ExperimentServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun grouped( + params: ExperimentGroupedParams, + requestOptions: RequestOptions, + ): ExperimentGroupedResponse = + // post /api/v1/datasets/{dataset_id}/experiments/grouped + withRawResponse().grouped(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ExperimentService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ExperimentService.WithRawResponse = + ExperimentServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val groupedHandler: Handler<ExperimentGroupedResponse> = + jsonHandler<ExperimentGroupedResponse>(clientOptions.jsonMapper) + + override fun grouped( + params: ExperimentGroupedParams, + requestOptions: RequestOptions, + ): HttpResponseFor<ExperimentGroupedResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "datasets", + params._pathParam(0), + "experiments", + "grouped", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { groupedHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/GroupService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/GroupService.kt new file mode 100644 index 00000000..c74abb37 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/GroupService.kt @@ -0,0 +1,89 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.datasets + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.datasets.group.GroupRunsParams +import com.langsmith_api.api.models.api.v1.datasets.group.GroupRunsResponse +import java.util.function.Consumer + +interface GroupService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): GroupService + + /** + * Fetch examples for a dataset, and fetch the runs for each example if they are associated with + * the given session_ids. + */ + fun runs(datasetId: String, params: GroupRunsParams): GroupRunsResponse = + runs(datasetId, params, RequestOptions.none()) + + /** @see runs */ + fun runs( + datasetId: String, + params: GroupRunsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): GroupRunsResponse = runs(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see runs */ + fun runs(params: GroupRunsParams): GroupRunsResponse = runs(params, RequestOptions.none()) + + /** @see runs */ + fun runs( + params: GroupRunsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): GroupRunsResponse + + /** A view of [GroupService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): GroupService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/datasets/{dataset_id}/group/runs`, but is + * otherwise the same as [GroupService.runs]. + */ + @MustBeClosed + fun runs(datasetId: String, params: GroupRunsParams): HttpResponseFor<GroupRunsResponse> = + runs(datasetId, params, RequestOptions.none()) + + /** @see runs */ + @MustBeClosed + fun runs( + datasetId: String, + params: GroupRunsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<GroupRunsResponse> = + runs(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see runs */ + @MustBeClosed + fun runs(params: GroupRunsParams): HttpResponseFor<GroupRunsResponse> = + runs(params, RequestOptions.none()) + + /** @see runs */ + @MustBeClosed + fun runs( + params: GroupRunsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<GroupRunsResponse> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/GroupServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/GroupServiceImpl.kt new file mode 100644 index 00000000..7533d5af --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/GroupServiceImpl.kt @@ -0,0 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.datasets + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.datasets.group.GroupRunsParams +import com.langsmith_api.api.models.api.v1.datasets.group.GroupRunsResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class GroupServiceImpl internal constructor(private val clientOptions: ClientOptions) : + GroupService { + + private val withRawResponse: GroupService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): GroupService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): GroupService = + GroupServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun runs(params: GroupRunsParams, requestOptions: RequestOptions): GroupRunsResponse = + // post /api/v1/datasets/{dataset_id}/group/runs + withRawResponse().runs(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + GroupService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): GroupService.WithRawResponse = + GroupServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val runsHandler: Handler<GroupRunsResponse> = + jsonHandler<GroupRunsResponse>(clientOptions.jsonMapper) + + override fun runs( + params: GroupRunsParams, + requestOptions: RequestOptions, + ): HttpResponseFor<GroupRunsResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "group", "runs") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { runsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/IndexService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/IndexService.kt new file mode 100644 index 00000000..5ca0fb6f --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/IndexService.kt @@ -0,0 +1,340 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.datasets + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.datasets.index.IndexCreateParams +import com.langsmith_api.api.models.api.v1.datasets.index.IndexCreateResponse +import com.langsmith_api.api.models.api.v1.datasets.index.IndexDeleteAllParams +import com.langsmith_api.api.models.api.v1.datasets.index.IndexDeleteAllResponse +import com.langsmith_api.api.models.api.v1.datasets.index.IndexListParams +import com.langsmith_api.api.models.api.v1.datasets.index.IndexListResponse +import com.langsmith_api.api.models.api.v1.datasets.index.IndexSyncParams +import com.langsmith_api.api.models.api.v1.datasets.index.IndexSyncResponse +import java.util.function.Consumer + +interface IndexService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): IndexService + + /** Index a dataset. */ + fun create(datasetId: String): IndexCreateResponse = create(datasetId, IndexCreateParams.none()) + + /** @see create */ + fun create( + datasetId: String, + params: IndexCreateParams = IndexCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): IndexCreateResponse = create(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see create */ + fun create( + datasetId: String, + params: IndexCreateParams = IndexCreateParams.none(), + ): IndexCreateResponse = create(datasetId, params, RequestOptions.none()) + + /** @see create */ + fun create( + params: IndexCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): IndexCreateResponse + + /** @see create */ + fun create(params: IndexCreateParams): IndexCreateResponse = + create(params, RequestOptions.none()) + + /** @see create */ + fun create(datasetId: String, requestOptions: RequestOptions): IndexCreateResponse = + create(datasetId, IndexCreateParams.none(), requestOptions) + + /** Get index info. */ + fun list(datasetId: String): IndexListResponse = list(datasetId, IndexListParams.none()) + + /** @see list */ + fun list( + datasetId: String, + params: IndexListParams = IndexListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): IndexListResponse = list(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see list */ + fun list( + datasetId: String, + params: IndexListParams = IndexListParams.none(), + ): IndexListResponse = list(datasetId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: IndexListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): IndexListResponse + + /** @see list */ + fun list(params: IndexListParams): IndexListResponse = list(params, RequestOptions.none()) + + /** @see list */ + fun list(datasetId: String, requestOptions: RequestOptions): IndexListResponse = + list(datasetId, IndexListParams.none(), requestOptions) + + /** Remove an index for a dataset. */ + fun deleteAll(datasetId: String): IndexDeleteAllResponse = + deleteAll(datasetId, IndexDeleteAllParams.none()) + + /** @see deleteAll */ + fun deleteAll( + datasetId: String, + params: IndexDeleteAllParams = IndexDeleteAllParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): IndexDeleteAllResponse = + deleteAll(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see deleteAll */ + fun deleteAll( + datasetId: String, + params: IndexDeleteAllParams = IndexDeleteAllParams.none(), + ): IndexDeleteAllResponse = deleteAll(datasetId, params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + params: IndexDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): IndexDeleteAllResponse + + /** @see deleteAll */ + fun deleteAll(params: IndexDeleteAllParams): IndexDeleteAllResponse = + deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll(datasetId: String, requestOptions: RequestOptions): IndexDeleteAllResponse = + deleteAll(datasetId, IndexDeleteAllParams.none(), requestOptions) + + /** Sync an index for a dataset. */ + fun sync(datasetId: String): IndexSyncResponse = sync(datasetId, IndexSyncParams.none()) + + /** @see sync */ + fun sync( + datasetId: String, + params: IndexSyncParams = IndexSyncParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): IndexSyncResponse = sync(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see sync */ + fun sync( + datasetId: String, + params: IndexSyncParams = IndexSyncParams.none(), + ): IndexSyncResponse = sync(datasetId, params, RequestOptions.none()) + + /** @see sync */ + fun sync( + params: IndexSyncParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): IndexSyncResponse + + /** @see sync */ + fun sync(params: IndexSyncParams): IndexSyncResponse = sync(params, RequestOptions.none()) + + /** @see sync */ + fun sync(datasetId: String, requestOptions: RequestOptions): IndexSyncResponse = + sync(datasetId, IndexSyncParams.none(), requestOptions) + + /** A view of [IndexService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): IndexService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/datasets/{dataset_id}/index`, but is + * otherwise the same as [IndexService.create]. + */ + @MustBeClosed + fun create(datasetId: String): HttpResponseFor<IndexCreateResponse> = + create(datasetId, IndexCreateParams.none()) + + /** @see create */ + @MustBeClosed + fun create( + datasetId: String, + params: IndexCreateParams = IndexCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<IndexCreateResponse> = + create(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see create */ + @MustBeClosed + fun create( + datasetId: String, + params: IndexCreateParams = IndexCreateParams.none(), + ): HttpResponseFor<IndexCreateResponse> = create(datasetId, params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: IndexCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<IndexCreateResponse> + + /** @see create */ + @MustBeClosed + fun create(params: IndexCreateParams): HttpResponseFor<IndexCreateResponse> = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + datasetId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<IndexCreateResponse> = + create(datasetId, IndexCreateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/datasets/{dataset_id}/index`, but is + * otherwise the same as [IndexService.list]. + */ + @MustBeClosed + fun list(datasetId: String): HttpResponseFor<IndexListResponse> = + list(datasetId, IndexListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + datasetId: String, + params: IndexListParams = IndexListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<IndexListResponse> = + list(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see list */ + @MustBeClosed + fun list( + datasetId: String, + params: IndexListParams = IndexListParams.none(), + ): HttpResponseFor<IndexListResponse> = list(datasetId, params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: IndexListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<IndexListResponse> + + /** @see list */ + @MustBeClosed + fun list(params: IndexListParams): HttpResponseFor<IndexListResponse> = + list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + datasetId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<IndexListResponse> = + list(datasetId, IndexListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/datasets/{dataset_id}/index`, but is + * otherwise the same as [IndexService.deleteAll]. + */ + @MustBeClosed + fun deleteAll(datasetId: String): HttpResponseFor<IndexDeleteAllResponse> = + deleteAll(datasetId, IndexDeleteAllParams.none()) + + /** @see deleteAll */ + @MustBeClosed + fun deleteAll( + datasetId: String, + params: IndexDeleteAllParams = IndexDeleteAllParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<IndexDeleteAllResponse> = + deleteAll(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see deleteAll */ + @MustBeClosed + fun deleteAll( + datasetId: String, + params: IndexDeleteAllParams = IndexDeleteAllParams.none(), + ): HttpResponseFor<IndexDeleteAllResponse> = + deleteAll(datasetId, params, RequestOptions.none()) + + /** @see deleteAll */ + @MustBeClosed + fun deleteAll( + params: IndexDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<IndexDeleteAllResponse> + + /** @see deleteAll */ + @MustBeClosed + fun deleteAll(params: IndexDeleteAllParams): HttpResponseFor<IndexDeleteAllResponse> = + deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + @MustBeClosed + fun deleteAll( + datasetId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<IndexDeleteAllResponse> = + deleteAll(datasetId, IndexDeleteAllParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/datasets/{dataset_id}/index/sync`, but is + * otherwise the same as [IndexService.sync]. + */ + @MustBeClosed + fun sync(datasetId: String): HttpResponseFor<IndexSyncResponse> = + sync(datasetId, IndexSyncParams.none()) + + /** @see sync */ + @MustBeClosed + fun sync( + datasetId: String, + params: IndexSyncParams = IndexSyncParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<IndexSyncResponse> = + sync(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see sync */ + @MustBeClosed + fun sync( + datasetId: String, + params: IndexSyncParams = IndexSyncParams.none(), + ): HttpResponseFor<IndexSyncResponse> = sync(datasetId, params, RequestOptions.none()) + + /** @see sync */ + @MustBeClosed + fun sync( + params: IndexSyncParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<IndexSyncResponse> + + /** @see sync */ + @MustBeClosed + fun sync(params: IndexSyncParams): HttpResponseFor<IndexSyncResponse> = + sync(params, RequestOptions.none()) + + /** @see sync */ + @MustBeClosed + fun sync( + datasetId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<IndexSyncResponse> = + sync(datasetId, IndexSyncParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/IndexServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/IndexServiceImpl.kt new file mode 100644 index 00000000..f5daa116 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/IndexServiceImpl.kt @@ -0,0 +1,200 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.datasets + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.datasets.index.IndexCreateParams +import com.langsmith_api.api.models.api.v1.datasets.index.IndexCreateResponse +import com.langsmith_api.api.models.api.v1.datasets.index.IndexDeleteAllParams +import com.langsmith_api.api.models.api.v1.datasets.index.IndexDeleteAllResponse +import com.langsmith_api.api.models.api.v1.datasets.index.IndexListParams +import com.langsmith_api.api.models.api.v1.datasets.index.IndexListResponse +import com.langsmith_api.api.models.api.v1.datasets.index.IndexSyncParams +import com.langsmith_api.api.models.api.v1.datasets.index.IndexSyncResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class IndexServiceImpl internal constructor(private val clientOptions: ClientOptions) : + IndexService { + + private val withRawResponse: IndexService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): IndexService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): IndexService = + IndexServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: IndexCreateParams, + requestOptions: RequestOptions, + ): IndexCreateResponse = + // post /api/v1/datasets/{dataset_id}/index + withRawResponse().create(params, requestOptions).parse() + + override fun list(params: IndexListParams, requestOptions: RequestOptions): IndexListResponse = + // get /api/v1/datasets/{dataset_id}/index + withRawResponse().list(params, requestOptions).parse() + + override fun deleteAll( + params: IndexDeleteAllParams, + requestOptions: RequestOptions, + ): IndexDeleteAllResponse = + // delete /api/v1/datasets/{dataset_id}/index + withRawResponse().deleteAll(params, requestOptions).parse() + + override fun sync(params: IndexSyncParams, requestOptions: RequestOptions): IndexSyncResponse = + // post /api/v1/datasets/{dataset_id}/index/sync + withRawResponse().sync(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + IndexService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): IndexService.WithRawResponse = + IndexServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<IndexCreateResponse> = + jsonHandler<IndexCreateResponse>(clientOptions.jsonMapper) + + override fun create( + params: IndexCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<IndexCreateResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "index") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler<IndexListResponse> = + jsonHandler<IndexListResponse>(clientOptions.jsonMapper) + + override fun list( + params: IndexListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<IndexListResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "index") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val deleteAllHandler: Handler<IndexDeleteAllResponse> = + jsonHandler<IndexDeleteAllResponse>(clientOptions.jsonMapper) + + override fun deleteAll( + params: IndexDeleteAllParams, + requestOptions: RequestOptions, + ): HttpResponseFor<IndexDeleteAllResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "index") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteAllHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val syncHandler: Handler<IndexSyncResponse> = + jsonHandler<IndexSyncResponse>(clientOptions.jsonMapper) + + override fun sync( + params: IndexSyncParams, + requestOptions: RequestOptions, + ): HttpResponseFor<IndexSyncResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "index", "sync") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { syncHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/PlaygroundExperimentService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/PlaygroundExperimentService.kt new file mode 100644 index 00000000..d31a209c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/PlaygroundExperimentService.kt @@ -0,0 +1,97 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.datasets + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.datasets.playgroundexperiment.PlaygroundExperimentBatchParams +import com.langsmith_api.api.models.api.v1.datasets.playgroundexperiment.PlaygroundExperimentBatchResponse +import com.langsmith_api.api.models.api.v1.datasets.playgroundexperiment.PlaygroundExperimentStreamParams +import com.langsmith_api.api.models.api.v1.datasets.playgroundexperiment.PlaygroundExperimentStreamResponse +import java.util.function.Consumer + +interface PlaygroundExperimentService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): PlaygroundExperimentService + + /** Dataset Handler */ + fun batch(params: PlaygroundExperimentBatchParams): PlaygroundExperimentBatchResponse = + batch(params, RequestOptions.none()) + + /** @see batch */ + fun batch( + params: PlaygroundExperimentBatchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): PlaygroundExperimentBatchResponse + + /** Stream Dataset Handler */ + fun stream(params: PlaygroundExperimentStreamParams): PlaygroundExperimentStreamResponse = + stream(params, RequestOptions.none()) + + /** @see stream */ + fun stream( + params: PlaygroundExperimentStreamParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): PlaygroundExperimentStreamResponse + + /** + * A view of [PlaygroundExperimentService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PlaygroundExperimentService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/datasets/playground_experiment/batch`, but + * is otherwise the same as [PlaygroundExperimentService.batch]. + */ + @MustBeClosed + fun batch( + params: PlaygroundExperimentBatchParams + ): HttpResponseFor<PlaygroundExperimentBatchResponse> = batch(params, RequestOptions.none()) + + /** @see batch */ + @MustBeClosed + fun batch( + params: PlaygroundExperimentBatchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<PlaygroundExperimentBatchResponse> + + /** + * Returns a raw HTTP response for `post /api/v1/datasets/playground_experiment/stream`, but + * is otherwise the same as [PlaygroundExperimentService.stream]. + */ + @MustBeClosed + fun stream( + params: PlaygroundExperimentStreamParams + ): HttpResponseFor<PlaygroundExperimentStreamResponse> = + stream(params, RequestOptions.none()) + + /** @see stream */ + @MustBeClosed + fun stream( + params: PlaygroundExperimentStreamParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<PlaygroundExperimentStreamResponse> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/PlaygroundExperimentServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/PlaygroundExperimentServiceImpl.kt new file mode 100644 index 00000000..9c6a1e4e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/PlaygroundExperimentServiceImpl.kt @@ -0,0 +1,121 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.datasets + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.datasets.playgroundexperiment.PlaygroundExperimentBatchParams +import com.langsmith_api.api.models.api.v1.datasets.playgroundexperiment.PlaygroundExperimentBatchResponse +import com.langsmith_api.api.models.api.v1.datasets.playgroundexperiment.PlaygroundExperimentStreamParams +import com.langsmith_api.api.models.api.v1.datasets.playgroundexperiment.PlaygroundExperimentStreamResponse +import java.util.function.Consumer + +class PlaygroundExperimentServiceImpl +internal constructor(private val clientOptions: ClientOptions) : PlaygroundExperimentService { + + private val withRawResponse: PlaygroundExperimentService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): PlaygroundExperimentService.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PlaygroundExperimentService = + PlaygroundExperimentServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun batch( + params: PlaygroundExperimentBatchParams, + requestOptions: RequestOptions, + ): PlaygroundExperimentBatchResponse = + // post /api/v1/datasets/playground_experiment/batch + withRawResponse().batch(params, requestOptions).parse() + + override fun stream( + params: PlaygroundExperimentStreamParams, + requestOptions: RequestOptions, + ): PlaygroundExperimentStreamResponse = + // post /api/v1/datasets/playground_experiment/stream + withRawResponse().stream(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + PlaygroundExperimentService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PlaygroundExperimentService.WithRawResponse = + PlaygroundExperimentServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val batchHandler: Handler<PlaygroundExperimentBatchResponse> = + jsonHandler<PlaygroundExperimentBatchResponse>(clientOptions.jsonMapper) + + override fun batch( + params: PlaygroundExperimentBatchParams, + requestOptions: RequestOptions, + ): HttpResponseFor<PlaygroundExperimentBatchResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", "playground_experiment", "batch") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { batchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val streamHandler: Handler<PlaygroundExperimentStreamResponse> = + jsonHandler<PlaygroundExperimentStreamResponse>(clientOptions.jsonMapper) + + override fun stream( + params: PlaygroundExperimentStreamParams, + requestOptions: RequestOptions, + ): HttpResponseFor<PlaygroundExperimentStreamResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", "playground_experiment", "stream") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { streamHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/RunService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/RunService.kt new file mode 100644 index 00000000..a5fabd53 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/RunService.kt @@ -0,0 +1,151 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.datasets + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.datasets.runs.RunCreateParams +import com.langsmith_api.api.models.api.v1.datasets.runs.RunCreateResponse +import com.langsmith_api.api.models.api.v1.datasets.runs.RunDeltaParams +import com.langsmith_api.api.models.api.v1.datasets.runs.SessionFeedbackDelta +import java.util.Optional +import java.util.function.Consumer + +interface RunService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunService + + /** + * Fetch examples for a dataset, and fetch the runs for each example if they are associated with + * the given session_ids. + */ + fun create(datasetId: String, params: RunCreateParams): Optional<RunCreateResponse> = + create(datasetId, params, RequestOptions.none()) + + /** @see create */ + fun create( + datasetId: String, + params: RunCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Optional<RunCreateResponse> = + create(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see create */ + fun create(params: RunCreateParams): Optional<RunCreateResponse> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: RunCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Optional<RunCreateResponse> + + /** + * Fetch the number of regressions/improvements for each example in a dataset, between + * sessions[0] and sessions[1]. + */ + fun delta(datasetId: String, params: RunDeltaParams): SessionFeedbackDelta = + delta(datasetId, params, RequestOptions.none()) + + /** @see delta */ + fun delta( + datasetId: String, + params: RunDeltaParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SessionFeedbackDelta = delta(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see delta */ + fun delta(params: RunDeltaParams): SessionFeedbackDelta = delta(params, RequestOptions.none()) + + /** @see delta */ + fun delta( + params: RunDeltaParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SessionFeedbackDelta + + /** A view of [RunService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/datasets/{dataset_id}/runs`, but is + * otherwise the same as [RunService.create]. + */ + @MustBeClosed + fun create( + datasetId: String, + params: RunCreateParams, + ): HttpResponseFor<Optional<RunCreateResponse>> = + create(datasetId, params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + datasetId: String, + params: RunCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<Optional<RunCreateResponse>> = + create(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(params: RunCreateParams): HttpResponseFor<Optional<RunCreateResponse>> = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: RunCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<Optional<RunCreateResponse>> + + /** + * Returns a raw HTTP response for `post /api/v1/datasets/{dataset_id}/runs/delta`, but is + * otherwise the same as [RunService.delta]. + */ + @MustBeClosed + fun delta( + datasetId: String, + params: RunDeltaParams, + ): HttpResponseFor<SessionFeedbackDelta> = delta(datasetId, params, RequestOptions.none()) + + /** @see delta */ + @MustBeClosed + fun delta( + datasetId: String, + params: RunDeltaParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<SessionFeedbackDelta> = + delta(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see delta */ + @MustBeClosed + fun delta(params: RunDeltaParams): HttpResponseFor<SessionFeedbackDelta> = + delta(params, RequestOptions.none()) + + /** @see delta */ + @MustBeClosed + fun delta( + params: RunDeltaParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<SessionFeedbackDelta> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/RunServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/RunServiceImpl.kt new file mode 100644 index 00000000..3078586d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/RunServiceImpl.kt @@ -0,0 +1,127 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.datasets + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.datasets.runs.RunCreateParams +import com.langsmith_api.api.models.api.v1.datasets.runs.RunCreateResponse +import com.langsmith_api.api.models.api.v1.datasets.runs.RunDeltaParams +import com.langsmith_api.api.models.api.v1.datasets.runs.SessionFeedbackDelta +import java.util.Optional +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class RunServiceImpl internal constructor(private val clientOptions: ClientOptions) : RunService { + + private val withRawResponse: RunService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): RunService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunService = + RunServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: RunCreateParams, + requestOptions: RequestOptions, + ): Optional<RunCreateResponse> = + // post /api/v1/datasets/{dataset_id}/runs + withRawResponse().create(params, requestOptions).parse() + + override fun delta( + params: RunDeltaParams, + requestOptions: RequestOptions, + ): SessionFeedbackDelta = + // post /api/v1/datasets/{dataset_id}/runs/delta + withRawResponse().delta(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RunService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): RunService.WithRawResponse = + RunServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<Optional<RunCreateResponse>> = + jsonHandler<Optional<RunCreateResponse>>(clientOptions.jsonMapper) + + override fun create( + params: RunCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<Optional<RunCreateResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "runs") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.ifPresent { it.validate() } + } + } + } + } + + private val deltaHandler: Handler<SessionFeedbackDelta> = + jsonHandler<SessionFeedbackDelta>(clientOptions.jsonMapper) + + override fun delta( + params: RunDeltaParams, + requestOptions: RequestOptions, + ): HttpResponseFor<SessionFeedbackDelta> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "runs", "delta") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deltaHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/ShareService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/ShareService.kt new file mode 100644 index 00000000..2f09df13 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/ShareService.kt @@ -0,0 +1,269 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.datasets + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.datasets.share.DatasetShareSchema +import com.langsmith_api.api.models.api.v1.datasets.share.ShareCreateParams +import com.langsmith_api.api.models.api.v1.datasets.share.ShareDeleteAllParams +import com.langsmith_api.api.models.api.v1.datasets.share.ShareDeleteAllResponse +import com.langsmith_api.api.models.api.v1.datasets.share.ShareListParams +import java.util.Optional +import java.util.function.Consumer + +interface ShareService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ShareService + + /** Share a dataset. */ + fun create(datasetId: String): DatasetShareSchema = create(datasetId, ShareCreateParams.none()) + + /** @see create */ + fun create( + datasetId: String, + params: ShareCreateParams = ShareCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): DatasetShareSchema = create(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see create */ + fun create( + datasetId: String, + params: ShareCreateParams = ShareCreateParams.none(), + ): DatasetShareSchema = create(datasetId, params, RequestOptions.none()) + + /** @see create */ + fun create( + params: ShareCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): DatasetShareSchema + + /** @see create */ + fun create(params: ShareCreateParams): DatasetShareSchema = + create(params, RequestOptions.none()) + + /** @see create */ + fun create(datasetId: String, requestOptions: RequestOptions): DatasetShareSchema = + create(datasetId, ShareCreateParams.none(), requestOptions) + + /** Get the state of sharing a dataset */ + fun list(datasetId: String): Optional<DatasetShareSchema> = + list(datasetId, ShareListParams.none()) + + /** @see list */ + fun list( + datasetId: String, + params: ShareListParams = ShareListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Optional<DatasetShareSchema> = + list(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see list */ + fun list( + datasetId: String, + params: ShareListParams = ShareListParams.none(), + ): Optional<DatasetShareSchema> = list(datasetId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: ShareListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Optional<DatasetShareSchema> + + /** @see list */ + fun list(params: ShareListParams): Optional<DatasetShareSchema> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(datasetId: String, requestOptions: RequestOptions): Optional<DatasetShareSchema> = + list(datasetId, ShareListParams.none(), requestOptions) + + /** Unshare a dataset. */ + fun deleteAll(datasetId: String): ShareDeleteAllResponse = + deleteAll(datasetId, ShareDeleteAllParams.none()) + + /** @see deleteAll */ + fun deleteAll( + datasetId: String, + params: ShareDeleteAllParams = ShareDeleteAllParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ShareDeleteAllResponse = + deleteAll(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see deleteAll */ + fun deleteAll( + datasetId: String, + params: ShareDeleteAllParams = ShareDeleteAllParams.none(), + ): ShareDeleteAllResponse = deleteAll(datasetId, params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + params: ShareDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ShareDeleteAllResponse + + /** @see deleteAll */ + fun deleteAll(params: ShareDeleteAllParams): ShareDeleteAllResponse = + deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll(datasetId: String, requestOptions: RequestOptions): ShareDeleteAllResponse = + deleteAll(datasetId, ShareDeleteAllParams.none(), requestOptions) + + /** A view of [ShareService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ShareService.WithRawResponse + + /** + * Returns a raw HTTP response for `put /api/v1/datasets/{dataset_id}/share`, but is + * otherwise the same as [ShareService.create]. + */ + @MustBeClosed + fun create(datasetId: String): HttpResponseFor<DatasetShareSchema> = + create(datasetId, ShareCreateParams.none()) + + /** @see create */ + @MustBeClosed + fun create( + datasetId: String, + params: ShareCreateParams = ShareCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<DatasetShareSchema> = + create(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see create */ + @MustBeClosed + fun create( + datasetId: String, + params: ShareCreateParams = ShareCreateParams.none(), + ): HttpResponseFor<DatasetShareSchema> = create(datasetId, params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: ShareCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<DatasetShareSchema> + + /** @see create */ + @MustBeClosed + fun create(params: ShareCreateParams): HttpResponseFor<DatasetShareSchema> = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + datasetId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<DatasetShareSchema> = + create(datasetId, ShareCreateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/datasets/{dataset_id}/share`, but is + * otherwise the same as [ShareService.list]. + */ + @MustBeClosed + fun list(datasetId: String): HttpResponseFor<Optional<DatasetShareSchema>> = + list(datasetId, ShareListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + datasetId: String, + params: ShareListParams = ShareListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<Optional<DatasetShareSchema>> = + list(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see list */ + @MustBeClosed + fun list( + datasetId: String, + params: ShareListParams = ShareListParams.none(), + ): HttpResponseFor<Optional<DatasetShareSchema>> = + list(datasetId, params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: ShareListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<Optional<DatasetShareSchema>> + + /** @see list */ + @MustBeClosed + fun list(params: ShareListParams): HttpResponseFor<Optional<DatasetShareSchema>> = + list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + datasetId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<Optional<DatasetShareSchema>> = + list(datasetId, ShareListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/datasets/{dataset_id}/share`, but is + * otherwise the same as [ShareService.deleteAll]. + */ + @MustBeClosed + fun deleteAll(datasetId: String): HttpResponseFor<ShareDeleteAllResponse> = + deleteAll(datasetId, ShareDeleteAllParams.none()) + + /** @see deleteAll */ + @MustBeClosed + fun deleteAll( + datasetId: String, + params: ShareDeleteAllParams = ShareDeleteAllParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ShareDeleteAllResponse> = + deleteAll(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see deleteAll */ + @MustBeClosed + fun deleteAll( + datasetId: String, + params: ShareDeleteAllParams = ShareDeleteAllParams.none(), + ): HttpResponseFor<ShareDeleteAllResponse> = + deleteAll(datasetId, params, RequestOptions.none()) + + /** @see deleteAll */ + @MustBeClosed + fun deleteAll( + params: ShareDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ShareDeleteAllResponse> + + /** @see deleteAll */ + @MustBeClosed + fun deleteAll(params: ShareDeleteAllParams): HttpResponseFor<ShareDeleteAllResponse> = + deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + @MustBeClosed + fun deleteAll( + datasetId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<ShareDeleteAllResponse> = + deleteAll(datasetId, ShareDeleteAllParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/ShareServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/ShareServiceImpl.kt new file mode 100644 index 00000000..88400e2b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/ShareServiceImpl.kt @@ -0,0 +1,166 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.datasets + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.datasets.share.DatasetShareSchema +import com.langsmith_api.api.models.api.v1.datasets.share.ShareCreateParams +import com.langsmith_api.api.models.api.v1.datasets.share.ShareDeleteAllParams +import com.langsmith_api.api.models.api.v1.datasets.share.ShareDeleteAllResponse +import com.langsmith_api.api.models.api.v1.datasets.share.ShareListParams +import java.util.Optional +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ShareServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ShareService { + + private val withRawResponse: ShareService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ShareService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): ShareService = + ShareServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: ShareCreateParams, + requestOptions: RequestOptions, + ): DatasetShareSchema = + // put /api/v1/datasets/{dataset_id}/share + withRawResponse().create(params, requestOptions).parse() + + override fun list( + params: ShareListParams, + requestOptions: RequestOptions, + ): Optional<DatasetShareSchema> = + // get /api/v1/datasets/{dataset_id}/share + withRawResponse().list(params, requestOptions).parse() + + override fun deleteAll( + params: ShareDeleteAllParams, + requestOptions: RequestOptions, + ): ShareDeleteAllResponse = + // delete /api/v1/datasets/{dataset_id}/share + withRawResponse().deleteAll(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ShareService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ShareService.WithRawResponse = + ShareServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<DatasetShareSchema> = + jsonHandler<DatasetShareSchema>(clientOptions.jsonMapper) + + override fun create( + params: ShareCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<DatasetShareSchema> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "share") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler<Optional<DatasetShareSchema>> = + jsonHandler<Optional<DatasetShareSchema>>(clientOptions.jsonMapper) + + override fun list( + params: ShareListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<Optional<DatasetShareSchema>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "share") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.ifPresent { it.validate() } + } + } + } + } + + private val deleteAllHandler: Handler<ShareDeleteAllResponse> = + jsonHandler<ShareDeleteAllResponse>(clientOptions.jsonMapper) + + override fun deleteAll( + params: ShareDeleteAllParams, + requestOptions: RequestOptions, + ): HttpResponseFor<ShareDeleteAllResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "share") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteAllHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/SplitService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/SplitService.kt new file mode 100644 index 00000000..bd457fee --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/SplitService.kt @@ -0,0 +1,154 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.datasets + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.datasets.splits.SplitCreateParams +import com.langsmith_api.api.models.api.v1.datasets.splits.SplitListParams +import java.util.function.Consumer + +interface SplitService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): SplitService + + /** Update Dataset Splits */ + fun create(datasetId: String, params: SplitCreateParams): List<String> = + create(datasetId, params, RequestOptions.none()) + + /** @see create */ + fun create( + datasetId: String, + params: SplitCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List<String> = create(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see create */ + fun create(params: SplitCreateParams): List<String> = create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: SplitCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List<String> + + /** Get Dataset Splits */ + fun list(datasetId: String): List<String> = list(datasetId, SplitListParams.none()) + + /** @see list */ + fun list( + datasetId: String, + params: SplitListParams = SplitListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<String> = list(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see list */ + fun list(datasetId: String, params: SplitListParams = SplitListParams.none()): List<String> = + list(datasetId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: SplitListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List<String> + + /** @see list */ + fun list(params: SplitListParams): List<String> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(datasetId: String, requestOptions: RequestOptions): List<String> = + list(datasetId, SplitListParams.none(), requestOptions) + + /** A view of [SplitService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): SplitService.WithRawResponse + + /** + * Returns a raw HTTP response for `put /api/v1/datasets/{dataset_id}/splits`, but is + * otherwise the same as [SplitService.create]. + */ + @MustBeClosed + fun create(datasetId: String, params: SplitCreateParams): HttpResponseFor<List<String>> = + create(datasetId, params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + datasetId: String, + params: SplitCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<String>> = + create(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(params: SplitCreateParams): HttpResponseFor<List<String>> = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: SplitCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<String>> + + /** + * Returns a raw HTTP response for `get /api/v1/datasets/{dataset_id}/splits`, but is + * otherwise the same as [SplitService.list]. + */ + @MustBeClosed + fun list(datasetId: String): HttpResponseFor<List<String>> = + list(datasetId, SplitListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + datasetId: String, + params: SplitListParams = SplitListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<String>> = + list(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see list */ + @MustBeClosed + fun list( + datasetId: String, + params: SplitListParams = SplitListParams.none(), + ): HttpResponseFor<List<String>> = list(datasetId, params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: SplitListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<String>> + + /** @see list */ + @MustBeClosed + fun list(params: SplitListParams): HttpResponseFor<List<String>> = + list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(datasetId: String, requestOptions: RequestOptions): HttpResponseFor<List<String>> = + list(datasetId, SplitListParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/SplitServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/SplitServiceImpl.kt new file mode 100644 index 00000000..1959e7d3 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/SplitServiceImpl.kt @@ -0,0 +1,106 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.datasets + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.datasets.splits.SplitCreateParams +import com.langsmith_api.api.models.api.v1.datasets.splits.SplitListParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class SplitServiceImpl internal constructor(private val clientOptions: ClientOptions) : + SplitService { + + private val withRawResponse: SplitService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): SplitService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): SplitService = + SplitServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create(params: SplitCreateParams, requestOptions: RequestOptions): List<String> = + // put /api/v1/datasets/{dataset_id}/splits + withRawResponse().create(params, requestOptions).parse() + + override fun list(params: SplitListParams, requestOptions: RequestOptions): List<String> = + // get /api/v1/datasets/{dataset_id}/splits + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SplitService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): SplitService.WithRawResponse = + SplitServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<List<String>> = + jsonHandler<List<String>>(clientOptions.jsonMapper) + + override fun create( + params: SplitCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<String>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "splits") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { createHandler.handle(it) } + } + } + + private val listHandler: Handler<List<String>> = + jsonHandler<List<String>>(clientOptions.jsonMapper) + + override fun list( + params: SplitListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<String>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "splits") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { listHandler.handle(it) } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/VersionService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/VersionService.kt new file mode 100644 index 00000000..2128a038 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/VersionService.kt @@ -0,0 +1,170 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.datasets + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.datasets.DatasetVersion +import com.langsmith_api.api.models.api.v1.datasets.versions.VersionListParams +import com.langsmith_api.api.models.api.v1.datasets.versions.VersionRetrieveDiffParams +import com.langsmith_api.api.models.api.v1.datasets.versions.VersionRetrieveDiffResponse +import java.util.function.Consumer + +interface VersionService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): VersionService + + /** Get dataset versions. */ + fun list(datasetId: String): List<DatasetVersion> = list(datasetId, VersionListParams.none()) + + /** @see list */ + fun list( + datasetId: String, + params: VersionListParams = VersionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<DatasetVersion> = list(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see list */ + fun list( + datasetId: String, + params: VersionListParams = VersionListParams.none(), + ): List<DatasetVersion> = list(datasetId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: VersionListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List<DatasetVersion> + + /** @see list */ + fun list(params: VersionListParams): List<DatasetVersion> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(datasetId: String, requestOptions: RequestOptions): List<DatasetVersion> = + list(datasetId, VersionListParams.none(), requestOptions) + + /** Get diff between two dataset versions. */ + fun retrieveDiff( + datasetId: String, + params: VersionRetrieveDiffParams, + ): VersionRetrieveDiffResponse = retrieveDiff(datasetId, params, RequestOptions.none()) + + /** @see retrieveDiff */ + fun retrieveDiff( + datasetId: String, + params: VersionRetrieveDiffParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): VersionRetrieveDiffResponse = + retrieveDiff(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see retrieveDiff */ + fun retrieveDiff(params: VersionRetrieveDiffParams): VersionRetrieveDiffResponse = + retrieveDiff(params, RequestOptions.none()) + + /** @see retrieveDiff */ + fun retrieveDiff( + params: VersionRetrieveDiffParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): VersionRetrieveDiffResponse + + /** A view of [VersionService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): VersionService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/datasets/{dataset_id}/versions`, but is + * otherwise the same as [VersionService.list]. + */ + @MustBeClosed + fun list(datasetId: String): HttpResponseFor<List<DatasetVersion>> = + list(datasetId, VersionListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + datasetId: String, + params: VersionListParams = VersionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<DatasetVersion>> = + list(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see list */ + @MustBeClosed + fun list( + datasetId: String, + params: VersionListParams = VersionListParams.none(), + ): HttpResponseFor<List<DatasetVersion>> = list(datasetId, params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: VersionListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<DatasetVersion>> + + /** @see list */ + @MustBeClosed + fun list(params: VersionListParams): HttpResponseFor<List<DatasetVersion>> = + list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + datasetId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<List<DatasetVersion>> = + list(datasetId, VersionListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/datasets/{dataset_id}/versions/diff`, but is + * otherwise the same as [VersionService.retrieveDiff]. + */ + @MustBeClosed + fun retrieveDiff( + datasetId: String, + params: VersionRetrieveDiffParams, + ): HttpResponseFor<VersionRetrieveDiffResponse> = + retrieveDiff(datasetId, params, RequestOptions.none()) + + /** @see retrieveDiff */ + @MustBeClosed + fun retrieveDiff( + datasetId: String, + params: VersionRetrieveDiffParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<VersionRetrieveDiffResponse> = + retrieveDiff(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see retrieveDiff */ + @MustBeClosed + fun retrieveDiff( + params: VersionRetrieveDiffParams + ): HttpResponseFor<VersionRetrieveDiffResponse> = + retrieveDiff(params, RequestOptions.none()) + + /** @see retrieveDiff */ + @MustBeClosed + fun retrieveDiff( + params: VersionRetrieveDiffParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<VersionRetrieveDiffResponse> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/VersionServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/VersionServiceImpl.kt new file mode 100644 index 00000000..844681a2 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/VersionServiceImpl.kt @@ -0,0 +1,131 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.datasets + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.datasets.DatasetVersion +import com.langsmith_api.api.models.api.v1.datasets.versions.VersionListParams +import com.langsmith_api.api.models.api.v1.datasets.versions.VersionRetrieveDiffParams +import com.langsmith_api.api.models.api.v1.datasets.versions.VersionRetrieveDiffResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class VersionServiceImpl internal constructor(private val clientOptions: ClientOptions) : + VersionService { + + private val withRawResponse: VersionService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): VersionService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): VersionService = + VersionServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: VersionListParams, + requestOptions: RequestOptions, + ): List<DatasetVersion> = + // get /api/v1/datasets/{dataset_id}/versions + withRawResponse().list(params, requestOptions).parse() + + override fun retrieveDiff( + params: VersionRetrieveDiffParams, + requestOptions: RequestOptions, + ): VersionRetrieveDiffResponse = + // get /api/v1/datasets/{dataset_id}/versions/diff + withRawResponse().retrieveDiff(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + VersionService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): VersionService.WithRawResponse = + VersionServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler<List<DatasetVersion>> = + jsonHandler<List<DatasetVersion>>(clientOptions.jsonMapper) + + override fun list( + params: VersionListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<DatasetVersion>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "datasets", params._pathParam(0), "versions") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val retrieveDiffHandler: Handler<VersionRetrieveDiffResponse> = + jsonHandler<VersionRetrieveDiffResponse>(clientOptions.jsonMapper) + + override fun retrieveDiff( + params: VersionRetrieveDiffParams, + requestOptions: RequestOptions, + ): HttpResponseFor<VersionRetrieveDiffResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("datasetId", params.datasetId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "datasets", + params._pathParam(0), + "versions", + "diff", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveDiffHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/examples/BulkService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/examples/BulkService.kt new file mode 100644 index 00000000..2642a11b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/examples/BulkService.kt @@ -0,0 +1,109 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.examples + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.examples.bulk.BulkCreateParams +import com.langsmith_api.api.models.api.v1.examples.bulk.BulkCreateResponse +import com.langsmith_api.api.models.api.v1.examples.bulk.BulkPatchAllParams +import com.langsmith_api.api.models.api.v1.examples.bulk.BulkPatchAllResponse +import java.util.function.Consumer + +interface BulkService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): BulkService + + /** Create a new example. */ + fun create(): BulkCreateResponse = create(BulkCreateParams.none()) + + /** @see create */ + fun create( + params: BulkCreateParams = BulkCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): BulkCreateResponse + + /** @see create */ + fun create(params: BulkCreateParams = BulkCreateParams.none()): BulkCreateResponse = + create(params, RequestOptions.none()) + + /** @see create */ + fun create(requestOptions: RequestOptions): BulkCreateResponse = + create(BulkCreateParams.none(), requestOptions) + + /** + * Legacy update examples in bulk. For update involving attachments, use PATCH + * /v1/platform/datasets/{dataset_id}/examples instead. + */ + fun patchAll(params: BulkPatchAllParams): BulkPatchAllResponse = + patchAll(params, RequestOptions.none()) + + /** @see patchAll */ + fun patchAll( + params: BulkPatchAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): BulkPatchAllResponse + + /** A view of [BulkService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): BulkService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/examples/bulk`, but is otherwise the same + * as [BulkService.create]. + */ + @MustBeClosed + fun create(): HttpResponseFor<BulkCreateResponse> = create(BulkCreateParams.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: BulkCreateParams = BulkCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<BulkCreateResponse> + + /** @see create */ + @MustBeClosed + fun create( + params: BulkCreateParams = BulkCreateParams.none() + ): HttpResponseFor<BulkCreateResponse> = create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create(requestOptions: RequestOptions): HttpResponseFor<BulkCreateResponse> = + create(BulkCreateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `patch /api/v1/examples/bulk`, but is otherwise the same + * as [BulkService.patchAll]. + */ + @MustBeClosed + fun patchAll(params: BulkPatchAllParams): HttpResponseFor<BulkPatchAllResponse> = + patchAll(params, RequestOptions.none()) + + /** @see patchAll */ + @MustBeClosed + fun patchAll( + params: BulkPatchAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<BulkPatchAllResponse> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/examples/BulkServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/examples/BulkServiceImpl.kt new file mode 100644 index 00000000..edff3767 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/examples/BulkServiceImpl.kt @@ -0,0 +1,118 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.examples + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.examples.bulk.BulkCreateParams +import com.langsmith_api.api.models.api.v1.examples.bulk.BulkCreateResponse +import com.langsmith_api.api.models.api.v1.examples.bulk.BulkPatchAllParams +import com.langsmith_api.api.models.api.v1.examples.bulk.BulkPatchAllResponse +import java.util.function.Consumer + +class BulkServiceImpl internal constructor(private val clientOptions: ClientOptions) : BulkService { + + private val withRawResponse: BulkService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): BulkService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): BulkService = + BulkServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: BulkCreateParams, + requestOptions: RequestOptions, + ): BulkCreateResponse = + // post /api/v1/examples/bulk + withRawResponse().create(params, requestOptions).parse() + + override fun patchAll( + params: BulkPatchAllParams, + requestOptions: RequestOptions, + ): BulkPatchAllResponse = + // patch /api/v1/examples/bulk + withRawResponse().patchAll(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BulkService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): BulkService.WithRawResponse = + BulkServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<BulkCreateResponse> = + jsonHandler<BulkCreateResponse>(clientOptions.jsonMapper) + + override fun create( + params: BulkCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<BulkCreateResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "examples", "bulk") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val patchAllHandler: Handler<BulkPatchAllResponse> = + jsonHandler<BulkPatchAllResponse>(clientOptions.jsonMapper) + + override fun patchAll( + params: BulkPatchAllParams, + requestOptions: RequestOptions, + ): HttpResponseFor<BulkPatchAllResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "examples", "bulk") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { patchAllHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/examples/ValidateService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/examples/ValidateService.kt new file mode 100644 index 00000000..469c3a22 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/examples/ValidateService.kt @@ -0,0 +1,124 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.examples + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.examples.validate.ExampleValidationResult +import com.langsmith_api.api.models.api.v1.examples.validate.ValidateBulkParams +import com.langsmith_api.api.models.api.v1.examples.validate.ValidateCreateParams +import java.util.function.Consumer + +interface ValidateService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ValidateService + + /** Validate an example. */ + fun create(): ExampleValidationResult = create(ValidateCreateParams.none()) + + /** @see create */ + fun create( + params: ValidateCreateParams = ValidateCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ExampleValidationResult + + /** @see create */ + fun create( + params: ValidateCreateParams = ValidateCreateParams.none() + ): ExampleValidationResult = create(params, RequestOptions.none()) + + /** @see create */ + fun create(requestOptions: RequestOptions): ExampleValidationResult = + create(ValidateCreateParams.none(), requestOptions) + + /** Validate an example. */ + fun bulk(): List<ExampleValidationResult> = bulk(ValidateBulkParams.none()) + + /** @see bulk */ + fun bulk( + params: ValidateBulkParams = ValidateBulkParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<ExampleValidationResult> + + /** @see bulk */ + fun bulk( + params: ValidateBulkParams = ValidateBulkParams.none() + ): List<ExampleValidationResult> = bulk(params, RequestOptions.none()) + + /** @see bulk */ + fun bulk(requestOptions: RequestOptions): List<ExampleValidationResult> = + bulk(ValidateBulkParams.none(), requestOptions) + + /** A view of [ValidateService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ValidateService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/examples/validate`, but is otherwise the + * same as [ValidateService.create]. + */ + @MustBeClosed + fun create(): HttpResponseFor<ExampleValidationResult> = create(ValidateCreateParams.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: ValidateCreateParams = ValidateCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ExampleValidationResult> + + /** @see create */ + @MustBeClosed + fun create( + params: ValidateCreateParams = ValidateCreateParams.none() + ): HttpResponseFor<ExampleValidationResult> = create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create(requestOptions: RequestOptions): HttpResponseFor<ExampleValidationResult> = + create(ValidateCreateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/examples/validate/bulk`, but is otherwise + * the same as [ValidateService.bulk]. + */ + @MustBeClosed + fun bulk(): HttpResponseFor<List<ExampleValidationResult>> = bulk(ValidateBulkParams.none()) + + /** @see bulk */ + @MustBeClosed + fun bulk( + params: ValidateBulkParams = ValidateBulkParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<ExampleValidationResult>> + + /** @see bulk */ + @MustBeClosed + fun bulk( + params: ValidateBulkParams = ValidateBulkParams.none() + ): HttpResponseFor<List<ExampleValidationResult>> = bulk(params, RequestOptions.none()) + + /** @see bulk */ + @MustBeClosed + fun bulk(requestOptions: RequestOptions): HttpResponseFor<List<ExampleValidationResult>> = + bulk(ValidateBulkParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/examples/ValidateServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/examples/ValidateServiceImpl.kt new file mode 100644 index 00000000..5386657f --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/examples/ValidateServiceImpl.kt @@ -0,0 +1,118 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.examples + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.examples.validate.ExampleValidationResult +import com.langsmith_api.api.models.api.v1.examples.validate.ValidateBulkParams +import com.langsmith_api.api.models.api.v1.examples.validate.ValidateCreateParams +import java.util.function.Consumer + +class ValidateServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ValidateService { + + private val withRawResponse: ValidateService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ValidateService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): ValidateService = + ValidateServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: ValidateCreateParams, + requestOptions: RequestOptions, + ): ExampleValidationResult = + // post /api/v1/examples/validate + withRawResponse().create(params, requestOptions).parse() + + override fun bulk( + params: ValidateBulkParams, + requestOptions: RequestOptions, + ): List<ExampleValidationResult> = + // post /api/v1/examples/validate/bulk + withRawResponse().bulk(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ValidateService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ValidateService.WithRawResponse = + ValidateServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<ExampleValidationResult> = + jsonHandler<ExampleValidationResult>(clientOptions.jsonMapper) + + override fun create( + params: ValidateCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<ExampleValidationResult> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "examples", "validate") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val bulkHandler: Handler<List<ExampleValidationResult>> = + jsonHandler<List<ExampleValidationResult>>(clientOptions.jsonMapper) + + override fun bulk( + params: ValidateBulkParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<ExampleValidationResult>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "examples", "validate", "bulk") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { bulkHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/feedback/FormulaService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/feedback/FormulaService.kt new file mode 100644 index 00000000..11b001be --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/feedback/FormulaService.kt @@ -0,0 +1,318 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.feedback + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.feedback.formulas.FeedbackFormula +import com.langsmith_api.api.models.api.v1.feedback.formulas.FormulaCreateParams +import com.langsmith_api.api.models.api.v1.feedback.formulas.FormulaDeleteParams +import com.langsmith_api.api.models.api.v1.feedback.formulas.FormulaDeleteResponse +import com.langsmith_api.api.models.api.v1.feedback.formulas.FormulaListParams +import com.langsmith_api.api.models.api.v1.feedback.formulas.FormulaRetrieveParams +import com.langsmith_api.api.models.api.v1.feedback.formulas.FormulaUpdateParams +import java.util.function.Consumer + +interface FormulaService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): FormulaService + + /** Create Feedback Formula Ep */ + fun create(params: FormulaCreateParams): FeedbackFormula = create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: FormulaCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FeedbackFormula + + /** Get Feedback Formula Ep */ + fun retrieve(feedbackFormulaId: String): FeedbackFormula = + retrieve(feedbackFormulaId, FormulaRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + feedbackFormulaId: String, + params: FormulaRetrieveParams = FormulaRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): FeedbackFormula = + retrieve(params.toBuilder().feedbackFormulaId(feedbackFormulaId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + feedbackFormulaId: String, + params: FormulaRetrieveParams = FormulaRetrieveParams.none(), + ): FeedbackFormula = retrieve(feedbackFormulaId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: FormulaRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FeedbackFormula + + /** @see retrieve */ + fun retrieve(params: FormulaRetrieveParams): FeedbackFormula = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(feedbackFormulaId: String, requestOptions: RequestOptions): FeedbackFormula = + retrieve(feedbackFormulaId, FormulaRetrieveParams.none(), requestOptions) + + /** Update Feedback Formula Ep */ + fun update(feedbackFormulaId: String, params: FormulaUpdateParams): FeedbackFormula = + update(feedbackFormulaId, params, RequestOptions.none()) + + /** @see update */ + fun update( + feedbackFormulaId: String, + params: FormulaUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FeedbackFormula = + update(params.toBuilder().feedbackFormulaId(feedbackFormulaId).build(), requestOptions) + + /** @see update */ + fun update(params: FormulaUpdateParams): FeedbackFormula = update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: FormulaUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FeedbackFormula + + /** List Feedback Formula Ep */ + fun list(): List<FeedbackFormula> = list(FormulaListParams.none()) + + /** @see list */ + fun list( + params: FormulaListParams = FormulaListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<FeedbackFormula> + + /** @see list */ + fun list(params: FormulaListParams = FormulaListParams.none()): List<FeedbackFormula> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): List<FeedbackFormula> = + list(FormulaListParams.none(), requestOptions) + + /** Delete Feedback Formula Endpoint */ + fun delete(feedbackFormulaId: String): FormulaDeleteResponse = + delete(feedbackFormulaId, FormulaDeleteParams.none()) + + /** @see delete */ + fun delete( + feedbackFormulaId: String, + params: FormulaDeleteParams = FormulaDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): FormulaDeleteResponse = + delete(params.toBuilder().feedbackFormulaId(feedbackFormulaId).build(), requestOptions) + + /** @see delete */ + fun delete( + feedbackFormulaId: String, + params: FormulaDeleteParams = FormulaDeleteParams.none(), + ): FormulaDeleteResponse = delete(feedbackFormulaId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: FormulaDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FormulaDeleteResponse + + /** @see delete */ + fun delete(params: FormulaDeleteParams): FormulaDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(feedbackFormulaId: String, requestOptions: RequestOptions): FormulaDeleteResponse = + delete(feedbackFormulaId, FormulaDeleteParams.none(), requestOptions) + + /** A view of [FormulaService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): FormulaService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/feedback/formulas`, but is otherwise the + * same as [FormulaService.create]. + */ + @MustBeClosed + fun create(params: FormulaCreateParams): HttpResponseFor<FeedbackFormula> = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: FormulaCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<FeedbackFormula> + + /** + * Returns a raw HTTP response for `get /api/v1/feedback/formulas/{feedback_formula_id}`, + * but is otherwise the same as [FormulaService.retrieve]. + */ + @MustBeClosed + fun retrieve(feedbackFormulaId: String): HttpResponseFor<FeedbackFormula> = + retrieve(feedbackFormulaId, FormulaRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + feedbackFormulaId: String, + params: FormulaRetrieveParams = FormulaRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<FeedbackFormula> = + retrieve( + params.toBuilder().feedbackFormulaId(feedbackFormulaId).build(), + requestOptions, + ) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + feedbackFormulaId: String, + params: FormulaRetrieveParams = FormulaRetrieveParams.none(), + ): HttpResponseFor<FeedbackFormula> = + retrieve(feedbackFormulaId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: FormulaRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<FeedbackFormula> + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: FormulaRetrieveParams): HttpResponseFor<FeedbackFormula> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + feedbackFormulaId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<FeedbackFormula> = + retrieve(feedbackFormulaId, FormulaRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `put /api/v1/feedback/formulas/{feedback_formula_id}`, + * but is otherwise the same as [FormulaService.update]. + */ + @MustBeClosed + fun update( + feedbackFormulaId: String, + params: FormulaUpdateParams, + ): HttpResponseFor<FeedbackFormula> = + update(feedbackFormulaId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + feedbackFormulaId: String, + params: FormulaUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<FeedbackFormula> = + update(params.toBuilder().feedbackFormulaId(feedbackFormulaId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(params: FormulaUpdateParams): HttpResponseFor<FeedbackFormula> = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: FormulaUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<FeedbackFormula> + + /** + * Returns a raw HTTP response for `get /api/v1/feedback/formulas`, but is otherwise the + * same as [FormulaService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor<List<FeedbackFormula>> = list(FormulaListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: FormulaListParams = FormulaListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<FeedbackFormula>> + + /** @see list */ + @MustBeClosed + fun list( + params: FormulaListParams = FormulaListParams.none() + ): HttpResponseFor<List<FeedbackFormula>> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor<List<FeedbackFormula>> = + list(FormulaListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/feedback/formulas/{feedback_formula_id}`, + * but is otherwise the same as [FormulaService.delete]. + */ + @MustBeClosed + fun delete(feedbackFormulaId: String): HttpResponseFor<FormulaDeleteResponse> = + delete(feedbackFormulaId, FormulaDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + feedbackFormulaId: String, + params: FormulaDeleteParams = FormulaDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<FormulaDeleteResponse> = + delete(params.toBuilder().feedbackFormulaId(feedbackFormulaId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + feedbackFormulaId: String, + params: FormulaDeleteParams = FormulaDeleteParams.none(), + ): HttpResponseFor<FormulaDeleteResponse> = + delete(feedbackFormulaId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: FormulaDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<FormulaDeleteResponse> + + /** @see delete */ + @MustBeClosed + fun delete(params: FormulaDeleteParams): HttpResponseFor<FormulaDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + feedbackFormulaId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<FormulaDeleteResponse> = + delete(feedbackFormulaId, FormulaDeleteParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/feedback/FormulaServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/feedback/FormulaServiceImpl.kt new file mode 100644 index 00000000..7eba7eeb --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/feedback/FormulaServiceImpl.kt @@ -0,0 +1,236 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.feedback + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.feedback.formulas.FeedbackFormula +import com.langsmith_api.api.models.api.v1.feedback.formulas.FormulaCreateParams +import com.langsmith_api.api.models.api.v1.feedback.formulas.FormulaDeleteParams +import com.langsmith_api.api.models.api.v1.feedback.formulas.FormulaDeleteResponse +import com.langsmith_api.api.models.api.v1.feedback.formulas.FormulaListParams +import com.langsmith_api.api.models.api.v1.feedback.formulas.FormulaRetrieveParams +import com.langsmith_api.api.models.api.v1.feedback.formulas.FormulaUpdateParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class FormulaServiceImpl internal constructor(private val clientOptions: ClientOptions) : + FormulaService { + + private val withRawResponse: FormulaService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): FormulaService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): FormulaService = + FormulaServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: FormulaCreateParams, + requestOptions: RequestOptions, + ): FeedbackFormula = + // post /api/v1/feedback/formulas + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve( + params: FormulaRetrieveParams, + requestOptions: RequestOptions, + ): FeedbackFormula = + // get /api/v1/feedback/formulas/{feedback_formula_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update( + params: FormulaUpdateParams, + requestOptions: RequestOptions, + ): FeedbackFormula = + // put /api/v1/feedback/formulas/{feedback_formula_id} + withRawResponse().update(params, requestOptions).parse() + + override fun list( + params: FormulaListParams, + requestOptions: RequestOptions, + ): List<FeedbackFormula> = + // get /api/v1/feedback/formulas + withRawResponse().list(params, requestOptions).parse() + + override fun delete( + params: FormulaDeleteParams, + requestOptions: RequestOptions, + ): FormulaDeleteResponse = + // delete /api/v1/feedback/formulas/{feedback_formula_id} + withRawResponse().delete(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + FormulaService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): FormulaService.WithRawResponse = + FormulaServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<FeedbackFormula> = + jsonHandler<FeedbackFormula>(clientOptions.jsonMapper) + + override fun create( + params: FormulaCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<FeedbackFormula> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "feedback", "formulas") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler<FeedbackFormula> = + jsonHandler<FeedbackFormula>(clientOptions.jsonMapper) + + override fun retrieve( + params: FormulaRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor<FeedbackFormula> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("feedbackFormulaId", params.feedbackFormulaId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "feedback", "formulas", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler<FeedbackFormula> = + jsonHandler<FeedbackFormula>(clientOptions.jsonMapper) + + override fun update( + params: FormulaUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<FeedbackFormula> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("feedbackFormulaId", params.feedbackFormulaId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "feedback", "formulas", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler<List<FeedbackFormula>> = + jsonHandler<List<FeedbackFormula>>(clientOptions.jsonMapper) + + override fun list( + params: FormulaListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<FeedbackFormula>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "feedback", "formulas") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val deleteHandler: Handler<FormulaDeleteResponse> = + jsonHandler<FormulaDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: FormulaDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<FormulaDeleteResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("feedbackFormulaId", params.feedbackFormulaId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "feedback", "formulas", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/feedback/TokenService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/feedback/TokenService.kt new file mode 100644 index 00000000..c271546b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/feedback/TokenService.kt @@ -0,0 +1,241 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.feedback + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.feedback.tokens.FeedbackIngestTokenSchema +import com.langsmith_api.api.models.api.v1.feedback.tokens.TokenCreateParams +import com.langsmith_api.api.models.api.v1.feedback.tokens.TokenCreateResponse +import com.langsmith_api.api.models.api.v1.feedback.tokens.TokenListParams +import com.langsmith_api.api.models.api.v1.feedback.tokens.TokenRetrieveParams +import com.langsmith_api.api.models.api.v1.feedback.tokens.TokenRetrieveResponse +import com.langsmith_api.api.models.api.v1.feedback.tokens.TokenUpdateParams +import com.langsmith_api.api.models.api.v1.feedback.tokens.TokenUpdateResponse +import java.util.function.Consumer + +interface TokenService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): TokenService + + /** Create a new feedback ingest token. */ + fun create(params: TokenCreateParams): TokenCreateResponse = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: TokenCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): TokenCreateResponse + + /** Create a new feedback with a token. */ + fun retrieve(token: String): TokenRetrieveResponse = retrieve(token, TokenRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + token: String, + params: TokenRetrieveParams = TokenRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): TokenRetrieveResponse = retrieve(params.toBuilder().token(token).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + token: String, + params: TokenRetrieveParams = TokenRetrieveParams.none(), + ): TokenRetrieveResponse = retrieve(token, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: TokenRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): TokenRetrieveResponse + + /** @see retrieve */ + fun retrieve(params: TokenRetrieveParams): TokenRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(token: String, requestOptions: RequestOptions): TokenRetrieveResponse = + retrieve(token, TokenRetrieveParams.none(), requestOptions) + + /** Create a new feedback with a token. */ + fun update(token: String): TokenUpdateResponse = update(token, TokenUpdateParams.none()) + + /** @see update */ + fun update( + token: String, + params: TokenUpdateParams = TokenUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): TokenUpdateResponse = update(params.toBuilder().token(token).build(), requestOptions) + + /** @see update */ + fun update( + token: String, + params: TokenUpdateParams = TokenUpdateParams.none(), + ): TokenUpdateResponse = update(token, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: TokenUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): TokenUpdateResponse + + /** @see update */ + fun update(params: TokenUpdateParams): TokenUpdateResponse = + update(params, RequestOptions.none()) + + /** @see update */ + fun update(token: String, requestOptions: RequestOptions): TokenUpdateResponse = + update(token, TokenUpdateParams.none(), requestOptions) + + /** List all feedback ingest tokens for a run. */ + fun list(params: TokenListParams): List<FeedbackIngestTokenSchema> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: TokenListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List<FeedbackIngestTokenSchema> + + /** A view of [TokenService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): TokenService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/feedback/tokens`, but is otherwise the same + * as [TokenService.create]. + */ + @MustBeClosed + fun create(params: TokenCreateParams): HttpResponseFor<TokenCreateResponse> = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: TokenCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<TokenCreateResponse> + + /** + * Returns a raw HTTP response for `get /api/v1/feedback/tokens/{token}`, but is otherwise + * the same as [TokenService.retrieve]. + */ + @MustBeClosed + fun retrieve(token: String): HttpResponseFor<TokenRetrieveResponse> = + retrieve(token, TokenRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + token: String, + params: TokenRetrieveParams = TokenRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<TokenRetrieveResponse> = + retrieve(params.toBuilder().token(token).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + token: String, + params: TokenRetrieveParams = TokenRetrieveParams.none(), + ): HttpResponseFor<TokenRetrieveResponse> = retrieve(token, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: TokenRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<TokenRetrieveResponse> + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: TokenRetrieveParams): HttpResponseFor<TokenRetrieveResponse> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + token: String, + requestOptions: RequestOptions, + ): HttpResponseFor<TokenRetrieveResponse> = + retrieve(token, TokenRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/feedback/tokens/{token}`, but is otherwise + * the same as [TokenService.update]. + */ + @MustBeClosed + fun update(token: String): HttpResponseFor<TokenUpdateResponse> = + update(token, TokenUpdateParams.none()) + + /** @see update */ + @MustBeClosed + fun update( + token: String, + params: TokenUpdateParams = TokenUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<TokenUpdateResponse> = + update(params.toBuilder().token(token).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update( + token: String, + params: TokenUpdateParams = TokenUpdateParams.none(), + ): HttpResponseFor<TokenUpdateResponse> = update(token, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: TokenUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<TokenUpdateResponse> + + /** @see update */ + @MustBeClosed + fun update(params: TokenUpdateParams): HttpResponseFor<TokenUpdateResponse> = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + token: String, + requestOptions: RequestOptions, + ): HttpResponseFor<TokenUpdateResponse> = + update(token, TokenUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/feedback/tokens`, but is otherwise the same + * as [TokenService.list]. + */ + @MustBeClosed + fun list(params: TokenListParams): HttpResponseFor<List<FeedbackIngestTokenSchema>> = + list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: TokenListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<FeedbackIngestTokenSchema>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/feedback/TokenServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/feedback/TokenServiceImpl.kt new file mode 100644 index 00000000..7adec07c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/feedback/TokenServiceImpl.kt @@ -0,0 +1,199 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.feedback + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.feedback.tokens.FeedbackIngestTokenSchema +import com.langsmith_api.api.models.api.v1.feedback.tokens.TokenCreateParams +import com.langsmith_api.api.models.api.v1.feedback.tokens.TokenCreateResponse +import com.langsmith_api.api.models.api.v1.feedback.tokens.TokenListParams +import com.langsmith_api.api.models.api.v1.feedback.tokens.TokenRetrieveParams +import com.langsmith_api.api.models.api.v1.feedback.tokens.TokenRetrieveResponse +import com.langsmith_api.api.models.api.v1.feedback.tokens.TokenUpdateParams +import com.langsmith_api.api.models.api.v1.feedback.tokens.TokenUpdateResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class TokenServiceImpl internal constructor(private val clientOptions: ClientOptions) : + TokenService { + + private val withRawResponse: TokenService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): TokenService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): TokenService = + TokenServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: TokenCreateParams, + requestOptions: RequestOptions, + ): TokenCreateResponse = + // post /api/v1/feedback/tokens + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve( + params: TokenRetrieveParams, + requestOptions: RequestOptions, + ): TokenRetrieveResponse = + // get /api/v1/feedback/tokens/{token} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update( + params: TokenUpdateParams, + requestOptions: RequestOptions, + ): TokenUpdateResponse = + // post /api/v1/feedback/tokens/{token} + withRawResponse().update(params, requestOptions).parse() + + override fun list( + params: TokenListParams, + requestOptions: RequestOptions, + ): List<FeedbackIngestTokenSchema> = + // get /api/v1/feedback/tokens + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TokenService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): TokenService.WithRawResponse = + TokenServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<TokenCreateResponse> = + jsonHandler<TokenCreateResponse>(clientOptions.jsonMapper) + + override fun create( + params: TokenCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<TokenCreateResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "feedback", "tokens") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler<TokenRetrieveResponse> = + jsonHandler<TokenRetrieveResponse>(clientOptions.jsonMapper) + + override fun retrieve( + params: TokenRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor<TokenRetrieveResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("token", params.token().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "feedback", "tokens", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler<TokenUpdateResponse> = + jsonHandler<TokenUpdateResponse>(clientOptions.jsonMapper) + + override fun update( + params: TokenUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<TokenUpdateResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("token", params.token().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "feedback", "tokens", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler<List<FeedbackIngestTokenSchema>> = + jsonHandler<List<FeedbackIngestTokenSchema>>(clientOptions.jsonMapper) + + override fun list( + params: TokenListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<FeedbackIngestTokenSchema>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "feedback", "tokens") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/me/OnboardingStateService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/me/OnboardingStateService.kt new file mode 100644 index 00000000..d6c7a634 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/me/OnboardingStateService.kt @@ -0,0 +1,218 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.me + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.me.onboardingstate.OnboardingStateCreateParams +import com.langsmith_api.api.models.api.v1.me.onboardingstate.OnboardingStateListParams +import com.langsmith_api.api.models.api.v1.me.onboardingstate.OnboardingStateUpdateParams +import com.langsmith_api.api.models.api.v1.me.onboardingstate.UserOnboardingStateResponse +import java.util.function.Consumer + +interface OnboardingStateService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): OnboardingStateService + + /** Initialize onboarding state for the current user. */ + fun create(): UserOnboardingStateResponse = create(OnboardingStateCreateParams.none()) + + /** @see create */ + fun create( + params: OnboardingStateCreateParams = OnboardingStateCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): UserOnboardingStateResponse + + /** @see create */ + fun create( + params: OnboardingStateCreateParams = OnboardingStateCreateParams.none() + ): UserOnboardingStateResponse = create(params, RequestOptions.none()) + + /** @see create */ + fun create(requestOptions: RequestOptions): UserOnboardingStateResponse = + create(OnboardingStateCreateParams.none(), requestOptions) + + /** + * Update a specific onboarding completion field for the current user. + * + * Valid fields: + * - tracing_completed_at + * - lgstudio_completed_at + * - playground_completed_at + * - evaluation_completed_at + * - success_viewed_at + */ + fun update(field: String): UserOnboardingStateResponse = + update(field, OnboardingStateUpdateParams.none()) + + /** @see update */ + fun update( + field: String, + params: OnboardingStateUpdateParams = OnboardingStateUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): UserOnboardingStateResponse = update(params.toBuilder().field(field).build(), requestOptions) + + /** @see update */ + fun update( + field: String, + params: OnboardingStateUpdateParams = OnboardingStateUpdateParams.none(), + ): UserOnboardingStateResponse = update(field, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: OnboardingStateUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): UserOnboardingStateResponse + + /** @see update */ + fun update(params: OnboardingStateUpdateParams): UserOnboardingStateResponse = + update(params, RequestOptions.none()) + + /** @see update */ + fun update(field: String, requestOptions: RequestOptions): UserOnboardingStateResponse = + update(field, OnboardingStateUpdateParams.none(), requestOptions) + + /** Get onboarding state for the current user. */ + fun list(): UserOnboardingStateResponse = list(OnboardingStateListParams.none()) + + /** @see list */ + fun list( + params: OnboardingStateListParams = OnboardingStateListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): UserOnboardingStateResponse + + /** @see list */ + fun list( + params: OnboardingStateListParams = OnboardingStateListParams.none() + ): UserOnboardingStateResponse = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): UserOnboardingStateResponse = + list(OnboardingStateListParams.none(), requestOptions) + + /** + * A view of [OnboardingStateService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): OnboardingStateService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/me/onboarding_state`, but is otherwise the + * same as [OnboardingStateService.create]. + */ + @MustBeClosed + fun create(): HttpResponseFor<UserOnboardingStateResponse> = + create(OnboardingStateCreateParams.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: OnboardingStateCreateParams = OnboardingStateCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<UserOnboardingStateResponse> + + /** @see create */ + @MustBeClosed + fun create( + params: OnboardingStateCreateParams = OnboardingStateCreateParams.none() + ): HttpResponseFor<UserOnboardingStateResponse> = create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create(requestOptions: RequestOptions): HttpResponseFor<UserOnboardingStateResponse> = + create(OnboardingStateCreateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `put /api/v1/me/onboarding_state/{field}`, but is + * otherwise the same as [OnboardingStateService.update]. + */ + @MustBeClosed + fun update(field: String): HttpResponseFor<UserOnboardingStateResponse> = + update(field, OnboardingStateUpdateParams.none()) + + /** @see update */ + @MustBeClosed + fun update( + field: String, + params: OnboardingStateUpdateParams = OnboardingStateUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<UserOnboardingStateResponse> = + update(params.toBuilder().field(field).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update( + field: String, + params: OnboardingStateUpdateParams = OnboardingStateUpdateParams.none(), + ): HttpResponseFor<UserOnboardingStateResponse> = + update(field, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: OnboardingStateUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<UserOnboardingStateResponse> + + /** @see update */ + @MustBeClosed + fun update( + params: OnboardingStateUpdateParams + ): HttpResponseFor<UserOnboardingStateResponse> = update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + field: String, + requestOptions: RequestOptions, + ): HttpResponseFor<UserOnboardingStateResponse> = + update(field, OnboardingStateUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/me/onboarding_state`, but is otherwise the + * same as [OnboardingStateService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor<UserOnboardingStateResponse> = + list(OnboardingStateListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: OnboardingStateListParams = OnboardingStateListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<UserOnboardingStateResponse> + + /** @see list */ + @MustBeClosed + fun list( + params: OnboardingStateListParams = OnboardingStateListParams.none() + ): HttpResponseFor<UserOnboardingStateResponse> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor<UserOnboardingStateResponse> = + list(OnboardingStateListParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/me/OnboardingStateServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/me/OnboardingStateServiceImpl.kt new file mode 100644 index 00000000..8b313b12 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/me/OnboardingStateServiceImpl.kt @@ -0,0 +1,158 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.me + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.me.onboardingstate.OnboardingStateCreateParams +import com.langsmith_api.api.models.api.v1.me.onboardingstate.OnboardingStateListParams +import com.langsmith_api.api.models.api.v1.me.onboardingstate.OnboardingStateUpdateParams +import com.langsmith_api.api.models.api.v1.me.onboardingstate.UserOnboardingStateResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class OnboardingStateServiceImpl internal constructor(private val clientOptions: ClientOptions) : + OnboardingStateService { + + private val withRawResponse: OnboardingStateService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): OnboardingStateService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): OnboardingStateService = + OnboardingStateServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: OnboardingStateCreateParams, + requestOptions: RequestOptions, + ): UserOnboardingStateResponse = + // post /api/v1/me/onboarding_state + withRawResponse().create(params, requestOptions).parse() + + override fun update( + params: OnboardingStateUpdateParams, + requestOptions: RequestOptions, + ): UserOnboardingStateResponse = + // put /api/v1/me/onboarding_state/{field} + withRawResponse().update(params, requestOptions).parse() + + override fun list( + params: OnboardingStateListParams, + requestOptions: RequestOptions, + ): UserOnboardingStateResponse = + // get /api/v1/me/onboarding_state + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + OnboardingStateService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): OnboardingStateService.WithRawResponse = + OnboardingStateServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<UserOnboardingStateResponse> = + jsonHandler<UserOnboardingStateResponse>(clientOptions.jsonMapper) + + override fun create( + params: OnboardingStateCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<UserOnboardingStateResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "me", "onboarding_state") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler<UserOnboardingStateResponse> = + jsonHandler<UserOnboardingStateResponse>(clientOptions.jsonMapper) + + override fun update( + params: OnboardingStateUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<UserOnboardingStateResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("field", params.field().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "me", "onboarding_state", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler<UserOnboardingStateResponse> = + jsonHandler<UserOnboardingStateResponse>(clientOptions.jsonMapper) + + override fun list( + params: OnboardingStateListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<UserOnboardingStateResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "me", "onboarding_state") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgcharts/SectionService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgcharts/SectionService.kt new file mode 100644 index 00000000..7987f3d2 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgcharts/SectionService.kt @@ -0,0 +1,279 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgcharts + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.charts.section.CustomChartsSectionCreate +import com.langsmith_api.api.models.api.v1.charts.section.CustomChartsSectionResponse +import com.langsmith_api.api.models.api.v1.orgcharts.section.SectionCreateParams +import com.langsmith_api.api.models.api.v1.orgcharts.section.SectionDeleteParams +import com.langsmith_api.api.models.api.v1.orgcharts.section.SectionDeleteResponse +import com.langsmith_api.api.models.api.v1.orgcharts.section.SectionListParams +import com.langsmith_api.api.models.api.v1.orgcharts.section.SectionUpdateParams +import java.util.function.Consumer + +interface SectionService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): SectionService + + /** Create a new section. */ + fun create(params: SectionCreateParams): CustomChartsSectionResponse = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: SectionCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomChartsSectionResponse + + /** @see create */ + fun create( + customChartsSectionCreate: CustomChartsSectionCreate, + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomChartsSectionResponse = + create( + SectionCreateParams.builder() + .customChartsSectionCreate(customChartsSectionCreate) + .build(), + requestOptions, + ) + + /** @see create */ + fun create(customChartsSectionCreate: CustomChartsSectionCreate): CustomChartsSectionResponse = + create(customChartsSectionCreate, RequestOptions.none()) + + /** Update a section. */ + fun update(sectionId: String, params: SectionUpdateParams): CustomChartsSectionResponse = + update(sectionId, params, RequestOptions.none()) + + /** @see update */ + fun update( + sectionId: String, + params: SectionUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomChartsSectionResponse = + update(params.toBuilder().sectionId(sectionId).build(), requestOptions) + + /** @see update */ + fun update(params: SectionUpdateParams): CustomChartsSectionResponse = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: SectionUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomChartsSectionResponse + + /** Get all sections for the tenant. */ + fun list(): List<CustomChartsSectionResponse> = list(SectionListParams.none()) + + /** @see list */ + fun list( + params: SectionListParams = SectionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<CustomChartsSectionResponse> + + /** @see list */ + fun list( + params: SectionListParams = SectionListParams.none() + ): List<CustomChartsSectionResponse> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): List<CustomChartsSectionResponse> = + list(SectionListParams.none(), requestOptions) + + /** Delete a section. */ + fun delete(sectionId: String): SectionDeleteResponse = + delete(sectionId, SectionDeleteParams.none()) + + /** @see delete */ + fun delete( + sectionId: String, + params: SectionDeleteParams = SectionDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): SectionDeleteResponse = + delete(params.toBuilder().sectionId(sectionId).build(), requestOptions) + + /** @see delete */ + fun delete( + sectionId: String, + params: SectionDeleteParams = SectionDeleteParams.none(), + ): SectionDeleteResponse = delete(sectionId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: SectionDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SectionDeleteResponse + + /** @see delete */ + fun delete(params: SectionDeleteParams): SectionDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(sectionId: String, requestOptions: RequestOptions): SectionDeleteResponse = + delete(sectionId, SectionDeleteParams.none(), requestOptions) + + /** A view of [SectionService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): SectionService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/org-charts/section`, but is otherwise the + * same as [SectionService.create]. + */ + @MustBeClosed + fun create(params: SectionCreateParams): HttpResponseFor<CustomChartsSectionResponse> = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: SectionCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CustomChartsSectionResponse> + + /** @see create */ + @MustBeClosed + fun create( + customChartsSectionCreate: CustomChartsSectionCreate, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CustomChartsSectionResponse> = + create( + SectionCreateParams.builder() + .customChartsSectionCreate(customChartsSectionCreate) + .build(), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + customChartsSectionCreate: CustomChartsSectionCreate + ): HttpResponseFor<CustomChartsSectionResponse> = + create(customChartsSectionCreate, RequestOptions.none()) + + /** + * Returns a raw HTTP response for `patch /api/v1/org-charts/section/{section_id}`, but is + * otherwise the same as [SectionService.update]. + */ + @MustBeClosed + fun update( + sectionId: String, + params: SectionUpdateParams, + ): HttpResponseFor<CustomChartsSectionResponse> = + update(sectionId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + sectionId: String, + params: SectionUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CustomChartsSectionResponse> = + update(params.toBuilder().sectionId(sectionId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(params: SectionUpdateParams): HttpResponseFor<CustomChartsSectionResponse> = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: SectionUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CustomChartsSectionResponse> + + /** + * Returns a raw HTTP response for `get /api/v1/org-charts/section`, but is otherwise the + * same as [SectionService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor<List<CustomChartsSectionResponse>> = + list(SectionListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: SectionListParams = SectionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<CustomChartsSectionResponse>> + + /** @see list */ + @MustBeClosed + fun list( + params: SectionListParams = SectionListParams.none() + ): HttpResponseFor<List<CustomChartsSectionResponse>> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + requestOptions: RequestOptions + ): HttpResponseFor<List<CustomChartsSectionResponse>> = + list(SectionListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/org-charts/section/{section_id}`, but is + * otherwise the same as [SectionService.delete]. + */ + @MustBeClosed + fun delete(sectionId: String): HttpResponseFor<SectionDeleteResponse> = + delete(sectionId, SectionDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + sectionId: String, + params: SectionDeleteParams = SectionDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<SectionDeleteResponse> = + delete(params.toBuilder().sectionId(sectionId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + sectionId: String, + params: SectionDeleteParams = SectionDeleteParams.none(), + ): HttpResponseFor<SectionDeleteResponse> = delete(sectionId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: SectionDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<SectionDeleteResponse> + + /** @see delete */ + @MustBeClosed + fun delete(params: SectionDeleteParams): HttpResponseFor<SectionDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + sectionId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<SectionDeleteResponse> = + delete(sectionId, SectionDeleteParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgcharts/SectionServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgcharts/SectionServiceImpl.kt new file mode 100644 index 00000000..e7243d80 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgcharts/SectionServiceImpl.kt @@ -0,0 +1,198 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgcharts + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.charts.section.CustomChartsSectionResponse +import com.langsmith_api.api.models.api.v1.orgcharts.section.SectionCreateParams +import com.langsmith_api.api.models.api.v1.orgcharts.section.SectionDeleteParams +import com.langsmith_api.api.models.api.v1.orgcharts.section.SectionDeleteResponse +import com.langsmith_api.api.models.api.v1.orgcharts.section.SectionListParams +import com.langsmith_api.api.models.api.v1.orgcharts.section.SectionUpdateParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class SectionServiceImpl internal constructor(private val clientOptions: ClientOptions) : + SectionService { + + private val withRawResponse: SectionService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): SectionService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): SectionService = + SectionServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: SectionCreateParams, + requestOptions: RequestOptions, + ): CustomChartsSectionResponse = + // post /api/v1/org-charts/section + withRawResponse().create(params, requestOptions).parse() + + override fun update( + params: SectionUpdateParams, + requestOptions: RequestOptions, + ): CustomChartsSectionResponse = + // patch /api/v1/org-charts/section/{section_id} + withRawResponse().update(params, requestOptions).parse() + + override fun list( + params: SectionListParams, + requestOptions: RequestOptions, + ): List<CustomChartsSectionResponse> = + // get /api/v1/org-charts/section + withRawResponse().list(params, requestOptions).parse() + + override fun delete( + params: SectionDeleteParams, + requestOptions: RequestOptions, + ): SectionDeleteResponse = + // delete /api/v1/org-charts/section/{section_id} + withRawResponse().delete(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SectionService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): SectionService.WithRawResponse = + SectionServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<CustomChartsSectionResponse> = + jsonHandler<CustomChartsSectionResponse>(clientOptions.jsonMapper) + + override fun create( + params: SectionCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<CustomChartsSectionResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "org-charts", "section") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler<CustomChartsSectionResponse> = + jsonHandler<CustomChartsSectionResponse>(clientOptions.jsonMapper) + + override fun update( + params: SectionUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<CustomChartsSectionResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("sectionId", params.sectionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "org-charts", "section", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler<List<CustomChartsSectionResponse>> = + jsonHandler<List<CustomChartsSectionResponse>>(clientOptions.jsonMapper) + + override fun list( + params: SectionListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<CustomChartsSectionResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "org-charts", "section") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val deleteHandler: Handler<SectionDeleteResponse> = + jsonHandler<SectionDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: SectionDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<SectionDeleteResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("sectionId", params.sectionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "org-charts", "section", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/CurrentService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/CurrentService.kt new file mode 100644 index 00000000..12efb8a0 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/CurrentService.kt @@ -0,0 +1,430 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentConfirmCheckoutSessionCompletionParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentConfirmCheckoutSessionCompletionResponse +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentListParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentListResponse +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentPaymentMethodParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentPaymentMethodResponse +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentPlanParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentPlanResponse +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentRetrieveDashboardParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentRetrieveDashboardResponse +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentSetDefaultSsoProvisionParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentSetDefaultSsoProvisionResponse +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentSetupParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentSetupResponse +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentStripeAccountLinksParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentStripeAccountLinksResponse +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentStripeCheckoutSessionParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentStripeCheckoutSessionResponse +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentUpdateLoginMethodsParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentUpdateLoginMethodsResponse +import com.langsmith_api.api.services.blocking.api.v1.orgs.current.BillingService +import com.langsmith_api.api.services.blocking.api.v1.orgs.current.BusinessInfoService +import com.langsmith_api.api.services.blocking.api.v1.orgs.current.InfoService +import com.langsmith_api.api.services.blocking.api.v1.orgs.current.MemberService +import com.langsmith_api.api.services.blocking.api.v1.orgs.current.PersonalAccessTokenService +import com.langsmith_api.api.services.blocking.api.v1.orgs.current.RoleService +import com.langsmith_api.api.services.blocking.api.v1.orgs.current.ServiceKeyService +import com.langsmith_api.api.services.blocking.api.v1.orgs.current.SsoSettingService +import com.langsmith_api.api.services.blocking.api.v1.orgs.current.UserService +import java.util.function.Consumer + +interface CurrentService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): CurrentService + + fun info(): InfoService + + fun billing(): BillingService + + fun businessInfo(): BusinessInfoService + + fun roles(): RoleService + + fun members(): MemberService + + fun ssoSettings(): SsoSettingService + + fun user(): UserService + + fun serviceKeys(): ServiceKeyService + + fun personalAccessTokens(): PersonalAccessTokenService + + /** Get Organization Info */ + fun list(): CurrentListResponse = list(CurrentListParams.none()) + + /** @see list */ + fun list( + params: CurrentListParams = CurrentListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CurrentListResponse + + /** @see list */ + fun list(params: CurrentListParams = CurrentListParams.none()): CurrentListResponse = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CurrentListResponse = + list(CurrentListParams.none(), requestOptions) + + /** Complete a Stripe checkout session flow. */ + fun confirmCheckoutSessionCompletion( + params: CurrentConfirmCheckoutSessionCompletionParams + ): CurrentConfirmCheckoutSessionCompletionResponse = + confirmCheckoutSessionCompletion(params, RequestOptions.none()) + + /** @see confirmCheckoutSessionCompletion */ + fun confirmCheckoutSessionCompletion( + params: CurrentConfirmCheckoutSessionCompletionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CurrentConfirmCheckoutSessionCompletionResponse + + /** On Payment Method Created */ + fun paymentMethod(params: CurrentPaymentMethodParams): CurrentPaymentMethodResponse = + paymentMethod(params, RequestOptions.none()) + + /** @see paymentMethod */ + fun paymentMethod( + params: CurrentPaymentMethodParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CurrentPaymentMethodResponse + + /** Change Payment Plan */ + fun plan(params: CurrentPlanParams): CurrentPlanResponse = plan(params, RequestOptions.none()) + + /** @see plan */ + fun plan( + params: CurrentPlanParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CurrentPlanResponse + + /** Get Dashboard */ + fun retrieveDashboard( + params: CurrentRetrieveDashboardParams + ): CurrentRetrieveDashboardResponse = retrieveDashboard(params, RequestOptions.none()) + + /** @see retrieveDashboard */ + fun retrieveDashboard( + params: CurrentRetrieveDashboardParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CurrentRetrieveDashboardResponse + + /** + * Set the current organization as the default for SSO provisioning in self-hosted environments. + */ + fun setDefaultSsoProvision(): CurrentSetDefaultSsoProvisionResponse = + setDefaultSsoProvision(CurrentSetDefaultSsoProvisionParams.none()) + + /** @see setDefaultSsoProvision */ + fun setDefaultSsoProvision( + params: CurrentSetDefaultSsoProvisionParams = CurrentSetDefaultSsoProvisionParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CurrentSetDefaultSsoProvisionResponse + + /** @see setDefaultSsoProvision */ + fun setDefaultSsoProvision( + params: CurrentSetDefaultSsoProvisionParams = CurrentSetDefaultSsoProvisionParams.none() + ): CurrentSetDefaultSsoProvisionResponse = setDefaultSsoProvision(params, RequestOptions.none()) + + /** @see setDefaultSsoProvision */ + fun setDefaultSsoProvision( + requestOptions: RequestOptions + ): CurrentSetDefaultSsoProvisionResponse = + setDefaultSsoProvision(CurrentSetDefaultSsoProvisionParams.none(), requestOptions) + + /** Create Customers And Get Stripe Setup Intent */ + fun setup(): CurrentSetupResponse = setup(CurrentSetupParams.none()) + + /** @see setup */ + fun setup( + params: CurrentSetupParams = CurrentSetupParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CurrentSetupResponse + + /** @see setup */ + fun setup(params: CurrentSetupParams = CurrentSetupParams.none()): CurrentSetupResponse = + setup(params, RequestOptions.none()) + + /** @see setup */ + fun setup(requestOptions: RequestOptions): CurrentSetupResponse = + setup(CurrentSetupParams.none(), requestOptions) + + /** Kick off a Stripe account link flow. */ + fun stripeAccountLinks( + params: CurrentStripeAccountLinksParams + ): CurrentStripeAccountLinksResponse = stripeAccountLinks(params, RequestOptions.none()) + + /** @see stripeAccountLinks */ + fun stripeAccountLinks( + params: CurrentStripeAccountLinksParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CurrentStripeAccountLinksResponse + + /** Kick off a Stripe checkout session flow. */ + fun stripeCheckoutSession( + params: CurrentStripeCheckoutSessionParams + ): CurrentStripeCheckoutSessionResponse = stripeCheckoutSession(params, RequestOptions.none()) + + /** @see stripeCheckoutSession */ + fun stripeCheckoutSession( + params: CurrentStripeCheckoutSessionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CurrentStripeCheckoutSessionResponse + + /** Update allowed login methods for the current organization. */ + fun updateLoginMethods( + params: CurrentUpdateLoginMethodsParams + ): CurrentUpdateLoginMethodsResponse = updateLoginMethods(params, RequestOptions.none()) + + /** @see updateLoginMethods */ + fun updateLoginMethods( + params: CurrentUpdateLoginMethodsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CurrentUpdateLoginMethodsResponse + + /** A view of [CurrentService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): CurrentService.WithRawResponse + + fun info(): InfoService.WithRawResponse + + fun billing(): BillingService.WithRawResponse + + fun businessInfo(): BusinessInfoService.WithRawResponse + + fun roles(): RoleService.WithRawResponse + + fun members(): MemberService.WithRawResponse + + fun ssoSettings(): SsoSettingService.WithRawResponse + + fun user(): UserService.WithRawResponse + + fun serviceKeys(): ServiceKeyService.WithRawResponse + + fun personalAccessTokens(): PersonalAccessTokenService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/orgs/current`, but is otherwise the same as + * [CurrentService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor<CurrentListResponse> = list(CurrentListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: CurrentListParams = CurrentListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CurrentListResponse> + + /** @see list */ + @MustBeClosed + fun list( + params: CurrentListParams = CurrentListParams.none() + ): HttpResponseFor<CurrentListResponse> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor<CurrentListResponse> = + list(CurrentListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post + * /api/v1/orgs/current/confirm_checkout_session_completion`, but is otherwise the same as + * [CurrentService.confirmCheckoutSessionCompletion]. + */ + @MustBeClosed + fun confirmCheckoutSessionCompletion( + params: CurrentConfirmCheckoutSessionCompletionParams + ): HttpResponseFor<CurrentConfirmCheckoutSessionCompletionResponse> = + confirmCheckoutSessionCompletion(params, RequestOptions.none()) + + /** @see confirmCheckoutSessionCompletion */ + @MustBeClosed + fun confirmCheckoutSessionCompletion( + params: CurrentConfirmCheckoutSessionCompletionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CurrentConfirmCheckoutSessionCompletionResponse> + + /** + * Returns a raw HTTP response for `post /api/v1/orgs/current/payment-method`, but is + * otherwise the same as [CurrentService.paymentMethod]. + */ + @MustBeClosed + fun paymentMethod( + params: CurrentPaymentMethodParams + ): HttpResponseFor<CurrentPaymentMethodResponse> = + paymentMethod(params, RequestOptions.none()) + + /** @see paymentMethod */ + @MustBeClosed + fun paymentMethod( + params: CurrentPaymentMethodParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CurrentPaymentMethodResponse> + + /** + * Returns a raw HTTP response for `post /api/v1/orgs/current/plan`, but is otherwise the + * same as [CurrentService.plan]. + */ + @MustBeClosed + fun plan(params: CurrentPlanParams): HttpResponseFor<CurrentPlanResponse> = + plan(params, RequestOptions.none()) + + /** @see plan */ + @MustBeClosed + fun plan( + params: CurrentPlanParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CurrentPlanResponse> + + /** + * Returns a raw HTTP response for `get /api/v1/orgs/current/dashboard`, but is otherwise + * the same as [CurrentService.retrieveDashboard]. + */ + @MustBeClosed + fun retrieveDashboard( + params: CurrentRetrieveDashboardParams + ): HttpResponseFor<CurrentRetrieveDashboardResponse> = + retrieveDashboard(params, RequestOptions.none()) + + /** @see retrieveDashboard */ + @MustBeClosed + fun retrieveDashboard( + params: CurrentRetrieveDashboardParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CurrentRetrieveDashboardResponse> + + /** + * Returns a raw HTTP response for `post /api/v1/orgs/current/set-default-sso-provision`, + * but is otherwise the same as [CurrentService.setDefaultSsoProvision]. + */ + @MustBeClosed + fun setDefaultSsoProvision(): HttpResponseFor<CurrentSetDefaultSsoProvisionResponse> = + setDefaultSsoProvision(CurrentSetDefaultSsoProvisionParams.none()) + + /** @see setDefaultSsoProvision */ + @MustBeClosed + fun setDefaultSsoProvision( + params: CurrentSetDefaultSsoProvisionParams = + CurrentSetDefaultSsoProvisionParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CurrentSetDefaultSsoProvisionResponse> + + /** @see setDefaultSsoProvision */ + @MustBeClosed + fun setDefaultSsoProvision( + params: CurrentSetDefaultSsoProvisionParams = CurrentSetDefaultSsoProvisionParams.none() + ): HttpResponseFor<CurrentSetDefaultSsoProvisionResponse> = + setDefaultSsoProvision(params, RequestOptions.none()) + + /** @see setDefaultSsoProvision */ + @MustBeClosed + fun setDefaultSsoProvision( + requestOptions: RequestOptions + ): HttpResponseFor<CurrentSetDefaultSsoProvisionResponse> = + setDefaultSsoProvision(CurrentSetDefaultSsoProvisionParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/orgs/current/setup`, but is otherwise the + * same as [CurrentService.setup]. + */ + @MustBeClosed + fun setup(): HttpResponseFor<CurrentSetupResponse> = setup(CurrentSetupParams.none()) + + /** @see setup */ + @MustBeClosed + fun setup( + params: CurrentSetupParams = CurrentSetupParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CurrentSetupResponse> + + /** @see setup */ + @MustBeClosed + fun setup( + params: CurrentSetupParams = CurrentSetupParams.none() + ): HttpResponseFor<CurrentSetupResponse> = setup(params, RequestOptions.none()) + + /** @see setup */ + @MustBeClosed + fun setup(requestOptions: RequestOptions): HttpResponseFor<CurrentSetupResponse> = + setup(CurrentSetupParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/orgs/current/stripe_account_links`, but is + * otherwise the same as [CurrentService.stripeAccountLinks]. + */ + @MustBeClosed + fun stripeAccountLinks( + params: CurrentStripeAccountLinksParams + ): HttpResponseFor<CurrentStripeAccountLinksResponse> = + stripeAccountLinks(params, RequestOptions.none()) + + /** @see stripeAccountLinks */ + @MustBeClosed + fun stripeAccountLinks( + params: CurrentStripeAccountLinksParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CurrentStripeAccountLinksResponse> + + /** + * Returns a raw HTTP response for `post /api/v1/orgs/current/stripe_checkout_session`, but + * is otherwise the same as [CurrentService.stripeCheckoutSession]. + */ + @MustBeClosed + fun stripeCheckoutSession( + params: CurrentStripeCheckoutSessionParams + ): HttpResponseFor<CurrentStripeCheckoutSessionResponse> = + stripeCheckoutSession(params, RequestOptions.none()) + + /** @see stripeCheckoutSession */ + @MustBeClosed + fun stripeCheckoutSession( + params: CurrentStripeCheckoutSessionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CurrentStripeCheckoutSessionResponse> + + /** + * Returns a raw HTTP response for `patch /api/v1/orgs/current/login-methods`, but is + * otherwise the same as [CurrentService.updateLoginMethods]. + */ + @MustBeClosed + fun updateLoginMethods( + params: CurrentUpdateLoginMethodsParams + ): HttpResponseFor<CurrentUpdateLoginMethodsResponse> = + updateLoginMethods(params, RequestOptions.none()) + + /** @see updateLoginMethods */ + @MustBeClosed + fun updateLoginMethods( + params: CurrentUpdateLoginMethodsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CurrentUpdateLoginMethodsResponse> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/CurrentServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/CurrentServiceImpl.kt new file mode 100644 index 00000000..8e049421 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/CurrentServiceImpl.kt @@ -0,0 +1,531 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentConfirmCheckoutSessionCompletionParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentConfirmCheckoutSessionCompletionResponse +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentListParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentListResponse +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentPaymentMethodParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentPaymentMethodResponse +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentPlanParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentPlanResponse +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentRetrieveDashboardParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentRetrieveDashboardResponse +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentSetDefaultSsoProvisionParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentSetDefaultSsoProvisionResponse +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentSetupParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentSetupResponse +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentStripeAccountLinksParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentStripeAccountLinksResponse +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentStripeCheckoutSessionParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentStripeCheckoutSessionResponse +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentUpdateLoginMethodsParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentUpdateLoginMethodsResponse +import com.langsmith_api.api.services.blocking.api.v1.orgs.current.BillingService +import com.langsmith_api.api.services.blocking.api.v1.orgs.current.BillingServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.orgs.current.BusinessInfoService +import com.langsmith_api.api.services.blocking.api.v1.orgs.current.BusinessInfoServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.orgs.current.InfoService +import com.langsmith_api.api.services.blocking.api.v1.orgs.current.InfoServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.orgs.current.MemberService +import com.langsmith_api.api.services.blocking.api.v1.orgs.current.MemberServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.orgs.current.PersonalAccessTokenService +import com.langsmith_api.api.services.blocking.api.v1.orgs.current.PersonalAccessTokenServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.orgs.current.RoleService +import com.langsmith_api.api.services.blocking.api.v1.orgs.current.RoleServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.orgs.current.ServiceKeyService +import com.langsmith_api.api.services.blocking.api.v1.orgs.current.ServiceKeyServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.orgs.current.SsoSettingService +import com.langsmith_api.api.services.blocking.api.v1.orgs.current.SsoSettingServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.orgs.current.UserService +import com.langsmith_api.api.services.blocking.api.v1.orgs.current.UserServiceImpl +import java.util.function.Consumer + +class CurrentServiceImpl internal constructor(private val clientOptions: ClientOptions) : + CurrentService { + + private val withRawResponse: CurrentService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val info: InfoService by lazy { InfoServiceImpl(clientOptions) } + + private val billing: BillingService by lazy { BillingServiceImpl(clientOptions) } + + private val businessInfo: BusinessInfoService by lazy { BusinessInfoServiceImpl(clientOptions) } + + private val roles: RoleService by lazy { RoleServiceImpl(clientOptions) } + + private val members: MemberService by lazy { MemberServiceImpl(clientOptions) } + + private val ssoSettings: SsoSettingService by lazy { SsoSettingServiceImpl(clientOptions) } + + private val user: UserService by lazy { UserServiceImpl(clientOptions) } + + private val serviceKeys: ServiceKeyService by lazy { ServiceKeyServiceImpl(clientOptions) } + + private val personalAccessTokens: PersonalAccessTokenService by lazy { + PersonalAccessTokenServiceImpl(clientOptions) + } + + override fun withRawResponse(): CurrentService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): CurrentService = + CurrentServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun info(): InfoService = info + + override fun billing(): BillingService = billing + + override fun businessInfo(): BusinessInfoService = businessInfo + + override fun roles(): RoleService = roles + + override fun members(): MemberService = members + + override fun ssoSettings(): SsoSettingService = ssoSettings + + override fun user(): UserService = user + + override fun serviceKeys(): ServiceKeyService = serviceKeys + + override fun personalAccessTokens(): PersonalAccessTokenService = personalAccessTokens + + override fun list( + params: CurrentListParams, + requestOptions: RequestOptions, + ): CurrentListResponse = + // get /api/v1/orgs/current + withRawResponse().list(params, requestOptions).parse() + + override fun confirmCheckoutSessionCompletion( + params: CurrentConfirmCheckoutSessionCompletionParams, + requestOptions: RequestOptions, + ): CurrentConfirmCheckoutSessionCompletionResponse = + // post /api/v1/orgs/current/confirm_checkout_session_completion + withRawResponse().confirmCheckoutSessionCompletion(params, requestOptions).parse() + + override fun paymentMethod( + params: CurrentPaymentMethodParams, + requestOptions: RequestOptions, + ): CurrentPaymentMethodResponse = + // post /api/v1/orgs/current/payment-method + withRawResponse().paymentMethod(params, requestOptions).parse() + + override fun plan( + params: CurrentPlanParams, + requestOptions: RequestOptions, + ): CurrentPlanResponse = + // post /api/v1/orgs/current/plan + withRawResponse().plan(params, requestOptions).parse() + + override fun retrieveDashboard( + params: CurrentRetrieveDashboardParams, + requestOptions: RequestOptions, + ): CurrentRetrieveDashboardResponse = + // get /api/v1/orgs/current/dashboard + withRawResponse().retrieveDashboard(params, requestOptions).parse() + + override fun setDefaultSsoProvision( + params: CurrentSetDefaultSsoProvisionParams, + requestOptions: RequestOptions, + ): CurrentSetDefaultSsoProvisionResponse = + // post /api/v1/orgs/current/set-default-sso-provision + withRawResponse().setDefaultSsoProvision(params, requestOptions).parse() + + override fun setup( + params: CurrentSetupParams, + requestOptions: RequestOptions, + ): CurrentSetupResponse = + // post /api/v1/orgs/current/setup + withRawResponse().setup(params, requestOptions).parse() + + override fun stripeAccountLinks( + params: CurrentStripeAccountLinksParams, + requestOptions: RequestOptions, + ): CurrentStripeAccountLinksResponse = + // post /api/v1/orgs/current/stripe_account_links + withRawResponse().stripeAccountLinks(params, requestOptions).parse() + + override fun stripeCheckoutSession( + params: CurrentStripeCheckoutSessionParams, + requestOptions: RequestOptions, + ): CurrentStripeCheckoutSessionResponse = + // post /api/v1/orgs/current/stripe_checkout_session + withRawResponse().stripeCheckoutSession(params, requestOptions).parse() + + override fun updateLoginMethods( + params: CurrentUpdateLoginMethodsParams, + requestOptions: RequestOptions, + ): CurrentUpdateLoginMethodsResponse = + // patch /api/v1/orgs/current/login-methods + withRawResponse().updateLoginMethods(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CurrentService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val info: InfoService.WithRawResponse by lazy { + InfoServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val billing: BillingService.WithRawResponse by lazy { + BillingServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val businessInfo: BusinessInfoService.WithRawResponse by lazy { + BusinessInfoServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val roles: RoleService.WithRawResponse by lazy { + RoleServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val members: MemberService.WithRawResponse by lazy { + MemberServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val ssoSettings: SsoSettingService.WithRawResponse by lazy { + SsoSettingServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val user: UserService.WithRawResponse by lazy { + UserServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val serviceKeys: ServiceKeyService.WithRawResponse by lazy { + ServiceKeyServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val personalAccessTokens: PersonalAccessTokenService.WithRawResponse by lazy { + PersonalAccessTokenServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): CurrentService.WithRawResponse = + CurrentServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun info(): InfoService.WithRawResponse = info + + override fun billing(): BillingService.WithRawResponse = billing + + override fun businessInfo(): BusinessInfoService.WithRawResponse = businessInfo + + override fun roles(): RoleService.WithRawResponse = roles + + override fun members(): MemberService.WithRawResponse = members + + override fun ssoSettings(): SsoSettingService.WithRawResponse = ssoSettings + + override fun user(): UserService.WithRawResponse = user + + override fun serviceKeys(): ServiceKeyService.WithRawResponse = serviceKeys + + override fun personalAccessTokens(): PersonalAccessTokenService.WithRawResponse = + personalAccessTokens + + private val listHandler: Handler<CurrentListResponse> = + jsonHandler<CurrentListResponse>(clientOptions.jsonMapper) + + override fun list( + params: CurrentListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<CurrentListResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val confirmCheckoutSessionCompletionHandler: + Handler<CurrentConfirmCheckoutSessionCompletionResponse> = + jsonHandler<CurrentConfirmCheckoutSessionCompletionResponse>(clientOptions.jsonMapper) + + override fun confirmCheckoutSessionCompletion( + params: CurrentConfirmCheckoutSessionCompletionParams, + requestOptions: RequestOptions, + ): HttpResponseFor<CurrentConfirmCheckoutSessionCompletionResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "orgs", + "current", + "confirm_checkout_session_completion", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { confirmCheckoutSessionCompletionHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val paymentMethodHandler: Handler<CurrentPaymentMethodResponse> = + jsonHandler<CurrentPaymentMethodResponse>(clientOptions.jsonMapper) + + override fun paymentMethod( + params: CurrentPaymentMethodParams, + requestOptions: RequestOptions, + ): HttpResponseFor<CurrentPaymentMethodResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "payment-method") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { paymentMethodHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val planHandler: Handler<CurrentPlanResponse> = + jsonHandler<CurrentPlanResponse>(clientOptions.jsonMapper) + + override fun plan( + params: CurrentPlanParams, + requestOptions: RequestOptions, + ): HttpResponseFor<CurrentPlanResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "plan") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { planHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveDashboardHandler: Handler<CurrentRetrieveDashboardResponse> = + jsonHandler<CurrentRetrieveDashboardResponse>(clientOptions.jsonMapper) + + override fun retrieveDashboard( + params: CurrentRetrieveDashboardParams, + requestOptions: RequestOptions, + ): HttpResponseFor<CurrentRetrieveDashboardResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "dashboard") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveDashboardHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val setDefaultSsoProvisionHandler: Handler<CurrentSetDefaultSsoProvisionResponse> = + jsonHandler<CurrentSetDefaultSsoProvisionResponse>(clientOptions.jsonMapper) + + override fun setDefaultSsoProvision( + params: CurrentSetDefaultSsoProvisionParams, + requestOptions: RequestOptions, + ): HttpResponseFor<CurrentSetDefaultSsoProvisionResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "set-default-sso-provision") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { setDefaultSsoProvisionHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val setupHandler: Handler<CurrentSetupResponse> = + jsonHandler<CurrentSetupResponse>(clientOptions.jsonMapper) + + override fun setup( + params: CurrentSetupParams, + requestOptions: RequestOptions, + ): HttpResponseFor<CurrentSetupResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "setup") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { setupHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val stripeAccountLinksHandler: Handler<CurrentStripeAccountLinksResponse> = + jsonHandler<CurrentStripeAccountLinksResponse>(clientOptions.jsonMapper) + + override fun stripeAccountLinks( + params: CurrentStripeAccountLinksParams, + requestOptions: RequestOptions, + ): HttpResponseFor<CurrentStripeAccountLinksResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "stripe_account_links") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { stripeAccountLinksHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val stripeCheckoutSessionHandler: Handler<CurrentStripeCheckoutSessionResponse> = + jsonHandler<CurrentStripeCheckoutSessionResponse>(clientOptions.jsonMapper) + + override fun stripeCheckoutSession( + params: CurrentStripeCheckoutSessionParams, + requestOptions: RequestOptions, + ): HttpResponseFor<CurrentStripeCheckoutSessionResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "stripe_checkout_session") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { stripeCheckoutSessionHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateLoginMethodsHandler: Handler<CurrentUpdateLoginMethodsResponse> = + jsonHandler<CurrentUpdateLoginMethodsResponse>(clientOptions.jsonMapper) + + override fun updateLoginMethods( + params: CurrentUpdateLoginMethodsParams, + requestOptions: RequestOptions, + ): HttpResponseFor<CurrentUpdateLoginMethodsResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "login-methods") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateLoginMethodsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/MemberService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/MemberService.kt new file mode 100644 index 00000000..ae69468b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/MemberService.kt @@ -0,0 +1,83 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.orgs.members.MemberUpdateBasicParams +import com.langsmith_api.api.models.api.v1.orgs.members.MemberUpdateBasicResponse +import java.util.function.Consumer + +interface MemberService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): MemberService + + /** Update a user's full_name/password (basic auth only) */ + fun updateBasic(): MemberUpdateBasicResponse = updateBasic(MemberUpdateBasicParams.none()) + + /** @see updateBasic */ + fun updateBasic( + params: MemberUpdateBasicParams = MemberUpdateBasicParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): MemberUpdateBasicResponse + + /** @see updateBasic */ + fun updateBasic( + params: MemberUpdateBasicParams = MemberUpdateBasicParams.none() + ): MemberUpdateBasicResponse = updateBasic(params, RequestOptions.none()) + + /** @see updateBasic */ + fun updateBasic(requestOptions: RequestOptions): MemberUpdateBasicResponse = + updateBasic(MemberUpdateBasicParams.none(), requestOptions) + + /** A view of [MemberService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): MemberService.WithRawResponse + + /** + * Returns a raw HTTP response for `patch /api/v1/orgs/members/basic`, but is otherwise the + * same as [MemberService.updateBasic]. + */ + @MustBeClosed + fun updateBasic(): HttpResponseFor<MemberUpdateBasicResponse> = + updateBasic(MemberUpdateBasicParams.none()) + + /** @see updateBasic */ + @MustBeClosed + fun updateBasic( + params: MemberUpdateBasicParams = MemberUpdateBasicParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<MemberUpdateBasicResponse> + + /** @see updateBasic */ + @MustBeClosed + fun updateBasic( + params: MemberUpdateBasicParams = MemberUpdateBasicParams.none() + ): HttpResponseFor<MemberUpdateBasicResponse> = updateBasic(params, RequestOptions.none()) + + /** @see updateBasic */ + @MustBeClosed + fun updateBasic( + requestOptions: RequestOptions + ): HttpResponseFor<MemberUpdateBasicResponse> = + updateBasic(MemberUpdateBasicParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/MemberServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/MemberServiceImpl.kt new file mode 100644 index 00000000..61cf62fe --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/MemberServiceImpl.kt @@ -0,0 +1,82 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.orgs.members.MemberUpdateBasicParams +import com.langsmith_api.api.models.api.v1.orgs.members.MemberUpdateBasicResponse +import java.util.function.Consumer + +class MemberServiceImpl internal constructor(private val clientOptions: ClientOptions) : + MemberService { + + private val withRawResponse: MemberService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): MemberService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): MemberService = + MemberServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun updateBasic( + params: MemberUpdateBasicParams, + requestOptions: RequestOptions, + ): MemberUpdateBasicResponse = + // patch /api/v1/orgs/members/basic + withRawResponse().updateBasic(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + MemberService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): MemberService.WithRawResponse = + MemberServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val updateBasicHandler: Handler<MemberUpdateBasicResponse> = + jsonHandler<MemberUpdateBasicResponse>(clientOptions.jsonMapper) + + override fun updateBasic( + params: MemberUpdateBasicParams, + requestOptions: RequestOptions, + ): HttpResponseFor<MemberUpdateBasicResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "members", "basic") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateBasicHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/PendingService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/PendingService.kt new file mode 100644 index 00000000..de5ee9da --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/PendingService.kt @@ -0,0 +1,233 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.orgs.OrganizationPgSchemaSlim +import com.langsmith_api.api.models.api.v1.orgs.pending.Identity +import com.langsmith_api.api.models.api.v1.orgs.pending.PendingClaimParams +import com.langsmith_api.api.models.api.v1.orgs.pending.PendingDeleteParams +import com.langsmith_api.api.models.api.v1.orgs.pending.PendingDeleteResponse +import com.langsmith_api.api.models.api.v1.orgs.pending.PendingListParams +import java.util.function.Consumer + +interface PendingService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): PendingService + + /** Get all pending orgs visible to this auth */ + fun list(): List<OrganizationPgSchemaSlim> = list(PendingListParams.none()) + + /** @see list */ + fun list( + params: PendingListParams = PendingListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<OrganizationPgSchemaSlim> + + /** @see list */ + fun list(params: PendingListParams = PendingListParams.none()): List<OrganizationPgSchemaSlim> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): List<OrganizationPgSchemaSlim> = + list(PendingListParams.none(), requestOptions) + + /** Delete Pending Organization Invite */ + fun delete(organizationId: String): PendingDeleteResponse = + delete(organizationId, PendingDeleteParams.none()) + + /** @see delete */ + fun delete( + organizationId: String, + params: PendingDeleteParams = PendingDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): PendingDeleteResponse = + delete(params.toBuilder().organizationId(organizationId).build(), requestOptions) + + /** @see delete */ + fun delete( + organizationId: String, + params: PendingDeleteParams = PendingDeleteParams.none(), + ): PendingDeleteResponse = delete(organizationId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: PendingDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): PendingDeleteResponse + + /** @see delete */ + fun delete(params: PendingDeleteParams): PendingDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(organizationId: String, requestOptions: RequestOptions): PendingDeleteResponse = + delete(organizationId, PendingDeleteParams.none(), requestOptions) + + /** Claim Pending Organization Invite */ + fun claim(organizationId: String): Identity = claim(organizationId, PendingClaimParams.none()) + + /** @see claim */ + fun claim( + organizationId: String, + params: PendingClaimParams = PendingClaimParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Identity = claim(params.toBuilder().organizationId(organizationId).build(), requestOptions) + + /** @see claim */ + fun claim( + organizationId: String, + params: PendingClaimParams = PendingClaimParams.none(), + ): Identity = claim(organizationId, params, RequestOptions.none()) + + /** @see claim */ + fun claim( + params: PendingClaimParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Identity + + /** @see claim */ + fun claim(params: PendingClaimParams): Identity = claim(params, RequestOptions.none()) + + /** @see claim */ + fun claim(organizationId: String, requestOptions: RequestOptions): Identity = + claim(organizationId, PendingClaimParams.none(), requestOptions) + + /** A view of [PendingService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): PendingService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/orgs/pending`, but is otherwise the same as + * [PendingService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor<List<OrganizationPgSchemaSlim>> = list(PendingListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: PendingListParams = PendingListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<OrganizationPgSchemaSlim>> + + /** @see list */ + @MustBeClosed + fun list( + params: PendingListParams = PendingListParams.none() + ): HttpResponseFor<List<OrganizationPgSchemaSlim>> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor<List<OrganizationPgSchemaSlim>> = + list(PendingListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/orgs/pending/{organization_id}`, but is + * otherwise the same as [PendingService.delete]. + */ + @MustBeClosed + fun delete(organizationId: String): HttpResponseFor<PendingDeleteResponse> = + delete(organizationId, PendingDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + organizationId: String, + params: PendingDeleteParams = PendingDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<PendingDeleteResponse> = + delete(params.toBuilder().organizationId(organizationId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + organizationId: String, + params: PendingDeleteParams = PendingDeleteParams.none(), + ): HttpResponseFor<PendingDeleteResponse> = + delete(organizationId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: PendingDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<PendingDeleteResponse> + + /** @see delete */ + @MustBeClosed + fun delete(params: PendingDeleteParams): HttpResponseFor<PendingDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + organizationId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<PendingDeleteResponse> = + delete(organizationId, PendingDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/orgs/pending/{organization_id}/claim`, but + * is otherwise the same as [PendingService.claim]. + */ + @MustBeClosed + fun claim(organizationId: String): HttpResponseFor<Identity> = + claim(organizationId, PendingClaimParams.none()) + + /** @see claim */ + @MustBeClosed + fun claim( + organizationId: String, + params: PendingClaimParams = PendingClaimParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<Identity> = + claim(params.toBuilder().organizationId(organizationId).build(), requestOptions) + + /** @see claim */ + @MustBeClosed + fun claim( + organizationId: String, + params: PendingClaimParams = PendingClaimParams.none(), + ): HttpResponseFor<Identity> = claim(organizationId, params, RequestOptions.none()) + + /** @see claim */ + @MustBeClosed + fun claim( + params: PendingClaimParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<Identity> + + /** @see claim */ + @MustBeClosed + fun claim(params: PendingClaimParams): HttpResponseFor<Identity> = + claim(params, RequestOptions.none()) + + /** @see claim */ + @MustBeClosed + fun claim( + organizationId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<Identity> = + claim(organizationId, PendingClaimParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/PendingServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/PendingServiceImpl.kt new file mode 100644 index 00000000..2a86e2f7 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/PendingServiceImpl.kt @@ -0,0 +1,160 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.orgs.OrganizationPgSchemaSlim +import com.langsmith_api.api.models.api.v1.orgs.pending.Identity +import com.langsmith_api.api.models.api.v1.orgs.pending.PendingClaimParams +import com.langsmith_api.api.models.api.v1.orgs.pending.PendingDeleteParams +import com.langsmith_api.api.models.api.v1.orgs.pending.PendingDeleteResponse +import com.langsmith_api.api.models.api.v1.orgs.pending.PendingListParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class PendingServiceImpl internal constructor(private val clientOptions: ClientOptions) : + PendingService { + + private val withRawResponse: PendingService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): PendingService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): PendingService = + PendingServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: PendingListParams, + requestOptions: RequestOptions, + ): List<OrganizationPgSchemaSlim> = + // get /api/v1/orgs/pending + withRawResponse().list(params, requestOptions).parse() + + override fun delete( + params: PendingDeleteParams, + requestOptions: RequestOptions, + ): PendingDeleteResponse = + // delete /api/v1/orgs/pending/{organization_id} + withRawResponse().delete(params, requestOptions).parse() + + override fun claim(params: PendingClaimParams, requestOptions: RequestOptions): Identity = + // post /api/v1/orgs/pending/{organization_id}/claim + withRawResponse().claim(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + PendingService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PendingService.WithRawResponse = + PendingServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler<List<OrganizationPgSchemaSlim>> = + jsonHandler<List<OrganizationPgSchemaSlim>>(clientOptions.jsonMapper) + + override fun list( + params: PendingListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<OrganizationPgSchemaSlim>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "pending") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val deleteHandler: Handler<PendingDeleteResponse> = + jsonHandler<PendingDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: PendingDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<PendingDeleteResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("organizationId", params.organizationId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "pending", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val claimHandler: Handler<Identity> = + jsonHandler<Identity>(clientOptions.jsonMapper) + + override fun claim( + params: PendingClaimParams, + requestOptions: RequestOptions, + ): HttpResponseFor<Identity> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("organizationId", params.organizationId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "pending", params._pathParam(0), "claim") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { claimHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/TtlSettingService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/TtlSettingService.kt new file mode 100644 index 00000000..5970a43e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/TtlSettingService.kt @@ -0,0 +1,151 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TtlSettingRetrieveTtlSettingsParams +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TtlSettingUpdateTtlSettingsParams +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TtlSettings +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.UpsertTtlSettingsRequest +import java.util.function.Consumer + +interface TtlSettingService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): TtlSettingService + + /** List out the configured TTL settings for a given org (org-level and tenant-level). */ + fun retrieveTtlSettings(): List<TtlSettings> = + retrieveTtlSettings(TtlSettingRetrieveTtlSettingsParams.none()) + + /** @see retrieveTtlSettings */ + fun retrieveTtlSettings( + params: TtlSettingRetrieveTtlSettingsParams = TtlSettingRetrieveTtlSettingsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<TtlSettings> + + /** @see retrieveTtlSettings */ + fun retrieveTtlSettings( + params: TtlSettingRetrieveTtlSettingsParams = TtlSettingRetrieveTtlSettingsParams.none() + ): List<TtlSettings> = retrieveTtlSettings(params, RequestOptions.none()) + + /** @see retrieveTtlSettings */ + fun retrieveTtlSettings(requestOptions: RequestOptions): List<TtlSettings> = + retrieveTtlSettings(TtlSettingRetrieveTtlSettingsParams.none(), requestOptions) + + /** Upsert Ttl Settings */ + fun updateTtlSettings(params: TtlSettingUpdateTtlSettingsParams): TtlSettings = + updateTtlSettings(params, RequestOptions.none()) + + /** @see updateTtlSettings */ + fun updateTtlSettings( + params: TtlSettingUpdateTtlSettingsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): TtlSettings + + /** @see updateTtlSettings */ + fun updateTtlSettings( + upsertTtlSettingsRequest: UpsertTtlSettingsRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): TtlSettings = + updateTtlSettings( + TtlSettingUpdateTtlSettingsParams.builder() + .upsertTtlSettingsRequest(upsertTtlSettingsRequest) + .build(), + requestOptions, + ) + + /** @see updateTtlSettings */ + fun updateTtlSettings(upsertTtlSettingsRequest: UpsertTtlSettingsRequest): TtlSettings = + updateTtlSettings(upsertTtlSettingsRequest, RequestOptions.none()) + + /** A view of [TtlSettingService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): TtlSettingService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/orgs/ttl-settings`, but is otherwise the + * same as [TtlSettingService.retrieveTtlSettings]. + */ + @MustBeClosed + fun retrieveTtlSettings(): HttpResponseFor<List<TtlSettings>> = + retrieveTtlSettings(TtlSettingRetrieveTtlSettingsParams.none()) + + /** @see retrieveTtlSettings */ + @MustBeClosed + fun retrieveTtlSettings( + params: TtlSettingRetrieveTtlSettingsParams = + TtlSettingRetrieveTtlSettingsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<TtlSettings>> + + /** @see retrieveTtlSettings */ + @MustBeClosed + fun retrieveTtlSettings( + params: TtlSettingRetrieveTtlSettingsParams = TtlSettingRetrieveTtlSettingsParams.none() + ): HttpResponseFor<List<TtlSettings>> = retrieveTtlSettings(params, RequestOptions.none()) + + /** @see retrieveTtlSettings */ + @MustBeClosed + fun retrieveTtlSettings( + requestOptions: RequestOptions + ): HttpResponseFor<List<TtlSettings>> = + retrieveTtlSettings(TtlSettingRetrieveTtlSettingsParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `put /api/v1/orgs/ttl-settings`, but is otherwise the + * same as [TtlSettingService.updateTtlSettings]. + */ + @MustBeClosed + fun updateTtlSettings( + params: TtlSettingUpdateTtlSettingsParams + ): HttpResponseFor<TtlSettings> = updateTtlSettings(params, RequestOptions.none()) + + /** @see updateTtlSettings */ + @MustBeClosed + fun updateTtlSettings( + params: TtlSettingUpdateTtlSettingsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<TtlSettings> + + /** @see updateTtlSettings */ + @MustBeClosed + fun updateTtlSettings( + upsertTtlSettingsRequest: UpsertTtlSettingsRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<TtlSettings> = + updateTtlSettings( + TtlSettingUpdateTtlSettingsParams.builder() + .upsertTtlSettingsRequest(upsertTtlSettingsRequest) + .build(), + requestOptions, + ) + + /** @see updateTtlSettings */ + @MustBeClosed + fun updateTtlSettings( + upsertTtlSettingsRequest: UpsertTtlSettingsRequest + ): HttpResponseFor<TtlSettings> = + updateTtlSettings(upsertTtlSettingsRequest, RequestOptions.none()) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/TtlSettingServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/TtlSettingServiceImpl.kt new file mode 100644 index 00000000..6eab2942 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/TtlSettingServiceImpl.kt @@ -0,0 +1,117 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TtlSettingRetrieveTtlSettingsParams +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TtlSettingUpdateTtlSettingsParams +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TtlSettings +import java.util.function.Consumer + +class TtlSettingServiceImpl internal constructor(private val clientOptions: ClientOptions) : + TtlSettingService { + + private val withRawResponse: TtlSettingService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): TtlSettingService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): TtlSettingService = + TtlSettingServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieveTtlSettings( + params: TtlSettingRetrieveTtlSettingsParams, + requestOptions: RequestOptions, + ): List<TtlSettings> = + // get /api/v1/orgs/ttl-settings + withRawResponse().retrieveTtlSettings(params, requestOptions).parse() + + override fun updateTtlSettings( + params: TtlSettingUpdateTtlSettingsParams, + requestOptions: RequestOptions, + ): TtlSettings = + // put /api/v1/orgs/ttl-settings + withRawResponse().updateTtlSettings(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TtlSettingService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): TtlSettingService.WithRawResponse = + TtlSettingServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveTtlSettingsHandler: Handler<List<TtlSettings>> = + jsonHandler<List<TtlSettings>>(clientOptions.jsonMapper) + + override fun retrieveTtlSettings( + params: TtlSettingRetrieveTtlSettingsParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<TtlSettings>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "ttl-settings") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveTtlSettingsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val updateTtlSettingsHandler: Handler<TtlSettings> = + jsonHandler<TtlSettings>(clientOptions.jsonMapper) + + override fun updateTtlSettings( + params: TtlSettingUpdateTtlSettingsParams, + requestOptions: RequestOptions, + ): HttpResponseFor<TtlSettings> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "ttl-settings") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateTtlSettingsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/BillingService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/BillingService.kt new file mode 100644 index 00000000..e9d14f4b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/BillingService.kt @@ -0,0 +1,108 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs.current + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.orgs.current.billing.BillingListParams +import com.langsmith_api.api.models.api.v1.orgs.current.billing.BillingListResponse +import com.langsmith_api.api.models.api.v1.orgs.current.billing.BillingRetrieveUsageParams +import com.langsmith_api.api.models.api.v1.orgs.current.billing.BillingRetrieveUsageResponse +import java.util.function.Consumer + +interface BillingService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): BillingService + + /** Get Organization Billing Info */ + fun list(): BillingListResponse = list(BillingListParams.none()) + + /** @see list */ + fun list( + params: BillingListParams = BillingListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): BillingListResponse + + /** @see list */ + fun list(params: BillingListParams = BillingListParams.none()): BillingListResponse = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): BillingListResponse = + list(BillingListParams.none(), requestOptions) + + /** Get Org Usage */ + fun retrieveUsage(params: BillingRetrieveUsageParams): List<BillingRetrieveUsageResponse> = + retrieveUsage(params, RequestOptions.none()) + + /** @see retrieveUsage */ + fun retrieveUsage( + params: BillingRetrieveUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List<BillingRetrieveUsageResponse> + + /** A view of [BillingService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): BillingService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/orgs/current/billing`, but is otherwise the + * same as [BillingService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor<BillingListResponse> = list(BillingListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: BillingListParams = BillingListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<BillingListResponse> + + /** @see list */ + @MustBeClosed + fun list( + params: BillingListParams = BillingListParams.none() + ): HttpResponseFor<BillingListResponse> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor<BillingListResponse> = + list(BillingListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/orgs/current/billing/usage`, but is + * otherwise the same as [BillingService.retrieveUsage]. + */ + @MustBeClosed + fun retrieveUsage( + params: BillingRetrieveUsageParams + ): HttpResponseFor<List<BillingRetrieveUsageResponse>> = + retrieveUsage(params, RequestOptions.none()) + + /** @see retrieveUsage */ + @MustBeClosed + fun retrieveUsage( + params: BillingRetrieveUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<BillingRetrieveUsageResponse>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/BillingServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/BillingServiceImpl.kt new file mode 100644 index 00000000..25d516c4 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/BillingServiceImpl.kt @@ -0,0 +1,116 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.orgs.current.billing.BillingListParams +import com.langsmith_api.api.models.api.v1.orgs.current.billing.BillingListResponse +import com.langsmith_api.api.models.api.v1.orgs.current.billing.BillingRetrieveUsageParams +import com.langsmith_api.api.models.api.v1.orgs.current.billing.BillingRetrieveUsageResponse +import java.util.function.Consumer + +class BillingServiceImpl internal constructor(private val clientOptions: ClientOptions) : + BillingService { + + private val withRawResponse: BillingService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): BillingService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): BillingService = + BillingServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: BillingListParams, + requestOptions: RequestOptions, + ): BillingListResponse = + // get /api/v1/orgs/current/billing + withRawResponse().list(params, requestOptions).parse() + + override fun retrieveUsage( + params: BillingRetrieveUsageParams, + requestOptions: RequestOptions, + ): List<BillingRetrieveUsageResponse> = + // get /api/v1/orgs/current/billing/usage + withRawResponse().retrieveUsage(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BillingService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): BillingService.WithRawResponse = + BillingServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler<BillingListResponse> = + jsonHandler<BillingListResponse>(clientOptions.jsonMapper) + + override fun list( + params: BillingListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<BillingListResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "billing") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveUsageHandler: Handler<List<BillingRetrieveUsageResponse>> = + jsonHandler<List<BillingRetrieveUsageResponse>>(clientOptions.jsonMapper) + + override fun retrieveUsage( + params: BillingRetrieveUsageParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<BillingRetrieveUsageResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "billing", "usage") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveUsageHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/BusinessInfoService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/BusinessInfoService.kt new file mode 100644 index 00000000..2669a93b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/BusinessInfoService.kt @@ -0,0 +1,146 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs.current + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.orgs.current.businessinfo.BusinessInfoBusinessInfoParams +import com.langsmith_api.api.models.api.v1.orgs.current.businessinfo.BusinessInfoBusinessInfoResponse +import com.langsmith_api.api.models.api.v1.orgs.current.businessinfo.BusinessInfoRetrieveBusinessInfoParams +import com.langsmith_api.api.models.api.v1.orgs.current.businessinfo.BusinessInfoRetrieveBusinessInfoResponse +import java.util.function.Consumer + +interface BusinessInfoService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): BusinessInfoService + + /** Set Company Info */ + fun businessInfo(): BusinessInfoBusinessInfoResponse = + businessInfo(BusinessInfoBusinessInfoParams.none()) + + /** @see businessInfo */ + fun businessInfo( + params: BusinessInfoBusinessInfoParams = BusinessInfoBusinessInfoParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): BusinessInfoBusinessInfoResponse + + /** @see businessInfo */ + fun businessInfo( + params: BusinessInfoBusinessInfoParams = BusinessInfoBusinessInfoParams.none() + ): BusinessInfoBusinessInfoResponse = businessInfo(params, RequestOptions.none()) + + /** @see businessInfo */ + fun businessInfo(requestOptions: RequestOptions): BusinessInfoBusinessInfoResponse = + businessInfo(BusinessInfoBusinessInfoParams.none(), requestOptions) + + /** Get Company Info */ + fun retrieveBusinessInfo(): BusinessInfoRetrieveBusinessInfoResponse = + retrieveBusinessInfo(BusinessInfoRetrieveBusinessInfoParams.none()) + + /** @see retrieveBusinessInfo */ + fun retrieveBusinessInfo( + params: BusinessInfoRetrieveBusinessInfoParams = + BusinessInfoRetrieveBusinessInfoParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): BusinessInfoRetrieveBusinessInfoResponse + + /** @see retrieveBusinessInfo */ + fun retrieveBusinessInfo( + params: BusinessInfoRetrieveBusinessInfoParams = + BusinessInfoRetrieveBusinessInfoParams.none() + ): BusinessInfoRetrieveBusinessInfoResponse = + retrieveBusinessInfo(params, RequestOptions.none()) + + /** @see retrieveBusinessInfo */ + fun retrieveBusinessInfo( + requestOptions: RequestOptions + ): BusinessInfoRetrieveBusinessInfoResponse = + retrieveBusinessInfo(BusinessInfoRetrieveBusinessInfoParams.none(), requestOptions) + + /** + * A view of [BusinessInfoService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): BusinessInfoService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/orgs/current/business-info`, but is + * otherwise the same as [BusinessInfoService.businessInfo]. + */ + @MustBeClosed + fun businessInfo(): HttpResponseFor<BusinessInfoBusinessInfoResponse> = + businessInfo(BusinessInfoBusinessInfoParams.none()) + + /** @see businessInfo */ + @MustBeClosed + fun businessInfo( + params: BusinessInfoBusinessInfoParams = BusinessInfoBusinessInfoParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<BusinessInfoBusinessInfoResponse> + + /** @see businessInfo */ + @MustBeClosed + fun businessInfo( + params: BusinessInfoBusinessInfoParams = BusinessInfoBusinessInfoParams.none() + ): HttpResponseFor<BusinessInfoBusinessInfoResponse> = + businessInfo(params, RequestOptions.none()) + + /** @see businessInfo */ + @MustBeClosed + fun businessInfo( + requestOptions: RequestOptions + ): HttpResponseFor<BusinessInfoBusinessInfoResponse> = + businessInfo(BusinessInfoBusinessInfoParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/orgs/current/business-info`, but is + * otherwise the same as [BusinessInfoService.retrieveBusinessInfo]. + */ + @MustBeClosed + fun retrieveBusinessInfo(): HttpResponseFor<BusinessInfoRetrieveBusinessInfoResponse> = + retrieveBusinessInfo(BusinessInfoRetrieveBusinessInfoParams.none()) + + /** @see retrieveBusinessInfo */ + @MustBeClosed + fun retrieveBusinessInfo( + params: BusinessInfoRetrieveBusinessInfoParams = + BusinessInfoRetrieveBusinessInfoParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<BusinessInfoRetrieveBusinessInfoResponse> + + /** @see retrieveBusinessInfo */ + @MustBeClosed + fun retrieveBusinessInfo( + params: BusinessInfoRetrieveBusinessInfoParams = + BusinessInfoRetrieveBusinessInfoParams.none() + ): HttpResponseFor<BusinessInfoRetrieveBusinessInfoResponse> = + retrieveBusinessInfo(params, RequestOptions.none()) + + /** @see retrieveBusinessInfo */ + @MustBeClosed + fun retrieveBusinessInfo( + requestOptions: RequestOptions + ): HttpResponseFor<BusinessInfoRetrieveBusinessInfoResponse> = + retrieveBusinessInfo(BusinessInfoRetrieveBusinessInfoParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/BusinessInfoServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/BusinessInfoServiceImpl.kt new file mode 100644 index 00000000..f3bd9a8e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/BusinessInfoServiceImpl.kt @@ -0,0 +1,118 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.orgs.current.businessinfo.BusinessInfoBusinessInfoParams +import com.langsmith_api.api.models.api.v1.orgs.current.businessinfo.BusinessInfoBusinessInfoResponse +import com.langsmith_api.api.models.api.v1.orgs.current.businessinfo.BusinessInfoRetrieveBusinessInfoParams +import com.langsmith_api.api.models.api.v1.orgs.current.businessinfo.BusinessInfoRetrieveBusinessInfoResponse +import java.util.function.Consumer + +class BusinessInfoServiceImpl internal constructor(private val clientOptions: ClientOptions) : + BusinessInfoService { + + private val withRawResponse: BusinessInfoService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): BusinessInfoService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): BusinessInfoService = + BusinessInfoServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun businessInfo( + params: BusinessInfoBusinessInfoParams, + requestOptions: RequestOptions, + ): BusinessInfoBusinessInfoResponse = + // post /api/v1/orgs/current/business-info + withRawResponse().businessInfo(params, requestOptions).parse() + + override fun retrieveBusinessInfo( + params: BusinessInfoRetrieveBusinessInfoParams, + requestOptions: RequestOptions, + ): BusinessInfoRetrieveBusinessInfoResponse = + // get /api/v1/orgs/current/business-info + withRawResponse().retrieveBusinessInfo(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BusinessInfoService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): BusinessInfoService.WithRawResponse = + BusinessInfoServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val businessInfoHandler: Handler<BusinessInfoBusinessInfoResponse> = + jsonHandler<BusinessInfoBusinessInfoResponse>(clientOptions.jsonMapper) + + override fun businessInfo( + params: BusinessInfoBusinessInfoParams, + requestOptions: RequestOptions, + ): HttpResponseFor<BusinessInfoBusinessInfoResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "business-info") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { businessInfoHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveBusinessInfoHandler: Handler<BusinessInfoRetrieveBusinessInfoResponse> = + jsonHandler<BusinessInfoRetrieveBusinessInfoResponse>(clientOptions.jsonMapper) + + override fun retrieveBusinessInfo( + params: BusinessInfoRetrieveBusinessInfoParams, + requestOptions: RequestOptions, + ): HttpResponseFor<BusinessInfoRetrieveBusinessInfoResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "business-info") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveBusinessInfoHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/InfoService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/InfoService.kt new file mode 100644 index 00000000..10ac1b2d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/InfoService.kt @@ -0,0 +1,121 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs.current + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.orgs.current.info.InfoListParams +import com.langsmith_api.api.models.api.v1.orgs.current.info.InfoPatchAllParams +import com.langsmith_api.api.models.api.v1.orgs.current.info.OrganizationInfo +import java.util.function.Consumer + +interface InfoService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): InfoService + + /** Get Current Organization Info */ + fun list(): OrganizationInfo = list(InfoListParams.none()) + + /** @see list */ + fun list( + params: InfoListParams = InfoListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): OrganizationInfo + + /** @see list */ + fun list(params: InfoListParams = InfoListParams.none()): OrganizationInfo = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): OrganizationInfo = + list(InfoListParams.none(), requestOptions) + + /** Update Current Organization Info */ + fun patchAll(): OrganizationInfo = patchAll(InfoPatchAllParams.none()) + + /** @see patchAll */ + fun patchAll( + params: InfoPatchAllParams = InfoPatchAllParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): OrganizationInfo + + /** @see patchAll */ + fun patchAll(params: InfoPatchAllParams = InfoPatchAllParams.none()): OrganizationInfo = + patchAll(params, RequestOptions.none()) + + /** @see patchAll */ + fun patchAll(requestOptions: RequestOptions): OrganizationInfo = + patchAll(InfoPatchAllParams.none(), requestOptions) + + /** A view of [InfoService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): InfoService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/orgs/current/info`, but is otherwise the + * same as [InfoService.list]. + */ + @MustBeClosed fun list(): HttpResponseFor<OrganizationInfo> = list(InfoListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: InfoListParams = InfoListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<OrganizationInfo> + + /** @see list */ + @MustBeClosed + fun list( + params: InfoListParams = InfoListParams.none() + ): HttpResponseFor<OrganizationInfo> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor<OrganizationInfo> = + list(InfoListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `patch /api/v1/orgs/current/info`, but is otherwise the + * same as [InfoService.patchAll]. + */ + @MustBeClosed + fun patchAll(): HttpResponseFor<OrganizationInfo> = patchAll(InfoPatchAllParams.none()) + + /** @see patchAll */ + @MustBeClosed + fun patchAll( + params: InfoPatchAllParams = InfoPatchAllParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<OrganizationInfo> + + /** @see patchAll */ + @MustBeClosed + fun patchAll( + params: InfoPatchAllParams = InfoPatchAllParams.none() + ): HttpResponseFor<OrganizationInfo> = patchAll(params, RequestOptions.none()) + + /** @see patchAll */ + @MustBeClosed + fun patchAll(requestOptions: RequestOptions): HttpResponseFor<OrganizationInfo> = + patchAll(InfoPatchAllParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/InfoServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/InfoServiceImpl.kt new file mode 100644 index 00000000..9b4edacb --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/InfoServiceImpl.kt @@ -0,0 +1,113 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.orgs.current.info.InfoListParams +import com.langsmith_api.api.models.api.v1.orgs.current.info.InfoPatchAllParams +import com.langsmith_api.api.models.api.v1.orgs.current.info.OrganizationInfo +import java.util.function.Consumer + +class InfoServiceImpl internal constructor(private val clientOptions: ClientOptions) : InfoService { + + private val withRawResponse: InfoService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): InfoService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): InfoService = + InfoServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list(params: InfoListParams, requestOptions: RequestOptions): OrganizationInfo = + // get /api/v1/orgs/current/info + withRawResponse().list(params, requestOptions).parse() + + override fun patchAll( + params: InfoPatchAllParams, + requestOptions: RequestOptions, + ): OrganizationInfo = + // patch /api/v1/orgs/current/info + withRawResponse().patchAll(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + InfoService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): InfoService.WithRawResponse = + InfoServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler<OrganizationInfo> = + jsonHandler<OrganizationInfo>(clientOptions.jsonMapper) + + override fun list( + params: InfoListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<OrganizationInfo> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "info") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val patchAllHandler: Handler<OrganizationInfo> = + jsonHandler<OrganizationInfo>(clientOptions.jsonMapper) + + override fun patchAll( + params: InfoPatchAllParams, + requestOptions: RequestOptions, + ): HttpResponseFor<OrganizationInfo> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "info") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { patchAllHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/MemberService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/MemberService.kt new file mode 100644 index 00000000..a3ebf744 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/MemberService.kt @@ -0,0 +1,379 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs.current + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberBatchParams +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberCreateParams +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberDeleteParams +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberDeleteResponse +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberListParams +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberListResponse +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberRetrieveActiveParams +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberUpdateParams +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberUpdateResponse +import com.langsmith_api.api.models.api.v1.orgs.current.members.OrgMemberIdentity +import com.langsmith_api.api.models.api.v1.orgs.current.members.PendingIdentity +import com.langsmith_api.api.models.api.v1.orgs.current.members.PendingIdentityCreate +import com.langsmith_api.api.services.blocking.api.v1.orgs.current.members.BasicService +import com.langsmith_api.api.services.blocking.api.v1.orgs.current.members.PendingService +import java.util.function.Consumer + +interface MemberService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): MemberService + + fun pending(): PendingService + + fun basic(): BasicService + + /** Add Member To Current Org */ + fun create(params: MemberCreateParams): PendingIdentity = create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: MemberCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): PendingIdentity + + /** @see create */ + fun create( + pendingIdentityCreate: PendingIdentityCreate, + requestOptions: RequestOptions = RequestOptions.none(), + ): PendingIdentity = + create( + MemberCreateParams.builder().pendingIdentityCreate(pendingIdentityCreate).build(), + requestOptions, + ) + + /** @see create */ + fun create(pendingIdentityCreate: PendingIdentityCreate): PendingIdentity = + create(pendingIdentityCreate, RequestOptions.none()) + + /** + * This is used for updating a user's role (all auth modes) or full_name/password (basic auth) + */ + fun update(identityId: String): MemberUpdateResponse = + update(identityId, MemberUpdateParams.none()) + + /** @see update */ + fun update( + identityId: String, + params: MemberUpdateParams = MemberUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): MemberUpdateResponse = + update(params.toBuilder().identityId(identityId).build(), requestOptions) + + /** @see update */ + fun update( + identityId: String, + params: MemberUpdateParams = MemberUpdateParams.none(), + ): MemberUpdateResponse = update(identityId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: MemberUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): MemberUpdateResponse + + /** @see update */ + fun update(params: MemberUpdateParams): MemberUpdateResponse = + update(params, RequestOptions.none()) + + /** @see update */ + fun update(identityId: String, requestOptions: RequestOptions): MemberUpdateResponse = + update(identityId, MemberUpdateParams.none(), requestOptions) + + /** Get Current Org Members */ + fun list(): MemberListResponse = list(MemberListParams.none()) + + /** @see list */ + fun list( + params: MemberListParams = MemberListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): MemberListResponse + + /** @see list */ + fun list(params: MemberListParams = MemberListParams.none()): MemberListResponse = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): MemberListResponse = + list(MemberListParams.none(), requestOptions) + + /** Remove a user from the current organization. */ + fun delete(identityId: String): MemberDeleteResponse = + delete(identityId, MemberDeleteParams.none()) + + /** @see delete */ + fun delete( + identityId: String, + params: MemberDeleteParams = MemberDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): MemberDeleteResponse = + delete(params.toBuilder().identityId(identityId).build(), requestOptions) + + /** @see delete */ + fun delete( + identityId: String, + params: MemberDeleteParams = MemberDeleteParams.none(), + ): MemberDeleteResponse = delete(identityId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: MemberDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): MemberDeleteResponse + + /** @see delete */ + fun delete(params: MemberDeleteParams): MemberDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(identityId: String, requestOptions: RequestOptions): MemberDeleteResponse = + delete(identityId, MemberDeleteParams.none(), requestOptions) + + /** Batch invite up to 500 users to the current org. */ + fun batch(params: MemberBatchParams): List<PendingIdentity> = + batch(params, RequestOptions.none()) + + /** @see batch */ + fun batch( + params: MemberBatchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List<PendingIdentity> + + /** Get Current Active Org Members */ + fun retrieveActive(): List<OrgMemberIdentity> = + retrieveActive(MemberRetrieveActiveParams.none()) + + /** @see retrieveActive */ + fun retrieveActive( + params: MemberRetrieveActiveParams = MemberRetrieveActiveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<OrgMemberIdentity> + + /** @see retrieveActive */ + fun retrieveActive( + params: MemberRetrieveActiveParams = MemberRetrieveActiveParams.none() + ): List<OrgMemberIdentity> = retrieveActive(params, RequestOptions.none()) + + /** @see retrieveActive */ + fun retrieveActive(requestOptions: RequestOptions): List<OrgMemberIdentity> = + retrieveActive(MemberRetrieveActiveParams.none(), requestOptions) + + /** A view of [MemberService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): MemberService.WithRawResponse + + fun pending(): PendingService.WithRawResponse + + fun basic(): BasicService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/orgs/current/members`, but is otherwise the + * same as [MemberService.create]. + */ + @MustBeClosed + fun create(params: MemberCreateParams): HttpResponseFor<PendingIdentity> = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: MemberCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<PendingIdentity> + + /** @see create */ + @MustBeClosed + fun create( + pendingIdentityCreate: PendingIdentityCreate, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<PendingIdentity> = + create( + MemberCreateParams.builder().pendingIdentityCreate(pendingIdentityCreate).build(), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create(pendingIdentityCreate: PendingIdentityCreate): HttpResponseFor<PendingIdentity> = + create(pendingIdentityCreate, RequestOptions.none()) + + /** + * Returns a raw HTTP response for `patch /api/v1/orgs/current/members/{identity_id}`, but + * is otherwise the same as [MemberService.update]. + */ + @MustBeClosed + fun update(identityId: String): HttpResponseFor<MemberUpdateResponse> = + update(identityId, MemberUpdateParams.none()) + + /** @see update */ + @MustBeClosed + fun update( + identityId: String, + params: MemberUpdateParams = MemberUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<MemberUpdateResponse> = + update(params.toBuilder().identityId(identityId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update( + identityId: String, + params: MemberUpdateParams = MemberUpdateParams.none(), + ): HttpResponseFor<MemberUpdateResponse> = update(identityId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: MemberUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<MemberUpdateResponse> + + /** @see update */ + @MustBeClosed + fun update(params: MemberUpdateParams): HttpResponseFor<MemberUpdateResponse> = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + identityId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<MemberUpdateResponse> = + update(identityId, MemberUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/orgs/current/members`, but is otherwise the + * same as [MemberService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor<MemberListResponse> = list(MemberListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: MemberListParams = MemberListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<MemberListResponse> + + /** @see list */ + @MustBeClosed + fun list( + params: MemberListParams = MemberListParams.none() + ): HttpResponseFor<MemberListResponse> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor<MemberListResponse> = + list(MemberListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/orgs/current/members/{identity_id}`, but + * is otherwise the same as [MemberService.delete]. + */ + @MustBeClosed + fun delete(identityId: String): HttpResponseFor<MemberDeleteResponse> = + delete(identityId, MemberDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + identityId: String, + params: MemberDeleteParams = MemberDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<MemberDeleteResponse> = + delete(params.toBuilder().identityId(identityId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + identityId: String, + params: MemberDeleteParams = MemberDeleteParams.none(), + ): HttpResponseFor<MemberDeleteResponse> = delete(identityId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: MemberDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<MemberDeleteResponse> + + /** @see delete */ + @MustBeClosed + fun delete(params: MemberDeleteParams): HttpResponseFor<MemberDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + identityId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<MemberDeleteResponse> = + delete(identityId, MemberDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/orgs/current/members/batch`, but is + * otherwise the same as [MemberService.batch]. + */ + @MustBeClosed + fun batch(params: MemberBatchParams): HttpResponseFor<List<PendingIdentity>> = + batch(params, RequestOptions.none()) + + /** @see batch */ + @MustBeClosed + fun batch( + params: MemberBatchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<PendingIdentity>> + + /** + * Returns a raw HTTP response for `get /api/v1/orgs/current/members/active`, but is + * otherwise the same as [MemberService.retrieveActive]. + */ + @MustBeClosed + fun retrieveActive(): HttpResponseFor<List<OrgMemberIdentity>> = + retrieveActive(MemberRetrieveActiveParams.none()) + + /** @see retrieveActive */ + @MustBeClosed + fun retrieveActive( + params: MemberRetrieveActiveParams = MemberRetrieveActiveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<OrgMemberIdentity>> + + /** @see retrieveActive */ + @MustBeClosed + fun retrieveActive( + params: MemberRetrieveActiveParams = MemberRetrieveActiveParams.none() + ): HttpResponseFor<List<OrgMemberIdentity>> = retrieveActive(params, RequestOptions.none()) + + /** @see retrieveActive */ + @MustBeClosed + fun retrieveActive( + requestOptions: RequestOptions + ): HttpResponseFor<List<OrgMemberIdentity>> = + retrieveActive(MemberRetrieveActiveParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/MemberServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/MemberServiceImpl.kt new file mode 100644 index 00000000..b432ceed --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/MemberServiceImpl.kt @@ -0,0 +1,310 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberBatchParams +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberCreateParams +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberDeleteParams +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberDeleteResponse +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberListParams +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberListResponse +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberRetrieveActiveParams +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberUpdateParams +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberUpdateResponse +import com.langsmith_api.api.models.api.v1.orgs.current.members.OrgMemberIdentity +import com.langsmith_api.api.models.api.v1.orgs.current.members.PendingIdentity +import com.langsmith_api.api.services.blocking.api.v1.orgs.current.members.BasicService +import com.langsmith_api.api.services.blocking.api.v1.orgs.current.members.BasicServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.orgs.current.members.PendingService +import com.langsmith_api.api.services.blocking.api.v1.orgs.current.members.PendingServiceImpl +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class MemberServiceImpl internal constructor(private val clientOptions: ClientOptions) : + MemberService { + + private val withRawResponse: MemberService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val pending: PendingService by lazy { PendingServiceImpl(clientOptions) } + + private val basic: BasicService by lazy { BasicServiceImpl(clientOptions) } + + override fun withRawResponse(): MemberService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): MemberService = + MemberServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun pending(): PendingService = pending + + override fun basic(): BasicService = basic + + override fun create( + params: MemberCreateParams, + requestOptions: RequestOptions, + ): PendingIdentity = + // post /api/v1/orgs/current/members + withRawResponse().create(params, requestOptions).parse() + + override fun update( + params: MemberUpdateParams, + requestOptions: RequestOptions, + ): MemberUpdateResponse = + // patch /api/v1/orgs/current/members/{identity_id} + withRawResponse().update(params, requestOptions).parse() + + override fun list( + params: MemberListParams, + requestOptions: RequestOptions, + ): MemberListResponse = + // get /api/v1/orgs/current/members + withRawResponse().list(params, requestOptions).parse() + + override fun delete( + params: MemberDeleteParams, + requestOptions: RequestOptions, + ): MemberDeleteResponse = + // delete /api/v1/orgs/current/members/{identity_id} + withRawResponse().delete(params, requestOptions).parse() + + override fun batch( + params: MemberBatchParams, + requestOptions: RequestOptions, + ): List<PendingIdentity> = + // post /api/v1/orgs/current/members/batch + withRawResponse().batch(params, requestOptions).parse() + + override fun retrieveActive( + params: MemberRetrieveActiveParams, + requestOptions: RequestOptions, + ): List<OrgMemberIdentity> = + // get /api/v1/orgs/current/members/active + withRawResponse().retrieveActive(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + MemberService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val pending: PendingService.WithRawResponse by lazy { + PendingServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val basic: BasicService.WithRawResponse by lazy { + BasicServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): MemberService.WithRawResponse = + MemberServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun pending(): PendingService.WithRawResponse = pending + + override fun basic(): BasicService.WithRawResponse = basic + + private val createHandler: Handler<PendingIdentity> = + jsonHandler<PendingIdentity>(clientOptions.jsonMapper) + + override fun create( + params: MemberCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<PendingIdentity> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "members") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler<MemberUpdateResponse> = + jsonHandler<MemberUpdateResponse>(clientOptions.jsonMapper) + + override fun update( + params: MemberUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<MemberUpdateResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("identityId", params.identityId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "orgs", + "current", + "members", + params._pathParam(0), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler<MemberListResponse> = + jsonHandler<MemberListResponse>(clientOptions.jsonMapper) + + override fun list( + params: MemberListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<MemberListResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "members") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val deleteHandler: Handler<MemberDeleteResponse> = + jsonHandler<MemberDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: MemberDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<MemberDeleteResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("identityId", params.identityId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "orgs", + "current", + "members", + params._pathParam(0), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val batchHandler: Handler<List<PendingIdentity>> = + jsonHandler<List<PendingIdentity>>(clientOptions.jsonMapper) + + override fun batch( + params: MemberBatchParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<PendingIdentity>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "members", "batch") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { batchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val retrieveActiveHandler: Handler<List<OrgMemberIdentity>> = + jsonHandler<List<OrgMemberIdentity>>(clientOptions.jsonMapper) + + override fun retrieveActive( + params: MemberRetrieveActiveParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<OrgMemberIdentity>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "members", "active") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveActiveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/PersonalAccessTokenService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/PersonalAccessTokenService.kt new file mode 100644 index 00000000..e9735480 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/PersonalAccessTokenService.kt @@ -0,0 +1,246 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs.current + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.orgs.current.personalaccesstokens.PersonalAccessTokenDeleteParams +import com.langsmith_api.api.models.api.v1.orgs.current.personalaccesstokens.PersonalAccessTokenPersonalAccessTokensParams +import com.langsmith_api.api.models.api.v1.orgs.current.personalaccesstokens.PersonalAccessTokenRetrievePersonalAccessTokensParams +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyCreateRequest +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyCreateResponse +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyGetResponse +import java.util.function.Consumer + +interface PersonalAccessTokenService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): PersonalAccessTokenService + + /** Delete Org Personal Access Token */ + fun delete(patId: String): ApiKeyGetResponse = + delete(patId, PersonalAccessTokenDeleteParams.none()) + + /** @see delete */ + fun delete( + patId: String, + params: PersonalAccessTokenDeleteParams = PersonalAccessTokenDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ApiKeyGetResponse = delete(params.toBuilder().patId(patId).build(), requestOptions) + + /** @see delete */ + fun delete( + patId: String, + params: PersonalAccessTokenDeleteParams = PersonalAccessTokenDeleteParams.none(), + ): ApiKeyGetResponse = delete(patId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: PersonalAccessTokenDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ApiKeyGetResponse + + /** @see delete */ + fun delete(params: PersonalAccessTokenDeleteParams): ApiKeyGetResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(patId: String, requestOptions: RequestOptions): ApiKeyGetResponse = + delete(patId, PersonalAccessTokenDeleteParams.none(), requestOptions) + + /** Create Org Personal Access Token */ + fun personalAccessTokens( + params: PersonalAccessTokenPersonalAccessTokensParams + ): ApiKeyCreateResponse = personalAccessTokens(params, RequestOptions.none()) + + /** @see personalAccessTokens */ + fun personalAccessTokens( + params: PersonalAccessTokenPersonalAccessTokensParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ApiKeyCreateResponse + + /** @see personalAccessTokens */ + fun personalAccessTokens( + apiKeyCreateRequest: ApiKeyCreateRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): ApiKeyCreateResponse = + personalAccessTokens( + PersonalAccessTokenPersonalAccessTokensParams.builder() + .apiKeyCreateRequest(apiKeyCreateRequest) + .build(), + requestOptions, + ) + + /** @see personalAccessTokens */ + fun personalAccessTokens(apiKeyCreateRequest: ApiKeyCreateRequest): ApiKeyCreateResponse = + personalAccessTokens(apiKeyCreateRequest, RequestOptions.none()) + + /** List Org Personal Access Tokens */ + fun retrievePersonalAccessTokens(): List<ApiKeyGetResponse> = + retrievePersonalAccessTokens(PersonalAccessTokenRetrievePersonalAccessTokensParams.none()) + + /** @see retrievePersonalAccessTokens */ + fun retrievePersonalAccessTokens( + params: PersonalAccessTokenRetrievePersonalAccessTokensParams = + PersonalAccessTokenRetrievePersonalAccessTokensParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<ApiKeyGetResponse> + + /** @see retrievePersonalAccessTokens */ + fun retrievePersonalAccessTokens( + params: PersonalAccessTokenRetrievePersonalAccessTokensParams = + PersonalAccessTokenRetrievePersonalAccessTokensParams.none() + ): List<ApiKeyGetResponse> = retrievePersonalAccessTokens(params, RequestOptions.none()) + + /** @see retrievePersonalAccessTokens */ + fun retrievePersonalAccessTokens(requestOptions: RequestOptions): List<ApiKeyGetResponse> = + retrievePersonalAccessTokens( + PersonalAccessTokenRetrievePersonalAccessTokensParams.none(), + requestOptions, + ) + + /** + * A view of [PersonalAccessTokenService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PersonalAccessTokenService.WithRawResponse + + /** + * Returns a raw HTTP response for `delete + * /api/v1/orgs/current/personal-access-tokens/{pat_id}`, but is otherwise the same as + * [PersonalAccessTokenService.delete]. + */ + @MustBeClosed + fun delete(patId: String): HttpResponseFor<ApiKeyGetResponse> = + delete(patId, PersonalAccessTokenDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + patId: String, + params: PersonalAccessTokenDeleteParams = PersonalAccessTokenDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ApiKeyGetResponse> = + delete(params.toBuilder().patId(patId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + patId: String, + params: PersonalAccessTokenDeleteParams = PersonalAccessTokenDeleteParams.none(), + ): HttpResponseFor<ApiKeyGetResponse> = delete(patId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: PersonalAccessTokenDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ApiKeyGetResponse> + + /** @see delete */ + @MustBeClosed + fun delete(params: PersonalAccessTokenDeleteParams): HttpResponseFor<ApiKeyGetResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + patId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<ApiKeyGetResponse> = + delete(patId, PersonalAccessTokenDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/orgs/current/personal-access-tokens`, but + * is otherwise the same as [PersonalAccessTokenService.personalAccessTokens]. + */ + @MustBeClosed + fun personalAccessTokens( + params: PersonalAccessTokenPersonalAccessTokensParams + ): HttpResponseFor<ApiKeyCreateResponse> = + personalAccessTokens(params, RequestOptions.none()) + + /** @see personalAccessTokens */ + @MustBeClosed + fun personalAccessTokens( + params: PersonalAccessTokenPersonalAccessTokensParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ApiKeyCreateResponse> + + /** @see personalAccessTokens */ + @MustBeClosed + fun personalAccessTokens( + apiKeyCreateRequest: ApiKeyCreateRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ApiKeyCreateResponse> = + personalAccessTokens( + PersonalAccessTokenPersonalAccessTokensParams.builder() + .apiKeyCreateRequest(apiKeyCreateRequest) + .build(), + requestOptions, + ) + + /** @see personalAccessTokens */ + @MustBeClosed + fun personalAccessTokens( + apiKeyCreateRequest: ApiKeyCreateRequest + ): HttpResponseFor<ApiKeyCreateResponse> = + personalAccessTokens(apiKeyCreateRequest, RequestOptions.none()) + + /** + * Returns a raw HTTP response for `get /api/v1/orgs/current/personal-access-tokens`, but is + * otherwise the same as [PersonalAccessTokenService.retrievePersonalAccessTokens]. + */ + @MustBeClosed + fun retrievePersonalAccessTokens(): HttpResponseFor<List<ApiKeyGetResponse>> = + retrievePersonalAccessTokens( + PersonalAccessTokenRetrievePersonalAccessTokensParams.none() + ) + + /** @see retrievePersonalAccessTokens */ + @MustBeClosed + fun retrievePersonalAccessTokens( + params: PersonalAccessTokenRetrievePersonalAccessTokensParams = + PersonalAccessTokenRetrievePersonalAccessTokensParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<ApiKeyGetResponse>> + + /** @see retrievePersonalAccessTokens */ + @MustBeClosed + fun retrievePersonalAccessTokens( + params: PersonalAccessTokenRetrievePersonalAccessTokensParams = + PersonalAccessTokenRetrievePersonalAccessTokensParams.none() + ): HttpResponseFor<List<ApiKeyGetResponse>> = + retrievePersonalAccessTokens(params, RequestOptions.none()) + + /** @see retrievePersonalAccessTokens */ + @MustBeClosed + fun retrievePersonalAccessTokens( + requestOptions: RequestOptions + ): HttpResponseFor<List<ApiKeyGetResponse>> = + retrievePersonalAccessTokens( + PersonalAccessTokenRetrievePersonalAccessTokensParams.none(), + requestOptions, + ) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/PersonalAccessTokenServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/PersonalAccessTokenServiceImpl.kt new file mode 100644 index 00000000..9be9406c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/PersonalAccessTokenServiceImpl.kt @@ -0,0 +1,168 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.orgs.current.personalaccesstokens.PersonalAccessTokenDeleteParams +import com.langsmith_api.api.models.api.v1.orgs.current.personalaccesstokens.PersonalAccessTokenPersonalAccessTokensParams +import com.langsmith_api.api.models.api.v1.orgs.current.personalaccesstokens.PersonalAccessTokenRetrievePersonalAccessTokensParams +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyCreateResponse +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyGetResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class PersonalAccessTokenServiceImpl +internal constructor(private val clientOptions: ClientOptions) : PersonalAccessTokenService { + + private val withRawResponse: PersonalAccessTokenService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): PersonalAccessTokenService.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PersonalAccessTokenService = + PersonalAccessTokenServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun delete( + params: PersonalAccessTokenDeleteParams, + requestOptions: RequestOptions, + ): ApiKeyGetResponse = + // delete /api/v1/orgs/current/personal-access-tokens/{pat_id} + withRawResponse().delete(params, requestOptions).parse() + + override fun personalAccessTokens( + params: PersonalAccessTokenPersonalAccessTokensParams, + requestOptions: RequestOptions, + ): ApiKeyCreateResponse = + // post /api/v1/orgs/current/personal-access-tokens + withRawResponse().personalAccessTokens(params, requestOptions).parse() + + override fun retrievePersonalAccessTokens( + params: PersonalAccessTokenRetrievePersonalAccessTokensParams, + requestOptions: RequestOptions, + ): List<ApiKeyGetResponse> = + // get /api/v1/orgs/current/personal-access-tokens + withRawResponse().retrievePersonalAccessTokens(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + PersonalAccessTokenService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PersonalAccessTokenService.WithRawResponse = + PersonalAccessTokenServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val deleteHandler: Handler<ApiKeyGetResponse> = + jsonHandler<ApiKeyGetResponse>(clientOptions.jsonMapper) + + override fun delete( + params: PersonalAccessTokenDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<ApiKeyGetResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("patId", params.patId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "orgs", + "current", + "personal-access-tokens", + params._pathParam(0), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val personalAccessTokensHandler: Handler<ApiKeyCreateResponse> = + jsonHandler<ApiKeyCreateResponse>(clientOptions.jsonMapper) + + override fun personalAccessTokens( + params: PersonalAccessTokenPersonalAccessTokensParams, + requestOptions: RequestOptions, + ): HttpResponseFor<ApiKeyCreateResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "personal-access-tokens") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { personalAccessTokensHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrievePersonalAccessTokensHandler: Handler<List<ApiKeyGetResponse>> = + jsonHandler<List<ApiKeyGetResponse>>(clientOptions.jsonMapper) + + override fun retrievePersonalAccessTokens( + params: PersonalAccessTokenRetrievePersonalAccessTokensParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<ApiKeyGetResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "personal-access-tokens") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrievePersonalAccessTokensHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/RoleService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/RoleService.kt new file mode 100644 index 00000000..c1fd91b7 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/RoleService.kt @@ -0,0 +1,218 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs.current + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.orgs.current.roles.Role +import com.langsmith_api.api.models.api.v1.orgs.current.roles.RoleCreateParams +import com.langsmith_api.api.models.api.v1.orgs.current.roles.RoleDeleteParams +import com.langsmith_api.api.models.api.v1.orgs.current.roles.RoleListParams +import com.langsmith_api.api.models.api.v1.orgs.current.roles.RoleUpdateParams +import java.util.function.Consumer + +interface RoleService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RoleService + + /** Create Organization Roles */ + fun create(params: RoleCreateParams): Role = create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: RoleCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Role + + /** Update Organization Roles */ + fun update(roleId: String, params: RoleUpdateParams): Role = + update(roleId, params, RequestOptions.none()) + + /** @see update */ + fun update( + roleId: String, + params: RoleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Role = update(params.toBuilder().roleId(roleId).build(), requestOptions) + + /** @see update */ + fun update(params: RoleUpdateParams): Role = update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: RoleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Role + + /** List Organization Roles */ + fun list(): List<Role> = list(RoleListParams.none()) + + /** @see list */ + fun list( + params: RoleListParams = RoleListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<Role> + + /** @see list */ + fun list(params: RoleListParams = RoleListParams.none()): List<Role> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): List<Role> = + list(RoleListParams.none(), requestOptions) + + /** Delete Organization Roles */ + fun delete(roleId: String): Role = delete(roleId, RoleDeleteParams.none()) + + /** @see delete */ + fun delete( + roleId: String, + params: RoleDeleteParams = RoleDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Role = delete(params.toBuilder().roleId(roleId).build(), requestOptions) + + /** @see delete */ + fun delete(roleId: String, params: RoleDeleteParams = RoleDeleteParams.none()): Role = + delete(roleId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: RoleDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Role + + /** @see delete */ + fun delete(params: RoleDeleteParams): Role = delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(roleId: String, requestOptions: RequestOptions): Role = + delete(roleId, RoleDeleteParams.none(), requestOptions) + + /** A view of [RoleService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RoleService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/orgs/current/roles`, but is otherwise the + * same as [RoleService.create]. + */ + @MustBeClosed + fun create(params: RoleCreateParams): HttpResponseFor<Role> = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: RoleCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<Role> + + /** + * Returns a raw HTTP response for `patch /api/v1/orgs/current/roles/{role_id}`, but is + * otherwise the same as [RoleService.update]. + */ + @MustBeClosed + fun update(roleId: String, params: RoleUpdateParams): HttpResponseFor<Role> = + update(roleId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + roleId: String, + params: RoleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<Role> = update(params.toBuilder().roleId(roleId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(params: RoleUpdateParams): HttpResponseFor<Role> = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: RoleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<Role> + + /** + * Returns a raw HTTP response for `get /api/v1/orgs/current/roles`, but is otherwise the + * same as [RoleService.list]. + */ + @MustBeClosed fun list(): HttpResponseFor<List<Role>> = list(RoleListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: RoleListParams = RoleListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<Role>> + + /** @see list */ + @MustBeClosed + fun list(params: RoleListParams = RoleListParams.none()): HttpResponseFor<List<Role>> = + list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor<List<Role>> = + list(RoleListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/orgs/current/roles/{role_id}`, but is + * otherwise the same as [RoleService.delete]. + */ + @MustBeClosed + fun delete(roleId: String): HttpResponseFor<Role> = delete(roleId, RoleDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + roleId: String, + params: RoleDeleteParams = RoleDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<Role> = delete(params.toBuilder().roleId(roleId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + roleId: String, + params: RoleDeleteParams = RoleDeleteParams.none(), + ): HttpResponseFor<Role> = delete(roleId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: RoleDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<Role> + + /** @see delete */ + @MustBeClosed + fun delete(params: RoleDeleteParams): HttpResponseFor<Role> = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete(roleId: String, requestOptions: RequestOptions): HttpResponseFor<Role> = + delete(roleId, RoleDeleteParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/RoleServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/RoleServiceImpl.kt new file mode 100644 index 00000000..faa33836 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/RoleServiceImpl.kt @@ -0,0 +1,181 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.orgs.current.roles.Role +import com.langsmith_api.api.models.api.v1.orgs.current.roles.RoleCreateParams +import com.langsmith_api.api.models.api.v1.orgs.current.roles.RoleDeleteParams +import com.langsmith_api.api.models.api.v1.orgs.current.roles.RoleListParams +import com.langsmith_api.api.models.api.v1.orgs.current.roles.RoleUpdateParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class RoleServiceImpl internal constructor(private val clientOptions: ClientOptions) : RoleService { + + private val withRawResponse: RoleService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): RoleService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): RoleService = + RoleServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create(params: RoleCreateParams, requestOptions: RequestOptions): Role = + // post /api/v1/orgs/current/roles + withRawResponse().create(params, requestOptions).parse() + + override fun update(params: RoleUpdateParams, requestOptions: RequestOptions): Role = + // patch /api/v1/orgs/current/roles/{role_id} + withRawResponse().update(params, requestOptions).parse() + + override fun list(params: RoleListParams, requestOptions: RequestOptions): List<Role> = + // get /api/v1/orgs/current/roles + withRawResponse().list(params, requestOptions).parse() + + override fun delete(params: RoleDeleteParams, requestOptions: RequestOptions): Role = + // delete /api/v1/orgs/current/roles/{role_id} + withRawResponse().delete(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RoleService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): RoleService.WithRawResponse = + RoleServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<Role> = jsonHandler<Role>(clientOptions.jsonMapper) + + override fun create( + params: RoleCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<Role> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "roles") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler<Role> = jsonHandler<Role>(clientOptions.jsonMapper) + + override fun update( + params: RoleUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<Role> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("roleId", params.roleId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "roles", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler<List<Role>> = + jsonHandler<List<Role>>(clientOptions.jsonMapper) + + override fun list( + params: RoleListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<Role>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "roles") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val deleteHandler: Handler<Role> = jsonHandler<Role>(clientOptions.jsonMapper) + + override fun delete( + params: RoleDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<Role> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("roleId", params.roleId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "roles", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/ServiceKeyService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/ServiceKeyService.kt new file mode 100644 index 00000000..a4332913 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/ServiceKeyService.kt @@ -0,0 +1,227 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs.current + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyCreateRequest +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyCreateResponse +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyGetResponse +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ServiceKeyDeleteParams +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ServiceKeyRetrieveServiceKeysParams +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ServiceKeyServiceKeysParams +import java.util.function.Consumer + +interface ServiceKeyService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ServiceKeyService + + /** Delete Org Service Key */ + fun delete(apiKeyId: String): ApiKeyGetResponse = + delete(apiKeyId, ServiceKeyDeleteParams.none()) + + /** @see delete */ + fun delete( + apiKeyId: String, + params: ServiceKeyDeleteParams = ServiceKeyDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ApiKeyGetResponse = delete(params.toBuilder().apiKeyId(apiKeyId).build(), requestOptions) + + /** @see delete */ + fun delete( + apiKeyId: String, + params: ServiceKeyDeleteParams = ServiceKeyDeleteParams.none(), + ): ApiKeyGetResponse = delete(apiKeyId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ServiceKeyDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ApiKeyGetResponse + + /** @see delete */ + fun delete(params: ServiceKeyDeleteParams): ApiKeyGetResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(apiKeyId: String, requestOptions: RequestOptions): ApiKeyGetResponse = + delete(apiKeyId, ServiceKeyDeleteParams.none(), requestOptions) + + /** List Org Service Keys */ + fun retrieveServiceKeys(): List<ApiKeyGetResponse> = + retrieveServiceKeys(ServiceKeyRetrieveServiceKeysParams.none()) + + /** @see retrieveServiceKeys */ + fun retrieveServiceKeys( + params: ServiceKeyRetrieveServiceKeysParams = ServiceKeyRetrieveServiceKeysParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<ApiKeyGetResponse> + + /** @see retrieveServiceKeys */ + fun retrieveServiceKeys( + params: ServiceKeyRetrieveServiceKeysParams = ServiceKeyRetrieveServiceKeysParams.none() + ): List<ApiKeyGetResponse> = retrieveServiceKeys(params, RequestOptions.none()) + + /** @see retrieveServiceKeys */ + fun retrieveServiceKeys(requestOptions: RequestOptions): List<ApiKeyGetResponse> = + retrieveServiceKeys(ServiceKeyRetrieveServiceKeysParams.none(), requestOptions) + + /** Create org-scoped service key. If workspaces is None, key is org-wide. */ + fun serviceKeys(params: ServiceKeyServiceKeysParams): ApiKeyCreateResponse = + serviceKeys(params, RequestOptions.none()) + + /** @see serviceKeys */ + fun serviceKeys( + params: ServiceKeyServiceKeysParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ApiKeyCreateResponse + + /** @see serviceKeys */ + fun serviceKeys( + apiKeyCreateRequest: ApiKeyCreateRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): ApiKeyCreateResponse = + serviceKeys( + ServiceKeyServiceKeysParams.builder().apiKeyCreateRequest(apiKeyCreateRequest).build(), + requestOptions, + ) + + /** @see serviceKeys */ + fun serviceKeys(apiKeyCreateRequest: ApiKeyCreateRequest): ApiKeyCreateResponse = + serviceKeys(apiKeyCreateRequest, RequestOptions.none()) + + /** A view of [ServiceKeyService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ServiceKeyService.WithRawResponse + + /** + * Returns a raw HTTP response for `delete /api/v1/orgs/current/service-keys/{api_key_id}`, + * but is otherwise the same as [ServiceKeyService.delete]. + */ + @MustBeClosed + fun delete(apiKeyId: String): HttpResponseFor<ApiKeyGetResponse> = + delete(apiKeyId, ServiceKeyDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + apiKeyId: String, + params: ServiceKeyDeleteParams = ServiceKeyDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ApiKeyGetResponse> = + delete(params.toBuilder().apiKeyId(apiKeyId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + apiKeyId: String, + params: ServiceKeyDeleteParams = ServiceKeyDeleteParams.none(), + ): HttpResponseFor<ApiKeyGetResponse> = delete(apiKeyId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: ServiceKeyDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ApiKeyGetResponse> + + /** @see delete */ + @MustBeClosed + fun delete(params: ServiceKeyDeleteParams): HttpResponseFor<ApiKeyGetResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + apiKeyId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<ApiKeyGetResponse> = + delete(apiKeyId, ServiceKeyDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/orgs/current/service-keys`, but is otherwise + * the same as [ServiceKeyService.retrieveServiceKeys]. + */ + @MustBeClosed + fun retrieveServiceKeys(): HttpResponseFor<List<ApiKeyGetResponse>> = + retrieveServiceKeys(ServiceKeyRetrieveServiceKeysParams.none()) + + /** @see retrieveServiceKeys */ + @MustBeClosed + fun retrieveServiceKeys( + params: ServiceKeyRetrieveServiceKeysParams = + ServiceKeyRetrieveServiceKeysParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<ApiKeyGetResponse>> + + /** @see retrieveServiceKeys */ + @MustBeClosed + fun retrieveServiceKeys( + params: ServiceKeyRetrieveServiceKeysParams = ServiceKeyRetrieveServiceKeysParams.none() + ): HttpResponseFor<List<ApiKeyGetResponse>> = + retrieveServiceKeys(params, RequestOptions.none()) + + /** @see retrieveServiceKeys */ + @MustBeClosed + fun retrieveServiceKeys( + requestOptions: RequestOptions + ): HttpResponseFor<List<ApiKeyGetResponse>> = + retrieveServiceKeys(ServiceKeyRetrieveServiceKeysParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/orgs/current/service-keys`, but is + * otherwise the same as [ServiceKeyService.serviceKeys]. + */ + @MustBeClosed + fun serviceKeys( + params: ServiceKeyServiceKeysParams + ): HttpResponseFor<ApiKeyCreateResponse> = serviceKeys(params, RequestOptions.none()) + + /** @see serviceKeys */ + @MustBeClosed + fun serviceKeys( + params: ServiceKeyServiceKeysParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ApiKeyCreateResponse> + + /** @see serviceKeys */ + @MustBeClosed + fun serviceKeys( + apiKeyCreateRequest: ApiKeyCreateRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ApiKeyCreateResponse> = + serviceKeys( + ServiceKeyServiceKeysParams.builder() + .apiKeyCreateRequest(apiKeyCreateRequest) + .build(), + requestOptions, + ) + + /** @see serviceKeys */ + @MustBeClosed + fun serviceKeys( + apiKeyCreateRequest: ApiKeyCreateRequest + ): HttpResponseFor<ApiKeyCreateResponse> = + serviceKeys(apiKeyCreateRequest, RequestOptions.none()) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/ServiceKeyServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/ServiceKeyServiceImpl.kt new file mode 100644 index 00000000..d40d7529 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/ServiceKeyServiceImpl.kt @@ -0,0 +1,166 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyCreateResponse +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyGetResponse +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ServiceKeyDeleteParams +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ServiceKeyRetrieveServiceKeysParams +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ServiceKeyServiceKeysParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ServiceKeyServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ServiceKeyService { + + private val withRawResponse: ServiceKeyService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ServiceKeyService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): ServiceKeyService = + ServiceKeyServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun delete( + params: ServiceKeyDeleteParams, + requestOptions: RequestOptions, + ): ApiKeyGetResponse = + // delete /api/v1/orgs/current/service-keys/{api_key_id} + withRawResponse().delete(params, requestOptions).parse() + + override fun retrieveServiceKeys( + params: ServiceKeyRetrieveServiceKeysParams, + requestOptions: RequestOptions, + ): List<ApiKeyGetResponse> = + // get /api/v1/orgs/current/service-keys + withRawResponse().retrieveServiceKeys(params, requestOptions).parse() + + override fun serviceKeys( + params: ServiceKeyServiceKeysParams, + requestOptions: RequestOptions, + ): ApiKeyCreateResponse = + // post /api/v1/orgs/current/service-keys + withRawResponse().serviceKeys(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ServiceKeyService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ServiceKeyService.WithRawResponse = + ServiceKeyServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val deleteHandler: Handler<ApiKeyGetResponse> = + jsonHandler<ApiKeyGetResponse>(clientOptions.jsonMapper) + + override fun delete( + params: ServiceKeyDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<ApiKeyGetResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("apiKeyId", params.apiKeyId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "orgs", + "current", + "service-keys", + params._pathParam(0), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveServiceKeysHandler: Handler<List<ApiKeyGetResponse>> = + jsonHandler<List<ApiKeyGetResponse>>(clientOptions.jsonMapper) + + override fun retrieveServiceKeys( + params: ServiceKeyRetrieveServiceKeysParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<ApiKeyGetResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "service-keys") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveServiceKeysHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val serviceKeysHandler: Handler<ApiKeyCreateResponse> = + jsonHandler<ApiKeyCreateResponse>(clientOptions.jsonMapper) + + override fun serviceKeys( + params: ServiceKeyServiceKeysParams, + requestOptions: RequestOptions, + ): HttpResponseFor<ApiKeyCreateResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "service-keys") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { serviceKeysHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/SsoSettingService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/SsoSettingService.kt new file mode 100644 index 00000000..e97a41a8 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/SsoSettingService.kt @@ -0,0 +1,253 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs.current + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.orgs.current.ssosettings.SsoProvider +import com.langsmith_api.api.models.api.v1.orgs.current.ssosettings.SsoSettingDeleteParams +import com.langsmith_api.api.models.api.v1.orgs.current.ssosettings.SsoSettingRetrieveSsoSettingsParams +import com.langsmith_api.api.models.api.v1.orgs.current.ssosettings.SsoSettingSsoSettingsParams +import com.langsmith_api.api.models.api.v1.orgs.current.ssosettings.SsoSettingUpdateParams +import java.util.function.Consumer + +interface SsoSettingService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): SsoSettingService + + /** Update SSO provider settings defaults for the current organization. */ + fun update(id: String): SsoProvider = update(id, SsoSettingUpdateParams.none()) + + /** @see update */ + fun update( + id: String, + params: SsoSettingUpdateParams = SsoSettingUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): SsoProvider = update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + fun update( + id: String, + params: SsoSettingUpdateParams = SsoSettingUpdateParams.none(), + ): SsoProvider = update(id, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: SsoSettingUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SsoProvider + + /** @see update */ + fun update(params: SsoSettingUpdateParams): SsoProvider = update(params, RequestOptions.none()) + + /** @see update */ + fun update(id: String, requestOptions: RequestOptions): SsoProvider = + update(id, SsoSettingUpdateParams.none(), requestOptions) + + /** Delete SSO provider settings for the current organization. */ + fun delete(id: String): SsoProvider = delete(id, SsoSettingDeleteParams.none()) + + /** @see delete */ + fun delete( + id: String, + params: SsoSettingDeleteParams = SsoSettingDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): SsoProvider = delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + fun delete( + id: String, + params: SsoSettingDeleteParams = SsoSettingDeleteParams.none(), + ): SsoProvider = delete(id, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: SsoSettingDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SsoProvider + + /** @see delete */ + fun delete(params: SsoSettingDeleteParams): SsoProvider = delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(id: String, requestOptions: RequestOptions): SsoProvider = + delete(id, SsoSettingDeleteParams.none(), requestOptions) + + /** Get SSO provider settings for the current organization. */ + fun retrieveSsoSettings(): List<SsoProvider> = + retrieveSsoSettings(SsoSettingRetrieveSsoSettingsParams.none()) + + /** @see retrieveSsoSettings */ + fun retrieveSsoSettings( + params: SsoSettingRetrieveSsoSettingsParams = SsoSettingRetrieveSsoSettingsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<SsoProvider> + + /** @see retrieveSsoSettings */ + fun retrieveSsoSettings( + params: SsoSettingRetrieveSsoSettingsParams = SsoSettingRetrieveSsoSettingsParams.none() + ): List<SsoProvider> = retrieveSsoSettings(params, RequestOptions.none()) + + /** @see retrieveSsoSettings */ + fun retrieveSsoSettings(requestOptions: RequestOptions): List<SsoProvider> = + retrieveSsoSettings(SsoSettingRetrieveSsoSettingsParams.none(), requestOptions) + + /** Create SSO provider settings for the current organization. */ + fun ssoSettings(params: SsoSettingSsoSettingsParams): SsoProvider = + ssoSettings(params, RequestOptions.none()) + + /** @see ssoSettings */ + fun ssoSettings( + params: SsoSettingSsoSettingsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SsoProvider + + /** A view of [SsoSettingService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): SsoSettingService.WithRawResponse + + /** + * Returns a raw HTTP response for `patch /api/v1/orgs/current/sso-settings/{id}`, but is + * otherwise the same as [SsoSettingService.update]. + */ + @MustBeClosed + fun update(id: String): HttpResponseFor<SsoProvider> = + update(id, SsoSettingUpdateParams.none()) + + /** @see update */ + @MustBeClosed + fun update( + id: String, + params: SsoSettingUpdateParams = SsoSettingUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<SsoProvider> = update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update( + id: String, + params: SsoSettingUpdateParams = SsoSettingUpdateParams.none(), + ): HttpResponseFor<SsoProvider> = update(id, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: SsoSettingUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<SsoProvider> + + /** @see update */ + @MustBeClosed + fun update(params: SsoSettingUpdateParams): HttpResponseFor<SsoProvider> = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update(id: String, requestOptions: RequestOptions): HttpResponseFor<SsoProvider> = + update(id, SsoSettingUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/orgs/current/sso-settings/{id}`, but is + * otherwise the same as [SsoSettingService.delete]. + */ + @MustBeClosed + fun delete(id: String): HttpResponseFor<SsoProvider> = + delete(id, SsoSettingDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + id: String, + params: SsoSettingDeleteParams = SsoSettingDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<SsoProvider> = delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + id: String, + params: SsoSettingDeleteParams = SsoSettingDeleteParams.none(), + ): HttpResponseFor<SsoProvider> = delete(id, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: SsoSettingDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<SsoProvider> + + /** @see delete */ + @MustBeClosed + fun delete(params: SsoSettingDeleteParams): HttpResponseFor<SsoProvider> = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete(id: String, requestOptions: RequestOptions): HttpResponseFor<SsoProvider> = + delete(id, SsoSettingDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/orgs/current/sso-settings`, but is otherwise + * the same as [SsoSettingService.retrieveSsoSettings]. + */ + @MustBeClosed + fun retrieveSsoSettings(): HttpResponseFor<List<SsoProvider>> = + retrieveSsoSettings(SsoSettingRetrieveSsoSettingsParams.none()) + + /** @see retrieveSsoSettings */ + @MustBeClosed + fun retrieveSsoSettings( + params: SsoSettingRetrieveSsoSettingsParams = + SsoSettingRetrieveSsoSettingsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<SsoProvider>> + + /** @see retrieveSsoSettings */ + @MustBeClosed + fun retrieveSsoSettings( + params: SsoSettingRetrieveSsoSettingsParams = SsoSettingRetrieveSsoSettingsParams.none() + ): HttpResponseFor<List<SsoProvider>> = retrieveSsoSettings(params, RequestOptions.none()) + + /** @see retrieveSsoSettings */ + @MustBeClosed + fun retrieveSsoSettings( + requestOptions: RequestOptions + ): HttpResponseFor<List<SsoProvider>> = + retrieveSsoSettings(SsoSettingRetrieveSsoSettingsParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/orgs/current/sso-settings`, but is + * otherwise the same as [SsoSettingService.ssoSettings]. + */ + @MustBeClosed + fun ssoSettings(params: SsoSettingSsoSettingsParams): HttpResponseFor<SsoProvider> = + ssoSettings(params, RequestOptions.none()) + + /** @see ssoSettings */ + @MustBeClosed + fun ssoSettings( + params: SsoSettingSsoSettingsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<SsoProvider> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/SsoSettingServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/SsoSettingServiceImpl.kt new file mode 100644 index 00000000..3fc1fe8b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/SsoSettingServiceImpl.kt @@ -0,0 +1,211 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.orgs.current.ssosettings.SsoProvider +import com.langsmith_api.api.models.api.v1.orgs.current.ssosettings.SsoSettingDeleteParams +import com.langsmith_api.api.models.api.v1.orgs.current.ssosettings.SsoSettingRetrieveSsoSettingsParams +import com.langsmith_api.api.models.api.v1.orgs.current.ssosettings.SsoSettingSsoSettingsParams +import com.langsmith_api.api.models.api.v1.orgs.current.ssosettings.SsoSettingUpdateParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class SsoSettingServiceImpl internal constructor(private val clientOptions: ClientOptions) : + SsoSettingService { + + private val withRawResponse: SsoSettingService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): SsoSettingService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): SsoSettingService = + SsoSettingServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun update( + params: SsoSettingUpdateParams, + requestOptions: RequestOptions, + ): SsoProvider = + // patch /api/v1/orgs/current/sso-settings/{id} + withRawResponse().update(params, requestOptions).parse() + + override fun delete( + params: SsoSettingDeleteParams, + requestOptions: RequestOptions, + ): SsoProvider = + // delete /api/v1/orgs/current/sso-settings/{id} + withRawResponse().delete(params, requestOptions).parse() + + override fun retrieveSsoSettings( + params: SsoSettingRetrieveSsoSettingsParams, + requestOptions: RequestOptions, + ): List<SsoProvider> = + // get /api/v1/orgs/current/sso-settings + withRawResponse().retrieveSsoSettings(params, requestOptions).parse() + + override fun ssoSettings( + params: SsoSettingSsoSettingsParams, + requestOptions: RequestOptions, + ): SsoProvider = + // post /api/v1/orgs/current/sso-settings + withRawResponse().ssoSettings(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SsoSettingService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): SsoSettingService.WithRawResponse = + SsoSettingServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val updateHandler: Handler<SsoProvider> = + jsonHandler<SsoProvider>(clientOptions.jsonMapper) + + override fun update( + params: SsoSettingUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<SsoProvider> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "orgs", + "current", + "sso-settings", + params._pathParam(0), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val deleteHandler: Handler<SsoProvider> = + jsonHandler<SsoProvider>(clientOptions.jsonMapper) + + override fun delete( + params: SsoSettingDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<SsoProvider> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "orgs", + "current", + "sso-settings", + params._pathParam(0), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveSsoSettingsHandler: Handler<List<SsoProvider>> = + jsonHandler<List<SsoProvider>>(clientOptions.jsonMapper) + + override fun retrieveSsoSettings( + params: SsoSettingRetrieveSsoSettingsParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<SsoProvider>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "sso-settings") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveSsoSettingsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val ssoSettingsHandler: Handler<SsoProvider> = + jsonHandler<SsoProvider>(clientOptions.jsonMapper) + + override fun ssoSettings( + params: SsoSettingSsoSettingsParams, + requestOptions: RequestOptions, + ): HttpResponseFor<SsoProvider> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "sso-settings") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { ssoSettingsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/UserService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/UserService.kt new file mode 100644 index 00000000..59e02310 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/UserService.kt @@ -0,0 +1,85 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs.current + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.orgs.current.user.ProviderUserSlim +import com.langsmith_api.api.models.api.v1.orgs.current.user.UserRetrieveLoginMethodsParams +import java.util.function.Consumer + +interface UserService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): UserService + + /** Get login methods for the current user. */ + fun retrieveLoginMethods(): List<ProviderUserSlim> = + retrieveLoginMethods(UserRetrieveLoginMethodsParams.none()) + + /** @see retrieveLoginMethods */ + fun retrieveLoginMethods( + params: UserRetrieveLoginMethodsParams = UserRetrieveLoginMethodsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<ProviderUserSlim> + + /** @see retrieveLoginMethods */ + fun retrieveLoginMethods( + params: UserRetrieveLoginMethodsParams = UserRetrieveLoginMethodsParams.none() + ): List<ProviderUserSlim> = retrieveLoginMethods(params, RequestOptions.none()) + + /** @see retrieveLoginMethods */ + fun retrieveLoginMethods(requestOptions: RequestOptions): List<ProviderUserSlim> = + retrieveLoginMethods(UserRetrieveLoginMethodsParams.none(), requestOptions) + + /** A view of [UserService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): UserService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/orgs/current/user/login-methods`, but is + * otherwise the same as [UserService.retrieveLoginMethods]. + */ + @MustBeClosed + fun retrieveLoginMethods(): HttpResponseFor<List<ProviderUserSlim>> = + retrieveLoginMethods(UserRetrieveLoginMethodsParams.none()) + + /** @see retrieveLoginMethods */ + @MustBeClosed + fun retrieveLoginMethods( + params: UserRetrieveLoginMethodsParams = UserRetrieveLoginMethodsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<ProviderUserSlim>> + + /** @see retrieveLoginMethods */ + @MustBeClosed + fun retrieveLoginMethods( + params: UserRetrieveLoginMethodsParams = UserRetrieveLoginMethodsParams.none() + ): HttpResponseFor<List<ProviderUserSlim>> = + retrieveLoginMethods(params, RequestOptions.none()) + + /** @see retrieveLoginMethods */ + @MustBeClosed + fun retrieveLoginMethods( + requestOptions: RequestOptions + ): HttpResponseFor<List<ProviderUserSlim>> = + retrieveLoginMethods(UserRetrieveLoginMethodsParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/UserServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/UserServiceImpl.kt new file mode 100644 index 00000000..ec599acf --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/UserServiceImpl.kt @@ -0,0 +1,79 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.orgs.current.user.ProviderUserSlim +import com.langsmith_api.api.models.api.v1.orgs.current.user.UserRetrieveLoginMethodsParams +import java.util.function.Consumer + +class UserServiceImpl internal constructor(private val clientOptions: ClientOptions) : UserService { + + private val withRawResponse: UserService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): UserService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): UserService = + UserServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieveLoginMethods( + params: UserRetrieveLoginMethodsParams, + requestOptions: RequestOptions, + ): List<ProviderUserSlim> = + // get /api/v1/orgs/current/user/login-methods + withRawResponse().retrieveLoginMethods(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + UserService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): UserService.WithRawResponse = + UserServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveLoginMethodsHandler: Handler<List<ProviderUserSlim>> = + jsonHandler<List<ProviderUserSlim>>(clientOptions.jsonMapper) + + override fun retrieveLoginMethods( + params: UserRetrieveLoginMethodsParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<ProviderUserSlim>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "user", "login-methods") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveLoginMethodsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/members/BasicService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/members/BasicService.kt new file mode 100644 index 00000000..62327994 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/members/BasicService.kt @@ -0,0 +1,62 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs.current.members + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.orgs.current.members.basic.BasicBatchParams +import com.langsmith_api.api.models.api.v1.orgs.current.members.basic.BasicBatchResponse +import java.util.function.Consumer + +interface BasicService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): BasicService + + /** Batch add up to 500 users to the org and specified workspaces in basic auth mode. */ + fun batch(params: BasicBatchParams): List<BasicBatchResponse> = + batch(params, RequestOptions.none()) + + /** @see batch */ + fun batch( + params: BasicBatchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List<BasicBatchResponse> + + /** A view of [BasicService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): BasicService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/orgs/current/members/basic/batch`, but is + * otherwise the same as [BasicService.batch]. + */ + @MustBeClosed + fun batch(params: BasicBatchParams): HttpResponseFor<List<BasicBatchResponse>> = + batch(params, RequestOptions.none()) + + /** @see batch */ + @MustBeClosed + fun batch( + params: BasicBatchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<BasicBatchResponse>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/members/BasicServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/members/BasicServiceImpl.kt new file mode 100644 index 00000000..97fdc5d1 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/members/BasicServiceImpl.kt @@ -0,0 +1,82 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs.current.members + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.orgs.current.members.basic.BasicBatchParams +import com.langsmith_api.api.models.api.v1.orgs.current.members.basic.BasicBatchResponse +import java.util.function.Consumer + +class BasicServiceImpl internal constructor(private val clientOptions: ClientOptions) : + BasicService { + + private val withRawResponse: BasicService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): BasicService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): BasicService = + BasicServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun batch( + params: BasicBatchParams, + requestOptions: RequestOptions, + ): List<BasicBatchResponse> = + // post /api/v1/orgs/current/members/basic/batch + withRawResponse().batch(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BasicService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): BasicService.WithRawResponse = + BasicServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val batchHandler: Handler<List<BasicBatchResponse>> = + jsonHandler<List<BasicBatchResponse>>(clientOptions.jsonMapper) + + override fun batch( + params: BasicBatchParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<BasicBatchResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "members", "basic", "batch") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { batchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/members/PendingService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/members/PendingService.kt new file mode 100644 index 00000000..9ee5c72d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/members/PendingService.kt @@ -0,0 +1,159 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs.current.members + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.orgs.current.members.pending.OrgPendingIdentity +import com.langsmith_api.api.models.api.v1.orgs.current.members.pending.PendingDeleteAllParams +import com.langsmith_api.api.models.api.v1.orgs.current.members.pending.PendingDeleteAllResponse +import com.langsmith_api.api.models.api.v1.orgs.current.members.pending.PendingListParams +import java.util.function.Consumer + +interface PendingService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): PendingService + + /** Get Current Pending Org Members */ + fun list(): List<OrgPendingIdentity> = list(PendingListParams.none()) + + /** @see list */ + fun list( + params: PendingListParams = PendingListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<OrgPendingIdentity> + + /** @see list */ + fun list(params: PendingListParams = PendingListParams.none()): List<OrgPendingIdentity> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): List<OrgPendingIdentity> = + list(PendingListParams.none(), requestOptions) + + /** When an admin deletes a pending member invite. */ + fun deleteAll(identityId: String): PendingDeleteAllResponse = + deleteAll(identityId, PendingDeleteAllParams.none()) + + /** @see deleteAll */ + fun deleteAll( + identityId: String, + params: PendingDeleteAllParams = PendingDeleteAllParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): PendingDeleteAllResponse = + deleteAll(params.toBuilder().identityId(identityId).build(), requestOptions) + + /** @see deleteAll */ + fun deleteAll( + identityId: String, + params: PendingDeleteAllParams = PendingDeleteAllParams.none(), + ): PendingDeleteAllResponse = deleteAll(identityId, params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + params: PendingDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): PendingDeleteAllResponse + + /** @see deleteAll */ + fun deleteAll(params: PendingDeleteAllParams): PendingDeleteAllResponse = + deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll(identityId: String, requestOptions: RequestOptions): PendingDeleteAllResponse = + deleteAll(identityId, PendingDeleteAllParams.none(), requestOptions) + + /** A view of [PendingService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): PendingService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/orgs/current/members/pending`, but is + * otherwise the same as [PendingService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor<List<OrgPendingIdentity>> = list(PendingListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: PendingListParams = PendingListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<OrgPendingIdentity>> + + /** @see list */ + @MustBeClosed + fun list( + params: PendingListParams = PendingListParams.none() + ): HttpResponseFor<List<OrgPendingIdentity>> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor<List<OrgPendingIdentity>> = + list(PendingListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete + * /api/v1/orgs/current/members/{identity_id}/pending`, but is otherwise the same as + * [PendingService.deleteAll]. + */ + @MustBeClosed + fun deleteAll(identityId: String): HttpResponseFor<PendingDeleteAllResponse> = + deleteAll(identityId, PendingDeleteAllParams.none()) + + /** @see deleteAll */ + @MustBeClosed + fun deleteAll( + identityId: String, + params: PendingDeleteAllParams = PendingDeleteAllParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<PendingDeleteAllResponse> = + deleteAll(params.toBuilder().identityId(identityId).build(), requestOptions) + + /** @see deleteAll */ + @MustBeClosed + fun deleteAll( + identityId: String, + params: PendingDeleteAllParams = PendingDeleteAllParams.none(), + ): HttpResponseFor<PendingDeleteAllResponse> = + deleteAll(identityId, params, RequestOptions.none()) + + /** @see deleteAll */ + @MustBeClosed + fun deleteAll( + params: PendingDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<PendingDeleteAllResponse> + + /** @see deleteAll */ + @MustBeClosed + fun deleteAll(params: PendingDeleteAllParams): HttpResponseFor<PendingDeleteAllResponse> = + deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + @MustBeClosed + fun deleteAll( + identityId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<PendingDeleteAllResponse> = + deleteAll(identityId, PendingDeleteAllParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/members/PendingServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/members/PendingServiceImpl.kt new file mode 100644 index 00000000..599db225 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/members/PendingServiceImpl.kt @@ -0,0 +1,131 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs.current.members + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.orgs.current.members.pending.OrgPendingIdentity +import com.langsmith_api.api.models.api.v1.orgs.current.members.pending.PendingDeleteAllParams +import com.langsmith_api.api.models.api.v1.orgs.current.members.pending.PendingDeleteAllResponse +import com.langsmith_api.api.models.api.v1.orgs.current.members.pending.PendingListParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class PendingServiceImpl internal constructor(private val clientOptions: ClientOptions) : + PendingService { + + private val withRawResponse: PendingService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): PendingService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): PendingService = + PendingServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: PendingListParams, + requestOptions: RequestOptions, + ): List<OrgPendingIdentity> = + // get /api/v1/orgs/current/members/pending + withRawResponse().list(params, requestOptions).parse() + + override fun deleteAll( + params: PendingDeleteAllParams, + requestOptions: RequestOptions, + ): PendingDeleteAllResponse = + // delete /api/v1/orgs/current/members/{identity_id}/pending + withRawResponse().deleteAll(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + PendingService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PendingService.WithRawResponse = + PendingServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler<List<OrgPendingIdentity>> = + jsonHandler<List<OrgPendingIdentity>>(clientOptions.jsonMapper) + + override fun list( + params: PendingListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<OrgPendingIdentity>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "orgs", "current", "members", "pending") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val deleteAllHandler: Handler<PendingDeleteAllResponse> = + jsonHandler<PendingDeleteAllResponse>(clientOptions.jsonMapper) + + override fun deleteAll( + params: PendingDeleteAllParams, + requestOptions: RequestOptions, + ): HttpResponseFor<PendingDeleteAllResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("identityId", params.identityId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "orgs", + "current", + "members", + params._pathParam(0), + "pending", + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteAllHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/DatasetService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/DatasetService.kt new file mode 100644 index 00000000..c58c2e83 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/DatasetService.kt @@ -0,0 +1,391 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.public_ + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.feedback.FeedbackSchema +import com.langsmith_api.api.models.api.v1.public_.datasets.DatasetListParams +import com.langsmith_api.api.models.api.v1.public_.datasets.DatasetListResponse +import com.langsmith_api.api.models.api.v1.public_.datasets.DatasetRetrieveComparativeParams +import com.langsmith_api.api.models.api.v1.public_.datasets.DatasetRetrieveComparativeResponse +import com.langsmith_api.api.models.api.v1.public_.datasets.DatasetRetrieveFeedbackParams +import com.langsmith_api.api.models.api.v1.public_.datasets.DatasetRetrieveSessionsBulkParams +import com.langsmith_api.api.models.api.v1.public_.datasets.DatasetRetrieveSessionsParams +import com.langsmith_api.api.models.api.v1.sessions.TracerSession +import com.langsmith_api.api.services.blocking.api.v1.public_.datasets.RunService +import java.util.function.Consumer + +interface DatasetService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): DatasetService + + fun runs(): RunService + + /** Get dataset by ids or the shared dataset if not specifed. */ + fun list(shareToken: String): DatasetListResponse = list(shareToken, DatasetListParams.none()) + + /** @see list */ + fun list( + shareToken: String, + params: DatasetListParams = DatasetListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): DatasetListResponse = list(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see list */ + fun list( + shareToken: String, + params: DatasetListParams = DatasetListParams.none(), + ): DatasetListResponse = list(shareToken, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: DatasetListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): DatasetListResponse + + /** @see list */ + fun list(params: DatasetListParams): DatasetListResponse = list(params, RequestOptions.none()) + + /** @see list */ + fun list(shareToken: String, requestOptions: RequestOptions): DatasetListResponse = + list(shareToken, DatasetListParams.none(), requestOptions) + + /** Get all comparative experiments for a given dataset. */ + fun retrieveComparative(shareToken: String): List<DatasetRetrieveComparativeResponse> = + retrieveComparative(shareToken, DatasetRetrieveComparativeParams.none()) + + /** @see retrieveComparative */ + fun retrieveComparative( + shareToken: String, + params: DatasetRetrieveComparativeParams = DatasetRetrieveComparativeParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<DatasetRetrieveComparativeResponse> = + retrieveComparative(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see retrieveComparative */ + fun retrieveComparative( + shareToken: String, + params: DatasetRetrieveComparativeParams = DatasetRetrieveComparativeParams.none(), + ): List<DatasetRetrieveComparativeResponse> = + retrieveComparative(shareToken, params, RequestOptions.none()) + + /** @see retrieveComparative */ + fun retrieveComparative( + params: DatasetRetrieveComparativeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List<DatasetRetrieveComparativeResponse> + + /** @see retrieveComparative */ + fun retrieveComparative( + params: DatasetRetrieveComparativeParams + ): List<DatasetRetrieveComparativeResponse> = retrieveComparative(params, RequestOptions.none()) + + /** @see retrieveComparative */ + fun retrieveComparative( + shareToken: String, + requestOptions: RequestOptions, + ): List<DatasetRetrieveComparativeResponse> = + retrieveComparative(shareToken, DatasetRetrieveComparativeParams.none(), requestOptions) + + /** Get feedback for runs in projects run over a dataset that has been shared. */ + fun retrieveFeedback(shareToken: String): List<FeedbackSchema> = + retrieveFeedback(shareToken, DatasetRetrieveFeedbackParams.none()) + + /** @see retrieveFeedback */ + fun retrieveFeedback( + shareToken: String, + params: DatasetRetrieveFeedbackParams = DatasetRetrieveFeedbackParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<FeedbackSchema> = + retrieveFeedback(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see retrieveFeedback */ + fun retrieveFeedback( + shareToken: String, + params: DatasetRetrieveFeedbackParams = DatasetRetrieveFeedbackParams.none(), + ): List<FeedbackSchema> = retrieveFeedback(shareToken, params, RequestOptions.none()) + + /** @see retrieveFeedback */ + fun retrieveFeedback( + params: DatasetRetrieveFeedbackParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List<FeedbackSchema> + + /** @see retrieveFeedback */ + fun retrieveFeedback(params: DatasetRetrieveFeedbackParams): List<FeedbackSchema> = + retrieveFeedback(params, RequestOptions.none()) + + /** @see retrieveFeedback */ + fun retrieveFeedback(shareToken: String, requestOptions: RequestOptions): List<FeedbackSchema> = + retrieveFeedback(shareToken, DatasetRetrieveFeedbackParams.none(), requestOptions) + + /** Get projects run on a dataset that has been shared. */ + fun retrieveSessions(shareToken: String): List<TracerSession> = + retrieveSessions(shareToken, DatasetRetrieveSessionsParams.none()) + + /** @see retrieveSessions */ + fun retrieveSessions( + shareToken: String, + params: DatasetRetrieveSessionsParams = DatasetRetrieveSessionsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<TracerSession> = + retrieveSessions(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see retrieveSessions */ + fun retrieveSessions( + shareToken: String, + params: DatasetRetrieveSessionsParams = DatasetRetrieveSessionsParams.none(), + ): List<TracerSession> = retrieveSessions(shareToken, params, RequestOptions.none()) + + /** @see retrieveSessions */ + fun retrieveSessions( + params: DatasetRetrieveSessionsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List<TracerSession> + + /** @see retrieveSessions */ + fun retrieveSessions(params: DatasetRetrieveSessionsParams): List<TracerSession> = + retrieveSessions(params, RequestOptions.none()) + + /** @see retrieveSessions */ + fun retrieveSessions(shareToken: String, requestOptions: RequestOptions): List<TracerSession> = + retrieveSessions(shareToken, DatasetRetrieveSessionsParams.none(), requestOptions) + + /** Get sessions from multiple datasets using share tokens. */ + fun retrieveSessionsBulk(params: DatasetRetrieveSessionsBulkParams): List<TracerSession> = + retrieveSessionsBulk(params, RequestOptions.none()) + + /** @see retrieveSessionsBulk */ + fun retrieveSessionsBulk( + params: DatasetRetrieveSessionsBulkParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List<TracerSession> + + /** A view of [DatasetService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): DatasetService.WithRawResponse + + fun runs(): RunService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/public/{share_token}/datasets`, but is + * otherwise the same as [DatasetService.list]. + */ + @MustBeClosed + fun list(shareToken: String): HttpResponseFor<DatasetListResponse> = + list(shareToken, DatasetListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + shareToken: String, + params: DatasetListParams = DatasetListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<DatasetListResponse> = + list(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see list */ + @MustBeClosed + fun list( + shareToken: String, + params: DatasetListParams = DatasetListParams.none(), + ): HttpResponseFor<DatasetListResponse> = list(shareToken, params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: DatasetListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<DatasetListResponse> + + /** @see list */ + @MustBeClosed + fun list(params: DatasetListParams): HttpResponseFor<DatasetListResponse> = + list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + shareToken: String, + requestOptions: RequestOptions, + ): HttpResponseFor<DatasetListResponse> = + list(shareToken, DatasetListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/public/{share_token}/datasets/comparative`, + * but is otherwise the same as [DatasetService.retrieveComparative]. + */ + @MustBeClosed + fun retrieveComparative( + shareToken: String + ): HttpResponseFor<List<DatasetRetrieveComparativeResponse>> = + retrieveComparative(shareToken, DatasetRetrieveComparativeParams.none()) + + /** @see retrieveComparative */ + @MustBeClosed + fun retrieveComparative( + shareToken: String, + params: DatasetRetrieveComparativeParams = DatasetRetrieveComparativeParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<DatasetRetrieveComparativeResponse>> = + retrieveComparative(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see retrieveComparative */ + @MustBeClosed + fun retrieveComparative( + shareToken: String, + params: DatasetRetrieveComparativeParams = DatasetRetrieveComparativeParams.none(), + ): HttpResponseFor<List<DatasetRetrieveComparativeResponse>> = + retrieveComparative(shareToken, params, RequestOptions.none()) + + /** @see retrieveComparative */ + @MustBeClosed + fun retrieveComparative( + params: DatasetRetrieveComparativeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<DatasetRetrieveComparativeResponse>> + + /** @see retrieveComparative */ + @MustBeClosed + fun retrieveComparative( + params: DatasetRetrieveComparativeParams + ): HttpResponseFor<List<DatasetRetrieveComparativeResponse>> = + retrieveComparative(params, RequestOptions.none()) + + /** @see retrieveComparative */ + @MustBeClosed + fun retrieveComparative( + shareToken: String, + requestOptions: RequestOptions, + ): HttpResponseFor<List<DatasetRetrieveComparativeResponse>> = + retrieveComparative(shareToken, DatasetRetrieveComparativeParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/public/{share_token}/datasets/feedback`, but + * is otherwise the same as [DatasetService.retrieveFeedback]. + */ + @MustBeClosed + fun retrieveFeedback(shareToken: String): HttpResponseFor<List<FeedbackSchema>> = + retrieveFeedback(shareToken, DatasetRetrieveFeedbackParams.none()) + + /** @see retrieveFeedback */ + @MustBeClosed + fun retrieveFeedback( + shareToken: String, + params: DatasetRetrieveFeedbackParams = DatasetRetrieveFeedbackParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<FeedbackSchema>> = + retrieveFeedback(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see retrieveFeedback */ + @MustBeClosed + fun retrieveFeedback( + shareToken: String, + params: DatasetRetrieveFeedbackParams = DatasetRetrieveFeedbackParams.none(), + ): HttpResponseFor<List<FeedbackSchema>> = + retrieveFeedback(shareToken, params, RequestOptions.none()) + + /** @see retrieveFeedback */ + @MustBeClosed + fun retrieveFeedback( + params: DatasetRetrieveFeedbackParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<FeedbackSchema>> + + /** @see retrieveFeedback */ + @MustBeClosed + fun retrieveFeedback( + params: DatasetRetrieveFeedbackParams + ): HttpResponseFor<List<FeedbackSchema>> = retrieveFeedback(params, RequestOptions.none()) + + /** @see retrieveFeedback */ + @MustBeClosed + fun retrieveFeedback( + shareToken: String, + requestOptions: RequestOptions, + ): HttpResponseFor<List<FeedbackSchema>> = + retrieveFeedback(shareToken, DatasetRetrieveFeedbackParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/public/{share_token}/datasets/sessions`, but + * is otherwise the same as [DatasetService.retrieveSessions]. + */ + @MustBeClosed + fun retrieveSessions(shareToken: String): HttpResponseFor<List<TracerSession>> = + retrieveSessions(shareToken, DatasetRetrieveSessionsParams.none()) + + /** @see retrieveSessions */ + @MustBeClosed + fun retrieveSessions( + shareToken: String, + params: DatasetRetrieveSessionsParams = DatasetRetrieveSessionsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<TracerSession>> = + retrieveSessions(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see retrieveSessions */ + @MustBeClosed + fun retrieveSessions( + shareToken: String, + params: DatasetRetrieveSessionsParams = DatasetRetrieveSessionsParams.none(), + ): HttpResponseFor<List<TracerSession>> = + retrieveSessions(shareToken, params, RequestOptions.none()) + + /** @see retrieveSessions */ + @MustBeClosed + fun retrieveSessions( + params: DatasetRetrieveSessionsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<TracerSession>> + + /** @see retrieveSessions */ + @MustBeClosed + fun retrieveSessions( + params: DatasetRetrieveSessionsParams + ): HttpResponseFor<List<TracerSession>> = retrieveSessions(params, RequestOptions.none()) + + /** @see retrieveSessions */ + @MustBeClosed + fun retrieveSessions( + shareToken: String, + requestOptions: RequestOptions, + ): HttpResponseFor<List<TracerSession>> = + retrieveSessions(shareToken, DatasetRetrieveSessionsParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/public/datasets/sessions-bulk`, but is + * otherwise the same as [DatasetService.retrieveSessionsBulk]. + */ + @MustBeClosed + fun retrieveSessionsBulk( + params: DatasetRetrieveSessionsBulkParams + ): HttpResponseFor<List<TracerSession>> = + retrieveSessionsBulk(params, RequestOptions.none()) + + /** @see retrieveSessionsBulk */ + @MustBeClosed + fun retrieveSessionsBulk( + params: DatasetRetrieveSessionsBulkParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<TracerSession>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/DatasetServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/DatasetServiceImpl.kt new file mode 100644 index 00000000..ac284659 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/DatasetServiceImpl.kt @@ -0,0 +1,270 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.public_ + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.feedback.FeedbackSchema +import com.langsmith_api.api.models.api.v1.public_.datasets.DatasetListParams +import com.langsmith_api.api.models.api.v1.public_.datasets.DatasetListResponse +import com.langsmith_api.api.models.api.v1.public_.datasets.DatasetRetrieveComparativeParams +import com.langsmith_api.api.models.api.v1.public_.datasets.DatasetRetrieveComparativeResponse +import com.langsmith_api.api.models.api.v1.public_.datasets.DatasetRetrieveFeedbackParams +import com.langsmith_api.api.models.api.v1.public_.datasets.DatasetRetrieveSessionsBulkParams +import com.langsmith_api.api.models.api.v1.public_.datasets.DatasetRetrieveSessionsParams +import com.langsmith_api.api.models.api.v1.sessions.TracerSession +import com.langsmith_api.api.services.blocking.api.v1.public_.datasets.RunService +import com.langsmith_api.api.services.blocking.api.v1.public_.datasets.RunServiceImpl +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class DatasetServiceImpl internal constructor(private val clientOptions: ClientOptions) : + DatasetService { + + private val withRawResponse: DatasetService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val runs: RunService by lazy { RunServiceImpl(clientOptions) } + + override fun withRawResponse(): DatasetService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): DatasetService = + DatasetServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun runs(): RunService = runs + + override fun list( + params: DatasetListParams, + requestOptions: RequestOptions, + ): DatasetListResponse = + // get /api/v1/public/{share_token}/datasets + withRawResponse().list(params, requestOptions).parse() + + override fun retrieveComparative( + params: DatasetRetrieveComparativeParams, + requestOptions: RequestOptions, + ): List<DatasetRetrieveComparativeResponse> = + // get /api/v1/public/{share_token}/datasets/comparative + withRawResponse().retrieveComparative(params, requestOptions).parse() + + override fun retrieveFeedback( + params: DatasetRetrieveFeedbackParams, + requestOptions: RequestOptions, + ): List<FeedbackSchema> = + // get /api/v1/public/{share_token}/datasets/feedback + withRawResponse().retrieveFeedback(params, requestOptions).parse() + + override fun retrieveSessions( + params: DatasetRetrieveSessionsParams, + requestOptions: RequestOptions, + ): List<TracerSession> = + // get /api/v1/public/{share_token}/datasets/sessions + withRawResponse().retrieveSessions(params, requestOptions).parse() + + override fun retrieveSessionsBulk( + params: DatasetRetrieveSessionsBulkParams, + requestOptions: RequestOptions, + ): List<TracerSession> = + // get /api/v1/public/datasets/sessions-bulk + withRawResponse().retrieveSessionsBulk(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + DatasetService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val runs: RunService.WithRawResponse by lazy { + RunServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): DatasetService.WithRawResponse = + DatasetServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun runs(): RunService.WithRawResponse = runs + + private val listHandler: Handler<DatasetListResponse> = + jsonHandler<DatasetListResponse>(clientOptions.jsonMapper) + + override fun list( + params: DatasetListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<DatasetListResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("shareToken", params.shareToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "public", params._pathParam(0), "datasets") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveComparativeHandler: Handler<List<DatasetRetrieveComparativeResponse>> = + jsonHandler<List<DatasetRetrieveComparativeResponse>>(clientOptions.jsonMapper) + + override fun retrieveComparative( + params: DatasetRetrieveComparativeParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<DatasetRetrieveComparativeResponse>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("shareToken", params.shareToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "public", + params._pathParam(0), + "datasets", + "comparative", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveComparativeHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val retrieveFeedbackHandler: Handler<List<FeedbackSchema>> = + jsonHandler<List<FeedbackSchema>>(clientOptions.jsonMapper) + + override fun retrieveFeedback( + params: DatasetRetrieveFeedbackParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<FeedbackSchema>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("shareToken", params.shareToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "public", + params._pathParam(0), + "datasets", + "feedback", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveFeedbackHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val retrieveSessionsHandler: Handler<List<TracerSession>> = + jsonHandler<List<TracerSession>>(clientOptions.jsonMapper) + + override fun retrieveSessions( + params: DatasetRetrieveSessionsParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<TracerSession>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("shareToken", params.shareToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "public", + params._pathParam(0), + "datasets", + "sessions", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveSessionsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val retrieveSessionsBulkHandler: Handler<List<TracerSession>> = + jsonHandler<List<TracerSession>>(clientOptions.jsonMapper) + + override fun retrieveSessionsBulk( + params: DatasetRetrieveSessionsBulkParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<TracerSession>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "public", "datasets", "sessions-bulk") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveSessionsBulkHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/ExampleService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/ExampleService.kt new file mode 100644 index 00000000..c4789ae6 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/ExampleService.kt @@ -0,0 +1,239 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.public_ + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.examples.Example +import com.langsmith_api.api.models.api.v1.public_.examples.ExampleListParams +import com.langsmith_api.api.models.api.v1.public_.examples.ExampleRetrieveCountParams +import com.langsmith_api.api.models.api.v1.public_.examples.ExampleRunsParams +import com.langsmith_api.api.models.api.v1.public_.examples.ExampleRunsResponse +import java.util.function.Consumer + +interface ExampleService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ExampleService + + /** Get example by ids or the shared example if not specifed. */ + fun list(shareToken: String): List<Example> = list(shareToken, ExampleListParams.none()) + + /** @see list */ + fun list( + shareToken: String, + params: ExampleListParams = ExampleListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<Example> = list(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see list */ + fun list( + shareToken: String, + params: ExampleListParams = ExampleListParams.none(), + ): List<Example> = list(shareToken, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: ExampleListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List<Example> + + /** @see list */ + fun list(params: ExampleListParams): List<Example> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(shareToken: String, requestOptions: RequestOptions): List<Example> = + list(shareToken, ExampleListParams.none(), requestOptions) + + /** Count all examples by query params */ + fun retrieveCount(shareToken: String): Long = + retrieveCount(shareToken, ExampleRetrieveCountParams.none()) + + /** @see retrieveCount */ + fun retrieveCount( + shareToken: String, + params: ExampleRetrieveCountParams = ExampleRetrieveCountParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Long = retrieveCount(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see retrieveCount */ + fun retrieveCount( + shareToken: String, + params: ExampleRetrieveCountParams = ExampleRetrieveCountParams.none(), + ): Long = retrieveCount(shareToken, params, RequestOptions.none()) + + /** @see retrieveCount */ + fun retrieveCount( + params: ExampleRetrieveCountParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Long + + /** @see retrieveCount */ + fun retrieveCount(params: ExampleRetrieveCountParams): Long = + retrieveCount(params, RequestOptions.none()) + + /** @see retrieveCount */ + fun retrieveCount(shareToken: String, requestOptions: RequestOptions): Long = + retrieveCount(shareToken, ExampleRetrieveCountParams.none(), requestOptions) + + /** Get examples with associated runs from sessions in a dataset that has been shared. */ + fun runs(shareToken: String, params: ExampleRunsParams): ExampleRunsResponse = + runs(shareToken, params, RequestOptions.none()) + + /** @see runs */ + fun runs( + shareToken: String, + params: ExampleRunsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ExampleRunsResponse = runs(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see runs */ + fun runs(params: ExampleRunsParams): ExampleRunsResponse = runs(params, RequestOptions.none()) + + /** @see runs */ + fun runs( + params: ExampleRunsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ExampleRunsResponse + + /** A view of [ExampleService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ExampleService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/public/{share_token}/examples`, but is + * otherwise the same as [ExampleService.list]. + */ + @MustBeClosed + fun list(shareToken: String): HttpResponseFor<List<Example>> = + list(shareToken, ExampleListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + shareToken: String, + params: ExampleListParams = ExampleListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<Example>> = + list(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see list */ + @MustBeClosed + fun list( + shareToken: String, + params: ExampleListParams = ExampleListParams.none(), + ): HttpResponseFor<List<Example>> = list(shareToken, params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: ExampleListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<Example>> + + /** @see list */ + @MustBeClosed + fun list(params: ExampleListParams): HttpResponseFor<List<Example>> = + list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + shareToken: String, + requestOptions: RequestOptions, + ): HttpResponseFor<List<Example>> = + list(shareToken, ExampleListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/public/{share_token}/examples/count`, but is + * otherwise the same as [ExampleService.retrieveCount]. + */ + @MustBeClosed + fun retrieveCount(shareToken: String): HttpResponseFor<Long> = + retrieveCount(shareToken, ExampleRetrieveCountParams.none()) + + /** @see retrieveCount */ + @MustBeClosed + fun retrieveCount( + shareToken: String, + params: ExampleRetrieveCountParams = ExampleRetrieveCountParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<Long> = + retrieveCount(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see retrieveCount */ + @MustBeClosed + fun retrieveCount( + shareToken: String, + params: ExampleRetrieveCountParams = ExampleRetrieveCountParams.none(), + ): HttpResponseFor<Long> = retrieveCount(shareToken, params, RequestOptions.none()) + + /** @see retrieveCount */ + @MustBeClosed + fun retrieveCount( + params: ExampleRetrieveCountParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<Long> + + /** @see retrieveCount */ + @MustBeClosed + fun retrieveCount(params: ExampleRetrieveCountParams): HttpResponseFor<Long> = + retrieveCount(params, RequestOptions.none()) + + /** @see retrieveCount */ + @MustBeClosed + fun retrieveCount( + shareToken: String, + requestOptions: RequestOptions, + ): HttpResponseFor<Long> = + retrieveCount(shareToken, ExampleRetrieveCountParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/public/{share_token}/examples/runs`, but is + * otherwise the same as [ExampleService.runs]. + */ + @MustBeClosed + fun runs( + shareToken: String, + params: ExampleRunsParams, + ): HttpResponseFor<ExampleRunsResponse> = runs(shareToken, params, RequestOptions.none()) + + /** @see runs */ + @MustBeClosed + fun runs( + shareToken: String, + params: ExampleRunsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ExampleRunsResponse> = + runs(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see runs */ + @MustBeClosed + fun runs(params: ExampleRunsParams): HttpResponseFor<ExampleRunsResponse> = + runs(params, RequestOptions.none()) + + /** @see runs */ + @MustBeClosed + fun runs( + params: ExampleRunsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ExampleRunsResponse> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/ExampleServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/ExampleServiceImpl.kt new file mode 100644 index 00000000..8e8d2887 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/ExampleServiceImpl.kt @@ -0,0 +1,169 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.public_ + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.examples.Example +import com.langsmith_api.api.models.api.v1.public_.examples.ExampleListParams +import com.langsmith_api.api.models.api.v1.public_.examples.ExampleRetrieveCountParams +import com.langsmith_api.api.models.api.v1.public_.examples.ExampleRunsParams +import com.langsmith_api.api.models.api.v1.public_.examples.ExampleRunsResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ExampleServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ExampleService { + + private val withRawResponse: ExampleService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ExampleService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): ExampleService = + ExampleServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list(params: ExampleListParams, requestOptions: RequestOptions): List<Example> = + // get /api/v1/public/{share_token}/examples + withRawResponse().list(params, requestOptions).parse() + + override fun retrieveCount( + params: ExampleRetrieveCountParams, + requestOptions: RequestOptions, + ): Long = + // get /api/v1/public/{share_token}/examples/count + withRawResponse().retrieveCount(params, requestOptions).parse() + + override fun runs( + params: ExampleRunsParams, + requestOptions: RequestOptions, + ): ExampleRunsResponse = + // post /api/v1/public/{share_token}/examples/runs + withRawResponse().runs(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ExampleService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ExampleService.WithRawResponse = + ExampleServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler<List<Example>> = + jsonHandler<List<Example>>(clientOptions.jsonMapper) + + override fun list( + params: ExampleListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<Example>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("shareToken", params.shareToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "public", params._pathParam(0), "examples") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val retrieveCountHandler: Handler<Long> = + jsonHandler<Long>(clientOptions.jsonMapper) + + override fun retrieveCount( + params: ExampleRetrieveCountParams, + requestOptions: RequestOptions, + ): HttpResponseFor<Long> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("shareToken", params.shareToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "public", + params._pathParam(0), + "examples", + "count", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { retrieveCountHandler.handle(it) } + } + } + + private val runsHandler: Handler<ExampleRunsResponse> = + jsonHandler<ExampleRunsResponse>(clientOptions.jsonMapper) + + override fun runs( + params: ExampleRunsParams, + requestOptions: RequestOptions, + ): HttpResponseFor<ExampleRunsResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("shareToken", params.shareToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "public", + params._pathParam(0), + "examples", + "runs", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { runsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/RunService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/RunService.kt new file mode 100644 index 00000000..9d77decd --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/RunService.kt @@ -0,0 +1,233 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.public_ + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.public_.runs.RunListParams +import com.langsmith_api.api.models.api.v1.public_.runs.RunPublicSchema +import com.langsmith_api.api.models.api.v1.public_.runs.RunQueryParams +import com.langsmith_api.api.models.api.v1.public_.runs.RunQueryResponse +import com.langsmith_api.api.models.api.v1.public_.runs.RunRetrieveParams +import java.util.function.Consumer + +interface RunService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunService + + /** Get the shared run. */ + fun retrieve(id: String, params: RunRetrieveParams): RunPublicSchema = + retrieve(id, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + id: String, + params: RunRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RunPublicSchema = retrieve(params.toBuilder().id(id).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: RunRetrieveParams): RunPublicSchema = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: RunRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RunPublicSchema + + /** Get the shared run. */ + fun list(shareToken: String): RunPublicSchema = list(shareToken, RunListParams.none()) + + /** @see list */ + fun list( + shareToken: String, + params: RunListParams = RunListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): RunPublicSchema = list(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see list */ + fun list(shareToken: String, params: RunListParams = RunListParams.none()): RunPublicSchema = + list(shareToken, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: RunListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RunPublicSchema + + /** @see list */ + fun list(params: RunListParams): RunPublicSchema = list(params, RequestOptions.none()) + + /** @see list */ + fun list(shareToken: String, requestOptions: RequestOptions): RunPublicSchema = + list(shareToken, RunListParams.none(), requestOptions) + + /** Get run by ids or the shared run if not specifed. */ + fun query(shareToken: String): RunQueryResponse = query(shareToken, RunQueryParams.none()) + + /** @see query */ + fun query( + shareToken: String, + params: RunQueryParams = RunQueryParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): RunQueryResponse = query(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see query */ + fun query( + shareToken: String, + params: RunQueryParams = RunQueryParams.none(), + ): RunQueryResponse = query(shareToken, params, RequestOptions.none()) + + /** @see query */ + fun query( + params: RunQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RunQueryResponse + + /** @see query */ + fun query(params: RunQueryParams): RunQueryResponse = query(params, RequestOptions.none()) + + /** @see query */ + fun query(shareToken: String, requestOptions: RequestOptions): RunQueryResponse = + query(shareToken, RunQueryParams.none(), requestOptions) + + /** A view of [RunService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/public/{share_token}/run/{id}`, but is + * otherwise the same as [RunService.retrieve]. + */ + @MustBeClosed + fun retrieve(id: String, params: RunRetrieveParams): HttpResponseFor<RunPublicSchema> = + retrieve(id, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + id: String, + params: RunRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RunPublicSchema> = + retrieve(params.toBuilder().id(id).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: RunRetrieveParams): HttpResponseFor<RunPublicSchema> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: RunRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RunPublicSchema> + + /** + * Returns a raw HTTP response for `get /api/v1/public/{share_token}/run`, but is otherwise + * the same as [RunService.list]. + */ + @MustBeClosed + fun list(shareToken: String): HttpResponseFor<RunPublicSchema> = + list(shareToken, RunListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + shareToken: String, + params: RunListParams = RunListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RunPublicSchema> = + list(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see list */ + @MustBeClosed + fun list( + shareToken: String, + params: RunListParams = RunListParams.none(), + ): HttpResponseFor<RunPublicSchema> = list(shareToken, params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: RunListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RunPublicSchema> + + /** @see list */ + @MustBeClosed + fun list(params: RunListParams): HttpResponseFor<RunPublicSchema> = + list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + shareToken: String, + requestOptions: RequestOptions, + ): HttpResponseFor<RunPublicSchema> = list(shareToken, RunListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/public/{share_token}/runs/query`, but is + * otherwise the same as [RunService.query]. + */ + @MustBeClosed + fun query(shareToken: String): HttpResponseFor<RunQueryResponse> = + query(shareToken, RunQueryParams.none()) + + /** @see query */ + @MustBeClosed + fun query( + shareToken: String, + params: RunQueryParams = RunQueryParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RunQueryResponse> = + query(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see query */ + @MustBeClosed + fun query( + shareToken: String, + params: RunQueryParams = RunQueryParams.none(), + ): HttpResponseFor<RunQueryResponse> = query(shareToken, params, RequestOptions.none()) + + /** @see query */ + @MustBeClosed + fun query( + params: RunQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RunQueryResponse> + + /** @see query */ + @MustBeClosed + fun query(params: RunQueryParams): HttpResponseFor<RunQueryResponse> = + query(params, RequestOptions.none()) + + /** @see query */ + @MustBeClosed + fun query( + shareToken: String, + requestOptions: RequestOptions, + ): HttpResponseFor<RunQueryResponse> = + query(shareToken, RunQueryParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/RunServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/RunServiceImpl.kt new file mode 100644 index 00000000..1fe39b12 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/RunServiceImpl.kt @@ -0,0 +1,164 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.public_ + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.public_.runs.RunListParams +import com.langsmith_api.api.models.api.v1.public_.runs.RunPublicSchema +import com.langsmith_api.api.models.api.v1.public_.runs.RunQueryParams +import com.langsmith_api.api.models.api.v1.public_.runs.RunQueryResponse +import com.langsmith_api.api.models.api.v1.public_.runs.RunRetrieveParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class RunServiceImpl internal constructor(private val clientOptions: ClientOptions) : RunService { + + private val withRawResponse: RunService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): RunService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunService = + RunServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: RunRetrieveParams, + requestOptions: RequestOptions, + ): RunPublicSchema = + // get /api/v1/public/{share_token}/run/{id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun list(params: RunListParams, requestOptions: RequestOptions): RunPublicSchema = + // get /api/v1/public/{share_token}/run + withRawResponse().list(params, requestOptions).parse() + + override fun query(params: RunQueryParams, requestOptions: RequestOptions): RunQueryResponse = + // post /api/v1/public/{share_token}/runs/query + withRawResponse().query(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RunService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): RunService.WithRawResponse = + RunServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler<RunPublicSchema> = + jsonHandler<RunPublicSchema>(clientOptions.jsonMapper) + + override fun retrieve( + params: RunRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor<RunPublicSchema> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "public", + params._pathParam(0), + "run", + params._pathParam(1), + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler<RunPublicSchema> = + jsonHandler<RunPublicSchema>(clientOptions.jsonMapper) + + override fun list( + params: RunListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<RunPublicSchema> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("shareToken", params.shareToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "public", params._pathParam(0), "run") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val queryHandler: Handler<RunQueryResponse> = + jsonHandler<RunQueryResponse>(clientOptions.jsonMapper) + + override fun query( + params: RunQueryParams, + requestOptions: RequestOptions, + ): HttpResponseFor<RunQueryResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("shareToken", params.shareToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "public", params._pathParam(0), "runs", "query") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { queryHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/SchemaService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/SchemaService.kt new file mode 100644 index 00000000..5774bb81 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/SchemaService.kt @@ -0,0 +1,211 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.public_ + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.public_.schemas.SchemaRetrieveMessageJsonParams +import com.langsmith_api.api.models.api.v1.public_.schemas.SchemaRetrieveMessageJsonResponse +import com.langsmith_api.api.models.api.v1.public_.schemas.SchemaRetrieveTooldefJsonParams +import com.langsmith_api.api.models.api.v1.public_.schemas.SchemaRetrieveTooldefJsonResponse +import java.util.function.Consumer + +interface SchemaService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): SchemaService + + /** Get Message Json Schema */ + fun retrieveMessageJson(version: String): SchemaRetrieveMessageJsonResponse = + retrieveMessageJson(version, SchemaRetrieveMessageJsonParams.none()) + + /** @see retrieveMessageJson */ + fun retrieveMessageJson( + version: String, + params: SchemaRetrieveMessageJsonParams = SchemaRetrieveMessageJsonParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): SchemaRetrieveMessageJsonResponse = + retrieveMessageJson(params.toBuilder().version(version).build(), requestOptions) + + /** @see retrieveMessageJson */ + fun retrieveMessageJson( + version: String, + params: SchemaRetrieveMessageJsonParams = SchemaRetrieveMessageJsonParams.none(), + ): SchemaRetrieveMessageJsonResponse = + retrieveMessageJson(version, params, RequestOptions.none()) + + /** @see retrieveMessageJson */ + fun retrieveMessageJson( + params: SchemaRetrieveMessageJsonParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SchemaRetrieveMessageJsonResponse + + /** @see retrieveMessageJson */ + fun retrieveMessageJson( + params: SchemaRetrieveMessageJsonParams + ): SchemaRetrieveMessageJsonResponse = retrieveMessageJson(params, RequestOptions.none()) + + /** @see retrieveMessageJson */ + fun retrieveMessageJson( + version: String, + requestOptions: RequestOptions, + ): SchemaRetrieveMessageJsonResponse = + retrieveMessageJson(version, SchemaRetrieveMessageJsonParams.none(), requestOptions) + + /** Get Tool Def Json Schema */ + fun retrieveTooldefJson(version: String): SchemaRetrieveTooldefJsonResponse = + retrieveTooldefJson(version, SchemaRetrieveTooldefJsonParams.none()) + + /** @see retrieveTooldefJson */ + fun retrieveTooldefJson( + version: String, + params: SchemaRetrieveTooldefJsonParams = SchemaRetrieveTooldefJsonParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): SchemaRetrieveTooldefJsonResponse = + retrieveTooldefJson(params.toBuilder().version(version).build(), requestOptions) + + /** @see retrieveTooldefJson */ + fun retrieveTooldefJson( + version: String, + params: SchemaRetrieveTooldefJsonParams = SchemaRetrieveTooldefJsonParams.none(), + ): SchemaRetrieveTooldefJsonResponse = + retrieveTooldefJson(version, params, RequestOptions.none()) + + /** @see retrieveTooldefJson */ + fun retrieveTooldefJson( + params: SchemaRetrieveTooldefJsonParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SchemaRetrieveTooldefJsonResponse + + /** @see retrieveTooldefJson */ + fun retrieveTooldefJson( + params: SchemaRetrieveTooldefJsonParams + ): SchemaRetrieveTooldefJsonResponse = retrieveTooldefJson(params, RequestOptions.none()) + + /** @see retrieveTooldefJson */ + fun retrieveTooldefJson( + version: String, + requestOptions: RequestOptions, + ): SchemaRetrieveTooldefJsonResponse = + retrieveTooldefJson(version, SchemaRetrieveTooldefJsonParams.none(), requestOptions) + + /** A view of [SchemaService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): SchemaService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/public/schemas/{version}/message.json`, but + * is otherwise the same as [SchemaService.retrieveMessageJson]. + */ + @MustBeClosed + fun retrieveMessageJson( + version: String + ): HttpResponseFor<SchemaRetrieveMessageJsonResponse> = + retrieveMessageJson(version, SchemaRetrieveMessageJsonParams.none()) + + /** @see retrieveMessageJson */ + @MustBeClosed + fun retrieveMessageJson( + version: String, + params: SchemaRetrieveMessageJsonParams = SchemaRetrieveMessageJsonParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<SchemaRetrieveMessageJsonResponse> = + retrieveMessageJson(params.toBuilder().version(version).build(), requestOptions) + + /** @see retrieveMessageJson */ + @MustBeClosed + fun retrieveMessageJson( + version: String, + params: SchemaRetrieveMessageJsonParams = SchemaRetrieveMessageJsonParams.none(), + ): HttpResponseFor<SchemaRetrieveMessageJsonResponse> = + retrieveMessageJson(version, params, RequestOptions.none()) + + /** @see retrieveMessageJson */ + @MustBeClosed + fun retrieveMessageJson( + params: SchemaRetrieveMessageJsonParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<SchemaRetrieveMessageJsonResponse> + + /** @see retrieveMessageJson */ + @MustBeClosed + fun retrieveMessageJson( + params: SchemaRetrieveMessageJsonParams + ): HttpResponseFor<SchemaRetrieveMessageJsonResponse> = + retrieveMessageJson(params, RequestOptions.none()) + + /** @see retrieveMessageJson */ + @MustBeClosed + fun retrieveMessageJson( + version: String, + requestOptions: RequestOptions, + ): HttpResponseFor<SchemaRetrieveMessageJsonResponse> = + retrieveMessageJson(version, SchemaRetrieveMessageJsonParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/public/schemas/{version}/tooldef.json`, but + * is otherwise the same as [SchemaService.retrieveTooldefJson]. + */ + @MustBeClosed + fun retrieveTooldefJson( + version: String + ): HttpResponseFor<SchemaRetrieveTooldefJsonResponse> = + retrieveTooldefJson(version, SchemaRetrieveTooldefJsonParams.none()) + + /** @see retrieveTooldefJson */ + @MustBeClosed + fun retrieveTooldefJson( + version: String, + params: SchemaRetrieveTooldefJsonParams = SchemaRetrieveTooldefJsonParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<SchemaRetrieveTooldefJsonResponse> = + retrieveTooldefJson(params.toBuilder().version(version).build(), requestOptions) + + /** @see retrieveTooldefJson */ + @MustBeClosed + fun retrieveTooldefJson( + version: String, + params: SchemaRetrieveTooldefJsonParams = SchemaRetrieveTooldefJsonParams.none(), + ): HttpResponseFor<SchemaRetrieveTooldefJsonResponse> = + retrieveTooldefJson(version, params, RequestOptions.none()) + + /** @see retrieveTooldefJson */ + @MustBeClosed + fun retrieveTooldefJson( + params: SchemaRetrieveTooldefJsonParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<SchemaRetrieveTooldefJsonResponse> + + /** @see retrieveTooldefJson */ + @MustBeClosed + fun retrieveTooldefJson( + params: SchemaRetrieveTooldefJsonParams + ): HttpResponseFor<SchemaRetrieveTooldefJsonResponse> = + retrieveTooldefJson(params, RequestOptions.none()) + + /** @see retrieveTooldefJson */ + @MustBeClosed + fun retrieveTooldefJson( + version: String, + requestOptions: RequestOptions, + ): HttpResponseFor<SchemaRetrieveTooldefJsonResponse> = + retrieveTooldefJson(version, SchemaRetrieveTooldefJsonParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/SchemaServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/SchemaServiceImpl.kt new file mode 100644 index 00000000..1603b69f --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/SchemaServiceImpl.kt @@ -0,0 +1,138 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.public_ + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.public_.schemas.SchemaRetrieveMessageJsonParams +import com.langsmith_api.api.models.api.v1.public_.schemas.SchemaRetrieveMessageJsonResponse +import com.langsmith_api.api.models.api.v1.public_.schemas.SchemaRetrieveTooldefJsonParams +import com.langsmith_api.api.models.api.v1.public_.schemas.SchemaRetrieveTooldefJsonResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class SchemaServiceImpl internal constructor(private val clientOptions: ClientOptions) : + SchemaService { + + private val withRawResponse: SchemaService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): SchemaService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): SchemaService = + SchemaServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieveMessageJson( + params: SchemaRetrieveMessageJsonParams, + requestOptions: RequestOptions, + ): SchemaRetrieveMessageJsonResponse = + // get /api/v1/public/schemas/{version}/message.json + withRawResponse().retrieveMessageJson(params, requestOptions).parse() + + override fun retrieveTooldefJson( + params: SchemaRetrieveTooldefJsonParams, + requestOptions: RequestOptions, + ): SchemaRetrieveTooldefJsonResponse = + // get /api/v1/public/schemas/{version}/tooldef.json + withRawResponse().retrieveTooldefJson(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SchemaService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): SchemaService.WithRawResponse = + SchemaServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveMessageJsonHandler: Handler<SchemaRetrieveMessageJsonResponse> = + jsonHandler<SchemaRetrieveMessageJsonResponse>(clientOptions.jsonMapper) + + override fun retrieveMessageJson( + params: SchemaRetrieveMessageJsonParams, + requestOptions: RequestOptions, + ): HttpResponseFor<SchemaRetrieveMessageJsonResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("version", params.version().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "public", + "schemas", + params._pathParam(0), + "message.json", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveMessageJsonHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveTooldefJsonHandler: Handler<SchemaRetrieveTooldefJsonResponse> = + jsonHandler<SchemaRetrieveTooldefJsonResponse>(clientOptions.jsonMapper) + + override fun retrieveTooldefJson( + params: SchemaRetrieveTooldefJsonParams, + requestOptions: RequestOptions, + ): HttpResponseFor<SchemaRetrieveTooldefJsonResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("version", params.version().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "public", + "schemas", + params._pathParam(0), + "tooldef.json", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveTooldefJsonHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/datasets/RunService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/datasets/RunService.kt new file mode 100644 index 00000000..e0ce79cd --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/datasets/RunService.kt @@ -0,0 +1,310 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.public_.datasets + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.datasets.runs.SessionFeedbackDelta +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunDeltaParams +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunGenerateQueryParams +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunPublicDatasetSchema +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunQueryParams +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunQueryResponse +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunRetrieveParams +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunStats +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunStatsParams +import com.langsmith_api.api.models.api.v1.runs.ResponseBodyForRunsGenerateQuery +import java.util.function.Consumer + +interface RunService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunService + + /** Get runs in projects run over a dataset that has been shared. */ + fun retrieve(runId: String, params: RunRetrieveParams): RunPublicDatasetSchema = + retrieve(runId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + runId: String, + params: RunRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RunPublicDatasetSchema = retrieve(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: RunRetrieveParams): RunPublicDatasetSchema = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: RunRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RunPublicDatasetSchema + + /** + * Fetch the number of regressions/improvements for each example in a dataset, between + * sessions[0] and sessions[1]. + */ + fun delta(shareToken: String, params: RunDeltaParams): SessionFeedbackDelta = + delta(shareToken, params, RequestOptions.none()) + + /** @see delta */ + fun delta( + shareToken: String, + params: RunDeltaParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SessionFeedbackDelta = + delta(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see delta */ + fun delta(params: RunDeltaParams): SessionFeedbackDelta = delta(params, RequestOptions.none()) + + /** @see delta */ + fun delta( + params: RunDeltaParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SessionFeedbackDelta + + /** Get runs in projects run over a dataset that has been shared. */ + fun generateQuery( + shareToken: String, + params: RunGenerateQueryParams, + ): ResponseBodyForRunsGenerateQuery = generateQuery(shareToken, params, RequestOptions.none()) + + /** @see generateQuery */ + fun generateQuery( + shareToken: String, + params: RunGenerateQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ResponseBodyForRunsGenerateQuery = + generateQuery(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see generateQuery */ + fun generateQuery(params: RunGenerateQueryParams): ResponseBodyForRunsGenerateQuery = + generateQuery(params, RequestOptions.none()) + + /** @see generateQuery */ + fun generateQuery( + params: RunGenerateQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ResponseBodyForRunsGenerateQuery + + /** Get runs in projects run over a dataset that has been shared. */ + fun query(shareToken: String, params: RunQueryParams): RunQueryResponse = + query(shareToken, params, RequestOptions.none()) + + /** @see query */ + fun query( + shareToken: String, + params: RunQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RunQueryResponse = query(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see query */ + fun query(params: RunQueryParams): RunQueryResponse = query(params, RequestOptions.none()) + + /** @see query */ + fun query( + params: RunQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RunQueryResponse + + /** Get run stats in projects run over a dataset that has been shared. */ + fun stats(shareToken: String, params: RunStatsParams): RunStats = + stats(shareToken, params, RequestOptions.none()) + + /** @see stats */ + fun stats( + shareToken: String, + params: RunStatsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RunStats = stats(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see stats */ + fun stats(params: RunStatsParams): RunStats = stats(params, RequestOptions.none()) + + /** @see stats */ + fun stats( + params: RunStatsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RunStats + + /** A view of [RunService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunService.WithRawResponse + + /** + * Returns a raw HTTP response for `get + * /api/v1/public/{share_token}/datasets/runs/{run_id}`, but is otherwise the same as + * [RunService.retrieve]. + */ + @MustBeClosed + fun retrieve( + runId: String, + params: RunRetrieveParams, + ): HttpResponseFor<RunPublicDatasetSchema> = retrieve(runId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + runId: String, + params: RunRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RunPublicDatasetSchema> = + retrieve(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: RunRetrieveParams): HttpResponseFor<RunPublicDatasetSchema> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: RunRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RunPublicDatasetSchema> + + /** + * Returns a raw HTTP response for `post /api/v1/public/{share_token}/datasets/runs/delta`, + * but is otherwise the same as [RunService.delta]. + */ + @MustBeClosed + fun delta( + shareToken: String, + params: RunDeltaParams, + ): HttpResponseFor<SessionFeedbackDelta> = delta(shareToken, params, RequestOptions.none()) + + /** @see delta */ + @MustBeClosed + fun delta( + shareToken: String, + params: RunDeltaParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<SessionFeedbackDelta> = + delta(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see delta */ + @MustBeClosed + fun delta(params: RunDeltaParams): HttpResponseFor<SessionFeedbackDelta> = + delta(params, RequestOptions.none()) + + /** @see delta */ + @MustBeClosed + fun delta( + params: RunDeltaParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<SessionFeedbackDelta> + + /** + * Returns a raw HTTP response for `post + * /api/v1/public/{share_token}/datasets/runs/generate-query`, but is otherwise the same as + * [RunService.generateQuery]. + */ + @MustBeClosed + fun generateQuery( + shareToken: String, + params: RunGenerateQueryParams, + ): HttpResponseFor<ResponseBodyForRunsGenerateQuery> = + generateQuery(shareToken, params, RequestOptions.none()) + + /** @see generateQuery */ + @MustBeClosed + fun generateQuery( + shareToken: String, + params: RunGenerateQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ResponseBodyForRunsGenerateQuery> = + generateQuery(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see generateQuery */ + @MustBeClosed + fun generateQuery( + params: RunGenerateQueryParams + ): HttpResponseFor<ResponseBodyForRunsGenerateQuery> = + generateQuery(params, RequestOptions.none()) + + /** @see generateQuery */ + @MustBeClosed + fun generateQuery( + params: RunGenerateQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ResponseBodyForRunsGenerateQuery> + + /** + * Returns a raw HTTP response for `post /api/v1/public/{share_token}/datasets/runs/query`, + * but is otherwise the same as [RunService.query]. + */ + @MustBeClosed + fun query(shareToken: String, params: RunQueryParams): HttpResponseFor<RunQueryResponse> = + query(shareToken, params, RequestOptions.none()) + + /** @see query */ + @MustBeClosed + fun query( + shareToken: String, + params: RunQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RunQueryResponse> = + query(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see query */ + @MustBeClosed + fun query(params: RunQueryParams): HttpResponseFor<RunQueryResponse> = + query(params, RequestOptions.none()) + + /** @see query */ + @MustBeClosed + fun query( + params: RunQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RunQueryResponse> + + /** + * Returns a raw HTTP response for `post /api/v1/public/{share_token}/datasets/runs/stats`, + * but is otherwise the same as [RunService.stats]. + */ + @MustBeClosed + fun stats(shareToken: String, params: RunStatsParams): HttpResponseFor<RunStats> = + stats(shareToken, params, RequestOptions.none()) + + /** @see stats */ + @MustBeClosed + fun stats( + shareToken: String, + params: RunStatsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RunStats> = + stats(params.toBuilder().shareToken(shareToken).build(), requestOptions) + + /** @see stats */ + @MustBeClosed + fun stats(params: RunStatsParams): HttpResponseFor<RunStats> = + stats(params, RequestOptions.none()) + + /** @see stats */ + @MustBeClosed + fun stats( + params: RunStatsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RunStats> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/datasets/RunServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/datasets/RunServiceImpl.kt new file mode 100644 index 00000000..801183ba --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/datasets/RunServiceImpl.kt @@ -0,0 +1,279 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.public_.datasets + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.datasets.runs.SessionFeedbackDelta +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunDeltaParams +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunGenerateQueryParams +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunPublicDatasetSchema +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunQueryParams +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunQueryResponse +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunRetrieveParams +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunStats +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunStatsParams +import com.langsmith_api.api.models.api.v1.runs.ResponseBodyForRunsGenerateQuery +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class RunServiceImpl internal constructor(private val clientOptions: ClientOptions) : RunService { + + private val withRawResponse: RunService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): RunService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): RunService = + RunServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: RunRetrieveParams, + requestOptions: RequestOptions, + ): RunPublicDatasetSchema = + // get /api/v1/public/{share_token}/datasets/runs/{run_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun delta( + params: RunDeltaParams, + requestOptions: RequestOptions, + ): SessionFeedbackDelta = + // post /api/v1/public/{share_token}/datasets/runs/delta + withRawResponse().delta(params, requestOptions).parse() + + override fun generateQuery( + params: RunGenerateQueryParams, + requestOptions: RequestOptions, + ): ResponseBodyForRunsGenerateQuery = + // post /api/v1/public/{share_token}/datasets/runs/generate-query + withRawResponse().generateQuery(params, requestOptions).parse() + + override fun query(params: RunQueryParams, requestOptions: RequestOptions): RunQueryResponse = + // post /api/v1/public/{share_token}/datasets/runs/query + withRawResponse().query(params, requestOptions).parse() + + override fun stats(params: RunStatsParams, requestOptions: RequestOptions): RunStats = + // post /api/v1/public/{share_token}/datasets/runs/stats + withRawResponse().stats(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RunService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): RunService.WithRawResponse = + RunServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler<RunPublicDatasetSchema> = + jsonHandler<RunPublicDatasetSchema>(clientOptions.jsonMapper) + + override fun retrieve( + params: RunRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor<RunPublicDatasetSchema> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("runId", params.runId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "public", + params._pathParam(0), + "datasets", + "runs", + params._pathParam(1), + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val deltaHandler: Handler<SessionFeedbackDelta> = + jsonHandler<SessionFeedbackDelta>(clientOptions.jsonMapper) + + override fun delta( + params: RunDeltaParams, + requestOptions: RequestOptions, + ): HttpResponseFor<SessionFeedbackDelta> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("shareToken", params.shareToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "public", + params._pathParam(0), + "datasets", + "runs", + "delta", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deltaHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val generateQueryHandler: Handler<ResponseBodyForRunsGenerateQuery> = + jsonHandler<ResponseBodyForRunsGenerateQuery>(clientOptions.jsonMapper) + + override fun generateQuery( + params: RunGenerateQueryParams, + requestOptions: RequestOptions, + ): HttpResponseFor<ResponseBodyForRunsGenerateQuery> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("shareToken", params.shareToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "public", + params._pathParam(0), + "datasets", + "runs", + "generate-query", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { generateQueryHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val queryHandler: Handler<RunQueryResponse> = + jsonHandler<RunQueryResponse>(clientOptions.jsonMapper) + + override fun query( + params: RunQueryParams, + requestOptions: RequestOptions, + ): HttpResponseFor<RunQueryResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("shareToken", params.shareToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "public", + params._pathParam(0), + "datasets", + "runs", + "query", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { queryHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val statsHandler: Handler<RunStats> = + jsonHandler<RunStats>(clientOptions.jsonMapper) + + override fun stats( + params: RunStatsParams, + requestOptions: RequestOptions, + ): HttpResponseFor<RunStats> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("shareToken", params.shareToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "public", + params._pathParam(0), + "datasets", + "runs", + "stats", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { statsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/repos/OptimizationJobService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/repos/OptimizationJobService.kt new file mode 100644 index 00000000..0d6628d2 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/repos/OptimizationJobService.kt @@ -0,0 +1,337 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.repos + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.OptimizationJobDeleteParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.OptimizationJobDeleteResponse +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.OptimizationJobOptimizationJobsParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.OptimizationJobRetrieveOptimizationJobsParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.OptimizationJobRetrieveParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.OptimizationJobRetrieveResponse +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.OptimizationJobUpdateParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.PromptOptimizationJob +import com.langsmith_api.api.services.blocking.api.v1.repos.optimizationjobs.LogService +import java.util.function.Consumer + +interface OptimizationJobService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): OptimizationJobService + + fun logs(): LogService + + /** Get a specific optimization job. */ + fun retrieve( + jobId: String, + params: OptimizationJobRetrieveParams, + ): OptimizationJobRetrieveResponse = retrieve(jobId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + jobId: String, + params: OptimizationJobRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): OptimizationJobRetrieveResponse = + retrieve(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: OptimizationJobRetrieveParams): OptimizationJobRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: OptimizationJobRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): OptimizationJobRetrieveResponse + + /** Replace an existing prompt optimization job with a new, modified job. */ + fun update(jobId: String, params: OptimizationJobUpdateParams): PromptOptimizationJob = + update(jobId, params, RequestOptions.none()) + + /** @see update */ + fun update( + jobId: String, + params: OptimizationJobUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): PromptOptimizationJob = update(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see update */ + fun update(params: OptimizationJobUpdateParams): PromptOptimizationJob = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: OptimizationJobUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): PromptOptimizationJob + + /** Delete a prompt optimization job. */ + fun delete(jobId: String, params: OptimizationJobDeleteParams): OptimizationJobDeleteResponse = + delete(jobId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + jobId: String, + params: OptimizationJobDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): OptimizationJobDeleteResponse = + delete(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see delete */ + fun delete(params: OptimizationJobDeleteParams): OptimizationJobDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: OptimizationJobDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): OptimizationJobDeleteResponse + + /** Create a new prompt optimization job. */ + fun optimizationJobs( + repo: String, + params: OptimizationJobOptimizationJobsParams, + ): PromptOptimizationJob = optimizationJobs(repo, params, RequestOptions.none()) + + /** @see optimizationJobs */ + fun optimizationJobs( + repo: String, + params: OptimizationJobOptimizationJobsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): PromptOptimizationJob = + optimizationJobs(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see optimizationJobs */ + fun optimizationJobs(params: OptimizationJobOptimizationJobsParams): PromptOptimizationJob = + optimizationJobs(params, RequestOptions.none()) + + /** @see optimizationJobs */ + fun optimizationJobs( + params: OptimizationJobOptimizationJobsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): PromptOptimizationJob + + /** List all prompt optimization jobs. */ + fun retrieveOptimizationJobs( + repo: String, + params: OptimizationJobRetrieveOptimizationJobsParams, + ): List<PromptOptimizationJob> = retrieveOptimizationJobs(repo, params, RequestOptions.none()) + + /** @see retrieveOptimizationJobs */ + fun retrieveOptimizationJobs( + repo: String, + params: OptimizationJobRetrieveOptimizationJobsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List<PromptOptimizationJob> = + retrieveOptimizationJobs(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see retrieveOptimizationJobs */ + fun retrieveOptimizationJobs( + params: OptimizationJobRetrieveOptimizationJobsParams + ): List<PromptOptimizationJob> = retrieveOptimizationJobs(params, RequestOptions.none()) + + /** @see retrieveOptimizationJobs */ + fun retrieveOptimizationJobs( + params: OptimizationJobRetrieveOptimizationJobsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List<PromptOptimizationJob> + + /** + * A view of [OptimizationJobService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): OptimizationJobService.WithRawResponse + + fun logs(): LogService.WithRawResponse + + /** + * Returns a raw HTTP response for `get + * /api/v1/repos/{owner}/{repo}/optimization-jobs/{job_id}`, but is otherwise the same as + * [OptimizationJobService.retrieve]. + */ + @MustBeClosed + fun retrieve( + jobId: String, + params: OptimizationJobRetrieveParams, + ): HttpResponseFor<OptimizationJobRetrieveResponse> = + retrieve(jobId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + jobId: String, + params: OptimizationJobRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<OptimizationJobRetrieveResponse> = + retrieve(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: OptimizationJobRetrieveParams + ): HttpResponseFor<OptimizationJobRetrieveResponse> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: OptimizationJobRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<OptimizationJobRetrieveResponse> + + /** + * Returns a raw HTTP response for `patch + * /api/v1/repos/{owner}/{repo}/optimization-jobs/{job_id}`, but is otherwise the same as + * [OptimizationJobService.update]. + */ + @MustBeClosed + fun update( + jobId: String, + params: OptimizationJobUpdateParams, + ): HttpResponseFor<PromptOptimizationJob> = update(jobId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + jobId: String, + params: OptimizationJobUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<PromptOptimizationJob> = + update(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(params: OptimizationJobUpdateParams): HttpResponseFor<PromptOptimizationJob> = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: OptimizationJobUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<PromptOptimizationJob> + + /** + * Returns a raw HTTP response for `delete + * /api/v1/repos/{owner}/{repo}/optimization-jobs/{job_id}`, but is otherwise the same as + * [OptimizationJobService.delete]. + */ + @MustBeClosed + fun delete( + jobId: String, + params: OptimizationJobDeleteParams, + ): HttpResponseFor<OptimizationJobDeleteResponse> = + delete(jobId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + jobId: String, + params: OptimizationJobDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<OptimizationJobDeleteResponse> = + delete(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + params: OptimizationJobDeleteParams + ): HttpResponseFor<OptimizationJobDeleteResponse> = delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: OptimizationJobDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<OptimizationJobDeleteResponse> + + /** + * Returns a raw HTTP response for `post /api/v1/repos/{owner}/{repo}/optimization-jobs`, + * but is otherwise the same as [OptimizationJobService.optimizationJobs]. + */ + @MustBeClosed + fun optimizationJobs( + repo: String, + params: OptimizationJobOptimizationJobsParams, + ): HttpResponseFor<PromptOptimizationJob> = + optimizationJobs(repo, params, RequestOptions.none()) + + /** @see optimizationJobs */ + @MustBeClosed + fun optimizationJobs( + repo: String, + params: OptimizationJobOptimizationJobsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<PromptOptimizationJob> = + optimizationJobs(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see optimizationJobs */ + @MustBeClosed + fun optimizationJobs( + params: OptimizationJobOptimizationJobsParams + ): HttpResponseFor<PromptOptimizationJob> = optimizationJobs(params, RequestOptions.none()) + + /** @see optimizationJobs */ + @MustBeClosed + fun optimizationJobs( + params: OptimizationJobOptimizationJobsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<PromptOptimizationJob> + + /** + * Returns a raw HTTP response for `get /api/v1/repos/{owner}/{repo}/optimization-jobs`, but + * is otherwise the same as [OptimizationJobService.retrieveOptimizationJobs]. + */ + @MustBeClosed + fun retrieveOptimizationJobs( + repo: String, + params: OptimizationJobRetrieveOptimizationJobsParams, + ): HttpResponseFor<List<PromptOptimizationJob>> = + retrieveOptimizationJobs(repo, params, RequestOptions.none()) + + /** @see retrieveOptimizationJobs */ + @MustBeClosed + fun retrieveOptimizationJobs( + repo: String, + params: OptimizationJobRetrieveOptimizationJobsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<PromptOptimizationJob>> = + retrieveOptimizationJobs(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see retrieveOptimizationJobs */ + @MustBeClosed + fun retrieveOptimizationJobs( + params: OptimizationJobRetrieveOptimizationJobsParams + ): HttpResponseFor<List<PromptOptimizationJob>> = + retrieveOptimizationJobs(params, RequestOptions.none()) + + /** @see retrieveOptimizationJobs */ + @MustBeClosed + fun retrieveOptimizationJobs( + params: OptimizationJobRetrieveOptimizationJobsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<PromptOptimizationJob>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/repos/OptimizationJobServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/repos/OptimizationJobServiceImpl.kt new file mode 100644 index 00000000..f8f90c3c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/repos/OptimizationJobServiceImpl.kt @@ -0,0 +1,293 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.repos + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.OptimizationJobDeleteParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.OptimizationJobDeleteResponse +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.OptimizationJobOptimizationJobsParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.OptimizationJobRetrieveOptimizationJobsParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.OptimizationJobRetrieveParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.OptimizationJobRetrieveResponse +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.OptimizationJobUpdateParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.PromptOptimizationJob +import com.langsmith_api.api.services.blocking.api.v1.repos.optimizationjobs.LogService +import com.langsmith_api.api.services.blocking.api.v1.repos.optimizationjobs.LogServiceImpl +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class OptimizationJobServiceImpl internal constructor(private val clientOptions: ClientOptions) : + OptimizationJobService { + + private val withRawResponse: OptimizationJobService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val logs: LogService by lazy { LogServiceImpl(clientOptions) } + + override fun withRawResponse(): OptimizationJobService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): OptimizationJobService = + OptimizationJobServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun logs(): LogService = logs + + override fun retrieve( + params: OptimizationJobRetrieveParams, + requestOptions: RequestOptions, + ): OptimizationJobRetrieveResponse = + // get /api/v1/repos/{owner}/{repo}/optimization-jobs/{job_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update( + params: OptimizationJobUpdateParams, + requestOptions: RequestOptions, + ): PromptOptimizationJob = + // patch /api/v1/repos/{owner}/{repo}/optimization-jobs/{job_id} + withRawResponse().update(params, requestOptions).parse() + + override fun delete( + params: OptimizationJobDeleteParams, + requestOptions: RequestOptions, + ): OptimizationJobDeleteResponse = + // delete /api/v1/repos/{owner}/{repo}/optimization-jobs/{job_id} + withRawResponse().delete(params, requestOptions).parse() + + override fun optimizationJobs( + params: OptimizationJobOptimizationJobsParams, + requestOptions: RequestOptions, + ): PromptOptimizationJob = + // post /api/v1/repos/{owner}/{repo}/optimization-jobs + withRawResponse().optimizationJobs(params, requestOptions).parse() + + override fun retrieveOptimizationJobs( + params: OptimizationJobRetrieveOptimizationJobsParams, + requestOptions: RequestOptions, + ): List<PromptOptimizationJob> = + // get /api/v1/repos/{owner}/{repo}/optimization-jobs + withRawResponse().retrieveOptimizationJobs(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + OptimizationJobService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val logs: LogService.WithRawResponse by lazy { + LogServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): OptimizationJobService.WithRawResponse = + OptimizationJobServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun logs(): LogService.WithRawResponse = logs + + private val retrieveHandler: Handler<OptimizationJobRetrieveResponse> = + jsonHandler<OptimizationJobRetrieveResponse>(clientOptions.jsonMapper) + + override fun retrieve( + params: OptimizationJobRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor<OptimizationJobRetrieveResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("jobId", params.jobId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "repos", + params._pathParam(0), + params._pathParam(1), + "optimization-jobs", + params._pathParam(2), + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler<PromptOptimizationJob> = + jsonHandler<PromptOptimizationJob>(clientOptions.jsonMapper) + + override fun update( + params: OptimizationJobUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<PromptOptimizationJob> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("jobId", params.jobId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "repos", + params._pathParam(0), + params._pathParam(1), + "optimization-jobs", + params._pathParam(2), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val deleteHandler: Handler<OptimizationJobDeleteResponse> = + jsonHandler<OptimizationJobDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: OptimizationJobDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<OptimizationJobDeleteResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("jobId", params.jobId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "repos", + params._pathParam(0), + params._pathParam(1), + "optimization-jobs", + params._pathParam(2), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val optimizationJobsHandler: Handler<PromptOptimizationJob> = + jsonHandler<PromptOptimizationJob>(clientOptions.jsonMapper) + + override fun optimizationJobs( + params: OptimizationJobOptimizationJobsParams, + requestOptions: RequestOptions, + ): HttpResponseFor<PromptOptimizationJob> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("repo", params.repo().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "repos", + params._pathParam(0), + params._pathParam(1), + "optimization-jobs", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { optimizationJobsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveOptimizationJobsHandler: Handler<List<PromptOptimizationJob>> = + jsonHandler<List<PromptOptimizationJob>>(clientOptions.jsonMapper) + + override fun retrieveOptimizationJobs( + params: OptimizationJobRetrieveOptimizationJobsParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<PromptOptimizationJob>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("repo", params.repo().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "repos", + params._pathParam(0), + params._pathParam(1), + "optimization-jobs", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveOptimizationJobsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/repos/TagService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/repos/TagService.kt new file mode 100644 index 00000000..899cfdcc --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/repos/TagService.kt @@ -0,0 +1,286 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.repos + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.repos.tags.RepoTag +import com.langsmith_api.api.models.api.v1.repos.tags.TagCreateParams +import com.langsmith_api.api.models.api.v1.repos.tags.TagDeleteParams +import com.langsmith_api.api.models.api.v1.repos.tags.TagDeleteResponse +import com.langsmith_api.api.models.api.v1.repos.tags.TagListParams +import com.langsmith_api.api.models.api.v1.repos.tags.TagRetrieveParams +import com.langsmith_api.api.models.api.v1.repos.tags.TagUpdateParams +import java.util.function.Consumer + +interface TagService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): TagService + + /** Create Tag */ + fun create(repo: String, params: TagCreateParams): RepoTag = + create(repo, params, RequestOptions.none()) + + /** @see create */ + fun create( + repo: String, + params: TagCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RepoTag = create(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see create */ + fun create(params: TagCreateParams): RepoTag = create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: TagCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RepoTag + + /** Get Tag */ + fun retrieve(tagName: String, params: TagRetrieveParams): RepoTag = + retrieve(tagName, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + tagName: String, + params: TagRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RepoTag = retrieve(params.toBuilder().tagName(tagName).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: TagRetrieveParams): RepoTag = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: TagRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RepoTag + + /** Update Tag */ + fun update(tagName: String, params: TagUpdateParams): RepoTag = + update(tagName, params, RequestOptions.none()) + + /** @see update */ + fun update( + tagName: String, + params: TagUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RepoTag = update(params.toBuilder().tagName(tagName).build(), requestOptions) + + /** @see update */ + fun update(params: TagUpdateParams): RepoTag = update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: TagUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RepoTag + + /** Get Tags */ + fun list(repo: String, params: TagListParams): List<RepoTag> = + list(repo, params, RequestOptions.none()) + + /** @see list */ + fun list( + repo: String, + params: TagListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List<RepoTag> = list(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see list */ + fun list(params: TagListParams): List<RepoTag> = list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: TagListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List<RepoTag> + + /** Delete Tag */ + fun delete(tagName: String, params: TagDeleteParams): TagDeleteResponse = + delete(tagName, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + tagName: String, + params: TagDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): TagDeleteResponse = delete(params.toBuilder().tagName(tagName).build(), requestOptions) + + /** @see delete */ + fun delete(params: TagDeleteParams): TagDeleteResponse = delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: TagDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): TagDeleteResponse + + /** A view of [TagService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): TagService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/repos/{owner}/{repo}/tags`, but is + * otherwise the same as [TagService.create]. + */ + @MustBeClosed + fun create(repo: String, params: TagCreateParams): HttpResponseFor<RepoTag> = + create(repo, params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + repo: String, + params: TagCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RepoTag> = create(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(params: TagCreateParams): HttpResponseFor<RepoTag> = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: TagCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RepoTag> + + /** + * Returns a raw HTTP response for `get /api/v1/repos/{owner}/{repo}/tags/{tag_name}`, but + * is otherwise the same as [TagService.retrieve]. + */ + @MustBeClosed + fun retrieve(tagName: String, params: TagRetrieveParams): HttpResponseFor<RepoTag> = + retrieve(tagName, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + tagName: String, + params: TagRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RepoTag> = + retrieve(params.toBuilder().tagName(tagName).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: TagRetrieveParams): HttpResponseFor<RepoTag> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: TagRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RepoTag> + + /** + * Returns a raw HTTP response for `patch /api/v1/repos/{owner}/{repo}/tags/{tag_name}`, but + * is otherwise the same as [TagService.update]. + */ + @MustBeClosed + fun update(tagName: String, params: TagUpdateParams): HttpResponseFor<RepoTag> = + update(tagName, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + tagName: String, + params: TagUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RepoTag> = + update(params.toBuilder().tagName(tagName).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(params: TagUpdateParams): HttpResponseFor<RepoTag> = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: TagUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RepoTag> + + /** + * Returns a raw HTTP response for `get /api/v1/repos/{owner}/{repo}/tags`, but is otherwise + * the same as [TagService.list]. + */ + @MustBeClosed + fun list(repo: String, params: TagListParams): HttpResponseFor<List<RepoTag>> = + list(repo, params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + repo: String, + params: TagListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<RepoTag>> = + list(params.toBuilder().repo(repo).build(), requestOptions) + + /** @see list */ + @MustBeClosed + fun list(params: TagListParams): HttpResponseFor<List<RepoTag>> = + list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: TagListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<RepoTag>> + + /** + * Returns a raw HTTP response for `delete /api/v1/repos/{owner}/{repo}/tags/{tag_name}`, + * but is otherwise the same as [TagService.delete]. + */ + @MustBeClosed + fun delete(tagName: String, params: TagDeleteParams): HttpResponseFor<TagDeleteResponse> = + delete(tagName, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + tagName: String, + params: TagDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<TagDeleteResponse> = + delete(params.toBuilder().tagName(tagName).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete(params: TagDeleteParams): HttpResponseFor<TagDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: TagDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<TagDeleteResponse> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/repos/TagServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/repos/TagServiceImpl.kt new file mode 100644 index 00000000..b6e597f5 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/repos/TagServiceImpl.kt @@ -0,0 +1,265 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.repos + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.repos.tags.RepoTag +import com.langsmith_api.api.models.api.v1.repos.tags.TagCreateParams +import com.langsmith_api.api.models.api.v1.repos.tags.TagDeleteParams +import com.langsmith_api.api.models.api.v1.repos.tags.TagDeleteResponse +import com.langsmith_api.api.models.api.v1.repos.tags.TagListParams +import com.langsmith_api.api.models.api.v1.repos.tags.TagRetrieveParams +import com.langsmith_api.api.models.api.v1.repos.tags.TagUpdateParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class TagServiceImpl internal constructor(private val clientOptions: ClientOptions) : TagService { + + private val withRawResponse: TagService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): TagService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): TagService = + TagServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create(params: TagCreateParams, requestOptions: RequestOptions): RepoTag = + // post /api/v1/repos/{owner}/{repo}/tags + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve(params: TagRetrieveParams, requestOptions: RequestOptions): RepoTag = + // get /api/v1/repos/{owner}/{repo}/tags/{tag_name} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update(params: TagUpdateParams, requestOptions: RequestOptions): RepoTag = + // patch /api/v1/repos/{owner}/{repo}/tags/{tag_name} + withRawResponse().update(params, requestOptions).parse() + + override fun list(params: TagListParams, requestOptions: RequestOptions): List<RepoTag> = + // get /api/v1/repos/{owner}/{repo}/tags + withRawResponse().list(params, requestOptions).parse() + + override fun delete( + params: TagDeleteParams, + requestOptions: RequestOptions, + ): TagDeleteResponse = + // delete /api/v1/repos/{owner}/{repo}/tags/{tag_name} + withRawResponse().delete(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TagService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): TagService.WithRawResponse = + TagServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<RepoTag> = jsonHandler<RepoTag>(clientOptions.jsonMapper) + + override fun create( + params: TagCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<RepoTag> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("repo", params.repo().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "repos", + params._pathParam(0), + params._pathParam(1), + "tags", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler<RepoTag> = + jsonHandler<RepoTag>(clientOptions.jsonMapper) + + override fun retrieve( + params: TagRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor<RepoTag> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tagName", params.tagName().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "repos", + params._pathParam(0), + params._pathParam(1), + "tags", + params._pathParam(2), + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler<RepoTag> = jsonHandler<RepoTag>(clientOptions.jsonMapper) + + override fun update( + params: TagUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<RepoTag> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tagName", params.tagName().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "repos", + params._pathParam(0), + params._pathParam(1), + "tags", + params._pathParam(2), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler<List<RepoTag>> = + jsonHandler<List<RepoTag>>(clientOptions.jsonMapper) + + override fun list( + params: TagListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<RepoTag>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("repo", params.repo().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "repos", + params._pathParam(0), + params._pathParam(1), + "tags", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val deleteHandler: Handler<TagDeleteResponse> = + jsonHandler<TagDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: TagDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<TagDeleteResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tagName", params.tagName().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "repos", + params._pathParam(0), + params._pathParam(1), + "tags", + params._pathParam(2), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/repos/optimizationjobs/LogService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/repos/optimizationjobs/LogService.kt new file mode 100644 index 00000000..7062b5b7 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/repos/optimizationjobs/LogService.kt @@ -0,0 +1,253 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.repos.optimizationjobs + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs.LogCreateParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs.LogDeleteParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs.LogDeleteResponse +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs.LogListParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs.LogRetrieveParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs.PromptOptimizationJobLog +import java.util.function.Consumer + +interface LogService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): LogService + + /** Create a new log entry for a prompt optimization job. */ + fun create(jobId: String, params: LogCreateParams): PromptOptimizationJobLog = + create(jobId, params, RequestOptions.none()) + + /** @see create */ + fun create( + jobId: String, + params: LogCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): PromptOptimizationJobLog = create(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see create */ + fun create(params: LogCreateParams): PromptOptimizationJobLog = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: LogCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): PromptOptimizationJobLog + + /** Get a specific prompt optimization job log. */ + fun retrieve(logId: String, params: LogRetrieveParams): PromptOptimizationJobLog = + retrieve(logId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + logId: String, + params: LogRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): PromptOptimizationJobLog = retrieve(params.toBuilder().logId(logId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: LogRetrieveParams): PromptOptimizationJobLog = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: LogRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): PromptOptimizationJobLog + + /** List all logs for a specific prompt optimization job. */ + fun list(jobId: String, params: LogListParams): List<PromptOptimizationJobLog> = + list(jobId, params, RequestOptions.none()) + + /** @see list */ + fun list( + jobId: String, + params: LogListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List<PromptOptimizationJobLog> = + list(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see list */ + fun list(params: LogListParams): List<PromptOptimizationJobLog> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: LogListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List<PromptOptimizationJobLog> + + /** Delete a prompt optimization job log. */ + fun delete(logId: String, params: LogDeleteParams): LogDeleteResponse = + delete(logId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + logId: String, + params: LogDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LogDeleteResponse = delete(params.toBuilder().logId(logId).build(), requestOptions) + + /** @see delete */ + fun delete(params: LogDeleteParams): LogDeleteResponse = delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: LogDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LogDeleteResponse + + /** A view of [LogService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): LogService.WithRawResponse + + /** + * Returns a raw HTTP response for `post + * /api/v1/repos/{owner}/{repo}/optimization-jobs/{job_id}/logs`, but is otherwise the same + * as [LogService.create]. + */ + @MustBeClosed + fun create( + jobId: String, + params: LogCreateParams, + ): HttpResponseFor<PromptOptimizationJobLog> = create(jobId, params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + jobId: String, + params: LogCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<PromptOptimizationJobLog> = + create(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(params: LogCreateParams): HttpResponseFor<PromptOptimizationJobLog> = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: LogCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<PromptOptimizationJobLog> + + /** + * Returns a raw HTTP response for `get + * /api/v1/repos/{owner}/{repo}/optimization-jobs/{job_id}/logs/{log_id}`, but is otherwise + * the same as [LogService.retrieve]. + */ + @MustBeClosed + fun retrieve( + logId: String, + params: LogRetrieveParams, + ): HttpResponseFor<PromptOptimizationJobLog> = + retrieve(logId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + logId: String, + params: LogRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<PromptOptimizationJobLog> = + retrieve(params.toBuilder().logId(logId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: LogRetrieveParams): HttpResponseFor<PromptOptimizationJobLog> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: LogRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<PromptOptimizationJobLog> + + /** + * Returns a raw HTTP response for `get + * /api/v1/repos/{owner}/{repo}/optimization-jobs/{job_id}/logs`, but is otherwise the same + * as [LogService.list]. + */ + @MustBeClosed + fun list( + jobId: String, + params: LogListParams, + ): HttpResponseFor<List<PromptOptimizationJobLog>> = + list(jobId, params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + jobId: String, + params: LogListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<PromptOptimizationJobLog>> = + list(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see list */ + @MustBeClosed + fun list(params: LogListParams): HttpResponseFor<List<PromptOptimizationJobLog>> = + list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: LogListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<PromptOptimizationJobLog>> + + /** + * Returns a raw HTTP response for `delete + * /api/v1/repos/{owner}/{repo}/optimization-jobs/{job_id}/logs/{log_id}`, but is otherwise + * the same as [LogService.delete]. + */ + @MustBeClosed + fun delete(logId: String, params: LogDeleteParams): HttpResponseFor<LogDeleteResponse> = + delete(logId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + logId: String, + params: LogDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<LogDeleteResponse> = + delete(params.toBuilder().logId(logId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete(params: LogDeleteParams): HttpResponseFor<LogDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: LogDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<LogDeleteResponse> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/repos/optimizationjobs/LogServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/repos/optimizationjobs/LogServiceImpl.kt new file mode 100644 index 00000000..b99b5d77 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/repos/optimizationjobs/LogServiceImpl.kt @@ -0,0 +1,240 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.repos.optimizationjobs + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs.LogCreateParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs.LogDeleteParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs.LogDeleteResponse +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs.LogListParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs.LogRetrieveParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs.PromptOptimizationJobLog +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class LogServiceImpl internal constructor(private val clientOptions: ClientOptions) : LogService { + + private val withRawResponse: LogService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): LogService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): LogService = + LogServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: LogCreateParams, + requestOptions: RequestOptions, + ): PromptOptimizationJobLog = + // post /api/v1/repos/{owner}/{repo}/optimization-jobs/{job_id}/logs + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve( + params: LogRetrieveParams, + requestOptions: RequestOptions, + ): PromptOptimizationJobLog = + // get /api/v1/repos/{owner}/{repo}/optimization-jobs/{job_id}/logs/{log_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun list( + params: LogListParams, + requestOptions: RequestOptions, + ): List<PromptOptimizationJobLog> = + // get /api/v1/repos/{owner}/{repo}/optimization-jobs/{job_id}/logs + withRawResponse().list(params, requestOptions).parse() + + override fun delete( + params: LogDeleteParams, + requestOptions: RequestOptions, + ): LogDeleteResponse = + // delete /api/v1/repos/{owner}/{repo}/optimization-jobs/{job_id}/logs/{log_id} + withRawResponse().delete(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + LogService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): LogService.WithRawResponse = + LogServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<PromptOptimizationJobLog> = + jsonHandler<PromptOptimizationJobLog>(clientOptions.jsonMapper) + + override fun create( + params: LogCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<PromptOptimizationJobLog> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("jobId", params.jobId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "repos", + params._pathParam(0), + params._pathParam(1), + "optimization-jobs", + params._pathParam(2), + "logs", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler<PromptOptimizationJobLog> = + jsonHandler<PromptOptimizationJobLog>(clientOptions.jsonMapper) + + override fun retrieve( + params: LogRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor<PromptOptimizationJobLog> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("logId", params.logId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "repos", + params._pathParam(0), + params._pathParam(1), + "optimization-jobs", + params._pathParam(2), + "logs", + params._pathParam(3), + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler<List<PromptOptimizationJobLog>> = + jsonHandler<List<PromptOptimizationJobLog>>(clientOptions.jsonMapper) + + override fun list( + params: LogListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<PromptOptimizationJobLog>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("jobId", params.jobId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "repos", + params._pathParam(0), + params._pathParam(1), + "optimization-jobs", + params._pathParam(2), + "logs", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val deleteHandler: Handler<LogDeleteResponse> = + jsonHandler<LogDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: LogDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<LogDeleteResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("logId", params.logId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "repos", + params._pathParam(0), + params._pathParam(1), + "optimization-jobs", + params._pathParam(2), + "logs", + params._pathParam(3), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/GroupService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/GroupService.kt new file mode 100644 index 00000000..092551fa --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/GroupService.kt @@ -0,0 +1,143 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.runs + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.runs.group.GroupCreateParams +import com.langsmith_api.api.models.api.v1.runs.group.GroupCreateResponse +import com.langsmith_api.api.models.api.v1.runs.group.GroupStatsParams +import com.langsmith_api.api.models.api.v1.runs.group.GroupStatsResponse +import com.langsmith_api.api.models.api.v1.runs.group.RunGroupRequest +import java.util.function.Consumer + +interface GroupService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): GroupService + + /** Get runs grouped by an expression */ + fun create(params: GroupCreateParams): GroupCreateResponse = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: GroupCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): GroupCreateResponse + + /** @see create */ + fun create( + runGroupRequest: RunGroupRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): GroupCreateResponse = + create(GroupCreateParams.builder().runGroupRequest(runGroupRequest).build(), requestOptions) + + /** @see create */ + fun create(runGroupRequest: RunGroupRequest): GroupCreateResponse = + create(runGroupRequest, RequestOptions.none()) + + /** Get stats for the grouped runs. */ + fun stats(params: GroupStatsParams): GroupStatsResponse = stats(params, RequestOptions.none()) + + /** @see stats */ + fun stats( + params: GroupStatsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): GroupStatsResponse + + /** @see stats */ + fun stats( + runGroupRequest: RunGroupRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): GroupStatsResponse = + stats(GroupStatsParams.builder().runGroupRequest(runGroupRequest).build(), requestOptions) + + /** @see stats */ + fun stats(runGroupRequest: RunGroupRequest): GroupStatsResponse = + stats(runGroupRequest, RequestOptions.none()) + + /** A view of [GroupService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): GroupService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/runs/group`, but is otherwise the same as + * [GroupService.create]. + */ + @MustBeClosed + fun create(params: GroupCreateParams): HttpResponseFor<GroupCreateResponse> = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: GroupCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<GroupCreateResponse> + + /** @see create */ + @MustBeClosed + fun create( + runGroupRequest: RunGroupRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<GroupCreateResponse> = + create( + GroupCreateParams.builder().runGroupRequest(runGroupRequest).build(), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create(runGroupRequest: RunGroupRequest): HttpResponseFor<GroupCreateResponse> = + create(runGroupRequest, RequestOptions.none()) + + /** + * Returns a raw HTTP response for `post /api/v1/runs/group/stats`, but is otherwise the + * same as [GroupService.stats]. + */ + @MustBeClosed + fun stats(params: GroupStatsParams): HttpResponseFor<GroupStatsResponse> = + stats(params, RequestOptions.none()) + + /** @see stats */ + @MustBeClosed + fun stats( + params: GroupStatsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<GroupStatsResponse> + + /** @see stats */ + @MustBeClosed + fun stats( + runGroupRequest: RunGroupRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<GroupStatsResponse> = + stats( + GroupStatsParams.builder().runGroupRequest(runGroupRequest).build(), + requestOptions, + ) + + /** @see stats */ + @MustBeClosed + fun stats(runGroupRequest: RunGroupRequest): HttpResponseFor<GroupStatsResponse> = + stats(runGroupRequest, RequestOptions.none()) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/GroupServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/GroupServiceImpl.kt new file mode 100644 index 00000000..c265df82 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/GroupServiceImpl.kt @@ -0,0 +1,119 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.runs + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.runs.group.GroupCreateParams +import com.langsmith_api.api.models.api.v1.runs.group.GroupCreateResponse +import com.langsmith_api.api.models.api.v1.runs.group.GroupStatsParams +import com.langsmith_api.api.models.api.v1.runs.group.GroupStatsResponse +import java.util.function.Consumer + +class GroupServiceImpl internal constructor(private val clientOptions: ClientOptions) : + GroupService { + + private val withRawResponse: GroupService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): GroupService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): GroupService = + GroupServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: GroupCreateParams, + requestOptions: RequestOptions, + ): GroupCreateResponse = + // post /api/v1/runs/group + withRawResponse().create(params, requestOptions).parse() + + override fun stats( + params: GroupStatsParams, + requestOptions: RequestOptions, + ): GroupStatsResponse = + // post /api/v1/runs/group/stats + withRawResponse().stats(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + GroupService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): GroupService.WithRawResponse = + GroupServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<GroupCreateResponse> = + jsonHandler<GroupCreateResponse>(clientOptions.jsonMapper) + + override fun create( + params: GroupCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<GroupCreateResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", "group") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val statsHandler: Handler<GroupStatsResponse> = + jsonHandler<GroupStatsResponse>(clientOptions.jsonMapper) + + override fun stats( + params: GroupStatsParams, + requestOptions: RequestOptions, + ): HttpResponseFor<GroupStatsResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", "group", "stats") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { statsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/RuleService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/RuleService.kt new file mode 100644 index 00000000..fe5bce7a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/RuleService.kt @@ -0,0 +1,391 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.runs + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.runs.rules.RuleCreateParams +import com.langsmith_api.api.models.api.v1.runs.rules.RuleDeleteParams +import com.langsmith_api.api.models.api.v1.runs.rules.RuleDeleteResponse +import com.langsmith_api.api.models.api.v1.runs.rules.RuleListParams +import com.langsmith_api.api.models.api.v1.runs.rules.RuleLogSchema +import com.langsmith_api.api.models.api.v1.runs.rules.RuleRetrieveLastAppliedParams +import com.langsmith_api.api.models.api.v1.runs.rules.RuleRetrieveLogsParams +import com.langsmith_api.api.models.api.v1.runs.rules.RuleUpdateParams +import com.langsmith_api.api.models.api.v1.runs.rules.RunRulesSchema +import com.langsmith_api.api.services.blocking.api.v1.runs.rules.TriggerService +import java.util.function.Consumer + +interface RuleService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RuleService + + fun trigger(): TriggerService + + /** Create a new run rule. */ + fun create(params: RuleCreateParams): RunRulesSchema = create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: RuleCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RunRulesSchema + + /** Update a run rule. */ + fun update(ruleId: String, params: RuleUpdateParams): RunRulesSchema = + update(ruleId, params, RequestOptions.none()) + + /** @see update */ + fun update( + ruleId: String, + params: RuleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RunRulesSchema = update(params.toBuilder().ruleId(ruleId).build(), requestOptions) + + /** @see update */ + fun update(params: RuleUpdateParams): RunRulesSchema = update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: RuleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RunRulesSchema + + /** List all run rules. */ + fun list(): List<RunRulesSchema> = list(RuleListParams.none()) + + /** @see list */ + fun list( + params: RuleListParams = RuleListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<RunRulesSchema> + + /** @see list */ + fun list(params: RuleListParams = RuleListParams.none()): List<RunRulesSchema> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): List<RunRulesSchema> = + list(RuleListParams.none(), requestOptions) + + /** Delete a run rule. */ + fun delete(ruleId: String): RuleDeleteResponse = delete(ruleId, RuleDeleteParams.none()) + + /** @see delete */ + fun delete( + ruleId: String, + params: RuleDeleteParams = RuleDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): RuleDeleteResponse = delete(params.toBuilder().ruleId(ruleId).build(), requestOptions) + + /** @see delete */ + fun delete( + ruleId: String, + params: RuleDeleteParams = RuleDeleteParams.none(), + ): RuleDeleteResponse = delete(ruleId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: RuleDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RuleDeleteResponse + + /** @see delete */ + fun delete(params: RuleDeleteParams): RuleDeleteResponse = delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(ruleId: String, requestOptions: RequestOptions): RuleDeleteResponse = + delete(ruleId, RuleDeleteParams.none(), requestOptions) + + /** Get the last applied rule. */ + fun retrieveLastApplied(ruleId: String): RuleLogSchema = + retrieveLastApplied(ruleId, RuleRetrieveLastAppliedParams.none()) + + /** @see retrieveLastApplied */ + fun retrieveLastApplied( + ruleId: String, + params: RuleRetrieveLastAppliedParams = RuleRetrieveLastAppliedParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): RuleLogSchema = + retrieveLastApplied(params.toBuilder().ruleId(ruleId).build(), requestOptions) + + /** @see retrieveLastApplied */ + fun retrieveLastApplied( + ruleId: String, + params: RuleRetrieveLastAppliedParams = RuleRetrieveLastAppliedParams.none(), + ): RuleLogSchema = retrieveLastApplied(ruleId, params, RequestOptions.none()) + + /** @see retrieveLastApplied */ + fun retrieveLastApplied( + params: RuleRetrieveLastAppliedParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RuleLogSchema + + /** @see retrieveLastApplied */ + fun retrieveLastApplied(params: RuleRetrieveLastAppliedParams): RuleLogSchema = + retrieveLastApplied(params, RequestOptions.none()) + + /** @see retrieveLastApplied */ + fun retrieveLastApplied(ruleId: String, requestOptions: RequestOptions): RuleLogSchema = + retrieveLastApplied(ruleId, RuleRetrieveLastAppliedParams.none(), requestOptions) + + /** List logs for a particular rule */ + fun retrieveLogs(ruleId: String): List<RuleLogSchema> = + retrieveLogs(ruleId, RuleRetrieveLogsParams.none()) + + /** @see retrieveLogs */ + fun retrieveLogs( + ruleId: String, + params: RuleRetrieveLogsParams = RuleRetrieveLogsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<RuleLogSchema> = retrieveLogs(params.toBuilder().ruleId(ruleId).build(), requestOptions) + + /** @see retrieveLogs */ + fun retrieveLogs( + ruleId: String, + params: RuleRetrieveLogsParams = RuleRetrieveLogsParams.none(), + ): List<RuleLogSchema> = retrieveLogs(ruleId, params, RequestOptions.none()) + + /** @see retrieveLogs */ + fun retrieveLogs( + params: RuleRetrieveLogsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List<RuleLogSchema> + + /** @see retrieveLogs */ + fun retrieveLogs(params: RuleRetrieveLogsParams): List<RuleLogSchema> = + retrieveLogs(params, RequestOptions.none()) + + /** @see retrieveLogs */ + fun retrieveLogs(ruleId: String, requestOptions: RequestOptions): List<RuleLogSchema> = + retrieveLogs(ruleId, RuleRetrieveLogsParams.none(), requestOptions) + + /** A view of [RuleService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RuleService.WithRawResponse + + fun trigger(): TriggerService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/runs/rules`, but is otherwise the same as + * [RuleService.create]. + */ + @MustBeClosed + fun create(params: RuleCreateParams): HttpResponseFor<RunRulesSchema> = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: RuleCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RunRulesSchema> + + /** + * Returns a raw HTTP response for `patch /api/v1/runs/rules/{rule_id}`, but is otherwise + * the same as [RuleService.update]. + */ + @MustBeClosed + fun update(ruleId: String, params: RuleUpdateParams): HttpResponseFor<RunRulesSchema> = + update(ruleId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + ruleId: String, + params: RuleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RunRulesSchema> = + update(params.toBuilder().ruleId(ruleId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(params: RuleUpdateParams): HttpResponseFor<RunRulesSchema> = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: RuleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RunRulesSchema> + + /** + * Returns a raw HTTP response for `get /api/v1/runs/rules`, but is otherwise the same as + * [RuleService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor<List<RunRulesSchema>> = list(RuleListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: RuleListParams = RuleListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<RunRulesSchema>> + + /** @see list */ + @MustBeClosed + fun list( + params: RuleListParams = RuleListParams.none() + ): HttpResponseFor<List<RunRulesSchema>> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor<List<RunRulesSchema>> = + list(RuleListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/runs/rules/{rule_id}`, but is otherwise + * the same as [RuleService.delete]. + */ + @MustBeClosed + fun delete(ruleId: String): HttpResponseFor<RuleDeleteResponse> = + delete(ruleId, RuleDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + ruleId: String, + params: RuleDeleteParams = RuleDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RuleDeleteResponse> = + delete(params.toBuilder().ruleId(ruleId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + ruleId: String, + params: RuleDeleteParams = RuleDeleteParams.none(), + ): HttpResponseFor<RuleDeleteResponse> = delete(ruleId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: RuleDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RuleDeleteResponse> + + /** @see delete */ + @MustBeClosed + fun delete(params: RuleDeleteParams): HttpResponseFor<RuleDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + ruleId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<RuleDeleteResponse> = + delete(ruleId, RuleDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/runs/rules/{rule_id}/last_applied`, but is + * otherwise the same as [RuleService.retrieveLastApplied]. + */ + @MustBeClosed + fun retrieveLastApplied(ruleId: String): HttpResponseFor<RuleLogSchema> = + retrieveLastApplied(ruleId, RuleRetrieveLastAppliedParams.none()) + + /** @see retrieveLastApplied */ + @MustBeClosed + fun retrieveLastApplied( + ruleId: String, + params: RuleRetrieveLastAppliedParams = RuleRetrieveLastAppliedParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RuleLogSchema> = + retrieveLastApplied(params.toBuilder().ruleId(ruleId).build(), requestOptions) + + /** @see retrieveLastApplied */ + @MustBeClosed + fun retrieveLastApplied( + ruleId: String, + params: RuleRetrieveLastAppliedParams = RuleRetrieveLastAppliedParams.none(), + ): HttpResponseFor<RuleLogSchema> = + retrieveLastApplied(ruleId, params, RequestOptions.none()) + + /** @see retrieveLastApplied */ + @MustBeClosed + fun retrieveLastApplied( + params: RuleRetrieveLastAppliedParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RuleLogSchema> + + /** @see retrieveLastApplied */ + @MustBeClosed + fun retrieveLastApplied( + params: RuleRetrieveLastAppliedParams + ): HttpResponseFor<RuleLogSchema> = retrieveLastApplied(params, RequestOptions.none()) + + /** @see retrieveLastApplied */ + @MustBeClosed + fun retrieveLastApplied( + ruleId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<RuleLogSchema> = + retrieveLastApplied(ruleId, RuleRetrieveLastAppliedParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/runs/rules/{rule_id}/logs`, but is otherwise + * the same as [RuleService.retrieveLogs]. + */ + @MustBeClosed + fun retrieveLogs(ruleId: String): HttpResponseFor<List<RuleLogSchema>> = + retrieveLogs(ruleId, RuleRetrieveLogsParams.none()) + + /** @see retrieveLogs */ + @MustBeClosed + fun retrieveLogs( + ruleId: String, + params: RuleRetrieveLogsParams = RuleRetrieveLogsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<RuleLogSchema>> = + retrieveLogs(params.toBuilder().ruleId(ruleId).build(), requestOptions) + + /** @see retrieveLogs */ + @MustBeClosed + fun retrieveLogs( + ruleId: String, + params: RuleRetrieveLogsParams = RuleRetrieveLogsParams.none(), + ): HttpResponseFor<List<RuleLogSchema>> = + retrieveLogs(ruleId, params, RequestOptions.none()) + + /** @see retrieveLogs */ + @MustBeClosed + fun retrieveLogs( + params: RuleRetrieveLogsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<RuleLogSchema>> + + /** @see retrieveLogs */ + @MustBeClosed + fun retrieveLogs(params: RuleRetrieveLogsParams): HttpResponseFor<List<RuleLogSchema>> = + retrieveLogs(params, RequestOptions.none()) + + /** @see retrieveLogs */ + @MustBeClosed + fun retrieveLogs( + ruleId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<List<RuleLogSchema>> = + retrieveLogs(ruleId, RuleRetrieveLogsParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/RuleServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/RuleServiceImpl.kt new file mode 100644 index 00000000..d494d6c1 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/RuleServiceImpl.kt @@ -0,0 +1,287 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.runs + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.runs.rules.RuleCreateParams +import com.langsmith_api.api.models.api.v1.runs.rules.RuleDeleteParams +import com.langsmith_api.api.models.api.v1.runs.rules.RuleDeleteResponse +import com.langsmith_api.api.models.api.v1.runs.rules.RuleListParams +import com.langsmith_api.api.models.api.v1.runs.rules.RuleLogSchema +import com.langsmith_api.api.models.api.v1.runs.rules.RuleRetrieveLastAppliedParams +import com.langsmith_api.api.models.api.v1.runs.rules.RuleRetrieveLogsParams +import com.langsmith_api.api.models.api.v1.runs.rules.RuleUpdateParams +import com.langsmith_api.api.models.api.v1.runs.rules.RunRulesSchema +import com.langsmith_api.api.services.blocking.api.v1.runs.rules.TriggerService +import com.langsmith_api.api.services.blocking.api.v1.runs.rules.TriggerServiceImpl +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class RuleServiceImpl internal constructor(private val clientOptions: ClientOptions) : RuleService { + + private val withRawResponse: RuleService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val trigger: TriggerService by lazy { TriggerServiceImpl(clientOptions) } + + override fun withRawResponse(): RuleService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): RuleService = + RuleServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun trigger(): TriggerService = trigger + + override fun create(params: RuleCreateParams, requestOptions: RequestOptions): RunRulesSchema = + // post /api/v1/runs/rules + withRawResponse().create(params, requestOptions).parse() + + override fun update(params: RuleUpdateParams, requestOptions: RequestOptions): RunRulesSchema = + // patch /api/v1/runs/rules/{rule_id} + withRawResponse().update(params, requestOptions).parse() + + override fun list( + params: RuleListParams, + requestOptions: RequestOptions, + ): List<RunRulesSchema> = + // get /api/v1/runs/rules + withRawResponse().list(params, requestOptions).parse() + + override fun delete( + params: RuleDeleteParams, + requestOptions: RequestOptions, + ): RuleDeleteResponse = + // delete /api/v1/runs/rules/{rule_id} + withRawResponse().delete(params, requestOptions).parse() + + override fun retrieveLastApplied( + params: RuleRetrieveLastAppliedParams, + requestOptions: RequestOptions, + ): RuleLogSchema = + // get /api/v1/runs/rules/{rule_id}/last_applied + withRawResponse().retrieveLastApplied(params, requestOptions).parse() + + override fun retrieveLogs( + params: RuleRetrieveLogsParams, + requestOptions: RequestOptions, + ): List<RuleLogSchema> = + // get /api/v1/runs/rules/{rule_id}/logs + withRawResponse().retrieveLogs(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RuleService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val trigger: TriggerService.WithRawResponse by lazy { + TriggerServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): RuleService.WithRawResponse = + RuleServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun trigger(): TriggerService.WithRawResponse = trigger + + private val createHandler: Handler<RunRulesSchema> = + jsonHandler<RunRulesSchema>(clientOptions.jsonMapper) + + override fun create( + params: RuleCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<RunRulesSchema> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", "rules") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler<RunRulesSchema> = + jsonHandler<RunRulesSchema>(clientOptions.jsonMapper) + + override fun update( + params: RuleUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<RunRulesSchema> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("ruleId", params.ruleId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", "rules", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler<List<RunRulesSchema>> = + jsonHandler<List<RunRulesSchema>>(clientOptions.jsonMapper) + + override fun list( + params: RuleListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<RunRulesSchema>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", "rules") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val deleteHandler: Handler<RuleDeleteResponse> = + jsonHandler<RuleDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: RuleDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<RuleDeleteResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("ruleId", params.ruleId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", "rules", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveLastAppliedHandler: Handler<RuleLogSchema> = + jsonHandler<RuleLogSchema>(clientOptions.jsonMapper) + + override fun retrieveLastApplied( + params: RuleRetrieveLastAppliedParams, + requestOptions: RequestOptions, + ): HttpResponseFor<RuleLogSchema> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("ruleId", params.ruleId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "runs", + "rules", + params._pathParam(0), + "last_applied", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveLastAppliedHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveLogsHandler: Handler<List<RuleLogSchema>> = + jsonHandler<List<RuleLogSchema>>(clientOptions.jsonMapper) + + override fun retrieveLogs( + params: RuleRetrieveLogsParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<RuleLogSchema>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("ruleId", params.ruleId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", "rules", params._pathParam(0), "logs") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveLogsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/ShareService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/ShareService.kt new file mode 100644 index 00000000..b923ea8e --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/ShareService.kt @@ -0,0 +1,260 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.runs + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.runs.share.RunShareSchema +import com.langsmith_api.api.models.api.v1.runs.share.ShareCreateParams +import com.langsmith_api.api.models.api.v1.runs.share.ShareDeleteAllParams +import com.langsmith_api.api.models.api.v1.runs.share.ShareDeleteAllResponse +import com.langsmith_api.api.models.api.v1.runs.share.ShareListParams +import java.util.Optional +import java.util.function.Consumer + +interface ShareService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ShareService + + /** Share a run. */ + fun create(runId: String): RunShareSchema = create(runId, ShareCreateParams.none()) + + /** @see create */ + fun create( + runId: String, + params: ShareCreateParams = ShareCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): RunShareSchema = create(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see create */ + fun create( + runId: String, + params: ShareCreateParams = ShareCreateParams.none(), + ): RunShareSchema = create(runId, params, RequestOptions.none()) + + /** @see create */ + fun create( + params: ShareCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RunShareSchema + + /** @see create */ + fun create(params: ShareCreateParams): RunShareSchema = create(params, RequestOptions.none()) + + /** @see create */ + fun create(runId: String, requestOptions: RequestOptions): RunShareSchema = + create(runId, ShareCreateParams.none(), requestOptions) + + /** Get the state of sharing of a run. */ + fun list(runId: String): Optional<RunShareSchema> = list(runId, ShareListParams.none()) + + /** @see list */ + fun list( + runId: String, + params: ShareListParams = ShareListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Optional<RunShareSchema> = list(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see list */ + fun list( + runId: String, + params: ShareListParams = ShareListParams.none(), + ): Optional<RunShareSchema> = list(runId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: ShareListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Optional<RunShareSchema> + + /** @see list */ + fun list(params: ShareListParams): Optional<RunShareSchema> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(runId: String, requestOptions: RequestOptions): Optional<RunShareSchema> = + list(runId, ShareListParams.none(), requestOptions) + + /** Unshare a run. */ + fun deleteAll(runId: String): ShareDeleteAllResponse = + deleteAll(runId, ShareDeleteAllParams.none()) + + /** @see deleteAll */ + fun deleteAll( + runId: String, + params: ShareDeleteAllParams = ShareDeleteAllParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ShareDeleteAllResponse = deleteAll(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see deleteAll */ + fun deleteAll( + runId: String, + params: ShareDeleteAllParams = ShareDeleteAllParams.none(), + ): ShareDeleteAllResponse = deleteAll(runId, params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + params: ShareDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ShareDeleteAllResponse + + /** @see deleteAll */ + fun deleteAll(params: ShareDeleteAllParams): ShareDeleteAllResponse = + deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll(runId: String, requestOptions: RequestOptions): ShareDeleteAllResponse = + deleteAll(runId, ShareDeleteAllParams.none(), requestOptions) + + /** A view of [ShareService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ShareService.WithRawResponse + + /** + * Returns a raw HTTP response for `put /api/v1/runs/{run_id}/share`, but is otherwise the + * same as [ShareService.create]. + */ + @MustBeClosed + fun create(runId: String): HttpResponseFor<RunShareSchema> = + create(runId, ShareCreateParams.none()) + + /** @see create */ + @MustBeClosed + fun create( + runId: String, + params: ShareCreateParams = ShareCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RunShareSchema> = + create(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see create */ + @MustBeClosed + fun create( + runId: String, + params: ShareCreateParams = ShareCreateParams.none(), + ): HttpResponseFor<RunShareSchema> = create(runId, params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: ShareCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<RunShareSchema> + + /** @see create */ + @MustBeClosed + fun create(params: ShareCreateParams): HttpResponseFor<RunShareSchema> = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create(runId: String, requestOptions: RequestOptions): HttpResponseFor<RunShareSchema> = + create(runId, ShareCreateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/runs/{run_id}/share`, but is otherwise the + * same as [ShareService.list]. + */ + @MustBeClosed + fun list(runId: String): HttpResponseFor<Optional<RunShareSchema>> = + list(runId, ShareListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + runId: String, + params: ShareListParams = ShareListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<Optional<RunShareSchema>> = + list(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see list */ + @MustBeClosed + fun list( + runId: String, + params: ShareListParams = ShareListParams.none(), + ): HttpResponseFor<Optional<RunShareSchema>> = list(runId, params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: ShareListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<Optional<RunShareSchema>> + + /** @see list */ + @MustBeClosed + fun list(params: ShareListParams): HttpResponseFor<Optional<RunShareSchema>> = + list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + runId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<Optional<RunShareSchema>> = + list(runId, ShareListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/runs/{run_id}/share`, but is otherwise + * the same as [ShareService.deleteAll]. + */ + @MustBeClosed + fun deleteAll(runId: String): HttpResponseFor<ShareDeleteAllResponse> = + deleteAll(runId, ShareDeleteAllParams.none()) + + /** @see deleteAll */ + @MustBeClosed + fun deleteAll( + runId: String, + params: ShareDeleteAllParams = ShareDeleteAllParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ShareDeleteAllResponse> = + deleteAll(params.toBuilder().runId(runId).build(), requestOptions) + + /** @see deleteAll */ + @MustBeClosed + fun deleteAll( + runId: String, + params: ShareDeleteAllParams = ShareDeleteAllParams.none(), + ): HttpResponseFor<ShareDeleteAllResponse> = deleteAll(runId, params, RequestOptions.none()) + + /** @see deleteAll */ + @MustBeClosed + fun deleteAll( + params: ShareDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ShareDeleteAllResponse> + + /** @see deleteAll */ + @MustBeClosed + fun deleteAll(params: ShareDeleteAllParams): HttpResponseFor<ShareDeleteAllResponse> = + deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + @MustBeClosed + fun deleteAll( + runId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<ShareDeleteAllResponse> = + deleteAll(runId, ShareDeleteAllParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/ShareServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/ShareServiceImpl.kt new file mode 100644 index 00000000..a85cb3b8 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/ShareServiceImpl.kt @@ -0,0 +1,163 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.runs + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.runs.share.RunShareSchema +import com.langsmith_api.api.models.api.v1.runs.share.ShareCreateParams +import com.langsmith_api.api.models.api.v1.runs.share.ShareDeleteAllParams +import com.langsmith_api.api.models.api.v1.runs.share.ShareDeleteAllResponse +import com.langsmith_api.api.models.api.v1.runs.share.ShareListParams +import java.util.Optional +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ShareServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ShareService { + + private val withRawResponse: ShareService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ShareService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): ShareService = + ShareServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create(params: ShareCreateParams, requestOptions: RequestOptions): RunShareSchema = + // put /api/v1/runs/{run_id}/share + withRawResponse().create(params, requestOptions).parse() + + override fun list( + params: ShareListParams, + requestOptions: RequestOptions, + ): Optional<RunShareSchema> = + // get /api/v1/runs/{run_id}/share + withRawResponse().list(params, requestOptions).parse() + + override fun deleteAll( + params: ShareDeleteAllParams, + requestOptions: RequestOptions, + ): ShareDeleteAllResponse = + // delete /api/v1/runs/{run_id}/share + withRawResponse().deleteAll(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ShareService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ShareService.WithRawResponse = + ShareServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<RunShareSchema> = + jsonHandler<RunShareSchema>(clientOptions.jsonMapper) + + override fun create( + params: ShareCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<RunShareSchema> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("runId", params.runId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", params._pathParam(0), "share") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler<Optional<RunShareSchema>> = + jsonHandler<Optional<RunShareSchema>>(clientOptions.jsonMapper) + + override fun list( + params: ShareListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<Optional<RunShareSchema>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("runId", params.runId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", params._pathParam(0), "share") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.ifPresent { it.validate() } + } + } + } + } + + private val deleteAllHandler: Handler<ShareDeleteAllResponse> = + jsonHandler<ShareDeleteAllResponse>(clientOptions.jsonMapper) + + override fun deleteAll( + params: ShareDeleteAllParams, + requestOptions: RequestOptions, + ): HttpResponseFor<ShareDeleteAllResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("runId", params.runId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", params._pathParam(0), "share") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteAllHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/rules/TriggerService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/rules/TriggerService.kt new file mode 100644 index 00000000..58bd8776 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/rules/TriggerService.kt @@ -0,0 +1,79 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.runs.rules + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.runs.rules.trigger.TriggerCreateParams +import com.langsmith_api.api.models.api.v1.runs.rules.trigger.TriggerCreateResponse +import java.util.function.Consumer + +interface TriggerService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): TriggerService + + /** Trigger an array of run rules manually. */ + fun create(): TriggerCreateResponse = create(TriggerCreateParams.none()) + + /** @see create */ + fun create( + params: TriggerCreateParams = TriggerCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): TriggerCreateResponse + + /** @see create */ + fun create(params: TriggerCreateParams = TriggerCreateParams.none()): TriggerCreateResponse = + create(params, RequestOptions.none()) + + /** @see create */ + fun create(requestOptions: RequestOptions): TriggerCreateResponse = + create(TriggerCreateParams.none(), requestOptions) + + /** A view of [TriggerService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): TriggerService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/runs/rules/trigger`, but is otherwise the + * same as [TriggerService.create]. + */ + @MustBeClosed + fun create(): HttpResponseFor<TriggerCreateResponse> = create(TriggerCreateParams.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: TriggerCreateParams = TriggerCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<TriggerCreateResponse> + + /** @see create */ + @MustBeClosed + fun create( + params: TriggerCreateParams = TriggerCreateParams.none() + ): HttpResponseFor<TriggerCreateResponse> = create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create(requestOptions: RequestOptions): HttpResponseFor<TriggerCreateResponse> = + create(TriggerCreateParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/rules/TriggerServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/rules/TriggerServiceImpl.kt new file mode 100644 index 00000000..1401c1a2 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/rules/TriggerServiceImpl.kt @@ -0,0 +1,82 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.runs.rules + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.runs.rules.trigger.TriggerCreateParams +import com.langsmith_api.api.models.api.v1.runs.rules.trigger.TriggerCreateResponse +import java.util.function.Consumer + +class TriggerServiceImpl internal constructor(private val clientOptions: ClientOptions) : + TriggerService { + + private val withRawResponse: TriggerService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): TriggerService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): TriggerService = + TriggerServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: TriggerCreateParams, + requestOptions: RequestOptions, + ): TriggerCreateResponse = + // post /api/v1/runs/rules/trigger + withRawResponse().create(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TriggerService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): TriggerService.WithRawResponse = + TriggerServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<TriggerCreateResponse> = + jsonHandler<TriggerCreateResponse>(clientOptions.jsonMapper) + + override fun create( + params: TriggerCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<TriggerCreateResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "runs", "rules", "trigger") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/sessions/InsightService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/sessions/InsightService.kt new file mode 100644 index 00000000..77a40053 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/sessions/InsightService.kt @@ -0,0 +1,396 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.sessions + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightCreateParams +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightCreateResponse +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightDeleteParams +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightDeleteResponse +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightListParams +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightListResponse +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightRetrieveParams +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightRetrieveResponse +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightRetrieveRunsParams +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightRetrieveRunsResponse +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightUpdateParams +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightUpdateResponse +import com.langsmith_api.api.services.blocking.api.v1.sessions.insights.ConfigService +import java.util.function.Consumer + +interface InsightService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): InsightService + + fun configs(): ConfigService + + /** Create an insights job. */ + fun create(sessionId: String, params: InsightCreateParams): InsightCreateResponse = + create(sessionId, params, RequestOptions.none()) + + /** @see create */ + fun create( + sessionId: String, + params: InsightCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): InsightCreateResponse = + create(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see create */ + fun create(params: InsightCreateParams): InsightCreateResponse = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: InsightCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): InsightCreateResponse + + /** Get a specific cluster for a session. */ + fun retrieve(clusterId: String, params: InsightRetrieveParams): InsightRetrieveResponse = + retrieve(clusterId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + clusterId: String, + params: InsightRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): InsightRetrieveResponse = + retrieve(params.toBuilder().clusterId(clusterId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: InsightRetrieveParams): InsightRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: InsightRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): InsightRetrieveResponse + + /** Update a session cluster job. */ + fun update(jobId: String, params: InsightUpdateParams): InsightUpdateResponse = + update(jobId, params, RequestOptions.none()) + + /** @see update */ + fun update( + jobId: String, + params: InsightUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): InsightUpdateResponse = update(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see update */ + fun update(params: InsightUpdateParams): InsightUpdateResponse = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: InsightUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): InsightUpdateResponse + + /** Get all clusters for a session. */ + fun list(sessionId: String): InsightListResponse = list(sessionId, InsightListParams.none()) + + /** @see list */ + fun list( + sessionId: String, + params: InsightListParams = InsightListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): InsightListResponse = list(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see list */ + fun list( + sessionId: String, + params: InsightListParams = InsightListParams.none(), + ): InsightListResponse = list(sessionId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: InsightListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): InsightListResponse + + /** @see list */ + fun list(params: InsightListParams): InsightListResponse = list(params, RequestOptions.none()) + + /** @see list */ + fun list(sessionId: String, requestOptions: RequestOptions): InsightListResponse = + list(sessionId, InsightListParams.none(), requestOptions) + + /** Delete a session cluster job. */ + fun delete(jobId: String, params: InsightDeleteParams): InsightDeleteResponse = + delete(jobId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + jobId: String, + params: InsightDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): InsightDeleteResponse = delete(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see delete */ + fun delete(params: InsightDeleteParams): InsightDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: InsightDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): InsightDeleteResponse + + /** Get all runs for a cluster job, optionally filtered by cluster. */ + fun retrieveRuns( + jobId: String, + params: InsightRetrieveRunsParams, + ): InsightRetrieveRunsResponse = retrieveRuns(jobId, params, RequestOptions.none()) + + /** @see retrieveRuns */ + fun retrieveRuns( + jobId: String, + params: InsightRetrieveRunsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): InsightRetrieveRunsResponse = + retrieveRuns(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see retrieveRuns */ + fun retrieveRuns(params: InsightRetrieveRunsParams): InsightRetrieveRunsResponse = + retrieveRuns(params, RequestOptions.none()) + + /** @see retrieveRuns */ + fun retrieveRuns( + params: InsightRetrieveRunsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): InsightRetrieveRunsResponse + + /** A view of [InsightService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): InsightService.WithRawResponse + + fun configs(): ConfigService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/sessions/{session_id}/insights`, but is + * otherwise the same as [InsightService.create]. + */ + @MustBeClosed + fun create( + sessionId: String, + params: InsightCreateParams, + ): HttpResponseFor<InsightCreateResponse> = create(sessionId, params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + sessionId: String, + params: InsightCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<InsightCreateResponse> = + create(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(params: InsightCreateParams): HttpResponseFor<InsightCreateResponse> = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: InsightCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<InsightCreateResponse> + + /** + * Returns a raw HTTP response for `get + * /api/v1/sessions/{session_id}/insights/{job_id}/clusters/{cluster_id}`, but is otherwise + * the same as [InsightService.retrieve]. + */ + @MustBeClosed + fun retrieve( + clusterId: String, + params: InsightRetrieveParams, + ): HttpResponseFor<InsightRetrieveResponse> = + retrieve(clusterId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + clusterId: String, + params: InsightRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<InsightRetrieveResponse> = + retrieve(params.toBuilder().clusterId(clusterId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: InsightRetrieveParams): HttpResponseFor<InsightRetrieveResponse> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: InsightRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<InsightRetrieveResponse> + + /** + * Returns a raw HTTP response for `patch /api/v1/sessions/{session_id}/insights/{job_id}`, + * but is otherwise the same as [InsightService.update]. + */ + @MustBeClosed + fun update( + jobId: String, + params: InsightUpdateParams, + ): HttpResponseFor<InsightUpdateResponse> = update(jobId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + jobId: String, + params: InsightUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<InsightUpdateResponse> = + update(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(params: InsightUpdateParams): HttpResponseFor<InsightUpdateResponse> = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: InsightUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<InsightUpdateResponse> + + /** + * Returns a raw HTTP response for `get /api/v1/sessions/{session_id}/insights`, but is + * otherwise the same as [InsightService.list]. + */ + @MustBeClosed + fun list(sessionId: String): HttpResponseFor<InsightListResponse> = + list(sessionId, InsightListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + sessionId: String, + params: InsightListParams = InsightListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<InsightListResponse> = + list(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see list */ + @MustBeClosed + fun list( + sessionId: String, + params: InsightListParams = InsightListParams.none(), + ): HttpResponseFor<InsightListResponse> = list(sessionId, params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: InsightListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<InsightListResponse> + + /** @see list */ + @MustBeClosed + fun list(params: InsightListParams): HttpResponseFor<InsightListResponse> = + list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + sessionId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<InsightListResponse> = + list(sessionId, InsightListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/sessions/{session_id}/insights/{job_id}`, + * but is otherwise the same as [InsightService.delete]. + */ + @MustBeClosed + fun delete( + jobId: String, + params: InsightDeleteParams, + ): HttpResponseFor<InsightDeleteResponse> = delete(jobId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + jobId: String, + params: InsightDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<InsightDeleteResponse> = + delete(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete(params: InsightDeleteParams): HttpResponseFor<InsightDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: InsightDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<InsightDeleteResponse> + + /** + * Returns a raw HTTP response for `get + * /api/v1/sessions/{session_id}/insights/{job_id}/runs`, but is otherwise the same as + * [InsightService.retrieveRuns]. + */ + @MustBeClosed + fun retrieveRuns( + jobId: String, + params: InsightRetrieveRunsParams, + ): HttpResponseFor<InsightRetrieveRunsResponse> = + retrieveRuns(jobId, params, RequestOptions.none()) + + /** @see retrieveRuns */ + @MustBeClosed + fun retrieveRuns( + jobId: String, + params: InsightRetrieveRunsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<InsightRetrieveRunsResponse> = + retrieveRuns(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see retrieveRuns */ + @MustBeClosed + fun retrieveRuns( + params: InsightRetrieveRunsParams + ): HttpResponseFor<InsightRetrieveRunsResponse> = + retrieveRuns(params, RequestOptions.none()) + + /** @see retrieveRuns */ + @MustBeClosed + fun retrieveRuns( + params: InsightRetrieveRunsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<InsightRetrieveRunsResponse> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/sessions/InsightServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/sessions/InsightServiceImpl.kt new file mode 100644 index 00000000..d2aff8d5 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/sessions/InsightServiceImpl.kt @@ -0,0 +1,327 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.sessions + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightCreateParams +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightCreateResponse +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightDeleteParams +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightDeleteResponse +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightListParams +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightListResponse +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightRetrieveParams +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightRetrieveResponse +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightRetrieveRunsParams +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightRetrieveRunsResponse +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightUpdateParams +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightUpdateResponse +import com.langsmith_api.api.services.blocking.api.v1.sessions.insights.ConfigService +import com.langsmith_api.api.services.blocking.api.v1.sessions.insights.ConfigServiceImpl +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class InsightServiceImpl internal constructor(private val clientOptions: ClientOptions) : + InsightService { + + private val withRawResponse: InsightService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val configs: ConfigService by lazy { ConfigServiceImpl(clientOptions) } + + override fun withRawResponse(): InsightService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): InsightService = + InsightServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun configs(): ConfigService = configs + + override fun create( + params: InsightCreateParams, + requestOptions: RequestOptions, + ): InsightCreateResponse = + // post /api/v1/sessions/{session_id}/insights + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve( + params: InsightRetrieveParams, + requestOptions: RequestOptions, + ): InsightRetrieveResponse = + // get /api/v1/sessions/{session_id}/insights/{job_id}/clusters/{cluster_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update( + params: InsightUpdateParams, + requestOptions: RequestOptions, + ): InsightUpdateResponse = + // patch /api/v1/sessions/{session_id}/insights/{job_id} + withRawResponse().update(params, requestOptions).parse() + + override fun list( + params: InsightListParams, + requestOptions: RequestOptions, + ): InsightListResponse = + // get /api/v1/sessions/{session_id}/insights + withRawResponse().list(params, requestOptions).parse() + + override fun delete( + params: InsightDeleteParams, + requestOptions: RequestOptions, + ): InsightDeleteResponse = + // delete /api/v1/sessions/{session_id}/insights/{job_id} + withRawResponse().delete(params, requestOptions).parse() + + override fun retrieveRuns( + params: InsightRetrieveRunsParams, + requestOptions: RequestOptions, + ): InsightRetrieveRunsResponse = + // get /api/v1/sessions/{session_id}/insights/{job_id}/runs + withRawResponse().retrieveRuns(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + InsightService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val configs: ConfigService.WithRawResponse by lazy { + ConfigServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): InsightService.WithRawResponse = + InsightServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun configs(): ConfigService.WithRawResponse = configs + + private val createHandler: Handler<InsightCreateResponse> = + jsonHandler<InsightCreateResponse>(clientOptions.jsonMapper) + + override fun create( + params: InsightCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<InsightCreateResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("sessionId", params.sessionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "sessions", params._pathParam(0), "insights") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler<InsightRetrieveResponse> = + jsonHandler<InsightRetrieveResponse>(clientOptions.jsonMapper) + + override fun retrieve( + params: InsightRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor<InsightRetrieveResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("clusterId", params.clusterId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "sessions", + params._pathParam(0), + "insights", + params._pathParam(1), + "clusters", + params._pathParam(2), + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler<InsightUpdateResponse> = + jsonHandler<InsightUpdateResponse>(clientOptions.jsonMapper) + + override fun update( + params: InsightUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<InsightUpdateResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("jobId", params.jobId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "sessions", + params._pathParam(0), + "insights", + params._pathParam(1), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler<InsightListResponse> = + jsonHandler<InsightListResponse>(clientOptions.jsonMapper) + + override fun list( + params: InsightListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<InsightListResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("sessionId", params.sessionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "sessions", params._pathParam(0), "insights") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val deleteHandler: Handler<InsightDeleteResponse> = + jsonHandler<InsightDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: InsightDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<InsightDeleteResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("jobId", params.jobId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "sessions", + params._pathParam(0), + "insights", + params._pathParam(1), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveRunsHandler: Handler<InsightRetrieveRunsResponse> = + jsonHandler<InsightRetrieveRunsResponse>(clientOptions.jsonMapper) + + override fun retrieveRuns( + params: InsightRetrieveRunsParams, + requestOptions: RequestOptions, + ): HttpResponseFor<InsightRetrieveRunsResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("jobId", params.jobId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "sessions", + params._pathParam(0), + "insights", + params._pathParam(1), + "runs", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveRunsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/sessions/ViewService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/sessions/ViewService.kt new file mode 100644 index 00000000..ba57fbe1 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/sessions/ViewService.kt @@ -0,0 +1,309 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.sessions + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.sessions.views.FilterView +import com.langsmith_api.api.models.api.v1.sessions.views.ViewCreateParams +import com.langsmith_api.api.models.api.v1.sessions.views.ViewDeleteParams +import com.langsmith_api.api.models.api.v1.sessions.views.ViewDeleteResponse +import com.langsmith_api.api.models.api.v1.sessions.views.ViewListParams +import com.langsmith_api.api.models.api.v1.sessions.views.ViewRetrieveParams +import com.langsmith_api.api.models.api.v1.sessions.views.ViewUpdateParams +import java.util.function.Consumer + +interface ViewService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ViewService + + /** Create a new filter view. */ + fun create(sessionId: String, params: ViewCreateParams): FilterView = + create(sessionId, params, RequestOptions.none()) + + /** @see create */ + fun create( + sessionId: String, + params: ViewCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FilterView = create(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see create */ + fun create(params: ViewCreateParams): FilterView = create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: ViewCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FilterView + + /** Get a specific filter view. */ + fun retrieve(viewId: String, params: ViewRetrieveParams): FilterView = + retrieve(viewId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + viewId: String, + params: ViewRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FilterView = retrieve(params.toBuilder().viewId(viewId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: ViewRetrieveParams): FilterView = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: ViewRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FilterView + + /** Update a filter view. */ + fun update(viewId: String, params: ViewUpdateParams): FilterView = + update(viewId, params, RequestOptions.none()) + + /** @see update */ + fun update( + viewId: String, + params: ViewUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FilterView = update(params.toBuilder().viewId(viewId).build(), requestOptions) + + /** @see update */ + fun update(params: ViewUpdateParams): FilterView = update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: ViewUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FilterView + + /** Get all filter views for a session. */ + fun list(sessionId: String): List<FilterView> = list(sessionId, ViewListParams.none()) + + /** @see list */ + fun list( + sessionId: String, + params: ViewListParams = ViewListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<FilterView> = list(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see list */ + fun list(sessionId: String, params: ViewListParams = ViewListParams.none()): List<FilterView> = + list(sessionId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: ViewListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List<FilterView> + + /** @see list */ + fun list(params: ViewListParams): List<FilterView> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(sessionId: String, requestOptions: RequestOptions): List<FilterView> = + list(sessionId, ViewListParams.none(), requestOptions) + + /** Delete a specific filter view. */ + fun delete(viewId: String, params: ViewDeleteParams): ViewDeleteResponse = + delete(viewId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + viewId: String, + params: ViewDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ViewDeleteResponse = delete(params.toBuilder().viewId(viewId).build(), requestOptions) + + /** @see delete */ + fun delete(params: ViewDeleteParams): ViewDeleteResponse = delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ViewDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ViewDeleteResponse + + /** A view of [ViewService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ViewService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/sessions/{session_id}/views`, but is + * otherwise the same as [ViewService.create]. + */ + @MustBeClosed + fun create(sessionId: String, params: ViewCreateParams): HttpResponseFor<FilterView> = + create(sessionId, params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + sessionId: String, + params: ViewCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<FilterView> = + create(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(params: ViewCreateParams): HttpResponseFor<FilterView> = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: ViewCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<FilterView> + + /** + * Returns a raw HTTP response for `get /api/v1/sessions/{session_id}/views/{view_id}`, but + * is otherwise the same as [ViewService.retrieve]. + */ + @MustBeClosed + fun retrieve(viewId: String, params: ViewRetrieveParams): HttpResponseFor<FilterView> = + retrieve(viewId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + viewId: String, + params: ViewRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<FilterView> = + retrieve(params.toBuilder().viewId(viewId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: ViewRetrieveParams): HttpResponseFor<FilterView> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: ViewRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<FilterView> + + /** + * Returns a raw HTTP response for `patch /api/v1/sessions/{session_id}/views/{view_id}`, + * but is otherwise the same as [ViewService.update]. + */ + @MustBeClosed + fun update(viewId: String, params: ViewUpdateParams): HttpResponseFor<FilterView> = + update(viewId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + viewId: String, + params: ViewUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<FilterView> = + update(params.toBuilder().viewId(viewId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(params: ViewUpdateParams): HttpResponseFor<FilterView> = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: ViewUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<FilterView> + + /** + * Returns a raw HTTP response for `get /api/v1/sessions/{session_id}/views`, but is + * otherwise the same as [ViewService.list]. + */ + @MustBeClosed + fun list(sessionId: String): HttpResponseFor<List<FilterView>> = + list(sessionId, ViewListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + sessionId: String, + params: ViewListParams = ViewListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<FilterView>> = + list(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see list */ + @MustBeClosed + fun list( + sessionId: String, + params: ViewListParams = ViewListParams.none(), + ): HttpResponseFor<List<FilterView>> = list(sessionId, params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: ViewListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<FilterView>> + + /** @see list */ + @MustBeClosed + fun list(params: ViewListParams): HttpResponseFor<List<FilterView>> = + list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + sessionId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<List<FilterView>> = + list(sessionId, ViewListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/sessions/{session_id}/views/{view_id}`, + * but is otherwise the same as [ViewService.delete]. + */ + @MustBeClosed + fun delete(viewId: String, params: ViewDeleteParams): HttpResponseFor<ViewDeleteResponse> = + delete(viewId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + viewId: String, + params: ViewDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ViewDeleteResponse> = + delete(params.toBuilder().viewId(viewId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete(params: ViewDeleteParams): HttpResponseFor<ViewDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: ViewDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ViewDeleteResponse> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/sessions/ViewServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/sessions/ViewServiceImpl.kt new file mode 100644 index 00000000..b8732b1b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/sessions/ViewServiceImpl.kt @@ -0,0 +1,250 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.sessions + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.sessions.views.FilterView +import com.langsmith_api.api.models.api.v1.sessions.views.ViewCreateParams +import com.langsmith_api.api.models.api.v1.sessions.views.ViewDeleteParams +import com.langsmith_api.api.models.api.v1.sessions.views.ViewDeleteResponse +import com.langsmith_api.api.models.api.v1.sessions.views.ViewListParams +import com.langsmith_api.api.models.api.v1.sessions.views.ViewRetrieveParams +import com.langsmith_api.api.models.api.v1.sessions.views.ViewUpdateParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ViewServiceImpl internal constructor(private val clientOptions: ClientOptions) : ViewService { + + private val withRawResponse: ViewService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ViewService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): ViewService = + ViewServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create(params: ViewCreateParams, requestOptions: RequestOptions): FilterView = + // post /api/v1/sessions/{session_id}/views + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve(params: ViewRetrieveParams, requestOptions: RequestOptions): FilterView = + // get /api/v1/sessions/{session_id}/views/{view_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update(params: ViewUpdateParams, requestOptions: RequestOptions): FilterView = + // patch /api/v1/sessions/{session_id}/views/{view_id} + withRawResponse().update(params, requestOptions).parse() + + override fun list(params: ViewListParams, requestOptions: RequestOptions): List<FilterView> = + // get /api/v1/sessions/{session_id}/views + withRawResponse().list(params, requestOptions).parse() + + override fun delete( + params: ViewDeleteParams, + requestOptions: RequestOptions, + ): ViewDeleteResponse = + // delete /api/v1/sessions/{session_id}/views/{view_id} + withRawResponse().delete(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ViewService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ViewService.WithRawResponse = + ViewServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<FilterView> = + jsonHandler<FilterView>(clientOptions.jsonMapper) + + override fun create( + params: ViewCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<FilterView> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("sessionId", params.sessionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "sessions", params._pathParam(0), "views") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler<FilterView> = + jsonHandler<FilterView>(clientOptions.jsonMapper) + + override fun retrieve( + params: ViewRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor<FilterView> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("viewId", params.viewId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "sessions", + params._pathParam(0), + "views", + params._pathParam(1), + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler<FilterView> = + jsonHandler<FilterView>(clientOptions.jsonMapper) + + override fun update( + params: ViewUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<FilterView> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("viewId", params.viewId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "sessions", + params._pathParam(0), + "views", + params._pathParam(1), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler<List<FilterView>> = + jsonHandler<List<FilterView>>(clientOptions.jsonMapper) + + override fun list( + params: ViewListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<FilterView>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("sessionId", params.sessionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "sessions", params._pathParam(0), "views") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val deleteHandler: Handler<ViewDeleteResponse> = + jsonHandler<ViewDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: ViewDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<ViewDeleteResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("viewId", params.viewId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "sessions", + params._pathParam(0), + "views", + params._pathParam(1), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/sessions/insights/ConfigService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/sessions/insights/ConfigService.kt new file mode 100644 index 00000000..1d43f2f6 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/sessions/insights/ConfigService.kt @@ -0,0 +1,334 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.sessions.insights + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigCreateParams +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigDeleteParams +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigDeleteResponse +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigGenerateParams +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigGenerateResponse +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigListParams +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigListResponse +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigUpdateParams +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.CreateClusteringJobConfigResponse +import java.util.function.Consumer + +interface ConfigService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ConfigService + + /** Save an insights job config. */ + fun create(sessionId: String, params: ConfigCreateParams): CreateClusteringJobConfigResponse = + create(sessionId, params, RequestOptions.none()) + + /** @see create */ + fun create( + sessionId: String, + params: ConfigCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CreateClusteringJobConfigResponse = + create(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see create */ + fun create(params: ConfigCreateParams): CreateClusteringJobConfigResponse = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: ConfigCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CreateClusteringJobConfigResponse + + /** Update an insights job config. */ + fun update(configId: String, params: ConfigUpdateParams): CreateClusteringJobConfigResponse = + update(configId, params, RequestOptions.none()) + + /** @see update */ + fun update( + configId: String, + params: ConfigUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CreateClusteringJobConfigResponse = + update(params.toBuilder().configId(configId).build(), requestOptions) + + /** @see update */ + fun update(params: ConfigUpdateParams): CreateClusteringJobConfigResponse = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: ConfigUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CreateClusteringJobConfigResponse + + /** Get all insights job configs for a session. */ + fun list(sessionId: String): ConfigListResponse = list(sessionId, ConfigListParams.none()) + + /** @see list */ + fun list( + sessionId: String, + params: ConfigListParams = ConfigListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ConfigListResponse = list(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see list */ + fun list( + sessionId: String, + params: ConfigListParams = ConfigListParams.none(), + ): ConfigListResponse = list(sessionId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: ConfigListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ConfigListResponse + + /** @see list */ + fun list(params: ConfigListParams): ConfigListResponse = list(params, RequestOptions.none()) + + /** @see list */ + fun list(sessionId: String, requestOptions: RequestOptions): ConfigListResponse = + list(sessionId, ConfigListParams.none(), requestOptions) + + /** Delete an insights job config. */ + fun delete(configId: String, params: ConfigDeleteParams): ConfigDeleteResponse = + delete(configId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + configId: String, + params: ConfigDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ConfigDeleteResponse = delete(params.toBuilder().configId(configId).build(), requestOptions) + + /** @see delete */ + fun delete(params: ConfigDeleteParams): ConfigDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ConfigDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ConfigDeleteResponse + + /** Auto-generate an insights job config. */ + fun generate(sessionId: String, params: ConfigGenerateParams): ConfigGenerateResponse = + generate(sessionId, params, RequestOptions.none()) + + /** @see generate */ + fun generate( + sessionId: String, + params: ConfigGenerateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ConfigGenerateResponse = + generate(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see generate */ + fun generate(params: ConfigGenerateParams): ConfigGenerateResponse = + generate(params, RequestOptions.none()) + + /** @see generate */ + fun generate( + params: ConfigGenerateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ConfigGenerateResponse + + /** A view of [ConfigService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ConfigService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/sessions/{session_id}/insights/configs`, + * but is otherwise the same as [ConfigService.create]. + */ + @MustBeClosed + fun create( + sessionId: String, + params: ConfigCreateParams, + ): HttpResponseFor<CreateClusteringJobConfigResponse> = + create(sessionId, params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + sessionId: String, + params: ConfigCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CreateClusteringJobConfigResponse> = + create(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(params: ConfigCreateParams): HttpResponseFor<CreateClusteringJobConfigResponse> = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: ConfigCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CreateClusteringJobConfigResponse> + + /** + * Returns a raw HTTP response for `patch + * /api/v1/sessions/{session_id}/insights/configs/{config_id}`, but is otherwise the same as + * [ConfigService.update]. + */ + @MustBeClosed + fun update( + configId: String, + params: ConfigUpdateParams, + ): HttpResponseFor<CreateClusteringJobConfigResponse> = + update(configId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + configId: String, + params: ConfigUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CreateClusteringJobConfigResponse> = + update(params.toBuilder().configId(configId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(params: ConfigUpdateParams): HttpResponseFor<CreateClusteringJobConfigResponse> = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: ConfigUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CreateClusteringJobConfigResponse> + + /** + * Returns a raw HTTP response for `get /api/v1/sessions/{session_id}/insights/configs`, but + * is otherwise the same as [ConfigService.list]. + */ + @MustBeClosed + fun list(sessionId: String): HttpResponseFor<ConfigListResponse> = + list(sessionId, ConfigListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + sessionId: String, + params: ConfigListParams = ConfigListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ConfigListResponse> = + list(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see list */ + @MustBeClosed + fun list( + sessionId: String, + params: ConfigListParams = ConfigListParams.none(), + ): HttpResponseFor<ConfigListResponse> = list(sessionId, params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: ConfigListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ConfigListResponse> + + /** @see list */ + @MustBeClosed + fun list(params: ConfigListParams): HttpResponseFor<ConfigListResponse> = + list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + sessionId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<ConfigListResponse> = + list(sessionId, ConfigListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete + * /api/v1/sessions/{session_id}/insights/configs/{config_id}`, but is otherwise the same as + * [ConfigService.delete]. + */ + @MustBeClosed + fun delete( + configId: String, + params: ConfigDeleteParams, + ): HttpResponseFor<ConfigDeleteResponse> = delete(configId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + configId: String, + params: ConfigDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ConfigDeleteResponse> = + delete(params.toBuilder().configId(configId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete(params: ConfigDeleteParams): HttpResponseFor<ConfigDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: ConfigDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ConfigDeleteResponse> + + /** + * Returns a raw HTTP response for `post + * /api/v1/sessions/{session_id}/insights/configs/generate`, but is otherwise the same as + * [ConfigService.generate]. + */ + @MustBeClosed + fun generate( + sessionId: String, + params: ConfigGenerateParams, + ): HttpResponseFor<ConfigGenerateResponse> = + generate(sessionId, params, RequestOptions.none()) + + /** @see generate */ + @MustBeClosed + fun generate( + sessionId: String, + params: ConfigGenerateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ConfigGenerateResponse> = + generate(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see generate */ + @MustBeClosed + fun generate(params: ConfigGenerateParams): HttpResponseFor<ConfigGenerateResponse> = + generate(params, RequestOptions.none()) + + /** @see generate */ + @MustBeClosed + fun generate( + params: ConfigGenerateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ConfigGenerateResponse> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/sessions/insights/ConfigServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/sessions/insights/ConfigServiceImpl.kt new file mode 100644 index 00000000..43e711b4 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/sessions/insights/ConfigServiceImpl.kt @@ -0,0 +1,283 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.sessions.insights + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigCreateParams +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigDeleteParams +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigDeleteResponse +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigGenerateParams +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigGenerateResponse +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigListParams +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigListResponse +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigUpdateParams +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.CreateClusteringJobConfigResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ConfigServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ConfigService { + + private val withRawResponse: ConfigService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ConfigService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): ConfigService = + ConfigServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: ConfigCreateParams, + requestOptions: RequestOptions, + ): CreateClusteringJobConfigResponse = + // post /api/v1/sessions/{session_id}/insights/configs + withRawResponse().create(params, requestOptions).parse() + + override fun update( + params: ConfigUpdateParams, + requestOptions: RequestOptions, + ): CreateClusteringJobConfigResponse = + // patch /api/v1/sessions/{session_id}/insights/configs/{config_id} + withRawResponse().update(params, requestOptions).parse() + + override fun list( + params: ConfigListParams, + requestOptions: RequestOptions, + ): ConfigListResponse = + // get /api/v1/sessions/{session_id}/insights/configs + withRawResponse().list(params, requestOptions).parse() + + override fun delete( + params: ConfigDeleteParams, + requestOptions: RequestOptions, + ): ConfigDeleteResponse = + // delete /api/v1/sessions/{session_id}/insights/configs/{config_id} + withRawResponse().delete(params, requestOptions).parse() + + override fun generate( + params: ConfigGenerateParams, + requestOptions: RequestOptions, + ): ConfigGenerateResponse = + // post /api/v1/sessions/{session_id}/insights/configs/generate + withRawResponse().generate(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ConfigService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ConfigService.WithRawResponse = + ConfigServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<CreateClusteringJobConfigResponse> = + jsonHandler<CreateClusteringJobConfigResponse>(clientOptions.jsonMapper) + + override fun create( + params: ConfigCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<CreateClusteringJobConfigResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("sessionId", params.sessionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "sessions", + params._pathParam(0), + "insights", + "configs", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler<CreateClusteringJobConfigResponse> = + jsonHandler<CreateClusteringJobConfigResponse>(clientOptions.jsonMapper) + + override fun update( + params: ConfigUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<CreateClusteringJobConfigResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("configId", params.configId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "sessions", + params._pathParam(0), + "insights", + "configs", + params._pathParam(1), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler<ConfigListResponse> = + jsonHandler<ConfigListResponse>(clientOptions.jsonMapper) + + override fun list( + params: ConfigListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<ConfigListResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("sessionId", params.sessionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "sessions", + params._pathParam(0), + "insights", + "configs", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val deleteHandler: Handler<ConfigDeleteResponse> = + jsonHandler<ConfigDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: ConfigDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<ConfigDeleteResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("configId", params.configId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "sessions", + params._pathParam(0), + "insights", + "configs", + params._pathParam(1), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val generateHandler: Handler<ConfigGenerateResponse> = + jsonHandler<ConfigGenerateResponse>(clientOptions.jsonMapper) + + override fun generate( + params: ConfigGenerateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<ConfigGenerateResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("sessionId", params.sessionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "sessions", + params._pathParam(0), + "insights", + "configs", + "generate", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { generateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/sso/EmailVerificationService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/sso/EmailVerificationService.kt new file mode 100644 index 00000000..a4cfb80b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/sso/EmailVerificationService.kt @@ -0,0 +1,125 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.sso + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.sso.emailverification.EmailVerificationConfirmParams +import com.langsmith_api.api.models.api.v1.sso.emailverification.EmailVerificationConfirmResponse +import com.langsmith_api.api.models.api.v1.sso.emailverification.EmailVerificationSendParams +import com.langsmith_api.api.models.api.v1.sso.emailverification.EmailVerificationSendResponse +import com.langsmith_api.api.models.api.v1.sso.emailverification.EmailVerificationStatusParams +import com.langsmith_api.api.models.api.v1.sso.emailverification.EmailVerificationStatusResponse +import java.util.function.Consumer + +interface EmailVerificationService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): EmailVerificationService + + /** Confirm the email of an SSO user. */ + fun confirm(params: EmailVerificationConfirmParams): EmailVerificationConfirmResponse = + confirm(params, RequestOptions.none()) + + /** @see confirm */ + fun confirm( + params: EmailVerificationConfirmParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): EmailVerificationConfirmResponse + + /** Send an email to confirm the email address for an SSO user. */ + fun send(params: EmailVerificationSendParams): EmailVerificationSendResponse = + send(params, RequestOptions.none()) + + /** @see send */ + fun send( + params: EmailVerificationSendParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): EmailVerificationSendResponse + + /** Retrieve the email verification status of an SSO user. */ + fun status(params: EmailVerificationStatusParams): EmailVerificationStatusResponse = + status(params, RequestOptions.none()) + + /** @see status */ + fun status( + params: EmailVerificationStatusParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): EmailVerificationStatusResponse + + /** + * A view of [EmailVerificationService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): EmailVerificationService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/sso/email-verification/confirm`, but is + * otherwise the same as [EmailVerificationService.confirm]. + */ + @MustBeClosed + fun confirm( + params: EmailVerificationConfirmParams + ): HttpResponseFor<EmailVerificationConfirmResponse> = + confirm(params, RequestOptions.none()) + + /** @see confirm */ + @MustBeClosed + fun confirm( + params: EmailVerificationConfirmParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<EmailVerificationConfirmResponse> + + /** + * Returns a raw HTTP response for `post /api/v1/sso/email-verification/send`, but is + * otherwise the same as [EmailVerificationService.send]. + */ + @MustBeClosed + fun send( + params: EmailVerificationSendParams + ): HttpResponseFor<EmailVerificationSendResponse> = send(params, RequestOptions.none()) + + /** @see send */ + @MustBeClosed + fun send( + params: EmailVerificationSendParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<EmailVerificationSendResponse> + + /** + * Returns a raw HTTP response for `post /api/v1/sso/email-verification/status`, but is + * otherwise the same as [EmailVerificationService.status]. + */ + @MustBeClosed + fun status( + params: EmailVerificationStatusParams + ): HttpResponseFor<EmailVerificationStatusResponse> = status(params, RequestOptions.none()) + + /** @see status */ + @MustBeClosed + fun status( + params: EmailVerificationStatusParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<EmailVerificationStatusResponse> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/sso/EmailVerificationServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/sso/EmailVerificationServiceImpl.kt new file mode 100644 index 00000000..4819e0e0 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/sso/EmailVerificationServiceImpl.kt @@ -0,0 +1,156 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.sso + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.sso.emailverification.EmailVerificationConfirmParams +import com.langsmith_api.api.models.api.v1.sso.emailverification.EmailVerificationConfirmResponse +import com.langsmith_api.api.models.api.v1.sso.emailverification.EmailVerificationSendParams +import com.langsmith_api.api.models.api.v1.sso.emailverification.EmailVerificationSendResponse +import com.langsmith_api.api.models.api.v1.sso.emailverification.EmailVerificationStatusParams +import com.langsmith_api.api.models.api.v1.sso.emailverification.EmailVerificationStatusResponse +import java.util.function.Consumer + +class EmailVerificationServiceImpl internal constructor(private val clientOptions: ClientOptions) : + EmailVerificationService { + + private val withRawResponse: EmailVerificationService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): EmailVerificationService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): EmailVerificationService = + EmailVerificationServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun confirm( + params: EmailVerificationConfirmParams, + requestOptions: RequestOptions, + ): EmailVerificationConfirmResponse = + // post /api/v1/sso/email-verification/confirm + withRawResponse().confirm(params, requestOptions).parse() + + override fun send( + params: EmailVerificationSendParams, + requestOptions: RequestOptions, + ): EmailVerificationSendResponse = + // post /api/v1/sso/email-verification/send + withRawResponse().send(params, requestOptions).parse() + + override fun status( + params: EmailVerificationStatusParams, + requestOptions: RequestOptions, + ): EmailVerificationStatusResponse = + // post /api/v1/sso/email-verification/status + withRawResponse().status(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + EmailVerificationService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): EmailVerificationService.WithRawResponse = + EmailVerificationServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val confirmHandler: Handler<EmailVerificationConfirmResponse> = + jsonHandler<EmailVerificationConfirmResponse>(clientOptions.jsonMapper) + + override fun confirm( + params: EmailVerificationConfirmParams, + requestOptions: RequestOptions, + ): HttpResponseFor<EmailVerificationConfirmResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "sso", "email-verification", "confirm") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { confirmHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val sendHandler: Handler<EmailVerificationSendResponse> = + jsonHandler<EmailVerificationSendResponse>(clientOptions.jsonMapper) + + override fun send( + params: EmailVerificationSendParams, + requestOptions: RequestOptions, + ): HttpResponseFor<EmailVerificationSendResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "sso", "email-verification", "send") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { sendHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val statusHandler: Handler<EmailVerificationStatusResponse> = + jsonHandler<EmailVerificationStatusResponse>(clientOptions.jsonMapper) + + override fun status( + params: EmailVerificationStatusParams, + requestOptions: RequestOptions, + ): HttpResponseFor<EmailVerificationStatusResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "sso", "email-verification", "status") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { statusHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/CurrentService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/CurrentService.kt new file mode 100644 index 00000000..ce3cde90 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/CurrentService.kt @@ -0,0 +1,165 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.workspaces + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.workspaces.current.CurrentRetrieveStatsParams +import com.langsmith_api.api.models.api.v1.workspaces.current.CurrentRetrieveStatsResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.CurrentRetrieveUsageLimitsParams +import com.langsmith_api.api.models.api.v1.workspaces.current.CurrentRetrieveUsageLimitsResponse +import com.langsmith_api.api.services.blocking.api.v1.workspaces.current.MemberService +import com.langsmith_api.api.services.blocking.api.v1.workspaces.current.SecretService +import com.langsmith_api.api.services.blocking.api.v1.workspaces.current.SharedService +import com.langsmith_api.api.services.blocking.api.v1.workspaces.current.TagKeyService +import com.langsmith_api.api.services.blocking.api.v1.workspaces.current.TagService +import com.langsmith_api.api.services.blocking.api.v1.workspaces.current.TaggingService +import java.util.function.Consumer + +interface CurrentService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): CurrentService + + fun members(): MemberService + + fun shared(): SharedService + + fun secrets(): SecretService + + fun tagKeys(): TagKeyService + + fun taggings(): TaggingService + + fun tags(): TagService + + /** Get Current Workspace Stats */ + fun retrieveStats(): CurrentRetrieveStatsResponse = + retrieveStats(CurrentRetrieveStatsParams.none()) + + /** @see retrieveStats */ + fun retrieveStats( + params: CurrentRetrieveStatsParams = CurrentRetrieveStatsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CurrentRetrieveStatsResponse + + /** @see retrieveStats */ + fun retrieveStats( + params: CurrentRetrieveStatsParams = CurrentRetrieveStatsParams.none() + ): CurrentRetrieveStatsResponse = retrieveStats(params, RequestOptions.none()) + + /** @see retrieveStats */ + fun retrieveStats(requestOptions: RequestOptions): CurrentRetrieveStatsResponse = + retrieveStats(CurrentRetrieveStatsParams.none(), requestOptions) + + /** Get Current Workspace Usage Limits Info */ + fun retrieveUsageLimits(): CurrentRetrieveUsageLimitsResponse = + retrieveUsageLimits(CurrentRetrieveUsageLimitsParams.none()) + + /** @see retrieveUsageLimits */ + fun retrieveUsageLimits( + params: CurrentRetrieveUsageLimitsParams = CurrentRetrieveUsageLimitsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CurrentRetrieveUsageLimitsResponse + + /** @see retrieveUsageLimits */ + fun retrieveUsageLimits( + params: CurrentRetrieveUsageLimitsParams = CurrentRetrieveUsageLimitsParams.none() + ): CurrentRetrieveUsageLimitsResponse = retrieveUsageLimits(params, RequestOptions.none()) + + /** @see retrieveUsageLimits */ + fun retrieveUsageLimits(requestOptions: RequestOptions): CurrentRetrieveUsageLimitsResponse = + retrieveUsageLimits(CurrentRetrieveUsageLimitsParams.none(), requestOptions) + + /** A view of [CurrentService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): CurrentService.WithRawResponse + + fun members(): MemberService.WithRawResponse + + fun shared(): SharedService.WithRawResponse + + fun secrets(): SecretService.WithRawResponse + + fun tagKeys(): TagKeyService.WithRawResponse + + fun taggings(): TaggingService.WithRawResponse + + fun tags(): TagService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/workspaces/current/stats`, but is otherwise + * the same as [CurrentService.retrieveStats]. + */ + @MustBeClosed + fun retrieveStats(): HttpResponseFor<CurrentRetrieveStatsResponse> = + retrieveStats(CurrentRetrieveStatsParams.none()) + + /** @see retrieveStats */ + @MustBeClosed + fun retrieveStats( + params: CurrentRetrieveStatsParams = CurrentRetrieveStatsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CurrentRetrieveStatsResponse> + + /** @see retrieveStats */ + @MustBeClosed + fun retrieveStats( + params: CurrentRetrieveStatsParams = CurrentRetrieveStatsParams.none() + ): HttpResponseFor<CurrentRetrieveStatsResponse> = + retrieveStats(params, RequestOptions.none()) + + /** @see retrieveStats */ + @MustBeClosed + fun retrieveStats( + requestOptions: RequestOptions + ): HttpResponseFor<CurrentRetrieveStatsResponse> = + retrieveStats(CurrentRetrieveStatsParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/workspaces/current/usage_limits`, but is + * otherwise the same as [CurrentService.retrieveUsageLimits]. + */ + @MustBeClosed + fun retrieveUsageLimits(): HttpResponseFor<CurrentRetrieveUsageLimitsResponse> = + retrieveUsageLimits(CurrentRetrieveUsageLimitsParams.none()) + + /** @see retrieveUsageLimits */ + @MustBeClosed + fun retrieveUsageLimits( + params: CurrentRetrieveUsageLimitsParams = CurrentRetrieveUsageLimitsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<CurrentRetrieveUsageLimitsResponse> + + /** @see retrieveUsageLimits */ + @MustBeClosed + fun retrieveUsageLimits( + params: CurrentRetrieveUsageLimitsParams = CurrentRetrieveUsageLimitsParams.none() + ): HttpResponseFor<CurrentRetrieveUsageLimitsResponse> = + retrieveUsageLimits(params, RequestOptions.none()) + + /** @see retrieveUsageLimits */ + @MustBeClosed + fun retrieveUsageLimits( + requestOptions: RequestOptions + ): HttpResponseFor<CurrentRetrieveUsageLimitsResponse> = + retrieveUsageLimits(CurrentRetrieveUsageLimitsParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/CurrentServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/CurrentServiceImpl.kt new file mode 100644 index 00000000..65bcb65b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/CurrentServiceImpl.kt @@ -0,0 +1,188 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.workspaces + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.workspaces.current.CurrentRetrieveStatsParams +import com.langsmith_api.api.models.api.v1.workspaces.current.CurrentRetrieveStatsResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.CurrentRetrieveUsageLimitsParams +import com.langsmith_api.api.models.api.v1.workspaces.current.CurrentRetrieveUsageLimitsResponse +import com.langsmith_api.api.services.blocking.api.v1.workspaces.current.MemberService +import com.langsmith_api.api.services.blocking.api.v1.workspaces.current.MemberServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.workspaces.current.SecretService +import com.langsmith_api.api.services.blocking.api.v1.workspaces.current.SecretServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.workspaces.current.SharedService +import com.langsmith_api.api.services.blocking.api.v1.workspaces.current.SharedServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.workspaces.current.TagKeyService +import com.langsmith_api.api.services.blocking.api.v1.workspaces.current.TagKeyServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.workspaces.current.TagService +import com.langsmith_api.api.services.blocking.api.v1.workspaces.current.TagServiceImpl +import com.langsmith_api.api.services.blocking.api.v1.workspaces.current.TaggingService +import com.langsmith_api.api.services.blocking.api.v1.workspaces.current.TaggingServiceImpl +import java.util.function.Consumer + +class CurrentServiceImpl internal constructor(private val clientOptions: ClientOptions) : + CurrentService { + + private val withRawResponse: CurrentService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val members: MemberService by lazy { MemberServiceImpl(clientOptions) } + + private val shared: SharedService by lazy { SharedServiceImpl(clientOptions) } + + private val secrets: SecretService by lazy { SecretServiceImpl(clientOptions) } + + private val tagKeys: TagKeyService by lazy { TagKeyServiceImpl(clientOptions) } + + private val taggings: TaggingService by lazy { TaggingServiceImpl(clientOptions) } + + private val tags: TagService by lazy { TagServiceImpl(clientOptions) } + + override fun withRawResponse(): CurrentService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): CurrentService = + CurrentServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun members(): MemberService = members + + override fun shared(): SharedService = shared + + override fun secrets(): SecretService = secrets + + override fun tagKeys(): TagKeyService = tagKeys + + override fun taggings(): TaggingService = taggings + + override fun tags(): TagService = tags + + override fun retrieveStats( + params: CurrentRetrieveStatsParams, + requestOptions: RequestOptions, + ): CurrentRetrieveStatsResponse = + // get /api/v1/workspaces/current/stats + withRawResponse().retrieveStats(params, requestOptions).parse() + + override fun retrieveUsageLimits( + params: CurrentRetrieveUsageLimitsParams, + requestOptions: RequestOptions, + ): CurrentRetrieveUsageLimitsResponse = + // get /api/v1/workspaces/current/usage_limits + withRawResponse().retrieveUsageLimits(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CurrentService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val members: MemberService.WithRawResponse by lazy { + MemberServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val shared: SharedService.WithRawResponse by lazy { + SharedServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val secrets: SecretService.WithRawResponse by lazy { + SecretServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val tagKeys: TagKeyService.WithRawResponse by lazy { + TagKeyServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val taggings: TaggingService.WithRawResponse by lazy { + TaggingServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val tags: TagService.WithRawResponse by lazy { + TagServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): CurrentService.WithRawResponse = + CurrentServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun members(): MemberService.WithRawResponse = members + + override fun shared(): SharedService.WithRawResponse = shared + + override fun secrets(): SecretService.WithRawResponse = secrets + + override fun tagKeys(): TagKeyService.WithRawResponse = tagKeys + + override fun taggings(): TaggingService.WithRawResponse = taggings + + override fun tags(): TagService.WithRawResponse = tags + + private val retrieveStatsHandler: Handler<CurrentRetrieveStatsResponse> = + jsonHandler<CurrentRetrieveStatsResponse>(clientOptions.jsonMapper) + + override fun retrieveStats( + params: CurrentRetrieveStatsParams, + requestOptions: RequestOptions, + ): HttpResponseFor<CurrentRetrieveStatsResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "current", "stats") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveStatsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveUsageLimitsHandler: Handler<CurrentRetrieveUsageLimitsResponse> = + jsonHandler<CurrentRetrieveUsageLimitsResponse>(clientOptions.jsonMapper) + + override fun retrieveUsageLimits( + params: CurrentRetrieveUsageLimitsParams, + requestOptions: RequestOptions, + ): HttpResponseFor<CurrentRetrieveUsageLimitsResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "current", "usage_limits") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveUsageLimitsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/PendingService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/PendingService.kt new file mode 100644 index 00000000..5fb91ac6 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/PendingService.kt @@ -0,0 +1,245 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.workspaces + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.tenants.AppSchemasTenant +import com.langsmith_api.api.models.api.v1.workspaces.pending.PendingClaimParams +import com.langsmith_api.api.models.api.v1.workspaces.pending.PendingClaimResponse +import com.langsmith_api.api.models.api.v1.workspaces.pending.PendingDeleteParams +import com.langsmith_api.api.models.api.v1.workspaces.pending.PendingDeleteResponse +import com.langsmith_api.api.models.api.v1.workspaces.pending.PendingListParams +import java.util.function.Consumer + +interface PendingService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): PendingService + + /** Get all workspaces visible to this auth */ + fun list(): List<AppSchemasTenant> = list(PendingListParams.none()) + + /** @see list */ + fun list( + params: PendingListParams = PendingListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<AppSchemasTenant> + + /** @see list */ + fun list(params: PendingListParams = PendingListParams.none()): List<AppSchemasTenant> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): List<AppSchemasTenant> = + list(PendingListParams.none(), requestOptions) + + /** Delete Pending Workspace Invite */ + fun delete(id: String): PendingDeleteResponse = delete(id, PendingDeleteParams.none()) + + /** @see delete */ + fun delete( + id: String, + params: PendingDeleteParams = PendingDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): PendingDeleteResponse = delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + fun delete( + id: String, + params: PendingDeleteParams = PendingDeleteParams.none(), + ): PendingDeleteResponse = delete(id, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: PendingDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): PendingDeleteResponse + + /** @see delete */ + fun delete(params: PendingDeleteParams): PendingDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(id: String, requestOptions: RequestOptions): PendingDeleteResponse = + delete(id, PendingDeleteParams.none(), requestOptions) + + /** Claim Pending Workspace Invite */ + @Deprecated("deprecated") + fun claim(workspaceId: String): PendingClaimResponse = + claim(workspaceId, PendingClaimParams.none()) + + /** @see claim */ + @Deprecated("deprecated") + fun claim( + workspaceId: String, + params: PendingClaimParams = PendingClaimParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): PendingClaimResponse = + claim(params.toBuilder().workspaceId(workspaceId).build(), requestOptions) + + /** @see claim */ + @Deprecated("deprecated") + fun claim( + workspaceId: String, + params: PendingClaimParams = PendingClaimParams.none(), + ): PendingClaimResponse = claim(workspaceId, params, RequestOptions.none()) + + /** @see claim */ + @Deprecated("deprecated") + fun claim( + params: PendingClaimParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): PendingClaimResponse + + /** @see claim */ + @Deprecated("deprecated") + fun claim(params: PendingClaimParams): PendingClaimResponse = + claim(params, RequestOptions.none()) + + /** @see claim */ + @Deprecated("deprecated") + fun claim(workspaceId: String, requestOptions: RequestOptions): PendingClaimResponse = + claim(workspaceId, PendingClaimParams.none(), requestOptions) + + /** A view of [PendingService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): PendingService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/workspaces/pending`, but is otherwise the + * same as [PendingService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor<List<AppSchemasTenant>> = list(PendingListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: PendingListParams = PendingListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<AppSchemasTenant>> + + /** @see list */ + @MustBeClosed + fun list( + params: PendingListParams = PendingListParams.none() + ): HttpResponseFor<List<AppSchemasTenant>> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor<List<AppSchemasTenant>> = + list(PendingListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/workspaces/pending/{id}`, but is + * otherwise the same as [PendingService.delete]. + */ + @MustBeClosed + fun delete(id: String): HttpResponseFor<PendingDeleteResponse> = + delete(id, PendingDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + id: String, + params: PendingDeleteParams = PendingDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<PendingDeleteResponse> = + delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + id: String, + params: PendingDeleteParams = PendingDeleteParams.none(), + ): HttpResponseFor<PendingDeleteResponse> = delete(id, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: PendingDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<PendingDeleteResponse> + + /** @see delete */ + @MustBeClosed + fun delete(params: PendingDeleteParams): HttpResponseFor<PendingDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + id: String, + requestOptions: RequestOptions, + ): HttpResponseFor<PendingDeleteResponse> = + delete(id, PendingDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/workspaces/pending/{workspace_id}/claim`, + * but is otherwise the same as [PendingService.claim]. + */ + @Deprecated("deprecated") + @MustBeClosed + fun claim(workspaceId: String): HttpResponseFor<PendingClaimResponse> = + claim(workspaceId, PendingClaimParams.none()) + + /** @see claim */ + @Deprecated("deprecated") + @MustBeClosed + fun claim( + workspaceId: String, + params: PendingClaimParams = PendingClaimParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<PendingClaimResponse> = + claim(params.toBuilder().workspaceId(workspaceId).build(), requestOptions) + + /** @see claim */ + @Deprecated("deprecated") + @MustBeClosed + fun claim( + workspaceId: String, + params: PendingClaimParams = PendingClaimParams.none(), + ): HttpResponseFor<PendingClaimResponse> = claim(workspaceId, params, RequestOptions.none()) + + /** @see claim */ + @Deprecated("deprecated") + @MustBeClosed + fun claim( + params: PendingClaimParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<PendingClaimResponse> + + /** @see claim */ + @Deprecated("deprecated") + @MustBeClosed + fun claim(params: PendingClaimParams): HttpResponseFor<PendingClaimResponse> = + claim(params, RequestOptions.none()) + + /** @see claim */ + @Deprecated("deprecated") + @MustBeClosed + fun claim( + workspaceId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<PendingClaimResponse> = + claim(workspaceId, PendingClaimParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/PendingServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/PendingServiceImpl.kt new file mode 100644 index 00000000..21b64bbe --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/PendingServiceImpl.kt @@ -0,0 +1,172 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.workspaces + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.tenants.AppSchemasTenant +import com.langsmith_api.api.models.api.v1.workspaces.pending.PendingClaimParams +import com.langsmith_api.api.models.api.v1.workspaces.pending.PendingClaimResponse +import com.langsmith_api.api.models.api.v1.workspaces.pending.PendingDeleteParams +import com.langsmith_api.api.models.api.v1.workspaces.pending.PendingDeleteResponse +import com.langsmith_api.api.models.api.v1.workspaces.pending.PendingListParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class PendingServiceImpl internal constructor(private val clientOptions: ClientOptions) : + PendingService { + + private val withRawResponse: PendingService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): PendingService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): PendingService = + PendingServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: PendingListParams, + requestOptions: RequestOptions, + ): List<AppSchemasTenant> = + // get /api/v1/workspaces/pending + withRawResponse().list(params, requestOptions).parse() + + override fun delete( + params: PendingDeleteParams, + requestOptions: RequestOptions, + ): PendingDeleteResponse = + // delete /api/v1/workspaces/pending/{id} + withRawResponse().delete(params, requestOptions).parse() + + @Deprecated("deprecated") + override fun claim( + params: PendingClaimParams, + requestOptions: RequestOptions, + ): PendingClaimResponse = + // post /api/v1/workspaces/pending/{workspace_id}/claim + withRawResponse().claim(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + PendingService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PendingService.WithRawResponse = + PendingServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler<List<AppSchemasTenant>> = + jsonHandler<List<AppSchemasTenant>>(clientOptions.jsonMapper) + + override fun list( + params: PendingListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<AppSchemasTenant>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "pending") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val deleteHandler: Handler<PendingDeleteResponse> = + jsonHandler<PendingDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: PendingDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<PendingDeleteResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "pending", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val claimHandler: Handler<PendingClaimResponse> = + jsonHandler<PendingClaimResponse>(clientOptions.jsonMapper) + + @Deprecated("deprecated") + override fun claim( + params: PendingClaimParams, + requestOptions: RequestOptions, + ): HttpResponseFor<PendingClaimResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("workspaceId", params.workspaceId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "workspaces", + "pending", + params._pathParam(0), + "claim", + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { claimHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/MemberService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/MemberService.kt new file mode 100644 index 00000000..c2ebd98c --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/MemberService.kt @@ -0,0 +1,334 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.workspaces.current + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.orgs.current.members.PendingIdentity +import com.langsmith_api.api.models.api.v1.orgs.pending.Identity +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberBatchParams +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberCreateParams +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberDeleteParams +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberDeleteResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberIdentity +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberListParams +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberListResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberRetrieveActiveParams +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberUpdateParams +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberUpdateResponse +import com.langsmith_api.api.services.blocking.api.v1.workspaces.current.members.PendingService +import java.util.function.Consumer + +interface MemberService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): MemberService + + fun pending(): PendingService + + /** Add an existing organization member to the current workspace. */ + fun create(): Identity = create(MemberCreateParams.none()) + + /** @see create */ + fun create( + params: MemberCreateParams = MemberCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Identity + + /** @see create */ + fun create(params: MemberCreateParams = MemberCreateParams.none()): Identity = + create(params, RequestOptions.none()) + + /** @see create */ + fun create(requestOptions: RequestOptions): Identity = + create(MemberCreateParams.none(), requestOptions) + + /** Patch Current Workspace Member */ + fun update(identityId: String, params: MemberUpdateParams): MemberUpdateResponse = + update(identityId, params, RequestOptions.none()) + + /** @see update */ + fun update( + identityId: String, + params: MemberUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): MemberUpdateResponse = + update(params.toBuilder().identityId(identityId).build(), requestOptions) + + /** @see update */ + fun update(params: MemberUpdateParams): MemberUpdateResponse = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: MemberUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): MemberUpdateResponse + + /** Get Current Workspace Members */ + fun list(): MemberListResponse = list(MemberListParams.none()) + + /** @see list */ + fun list( + params: MemberListParams = MemberListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): MemberListResponse + + /** @see list */ + fun list(params: MemberListParams = MemberListParams.none()): MemberListResponse = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): MemberListResponse = + list(MemberListParams.none(), requestOptions) + + /** Delete Current Workspace Member */ + fun delete(identityId: String): MemberDeleteResponse = + delete(identityId, MemberDeleteParams.none()) + + /** @see delete */ + fun delete( + identityId: String, + params: MemberDeleteParams = MemberDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): MemberDeleteResponse = + delete(params.toBuilder().identityId(identityId).build(), requestOptions) + + /** @see delete */ + fun delete( + identityId: String, + params: MemberDeleteParams = MemberDeleteParams.none(), + ): MemberDeleteResponse = delete(identityId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: MemberDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): MemberDeleteResponse + + /** @see delete */ + fun delete(params: MemberDeleteParams): MemberDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(identityId: String, requestOptions: RequestOptions): MemberDeleteResponse = + delete(identityId, MemberDeleteParams.none(), requestOptions) + + /** Batch invite up to 500 users to the current workspace and organization. */ + fun batch(params: MemberBatchParams): List<PendingIdentity> = + batch(params, RequestOptions.none()) + + /** @see batch */ + fun batch( + params: MemberBatchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List<PendingIdentity> + + /** Get Current Active Workspace Members */ + fun retrieveActive(): List<MemberIdentity> = retrieveActive(MemberRetrieveActiveParams.none()) + + /** @see retrieveActive */ + fun retrieveActive( + params: MemberRetrieveActiveParams = MemberRetrieveActiveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<MemberIdentity> + + /** @see retrieveActive */ + fun retrieveActive( + params: MemberRetrieveActiveParams = MemberRetrieveActiveParams.none() + ): List<MemberIdentity> = retrieveActive(params, RequestOptions.none()) + + /** @see retrieveActive */ + fun retrieveActive(requestOptions: RequestOptions): List<MemberIdentity> = + retrieveActive(MemberRetrieveActiveParams.none(), requestOptions) + + /** A view of [MemberService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): MemberService.WithRawResponse + + fun pending(): PendingService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/workspaces/current/members`, but is + * otherwise the same as [MemberService.create]. + */ + @MustBeClosed fun create(): HttpResponseFor<Identity> = create(MemberCreateParams.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: MemberCreateParams = MemberCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<Identity> + + /** @see create */ + @MustBeClosed + fun create( + params: MemberCreateParams = MemberCreateParams.none() + ): HttpResponseFor<Identity> = create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create(requestOptions: RequestOptions): HttpResponseFor<Identity> = + create(MemberCreateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `patch /api/v1/workspaces/current/members/{identity_id}`, + * but is otherwise the same as [MemberService.update]. + */ + @MustBeClosed + fun update( + identityId: String, + params: MemberUpdateParams, + ): HttpResponseFor<MemberUpdateResponse> = update(identityId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + identityId: String, + params: MemberUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<MemberUpdateResponse> = + update(params.toBuilder().identityId(identityId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(params: MemberUpdateParams): HttpResponseFor<MemberUpdateResponse> = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: MemberUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<MemberUpdateResponse> + + /** + * Returns a raw HTTP response for `get /api/v1/workspaces/current/members`, but is + * otherwise the same as [MemberService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor<MemberListResponse> = list(MemberListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: MemberListParams = MemberListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<MemberListResponse> + + /** @see list */ + @MustBeClosed + fun list( + params: MemberListParams = MemberListParams.none() + ): HttpResponseFor<MemberListResponse> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor<MemberListResponse> = + list(MemberListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete + * /api/v1/workspaces/current/members/{identity_id}`, but is otherwise the same as + * [MemberService.delete]. + */ + @MustBeClosed + fun delete(identityId: String): HttpResponseFor<MemberDeleteResponse> = + delete(identityId, MemberDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + identityId: String, + params: MemberDeleteParams = MemberDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<MemberDeleteResponse> = + delete(params.toBuilder().identityId(identityId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + identityId: String, + params: MemberDeleteParams = MemberDeleteParams.none(), + ): HttpResponseFor<MemberDeleteResponse> = delete(identityId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: MemberDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<MemberDeleteResponse> + + /** @see delete */ + @MustBeClosed + fun delete(params: MemberDeleteParams): HttpResponseFor<MemberDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + identityId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<MemberDeleteResponse> = + delete(identityId, MemberDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/workspaces/current/members/batch`, but is + * otherwise the same as [MemberService.batch]. + */ + @MustBeClosed + fun batch(params: MemberBatchParams): HttpResponseFor<List<PendingIdentity>> = + batch(params, RequestOptions.none()) + + /** @see batch */ + @MustBeClosed + fun batch( + params: MemberBatchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<PendingIdentity>> + + /** + * Returns a raw HTTP response for `get /api/v1/workspaces/current/members/active`, but is + * otherwise the same as [MemberService.retrieveActive]. + */ + @MustBeClosed + fun retrieveActive(): HttpResponseFor<List<MemberIdentity>> = + retrieveActive(MemberRetrieveActiveParams.none()) + + /** @see retrieveActive */ + @MustBeClosed + fun retrieveActive( + params: MemberRetrieveActiveParams = MemberRetrieveActiveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<MemberIdentity>> + + /** @see retrieveActive */ + @MustBeClosed + fun retrieveActive( + params: MemberRetrieveActiveParams = MemberRetrieveActiveParams.none() + ): HttpResponseFor<List<MemberIdentity>> = retrieveActive(params, RequestOptions.none()) + + /** @see retrieveActive */ + @MustBeClosed + fun retrieveActive(requestOptions: RequestOptions): HttpResponseFor<List<MemberIdentity>> = + retrieveActive(MemberRetrieveActiveParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/MemberServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/MemberServiceImpl.kt new file mode 100644 index 00000000..c0624ba6 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/MemberServiceImpl.kt @@ -0,0 +1,296 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.workspaces.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.orgs.current.members.PendingIdentity +import com.langsmith_api.api.models.api.v1.orgs.pending.Identity +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberBatchParams +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberCreateParams +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberDeleteParams +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberDeleteResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberIdentity +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberListParams +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberListResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberRetrieveActiveParams +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberUpdateParams +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberUpdateResponse +import com.langsmith_api.api.services.blocking.api.v1.workspaces.current.members.PendingService +import com.langsmith_api.api.services.blocking.api.v1.workspaces.current.members.PendingServiceImpl +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class MemberServiceImpl internal constructor(private val clientOptions: ClientOptions) : + MemberService { + + private val withRawResponse: MemberService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val pending: PendingService by lazy { PendingServiceImpl(clientOptions) } + + override fun withRawResponse(): MemberService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): MemberService = + MemberServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun pending(): PendingService = pending + + override fun create(params: MemberCreateParams, requestOptions: RequestOptions): Identity = + // post /api/v1/workspaces/current/members + withRawResponse().create(params, requestOptions).parse() + + override fun update( + params: MemberUpdateParams, + requestOptions: RequestOptions, + ): MemberUpdateResponse = + // patch /api/v1/workspaces/current/members/{identity_id} + withRawResponse().update(params, requestOptions).parse() + + override fun list( + params: MemberListParams, + requestOptions: RequestOptions, + ): MemberListResponse = + // get /api/v1/workspaces/current/members + withRawResponse().list(params, requestOptions).parse() + + override fun delete( + params: MemberDeleteParams, + requestOptions: RequestOptions, + ): MemberDeleteResponse = + // delete /api/v1/workspaces/current/members/{identity_id} + withRawResponse().delete(params, requestOptions).parse() + + override fun batch( + params: MemberBatchParams, + requestOptions: RequestOptions, + ): List<PendingIdentity> = + // post /api/v1/workspaces/current/members/batch + withRawResponse().batch(params, requestOptions).parse() + + override fun retrieveActive( + params: MemberRetrieveActiveParams, + requestOptions: RequestOptions, + ): List<MemberIdentity> = + // get /api/v1/workspaces/current/members/active + withRawResponse().retrieveActive(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + MemberService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val pending: PendingService.WithRawResponse by lazy { + PendingServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): MemberService.WithRawResponse = + MemberServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun pending(): PendingService.WithRawResponse = pending + + private val createHandler: Handler<Identity> = + jsonHandler<Identity>(clientOptions.jsonMapper) + + override fun create( + params: MemberCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<Identity> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "current", "members") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler<MemberUpdateResponse> = + jsonHandler<MemberUpdateResponse>(clientOptions.jsonMapper) + + override fun update( + params: MemberUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<MemberUpdateResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("identityId", params.identityId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "workspaces", + "current", + "members", + params._pathParam(0), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler<MemberListResponse> = + jsonHandler<MemberListResponse>(clientOptions.jsonMapper) + + override fun list( + params: MemberListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<MemberListResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "current", "members") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val deleteHandler: Handler<MemberDeleteResponse> = + jsonHandler<MemberDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: MemberDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<MemberDeleteResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("identityId", params.identityId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "workspaces", + "current", + "members", + params._pathParam(0), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val batchHandler: Handler<List<PendingIdentity>> = + jsonHandler<List<PendingIdentity>>(clientOptions.jsonMapper) + + override fun batch( + params: MemberBatchParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<PendingIdentity>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "current", "members", "batch") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { batchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val retrieveActiveHandler: Handler<List<MemberIdentity>> = + jsonHandler<List<MemberIdentity>>(clientOptions.jsonMapper) + + override fun retrieveActive( + params: MemberRetrieveActiveParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<MemberIdentity>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "current", "members", "active") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveActiveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/SecretService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/SecretService.kt new file mode 100644 index 00000000..bd86b05d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/SecretService.kt @@ -0,0 +1,135 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.workspaces.current + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.workspaces.current.secrets.SecretCreateParams +import com.langsmith_api.api.models.api.v1.workspaces.current.secrets.SecretCreateResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.secrets.SecretListParams +import com.langsmith_api.api.models.api.v1.workspaces.current.secrets.SecretListResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.secrets.SecretRetrieveEncryptedParams +import com.langsmith_api.api.models.api.v1.workspaces.current.secrets.SecretRetrieveEncryptedResponse +import java.util.function.Consumer + +interface SecretService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): SecretService + + /** Upsert Current Workspace Secrets */ + fun create(params: SecretCreateParams): SecretCreateResponse = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: SecretCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SecretCreateResponse + + /** List Current Workspace Secrets */ + fun list(): List<SecretListResponse> = list(SecretListParams.none()) + + /** @see list */ + fun list( + params: SecretListParams = SecretListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<SecretListResponse> + + /** @see list */ + fun list(params: SecretListParams = SecretListParams.none()): List<SecretListResponse> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): List<SecretListResponse> = + list(SecretListParams.none(), requestOptions) + + /** Get encrypted workspace secrets for use with Agent Builder and external services. */ + fun retrieveEncrypted(params: SecretRetrieveEncryptedParams): SecretRetrieveEncryptedResponse = + retrieveEncrypted(params, RequestOptions.none()) + + /** @see retrieveEncrypted */ + fun retrieveEncrypted( + params: SecretRetrieveEncryptedParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SecretRetrieveEncryptedResponse + + /** A view of [SecretService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): SecretService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/workspaces/current/secrets`, but is + * otherwise the same as [SecretService.create]. + */ + @MustBeClosed + fun create(params: SecretCreateParams): HttpResponseFor<SecretCreateResponse> = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: SecretCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<SecretCreateResponse> + + /** + * Returns a raw HTTP response for `get /api/v1/workspaces/current/secrets`, but is + * otherwise the same as [SecretService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor<List<SecretListResponse>> = list(SecretListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: SecretListParams = SecretListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<SecretListResponse>> + + /** @see list */ + @MustBeClosed + fun list( + params: SecretListParams = SecretListParams.none() + ): HttpResponseFor<List<SecretListResponse>> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor<List<SecretListResponse>> = + list(SecretListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/workspaces/current/secrets/encrypted`, but + * is otherwise the same as [SecretService.retrieveEncrypted]. + */ + @MustBeClosed + fun retrieveEncrypted( + params: SecretRetrieveEncryptedParams + ): HttpResponseFor<SecretRetrieveEncryptedResponse> = + retrieveEncrypted(params, RequestOptions.none()) + + /** @see retrieveEncrypted */ + @MustBeClosed + fun retrieveEncrypted( + params: SecretRetrieveEncryptedParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<SecretRetrieveEncryptedResponse> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/SecretServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/SecretServiceImpl.kt new file mode 100644 index 00000000..db56367f --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/SecretServiceImpl.kt @@ -0,0 +1,154 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.workspaces.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.workspaces.current.secrets.SecretCreateParams +import com.langsmith_api.api.models.api.v1.workspaces.current.secrets.SecretCreateResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.secrets.SecretListParams +import com.langsmith_api.api.models.api.v1.workspaces.current.secrets.SecretListResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.secrets.SecretRetrieveEncryptedParams +import com.langsmith_api.api.models.api.v1.workspaces.current.secrets.SecretRetrieveEncryptedResponse +import java.util.function.Consumer + +class SecretServiceImpl internal constructor(private val clientOptions: ClientOptions) : + SecretService { + + private val withRawResponse: SecretService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): SecretService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): SecretService = + SecretServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: SecretCreateParams, + requestOptions: RequestOptions, + ): SecretCreateResponse = + // post /api/v1/workspaces/current/secrets + withRawResponse().create(params, requestOptions).parse() + + override fun list( + params: SecretListParams, + requestOptions: RequestOptions, + ): List<SecretListResponse> = + // get /api/v1/workspaces/current/secrets + withRawResponse().list(params, requestOptions).parse() + + override fun retrieveEncrypted( + params: SecretRetrieveEncryptedParams, + requestOptions: RequestOptions, + ): SecretRetrieveEncryptedResponse = + // get /api/v1/workspaces/current/secrets/encrypted + withRawResponse().retrieveEncrypted(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SecretService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): SecretService.WithRawResponse = + SecretServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<SecretCreateResponse> = + jsonHandler<SecretCreateResponse>(clientOptions.jsonMapper) + + override fun create( + params: SecretCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<SecretCreateResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "current", "secrets") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler<List<SecretListResponse>> = + jsonHandler<List<SecretListResponse>>(clientOptions.jsonMapper) + + override fun list( + params: SecretListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<SecretListResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "current", "secrets") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val retrieveEncryptedHandler: Handler<SecretRetrieveEncryptedResponse> = + jsonHandler<SecretRetrieveEncryptedResponse>(clientOptions.jsonMapper) + + override fun retrieveEncrypted( + params: SecretRetrieveEncryptedParams, + requestOptions: RequestOptions, + ): HttpResponseFor<SecretRetrieveEncryptedResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "current", "secrets", "encrypted") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveEncryptedHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/SharedService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/SharedService.kt new file mode 100644 index 00000000..51b773d1 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/SharedService.kt @@ -0,0 +1,125 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.workspaces.current + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.workspaces.current.shared.SharedDeleteAllParams +import com.langsmith_api.api.models.api.v1.workspaces.current.shared.SharedDeleteAllResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.shared.SharedListParams +import com.langsmith_api.api.models.api.v1.workspaces.current.shared.SharedListResponse +import java.util.function.Consumer + +interface SharedService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): SharedService + + /** List all shared entities and their tokens by the workspace. */ + fun list(): SharedListResponse = list(SharedListParams.none()) + + /** @see list */ + fun list( + params: SharedListParams = SharedListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): SharedListResponse + + /** @see list */ + fun list(params: SharedListParams = SharedListParams.none()): SharedListResponse = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): SharedListResponse = + list(SharedListParams.none(), requestOptions) + + /** Bulk unshare entities by share tokens for the workspace. */ + fun deleteAll(): SharedDeleteAllResponse = deleteAll(SharedDeleteAllParams.none()) + + /** @see deleteAll */ + fun deleteAll( + params: SharedDeleteAllParams = SharedDeleteAllParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): SharedDeleteAllResponse + + /** @see deleteAll */ + fun deleteAll( + params: SharedDeleteAllParams = SharedDeleteAllParams.none() + ): SharedDeleteAllResponse = deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll(requestOptions: RequestOptions): SharedDeleteAllResponse = + deleteAll(SharedDeleteAllParams.none(), requestOptions) + + /** A view of [SharedService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): SharedService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/workspaces/current/shared`, but is otherwise + * the same as [SharedService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor<SharedListResponse> = list(SharedListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: SharedListParams = SharedListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<SharedListResponse> + + /** @see list */ + @MustBeClosed + fun list( + params: SharedListParams = SharedListParams.none() + ): HttpResponseFor<SharedListResponse> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor<SharedListResponse> = + list(SharedListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/workspaces/current/shared`, but is + * otherwise the same as [SharedService.deleteAll]. + */ + @MustBeClosed + fun deleteAll(): HttpResponseFor<SharedDeleteAllResponse> = + deleteAll(SharedDeleteAllParams.none()) + + /** @see deleteAll */ + @MustBeClosed + fun deleteAll( + params: SharedDeleteAllParams = SharedDeleteAllParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<SharedDeleteAllResponse> + + /** @see deleteAll */ + @MustBeClosed + fun deleteAll( + params: SharedDeleteAllParams = SharedDeleteAllParams.none() + ): HttpResponseFor<SharedDeleteAllResponse> = deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + @MustBeClosed + fun deleteAll(requestOptions: RequestOptions): HttpResponseFor<SharedDeleteAllResponse> = + deleteAll(SharedDeleteAllParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/SharedServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/SharedServiceImpl.kt new file mode 100644 index 00000000..fced6980 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/SharedServiceImpl.kt @@ -0,0 +1,118 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.workspaces.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.workspaces.current.shared.SharedDeleteAllParams +import com.langsmith_api.api.models.api.v1.workspaces.current.shared.SharedDeleteAllResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.shared.SharedListParams +import com.langsmith_api.api.models.api.v1.workspaces.current.shared.SharedListResponse +import java.util.function.Consumer + +class SharedServiceImpl internal constructor(private val clientOptions: ClientOptions) : + SharedService { + + private val withRawResponse: SharedService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): SharedService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): SharedService = + SharedServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: SharedListParams, + requestOptions: RequestOptions, + ): SharedListResponse = + // get /api/v1/workspaces/current/shared + withRawResponse().list(params, requestOptions).parse() + + override fun deleteAll( + params: SharedDeleteAllParams, + requestOptions: RequestOptions, + ): SharedDeleteAllResponse = + // delete /api/v1/workspaces/current/shared + withRawResponse().deleteAll(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SharedService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): SharedService.WithRawResponse = + SharedServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler<SharedListResponse> = + jsonHandler<SharedListResponse>(clientOptions.jsonMapper) + + override fun list( + params: SharedListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<SharedListResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "current", "shared") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val deleteAllHandler: Handler<SharedDeleteAllResponse> = + jsonHandler<SharedDeleteAllResponse>(clientOptions.jsonMapper) + + override fun deleteAll( + params: SharedDeleteAllParams, + requestOptions: RequestOptions, + ): HttpResponseFor<SharedDeleteAllResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "current", "shared") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteAllHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/TagKeyService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/TagKeyService.kt new file mode 100644 index 00000000..16587bb7 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/TagKeyService.kt @@ -0,0 +1,328 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.workspaces.current + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.TagKey +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.TagKeyDeleteParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.TagKeyDeleteResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.TagKeyRetrieveParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.TagKeyRetrieveTagKeysParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.TagKeyTagKeysParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.TagKeyUpdateParams +import com.langsmith_api.api.services.blocking.api.v1.workspaces.current.tagkeys.TagValueService +import java.util.function.Consumer + +interface TagKeyService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): TagKeyService + + fun tagValues(): TagValueService + + /** Get Tag Key */ + fun retrieve(tagKeyId: String): TagKey = retrieve(tagKeyId, TagKeyRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + tagKeyId: String, + params: TagKeyRetrieveParams = TagKeyRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): TagKey = retrieve(params.toBuilder().tagKeyId(tagKeyId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + tagKeyId: String, + params: TagKeyRetrieveParams = TagKeyRetrieveParams.none(), + ): TagKey = retrieve(tagKeyId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: TagKeyRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): TagKey + + /** @see retrieve */ + fun retrieve(params: TagKeyRetrieveParams): TagKey = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(tagKeyId: String, requestOptions: RequestOptions): TagKey = + retrieve(tagKeyId, TagKeyRetrieveParams.none(), requestOptions) + + /** Update Tag Key */ + fun update(tagKeyId: String): TagKey = update(tagKeyId, TagKeyUpdateParams.none()) + + /** @see update */ + fun update( + tagKeyId: String, + params: TagKeyUpdateParams = TagKeyUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): TagKey = update(params.toBuilder().tagKeyId(tagKeyId).build(), requestOptions) + + /** @see update */ + fun update(tagKeyId: String, params: TagKeyUpdateParams = TagKeyUpdateParams.none()): TagKey = + update(tagKeyId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: TagKeyUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): TagKey + + /** @see update */ + fun update(params: TagKeyUpdateParams): TagKey = update(params, RequestOptions.none()) + + /** @see update */ + fun update(tagKeyId: String, requestOptions: RequestOptions): TagKey = + update(tagKeyId, TagKeyUpdateParams.none(), requestOptions) + + /** Delete Tag Key */ + fun delete(tagKeyId: String): TagKeyDeleteResponse = delete(tagKeyId, TagKeyDeleteParams.none()) + + /** @see delete */ + fun delete( + tagKeyId: String, + params: TagKeyDeleteParams = TagKeyDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): TagKeyDeleteResponse = delete(params.toBuilder().tagKeyId(tagKeyId).build(), requestOptions) + + /** @see delete */ + fun delete( + tagKeyId: String, + params: TagKeyDeleteParams = TagKeyDeleteParams.none(), + ): TagKeyDeleteResponse = delete(tagKeyId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: TagKeyDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): TagKeyDeleteResponse + + /** @see delete */ + fun delete(params: TagKeyDeleteParams): TagKeyDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(tagKeyId: String, requestOptions: RequestOptions): TagKeyDeleteResponse = + delete(tagKeyId, TagKeyDeleteParams.none(), requestOptions) + + /** List Tag Keys */ + fun retrieveTagKeys(): List<TagKey> = retrieveTagKeys(TagKeyRetrieveTagKeysParams.none()) + + /** @see retrieveTagKeys */ + fun retrieveTagKeys( + params: TagKeyRetrieveTagKeysParams = TagKeyRetrieveTagKeysParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<TagKey> + + /** @see retrieveTagKeys */ + fun retrieveTagKeys( + params: TagKeyRetrieveTagKeysParams = TagKeyRetrieveTagKeysParams.none() + ): List<TagKey> = retrieveTagKeys(params, RequestOptions.none()) + + /** @see retrieveTagKeys */ + fun retrieveTagKeys(requestOptions: RequestOptions): List<TagKey> = + retrieveTagKeys(TagKeyRetrieveTagKeysParams.none(), requestOptions) + + /** Create Tag Key */ + fun tagKeys(params: TagKeyTagKeysParams): TagKey = tagKeys(params, RequestOptions.none()) + + /** @see tagKeys */ + fun tagKeys( + params: TagKeyTagKeysParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): TagKey + + /** A view of [TagKeyService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): TagKeyService.WithRawResponse + + fun tagValues(): TagValueService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/workspaces/current/tag-keys/{tag_key_id}`, + * but is otherwise the same as [TagKeyService.retrieve]. + */ + @MustBeClosed + fun retrieve(tagKeyId: String): HttpResponseFor<TagKey> = + retrieve(tagKeyId, TagKeyRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + tagKeyId: String, + params: TagKeyRetrieveParams = TagKeyRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<TagKey> = + retrieve(params.toBuilder().tagKeyId(tagKeyId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + tagKeyId: String, + params: TagKeyRetrieveParams = TagKeyRetrieveParams.none(), + ): HttpResponseFor<TagKey> = retrieve(tagKeyId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: TagKeyRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<TagKey> + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: TagKeyRetrieveParams): HttpResponseFor<TagKey> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve(tagKeyId: String, requestOptions: RequestOptions): HttpResponseFor<TagKey> = + retrieve(tagKeyId, TagKeyRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `patch /api/v1/workspaces/current/tag-keys/{tag_key_id}`, + * but is otherwise the same as [TagKeyService.update]. + */ + @MustBeClosed + fun update(tagKeyId: String): HttpResponseFor<TagKey> = + update(tagKeyId, TagKeyUpdateParams.none()) + + /** @see update */ + @MustBeClosed + fun update( + tagKeyId: String, + params: TagKeyUpdateParams = TagKeyUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<TagKey> = + update(params.toBuilder().tagKeyId(tagKeyId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update( + tagKeyId: String, + params: TagKeyUpdateParams = TagKeyUpdateParams.none(), + ): HttpResponseFor<TagKey> = update(tagKeyId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: TagKeyUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<TagKey> + + /** @see update */ + @MustBeClosed + fun update(params: TagKeyUpdateParams): HttpResponseFor<TagKey> = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update(tagKeyId: String, requestOptions: RequestOptions): HttpResponseFor<TagKey> = + update(tagKeyId, TagKeyUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete + * /api/v1/workspaces/current/tag-keys/{tag_key_id}`, but is otherwise the same as + * [TagKeyService.delete]. + */ + @MustBeClosed + fun delete(tagKeyId: String): HttpResponseFor<TagKeyDeleteResponse> = + delete(tagKeyId, TagKeyDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + tagKeyId: String, + params: TagKeyDeleteParams = TagKeyDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<TagKeyDeleteResponse> = + delete(params.toBuilder().tagKeyId(tagKeyId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + tagKeyId: String, + params: TagKeyDeleteParams = TagKeyDeleteParams.none(), + ): HttpResponseFor<TagKeyDeleteResponse> = delete(tagKeyId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: TagKeyDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<TagKeyDeleteResponse> + + /** @see delete */ + @MustBeClosed + fun delete(params: TagKeyDeleteParams): HttpResponseFor<TagKeyDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + tagKeyId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<TagKeyDeleteResponse> = + delete(tagKeyId, TagKeyDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/workspaces/current/tag-keys`, but is + * otherwise the same as [TagKeyService.retrieveTagKeys]. + */ + @MustBeClosed + fun retrieveTagKeys(): HttpResponseFor<List<TagKey>> = + retrieveTagKeys(TagKeyRetrieveTagKeysParams.none()) + + /** @see retrieveTagKeys */ + @MustBeClosed + fun retrieveTagKeys( + params: TagKeyRetrieveTagKeysParams = TagKeyRetrieveTagKeysParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<TagKey>> + + /** @see retrieveTagKeys */ + @MustBeClosed + fun retrieveTagKeys( + params: TagKeyRetrieveTagKeysParams = TagKeyRetrieveTagKeysParams.none() + ): HttpResponseFor<List<TagKey>> = retrieveTagKeys(params, RequestOptions.none()) + + /** @see retrieveTagKeys */ + @MustBeClosed + fun retrieveTagKeys(requestOptions: RequestOptions): HttpResponseFor<List<TagKey>> = + retrieveTagKeys(TagKeyRetrieveTagKeysParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/workspaces/current/tag-keys`, but is + * otherwise the same as [TagKeyService.tagKeys]. + */ + @MustBeClosed + fun tagKeys(params: TagKeyTagKeysParams): HttpResponseFor<TagKey> = + tagKeys(params, RequestOptions.none()) + + /** @see tagKeys */ + @MustBeClosed + fun tagKeys( + params: TagKeyTagKeysParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<TagKey> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/TagKeyServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/TagKeyServiceImpl.kt new file mode 100644 index 00000000..d647a02d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/TagKeyServiceImpl.kt @@ -0,0 +1,257 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.workspaces.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.TagKey +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.TagKeyDeleteParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.TagKeyDeleteResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.TagKeyRetrieveParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.TagKeyRetrieveTagKeysParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.TagKeyTagKeysParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.TagKeyUpdateParams +import com.langsmith_api.api.services.blocking.api.v1.workspaces.current.tagkeys.TagValueService +import com.langsmith_api.api.services.blocking.api.v1.workspaces.current.tagkeys.TagValueServiceImpl +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class TagKeyServiceImpl internal constructor(private val clientOptions: ClientOptions) : + TagKeyService { + + private val withRawResponse: TagKeyService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val tagValues: TagValueService by lazy { TagValueServiceImpl(clientOptions) } + + override fun withRawResponse(): TagKeyService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): TagKeyService = + TagKeyServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun tagValues(): TagValueService = tagValues + + override fun retrieve(params: TagKeyRetrieveParams, requestOptions: RequestOptions): TagKey = + // get /api/v1/workspaces/current/tag-keys/{tag_key_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update(params: TagKeyUpdateParams, requestOptions: RequestOptions): TagKey = + // patch /api/v1/workspaces/current/tag-keys/{tag_key_id} + withRawResponse().update(params, requestOptions).parse() + + override fun delete( + params: TagKeyDeleteParams, + requestOptions: RequestOptions, + ): TagKeyDeleteResponse = + // delete /api/v1/workspaces/current/tag-keys/{tag_key_id} + withRawResponse().delete(params, requestOptions).parse() + + override fun retrieveTagKeys( + params: TagKeyRetrieveTagKeysParams, + requestOptions: RequestOptions, + ): List<TagKey> = + // get /api/v1/workspaces/current/tag-keys + withRawResponse().retrieveTagKeys(params, requestOptions).parse() + + override fun tagKeys(params: TagKeyTagKeysParams, requestOptions: RequestOptions): TagKey = + // post /api/v1/workspaces/current/tag-keys + withRawResponse().tagKeys(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TagKeyService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val tagValues: TagValueService.WithRawResponse by lazy { + TagValueServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): TagKeyService.WithRawResponse = + TagKeyServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun tagValues(): TagValueService.WithRawResponse = tagValues + + private val retrieveHandler: Handler<TagKey> = jsonHandler<TagKey>(clientOptions.jsonMapper) + + override fun retrieve( + params: TagKeyRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor<TagKey> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tagKeyId", params.tagKeyId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "workspaces", + "current", + "tag-keys", + params._pathParam(0), + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler<TagKey> = jsonHandler<TagKey>(clientOptions.jsonMapper) + + override fun update( + params: TagKeyUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<TagKey> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tagKeyId", params.tagKeyId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "workspaces", + "current", + "tag-keys", + params._pathParam(0), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val deleteHandler: Handler<TagKeyDeleteResponse> = + jsonHandler<TagKeyDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: TagKeyDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<TagKeyDeleteResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tagKeyId", params.tagKeyId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "workspaces", + "current", + "tag-keys", + params._pathParam(0), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveTagKeysHandler: Handler<List<TagKey>> = + jsonHandler<List<TagKey>>(clientOptions.jsonMapper) + + override fun retrieveTagKeys( + params: TagKeyRetrieveTagKeysParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<TagKey>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "current", "tag-keys") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveTagKeysHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val tagKeysHandler: Handler<TagKey> = jsonHandler<TagKey>(clientOptions.jsonMapper) + + override fun tagKeys( + params: TagKeyTagKeysParams, + requestOptions: RequestOptions, + ): HttpResponseFor<TagKey> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "current", "tag-keys") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { tagKeysHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/TagService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/TagService.kt new file mode 100644 index 00000000..52f74d1a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/TagService.kt @@ -0,0 +1,135 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.workspaces.current + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.workspaces.current.tags.TagListParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tags.TagListResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.tags.TagResourcesParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tags.TagResourcesResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.tags.TagRetrieveResourceParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tags.TagRetrieveResourceResponse +import java.util.function.Consumer + +interface TagService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): TagService + + /** List Tags */ + fun list(): List<TagListResponse> = list(TagListParams.none()) + + /** @see list */ + fun list( + params: TagListParams = TagListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<TagListResponse> + + /** @see list */ + fun list(params: TagListParams = TagListParams.none()): List<TagListResponse> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): List<TagListResponse> = + list(TagListParams.none(), requestOptions) + + /** List Tags For Resources */ + fun resources(params: TagResourcesParams): TagResourcesResponse = + resources(params, RequestOptions.none()) + + /** @see resources */ + fun resources( + params: TagResourcesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): TagResourcesResponse + + /** List Tags For Resource */ + fun retrieveResource(params: TagRetrieveResourceParams): List<TagRetrieveResourceResponse> = + retrieveResource(params, RequestOptions.none()) + + /** @see retrieveResource */ + fun retrieveResource( + params: TagRetrieveResourceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List<TagRetrieveResourceResponse> + + /** A view of [TagService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): TagService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/workspaces/current/tags`, but is otherwise + * the same as [TagService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor<List<TagListResponse>> = list(TagListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: TagListParams = TagListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<TagListResponse>> + + /** @see list */ + @MustBeClosed + fun list( + params: TagListParams = TagListParams.none() + ): HttpResponseFor<List<TagListResponse>> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor<List<TagListResponse>> = + list(TagListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/workspaces/current/tags/resources`, but is + * otherwise the same as [TagService.resources]. + */ + @MustBeClosed + fun resources(params: TagResourcesParams): HttpResponseFor<TagResourcesResponse> = + resources(params, RequestOptions.none()) + + /** @see resources */ + @MustBeClosed + fun resources( + params: TagResourcesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<TagResourcesResponse> + + /** + * Returns a raw HTTP response for `get /api/v1/workspaces/current/tags/resource`, but is + * otherwise the same as [TagService.retrieveResource]. + */ + @MustBeClosed + fun retrieveResource( + params: TagRetrieveResourceParams + ): HttpResponseFor<List<TagRetrieveResourceResponse>> = + retrieveResource(params, RequestOptions.none()) + + /** @see retrieveResource */ + @MustBeClosed + fun retrieveResource( + params: TagRetrieveResourceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<TagRetrieveResourceResponse>> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/TagServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/TagServiceImpl.kt new file mode 100644 index 00000000..434105bc --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/TagServiceImpl.kt @@ -0,0 +1,153 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.workspaces.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.workspaces.current.tags.TagListParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tags.TagListResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.tags.TagResourcesParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tags.TagResourcesResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.tags.TagRetrieveResourceParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tags.TagRetrieveResourceResponse +import java.util.function.Consumer + +class TagServiceImpl internal constructor(private val clientOptions: ClientOptions) : TagService { + + private val withRawResponse: TagService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): TagService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): TagService = + TagServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: TagListParams, + requestOptions: RequestOptions, + ): List<TagListResponse> = + // get /api/v1/workspaces/current/tags + withRawResponse().list(params, requestOptions).parse() + + override fun resources( + params: TagResourcesParams, + requestOptions: RequestOptions, + ): TagResourcesResponse = + // post /api/v1/workspaces/current/tags/resources + withRawResponse().resources(params, requestOptions).parse() + + override fun retrieveResource( + params: TagRetrieveResourceParams, + requestOptions: RequestOptions, + ): List<TagRetrieveResourceResponse> = + // get /api/v1/workspaces/current/tags/resource + withRawResponse().retrieveResource(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TagService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): TagService.WithRawResponse = + TagServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler<List<TagListResponse>> = + jsonHandler<List<TagListResponse>>(clientOptions.jsonMapper) + + override fun list( + params: TagListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<TagListResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "current", "tags") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val resourcesHandler: Handler<TagResourcesResponse> = + jsonHandler<TagResourcesResponse>(clientOptions.jsonMapper) + + override fun resources( + params: TagResourcesParams, + requestOptions: RequestOptions, + ): HttpResponseFor<TagResourcesResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "current", "tags", "resources") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { resourcesHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveResourceHandler: Handler<List<TagRetrieveResourceResponse>> = + jsonHandler<List<TagRetrieveResourceResponse>>(clientOptions.jsonMapper) + + override fun retrieveResource( + params: TagRetrieveResourceParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<TagRetrieveResourceResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "current", "tags", "resource") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveResourceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/TaggingService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/TaggingService.kt new file mode 100644 index 00000000..82c074d5 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/TaggingService.kt @@ -0,0 +1,184 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.workspaces.current + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.workspaces.current.taggings.Tagging +import com.langsmith_api.api.models.api.v1.workspaces.current.taggings.TaggingCreateParams +import com.langsmith_api.api.models.api.v1.workspaces.current.taggings.TaggingDeleteParams +import com.langsmith_api.api.models.api.v1.workspaces.current.taggings.TaggingDeleteResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.taggings.TaggingListParams +import com.langsmith_api.api.models.api.v1.workspaces.current.taggings.TaggingListResponse +import java.util.function.Consumer + +interface TaggingService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): TaggingService + + /** Create Tagging */ + fun create(params: TaggingCreateParams): Tagging = create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: TaggingCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Tagging + + /** List Taggings */ + fun list(): List<TaggingListResponse> = list(TaggingListParams.none()) + + /** @see list */ + fun list( + params: TaggingListParams = TaggingListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<TaggingListResponse> + + /** @see list */ + fun list(params: TaggingListParams = TaggingListParams.none()): List<TaggingListResponse> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): List<TaggingListResponse> = + list(TaggingListParams.none(), requestOptions) + + /** Delete Tagging */ + fun delete(taggingId: String): TaggingDeleteResponse = + delete(taggingId, TaggingDeleteParams.none()) + + /** @see delete */ + fun delete( + taggingId: String, + params: TaggingDeleteParams = TaggingDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): TaggingDeleteResponse = + delete(params.toBuilder().taggingId(taggingId).build(), requestOptions) + + /** @see delete */ + fun delete( + taggingId: String, + params: TaggingDeleteParams = TaggingDeleteParams.none(), + ): TaggingDeleteResponse = delete(taggingId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: TaggingDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): TaggingDeleteResponse + + /** @see delete */ + fun delete(params: TaggingDeleteParams): TaggingDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(taggingId: String, requestOptions: RequestOptions): TaggingDeleteResponse = + delete(taggingId, TaggingDeleteParams.none(), requestOptions) + + /** A view of [TaggingService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): TaggingService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/workspaces/current/taggings`, but is + * otherwise the same as [TaggingService.create]. + */ + @MustBeClosed + fun create(params: TaggingCreateParams): HttpResponseFor<Tagging> = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: TaggingCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<Tagging> + + /** + * Returns a raw HTTP response for `get /api/v1/workspaces/current/taggings`, but is + * otherwise the same as [TaggingService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor<List<TaggingListResponse>> = list(TaggingListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: TaggingListParams = TaggingListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<TaggingListResponse>> + + /** @see list */ + @MustBeClosed + fun list( + params: TaggingListParams = TaggingListParams.none() + ): HttpResponseFor<List<TaggingListResponse>> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor<List<TaggingListResponse>> = + list(TaggingListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete + * /api/v1/workspaces/current/taggings/{tagging_id}`, but is otherwise the same as + * [TaggingService.delete]. + */ + @MustBeClosed + fun delete(taggingId: String): HttpResponseFor<TaggingDeleteResponse> = + delete(taggingId, TaggingDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + taggingId: String, + params: TaggingDeleteParams = TaggingDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<TaggingDeleteResponse> = + delete(params.toBuilder().taggingId(taggingId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + taggingId: String, + params: TaggingDeleteParams = TaggingDeleteParams.none(), + ): HttpResponseFor<TaggingDeleteResponse> = delete(taggingId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: TaggingDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<TaggingDeleteResponse> + + /** @see delete */ + @MustBeClosed + fun delete(params: TaggingDeleteParams): HttpResponseFor<TaggingDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + taggingId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<TaggingDeleteResponse> = + delete(taggingId, TaggingDeleteParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/TaggingServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/TaggingServiceImpl.kt new file mode 100644 index 00000000..99adb84b --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/TaggingServiceImpl.kt @@ -0,0 +1,163 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.workspaces.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.workspaces.current.taggings.Tagging +import com.langsmith_api.api.models.api.v1.workspaces.current.taggings.TaggingCreateParams +import com.langsmith_api.api.models.api.v1.workspaces.current.taggings.TaggingDeleteParams +import com.langsmith_api.api.models.api.v1.workspaces.current.taggings.TaggingDeleteResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.taggings.TaggingListParams +import com.langsmith_api.api.models.api.v1.workspaces.current.taggings.TaggingListResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class TaggingServiceImpl internal constructor(private val clientOptions: ClientOptions) : + TaggingService { + + private val withRawResponse: TaggingService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): TaggingService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): TaggingService = + TaggingServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create(params: TaggingCreateParams, requestOptions: RequestOptions): Tagging = + // post /api/v1/workspaces/current/taggings + withRawResponse().create(params, requestOptions).parse() + + override fun list( + params: TaggingListParams, + requestOptions: RequestOptions, + ): List<TaggingListResponse> = + // get /api/v1/workspaces/current/taggings + withRawResponse().list(params, requestOptions).parse() + + override fun delete( + params: TaggingDeleteParams, + requestOptions: RequestOptions, + ): TaggingDeleteResponse = + // delete /api/v1/workspaces/current/taggings/{tagging_id} + withRawResponse().delete(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TaggingService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): TaggingService.WithRawResponse = + TaggingServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<Tagging> = jsonHandler<Tagging>(clientOptions.jsonMapper) + + override fun create( + params: TaggingCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<Tagging> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "current", "taggings") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler<List<TaggingListResponse>> = + jsonHandler<List<TaggingListResponse>>(clientOptions.jsonMapper) + + override fun list( + params: TaggingListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<TaggingListResponse>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "current", "taggings") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val deleteHandler: Handler<TaggingDeleteResponse> = + jsonHandler<TaggingDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: TaggingDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<TaggingDeleteResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("taggingId", params.taggingId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "workspaces", + "current", + "taggings", + params._pathParam(0), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/members/PendingService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/members/PendingService.kt new file mode 100644 index 00000000..b2960661 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/members/PendingService.kt @@ -0,0 +1,159 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.workspaces.current.members + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.orgs.current.members.PendingIdentity +import com.langsmith_api.api.models.api.v1.workspaces.current.members.pending.PendingDeleteAllParams +import com.langsmith_api.api.models.api.v1.workspaces.current.members.pending.PendingDeleteAllResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.members.pending.PendingListParams +import java.util.function.Consumer + +interface PendingService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): PendingService + + /** Get Current Pending Workspace Members */ + fun list(): List<PendingIdentity> = list(PendingListParams.none()) + + /** @see list */ + fun list( + params: PendingListParams = PendingListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<PendingIdentity> + + /** @see list */ + fun list(params: PendingListParams = PendingListParams.none()): List<PendingIdentity> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): List<PendingIdentity> = + list(PendingListParams.none(), requestOptions) + + /** Delete Current Workspace Pending Member */ + fun deleteAll(identityId: String): PendingDeleteAllResponse = + deleteAll(identityId, PendingDeleteAllParams.none()) + + /** @see deleteAll */ + fun deleteAll( + identityId: String, + params: PendingDeleteAllParams = PendingDeleteAllParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): PendingDeleteAllResponse = + deleteAll(params.toBuilder().identityId(identityId).build(), requestOptions) + + /** @see deleteAll */ + fun deleteAll( + identityId: String, + params: PendingDeleteAllParams = PendingDeleteAllParams.none(), + ): PendingDeleteAllResponse = deleteAll(identityId, params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + params: PendingDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): PendingDeleteAllResponse + + /** @see deleteAll */ + fun deleteAll(params: PendingDeleteAllParams): PendingDeleteAllResponse = + deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll(identityId: String, requestOptions: RequestOptions): PendingDeleteAllResponse = + deleteAll(identityId, PendingDeleteAllParams.none(), requestOptions) + + /** A view of [PendingService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): PendingService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/workspaces/current/members/pending`, but is + * otherwise the same as [PendingService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor<List<PendingIdentity>> = list(PendingListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: PendingListParams = PendingListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<PendingIdentity>> + + /** @see list */ + @MustBeClosed + fun list( + params: PendingListParams = PendingListParams.none() + ): HttpResponseFor<List<PendingIdentity>> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor<List<PendingIdentity>> = + list(PendingListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete + * /api/v1/workspaces/current/members/{identity_id}/pending`, but is otherwise the same as + * [PendingService.deleteAll]. + */ + @MustBeClosed + fun deleteAll(identityId: String): HttpResponseFor<PendingDeleteAllResponse> = + deleteAll(identityId, PendingDeleteAllParams.none()) + + /** @see deleteAll */ + @MustBeClosed + fun deleteAll( + identityId: String, + params: PendingDeleteAllParams = PendingDeleteAllParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<PendingDeleteAllResponse> = + deleteAll(params.toBuilder().identityId(identityId).build(), requestOptions) + + /** @see deleteAll */ + @MustBeClosed + fun deleteAll( + identityId: String, + params: PendingDeleteAllParams = PendingDeleteAllParams.none(), + ): HttpResponseFor<PendingDeleteAllResponse> = + deleteAll(identityId, params, RequestOptions.none()) + + /** @see deleteAll */ + @MustBeClosed + fun deleteAll( + params: PendingDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<PendingDeleteAllResponse> + + /** @see deleteAll */ + @MustBeClosed + fun deleteAll(params: PendingDeleteAllParams): HttpResponseFor<PendingDeleteAllResponse> = + deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + @MustBeClosed + fun deleteAll( + identityId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<PendingDeleteAllResponse> = + deleteAll(identityId, PendingDeleteAllParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/members/PendingServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/members/PendingServiceImpl.kt new file mode 100644 index 00000000..f5d19391 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/members/PendingServiceImpl.kt @@ -0,0 +1,131 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.workspaces.current.members + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.orgs.current.members.PendingIdentity +import com.langsmith_api.api.models.api.v1.workspaces.current.members.pending.PendingDeleteAllParams +import com.langsmith_api.api.models.api.v1.workspaces.current.members.pending.PendingDeleteAllResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.members.pending.PendingListParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class PendingServiceImpl internal constructor(private val clientOptions: ClientOptions) : + PendingService { + + private val withRawResponse: PendingService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): PendingService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): PendingService = + PendingServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: PendingListParams, + requestOptions: RequestOptions, + ): List<PendingIdentity> = + // get /api/v1/workspaces/current/members/pending + withRawResponse().list(params, requestOptions).parse() + + override fun deleteAll( + params: PendingDeleteAllParams, + requestOptions: RequestOptions, + ): PendingDeleteAllResponse = + // delete /api/v1/workspaces/current/members/{identity_id}/pending + withRawResponse().deleteAll(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + PendingService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): PendingService.WithRawResponse = + PendingServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler<List<PendingIdentity>> = + jsonHandler<List<PendingIdentity>>(clientOptions.jsonMapper) + + override fun list( + params: PendingListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<PendingIdentity>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "workspaces", "current", "members", "pending") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val deleteAllHandler: Handler<PendingDeleteAllResponse> = + jsonHandler<PendingDeleteAllResponse>(clientOptions.jsonMapper) + + override fun deleteAll( + params: PendingDeleteAllParams, + requestOptions: RequestOptions, + ): HttpResponseFor<PendingDeleteAllResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("identityId", params.identityId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "workspaces", + "current", + "members", + params._pathParam(0), + "pending", + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteAllHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/tagkeys/TagValueService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/tagkeys/TagValueService.kt new file mode 100644 index 00000000..df2023ba --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/tagkeys/TagValueService.kt @@ -0,0 +1,331 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.workspaces.current.tagkeys + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues.TagValue +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues.TagValueDeleteParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues.TagValueDeleteResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues.TagValueRetrieveParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues.TagValueRetrieveTagValuesParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues.TagValueTagValuesParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues.TagValueUpdateParams +import java.util.function.Consumer + +interface TagValueService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): TagValueService + + /** Get Tag Value */ + fun retrieve(tagValueId: String, params: TagValueRetrieveParams): TagValue = + retrieve(tagValueId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + tagValueId: String, + params: TagValueRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): TagValue = retrieve(params.toBuilder().tagValueId(tagValueId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: TagValueRetrieveParams): TagValue = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: TagValueRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): TagValue + + /** Update Tag Value */ + fun update(tagValueId: String, params: TagValueUpdateParams): TagValue = + update(tagValueId, params, RequestOptions.none()) + + /** @see update */ + fun update( + tagValueId: String, + params: TagValueUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): TagValue = update(params.toBuilder().tagValueId(tagValueId).build(), requestOptions) + + /** @see update */ + fun update(params: TagValueUpdateParams): TagValue = update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: TagValueUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): TagValue + + /** Delete Tag Value */ + fun delete(tagValueId: String, params: TagValueDeleteParams): TagValueDeleteResponse = + delete(tagValueId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + tagValueId: String, + params: TagValueDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): TagValueDeleteResponse = + delete(params.toBuilder().tagValueId(tagValueId).build(), requestOptions) + + /** @see delete */ + fun delete(params: TagValueDeleteParams): TagValueDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: TagValueDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): TagValueDeleteResponse + + /** List Tag Values */ + fun retrieveTagValues(tagKeyId: String): List<TagValue> = + retrieveTagValues(tagKeyId, TagValueRetrieveTagValuesParams.none()) + + /** @see retrieveTagValues */ + fun retrieveTagValues( + tagKeyId: String, + params: TagValueRetrieveTagValuesParams = TagValueRetrieveTagValuesParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<TagValue> = + retrieveTagValues(params.toBuilder().tagKeyId(tagKeyId).build(), requestOptions) + + /** @see retrieveTagValues */ + fun retrieveTagValues( + tagKeyId: String, + params: TagValueRetrieveTagValuesParams = TagValueRetrieveTagValuesParams.none(), + ): List<TagValue> = retrieveTagValues(tagKeyId, params, RequestOptions.none()) + + /** @see retrieveTagValues */ + fun retrieveTagValues( + params: TagValueRetrieveTagValuesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List<TagValue> + + /** @see retrieveTagValues */ + fun retrieveTagValues(params: TagValueRetrieveTagValuesParams): List<TagValue> = + retrieveTagValues(params, RequestOptions.none()) + + /** @see retrieveTagValues */ + fun retrieveTagValues(tagKeyId: String, requestOptions: RequestOptions): List<TagValue> = + retrieveTagValues(tagKeyId, TagValueRetrieveTagValuesParams.none(), requestOptions) + + /** Create Tag Value */ + fun tagValues(tagKeyId: String, params: TagValueTagValuesParams): TagValue = + tagValues(tagKeyId, params, RequestOptions.none()) + + /** @see tagValues */ + fun tagValues( + tagKeyId: String, + params: TagValueTagValuesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): TagValue = tagValues(params.toBuilder().tagKeyId(tagKeyId).build(), requestOptions) + + /** @see tagValues */ + fun tagValues(params: TagValueTagValuesParams): TagValue = + tagValues(params, RequestOptions.none()) + + /** @see tagValues */ + fun tagValues( + params: TagValueTagValuesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): TagValue + + /** A view of [TagValueService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): TagValueService.WithRawResponse + + /** + * Returns a raw HTTP response for `get + * /api/v1/workspaces/current/tag-keys/{tag_key_id}/tag-values/{tag_value_id}`, but is + * otherwise the same as [TagValueService.retrieve]. + */ + @MustBeClosed + fun retrieve( + tagValueId: String, + params: TagValueRetrieveParams, + ): HttpResponseFor<TagValue> = retrieve(tagValueId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + tagValueId: String, + params: TagValueRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<TagValue> = + retrieve(params.toBuilder().tagValueId(tagValueId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: TagValueRetrieveParams): HttpResponseFor<TagValue> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: TagValueRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<TagValue> + + /** + * Returns a raw HTTP response for `patch + * /api/v1/workspaces/current/tag-keys/{tag_key_id}/tag-values/{tag_value_id}`, but is + * otherwise the same as [TagValueService.update]. + */ + @MustBeClosed + fun update(tagValueId: String, params: TagValueUpdateParams): HttpResponseFor<TagValue> = + update(tagValueId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + tagValueId: String, + params: TagValueUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<TagValue> = + update(params.toBuilder().tagValueId(tagValueId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(params: TagValueUpdateParams): HttpResponseFor<TagValue> = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: TagValueUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<TagValue> + + /** + * Returns a raw HTTP response for `delete + * /api/v1/workspaces/current/tag-keys/{tag_key_id}/tag-values/{tag_value_id}`, but is + * otherwise the same as [TagValueService.delete]. + */ + @MustBeClosed + fun delete( + tagValueId: String, + params: TagValueDeleteParams, + ): HttpResponseFor<TagValueDeleteResponse> = + delete(tagValueId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + tagValueId: String, + params: TagValueDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<TagValueDeleteResponse> = + delete(params.toBuilder().tagValueId(tagValueId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete(params: TagValueDeleteParams): HttpResponseFor<TagValueDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: TagValueDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<TagValueDeleteResponse> + + /** + * Returns a raw HTTP response for `get + * /api/v1/workspaces/current/tag-keys/{tag_key_id}/tag-values`, but is otherwise the same + * as [TagValueService.retrieveTagValues]. + */ + @MustBeClosed + fun retrieveTagValues(tagKeyId: String): HttpResponseFor<List<TagValue>> = + retrieveTagValues(tagKeyId, TagValueRetrieveTagValuesParams.none()) + + /** @see retrieveTagValues */ + @MustBeClosed + fun retrieveTagValues( + tagKeyId: String, + params: TagValueRetrieveTagValuesParams = TagValueRetrieveTagValuesParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<TagValue>> = + retrieveTagValues(params.toBuilder().tagKeyId(tagKeyId).build(), requestOptions) + + /** @see retrieveTagValues */ + @MustBeClosed + fun retrieveTagValues( + tagKeyId: String, + params: TagValueRetrieveTagValuesParams = TagValueRetrieveTagValuesParams.none(), + ): HttpResponseFor<List<TagValue>> = + retrieveTagValues(tagKeyId, params, RequestOptions.none()) + + /** @see retrieveTagValues */ + @MustBeClosed + fun retrieveTagValues( + params: TagValueRetrieveTagValuesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<TagValue>> + + /** @see retrieveTagValues */ + @MustBeClosed + fun retrieveTagValues( + params: TagValueRetrieveTagValuesParams + ): HttpResponseFor<List<TagValue>> = retrieveTagValues(params, RequestOptions.none()) + + /** @see retrieveTagValues */ + @MustBeClosed + fun retrieveTagValues( + tagKeyId: String, + requestOptions: RequestOptions, + ): HttpResponseFor<List<TagValue>> = + retrieveTagValues(tagKeyId, TagValueRetrieveTagValuesParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post + * /api/v1/workspaces/current/tag-keys/{tag_key_id}/tag-values`, but is otherwise the same + * as [TagValueService.tagValues]. + */ + @MustBeClosed + fun tagValues( + tagKeyId: String, + params: TagValueTagValuesParams, + ): HttpResponseFor<TagValue> = tagValues(tagKeyId, params, RequestOptions.none()) + + /** @see tagValues */ + @MustBeClosed + fun tagValues( + tagKeyId: String, + params: TagValueTagValuesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<TagValue> = + tagValues(params.toBuilder().tagKeyId(tagKeyId).build(), requestOptions) + + /** @see tagValues */ + @MustBeClosed + fun tagValues(params: TagValueTagValuesParams): HttpResponseFor<TagValue> = + tagValues(params, RequestOptions.none()) + + /** @see tagValues */ + @MustBeClosed + fun tagValues( + params: TagValueTagValuesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<TagValue> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/tagkeys/TagValueServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/tagkeys/TagValueServiceImpl.kt new file mode 100644 index 00000000..6944ebbd --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/tagkeys/TagValueServiceImpl.kt @@ -0,0 +1,282 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.workspaces.current.tagkeys + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.checkRequired +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues.TagValue +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues.TagValueDeleteParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues.TagValueDeleteResponse +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues.TagValueRetrieveParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues.TagValueRetrieveTagValuesParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues.TagValueTagValuesParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues.TagValueUpdateParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class TagValueServiceImpl internal constructor(private val clientOptions: ClientOptions) : + TagValueService { + + private val withRawResponse: TagValueService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): TagValueService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): TagValueService = + TagValueServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: TagValueRetrieveParams, + requestOptions: RequestOptions, + ): TagValue = + // get /api/v1/workspaces/current/tag-keys/{tag_key_id}/tag-values/{tag_value_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update(params: TagValueUpdateParams, requestOptions: RequestOptions): TagValue = + // patch /api/v1/workspaces/current/tag-keys/{tag_key_id}/tag-values/{tag_value_id} + withRawResponse().update(params, requestOptions).parse() + + override fun delete( + params: TagValueDeleteParams, + requestOptions: RequestOptions, + ): TagValueDeleteResponse = + // delete /api/v1/workspaces/current/tag-keys/{tag_key_id}/tag-values/{tag_value_id} + withRawResponse().delete(params, requestOptions).parse() + + override fun retrieveTagValues( + params: TagValueRetrieveTagValuesParams, + requestOptions: RequestOptions, + ): List<TagValue> = + // get /api/v1/workspaces/current/tag-keys/{tag_key_id}/tag-values + withRawResponse().retrieveTagValues(params, requestOptions).parse() + + override fun tagValues( + params: TagValueTagValuesParams, + requestOptions: RequestOptions, + ): TagValue = + // post /api/v1/workspaces/current/tag-keys/{tag_key_id}/tag-values + withRawResponse().tagValues(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TagValueService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): TagValueService.WithRawResponse = + TagValueServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler<TagValue> = + jsonHandler<TagValue>(clientOptions.jsonMapper) + + override fun retrieve( + params: TagValueRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor<TagValue> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tagValueId", params.tagValueId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "workspaces", + "current", + "tag-keys", + params._pathParam(0), + "tag-values", + params._pathParam(1), + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler<TagValue> = + jsonHandler<TagValue>(clientOptions.jsonMapper) + + override fun update( + params: TagValueUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<TagValue> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tagValueId", params.tagValueId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "workspaces", + "current", + "tag-keys", + params._pathParam(0), + "tag-values", + params._pathParam(1), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val deleteHandler: Handler<TagValueDeleteResponse> = + jsonHandler<TagValueDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: TagValueDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<TagValueDeleteResponse> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tagValueId", params.tagValueId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "workspaces", + "current", + "tag-keys", + params._pathParam(0), + "tag-values", + params._pathParam(1), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveTagValuesHandler: Handler<List<TagValue>> = + jsonHandler<List<TagValue>>(clientOptions.jsonMapper) + + override fun retrieveTagValues( + params: TagValueRetrieveTagValuesParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<TagValue>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tagKeyId", params.tagKeyId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "workspaces", + "current", + "tag-keys", + params._pathParam(0), + "tag-values", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveTagValuesHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val tagValuesHandler: Handler<TagValue> = + jsonHandler<TagValue>(clientOptions.jsonMapper) + + override fun tagValues( + params: TagValueTagValuesParams, + requestOptions: RequestOptions, + ): HttpResponseFor<TagValue> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tagKeyId", params.tagKeyId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "workspaces", + "current", + "tag-keys", + params._pathParam(0), + "tag-values", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { tagValuesHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/datasets/ExperimentViewOverrideService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/datasets/ExperimentViewOverrideService.kt new file mode 100644 index 00000000..239427c1 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/datasets/ExperimentViewOverrideService.kt @@ -0,0 +1,413 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.datasets + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.datasets.experimentviewoverrides.ExperimentViewOverride +import com.langsmith_api.api.models.datasets.experimentviewoverrides.ExperimentViewOverrideCreateParams +import com.langsmith_api.api.models.datasets.experimentviewoverrides.ExperimentViewOverrideDeleteParams +import com.langsmith_api.api.models.datasets.experimentviewoverrides.ExperimentViewOverrideListParams +import com.langsmith_api.api.models.datasets.experimentviewoverrides.ExperimentViewOverrideRetrieveParams +import com.langsmith_api.api.models.datasets.experimentviewoverrides.ExperimentViewOverrideUpdateParams +import java.util.function.Consumer + +interface ExperimentViewOverrideService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ExperimentViewOverrideService + + /** + * Creates a new experiment view override configuration for a dataset with column display + * settings. This endpoint allows you to customize how experiment results are displayed by + * configuring column-specific overrides including colors, precision, and visibility. + * + * The request must include a 'column_overrides' array with at least one override configuration. + * Each column override can specify: + * - column: Required field name (must start with inputs, outputs, reference_outputs, feedback, + * metrics, attachments, or metadata) + * - color_gradient: Optional array of [number, color] tuples for numeric data visualization + * - precision: Optional number (1-6) for decimal places in numeric columns + * - hide: Optional boolean to control column visibility + * + * Example request body: { "column_overrides": + * [ { "column": "outputs.accuracy", "color_gradient": [[0.0, "#ff0000"], [0.5, "#ffff00"], + * [1.0, "#00ff00"]], "precision": 3 }, { "column": "inputs.model_type", "hide": false } ] } + * + * This operation fails if an override already exists for the dataset (use PATCH to update). + */ + fun create( + datasetId: JsonValue, + params: ExperimentViewOverrideCreateParams, + ): ExperimentViewOverride = create(datasetId, params, RequestOptions.none()) + + /** @see create */ + fun create( + datasetId: JsonValue, + params: ExperimentViewOverrideCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ExperimentViewOverride = + create(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see create */ + fun create(params: ExperimentViewOverrideCreateParams): ExperimentViewOverride = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: ExperimentViewOverrideCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ExperimentViewOverride + + /** + * Retrieves a specific experiment view override configuration using both dataset ID and + * override ID. This endpoint provides more precise access to experiment view overrides when you + * have the specific override ID, useful for direct links or cached references. + * + * The response includes the same column override information as the dataset-level endpoint: + * - Column identifiers with validation prefixes + * - Color gradient settings for numeric data visualization + * - Numeric precision configurations + * - Column visibility controls + * + * Both the dataset and override must exist and be accessible by the authenticated user. + */ + fun retrieve( + id: JsonValue, + params: ExperimentViewOverrideRetrieveParams, + ): ExperimentViewOverride = retrieve(id, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + id: JsonValue, + params: ExperimentViewOverrideRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ExperimentViewOverride = retrieve(params.toBuilder().id(id).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: ExperimentViewOverrideRetrieveParams): ExperimentViewOverride = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: ExperimentViewOverrideRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ExperimentViewOverride + + /** + * Updates an existing experiment view override configuration by completely replacing the column + * overrides for the specified dataset and override ID. + * + * This endpoint performs a complete replacement of the column overrides configuration. All + * existing column overrides will be replaced with the new configuration provided in the request + * body. To add or modify individual columns, include the complete desired configuration in the + * request. + * + * The request format is identical to the create endpoint: + * - column_overrides: Required array with at least one override configuration + * - Each override can specify color gradients, precision, and visibility + * + * Example request body: { "column_overrides": + * [ { "column": "metrics.f1_score", "color_gradient": [[0.0, "#ff4444"], [0.8, "#44ff44"]], + * "precision": 4 }, { "column": "feedback.rating", "hide": false } ] } + * + * Both the dataset and override must exist and be accessible by the authenticated user. + */ + fun update(id: JsonValue, params: ExperimentViewOverrideUpdateParams): ExperimentViewOverride = + update(id, params, RequestOptions.none()) + + /** @see update */ + fun update( + id: JsonValue, + params: ExperimentViewOverrideUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ExperimentViewOverride = update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + fun update(params: ExperimentViewOverrideUpdateParams): ExperimentViewOverride = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: ExperimentViewOverrideUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ExperimentViewOverride + + /** + * Retrieves all experiment view override configurations for a specific dataset. This endpoint + * returns column display overrides including color gradients, precision settings, and column + * visibility configurations that customize how experiment results are displayed in the UI. + * + * The response includes all column overrides with their display settings: + * - Column identifiers (must start with inputs, outputs, reference_outputs, feedback, metrics, + * attachments, or metadata) + * - Color gradients for numeric data visualization + * - Precision settings for numeric columns (1-6 decimal places) + * - Hide flags to control column visibility + */ + fun list(datasetId: JsonValue): List<ExperimentViewOverride> = + list(datasetId, ExperimentViewOverrideListParams.none()) + + /** @see list */ + fun list( + datasetId: JsonValue, + params: ExperimentViewOverrideListParams = ExperimentViewOverrideListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List<ExperimentViewOverride> = + list(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see list */ + fun list( + datasetId: JsonValue, + params: ExperimentViewOverrideListParams = ExperimentViewOverrideListParams.none(), + ): List<ExperimentViewOverride> = list(datasetId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: ExperimentViewOverrideListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List<ExperimentViewOverride> + + /** @see list */ + fun list(params: ExperimentViewOverrideListParams): List<ExperimentViewOverride> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(datasetId: JsonValue, requestOptions: RequestOptions): List<ExperimentViewOverride> = + list(datasetId, ExperimentViewOverrideListParams.none(), requestOptions) + + /** + * Permanently deletes an experiment view override configuration for a dataset. This operation + * removes all column override settings including color gradients, precision configurations, and + * visibility settings. + * + * After deletion, the experiment view will revert to default column display settings. This + * action cannot be undone - you will need to recreate the override configuration if you want to + * restore custom column settings. + * + * Both the dataset and override must exist and be accessible by the authenticated user. The + * operation will fail if the override doesn't exist or if the user doesn't have appropriate + * permissions for the dataset. + */ + fun delete(id: JsonValue, params: ExperimentViewOverrideDeleteParams) = + delete(id, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + id: JsonValue, + params: ExperimentViewOverrideDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) = delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + fun delete(params: ExperimentViewOverrideDeleteParams) = delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ExperimentViewOverrideDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) + + /** + * A view of [ExperimentViewOverrideService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ExperimentViewOverrideService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /datasets/{dataset_id}/experiment-view-overrides`, + * but is otherwise the same as [ExperimentViewOverrideService.create]. + */ + @MustBeClosed + fun create( + datasetId: JsonValue, + params: ExperimentViewOverrideCreateParams, + ): HttpResponseFor<ExperimentViewOverride> = + create(datasetId, params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + datasetId: JsonValue, + params: ExperimentViewOverrideCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ExperimentViewOverride> = + create(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see create */ + @MustBeClosed + fun create( + params: ExperimentViewOverrideCreateParams + ): HttpResponseFor<ExperimentViewOverride> = create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: ExperimentViewOverrideCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ExperimentViewOverride> + + /** + * Returns a raw HTTP response for `get + * /datasets/{dataset_id}/experiment-view-overrides/{id}`, but is otherwise the same as + * [ExperimentViewOverrideService.retrieve]. + */ + @MustBeClosed + fun retrieve( + id: JsonValue, + params: ExperimentViewOverrideRetrieveParams, + ): HttpResponseFor<ExperimentViewOverride> = retrieve(id, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + id: JsonValue, + params: ExperimentViewOverrideRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ExperimentViewOverride> = + retrieve(params.toBuilder().id(id).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: ExperimentViewOverrideRetrieveParams + ): HttpResponseFor<ExperimentViewOverride> = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: ExperimentViewOverrideRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ExperimentViewOverride> + + /** + * Returns a raw HTTP response for `patch + * /datasets/{dataset_id}/experiment-view-overrides/{id}`, but is otherwise the same as + * [ExperimentViewOverrideService.update]. + */ + @MustBeClosed + fun update( + id: JsonValue, + params: ExperimentViewOverrideUpdateParams, + ): HttpResponseFor<ExperimentViewOverride> = update(id, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + id: JsonValue, + params: ExperimentViewOverrideUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ExperimentViewOverride> = + update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update( + params: ExperimentViewOverrideUpdateParams + ): HttpResponseFor<ExperimentViewOverride> = update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: ExperimentViewOverrideUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ExperimentViewOverride> + + /** + * Returns a raw HTTP response for `get /datasets/{dataset_id}/experiment-view-overrides`, + * but is otherwise the same as [ExperimentViewOverrideService.list]. + */ + @MustBeClosed + fun list(datasetId: JsonValue): HttpResponseFor<List<ExperimentViewOverride>> = + list(datasetId, ExperimentViewOverrideListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + datasetId: JsonValue, + params: ExperimentViewOverrideListParams = ExperimentViewOverrideListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<ExperimentViewOverride>> = + list(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see list */ + @MustBeClosed + fun list( + datasetId: JsonValue, + params: ExperimentViewOverrideListParams = ExperimentViewOverrideListParams.none(), + ): HttpResponseFor<List<ExperimentViewOverride>> = + list(datasetId, params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: ExperimentViewOverrideListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<List<ExperimentViewOverride>> + + /** @see list */ + @MustBeClosed + fun list( + params: ExperimentViewOverrideListParams + ): HttpResponseFor<List<ExperimentViewOverride>> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + datasetId: JsonValue, + requestOptions: RequestOptions, + ): HttpResponseFor<List<ExperimentViewOverride>> = + list(datasetId, ExperimentViewOverrideListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete + * /datasets/{dataset_id}/experiment-view-overrides/{id}`, but is otherwise the same as + * [ExperimentViewOverrideService.delete]. + */ + @MustBeClosed + fun delete(id: JsonValue, params: ExperimentViewOverrideDeleteParams): HttpResponse = + delete(id, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + id: JsonValue, + params: ExperimentViewOverrideDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete(params: ExperimentViewOverrideDeleteParams): HttpResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: ExperimentViewOverrideDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/datasets/ExperimentViewOverrideServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/datasets/ExperimentViewOverrideServiceImpl.kt new file mode 100644 index 00000000..030360af --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/datasets/ExperimentViewOverrideServiceImpl.kt @@ -0,0 +1,236 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.datasets + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.emptyHandler +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.datasets.experimentviewoverrides.ExperimentViewOverride +import com.langsmith_api.api.models.datasets.experimentviewoverrides.ExperimentViewOverrideCreateParams +import com.langsmith_api.api.models.datasets.experimentviewoverrides.ExperimentViewOverrideDeleteParams +import com.langsmith_api.api.models.datasets.experimentviewoverrides.ExperimentViewOverrideListParams +import com.langsmith_api.api.models.datasets.experimentviewoverrides.ExperimentViewOverrideRetrieveParams +import com.langsmith_api.api.models.datasets.experimentviewoverrides.ExperimentViewOverrideUpdateParams +import java.util.function.Consumer + +class ExperimentViewOverrideServiceImpl +internal constructor(private val clientOptions: ClientOptions) : ExperimentViewOverrideService { + + private val withRawResponse: ExperimentViewOverrideService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ExperimentViewOverrideService.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ExperimentViewOverrideService = + ExperimentViewOverrideServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: ExperimentViewOverrideCreateParams, + requestOptions: RequestOptions, + ): ExperimentViewOverride = + // post /datasets/{dataset_id}/experiment-view-overrides + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve( + params: ExperimentViewOverrideRetrieveParams, + requestOptions: RequestOptions, + ): ExperimentViewOverride = + // get /datasets/{dataset_id}/experiment-view-overrides/{id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update( + params: ExperimentViewOverrideUpdateParams, + requestOptions: RequestOptions, + ): ExperimentViewOverride = + // patch /datasets/{dataset_id}/experiment-view-overrides/{id} + withRawResponse().update(params, requestOptions).parse() + + override fun list( + params: ExperimentViewOverrideListParams, + requestOptions: RequestOptions, + ): List<ExperimentViewOverride> = + // get /datasets/{dataset_id}/experiment-view-overrides + withRawResponse().list(params, requestOptions).parse() + + override fun delete( + params: ExperimentViewOverrideDeleteParams, + requestOptions: RequestOptions, + ) { + // delete /datasets/{dataset_id}/experiment-view-overrides/{id} + withRawResponse().delete(params, requestOptions) + } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ExperimentViewOverrideService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ExperimentViewOverrideService.WithRawResponse = + ExperimentViewOverrideServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<ExperimentViewOverride> = + jsonHandler<ExperimentViewOverride>(clientOptions.jsonMapper) + + override fun create( + params: ExperimentViewOverrideCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<ExperimentViewOverride> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("datasets", params._pathParam(0), "experiment-view-overrides") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler<ExperimentViewOverride> = + jsonHandler<ExperimentViewOverride>(clientOptions.jsonMapper) + + override fun retrieve( + params: ExperimentViewOverrideRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor<ExperimentViewOverride> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "datasets", + params._pathParam(0), + "experiment-view-overrides", + params._pathParam(1), + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler<ExperimentViewOverride> = + jsonHandler<ExperimentViewOverride>(clientOptions.jsonMapper) + + override fun update( + params: ExperimentViewOverrideUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<ExperimentViewOverride> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "datasets", + params._pathParam(0), + "experiment-view-overrides", + params._pathParam(1), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler<List<ExperimentViewOverride>> = + jsonHandler<List<ExperimentViewOverride>>(clientOptions.jsonMapper) + + override fun list( + params: ExperimentViewOverrideListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<List<ExperimentViewOverride>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("datasets", params._pathParam(0), "experiment-view-overrides") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val deleteHandler: Handler<Void?> = emptyHandler() + + override fun delete( + params: ExperimentViewOverrideDeleteParams, + requestOptions: RequestOptions, + ): HttpResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "datasets", + params._pathParam(0), + "experiment-view-overrides", + params._pathParam(1), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { deleteHandler.handle(it) } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/AlertService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/AlertService.kt new file mode 100644 index 00000000..a756be5a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/AlertService.kt @@ -0,0 +1,335 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.platform + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.platform.alerts.AlertCreateParams +import com.langsmith_api.api.models.platform.alerts.AlertDeleteParams +import com.langsmith_api.api.models.platform.alerts.AlertDeleteResponse +import com.langsmith_api.api.models.platform.alerts.AlertRetrieveParams +import com.langsmith_api.api.models.platform.alerts.AlertRuleResponse +import com.langsmith_api.api.models.platform.alerts.AlertTestParams +import com.langsmith_api.api.models.platform.alerts.AlertTestResponse +import com.langsmith_api.api.models.platform.alerts.AlertUpdateParams +import com.langsmith_api.api.models.platform.alerts.AlertUpdateResponse +import java.util.function.Consumer + +interface AlertService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): AlertService + + /** + * Creates a new alert rule. The request body must be a JSON-encoded alert rule object that + * follows the CreateAlertRuleRequest schema. + */ + fun create(sessionId: JsonValue, params: AlertCreateParams): AlertRuleResponse = + create(sessionId, params, RequestOptions.none()) + + /** @see create */ + fun create( + sessionId: JsonValue, + params: AlertCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AlertRuleResponse = create(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see create */ + fun create(params: AlertCreateParams): AlertRuleResponse = create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: AlertCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AlertRuleResponse + + /** Gets an alert rule. */ + fun retrieve(alertRuleId: JsonValue, params: AlertRetrieveParams): AlertRuleResponse = + retrieve(alertRuleId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + alertRuleId: JsonValue, + params: AlertRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AlertRuleResponse = + retrieve(params.toBuilder().alertRuleId(alertRuleId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: AlertRetrieveParams): AlertRuleResponse = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: AlertRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AlertRuleResponse + + /** Updates an alert rule. */ + fun update(alertRuleId: JsonValue, params: AlertUpdateParams): AlertUpdateResponse = + update(alertRuleId, params, RequestOptions.none()) + + /** @see update */ + fun update( + alertRuleId: JsonValue, + params: AlertUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AlertUpdateResponse = + update(params.toBuilder().alertRuleId(alertRuleId).build(), requestOptions) + + /** @see update */ + fun update(params: AlertUpdateParams): AlertUpdateResponse = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: AlertUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AlertUpdateResponse + + /** Deletes an alert rule */ + fun delete(alertRuleId: JsonValue, params: AlertDeleteParams): AlertDeleteResponse = + delete(alertRuleId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + alertRuleId: JsonValue, + params: AlertDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AlertDeleteResponse = + delete(params.toBuilder().alertRuleId(alertRuleId).build(), requestOptions) + + /** @see delete */ + fun delete(params: AlertDeleteParams): AlertDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: AlertDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AlertDeleteResponse + + /** + * Tests an alert action which will fire a notification to all configured recipients if the + * configuration is valid. + */ + fun test(sessionId: JsonValue): AlertTestResponse = test(sessionId, AlertTestParams.none()) + + /** @see test */ + fun test( + sessionId: JsonValue, + params: AlertTestParams = AlertTestParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AlertTestResponse = test(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see test */ + fun test( + sessionId: JsonValue, + params: AlertTestParams = AlertTestParams.none(), + ): AlertTestResponse = test(sessionId, params, RequestOptions.none()) + + /** @see test */ + fun test( + params: AlertTestParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AlertTestResponse + + /** @see test */ + fun test(params: AlertTestParams): AlertTestResponse = test(params, RequestOptions.none()) + + /** @see test */ + fun test(sessionId: JsonValue, requestOptions: RequestOptions): AlertTestResponse = + test(sessionId, AlertTestParams.none(), requestOptions) + + /** A view of [AlertService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): AlertService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/platform/alerts/{session_id}`, but is otherwise + * the same as [AlertService.create]. + */ + @MustBeClosed + fun create( + sessionId: JsonValue, + params: AlertCreateParams, + ): HttpResponseFor<AlertRuleResponse> = create(sessionId, params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + sessionId: JsonValue, + params: AlertCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<AlertRuleResponse> = + create(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(params: AlertCreateParams): HttpResponseFor<AlertRuleResponse> = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: AlertCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<AlertRuleResponse> + + /** + * Returns a raw HTTP response for `get /v1/platform/alerts/{session_id}/{alert_rule_id}`, + * but is otherwise the same as [AlertService.retrieve]. + */ + @MustBeClosed + fun retrieve( + alertRuleId: JsonValue, + params: AlertRetrieveParams, + ): HttpResponseFor<AlertRuleResponse> = retrieve(alertRuleId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + alertRuleId: JsonValue, + params: AlertRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<AlertRuleResponse> = + retrieve(params.toBuilder().alertRuleId(alertRuleId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: AlertRetrieveParams): HttpResponseFor<AlertRuleResponse> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: AlertRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<AlertRuleResponse> + + /** + * Returns a raw HTTP response for `patch /v1/platform/alerts/{session_id}/{alert_rule_id}`, + * but is otherwise the same as [AlertService.update]. + */ + @MustBeClosed + fun update( + alertRuleId: JsonValue, + params: AlertUpdateParams, + ): HttpResponseFor<AlertUpdateResponse> = update(alertRuleId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + alertRuleId: JsonValue, + params: AlertUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<AlertUpdateResponse> = + update(params.toBuilder().alertRuleId(alertRuleId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(params: AlertUpdateParams): HttpResponseFor<AlertUpdateResponse> = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: AlertUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<AlertUpdateResponse> + + /** + * Returns a raw HTTP response for `delete + * /v1/platform/alerts/{session_id}/{alert_rule_id}`, but is otherwise the same as + * [AlertService.delete]. + */ + @MustBeClosed + fun delete( + alertRuleId: JsonValue, + params: AlertDeleteParams, + ): HttpResponseFor<AlertDeleteResponse> = delete(alertRuleId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + alertRuleId: JsonValue, + params: AlertDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<AlertDeleteResponse> = + delete(params.toBuilder().alertRuleId(alertRuleId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete(params: AlertDeleteParams): HttpResponseFor<AlertDeleteResponse> = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: AlertDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<AlertDeleteResponse> + + /** + * Returns a raw HTTP response for `post /v1/platform/alerts/{session_id}/test`, but is + * otherwise the same as [AlertService.test]. + */ + @MustBeClosed + fun test(sessionId: JsonValue): HttpResponseFor<AlertTestResponse> = + test(sessionId, AlertTestParams.none()) + + /** @see test */ + @MustBeClosed + fun test( + sessionId: JsonValue, + params: AlertTestParams = AlertTestParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<AlertTestResponse> = + test(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see test */ + @MustBeClosed + fun test( + sessionId: JsonValue, + params: AlertTestParams = AlertTestParams.none(), + ): HttpResponseFor<AlertTestResponse> = test(sessionId, params, RequestOptions.none()) + + /** @see test */ + @MustBeClosed + fun test( + params: AlertTestParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<AlertTestResponse> + + /** @see test */ + @MustBeClosed + fun test(params: AlertTestParams): HttpResponseFor<AlertTestResponse> = + test(params, RequestOptions.none()) + + /** @see test */ + @MustBeClosed + fun test( + sessionId: JsonValue, + requestOptions: RequestOptions, + ): HttpResponseFor<AlertTestResponse> = + test(sessionId, AlertTestParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/AlertServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/AlertServiceImpl.kt new file mode 100644 index 00000000..f850326a --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/AlertServiceImpl.kt @@ -0,0 +1,243 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.platform + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.platform.alerts.AlertCreateParams +import com.langsmith_api.api.models.platform.alerts.AlertDeleteParams +import com.langsmith_api.api.models.platform.alerts.AlertDeleteResponse +import com.langsmith_api.api.models.platform.alerts.AlertRetrieveParams +import com.langsmith_api.api.models.platform.alerts.AlertRuleResponse +import com.langsmith_api.api.models.platform.alerts.AlertTestParams +import com.langsmith_api.api.models.platform.alerts.AlertTestResponse +import com.langsmith_api.api.models.platform.alerts.AlertUpdateParams +import com.langsmith_api.api.models.platform.alerts.AlertUpdateResponse +import java.util.function.Consumer + +class AlertServiceImpl internal constructor(private val clientOptions: ClientOptions) : + AlertService { + + private val withRawResponse: AlertService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): AlertService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): AlertService = + AlertServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: AlertCreateParams, + requestOptions: RequestOptions, + ): AlertRuleResponse = + // post /v1/platform/alerts/{session_id} + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve( + params: AlertRetrieveParams, + requestOptions: RequestOptions, + ): AlertRuleResponse = + // get /v1/platform/alerts/{session_id}/{alert_rule_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update( + params: AlertUpdateParams, + requestOptions: RequestOptions, + ): AlertUpdateResponse = + // patch /v1/platform/alerts/{session_id}/{alert_rule_id} + withRawResponse().update(params, requestOptions).parse() + + override fun delete( + params: AlertDeleteParams, + requestOptions: RequestOptions, + ): AlertDeleteResponse = + // delete /v1/platform/alerts/{session_id}/{alert_rule_id} + withRawResponse().delete(params, requestOptions).parse() + + override fun test(params: AlertTestParams, requestOptions: RequestOptions): AlertTestResponse = + // post /v1/platform/alerts/{session_id}/test + withRawResponse().test(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AlertService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): AlertService.WithRawResponse = + AlertServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler<AlertRuleResponse> = + jsonHandler<AlertRuleResponse>(clientOptions.jsonMapper) + + override fun create( + params: AlertCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<AlertRuleResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "platform", "alerts", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler<AlertRuleResponse> = + jsonHandler<AlertRuleResponse>(clientOptions.jsonMapper) + + override fun retrieve( + params: AlertRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor<AlertRuleResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "v1", + "platform", + "alerts", + params._pathParam(0), + params._pathParam(1), + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler<AlertUpdateResponse> = + jsonHandler<AlertUpdateResponse>(clientOptions.jsonMapper) + + override fun update( + params: AlertUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<AlertUpdateResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "v1", + "platform", + "alerts", + params._pathParam(0), + params._pathParam(1), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val deleteHandler: Handler<AlertDeleteResponse> = + jsonHandler<AlertDeleteResponse>(clientOptions.jsonMapper) + + override fun delete( + params: AlertDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<AlertDeleteResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "v1", + "platform", + "alerts", + params._pathParam(0), + params._pathParam(1), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val testHandler: Handler<AlertTestResponse> = + jsonHandler<AlertTestResponse>(clientOptions.jsonMapper) + + override fun test( + params: AlertTestParams, + requestOptions: RequestOptions, + ): HttpResponseFor<AlertTestResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "platform", "alerts", params._pathParam(0), "test") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { testHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/DatasetService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/DatasetService.kt new file mode 100644 index 00000000..7decb166 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/DatasetService.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.platform + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.services.blocking.platform.datasets.ExampleService +import java.util.function.Consumer + +interface DatasetService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): DatasetService + + fun examples(): ExampleService + + /** A view of [DatasetService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): DatasetService.WithRawResponse + + fun examples(): ExampleService.WithRawResponse + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/DatasetServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/DatasetServiceImpl.kt new file mode 100644 index 00000000..9dd41ad5 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/DatasetServiceImpl.kt @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.platform + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.services.blocking.platform.datasets.ExampleService +import com.langsmith_api.api.services.blocking.platform.datasets.ExampleServiceImpl +import java.util.function.Consumer + +class DatasetServiceImpl internal constructor(private val clientOptions: ClientOptions) : + DatasetService { + + private val withRawResponse: DatasetService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val examples: ExampleService by lazy { ExampleServiceImpl(clientOptions) } + + override fun withRawResponse(): DatasetService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): DatasetService = + DatasetServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun examples(): ExampleService = examples + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + DatasetService.WithRawResponse { + + private val examples: ExampleService.WithRawResponse by lazy { + ExampleServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): DatasetService.WithRawResponse = + DatasetServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun examples(): ExampleService.WithRawResponse = examples + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/OrgService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/OrgService.kt new file mode 100644 index 00000000..f6132db5 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/OrgService.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.platform + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.services.blocking.platform.orgs.CurrentService +import java.util.function.Consumer + +interface OrgService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): OrgService + + fun current(): CurrentService + + /** A view of [OrgService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): OrgService.WithRawResponse + + fun current(): CurrentService.WithRawResponse + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/OrgServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/OrgServiceImpl.kt new file mode 100644 index 00000000..52b254f0 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/OrgServiceImpl.kt @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.platform + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.services.blocking.platform.orgs.CurrentService +import com.langsmith_api.api.services.blocking.platform.orgs.CurrentServiceImpl +import java.util.function.Consumer + +class OrgServiceImpl internal constructor(private val clientOptions: ClientOptions) : OrgService { + + private val withRawResponse: OrgService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val current: CurrentService by lazy { CurrentServiceImpl(clientOptions) } + + override fun withRawResponse(): OrgService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): OrgService = + OrgServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun current(): CurrentService = current + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + OrgService.WithRawResponse { + + private val current: CurrentService.WithRawResponse by lazy { + CurrentServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): OrgService.WithRawResponse = + OrgServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun current(): CurrentService.WithRawResponse = current + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/datasets/ExampleService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/datasets/ExampleService.kt new file mode 100644 index 00000000..6fea64a4 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/datasets/ExampleService.kt @@ -0,0 +1,187 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.platform.datasets + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.platform.datasets.examples.ExampleHardDeleteParams +import com.langsmith_api.api.models.platform.datasets.examples.ExampleHardDeleteResponse +import com.langsmith_api.api.models.platform.datasets.examples.ExampleUpdateParams +import com.langsmith_api.api.models.platform.datasets.examples.ExampleUpdateResponse +import com.langsmith_api.api.models.platform.datasets.examples.ExampleUploadParams +import com.langsmith_api.api.models.platform.datasets.examples.ExampleUploadResponse +import java.util.function.Consumer + +interface ExampleService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ExampleService + + /** + * This endpoint allows clients to update existing examples in a specified dataset by sending a + * multipart/form-data PATCH request. Each form part contains either JSON-encoded data or binary + * attachment files to update an example. + */ + fun update(datasetId: JsonValue, params: ExampleUpdateParams): ExampleUpdateResponse = + update(datasetId, params, RequestOptions.none()) + + /** @see update */ + fun update( + datasetId: JsonValue, + params: ExampleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ExampleUpdateResponse = + update(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see update */ + fun update(params: ExampleUpdateParams): ExampleUpdateResponse = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: ExampleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ExampleUpdateResponse + + /** + * This endpoint hard deletes *all* versions of a dataset example(s). Deletion is performed by + * setting inputs, outputs, and metadata to null and deleting attachment files while keeping the + * example ID, dataset ID, and creation timestamp. IMPORTANT: attachment files can take up to 7 + * days to be deleted. inputs, outputs and metadata are nullified immediately. + */ + fun hardDelete(params: ExampleHardDeleteParams): ExampleHardDeleteResponse = + hardDelete(params, RequestOptions.none()) + + /** @see hardDelete */ + fun hardDelete( + params: ExampleHardDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ExampleHardDeleteResponse + + /** + * This endpoint allows clients to upload examples to a specified dataset by sending a + * multipart/form-data POST request. Each form part contains either JSON-encoded data or binary + * attachment files associated with an example. + */ + fun upload(datasetId: JsonValue, params: ExampleUploadParams): ExampleUploadResponse = + upload(datasetId, params, RequestOptions.none()) + + /** @see upload */ + fun upload( + datasetId: JsonValue, + params: ExampleUploadParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ExampleUploadResponse = + upload(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see upload */ + fun upload(params: ExampleUploadParams): ExampleUploadResponse = + upload(params, RequestOptions.none()) + + /** @see upload */ + fun upload( + params: ExampleUploadParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ExampleUploadResponse + + /** A view of [ExampleService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): ExampleService.WithRawResponse + + /** + * Returns a raw HTTP response for `patch /v1/platform/datasets/{dataset_id}/examples`, but + * is otherwise the same as [ExampleService.update]. + */ + @MustBeClosed + fun update( + datasetId: JsonValue, + params: ExampleUpdateParams, + ): HttpResponseFor<ExampleUpdateResponse> = update(datasetId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + datasetId: JsonValue, + params: ExampleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ExampleUpdateResponse> = + update(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(params: ExampleUpdateParams): HttpResponseFor<ExampleUpdateResponse> = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: ExampleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ExampleUpdateResponse> + + /** + * Returns a raw HTTP response for `post /v1/platform/datasets/examples/delete`, but is + * otherwise the same as [ExampleService.hardDelete]. + */ + @MustBeClosed + fun hardDelete( + params: ExampleHardDeleteParams + ): HttpResponseFor<ExampleHardDeleteResponse> = hardDelete(params, RequestOptions.none()) + + /** @see hardDelete */ + @MustBeClosed + fun hardDelete( + params: ExampleHardDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ExampleHardDeleteResponse> + + /** + * Returns a raw HTTP response for `post /v1/platform/datasets/{dataset_id}/examples`, but + * is otherwise the same as [ExampleService.upload]. + */ + @MustBeClosed + fun upload( + datasetId: JsonValue, + params: ExampleUploadParams, + ): HttpResponseFor<ExampleUploadResponse> = upload(datasetId, params, RequestOptions.none()) + + /** @see upload */ + @MustBeClosed + fun upload( + datasetId: JsonValue, + params: ExampleUploadParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ExampleUploadResponse> = + upload(params.toBuilder().datasetId(datasetId).build(), requestOptions) + + /** @see upload */ + @MustBeClosed + fun upload(params: ExampleUploadParams): HttpResponseFor<ExampleUploadResponse> = + upload(params, RequestOptions.none()) + + /** @see upload */ + @MustBeClosed + fun upload( + params: ExampleUploadParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<ExampleUploadResponse> + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/datasets/ExampleServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/datasets/ExampleServiceImpl.kt new file mode 100644 index 00000000..c1dd8487 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/datasets/ExampleServiceImpl.kt @@ -0,0 +1,157 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.platform.datasets + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.multipartFormData +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.platform.datasets.examples.ExampleHardDeleteParams +import com.langsmith_api.api.models.platform.datasets.examples.ExampleHardDeleteResponse +import com.langsmith_api.api.models.platform.datasets.examples.ExampleUpdateParams +import com.langsmith_api.api.models.platform.datasets.examples.ExampleUpdateResponse +import com.langsmith_api.api.models.platform.datasets.examples.ExampleUploadParams +import com.langsmith_api.api.models.platform.datasets.examples.ExampleUploadResponse +import java.util.function.Consumer + +class ExampleServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ExampleService { + + private val withRawResponse: ExampleService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ExampleService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): ExampleService = + ExampleServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun update( + params: ExampleUpdateParams, + requestOptions: RequestOptions, + ): ExampleUpdateResponse = + // patch /v1/platform/datasets/{dataset_id}/examples + withRawResponse().update(params, requestOptions).parse() + + override fun hardDelete( + params: ExampleHardDeleteParams, + requestOptions: RequestOptions, + ): ExampleHardDeleteResponse = + // post /v1/platform/datasets/examples/delete + withRawResponse().hardDelete(params, requestOptions).parse() + + override fun upload( + params: ExampleUploadParams, + requestOptions: RequestOptions, + ): ExampleUploadResponse = + // post /v1/platform/datasets/{dataset_id}/examples + withRawResponse().upload(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ExampleService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): ExampleService.WithRawResponse = + ExampleServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val updateHandler: Handler<ExampleUpdateResponse> = + jsonHandler<ExampleUpdateResponse>(clientOptions.jsonMapper) + + override fun update( + params: ExampleUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<ExampleUpdateResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "platform", "datasets", params._pathParam(0), "examples") + .body(multipartFormData(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val hardDeleteHandler: Handler<ExampleHardDeleteResponse> = + jsonHandler<ExampleHardDeleteResponse>(clientOptions.jsonMapper) + + override fun hardDelete( + params: ExampleHardDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor<ExampleHardDeleteResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "platform", "datasets", "examples", "delete") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { hardDeleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val uploadHandler: Handler<ExampleUploadResponse> = + jsonHandler<ExampleUploadResponse>(clientOptions.jsonMapper) + + override fun upload( + params: ExampleUploadParams, + requestOptions: RequestOptions, + ): HttpResponseFor<ExampleUploadResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "platform", "datasets", params._pathParam(0), "examples") + .body(multipartFormData(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { uploadHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/orgs/CurrentService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/orgs/CurrentService.kt new file mode 100644 index 00000000..29050b6d --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/orgs/CurrentService.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.platform.orgs + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.services.blocking.platform.orgs.current.AccessPolicyService +import java.util.function.Consumer + +interface CurrentService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): CurrentService + + fun accessPolicies(): AccessPolicyService + + /** A view of [CurrentService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): CurrentService.WithRawResponse + + fun accessPolicies(): AccessPolicyService.WithRawResponse + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/orgs/CurrentServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/orgs/CurrentServiceImpl.kt new file mode 100644 index 00000000..62fde636 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/orgs/CurrentServiceImpl.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.platform.orgs + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.services.blocking.platform.orgs.current.AccessPolicyService +import com.langsmith_api.api.services.blocking.platform.orgs.current.AccessPolicyServiceImpl +import java.util.function.Consumer + +class CurrentServiceImpl internal constructor(private val clientOptions: ClientOptions) : + CurrentService { + + private val withRawResponse: CurrentService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val accessPolicies: AccessPolicyService by lazy { + AccessPolicyServiceImpl(clientOptions) + } + + override fun withRawResponse(): CurrentService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): CurrentService = + CurrentServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun accessPolicies(): AccessPolicyService = accessPolicies + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CurrentService.WithRawResponse { + + private val accessPolicies: AccessPolicyService.WithRawResponse by lazy { + AccessPolicyServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): CurrentService.WithRawResponse = + CurrentServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun accessPolicies(): AccessPolicyService.WithRawResponse = accessPolicies + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/orgs/current/AccessPolicyService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/orgs/current/AccessPolicyService.kt new file mode 100644 index 00000000..a529b1c9 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/orgs/current/AccessPolicyService.kt @@ -0,0 +1,291 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.platform.orgs.current + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.models.platform.orgs.current.accesspolicies.AccessPolicy +import com.langsmith_api.api.models.platform.orgs.current.accesspolicies.AccessPolicyCreateParams +import com.langsmith_api.api.models.platform.orgs.current.accesspolicies.AccessPolicyCreateResponse +import com.langsmith_api.api.models.platform.orgs.current.accesspolicies.AccessPolicyDeleteParams +import com.langsmith_api.api.models.platform.orgs.current.accesspolicies.AccessPolicyListParams +import com.langsmith_api.api.models.platform.orgs.current.accesspolicies.AccessPolicyListResponse +import com.langsmith_api.api.models.platform.orgs.current.accesspolicies.AccessPolicyRetrieveParams +import com.langsmith_api.api.services.blocking.platform.orgs.current.accesspolicies.RoleService +import java.util.function.Consumer + +interface AccessPolicyService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): AccessPolicyService + + fun roles(): RoleService + + /** + * Creates a new access policy. The request body must be a JSON-encoded access policy object + * that follows the CreateAccessPolicyRequest schema. + */ + fun create(): AccessPolicyCreateResponse = create(AccessPolicyCreateParams.none()) + + /** @see create */ + fun create( + params: AccessPolicyCreateParams = AccessPolicyCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AccessPolicyCreateResponse + + /** @see create */ + fun create( + params: AccessPolicyCreateParams = AccessPolicyCreateParams.none() + ): AccessPolicyCreateResponse = create(params, RequestOptions.none()) + + /** @see create */ + fun create(requestOptions: RequestOptions): AccessPolicyCreateResponse = + create(AccessPolicyCreateParams.none(), requestOptions) + + /** Gets a specific access policy by ID. */ + fun retrieve(accessPolicyId: JsonValue): AccessPolicy = + retrieve(accessPolicyId, AccessPolicyRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + accessPolicyId: JsonValue, + params: AccessPolicyRetrieveParams = AccessPolicyRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AccessPolicy = + retrieve(params.toBuilder().accessPolicyId(accessPolicyId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + accessPolicyId: JsonValue, + params: AccessPolicyRetrieveParams = AccessPolicyRetrieveParams.none(), + ): AccessPolicy = retrieve(accessPolicyId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: AccessPolicyRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AccessPolicy + + /** @see retrieve */ + fun retrieve(params: AccessPolicyRetrieveParams): AccessPolicy = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(accessPolicyId: JsonValue, requestOptions: RequestOptions): AccessPolicy = + retrieve(accessPolicyId, AccessPolicyRetrieveParams.none(), requestOptions) + + /** Lists all access policies for the organization. */ + fun list(): AccessPolicyListResponse = list(AccessPolicyListParams.none()) + + /** @see list */ + fun list( + params: AccessPolicyListParams = AccessPolicyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AccessPolicyListResponse + + /** @see list */ + fun list( + params: AccessPolicyListParams = AccessPolicyListParams.none() + ): AccessPolicyListResponse = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): AccessPolicyListResponse = + list(AccessPolicyListParams.none(), requestOptions) + + /** Deletes a specific access policy by ID. */ + fun delete(accessPolicyId: JsonValue) = delete(accessPolicyId, AccessPolicyDeleteParams.none()) + + /** @see delete */ + fun delete( + accessPolicyId: JsonValue, + params: AccessPolicyDeleteParams = AccessPolicyDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ) = delete(params.toBuilder().accessPolicyId(accessPolicyId).build(), requestOptions) + + /** @see delete */ + fun delete( + accessPolicyId: JsonValue, + params: AccessPolicyDeleteParams = AccessPolicyDeleteParams.none(), + ) = delete(accessPolicyId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: AccessPolicyDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) + + /** @see delete */ + fun delete(params: AccessPolicyDeleteParams) = delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(accessPolicyId: JsonValue, requestOptions: RequestOptions) = + delete(accessPolicyId, AccessPolicyDeleteParams.none(), requestOptions) + + /** + * A view of [AccessPolicyService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): AccessPolicyService.WithRawResponse + + fun roles(): RoleService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/platform/orgs/current/access-policies`, but is + * otherwise the same as [AccessPolicyService.create]. + */ + @MustBeClosed + fun create(): HttpResponseFor<AccessPolicyCreateResponse> = + create(AccessPolicyCreateParams.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: AccessPolicyCreateParams = AccessPolicyCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<AccessPolicyCreateResponse> + + /** @see create */ + @MustBeClosed + fun create( + params: AccessPolicyCreateParams = AccessPolicyCreateParams.none() + ): HttpResponseFor<AccessPolicyCreateResponse> = create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create(requestOptions: RequestOptions): HttpResponseFor<AccessPolicyCreateResponse> = + create(AccessPolicyCreateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get + * /v1/platform/orgs/current/access-policies/{access_policy_id}`, but is otherwise the same + * as [AccessPolicyService.retrieve]. + */ + @MustBeClosed + fun retrieve(accessPolicyId: JsonValue): HttpResponseFor<AccessPolicy> = + retrieve(accessPolicyId, AccessPolicyRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + accessPolicyId: JsonValue, + params: AccessPolicyRetrieveParams = AccessPolicyRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<AccessPolicy> = + retrieve(params.toBuilder().accessPolicyId(accessPolicyId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + accessPolicyId: JsonValue, + params: AccessPolicyRetrieveParams = AccessPolicyRetrieveParams.none(), + ): HttpResponseFor<AccessPolicy> = retrieve(accessPolicyId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: AccessPolicyRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<AccessPolicy> + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: AccessPolicyRetrieveParams): HttpResponseFor<AccessPolicy> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + accessPolicyId: JsonValue, + requestOptions: RequestOptions, + ): HttpResponseFor<AccessPolicy> = + retrieve(accessPolicyId, AccessPolicyRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /v1/platform/orgs/current/access-policies`, but is + * otherwise the same as [AccessPolicyService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor<AccessPolicyListResponse> = list(AccessPolicyListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: AccessPolicyListParams = AccessPolicyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor<AccessPolicyListResponse> + + /** @see list */ + @MustBeClosed + fun list( + params: AccessPolicyListParams = AccessPolicyListParams.none() + ): HttpResponseFor<AccessPolicyListResponse> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor<AccessPolicyListResponse> = + list(AccessPolicyListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete + * /v1/platform/orgs/current/access-policies/{access_policy_id}`, but is otherwise the same + * as [AccessPolicyService.delete]. + */ + @MustBeClosed + fun delete(accessPolicyId: JsonValue): HttpResponse = + delete(accessPolicyId, AccessPolicyDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + accessPolicyId: JsonValue, + params: AccessPolicyDeleteParams = AccessPolicyDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = + delete(params.toBuilder().accessPolicyId(accessPolicyId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + accessPolicyId: JsonValue, + params: AccessPolicyDeleteParams = AccessPolicyDeleteParams.none(), + ): HttpResponse = delete(accessPolicyId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: AccessPolicyDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** @see delete */ + @MustBeClosed + fun delete(params: AccessPolicyDeleteParams): HttpResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete(accessPolicyId: JsonValue, requestOptions: RequestOptions): HttpResponse = + delete(accessPolicyId, AccessPolicyDeleteParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/orgs/current/AccessPolicyServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/orgs/current/AccessPolicyServiceImpl.kt new file mode 100644 index 00000000..497f7839 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/orgs/current/AccessPolicyServiceImpl.kt @@ -0,0 +1,208 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.platform.orgs.current + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.emptyHandler +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.handlers.jsonHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.HttpResponseFor +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.platform.orgs.current.accesspolicies.AccessPolicy +import com.langsmith_api.api.models.platform.orgs.current.accesspolicies.AccessPolicyCreateParams +import com.langsmith_api.api.models.platform.orgs.current.accesspolicies.AccessPolicyCreateResponse +import com.langsmith_api.api.models.platform.orgs.current.accesspolicies.AccessPolicyDeleteParams +import com.langsmith_api.api.models.platform.orgs.current.accesspolicies.AccessPolicyListParams +import com.langsmith_api.api.models.platform.orgs.current.accesspolicies.AccessPolicyListResponse +import com.langsmith_api.api.models.platform.orgs.current.accesspolicies.AccessPolicyRetrieveParams +import com.langsmith_api.api.services.blocking.platform.orgs.current.accesspolicies.RoleService +import com.langsmith_api.api.services.blocking.platform.orgs.current.accesspolicies.RoleServiceImpl +import java.util.function.Consumer + +class AccessPolicyServiceImpl internal constructor(private val clientOptions: ClientOptions) : + AccessPolicyService { + + private val withRawResponse: AccessPolicyService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val roles: RoleService by lazy { RoleServiceImpl(clientOptions) } + + override fun withRawResponse(): AccessPolicyService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): AccessPolicyService = + AccessPolicyServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun roles(): RoleService = roles + + override fun create( + params: AccessPolicyCreateParams, + requestOptions: RequestOptions, + ): AccessPolicyCreateResponse = + // post /v1/platform/orgs/current/access-policies + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve( + params: AccessPolicyRetrieveParams, + requestOptions: RequestOptions, + ): AccessPolicy = + // get /v1/platform/orgs/current/access-policies/{access_policy_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun list( + params: AccessPolicyListParams, + requestOptions: RequestOptions, + ): AccessPolicyListResponse = + // get /v1/platform/orgs/current/access-policies + withRawResponse().list(params, requestOptions).parse() + + override fun delete(params: AccessPolicyDeleteParams, requestOptions: RequestOptions) { + // delete /v1/platform/orgs/current/access-policies/{access_policy_id} + withRawResponse().delete(params, requestOptions) + } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AccessPolicyService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val roles: RoleService.WithRawResponse by lazy { + RoleServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): AccessPolicyService.WithRawResponse = + AccessPolicyServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun roles(): RoleService.WithRawResponse = roles + + private val createHandler: Handler<AccessPolicyCreateResponse> = + jsonHandler<AccessPolicyCreateResponse>(clientOptions.jsonMapper) + + override fun create( + params: AccessPolicyCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor<AccessPolicyCreateResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "platform", "orgs", "current", "access-policies") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler<AccessPolicy> = + jsonHandler<AccessPolicy>(clientOptions.jsonMapper) + + override fun retrieve( + params: AccessPolicyRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor<AccessPolicy> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "v1", + "platform", + "orgs", + "current", + "access-policies", + params._pathParam(0), + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler<AccessPolicyListResponse> = + jsonHandler<AccessPolicyListResponse>(clientOptions.jsonMapper) + + override fun list( + params: AccessPolicyListParams, + requestOptions: RequestOptions, + ): HttpResponseFor<AccessPolicyListResponse> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "platform", "orgs", "current", "access-policies") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val deleteHandler: Handler<Void?> = emptyHandler() + + override fun delete( + params: AccessPolicyDeleteParams, + requestOptions: RequestOptions, + ): HttpResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "v1", + "platform", + "orgs", + "current", + "access-policies", + params._pathParam(0), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { deleteHandler.handle(it) } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/orgs/current/accesspolicies/RoleService.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/orgs/current/accesspolicies/RoleService.kt new file mode 100644 index 00000000..18838ee5 --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/orgs/current/accesspolicies/RoleService.kt @@ -0,0 +1,103 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.platform.orgs.current.accesspolicies + +import com.google.errorprone.annotations.MustBeClosed +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.models.platform.orgs.current.accesspolicies.roles.RoleAttachParams +import java.util.function.Consumer + +interface RoleService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RoleService + + /** + * Attaches one or more access policies to a specific role. The request body must contain an + * array of access policy IDs. + */ + fun attach(roleId: JsonValue) = attach(roleId, RoleAttachParams.none()) + + /** @see attach */ + fun attach( + roleId: JsonValue, + params: RoleAttachParams = RoleAttachParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ) = attach(params.toBuilder().roleId(roleId).build(), requestOptions) + + /** @see attach */ + fun attach(roleId: JsonValue, params: RoleAttachParams = RoleAttachParams.none()) = + attach(roleId, params, RequestOptions.none()) + + /** @see attach */ + fun attach(params: RoleAttachParams, requestOptions: RequestOptions = RequestOptions.none()) + + /** @see attach */ + fun attach(params: RoleAttachParams) = attach(params, RequestOptions.none()) + + /** @see attach */ + fun attach(roleId: JsonValue, requestOptions: RequestOptions) = + attach(roleId, RoleAttachParams.none(), requestOptions) + + /** A view of [RoleService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer<ClientOptions.Builder>): RoleService.WithRawResponse + + /** + * Returns a raw HTTP response for `post + * /v1/platform/orgs/current/access-policies/roles/{role_id}/access-policies`, but is + * otherwise the same as [RoleService.attach]. + */ + @MustBeClosed + fun attach(roleId: JsonValue): HttpResponse = attach(roleId, RoleAttachParams.none()) + + /** @see attach */ + @MustBeClosed + fun attach( + roleId: JsonValue, + params: RoleAttachParams = RoleAttachParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = attach(params.toBuilder().roleId(roleId).build(), requestOptions) + + /** @see attach */ + @MustBeClosed + fun attach( + roleId: JsonValue, + params: RoleAttachParams = RoleAttachParams.none(), + ): HttpResponse = attach(roleId, params, RequestOptions.none()) + + /** @see attach */ + @MustBeClosed + fun attach( + params: RoleAttachParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** @see attach */ + @MustBeClosed + fun attach(params: RoleAttachParams): HttpResponse = attach(params, RequestOptions.none()) + + /** @see attach */ + @MustBeClosed + fun attach(roleId: JsonValue, requestOptions: RequestOptions): HttpResponse = + attach(roleId, RoleAttachParams.none(), requestOptions) + } +} diff --git a/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/orgs/current/accesspolicies/RoleServiceImpl.kt b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/orgs/current/accesspolicies/RoleServiceImpl.kt new file mode 100644 index 00000000..49ccbacf --- /dev/null +++ b/langsmith-api-java-core/src/main/kotlin/com/langsmith_api/api/services/blocking/platform/orgs/current/accesspolicies/RoleServiceImpl.kt @@ -0,0 +1,79 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.platform.orgs.current.accesspolicies + +import com.langsmith_api.api.core.ClientOptions +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.handlers.emptyHandler +import com.langsmith_api.api.core.handlers.errorBodyHandler +import com.langsmith_api.api.core.handlers.errorHandler +import com.langsmith_api.api.core.http.HttpMethod +import com.langsmith_api.api.core.http.HttpRequest +import com.langsmith_api.api.core.http.HttpResponse +import com.langsmith_api.api.core.http.HttpResponse.Handler +import com.langsmith_api.api.core.http.json +import com.langsmith_api.api.core.http.parseable +import com.langsmith_api.api.core.prepare +import com.langsmith_api.api.models.platform.orgs.current.accesspolicies.roles.RoleAttachParams +import java.util.function.Consumer + +class RoleServiceImpl internal constructor(private val clientOptions: ClientOptions) : RoleService { + + private val withRawResponse: RoleService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): RoleService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer<ClientOptions.Builder>): RoleService = + RoleServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun attach(params: RoleAttachParams, requestOptions: RequestOptions) { + // post /v1/platform/orgs/current/access-policies/roles/{role_id}/access-policies + withRawResponse().attach(params, requestOptions) + } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RoleService.WithRawResponse { + + private val errorHandler: Handler<HttpResponse> = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer<ClientOptions.Builder> + ): RoleService.WithRawResponse = + RoleServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val attachHandler: Handler<Void?> = emptyHandler() + + override fun attach( + params: RoleAttachParams, + requestOptions: RequestOptions, + ): HttpResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "v1", + "platform", + "orgs", + "current", + "access-policies", + "roles", + params._pathParam(0), + "access-policies", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { attachHandler.handle(it) } + } + } + } +} diff --git a/langsmith-api-java-core/src/main/resources/META-INF/proguard/langsmith-api-java-core.pro b/langsmith-api-java-core/src/main/resources/META-INF/proguard/langsmith-api-java-core.pro new file mode 100644 index 00000000..5f1763a6 --- /dev/null +++ b/langsmith-api-java-core/src/main/resources/META-INF/proguard/langsmith-api-java-core.pro @@ -0,0 +1,32 @@ +# Jackson uses reflection and depends heavily on runtime attributes. +-keepattributes Exceptions,InnerClasses,Signature,Deprecated,*Annotation* + +# Jackson uses Kotlin reflection utilities, which themselves use reflection to access things. +-keep class kotlin.reflect.** { *; } +-keep class kotlin.Metadata { *; } + +# Jackson uses reflection to access enum members (e.g. via `java.lang.Class.getEnumConstants()`). +-keepclassmembers class com.fasterxml.jackson.** extends java.lang.Enum { + <fields>; + public static **[] values(); + public static ** valueOf(java.lang.String); +} + +# Jackson uses reflection to access annotation members. +-keepclassmembers @interface com.fasterxml.jackson.annotation.** { + *; +} + +# Jackson uses reified type information to serialize and deserialize our classes (via `TypeReference`). +-keep class com.fasterxml.jackson.core.type.TypeReference { *; } +-keep class * extends com.fasterxml.jackson.core.type.TypeReference { *; } + +# Jackson uses reflection to access our class serializers and deserializers. +-keep @com.fasterxml.jackson.databind.annotation.JsonSerialize class com.langsmith_api.api.** { *; } +-keep @com.fasterxml.jackson.databind.annotation.JsonDeserialize class com.langsmith_api.api.** { *; } + +# Jackson uses reflection to serialize and deserialize our classes based on their constructors and annotated members. +-keepclassmembers class com.langsmith_api.api.** { + <init>(...); + @com.fasterxml.jackson.annotation.* *; +} \ No newline at end of file diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/TestServerExtension.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/TestServerExtension.kt new file mode 100644 index 00000000..a0371d42 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/TestServerExtension.kt @@ -0,0 +1,62 @@ +package com.langsmith_api.api + +import java.lang.RuntimeException +import java.net.URL +import org.junit.jupiter.api.extension.BeforeAllCallback +import org.junit.jupiter.api.extension.ConditionEvaluationResult +import org.junit.jupiter.api.extension.ExecutionCondition +import org.junit.jupiter.api.extension.ExtensionContext + +class TestServerExtension : BeforeAllCallback, ExecutionCondition { + + override fun beforeAll(context: ExtensionContext?) { + try { + URL(BASE_URL).openConnection().connect() + } catch (e: Exception) { + throw RuntimeException( + """ + The test suite will not run without a mock Prism server running against your OpenAPI spec. + + You can set the environment variable `SKIP_MOCK_TESTS` to `true` to skip running any tests + that require the mock server. + + To fix: + + 1. Install Prism (requires Node 16+): + + With npm: + $ npm install -g @stoplight/prism-cli + + With yarn: + $ yarn global add @stoplight/prism-cli + + 2. Run the mock server + + To run the server, pass in the path of your OpenAPI spec to the prism command: + $ prism mock path/to/your.openapi.yml + """ + .trimIndent(), + e, + ) + } + } + + override fun evaluateExecutionCondition(context: ExtensionContext): ConditionEvaluationResult { + return if (System.getenv(SKIP_TESTS_ENV).toBoolean()) { + ConditionEvaluationResult.disabled( + "Environment variable $SKIP_TESTS_ENV is set to true" + ) + } else { + ConditionEvaluationResult.enabled( + "Environment variable $SKIP_TESTS_ENV is not set to true" + ) + } + } + + companion object { + + val BASE_URL = System.getenv("TEST_API_BASE_URL") ?: "http://localhost:4010" + + const val SKIP_TESTS_ENV: String = "SKIP_MOCK_TESTS" + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/core/ClientOptionsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/core/ClientOptionsTest.kt new file mode 100644 index 00000000..81f64031 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/core/ClientOptionsTest.kt @@ -0,0 +1,39 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.core + +import com.langsmith_api.api.core.http.HttpClient +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.mockito.junit.jupiter.MockitoExtension +import org.mockito.kotlin.mock +import org.mockito.kotlin.never +import org.mockito.kotlin.verify + +@ExtendWith(MockitoExtension::class) +internal class ClientOptionsTest { + + private val httpClient = mock<HttpClient>() + + @Test + fun toBuilder_whenOriginalClientOptionsGarbageCollected_doesNotCloseOriginalClient() { + var clientOptions = + ClientOptions.builder() + .httpClient(httpClient) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + verify(httpClient, never()).close() + + // Overwrite the `clientOptions` variable so that the original `ClientOptions` is GC'd. + clientOptions = clientOptions.toBuilder().build() + System.gc() + Thread.sleep(100) + + verify(httpClient, never()).close() + // This exists so that `clientOptions` is still reachable. + assertThat(clientOptions).isEqualTo(clientOptions) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/core/ObjectMappersTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/core/ObjectMappersTest.kt new file mode 100644 index 00000000..569090e0 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/core/ObjectMappersTest.kt @@ -0,0 +1,102 @@ +package com.langsmith_api.api.core + +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.exc.MismatchedInputException +import com.fasterxml.jackson.module.kotlin.readValue +import java.time.LocalDateTime +import kotlin.reflect.KClass +import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.api.Assertions.catchThrowable +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertDoesNotThrow +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource +import org.junitpioneer.jupiter.cartesian.CartesianTest + +internal class ObjectMappersTest { + + internal class ClassWithBooleanFieldPrefixedWithIs(private val isActive: JsonField<Boolean>) { + + @JsonProperty("is_active") @ExcludeMissing fun _isActive() = isActive + } + + @Test + fun write_whenFieldPrefixedWithIs_keepsPrefix() { + val value = ClassWithBooleanFieldPrefixedWithIs(JsonField.of(true)) + + val json = jsonMapper().writeValueAsString(value) + + assertThat(json).isEqualTo("{\"is_active\":true}") + } + + internal class Class(@get:JsonProperty("field") @JsonProperty("field") val field: String) + + enum class ShapeTestCase(val value: Any, val kClass: KClass<*>) { + STRING("Hello World!", String::class), + BOOLEAN(true, Boolean::class), + FLOAT(3.14F, Float::class), + DOUBLE(3.14, Double::class), + INTEGER(42, Int::class), + LONG(42L, Long::class), + MAP(mapOf("property" to "value"), Map::class), + CLASS(Class("Hello World!"), Class::class), + LIST(listOf(1, 2, 3), List::class); + + companion object { + val VALID_CONVERSIONS = + listOf( + FLOAT to DOUBLE, + FLOAT to INTEGER, + FLOAT to LONG, + DOUBLE to FLOAT, + DOUBLE to INTEGER, + DOUBLE to LONG, + INTEGER to FLOAT, + INTEGER to DOUBLE, + INTEGER to LONG, + LONG to FLOAT, + LONG to DOUBLE, + LONG to INTEGER, + CLASS to MAP, + // These aren't actually valid, but coercion configs don't work for String until + // v2.14.0: https://github.com/FasterXML/jackson-databind/issues/3240 + // We currently test on v2.13.4. + BOOLEAN to STRING, + FLOAT to STRING, + DOUBLE to STRING, + INTEGER to STRING, + LONG to STRING, + ) + } + } + + @CartesianTest + fun read(@CartesianTest.Enum shape1: ShapeTestCase, @CartesianTest.Enum shape2: ShapeTestCase) { + val jsonMapper = jsonMapper() + val json = jsonMapper.writeValueAsString(shape1.value) + + val e = catchThrowable { jsonMapper.readValue(json, shape2.kClass.java) } + + if (shape1 == shape2 || shape1 to shape2 in ShapeTestCase.VALID_CONVERSIONS) { + assertThat(e).isNull() + } else { + assertThat(e).isInstanceOf(MismatchedInputException::class.java) + } + } + + enum class LenientLocalDateTimeTestCase(val string: String) { + DATE("1998-04-21"), + DATE_TIME("1998-04-21T04:00:00"), + ZONED_DATE_TIME_1("1998-04-21T04:00:00+03:00"), + ZONED_DATE_TIME_2("1998-04-21T04:00:00Z"), + } + + @ParameterizedTest + @EnumSource + fun readLocalDateTime_lenient(testCase: LenientLocalDateTimeTestCase) { + val jsonMapper = jsonMapper() + val json = jsonMapper.writeValueAsString(testCase.string) + + assertDoesNotThrow { jsonMapper().readValue<LocalDateTime>(json) } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/core/PhantomReachableTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/core/PhantomReachableTest.kt new file mode 100644 index 00000000..089db50a --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/core/PhantomReachableTest.kt @@ -0,0 +1,27 @@ +package com.langsmith_api.api.core + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PhantomReachableTest { + + @Test + fun closeWhenPhantomReachable_whenObservedIsGarbageCollected_closesCloseable() { + var closed = false + val closeable = AutoCloseable { closed = true } + + closeWhenPhantomReachable( + // Pass an inline object for the object to observe so that it becomes immediately + // unreachable. + Any(), + closeable, + ) + + assertThat(closed).isFalse() + + System.gc() + Thread.sleep(100) + + assertThat(closed).isTrue() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/core/UtilsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/core/UtilsTest.kt new file mode 100644 index 00000000..e0e7f55c --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/core/UtilsTest.kt @@ -0,0 +1,33 @@ +package com.langsmith_api.api.core + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UtilsTest { + @Test + fun contentDeepEquals() { + assertThat(42 contentEquals 42).isTrue() + assertThat(42 contentEquals "Hello World!").isFalse() + assertThat(byteArrayOf(1, 2, 3) contentEquals byteArrayOf(1, 2, 3)).isTrue() + assertThat(byteArrayOf(1, 2, 3) contentEquals byteArrayOf(1, 2, 4)).isFalse() + assertThat( + arrayOf(byteArrayOf(1, 2), byteArrayOf(3)) contentEquals + arrayOf(byteArrayOf(1, 2), byteArrayOf(3)) + ) + .isTrue() + assertThat( + arrayOf(byteArrayOf(1, 2), byteArrayOf(3)) contentEquals + arrayOf(byteArrayOf(1), byteArrayOf(2, 3)) + ) + .isFalse() + } + + @Test + fun contentToString() { + assertThat((42).contentToString()).isEqualTo("42") + assertThat("Hello World!".contentToString()).isEqualTo("Hello World!") + assertThat(byteArrayOf(1, 2, 3).contentToString()).isEqualTo("[1, 2, 3]") + assertThat(arrayOf(byteArrayOf(1, 2), byteArrayOf(3)).contentToString()) + .isEqualTo("[[1, 2], [3]]") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/core/ValuesTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/core/ValuesTest.kt new file mode 100644 index 00000000..72f6e997 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/core/ValuesTest.kt @@ -0,0 +1,144 @@ +package com.langsmith_api.api.core + +import java.util.Optional +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class ValuesTest { + companion object { + private val NON_JSON = Any() + } + + enum class TestCase( + val value: JsonField<*>, + val expectedIsMissing: Boolean = false, + val expectedIsNull: Boolean = false, + val expectedAsKnown: Optional<*> = Optional.empty<Nothing>(), + val expectedAsBoolean: Optional<Boolean> = Optional.empty(), + val expectedAsNumber: Optional<Number> = Optional.empty(), + val expectedAsString: Optional<String> = Optional.empty(), + val expectedAsArray: Optional<List<JsonValue>> = Optional.empty(), + val expectedAsObject: Optional<Map<String, JsonValue>> = Optional.empty(), + ) { + MISSING(JsonMissing.of(), expectedIsMissing = true), + NULL(JsonNull.of(), expectedIsNull = true), + KNOWN(KnownValue.of(NON_JSON), expectedAsKnown = Optional.of(NON_JSON)), + KNOWN_BOOLEAN( + KnownValue.of(true), + expectedAsKnown = Optional.of(true), + expectedAsBoolean = Optional.of(true), + ), + BOOLEAN(JsonBoolean.of(true), expectedAsBoolean = Optional.of(true)), + KNOWN_NUMBER( + KnownValue.of(42), + expectedAsKnown = Optional.of(42), + expectedAsNumber = Optional.of(42), + ), + NUMBER(JsonNumber.of(42), expectedAsNumber = Optional.of(42)), + KNOWN_STRING( + KnownValue.of("hello"), + expectedAsKnown = Optional.of("hello"), + expectedAsString = Optional.of("hello"), + ), + STRING(JsonString.of("hello"), expectedAsString = Optional.of("hello")), + KNOWN_ARRAY_NOT_ALL_JSON( + KnownValue.of(listOf("a", "b", NON_JSON)), + expectedAsKnown = Optional.of(listOf("a", "b", NON_JSON)), + ), + KNOWN_ARRAY( + KnownValue.of(listOf("a", "b", "c")), + expectedAsKnown = Optional.of(listOf("a", "b", "c")), + expectedAsArray = + Optional.of(listOf(JsonString.of("a"), JsonString.of("b"), JsonString.of("c"))), + ), + ARRAY( + JsonArray.of(listOf(JsonString.of("a"), JsonString.of("b"), JsonString.of("c"))), + expectedAsArray = + Optional.of(listOf(JsonString.of("a"), JsonString.of("b"), JsonString.of("c"))), + ), + KNOWN_OBJECT_NOT_ALL_STRING_KEYS( + KnownValue.of(mapOf("a" to "b", 42 to "c")), + expectedAsKnown = Optional.of(mapOf("a" to "b", 42 to "c")), + ), + KNOWN_OBJECT_NOT_ALL_JSON( + KnownValue.of(mapOf("a" to "b", "b" to NON_JSON)), + expectedAsKnown = Optional.of(mapOf("a" to "b", "b" to NON_JSON)), + ), + KNOWN_OBJECT( + KnownValue.of(mapOf("a" to "b", "b" to "c")), + expectedAsKnown = Optional.of(mapOf("a" to "b", "b" to "c")), + expectedAsObject = + Optional.of(mapOf("a" to JsonString.of("b"), "b" to JsonString.of("c"))), + ), + OBJECT( + JsonObject.of(mapOf("a" to JsonString.of("b"), "b" to JsonString.of("c"))), + expectedAsObject = + Optional.of(mapOf("a" to JsonString.of("b"), "b" to JsonString.of("c"))), + ), + } + + @ParameterizedTest + @EnumSource + fun isMissing(testCase: TestCase) { + val isMissing = testCase.value.isMissing() + + assertThat(isMissing).isEqualTo(testCase.expectedIsMissing) + } + + @ParameterizedTest + @EnumSource + fun isNull(testCase: TestCase) { + val isNull = testCase.value.isNull() + + assertThat(isNull).isEqualTo(testCase.expectedIsNull) + } + + @ParameterizedTest + @EnumSource + fun asKnown(testCase: TestCase) { + val known = testCase.value.asKnown() + + assertThat(known).isEqualTo(testCase.expectedAsKnown) + } + + @ParameterizedTest + @EnumSource + fun asBoolean(testCase: TestCase) { + val boolean = testCase.value.asBoolean() + + assertThat(boolean).isEqualTo(testCase.expectedAsBoolean) + } + + @ParameterizedTest + @EnumSource + fun asNumber(testCase: TestCase) { + val number = testCase.value.asNumber() + + assertThat(number).isEqualTo(testCase.expectedAsNumber) + } + + @ParameterizedTest + @EnumSource + fun asString(testCase: TestCase) { + val string = testCase.value.asString() + + assertThat(string).isEqualTo(testCase.expectedAsString) + } + + @ParameterizedTest + @EnumSource + fun asArray(testCase: TestCase) { + val array = testCase.value.asArray() + + assertThat(array).isEqualTo(testCase.expectedAsArray) + } + + @ParameterizedTest + @EnumSource + fun asObject(testCase: TestCase) { + val obj = testCase.value.asObject() + + assertThat(obj).isEqualTo(testCase.expectedAsObject) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/core/http/AsyncStreamResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/core/http/AsyncStreamResponseTest.kt new file mode 100644 index 00000000..e218e10f --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/core/http/AsyncStreamResponseTest.kt @@ -0,0 +1,268 @@ +package com.langsmith_api.api.core.http + +import java.util.* +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.stream.Stream +import kotlin.streams.asStream +import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.api.Assertions.catchThrowable +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertDoesNotThrow +import org.junit.jupiter.api.extension.ExtendWith +import org.mockito.junit.jupiter.MockitoExtension +import org.mockito.kotlin.* + +@ExtendWith(MockitoExtension::class) +internal class AsyncStreamResponseTest { + + companion object { + private val ERROR = RuntimeException("ERROR!") + } + + private val streamResponse = + spy<StreamResponse<String>> { + doReturn(Stream.of("chunk1", "chunk2", "chunk3")).whenever(it).stream() + } + private val erroringStreamResponse = + spy<StreamResponse<String>> { + doReturn( + sequence { + yield("chunk1") + yield("chunk2") + throw ERROR + } + .asStream() + ) + .whenever(it) + .stream() + } + private val executor = + spy<Executor> { + doAnswer { invocation -> invocation.getArgument<Runnable>(0).run() } + .whenever(it) + .execute(any()) + } + private val handler = mock<AsyncStreamResponse.Handler<String>>() + + @Test + fun subscribe_whenAlreadySubscribed_throws() { + val asyncStreamResponse = CompletableFuture<StreamResponse<String>>().toAsync(executor) + asyncStreamResponse.subscribe {} + + val throwable = catchThrowable { asyncStreamResponse.subscribe {} } + + assertThat(throwable).isInstanceOf(IllegalStateException::class.java) + assertThat(throwable).hasMessage("Cannot subscribe more than once") + verify(executor, never()).execute(any()) + } + + @Test + fun subscribe_whenClosed_throws() { + val asyncStreamResponse = CompletableFuture<StreamResponse<String>>().toAsync(executor) + asyncStreamResponse.close() + + val throwable = catchThrowable { asyncStreamResponse.subscribe {} } + + assertThat(throwable).isInstanceOf(IllegalStateException::class.java) + assertThat(throwable).hasMessage("Cannot subscribe after the response is closed") + verify(executor, never()).execute(any()) + } + + @Test + fun subscribe_whenFutureCompletesAfterClose_doesNothing() { + val future = CompletableFuture<StreamResponse<String>>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + asyncStreamResponse.close() + + future.complete(streamResponse) + + verify(handler, never()).onNext(any()) + verify(handler, never()).onComplete(any()) + verify(executor, times(1)).execute(any()) + } + + @Test + fun subscribe_whenFutureErrors_callsOnComplete() { + val future = CompletableFuture<StreamResponse<String>>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + + future.completeExceptionally(ERROR) + + verify(handler, never()).onNext(any()) + verify(handler, times(1)).onComplete(Optional.of(ERROR)) + verify(executor, times(1)).execute(any()) + } + + @Test + fun subscribe_whenFutureCompletes_runsHandler() { + val future = CompletableFuture<StreamResponse<String>>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + + future.complete(streamResponse) + + inOrder(handler, streamResponse) { + verify(handler, times(1)).onNext("chunk1") + verify(handler, times(1)).onNext("chunk2") + verify(handler, times(1)).onNext("chunk3") + verify(handler, times(1)).onComplete(Optional.empty()) + verify(streamResponse, times(1)).close() + } + verify(executor, times(1)).execute(any()) + } + + @Test + fun subscribe_whenStreamErrors_callsOnCompleteEarly() { + val future = CompletableFuture<StreamResponse<String>>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + + future.complete(erroringStreamResponse) + + inOrder(handler, erroringStreamResponse) { + verify(handler, times(1)).onNext("chunk1") + verify(handler, times(1)).onNext("chunk2") + verify(handler, times(1)).onComplete(Optional.of(ERROR)) + verify(erroringStreamResponse, times(1)).close() + } + verify(executor, times(1)).execute(any()) + } + + @Test + fun onCompleteFuture_whenStreamResponseFutureNotCompleted_onCompleteFutureNotCompleted() { + val future = CompletableFuture<StreamResponse<String>>() + val asyncStreamResponse = future.toAsync(executor) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isNotCompleted + } + + @Test + fun onCompleteFuture_whenStreamResponseFutureErrors_onCompleteFutureCompletedExceptionally() { + val future = CompletableFuture<StreamResponse<String>>() + val asyncStreamResponse = future.toAsync(executor) + future.completeExceptionally(ERROR) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompletedExceptionally + } + + @Test + fun onCompleteFuture_whenStreamResponseFutureCompletedButStillStreaming_onCompleteFutureNotCompleted() { + val future = CompletableFuture<StreamResponse<String>>() + val asyncStreamResponse = future.toAsync(executor) + future.complete(streamResponse) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isNotCompleted + } + + @Test + fun onCompleteFuture_whenStreamResponseFutureCompletedAndStreamErrors_onCompleteFutureCompletedExceptionally() { + val future = CompletableFuture<StreamResponse<String>>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + future.complete(erroringStreamResponse) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompletedExceptionally + } + + @Test + fun onCompleteFuture_whenStreamResponseFutureCompletedAndStreamCompleted_onCompleteFutureCompleted() { + val future = CompletableFuture<StreamResponse<String>>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + future.complete(streamResponse) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompleted + } + + @Test + fun onCompleteFuture_whenHandlerOnCompleteWithoutThrowableThrows_onCompleteFutureCompleted() { + val future = CompletableFuture<StreamResponse<String>>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe( + object : AsyncStreamResponse.Handler<String> { + override fun onNext(value: String) {} + + override fun onComplete(error: Optional<Throwable>) = throw ERROR + } + ) + future.complete(streamResponse) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompleted + } + + @Test + fun onCompleteFuture_whenHandlerOnCompleteWithThrowableThrows_onCompleteFutureCompletedExceptionally() { + val future = CompletableFuture<StreamResponse<String>>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe( + object : AsyncStreamResponse.Handler<String> { + override fun onNext(value: String) {} + + override fun onComplete(error: Optional<Throwable>) = throw ERROR + } + ) + future.complete(erroringStreamResponse) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompletedExceptionally + } + + @Test + fun onCompleteFuture_whenClosed_onCompleteFutureCompleted() { + val future = CompletableFuture<StreamResponse<String>>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.close() + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompleted + } + + @Test + fun close_whenNotClosed_closesStreamResponse() { + val future = CompletableFuture<StreamResponse<String>>() + val asyncStreamResponse = future.toAsync(executor) + + asyncStreamResponse.close() + future.complete(streamResponse) + + verify(streamResponse, times(1)).close() + } + + @Test + fun close_whenAlreadyClosed_doesNothing() { + val future = CompletableFuture<StreamResponse<String>>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.close() + future.complete(streamResponse) + + asyncStreamResponse.close() + + verify(streamResponse, times(1)).close() + } + + @Test + fun close_whenFutureErrors_doesNothing() { + val future = CompletableFuture<StreamResponse<String>>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.close() + + assertDoesNotThrow { future.completeExceptionally(ERROR) } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/core/http/HeadersTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/core/http/HeadersTest.kt new file mode 100644 index 00000000..39aaf5ff --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/core/http/HeadersTest.kt @@ -0,0 +1,242 @@ +package com.langsmith_api.api.core.http + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class HeadersTest { + + enum class TestCase( + val headers: Headers, + val expectedMap: Map<String, List<String>>, + val expectedSize: Int, + ) { + EMPTY(Headers.builder().build(), expectedMap = mapOf(), expectedSize = 0), + PUT_ONE( + Headers.builder().put("name", "value").build(), + expectedMap = mapOf("name" to listOf("value")), + expectedSize = 1, + ), + PUT_MULTIPLE( + Headers.builder().put("name", listOf("value1", "value2")).build(), + expectedMap = mapOf("name" to listOf("value1", "value2")), + expectedSize = 2, + ), + MULTIPLE_PUT( + Headers.builder().put("name1", "value").put("name2", "value").build(), + expectedMap = mapOf("name1" to listOf("value"), "name2" to listOf("value")), + expectedSize = 2, + ), + MULTIPLE_PUT_SAME_NAME( + Headers.builder().put("name", "value1").put("name", "value2").build(), + expectedMap = mapOf("name" to listOf("value1", "value2")), + expectedSize = 2, + ), + MULTIPLE_PUT_MULTIPLE( + Headers.builder() + .put("name", listOf("value1", "value2")) + .put("name", listOf("value1", "value2")) + .build(), + expectedMap = mapOf("name" to listOf("value1", "value2", "value1", "value2")), + expectedSize = 4, + ), + PUT_CASE_INSENSITIVE( + Headers.builder() + .put("name", "value1") + .put("NAME", "value2") + .put("nAmE", "value3") + .build(), + expectedMap = mapOf("name" to listOf("value1", "value2", "value3")), + expectedSize = 3, + ), + PUT_ALL_MAP( + Headers.builder() + .putAll( + mapOf( + "name1" to listOf("value1", "value2"), + "name2" to listOf("value1", "value2"), + ) + ) + .build(), + expectedMap = + mapOf("name1" to listOf("value1", "value2"), "name2" to listOf("value1", "value2")), + expectedSize = 4, + ), + PUT_ALL_HEADERS( + Headers.builder().putAll(Headers.builder().put("name", "value").build()).build(), + expectedMap = mapOf("name" to listOf("value")), + expectedSize = 1, + ), + PUT_ALL_CASE_INSENSITIVE( + Headers.builder() + .putAll( + mapOf( + "name" to listOf("value1"), + "NAME" to listOf("value2"), + "nAmE" to listOf("value3"), + ) + ) + .build(), + expectedMap = mapOf("name" to listOf("value1", "value2", "value3")), + expectedSize = 3, + ), + REMOVE_ABSENT( + Headers.builder().remove("name").build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REMOVE_PRESENT_ONE( + Headers.builder().put("name", "value").remove("name").build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REMOVE_PRESENT_MULTIPLE( + Headers.builder().put("name", listOf("value1", "value2")).remove("name").build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REMOVE_CASE_INSENSITIVE( + Headers.builder().put("name", listOf("value1", "value2")).remove("NAME").build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REMOVE_ALL( + Headers.builder() + .put("name1", "value") + .put("name3", "value") + .removeAll(setOf("name1", "name2", "name3")) + .build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REMOVE_ALL_CASE_INSENSITIVE( + Headers.builder() + .put("name1", "value") + .put("name3", "value") + .removeAll(setOf("NAME1", "nAmE3")) + .build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + CLEAR( + Headers.builder().put("name1", "value").put("name2", "value").clear().build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REPLACE_ONE_ABSENT( + Headers.builder().replace("name", "value").build(), + expectedMap = mapOf("name" to listOf("value")), + expectedSize = 1, + ), + REPLACE_ONE_PRESENT_ONE( + Headers.builder().put("name", "value1").replace("name", "value2").build(), + expectedMap = mapOf("name" to listOf("value2")), + expectedSize = 1, + ), + REPLACE_ONE_PRESENT_MULTIPLE( + Headers.builder() + .put("name", listOf("value1", "value2")) + .replace("name", "value3") + .build(), + expectedMap = mapOf("name" to listOf("value3")), + expectedSize = 1, + ), + REPLACE_MULTIPLE_ABSENT( + Headers.builder().replace("name", listOf("value1", "value2")).build(), + expectedMap = mapOf("name" to listOf("value1", "value2")), + expectedSize = 2, + ), + REPLACE_MULTIPLE_PRESENT_ONE( + Headers.builder() + .put("name", "value1") + .replace("name", listOf("value2", "value3")) + .build(), + expectedMap = mapOf("name" to listOf("value2", "value3")), + expectedSize = 2, + ), + REPLACE_MULTIPLE_PRESENT_MULTIPLE( + Headers.builder() + .put("name", listOf("value1", "value2")) + .replace("name", listOf("value3", "value4")) + .build(), + expectedMap = mapOf("name" to listOf("value3", "value4")), + expectedSize = 2, + ), + REPLACE_CASE_INSENSITIVE( + Headers.builder() + .put("name", "value1") + .replace("NAME", listOf("value2", "value3")) + .build(), + expectedMap = mapOf("NAME" to listOf("value2", "value3")), + expectedSize = 2, + ), + REPLACE_ALL_MAP( + Headers.builder() + .put("name1", "value1") + .put("name2", "value1") + .put("name3", "value1") + .replaceAll(mapOf("name1" to listOf("value2"), "name3" to listOf("value2"))) + .build(), + expectedMap = + mapOf( + "name1" to listOf("value2"), + "name2" to listOf("value1"), + "name3" to listOf("value2"), + ), + expectedSize = 3, + ), + REPLACE_ALL_HEADERS( + Headers.builder() + .put("name1", "value1") + .put("name2", "value1") + .put("name3", "value1") + .replaceAll(Headers.builder().put("name1", "value2").put("name3", "value2").build()) + .build(), + expectedMap = + mapOf( + "name1" to listOf("value2"), + "name2" to listOf("value1"), + "name3" to listOf("value2"), + ), + expectedSize = 3, + ), + REPLACE_ALL_CASE_INSENSITIVE( + Headers.builder() + .put("name1", "value1") + .put("name2", "value1") + .replaceAll(mapOf("NAME1" to listOf("value2"), "nAmE2" to listOf("value2"))) + .build(), + expectedMap = mapOf("NAME1" to listOf("value2"), "nAmE2" to listOf("value2")), + expectedSize = 2, + ), + } + + @ParameterizedTest + @EnumSource + fun namesAndValues(testCase: TestCase) { + val map = mutableMapOf<String, List<String>>() + val headers = testCase.headers + headers.names().forEach { name -> map[name] = headers.values(name) } + + assertThat(map).isEqualTo(testCase.expectedMap) + } + + @ParameterizedTest + @EnumSource + fun caseInsensitiveNames(testCase: TestCase) { + val headers = testCase.headers + + for (name in headers.names()) { + assertThat(headers.values(name)).isEqualTo(headers.values(name.lowercase())) + assertThat(headers.values(name)).isEqualTo(headers.values(name.uppercase())) + } + } + + @ParameterizedTest + @EnumSource + fun size(testCase: TestCase) { + val size = testCase.headers.size + + assertThat(size).isEqualTo(testCase.expectedSize) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/core/http/QueryParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/core/http/QueryParamsTest.kt new file mode 100644 index 00000000..ed17d1f4 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/core/http/QueryParamsTest.kt @@ -0,0 +1,180 @@ +package com.langsmith_api.api.core.http + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class QueryParamsTest { + + enum class TestCase( + val queryParams: QueryParams, + val expectedMap: Map<String, List<String>>, + val expectedSize: Int, + ) { + EMPTY(QueryParams.builder().build(), expectedMap = mapOf(), expectedSize = 0), + PUT_ONE( + QueryParams.builder().put("key", "value").build(), + expectedMap = mapOf("key" to listOf("value")), + expectedSize = 1, + ), + PUT_MULTIPLE( + QueryParams.builder().put("key", listOf("value1", "value2")).build(), + expectedMap = mapOf("key" to listOf("value1", "value2")), + expectedSize = 2, + ), + MULTIPLE_PUT( + QueryParams.builder().put("key1", "value").put("key2", "value").build(), + expectedMap = mapOf("key1" to listOf("value"), "key2" to listOf("value")), + expectedSize = 2, + ), + MULTIPLE_PUT_SAME_NAME( + QueryParams.builder().put("key", "value1").put("key", "value2").build(), + expectedMap = mapOf("key" to listOf("value1", "value2")), + expectedSize = 2, + ), + MULTIPLE_PUT_MULTIPLE( + QueryParams.builder() + .put("key", listOf("value1", "value2")) + .put("key", listOf("value1", "value2")) + .build(), + expectedMap = mapOf("key" to listOf("value1", "value2", "value1", "value2")), + expectedSize = 4, + ), + PUT_ALL_MAP( + QueryParams.builder() + .putAll( + mapOf( + "key1" to listOf("value1", "value2"), + "key2" to listOf("value1", "value2"), + ) + ) + .build(), + expectedMap = + mapOf("key1" to listOf("value1", "value2"), "key2" to listOf("value1", "value2")), + expectedSize = 4, + ), + PUT_ALL_HEADERS( + QueryParams.builder().putAll(QueryParams.builder().put("key", "value").build()).build(), + expectedMap = mapOf("key" to listOf("value")), + expectedSize = 1, + ), + REMOVE_ABSENT( + QueryParams.builder().remove("key").build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REMOVE_PRESENT_ONE( + QueryParams.builder().put("key", "value").remove("key").build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REMOVE_PRESENT_MULTIPLE( + QueryParams.builder().put("key", listOf("value1", "value2")).remove("key").build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REMOVE_ALL( + QueryParams.builder() + .put("key1", "value") + .put("key3", "value") + .removeAll(setOf("key1", "key2", "key3")) + .build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + CLEAR( + QueryParams.builder().put("key1", "value").put("key2", "value").clear().build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REPLACE_ONE_ABSENT( + QueryParams.builder().replace("key", "value").build(), + expectedMap = mapOf("key" to listOf("value")), + expectedSize = 1, + ), + REPLACE_ONE_PRESENT_ONE( + QueryParams.builder().put("key", "value1").replace("key", "value2").build(), + expectedMap = mapOf("key" to listOf("value2")), + expectedSize = 1, + ), + REPLACE_ONE_PRESENT_MULTIPLE( + QueryParams.builder() + .put("key", listOf("value1", "value2")) + .replace("key", "value3") + .build(), + expectedMap = mapOf("key" to listOf("value3")), + expectedSize = 1, + ), + REPLACE_MULTIPLE_ABSENT( + QueryParams.builder().replace("key", listOf("value1", "value2")).build(), + expectedMap = mapOf("key" to listOf("value1", "value2")), + expectedSize = 2, + ), + REPLACE_MULTIPLE_PRESENT_ONE( + QueryParams.builder() + .put("key", "value1") + .replace("key", listOf("value2", "value3")) + .build(), + expectedMap = mapOf("key" to listOf("value2", "value3")), + expectedSize = 2, + ), + REPLACE_MULTIPLE_PRESENT_MULTIPLE( + QueryParams.builder() + .put("key", listOf("value1", "value2")) + .replace("key", listOf("value3", "value4")) + .build(), + expectedMap = mapOf("key" to listOf("value3", "value4")), + expectedSize = 2, + ), + REPLACE_ALL_MAP( + QueryParams.builder() + .put("key1", "value1") + .put("key2", "value1") + .put("key3", "value1") + .replaceAll(mapOf("key1" to listOf("value2"), "key3" to listOf("value2"))) + .build(), + expectedMap = + mapOf( + "key1" to listOf("value2"), + "key2" to listOf("value1"), + "key3" to listOf("value2"), + ), + expectedSize = 3, + ), + REPLACE_ALL_HEADERS( + QueryParams.builder() + .put("key1", "value1") + .put("key2", "value1") + .put("key3", "value1") + .replaceAll( + QueryParams.builder().put("key1", "value2").put("key3", "value2").build() + ) + .build(), + expectedMap = + mapOf( + "key1" to listOf("value2"), + "key2" to listOf("value1"), + "key3" to listOf("value2"), + ), + expectedSize = 3, + ), + } + + @ParameterizedTest + @EnumSource + fun keysAndValues(testCase: TestCase) { + val map = mutableMapOf<String, List<String>>() + val queryParams = testCase.queryParams + queryParams.keys().forEach { key -> map[key] = queryParams.values(key) } + + assertThat(map).isEqualTo(testCase.expectedMap) + } + + @ParameterizedTest + @EnumSource + fun size(testCase: TestCase) { + val size = testCase.queryParams.size + + assertThat(size).isEqualTo(testCase.expectedSize) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/core/http/RetryingHttpClientTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/core/http/RetryingHttpClientTest.kt new file mode 100644 index 00000000..69265ade --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/core/http/RetryingHttpClientTest.kt @@ -0,0 +1,356 @@ +package com.langsmith_api.api.core.http + +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 com.langsmith_api.api.client.okhttp.OkHttpClient +import com.langsmith_api.api.core.RequestOptions +import com.langsmith_api.api.core.Sleeper +import com.langsmith_api.api.errors.LangsmithApiRetryableException +import java.io.InputStream +import java.time.Duration +import java.util.concurrent.CompletableFuture +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.parallel.ResourceLock +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.ValueSource + +@WireMockTest +@ResourceLock("https://github.com/wiremock/wiremock/issues/169") +internal class RetryingHttpClientTest { + + private var openResponseCount = 0 + private lateinit var baseUrl: String + private lateinit var httpClient: HttpClient + + @BeforeEach + fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { + baseUrl = wmRuntimeInfo.httpBaseUrl + val okHttpClient = OkHttpClient.builder().build() + httpClient = + object : HttpClient { + + override fun execute( + request: HttpRequest, + requestOptions: RequestOptions, + ): HttpResponse = trackClose(okHttpClient.execute(request, requestOptions)) + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponse> = + okHttpClient.executeAsync(request, requestOptions).thenApply { trackClose(it) } + + override fun close() = okHttpClient.close() + + private fun trackClose(response: HttpResponse): HttpResponse { + openResponseCount++ + return object : HttpResponse { + + private var isClosed = false + + override fun statusCode(): Int = response.statusCode() + + override fun headers(): Headers = response.headers() + + override fun body(): InputStream = response.body() + + override fun close() { + response.close() + if (isClosed) { + return + } + openResponseCount-- + isClosed = true + } + } + } + } + resetAllScenarios() + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute(async: Boolean) { + stubFor(post(urlPathEqualTo("/something")).willReturn(ok())) + val retryingClient = retryingHttpClientBuilder().build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) + + assertThat(response.statusCode()).isEqualTo(200) + verify(1, postRequestedFor(urlPathEqualTo("/something"))) + assertNoResponseLeaks() + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withIdempotencyHeader(async: Boolean) { + stubFor( + post(urlPathEqualTo("/something")) + .withHeader("X-Some-Header", matching("stainless-java-retry-.+")) + .willReturn(ok()) + ) + val retryingClient = + retryingHttpClientBuilder().maxRetries(2).idempotencyHeader("X-Some-Header").build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) + + assertThat(response.statusCode()).isEqualTo(200) + verify(1, postRequestedFor(urlPathEqualTo("/something"))) + assertNoResponseLeaks() + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withRetryAfterHeader(async: Boolean) { + stubFor( + post(urlPathEqualTo("/something")) + // First we fail with a retry after header given as a date + .inScenario("foo") + .whenScenarioStateIs(Scenario.STARTED) + .willReturn( + serviceUnavailable().withHeader("Retry-After", "Wed, 21 Oct 2015 07:28:00 GMT") + ) + .willSetStateTo("RETRY_AFTER_DATE") + ) + stubFor( + post(urlPathEqualTo("/something")) + // Then we fail with a retry after header given as a delay + .inScenario("foo") + .whenScenarioStateIs("RETRY_AFTER_DATE") + .willReturn(serviceUnavailable().withHeader("Retry-After", "1.234")) + .willSetStateTo("RETRY_AFTER_DELAY") + ) + stubFor( + post(urlPathEqualTo("/something")) + // Then we return a success + .inScenario("foo") + .whenScenarioStateIs("RETRY_AFTER_DELAY") + .willReturn(ok()) + .willSetStateTo("COMPLETED") + ) + val retryingClient = retryingHttpClientBuilder().maxRetries(2).build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) + + assertThat(response.statusCode()).isEqualTo(200) + verify( + 1, + postRequestedFor(urlPathEqualTo("/something")) + .withHeader("x-stainless-retry-count", equalTo("0")), + ) + verify( + 1, + postRequestedFor(urlPathEqualTo("/something")) + .withHeader("x-stainless-retry-count", equalTo("1")), + ) + verify( + 1, + postRequestedFor(urlPathEqualTo("/something")) + .withHeader("x-stainless-retry-count", equalTo("2")), + ) + assertNoResponseLeaks() + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withOverwrittenRetryCountHeader(async: Boolean) { + 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") + ) + .willSetStateTo("RETRY_AFTER_DATE") + ) + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") // then we return a success + .whenScenarioStateIs("RETRY_AFTER_DATE") + .willReturn(ok()) + .willSetStateTo("COMPLETED") + ) + val retryingClient = retryingHttpClientBuilder().maxRetries(2).build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .putHeader("x-stainless-retry-count", "42") + .build(), + async, + ) + + assertThat(response.statusCode()).isEqualTo(200) + verify( + 2, + postRequestedFor(urlPathEqualTo("/something")) + .withHeader("x-stainless-retry-count", equalTo("42")), + ) + assertNoResponseLeaks() + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withRetryAfterMsHeader(async: Boolean) { + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") + .whenScenarioStateIs(Scenario.STARTED) + .willReturn(serviceUnavailable().withHeader("Retry-After-Ms", "10")) + .willSetStateTo("RETRY_AFTER_DELAY") + ) + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") // then we return a success + .whenScenarioStateIs("RETRY_AFTER_DELAY") + .willReturn(ok()) + .willSetStateTo("COMPLETED") + ) + val retryingClient = retryingHttpClientBuilder().maxRetries(1).build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) + + assertThat(response.statusCode()).isEqualTo(200) + verify(2, postRequestedFor(urlPathEqualTo("/something"))) + assertNoResponseLeaks() + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withRetryableException(async: Boolean) { + stubFor(post(urlPathEqualTo("/something")).willReturn(ok())) + + var callCount = 0 + val failingHttpClient = + object : HttpClient { + override fun execute( + request: HttpRequest, + requestOptions: RequestOptions, + ): HttpResponse { + callCount++ + if (callCount == 1) { + throw LangsmithApiRetryableException("Simulated retryable failure") + } + return httpClient.execute(request, requestOptions) + } + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture<HttpResponse> { + callCount++ + if (callCount == 1) { + val future = CompletableFuture<HttpResponse>() + future.completeExceptionally( + LangsmithApiRetryableException("Simulated retryable failure") + ) + return future + } + return httpClient.executeAsync(request, requestOptions) + } + + override fun close() = httpClient.close() + } + + val retryingClient = + RetryingHttpClient.builder() + .httpClient(failingHttpClient) + .maxRetries(2) + .sleeper( + object : Sleeper { + + override fun sleep(duration: Duration) {} + + override fun sleepAsync(duration: Duration): CompletableFuture<Void> = + CompletableFuture.completedFuture(null) + + override fun close() {} + } + ) + .build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) + + assertThat(response.statusCode()).isEqualTo(200) + verify( + 1, + postRequestedFor(urlPathEqualTo("/something")) + .withHeader("x-stainless-retry-count", equalTo("1")), + ) + verify( + 0, + postRequestedFor(urlPathEqualTo("/something")) + .withHeader("x-stainless-retry-count", equalTo("0")), + ) + assertNoResponseLeaks() + } + + private fun retryingHttpClientBuilder() = + RetryingHttpClient.builder() + .httpClient(httpClient) + // Use a no-op `Sleeper` to make the test fast. + .sleeper( + object : Sleeper { + + override fun sleep(duration: Duration) {} + + override fun sleepAsync(duration: Duration): CompletableFuture<Void> = + CompletableFuture.completedFuture(null) + + override fun close() {} + } + ) + + private fun HttpClient.execute(request: HttpRequest, async: Boolean): HttpResponse = + if (async) executeAsync(request).get() else execute(request) + + // When retrying, all failed responses should be closed. Only the final returned response should + // be open. + private fun assertNoResponseLeaks() = assertThat(openResponseCount).isEqualTo(1) +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/V1EventsParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/V1EventsParamsTest.kt new file mode 100644 index 00000000..d9d942c7 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/V1EventsParamsTest.kt @@ -0,0 +1,53 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1 + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class V1EventsParamsTest { + + @Test + fun create() { + V1EventsParams.builder() + .eventType(V1EventsParams.EventType.PLAYGROUND_VIEW) + .owner("owner") + .repo("repo") + .commit("commit") + .build() + } + + @Test + fun body() { + val params = + V1EventsParams.builder() + .eventType(V1EventsParams.EventType.PLAYGROUND_VIEW) + .owner("owner") + .repo("repo") + .commit("commit") + .build() + + val body = params._body() + + assertThat(body.eventType()).isEqualTo(V1EventsParams.EventType.PLAYGROUND_VIEW) + assertThat(body.owner()).isEqualTo("owner") + assertThat(body.repo()).isEqualTo("repo") + assertThat(body.commit()).contains("commit") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + V1EventsParams.builder() + .eventType(V1EventsParams.EventType.PLAYGROUND_VIEW) + .owner("owner") + .repo("repo") + .build() + + val body = params._body() + + assertThat(body.eventType()).isEqualTo(V1EventsParams.EventType.PLAYGROUND_VIEW) + assertThat(body.owner()).isEqualTo("owner") + assertThat(body.repo()).isEqualTo("repo") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/V1EventsResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/V1EventsResponseTest.kt new file mode 100644 index 00000000..d297f7f2 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/V1EventsResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1 + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class V1EventsResponseTest { + + @Test + fun create() { + val v1EventsResponse = V1EventsResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val v1EventsResponse = V1EventsResponse.builder().build() + + val roundtrippedV1EventsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(v1EventsResponse), + jacksonTypeRef<V1EventsResponse>(), + ) + + assertThat(roundtrippedV1EventsResponse).isEqualTo(v1EventsResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/V1LoginParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/V1LoginParamsTest.kt new file mode 100644 index 00000000..a834379e --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/V1LoginParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1 + +import org.junit.jupiter.api.Test + +internal class V1LoginParamsTest { + + @Test + fun create() { + V1LoginParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/V1LoginResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/V1LoginResponseTest.kt new file mode 100644 index 00000000..b88a9b6b --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/V1LoginResponseTest.kt @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1 + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class V1LoginResponseTest { + + @Test + fun create() { + val v1LoginResponse = V1LoginResponse.builder().accessToken("access_token").build() + + assertThat(v1LoginResponse.accessToken()).isEqualTo("access_token") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val v1LoginResponse = V1LoginResponse.builder().accessToken("access_token").build() + + val roundtrippedV1LoginResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(v1LoginResponse), + jacksonTypeRef<V1LoginResponse>(), + ) + + assertThat(roundtrippedV1LoginResponse).isEqualTo(v1LoginResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/V1RetrieveOkParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/V1RetrieveOkParamsTest.kt new file mode 100644 index 00000000..378eb268 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/V1RetrieveOkParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1 + +import org.junit.jupiter.api.Test + +internal class V1RetrieveOkParamsTest { + + @Test + fun create() { + V1RetrieveOkParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/V1RetrieveOkResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/V1RetrieveOkResponseTest.kt new file mode 100644 index 00000000..7730451a --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/V1RetrieveOkResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1 + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class V1RetrieveOkResponseTest { + + @Test + fun create() { + val v1RetrieveOkResponse = V1RetrieveOkResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val v1RetrieveOkResponse = V1RetrieveOkResponse.builder().build() + + val roundtrippedV1RetrieveOkResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(v1RetrieveOkResponse), + jacksonTypeRef<V1RetrieveOkResponse>(), + ) + + assertThat(roundtrippedV1RetrieveOkResponse).isEqualTo(v1RetrieveOkResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/V1UpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/V1UpdateParamsTest.kt new file mode 100644 index 00000000..dfc3a24b --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/V1UpdateParamsTest.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1 + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class V1UpdateParamsTest { + + @Test + fun create() { + V1UpdateParams.builder().owner("owner").repo("repo").like(true).build() + } + + @Test + fun pathParams() { + val params = V1UpdateParams.builder().owner("owner").repo("repo").like(true).build() + + assertThat(params._pathParam(0)).isEqualTo("owner") + assertThat(params._pathParam(1)).isEqualTo("repo") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } + + @Test + fun body() { + val params = V1UpdateParams.builder().owner("owner").repo("repo").like(true).build() + + val body = params._body() + + assertThat(body.like()).isEqualTo(true) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/V1UpdateResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/V1UpdateResponseTest.kt new file mode 100644 index 00000000..11c9006f --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/V1UpdateResponseTest.kt @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1 + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class V1UpdateResponseTest { + + @Test + fun create() { + val v1UpdateResponse = V1UpdateResponse.builder().likes(0L).build() + + assertThat(v1UpdateResponse.likes()).isEqualTo(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val v1UpdateResponse = V1UpdateResponse.builder().likes(0L).build() + + val roundtrippedV1UpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(v1UpdateResponse), + jacksonTypeRef<V1UpdateResponse>(), + ) + + assertThat(roundtrippedV1UpdateResponse).isEqualTo(v1UpdateResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/ace/AceExecuteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/ace/AceExecuteParamsTest.kt new file mode 100644 index 00000000..74d6ff74 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/ace/AceExecuteParamsTest.kt @@ -0,0 +1,35 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.ace + +import com.langsmith_api.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AceExecuteParamsTest { + + @Test + fun create() { + AceExecuteParams.builder() + .addArg(JsonValue.from(mapOf<String, Any>())) + .code("code") + .language("language") + .build() + } + + @Test + fun body() { + val params = + AceExecuteParams.builder() + .addArg(JsonValue.from(mapOf<String, Any>())) + .code("code") + .language("language") + .build() + + val body = params._body() + + assertThat(body.args()).containsExactly(JsonValue.from(mapOf<String, Any>())) + assertThat(body.code()).isEqualTo("code") + assertThat(body.language()).isEqualTo("language") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/ace/AceExecuteResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/ace/AceExecuteResponseTest.kt new file mode 100644 index 00000000..ec166140 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/ace/AceExecuteResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.ace + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AceExecuteResponseTest { + + @Test + fun create() { + val aceExecuteResponse = AceExecuteResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val aceExecuteResponse = AceExecuteResponse.builder().build() + + val roundtrippedAceExecuteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(aceExecuteResponse), + jacksonTypeRef<AceExecuteResponse>(), + ) + + assertThat(roundtrippedAceExecuteResponse).isEqualTo(aceExecuteResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueAnnotationQueuesParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueAnnotationQueuesParamsTest.kt new file mode 100644 index 00000000..38c921ed --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueAnnotationQueuesParamsTest.kt @@ -0,0 +1,120 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +import com.langsmith_api.api.core.JsonValue +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AnnotationQueueAnnotationQueuesParamsTest { + + @Test + fun create() { + AnnotationQueueAnnotationQueuesParams.builder() + .name("name") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .defaultDataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .enableReservations(true) + .numReviewersPerItem(0L) + .reservationMinutes(0L) + .rubricInstructions("rubric_instructions") + .addRubricItem( + AnnotationQueueRubricItemSchema.builder() + .feedbackKey("feedback_key") + .description("description") + .scoreDescriptions( + AnnotationQueueRubricItemSchema.ScoreDescriptions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .valueDescriptions( + AnnotationQueueRubricItemSchema.ValueDescriptions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + } + + @Test + fun body() { + val params = + AnnotationQueueAnnotationQueuesParams.builder() + .name("name") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .defaultDataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .enableReservations(true) + .numReviewersPerItem(0L) + .reservationMinutes(0L) + .rubricInstructions("rubric_instructions") + .addRubricItem( + AnnotationQueueRubricItemSchema.builder() + .feedbackKey("feedback_key") + .description("description") + .scoreDescriptions( + AnnotationQueueRubricItemSchema.ScoreDescriptions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .valueDescriptions( + AnnotationQueueRubricItemSchema.ValueDescriptions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val body = params._body() + + assertThat(body.name()).isEqualTo("name") + assertThat(body.id()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.createdAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(body.defaultDataset()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.description()).contains("description") + assertThat(body.enableReservations()).contains(true) + assertThat(body.numReviewersPerItem()).contains(0L) + assertThat(body.reservationMinutes()).contains(0L) + assertThat(body.rubricInstructions()).contains("rubric_instructions") + assertThat(body.rubricItems().getOrNull()) + .containsExactly( + AnnotationQueueRubricItemSchema.builder() + .feedbackKey("feedback_key") + .description("description") + .scoreDescriptions( + AnnotationQueueRubricItemSchema.ScoreDescriptions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .valueDescriptions( + AnnotationQueueRubricItemSchema.ValueDescriptions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + assertThat(body.sessionIds().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.updatedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = AnnotationQueueAnnotationQueuesParams.builder().name("name").build() + + val body = params._body() + + assertThat(body.name()).isEqualTo("name") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueDeleteParamsTest.kt new file mode 100644 index 00000000..68247127 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueDeleteParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AnnotationQueueDeleteParamsTest { + + @Test + fun create() { + AnnotationQueueDeleteParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + AnnotationQueueDeleteParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueDeleteResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueDeleteResponseTest.kt new file mode 100644 index 00000000..63c0af10 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueDeleteResponseTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AnnotationQueueDeleteResponseTest { + + @Test + fun create() { + val annotationQueueDeleteResponse = AnnotationQueueDeleteResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val annotationQueueDeleteResponse = AnnotationQueueDeleteResponse.builder().build() + + val roundtrippedAnnotationQueueDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(annotationQueueDeleteResponse), + jacksonTypeRef<AnnotationQueueDeleteResponse>(), + ) + + assertThat(roundtrippedAnnotationQueueDeleteResponse) + .isEqualTo(annotationQueueDeleteResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueExportParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueExportParamsTest.kt new file mode 100644 index 00000000..0906b0c8 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueExportParamsTest.kt @@ -0,0 +1,56 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AnnotationQueueExportParamsTest { + + @Test + fun create() { + AnnotationQueueExportParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + } + + @Test + fun pathParams() { + val params = + AnnotationQueueExportParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + AnnotationQueueExportParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val body = params._body() + + assertThat(body.endTime()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(body.startTime()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + AnnotationQueueExportParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueExportResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueExportResponseTest.kt new file mode 100644 index 00000000..00885a59 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueExportResponseTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AnnotationQueueExportResponseTest { + + @Test + fun create() { + val annotationQueueExportResponse = AnnotationQueueExportResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val annotationQueueExportResponse = AnnotationQueueExportResponse.builder().build() + + val roundtrippedAnnotationQueueExportResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(annotationQueueExportResponse), + jacksonTypeRef<AnnotationQueueExportResponse>(), + ) + + assertThat(roundtrippedAnnotationQueueExportResponse) + .isEqualTo(annotationQueueExportResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueuePopulateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueuePopulateParamsTest.kt new file mode 100644 index 00000000..b7867108 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueuePopulateParamsTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AnnotationQueuePopulateParamsTest { + + @Test + fun create() { + AnnotationQueuePopulateParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun body() { + val params = + AnnotationQueuePopulateParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + + assertThat(body.queueId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.sessionIds()).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueuePopulateResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueuePopulateResponseTest.kt new file mode 100644 index 00000000..210c16ad --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueuePopulateResponseTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AnnotationQueuePopulateResponseTest { + + @Test + fun create() { + val annotationQueuePopulateResponse = AnnotationQueuePopulateResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val annotationQueuePopulateResponse = AnnotationQueuePopulateResponse.builder().build() + + val roundtrippedAnnotationQueuePopulateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(annotationQueuePopulateResponse), + jacksonTypeRef<AnnotationQueuePopulateResponse>(), + ) + + assertThat(roundtrippedAnnotationQueuePopulateResponse) + .isEqualTo(annotationQueuePopulateResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveAnnotationQueuesParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveAnnotationQueuesParamsTest.kt new file mode 100644 index 00000000..4e596c00 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveAnnotationQueuesParamsTest.kt @@ -0,0 +1,64 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AnnotationQueueRetrieveAnnotationQueuesParamsTest { + + @Test + fun create() { + AnnotationQueueRetrieveAnnotationQueuesParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .name("name") + .nameContains("name_contains") + .offset(0L) + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun queryParams() { + val params = + AnnotationQueueRetrieveAnnotationQueuesParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .name("name") + .nameContains("name_contains") + .offset(0L) + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("dataset_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("ids", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").joinToString(",")) + .put("limit", "1") + .put("name", "name") + .put("name_contains", "name_contains") + .put("offset", "0") + .put( + "tag_value_id", + listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").joinToString(","), + ) + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = AnnotationQueueRetrieveAnnotationQueuesParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveAnnotationQueuesResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveAnnotationQueuesResponseTest.kt new file mode 100644 index 00000000..6d0caf4a --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveAnnotationQueuesResponseTest.kt @@ -0,0 +1,87 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AnnotationQueueRetrieveAnnotationQueuesResponseTest { + + @Test + fun create() { + val annotationQueueRetrieveAnnotationQueuesResponse = + AnnotationQueueRetrieveAnnotationQueuesResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .totalRuns(0L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .defaultDataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .enableReservations(true) + .numReviewersPerItem(0L) + .reservationMinutes(0L) + .runRuleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sourceRuleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(annotationQueueRetrieveAnnotationQueuesResponse.id()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(annotationQueueRetrieveAnnotationQueuesResponse.name()).isEqualTo("name") + assertThat(annotationQueueRetrieveAnnotationQueuesResponse.tenantId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(annotationQueueRetrieveAnnotationQueuesResponse.totalRuns()).isEqualTo(0L) + assertThat(annotationQueueRetrieveAnnotationQueuesResponse.createdAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(annotationQueueRetrieveAnnotationQueuesResponse.defaultDataset()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(annotationQueueRetrieveAnnotationQueuesResponse.description()) + .contains("description") + assertThat(annotationQueueRetrieveAnnotationQueuesResponse.enableReservations()) + .contains(true) + assertThat(annotationQueueRetrieveAnnotationQueuesResponse.numReviewersPerItem()) + .contains(0L) + assertThat(annotationQueueRetrieveAnnotationQueuesResponse.reservationMinutes()) + .contains(0L) + assertThat(annotationQueueRetrieveAnnotationQueuesResponse.runRuleId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(annotationQueueRetrieveAnnotationQueuesResponse.sourceRuleId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(annotationQueueRetrieveAnnotationQueuesResponse.updatedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val annotationQueueRetrieveAnnotationQueuesResponse = + AnnotationQueueRetrieveAnnotationQueuesResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .totalRuns(0L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .defaultDataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .enableReservations(true) + .numReviewersPerItem(0L) + .reservationMinutes(0L) + .runRuleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sourceRuleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedAnnotationQueueRetrieveAnnotationQueuesResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(annotationQueueRetrieveAnnotationQueuesResponse), + jacksonTypeRef<AnnotationQueueRetrieveAnnotationQueuesResponse>(), + ) + + assertThat(roundtrippedAnnotationQueueRetrieveAnnotationQueuesResponse) + .isEqualTo(annotationQueueRetrieveAnnotationQueuesResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveParamsTest.kt new file mode 100644 index 00000000..339ab129 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveParamsTest.kt @@ -0,0 +1,61 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AnnotationQueueRetrieveParamsTest { + + @Test + fun create() { + AnnotationQueueRetrieveParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .index(0L) + .includeExtra(true) + .build() + } + + @Test + fun pathParams() { + val params = + AnnotationQueueRetrieveParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .index(0L) + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._pathParam(1)).isEqualTo("0") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + AnnotationQueueRetrieveParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .index(0L) + .includeExtra(true) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("include_extra", "true").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + AnnotationQueueRetrieveParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .index(0L) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveQueuesParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveQueuesParamsTest.kt new file mode 100644 index 00000000..29acd88d --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveQueuesParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AnnotationQueueRetrieveQueuesParamsTest { + + @Test + fun create() { + AnnotationQueueRetrieveQueuesParams.builder() + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + AnnotationQueueRetrieveQueuesParams.builder() + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveSizeParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveSizeParamsTest.kt new file mode 100644 index 00000000..8992471b --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveSizeParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AnnotationQueueRetrieveSizeParamsTest { + + @Test + fun create() { + AnnotationQueueRetrieveSizeParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + AnnotationQueueRetrieveSizeParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveTotalArchivedParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveTotalArchivedParamsTest.kt new file mode 100644 index 00000000..012712bc --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveTotalArchivedParamsTest.kt @@ -0,0 +1,64 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +import com.langsmith_api.api.core.http.QueryParams +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AnnotationQueueRetrieveTotalArchivedParamsTest { + + @Test + fun create() { + AnnotationQueueRetrieveTotalArchivedParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + } + + @Test + fun pathParams() { + val params = + AnnotationQueueRetrieveTotalArchivedParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + AnnotationQueueRetrieveTotalArchivedParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("end_time", "2019-12-27T18:11:19.117Z") + .put("start_time", "2019-12-27T18:11:19.117Z") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + AnnotationQueueRetrieveTotalArchivedParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveTotalSizeParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveTotalSizeParamsTest.kt new file mode 100644 index 00000000..554b5e0b --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRetrieveTotalSizeParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AnnotationQueueRetrieveTotalSizeParamsTest { + + @Test + fun create() { + AnnotationQueueRetrieveTotalSizeParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + AnnotationQueueRetrieveTotalSizeParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRubricItemSchemaTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRubricItemSchemaTest.kt new file mode 100644 index 00000000..f92da6c1 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueRubricItemSchemaTest.kt @@ -0,0 +1,75 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AnnotationQueueRubricItemSchemaTest { + + @Test + fun create() { + val annotationQueueRubricItemSchema = + AnnotationQueueRubricItemSchema.builder() + .feedbackKey("feedback_key") + .description("description") + .scoreDescriptions( + AnnotationQueueRubricItemSchema.ScoreDescriptions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .valueDescriptions( + AnnotationQueueRubricItemSchema.ValueDescriptions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + + assertThat(annotationQueueRubricItemSchema.feedbackKey()).isEqualTo("feedback_key") + assertThat(annotationQueueRubricItemSchema.description()).contains("description") + assertThat(annotationQueueRubricItemSchema.scoreDescriptions()) + .contains( + AnnotationQueueRubricItemSchema.ScoreDescriptions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(annotationQueueRubricItemSchema.valueDescriptions()) + .contains( + AnnotationQueueRubricItemSchema.ValueDescriptions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val annotationQueueRubricItemSchema = + AnnotationQueueRubricItemSchema.builder() + .feedbackKey("feedback_key") + .description("description") + .scoreDescriptions( + AnnotationQueueRubricItemSchema.ScoreDescriptions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .valueDescriptions( + AnnotationQueueRubricItemSchema.ValueDescriptions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + + val roundtrippedAnnotationQueueRubricItemSchema = + jsonMapper.readValue( + jsonMapper.writeValueAsString(annotationQueueRubricItemSchema), + jacksonTypeRef<AnnotationQueueRubricItemSchema>(), + ) + + assertThat(roundtrippedAnnotationQueueRubricItemSchema) + .isEqualTo(annotationQueueRubricItemSchema) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueSchemaTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueSchemaTest.kt new file mode 100644 index 00000000..ca9343f1 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueSchemaTest.kt @@ -0,0 +1,78 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AnnotationQueueSchemaTest { + + @Test + fun create() { + val annotationQueueSchema = + AnnotationQueueSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .defaultDataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .enableReservations(true) + .numReviewersPerItem(0L) + .reservationMinutes(0L) + .runRuleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sourceRuleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(annotationQueueSchema.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(annotationQueueSchema.name()).isEqualTo("name") + assertThat(annotationQueueSchema.tenantId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(annotationQueueSchema.createdAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(annotationQueueSchema.defaultDataset()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(annotationQueueSchema.description()).contains("description") + assertThat(annotationQueueSchema.enableReservations()).contains(true) + assertThat(annotationQueueSchema.numReviewersPerItem()).contains(0L) + assertThat(annotationQueueSchema.reservationMinutes()).contains(0L) + assertThat(annotationQueueSchema.runRuleId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(annotationQueueSchema.sourceRuleId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(annotationQueueSchema.updatedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val annotationQueueSchema = + AnnotationQueueSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .defaultDataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .enableReservations(true) + .numReviewersPerItem(0L) + .reservationMinutes(0L) + .runRuleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sourceRuleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedAnnotationQueueSchema = + jsonMapper.readValue( + jsonMapper.writeValueAsString(annotationQueueSchema), + jacksonTypeRef<AnnotationQueueSchema>(), + ) + + assertThat(roundtrippedAnnotationQueueSchema).isEqualTo(annotationQueueSchema) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueSizeSchemaTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueSizeSchemaTest.kt new file mode 100644 index 00000000..ebc3108c --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueSizeSchemaTest.kt @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AnnotationQueueSizeSchemaTest { + + @Test + fun create() { + val annotationQueueSizeSchema = AnnotationQueueSizeSchema.builder().size(0L).build() + + assertThat(annotationQueueSizeSchema.size()).isEqualTo(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val annotationQueueSizeSchema = AnnotationQueueSizeSchema.builder().size(0L).build() + + val roundtrippedAnnotationQueueSizeSchema = + jsonMapper.readValue( + jsonMapper.writeValueAsString(annotationQueueSizeSchema), + jacksonTypeRef<AnnotationQueueSizeSchema>(), + ) + + assertThat(roundtrippedAnnotationQueueSizeSchema).isEqualTo(annotationQueueSizeSchema) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueUpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueUpdateParamsTest.kt new file mode 100644 index 00000000..e3ddcf06 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueUpdateParamsTest.kt @@ -0,0 +1,57 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AnnotationQueueUpdateParamsTest { + + @Test + fun create() { + AnnotationQueueUpdateParams.builder() + .annotationQueueRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .overrideAddedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status("status") + .build() + } + + @Test + fun pathParams() { + val params = + AnnotationQueueUpdateParams.builder() + .annotationQueueRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + AnnotationQueueUpdateParams.builder() + .annotationQueueRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .overrideAddedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status("status") + .build() + + val body = params._body() + + assertThat(body.overrideAddedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(body.status()).contains("status") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + AnnotationQueueUpdateParams.builder() + .annotationQueueRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueUpdateResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueUpdateResponseTest.kt new file mode 100644 index 00000000..bf621dcc --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/AnnotationQueueUpdateResponseTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AnnotationQueueUpdateResponseTest { + + @Test + fun create() { + val annotationQueueUpdateResponse = AnnotationQueueUpdateResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val annotationQueueUpdateResponse = AnnotationQueueUpdateResponse.builder().build() + + val roundtrippedAnnotationQueueUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(annotationQueueUpdateResponse), + jacksonTypeRef<AnnotationQueueUpdateResponse>(), + ) + + assertThat(roundtrippedAnnotationQueueUpdateResponse) + .isEqualTo(annotationQueueUpdateResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/RunSchemaWithAnnotationQueueInfoTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/RunSchemaWithAnnotationQueueInfoTest.kt new file mode 100644 index 00000000..d8b1d87f --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/RunSchemaWithAnnotationQueueInfoTest.kt @@ -0,0 +1,312 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TraceTier +import com.langsmith_api.api.models.api.v1.runs.RunTypeEnum +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunSchemaWithAnnotationQueueInfoTest { + + @Test + fun create() { + val runSchemaWithAnnotationQueueInfo = + RunSchemaWithAnnotationQueueInfo.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .appPath("app_path") + .dottedOrder("dotted_order") + .name("name") + .queueRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runType(RunTypeEnum.TOOL) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status("status") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost("completion_cost") + .completionCostDetails( + RunSchemaWithAnnotationQueueInfo.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .completionTokenDetails( + RunSchemaWithAnnotationQueueInfo.CompletionTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .completionTokens(0L) + .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .effectiveAddedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error("error") + .addEvent(JsonValue.from(mapOf<String, Any>())) + .executionOrder(1L) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats( + RunSchemaWithAnnotationQueueInfo.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf<String, Any>())) + .build() + ) + .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inDataset(true) + .inputs(JsonValue.from(mapOf<String, Any>())) + .inputsPreview("inputs_preview") + .inputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .lastQueuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lastReviewedTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .outputs(JsonValue.from(mapOf<String, Any>())) + .outputsPreview("outputs_preview") + .outputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .promptCost("prompt_cost") + .promptCostDetails( + RunSchemaWithAnnotationQueueInfo.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .promptTokenDetails( + RunSchemaWithAnnotationQueueInfo.PromptTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .promptTokens(0L) + .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .s3Urls(JsonValue.from(mapOf<String, Any>())) + .serialized(JsonValue.from(mapOf<String, Any>())) + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTag("string") + .threadId("thread_id") + .totalCost("total_cost") + .totalTokens(0L) + .traceFirstReceivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceTier(TraceTier.LONGLIVED) + .traceUpgrade(true) + .ttlSeconds(0L) + .build() + + assertThat(runSchemaWithAnnotationQueueInfo.id()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchemaWithAnnotationQueueInfo.appPath()).isEqualTo("app_path") + assertThat(runSchemaWithAnnotationQueueInfo.dottedOrder()).isEqualTo("dotted_order") + assertThat(runSchemaWithAnnotationQueueInfo.name()).isEqualTo("name") + assertThat(runSchemaWithAnnotationQueueInfo.queueRunId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchemaWithAnnotationQueueInfo.runType()).isEqualTo(RunTypeEnum.TOOL) + assertThat(runSchemaWithAnnotationQueueInfo.sessionId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchemaWithAnnotationQueueInfo.status()).isEqualTo("status") + assertThat(runSchemaWithAnnotationQueueInfo.traceId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchemaWithAnnotationQueueInfo.addedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runSchemaWithAnnotationQueueInfo.childRunIds().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchemaWithAnnotationQueueInfo.completionCost()).contains("completion_cost") + assertThat(runSchemaWithAnnotationQueueInfo.completionCostDetails()) + .contains( + RunSchemaWithAnnotationQueueInfo.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(runSchemaWithAnnotationQueueInfo.completionTokenDetails()) + .contains( + RunSchemaWithAnnotationQueueInfo.CompletionTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + assertThat(runSchemaWithAnnotationQueueInfo.completionTokens()).contains(0L) + assertThat(runSchemaWithAnnotationQueueInfo.directChildRunIds().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchemaWithAnnotationQueueInfo.effectiveAddedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runSchemaWithAnnotationQueueInfo.endTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runSchemaWithAnnotationQueueInfo.error()).contains("error") + assertThat(runSchemaWithAnnotationQueueInfo.events().getOrNull()) + .containsExactly(JsonValue.from(mapOf<String, Any>())) + assertThat(runSchemaWithAnnotationQueueInfo.executionOrder()).contains(1L) + assertThat(runSchemaWithAnnotationQueueInfo._extra()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(runSchemaWithAnnotationQueueInfo.feedbackStats()) + .contains( + RunSchemaWithAnnotationQueueInfo.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf<String, Any>())) + .build() + ) + assertThat(runSchemaWithAnnotationQueueInfo.firstTokenTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runSchemaWithAnnotationQueueInfo.inDataset()).contains(true) + assertThat(runSchemaWithAnnotationQueueInfo._inputs()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(runSchemaWithAnnotationQueueInfo.inputsPreview()).contains("inputs_preview") + assertThat(runSchemaWithAnnotationQueueInfo._inputsS3Urls()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(runSchemaWithAnnotationQueueInfo.lastQueuedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runSchemaWithAnnotationQueueInfo.lastReviewedTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runSchemaWithAnnotationQueueInfo.manifestId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchemaWithAnnotationQueueInfo.manifestS3Id()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchemaWithAnnotationQueueInfo._outputs()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(runSchemaWithAnnotationQueueInfo.outputsPreview()).contains("outputs_preview") + assertThat(runSchemaWithAnnotationQueueInfo._outputsS3Urls()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(runSchemaWithAnnotationQueueInfo.parentRunId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchemaWithAnnotationQueueInfo.parentRunIds().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchemaWithAnnotationQueueInfo.priceModelId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchemaWithAnnotationQueueInfo.promptCost()).contains("prompt_cost") + assertThat(runSchemaWithAnnotationQueueInfo.promptCostDetails()) + .contains( + RunSchemaWithAnnotationQueueInfo.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(runSchemaWithAnnotationQueueInfo.promptTokenDetails()) + .contains( + RunSchemaWithAnnotationQueueInfo.PromptTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + assertThat(runSchemaWithAnnotationQueueInfo.promptTokens()).contains(0L) + assertThat(runSchemaWithAnnotationQueueInfo.referenceDatasetId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchemaWithAnnotationQueueInfo.referenceExampleId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchemaWithAnnotationQueueInfo._s3Urls()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(runSchemaWithAnnotationQueueInfo._serialized()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(runSchemaWithAnnotationQueueInfo.shareToken()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchemaWithAnnotationQueueInfo.startTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runSchemaWithAnnotationQueueInfo.tags().getOrNull()).containsExactly("string") + assertThat(runSchemaWithAnnotationQueueInfo.threadId()).contains("thread_id") + assertThat(runSchemaWithAnnotationQueueInfo.totalCost()).contains("total_cost") + assertThat(runSchemaWithAnnotationQueueInfo.totalTokens()).contains(0L) + assertThat(runSchemaWithAnnotationQueueInfo.traceFirstReceivedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runSchemaWithAnnotationQueueInfo.traceMaxStartTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runSchemaWithAnnotationQueueInfo.traceMinStartTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runSchemaWithAnnotationQueueInfo.traceTier()).contains(TraceTier.LONGLIVED) + assertThat(runSchemaWithAnnotationQueueInfo.traceUpgrade()).contains(true) + assertThat(runSchemaWithAnnotationQueueInfo.ttlSeconds()).contains(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val runSchemaWithAnnotationQueueInfo = + RunSchemaWithAnnotationQueueInfo.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .appPath("app_path") + .dottedOrder("dotted_order") + .name("name") + .queueRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runType(RunTypeEnum.TOOL) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status("status") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost("completion_cost") + .completionCostDetails( + RunSchemaWithAnnotationQueueInfo.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .completionTokenDetails( + RunSchemaWithAnnotationQueueInfo.CompletionTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .completionTokens(0L) + .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .effectiveAddedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error("error") + .addEvent(JsonValue.from(mapOf<String, Any>())) + .executionOrder(1L) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats( + RunSchemaWithAnnotationQueueInfo.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf<String, Any>())) + .build() + ) + .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inDataset(true) + .inputs(JsonValue.from(mapOf<String, Any>())) + .inputsPreview("inputs_preview") + .inputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .lastQueuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lastReviewedTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .outputs(JsonValue.from(mapOf<String, Any>())) + .outputsPreview("outputs_preview") + .outputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .promptCost("prompt_cost") + .promptCostDetails( + RunSchemaWithAnnotationQueueInfo.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .promptTokenDetails( + RunSchemaWithAnnotationQueueInfo.PromptTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .promptTokens(0L) + .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .s3Urls(JsonValue.from(mapOf<String, Any>())) + .serialized(JsonValue.from(mapOf<String, Any>())) + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTag("string") + .threadId("thread_id") + .totalCost("total_cost") + .totalTokens(0L) + .traceFirstReceivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceTier(TraceTier.LONGLIVED) + .traceUpgrade(true) + .ttlSeconds(0L) + .build() + + val roundtrippedRunSchemaWithAnnotationQueueInfo = + jsonMapper.readValue( + jsonMapper.writeValueAsString(runSchemaWithAnnotationQueueInfo), + jacksonTypeRef<RunSchemaWithAnnotationQueueInfo>(), + ) + + assertThat(roundtrippedRunSchemaWithAnnotationQueueInfo) + .isEqualTo(runSchemaWithAnnotationQueueInfo) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunCreateParamsTest.kt new file mode 100644 index 00000000..81a16a1c --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunCreateParamsTest.kt @@ -0,0 +1,43 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues.runs + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunCreateParamsTest { + + @Test + fun create() { + RunCreateParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addBody("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + RunCreateParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addBody("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + RunCreateParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addBody("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + + assertThat(body).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunCreateResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunCreateResponseTest.kt new file mode 100644 index 00000000..0d011498 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunCreateResponseTest.kt @@ -0,0 +1,53 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues.runs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunCreateResponseTest { + + @Test + fun create() { + val runCreateResponse = + RunCreateResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lastReviewedTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(runCreateResponse.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runCreateResponse.queueId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runCreateResponse.runId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runCreateResponse.addedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runCreateResponse.lastReviewedTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val runCreateResponse = + RunCreateResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lastReviewedTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedRunCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(runCreateResponse), + jacksonTypeRef<RunCreateResponse>(), + ) + + assertThat(roundtrippedRunCreateResponse).isEqualTo(runCreateResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunDeleteParamsTest.kt new file mode 100644 index 00000000..12a2d8db --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunDeleteParamsTest.kt @@ -0,0 +1,57 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues.runs + +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunDeleteParamsTest { + + @Test + fun create() { + RunDeleteParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .deleteAll(true) + .addExcludeRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + RunDeleteParams.builder().queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + RunDeleteParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .deleteAll(true) + .addExcludeRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + + assertThat(body.deleteAll()).contains(true) + assertThat(body.excludeRunIds().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.runIds().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + RunDeleteParams.builder().queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + val body = params._body() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunDeleteResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunDeleteResponseTest.kt new file mode 100644 index 00000000..6784ec07 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunDeleteResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues.runs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunDeleteResponseTest { + + @Test + fun create() { + val runDeleteResponse = RunDeleteResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val runDeleteResponse = RunDeleteResponse.builder().build() + + val roundtrippedRunDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(runDeleteResponse), + jacksonTypeRef<RunDeleteResponse>(), + ) + + assertThat(roundtrippedRunDeleteResponse).isEqualTo(runDeleteResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunListParamsTest.kt new file mode 100644 index 00000000..7e47ab64 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunListParamsTest.kt @@ -0,0 +1,63 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues.runs + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunListParamsTest { + + @Test + fun create() { + RunListParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .archived(true) + .includeStats(true) + .limit(1L) + .offset(0L) + .build() + } + + @Test + fun pathParams() { + val params = RunListParams.builder().queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + RunListParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .archived(true) + .includeStats(true) + .limit(1L) + .offset(0L) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("archived", "true") + .put("include_stats", "true") + .put("limit", "1") + .put("offset", "0") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = RunListParams.builder().queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunUpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunUpdateParamsTest.kt new file mode 100644 index 00000000..f8abc028 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunUpdateParamsTest.kt @@ -0,0 +1,62 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues.runs + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunUpdateParamsTest { + + @Test + fun create() { + RunUpdateParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .queueRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lastReviewedTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + } + + @Test + fun pathParams() { + val params = + RunUpdateParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .queueRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._pathParam(1)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } + + @Test + fun body() { + val params = + RunUpdateParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .queueRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lastReviewedTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val body = params._body() + + assertThat(body.addedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(body.lastReviewedTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + RunUpdateParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .queueRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunUpdateResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunUpdateResponseTest.kt new file mode 100644 index 00000000..db7d8fa6 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/annotationqueues/runs/RunUpdateResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.annotationqueues.runs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunUpdateResponseTest { + + @Test + fun create() { + val runUpdateResponse = RunUpdateResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val runUpdateResponse = RunUpdateResponse.builder().build() + + val roundtrippedRunUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(runUpdateResponse), + jacksonTypeRef<RunUpdateResponse>(), + ) + + assertThat(roundtrippedRunUpdateResponse).isEqualTo(runUpdateResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/apikey/ApiKeyApiKeyParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/apikey/ApiKeyApiKeyParamsTest.kt new file mode 100644 index 00000000..1e645d80 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/apikey/ApiKeyApiKeyParamsTest.kt @@ -0,0 +1,69 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.apikey + +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyCreateRequest +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ApiKeyApiKeyParamsTest { + + @Test + fun create() { + ApiKeyApiKeyParams.builder() + .apiKeyCreateRequest( + ApiKeyCreateRequest.builder() + .defaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + } + + @Test + fun body() { + val params = + ApiKeyApiKeyParams.builder() + .apiKeyCreateRequest( + ApiKeyCreateRequest.builder() + .defaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + + val body = params._body().getOrNull() + + assertThat(body) + .isEqualTo( + ApiKeyCreateRequest.builder() + .defaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = ApiKeyApiKeyParams.builder().build() + + val body = params._body().getOrNull() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/apikey/ApiKeyDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/apikey/ApiKeyDeleteParamsTest.kt new file mode 100644 index 00000000..956c9914 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/apikey/ApiKeyDeleteParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.apikey + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ApiKeyDeleteParamsTest { + + @Test + fun create() { + ApiKeyDeleteParams.builder().apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + ApiKeyDeleteParams.builder().apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/apikey/ApiKeyRetrieveApiKeyParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/apikey/ApiKeyRetrieveApiKeyParamsTest.kt new file mode 100644 index 00000000..1eed0266 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/apikey/ApiKeyRetrieveApiKeyParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.apikey + +import org.junit.jupiter.api.Test + +internal class ApiKeyRetrieveApiKeyParamsTest { + + @Test + fun create() { + ApiKeyRetrieveApiKeyParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/apikey/current/CurrentCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/apikey/current/CurrentCreateParamsTest.kt new file mode 100644 index 00000000..c0ff33bd --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/apikey/current/CurrentCreateParamsTest.kt @@ -0,0 +1,69 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.apikey.current + +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyCreateRequest +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CurrentCreateParamsTest { + + @Test + fun create() { + CurrentCreateParams.builder() + .apiKeyCreateRequest( + ApiKeyCreateRequest.builder() + .defaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + } + + @Test + fun body() { + val params = + CurrentCreateParams.builder() + .apiKeyCreateRequest( + ApiKeyCreateRequest.builder() + .defaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + + val body = params._body().getOrNull() + + assertThat(body) + .isEqualTo( + ApiKeyCreateRequest.builder() + .defaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = CurrentCreateParams.builder().build() + + val body = params._body().getOrNull() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/apikey/current/CurrentDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/apikey/current/CurrentDeleteParamsTest.kt new file mode 100644 index 00000000..76657884 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/apikey/current/CurrentDeleteParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.apikey.current + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CurrentDeleteParamsTest { + + @Test + fun create() { + CurrentDeleteParams.builder().patId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + CurrentDeleteParams.builder().patId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/apikey/current/CurrentListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/apikey/current/CurrentListParamsTest.kt new file mode 100644 index 00000000..9ca7e124 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/apikey/current/CurrentListParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.apikey.current + +import org.junit.jupiter.api.Test + +internal class CurrentListParamsTest { + + @Test + fun create() { + CurrentListParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportBulkExportsParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportBulkExportsParamsTest.kt new file mode 100644 index 00000000..3db727ab --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportBulkExportsParamsTest.kt @@ -0,0 +1,66 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.bulkexports + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BulkExportBulkExportsParamsTest { + + @Test + fun create() { + BulkExportBulkExportsParams.builder() + .bulkExportDestinationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .compression(BulkExportCompression.NONE) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .format(BulkExportFormat.PARQUET) + .intervalHours(0L) + .build() + } + + @Test + fun body() { + val params = + BulkExportBulkExportsParams.builder() + .bulkExportDestinationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .compression(BulkExportCompression.NONE) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .format(BulkExportFormat.PARQUET) + .intervalHours(0L) + .build() + + val body = params._body() + + assertThat(body.bulkExportDestinationId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.sessionId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.startTime()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(body.compression()).contains(BulkExportCompression.NONE) + assertThat(body.endTime()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(body.filter()).contains("filter") + assertThat(body.format()).contains(BulkExportFormat.PARQUET) + assertThat(body.intervalHours()).contains(0L) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + BulkExportBulkExportsParams.builder() + .bulkExportDestinationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val body = params._body() + + assertThat(body.bulkExportDestinationId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.sessionId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.startTime()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportRetrieveBulkExportsParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportRetrieveBulkExportsParamsTest.kt new file mode 100644 index 00000000..fccac1f4 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportRetrieveBulkExportsParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.bulkexports + +import org.junit.jupiter.api.Test + +internal class BulkExportRetrieveBulkExportsParamsTest { + + @Test + fun create() { + BulkExportRetrieveBulkExportsParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportRetrieveParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportRetrieveParamsTest.kt new file mode 100644 index 00000000..0836a7ea --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportRetrieveParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.bulkexports + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BulkExportRetrieveParamsTest { + + @Test + fun create() { + BulkExportRetrieveParams.builder() + .bulkExportId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + BulkExportRetrieveParams.builder() + .bulkExportId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportTest.kt new file mode 100644 index 00000000..635f47fe --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportTest.kt @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.bulkexports + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BulkExportTest { + + @Test + fun create() { + val bulkExport = + BulkExport.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .bulkExportDestinationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .finishedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(BulkExport.Status.CANCELLED) + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .compression(BulkExportCompression.NONE) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .format(BulkExportFormat.PARQUET) + .intervalHours(0L) + .sourceBulkExportId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(bulkExport.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(bulkExport.bulkExportDestinationId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(bulkExport.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(bulkExport.finishedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(bulkExport.sessionId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(bulkExport.startTime()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(bulkExport.status()).isEqualTo(BulkExport.Status.CANCELLED) + assertThat(bulkExport.tenantId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(bulkExport.updatedAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(bulkExport.compression()).contains(BulkExportCompression.NONE) + assertThat(bulkExport.endTime()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(bulkExport.filter()).contains("filter") + assertThat(bulkExport.format()).contains(BulkExportFormat.PARQUET) + assertThat(bulkExport.intervalHours()).contains(0L) + assertThat(bulkExport.sourceBulkExportId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val bulkExport = + BulkExport.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .bulkExportDestinationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .finishedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(BulkExport.Status.CANCELLED) + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .compression(BulkExportCompression.NONE) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .format(BulkExportFormat.PARQUET) + .intervalHours(0L) + .sourceBulkExportId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val roundtrippedBulkExport = + jsonMapper.readValue( + jsonMapper.writeValueAsString(bulkExport), + jacksonTypeRef<BulkExport>(), + ) + + assertThat(roundtrippedBulkExport).isEqualTo(bulkExport) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportUpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportUpdateParamsTest.kt new file mode 100644 index 00000000..12bcfadd --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/BulkExportUpdateParamsTest.kt @@ -0,0 +1,38 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.bulkexports + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BulkExportUpdateParamsTest { + + @Test + fun create() { + BulkExportUpdateParams.builder() + .bulkExportId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + BulkExportUpdateParams.builder() + .bulkExportId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + BulkExportUpdateParams.builder() + .bulkExportId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/BulkExportDestinationS3ConfigTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/BulkExportDestinationS3ConfigTest.kt new file mode 100644 index 00000000..cca208b4 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/BulkExportDestinationS3ConfigTest.kt @@ -0,0 +1,53 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.bulkexports.destinations + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BulkExportDestinationS3ConfigTest { + + @Test + fun create() { + val bulkExportDestinationS3Config = + BulkExportDestinationS3Config.builder() + .bucketName("xxx") + .endpointUrl("endpoint_url") + .prefix("prefix") + .region("x") + .s3AdditionalKwargs(JsonValue.from(mapOf<String, Any>())) + .build() + + assertThat(bulkExportDestinationS3Config.bucketName()).contains("xxx") + assertThat(bulkExportDestinationS3Config.endpointUrl()).contains("endpoint_url") + assertThat(bulkExportDestinationS3Config.prefix()).contains("prefix") + assertThat(bulkExportDestinationS3Config.region()).contains("x") + assertThat(bulkExportDestinationS3Config._s3AdditionalKwargs()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val bulkExportDestinationS3Config = + BulkExportDestinationS3Config.builder() + .bucketName("xxx") + .endpointUrl("endpoint_url") + .prefix("prefix") + .region("x") + .s3AdditionalKwargs(JsonValue.from(mapOf<String, Any>())) + .build() + + val roundtrippedBulkExportDestinationS3Config = + jsonMapper.readValue( + jsonMapper.writeValueAsString(bulkExportDestinationS3Config), + jacksonTypeRef<BulkExportDestinationS3Config>(), + ) + + assertThat(roundtrippedBulkExportDestinationS3Config) + .isEqualTo(bulkExportDestinationS3Config) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/BulkExportDestinationTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/BulkExportDestinationTest.kt new file mode 100644 index 00000000..6ba00538 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/BulkExportDestinationTest.kt @@ -0,0 +1,89 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.bulkexports.destinations + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BulkExportDestinationTest { + + @Test + fun create() { + val bulkExportDestination = + BulkExportDestination.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config( + BulkExportDestinationS3Config.builder() + .bucketName("xxx") + .endpointUrl("endpoint_url") + .prefix("prefix") + .region("x") + .s3AdditionalKwargs(JsonValue.from(mapOf<String, Any>())) + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addCredentialsKey("string") + .displayName("display_name") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .destinationType(BulkExportDestinationType.S3) + .build() + + assertThat(bulkExportDestination.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(bulkExportDestination.config()) + .isEqualTo( + BulkExportDestinationS3Config.builder() + .bucketName("xxx") + .endpointUrl("endpoint_url") + .prefix("prefix") + .region("x") + .s3AdditionalKwargs(JsonValue.from(mapOf<String, Any>())) + .build() + ) + assertThat(bulkExportDestination.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(bulkExportDestination.credentialsKeys()).containsExactly("string") + assertThat(bulkExportDestination.displayName()).isEqualTo("display_name") + assertThat(bulkExportDestination.tenantId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(bulkExportDestination.updatedAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(bulkExportDestination.destinationType()).contains(BulkExportDestinationType.S3) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val bulkExportDestination = + BulkExportDestination.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config( + BulkExportDestinationS3Config.builder() + .bucketName("xxx") + .endpointUrl("endpoint_url") + .prefix("prefix") + .region("x") + .s3AdditionalKwargs(JsonValue.from(mapOf<String, Any>())) + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addCredentialsKey("string") + .displayName("display_name") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .destinationType(BulkExportDestinationType.S3) + .build() + + val roundtrippedBulkExportDestination = + jsonMapper.readValue( + jsonMapper.writeValueAsString(bulkExportDestination), + jacksonTypeRef<BulkExportDestination>(), + ) + + assertThat(roundtrippedBulkExportDestination).isEqualTo(bulkExportDestination) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/DestinationCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/DestinationCreateParamsTest.kt new file mode 100644 index 00000000..37b41366 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/DestinationCreateParamsTest.kt @@ -0,0 +1,96 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.bulkexports.destinations + +import com.langsmith_api.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DestinationCreateParamsTest { + + @Test + fun create() { + DestinationCreateParams.builder() + .config( + BulkExportDestinationS3Config.builder() + .bucketName("xxx") + .endpointUrl("endpoint_url") + .prefix("prefix") + .region("x") + .s3AdditionalKwargs(JsonValue.from(mapOf<String, Any>())) + .build() + ) + .displayName("display_name") + .credentials( + DestinationCreateParams.Credentials.builder() + .accessKeyId("x") + .secretAccessKey("x") + .sessionToken("session_token") + .build() + ) + .destinationType(BulkExportDestinationType.S3) + .build() + } + + @Test + fun body() { + val params = + DestinationCreateParams.builder() + .config( + BulkExportDestinationS3Config.builder() + .bucketName("xxx") + .endpointUrl("endpoint_url") + .prefix("prefix") + .region("x") + .s3AdditionalKwargs(JsonValue.from(mapOf<String, Any>())) + .build() + ) + .displayName("display_name") + .credentials( + DestinationCreateParams.Credentials.builder() + .accessKeyId("x") + .secretAccessKey("x") + .sessionToken("session_token") + .build() + ) + .destinationType(BulkExportDestinationType.S3) + .build() + + val body = params._body() + + assertThat(body.config()) + .isEqualTo( + BulkExportDestinationS3Config.builder() + .bucketName("xxx") + .endpointUrl("endpoint_url") + .prefix("prefix") + .region("x") + .s3AdditionalKwargs(JsonValue.from(mapOf<String, Any>())) + .build() + ) + assertThat(body.displayName()).isEqualTo("display_name") + assertThat(body.credentials()) + .contains( + DestinationCreateParams.Credentials.builder() + .accessKeyId("x") + .secretAccessKey("x") + .sessionToken("session_token") + .build() + ) + assertThat(body.destinationType()).contains(BulkExportDestinationType.S3) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + DestinationCreateParams.builder() + .config(BulkExportDestinationS3Config.builder().build()) + .displayName("display_name") + .build() + + val body = params._body() + + assertThat(body.config()).isEqualTo(BulkExportDestinationS3Config.builder().build()) + assertThat(body.displayName()).isEqualTo("display_name") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/DestinationListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/DestinationListParamsTest.kt new file mode 100644 index 00000000..c67e90f9 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/DestinationListParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.bulkexports.destinations + +import org.junit.jupiter.api.Test + +internal class DestinationListParamsTest { + + @Test + fun create() { + DestinationListParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/DestinationRetrieveParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/DestinationRetrieveParamsTest.kt new file mode 100644 index 00000000..6616382b --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/destinations/DestinationRetrieveParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.bulkexports.destinations + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DestinationRetrieveParamsTest { + + @Test + fun create() { + DestinationRetrieveParams.builder() + .destinationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + DestinationRetrieveParams.builder() + .destinationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/runs/BulkExportRunTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/runs/BulkExportRunTest.kt new file mode 100644 index 00000000..c4e24eae --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/runs/BulkExportRunTest.kt @@ -0,0 +1,110 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.bulkexports.runs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BulkExportRunTest { + + @Test + fun create() { + val bulkExportRun = + BulkExportRun.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .bulkExportId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .finishedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .metadata( + BulkExportRun.Metadata.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .prefix("prefix") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .result( + BulkExportRun.Metadata.Result.builder() + .exportPath("export_path") + .addExportedFile("string") + .latestCursor("latest_cursor") + .rowsWritten(0L) + .build() + ) + .build() + ) + .status(BulkExportRun.Status.CANCELLED) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .errors(JsonValue.from(mapOf<String, Any>())) + .retryNumber(0L) + .build() + + assertThat(bulkExportRun.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(bulkExportRun.bulkExportId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(bulkExportRun.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(bulkExportRun.finishedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(bulkExportRun.metadata()) + .isEqualTo( + BulkExportRun.Metadata.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .prefix("prefix") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .result( + BulkExportRun.Metadata.Result.builder() + .exportPath("export_path") + .addExportedFile("string") + .latestCursor("latest_cursor") + .rowsWritten(0L) + .build() + ) + .build() + ) + assertThat(bulkExportRun.status()).isEqualTo(BulkExportRun.Status.CANCELLED) + assertThat(bulkExportRun.updatedAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(bulkExportRun._errors()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(bulkExportRun.retryNumber()).contains(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val bulkExportRun = + BulkExportRun.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .bulkExportId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .finishedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .metadata( + BulkExportRun.Metadata.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .prefix("prefix") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .result( + BulkExportRun.Metadata.Result.builder() + .exportPath("export_path") + .addExportedFile("string") + .latestCursor("latest_cursor") + .rowsWritten(0L) + .build() + ) + .build() + ) + .status(BulkExportRun.Status.CANCELLED) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .errors(JsonValue.from(mapOf<String, Any>())) + .retryNumber(0L) + .build() + + val roundtrippedBulkExportRun = + jsonMapper.readValue( + jsonMapper.writeValueAsString(bulkExportRun), + jacksonTypeRef<BulkExportRun>(), + ) + + assertThat(roundtrippedBulkExportRun).isEqualTo(bulkExportRun) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/runs/RunListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/runs/RunListParamsTest.kt new file mode 100644 index 00000000..f9547e7e --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/runs/RunListParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.bulkexports.runs + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunListParamsTest { + + @Test + fun create() { + RunListParams.builder().bulkExportId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + RunListParams.builder().bulkExportId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/runs/RunRetrieveParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/runs/RunRetrieveParamsTest.kt new file mode 100644 index 00000000..efe3c5e2 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/bulkexports/runs/RunRetrieveParamsTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.bulkexports.runs + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunRetrieveParamsTest { + + @Test + fun create() { + RunRetrieveParams.builder() + .bulkExportId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + RunRetrieveParams.builder() + .bulkExportId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._pathParam(1)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartCreateParamsTest.kt new file mode 100644 index 00000000..8511bcd7 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartCreateParamsTest.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.sessions.RunStatsGroupBy +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ChartCreateParamsTest { + + @Test + fun create() { + ChartCreateParams.builder() + .customChartCreate( + CustomChartCreate.builder() + .chartType(CustomChartType.LINE) + .addSeries( + CustomChartCreate.Series.builder() + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .title("title") + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("description") + .index(0L) + .metadata(JsonValue.from(mapOf<String, Any>())) + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + } + + @Test + fun body() { + val params = + ChartCreateParams.builder() + .customChartCreate( + CustomChartCreate.builder() + .chartType(CustomChartType.LINE) + .addSeries( + CustomChartCreate.Series.builder() + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .title("title") + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("description") + .index(0L) + .metadata(JsonValue.from(mapOf<String, Any>())) + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + CustomChartCreate.builder() + .chartType(CustomChartType.LINE) + .addSeries( + CustomChartCreate.Series.builder() + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .title("title") + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("description") + .index(0L) + .metadata(JsonValue.from(mapOf<String, Any>())) + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + ChartCreateParams.builder() + .customChartCreate( + CustomChartCreate.builder() + .chartType(CustomChartType.LINE) + .addSeries( + CustomChartCreate.Series.builder() + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .build() + ) + .title("title") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + CustomChartCreate.builder() + .chartType(CustomChartType.LINE) + .addSeries( + CustomChartCreate.Series.builder() + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .build() + ) + .title("title") + .build() + ) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartDeleteParamsTest.kt new file mode 100644 index 00000000..e09ef928 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartDeleteParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ChartDeleteParamsTest { + + @Test + fun create() { + ChartDeleteParams.builder().chartId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + ChartDeleteParams.builder().chartId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartDeleteResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartDeleteResponseTest.kt new file mode 100644 index 00000000..1a756020 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartDeleteResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ChartDeleteResponseTest { + + @Test + fun create() { + val chartDeleteResponse = ChartDeleteResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val chartDeleteResponse = ChartDeleteResponse.builder().build() + + val roundtrippedChartDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(chartDeleteResponse), + jacksonTypeRef<ChartDeleteResponse>(), + ) + + assertThat(roundtrippedChartDeleteResponse).isEqualTo(chartDeleteResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartPreviewParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartPreviewParamsTest.kt new file mode 100644 index 00000000..e1fcb367 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartPreviewParamsTest.kt @@ -0,0 +1,227 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts + +import com.langsmith_api.api.models.api.v1.orgcharts.section.CustomChartsRequestBase +import com.langsmith_api.api.models.api.v1.sessions.TimedeltaInput +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ChartPreviewParamsTest { + + @Test + fun create() { + ChartPreviewParams.builder() + .customChartPreviewRequest( + CustomChartPreviewRequest.builder() + .bucketInfo( + CustomChartsRequestBase.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride(TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build()) + .timezone("timezone") + .build() + ) + .chart( + CustomChartPreviewRequest.Chart.builder() + .addSeries( + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + CustomChartSeries.GroupBy.builder() + .attribute(CustomChartSeries.GroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .setBy(CustomChartSeries.GroupBy.SetBy.SECTION) + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .build() + ) + .build() + ) + .build() + } + + @Test + fun body() { + val params = + ChartPreviewParams.builder() + .customChartPreviewRequest( + CustomChartPreviewRequest.builder() + .bucketInfo( + CustomChartsRequestBase.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride( + TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build() + ) + .timezone("timezone") + .build() + ) + .chart( + CustomChartPreviewRequest.Chart.builder() + .addSeries( + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + CustomChartSeries.GroupBy.builder() + .attribute(CustomChartSeries.GroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .setBy(CustomChartSeries.GroupBy.SetBy.SECTION) + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .build() + ) + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + CustomChartPreviewRequest.builder() + .bucketInfo( + CustomChartsRequestBase.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride(TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build()) + .timezone("timezone") + .build() + ) + .chart( + CustomChartPreviewRequest.Chart.builder() + .addSeries( + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + CustomChartSeries.GroupBy.builder() + .attribute(CustomChartSeries.GroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .setBy(CustomChartSeries.GroupBy.SetBy.SECTION) + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .build() + ) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + ChartPreviewParams.builder() + .customChartPreviewRequest( + CustomChartPreviewRequest.builder() + .bucketInfo(CustomChartsRequestBase.builder().build()) + .chart( + CustomChartPreviewRequest.Chart.builder() + .addSeries( + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .build() + ) + .build() + ) + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + CustomChartPreviewRequest.builder() + .bucketInfo(CustomChartsRequestBase.builder().build()) + .chart( + CustomChartPreviewRequest.Chart.builder() + .addSeries( + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .build() + ) + .build() + ) + .build() + ) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartUpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartUpdateParamsTest.kt new file mode 100644 index 00000000..92fc4d43 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/ChartUpdateParamsTest.kt @@ -0,0 +1,191 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.sessions.RunStatsGroupBy +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ChartUpdateParamsTest { + + @Test + fun create() { + ChartUpdateParams.builder() + .chartId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .customChartUpdate( + CustomChartUpdate.builder() + .chartType(CustomChartType.LINE) + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("string") + .index(0L) + .metadata(JsonValue.from(mapOf<String, Any>())) + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .seriesOfCustomChartSeriesUpdates( + listOf( + CustomChartUpdate.Series.CustomChartSeriesUpdate.builder() + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + ) + .title("string") + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + ChartUpdateParams.builder() + .chartId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .customChartUpdate(CustomChartUpdate.builder().build()) + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + ChartUpdateParams.builder() + .chartId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .customChartUpdate( + CustomChartUpdate.builder() + .chartType(CustomChartType.LINE) + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("string") + .index(0L) + .metadata(JsonValue.from(mapOf<String, Any>())) + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .seriesOfCustomChartSeriesUpdates( + listOf( + CustomChartUpdate.Series.CustomChartSeriesUpdate.builder() + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + ) + .title("string") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + CustomChartUpdate.builder() + .chartType(CustomChartType.LINE) + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("string") + .index(0L) + .metadata(JsonValue.from(mapOf<String, Any>())) + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .seriesOfCustomChartSeriesUpdates( + listOf( + CustomChartUpdate.Series.CustomChartSeriesUpdate.builder() + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + ) + .title("string") + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + ChartUpdateParams.builder() + .chartId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .customChartUpdate(CustomChartUpdate.builder().build()) + .build() + + val body = params._body() + + assertThat(body).isEqualTo(CustomChartUpdate.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartCreateTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartCreateTest.kt new file mode 100644 index 00000000..5d27b34f --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartCreateTest.kt @@ -0,0 +1,153 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.sessions.RunStatsGroupBy +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CustomChartCreateTest { + + @Test + fun create() { + val customChartCreate = + CustomChartCreate.builder() + .chartType(CustomChartType.LINE) + .addSeries( + CustomChartCreate.Series.builder() + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .title("title") + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("description") + .index(0L) + .metadata(JsonValue.from(mapOf<String, Any>())) + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(customChartCreate.chartType()).isEqualTo(CustomChartType.LINE) + assertThat(customChartCreate.series()) + .containsExactly( + CustomChartCreate.Series.builder() + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + assertThat(customChartCreate.title()).isEqualTo("title") + assertThat(customChartCreate.commonFilters()) + .contains( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + assertThat(customChartCreate.description()).contains("description") + assertThat(customChartCreate.index()).contains(0L) + assertThat(customChartCreate._metadata()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(customChartCreate.sectionId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customChartCreate = + CustomChartCreate.builder() + .chartType(CustomChartType.LINE) + .addSeries( + CustomChartCreate.Series.builder() + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .title("title") + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("description") + .index(0L) + .metadata(JsonValue.from(mapOf<String, Any>())) + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val roundtrippedCustomChartCreate = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customChartCreate), + jacksonTypeRef<CustomChartCreate>(), + ) + + assertThat(roundtrippedCustomChartCreate).isEqualTo(customChartCreate) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartPreviewRequestTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartPreviewRequestTest.kt new file mode 100644 index 00000000..f49135b4 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartPreviewRequestTest.kt @@ -0,0 +1,181 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.orgcharts.section.CustomChartsRequestBase +import com.langsmith_api.api.models.api.v1.sessions.TimedeltaInput +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CustomChartPreviewRequestTest { + + @Test + fun create() { + val customChartPreviewRequest = + CustomChartPreviewRequest.builder() + .bucketInfo( + CustomChartsRequestBase.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride(TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build()) + .timezone("timezone") + .build() + ) + .chart( + CustomChartPreviewRequest.Chart.builder() + .addSeries( + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + CustomChartSeries.GroupBy.builder() + .attribute(CustomChartSeries.GroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .setBy(CustomChartSeries.GroupBy.SetBy.SECTION) + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .build() + ) + .build() + + assertThat(customChartPreviewRequest.bucketInfo()) + .isEqualTo( + CustomChartsRequestBase.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride(TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build()) + .timezone("timezone") + .build() + ) + assertThat(customChartPreviewRequest.chart()) + .isEqualTo( + CustomChartPreviewRequest.Chart.builder() + .addSeries( + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + CustomChartSeries.GroupBy.builder() + .attribute(CustomChartSeries.GroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .setBy(CustomChartSeries.GroupBy.SetBy.SECTION) + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customChartPreviewRequest = + CustomChartPreviewRequest.builder() + .bucketInfo( + CustomChartsRequestBase.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride(TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build()) + .timezone("timezone") + .build() + ) + .chart( + CustomChartPreviewRequest.Chart.builder() + .addSeries( + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + CustomChartSeries.GroupBy.builder() + .attribute(CustomChartSeries.GroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .setBy(CustomChartSeries.GroupBy.SetBy.SECTION) + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .build() + ) + .build() + + val roundtrippedCustomChartPreviewRequest = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customChartPreviewRequest), + jacksonTypeRef<CustomChartPreviewRequest>(), + ) + + assertThat(roundtrippedCustomChartPreviewRequest).isEqualTo(customChartPreviewRequest) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartResponseTest.kt new file mode 100644 index 00000000..748a3cc6 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartResponseTest.kt @@ -0,0 +1,138 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CustomChartResponseTest { + + @Test + fun create() { + val customChartResponse = + CustomChartResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .chartType(CustomChartType.LINE) + .index(0L) + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addSeries( + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + CustomChartSeries.GroupBy.builder() + .attribute(CustomChartSeries.GroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .setBy(CustomChartSeries.GroupBy.SetBy.SECTION) + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .title("title") + .description("description") + .metadata(JsonValue.from(mapOf<String, Any>())) + .build() + + assertThat(customChartResponse.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(customChartResponse.chartType()).isEqualTo(CustomChartType.LINE) + assertThat(customChartResponse.index()).isEqualTo(0L) + assertThat(customChartResponse.sectionId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(customChartResponse.series().getOrNull()) + .containsExactly( + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + CustomChartSeries.GroupBy.builder() + .attribute(CustomChartSeries.GroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .setBy(CustomChartSeries.GroupBy.SetBy.SECTION) + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + assertThat(customChartResponse.title()).isEqualTo("title") + assertThat(customChartResponse.description()).contains("description") + assertThat(customChartResponse._metadata()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customChartResponse = + CustomChartResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .chartType(CustomChartType.LINE) + .index(0L) + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addSeries( + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + CustomChartSeries.GroupBy.builder() + .attribute(CustomChartSeries.GroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .setBy(CustomChartSeries.GroupBy.SetBy.SECTION) + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .title("title") + .description("description") + .metadata(JsonValue.from(mapOf<String, Any>())) + .build() + + val roundtrippedCustomChartResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customChartResponse), + jacksonTypeRef<CustomChartResponse>(), + ) + + assertThat(roundtrippedCustomChartResponse).isEqualTo(customChartResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartSeriesFiltersTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartSeriesFiltersTest.kt new file mode 100644 index 00000000..1150091f --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartSeriesFiltersTest.kt @@ -0,0 +1,49 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CustomChartSeriesFiltersTest { + + @Test + fun create() { + val customChartSeriesFilters = + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + + assertThat(customChartSeriesFilters.filter()).contains("filter") + assertThat(customChartSeriesFilters.session().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(customChartSeriesFilters.traceFilter()).contains("trace_filter") + assertThat(customChartSeriesFilters.treeFilter()).contains("tree_filter") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customChartSeriesFilters = + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + + val roundtrippedCustomChartSeriesFilters = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customChartSeriesFilters), + jacksonTypeRef<CustomChartSeriesFilters>(), + ) + + assertThat(roundtrippedCustomChartSeriesFilters).isEqualTo(customChartSeriesFilters) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartSeriesTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartSeriesTest.kt new file mode 100644 index 00000000..c0cddadc --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartSeriesTest.kt @@ -0,0 +1,103 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CustomChartSeriesTest { + + @Test + fun create() { + val customChartSeries = + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + CustomChartSeries.GroupBy.builder() + .attribute(CustomChartSeries.GroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .setBy(CustomChartSeries.GroupBy.SetBy.SECTION) + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(customChartSeries.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(customChartSeries.metric()).isEqualTo(CustomChartMetric.RUN_COUNT) + assertThat(customChartSeries.name()).isEqualTo("name") + assertThat(customChartSeries.feedbackKey()).contains("feedback_key") + assertThat(customChartSeries.filters()) + .contains( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + assertThat(customChartSeries.groupBy()) + .contains( + CustomChartSeries.GroupBy.builder() + .attribute(CustomChartSeries.GroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .setBy(CustomChartSeries.GroupBy.SetBy.SECTION) + .build() + ) + assertThat(customChartSeries.projectMetric()).contains(HostProjectChartMetric.MEMORY_USAGE) + assertThat(customChartSeries.workspaceId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customChartSeries = + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + CustomChartSeries.GroupBy.builder() + .attribute(CustomChartSeries.GroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .setBy(CustomChartSeries.GroupBy.SetBy.SECTION) + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val roundtrippedCustomChartSeries = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customChartSeries), + jacksonTypeRef<CustomChartSeries>(), + ) + + assertThat(roundtrippedCustomChartSeries).isEqualTo(customChartSeries) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartUpdateTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartUpdateTest.kt new file mode 100644 index 00000000..bd1c05f7 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartUpdateTest.kt @@ -0,0 +1,170 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.sessions.RunStatsGroupBy +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CustomChartUpdateTest { + + @Test + fun create() { + val customChartUpdate = + CustomChartUpdate.builder() + .chartType(CustomChartType.LINE) + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("string") + .index(0L) + .metadata(JsonValue.from(mapOf<String, Any>())) + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .seriesOfCustomChartSeriesUpdates( + listOf( + CustomChartUpdate.Series.CustomChartSeriesUpdate.builder() + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + ) + .title("string") + .build() + + assertThat(customChartUpdate.chartType()) + .contains(CustomChartUpdate.ChartType.ofCustom(CustomChartType.LINE)) + assertThat(customChartUpdate.commonFilters()) + .contains( + CustomChartUpdate.CommonFilters.ofCustomChartSeries( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + ) + assertThat(customChartUpdate.description()) + .contains(CustomChartUpdate.Description.ofString("string")) + assertThat(customChartUpdate.index()).contains(CustomChartUpdate.Index.ofInteger(0L)) + assertThat(customChartUpdate.metadata()) + .contains(CustomChartUpdate.Metadata.ofJsonValue(JsonValue.from(mapOf<String, Any>()))) + assertThat(customChartUpdate.sectionId()) + .contains(CustomChartUpdate.SectionId.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(customChartUpdate.series()) + .contains( + CustomChartUpdate.Series.ofCustomChartSeriesUpdates( + listOf( + CustomChartUpdate.Series.CustomChartSeriesUpdate.builder() + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + ) + ) + assertThat(customChartUpdate.title()).contains(CustomChartUpdate.Title.ofString("string")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customChartUpdate = + CustomChartUpdate.builder() + .chartType(CustomChartType.LINE) + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("string") + .index(0L) + .metadata(JsonValue.from(mapOf<String, Any>())) + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .seriesOfCustomChartSeriesUpdates( + listOf( + CustomChartUpdate.Series.CustomChartSeriesUpdate.builder() + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + ) + .title("string") + .build() + + val roundtrippedCustomChartUpdate = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customChartUpdate), + jacksonTypeRef<CustomChartUpdate>(), + ) + + assertThat(roundtrippedCustomChartUpdate).isEqualTo(customChartUpdate) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartsDataPointTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartsDataPointTest.kt new file mode 100644 index 00000000..6e526922 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartsDataPointTest.kt @@ -0,0 +1,50 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CustomChartsDataPointTest { + + @Test + fun create() { + val customChartsDataPoint = + CustomChartsDataPoint.builder() + .seriesId("series_id") + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .value(0.0) + .group("group") + .build() + + assertThat(customChartsDataPoint.seriesId()).isEqualTo("series_id") + assertThat(customChartsDataPoint.timestamp()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(customChartsDataPoint.value()) + .contains(CustomChartsDataPoint.Value.ofNumber(0.0)) + assertThat(customChartsDataPoint.group()).contains("group") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customChartsDataPoint = + CustomChartsDataPoint.builder() + .seriesId("series_id") + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .value(0.0) + .group("group") + .build() + + val roundtrippedCustomChartsDataPoint = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customChartsDataPoint), + jacksonTypeRef<CustomChartsDataPoint>(), + ) + + assertThat(roundtrippedCustomChartsDataPoint).isEqualTo(customChartsDataPoint) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartsRequestTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartsRequestTest.kt new file mode 100644 index 00000000..2321534f --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartsRequestTest.kt @@ -0,0 +1,63 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.sessions.TimedeltaInput +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CustomChartsRequestTest { + + @Test + fun create() { + val customChartsRequest = + CustomChartsRequest.builder() + .afterIndex(0L) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride(TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build()) + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .timezone("timezone") + .build() + + assertThat(customChartsRequest.afterIndex()).contains(0L) + assertThat(customChartsRequest.endTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(customChartsRequest.omitData()).contains(true) + assertThat(customChartsRequest.startTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(customChartsRequest.stride()) + .contains(TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build()) + assertThat(customChartsRequest.tagValueId().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(customChartsRequest.timezone()).contains("timezone") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customChartsRequest = + CustomChartsRequest.builder() + .afterIndex(0L) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride(TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build()) + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .timezone("timezone") + .build() + + val roundtrippedCustomChartsRequest = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customChartsRequest), + jacksonTypeRef<CustomChartsRequest>(), + ) + + assertThat(roundtrippedCustomChartsRequest).isEqualTo(customChartsRequest) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartsResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartsResponseTest.kt new file mode 100644 index 00000000..414aca60 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/CustomChartsResponseTest.kt @@ -0,0 +1,424 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.sessions.CustomChartsSection +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CustomChartsResponseTest { + + @Test + fun create() { + val customChartsResponse = + CustomChartsResponse.builder() + .addSection( + CustomChartsSection.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChart( + SingleCustomChartResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .chartType(CustomChartType.LINE) + .addData( + CustomChartsDataPoint.builder() + .seriesId("series_id") + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .value(0.0) + .group("group") + .build() + ) + .index(0L) + .addSeries( + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + CustomChartSeries.GroupBy.builder() + .attribute(CustomChartSeries.GroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .setBy(CustomChartSeries.GroupBy.SetBy.SECTION) + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .title("title") + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("description") + .metadata(JsonValue.from(mapOf<String, Any>())) + .build() + ) + .title("title") + .description("description") + .index(0L) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addSubSection( + CustomChartsSection.SubSection.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChart( + SingleCustomChartResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .chartType(CustomChartType.LINE) + .addData( + CustomChartsDataPoint.builder() + .seriesId("series_id") + .timestamp( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .value(0.0) + .group("group") + .build() + ) + .index(0L) + .addSeries( + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e" + ) + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + CustomChartSeries.GroupBy.builder() + .attribute( + CustomChartSeries.GroupBy.Attribute.NAME + ) + .maxGroups(0L) + .path("path") + .setBy( + CustomChartSeries.GroupBy.SetBy.SECTION + ) + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .title("title") + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("description") + .metadata(JsonValue.from(mapOf<String, Any>())) + .build() + ) + .index(0L) + .title("title") + .description("description") + .build() + ) + .build() + ) + .build() + + assertThat(customChartsResponse.sections()) + .containsExactly( + CustomChartsSection.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChart( + SingleCustomChartResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .chartType(CustomChartType.LINE) + .addData( + CustomChartsDataPoint.builder() + .seriesId("series_id") + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .value(0.0) + .group("group") + .build() + ) + .index(0L) + .addSeries( + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + CustomChartSeries.GroupBy.builder() + .attribute(CustomChartSeries.GroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .setBy(CustomChartSeries.GroupBy.SetBy.SECTION) + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .title("title") + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("description") + .metadata(JsonValue.from(mapOf<String, Any>())) + .build() + ) + .title("title") + .description("description") + .index(0L) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addSubSection( + CustomChartsSection.SubSection.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChart( + SingleCustomChartResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .chartType(CustomChartType.LINE) + .addData( + CustomChartsDataPoint.builder() + .seriesId("series_id") + .timestamp( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .value(0.0) + .group("group") + .build() + ) + .index(0L) + .addSeries( + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e" + ) + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + CustomChartSeries.GroupBy.builder() + .attribute( + CustomChartSeries.GroupBy.Attribute.NAME + ) + .maxGroups(0L) + .path("path") + .setBy(CustomChartSeries.GroupBy.SetBy.SECTION) + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .title("title") + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("description") + .metadata(JsonValue.from(mapOf<String, Any>())) + .build() + ) + .index(0L) + .title("title") + .description("description") + .build() + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customChartsResponse = + CustomChartsResponse.builder() + .addSection( + CustomChartsSection.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChart( + SingleCustomChartResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .chartType(CustomChartType.LINE) + .addData( + CustomChartsDataPoint.builder() + .seriesId("series_id") + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .value(0.0) + .group("group") + .build() + ) + .index(0L) + .addSeries( + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + CustomChartSeries.GroupBy.builder() + .attribute(CustomChartSeries.GroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .setBy(CustomChartSeries.GroupBy.SetBy.SECTION) + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .title("title") + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("description") + .metadata(JsonValue.from(mapOf<String, Any>())) + .build() + ) + .title("title") + .description("description") + .index(0L) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addSubSection( + CustomChartsSection.SubSection.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChart( + SingleCustomChartResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .chartType(CustomChartType.LINE) + .addData( + CustomChartsDataPoint.builder() + .seriesId("series_id") + .timestamp( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .value(0.0) + .group("group") + .build() + ) + .index(0L) + .addSeries( + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e" + ) + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + CustomChartSeries.GroupBy.builder() + .attribute( + CustomChartSeries.GroupBy.Attribute.NAME + ) + .maxGroups(0L) + .path("path") + .setBy( + CustomChartSeries.GroupBy.SetBy.SECTION + ) + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .title("title") + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("description") + .metadata(JsonValue.from(mapOf<String, Any>())) + .build() + ) + .index(0L) + .title("title") + .description("description") + .build() + ) + .build() + ) + .build() + + val roundtrippedCustomChartsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customChartsResponse), + jacksonTypeRef<CustomChartsResponse>(), + ) + + assertThat(roundtrippedCustomChartsResponse).isEqualTo(customChartsResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/SingleCustomChartResponseBaseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/SingleCustomChartResponseBaseTest.kt new file mode 100644 index 00000000..6ff571bb --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/SingleCustomChartResponseBaseTest.kt @@ -0,0 +1,62 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SingleCustomChartResponseBaseTest { + + @Test + fun create() { + val singleCustomChartResponseBase = + SingleCustomChartResponseBase.builder() + .addData( + CustomChartsDataPoint.builder() + .seriesId("series_id") + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .value(0.0) + .group("group") + .build() + ) + .build() + + assertThat(singleCustomChartResponseBase.data()) + .containsExactly( + CustomChartsDataPoint.builder() + .seriesId("series_id") + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .value(0.0) + .group("group") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val singleCustomChartResponseBase = + SingleCustomChartResponseBase.builder() + .addData( + CustomChartsDataPoint.builder() + .seriesId("series_id") + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .value(0.0) + .group("group") + .build() + ) + .build() + + val roundtrippedSingleCustomChartResponseBase = + jsonMapper.readValue( + jsonMapper.writeValueAsString(singleCustomChartResponseBase), + jacksonTypeRef<SingleCustomChartResponseBase>(), + ) + + assertThat(roundtrippedSingleCustomChartResponseBase) + .isEqualTo(singleCustomChartResponseBase) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/SingleCustomChartResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/SingleCustomChartResponseTest.kt new file mode 100644 index 00000000..33ffce6b --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/SingleCustomChartResponseTest.kt @@ -0,0 +1,185 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SingleCustomChartResponseTest { + + @Test + fun create() { + val singleCustomChartResponse = + SingleCustomChartResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .chartType(CustomChartType.LINE) + .addData( + CustomChartsDataPoint.builder() + .seriesId("series_id") + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .value(0.0) + .group("group") + .build() + ) + .index(0L) + .addSeries( + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + CustomChartSeries.GroupBy.builder() + .attribute(CustomChartSeries.GroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .setBy(CustomChartSeries.GroupBy.SetBy.SECTION) + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .title("title") + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("description") + .metadata(JsonValue.from(mapOf<String, Any>())) + .build() + + assertThat(singleCustomChartResponse.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(singleCustomChartResponse.chartType()).isEqualTo(CustomChartType.LINE) + assertThat(singleCustomChartResponse.data()) + .containsExactly( + CustomChartsDataPoint.builder() + .seriesId("series_id") + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .value(0.0) + .group("group") + .build() + ) + assertThat(singleCustomChartResponse.index()).isEqualTo(0L) + assertThat(singleCustomChartResponse.series()) + .containsExactly( + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + CustomChartSeries.GroupBy.builder() + .attribute(CustomChartSeries.GroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .setBy(CustomChartSeries.GroupBy.SetBy.SECTION) + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + assertThat(singleCustomChartResponse.title()).isEqualTo("title") + assertThat(singleCustomChartResponse.commonFilters()) + .contains( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + assertThat(singleCustomChartResponse.description()).contains("description") + assertThat(singleCustomChartResponse._metadata()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val singleCustomChartResponse = + SingleCustomChartResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .chartType(CustomChartType.LINE) + .addData( + CustomChartsDataPoint.builder() + .seriesId("series_id") + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .value(0.0) + .group("group") + .build() + ) + .index(0L) + .addSeries( + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + CustomChartSeries.GroupBy.builder() + .attribute(CustomChartSeries.GroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .setBy(CustomChartSeries.GroupBy.SetBy.SECTION) + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .title("title") + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("description") + .metadata(JsonValue.from(mapOf<String, Any>())) + .build() + + val roundtrippedSingleCustomChartResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(singleCustomChartResponse), + jacksonTypeRef<SingleCustomChartResponse>(), + ) + + assertThat(roundtrippedSingleCustomChartResponse).isEqualTo(singleCustomChartResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/section/CustomChartsSectionCreateTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/section/CustomChartsSectionCreateTest.kt new file mode 100644 index 00000000..d80a55ed --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/section/CustomChartsSectionCreateTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts.section + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CustomChartsSectionCreateTest { + + @Test + fun create() { + val customChartsSectionCreate = + CustomChartsSectionCreate.builder() + .title("title") + .description("description") + .index(0L) + .build() + + assertThat(customChartsSectionCreate.title()).isEqualTo("title") + assertThat(customChartsSectionCreate.description()).contains("description") + assertThat(customChartsSectionCreate.index()).contains(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customChartsSectionCreate = + CustomChartsSectionCreate.builder() + .title("title") + .description("description") + .index(0L) + .build() + + val roundtrippedCustomChartsSectionCreate = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customChartsSectionCreate), + jacksonTypeRef<CustomChartsSectionCreate>(), + ) + + assertThat(roundtrippedCustomChartsSectionCreate).isEqualTo(customChartsSectionCreate) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/section/CustomChartsSectionResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/section/CustomChartsSectionResponseTest.kt new file mode 100644 index 00000000..38a43d73 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/section/CustomChartsSectionResponseTest.kt @@ -0,0 +1,60 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts.section + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CustomChartsSectionResponseTest { + + @Test + fun create() { + val customChartsSectionResponse = + CustomChartsSectionResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .title("title") + .chartCount(0L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .index(0L) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(customChartsSectionResponse.id()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(customChartsSectionResponse.title()).isEqualTo("title") + assertThat(customChartsSectionResponse.chartCount()).contains(0L) + assertThat(customChartsSectionResponse.createdAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(customChartsSectionResponse.description()).contains("description") + assertThat(customChartsSectionResponse.index()).contains(0L) + assertThat(customChartsSectionResponse.modifiedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customChartsSectionResponse = + CustomChartsSectionResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .title("title") + .chartCount(0L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .index(0L) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedCustomChartsSectionResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customChartsSectionResponse), + jacksonTypeRef<CustomChartsSectionResponse>(), + ) + + assertThat(roundtrippedCustomChartsSectionResponse).isEqualTo(customChartsSectionResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/section/CustomChartsSectionUpdateTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/section/CustomChartsSectionUpdateTest.kt new file mode 100644 index 00000000..db5ed4ae --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/section/CustomChartsSectionUpdateTest.kt @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts.section + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CustomChartsSectionUpdateTest { + + @Test + fun create() { + val customChartsSectionUpdate = + CustomChartsSectionUpdate.builder() + .description("string") + .index(0L) + .title("string") + .build() + + assertThat(customChartsSectionUpdate.description()) + .contains(CustomChartsSectionUpdate.Description.ofString("string")) + assertThat(customChartsSectionUpdate.index()) + .contains(CustomChartsSectionUpdate.Index.ofInteger(0L)) + assertThat(customChartsSectionUpdate.title()) + .contains(CustomChartsSectionUpdate.Title.ofString("string")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customChartsSectionUpdate = + CustomChartsSectionUpdate.builder() + .description("string") + .index(0L) + .title("string") + .build() + + val roundtrippedCustomChartsSectionUpdate = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customChartsSectionUpdate), + jacksonTypeRef<CustomChartsSectionUpdate>(), + ) + + assertThat(roundtrippedCustomChartsSectionUpdate).isEqualTo(customChartsSectionUpdate) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionCloneParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionCloneParamsTest.kt new file mode 100644 index 00000000..0dd35544 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionCloneParamsTest.kt @@ -0,0 +1,38 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts.section + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SectionCloneParamsTest { + + @Test + fun create() { + SectionCloneParams.builder() + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun body() { + val params = + SectionCloneParams.builder() + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + + assertThat(body.sectionId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.sessionId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = SectionCloneParams.builder().build() + + val body = params._body() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionCreateParamsTest.kt new file mode 100644 index 00000000..af461e62 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionCreateParamsTest.kt @@ -0,0 +1,61 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts.section + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SectionCreateParamsTest { + + @Test + fun create() { + SectionCreateParams.builder() + .customChartsSectionCreate( + CustomChartsSectionCreate.builder() + .title("title") + .description("description") + .index(0L) + .build() + ) + .build() + } + + @Test + fun body() { + val params = + SectionCreateParams.builder() + .customChartsSectionCreate( + CustomChartsSectionCreate.builder() + .title("title") + .description("description") + .index(0L) + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + CustomChartsSectionCreate.builder() + .title("title") + .description("description") + .index(0L) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + SectionCreateParams.builder() + .customChartsSectionCreate( + CustomChartsSectionCreate.builder().title("title").build() + ) + .build() + + val body = params._body() + + assertThat(body).isEqualTo(CustomChartsSectionCreate.builder().title("title").build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionDeleteParamsTest.kt new file mode 100644 index 00000000..5361230e --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionDeleteParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts.section + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SectionDeleteParamsTest { + + @Test + fun create() { + SectionDeleteParams.builder().sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + SectionDeleteParams.builder().sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionDeleteResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionDeleteResponseTest.kt new file mode 100644 index 00000000..669b33a7 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionDeleteResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts.section + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SectionDeleteResponseTest { + + @Test + fun create() { + val sectionDeleteResponse = SectionDeleteResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val sectionDeleteResponse = SectionDeleteResponse.builder().build() + + val roundtrippedSectionDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(sectionDeleteResponse), + jacksonTypeRef<SectionDeleteResponse>(), + ) + + assertThat(roundtrippedSectionDeleteResponse).isEqualTo(sectionDeleteResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionListParamsTest.kt new file mode 100644 index 00000000..0bdc6e17 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionListParamsTest.kt @@ -0,0 +1,64 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts.section + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SectionListParamsTest { + + @Test + fun create() { + SectionListParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .offset(0L) + .sortBy("sort_by") + .sortByDesc(true) + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .titleContains("title_contains") + .build() + } + + @Test + fun queryParams() { + val params = + SectionListParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .offset(0L) + .sortBy("sort_by") + .sortByDesc(true) + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .titleContains("title_contains") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("ids", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").joinToString(",")) + .put("limit", "1") + .put("offset", "0") + .put("sort_by", "sort_by") + .put("sort_by_desc", "true") + .put( + "tag_value_id", + listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").joinToString(","), + ) + .put("title_contains", "title_contains") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = SectionListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionUpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionUpdateParamsTest.kt new file mode 100644 index 00000000..669879c3 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/charts/section/SectionUpdateParamsTest.kt @@ -0,0 +1,75 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.charts.section + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SectionUpdateParamsTest { + + @Test + fun create() { + SectionUpdateParams.builder() + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .customChartsSectionUpdate( + CustomChartsSectionUpdate.builder() + .description("string") + .index(0L) + .title("string") + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + SectionUpdateParams.builder() + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .customChartsSectionUpdate(CustomChartsSectionUpdate.builder().build()) + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + SectionUpdateParams.builder() + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .customChartsSectionUpdate( + CustomChartsSectionUpdate.builder() + .description("string") + .index(0L) + .title("string") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + CustomChartsSectionUpdate.builder() + .description("string") + .index(0L) + .title("string") + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + SectionUpdateParams.builder() + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .customChartsSectionUpdate(CustomChartsSectionUpdate.builder().build()) + .build() + + val body = params._body() + + assertThat(body).isEqualTo(CustomChartsSectionUpdate.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/comments/CommentRetrieveParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/comments/CommentRetrieveParamsTest.kt new file mode 100644 index 00000000..d78cac71 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/comments/CommentRetrieveParamsTest.kt @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.comments + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CommentRetrieveParamsTest { + + @Test + fun create() { + CommentRetrieveParams.builder() + .owner("owner") + .repo("repo") + .parentCommentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .offset(0L) + .build() + } + + @Test + fun pathParams() { + val params = + CommentRetrieveParams.builder() + .owner("owner") + .repo("repo") + .parentCommentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("owner") + assertThat(params._pathParam(1)).isEqualTo("repo") + assertThat(params._pathParam(2)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(3)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + CommentRetrieveParams.builder() + .owner("owner") + .repo("repo") + .parentCommentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .offset(0L) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("limit", "1").put("offset", "0").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + CommentRetrieveParams.builder() + .owner("owner") + .repo("repo") + .parentCommentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/comments/CommentTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/comments/CommentTest.kt new file mode 100644 index 00000000..66666aff --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/comments/CommentTest.kt @@ -0,0 +1,66 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.comments + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CommentTest { + + @Test + fun create() { + val comment = + Comment.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .commentOn("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .content("content") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .numLikes(0L) + .numSubComments(0L) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .commentBy("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .commentByName("comment_by_name") + .likedByAuthUser(true) + .parentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(comment.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(comment.commentOn()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(comment.content()).isEqualTo("content") + assertThat(comment.createdAt()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(comment.numLikes()).isEqualTo(0L) + assertThat(comment.numSubComments()).isEqualTo(0L) + assertThat(comment.updatedAt()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(comment.commentBy()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(comment.commentByName()).contains("comment_by_name") + assertThat(comment.likedByAuthUser()).contains(true) + assertThat(comment.parentId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val comment = + Comment.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .commentOn("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .content("content") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .numLikes(0L) + .numSubComments(0L) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .commentBy("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .commentByName("comment_by_name") + .likedByAuthUser(true) + .parentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val roundtrippedComment = + jsonMapper.readValue(jsonMapper.writeValueAsString(comment), jacksonTypeRef<Comment>()) + + assertThat(roundtrippedComment).isEqualTo(comment) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/comments/CommentUpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/comments/CommentUpdateParamsTest.kt new file mode 100644 index 00000000..a6833d97 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/comments/CommentUpdateParamsTest.kt @@ -0,0 +1,51 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.comments + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CommentUpdateParamsTest { + + @Test + fun create() { + CommentUpdateParams.builder() + .owner("owner") + .repo("repo") + .parentCommentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createCommentRequest(CreateCommentRequest.builder().content("content").build()) + .build() + } + + @Test + fun pathParams() { + val params = + CommentUpdateParams.builder() + .owner("owner") + .repo("repo") + .parentCommentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createCommentRequest(CreateCommentRequest.builder().content("content").build()) + .build() + + assertThat(params._pathParam(0)).isEqualTo("owner") + assertThat(params._pathParam(1)).isEqualTo("repo") + assertThat(params._pathParam(2)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(3)).isEqualTo("") + } + + @Test + fun body() { + val params = + CommentUpdateParams.builder() + .owner("owner") + .repo("repo") + .parentCommentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createCommentRequest(CreateCommentRequest.builder().content("content").build()) + .build() + + val body = params._body() + + assertThat(body).isEqualTo(CreateCommentRequest.builder().content("content").build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/comments/CreateCommentRequestTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/comments/CreateCommentRequestTest.kt new file mode 100644 index 00000000..80ae6af5 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/comments/CreateCommentRequestTest.kt @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.comments + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CreateCommentRequestTest { + + @Test + fun create() { + val createCommentRequest = CreateCommentRequest.builder().content("content").build() + + assertThat(createCommentRequest.content()).isEqualTo("content") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val createCommentRequest = CreateCommentRequest.builder().content("content").build() + + val roundtrippedCreateCommentRequest = + jsonMapper.readValue( + jsonMapper.writeValueAsString(createCommentRequest), + jacksonTypeRef<CreateCommentRequest>(), + ) + + assertThat(roundtrippedCreateCommentRequest).isEqualTo(createCommentRequest) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/comments/ListCommentsResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/comments/ListCommentsResponseTest.kt new file mode 100644 index 00000000..a6f6a1fd --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/comments/ListCommentsResponseTest.kt @@ -0,0 +1,85 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.comments + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ListCommentsResponseTest { + + @Test + fun create() { + val listCommentsResponse = + ListCommentsResponse.builder() + .addComment( + Comment.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .commentOn("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .content("content") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .numLikes(0L) + .numSubComments(0L) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .commentBy("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .commentByName("comment_by_name") + .likedByAuthUser(true) + .parentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .total(0L) + .build() + + assertThat(listCommentsResponse.comments()) + .containsExactly( + Comment.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .commentOn("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .content("content") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .numLikes(0L) + .numSubComments(0L) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .commentBy("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .commentByName("comment_by_name") + .likedByAuthUser(true) + .parentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + assertThat(listCommentsResponse.total()).isEqualTo(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val listCommentsResponse = + ListCommentsResponse.builder() + .addComment( + Comment.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .commentOn("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .content("content") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .numLikes(0L) + .numSubComments(0L) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .commentBy("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .commentByName("comment_by_name") + .likedByAuthUser(true) + .parentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .total(0L) + .build() + + val roundtrippedListCommentsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(listCommentsResponse), + jacksonTypeRef<ListCommentsResponse>(), + ) + + assertThat(roundtrippedListCommentsResponse).isEqualTo(listCommentsResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/comments/like/LikeCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/comments/like/LikeCreateParamsTest.kt new file mode 100644 index 00000000..bcb710eb --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/comments/like/LikeCreateParamsTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.comments.like + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LikeCreateParamsTest { + + @Test + fun create() { + LikeCreateParams.builder() + .owner("owner") + .repo("repo") + .parentCommentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + LikeCreateParams.builder() + .owner("owner") + .repo("repo") + .parentCommentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("owner") + assertThat(params._pathParam(1)).isEqualTo("repo") + assertThat(params._pathParam(2)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(3)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/comments/like/LikeCreateResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/comments/like/LikeCreateResponseTest.kt new file mode 100644 index 00000000..4ca064ab --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/comments/like/LikeCreateResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.comments.like + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LikeCreateResponseTest { + + @Test + fun create() { + val likeCreateResponse = LikeCreateResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val likeCreateResponse = LikeCreateResponse.builder().build() + + val roundtrippedLikeCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(likeCreateResponse), + jacksonTypeRef<LikeCreateResponse>(), + ) + + assertThat(roundtrippedLikeCreateResponse).isEqualTo(likeCreateResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/comments/like/LikeDeleteAllParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/comments/like/LikeDeleteAllParamsTest.kt new file mode 100644 index 00000000..dbb5ed40 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/comments/like/LikeDeleteAllParamsTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.comments.like + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LikeDeleteAllParamsTest { + + @Test + fun create() { + LikeDeleteAllParams.builder() + .owner("owner") + .repo("repo") + .parentCommentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + LikeDeleteAllParams.builder() + .owner("owner") + .repo("repo") + .parentCommentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("owner") + assertThat(params._pathParam(1)).isEqualTo("repo") + assertThat(params._pathParam(2)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(3)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/comments/like/LikeDeleteAllResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/comments/like/LikeDeleteAllResponseTest.kt new file mode 100644 index 00000000..ea9988f0 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/comments/like/LikeDeleteAllResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.comments.like + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LikeDeleteAllResponseTest { + + @Test + fun create() { + val likeDeleteAllResponse = LikeDeleteAllResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val likeDeleteAllResponse = LikeDeleteAllResponse.builder().build() + + val roundtrippedLikeDeleteAllResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(likeDeleteAllResponse), + jacksonTypeRef<LikeDeleteAllResponse>(), + ) + + assertThat(roundtrippedLikeDeleteAllResponse).isEqualTo(likeDeleteAllResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitManifestResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitManifestResponseTest.kt new file mode 100644 index 00000000..a4f4f07f --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitManifestResponseTest.kt @@ -0,0 +1,73 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.commits + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CommitManifestResponseTest { + + @Test + fun create() { + val commitManifestResponse = + CommitManifestResponse.builder() + .commitHash("commit_hash") + .manifest(JsonValue.from(mapOf<String, Any>())) + .addExample( + CommitManifestResponse.Example.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .outputs(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + + assertThat(commitManifestResponse.commitHash()).isEqualTo("commit_hash") + assertThat(commitManifestResponse._manifest()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(commitManifestResponse.examples().getOrNull()) + .containsExactly( + CommitManifestResponse.Example.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .outputs(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val commitManifestResponse = + CommitManifestResponse.builder() + .commitHash("commit_hash") + .manifest(JsonValue.from(mapOf<String, Any>())) + .addExample( + CommitManifestResponse.Example.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .outputs(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + + val roundtrippedCommitManifestResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(commitManifestResponse), + jacksonTypeRef<CommitManifestResponse>(), + ) + + assertThat(roundtrippedCommitManifestResponse).isEqualTo(commitManifestResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitRetrieveParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitRetrieveParamsTest.kt new file mode 100644 index 00000000..ad4e9946 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitRetrieveParamsTest.kt @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.commits + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CommitRetrieveParamsTest { + + @Test + fun create() { + CommitRetrieveParams.builder() + .owner("owner") + .repo("repo") + .commit("commit") + .getExamples(true) + .includeModel(true) + .isView(true) + .build() + } + + @Test + fun pathParams() { + val params = + CommitRetrieveParams.builder().owner("owner").repo("repo").commit("commit").build() + + assertThat(params._pathParam(0)).isEqualTo("owner") + assertThat(params._pathParam(1)).isEqualTo("repo") + assertThat(params._pathParam(2)).isEqualTo("commit") + // out-of-bound path param + assertThat(params._pathParam(3)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + CommitRetrieveParams.builder() + .owner("owner") + .repo("repo") + .commit("commit") + .getExamples(true) + .includeModel(true) + .isView(true) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("get_examples", "true") + .put("include_model", "true") + .put("is_view", "true") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + CommitRetrieveParams.builder().owner("owner").repo("repo").commit("commit").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitUpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitUpdateParamsTest.kt new file mode 100644 index 00000000..22b45e16 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitUpdateParamsTest.kt @@ -0,0 +1,73 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.commits + +import com.langsmith_api.api.core.JsonValue +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CommitUpdateParamsTest { + + @Test + fun create() { + CommitUpdateParams.builder() + .owner("owner") + .repo("repo") + .manifest(JsonValue.from(mapOf<String, Any>())) + .addExampleRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .parentCommit("parent_commit") + .skipWebhooks(true) + .build() + } + + @Test + fun pathParams() { + val params = + CommitUpdateParams.builder() + .owner("owner") + .repo("repo") + .manifest(JsonValue.from(mapOf<String, Any>())) + .build() + + assertThat(params._pathParam(0)).isEqualTo("owner") + assertThat(params._pathParam(1)).isEqualTo("repo") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } + + @Test + fun body() { + val params = + CommitUpdateParams.builder() + .owner("owner") + .repo("repo") + .manifest(JsonValue.from(mapOf<String, Any>())) + .addExampleRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .parentCommit("parent_commit") + .skipWebhooks(true) + .build() + + val body = params._body() + + assertThat(body._manifest()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(body.exampleRunIds().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.parentCommit()).contains("parent_commit") + assertThat(body.skipWebhooks()).contains(CommitUpdateParams.SkipWebhooks.ofBool(true)) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + CommitUpdateParams.builder() + .owner("owner") + .repo("repo") + .manifest(JsonValue.from(mapOf<String, Any>())) + .build() + + val body = params._body() + + assertThat(body._manifest()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitUpdateResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitUpdateResponseTest.kt new file mode 100644 index 00000000..051a241a --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitUpdateResponseTest.kt @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.commits + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CommitUpdateResponseTest { + + @Test + fun create() { + val commitUpdateResponse = + CommitUpdateResponse.builder() + .commit( + CommitWithLookups.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .commitHash("commit_hash") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addExampleRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifest(JsonValue.from(mapOf<String, Any>())) + .numDownloads(0L) + .numViews(0L) + .repoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .fullName("full_name") + .parentCommitHash("parent_commit_hash") + .parentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + + assertThat(commitUpdateResponse.commit()) + .isEqualTo( + CommitWithLookups.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .commitHash("commit_hash") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addExampleRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifest(JsonValue.from(mapOf<String, Any>())) + .numDownloads(0L) + .numViews(0L) + .repoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .fullName("full_name") + .parentCommitHash("parent_commit_hash") + .parentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val commitUpdateResponse = + CommitUpdateResponse.builder() + .commit( + CommitWithLookups.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .commitHash("commit_hash") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addExampleRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifest(JsonValue.from(mapOf<String, Any>())) + .numDownloads(0L) + .numViews(0L) + .repoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .fullName("full_name") + .parentCommitHash("parent_commit_hash") + .parentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + + val roundtrippedCommitUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(commitUpdateResponse), + jacksonTypeRef<CommitUpdateResponse>(), + ) + + assertThat(roundtrippedCommitUpdateResponse).isEqualTo(commitUpdateResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitWithLookupsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitWithLookupsTest.kt new file mode 100644 index 00000000..4ec5484a --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/commits/CommitWithLookupsTest.kt @@ -0,0 +1,76 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.commits + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CommitWithLookupsTest { + + @Test + fun create() { + val commitWithLookups = + CommitWithLookups.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .commitHash("commit_hash") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addExampleRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifest(JsonValue.from(mapOf<String, Any>())) + .numDownloads(0L) + .numViews(0L) + .repoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .fullName("full_name") + .parentCommitHash("parent_commit_hash") + .parentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(commitWithLookups.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(commitWithLookups.commitHash()).isEqualTo("commit_hash") + assertThat(commitWithLookups.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(commitWithLookups.exampleRunIds()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(commitWithLookups._manifest()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(commitWithLookups.numDownloads()).isEqualTo(0L) + assertThat(commitWithLookups.numViews()).isEqualTo(0L) + assertThat(commitWithLookups.repoId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(commitWithLookups.updatedAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(commitWithLookups.fullName()).contains("full_name") + assertThat(commitWithLookups.parentCommitHash()).contains("parent_commit_hash") + assertThat(commitWithLookups.parentId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val commitWithLookups = + CommitWithLookups.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .commitHash("commit_hash") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addExampleRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifest(JsonValue.from(mapOf<String, Any>())) + .numDownloads(0L) + .numViews(0L) + .repoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .fullName("full_name") + .parentCommitHash("parent_commit_hash") + .parentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val roundtrippedCommitWithLookups = + jsonMapper.readValue( + jsonMapper.writeValueAsString(commitWithLookups), + jacksonTypeRef<CommitWithLookups>(), + ) + + assertThat(roundtrippedCommitWithLookups).isEqualTo(commitWithLookups) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetCloneParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetCloneParamsTest.kt new file mode 100644 index 00000000..2396c09e --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetCloneParamsTest.kt @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetCloneParamsTest { + + @Test + fun create() { + DatasetCloneParams.builder() + .sourceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .targetDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun body() { + val params = + DatasetCloneParams.builder() + .sourceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .targetDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + + assertThat(body.sourceDatasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.targetDatasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.asOf()) + .contains( + DatasetCloneParams.AsOf.ofOffsetDateTime( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + ) + assertThat(body.examples().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + DatasetCloneParams.builder() + .sourceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .targetDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + + assertThat(body.sourceDatasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.targetDatasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetCloneResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetCloneResponseTest.kt new file mode 100644 index 00000000..3fb5053c --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetCloneResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetCloneResponseTest { + + @Test + fun create() { + val datasetCloneResponse = DatasetCloneResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val datasetCloneResponse = DatasetCloneResponse.builder().build() + + val roundtrippedDatasetCloneResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(datasetCloneResponse), + jacksonTypeRef<DatasetCloneResponse>(), + ) + + assertThat(roundtrippedDatasetCloneResponse).isEqualTo(datasetCloneResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetCreateParamsTest.kt new file mode 100644 index 00000000..f717e9e7 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetCreateParamsTest.kt @@ -0,0 +1,89 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.langsmith_api.api.core.JsonValue +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetCreateParamsTest { + + @Test + fun create() { + DatasetCreateParams.builder() + .name("name") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dataType(DataType.KV) + .description("description") + .externallyManaged(true) + .extra(JsonValue.from(mapOf<String, Any>())) + .inputsSchemaDefinition(JsonValue.from(mapOf<String, Any>())) + .outputsSchemaDefinition(JsonValue.from(mapOf<String, Any>())) + .addTransformation( + DatasetTransformation.builder() + .addPath("string") + .transformationType( + DatasetTransformation.TransformationType.CONVERT_TO_OPENAI_MESSAGE + ) + .build() + ) + .build() + } + + @Test + fun body() { + val params = + DatasetCreateParams.builder() + .name("name") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dataType(DataType.KV) + .description("description") + .externallyManaged(true) + .extra(JsonValue.from(mapOf<String, Any>())) + .inputsSchemaDefinition(JsonValue.from(mapOf<String, Any>())) + .outputsSchemaDefinition(JsonValue.from(mapOf<String, Any>())) + .addTransformation( + DatasetTransformation.builder() + .addPath("string") + .transformationType( + DatasetTransformation.TransformationType.CONVERT_TO_OPENAI_MESSAGE + ) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.name()).isEqualTo("name") + assertThat(body.id()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.createdAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(body.dataType()).contains(DataType.KV) + assertThat(body.description()).contains("description") + assertThat(body.externallyManaged()).contains(true) + assertThat(body._extra()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(body._inputsSchemaDefinition()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(body._outputsSchemaDefinition()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(body.transformations().getOrNull()) + .containsExactly( + DatasetTransformation.builder() + .addPath("string") + .transformationType( + DatasetTransformation.TransformationType.CONVERT_TO_OPENAI_MESSAGE + ) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = DatasetCreateParams.builder().name("name").build() + + val body = params._body() + + assertThat(body.name()).isEqualTo("name") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetDeleteParamsTest.kt new file mode 100644 index 00000000..cedb6d4a --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetDeleteParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetDeleteParamsTest { + + @Test + fun create() { + DatasetDeleteParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + DatasetDeleteParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetDeleteResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetDeleteResponseTest.kt new file mode 100644 index 00000000..7d332ed0 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetDeleteResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetDeleteResponseTest { + + @Test + fun create() { + val datasetDeleteResponse = DatasetDeleteResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val datasetDeleteResponse = DatasetDeleteResponse.builder().build() + + val roundtrippedDatasetDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(datasetDeleteResponse), + jacksonTypeRef<DatasetDeleteResponse>(), + ) + + assertThat(roundtrippedDatasetDeleteResponse).isEqualTo(datasetDeleteResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetGenerateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetGenerateParamsTest.kt new file mode 100644 index 00000000..8b0fc1c2 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetGenerateParamsTest.kt @@ -0,0 +1,61 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetGenerateParamsTest { + + @Test + fun create() { + DatasetGenerateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .numExamples(0L) + .addExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + DatasetGenerateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .numExamples(0L) + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + DatasetGenerateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .numExamples(0L) + .addExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + + assertThat(body.numExamples()).isEqualTo(0L) + assertThat(body.exampleIds().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + DatasetGenerateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .numExamples(0L) + .build() + + val body = params._body() + + assertThat(body.numExamples()).isEqualTo(0L) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetGenerateResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetGenerateResponseTest.kt new file mode 100644 index 00000000..e34047c0 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetGenerateResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetGenerateResponseTest { + + @Test + fun create() { + val datasetGenerateResponse = DatasetGenerateResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val datasetGenerateResponse = DatasetGenerateResponse.builder().build() + + val roundtrippedDatasetGenerateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(datasetGenerateResponse), + jacksonTypeRef<DatasetGenerateResponse>(), + ) + + assertThat(roundtrippedDatasetGenerateResponse).isEqualTo(datasetGenerateResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetListParamsTest.kt new file mode 100644 index 00000000..93110769 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetListParamsTest.kt @@ -0,0 +1,76 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetListParamsTest { + + @Test + fun create() { + DatasetListParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dataTypeOfTypes(listOf(DataType.KV)) + .excludeCorrectionsDatasets(true) + .limit(1L) + .metadata("metadata") + .name("name") + .nameContains("name_contains") + .offset(0L) + .sortBy(SortByDatasetColumn.NAME) + .sortByDesc(true) + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun queryParams() { + val params = + DatasetListParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dataTypeOfTypes(listOf(DataType.KV)) + .excludeCorrectionsDatasets(true) + .limit(1L) + .metadata("metadata") + .name("name") + .nameContains("name_contains") + .offset(0L) + .sortBy(SortByDatasetColumn.NAME) + .sortByDesc(true) + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").joinToString(",")) + .put("data_type", listOf("kv").joinToString(",")) + .put("exclude_corrections_datasets", "true") + .put("limit", "1") + .put("metadata", "metadata") + .put("name", "name") + .put("name_contains", "name_contains") + .put("offset", "0") + .put("sort_by", "name") + .put("sort_by_desc", "true") + .put( + "tag_value_id", + listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").joinToString(","), + ) + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = DatasetListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveCsvParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveCsvParamsTest.kt new file mode 100644 index 00000000..feb9b1f6 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveCsvParamsTest.kt @@ -0,0 +1,57 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.langsmith_api.api.core.http.QueryParams +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetRetrieveCsvParamsTest { + + @Test + fun create() { + DatasetRetrieveCsvParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + } + + @Test + fun pathParams() { + val params = + DatasetRetrieveCsvParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + DatasetRetrieveCsvParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("as_of", "2019-12-27T18:11:19.117Z").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + DatasetRetrieveCsvParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveCsvResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveCsvResponseTest.kt new file mode 100644 index 00000000..76fdaf9d --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveCsvResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetRetrieveCsvResponseTest { + + @Test + fun create() { + val datasetRetrieveCsvResponse = DatasetRetrieveCsvResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val datasetRetrieveCsvResponse = DatasetRetrieveCsvResponse.builder().build() + + val roundtrippedDatasetRetrieveCsvResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(datasetRetrieveCsvResponse), + jacksonTypeRef<DatasetRetrieveCsvResponse>(), + ) + + assertThat(roundtrippedDatasetRetrieveCsvResponse).isEqualTo(datasetRetrieveCsvResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveJsonlParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveJsonlParamsTest.kt new file mode 100644 index 00000000..b1ef5ed5 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveJsonlParamsTest.kt @@ -0,0 +1,57 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.langsmith_api.api.core.http.QueryParams +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetRetrieveJsonlParamsTest { + + @Test + fun create() { + DatasetRetrieveJsonlParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + } + + @Test + fun pathParams() { + val params = + DatasetRetrieveJsonlParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + DatasetRetrieveJsonlParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("as_of", "2019-12-27T18:11:19.117Z").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + DatasetRetrieveJsonlParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveJsonlResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveJsonlResponseTest.kt new file mode 100644 index 00000000..dcea0b97 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveJsonlResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetRetrieveJsonlResponseTest { + + @Test + fun create() { + val datasetRetrieveJsonlResponse = DatasetRetrieveJsonlResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val datasetRetrieveJsonlResponse = DatasetRetrieveJsonlResponse.builder().build() + + val roundtrippedDatasetRetrieveJsonlResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(datasetRetrieveJsonlResponse), + jacksonTypeRef<DatasetRetrieveJsonlResponse>(), + ) + + assertThat(roundtrippedDatasetRetrieveJsonlResponse).isEqualTo(datasetRetrieveJsonlResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveOpenAIFtParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveOpenAIFtParamsTest.kt new file mode 100644 index 00000000..cd6c3103 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveOpenAIFtParamsTest.kt @@ -0,0 +1,57 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.langsmith_api.api.core.http.QueryParams +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetRetrieveOpenAIFtParamsTest { + + @Test + fun create() { + DatasetRetrieveOpenAIFtParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + } + + @Test + fun pathParams() { + val params = + DatasetRetrieveOpenAIFtParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + DatasetRetrieveOpenAIFtParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("as_of", "2019-12-27T18:11:19.117Z").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + DatasetRetrieveOpenAIFtParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveOpenAIFtResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveOpenAIFtResponseTest.kt new file mode 100644 index 00000000..9251babf --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveOpenAIFtResponseTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetRetrieveOpenAIFtResponseTest { + + @Test + fun create() { + val datasetRetrieveOpenAIFtResponse = DatasetRetrieveOpenAIFtResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val datasetRetrieveOpenAIFtResponse = DatasetRetrieveOpenAIFtResponse.builder().build() + + val roundtrippedDatasetRetrieveOpenAIFtResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(datasetRetrieveOpenAIFtResponse), + jacksonTypeRef<DatasetRetrieveOpenAIFtResponse>(), + ) + + assertThat(roundtrippedDatasetRetrieveOpenAIFtResponse) + .isEqualTo(datasetRetrieveOpenAIFtResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveOpenAIParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveOpenAIParamsTest.kt new file mode 100644 index 00000000..97b5e636 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveOpenAIParamsTest.kt @@ -0,0 +1,57 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.langsmith_api.api.core.http.QueryParams +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetRetrieveOpenAIParamsTest { + + @Test + fun create() { + DatasetRetrieveOpenAIParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + } + + @Test + fun pathParams() { + val params = + DatasetRetrieveOpenAIParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + DatasetRetrieveOpenAIParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("as_of", "2019-12-27T18:11:19.117Z").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + DatasetRetrieveOpenAIParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveOpenAIResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveOpenAIResponseTest.kt new file mode 100644 index 00000000..b27bbaee --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveOpenAIResponseTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetRetrieveOpenAIResponseTest { + + @Test + fun create() { + val datasetRetrieveOpenAIResponse = DatasetRetrieveOpenAIResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val datasetRetrieveOpenAIResponse = DatasetRetrieveOpenAIResponse.builder().build() + + val roundtrippedDatasetRetrieveOpenAIResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(datasetRetrieveOpenAIResponse), + jacksonTypeRef<DatasetRetrieveOpenAIResponse>(), + ) + + assertThat(roundtrippedDatasetRetrieveOpenAIResponse) + .isEqualTo(datasetRetrieveOpenAIResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveParamsTest.kt new file mode 100644 index 00000000..37d08dea --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveParamsTest.kt @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetRetrieveParamsTest { + + @Test + fun create() { + DatasetRetrieveParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + DatasetRetrieveParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveVersionParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveVersionParamsTest.kt new file mode 100644 index 00000000..8910a67f --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetRetrieveVersionParamsTest.kt @@ -0,0 +1,64 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.langsmith_api.api.core.http.QueryParams +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetRetrieveVersionParamsTest { + + @Test + fun create() { + DatasetRetrieveVersionParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tag("tag") + .build() + } + + @Test + fun pathParams() { + val params = + DatasetRetrieveVersionParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + DatasetRetrieveVersionParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tag("tag") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("as_of", "2019-12-27T18:11:19.117Z") + .put("tag", "tag") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + DatasetRetrieveVersionParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetSearchParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetSearchParamsTest.kt new file mode 100644 index 00000000..f05cdec9 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetSearchParamsTest.kt @@ -0,0 +1,66 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.langsmith_api.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetSearchParamsTest { + + @Test + fun create() { + DatasetSearchParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .debug(true) + .filter("filter") + .limit(1L) + .build() + } + + @Test + fun pathParams() { + val params = + DatasetSearchParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + DatasetSearchParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .debug(true) + .filter("filter") + .limit(1L) + .build() + + val body = params._body() + + assertThat(body._inputs()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(body.debug()).contains(true) + assertThat(body.filter()).contains("filter") + assertThat(body.limit()).contains(1L) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + DatasetSearchParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .build() + + val body = params._body() + + assertThat(body._inputs()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetSearchResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetSearchResponseTest.kt new file mode 100644 index 00000000..ceac787a --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetSearchResponseTest.kt @@ -0,0 +1,61 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetSearchResponseTest { + + @Test + fun create() { + val datasetSearchResponse = + DatasetSearchResponse.builder() + .addExample( + DatasetSearchResponse.Example.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .outputs(JsonValue.from(mapOf<String, Any>())) + .debugInfo(JsonValue.from(mapOf<String, Any>())) + .build() + ) + .build() + + assertThat(datasetSearchResponse.examples()) + .containsExactly( + DatasetSearchResponse.Example.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .outputs(JsonValue.from(mapOf<String, Any>())) + .debugInfo(JsonValue.from(mapOf<String, Any>())) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val datasetSearchResponse = + DatasetSearchResponse.builder() + .addExample( + DatasetSearchResponse.Example.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .outputs(JsonValue.from(mapOf<String, Any>())) + .debugInfo(JsonValue.from(mapOf<String, Any>())) + .build() + ) + .build() + + val roundtrippedDatasetSearchResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(datasetSearchResponse), + jacksonTypeRef<DatasetSearchResponse>(), + ) + + assertThat(roundtrippedDatasetSearchResponse).isEqualTo(datasetSearchResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetStudioExperimentParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetStudioExperimentParamsTest.kt new file mode 100644 index 00000000..f1166a0b --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetStudioExperimentParamsTest.kt @@ -0,0 +1,50 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetStudioExperimentParamsTest { + + @Test + fun create() { + DatasetStudioExperimentParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .addEvaluatorRule("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun body() { + val params = + DatasetStudioExperimentParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .addEvaluatorRule("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + + assertThat(body.datasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.projectName()).isEqualTo("project_name") + assertThat(body.evaluatorRules().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + DatasetStudioExperimentParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .build() + + val body = params._body() + + assertThat(body.datasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.projectName()).isEqualTo("project_name") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetStudioExperimentResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetStudioExperimentResponseTest.kt new file mode 100644 index 00000000..98406d0d --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetStudioExperimentResponseTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetStudioExperimentResponseTest { + + @Test + fun create() { + val datasetStudioExperimentResponse = DatasetStudioExperimentResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val datasetStudioExperimentResponse = DatasetStudioExperimentResponse.builder().build() + + val roundtrippedDatasetStudioExperimentResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(datasetStudioExperimentResponse), + jacksonTypeRef<DatasetStudioExperimentResponse>(), + ) + + assertThat(roundtrippedDatasetStudioExperimentResponse) + .isEqualTo(datasetStudioExperimentResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetTest.kt new file mode 100644 index 00000000..371d9856 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetTest.kt @@ -0,0 +1,105 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetTest { + + @Test + fun create() { + val dataset = + Dataset.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .exampleCount(0L) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .sessionCount(0L) + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dataType(DataType.KV) + .description("description") + .externallyManaged(true) + .inputsSchemaDefinition(JsonValue.from(mapOf<String, Any>())) + .lastSessionStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .metadata(JsonValue.from(mapOf<String, Any>())) + .outputsSchemaDefinition(JsonValue.from(mapOf<String, Any>())) + .addTransformation( + DatasetTransformation.builder() + .addPath("string") + .transformationType( + DatasetTransformation.TransformationType.CONVERT_TO_OPENAI_MESSAGE + ) + .build() + ) + .build() + + assertThat(dataset.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(dataset.exampleCount()).isEqualTo(0L) + assertThat(dataset.modifiedAt()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(dataset.name()).isEqualTo("name") + assertThat(dataset.sessionCount()).isEqualTo(0L) + assertThat(dataset.tenantId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(dataset.createdAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(dataset.dataType()).contains(DataType.KV) + assertThat(dataset.description()).contains("description") + assertThat(dataset.externallyManaged()).contains(true) + assertThat(dataset._inputsSchemaDefinition()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(dataset.lastSessionStartTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(dataset._metadata()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(dataset._outputsSchemaDefinition()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(dataset.transformations().getOrNull()) + .containsExactly( + DatasetTransformation.builder() + .addPath("string") + .transformationType( + DatasetTransformation.TransformationType.CONVERT_TO_OPENAI_MESSAGE + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val dataset = + Dataset.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .exampleCount(0L) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .sessionCount(0L) + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dataType(DataType.KV) + .description("description") + .externallyManaged(true) + .inputsSchemaDefinition(JsonValue.from(mapOf<String, Any>())) + .lastSessionStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .metadata(JsonValue.from(mapOf<String, Any>())) + .outputsSchemaDefinition(JsonValue.from(mapOf<String, Any>())) + .addTransformation( + DatasetTransformation.builder() + .addPath("string") + .transformationType( + DatasetTransformation.TransformationType.CONVERT_TO_OPENAI_MESSAGE + ) + .build() + ) + .build() + + val roundtrippedDataset = + jsonMapper.readValue(jsonMapper.writeValueAsString(dataset), jacksonTypeRef<Dataset>()) + + assertThat(roundtrippedDataset).isEqualTo(dataset) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetTransformationTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetTransformationTest.kt new file mode 100644 index 00000000..de127fa6 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetTransformationTest.kt @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetTransformationTest { + + @Test + fun create() { + val datasetTransformation = + DatasetTransformation.builder() + .addPath("string") + .transformationType( + DatasetTransformation.TransformationType.CONVERT_TO_OPENAI_MESSAGE + ) + .build() + + assertThat(datasetTransformation.path()).containsExactly("string") + assertThat(datasetTransformation.transformationType()) + .isEqualTo(DatasetTransformation.TransformationType.CONVERT_TO_OPENAI_MESSAGE) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val datasetTransformation = + DatasetTransformation.builder() + .addPath("string") + .transformationType( + DatasetTransformation.TransformationType.CONVERT_TO_OPENAI_MESSAGE + ) + .build() + + val roundtrippedDatasetTransformation = + jsonMapper.readValue( + jsonMapper.writeValueAsString(datasetTransformation), + jacksonTypeRef<DatasetTransformation>(), + ) + + assertThat(roundtrippedDatasetTransformation).isEqualTo(datasetTransformation) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUpdateParamsTest.kt new file mode 100644 index 00000000..280cc690 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUpdateParamsTest.kt @@ -0,0 +1,174 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.langsmith_api.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetUpdateParamsTest { + + @Test + fun create() { + DatasetUpdateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("string") + .inputsSchemaDefinition(JsonValue.from(mapOf<String, Any>())) + .metadata(JsonValue.from(mapOf<String, Any>())) + .name("string") + .outputsSchemaDefinition(JsonValue.from(mapOf<String, Any>())) + .patchExamples( + DatasetUpdateParams.PatchExamples.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "attachments_operations" to + mapOf( + "rename" to mapOf("foo" to "string"), + "retain" to listOf("string"), + ), + "dataset_id" to "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "inputs" to mapOf<String, Any>(), + "metadata" to mapOf<String, Any>(), + "outputs" to mapOf<String, Any>(), + "overwrite" to true, + "split" to listOf("string"), + ) + ), + ) + .build() + ) + .transformationsOfDataset( + listOf( + DatasetTransformation.builder() + .addPath("string") + .transformationType( + DatasetTransformation.TransformationType.CONVERT_TO_OPENAI_MESSAGE + ) + .build() + ) + ) + .build() + } + + @Test + fun pathParams() { + val params = + DatasetUpdateParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + DatasetUpdateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("string") + .inputsSchemaDefinition(JsonValue.from(mapOf<String, Any>())) + .metadata(JsonValue.from(mapOf<String, Any>())) + .name("string") + .outputsSchemaDefinition(JsonValue.from(mapOf<String, Any>())) + .patchExamples( + DatasetUpdateParams.PatchExamples.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "attachments_operations" to + mapOf( + "rename" to mapOf("foo" to "string"), + "retain" to listOf("string"), + ), + "dataset_id" to "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "inputs" to mapOf<String, Any>(), + "metadata" to mapOf<String, Any>(), + "outputs" to mapOf<String, Any>(), + "overwrite" to true, + "split" to listOf("string"), + ) + ), + ) + .build() + ) + .transformationsOfDataset( + listOf( + DatasetTransformation.builder() + .addPath("string") + .transformationType( + DatasetTransformation.TransformationType.CONVERT_TO_OPENAI_MESSAGE + ) + .build() + ) + ) + .build() + + val body = params._body() + + assertThat(body.description()).contains(DatasetUpdateParams.Description.ofString("string")) + assertThat(body.inputsSchemaDefinition()) + .contains( + DatasetUpdateParams.InputsSchemaDefinition.ofJsonValue( + JsonValue.from(mapOf<String, Any>()) + ) + ) + assertThat(body.metadata()) + .contains( + DatasetUpdateParams.Metadata.ofJsonValue(JsonValue.from(mapOf<String, Any>())) + ) + assertThat(body.name()).contains(DatasetUpdateParams.Name.ofString("string")) + assertThat(body.outputsSchemaDefinition()) + .contains( + DatasetUpdateParams.OutputsSchemaDefinition.ofJsonValue( + JsonValue.from(mapOf<String, Any>()) + ) + ) + assertThat(body.patchExamples()) + .contains( + DatasetUpdateParams.PatchExamples.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "attachments_operations" to + mapOf( + "rename" to mapOf("foo" to "string"), + "retain" to listOf("string"), + ), + "dataset_id" to "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "inputs" to mapOf<String, Any>(), + "metadata" to mapOf<String, Any>(), + "outputs" to mapOf<String, Any>(), + "overwrite" to true, + "split" to listOf("string"), + ) + ), + ) + .build() + ) + assertThat(body.transformations()) + .contains( + DatasetUpdateParams.Transformations.ofDataset( + listOf( + DatasetTransformation.builder() + .addPath("string") + .transformationType( + DatasetTransformation.TransformationType.CONVERT_TO_OPENAI_MESSAGE + ) + .build() + ) + ) + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + DatasetUpdateParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + val body = params._body() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUpdateResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUpdateResponseTest.kt new file mode 100644 index 00000000..0ddc5121 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUpdateResponseTest.kt @@ -0,0 +1,94 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetUpdateResponseTest { + + @Test + fun create() { + val datasetUpdateResponse = + DatasetUpdateResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dataType(DataType.KV) + .description("description") + .externallyManaged(true) + .inputsSchemaDefinition(JsonValue.from(mapOf<String, Any>())) + .outputsSchemaDefinition(JsonValue.from(mapOf<String, Any>())) + .addTransformation( + DatasetTransformation.builder() + .addPath("string") + .transformationType( + DatasetTransformation.TransformationType.CONVERT_TO_OPENAI_MESSAGE + ) + .build() + ) + .build() + + assertThat(datasetUpdateResponse.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(datasetUpdateResponse.name()).isEqualTo("name") + assertThat(datasetUpdateResponse.tenantId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(datasetUpdateResponse.createdAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(datasetUpdateResponse.dataType()).contains(DataType.KV) + assertThat(datasetUpdateResponse.description()).contains("description") + assertThat(datasetUpdateResponse.externallyManaged()).contains(true) + assertThat(datasetUpdateResponse._inputsSchemaDefinition()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(datasetUpdateResponse._outputsSchemaDefinition()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(datasetUpdateResponse.transformations().getOrNull()) + .containsExactly( + DatasetTransformation.builder() + .addPath("string") + .transformationType( + DatasetTransformation.TransformationType.CONVERT_TO_OPENAI_MESSAGE + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val datasetUpdateResponse = + DatasetUpdateResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dataType(DataType.KV) + .description("description") + .externallyManaged(true) + .inputsSchemaDefinition(JsonValue.from(mapOf<String, Any>())) + .outputsSchemaDefinition(JsonValue.from(mapOf<String, Any>())) + .addTransformation( + DatasetTransformation.builder() + .addPath("string") + .transformationType( + DatasetTransformation.TransformationType.CONVERT_TO_OPENAI_MESSAGE + ) + .build() + ) + .build() + + val roundtrippedDatasetUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(datasetUpdateResponse), + jacksonTypeRef<DatasetUpdateResponse>(), + ) + + assertThat(roundtrippedDatasetUpdateResponse).isEqualTo(datasetUpdateResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUpdateTagsParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUpdateTagsParamsTest.kt new file mode 100644 index 00000000..bf6bacc9 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUpdateTagsParamsTest.kt @@ -0,0 +1,53 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetUpdateTagsParamsTest { + + @Test + fun create() { + DatasetUpdateTagsParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tag("tag") + .build() + } + + @Test + fun pathParams() { + val params = + DatasetUpdateTagsParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tag("tag") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + DatasetUpdateTagsParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tag("tag") + .build() + + val body = params._body() + + assertThat(body.asOf()) + .isEqualTo( + DatasetUpdateTagsParams.AsOf.ofOffsetDateTime( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + ) + assertThat(body.tag()).isEqualTo("tag") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUploadExperimentParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUploadExperimentParamsTest.kt new file mode 100644 index 00000000..358cd26f --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUploadExperimentParamsTest.kt @@ -0,0 +1,325 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.feedback.AppFeedbackSource +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfig +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetUploadExperimentParamsTest { + + @Test + fun create() { + DatasetUploadExperimentParams.builder() + .experimentEndTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .experimentName("experiment_name") + .experimentStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addResult( + DatasetUploadExperimentParams.Result.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inputs(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .actualOutputs(JsonValue.from(mapOf<String, Any>())) + .error("error") + .addEvaluationScore( + FeedbackCreateCoreSchema.builder() + .key("key") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .correction(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder() + .value(0.0) + .label("x") + .build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .feedbackGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackSource( + AppFeedbackSource.builder() + .metadata(JsonValue.from(mapOf<String, Any>())) + .type("type") + .build() + ) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .score(0.0) + .value(0.0) + .build() + ) + .expectedOutputs(JsonValue.from(mapOf<String, Any>())) + .rowId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runMetadata(JsonValue.from(mapOf<String, Any>())) + .runName("run_name") + .build() + ) + .datasetDescription("dataset_description") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetName("dataset_name") + .experimentDescription("experiment_description") + .experimentMetadata(JsonValue.from(mapOf<String, Any>())) + .addSummaryExperimentScore( + FeedbackCreateCoreSchema.builder() + .key("key") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .correction(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder().value(0.0).label("x").build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .feedbackGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackSource( + AppFeedbackSource.builder() + .metadata(JsonValue.from(mapOf<String, Any>())) + .type("type") + .build() + ) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .score(0.0) + .value(0.0) + .build() + ) + .build() + } + + @Test + fun body() { + val params = + DatasetUploadExperimentParams.builder() + .experimentEndTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .experimentName("experiment_name") + .experimentStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addResult( + DatasetUploadExperimentParams.Result.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inputs(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .actualOutputs(JsonValue.from(mapOf<String, Any>())) + .error("error") + .addEvaluationScore( + FeedbackCreateCoreSchema.builder() + .key("key") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .correction(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder() + .value(0.0) + .label("x") + .build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .feedbackGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackSource( + AppFeedbackSource.builder() + .metadata(JsonValue.from(mapOf<String, Any>())) + .type("type") + .build() + ) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .score(0.0) + .value(0.0) + .build() + ) + .expectedOutputs(JsonValue.from(mapOf<String, Any>())) + .rowId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runMetadata(JsonValue.from(mapOf<String, Any>())) + .runName("run_name") + .build() + ) + .datasetDescription("dataset_description") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetName("dataset_name") + .experimentDescription("experiment_description") + .experimentMetadata(JsonValue.from(mapOf<String, Any>())) + .addSummaryExperimentScore( + FeedbackCreateCoreSchema.builder() + .key("key") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .correction(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder().value(0.0).label("x").build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .feedbackGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackSource( + AppFeedbackSource.builder() + .metadata(JsonValue.from(mapOf<String, Any>())) + .type("type") + .build() + ) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .score(0.0) + .value(0.0) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.experimentEndTime()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(body.experimentName()).isEqualTo("experiment_name") + assertThat(body.experimentStartTime()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(body.results()) + .containsExactly( + DatasetUploadExperimentParams.Result.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inputs(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .actualOutputs(JsonValue.from(mapOf<String, Any>())) + .error("error") + .addEvaluationScore( + FeedbackCreateCoreSchema.builder() + .key("key") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .correction(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder() + .value(0.0) + .label("x") + .build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .feedbackGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackSource( + AppFeedbackSource.builder() + .metadata(JsonValue.from(mapOf<String, Any>())) + .type("type") + .build() + ) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .score(0.0) + .value(0.0) + .build() + ) + .expectedOutputs(JsonValue.from(mapOf<String, Any>())) + .rowId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runMetadata(JsonValue.from(mapOf<String, Any>())) + .runName("run_name") + .build() + ) + assertThat(body.datasetDescription()).contains("dataset_description") + assertThat(body.datasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.datasetName()).contains("dataset_name") + assertThat(body.experimentDescription()).contains("experiment_description") + assertThat(body._experimentMetadata()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(body.summaryExperimentScores().getOrNull()) + .containsExactly( + FeedbackCreateCoreSchema.builder() + .key("key") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .correction(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder().value(0.0).label("x").build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .feedbackGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackSource( + AppFeedbackSource.builder() + .metadata(JsonValue.from(mapOf<String, Any>())) + .type("type") + .build() + ) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .score(0.0) + .value(0.0) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + DatasetUploadExperimentParams.builder() + .experimentEndTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .experimentName("experiment_name") + .experimentStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addResult( + DatasetUploadExperimentParams.Result.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inputs(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.experimentEndTime()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(body.experimentName()).isEqualTo("experiment_name") + assertThat(body.experimentStartTime()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(body.results()) + .containsExactly( + DatasetUploadExperimentParams.Result.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inputs(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUploadExperimentResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUploadExperimentResponseTest.kt new file mode 100644 index 00000000..af1c64ff --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUploadExperimentResponseTest.kt @@ -0,0 +1,221 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TraceTier +import com.langsmith_api.api.models.api.v1.sessions.TracerSession +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetUploadExperimentResponseTest { + + @Test + fun create() { + val datasetUploadExperimentResponse = + DatasetUploadExperimentResponse.builder() + .dataset( + Dataset.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .exampleCount(0L) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .sessionCount(0L) + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dataType(DataType.KV) + .description("description") + .externallyManaged(true) + .inputsSchemaDefinition(JsonValue.from(mapOf<String, Any>())) + .lastSessionStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .metadata(JsonValue.from(mapOf<String, Any>())) + .outputsSchemaDefinition(JsonValue.from(mapOf<String, Any>())) + .addTransformation( + DatasetTransformation.builder() + .addPath("string") + .transformationType( + DatasetTransformation.TransformationType + .CONVERT_TO_OPENAI_MESSAGE + ) + .build() + ) + .build() + ) + .experiment( + TracerSession.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost("completion_cost") + .completionTokens(0L) + .defaultDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .errorRate(0.0) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats(JsonValue.from(mapOf<String, Any>())) + .firstTokenP50(0.0) + .firstTokenP99(0.0) + .lastRunStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lastRunStartTimeLive(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .latencyP50(0.0) + .latencyP99(0.0) + .name("name") + .promptCost("prompt_cost") + .promptTokens(0L) + .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runCount(0L) + .addRunFacet(JsonValue.from(mapOf<String, Any>())) + .sessionFeedbackStats(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .streamingRate(0.0) + .testRunNumber(0L) + .totalCost("total_cost") + .totalTokens(0L) + .traceTier(TraceTier.LONGLIVED) + .build() + ) + .build() + + assertThat(datasetUploadExperimentResponse.dataset()) + .isEqualTo( + Dataset.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .exampleCount(0L) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .sessionCount(0L) + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dataType(DataType.KV) + .description("description") + .externallyManaged(true) + .inputsSchemaDefinition(JsonValue.from(mapOf<String, Any>())) + .lastSessionStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .metadata(JsonValue.from(mapOf<String, Any>())) + .outputsSchemaDefinition(JsonValue.from(mapOf<String, Any>())) + .addTransformation( + DatasetTransformation.builder() + .addPath("string") + .transformationType( + DatasetTransformation.TransformationType.CONVERT_TO_OPENAI_MESSAGE + ) + .build() + ) + .build() + ) + assertThat(datasetUploadExperimentResponse.experiment()) + .isEqualTo( + TracerSession.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost("completion_cost") + .completionTokens(0L) + .defaultDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .errorRate(0.0) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats(JsonValue.from(mapOf<String, Any>())) + .firstTokenP50(0.0) + .firstTokenP99(0.0) + .lastRunStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lastRunStartTimeLive(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .latencyP50(0.0) + .latencyP99(0.0) + .name("name") + .promptCost("prompt_cost") + .promptTokens(0L) + .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runCount(0L) + .addRunFacet(JsonValue.from(mapOf<String, Any>())) + .sessionFeedbackStats(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .streamingRate(0.0) + .testRunNumber(0L) + .totalCost("total_cost") + .totalTokens(0L) + .traceTier(TraceTier.LONGLIVED) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val datasetUploadExperimentResponse = + DatasetUploadExperimentResponse.builder() + .dataset( + Dataset.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .exampleCount(0L) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .sessionCount(0L) + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dataType(DataType.KV) + .description("description") + .externallyManaged(true) + .inputsSchemaDefinition(JsonValue.from(mapOf<String, Any>())) + .lastSessionStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .metadata(JsonValue.from(mapOf<String, Any>())) + .outputsSchemaDefinition(JsonValue.from(mapOf<String, Any>())) + .addTransformation( + DatasetTransformation.builder() + .addPath("string") + .transformationType( + DatasetTransformation.TransformationType + .CONVERT_TO_OPENAI_MESSAGE + ) + .build() + ) + .build() + ) + .experiment( + TracerSession.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost("completion_cost") + .completionTokens(0L) + .defaultDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .errorRate(0.0) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats(JsonValue.from(mapOf<String, Any>())) + .firstTokenP50(0.0) + .firstTokenP99(0.0) + .lastRunStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lastRunStartTimeLive(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .latencyP50(0.0) + .latencyP99(0.0) + .name("name") + .promptCost("prompt_cost") + .promptTokens(0L) + .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runCount(0L) + .addRunFacet(JsonValue.from(mapOf<String, Any>())) + .sessionFeedbackStats(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .streamingRate(0.0) + .testRunNumber(0L) + .totalCost("total_cost") + .totalTokens(0L) + .traceTier(TraceTier.LONGLIVED) + .build() + ) + .build() + + val roundtrippedDatasetUploadExperimentResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(datasetUploadExperimentResponse), + jacksonTypeRef<DatasetUploadExperimentResponse>(), + ) + + assertThat(roundtrippedDatasetUploadExperimentResponse) + .isEqualTo(datasetUploadExperimentResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUploadParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUploadParamsTest.kt new file mode 100644 index 00000000..3af3a2d6 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetUploadParamsTest.kt @@ -0,0 +1,111 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.langsmith_api.api.core.MultipartField +import java.io.InputStream +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetUploadParamsTest { + + @Test + fun create() { + DatasetUploadParams.builder() + .file("some content".byteInputStream()) + .addInputKey("string") + .dataType(DataType.KV) + .description("description") + .inputKeyMappings("input_key_mappings") + .inputsSchemaDefinition("inputs_schema_definition") + .metadataKeyMappings("metadata_key_mappings") + .addMetadataKey("string") + .name("name") + .outputKeyMappings("output_key_mappings") + .addOutputKey("string") + .outputsSchemaDefinition("outputs_schema_definition") + .transformations("transformations") + .build() + } + + @Test + fun body() { + val params = + DatasetUploadParams.builder() + .file("some content".byteInputStream()) + .addInputKey("string") + .dataType(DataType.KV) + .description("description") + .inputKeyMappings("input_key_mappings") + .inputsSchemaDefinition("inputs_schema_definition") + .metadataKeyMappings("metadata_key_mappings") + .addMetadataKey("string") + .name("name") + .outputKeyMappings("output_key_mappings") + .addOutputKey("string") + .outputsSchemaDefinition("outputs_schema_definition") + .transformations("transformations") + .build() + + val body = params._body() + + assertThat(body.filterValues { !it.value.isNull() }) + .usingRecursiveComparison() + // TODO(AssertJ): Replace this and the `mapValues` below with: + // https://github.com/assertj/assertj/issues/3165 + .withEqualsForType( + { a, b -> a.readBytes() contentEquals b.readBytes() }, + InputStream::class.java, + ) + .isEqualTo( + mapOf( + "file" to MultipartField.of("some content".byteInputStream()), + "input_keys" to MultipartField.of(listOf("string")), + "data_type" to MultipartField.of(DataType.KV), + "description" to MultipartField.of("description"), + "input_key_mappings" to MultipartField.of("input_key_mappings"), + "inputs_schema_definition" to MultipartField.of("inputs_schema_definition"), + "metadata_key_mappings" to MultipartField.of("metadata_key_mappings"), + "metadata_keys" to MultipartField.of(listOf("string")), + "name" to MultipartField.of("name"), + "output_key_mappings" to MultipartField.of("output_key_mappings"), + "output_keys" to MultipartField.of(listOf("string")), + "outputs_schema_definition" to + MultipartField.of("outputs_schema_definition"), + "transformations" to MultipartField.of("transformations"), + ) + .mapValues { (_, field) -> + field.map { (it as? ByteArray)?.inputStream() ?: it } + } + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + DatasetUploadParams.builder() + .file("some content".byteInputStream()) + .addInputKey("string") + .build() + + val body = params._body() + + assertThat(body.filterValues { !it.value.isNull() }) + .usingRecursiveComparison() + // TODO(AssertJ): Replace this and the `mapValues` below with: + // https://github.com/assertj/assertj/issues/3165 + .withEqualsForType( + { a, b -> a.readBytes() contentEquals b.readBytes() }, + InputStream::class.java, + ) + .isEqualTo( + mapOf( + "file" to MultipartField.of("some content".byteInputStream()), + "input_keys" to MultipartField.of(listOf("string")), + ) + .mapValues { (_, field) -> + field.map { (it as? ByteArray)?.inputStream() ?: it } + } + ) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetVersionTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetVersionTest.kt new file mode 100644 index 00000000..65a76379 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/DatasetVersionTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetVersionTest { + + @Test + fun create() { + val datasetVersion = + DatasetVersion.builder() + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTag("string") + .build() + + assertThat(datasetVersion.asOf()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(datasetVersion.tags().getOrNull()).containsExactly("string") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val datasetVersion = + DatasetVersion.builder() + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTag("string") + .build() + + val roundtrippedDatasetVersion = + jsonMapper.readValue( + jsonMapper.writeValueAsString(datasetVersion), + jacksonTypeRef<DatasetVersion>(), + ) + + assertThat(roundtrippedDatasetVersion).isEqualTo(datasetVersion) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/FeedbackCreateCoreSchemaTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/FeedbackCreateCoreSchemaTest.kt new file mode 100644 index 00000000..5af0dd7b --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/FeedbackCreateCoreSchemaTest.kt @@ -0,0 +1,134 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.feedback.AppFeedbackSource +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfig +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FeedbackCreateCoreSchemaTest { + + @Test + fun create() { + val feedbackCreateCoreSchema = + FeedbackCreateCoreSchema.builder() + .key("key") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .correction(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder().value(0.0).label("x").build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .feedbackGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackSource( + AppFeedbackSource.builder() + .metadata(JsonValue.from(mapOf<String, Any>())) + .type("type") + .build() + ) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .score(0.0) + .value(0.0) + .build() + + assertThat(feedbackCreateCoreSchema.key()).isEqualTo("key") + assertThat(feedbackCreateCoreSchema.id()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(feedbackCreateCoreSchema.comment()).contains("comment") + assertThat(feedbackCreateCoreSchema.comparativeExperimentId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(feedbackCreateCoreSchema.correction()) + .contains( + FeedbackCreateCoreSchema.Correction.ofJsonValue( + JsonValue.from(mapOf<String, Any>()) + ) + ) + assertThat(feedbackCreateCoreSchema.createdAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(feedbackCreateCoreSchema._extra()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(feedbackCreateCoreSchema.feedbackConfig()) + .contains( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory(FeedbackConfig.Category.builder().value(0.0).label("x").build()) + .max(0.0) + .min(0.0) + .build() + ) + assertThat(feedbackCreateCoreSchema.feedbackGroupId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(feedbackCreateCoreSchema.feedbackSource()) + .contains( + FeedbackCreateCoreSchema.FeedbackSource.ofApp( + AppFeedbackSource.builder() + .metadata(JsonValue.from(mapOf<String, Any>())) + .type("type") + .build() + ) + ) + assertThat(feedbackCreateCoreSchema.modifiedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(feedbackCreateCoreSchema.score()) + .contains(FeedbackCreateCoreSchema.Score.ofNumber(0.0)) + assertThat(feedbackCreateCoreSchema.value()) + .contains(FeedbackCreateCoreSchema.Value.ofNumber(0.0)) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val feedbackCreateCoreSchema = + FeedbackCreateCoreSchema.builder() + .key("key") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .correction(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder().value(0.0).label("x").build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .feedbackGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackSource( + AppFeedbackSource.builder() + .metadata(JsonValue.from(mapOf<String, Any>())) + .type("type") + .build() + ) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .score(0.0) + .value(0.0) + .build() + + val roundtrippedFeedbackCreateCoreSchema = + jsonMapper.readValue( + jsonMapper.writeValueAsString(feedbackCreateCoreSchema), + jacksonTypeRef<FeedbackCreateCoreSchema>(), + ) + + assertThat(roundtrippedFeedbackCreateCoreSchema).isEqualTo(feedbackCreateCoreSchema) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/MissingTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/MissingTest.kt new file mode 100644 index 00000000..cbd6deec --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/MissingTest.kt @@ -0,0 +1,27 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MissingTest { + + @Test + fun create() { + val missing = Missing.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val missing = Missing.builder().build() + + val roundtrippedMissing = + jsonMapper.readValue(jsonMapper.writeValueAsString(missing), jacksonTypeRef<Missing>()) + + assertThat(roundtrippedMissing).isEqualTo(missing) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeCreateParamsTest.kt new file mode 100644 index 00000000..f6b8c6ba --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeCreateParamsTest.kt @@ -0,0 +1,65 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.comparative + +import com.langsmith_api.api.core.JsonValue +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComparativeCreateParamsTest { + + @Test + fun create() { + ComparativeCreateParams.builder() + .addExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .extra(JsonValue.from(mapOf<String, Any>())) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .build() + } + + @Test + fun body() { + val params = + ComparativeCreateParams.builder() + .addExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .extra(JsonValue.from(mapOf<String, Any>())) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .build() + + val body = params._body() + + assertThat(body.experimentIds()).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.referenceDatasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.id()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.createdAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(body.description()).contains("description") + assertThat(body._extra()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(body.modifiedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(body.name()).contains("name") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + ComparativeCreateParams.builder() + .addExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + + assertThat(body.experimentIds()).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.referenceDatasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeCreateResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeCreateResponseTest.kt new file mode 100644 index 00000000..97c328dc --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeCreateResponseTest.kt @@ -0,0 +1,66 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.comparative + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComparativeCreateResponseTest { + + @Test + fun create() { + val comparativeCreateResponse = + ComparativeCreateResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .extra(JsonValue.from(mapOf<String, Any>())) + .name("name") + .build() + + assertThat(comparativeCreateResponse.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(comparativeCreateResponse.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(comparativeCreateResponse.modifiedAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(comparativeCreateResponse.referenceDatasetId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(comparativeCreateResponse.tenantId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(comparativeCreateResponse.description()).contains("description") + assertThat(comparativeCreateResponse._extra()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(comparativeCreateResponse.name()).contains("name") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val comparativeCreateResponse = + ComparativeCreateResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .extra(JsonValue.from(mapOf<String, Any>())) + .name("name") + .build() + + val roundtrippedComparativeCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(comparativeCreateResponse), + jacksonTypeRef<ComparativeCreateResponse>(), + ) + + assertThat(roundtrippedComparativeCreateResponse).isEqualTo(comparativeCreateResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeDeleteParamsTest.kt new file mode 100644 index 00000000..7fc77c48 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeDeleteParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.comparative + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComparativeDeleteParamsTest { + + @Test + fun create() { + ComparativeDeleteParams.builder() + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + ComparativeDeleteParams.builder() + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeDeleteResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeDeleteResponseTest.kt new file mode 100644 index 00000000..ae5a742b --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeDeleteResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.comparative + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComparativeDeleteResponseTest { + + @Test + fun create() { + val comparativeDeleteResponse = ComparativeDeleteResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val comparativeDeleteResponse = ComparativeDeleteResponse.builder().build() + + val roundtrippedComparativeDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(comparativeDeleteResponse), + jacksonTypeRef<ComparativeDeleteResponse>(), + ) + + assertThat(roundtrippedComparativeDeleteResponse).isEqualTo(comparativeDeleteResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeListParamsTest.kt new file mode 100644 index 00000000..5e8aab56 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeListParamsTest.kt @@ -0,0 +1,78 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.comparative + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComparativeListParamsTest { + + @Test + fun create() { + ComparativeListParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .name("name") + .nameContains("name_contains") + .offset(0L) + .sortBy(SortByComparativeExperimentColumn.NAME) + .sortByDesc(true) + .build() + } + + @Test + fun pathParams() { + val params = + ComparativeListParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + ComparativeListParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .name("name") + .nameContains("name_contains") + .offset(0L) + .sortBy(SortByComparativeExperimentColumn.NAME) + .sortByDesc(true) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").joinToString(",")) + .put("limit", "1") + .put("name", "name") + .put("name_contains", "name_contains") + .put("offset", "0") + .put("sort_by", "name") + .put("sort_by_desc", "true") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + ComparativeListParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeListResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeListResponseTest.kt new file mode 100644 index 00000000..aba78e40 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/ComparativeListResponseTest.kt @@ -0,0 +1,88 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.comparative + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComparativeListResponseTest { + + @Test + fun create() { + val comparativeListResponse = + ComparativeListResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addExperimentsInfo( + SimpleExperimentInfo.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .build() + ) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats(JsonValue.from(mapOf<String, Any>())) + .name("name") + .build() + + assertThat(comparativeListResponse.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(comparativeListResponse.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(comparativeListResponse.experimentsInfo()) + .containsExactly( + SimpleExperimentInfo.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .build() + ) + assertThat(comparativeListResponse.modifiedAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(comparativeListResponse.referenceDatasetId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(comparativeListResponse.tenantId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(comparativeListResponse.description()).contains("description") + assertThat(comparativeListResponse._extra()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(comparativeListResponse._feedbackStats()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(comparativeListResponse.name()).contains("name") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val comparativeListResponse = + ComparativeListResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addExperimentsInfo( + SimpleExperimentInfo.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .build() + ) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats(JsonValue.from(mapOf<String, Any>())) + .name("name") + .build() + + val roundtrippedComparativeListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(comparativeListResponse), + jacksonTypeRef<ComparativeListResponse>(), + ) + + assertThat(roundtrippedComparativeListResponse).isEqualTo(comparativeListResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/SimpleExperimentInfoTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/SimpleExperimentInfoTest.kt new file mode 100644 index 00000000..4de20042 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/comparative/SimpleExperimentInfoTest.kt @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.comparative + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SimpleExperimentInfoTest { + + @Test + fun create() { + val simpleExperimentInfo = + SimpleExperimentInfo.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .build() + + assertThat(simpleExperimentInfo.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(simpleExperimentInfo.name()).isEqualTo("name") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val simpleExperimentInfo = + SimpleExperimentInfo.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .build() + + val roundtrippedSimpleExperimentInfo = + jsonMapper.readValue( + jsonMapper.writeValueAsString(simpleExperimentInfo), + jacksonTypeRef<SimpleExperimentInfo>(), + ) + + assertThat(roundtrippedSimpleExperimentInfo).isEqualTo(simpleExperimentInfo) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/experiments/ExperimentGroupedParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/experiments/ExperimentGroupedParamsTest.kt new file mode 100644 index 00000000..6c2dd299 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/experiments/ExperimentGroupedParamsTest.kt @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.experiments + +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ExperimentGroupedParamsTest { + + @Test + fun create() { + ExperimentGroupedParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metadataKey("x") + .datasetVersion("dataset_version") + .experimentLimit(1L) + .filter("filter") + .nameContains("name_contains") + .statsStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .useApproxStats(true) + .build() + } + + @Test + fun pathParams() { + val params = + ExperimentGroupedParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metadataKey("x") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + ExperimentGroupedParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metadataKey("x") + .datasetVersion("dataset_version") + .experimentLimit(1L) + .filter("filter") + .nameContains("name_contains") + .statsStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .useApproxStats(true) + .build() + + val body = params._body() + + assertThat(body.metadataKey()).isEqualTo("x") + assertThat(body.datasetVersion()).contains("dataset_version") + assertThat(body.experimentLimit()).contains(1L) + assertThat(body.filter()).contains("filter") + assertThat(body.nameContains()).contains("name_contains") + assertThat(body.statsStartTime()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(body.tagValueId().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.useApproxStats()).contains(true) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + ExperimentGroupedParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metadataKey("x") + .build() + + val body = params._body() + + assertThat(body.metadataKey()).isEqualTo("x") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/experiments/ExperimentGroupedResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/experiments/ExperimentGroupedResponseTest.kt new file mode 100644 index 00000000..6dfba9ff --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/experiments/ExperimentGroupedResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.experiments + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ExperimentGroupedResponseTest { + + @Test + fun create() { + val experimentGroupedResponse = ExperimentGroupedResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val experimentGroupedResponse = ExperimentGroupedResponse.builder().build() + + val roundtrippedExperimentGroupedResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(experimentGroupedResponse), + jacksonTypeRef<ExperimentGroupedResponse>(), + ) + + assertThat(roundtrippedExperimentGroupedResponse).isEqualTo(experimentGroupedResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/group/GroupRunsParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/group/GroupRunsParamsTest.kt new file mode 100644 index 00000000..5ad104ff --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/group/GroupRunsParamsTest.kt @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.group + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class GroupRunsParamsTest { + + @Test + fun create() { + GroupRunsParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupBy(GroupRunsParams.GroupBy.RUN_METADATA) + .metadataKey("metadata_key") + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .offset(0L) + .perGroupLimit(1L) + .preview(true) + .build() + } + + @Test + fun pathParams() { + val params = + GroupRunsParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupBy(GroupRunsParams.GroupBy.RUN_METADATA) + .metadataKey("metadata_key") + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + GroupRunsParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupBy(GroupRunsParams.GroupBy.RUN_METADATA) + .metadataKey("metadata_key") + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .offset(0L) + .perGroupLimit(1L) + .preview(true) + .build() + + val body = params._body() + + assertThat(body.groupBy()).isEqualTo(GroupRunsParams.GroupBy.RUN_METADATA) + assertThat(body.metadataKey()).isEqualTo("metadata_key") + assertThat(body.sessionIds()).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.limit()).contains(1L) + assertThat(body.offset()).contains(0L) + assertThat(body.perGroupLimit()).contains(1L) + assertThat(body.preview()).contains(true) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + GroupRunsParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupBy(GroupRunsParams.GroupBy.RUN_METADATA) + .metadataKey("metadata_key") + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + + assertThat(body.groupBy()).isEqualTo(GroupRunsParams.GroupBy.RUN_METADATA) + assertThat(body.metadataKey()).isEqualTo("metadata_key") + assertThat(body.sessionIds()).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/group/GroupRunsResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/group/GroupRunsResponseTest.kt new file mode 100644 index 00000000..d376ee87 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/group/GroupRunsResponseTest.kt @@ -0,0 +1,458 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.group + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.datasets.runs.ExampleWithRuns +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TraceTier +import com.langsmith_api.api.models.api.v1.runs.RunSchema +import com.langsmith_api.api.models.api.v1.runs.RunTypeEnum +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class GroupRunsResponseTest { + + @Test + fun create() { + val groupRunsResponse = + GroupRunsResponse.builder() + .addGroup( + GroupRunsResponse.Group.builder() + .examplesOfExampleWithRuns( + listOf( + ExampleWithRuns.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .name("name") + .addRun( + RunSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .appPath("app_path") + .dottedOrder("dotted_order") + .name("name") + .runType(RunTypeEnum.TOOL) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status("status") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost("completion_cost") + .completionCostDetails( + RunSchema.CompletionCostDetails.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .completionTokenDetails( + RunSchema.CompletionTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .completionTokens(0L) + .addDirectChildRunId( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e" + ) + .endTime( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .error("error") + .addEvent(JsonValue.from(mapOf<String, Any>())) + .executionOrder(1L) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats( + RunSchema.FeedbackStats.builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf<String, Any>()), + ) + .build() + ) + .firstTokenTime( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .inDataset(true) + .inputs(JsonValue.from(mapOf<String, Any>())) + .inputsPreview("inputs_preview") + .inputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .lastQueuedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .outputs(JsonValue.from(mapOf<String, Any>())) + .outputsPreview("outputs_preview") + .outputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .promptCost("prompt_cost") + .promptCostDetails( + RunSchema.PromptCostDetails.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .promptTokenDetails( + RunSchema.PromptTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .promptTokens(0L) + .referenceDatasetId( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e" + ) + .referenceExampleId( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e" + ) + .s3Urls(JsonValue.from(mapOf<String, Any>())) + .serialized(JsonValue.from(mapOf<String, Any>())) + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .addTag("string") + .threadId("thread_id") + .totalCost("total_cost") + .totalTokens(0L) + .traceFirstReceivedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .traceMaxStartTime( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .traceMinStartTime( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .traceTier(TraceTier.LONGLIVED) + .traceUpgrade(true) + .ttlSeconds(0L) + .build() + ) + .attachmentUrls(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .metadata(JsonValue.from(mapOf<String, Any>())) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .outputs(JsonValue.from(mapOf<String, Any>())) + .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + ) + .filter("filter") + .groupKey(JsonValue.from(mapOf<String, Any>())) + .completionCost("completion_cost") + .completionTokens(0L) + .count(0L) + .errorRate(0.0) + .feedbackStats(JsonValue.from(mapOf<String, Any>())) + .latencyP50(0.0) + .latencyP99(0.0) + .maxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .promptCost("prompt_cost") + .promptTokens(0L) + .totalCost("total_cost") + .totalTokens(0L) + .build() + ) + .build() + + assertThat(groupRunsResponse.groups()) + .containsExactly( + GroupRunsResponse.Group.builder() + .examplesOfExampleWithRuns( + listOf( + ExampleWithRuns.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .name("name") + .addRun( + RunSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .appPath("app_path") + .dottedOrder("dotted_order") + .name("name") + .runType(RunTypeEnum.TOOL) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status("status") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost("completion_cost") + .completionCostDetails( + RunSchema.CompletionCostDetails.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .completionTokenDetails( + RunSchema.CompletionTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .completionTokens(0L) + .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error("error") + .addEvent(JsonValue.from(mapOf<String, Any>())) + .executionOrder(1L) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats( + RunSchema.FeedbackStats.builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf<String, Any>()), + ) + .build() + ) + .firstTokenTime( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .inDataset(true) + .inputs(JsonValue.from(mapOf<String, Any>())) + .inputsPreview("inputs_preview") + .inputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .lastQueuedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .outputs(JsonValue.from(mapOf<String, Any>())) + .outputsPreview("outputs_preview") + .outputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .promptCost("prompt_cost") + .promptCostDetails( + RunSchema.PromptCostDetails.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .promptTokenDetails( + RunSchema.PromptTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .promptTokens(0L) + .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .s3Urls(JsonValue.from(mapOf<String, Any>())) + .serialized(JsonValue.from(mapOf<String, Any>())) + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTag("string") + .threadId("thread_id") + .totalCost("total_cost") + .totalTokens(0L) + .traceFirstReceivedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .traceMaxStartTime( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .traceMinStartTime( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .traceTier(TraceTier.LONGLIVED) + .traceUpgrade(true) + .ttlSeconds(0L) + .build() + ) + .attachmentUrls(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .metadata(JsonValue.from(mapOf<String, Any>())) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .outputs(JsonValue.from(mapOf<String, Any>())) + .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + ) + .filter("filter") + .groupKey(JsonValue.from(mapOf<String, Any>())) + .completionCost("completion_cost") + .completionTokens(0L) + .count(0L) + .errorRate(0.0) + .feedbackStats(JsonValue.from(mapOf<String, Any>())) + .latencyP50(0.0) + .latencyP99(0.0) + .maxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .promptCost("prompt_cost") + .promptTokens(0L) + .totalCost("total_cost") + .totalTokens(0L) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val groupRunsResponse = + GroupRunsResponse.builder() + .addGroup( + GroupRunsResponse.Group.builder() + .examplesOfExampleWithRuns( + listOf( + ExampleWithRuns.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .name("name") + .addRun( + RunSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .appPath("app_path") + .dottedOrder("dotted_order") + .name("name") + .runType(RunTypeEnum.TOOL) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status("status") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost("completion_cost") + .completionCostDetails( + RunSchema.CompletionCostDetails.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .completionTokenDetails( + RunSchema.CompletionTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .completionTokens(0L) + .addDirectChildRunId( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e" + ) + .endTime( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .error("error") + .addEvent(JsonValue.from(mapOf<String, Any>())) + .executionOrder(1L) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats( + RunSchema.FeedbackStats.builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf<String, Any>()), + ) + .build() + ) + .firstTokenTime( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .inDataset(true) + .inputs(JsonValue.from(mapOf<String, Any>())) + .inputsPreview("inputs_preview") + .inputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .lastQueuedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .outputs(JsonValue.from(mapOf<String, Any>())) + .outputsPreview("outputs_preview") + .outputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .promptCost("prompt_cost") + .promptCostDetails( + RunSchema.PromptCostDetails.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .promptTokenDetails( + RunSchema.PromptTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .promptTokens(0L) + .referenceDatasetId( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e" + ) + .referenceExampleId( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e" + ) + .s3Urls(JsonValue.from(mapOf<String, Any>())) + .serialized(JsonValue.from(mapOf<String, Any>())) + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .addTag("string") + .threadId("thread_id") + .totalCost("total_cost") + .totalTokens(0L) + .traceFirstReceivedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .traceMaxStartTime( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .traceMinStartTime( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .traceTier(TraceTier.LONGLIVED) + .traceUpgrade(true) + .ttlSeconds(0L) + .build() + ) + .attachmentUrls(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .metadata(JsonValue.from(mapOf<String, Any>())) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .outputs(JsonValue.from(mapOf<String, Any>())) + .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + ) + .filter("filter") + .groupKey(JsonValue.from(mapOf<String, Any>())) + .completionCost("completion_cost") + .completionTokens(0L) + .count(0L) + .errorRate(0.0) + .feedbackStats(JsonValue.from(mapOf<String, Any>())) + .latencyP50(0.0) + .latencyP99(0.0) + .maxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .promptCost("prompt_cost") + .promptTokens(0L) + .totalCost("total_cost") + .totalTokens(0L) + .build() + ) + .build() + + val roundtrippedGroupRunsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(groupRunsResponse), + jacksonTypeRef<GroupRunsResponse>(), + ) + + assertThat(roundtrippedGroupRunsResponse).isEqualTo(groupRunsResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexCreateParamsTest.kt new file mode 100644 index 00000000..7e07944f --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexCreateParamsTest.kt @@ -0,0 +1,48 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.index + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class IndexCreateParamsTest { + + @Test + fun create() { + IndexCreateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tag("tag") + .build() + } + + @Test + fun pathParams() { + val params = + IndexCreateParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + IndexCreateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tag("tag") + .build() + + val body = params._body() + + assertThat(body.tag()).contains("tag") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + IndexCreateParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + val body = params._body() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexCreateResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexCreateResponseTest.kt new file mode 100644 index 00000000..8764c4a2 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexCreateResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.index + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class IndexCreateResponseTest { + + @Test + fun create() { + val indexCreateResponse = IndexCreateResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val indexCreateResponse = IndexCreateResponse.builder().build() + + val roundtrippedIndexCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(indexCreateResponse), + jacksonTypeRef<IndexCreateResponse>(), + ) + + assertThat(roundtrippedIndexCreateResponse).isEqualTo(indexCreateResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexDeleteAllParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexDeleteAllParamsTest.kt new file mode 100644 index 00000000..93ac5d16 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexDeleteAllParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.index + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class IndexDeleteAllParamsTest { + + @Test + fun create() { + IndexDeleteAllParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + IndexDeleteAllParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexDeleteAllResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexDeleteAllResponseTest.kt new file mode 100644 index 00000000..626faa70 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexDeleteAllResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.index + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class IndexDeleteAllResponseTest { + + @Test + fun create() { + val indexDeleteAllResponse = IndexDeleteAllResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val indexDeleteAllResponse = IndexDeleteAllResponse.builder().build() + + val roundtrippedIndexDeleteAllResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(indexDeleteAllResponse), + jacksonTypeRef<IndexDeleteAllResponse>(), + ) + + assertThat(roundtrippedIndexDeleteAllResponse).isEqualTo(indexDeleteAllResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexListParamsTest.kt new file mode 100644 index 00000000..42135417 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexListParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.index + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class IndexListParamsTest { + + @Test + fun create() { + IndexListParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + IndexListParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexListResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexListResponseTest.kt new file mode 100644 index 00000000..20df206a --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexListResponseTest.kt @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.index + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class IndexListResponseTest { + + @Test + fun create() { + val indexListResponse = + IndexListResponse.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .lastUpdatedVersion(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tag("tag") + .build() + + assertThat(indexListResponse.datasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(indexListResponse.lastUpdatedVersion()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(indexListResponse.tag()).contains("tag") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val indexListResponse = + IndexListResponse.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .lastUpdatedVersion(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tag("tag") + .build() + + val roundtrippedIndexListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(indexListResponse), + jacksonTypeRef<IndexListResponse>(), + ) + + assertThat(roundtrippedIndexListResponse).isEqualTo(indexListResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexSyncParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexSyncParamsTest.kt new file mode 100644 index 00000000..b8c7ced3 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexSyncParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.index + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class IndexSyncParamsTest { + + @Test + fun create() { + IndexSyncParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + IndexSyncParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexSyncResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexSyncResponseTest.kt new file mode 100644 index 00000000..b5a83065 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/index/IndexSyncResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.index + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class IndexSyncResponseTest { + + @Test + fun create() { + val indexSyncResponse = IndexSyncResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val indexSyncResponse = IndexSyncResponse.builder().build() + + val roundtrippedIndexSyncResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(indexSyncResponse), + jacksonTypeRef<IndexSyncResponse>(), + ) + + assertThat(roundtrippedIndexSyncResponse).isEqualTo(indexSyncResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/PlaygroundExperimentBatchParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/PlaygroundExperimentBatchParamsTest.kt new file mode 100644 index 00000000..5a073661 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/PlaygroundExperimentBatchParamsTest.kt @@ -0,0 +1,164 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.playgroundexperiment + +import com.langsmith_api.api.core.JsonValue +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PlaygroundExperimentBatchParamsTest { + + @Test + fun create() { + PlaygroundExperimentBatchParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifest(JsonValue.from(mapOf<String, Any>())) + .options( + RunnableConfig.builder() + .callbacksOfJsonValues(listOf(JsonValue.from(mapOf<String, Any>()))) + .configurable(JsonValue.from(mapOf<String, Any>())) + .maxConcurrency(0L) + .metadata(JsonValue.from(mapOf<String, Any>())) + .recursionLimit(0L) + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runName("run_name") + .addTag("string") + .build() + ) + .projectName("project_name") + .secrets( + PlaygroundExperimentBatchParams.Secrets.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .batchSize(1L) + .commit("commit") + .addDatasetSplit("string") + .addEvaluatorRule("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .owner("owner") + .parallelToolCalls(true) + .repetitions(1L) + .repoHandle("repo_handle") + .repoId("repo_id") + .requestsPerSecond(0L) + .runId("run_id") + .runnerContext(RunnerContextEnum.LANGSMITH_UI) + .toolChoice("tool_choice") + .addTool(JsonValue.from(mapOf<String, Any>())) + .useOrFallbackToWorkspaceSecrets(true) + .build() + } + + @Test + fun body() { + val params = + PlaygroundExperimentBatchParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifest(JsonValue.from(mapOf<String, Any>())) + .options( + RunnableConfig.builder() + .callbacksOfJsonValues(listOf(JsonValue.from(mapOf<String, Any>()))) + .configurable(JsonValue.from(mapOf<String, Any>())) + .maxConcurrency(0L) + .metadata(JsonValue.from(mapOf<String, Any>())) + .recursionLimit(0L) + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runName("run_name") + .addTag("string") + .build() + ) + .projectName("project_name") + .secrets( + PlaygroundExperimentBatchParams.Secrets.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .batchSize(1L) + .commit("commit") + .addDatasetSplit("string") + .addEvaluatorRule("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .owner("owner") + .parallelToolCalls(true) + .repetitions(1L) + .repoHandle("repo_handle") + .repoId("repo_id") + .requestsPerSecond(0L) + .runId("run_id") + .runnerContext(RunnerContextEnum.LANGSMITH_UI) + .toolChoice("tool_choice") + .addTool(JsonValue.from(mapOf<String, Any>())) + .useOrFallbackToWorkspaceSecrets(true) + .build() + + val body = params._body() + + assertThat(body.datasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body._manifest()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(body.options()) + .isEqualTo( + RunnableConfig.builder() + .callbacksOfJsonValues(listOf(JsonValue.from(mapOf<String, Any>()))) + .configurable(JsonValue.from(mapOf<String, Any>())) + .maxConcurrency(0L) + .metadata(JsonValue.from(mapOf<String, Any>())) + .recursionLimit(0L) + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runName("run_name") + .addTag("string") + .build() + ) + assertThat(body.projectName()).isEqualTo("project_name") + assertThat(body.secrets()) + .isEqualTo( + PlaygroundExperimentBatchParams.Secrets.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(body.batchSize()).contains(1L) + assertThat(body.commit()).contains("commit") + assertThat(body.datasetSplits().getOrNull()).containsExactly("string") + assertThat(body.evaluatorRules().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.owner()).contains("owner") + assertThat(body.parallelToolCalls()).contains(true) + assertThat(body.repetitions()).contains(1L) + assertThat(body.repoHandle()).contains("repo_handle") + assertThat(body.repoId()).contains("repo_id") + assertThat(body.requestsPerSecond()).contains(0L) + assertThat(body.runId()).contains("run_id") + assertThat(body.runnerContext()).contains(RunnerContextEnum.LANGSMITH_UI) + assertThat(body.toolChoice()).contains("tool_choice") + assertThat(body.tools().getOrNull()).containsExactly(JsonValue.from(mapOf<String, Any>())) + assertThat(body.useOrFallbackToWorkspaceSecrets()).contains(true) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + PlaygroundExperimentBatchParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifest(JsonValue.from(mapOf<String, Any>())) + .options(RunnableConfig.builder().build()) + .projectName("project_name") + .secrets( + PlaygroundExperimentBatchParams.Secrets.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.datasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body._manifest()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(body.options()).isEqualTo(RunnableConfig.builder().build()) + assertThat(body.projectName()).isEqualTo("project_name") + assertThat(body.secrets()) + .isEqualTo( + PlaygroundExperimentBatchParams.Secrets.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/PlaygroundExperimentBatchResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/PlaygroundExperimentBatchResponseTest.kt new file mode 100644 index 00000000..3e95256c --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/PlaygroundExperimentBatchResponseTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.playgroundexperiment + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PlaygroundExperimentBatchResponseTest { + + @Test + fun create() { + val playgroundExperimentBatchResponse = PlaygroundExperimentBatchResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val playgroundExperimentBatchResponse = PlaygroundExperimentBatchResponse.builder().build() + + val roundtrippedPlaygroundExperimentBatchResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(playgroundExperimentBatchResponse), + jacksonTypeRef<PlaygroundExperimentBatchResponse>(), + ) + + assertThat(roundtrippedPlaygroundExperimentBatchResponse) + .isEqualTo(playgroundExperimentBatchResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/PlaygroundExperimentStreamParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/PlaygroundExperimentStreamParamsTest.kt new file mode 100644 index 00000000..d9d00c4b --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/PlaygroundExperimentStreamParamsTest.kt @@ -0,0 +1,161 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.playgroundexperiment + +import com.langsmith_api.api.core.JsonValue +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PlaygroundExperimentStreamParamsTest { + + @Test + fun create() { + PlaygroundExperimentStreamParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifest(JsonValue.from(mapOf<String, Any>())) + .options( + RunnableConfig.builder() + .callbacksOfJsonValues(listOf(JsonValue.from(mapOf<String, Any>()))) + .configurable(JsonValue.from(mapOf<String, Any>())) + .maxConcurrency(0L) + .metadata(JsonValue.from(mapOf<String, Any>())) + .recursionLimit(0L) + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runName("run_name") + .addTag("string") + .build() + ) + .projectName("project_name") + .secrets( + PlaygroundExperimentStreamParams.Secrets.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .commit("commit") + .addDatasetSplit("string") + .addEvaluatorRule("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .owner("owner") + .parallelToolCalls(true) + .repetitions(1L) + .repoHandle("repo_handle") + .repoId("repo_id") + .requestsPerSecond(0L) + .runId("run_id") + .runnerContext(RunnerContextEnum.LANGSMITH_UI) + .toolChoice("tool_choice") + .addTool(JsonValue.from(mapOf<String, Any>())) + .useOrFallbackToWorkspaceSecrets(true) + .build() + } + + @Test + fun body() { + val params = + PlaygroundExperimentStreamParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifest(JsonValue.from(mapOf<String, Any>())) + .options( + RunnableConfig.builder() + .callbacksOfJsonValues(listOf(JsonValue.from(mapOf<String, Any>()))) + .configurable(JsonValue.from(mapOf<String, Any>())) + .maxConcurrency(0L) + .metadata(JsonValue.from(mapOf<String, Any>())) + .recursionLimit(0L) + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runName("run_name") + .addTag("string") + .build() + ) + .projectName("project_name") + .secrets( + PlaygroundExperimentStreamParams.Secrets.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .commit("commit") + .addDatasetSplit("string") + .addEvaluatorRule("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .owner("owner") + .parallelToolCalls(true) + .repetitions(1L) + .repoHandle("repo_handle") + .repoId("repo_id") + .requestsPerSecond(0L) + .runId("run_id") + .runnerContext(RunnerContextEnum.LANGSMITH_UI) + .toolChoice("tool_choice") + .addTool(JsonValue.from(mapOf<String, Any>())) + .useOrFallbackToWorkspaceSecrets(true) + .build() + + val body = params._body() + + assertThat(body.datasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body._manifest()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(body.options()) + .isEqualTo( + RunnableConfig.builder() + .callbacksOfJsonValues(listOf(JsonValue.from(mapOf<String, Any>()))) + .configurable(JsonValue.from(mapOf<String, Any>())) + .maxConcurrency(0L) + .metadata(JsonValue.from(mapOf<String, Any>())) + .recursionLimit(0L) + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runName("run_name") + .addTag("string") + .build() + ) + assertThat(body.projectName()).isEqualTo("project_name") + assertThat(body.secrets()) + .isEqualTo( + PlaygroundExperimentStreamParams.Secrets.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(body.commit()).contains("commit") + assertThat(body.datasetSplits().getOrNull()).containsExactly("string") + assertThat(body.evaluatorRules().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.owner()).contains("owner") + assertThat(body.parallelToolCalls()).contains(true) + assertThat(body.repetitions()).contains(1L) + assertThat(body.repoHandle()).contains("repo_handle") + assertThat(body.repoId()).contains("repo_id") + assertThat(body.requestsPerSecond()).contains(0L) + assertThat(body.runId()).contains("run_id") + assertThat(body.runnerContext()).contains(RunnerContextEnum.LANGSMITH_UI) + assertThat(body.toolChoice()).contains("tool_choice") + assertThat(body.tools().getOrNull()).containsExactly(JsonValue.from(mapOf<String, Any>())) + assertThat(body.useOrFallbackToWorkspaceSecrets()).contains(true) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + PlaygroundExperimentStreamParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifest(JsonValue.from(mapOf<String, Any>())) + .options(RunnableConfig.builder().build()) + .projectName("project_name") + .secrets( + PlaygroundExperimentStreamParams.Secrets.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.datasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body._manifest()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(body.options()).isEqualTo(RunnableConfig.builder().build()) + assertThat(body.projectName()).isEqualTo("project_name") + assertThat(body.secrets()) + .isEqualTo( + PlaygroundExperimentStreamParams.Secrets.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/PlaygroundExperimentStreamResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/PlaygroundExperimentStreamResponseTest.kt new file mode 100644 index 00000000..e5e39911 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/PlaygroundExperimentStreamResponseTest.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.playgroundexperiment + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PlaygroundExperimentStreamResponseTest { + + @Test + fun create() { + val playgroundExperimentStreamResponse = + PlaygroundExperimentStreamResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val playgroundExperimentStreamResponse = + PlaygroundExperimentStreamResponse.builder().build() + + val roundtrippedPlaygroundExperimentStreamResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(playgroundExperimentStreamResponse), + jacksonTypeRef<PlaygroundExperimentStreamResponse>(), + ) + + assertThat(roundtrippedPlaygroundExperimentStreamResponse) + .isEqualTo(playgroundExperimentStreamResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/RunnableConfigTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/RunnableConfigTest.kt new file mode 100644 index 00000000..b9a4df80 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/playgroundexperiment/RunnableConfigTest.kt @@ -0,0 +1,64 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.playgroundexperiment + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunnableConfigTest { + + @Test + fun create() { + val runnableConfig = + RunnableConfig.builder() + .callbacksOfJsonValues(listOf(JsonValue.from(mapOf<String, Any>()))) + .configurable(JsonValue.from(mapOf<String, Any>())) + .maxConcurrency(0L) + .metadata(JsonValue.from(mapOf<String, Any>())) + .recursionLimit(0L) + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runName("run_name") + .addTag("string") + .build() + + assertThat(runnableConfig.callbacks()) + .contains( + RunnableConfig.Callbacks.ofJsonValues(listOf(JsonValue.from(mapOf<String, Any>()))) + ) + assertThat(runnableConfig._configurable()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(runnableConfig.maxConcurrency()).contains(0L) + assertThat(runnableConfig._metadata()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(runnableConfig.recursionLimit()).contains(0L) + assertThat(runnableConfig.runId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runnableConfig.runName()).contains("run_name") + assertThat(runnableConfig.tags().getOrNull()).containsExactly("string") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val runnableConfig = + RunnableConfig.builder() + .callbacksOfJsonValues(listOf(JsonValue.from(mapOf<String, Any>()))) + .configurable(JsonValue.from(mapOf<String, Any>())) + .maxConcurrency(0L) + .metadata(JsonValue.from(mapOf<String, Any>())) + .recursionLimit(0L) + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runName("run_name") + .addTag("string") + .build() + + val roundtrippedRunnableConfig = + jsonMapper.readValue( + jsonMapper.writeValueAsString(runnableConfig), + jacksonTypeRef<RunnableConfig>(), + ) + + assertThat(roundtrippedRunnableConfig).isEqualTo(runnableConfig) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/ExampleWithRunsChTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/ExampleWithRunsChTest.kt new file mode 100644 index 00000000..13fc080a --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/ExampleWithRunsChTest.kt @@ -0,0 +1,204 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.runs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.runs.RunTypeEnum +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ExampleWithRunsChTest { + + @Test + fun create() { + val exampleWithRunsCh = + ExampleWithRunsCh.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .name("name") + .addRun( + ExampleWithRunsCh.Run.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .runType(RunTypeEnum.TOOL) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status("status") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .appPath("app_path") + .completionCost("completion_cost") + .completionTokens(0L) + .dottedOrder("dotted_order") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error("error") + .addEvent(JsonValue.from(mapOf<String, Any>())) + .executionOrder(1L) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats( + ExampleWithRunsCh.Run.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf<String, Any>())) + .build() + ) + .inputs(JsonValue.from(mapOf<String, Any>())) + .inputsPreview("inputs_preview") + .inputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .outputs(JsonValue.from(mapOf<String, Any>())) + .outputsPreview("outputs_preview") + .outputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .promptCost("prompt_cost") + .promptTokens(0L) + .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .s3Urls(JsonValue.from(mapOf<String, Any>())) + .serialized(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTag("string") + .totalCost("total_cost") + .totalTokens(0L) + .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .attachmentUrls(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .metadata(JsonValue.from(mapOf<String, Any>())) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .outputs(JsonValue.from(mapOf<String, Any>())) + .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(exampleWithRunsCh.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(exampleWithRunsCh.datasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(exampleWithRunsCh._inputs()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(exampleWithRunsCh.name()).isEqualTo("name") + assertThat(exampleWithRunsCh.runs()) + .containsExactly( + ExampleWithRunsCh.Run.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .runType(RunTypeEnum.TOOL) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status("status") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .appPath("app_path") + .completionCost("completion_cost") + .completionTokens(0L) + .dottedOrder("dotted_order") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error("error") + .addEvent(JsonValue.from(mapOf<String, Any>())) + .executionOrder(1L) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats( + ExampleWithRunsCh.Run.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf<String, Any>())) + .build() + ) + .inputs(JsonValue.from(mapOf<String, Any>())) + .inputsPreview("inputs_preview") + .inputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .outputs(JsonValue.from(mapOf<String, Any>())) + .outputsPreview("outputs_preview") + .outputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .promptCost("prompt_cost") + .promptTokens(0L) + .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .s3Urls(JsonValue.from(mapOf<String, Any>())) + .serialized(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTag("string") + .totalCost("total_cost") + .totalTokens(0L) + .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(exampleWithRunsCh._attachmentUrls()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(exampleWithRunsCh.createdAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(exampleWithRunsCh._metadata()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(exampleWithRunsCh.modifiedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(exampleWithRunsCh._outputs()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(exampleWithRunsCh.sourceRunId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val exampleWithRunsCh = + ExampleWithRunsCh.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .name("name") + .addRun( + ExampleWithRunsCh.Run.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .runType(RunTypeEnum.TOOL) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status("status") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .appPath("app_path") + .completionCost("completion_cost") + .completionTokens(0L) + .dottedOrder("dotted_order") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error("error") + .addEvent(JsonValue.from(mapOf<String, Any>())) + .executionOrder(1L) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats( + ExampleWithRunsCh.Run.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf<String, Any>())) + .build() + ) + .inputs(JsonValue.from(mapOf<String, Any>())) + .inputsPreview("inputs_preview") + .inputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .outputs(JsonValue.from(mapOf<String, Any>())) + .outputsPreview("outputs_preview") + .outputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .promptCost("prompt_cost") + .promptTokens(0L) + .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .s3Urls(JsonValue.from(mapOf<String, Any>())) + .serialized(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTag("string") + .totalCost("total_cost") + .totalTokens(0L) + .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .attachmentUrls(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .metadata(JsonValue.from(mapOf<String, Any>())) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .outputs(JsonValue.from(mapOf<String, Any>())) + .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val roundtrippedExampleWithRunsCh = + jsonMapper.readValue( + jsonMapper.writeValueAsString(exampleWithRunsCh), + jacksonTypeRef<ExampleWithRunsCh>(), + ) + + assertThat(roundtrippedExampleWithRunsCh).isEqualTo(exampleWithRunsCh) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/ExampleWithRunsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/ExampleWithRunsTest.kt new file mode 100644 index 00000000..de89c902 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/ExampleWithRunsTest.kt @@ -0,0 +1,308 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.runs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TraceTier +import com.langsmith_api.api.models.api.v1.runs.RunSchema +import com.langsmith_api.api.models.api.v1.runs.RunTypeEnum +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ExampleWithRunsTest { + + @Test + fun create() { + val exampleWithRuns = + ExampleWithRuns.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .name("name") + .addRun( + RunSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .appPath("app_path") + .dottedOrder("dotted_order") + .name("name") + .runType(RunTypeEnum.TOOL) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status("status") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost("completion_cost") + .completionCostDetails( + RunSchema.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .completionTokenDetails( + RunSchema.CompletionTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .completionTokens(0L) + .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error("error") + .addEvent(JsonValue.from(mapOf<String, Any>())) + .executionOrder(1L) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats( + RunSchema.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf<String, Any>())) + .build() + ) + .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inDataset(true) + .inputs(JsonValue.from(mapOf<String, Any>())) + .inputsPreview("inputs_preview") + .inputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .lastQueuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .outputs(JsonValue.from(mapOf<String, Any>())) + .outputsPreview("outputs_preview") + .outputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .promptCost("prompt_cost") + .promptCostDetails( + RunSchema.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .promptTokenDetails( + RunSchema.PromptTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .promptTokens(0L) + .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .s3Urls(JsonValue.from(mapOf<String, Any>())) + .serialized(JsonValue.from(mapOf<String, Any>())) + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTag("string") + .threadId("thread_id") + .totalCost("total_cost") + .totalTokens(0L) + .traceFirstReceivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceTier(TraceTier.LONGLIVED) + .traceUpgrade(true) + .ttlSeconds(0L) + .build() + ) + .attachmentUrls(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .metadata(JsonValue.from(mapOf<String, Any>())) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .outputs(JsonValue.from(mapOf<String, Any>())) + .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(exampleWithRuns.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(exampleWithRuns.datasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(exampleWithRuns._inputs()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(exampleWithRuns.name()).isEqualTo("name") + assertThat(exampleWithRuns.runs()) + .containsExactly( + RunSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .appPath("app_path") + .dottedOrder("dotted_order") + .name("name") + .runType(RunTypeEnum.TOOL) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status("status") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost("completion_cost") + .completionCostDetails( + RunSchema.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .completionTokenDetails( + RunSchema.CompletionTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .completionTokens(0L) + .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error("error") + .addEvent(JsonValue.from(mapOf<String, Any>())) + .executionOrder(1L) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats( + RunSchema.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf<String, Any>())) + .build() + ) + .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inDataset(true) + .inputs(JsonValue.from(mapOf<String, Any>())) + .inputsPreview("inputs_preview") + .inputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .lastQueuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .outputs(JsonValue.from(mapOf<String, Any>())) + .outputsPreview("outputs_preview") + .outputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .promptCost("prompt_cost") + .promptCostDetails( + RunSchema.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .promptTokenDetails( + RunSchema.PromptTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .promptTokens(0L) + .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .s3Urls(JsonValue.from(mapOf<String, Any>())) + .serialized(JsonValue.from(mapOf<String, Any>())) + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTag("string") + .threadId("thread_id") + .totalCost("total_cost") + .totalTokens(0L) + .traceFirstReceivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceTier(TraceTier.LONGLIVED) + .traceUpgrade(true) + .ttlSeconds(0L) + .build() + ) + assertThat(exampleWithRuns._attachmentUrls()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(exampleWithRuns.createdAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(exampleWithRuns._metadata()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(exampleWithRuns.modifiedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(exampleWithRuns._outputs()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(exampleWithRuns.sourceRunId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val exampleWithRuns = + ExampleWithRuns.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .name("name") + .addRun( + RunSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .appPath("app_path") + .dottedOrder("dotted_order") + .name("name") + .runType(RunTypeEnum.TOOL) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status("status") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost("completion_cost") + .completionCostDetails( + RunSchema.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .completionTokenDetails( + RunSchema.CompletionTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .completionTokens(0L) + .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error("error") + .addEvent(JsonValue.from(mapOf<String, Any>())) + .executionOrder(1L) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats( + RunSchema.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf<String, Any>())) + .build() + ) + .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inDataset(true) + .inputs(JsonValue.from(mapOf<String, Any>())) + .inputsPreview("inputs_preview") + .inputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .lastQueuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .outputs(JsonValue.from(mapOf<String, Any>())) + .outputsPreview("outputs_preview") + .outputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .promptCost("prompt_cost") + .promptCostDetails( + RunSchema.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .promptTokenDetails( + RunSchema.PromptTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .promptTokens(0L) + .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .s3Urls(JsonValue.from(mapOf<String, Any>())) + .serialized(JsonValue.from(mapOf<String, Any>())) + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTag("string") + .threadId("thread_id") + .totalCost("total_cost") + .totalTokens(0L) + .traceFirstReceivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceTier(TraceTier.LONGLIVED) + .traceUpgrade(true) + .ttlSeconds(0L) + .build() + ) + .attachmentUrls(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .metadata(JsonValue.from(mapOf<String, Any>())) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .outputs(JsonValue.from(mapOf<String, Any>())) + .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val roundtrippedExampleWithRuns = + jsonMapper.readValue( + jsonMapper.writeValueAsString(exampleWithRuns), + jacksonTypeRef<ExampleWithRuns>(), + ) + + assertThat(roundtrippedExampleWithRuns).isEqualTo(exampleWithRuns) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/QueryExampleSchemaWithRunsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/QueryExampleSchemaWithRunsTest.kt new file mode 100644 index 00000000..46a8bcc1 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/QueryExampleSchemaWithRunsTest.kt @@ -0,0 +1,92 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.runs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class QueryExampleSchemaWithRunsTest { + + @Test + fun create() { + val queryExampleSchemaWithRuns = + QueryExampleSchemaWithRuns.builder() + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .filters( + QueryExampleSchemaWithRuns.Filters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + ) + .format(QueryExampleSchemaWithRuns.Format.CSV) + .limit(1L) + .offset(0L) + .preview(true) + .sortParams( + QueryExampleSchemaWithRuns.SortParams.builder() + .sortBy("sort_by") + .sortOrder(QueryExampleSchemaWithRuns.SortParams.SortOrder.ASC) + .build() + ) + .build() + + assertThat(queryExampleSchemaWithRuns.sessionIds()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(queryExampleSchemaWithRuns.comparativeExperimentId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(queryExampleSchemaWithRuns.filters()) + .contains( + QueryExampleSchemaWithRuns.Filters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + ) + assertThat(queryExampleSchemaWithRuns.format()) + .contains(QueryExampleSchemaWithRuns.Format.CSV) + assertThat(queryExampleSchemaWithRuns.limit()).contains(1L) + assertThat(queryExampleSchemaWithRuns.offset()).contains(0L) + assertThat(queryExampleSchemaWithRuns.preview()).contains(true) + assertThat(queryExampleSchemaWithRuns.sortParams()) + .contains( + QueryExampleSchemaWithRuns.SortParams.builder() + .sortBy("sort_by") + .sortOrder(QueryExampleSchemaWithRuns.SortParams.SortOrder.ASC) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val queryExampleSchemaWithRuns = + QueryExampleSchemaWithRuns.builder() + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .filters( + QueryExampleSchemaWithRuns.Filters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + ) + .format(QueryExampleSchemaWithRuns.Format.CSV) + .limit(1L) + .offset(0L) + .preview(true) + .sortParams( + QueryExampleSchemaWithRuns.SortParams.builder() + .sortBy("sort_by") + .sortOrder(QueryExampleSchemaWithRuns.SortParams.SortOrder.ASC) + .build() + ) + .build() + + val roundtrippedQueryExampleSchemaWithRuns = + jsonMapper.readValue( + jsonMapper.writeValueAsString(queryExampleSchemaWithRuns), + jacksonTypeRef<QueryExampleSchemaWithRuns>(), + ) + + assertThat(roundtrippedQueryExampleSchemaWithRuns).isEqualTo(queryExampleSchemaWithRuns) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/QueryFeedbackDeltaTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/QueryFeedbackDeltaTest.kt new file mode 100644 index 00000000..44e418e3 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/QueryFeedbackDeltaTest.kt @@ -0,0 +1,73 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.runs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class QueryFeedbackDeltaTest { + + @Test + fun create() { + val queryFeedbackDelta = + QueryFeedbackDelta.builder() + .baselineSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addComparisonSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackKey("feedback_key") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .filters( + QueryFeedbackDelta.Filters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + ) + .limit(1L) + .offset(0L) + .build() + + assertThat(queryFeedbackDelta.baselineSessionId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(queryFeedbackDelta.comparisonSessionIds()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(queryFeedbackDelta.feedbackKey()).isEqualTo("feedback_key") + assertThat(queryFeedbackDelta.comparativeExperimentId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(queryFeedbackDelta.filters()) + .contains( + QueryFeedbackDelta.Filters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + ) + assertThat(queryFeedbackDelta.limit()).contains(1L) + assertThat(queryFeedbackDelta.offset()).contains(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val queryFeedbackDelta = + QueryFeedbackDelta.builder() + .baselineSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addComparisonSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackKey("feedback_key") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .filters( + QueryFeedbackDelta.Filters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + ) + .limit(1L) + .offset(0L) + .build() + + val roundtrippedQueryFeedbackDelta = + jsonMapper.readValue( + jsonMapper.writeValueAsString(queryFeedbackDelta), + jacksonTypeRef<QueryFeedbackDelta>(), + ) + + assertThat(roundtrippedQueryFeedbackDelta).isEqualTo(queryFeedbackDelta) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/RunCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/RunCreateParamsTest.kt new file mode 100644 index 00000000..3841263c --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/RunCreateParamsTest.kt @@ -0,0 +1,185 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.runs + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunCreateParamsTest { + + @Test + fun create() { + RunCreateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .queryFormat("format") + .queryExampleSchemaWithRuns( + QueryExampleSchemaWithRuns.builder() + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .filters( + QueryExampleSchemaWithRuns.Filters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + ) + .format(QueryExampleSchemaWithRuns.Format.CSV) + .limit(1L) + .offset(0L) + .preview(true) + .sortParams( + QueryExampleSchemaWithRuns.SortParams.builder() + .sortBy("sort_by") + .sortOrder(QueryExampleSchemaWithRuns.SortParams.SortOrder.ASC) + .build() + ) + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + RunCreateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .queryExampleSchemaWithRuns( + QueryExampleSchemaWithRuns.builder() + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + RunCreateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .queryFormat("format") + .queryExampleSchemaWithRuns( + QueryExampleSchemaWithRuns.builder() + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .filters( + QueryExampleSchemaWithRuns.Filters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + ) + .format(QueryExampleSchemaWithRuns.Format.CSV) + .limit(1L) + .offset(0L) + .preview(true) + .sortParams( + QueryExampleSchemaWithRuns.SortParams.builder() + .sortBy("sort_by") + .sortOrder(QueryExampleSchemaWithRuns.SortParams.SortOrder.ASC) + .build() + ) + .build() + ) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().put("format", "format").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + RunCreateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .queryExampleSchemaWithRuns( + QueryExampleSchemaWithRuns.builder() + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } + + @Test + fun body() { + val params = + RunCreateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .queryFormat("format") + .queryExampleSchemaWithRuns( + QueryExampleSchemaWithRuns.builder() + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .filters( + QueryExampleSchemaWithRuns.Filters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + ) + .format(QueryExampleSchemaWithRuns.Format.CSV) + .limit(1L) + .offset(0L) + .preview(true) + .sortParams( + QueryExampleSchemaWithRuns.SortParams.builder() + .sortBy("sort_by") + .sortOrder(QueryExampleSchemaWithRuns.SortParams.SortOrder.ASC) + .build() + ) + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + QueryExampleSchemaWithRuns.builder() + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .filters( + QueryExampleSchemaWithRuns.Filters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + ) + .format(QueryExampleSchemaWithRuns.Format.CSV) + .limit(1L) + .offset(0L) + .preview(true) + .sortParams( + QueryExampleSchemaWithRuns.SortParams.builder() + .sortBy("sort_by") + .sortOrder(QueryExampleSchemaWithRuns.SortParams.SortOrder.ASC) + .build() + ) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + RunCreateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .queryExampleSchemaWithRuns( + QueryExampleSchemaWithRuns.builder() + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + QueryExampleSchemaWithRuns.builder() + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/RunCreateResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/RunCreateResponseTest.kt new file mode 100644 index 00000000..bf0a85eb --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/RunCreateResponseTest.kt @@ -0,0 +1,404 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.runs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TraceTier +import com.langsmith_api.api.models.api.v1.runs.RunSchema +import com.langsmith_api.api.models.api.v1.runs.RunTypeEnum +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class RunCreateResponseTest { + + @Test + fun ofExampleWithRuns() { + val exampleWithRuns = + listOf( + ExampleWithRuns.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .name("name") + .addRun( + RunSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .appPath("app_path") + .dottedOrder("dotted_order") + .name("name") + .runType(RunTypeEnum.TOOL) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status("status") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost("completion_cost") + .completionCostDetails( + RunSchema.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .completionTokenDetails( + RunSchema.CompletionTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .completionTokens(0L) + .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error("error") + .addEvent(JsonValue.from(mapOf<String, Any>())) + .executionOrder(1L) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats( + RunSchema.FeedbackStats.builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf<String, Any>()), + ) + .build() + ) + .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inDataset(true) + .inputs(JsonValue.from(mapOf<String, Any>())) + .inputsPreview("inputs_preview") + .inputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .lastQueuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .outputs(JsonValue.from(mapOf<String, Any>())) + .outputsPreview("outputs_preview") + .outputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .promptCost("prompt_cost") + .promptCostDetails( + RunSchema.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .promptTokenDetails( + RunSchema.PromptTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .promptTokens(0L) + .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .s3Urls(JsonValue.from(mapOf<String, Any>())) + .serialized(JsonValue.from(mapOf<String, Any>())) + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTag("string") + .threadId("thread_id") + .totalCost("total_cost") + .totalTokens(0L) + .traceFirstReceivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceTier(TraceTier.LONGLIVED) + .traceUpgrade(true) + .ttlSeconds(0L) + .build() + ) + .attachmentUrls(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .metadata(JsonValue.from(mapOf<String, Any>())) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .outputs(JsonValue.from(mapOf<String, Any>())) + .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val runCreateResponse = RunCreateResponse.ofExampleWithRuns(exampleWithRuns) + + assertThat(runCreateResponse.exampleWithRuns()).contains(exampleWithRuns) + assertThat(runCreateResponse.exampleWithRunsChes()).isEmpty + } + + @Test + fun ofExampleWithRunsRoundtrip() { + val jsonMapper = jsonMapper() + val runCreateResponse = + RunCreateResponse.ofExampleWithRuns( + listOf( + ExampleWithRuns.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .name("name") + .addRun( + RunSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .appPath("app_path") + .dottedOrder("dotted_order") + .name("name") + .runType(RunTypeEnum.TOOL) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status("status") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost("completion_cost") + .completionCostDetails( + RunSchema.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .completionTokenDetails( + RunSchema.CompletionTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .completionTokens(0L) + .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error("error") + .addEvent(JsonValue.from(mapOf<String, Any>())) + .executionOrder(1L) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats( + RunSchema.FeedbackStats.builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf<String, Any>()), + ) + .build() + ) + .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inDataset(true) + .inputs(JsonValue.from(mapOf<String, Any>())) + .inputsPreview("inputs_preview") + .inputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .lastQueuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .outputs(JsonValue.from(mapOf<String, Any>())) + .outputsPreview("outputs_preview") + .outputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .promptCost("prompt_cost") + .promptCostDetails( + RunSchema.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .promptTokenDetails( + RunSchema.PromptTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .promptTokens(0L) + .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .s3Urls(JsonValue.from(mapOf<String, Any>())) + .serialized(JsonValue.from(mapOf<String, Any>())) + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTag("string") + .threadId("thread_id") + .totalCost("total_cost") + .totalTokens(0L) + .traceFirstReceivedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceTier(TraceTier.LONGLIVED) + .traceUpgrade(true) + .ttlSeconds(0L) + .build() + ) + .attachmentUrls(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .metadata(JsonValue.from(mapOf<String, Any>())) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .outputs(JsonValue.from(mapOf<String, Any>())) + .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + ) + + val roundtrippedRunCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(runCreateResponse), + jacksonTypeRef<RunCreateResponse>(), + ) + + assertThat(roundtrippedRunCreateResponse).isEqualTo(runCreateResponse) + } + + @Test + fun ofExampleWithRunsChes() { + val exampleWithRunsChes = + listOf( + ExampleWithRunsCh.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .name("name") + .addRun( + ExampleWithRunsCh.Run.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .runType(RunTypeEnum.TOOL) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status("status") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .appPath("app_path") + .completionCost("completion_cost") + .completionTokens(0L) + .dottedOrder("dotted_order") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error("error") + .addEvent(JsonValue.from(mapOf<String, Any>())) + .executionOrder(1L) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats( + ExampleWithRunsCh.Run.FeedbackStats.builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf<String, Any>()), + ) + .build() + ) + .inputs(JsonValue.from(mapOf<String, Any>())) + .inputsPreview("inputs_preview") + .inputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .outputs(JsonValue.from(mapOf<String, Any>())) + .outputsPreview("outputs_preview") + .outputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .promptCost("prompt_cost") + .promptTokens(0L) + .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .s3Urls(JsonValue.from(mapOf<String, Any>())) + .serialized(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTag("string") + .totalCost("total_cost") + .totalTokens(0L) + .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .attachmentUrls(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .metadata(JsonValue.from(mapOf<String, Any>())) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .outputs(JsonValue.from(mapOf<String, Any>())) + .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val runCreateResponse = RunCreateResponse.ofExampleWithRunsChes(exampleWithRunsChes) + + assertThat(runCreateResponse.exampleWithRuns()).isEmpty + assertThat(runCreateResponse.exampleWithRunsChes()).contains(exampleWithRunsChes) + } + + @Test + fun ofExampleWithRunsChesRoundtrip() { + val jsonMapper = jsonMapper() + val runCreateResponse = + RunCreateResponse.ofExampleWithRunsChes( + listOf( + ExampleWithRunsCh.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .name("name") + .addRun( + ExampleWithRunsCh.Run.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .runType(RunTypeEnum.TOOL) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status("status") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .appPath("app_path") + .completionCost("completion_cost") + .completionTokens(0L) + .dottedOrder("dotted_order") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error("error") + .addEvent(JsonValue.from(mapOf<String, Any>())) + .executionOrder(1L) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats( + ExampleWithRunsCh.Run.FeedbackStats.builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf<String, Any>()), + ) + .build() + ) + .inputs(JsonValue.from(mapOf<String, Any>())) + .inputsPreview("inputs_preview") + .inputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .outputs(JsonValue.from(mapOf<String, Any>())) + .outputsPreview("outputs_preview") + .outputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .promptCost("prompt_cost") + .promptTokens(0L) + .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .s3Urls(JsonValue.from(mapOf<String, Any>())) + .serialized(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTag("string") + .totalCost("total_cost") + .totalTokens(0L) + .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .attachmentUrls(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .metadata(JsonValue.from(mapOf<String, Any>())) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .outputs(JsonValue.from(mapOf<String, Any>())) + .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + ) + + val roundtrippedRunCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(runCreateResponse), + jacksonTypeRef<RunCreateResponse>(), + ) + + assertThat(roundtrippedRunCreateResponse).isEqualTo(runCreateResponse) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + OBJECT(JsonValue.from(mapOf("invalid" to "object"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val runCreateResponse = + jsonMapper().convertValue(testCase.value, jacksonTypeRef<RunCreateResponse>()) + + val e = assertThrows<LangsmithApiInvalidDataException> { runCreateResponse.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/RunDeltaParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/RunDeltaParamsTest.kt new file mode 100644 index 00000000..cbbe8c9d --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/RunDeltaParamsTest.kt @@ -0,0 +1,119 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.runs + +import com.langsmith_api.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunDeltaParamsTest { + + @Test + fun create() { + RunDeltaParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .queryFeedbackDelta( + QueryFeedbackDelta.builder() + .baselineSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addComparisonSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackKey("feedback_key") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .filters( + QueryFeedbackDelta.Filters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + ) + .limit(1L) + .offset(0L) + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + RunDeltaParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .queryFeedbackDelta( + QueryFeedbackDelta.builder() + .baselineSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addComparisonSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackKey("feedback_key") + .build() + ) + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + RunDeltaParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .queryFeedbackDelta( + QueryFeedbackDelta.builder() + .baselineSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addComparisonSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackKey("feedback_key") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .filters( + QueryFeedbackDelta.Filters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + ) + .limit(1L) + .offset(0L) + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + QueryFeedbackDelta.builder() + .baselineSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addComparisonSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackKey("feedback_key") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .filters( + QueryFeedbackDelta.Filters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + ) + .limit(1L) + .offset(0L) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + RunDeltaParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .queryFeedbackDelta( + QueryFeedbackDelta.builder() + .baselineSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addComparisonSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackKey("feedback_key") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + QueryFeedbackDelta.builder() + .baselineSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addComparisonSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackKey("feedback_key") + .build() + ) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/SessionFeedbackDeltaTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/SessionFeedbackDeltaTest.kt new file mode 100644 index 00000000..acc3f83d --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/runs/SessionFeedbackDeltaTest.kt @@ -0,0 +1,82 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.runs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SessionFeedbackDeltaTest { + + @Test + fun create() { + val sessionFeedbackDelta = + SessionFeedbackDelta.builder() + .feedbackDeltas( + SessionFeedbackDelta.FeedbackDeltas.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "improved_examples" to + listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"), + "regressed_examples" to + listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"), + ) + ), + ) + .build() + ) + .build() + + assertThat(sessionFeedbackDelta.feedbackDeltas()) + .isEqualTo( + SessionFeedbackDelta.FeedbackDeltas.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "improved_examples" to + listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"), + "regressed_examples" to + listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"), + ) + ), + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val sessionFeedbackDelta = + SessionFeedbackDelta.builder() + .feedbackDeltas( + SessionFeedbackDelta.FeedbackDeltas.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "improved_examples" to + listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"), + "regressed_examples" to + listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"), + ) + ), + ) + .build() + ) + .build() + + val roundtrippedSessionFeedbackDelta = + jsonMapper.readValue( + jsonMapper.writeValueAsString(sessionFeedbackDelta), + jacksonTypeRef<SessionFeedbackDelta>(), + ) + + assertThat(roundtrippedSessionFeedbackDelta).isEqualTo(sessionFeedbackDelta) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/DatasetShareSchemaTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/DatasetShareSchemaTest.kt new file mode 100644 index 00000000..42a33174 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/DatasetShareSchemaTest.kt @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.share + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetShareSchemaTest { + + @Test + fun create() { + val datasetShareSchema = + DatasetShareSchema.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(datasetShareSchema.datasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(datasetShareSchema.shareToken()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val datasetShareSchema = + DatasetShareSchema.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val roundtrippedDatasetShareSchema = + jsonMapper.readValue( + jsonMapper.writeValueAsString(datasetShareSchema), + jacksonTypeRef<DatasetShareSchema>(), + ) + + assertThat(roundtrippedDatasetShareSchema).isEqualTo(datasetShareSchema) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/ShareCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/ShareCreateParamsTest.kt new file mode 100644 index 00000000..5ed97492 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/ShareCreateParamsTest.kt @@ -0,0 +1,52 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.share + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ShareCreateParamsTest { + + @Test + fun create() { + ShareCreateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .shareProjects(true) + .build() + } + + @Test + fun pathParams() { + val params = + ShareCreateParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + ShareCreateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .shareProjects(true) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("share_projects", "true").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + ShareCreateParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/ShareDeleteAllParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/ShareDeleteAllParamsTest.kt new file mode 100644 index 00000000..cfa3b75b --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/ShareDeleteAllParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.share + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ShareDeleteAllParamsTest { + + @Test + fun create() { + ShareDeleteAllParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + ShareDeleteAllParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/ShareDeleteAllResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/ShareDeleteAllResponseTest.kt new file mode 100644 index 00000000..2974bc6c --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/ShareDeleteAllResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.share + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ShareDeleteAllResponseTest { + + @Test + fun create() { + val shareDeleteAllResponse = ShareDeleteAllResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val shareDeleteAllResponse = ShareDeleteAllResponse.builder().build() + + val roundtrippedShareDeleteAllResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(shareDeleteAllResponse), + jacksonTypeRef<ShareDeleteAllResponse>(), + ) + + assertThat(roundtrippedShareDeleteAllResponse).isEqualTo(shareDeleteAllResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/ShareListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/ShareListParamsTest.kt new file mode 100644 index 00000000..422aa904 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/share/ShareListParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.share + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ShareListParamsTest { + + @Test + fun create() { + ShareListParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + ShareListParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/splits/SplitCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/splits/SplitCreateParamsTest.kt new file mode 100644 index 00000000..39c585ba --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/splits/SplitCreateParamsTest.kt @@ -0,0 +1,65 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.splits + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SplitCreateParamsTest { + + @Test + fun create() { + SplitCreateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .splitName("split_name") + .remove(true) + .build() + } + + @Test + fun pathParams() { + val params = + SplitCreateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .splitName("split_name") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + SplitCreateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .splitName("split_name") + .remove(true) + .build() + + val body = params._body() + + assertThat(body.examples()).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.splitName()).isEqualTo("split_name") + assertThat(body.remove()).contains(true) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + SplitCreateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .splitName("split_name") + .build() + + val body = params._body() + + assertThat(body.examples()).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.splitName()).isEqualTo("split_name") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/splits/SplitListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/splits/SplitListParamsTest.kt new file mode 100644 index 00000000..8babce06 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/splits/SplitListParamsTest.kt @@ -0,0 +1,53 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.splits + +import com.langsmith_api.api.core.http.QueryParams +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SplitListParamsTest { + + @Test + fun create() { + SplitListParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + } + + @Test + fun pathParams() { + val params = + SplitListParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + SplitListParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("as_of", "2019-12-27T18:11:19.117Z").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + SplitListParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/versions/VersionListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/versions/VersionListParamsTest.kt new file mode 100644 index 00000000..d1d06a57 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/versions/VersionListParamsTest.kt @@ -0,0 +1,65 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.versions + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VersionListParamsTest { + + @Test + fun create() { + VersionListParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .example("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .offset(0L) + .search("search") + .build() + } + + @Test + fun pathParams() { + val params = + VersionListParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + VersionListParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .example("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .offset(0L) + .search("search") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("example", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("limit", "1") + .put("offset", "0") + .put("search", "search") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + VersionListParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/versions/VersionRetrieveDiffParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/versions/VersionRetrieveDiffParamsTest.kt new file mode 100644 index 00000000..e1d47ba3 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/versions/VersionRetrieveDiffParamsTest.kt @@ -0,0 +1,54 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.versions + +import com.langsmith_api.api.core.http.QueryParams +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VersionRetrieveDiffParamsTest { + + @Test + fun create() { + VersionRetrieveDiffParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .fromVersion(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .toVersion(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + } + + @Test + fun pathParams() { + val params = + VersionRetrieveDiffParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .fromVersion(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .toVersion(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + VersionRetrieveDiffParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .fromVersion(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .toVersion(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("from_version", "2019-12-27T18:11:19.117Z") + .put("to_version", "2019-12-27T18:11:19.117Z") + .build() + ) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/versions/VersionRetrieveDiffResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/versions/VersionRetrieveDiffResponseTest.kt new file mode 100644 index 00000000..eb29a755 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/datasets/versions/VersionRetrieveDiffResponseTest.kt @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.datasets.versions + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VersionRetrieveDiffResponseTest { + + @Test + fun create() { + val versionRetrieveDiffResponse = + VersionRetrieveDiffResponse.builder() + .addExamplesAdded("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addExamplesModified("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addExamplesRemoved("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(versionRetrieveDiffResponse.examplesAdded()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(versionRetrieveDiffResponse.examplesModified()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(versionRetrieveDiffResponse.examplesRemoved()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val versionRetrieveDiffResponse = + VersionRetrieveDiffResponse.builder() + .addExamplesAdded("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addExamplesModified("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addExamplesRemoved("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val roundtrippedVersionRetrieveDiffResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(versionRetrieveDiffResponse), + jacksonTypeRef<VersionRetrieveDiffResponse>(), + ) + + assertThat(roundtrippedVersionRetrieveDiffResponse).isEqualTo(versionRetrieveDiffResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/AttachmentsOperationsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/AttachmentsOperationsTest.kt new file mode 100644 index 00000000..bf3aadbf --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/AttachmentsOperationsTest.kt @@ -0,0 +1,56 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.examples + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AttachmentsOperationsTest { + + @Test + fun create() { + val attachmentsOperations = + AttachmentsOperations.builder() + .rename( + AttachmentsOperations.Rename.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addRetain("string") + .build() + + assertThat(attachmentsOperations.rename()) + .contains( + AttachmentsOperations.Rename.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(attachmentsOperations.retain().getOrNull()).containsExactly("string") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val attachmentsOperations = + AttachmentsOperations.builder() + .rename( + AttachmentsOperations.Rename.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addRetain("string") + .build() + + val roundtrippedAttachmentsOperations = + jsonMapper.readValue( + jsonMapper.writeValueAsString(attachmentsOperations), + jacksonTypeRef<AttachmentsOperations>(), + ) + + assertThat(roundtrippedAttachmentsOperations).isEqualTo(attachmentsOperations) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleCreateParamsTest.kt new file mode 100644 index 00000000..418be0ea --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleCreateParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.examples + +import org.junit.jupiter.api.Test + +internal class ExampleCreateParamsTest { + + @Test + fun create() { + ExampleCreateParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleDeleteAllParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleDeleteAllParamsTest.kt new file mode 100644 index 00000000..5ed7714a --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleDeleteAllParamsTest.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.examples + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ExampleDeleteAllParamsTest { + + @Test + fun create() { + ExampleDeleteAllParams.builder() + .addExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun queryParams() { + val params = + ExampleDeleteAllParams.builder() + .addExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put( + "example_ids", + listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").joinToString(","), + ) + .build() + ) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleDeleteAllResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleDeleteAllResponseTest.kt new file mode 100644 index 00000000..f5819fd9 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleDeleteAllResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.examples + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ExampleDeleteAllResponseTest { + + @Test + fun create() { + val exampleDeleteAllResponse = ExampleDeleteAllResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val exampleDeleteAllResponse = ExampleDeleteAllResponse.builder().build() + + val roundtrippedExampleDeleteAllResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(exampleDeleteAllResponse), + jacksonTypeRef<ExampleDeleteAllResponse>(), + ) + + assertThat(roundtrippedExampleDeleteAllResponse).isEqualTo(exampleDeleteAllResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleDeleteParamsTest.kt new file mode 100644 index 00000000..2707c538 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleDeleteParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.examples + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ExampleDeleteParamsTest { + + @Test + fun create() { + ExampleDeleteParams.builder().exampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + ExampleDeleteParams.builder().exampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleDeleteResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleDeleteResponseTest.kt new file mode 100644 index 00000000..a69b9e66 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleDeleteResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.examples + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ExampleDeleteResponseTest { + + @Test + fun create() { + val exampleDeleteResponse = ExampleDeleteResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val exampleDeleteResponse = ExampleDeleteResponse.builder().build() + + val roundtrippedExampleDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(exampleDeleteResponse), + jacksonTypeRef<ExampleDeleteResponse>(), + ) + + assertThat(roundtrippedExampleDeleteResponse).isEqualTo(exampleDeleteResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleListParamsTest.kt new file mode 100644 index 00000000..990f33dd --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleListParamsTest.kt @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.examples + +import com.langsmith_api.api.core.http.QueryParams +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ExampleListParamsTest { + + @Test + fun create() { + ExampleListParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .descending(true) + .filter("filter") + .addFullTextContain("string") + .limit(1L) + .metadata("metadata") + .offset(0L) + .order(ExampleListParams.Order.RECENT) + .randomSeed(0.0) + .addSelect(ExampleSelect.ID) + .addSplit("string") + .build() + } + + @Test + fun queryParams() { + val params = + ExampleListParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .descending(true) + .filter("filter") + .addFullTextContain("string") + .limit(1L) + .metadata("metadata") + .offset(0L) + .order(ExampleListParams.Order.RECENT) + .randomSeed(0.0) + .addSelect(ExampleSelect.ID) + .addSplit("string") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").joinToString(",")) + .put("as_of", "2019-12-27T18:11:19.117Z") + .put("dataset", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("descending", "true") + .put("filter", "filter") + .put("full_text_contains", listOf("string").joinToString(",")) + .put("limit", "1") + .put("metadata", "metadata") + .put("offset", "0") + .put("order", "recent") + .put("random_seed", "0.0") + .put("select", listOf("id").joinToString(",")) + .put("splits", listOf("string").joinToString(",")) + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = ExampleListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleRetrieveCountParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleRetrieveCountParamsTest.kt new file mode 100644 index 00000000..d5694240 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleRetrieveCountParamsTest.kt @@ -0,0 +1,62 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.examples + +import com.langsmith_api.api.core.http.QueryParams +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ExampleRetrieveCountParamsTest { + + @Test + fun create() { + ExampleRetrieveCountParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .filter("filter") + .addFullTextContain("string") + .metadata("metadata") + .addSplit("string") + .build() + } + + @Test + fun queryParams() { + val params = + ExampleRetrieveCountParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .filter("filter") + .addFullTextContain("string") + .metadata("metadata") + .addSplit("string") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").joinToString(",")) + .put("as_of", "2019-12-27T18:11:19.117Z") + .put("dataset", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("filter", "filter") + .put("full_text_contains", listOf("string").joinToString(",")) + .put("metadata", "metadata") + .put("splits", listOf("string").joinToString(",")) + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = ExampleRetrieveCountParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleRetrieveParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleRetrieveParamsTest.kt new file mode 100644 index 00000000..52edfdad --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleRetrieveParamsTest.kt @@ -0,0 +1,57 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.examples + +import com.langsmith_api.api.core.http.QueryParams +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ExampleRetrieveParamsTest { + + @Test + fun create() { + ExampleRetrieveParams.builder() + .exampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + } + + @Test + fun pathParams() { + val params = + ExampleRetrieveParams.builder() + .exampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + ExampleRetrieveParams.builder() + .exampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("as_of", "2019-12-27T18:11:19.117Z").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + ExampleRetrieveParams.builder() + .exampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleTest.kt new file mode 100644 index 00000000..0584c600 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleTest.kt @@ -0,0 +1,64 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.examples + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ExampleTest { + + @Test + fun create() { + val example = + Example.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .name("name") + .attachmentUrls(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .metadata(JsonValue.from(mapOf<String, Any>())) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .outputs(JsonValue.from(mapOf<String, Any>())) + .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(example.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(example.datasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(example._inputs()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(example.name()).isEqualTo("name") + assertThat(example._attachmentUrls()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(example.createdAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(example._metadata()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(example.modifiedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(example._outputs()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(example.sourceRunId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val example = + Example.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .name("name") + .attachmentUrls(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .metadata(JsonValue.from(mapOf<String, Any>())) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .outputs(JsonValue.from(mapOf<String, Any>())) + .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val roundtrippedExample = + jsonMapper.readValue(jsonMapper.writeValueAsString(example), jacksonTypeRef<Example>()) + + assertThat(roundtrippedExample).isEqualTo(example) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleUpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleUpdateParamsTest.kt new file mode 100644 index 00000000..e0caed19 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/ExampleUpdateParamsTest.kt @@ -0,0 +1,100 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.examples + +import com.langsmith_api.api.core.MultipartField +import java.io.InputStream +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ExampleUpdateParamsTest { + + @Test + fun create() { + ExampleUpdateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .file("some content".byteInputStream()) + .addInputKey("string") + .addMetadataKey("string") + .addOutputKey("string") + .build() + } + + @Test + fun pathParams() { + val params = + ExampleUpdateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .file("some content".byteInputStream()) + .addInputKey("string") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + ExampleUpdateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .file("some content".byteInputStream()) + .addInputKey("string") + .addMetadataKey("string") + .addOutputKey("string") + .build() + + val body = params._body() + + assertThat(body.filterValues { !it.value.isNull() }) + .usingRecursiveComparison() + // TODO(AssertJ): Replace this and the `mapValues` below with: + // https://github.com/assertj/assertj/issues/3165 + .withEqualsForType( + { a, b -> a.readBytes() contentEquals b.readBytes() }, + InputStream::class.java, + ) + .isEqualTo( + mapOf( + "file" to MultipartField.of("some content".byteInputStream()), + "input_keys" to MultipartField.of(listOf("string")), + "metadata_keys" to MultipartField.of(listOf("string")), + "output_keys" to MultipartField.of(listOf("string")), + ) + .mapValues { (_, field) -> + field.map { (it as? ByteArray)?.inputStream() ?: it } + } + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + ExampleUpdateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .file("some content".byteInputStream()) + .addInputKey("string") + .build() + + val body = params._body() + + assertThat(body.filterValues { !it.value.isNull() }) + .usingRecursiveComparison() + // TODO(AssertJ): Replace this and the `mapValues` below with: + // https://github.com/assertj/assertj/issues/3165 + .withEqualsForType( + { a, b -> a.readBytes() contentEquals b.readBytes() }, + InputStream::class.java, + ) + .isEqualTo( + mapOf( + "file" to MultipartField.of("some content".byteInputStream()), + "input_keys" to MultipartField.of(listOf("string")), + ) + .mapValues { (_, field) -> + field.map { (it as? ByteArray)?.inputStream() ?: it } + } + ) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/bulk/BulkCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/bulk/BulkCreateParamsTest.kt new file mode 100644 index 00000000..7a8a3645 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/bulk/BulkCreateParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.examples.bulk + +import org.junit.jupiter.api.Test + +internal class BulkCreateParamsTest { + + @Test + fun create() { + BulkCreateParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/bulk/BulkCreateResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/bulk/BulkCreateResponseTest.kt new file mode 100644 index 00000000..a071a89b --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/bulk/BulkCreateResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.examples.bulk + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BulkCreateResponseTest { + + @Test + fun create() { + val bulkCreateResponse = BulkCreateResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val bulkCreateResponse = BulkCreateResponse.builder().build() + + val roundtrippedBulkCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(bulkCreateResponse), + jacksonTypeRef<BulkCreateResponse>(), + ) + + assertThat(roundtrippedBulkCreateResponse).isEqualTo(bulkCreateResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/bulk/BulkPatchAllParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/bulk/BulkPatchAllParamsTest.kt new file mode 100644 index 00000000..f7ec858c --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/bulk/BulkPatchAllParamsTest.kt @@ -0,0 +1,110 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.examples.bulk + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.examples.AttachmentsOperations +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BulkPatchAllParamsTest { + + @Test + fun create() { + BulkPatchAllParams.builder() + .addBody( + BulkPatchAllParams.Body.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .attachmentsOperations( + AttachmentsOperations.builder() + .rename( + AttachmentsOperations.Rename.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addRetain("string") + .build() + ) + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .metadata(JsonValue.from(mapOf<String, Any>())) + .outputs(JsonValue.from(mapOf<String, Any>())) + .overwrite(true) + .splitOfStrings(listOf("string")) + .build() + ) + .build() + } + + @Test + fun body() { + val params = + BulkPatchAllParams.builder() + .addBody( + BulkPatchAllParams.Body.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .attachmentsOperations( + AttachmentsOperations.builder() + .rename( + AttachmentsOperations.Rename.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addRetain("string") + .build() + ) + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .metadata(JsonValue.from(mapOf<String, Any>())) + .outputs(JsonValue.from(mapOf<String, Any>())) + .overwrite(true) + .splitOfStrings(listOf("string")) + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .containsExactly( + BulkPatchAllParams.Body.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .attachmentsOperations( + AttachmentsOperations.builder() + .rename( + AttachmentsOperations.Rename.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addRetain("string") + .build() + ) + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .metadata(JsonValue.from(mapOf<String, Any>())) + .outputs(JsonValue.from(mapOf<String, Any>())) + .overwrite(true) + .splitOfStrings(listOf("string")) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + BulkPatchAllParams.builder() + .addBody( + BulkPatchAllParams.Body.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .containsExactly( + BulkPatchAllParams.Body.builder().id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + ) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/bulk/BulkPatchAllResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/bulk/BulkPatchAllResponseTest.kt new file mode 100644 index 00000000..21eb9241 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/bulk/BulkPatchAllResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.examples.bulk + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BulkPatchAllResponseTest { + + @Test + fun create() { + val bulkPatchAllResponse = BulkPatchAllResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val bulkPatchAllResponse = BulkPatchAllResponse.builder().build() + + val roundtrippedBulkPatchAllResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(bulkPatchAllResponse), + jacksonTypeRef<BulkPatchAllResponse>(), + ) + + assertThat(roundtrippedBulkPatchAllResponse).isEqualTo(bulkPatchAllResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/validate/ExampleValidationResultTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/validate/ExampleValidationResultTest.kt new file mode 100644 index 00000000..25155ca9 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/validate/ExampleValidationResultTest.kt @@ -0,0 +1,74 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.examples.validate + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ExampleValidationResultTest { + + @Test + fun create() { + val exampleValidationResult = + ExampleValidationResult.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .metadata(JsonValue.from(mapOf<String, Any>())) + .outputs(JsonValue.from(mapOf<String, Any>())) + .overwrite(true) + .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .splitOfStrings(listOf("string")) + .useSourceRunIo(true) + .build() + + assertThat(exampleValidationResult.id()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(exampleValidationResult.createdAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(exampleValidationResult.datasetId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(exampleValidationResult._inputs()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(exampleValidationResult._metadata()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(exampleValidationResult._outputs()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(exampleValidationResult.overwrite()).contains(true) + assertThat(exampleValidationResult.sourceRunId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(exampleValidationResult.split()) + .contains(ExampleValidationResult.Split.ofStrings(listOf("string"))) + assertThat(exampleValidationResult.useSourceRunIo()).contains(true) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val exampleValidationResult = + ExampleValidationResult.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .metadata(JsonValue.from(mapOf<String, Any>())) + .outputs(JsonValue.from(mapOf<String, Any>())) + .overwrite(true) + .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .splitOfStrings(listOf("string")) + .useSourceRunIo(true) + .build() + + val roundtrippedExampleValidationResult = + jsonMapper.readValue( + jsonMapper.writeValueAsString(exampleValidationResult), + jacksonTypeRef<ExampleValidationResult>(), + ) + + assertThat(roundtrippedExampleValidationResult).isEqualTo(exampleValidationResult) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/validate/ValidateBulkParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/validate/ValidateBulkParamsTest.kt new file mode 100644 index 00000000..a2d5e85c --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/validate/ValidateBulkParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.examples.validate + +import org.junit.jupiter.api.Test + +internal class ValidateBulkParamsTest { + + @Test + fun create() { + ValidateBulkParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/validate/ValidateCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/validate/ValidateCreateParamsTest.kt new file mode 100644 index 00000000..06393176 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/examples/validate/ValidateCreateParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.examples.validate + +import org.junit.jupiter.api.Test + +internal class ValidateCreateParamsTest { + + @Test + fun create() { + ValidateCreateParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/ApiFeedbackSourceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/ApiFeedbackSourceTest.kt new file mode 100644 index 00000000..eff0ac7d --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/ApiFeedbackSourceTest.kt @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ApiFeedbackSourceTest { + + @Test + fun create() { + val apiFeedbackSource = + ApiFeedbackSource.builder() + .metadata(JsonValue.from(mapOf<String, Any>())) + .type("type") + .build() + + assertThat(apiFeedbackSource._metadata()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(apiFeedbackSource.type()).contains("type") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val apiFeedbackSource = + ApiFeedbackSource.builder() + .metadata(JsonValue.from(mapOf<String, Any>())) + .type("type") + .build() + + val roundtrippedApiFeedbackSource = + jsonMapper.readValue( + jsonMapper.writeValueAsString(apiFeedbackSource), + jacksonTypeRef<ApiFeedbackSource>(), + ) + + assertThat(roundtrippedApiFeedbackSource).isEqualTo(apiFeedbackSource) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/AppFeedbackSourceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/AppFeedbackSourceTest.kt new file mode 100644 index 00000000..18630b15 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/AppFeedbackSourceTest.kt @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AppFeedbackSourceTest { + + @Test + fun create() { + val appFeedbackSource = + AppFeedbackSource.builder() + .metadata(JsonValue.from(mapOf<String, Any>())) + .type("type") + .build() + + assertThat(appFeedbackSource._metadata()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(appFeedbackSource.type()).contains("type") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val appFeedbackSource = + AppFeedbackSource.builder() + .metadata(JsonValue.from(mapOf<String, Any>())) + .type("type") + .build() + + val roundtrippedAppFeedbackSource = + jsonMapper.readValue( + jsonMapper.writeValueAsString(appFeedbackSource), + jacksonTypeRef<AppFeedbackSource>(), + ) + + assertThat(roundtrippedAppFeedbackSource).isEqualTo(appFeedbackSource) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/AutoEvalFeedbackSourceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/AutoEvalFeedbackSourceTest.kt new file mode 100644 index 00000000..22bfd1ea --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/AutoEvalFeedbackSourceTest.kt @@ -0,0 +1,43 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AutoEvalFeedbackSourceTest { + + @Test + fun create() { + val autoEvalFeedbackSource = + AutoEvalFeedbackSource.builder() + .metadata(JsonValue.from(mapOf<String, Any>())) + .type("type") + .build() + + assertThat(autoEvalFeedbackSource._metadata()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(autoEvalFeedbackSource.type()).contains("type") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val autoEvalFeedbackSource = + AutoEvalFeedbackSource.builder() + .metadata(JsonValue.from(mapOf<String, Any>())) + .type("type") + .build() + + val roundtrippedAutoEvalFeedbackSource = + jsonMapper.readValue( + jsonMapper.writeValueAsString(autoEvalFeedbackSource), + jacksonTypeRef<AutoEvalFeedbackSource>(), + ) + + assertThat(roundtrippedAutoEvalFeedbackSource).isEqualTo(autoEvalFeedbackSource) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackCreateParamsTest.kt new file mode 100644 index 00000000..1fec4dca --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackCreateParamsTest.kt @@ -0,0 +1,143 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfig +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FeedbackCreateParamsTest { + + @Test + fun create() { + FeedbackCreateParams.builder() + .feedbackCreateSchema( + FeedbackCreateSchema.builder() + .key("key") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .correction(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder().value(0.0).label("x").build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .feedbackGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackSource( + AppFeedbackSource.builder() + .metadata(JsonValue.from(mapOf<String, Any>())) + .type("type") + .build() + ) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .score(0.0) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .value(0.0) + .build() + ) + .build() + } + + @Test + fun body() { + val params = + FeedbackCreateParams.builder() + .feedbackCreateSchema( + FeedbackCreateSchema.builder() + .key("key") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .correction(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder().value(0.0).label("x").build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .feedbackGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackSource( + AppFeedbackSource.builder() + .metadata(JsonValue.from(mapOf<String, Any>())) + .type("type") + .build() + ) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .score(0.0) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .value(0.0) + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + FeedbackCreateSchema.builder() + .key("key") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .correction(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder().value(0.0).label("x").build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .feedbackGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackSource( + AppFeedbackSource.builder() + .metadata(JsonValue.from(mapOf<String, Any>())) + .type("type") + .build() + ) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .score(0.0) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .value(0.0) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + FeedbackCreateParams.builder() + .feedbackCreateSchema(FeedbackCreateSchema.builder().key("key").build()) + .build() + + val body = params._body() + + assertThat(body).isEqualTo(FeedbackCreateSchema.builder().key("key").build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackCreateSchemaTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackCreateSchemaTest.kt new file mode 100644 index 00000000..7ee2c831 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackCreateSchemaTest.kt @@ -0,0 +1,138 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfig +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FeedbackCreateSchemaTest { + + @Test + fun create() { + val feedbackCreateSchema = + FeedbackCreateSchema.builder() + .key("key") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .correction(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder().value(0.0).label("x").build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .feedbackGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackSource( + AppFeedbackSource.builder() + .metadata(JsonValue.from(mapOf<String, Any>())) + .type("type") + .build() + ) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .score(0.0) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .value(0.0) + .build() + + assertThat(feedbackCreateSchema.key()).isEqualTo("key") + assertThat(feedbackCreateSchema.id()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(feedbackCreateSchema.comment()).contains("comment") + assertThat(feedbackCreateSchema.comparativeExperimentId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(feedbackCreateSchema.correction()) + .contains( + FeedbackCreateSchema.Correction.ofJsonValue(JsonValue.from(mapOf<String, Any>())) + ) + assertThat(feedbackCreateSchema.createdAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(feedbackCreateSchema.error()).contains(true) + assertThat(feedbackCreateSchema.feedbackConfig()) + .contains( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory(FeedbackConfig.Category.builder().value(0.0).label("x").build()) + .max(0.0) + .min(0.0) + .build() + ) + assertThat(feedbackCreateSchema.feedbackGroupId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(feedbackCreateSchema.feedbackSource()) + .contains( + FeedbackCreateSchema.FeedbackSource.ofApp( + AppFeedbackSource.builder() + .metadata(JsonValue.from(mapOf<String, Any>())) + .type("type") + .build() + ) + ) + assertThat(feedbackCreateSchema.modifiedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(feedbackCreateSchema.runId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(feedbackCreateSchema.score()).contains(FeedbackCreateSchema.Score.ofNumber(0.0)) + assertThat(feedbackCreateSchema.sessionId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(feedbackCreateSchema.traceId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(feedbackCreateSchema.value()).contains(FeedbackCreateSchema.Value.ofNumber(0.0)) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val feedbackCreateSchema = + FeedbackCreateSchema.builder() + .key("key") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .correction(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder().value(0.0).label("x").build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .feedbackGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackSource( + AppFeedbackSource.builder() + .metadata(JsonValue.from(mapOf<String, Any>())) + .type("type") + .build() + ) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .score(0.0) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .value(0.0) + .build() + + val roundtrippedFeedbackCreateSchema = + jsonMapper.readValue( + jsonMapper.writeValueAsString(feedbackCreateSchema), + jacksonTypeRef<FeedbackCreateSchema>(), + ) + + assertThat(roundtrippedFeedbackCreateSchema).isEqualTo(feedbackCreateSchema) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackDeleteParamsTest.kt new file mode 100644 index 00000000..be98b3d2 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackDeleteParamsTest.kt @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FeedbackDeleteParamsTest { + + @Test + fun create() { + FeedbackDeleteParams.builder().feedbackId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + FeedbackDeleteParams.builder() + .feedbackId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackDeleteResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackDeleteResponseTest.kt new file mode 100644 index 00000000..28e39390 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackDeleteResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FeedbackDeleteResponseTest { + + @Test + fun create() { + val feedbackDeleteResponse = FeedbackDeleteResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val feedbackDeleteResponse = FeedbackDeleteResponse.builder().build() + + val roundtrippedFeedbackDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(feedbackDeleteResponse), + jacksonTypeRef<FeedbackDeleteResponse>(), + ) + + assertThat(roundtrippedFeedbackDeleteResponse).isEqualTo(feedbackDeleteResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackEagerParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackEagerParamsTest.kt new file mode 100644 index 00000000..f7fc27d5 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackEagerParamsTest.kt @@ -0,0 +1,143 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfig +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FeedbackEagerParamsTest { + + @Test + fun create() { + FeedbackEagerParams.builder() + .feedbackCreateSchema( + FeedbackCreateSchema.builder() + .key("key") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .correction(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder().value(0.0).label("x").build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .feedbackGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackSource( + AppFeedbackSource.builder() + .metadata(JsonValue.from(mapOf<String, Any>())) + .type("type") + .build() + ) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .score(0.0) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .value(0.0) + .build() + ) + .build() + } + + @Test + fun body() { + val params = + FeedbackEagerParams.builder() + .feedbackCreateSchema( + FeedbackCreateSchema.builder() + .key("key") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .correction(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder().value(0.0).label("x").build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .feedbackGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackSource( + AppFeedbackSource.builder() + .metadata(JsonValue.from(mapOf<String, Any>())) + .type("type") + .build() + ) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .score(0.0) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .value(0.0) + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + FeedbackCreateSchema.builder() + .key("key") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .correction(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder().value(0.0).label("x").build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .feedbackGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackSource( + AppFeedbackSource.builder() + .metadata(JsonValue.from(mapOf<String, Any>())) + .type("type") + .build() + ) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .score(0.0) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .value(0.0) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + FeedbackEagerParams.builder() + .feedbackCreateSchema(FeedbackCreateSchema.builder().key("key").build()) + .build() + + val body = params._body() + + assertThat(body).isEqualTo(FeedbackCreateSchema.builder().key("key").build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackListParamsTest.kt new file mode 100644 index 00000000..00470686 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackListParamsTest.kt @@ -0,0 +1,83 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback + +import com.langsmith_api.api.core.http.QueryParams +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FeedbackListParamsTest { + + @Test + fun create() { + FeedbackListParams.builder() + .hasComment(true) + .hasScore(true) + .includeUserNames(true) + .addKey("string") + .level(FeedbackLevel.RUN) + .limit(1L) + .maxCreatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minCreatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .offset(0L) + .addRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addSource(SourceType.API) + .addUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun queryParams() { + val params = + FeedbackListParams.builder() + .hasComment(true) + .hasScore(true) + .includeUserNames(true) + .addKey("string") + .level(FeedbackLevel.RUN) + .limit(1L) + .maxCreatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minCreatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .offset(0L) + .addRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addSource(SourceType.API) + .addUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("has_comment", "true") + .put("has_score", "true") + .put("include_user_names", "true") + .put("key", listOf("string").joinToString(",")) + .put("level", "run") + .put("limit", "1") + .put("max_created_at", "2019-12-27T18:11:19.117Z") + .put("min_created_at", "2019-12-27T18:11:19.117Z") + .put("offset", "0") + .put("run", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").joinToString(",")) + .put( + "session", + listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").joinToString(","), + ) + .put("source", listOf("api").joinToString(",")) + .put("user", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").joinToString(",")) + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = FeedbackListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackRetrieveParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackRetrieveParamsTest.kt new file mode 100644 index 00000000..8363a5be --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackRetrieveParamsTest.kt @@ -0,0 +1,56 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FeedbackRetrieveParamsTest { + + @Test + fun create() { + FeedbackRetrieveParams.builder() + .feedbackId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .includeUserNames(true) + .build() + } + + @Test + fun pathParams() { + val params = + FeedbackRetrieveParams.builder() + .feedbackId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + FeedbackRetrieveParams.builder() + .feedbackId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .includeUserNames(true) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("include_user_names", "true").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + FeedbackRetrieveParams.builder() + .feedbackId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackSchemaTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackSchemaTest.kt new file mode 100644 index 00000000..0d7fccb2 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackSchemaTest.kt @@ -0,0 +1,119 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FeedbackSchemaTest { + + @Test + fun create() { + val feedbackSchema = + FeedbackSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .key("key") + .comment("comment") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .correction(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackSource( + FeedbackSchema.FeedbackSource.builder() + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metadata(JsonValue.from(mapOf<String, Any>())) + .type("type") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userName("user_name") + .build() + ) + .feedbackThreadId("feedback_thread_id") + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .score(0.0) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .value(0.0) + .build() + + assertThat(feedbackSchema.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(feedbackSchema.key()).isEqualTo("key") + assertThat(feedbackSchema.comment()).contains("comment") + assertThat(feedbackSchema.comparativeExperimentId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(feedbackSchema.correction()) + .contains(FeedbackSchema.Correction.ofJsonValue(JsonValue.from(mapOf<String, Any>()))) + assertThat(feedbackSchema.createdAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(feedbackSchema._extra()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(feedbackSchema.feedbackGroupId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(feedbackSchema.feedbackSource()) + .contains( + FeedbackSchema.FeedbackSource.builder() + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metadata(JsonValue.from(mapOf<String, Any>())) + .type("type") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userName("user_name") + .build() + ) + assertThat(feedbackSchema.feedbackThreadId()).contains("feedback_thread_id") + assertThat(feedbackSchema.modifiedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(feedbackSchema.runId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(feedbackSchema.score()).contains(FeedbackSchema.Score.ofNumber(0.0)) + assertThat(feedbackSchema.sessionId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(feedbackSchema.startTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(feedbackSchema.traceId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(feedbackSchema.value()).contains(FeedbackSchema.Value.ofNumber(0.0)) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val feedbackSchema = + FeedbackSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .key("key") + .comment("comment") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .correction(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackSource( + FeedbackSchema.FeedbackSource.builder() + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metadata(JsonValue.from(mapOf<String, Any>())) + .type("type") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userName("user_name") + .build() + ) + .feedbackThreadId("feedback_thread_id") + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .score(0.0) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .value(0.0) + .build() + + val roundtrippedFeedbackSchema = + jsonMapper.readValue( + jsonMapper.writeValueAsString(feedbackSchema), + jacksonTypeRef<FeedbackSchema>(), + ) + + assertThat(roundtrippedFeedbackSchema).isEqualTo(feedbackSchema) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackUpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackUpdateParamsTest.kt new file mode 100644 index 00000000..6742b628 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/FeedbackUpdateParamsTest.kt @@ -0,0 +1,93 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfig +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FeedbackUpdateParamsTest { + + @Test + fun create() { + FeedbackUpdateParams.builder() + .feedbackId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") + .correction(JsonValue.from(mapOf<String, Any>())) + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory(FeedbackConfig.Category.builder().value(0.0).label("x").build()) + .max(0.0) + .min(0.0) + .build() + ) + .score(0.0) + .value(0.0) + .build() + } + + @Test + fun pathParams() { + val params = + FeedbackUpdateParams.builder() + .feedbackId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + FeedbackUpdateParams.builder() + .feedbackId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") + .correction(JsonValue.from(mapOf<String, Any>())) + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder().value(0.0).label("x").build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .score(0.0) + .value(0.0) + .build() + + val body = params._body() + + assertThat(body.comment()).contains("comment") + assertThat(body.correction()) + .contains( + FeedbackUpdateParams.Correction.ofJsonValue(JsonValue.from(mapOf<String, Any>())) + ) + assertThat(body.feedbackConfig()) + .contains( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory(FeedbackConfig.Category.builder().value(0.0).label("x").build()) + .max(0.0) + .min(0.0) + .build() + ) + assertThat(body.score()).contains(FeedbackUpdateParams.Score.ofNumber(0.0)) + assertThat(body.value()).contains(FeedbackUpdateParams.Value.ofNumber(0.0)) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + FeedbackUpdateParams.builder() + .feedbackId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/ModelFeedbackSourceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/ModelFeedbackSourceTest.kt new file mode 100644 index 00000000..fe8ce8ad --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/ModelFeedbackSourceTest.kt @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ModelFeedbackSourceTest { + + @Test + fun create() { + val modelFeedbackSource = + ModelFeedbackSource.builder() + .metadata(JsonValue.from(mapOf<String, Any>())) + .type("type") + .build() + + assertThat(modelFeedbackSource._metadata()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(modelFeedbackSource.type()).contains("type") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val modelFeedbackSource = + ModelFeedbackSource.builder() + .metadata(JsonValue.from(mapOf<String, Any>())) + .type("type") + .build() + + val roundtrippedModelFeedbackSource = + jsonMapper.readValue( + jsonMapper.writeValueAsString(modelFeedbackSource), + jacksonTypeRef<ModelFeedbackSource>(), + ) + + assertThat(roundtrippedModelFeedbackSource).isEqualTo(modelFeedbackSource) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FeedbackFormulaTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FeedbackFormulaTest.kt new file mode 100644 index 00000000..063b70bd --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FeedbackFormulaTest.kt @@ -0,0 +1,67 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback.formulas + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FeedbackFormulaTest { + + @Test + fun create() { + val feedbackFormula = + FeedbackFormula.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .aggregationType(FeedbackFormula.AggregationType.SUM) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .feedbackKey("feedback_key") + .addFormulaPart( + FeedbackFormulaWeightedVariable.builder().key("x").weight(0.0).build() + ) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(feedbackFormula.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(feedbackFormula.aggregationType()).isEqualTo(FeedbackFormula.AggregationType.SUM) + assertThat(feedbackFormula.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(feedbackFormula.feedbackKey()).isEqualTo("feedback_key") + assertThat(feedbackFormula.formulaParts()) + .containsExactly(FeedbackFormulaWeightedVariable.builder().key("x").weight(0.0).build()) + assertThat(feedbackFormula.modifiedAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(feedbackFormula.datasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(feedbackFormula.sessionId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val feedbackFormula = + FeedbackFormula.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .aggregationType(FeedbackFormula.AggregationType.SUM) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .feedbackKey("feedback_key") + .addFormulaPart( + FeedbackFormulaWeightedVariable.builder().key("x").weight(0.0).build() + ) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val roundtrippedFeedbackFormula = + jsonMapper.readValue( + jsonMapper.writeValueAsString(feedbackFormula), + jacksonTypeRef<FeedbackFormula>(), + ) + + assertThat(roundtrippedFeedbackFormula).isEqualTo(feedbackFormula) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FeedbackFormulaWeightedVariableTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FeedbackFormulaWeightedVariableTest.kt new file mode 100644 index 00000000..8679d2ec --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FeedbackFormulaWeightedVariableTest.kt @@ -0,0 +1,36 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback.formulas + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FeedbackFormulaWeightedVariableTest { + + @Test + fun create() { + val feedbackFormulaWeightedVariable = + FeedbackFormulaWeightedVariable.builder().key("x").weight(0.0).build() + + assertThat(feedbackFormulaWeightedVariable.key()).isEqualTo("x") + assertThat(feedbackFormulaWeightedVariable.weight()).isEqualTo(0.0) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val feedbackFormulaWeightedVariable = + FeedbackFormulaWeightedVariable.builder().key("x").weight(0.0).build() + + val roundtrippedFeedbackFormulaWeightedVariable = + jsonMapper.readValue( + jsonMapper.writeValueAsString(feedbackFormulaWeightedVariable), + jacksonTypeRef<FeedbackFormulaWeightedVariable>(), + ) + + assertThat(roundtrippedFeedbackFormulaWeightedVariable) + .isEqualTo(feedbackFormulaWeightedVariable) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaCreateParamsTest.kt new file mode 100644 index 00000000..43233140 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaCreateParamsTest.kt @@ -0,0 +1,62 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback.formulas + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FormulaCreateParamsTest { + + @Test + fun create() { + FormulaCreateParams.builder() + .aggregationType(FormulaCreateParams.AggregationType.SUM) + .feedbackKey("feedback_key") + .addFormulaPart(FeedbackFormulaWeightedVariable.builder().key("x").weight(0.0).build()) + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun body() { + val params = + FormulaCreateParams.builder() + .aggregationType(FormulaCreateParams.AggregationType.SUM) + .feedbackKey("feedback_key") + .addFormulaPart( + FeedbackFormulaWeightedVariable.builder().key("x").weight(0.0).build() + ) + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + + assertThat(body.aggregationType()).isEqualTo(FormulaCreateParams.AggregationType.SUM) + assertThat(body.feedbackKey()).isEqualTo("feedback_key") + assertThat(body.formulaParts()) + .containsExactly(FeedbackFormulaWeightedVariable.builder().key("x").weight(0.0).build()) + assertThat(body.datasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.sessionId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + FormulaCreateParams.builder() + .aggregationType(FormulaCreateParams.AggregationType.SUM) + .feedbackKey("feedback_key") + .addFormulaPart( + FeedbackFormulaWeightedVariable.builder().key("x").weight(0.0).build() + ) + .build() + + val body = params._body() + + assertThat(body.aggregationType()).isEqualTo(FormulaCreateParams.AggregationType.SUM) + assertThat(body.feedbackKey()).isEqualTo("feedback_key") + assertThat(body.formulaParts()) + .containsExactly(FeedbackFormulaWeightedVariable.builder().key("x").weight(0.0).build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaDeleteParamsTest.kt new file mode 100644 index 00000000..8761830f --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaDeleteParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback.formulas + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FormulaDeleteParamsTest { + + @Test + fun create() { + FormulaDeleteParams.builder() + .feedbackFormulaId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + FormulaDeleteParams.builder() + .feedbackFormulaId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaDeleteResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaDeleteResponseTest.kt new file mode 100644 index 00000000..1d0d95c2 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaDeleteResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback.formulas + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FormulaDeleteResponseTest { + + @Test + fun create() { + val formulaDeleteResponse = FormulaDeleteResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val formulaDeleteResponse = FormulaDeleteResponse.builder().build() + + val roundtrippedFormulaDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(formulaDeleteResponse), + jacksonTypeRef<FormulaDeleteResponse>(), + ) + + assertThat(roundtrippedFormulaDeleteResponse).isEqualTo(formulaDeleteResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaListParamsTest.kt new file mode 100644 index 00000000..5066514e --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaListParamsTest.kt @@ -0,0 +1,52 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback.formulas + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FormulaListParamsTest { + + @Test + fun create() { + FormulaListParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .offset(0L) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun queryParams() { + val params = + FormulaListParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .offset(0L) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("dataset_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("limit", "0") + .put("offset", "0") + .put("session_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = FormulaListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaRetrieveParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaRetrieveParamsTest.kt new file mode 100644 index 00000000..cd7c7309 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaRetrieveParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback.formulas + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FormulaRetrieveParamsTest { + + @Test + fun create() { + FormulaRetrieveParams.builder() + .feedbackFormulaId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + FormulaRetrieveParams.builder() + .feedbackFormulaId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaUpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaUpdateParamsTest.kt new file mode 100644 index 00000000..9e2bfe75 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/formulas/FormulaUpdateParamsTest.kt @@ -0,0 +1,56 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback.formulas + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FormulaUpdateParamsTest { + + @Test + fun create() { + FormulaUpdateParams.builder() + .feedbackFormulaId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .aggregationType(FormulaUpdateParams.AggregationType.SUM) + .feedbackKey("feedback_key") + .addFormulaPart(FeedbackFormulaWeightedVariable.builder().key("x").weight(0.0).build()) + .build() + } + + @Test + fun pathParams() { + val params = + FormulaUpdateParams.builder() + .feedbackFormulaId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .aggregationType(FormulaUpdateParams.AggregationType.SUM) + .feedbackKey("feedback_key") + .addFormulaPart( + FeedbackFormulaWeightedVariable.builder().key("x").weight(0.0).build() + ) + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + FormulaUpdateParams.builder() + .feedbackFormulaId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .aggregationType(FormulaUpdateParams.AggregationType.SUM) + .feedbackKey("feedback_key") + .addFormulaPart( + FeedbackFormulaWeightedVariable.builder().key("x").weight(0.0).build() + ) + .build() + + val body = params._body() + + assertThat(body.aggregationType()).isEqualTo(FormulaUpdateParams.AggregationType.SUM) + assertThat(body.feedbackKey()).isEqualTo("feedback_key") + assertThat(body.formulaParts()) + .containsExactly(FeedbackFormulaWeightedVariable.builder().key("x").weight(0.0).build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/FeedbackIngestTokenCreateSchemaTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/FeedbackIngestTokenCreateSchemaTest.kt new file mode 100644 index 00000000..2d0252df --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/FeedbackIngestTokenCreateSchemaTest.kt @@ -0,0 +1,83 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback.tokens + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfig +import com.langsmith_api.api.models.api.v1.sessions.TimedeltaInput +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FeedbackIngestTokenCreateSchemaTest { + + @Test + fun create() { + val feedbackIngestTokenCreateSchema = + FeedbackIngestTokenCreateSchema.builder() + .feedbackKey("feedback_key") + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiresIn(TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build()) + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder().value(0.0).label("x").build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .build() + + assertThat(feedbackIngestTokenCreateSchema.feedbackKey()).isEqualTo("feedback_key") + assertThat(feedbackIngestTokenCreateSchema.runId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(feedbackIngestTokenCreateSchema.expiresAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(feedbackIngestTokenCreateSchema.expiresIn()) + .contains(TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build()) + assertThat(feedbackIngestTokenCreateSchema.feedbackConfig()) + .contains( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory(FeedbackConfig.Category.builder().value(0.0).label("x").build()) + .max(0.0) + .min(0.0) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val feedbackIngestTokenCreateSchema = + FeedbackIngestTokenCreateSchema.builder() + .feedbackKey("feedback_key") + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiresIn(TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build()) + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder().value(0.0).label("x").build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .build() + + val roundtrippedFeedbackIngestTokenCreateSchema = + jsonMapper.readValue( + jsonMapper.writeValueAsString(feedbackIngestTokenCreateSchema), + jacksonTypeRef<FeedbackIngestTokenCreateSchema>(), + ) + + assertThat(roundtrippedFeedbackIngestTokenCreateSchema) + .isEqualTo(feedbackIngestTokenCreateSchema) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/FeedbackIngestTokenSchemaTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/FeedbackIngestTokenSchemaTest.kt new file mode 100644 index 00000000..af125f02 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/FeedbackIngestTokenSchemaTest.kt @@ -0,0 +1,49 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback.tokens + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FeedbackIngestTokenSchemaTest { + + @Test + fun create() { + val feedbackIngestTokenSchema = + FeedbackIngestTokenSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .feedbackKey("feedback_key") + .url("url") + .build() + + assertThat(feedbackIngestTokenSchema.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(feedbackIngestTokenSchema.expiresAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(feedbackIngestTokenSchema.feedbackKey()).isEqualTo("feedback_key") + assertThat(feedbackIngestTokenSchema.url()).isEqualTo("url") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val feedbackIngestTokenSchema = + FeedbackIngestTokenSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .feedbackKey("feedback_key") + .url("url") + .build() + + val roundtrippedFeedbackIngestTokenSchema = + jsonMapper.readValue( + jsonMapper.writeValueAsString(feedbackIngestTokenSchema), + jacksonTypeRef<FeedbackIngestTokenSchema>(), + ) + + assertThat(roundtrippedFeedbackIngestTokenSchema).isEqualTo(feedbackIngestTokenSchema) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenCreateParamsTest.kt new file mode 100644 index 00000000..1cfbfced --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenCreateParamsTest.kt @@ -0,0 +1,110 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback.tokens + +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfig +import com.langsmith_api.api.models.api.v1.sessions.TimedeltaInput +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TokenCreateParamsTest { + + @Test + fun create() { + TokenCreateParams.builder() + .body( + FeedbackIngestTokenCreateSchema.builder() + .feedbackKey("feedback_key") + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiresIn(TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build()) + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder().value(0.0).label("x").build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .build() + ) + .build() + } + + @Test + fun body() { + val params = + TokenCreateParams.builder() + .body( + FeedbackIngestTokenCreateSchema.builder() + .feedbackKey("feedback_key") + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiresIn(TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build()) + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder().value(0.0).label("x").build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + TokenCreateParams.Body.ofFeedbackIngestTokenCreateSchema( + FeedbackIngestTokenCreateSchema.builder() + .feedbackKey("feedback_key") + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiresIn(TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build()) + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder().value(0.0).label("x").build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .build() + ) + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + TokenCreateParams.builder() + .body( + FeedbackIngestTokenCreateSchema.builder() + .feedbackKey("feedback_key") + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + TokenCreateParams.Body.ofFeedbackIngestTokenCreateSchema( + FeedbackIngestTokenCreateSchema.builder() + .feedbackKey("feedback_key") + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + ) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenCreateResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenCreateResponseTest.kt new file mode 100644 index 00000000..7f9680cf --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenCreateResponseTest.kt @@ -0,0 +1,118 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback.tokens + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class TokenCreateResponseTest { + + @Test + fun ofFeedbackIngestTokenSchema() { + val feedbackIngestTokenSchema = + FeedbackIngestTokenSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .feedbackKey("feedback_key") + .url("url") + .build() + + val tokenCreateResponse = + TokenCreateResponse.ofFeedbackIngestTokenSchema(feedbackIngestTokenSchema) + + assertThat(tokenCreateResponse.feedbackIngestTokenSchema()) + .contains(feedbackIngestTokenSchema) + assertThat(tokenCreateResponse.feedbackIngestTokenSchemas()).isEmpty + } + + @Test + fun ofFeedbackIngestTokenSchemaRoundtrip() { + val jsonMapper = jsonMapper() + val tokenCreateResponse = + TokenCreateResponse.ofFeedbackIngestTokenSchema( + FeedbackIngestTokenSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .feedbackKey("feedback_key") + .url("url") + .build() + ) + + val roundtrippedTokenCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(tokenCreateResponse), + jacksonTypeRef<TokenCreateResponse>(), + ) + + assertThat(roundtrippedTokenCreateResponse).isEqualTo(tokenCreateResponse) + } + + @Test + fun ofFeedbackIngestTokenSchemas() { + val feedbackIngestTokenSchemas = + listOf( + FeedbackIngestTokenSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .feedbackKey("feedback_key") + .url("url") + .build() + ) + + val tokenCreateResponse = + TokenCreateResponse.ofFeedbackIngestTokenSchemas(feedbackIngestTokenSchemas) + + assertThat(tokenCreateResponse.feedbackIngestTokenSchema()).isEmpty + assertThat(tokenCreateResponse.feedbackIngestTokenSchemas()) + .contains(feedbackIngestTokenSchemas) + } + + @Test + fun ofFeedbackIngestTokenSchemasRoundtrip() { + val jsonMapper = jsonMapper() + val tokenCreateResponse = + TokenCreateResponse.ofFeedbackIngestTokenSchemas( + listOf( + FeedbackIngestTokenSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .feedbackKey("feedback_key") + .url("url") + .build() + ) + ) + + val roundtrippedTokenCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(tokenCreateResponse), + jacksonTypeRef<TokenCreateResponse>(), + ) + + assertThat(roundtrippedTokenCreateResponse).isEqualTo(tokenCreateResponse) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val tokenCreateResponse = + jsonMapper().convertValue(testCase.value, jacksonTypeRef<TokenCreateResponse>()) + + val e = assertThrows<LangsmithApiInvalidDataException> { tokenCreateResponse.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenListParamsTest.kt new file mode 100644 index 00000000..c7d24edb --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenListParamsTest.kt @@ -0,0 +1,27 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback.tokens + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TokenListParamsTest { + + @Test + fun create() { + TokenListParams.builder().runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun queryParams() { + val params = TokenListParams.builder().runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder().put("run_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + ) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenRetrieveParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenRetrieveParamsTest.kt new file mode 100644 index 00000000..39cd2da7 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenRetrieveParamsTest.kt @@ -0,0 +1,65 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback.tokens + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TokenRetrieveParamsTest { + + @Test + fun create() { + TokenRetrieveParams.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") + .correction("correction") + .score(0.0) + .value(0.0) + .build() + } + + @Test + fun pathParams() { + val params = + TokenRetrieveParams.builder().token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + TokenRetrieveParams.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") + .correction("correction") + .score(0.0) + .value(0.0) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("comment", "comment") + .put("correction", "correction") + .put("score", "0.0") + .put("value", "0.0") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + TokenRetrieveParams.builder().token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenRetrieveResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenRetrieveResponseTest.kt new file mode 100644 index 00000000..8ae7cbb3 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenRetrieveResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback.tokens + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TokenRetrieveResponseTest { + + @Test + fun create() { + val tokenRetrieveResponse = TokenRetrieveResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val tokenRetrieveResponse = TokenRetrieveResponse.builder().build() + + val roundtrippedTokenRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(tokenRetrieveResponse), + jacksonTypeRef<TokenRetrieveResponse>(), + ) + + assertThat(roundtrippedTokenRetrieveResponse).isEqualTo(tokenRetrieveResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenUpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenUpdateParamsTest.kt new file mode 100644 index 00000000..5b2945e1 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenUpdateParamsTest.kt @@ -0,0 +1,64 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback.tokens + +import com.langsmith_api.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TokenUpdateParamsTest { + + @Test + fun create() { + TokenUpdateParams.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") + .correction(JsonValue.from(mapOf<String, Any>())) + .metadata(JsonValue.from(mapOf<String, Any>())) + .score(0.0) + .value(0.0) + .build() + } + + @Test + fun pathParams() { + val params = + TokenUpdateParams.builder().token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + TokenUpdateParams.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") + .correction(JsonValue.from(mapOf<String, Any>())) + .metadata(JsonValue.from(mapOf<String, Any>())) + .score(0.0) + .value(0.0) + .build() + + val body = params._body() + + assertThat(body.comment()).contains("comment") + assertThat(body.correction()) + .contains( + TokenUpdateParams.Correction.ofJsonValue(JsonValue.from(mapOf<String, Any>())) + ) + assertThat(body._metadata()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(body.score()).contains(TokenUpdateParams.Score.ofNumber(0.0)) + assertThat(body.value()).contains(TokenUpdateParams.Value.ofNumber(0.0)) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + TokenUpdateParams.builder().token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + val body = params._body() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenUpdateResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenUpdateResponseTest.kt new file mode 100644 index 00000000..232d2a96 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedback/tokens/TokenUpdateResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedback.tokens + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TokenUpdateResponseTest { + + @Test + fun create() { + val tokenUpdateResponse = TokenUpdateResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val tokenUpdateResponse = TokenUpdateResponse.builder().build() + + val roundtrippedTokenUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(tokenUpdateResponse), + jacksonTypeRef<TokenUpdateResponse>(), + ) + + assertThat(roundtrippedTokenUpdateResponse).isEqualTo(tokenUpdateResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfigFeedbackConfigsParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfigFeedbackConfigsParamsTest.kt new file mode 100644 index 00000000..7b5491eb --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfigFeedbackConfigsParamsTest.kt @@ -0,0 +1,75 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedbackconfigs + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FeedbackConfigFeedbackConfigsParamsTest { + + @Test + fun create() { + FeedbackConfigFeedbackConfigsParams.builder() + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory(FeedbackConfig.Category.builder().value(0.0).label("x").build()) + .max(0.0) + .min(0.0) + .build() + ) + .feedbackKey("feedback_key") + .isLowerScoreBetter(true) + .build() + } + + @Test + fun body() { + val params = + FeedbackConfigFeedbackConfigsParams.builder() + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder().value(0.0).label("x").build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .feedbackKey("feedback_key") + .isLowerScoreBetter(true) + .build() + + val body = params._body() + + assertThat(body.feedbackConfig()) + .isEqualTo( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory(FeedbackConfig.Category.builder().value(0.0).label("x").build()) + .max(0.0) + .min(0.0) + .build() + ) + assertThat(body.feedbackKey()).isEqualTo("feedback_key") + assertThat(body.isLowerScoreBetter()).contains(true) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + FeedbackConfigFeedbackConfigsParams.builder() + .feedbackConfig( + FeedbackConfig.builder().type(FeedbackConfig.Type.CONTINUOUS).build() + ) + .feedbackKey("feedback_key") + .build() + + val body = params._body() + + assertThat(body.feedbackConfig()) + .isEqualTo(FeedbackConfig.builder().type(FeedbackConfig.Type.CONTINUOUS).build()) + assertThat(body.feedbackKey()).isEqualTo("feedback_key") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfigRetrieveFeedbackConfigsParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfigRetrieveFeedbackConfigsParamsTest.kt new file mode 100644 index 00000000..4dec7fec --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfigRetrieveFeedbackConfigsParamsTest.kt @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedbackconfigs + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FeedbackConfigRetrieveFeedbackConfigsParamsTest { + + @Test + fun create() { + FeedbackConfigRetrieveFeedbackConfigsParams.builder() + .addKey("string") + .readAfterWrite(true) + .build() + } + + @Test + fun queryParams() { + val params = + FeedbackConfigRetrieveFeedbackConfigsParams.builder() + .addKey("string") + .readAfterWrite(true) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("key", listOf("string").joinToString(",")) + .put("read_after_write", "true") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = FeedbackConfigRetrieveFeedbackConfigsParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfigSchemaTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfigSchemaTest.kt new file mode 100644 index 00000000..dbb6a883 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfigSchemaTest.kt @@ -0,0 +1,79 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedbackconfigs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FeedbackConfigSchemaTest { + + @Test + fun create() { + val feedbackConfigSchema = + FeedbackConfigSchema.builder() + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder().value(0.0).label("x").build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .feedbackKey("feedback_key") + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .isLowerScoreBetter(true) + .build() + + assertThat(feedbackConfigSchema.feedbackConfig()) + .isEqualTo( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory(FeedbackConfig.Category.builder().value(0.0).label("x").build()) + .max(0.0) + .min(0.0) + .build() + ) + assertThat(feedbackConfigSchema.feedbackKey()).isEqualTo("feedback_key") + assertThat(feedbackConfigSchema.modifiedAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(feedbackConfigSchema.tenantId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(feedbackConfigSchema.isLowerScoreBetter()).contains(true) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val feedbackConfigSchema = + FeedbackConfigSchema.builder() + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder().value(0.0).label("x").build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .feedbackKey("feedback_key") + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .isLowerScoreBetter(true) + .build() + + val roundtrippedFeedbackConfigSchema = + jsonMapper.readValue( + jsonMapper.writeValueAsString(feedbackConfigSchema), + jacksonTypeRef<FeedbackConfigSchema>(), + ) + + assertThat(roundtrippedFeedbackConfigSchema).isEqualTo(feedbackConfigSchema) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfigTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfigTest.kt new file mode 100644 index 00000000..c4e9c78a --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfigTest.kt @@ -0,0 +1,49 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedbackconfigs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FeedbackConfigTest { + + @Test + fun create() { + val feedbackConfig = + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory(FeedbackConfig.Category.builder().value(0.0).label("x").build()) + .max(0.0) + .min(0.0) + .build() + + assertThat(feedbackConfig.type()).isEqualTo(FeedbackConfig.Type.CONTINUOUS) + assertThat(feedbackConfig.categories().getOrNull()) + .containsExactly(FeedbackConfig.Category.builder().value(0.0).label("x").build()) + assertThat(feedbackConfig.max()).contains(0.0) + assertThat(feedbackConfig.min()).contains(0.0) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val feedbackConfig = + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory(FeedbackConfig.Category.builder().value(0.0).label("x").build()) + .max(0.0) + .min(0.0) + .build() + + val roundtrippedFeedbackConfig = + jsonMapper.readValue( + jsonMapper.writeValueAsString(feedbackConfig), + jacksonTypeRef<FeedbackConfig>(), + ) + + assertThat(roundtrippedFeedbackConfig).isEqualTo(feedbackConfig) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfigUpdateFeedbackConfigsParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfigUpdateFeedbackConfigsParamsTest.kt new file mode 100644 index 00000000..e2453a4e --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/feedbackconfigs/FeedbackConfigUpdateFeedbackConfigsParamsTest.kt @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.feedbackconfigs + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FeedbackConfigUpdateFeedbackConfigsParamsTest { + + @Test + fun create() { + FeedbackConfigUpdateFeedbackConfigsParams.builder() + .feedbackKey("feedback_key") + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory(FeedbackConfig.Category.builder().value(0.0).label("x").build()) + .max(0.0) + .min(0.0) + .build() + ) + .isLowerScoreBetter(true) + .build() + } + + @Test + fun body() { + val params = + FeedbackConfigUpdateFeedbackConfigsParams.builder() + .feedbackKey("feedback_key") + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder().value(0.0).label("x").build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .isLowerScoreBetter(true) + .build() + + val body = params._body() + + assertThat(body.feedbackKey()).isEqualTo("feedback_key") + assertThat(body.feedbackConfig()) + .contains( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory(FeedbackConfig.Category.builder().value(0.0).label("x").build()) + .max(0.0) + .min(0.0) + .build() + ) + assertThat(body.isLowerScoreBetter()).contains(true) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + FeedbackConfigUpdateFeedbackConfigsParams.builder().feedbackKey("feedback_key").build() + + val body = params._body() + + assertThat(body.feedbackKey()).isEqualTo("feedback_key") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/info/InfoListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/info/InfoListParamsTest.kt new file mode 100644 index 00000000..8d0e0bfa --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/info/InfoListParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.info + +import org.junit.jupiter.api.Test + +internal class InfoListParamsTest { + + @Test + fun create() { + InfoListParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/info/InfoListResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/info/InfoListResponseTest.kt new file mode 100644 index 00000000..3bdd2be2 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/info/InfoListResponseTest.kt @@ -0,0 +1,98 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.info + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InfoListResponseTest { + + @Test + fun create() { + val infoListResponse = + InfoListResponse.builder() + .version("version") + .batchIngestConfig( + InfoListResponse.BatchIngestConfig.builder() + .scaleDownNemptyTrigger(0L) + .scaleUpNthreadsLimit(0L) + .scaleUpQsizeTrigger(0L) + .sizeLimit(0L) + .sizeLimitBytes(0L) + .useMultipartEndpoint(true) + .build() + ) + .customerInfo( + InfoListResponse.CustomerInfo.builder() + .customerId("customer_id") + .customerName("customer_name") + .build() + ) + .instanceFlags(JsonValue.from(mapOf<String, Any>())) + .licenseExpirationTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(infoListResponse.version()).isEqualTo("version") + assertThat(infoListResponse.batchIngestConfig()) + .contains( + InfoListResponse.BatchIngestConfig.builder() + .scaleDownNemptyTrigger(0L) + .scaleUpNthreadsLimit(0L) + .scaleUpQsizeTrigger(0L) + .sizeLimit(0L) + .sizeLimitBytes(0L) + .useMultipartEndpoint(true) + .build() + ) + assertThat(infoListResponse.customerInfo()) + .contains( + InfoListResponse.CustomerInfo.builder() + .customerId("customer_id") + .customerName("customer_name") + .build() + ) + assertThat(infoListResponse._instanceFlags()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(infoListResponse.licenseExpirationTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val infoListResponse = + InfoListResponse.builder() + .version("version") + .batchIngestConfig( + InfoListResponse.BatchIngestConfig.builder() + .scaleDownNemptyTrigger(0L) + .scaleUpNthreadsLimit(0L) + .scaleUpQsizeTrigger(0L) + .sizeLimit(0L) + .sizeLimitBytes(0L) + .useMultipartEndpoint(true) + .build() + ) + .customerInfo( + InfoListResponse.CustomerInfo.builder() + .customerId("customer_id") + .customerName("customer_name") + .build() + ) + .instanceFlags(JsonValue.from(mapOf<String, Any>())) + .licenseExpirationTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedInfoListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(infoListResponse), + jacksonTypeRef<InfoListResponse>(), + ) + + assertThat(roundtrippedInfoListResponse).isEqualTo(infoListResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/info/InfoRetrieveHealthParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/info/InfoRetrieveHealthParamsTest.kt new file mode 100644 index 00000000..9142ad84 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/info/InfoRetrieveHealthParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.info + +import org.junit.jupiter.api.Test + +internal class InfoRetrieveHealthParamsTest { + + @Test + fun create() { + InfoRetrieveHealthParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/info/InfoRetrieveHealthResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/info/InfoRetrieveHealthResponseTest.kt new file mode 100644 index 00000000..96866098 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/info/InfoRetrieveHealthResponseTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.info + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InfoRetrieveHealthResponseTest { + + @Test + fun create() { + val infoRetrieveHealthResponse = + InfoRetrieveHealthResponse.builder().clickhouseDiskFreePct(0.0).build() + + assertThat(infoRetrieveHealthResponse.clickhouseDiskFreePct()).isEqualTo(0.0) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val infoRetrieveHealthResponse = + InfoRetrieveHealthResponse.builder().clickhouseDiskFreePct(0.0).build() + + val roundtrippedInfoRetrieveHealthResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(infoRetrieveHealthResponse), + jacksonTypeRef<InfoRetrieveHealthResponse>(), + ) + + assertThat(roundtrippedInfoRetrieveHealthResponse).isEqualTo(infoRetrieveHealthResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/me/MeRetrieveLsUserIdParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/me/MeRetrieveLsUserIdParamsTest.kt new file mode 100644 index 00000000..d3ee82d7 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/me/MeRetrieveLsUserIdParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.me + +import org.junit.jupiter.api.Test + +internal class MeRetrieveLsUserIdParamsTest { + + @Test + fun create() { + MeRetrieveLsUserIdParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/me/onboardingstate/OnboardingStateCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/me/onboardingstate/OnboardingStateCreateParamsTest.kt new file mode 100644 index 00000000..1f76a49c --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/me/onboardingstate/OnboardingStateCreateParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.me.onboardingstate + +import org.junit.jupiter.api.Test + +internal class OnboardingStateCreateParamsTest { + + @Test + fun create() { + OnboardingStateCreateParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/me/onboardingstate/OnboardingStateListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/me/onboardingstate/OnboardingStateListParamsTest.kt new file mode 100644 index 00000000..eed44c9f --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/me/onboardingstate/OnboardingStateListParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.me.onboardingstate + +import org.junit.jupiter.api.Test + +internal class OnboardingStateListParamsTest { + + @Test + fun create() { + OnboardingStateListParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/me/onboardingstate/OnboardingStateUpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/me/onboardingstate/OnboardingStateUpdateParamsTest.kt new file mode 100644 index 00000000..4f7cf013 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/me/onboardingstate/OnboardingStateUpdateParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.me.onboardingstate + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OnboardingStateUpdateParamsTest { + + @Test + fun create() { + OnboardingStateUpdateParams.builder().field("field").build() + } + + @Test + fun pathParams() { + val params = OnboardingStateUpdateParams.builder().field("field").build() + + assertThat(params._pathParam(0)).isEqualTo("field") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/me/onboardingstate/UserOnboardingStateResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/me/onboardingstate/UserOnboardingStateResponseTest.kt new file mode 100644 index 00000000..f14605f8 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/me/onboardingstate/UserOnboardingStateResponseTest.kt @@ -0,0 +1,72 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.me.onboardingstate + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UserOnboardingStateResponseTest { + + @Test + fun create() { + val userOnboardingStateResponse = + UserOnboardingStateResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .evaluationCompletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lgstudioCompletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .playgroundCompletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .successViewedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tracingCompletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(userOnboardingStateResponse.id()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(userOnboardingStateResponse.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(userOnboardingStateResponse.lsUserId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(userOnboardingStateResponse.updatedAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(userOnboardingStateResponse.evaluationCompletedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(userOnboardingStateResponse.lgstudioCompletedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(userOnboardingStateResponse.playgroundCompletedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(userOnboardingStateResponse.successViewedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(userOnboardingStateResponse.tracingCompletedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val userOnboardingStateResponse = + UserOnboardingStateResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .evaluationCompletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lgstudioCompletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .playgroundCompletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .successViewedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tracingCompletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedUserOnboardingStateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(userOnboardingStateResponse), + jacksonTypeRef<UserOnboardingStateResponse>(), + ) + + assertThat(roundtrippedUserOnboardingStateResponse).isEqualTo(userOnboardingStateResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapDeleteParamsTest.kt new file mode 100644 index 00000000..3a2925b3 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapDeleteParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.modelpricemap + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ModelPriceMapDeleteParamsTest { + + @Test + fun create() { + ModelPriceMapDeleteParams.builder().id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + ModelPriceMapDeleteParams.builder().id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapDeleteResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapDeleteResponseTest.kt new file mode 100644 index 00000000..89229d92 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapDeleteResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.modelpricemap + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ModelPriceMapDeleteResponseTest { + + @Test + fun create() { + val modelPriceMapDeleteResponse = ModelPriceMapDeleteResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val modelPriceMapDeleteResponse = ModelPriceMapDeleteResponse.builder().build() + + val roundtrippedModelPriceMapDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(modelPriceMapDeleteResponse), + jacksonTypeRef<ModelPriceMapDeleteResponse>(), + ) + + assertThat(roundtrippedModelPriceMapDeleteResponse).isEqualTo(modelPriceMapDeleteResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapModelPriceMapParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapModelPriceMapParamsTest.kt new file mode 100644 index 00000000..7ae41c5a --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapModelPriceMapParamsTest.kt @@ -0,0 +1,103 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.modelpricemap + +import com.langsmith_api.api.core.JsonValue +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ModelPriceMapModelPriceMapParamsTest { + + @Test + fun create() { + ModelPriceMapModelPriceMapParams.builder() + .completionCost(0.0) + .matchPattern("match_pattern") + .name("name") + .promptCost(0.0) + .completionCostDetails( + ModelPriceMapModelPriceMapParams.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .addMatchPath("string") + .promptCostDetails( + ModelPriceMapModelPriceMapParams.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .provider("provider") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + } + + @Test + fun body() { + val params = + ModelPriceMapModelPriceMapParams.builder() + .completionCost(0.0) + .matchPattern("match_pattern") + .name("name") + .promptCost(0.0) + .completionCostDetails( + ModelPriceMapModelPriceMapParams.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .addMatchPath("string") + .promptCostDetails( + ModelPriceMapModelPriceMapParams.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .provider("provider") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val body = params._body() + + assertThat(body.completionCost()) + .isEqualTo(ModelPriceMapModelPriceMapParams.CompletionCost.ofNumber(0.0)) + assertThat(body.matchPattern()).isEqualTo("match_pattern") + assertThat(body.name()).isEqualTo("name") + assertThat(body.promptCost()) + .isEqualTo(ModelPriceMapModelPriceMapParams.PromptCost.ofNumber(0.0)) + assertThat(body.completionCostDetails()) + .contains( + ModelPriceMapModelPriceMapParams.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + assertThat(body.matchPath().getOrNull()).containsExactly("string") + assertThat(body.promptCostDetails()) + .contains( + ModelPriceMapModelPriceMapParams.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + assertThat(body.provider()).contains("provider") + assertThat(body.startTime()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + ModelPriceMapModelPriceMapParams.builder() + .completionCost(0.0) + .matchPattern("match_pattern") + .name("name") + .promptCost(0.0) + .build() + + val body = params._body() + + assertThat(body.completionCost()) + .isEqualTo(ModelPriceMapModelPriceMapParams.CompletionCost.ofNumber(0.0)) + assertThat(body.matchPattern()).isEqualTo("match_pattern") + assertThat(body.name()).isEqualTo("name") + assertThat(body.promptCost()) + .isEqualTo(ModelPriceMapModelPriceMapParams.PromptCost.ofNumber(0.0)) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapModelPriceMapResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapModelPriceMapResponseTest.kt new file mode 100644 index 00000000..f0ffd0f4 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapModelPriceMapResponseTest.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.modelpricemap + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ModelPriceMapModelPriceMapResponseTest { + + @Test + fun create() { + val modelPriceMapModelPriceMapResponse = + ModelPriceMapModelPriceMapResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val modelPriceMapModelPriceMapResponse = + ModelPriceMapModelPriceMapResponse.builder().build() + + val roundtrippedModelPriceMapModelPriceMapResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(modelPriceMapModelPriceMapResponse), + jacksonTypeRef<ModelPriceMapModelPriceMapResponse>(), + ) + + assertThat(roundtrippedModelPriceMapModelPriceMapResponse) + .isEqualTo(modelPriceMapModelPriceMapResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapRetrieveModelPriceMapParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapRetrieveModelPriceMapParamsTest.kt new file mode 100644 index 00000000..4d150cbd --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapRetrieveModelPriceMapParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.modelpricemap + +import org.junit.jupiter.api.Test + +internal class ModelPriceMapRetrieveModelPriceMapParamsTest { + + @Test + fun create() { + ModelPriceMapRetrieveModelPriceMapParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapRetrieveModelPriceMapResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapRetrieveModelPriceMapResponseTest.kt new file mode 100644 index 00000000..963cd9a9 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapRetrieveModelPriceMapResponseTest.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.modelpricemap + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ModelPriceMapRetrieveModelPriceMapResponseTest { + + @Test + fun create() { + val modelPriceMapRetrieveModelPriceMapResponse = + ModelPriceMapRetrieveModelPriceMapResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val modelPriceMapRetrieveModelPriceMapResponse = + ModelPriceMapRetrieveModelPriceMapResponse.builder().build() + + val roundtrippedModelPriceMapRetrieveModelPriceMapResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(modelPriceMapRetrieveModelPriceMapResponse), + jacksonTypeRef<ModelPriceMapRetrieveModelPriceMapResponse>(), + ) + + assertThat(roundtrippedModelPriceMapRetrieveModelPriceMapResponse) + .isEqualTo(modelPriceMapRetrieveModelPriceMapResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapUpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapUpdateParamsTest.kt new file mode 100644 index 00000000..fbfa44fc --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapUpdateParamsTest.kt @@ -0,0 +1,120 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.modelpricemap + +import com.langsmith_api.api.core.JsonValue +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ModelPriceMapUpdateParamsTest { + + @Test + fun create() { + ModelPriceMapUpdateParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost(0.0) + .matchPattern("match_pattern") + .name("name") + .promptCost(0.0) + .completionCostDetails( + ModelPriceMapUpdateParams.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .addMatchPath("string") + .promptCostDetails( + ModelPriceMapUpdateParams.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .provider("provider") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + } + + @Test + fun pathParams() { + val params = + ModelPriceMapUpdateParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost(0.0) + .matchPattern("match_pattern") + .name("name") + .promptCost(0.0) + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + ModelPriceMapUpdateParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost(0.0) + .matchPattern("match_pattern") + .name("name") + .promptCost(0.0) + .completionCostDetails( + ModelPriceMapUpdateParams.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .addMatchPath("string") + .promptCostDetails( + ModelPriceMapUpdateParams.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .provider("provider") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val body = params._body() + + assertThat(body.completionCost()) + .isEqualTo(ModelPriceMapUpdateParams.CompletionCost.ofNumber(0.0)) + assertThat(body.matchPattern()).isEqualTo("match_pattern") + assertThat(body.name()).isEqualTo("name") + assertThat(body.promptCost()).isEqualTo(ModelPriceMapUpdateParams.PromptCost.ofNumber(0.0)) + assertThat(body.completionCostDetails()) + .contains( + ModelPriceMapUpdateParams.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + assertThat(body.matchPath().getOrNull()).containsExactly("string") + assertThat(body.promptCostDetails()) + .contains( + ModelPriceMapUpdateParams.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + assertThat(body.provider()).contains("provider") + assertThat(body.startTime()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + ModelPriceMapUpdateParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost(0.0) + .matchPattern("match_pattern") + .name("name") + .promptCost(0.0) + .build() + + val body = params._body() + + assertThat(body.completionCost()) + .isEqualTo(ModelPriceMapUpdateParams.CompletionCost.ofNumber(0.0)) + assertThat(body.matchPattern()).isEqualTo("match_pattern") + assertThat(body.name()).isEqualTo("name") + assertThat(body.promptCost()).isEqualTo(ModelPriceMapUpdateParams.PromptCost.ofNumber(0.0)) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapUpdateResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapUpdateResponseTest.kt new file mode 100644 index 00000000..a16e9b12 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/modelpricemap/ModelPriceMapUpdateResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.modelpricemap + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ModelPriceMapUpdateResponseTest { + + @Test + fun create() { + val modelPriceMapUpdateResponse = ModelPriceMapUpdateResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val modelPriceMapUpdateResponse = ModelPriceMapUpdateResponse.builder().build() + + val roundtrippedModelPriceMapUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(modelPriceMapUpdateResponse), + jacksonTypeRef<ModelPriceMapUpdateResponse>(), + ) + + assertThat(roundtrippedModelPriceMapUpdateResponse).isEqualTo(modelPriceMapUpdateResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveCallbackParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveCallbackParamsTest.kt new file mode 100644 index 00000000..cc65b69c --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveCallbackParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.oauth + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OAuthRetrieveCallbackParamsTest { + + @Test + fun create() { + OAuthRetrieveCallbackParams.builder().provider(OAuthProvider.CUSTOM_OIDC).build() + } + + @Test + fun pathParams() { + val params = + OAuthRetrieveCallbackParams.builder().provider(OAuthProvider.CUSTOM_OIDC).build() + + assertThat(params._pathParam(0)).isEqualTo("custom-oidc") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveCallbackResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveCallbackResponseTest.kt new file mode 100644 index 00000000..4bca3c66 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveCallbackResponseTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.oauth + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OAuthRetrieveCallbackResponseTest { + + @Test + fun create() { + val oauthRetrieveCallbackResponse = OAuthRetrieveCallbackResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val oauthRetrieveCallbackResponse = OAuthRetrieveCallbackResponse.builder().build() + + val roundtrippedOAuthRetrieveCallbackResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(oauthRetrieveCallbackResponse), + jacksonTypeRef<OAuthRetrieveCallbackResponse>(), + ) + + assertThat(roundtrippedOAuthRetrieveCallbackResponse) + .isEqualTo(oauthRetrieveCallbackResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveCurrentUserParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveCurrentUserParamsTest.kt new file mode 100644 index 00000000..fd89d9c0 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveCurrentUserParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.oauth + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OAuthRetrieveCurrentUserParamsTest { + + @Test + fun create() { + OAuthRetrieveCurrentUserParams.builder().provider(OAuthProvider.CUSTOM_OIDC).build() + } + + @Test + fun pathParams() { + val params = + OAuthRetrieveCurrentUserParams.builder().provider(OAuthProvider.CUSTOM_OIDC).build() + + assertThat(params._pathParam(0)).isEqualTo("custom-oidc") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveCurrentUserResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveCurrentUserResponseTest.kt new file mode 100644 index 00000000..6aee0657 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveCurrentUserResponseTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.oauth + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OAuthRetrieveCurrentUserResponseTest { + + @Test + fun create() { + val oauthRetrieveCurrentUserResponse = OAuthRetrieveCurrentUserResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val oauthRetrieveCurrentUserResponse = OAuthRetrieveCurrentUserResponse.builder().build() + + val roundtrippedOAuthRetrieveCurrentUserResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(oauthRetrieveCurrentUserResponse), + jacksonTypeRef<OAuthRetrieveCurrentUserResponse>(), + ) + + assertThat(roundtrippedOAuthRetrieveCurrentUserResponse) + .isEqualTo(oauthRetrieveCurrentUserResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveLogoutParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveLogoutParamsTest.kt new file mode 100644 index 00000000..aad58499 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveLogoutParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.oauth + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OAuthRetrieveLogoutParamsTest { + + @Test + fun create() { + OAuthRetrieveLogoutParams.builder().provider(OAuthProvider.CUSTOM_OIDC).build() + } + + @Test + fun pathParams() { + val params = OAuthRetrieveLogoutParams.builder().provider(OAuthProvider.CUSTOM_OIDC).build() + + assertThat(params._pathParam(0)).isEqualTo("custom-oidc") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveLogoutResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveLogoutResponseTest.kt new file mode 100644 index 00000000..275754c8 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveLogoutResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.oauth + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OAuthRetrieveLogoutResponseTest { + + @Test + fun create() { + val oauthRetrieveLogoutResponse = OAuthRetrieveLogoutResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val oauthRetrieveLogoutResponse = OAuthRetrieveLogoutResponse.builder().build() + + val roundtrippedOAuthRetrieveLogoutResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(oauthRetrieveLogoutResponse), + jacksonTypeRef<OAuthRetrieveLogoutResponse>(), + ) + + assertThat(roundtrippedOAuthRetrieveLogoutResponse).isEqualTo(oauthRetrieveLogoutResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveParamsTest.kt new file mode 100644 index 00000000..351cd86a --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.oauth + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OAuthRetrieveParamsTest { + + @Test + fun create() { + OAuthRetrieveParams.builder().provider(OAuthProvider.CUSTOM_OIDC).build() + } + + @Test + fun pathParams() { + val params = OAuthRetrieveParams.builder().provider(OAuthProvider.CUSTOM_OIDC).build() + + assertThat(params._pathParam(0)).isEqualTo("custom-oidc") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveResponseTest.kt new file mode 100644 index 00000000..ae5c6e06 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/oauth/OAuthRetrieveResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.oauth + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OAuthRetrieveResponseTest { + + @Test + fun create() { + val oauthRetrieveResponse = OAuthRetrieveResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val oauthRetrieveResponse = OAuthRetrieveResponse.builder().build() + + val roundtrippedOAuthRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(oauthRetrieveResponse), + jacksonTypeRef<OAuthRetrieveResponse>(), + ) + + assertThat(roundtrippedOAuthRetrieveResponse).isEqualTo(oauthRetrieveResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartCreateParamsTest.kt new file mode 100644 index 00000000..0449e906 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartCreateParamsTest.kt @@ -0,0 +1,194 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgcharts + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.charts.CustomChartCreate +import com.langsmith_api.api.models.api.v1.charts.CustomChartMetric +import com.langsmith_api.api.models.api.v1.charts.CustomChartSeriesFilters +import com.langsmith_api.api.models.api.v1.charts.CustomChartType +import com.langsmith_api.api.models.api.v1.charts.HostProjectChartMetric +import com.langsmith_api.api.models.api.v1.sessions.RunStatsGroupBy +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OrgChartCreateParamsTest { + + @Test + fun create() { + OrgChartCreateParams.builder() + .customChartCreate( + CustomChartCreate.builder() + .chartType(CustomChartType.LINE) + .addSeries( + CustomChartCreate.Series.builder() + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .title("title") + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("description") + .index(0L) + .metadata(JsonValue.from(mapOf<String, Any>())) + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + } + + @Test + fun body() { + val params = + OrgChartCreateParams.builder() + .customChartCreate( + CustomChartCreate.builder() + .chartType(CustomChartType.LINE) + .addSeries( + CustomChartCreate.Series.builder() + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .title("title") + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("description") + .index(0L) + .metadata(JsonValue.from(mapOf<String, Any>())) + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + CustomChartCreate.builder() + .chartType(CustomChartType.LINE) + .addSeries( + CustomChartCreate.Series.builder() + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .title("title") + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("description") + .index(0L) + .metadata(JsonValue.from(mapOf<String, Any>())) + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + OrgChartCreateParams.builder() + .customChartCreate( + CustomChartCreate.builder() + .chartType(CustomChartType.LINE) + .addSeries( + CustomChartCreate.Series.builder() + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .build() + ) + .title("title") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + CustomChartCreate.builder() + .chartType(CustomChartType.LINE) + .addSeries( + CustomChartCreate.Series.builder() + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .build() + ) + .title("title") + .build() + ) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartDeleteParamsTest.kt new file mode 100644 index 00000000..4ed3a3ad --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartDeleteParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgcharts + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OrgChartDeleteParamsTest { + + @Test + fun create() { + OrgChartDeleteParams.builder().chartId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + OrgChartDeleteParams.builder().chartId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartDeleteResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartDeleteResponseTest.kt new file mode 100644 index 00000000..8578a7ce --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartDeleteResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgcharts + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OrgChartDeleteResponseTest { + + @Test + fun create() { + val orgChartDeleteResponse = OrgChartDeleteResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val orgChartDeleteResponse = OrgChartDeleteResponse.builder().build() + + val roundtrippedOrgChartDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(orgChartDeleteResponse), + jacksonTypeRef<OrgChartDeleteResponse>(), + ) + + assertThat(roundtrippedOrgChartDeleteResponse).isEqualTo(orgChartDeleteResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartOrgChartsParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartOrgChartsParamsTest.kt new file mode 100644 index 00000000..e80be8d1 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartOrgChartsParamsTest.kt @@ -0,0 +1,74 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgcharts + +import com.langsmith_api.api.models.api.v1.charts.CustomChartsRequest +import com.langsmith_api.api.models.api.v1.sessions.TimedeltaInput +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OrgChartOrgChartsParamsTest { + + @Test + fun create() { + OrgChartOrgChartsParams.builder() + .customChartsRequest( + CustomChartsRequest.builder() + .afterIndex(0L) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride(TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build()) + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .timezone("timezone") + .build() + ) + .build() + } + + @Test + fun body() { + val params = + OrgChartOrgChartsParams.builder() + .customChartsRequest( + CustomChartsRequest.builder() + .afterIndex(0L) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride(TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build()) + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .timezone("timezone") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + CustomChartsRequest.builder() + .afterIndex(0L) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride(TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build()) + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .timezone("timezone") + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + OrgChartOrgChartsParams.builder() + .customChartsRequest(CustomChartsRequest.builder().build()) + .build() + + val body = params._body() + + assertThat(body).isEqualTo(CustomChartsRequest.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartPreviewParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartPreviewParamsTest.kt new file mode 100644 index 00000000..44e641e3 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartPreviewParamsTest.kt @@ -0,0 +1,232 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgcharts + +import com.langsmith_api.api.models.api.v1.charts.CustomChartMetric +import com.langsmith_api.api.models.api.v1.charts.CustomChartPreviewRequest +import com.langsmith_api.api.models.api.v1.charts.CustomChartSeries +import com.langsmith_api.api.models.api.v1.charts.CustomChartSeriesFilters +import com.langsmith_api.api.models.api.v1.charts.HostProjectChartMetric +import com.langsmith_api.api.models.api.v1.orgcharts.section.CustomChartsRequestBase +import com.langsmith_api.api.models.api.v1.sessions.TimedeltaInput +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OrgChartPreviewParamsTest { + + @Test + fun create() { + OrgChartPreviewParams.builder() + .customChartPreviewRequest( + CustomChartPreviewRequest.builder() + .bucketInfo( + CustomChartsRequestBase.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride(TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build()) + .timezone("timezone") + .build() + ) + .chart( + CustomChartPreviewRequest.Chart.builder() + .addSeries( + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + CustomChartSeries.GroupBy.builder() + .attribute(CustomChartSeries.GroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .setBy(CustomChartSeries.GroupBy.SetBy.SECTION) + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .build() + ) + .build() + ) + .build() + } + + @Test + fun body() { + val params = + OrgChartPreviewParams.builder() + .customChartPreviewRequest( + CustomChartPreviewRequest.builder() + .bucketInfo( + CustomChartsRequestBase.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride( + TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build() + ) + .timezone("timezone") + .build() + ) + .chart( + CustomChartPreviewRequest.Chart.builder() + .addSeries( + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + CustomChartSeries.GroupBy.builder() + .attribute(CustomChartSeries.GroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .setBy(CustomChartSeries.GroupBy.SetBy.SECTION) + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .build() + ) + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + CustomChartPreviewRequest.builder() + .bucketInfo( + CustomChartsRequestBase.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride(TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build()) + .timezone("timezone") + .build() + ) + .chart( + CustomChartPreviewRequest.Chart.builder() + .addSeries( + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + CustomChartSeries.GroupBy.builder() + .attribute(CustomChartSeries.GroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .setBy(CustomChartSeries.GroupBy.SetBy.SECTION) + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .build() + ) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + OrgChartPreviewParams.builder() + .customChartPreviewRequest( + CustomChartPreviewRequest.builder() + .bucketInfo(CustomChartsRequestBase.builder().build()) + .chart( + CustomChartPreviewRequest.Chart.builder() + .addSeries( + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .build() + ) + .build() + ) + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + CustomChartPreviewRequest.builder() + .bucketInfo(CustomChartsRequestBase.builder().build()) + .chart( + CustomChartPreviewRequest.Chart.builder() + .addSeries( + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .build() + ) + .build() + ) + .build() + ) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartUpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartUpdateParamsTest.kt new file mode 100644 index 00000000..1f8c0b18 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/OrgChartUpdateParamsTest.kt @@ -0,0 +1,196 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgcharts + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.charts.CustomChartMetric +import com.langsmith_api.api.models.api.v1.charts.CustomChartSeriesFilters +import com.langsmith_api.api.models.api.v1.charts.CustomChartType +import com.langsmith_api.api.models.api.v1.charts.CustomChartUpdate +import com.langsmith_api.api.models.api.v1.charts.HostProjectChartMetric +import com.langsmith_api.api.models.api.v1.sessions.RunStatsGroupBy +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OrgChartUpdateParamsTest { + + @Test + fun create() { + OrgChartUpdateParams.builder() + .chartId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .customChartUpdate( + CustomChartUpdate.builder() + .chartType(CustomChartType.LINE) + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("string") + .index(0L) + .metadata(JsonValue.from(mapOf<String, Any>())) + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .seriesOfCustomChartSeriesUpdates( + listOf( + CustomChartUpdate.Series.CustomChartSeriesUpdate.builder() + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + ) + .title("string") + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + OrgChartUpdateParams.builder() + .chartId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .customChartUpdate(CustomChartUpdate.builder().build()) + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + OrgChartUpdateParams.builder() + .chartId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .customChartUpdate( + CustomChartUpdate.builder() + .chartType(CustomChartType.LINE) + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("string") + .index(0L) + .metadata(JsonValue.from(mapOf<String, Any>())) + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .seriesOfCustomChartSeriesUpdates( + listOf( + CustomChartUpdate.Series.CustomChartSeriesUpdate.builder() + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + ) + .title("string") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + CustomChartUpdate.builder() + .chartType(CustomChartType.LINE) + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("string") + .index(0L) + .metadata(JsonValue.from(mapOf<String, Any>())) + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .seriesOfCustomChartSeriesUpdates( + listOf( + CustomChartUpdate.Series.CustomChartSeriesUpdate.builder() + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + ) + .title("string") + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + OrgChartUpdateParams.builder() + .chartId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .customChartUpdate(CustomChartUpdate.builder().build()) + .build() + + val body = params._body() + + assertThat(body).isEqualTo(CustomChartUpdate.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/CustomChartsRequestBaseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/CustomChartsRequestBaseTest.kt new file mode 100644 index 00000000..ef18f820 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/CustomChartsRequestBaseTest.kt @@ -0,0 +1,55 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgcharts.section + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.sessions.TimedeltaInput +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CustomChartsRequestBaseTest { + + @Test + fun create() { + val customChartsRequestBase = + CustomChartsRequestBase.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride(TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build()) + .timezone("timezone") + .build() + + assertThat(customChartsRequestBase.endTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(customChartsRequestBase.omitData()).contains(true) + assertThat(customChartsRequestBase.startTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(customChartsRequestBase.stride()) + .contains(TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build()) + assertThat(customChartsRequestBase.timezone()).contains("timezone") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customChartsRequestBase = + CustomChartsRequestBase.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride(TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build()) + .timezone("timezone") + .build() + + val roundtrippedCustomChartsRequestBase = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customChartsRequestBase), + jacksonTypeRef<CustomChartsRequestBase>(), + ) + + assertThat(roundtrippedCustomChartsRequestBase).isEqualTo(customChartsRequestBase) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionCreateParamsTest.kt new file mode 100644 index 00000000..82d45093 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionCreateParamsTest.kt @@ -0,0 +1,62 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgcharts.section + +import com.langsmith_api.api.models.api.v1.charts.section.CustomChartsSectionCreate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SectionCreateParamsTest { + + @Test + fun create() { + SectionCreateParams.builder() + .customChartsSectionCreate( + CustomChartsSectionCreate.builder() + .title("title") + .description("description") + .index(0L) + .build() + ) + .build() + } + + @Test + fun body() { + val params = + SectionCreateParams.builder() + .customChartsSectionCreate( + CustomChartsSectionCreate.builder() + .title("title") + .description("description") + .index(0L) + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + CustomChartsSectionCreate.builder() + .title("title") + .description("description") + .index(0L) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + SectionCreateParams.builder() + .customChartsSectionCreate( + CustomChartsSectionCreate.builder().title("title").build() + ) + .build() + + val body = params._body() + + assertThat(body).isEqualTo(CustomChartsSectionCreate.builder().title("title").build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionDeleteParamsTest.kt new file mode 100644 index 00000000..8ec73005 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionDeleteParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgcharts.section + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SectionDeleteParamsTest { + + @Test + fun create() { + SectionDeleteParams.builder().sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + SectionDeleteParams.builder().sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionDeleteResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionDeleteResponseTest.kt new file mode 100644 index 00000000..f9d69401 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionDeleteResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgcharts.section + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SectionDeleteResponseTest { + + @Test + fun create() { + val sectionDeleteResponse = SectionDeleteResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val sectionDeleteResponse = SectionDeleteResponse.builder().build() + + val roundtrippedSectionDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(sectionDeleteResponse), + jacksonTypeRef<SectionDeleteResponse>(), + ) + + assertThat(roundtrippedSectionDeleteResponse).isEqualTo(sectionDeleteResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionListParamsTest.kt new file mode 100644 index 00000000..c1749f31 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionListParamsTest.kt @@ -0,0 +1,64 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgcharts.section + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SectionListParamsTest { + + @Test + fun create() { + SectionListParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .offset(0L) + .sortBy("sort_by") + .sortByDesc(true) + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .titleContains("title_contains") + .build() + } + + @Test + fun queryParams() { + val params = + SectionListParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .offset(0L) + .sortBy("sort_by") + .sortByDesc(true) + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .titleContains("title_contains") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("ids", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").joinToString(",")) + .put("limit", "1") + .put("offset", "0") + .put("sort_by", "sort_by") + .put("sort_by_desc", "true") + .put( + "tag_value_id", + listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").joinToString(","), + ) + .put("title_contains", "title_contains") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = SectionListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionUpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionUpdateParamsTest.kt new file mode 100644 index 00000000..69fa916a --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgcharts/section/SectionUpdateParamsTest.kt @@ -0,0 +1,76 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgcharts.section + +import com.langsmith_api.api.models.api.v1.charts.section.CustomChartsSectionUpdate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SectionUpdateParamsTest { + + @Test + fun create() { + SectionUpdateParams.builder() + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .customChartsSectionUpdate( + CustomChartsSectionUpdate.builder() + .description("string") + .index(0L) + .title("string") + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + SectionUpdateParams.builder() + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .customChartsSectionUpdate(CustomChartsSectionUpdate.builder().build()) + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + SectionUpdateParams.builder() + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .customChartsSectionUpdate( + CustomChartsSectionUpdate.builder() + .description("string") + .index(0L) + .title("string") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + CustomChartsSectionUpdate.builder() + .description("string") + .index(0L) + .title("string") + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + SectionUpdateParams.builder() + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .customChartsSectionUpdate(CustomChartsSectionUpdate.builder().build()) + .build() + + val body = params._body() + + assertThat(body).isEqualTo(CustomChartsSectionUpdate.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrgCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrgCreateParamsTest.kt new file mode 100644 index 00000000..2e4c8413 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrgCreateParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OrgCreateParamsTest { + + @Test + fun create() { + OrgCreateParams.builder().displayName("display_name").isPersonal(true).build() + } + + @Test + fun body() { + val params = OrgCreateParams.builder().displayName("display_name").isPersonal(true).build() + + val body = params._body() + + assertThat(body.displayName()).isEqualTo("display_name") + assertThat(body.isPersonal()).isEqualTo(true) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrgListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrgListParamsTest.kt new file mode 100644 index 00000000..85dd7f7e --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrgListParamsTest.kt @@ -0,0 +1,36 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OrgListParamsTest { + + @Test + fun create() { + OrgListParams.builder().includeTier(true).skipCreate(true).build() + } + + @Test + fun queryParams() { + val params = OrgListParams.builder().includeTier(true).skipCreate(true).build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder().put("include_tier", "true").put("skip_create", "true").build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = OrgListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrgRetrievePermissionsParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrgRetrievePermissionsParamsTest.kt new file mode 100644 index 00000000..7851b717 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrgRetrievePermissionsParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs + +import org.junit.jupiter.api.Test + +internal class OrgRetrievePermissionsParamsTest { + + @Test + fun create() { + OrgRetrievePermissionsParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrgRetrievePermissionsResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrgRetrievePermissionsResponseTest.kt new file mode 100644 index 00000000..c47b20b4 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrgRetrievePermissionsResponseTest.kt @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.orgs.current.members.AccessScope +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OrgRetrievePermissionsResponseTest { + + @Test + fun create() { + val orgRetrievePermissionsResponse = + OrgRetrievePermissionsResponse.builder() + .accessScope(AccessScope.ORGANIZATION) + .description("description") + .name("name") + .build() + + assertThat(orgRetrievePermissionsResponse.accessScope()).isEqualTo(AccessScope.ORGANIZATION) + assertThat(orgRetrievePermissionsResponse.description()).isEqualTo("description") + assertThat(orgRetrievePermissionsResponse.name()).isEqualTo("name") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val orgRetrievePermissionsResponse = + OrgRetrievePermissionsResponse.builder() + .accessScope(AccessScope.ORGANIZATION) + .description("description") + .name("name") + .build() + + val roundtrippedOrgRetrievePermissionsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(orgRetrievePermissionsResponse), + jacksonTypeRef<OrgRetrievePermissionsResponse>(), + ) + + assertThat(roundtrippedOrgRetrievePermissionsResponse) + .isEqualTo(orgRetrievePermissionsResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrganizationPgSchemaSlimTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrganizationPgSchemaSlimTest.kt new file mode 100644 index 00000000..64e851e9 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/OrganizationPgSchemaSlimTest.kt @@ -0,0 +1,88 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OrganizationPgSchemaSlimTest { + + @Test + fun create() { + val organizationPgSchemaSlim = + OrganizationPgSchemaSlim.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .disabled(true) + .displayName("display_name") + .isPersonal(true) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdByLsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdByUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .defaultSsoProvision(true) + .jitProvisioningEnabled(true) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .patCreationDisabled(true) + .publicSharingDisabled(true) + .ssoLoginSlug("sso_login_slug") + .ssoOnly(true) + .tier(PaymentPlanTier.NO_PLAN) + .workspaceAdminCanInviteToOrg(true) + .build() + + assertThat(organizationPgSchemaSlim.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(organizationPgSchemaSlim.disabled()).isEqualTo(true) + assertThat(organizationPgSchemaSlim.displayName()).isEqualTo("display_name") + assertThat(organizationPgSchemaSlim.isPersonal()).isEqualTo(true) + assertThat(organizationPgSchemaSlim.createdAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(organizationPgSchemaSlim.createdByLsUserId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(organizationPgSchemaSlim.createdByUserId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(organizationPgSchemaSlim.defaultSsoProvision()).contains(true) + assertThat(organizationPgSchemaSlim.jitProvisioningEnabled()).contains(true) + assertThat(organizationPgSchemaSlim.modifiedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(organizationPgSchemaSlim.patCreationDisabled()).contains(true) + assertThat(organizationPgSchemaSlim.publicSharingDisabled()).contains(true) + assertThat(organizationPgSchemaSlim.ssoLoginSlug()).contains("sso_login_slug") + assertThat(organizationPgSchemaSlim.ssoOnly()).contains(true) + assertThat(organizationPgSchemaSlim.tier()).contains(PaymentPlanTier.NO_PLAN) + assertThat(organizationPgSchemaSlim.workspaceAdminCanInviteToOrg()).contains(true) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val organizationPgSchemaSlim = + OrganizationPgSchemaSlim.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .disabled(true) + .displayName("display_name") + .isPersonal(true) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdByLsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdByUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .defaultSsoProvision(true) + .jitProvisioningEnabled(true) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .patCreationDisabled(true) + .publicSharingDisabled(true) + .ssoLoginSlug("sso_login_slug") + .ssoOnly(true) + .tier(PaymentPlanTier.NO_PLAN) + .workspaceAdminCanInviteToOrg(true) + .build() + + val roundtrippedOrganizationPgSchemaSlim = + jsonMapper.readValue( + jsonMapper.writeValueAsString(organizationPgSchemaSlim), + jacksonTypeRef<OrganizationPgSchemaSlim>(), + ) + + assertThat(roundtrippedOrganizationPgSchemaSlim).isEqualTo(organizationPgSchemaSlim) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentConfirmCheckoutSessionCompletionParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentConfirmCheckoutSessionCompletionParamsTest.kt new file mode 100644 index 00000000..1b22893a --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentConfirmCheckoutSessionCompletionParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CurrentConfirmCheckoutSessionCompletionParamsTest { + + @Test + fun create() { + CurrentConfirmCheckoutSessionCompletionParams.builder() + .stripeSessionId("stripe_session_id") + .build() + } + + @Test + fun body() { + val params = + CurrentConfirmCheckoutSessionCompletionParams.builder() + .stripeSessionId("stripe_session_id") + .build() + + val body = params._body() + + assertThat(body.stripeSessionId()).isEqualTo("stripe_session_id") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentConfirmCheckoutSessionCompletionResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentConfirmCheckoutSessionCompletionResponseTest.kt new file mode 100644 index 00000000..8236e5a4 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentConfirmCheckoutSessionCompletionResponseTest.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CurrentConfirmCheckoutSessionCompletionResponseTest { + + @Test + fun create() { + val currentConfirmCheckoutSessionCompletionResponse = + CurrentConfirmCheckoutSessionCompletionResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val currentConfirmCheckoutSessionCompletionResponse = + CurrentConfirmCheckoutSessionCompletionResponse.builder().build() + + val roundtrippedCurrentConfirmCheckoutSessionCompletionResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(currentConfirmCheckoutSessionCompletionResponse), + jacksonTypeRef<CurrentConfirmCheckoutSessionCompletionResponse>(), + ) + + assertThat(roundtrippedCurrentConfirmCheckoutSessionCompletionResponse) + .isEqualTo(currentConfirmCheckoutSessionCompletionResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentListParamsTest.kt new file mode 100644 index 00000000..7237dca8 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentListParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +import org.junit.jupiter.api.Test + +internal class CurrentListParamsTest { + + @Test + fun create() { + CurrentListParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentListResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentListResponseTest.kt new file mode 100644 index 00000000..77ea9510 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentListResponseTest.kt @@ -0,0 +1,323 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.orgs.PaymentPlanTier +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CurrentListResponseTest { + + @Test + fun create() { + val currentListResponse = + CurrentListResponse.builder() + .config( + OrganizationConfig.builder() + .allowCustomIframes(true) + .canAddSeats(true) + .canDisablePublicSharing(true) + .canServeDatasets(true) + .canUseAbac(true) + .canUseAgentBuilder(true) + .canUseBulkExport(true) + .canUseLanggraphCloud(true) + .canUseRbac(true) + .canUseSamlSso(true) + .clioEnabled(true) + .datadogRumSessionSampleRate(0L) + .demoLgpNewGraphEnabled(true) + .enableAlignEvaluators(true) + .enableIncludeExtendedStats(true) + .enableLanggraphPricing(true) + .enableLgpListenersPage(true) + .enableMarkdownInTracing(true) + .enableMonthlyUsageCharts(true) + .enableOrgUsageCharts(true) + .enablePricingRedesign(true) + .enableQueryingV2Endpoints(true) + .enableRunTreeStreaming(true) + .enableThreadViewPlayground(true) + .enableThreadsImprovements(true) + .kvDatasetMessageSupport(true) + .langgraphDeployOwnCloudEnabled(true) + .langgraphEnterpriseEnabled(true) + .langgraphRemoteReconcilerEnabled(true) + .langsmithAlertsLegacyPocEnabled(true) + .langsmithAlertsPocEnabled(true) + .langsmithExperimentalSearchEnabled(true) + .lgpTemplatesEnabled(true) + .maxFreeLanggraphCloudDeployments(0L) + .maxIdentities(0L) + .maxLanggraphCloudDeployments(0L) + .maxPromptWebhooks(0L) + .maxThreadEvaluatorsPerTenant(0L) + .maxWorkspaces(0L) + .newRuleEvaluatorCreationVersion(0L) + .partnerPlanApprovalDate("partner_plan_approval_date") + .playgroundEvaluatorStrategy("playground_evaluator_strategy") + .premierPlanApprovalDate("premier_plan_approval_date") + .promptOptimizationJobsEnabled(true) + .requireCodeEvaluatorLanguageField(true) + .showPlaygroundPromptCanvas(true) + .showUpdatedResourceTags(true) + .showUpdatedSidenav(true) + .startupPlanApprovalDate("startup_plan_approval_date") + .tenantSkipTopkFacets(true) + .threadEvaluatorsEnabled(true) + .useExactSearchForPrompts(true) + .usePythonPlaygroundService(true) + .build() + ) + .connectedToMetronome(true) + .connectedToStripe(true) + .hasCancelled(true) + .isPersonal(true) + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .currentPlan( + CustomerVisiblePlanInfo.builder() + .startedOn(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tier(PaymentPlanTier.NO_PLAN) + .endsOn(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .defaultSsoProvision(true) + .displayName("display_name") + .endOfBillingPeriod(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .marketplacePayoutsEnabled(true) + .paymentMethod( + StripePaymentMethodInfo.builder() + .brand("brand") + .email("email") + .expMonth(0L) + .expYear(0L) + .last4("last4") + .build() + ) + .addPermission("string") + .reachedMaxWorkspaces(true) + .tier(PaymentPlanTier.NO_PLAN) + .upcomingPlan( + CustomerVisiblePlanInfo.builder() + .startedOn(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tier(PaymentPlanTier.NO_PLAN) + .endsOn(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .wallet(Wallet.builder().creditBalanceMicros(0L).inflightBalanceMicros(0L).build()) + .build() + + assertThat(currentListResponse.config()) + .isEqualTo( + OrganizationConfig.builder() + .allowCustomIframes(true) + .canAddSeats(true) + .canDisablePublicSharing(true) + .canServeDatasets(true) + .canUseAbac(true) + .canUseAgentBuilder(true) + .canUseBulkExport(true) + .canUseLanggraphCloud(true) + .canUseRbac(true) + .canUseSamlSso(true) + .clioEnabled(true) + .datadogRumSessionSampleRate(0L) + .demoLgpNewGraphEnabled(true) + .enableAlignEvaluators(true) + .enableIncludeExtendedStats(true) + .enableLanggraphPricing(true) + .enableLgpListenersPage(true) + .enableMarkdownInTracing(true) + .enableMonthlyUsageCharts(true) + .enableOrgUsageCharts(true) + .enablePricingRedesign(true) + .enableQueryingV2Endpoints(true) + .enableRunTreeStreaming(true) + .enableThreadViewPlayground(true) + .enableThreadsImprovements(true) + .kvDatasetMessageSupport(true) + .langgraphDeployOwnCloudEnabled(true) + .langgraphEnterpriseEnabled(true) + .langgraphRemoteReconcilerEnabled(true) + .langsmithAlertsLegacyPocEnabled(true) + .langsmithAlertsPocEnabled(true) + .langsmithExperimentalSearchEnabled(true) + .lgpTemplatesEnabled(true) + .maxFreeLanggraphCloudDeployments(0L) + .maxIdentities(0L) + .maxLanggraphCloudDeployments(0L) + .maxPromptWebhooks(0L) + .maxThreadEvaluatorsPerTenant(0L) + .maxWorkspaces(0L) + .newRuleEvaluatorCreationVersion(0L) + .partnerPlanApprovalDate("partner_plan_approval_date") + .playgroundEvaluatorStrategy("playground_evaluator_strategy") + .premierPlanApprovalDate("premier_plan_approval_date") + .promptOptimizationJobsEnabled(true) + .requireCodeEvaluatorLanguageField(true) + .showPlaygroundPromptCanvas(true) + .showUpdatedResourceTags(true) + .showUpdatedSidenav(true) + .startupPlanApprovalDate("startup_plan_approval_date") + .tenantSkipTopkFacets(true) + .threadEvaluatorsEnabled(true) + .useExactSearchForPrompts(true) + .usePythonPlaygroundService(true) + .build() + ) + assertThat(currentListResponse.connectedToMetronome()).isEqualTo(true) + assertThat(currentListResponse.connectedToStripe()).isEqualTo(true) + assertThat(currentListResponse.hasCancelled()).isEqualTo(true) + assertThat(currentListResponse.isPersonal()).isEqualTo(true) + assertThat(currentListResponse.id()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(currentListResponse.currentPlan()) + .contains( + CustomerVisiblePlanInfo.builder() + .startedOn(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tier(PaymentPlanTier.NO_PLAN) + .endsOn(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(currentListResponse.defaultSsoProvision()).contains(true) + assertThat(currentListResponse.displayName()).contains("display_name") + assertThat(currentListResponse.endOfBillingPeriod()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(currentListResponse.marketplacePayoutsEnabled()).contains(true) + assertThat(currentListResponse.paymentMethod()) + .contains( + StripePaymentMethodInfo.builder() + .brand("brand") + .email("email") + .expMonth(0L) + .expYear(0L) + .last4("last4") + .build() + ) + assertThat(currentListResponse.permissions().getOrNull()).containsExactly("string") + assertThat(currentListResponse.reachedMaxWorkspaces()).contains(true) + assertThat(currentListResponse.tier()).contains(PaymentPlanTier.NO_PLAN) + assertThat(currentListResponse.upcomingPlan()) + .contains( + CustomerVisiblePlanInfo.builder() + .startedOn(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tier(PaymentPlanTier.NO_PLAN) + .endsOn(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(currentListResponse.wallet()) + .contains(Wallet.builder().creditBalanceMicros(0L).inflightBalanceMicros(0L).build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val currentListResponse = + CurrentListResponse.builder() + .config( + OrganizationConfig.builder() + .allowCustomIframes(true) + .canAddSeats(true) + .canDisablePublicSharing(true) + .canServeDatasets(true) + .canUseAbac(true) + .canUseAgentBuilder(true) + .canUseBulkExport(true) + .canUseLanggraphCloud(true) + .canUseRbac(true) + .canUseSamlSso(true) + .clioEnabled(true) + .datadogRumSessionSampleRate(0L) + .demoLgpNewGraphEnabled(true) + .enableAlignEvaluators(true) + .enableIncludeExtendedStats(true) + .enableLanggraphPricing(true) + .enableLgpListenersPage(true) + .enableMarkdownInTracing(true) + .enableMonthlyUsageCharts(true) + .enableOrgUsageCharts(true) + .enablePricingRedesign(true) + .enableQueryingV2Endpoints(true) + .enableRunTreeStreaming(true) + .enableThreadViewPlayground(true) + .enableThreadsImprovements(true) + .kvDatasetMessageSupport(true) + .langgraphDeployOwnCloudEnabled(true) + .langgraphEnterpriseEnabled(true) + .langgraphRemoteReconcilerEnabled(true) + .langsmithAlertsLegacyPocEnabled(true) + .langsmithAlertsPocEnabled(true) + .langsmithExperimentalSearchEnabled(true) + .lgpTemplatesEnabled(true) + .maxFreeLanggraphCloudDeployments(0L) + .maxIdentities(0L) + .maxLanggraphCloudDeployments(0L) + .maxPromptWebhooks(0L) + .maxThreadEvaluatorsPerTenant(0L) + .maxWorkspaces(0L) + .newRuleEvaluatorCreationVersion(0L) + .partnerPlanApprovalDate("partner_plan_approval_date") + .playgroundEvaluatorStrategy("playground_evaluator_strategy") + .premierPlanApprovalDate("premier_plan_approval_date") + .promptOptimizationJobsEnabled(true) + .requireCodeEvaluatorLanguageField(true) + .showPlaygroundPromptCanvas(true) + .showUpdatedResourceTags(true) + .showUpdatedSidenav(true) + .startupPlanApprovalDate("startup_plan_approval_date") + .tenantSkipTopkFacets(true) + .threadEvaluatorsEnabled(true) + .useExactSearchForPrompts(true) + .usePythonPlaygroundService(true) + .build() + ) + .connectedToMetronome(true) + .connectedToStripe(true) + .hasCancelled(true) + .isPersonal(true) + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .currentPlan( + CustomerVisiblePlanInfo.builder() + .startedOn(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tier(PaymentPlanTier.NO_PLAN) + .endsOn(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .defaultSsoProvision(true) + .displayName("display_name") + .endOfBillingPeriod(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .marketplacePayoutsEnabled(true) + .paymentMethod( + StripePaymentMethodInfo.builder() + .brand("brand") + .email("email") + .expMonth(0L) + .expYear(0L) + .last4("last4") + .build() + ) + .addPermission("string") + .reachedMaxWorkspaces(true) + .tier(PaymentPlanTier.NO_PLAN) + .upcomingPlan( + CustomerVisiblePlanInfo.builder() + .startedOn(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tier(PaymentPlanTier.NO_PLAN) + .endsOn(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .wallet(Wallet.builder().creditBalanceMicros(0L).inflightBalanceMicros(0L).build()) + .build() + + val roundtrippedCurrentListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(currentListResponse), + jacksonTypeRef<CurrentListResponse>(), + ) + + assertThat(roundtrippedCurrentListResponse).isEqualTo(currentListResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentPaymentMethodParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentPaymentMethodParamsTest.kt new file mode 100644 index 00000000..9044fd14 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentPaymentMethodParamsTest.kt @@ -0,0 +1,113 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CurrentPaymentMethodParamsTest { + + @Test + fun create() { + CurrentPaymentMethodParams.builder() + .billingInfo( + CurrentPaymentMethodParams.BillingInfo.builder() + .address( + StripeCustomerAddress.builder() + .city("city") + .country("country") + .line1("line1") + .postalCode("postal_code") + .line2("line2") + .state("state") + .build() + ) + .name("name") + .build() + ) + .setupIntent("setup_intent") + .build() + } + + @Test + fun body() { + val params = + CurrentPaymentMethodParams.builder() + .billingInfo( + CurrentPaymentMethodParams.BillingInfo.builder() + .address( + StripeCustomerAddress.builder() + .city("city") + .country("country") + .line1("line1") + .postalCode("postal_code") + .line2("line2") + .state("state") + .build() + ) + .name("name") + .build() + ) + .setupIntent("setup_intent") + .build() + + val body = params._body() + + assertThat(body.billingInfo()) + .isEqualTo( + CurrentPaymentMethodParams.BillingInfo.builder() + .address( + StripeCustomerAddress.builder() + .city("city") + .country("country") + .line1("line1") + .postalCode("postal_code") + .line2("line2") + .state("state") + .build() + ) + .name("name") + .build() + ) + assertThat(body.setupIntent()).isEqualTo("setup_intent") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + CurrentPaymentMethodParams.builder() + .billingInfo( + CurrentPaymentMethodParams.BillingInfo.builder() + .address( + StripeCustomerAddress.builder() + .city("city") + .country("country") + .line1("line1") + .postalCode("postal_code") + .build() + ) + .name("name") + .build() + ) + .setupIntent("setup_intent") + .build() + + val body = params._body() + + assertThat(body.billingInfo()) + .isEqualTo( + CurrentPaymentMethodParams.BillingInfo.builder() + .address( + StripeCustomerAddress.builder() + .city("city") + .country("country") + .line1("line1") + .postalCode("postal_code") + .build() + ) + .name("name") + .build() + ) + assertThat(body.setupIntent()).isEqualTo("setup_intent") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentPaymentMethodResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentPaymentMethodResponseTest.kt new file mode 100644 index 00000000..fe1cd048 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentPaymentMethodResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CurrentPaymentMethodResponseTest { + + @Test + fun create() { + val currentPaymentMethodResponse = CurrentPaymentMethodResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val currentPaymentMethodResponse = CurrentPaymentMethodResponse.builder().build() + + val roundtrippedCurrentPaymentMethodResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(currentPaymentMethodResponse), + jacksonTypeRef<CurrentPaymentMethodResponse>(), + ) + + assertThat(roundtrippedCurrentPaymentMethodResponse).isEqualTo(currentPaymentMethodResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentPlanParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentPlanParamsTest.kt new file mode 100644 index 00000000..3f2bf3dc --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentPlanParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CurrentPlanParamsTest { + + @Test + fun create() { + CurrentPlanParams.builder().tier(CurrentPlanParams.Tier.DISABLED).build() + } + + @Test + fun body() { + val params = CurrentPlanParams.builder().tier(CurrentPlanParams.Tier.DISABLED).build() + + val body = params._body() + + assertThat(body.tier()).isEqualTo(CurrentPlanParams.Tier.DISABLED) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentPlanResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentPlanResponseTest.kt new file mode 100644 index 00000000..bbbb3dc8 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentPlanResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CurrentPlanResponseTest { + + @Test + fun create() { + val currentPlanResponse = CurrentPlanResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val currentPlanResponse = CurrentPlanResponse.builder().build() + + val roundtrippedCurrentPlanResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(currentPlanResponse), + jacksonTypeRef<CurrentPlanResponse>(), + ) + + assertThat(roundtrippedCurrentPlanResponse).isEqualTo(currentPlanResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentRetrieveDashboardParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentRetrieveDashboardParamsTest.kt new file mode 100644 index 00000000..d0a56c35 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentRetrieveDashboardParamsTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CurrentRetrieveDashboardParamsTest { + + @Test + fun create() { + CurrentRetrieveDashboardParams.builder() + .colorScheme(CurrentRetrieveDashboardParams.ColorScheme.LIGHT) + .type(CurrentRetrieveDashboardParams.Type.INVOICES) + .build() + } + + @Test + fun queryParams() { + val params = + CurrentRetrieveDashboardParams.builder() + .colorScheme(CurrentRetrieveDashboardParams.ColorScheme.LIGHT) + .type(CurrentRetrieveDashboardParams.Type.INVOICES) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder().put("color_scheme", "light").put("type", "invoices").build() + ) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentRetrieveDashboardResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentRetrieveDashboardResponseTest.kt new file mode 100644 index 00000000..ddf88b11 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentRetrieveDashboardResponseTest.kt @@ -0,0 +1,35 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CurrentRetrieveDashboardResponseTest { + + @Test + fun create() { + val currentRetrieveDashboardResponse = + CurrentRetrieveDashboardResponse.builder().embeddableUrl("embeddable_url").build() + + assertThat(currentRetrieveDashboardResponse.embeddableUrl()).isEqualTo("embeddable_url") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val currentRetrieveDashboardResponse = + CurrentRetrieveDashboardResponse.builder().embeddableUrl("embeddable_url").build() + + val roundtrippedCurrentRetrieveDashboardResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(currentRetrieveDashboardResponse), + jacksonTypeRef<CurrentRetrieveDashboardResponse>(), + ) + + assertThat(roundtrippedCurrentRetrieveDashboardResponse) + .isEqualTo(currentRetrieveDashboardResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentSetDefaultSsoProvisionParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentSetDefaultSsoProvisionParamsTest.kt new file mode 100644 index 00000000..d7c8b9a0 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentSetDefaultSsoProvisionParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +import org.junit.jupiter.api.Test + +internal class CurrentSetDefaultSsoProvisionParamsTest { + + @Test + fun create() { + CurrentSetDefaultSsoProvisionParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentSetDefaultSsoProvisionResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentSetDefaultSsoProvisionResponseTest.kt new file mode 100644 index 00000000..51bf481b --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentSetDefaultSsoProvisionResponseTest.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CurrentSetDefaultSsoProvisionResponseTest { + + @Test + fun create() { + val currentSetDefaultSsoProvisionResponse = + CurrentSetDefaultSsoProvisionResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val currentSetDefaultSsoProvisionResponse = + CurrentSetDefaultSsoProvisionResponse.builder().build() + + val roundtrippedCurrentSetDefaultSsoProvisionResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(currentSetDefaultSsoProvisionResponse), + jacksonTypeRef<CurrentSetDefaultSsoProvisionResponse>(), + ) + + assertThat(roundtrippedCurrentSetDefaultSsoProvisionResponse) + .isEqualTo(currentSetDefaultSsoProvisionResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentSetupParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentSetupParamsTest.kt new file mode 100644 index 00000000..f4368bbb --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentSetupParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +import org.junit.jupiter.api.Test + +internal class CurrentSetupParamsTest { + + @Test + fun create() { + CurrentSetupParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentSetupResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentSetupResponseTest.kt new file mode 100644 index 00000000..65611b27 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentSetupResponseTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CurrentSetupResponseTest { + + @Test + fun create() { + val currentSetupResponse = + CurrentSetupResponse.builder().clientSecret("client_secret").build() + + assertThat(currentSetupResponse.clientSecret()).isEqualTo("client_secret") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val currentSetupResponse = + CurrentSetupResponse.builder().clientSecret("client_secret").build() + + val roundtrippedCurrentSetupResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(currentSetupResponse), + jacksonTypeRef<CurrentSetupResponse>(), + ) + + assertThat(roundtrippedCurrentSetupResponse).isEqualTo(currentSetupResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentStripeAccountLinksParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentStripeAccountLinksParamsTest.kt new file mode 100644 index 00000000..ca28b7d1 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentStripeAccountLinksParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CurrentStripeAccountLinksParamsTest { + + @Test + fun create() { + CurrentStripeAccountLinksParams.builder().successPath("success_path").build() + } + + @Test + fun body() { + val params = CurrentStripeAccountLinksParams.builder().successPath("success_path").build() + + val body = params._body() + + assertThat(body.successPath()).isEqualTo("success_path") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentStripeAccountLinksResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentStripeAccountLinksResponseTest.kt new file mode 100644 index 00000000..1e6e4985 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentStripeAccountLinksResponseTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CurrentStripeAccountLinksResponseTest { + + @Test + fun create() { + val currentStripeAccountLinksResponse = CurrentStripeAccountLinksResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val currentStripeAccountLinksResponse = CurrentStripeAccountLinksResponse.builder().build() + + val roundtrippedCurrentStripeAccountLinksResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(currentStripeAccountLinksResponse), + jacksonTypeRef<CurrentStripeAccountLinksResponse>(), + ) + + assertThat(roundtrippedCurrentStripeAccountLinksResponse) + .isEqualTo(currentStripeAccountLinksResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentStripeCheckoutSessionParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentStripeCheckoutSessionParamsTest.kt new file mode 100644 index 00000000..61db07f7 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentStripeCheckoutSessionParamsTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CurrentStripeCheckoutSessionParamsTest { + + @Test + fun create() { + CurrentStripeCheckoutSessionParams.builder() + .amountCents(0L) + .successPath("success_path") + .build() + } + + @Test + fun body() { + val params = + CurrentStripeCheckoutSessionParams.builder() + .amountCents(0L) + .successPath("success_path") + .build() + + val body = params._body() + + assertThat(body.amountCents()).isEqualTo(0L) + assertThat(body.successPath()).isEqualTo("success_path") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentStripeCheckoutSessionResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentStripeCheckoutSessionResponseTest.kt new file mode 100644 index 00000000..ad9d51b4 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentStripeCheckoutSessionResponseTest.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CurrentStripeCheckoutSessionResponseTest { + + @Test + fun create() { + val currentStripeCheckoutSessionResponse = + CurrentStripeCheckoutSessionResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val currentStripeCheckoutSessionResponse = + CurrentStripeCheckoutSessionResponse.builder().build() + + val roundtrippedCurrentStripeCheckoutSessionResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(currentStripeCheckoutSessionResponse), + jacksonTypeRef<CurrentStripeCheckoutSessionResponse>(), + ) + + assertThat(roundtrippedCurrentStripeCheckoutSessionResponse) + .isEqualTo(currentStripeCheckoutSessionResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentUpdateLoginMethodsParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentUpdateLoginMethodsParamsTest.kt new file mode 100644 index 00000000..ac5e1451 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentUpdateLoginMethodsParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CurrentUpdateLoginMethodsParamsTest { + + @Test + fun create() { + CurrentUpdateLoginMethodsParams.builder().ssoOnly(true).build() + } + + @Test + fun body() { + val params = CurrentUpdateLoginMethodsParams.builder().ssoOnly(true).build() + + val body = params._body() + + assertThat(body.ssoOnly()).isEqualTo(true) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentUpdateLoginMethodsResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentUpdateLoginMethodsResponseTest.kt new file mode 100644 index 00000000..30e36de8 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CurrentUpdateLoginMethodsResponseTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CurrentUpdateLoginMethodsResponseTest { + + @Test + fun create() { + val currentUpdateLoginMethodsResponse = CurrentUpdateLoginMethodsResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val currentUpdateLoginMethodsResponse = CurrentUpdateLoginMethodsResponse.builder().build() + + val roundtrippedCurrentUpdateLoginMethodsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(currentUpdateLoginMethodsResponse), + jacksonTypeRef<CurrentUpdateLoginMethodsResponse>(), + ) + + assertThat(roundtrippedCurrentUpdateLoginMethodsResponse) + .isEqualTo(currentUpdateLoginMethodsResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CustomerVisiblePlanInfoTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CustomerVisiblePlanInfoTest.kt new file mode 100644 index 00000000..7fab8919 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/CustomerVisiblePlanInfoTest.kt @@ -0,0 +1,48 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.orgs.PaymentPlanTier +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CustomerVisiblePlanInfoTest { + + @Test + fun create() { + val customerVisiblePlanInfo = + CustomerVisiblePlanInfo.builder() + .startedOn(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tier(PaymentPlanTier.NO_PLAN) + .endsOn(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(customerVisiblePlanInfo.startedOn()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(customerVisiblePlanInfo.tier()).isEqualTo(PaymentPlanTier.NO_PLAN) + assertThat(customerVisiblePlanInfo.endsOn()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customerVisiblePlanInfo = + CustomerVisiblePlanInfo.builder() + .startedOn(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tier(PaymentPlanTier.NO_PLAN) + .endsOn(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedCustomerVisiblePlanInfo = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customerVisiblePlanInfo), + jacksonTypeRef<CustomerVisiblePlanInfo>(), + ) + + assertThat(roundtrippedCustomerVisiblePlanInfo).isEqualTo(customerVisiblePlanInfo) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/OrganizationConfigTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/OrganizationConfigTest.kt new file mode 100644 index 00000000..b75817bf --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/OrganizationConfigTest.kt @@ -0,0 +1,198 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OrganizationConfigTest { + + @Test + fun create() { + val organizationConfig = + OrganizationConfig.builder() + .allowCustomIframes(true) + .canAddSeats(true) + .canDisablePublicSharing(true) + .canServeDatasets(true) + .canUseAbac(true) + .canUseAgentBuilder(true) + .canUseBulkExport(true) + .canUseLanggraphCloud(true) + .canUseRbac(true) + .canUseSamlSso(true) + .clioEnabled(true) + .datadogRumSessionSampleRate(0L) + .demoLgpNewGraphEnabled(true) + .enableAlignEvaluators(true) + .enableIncludeExtendedStats(true) + .enableLanggraphPricing(true) + .enableLgpListenersPage(true) + .enableMarkdownInTracing(true) + .enableMonthlyUsageCharts(true) + .enableOrgUsageCharts(true) + .enablePricingRedesign(true) + .enableQueryingV2Endpoints(true) + .enableRunTreeStreaming(true) + .enableThreadViewPlayground(true) + .enableThreadsImprovements(true) + .kvDatasetMessageSupport(true) + .langgraphDeployOwnCloudEnabled(true) + .langgraphEnterpriseEnabled(true) + .langgraphRemoteReconcilerEnabled(true) + .langsmithAlertsLegacyPocEnabled(true) + .langsmithAlertsPocEnabled(true) + .langsmithExperimentalSearchEnabled(true) + .lgpTemplatesEnabled(true) + .maxFreeLanggraphCloudDeployments(0L) + .maxIdentities(0L) + .maxLanggraphCloudDeployments(0L) + .maxPromptWebhooks(0L) + .maxThreadEvaluatorsPerTenant(0L) + .maxWorkspaces(0L) + .newRuleEvaluatorCreationVersion(0L) + .partnerPlanApprovalDate("partner_plan_approval_date") + .playgroundEvaluatorStrategy("playground_evaluator_strategy") + .premierPlanApprovalDate("premier_plan_approval_date") + .promptOptimizationJobsEnabled(true) + .requireCodeEvaluatorLanguageField(true) + .showPlaygroundPromptCanvas(true) + .showUpdatedResourceTags(true) + .showUpdatedSidenav(true) + .startupPlanApprovalDate("startup_plan_approval_date") + .tenantSkipTopkFacets(true) + .threadEvaluatorsEnabled(true) + .useExactSearchForPrompts(true) + .usePythonPlaygroundService(true) + .build() + + assertThat(organizationConfig.allowCustomIframes()).contains(true) + assertThat(organizationConfig.canAddSeats()).contains(true) + assertThat(organizationConfig.canDisablePublicSharing()).contains(true) + assertThat(organizationConfig.canServeDatasets()).contains(true) + assertThat(organizationConfig.canUseAbac()).contains(true) + assertThat(organizationConfig.canUseAgentBuilder()).contains(true) + assertThat(organizationConfig.canUseBulkExport()).contains(true) + assertThat(organizationConfig.canUseLanggraphCloud()).contains(true) + assertThat(organizationConfig.canUseRbac()).contains(true) + assertThat(organizationConfig.canUseSamlSso()).contains(true) + assertThat(organizationConfig.clioEnabled()).contains(true) + assertThat(organizationConfig.datadogRumSessionSampleRate()).contains(0L) + assertThat(organizationConfig.demoLgpNewGraphEnabled()).contains(true) + assertThat(organizationConfig.enableAlignEvaluators()).contains(true) + assertThat(organizationConfig.enableIncludeExtendedStats()).contains(true) + assertThat(organizationConfig.enableLanggraphPricing()).contains(true) + assertThat(organizationConfig.enableLgpListenersPage()).contains(true) + assertThat(organizationConfig.enableMarkdownInTracing()).contains(true) + assertThat(organizationConfig.enableMonthlyUsageCharts()).contains(true) + assertThat(organizationConfig.enableOrgUsageCharts()).contains(true) + assertThat(organizationConfig.enablePricingRedesign()).contains(true) + assertThat(organizationConfig.enableQueryingV2Endpoints()).contains(true) + assertThat(organizationConfig.enableRunTreeStreaming()).contains(true) + assertThat(organizationConfig.enableThreadViewPlayground()).contains(true) + assertThat(organizationConfig.enableThreadsImprovements()).contains(true) + assertThat(organizationConfig.kvDatasetMessageSupport()).contains(true) + assertThat(organizationConfig.langgraphDeployOwnCloudEnabled()).contains(true) + assertThat(organizationConfig.langgraphEnterpriseEnabled()).contains(true) + assertThat(organizationConfig.langgraphRemoteReconcilerEnabled()).contains(true) + assertThat(organizationConfig.langsmithAlertsLegacyPocEnabled()).contains(true) + assertThat(organizationConfig.langsmithAlertsPocEnabled()).contains(true) + assertThat(organizationConfig.langsmithExperimentalSearchEnabled()).contains(true) + assertThat(organizationConfig.lgpTemplatesEnabled()).contains(true) + assertThat(organizationConfig.maxFreeLanggraphCloudDeployments()).contains(0L) + assertThat(organizationConfig.maxIdentities()).contains(0L) + assertThat(organizationConfig.maxLanggraphCloudDeployments()).contains(0L) + assertThat(organizationConfig.maxPromptWebhooks()).contains(0L) + assertThat(organizationConfig.maxThreadEvaluatorsPerTenant()).contains(0L) + assertThat(organizationConfig.maxWorkspaces()).contains(0L) + assertThat(organizationConfig.newRuleEvaluatorCreationVersion()).contains(0L) + assertThat(organizationConfig.partnerPlanApprovalDate()) + .contains("partner_plan_approval_date") + assertThat(organizationConfig.playgroundEvaluatorStrategy()) + .contains("playground_evaluator_strategy") + assertThat(organizationConfig.premierPlanApprovalDate()) + .contains("premier_plan_approval_date") + assertThat(organizationConfig.promptOptimizationJobsEnabled()).contains(true) + assertThat(organizationConfig.requireCodeEvaluatorLanguageField()).contains(true) + assertThat(organizationConfig.showPlaygroundPromptCanvas()).contains(true) + assertThat(organizationConfig.showUpdatedResourceTags()).contains(true) + assertThat(organizationConfig.showUpdatedSidenav()).contains(true) + assertThat(organizationConfig.startupPlanApprovalDate()) + .contains("startup_plan_approval_date") + assertThat(organizationConfig.tenantSkipTopkFacets()).contains(true) + assertThat(organizationConfig.threadEvaluatorsEnabled()).contains(true) + assertThat(organizationConfig.useExactSearchForPrompts()).contains(true) + assertThat(organizationConfig.usePythonPlaygroundService()).contains(true) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val organizationConfig = + OrganizationConfig.builder() + .allowCustomIframes(true) + .canAddSeats(true) + .canDisablePublicSharing(true) + .canServeDatasets(true) + .canUseAbac(true) + .canUseAgentBuilder(true) + .canUseBulkExport(true) + .canUseLanggraphCloud(true) + .canUseRbac(true) + .canUseSamlSso(true) + .clioEnabled(true) + .datadogRumSessionSampleRate(0L) + .demoLgpNewGraphEnabled(true) + .enableAlignEvaluators(true) + .enableIncludeExtendedStats(true) + .enableLanggraphPricing(true) + .enableLgpListenersPage(true) + .enableMarkdownInTracing(true) + .enableMonthlyUsageCharts(true) + .enableOrgUsageCharts(true) + .enablePricingRedesign(true) + .enableQueryingV2Endpoints(true) + .enableRunTreeStreaming(true) + .enableThreadViewPlayground(true) + .enableThreadsImprovements(true) + .kvDatasetMessageSupport(true) + .langgraphDeployOwnCloudEnabled(true) + .langgraphEnterpriseEnabled(true) + .langgraphRemoteReconcilerEnabled(true) + .langsmithAlertsLegacyPocEnabled(true) + .langsmithAlertsPocEnabled(true) + .langsmithExperimentalSearchEnabled(true) + .lgpTemplatesEnabled(true) + .maxFreeLanggraphCloudDeployments(0L) + .maxIdentities(0L) + .maxLanggraphCloudDeployments(0L) + .maxPromptWebhooks(0L) + .maxThreadEvaluatorsPerTenant(0L) + .maxWorkspaces(0L) + .newRuleEvaluatorCreationVersion(0L) + .partnerPlanApprovalDate("partner_plan_approval_date") + .playgroundEvaluatorStrategy("playground_evaluator_strategy") + .premierPlanApprovalDate("premier_plan_approval_date") + .promptOptimizationJobsEnabled(true) + .requireCodeEvaluatorLanguageField(true) + .showPlaygroundPromptCanvas(true) + .showUpdatedResourceTags(true) + .showUpdatedSidenav(true) + .startupPlanApprovalDate("startup_plan_approval_date") + .tenantSkipTopkFacets(true) + .threadEvaluatorsEnabled(true) + .useExactSearchForPrompts(true) + .usePythonPlaygroundService(true) + .build() + + val roundtrippedOrganizationConfig = + jsonMapper.readValue( + jsonMapper.writeValueAsString(organizationConfig), + jacksonTypeRef<OrganizationConfig>(), + ) + + assertThat(roundtrippedOrganizationConfig).isEqualTo(organizationConfig) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/StripeCustomerAddressTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/StripeCustomerAddressTest.kt new file mode 100644 index 00000000..cf24e706 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/StripeCustomerAddressTest.kt @@ -0,0 +1,53 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class StripeCustomerAddressTest { + + @Test + fun create() { + val stripeCustomerAddress = + StripeCustomerAddress.builder() + .city("city") + .country("country") + .line1("line1") + .postalCode("postal_code") + .line2("line2") + .state("state") + .build() + + assertThat(stripeCustomerAddress.city()).isEqualTo("city") + assertThat(stripeCustomerAddress.country()).isEqualTo("country") + assertThat(stripeCustomerAddress.line1()).isEqualTo("line1") + assertThat(stripeCustomerAddress.postalCode()).isEqualTo("postal_code") + assertThat(stripeCustomerAddress.line2()).contains("line2") + assertThat(stripeCustomerAddress.state()).contains("state") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val stripeCustomerAddress = + StripeCustomerAddress.builder() + .city("city") + .country("country") + .line1("line1") + .postalCode("postal_code") + .line2("line2") + .state("state") + .build() + + val roundtrippedStripeCustomerAddress = + jsonMapper.readValue( + jsonMapper.writeValueAsString(stripeCustomerAddress), + jacksonTypeRef<StripeCustomerAddress>(), + ) + + assertThat(roundtrippedStripeCustomerAddress).isEqualTo(stripeCustomerAddress) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/StripePaymentMethodInfoTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/StripePaymentMethodInfoTest.kt new file mode 100644 index 00000000..f10018a4 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/StripePaymentMethodInfoTest.kt @@ -0,0 +1,50 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class StripePaymentMethodInfoTest { + + @Test + fun create() { + val stripePaymentMethodInfo = + StripePaymentMethodInfo.builder() + .brand("brand") + .email("email") + .expMonth(0L) + .expYear(0L) + .last4("last4") + .build() + + assertThat(stripePaymentMethodInfo.brand()).contains("brand") + assertThat(stripePaymentMethodInfo.email()).contains("email") + assertThat(stripePaymentMethodInfo.expMonth()).contains(0L) + assertThat(stripePaymentMethodInfo.expYear()).contains(0L) + assertThat(stripePaymentMethodInfo.last4()).contains("last4") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val stripePaymentMethodInfo = + StripePaymentMethodInfo.builder() + .brand("brand") + .email("email") + .expMonth(0L) + .expYear(0L) + .last4("last4") + .build() + + val roundtrippedStripePaymentMethodInfo = + jsonMapper.readValue( + jsonMapper.writeValueAsString(stripePaymentMethodInfo), + jacksonTypeRef<StripePaymentMethodInfo>(), + ) + + assertThat(roundtrippedStripePaymentMethodInfo).isEqualTo(stripePaymentMethodInfo) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/WalletTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/WalletTest.kt new file mode 100644 index 00000000..c255a8db --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/WalletTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class WalletTest { + + @Test + fun create() { + val wallet = Wallet.builder().creditBalanceMicros(0L).inflightBalanceMicros(0L).build() + + assertThat(wallet.creditBalanceMicros()).isEqualTo(0L) + assertThat(wallet.inflightBalanceMicros()).isEqualTo(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val wallet = Wallet.builder().creditBalanceMicros(0L).inflightBalanceMicros(0L).build() + + val roundtrippedWallet = + jsonMapper.readValue(jsonMapper.writeValueAsString(wallet), jacksonTypeRef<Wallet>()) + + assertThat(roundtrippedWallet).isEqualTo(wallet) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/billing/BillingListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/billing/BillingListParamsTest.kt new file mode 100644 index 00000000..e9260bc1 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/billing/BillingListParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.billing + +import org.junit.jupiter.api.Test + +internal class BillingListParamsTest { + + @Test + fun create() { + BillingListParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/billing/BillingListResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/billing/BillingListResponseTest.kt new file mode 100644 index 00000000..882336e4 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/billing/BillingListResponseTest.kt @@ -0,0 +1,315 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.billing + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.orgs.PaymentPlanTier +import com.langsmith_api.api.models.api.v1.orgs.current.CustomerVisiblePlanInfo +import com.langsmith_api.api.models.api.v1.orgs.current.OrganizationConfig +import com.langsmith_api.api.models.api.v1.orgs.current.StripePaymentMethodInfo +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BillingListResponseTest { + + @Test + fun create() { + val billingListResponse = + BillingListResponse.builder() + .config( + OrganizationConfig.builder() + .allowCustomIframes(true) + .canAddSeats(true) + .canDisablePublicSharing(true) + .canServeDatasets(true) + .canUseAbac(true) + .canUseAgentBuilder(true) + .canUseBulkExport(true) + .canUseLanggraphCloud(true) + .canUseRbac(true) + .canUseSamlSso(true) + .clioEnabled(true) + .datadogRumSessionSampleRate(0L) + .demoLgpNewGraphEnabled(true) + .enableAlignEvaluators(true) + .enableIncludeExtendedStats(true) + .enableLanggraphPricing(true) + .enableLgpListenersPage(true) + .enableMarkdownInTracing(true) + .enableMonthlyUsageCharts(true) + .enableOrgUsageCharts(true) + .enablePricingRedesign(true) + .enableQueryingV2Endpoints(true) + .enableRunTreeStreaming(true) + .enableThreadViewPlayground(true) + .enableThreadsImprovements(true) + .kvDatasetMessageSupport(true) + .langgraphDeployOwnCloudEnabled(true) + .langgraphEnterpriseEnabled(true) + .langgraphRemoteReconcilerEnabled(true) + .langsmithAlertsLegacyPocEnabled(true) + .langsmithAlertsPocEnabled(true) + .langsmithExperimentalSearchEnabled(true) + .lgpTemplatesEnabled(true) + .maxFreeLanggraphCloudDeployments(0L) + .maxIdentities(0L) + .maxLanggraphCloudDeployments(0L) + .maxPromptWebhooks(0L) + .maxThreadEvaluatorsPerTenant(0L) + .maxWorkspaces(0L) + .newRuleEvaluatorCreationVersion(0L) + .partnerPlanApprovalDate("partner_plan_approval_date") + .playgroundEvaluatorStrategy("playground_evaluator_strategy") + .premierPlanApprovalDate("premier_plan_approval_date") + .promptOptimizationJobsEnabled(true) + .requireCodeEvaluatorLanguageField(true) + .showPlaygroundPromptCanvas(true) + .showUpdatedResourceTags(true) + .showUpdatedSidenav(true) + .startupPlanApprovalDate("startup_plan_approval_date") + .tenantSkipTopkFacets(true) + .threadEvaluatorsEnabled(true) + .useExactSearchForPrompts(true) + .usePythonPlaygroundService(true) + .build() + ) + .connectedToMetronome(true) + .connectedToStripe(true) + .displayName("display_name") + .isPersonal(true) + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .currentPlan( + CustomerVisiblePlanInfo.builder() + .startedOn(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tier(PaymentPlanTier.NO_PLAN) + .endsOn(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .defaultSsoProvision(true) + .disabled(true) + .endOfBillingPeriod(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentMethod( + StripePaymentMethodInfo.builder() + .brand("brand") + .email("email") + .expMonth(0L) + .expYear(0L) + .last4("last4") + .build() + ) + .reachedMaxWorkspaces(true) + .tier(PaymentPlanTier.NO_PLAN) + .upcomingPlan( + CustomerVisiblePlanInfo.builder() + .startedOn(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tier(PaymentPlanTier.NO_PLAN) + .endsOn(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + + assertThat(billingListResponse.config()) + .isEqualTo( + OrganizationConfig.builder() + .allowCustomIframes(true) + .canAddSeats(true) + .canDisablePublicSharing(true) + .canServeDatasets(true) + .canUseAbac(true) + .canUseAgentBuilder(true) + .canUseBulkExport(true) + .canUseLanggraphCloud(true) + .canUseRbac(true) + .canUseSamlSso(true) + .clioEnabled(true) + .datadogRumSessionSampleRate(0L) + .demoLgpNewGraphEnabled(true) + .enableAlignEvaluators(true) + .enableIncludeExtendedStats(true) + .enableLanggraphPricing(true) + .enableLgpListenersPage(true) + .enableMarkdownInTracing(true) + .enableMonthlyUsageCharts(true) + .enableOrgUsageCharts(true) + .enablePricingRedesign(true) + .enableQueryingV2Endpoints(true) + .enableRunTreeStreaming(true) + .enableThreadViewPlayground(true) + .enableThreadsImprovements(true) + .kvDatasetMessageSupport(true) + .langgraphDeployOwnCloudEnabled(true) + .langgraphEnterpriseEnabled(true) + .langgraphRemoteReconcilerEnabled(true) + .langsmithAlertsLegacyPocEnabled(true) + .langsmithAlertsPocEnabled(true) + .langsmithExperimentalSearchEnabled(true) + .lgpTemplatesEnabled(true) + .maxFreeLanggraphCloudDeployments(0L) + .maxIdentities(0L) + .maxLanggraphCloudDeployments(0L) + .maxPromptWebhooks(0L) + .maxThreadEvaluatorsPerTenant(0L) + .maxWorkspaces(0L) + .newRuleEvaluatorCreationVersion(0L) + .partnerPlanApprovalDate("partner_plan_approval_date") + .playgroundEvaluatorStrategy("playground_evaluator_strategy") + .premierPlanApprovalDate("premier_plan_approval_date") + .promptOptimizationJobsEnabled(true) + .requireCodeEvaluatorLanguageField(true) + .showPlaygroundPromptCanvas(true) + .showUpdatedResourceTags(true) + .showUpdatedSidenav(true) + .startupPlanApprovalDate("startup_plan_approval_date") + .tenantSkipTopkFacets(true) + .threadEvaluatorsEnabled(true) + .useExactSearchForPrompts(true) + .usePythonPlaygroundService(true) + .build() + ) + assertThat(billingListResponse.connectedToMetronome()).isEqualTo(true) + assertThat(billingListResponse.connectedToStripe()).isEqualTo(true) + assertThat(billingListResponse.displayName()).isEqualTo("display_name") + assertThat(billingListResponse.isPersonal()).isEqualTo(true) + assertThat(billingListResponse.id()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(billingListResponse.currentPlan()) + .contains( + CustomerVisiblePlanInfo.builder() + .startedOn(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tier(PaymentPlanTier.NO_PLAN) + .endsOn(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(billingListResponse.defaultSsoProvision()).contains(true) + assertThat(billingListResponse.disabled()).contains(true) + assertThat(billingListResponse.endOfBillingPeriod()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(billingListResponse.paymentMethod()) + .contains( + StripePaymentMethodInfo.builder() + .brand("brand") + .email("email") + .expMonth(0L) + .expYear(0L) + .last4("last4") + .build() + ) + assertThat(billingListResponse.reachedMaxWorkspaces()).contains(true) + assertThat(billingListResponse.tier()).contains(PaymentPlanTier.NO_PLAN) + assertThat(billingListResponse.upcomingPlan()) + .contains( + CustomerVisiblePlanInfo.builder() + .startedOn(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tier(PaymentPlanTier.NO_PLAN) + .endsOn(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val billingListResponse = + BillingListResponse.builder() + .config( + OrganizationConfig.builder() + .allowCustomIframes(true) + .canAddSeats(true) + .canDisablePublicSharing(true) + .canServeDatasets(true) + .canUseAbac(true) + .canUseAgentBuilder(true) + .canUseBulkExport(true) + .canUseLanggraphCloud(true) + .canUseRbac(true) + .canUseSamlSso(true) + .clioEnabled(true) + .datadogRumSessionSampleRate(0L) + .demoLgpNewGraphEnabled(true) + .enableAlignEvaluators(true) + .enableIncludeExtendedStats(true) + .enableLanggraphPricing(true) + .enableLgpListenersPage(true) + .enableMarkdownInTracing(true) + .enableMonthlyUsageCharts(true) + .enableOrgUsageCharts(true) + .enablePricingRedesign(true) + .enableQueryingV2Endpoints(true) + .enableRunTreeStreaming(true) + .enableThreadViewPlayground(true) + .enableThreadsImprovements(true) + .kvDatasetMessageSupport(true) + .langgraphDeployOwnCloudEnabled(true) + .langgraphEnterpriseEnabled(true) + .langgraphRemoteReconcilerEnabled(true) + .langsmithAlertsLegacyPocEnabled(true) + .langsmithAlertsPocEnabled(true) + .langsmithExperimentalSearchEnabled(true) + .lgpTemplatesEnabled(true) + .maxFreeLanggraphCloudDeployments(0L) + .maxIdentities(0L) + .maxLanggraphCloudDeployments(0L) + .maxPromptWebhooks(0L) + .maxThreadEvaluatorsPerTenant(0L) + .maxWorkspaces(0L) + .newRuleEvaluatorCreationVersion(0L) + .partnerPlanApprovalDate("partner_plan_approval_date") + .playgroundEvaluatorStrategy("playground_evaluator_strategy") + .premierPlanApprovalDate("premier_plan_approval_date") + .promptOptimizationJobsEnabled(true) + .requireCodeEvaluatorLanguageField(true) + .showPlaygroundPromptCanvas(true) + .showUpdatedResourceTags(true) + .showUpdatedSidenav(true) + .startupPlanApprovalDate("startup_plan_approval_date") + .tenantSkipTopkFacets(true) + .threadEvaluatorsEnabled(true) + .useExactSearchForPrompts(true) + .usePythonPlaygroundService(true) + .build() + ) + .connectedToMetronome(true) + .connectedToStripe(true) + .displayName("display_name") + .isPersonal(true) + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .currentPlan( + CustomerVisiblePlanInfo.builder() + .startedOn(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tier(PaymentPlanTier.NO_PLAN) + .endsOn(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .defaultSsoProvision(true) + .disabled(true) + .endOfBillingPeriod(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentMethod( + StripePaymentMethodInfo.builder() + .brand("brand") + .email("email") + .expMonth(0L) + .expYear(0L) + .last4("last4") + .build() + ) + .reachedMaxWorkspaces(true) + .tier(PaymentPlanTier.NO_PLAN) + .upcomingPlan( + CustomerVisiblePlanInfo.builder() + .startedOn(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tier(PaymentPlanTier.NO_PLAN) + .endsOn(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + + val roundtrippedBillingListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(billingListResponse), + jacksonTypeRef<BillingListResponse>(), + ) + + assertThat(roundtrippedBillingListResponse).isEqualTo(billingListResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/billing/BillingRetrieveUsageParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/billing/BillingRetrieveUsageParamsTest.kt new file mode 100644 index 00000000..5ef41f1c --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/billing/BillingRetrieveUsageParamsTest.kt @@ -0,0 +1,60 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.billing + +import com.langsmith_api.api.core.http.QueryParams +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BillingRetrieveUsageParamsTest { + + @Test + fun create() { + BillingRetrieveUsageParams.builder() + .endingBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startingOn(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .onCurrentPlan(true) + .build() + } + + @Test + fun queryParams() { + val params = + BillingRetrieveUsageParams.builder() + .endingBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startingOn(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .onCurrentPlan(true) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("ending_before", "2019-12-27T18:11:19.117Z") + .put("starting_on", "2019-12-27T18:11:19.117Z") + .put("on_current_plan", "true") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + BillingRetrieveUsageParams.builder() + .endingBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startingOn(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("ending_before", "2019-12-27T18:11:19.117Z") + .put("starting_on", "2019-12-27T18:11:19.117Z") + .build() + ) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/billing/BillingRetrieveUsageResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/billing/BillingRetrieveUsageResponseTest.kt new file mode 100644 index 00000000..2ece5497 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/billing/BillingRetrieveUsageResponseTest.kt @@ -0,0 +1,71 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.billing + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BillingRetrieveUsageResponseTest { + + @Test + fun create() { + val billingRetrieveUsageResponse = + BillingRetrieveUsageResponse.builder() + .billableMetricId("billable_metric_id") + .billableMetricName("billable_metric_name") + .customerId("customer_id") + .endTimestamp("end_timestamp") + .groups( + BillingRetrieveUsageResponse.Groups.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .startTimestamp("start_timestamp") + .value(0.0) + .build() + + assertThat(billingRetrieveUsageResponse.billableMetricId()).isEqualTo("billable_metric_id") + assertThat(billingRetrieveUsageResponse.billableMetricName()) + .isEqualTo("billable_metric_name") + assertThat(billingRetrieveUsageResponse.customerId()).isEqualTo("customer_id") + assertThat(billingRetrieveUsageResponse.endTimestamp()).isEqualTo("end_timestamp") + assertThat(billingRetrieveUsageResponse.groups()) + .contains( + BillingRetrieveUsageResponse.Groups.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + assertThat(billingRetrieveUsageResponse.startTimestamp()).isEqualTo("start_timestamp") + assertThat(billingRetrieveUsageResponse.value()).contains(0.0) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val billingRetrieveUsageResponse = + BillingRetrieveUsageResponse.builder() + .billableMetricId("billable_metric_id") + .billableMetricName("billable_metric_name") + .customerId("customer_id") + .endTimestamp("end_timestamp") + .groups( + BillingRetrieveUsageResponse.Groups.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .startTimestamp("start_timestamp") + .value(0.0) + .build() + + val roundtrippedBillingRetrieveUsageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(billingRetrieveUsageResponse), + jacksonTypeRef<BillingRetrieveUsageResponse>(), + ) + + assertThat(roundtrippedBillingRetrieveUsageResponse).isEqualTo(billingRetrieveUsageResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/BusinessInfoBusinessInfoParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/BusinessInfoBusinessInfoParamsTest.kt new file mode 100644 index 00000000..c0dd82d5 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/BusinessInfoBusinessInfoParamsTest.kt @@ -0,0 +1,88 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.businessinfo + +import com.langsmith_api.api.models.api.v1.orgs.current.StripeCustomerAddress +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BusinessInfoBusinessInfoParamsTest { + + @Test + fun create() { + BusinessInfoBusinessInfoParams.builder() + .companyInfo( + StripeBusinessBillingInfo.builder() + .name("name") + .address( + StripeCustomerAddress.builder() + .city("city") + .country("country") + .line1("line1") + .postalCode("postal_code") + .line2("line2") + .state("state") + .build() + ) + .build() + ) + .invoiceEmail("invoice_email") + .isBusiness(true) + .taxId(StripeTaxId.builder().type("type").value("value").build()) + .build() + } + + @Test + fun body() { + val params = + BusinessInfoBusinessInfoParams.builder() + .companyInfo( + StripeBusinessBillingInfo.builder() + .name("name") + .address( + StripeCustomerAddress.builder() + .city("city") + .country("country") + .line1("line1") + .postalCode("postal_code") + .line2("line2") + .state("state") + .build() + ) + .build() + ) + .invoiceEmail("invoice_email") + .isBusiness(true) + .taxId(StripeTaxId.builder().type("type").value("value").build()) + .build() + + val body = params._body() + + assertThat(body.companyInfo()) + .contains( + StripeBusinessBillingInfo.builder() + .name("name") + .address( + StripeCustomerAddress.builder() + .city("city") + .country("country") + .line1("line1") + .postalCode("postal_code") + .line2("line2") + .state("state") + .build() + ) + .build() + ) + assertThat(body.invoiceEmail()).contains("invoice_email") + assertThat(body.isBusiness()).contains(true) + assertThat(body.taxId()).contains(StripeTaxId.builder().type("type").value("value").build()) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = BusinessInfoBusinessInfoParams.builder().build() + + val body = params._body() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/BusinessInfoBusinessInfoResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/BusinessInfoBusinessInfoResponseTest.kt new file mode 100644 index 00000000..d5db3c21 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/BusinessInfoBusinessInfoResponseTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.businessinfo + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BusinessInfoBusinessInfoResponseTest { + + @Test + fun create() { + val businessInfoBusinessInfoResponse = BusinessInfoBusinessInfoResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val businessInfoBusinessInfoResponse = BusinessInfoBusinessInfoResponse.builder().build() + + val roundtrippedBusinessInfoBusinessInfoResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(businessInfoBusinessInfoResponse), + jacksonTypeRef<BusinessInfoBusinessInfoResponse>(), + ) + + assertThat(roundtrippedBusinessInfoBusinessInfoResponse) + .isEqualTo(businessInfoBusinessInfoResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/BusinessInfoRetrieveBusinessInfoParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/BusinessInfoRetrieveBusinessInfoParamsTest.kt new file mode 100644 index 00000000..1924c2bd --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/BusinessInfoRetrieveBusinessInfoParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.businessinfo + +import org.junit.jupiter.api.Test + +internal class BusinessInfoRetrieveBusinessInfoParamsTest { + + @Test + fun create() { + BusinessInfoRetrieveBusinessInfoParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/BusinessInfoRetrieveBusinessInfoResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/BusinessInfoRetrieveBusinessInfoResponseTest.kt new file mode 100644 index 00000000..573821d8 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/BusinessInfoRetrieveBusinessInfoResponseTest.kt @@ -0,0 +1,94 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.businessinfo + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.orgs.current.StripeCustomerAddress +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BusinessInfoRetrieveBusinessInfoResponseTest { + + @Test + fun create() { + val businessInfoRetrieveBusinessInfoResponse = + BusinessInfoRetrieveBusinessInfoResponse.builder() + .companyInfo( + StripeBusinessBillingInfo.builder() + .name("name") + .address( + StripeCustomerAddress.builder() + .city("city") + .country("country") + .line1("line1") + .postalCode("postal_code") + .line2("line2") + .state("state") + .build() + ) + .build() + ) + .invoiceEmail("invoice_email") + .isBusiness(true) + .taxId(StripeTaxId.builder().type("type").value("value").build()) + .build() + + assertThat(businessInfoRetrieveBusinessInfoResponse.companyInfo()) + .contains( + StripeBusinessBillingInfo.builder() + .name("name") + .address( + StripeCustomerAddress.builder() + .city("city") + .country("country") + .line1("line1") + .postalCode("postal_code") + .line2("line2") + .state("state") + .build() + ) + .build() + ) + assertThat(businessInfoRetrieveBusinessInfoResponse.invoiceEmail()) + .contains("invoice_email") + assertThat(businessInfoRetrieveBusinessInfoResponse.isBusiness()).contains(true) + assertThat(businessInfoRetrieveBusinessInfoResponse.taxId()) + .contains(StripeTaxId.builder().type("type").value("value").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val businessInfoRetrieveBusinessInfoResponse = + BusinessInfoRetrieveBusinessInfoResponse.builder() + .companyInfo( + StripeBusinessBillingInfo.builder() + .name("name") + .address( + StripeCustomerAddress.builder() + .city("city") + .country("country") + .line1("line1") + .postalCode("postal_code") + .line2("line2") + .state("state") + .build() + ) + .build() + ) + .invoiceEmail("invoice_email") + .isBusiness(true) + .taxId(StripeTaxId.builder().type("type").value("value").build()) + .build() + + val roundtrippedBusinessInfoRetrieveBusinessInfoResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(businessInfoRetrieveBusinessInfoResponse), + jacksonTypeRef<BusinessInfoRetrieveBusinessInfoResponse>(), + ) + + assertThat(roundtrippedBusinessInfoRetrieveBusinessInfoResponse) + .isEqualTo(businessInfoRetrieveBusinessInfoResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/StripeBusinessBillingInfoTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/StripeBusinessBillingInfoTest.kt new file mode 100644 index 00000000..dd5ace79 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/StripeBusinessBillingInfoTest.kt @@ -0,0 +1,70 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.businessinfo + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.orgs.current.StripeCustomerAddress +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class StripeBusinessBillingInfoTest { + + @Test + fun create() { + val stripeBusinessBillingInfo = + StripeBusinessBillingInfo.builder() + .name("name") + .address( + StripeCustomerAddress.builder() + .city("city") + .country("country") + .line1("line1") + .postalCode("postal_code") + .line2("line2") + .state("state") + .build() + ) + .build() + + assertThat(stripeBusinessBillingInfo.name()).isEqualTo("name") + assertThat(stripeBusinessBillingInfo.address()) + .contains( + StripeCustomerAddress.builder() + .city("city") + .country("country") + .line1("line1") + .postalCode("postal_code") + .line2("line2") + .state("state") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val stripeBusinessBillingInfo = + StripeBusinessBillingInfo.builder() + .name("name") + .address( + StripeCustomerAddress.builder() + .city("city") + .country("country") + .line1("line1") + .postalCode("postal_code") + .line2("line2") + .state("state") + .build() + ) + .build() + + val roundtrippedStripeBusinessBillingInfo = + jsonMapper.readValue( + jsonMapper.writeValueAsString(stripeBusinessBillingInfo), + jacksonTypeRef<StripeBusinessBillingInfo>(), + ) + + assertThat(roundtrippedStripeBusinessBillingInfo).isEqualTo(stripeBusinessBillingInfo) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/StripeTaxIdTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/StripeTaxIdTest.kt new file mode 100644 index 00000000..6742671b --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/businessinfo/StripeTaxIdTest.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.businessinfo + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class StripeTaxIdTest { + + @Test + fun create() { + val stripeTaxId = StripeTaxId.builder().type("type").value("value").build() + + assertThat(stripeTaxId.type()).isEqualTo("type") + assertThat(stripeTaxId.value()).isEqualTo("value") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val stripeTaxId = StripeTaxId.builder().type("type").value("value").build() + + val roundtrippedStripeTaxId = + jsonMapper.readValue( + jsonMapper.writeValueAsString(stripeTaxId), + jacksonTypeRef<StripeTaxId>(), + ) + + assertThat(roundtrippedStripeTaxId).isEqualTo(stripeTaxId) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/info/InfoListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/info/InfoListParamsTest.kt new file mode 100644 index 00000000..ad703a8d --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/info/InfoListParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.info + +import org.junit.jupiter.api.Test + +internal class InfoListParamsTest { + + @Test + fun create() { + InfoListParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/info/InfoPatchAllParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/info/InfoPatchAllParamsTest.kt new file mode 100644 index 00000000..8a78e0bc --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/info/InfoPatchAllParamsTest.kt @@ -0,0 +1,50 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.info + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InfoPatchAllParamsTest { + + @Test + fun create() { + InfoPatchAllParams.builder() + .displayName("display_name") + .jitProvisioningEnabled(true) + .patCreationDisabled(true) + .publicSharingDisabled(true) + .unshareAll(true) + .workspaceAdminCanInviteToOrg(true) + .build() + } + + @Test + fun body() { + val params = + InfoPatchAllParams.builder() + .displayName("display_name") + .jitProvisioningEnabled(true) + .patCreationDisabled(true) + .publicSharingDisabled(true) + .unshareAll(true) + .workspaceAdminCanInviteToOrg(true) + .build() + + val body = params._body() + + assertThat(body.displayName()).contains("display_name") + assertThat(body.jitProvisioningEnabled()).contains(true) + assertThat(body.patCreationDisabled()).contains(true) + assertThat(body.publicSharingDisabled()).contains(true) + assertThat(body.unshareAll()).contains(true) + assertThat(body.workspaceAdminCanInviteToOrg()).contains(true) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = InfoPatchAllParams.builder().build() + + val body = params._body() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/info/OrganizationInfoTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/info/OrganizationInfoTest.kt new file mode 100644 index 00000000..9bbef08b --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/info/OrganizationInfoTest.kt @@ -0,0 +1,260 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.info + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.orgs.PaymentPlanTier +import com.langsmith_api.api.models.api.v1.orgs.current.OrganizationConfig +import com.langsmith_api.api.models.api.v1.orgs.current.Wallet +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OrganizationInfoTest { + + @Test + fun create() { + val organizationInfo = + OrganizationInfo.builder() + .config( + OrganizationConfig.builder() + .allowCustomIframes(true) + .canAddSeats(true) + .canDisablePublicSharing(true) + .canServeDatasets(true) + .canUseAbac(true) + .canUseAgentBuilder(true) + .canUseBulkExport(true) + .canUseLanggraphCloud(true) + .canUseRbac(true) + .canUseSamlSso(true) + .clioEnabled(true) + .datadogRumSessionSampleRate(0L) + .demoLgpNewGraphEnabled(true) + .enableAlignEvaluators(true) + .enableIncludeExtendedStats(true) + .enableLanggraphPricing(true) + .enableLgpListenersPage(true) + .enableMarkdownInTracing(true) + .enableMonthlyUsageCharts(true) + .enableOrgUsageCharts(true) + .enablePricingRedesign(true) + .enableQueryingV2Endpoints(true) + .enableRunTreeStreaming(true) + .enableThreadViewPlayground(true) + .enableThreadsImprovements(true) + .kvDatasetMessageSupport(true) + .langgraphDeployOwnCloudEnabled(true) + .langgraphEnterpriseEnabled(true) + .langgraphRemoteReconcilerEnabled(true) + .langsmithAlertsLegacyPocEnabled(true) + .langsmithAlertsPocEnabled(true) + .langsmithExperimentalSearchEnabled(true) + .lgpTemplatesEnabled(true) + .maxFreeLanggraphCloudDeployments(0L) + .maxIdentities(0L) + .maxLanggraphCloudDeployments(0L) + .maxPromptWebhooks(0L) + .maxThreadEvaluatorsPerTenant(0L) + .maxWorkspaces(0L) + .newRuleEvaluatorCreationVersion(0L) + .partnerPlanApprovalDate("partner_plan_approval_date") + .playgroundEvaluatorStrategy("playground_evaluator_strategy") + .premierPlanApprovalDate("premier_plan_approval_date") + .promptOptimizationJobsEnabled(true) + .requireCodeEvaluatorLanguageField(true) + .showPlaygroundPromptCanvas(true) + .showUpdatedResourceTags(true) + .showUpdatedSidenav(true) + .startupPlanApprovalDate("startup_plan_approval_date") + .tenantSkipTopkFacets(true) + .threadEvaluatorsEnabled(true) + .useExactSearchForPrompts(true) + .usePythonPlaygroundService(true) + .build() + ) + .isPersonal(true) + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .defaultSsoProvision(true) + .disabled(true) + .displayName("display_name") + .jitProvisioningEnabled(true) + .marketplacePayoutsEnabled(true) + .patCreationDisabled(true) + .addPermission("string") + .publicSharingDisabled(true) + .reachedMaxWorkspaces(true) + .ssoLoginSlug("sso_login_slug") + .ssoOnly(true) + .tier(PaymentPlanTier.NO_PLAN) + .wallet(Wallet.builder().creditBalanceMicros(0L).inflightBalanceMicros(0L).build()) + .workspaceAdminCanInviteToOrg(true) + .build() + + assertThat(organizationInfo.config()) + .isEqualTo( + OrganizationConfig.builder() + .allowCustomIframes(true) + .canAddSeats(true) + .canDisablePublicSharing(true) + .canServeDatasets(true) + .canUseAbac(true) + .canUseAgentBuilder(true) + .canUseBulkExport(true) + .canUseLanggraphCloud(true) + .canUseRbac(true) + .canUseSamlSso(true) + .clioEnabled(true) + .datadogRumSessionSampleRate(0L) + .demoLgpNewGraphEnabled(true) + .enableAlignEvaluators(true) + .enableIncludeExtendedStats(true) + .enableLanggraphPricing(true) + .enableLgpListenersPage(true) + .enableMarkdownInTracing(true) + .enableMonthlyUsageCharts(true) + .enableOrgUsageCharts(true) + .enablePricingRedesign(true) + .enableQueryingV2Endpoints(true) + .enableRunTreeStreaming(true) + .enableThreadViewPlayground(true) + .enableThreadsImprovements(true) + .kvDatasetMessageSupport(true) + .langgraphDeployOwnCloudEnabled(true) + .langgraphEnterpriseEnabled(true) + .langgraphRemoteReconcilerEnabled(true) + .langsmithAlertsLegacyPocEnabled(true) + .langsmithAlertsPocEnabled(true) + .langsmithExperimentalSearchEnabled(true) + .lgpTemplatesEnabled(true) + .maxFreeLanggraphCloudDeployments(0L) + .maxIdentities(0L) + .maxLanggraphCloudDeployments(0L) + .maxPromptWebhooks(0L) + .maxThreadEvaluatorsPerTenant(0L) + .maxWorkspaces(0L) + .newRuleEvaluatorCreationVersion(0L) + .partnerPlanApprovalDate("partner_plan_approval_date") + .playgroundEvaluatorStrategy("playground_evaluator_strategy") + .premierPlanApprovalDate("premier_plan_approval_date") + .promptOptimizationJobsEnabled(true) + .requireCodeEvaluatorLanguageField(true) + .showPlaygroundPromptCanvas(true) + .showUpdatedResourceTags(true) + .showUpdatedSidenav(true) + .startupPlanApprovalDate("startup_plan_approval_date") + .tenantSkipTopkFacets(true) + .threadEvaluatorsEnabled(true) + .useExactSearchForPrompts(true) + .usePythonPlaygroundService(true) + .build() + ) + assertThat(organizationInfo.isPersonal()).isEqualTo(true) + assertThat(organizationInfo.id()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(organizationInfo.defaultSsoProvision()).contains(true) + assertThat(organizationInfo.disabled()).contains(true) + assertThat(organizationInfo.displayName()).contains("display_name") + assertThat(organizationInfo.jitProvisioningEnabled()).contains(true) + assertThat(organizationInfo.marketplacePayoutsEnabled()).contains(true) + assertThat(organizationInfo.patCreationDisabled()).contains(true) + assertThat(organizationInfo.permissions().getOrNull()).containsExactly("string") + assertThat(organizationInfo.publicSharingDisabled()).contains(true) + assertThat(organizationInfo.reachedMaxWorkspaces()).contains(true) + assertThat(organizationInfo.ssoLoginSlug()).contains("sso_login_slug") + assertThat(organizationInfo.ssoOnly()).contains(true) + assertThat(organizationInfo.tier()).contains(PaymentPlanTier.NO_PLAN) + assertThat(organizationInfo.wallet()) + .contains(Wallet.builder().creditBalanceMicros(0L).inflightBalanceMicros(0L).build()) + assertThat(organizationInfo.workspaceAdminCanInviteToOrg()).contains(true) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val organizationInfo = + OrganizationInfo.builder() + .config( + OrganizationConfig.builder() + .allowCustomIframes(true) + .canAddSeats(true) + .canDisablePublicSharing(true) + .canServeDatasets(true) + .canUseAbac(true) + .canUseAgentBuilder(true) + .canUseBulkExport(true) + .canUseLanggraphCloud(true) + .canUseRbac(true) + .canUseSamlSso(true) + .clioEnabled(true) + .datadogRumSessionSampleRate(0L) + .demoLgpNewGraphEnabled(true) + .enableAlignEvaluators(true) + .enableIncludeExtendedStats(true) + .enableLanggraphPricing(true) + .enableLgpListenersPage(true) + .enableMarkdownInTracing(true) + .enableMonthlyUsageCharts(true) + .enableOrgUsageCharts(true) + .enablePricingRedesign(true) + .enableQueryingV2Endpoints(true) + .enableRunTreeStreaming(true) + .enableThreadViewPlayground(true) + .enableThreadsImprovements(true) + .kvDatasetMessageSupport(true) + .langgraphDeployOwnCloudEnabled(true) + .langgraphEnterpriseEnabled(true) + .langgraphRemoteReconcilerEnabled(true) + .langsmithAlertsLegacyPocEnabled(true) + .langsmithAlertsPocEnabled(true) + .langsmithExperimentalSearchEnabled(true) + .lgpTemplatesEnabled(true) + .maxFreeLanggraphCloudDeployments(0L) + .maxIdentities(0L) + .maxLanggraphCloudDeployments(0L) + .maxPromptWebhooks(0L) + .maxThreadEvaluatorsPerTenant(0L) + .maxWorkspaces(0L) + .newRuleEvaluatorCreationVersion(0L) + .partnerPlanApprovalDate("partner_plan_approval_date") + .playgroundEvaluatorStrategy("playground_evaluator_strategy") + .premierPlanApprovalDate("premier_plan_approval_date") + .promptOptimizationJobsEnabled(true) + .requireCodeEvaluatorLanguageField(true) + .showPlaygroundPromptCanvas(true) + .showUpdatedResourceTags(true) + .showUpdatedSidenav(true) + .startupPlanApprovalDate("startup_plan_approval_date") + .tenantSkipTopkFacets(true) + .threadEvaluatorsEnabled(true) + .useExactSearchForPrompts(true) + .usePythonPlaygroundService(true) + .build() + ) + .isPersonal(true) + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .defaultSsoProvision(true) + .disabled(true) + .displayName("display_name") + .jitProvisioningEnabled(true) + .marketplacePayoutsEnabled(true) + .patCreationDisabled(true) + .addPermission("string") + .publicSharingDisabled(true) + .reachedMaxWorkspaces(true) + .ssoLoginSlug("sso_login_slug") + .ssoOnly(true) + .tier(PaymentPlanTier.NO_PLAN) + .wallet(Wallet.builder().creditBalanceMicros(0L).inflightBalanceMicros(0L).build()) + .workspaceAdminCanInviteToOrg(true) + .build() + + val roundtrippedOrganizationInfo = + jsonMapper.readValue( + jsonMapper.writeValueAsString(organizationInfo), + jacksonTypeRef<OrganizationInfo>(), + ) + + assertThat(roundtrippedOrganizationInfo).isEqualTo(organizationInfo) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberBatchParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberBatchParamsTest.kt new file mode 100644 index 00000000..ee3d7868 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberBatchParamsTest.kt @@ -0,0 +1,71 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.members + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MemberBatchParamsTest { + + @Test + fun create() { + MemberBatchParams.builder() + .addBody( + PendingIdentityCreate.builder() + .email("email") + .fullName("full_name") + .password("password") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .workspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + } + + @Test + fun body() { + val params = + MemberBatchParams.builder() + .addBody( + PendingIdentityCreate.builder() + .email("email") + .fullName("full_name") + .password("password") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .workspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .containsExactly( + PendingIdentityCreate.builder() + .email("email") + .fullName("full_name") + .password("password") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .workspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + MemberBatchParams.builder() + .addBody(PendingIdentityCreate.builder().email("email").build()) + .build() + + val body = params._body() + + assertThat(body).containsExactly(PendingIdentityCreate.builder().email("email").build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberCreateParamsTest.kt new file mode 100644 index 00000000..5ff46945 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberCreateParamsTest.kt @@ -0,0 +1,71 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.members + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MemberCreateParamsTest { + + @Test + fun create() { + MemberCreateParams.builder() + .pendingIdentityCreate( + PendingIdentityCreate.builder() + .email("email") + .fullName("full_name") + .password("password") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .workspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + } + + @Test + fun body() { + val params = + MemberCreateParams.builder() + .pendingIdentityCreate( + PendingIdentityCreate.builder() + .email("email") + .fullName("full_name") + .password("password") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .workspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + PendingIdentityCreate.builder() + .email("email") + .fullName("full_name") + .password("password") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .workspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + MemberCreateParams.builder() + .pendingIdentityCreate(PendingIdentityCreate.builder().email("email").build()) + .build() + + val body = params._body() + + assertThat(body).isEqualTo(PendingIdentityCreate.builder().email("email").build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberDeleteParamsTest.kt new file mode 100644 index 00000000..b076897b --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberDeleteParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.members + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MemberDeleteParamsTest { + + @Test + fun create() { + MemberDeleteParams.builder().identityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + MemberDeleteParams.builder().identityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberDeleteResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberDeleteResponseTest.kt new file mode 100644 index 00000000..4f72f866 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberDeleteResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.members + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MemberDeleteResponseTest { + + @Test + fun create() { + val memberDeleteResponse = MemberDeleteResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val memberDeleteResponse = MemberDeleteResponse.builder().build() + + val roundtrippedMemberDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(memberDeleteResponse), + jacksonTypeRef<MemberDeleteResponse>(), + ) + + assertThat(roundtrippedMemberDeleteResponse).isEqualTo(memberDeleteResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberListParamsTest.kt new file mode 100644 index 00000000..ee16f1c0 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberListParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.members + +import org.junit.jupiter.api.Test + +internal class MemberListParamsTest { + + @Test + fun create() { + MemberListParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberListResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberListResponseTest.kt new file mode 100644 index 00000000..dea2616b --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberListResponseTest.kt @@ -0,0 +1,224 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.members + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.orgs.current.members.pending.OrgPendingIdentity +import com.langsmith_api.api.models.api.v1.orgs.current.user.ProviderUserSlim +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MemberListResponseTest { + + @Test + fun create() { + val memberListResponse = + MemberListResponse.builder() + .addMember( + OrgMemberIdentity.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accessScope(AccessScope.ORGANIZATION) + .avatarUrl("avatar_url") + .email("email") + .fullName("full_name") + .addLinkedLoginMethod( + ProviderUserSlim.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("email") + .emailConfirmedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .firstName("first_name") + .fullName("full_name") + .isDisabled(true) + .lastName("last_name") + .provider(ProviderUserSlim.Provider.EMAIL) + .providerUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .provisioningMethod(ProviderUserSlim.ProvisioningMethod.SCIM) + .samlProviderId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .username("username") + .build() + ) + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgRoleName("org_role_name") + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .roleName("role_name") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addTenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addPending( + OrgPendingIdentity.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("email") + .accessScope(AccessScope.ORGANIZATION) + .fullName("full_name") + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgRoleName("org_role_name") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .password("password") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .roleName("role_name") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addTenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .workspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + + assertThat(memberListResponse.members()) + .containsExactly( + OrgMemberIdentity.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accessScope(AccessScope.ORGANIZATION) + .avatarUrl("avatar_url") + .email("email") + .fullName("full_name") + .addLinkedLoginMethod( + ProviderUserSlim.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("email") + .emailConfirmedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .firstName("first_name") + .fullName("full_name") + .isDisabled(true) + .lastName("last_name") + .provider(ProviderUserSlim.Provider.EMAIL) + .providerUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .provisioningMethod(ProviderUserSlim.ProvisioningMethod.SCIM) + .samlProviderId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .username("username") + .build() + ) + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgRoleName("org_role_name") + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .roleName("role_name") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addTenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + assertThat(memberListResponse.organizationId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(memberListResponse.pending()) + .containsExactly( + OrgPendingIdentity.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("email") + .accessScope(AccessScope.ORGANIZATION) + .fullName("full_name") + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgRoleName("org_role_name") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .password("password") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .roleName("role_name") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addTenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .workspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val memberListResponse = + MemberListResponse.builder() + .addMember( + OrgMemberIdentity.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accessScope(AccessScope.ORGANIZATION) + .avatarUrl("avatar_url") + .email("email") + .fullName("full_name") + .addLinkedLoginMethod( + ProviderUserSlim.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("email") + .emailConfirmedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .firstName("first_name") + .fullName("full_name") + .isDisabled(true) + .lastName("last_name") + .provider(ProviderUserSlim.Provider.EMAIL) + .providerUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .provisioningMethod(ProviderUserSlim.ProvisioningMethod.SCIM) + .samlProviderId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .username("username") + .build() + ) + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgRoleName("org_role_name") + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .roleName("role_name") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addTenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addPending( + OrgPendingIdentity.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("email") + .accessScope(AccessScope.ORGANIZATION) + .fullName("full_name") + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgRoleName("org_role_name") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .password("password") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .roleName("role_name") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addTenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .workspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + + val roundtrippedMemberListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(memberListResponse), + jacksonTypeRef<MemberListResponse>(), + ) + + assertThat(roundtrippedMemberListResponse).isEqualTo(memberListResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberRetrieveActiveParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberRetrieveActiveParamsTest.kt new file mode 100644 index 00000000..86d4663e --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberRetrieveActiveParamsTest.kt @@ -0,0 +1,61 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.members + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MemberRetrieveActiveParamsTest { + + @Test + fun create() { + MemberRetrieveActiveParams.builder() + .addEmail("string") + .limit(1L) + .addLsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .offset(0L) + .addUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun queryParams() { + val params = + MemberRetrieveActiveParams.builder() + .addEmail("string") + .limit(1L) + .addLsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .offset(0L) + .addUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("emails", listOf("string").joinToString(",")) + .put("limit", "1") + .put( + "ls_user_ids", + listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").joinToString(","), + ) + .put("offset", "0") + .put( + "user_ids", + listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").joinToString(","), + ) + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = MemberRetrieveActiveParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberUpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberUpdateParamsTest.kt new file mode 100644 index 00000000..0fff5959 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberUpdateParamsTest.kt @@ -0,0 +1,54 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.members + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MemberUpdateParamsTest { + + @Test + fun create() { + MemberUpdateParams.builder() + .identityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .fullName("full_name") + .password("password") + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + MemberUpdateParams.builder().identityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + MemberUpdateParams.builder() + .identityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .fullName("full_name") + .password("password") + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + + assertThat(body.fullName()).contains("full_name") + assertThat(body.password()).contains("password") + assertThat(body.roleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + MemberUpdateParams.builder().identityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + val body = params._body() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberUpdateResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberUpdateResponseTest.kt new file mode 100644 index 00000000..6542671e --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/MemberUpdateResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.members + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MemberUpdateResponseTest { + + @Test + fun create() { + val memberUpdateResponse = MemberUpdateResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val memberUpdateResponse = MemberUpdateResponse.builder().build() + + val roundtrippedMemberUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(memberUpdateResponse), + jacksonTypeRef<MemberUpdateResponse>(), + ) + + assertThat(roundtrippedMemberUpdateResponse).isEqualTo(memberUpdateResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/OrgMemberIdentityTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/OrgMemberIdentityTest.kt new file mode 100644 index 00000000..6fc46257 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/OrgMemberIdentityTest.kt @@ -0,0 +1,147 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.members + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.orgs.current.user.ProviderUserSlim +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OrgMemberIdentityTest { + + @Test + fun create() { + val orgMemberIdentity = + OrgMemberIdentity.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accessScope(AccessScope.ORGANIZATION) + .avatarUrl("avatar_url") + .email("email") + .fullName("full_name") + .addLinkedLoginMethod( + ProviderUserSlim.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("email") + .emailConfirmedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .firstName("first_name") + .fullName("full_name") + .isDisabled(true) + .lastName("last_name") + .provider(ProviderUserSlim.Provider.EMAIL) + .providerUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .provisioningMethod(ProviderUserSlim.ProvisioningMethod.SCIM) + .samlProviderId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .username("username") + .build() + ) + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgRoleName("org_role_name") + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .roleName("role_name") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addTenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(orgMemberIdentity.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(orgMemberIdentity.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(orgMemberIdentity.lsUserId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(orgMemberIdentity.organizationId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(orgMemberIdentity.readOnly()).isEqualTo(true) + assertThat(orgMemberIdentity.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(orgMemberIdentity.accessScope()).contains(AccessScope.ORGANIZATION) + assertThat(orgMemberIdentity.avatarUrl()).contains("avatar_url") + assertThat(orgMemberIdentity.email()).contains("email") + assertThat(orgMemberIdentity.fullName()).contains("full_name") + assertThat(orgMemberIdentity.linkedLoginMethods().getOrNull()) + .containsExactly( + ProviderUserSlim.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("email") + .emailConfirmedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .firstName("first_name") + .fullName("full_name") + .isDisabled(true) + .lastName("last_name") + .provider(ProviderUserSlim.Provider.EMAIL) + .providerUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .provisioningMethod(ProviderUserSlim.ProvisioningMethod.SCIM) + .samlProviderId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .username("username") + .build() + ) + assertThat(orgMemberIdentity.orgRoleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(orgMemberIdentity.orgRoleName()).contains("org_role_name") + assertThat(orgMemberIdentity.roleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(orgMemberIdentity.roleName()).contains("role_name") + assertThat(orgMemberIdentity.tenantId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(orgMemberIdentity.tenantIds().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val orgMemberIdentity = + OrgMemberIdentity.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accessScope(AccessScope.ORGANIZATION) + .avatarUrl("avatar_url") + .email("email") + .fullName("full_name") + .addLinkedLoginMethod( + ProviderUserSlim.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("email") + .emailConfirmedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .firstName("first_name") + .fullName("full_name") + .isDisabled(true) + .lastName("last_name") + .provider(ProviderUserSlim.Provider.EMAIL) + .providerUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .provisioningMethod(ProviderUserSlim.ProvisioningMethod.SCIM) + .samlProviderId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .username("username") + .build() + ) + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgRoleName("org_role_name") + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .roleName("role_name") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addTenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val roundtrippedOrgMemberIdentity = + jsonMapper.readValue( + jsonMapper.writeValueAsString(orgMemberIdentity), + jacksonTypeRef<OrgMemberIdentity>(), + ) + + assertThat(roundtrippedOrgMemberIdentity).isEqualTo(orgMemberIdentity) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/PendingIdentityCreateTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/PendingIdentityCreateTest.kt new file mode 100644 index 00000000..eddb2987 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/PendingIdentityCreateTest.kt @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.members + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PendingIdentityCreateTest { + + @Test + fun create() { + val pendingIdentityCreate = + PendingIdentityCreate.builder() + .email("email") + .fullName("full_name") + .password("password") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .workspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(pendingIdentityCreate.email()).isEqualTo("email") + assertThat(pendingIdentityCreate.fullName()).contains("full_name") + assertThat(pendingIdentityCreate.password()).contains("password") + assertThat(pendingIdentityCreate.readOnly()).contains(true) + assertThat(pendingIdentityCreate.roleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(pendingIdentityCreate.workspaceIds().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(pendingIdentityCreate.workspaceRoleId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val pendingIdentityCreate = + PendingIdentityCreate.builder() + .email("email") + .fullName("full_name") + .password("password") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .workspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val roundtrippedPendingIdentityCreate = + jsonMapper.readValue( + jsonMapper.writeValueAsString(pendingIdentityCreate), + jacksonTypeRef<PendingIdentityCreate>(), + ) + + assertThat(roundtrippedPendingIdentityCreate).isEqualTo(pendingIdentityCreate) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/PendingIdentityTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/PendingIdentityTest.kt new file mode 100644 index 00000000..2246adba --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/PendingIdentityTest.kt @@ -0,0 +1,89 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.members + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PendingIdentityTest { + + @Test + fun create() { + val pendingIdentity = + PendingIdentity.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("email") + .accessScope(AccessScope.ORGANIZATION) + .fullName("full_name") + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgRoleName("org_role_name") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .password("password") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .roleName("role_name") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .workspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(pendingIdentity.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(pendingIdentity.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(pendingIdentity.email()).isEqualTo("email") + assertThat(pendingIdentity.accessScope()).contains(AccessScope.ORGANIZATION) + assertThat(pendingIdentity.fullName()).contains("full_name") + assertThat(pendingIdentity.orgRoleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(pendingIdentity.orgRoleName()).contains("org_role_name") + assertThat(pendingIdentity.organizationId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(pendingIdentity.password()).contains("password") + assertThat(pendingIdentity.readOnly()).contains(true) + assertThat(pendingIdentity.roleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(pendingIdentity.roleName()).contains("role_name") + assertThat(pendingIdentity.tenantId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(pendingIdentity.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(pendingIdentity.workspaceIds().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(pendingIdentity.workspaceRoleId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val pendingIdentity = + PendingIdentity.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("email") + .accessScope(AccessScope.ORGANIZATION) + .fullName("full_name") + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgRoleName("org_role_name") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .password("password") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .roleName("role_name") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .workspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val roundtrippedPendingIdentity = + jsonMapper.readValue( + jsonMapper.writeValueAsString(pendingIdentity), + jacksonTypeRef<PendingIdentity>(), + ) + + assertThat(roundtrippedPendingIdentity).isEqualTo(pendingIdentity) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/basic/BasicBatchParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/basic/BasicBatchParamsTest.kt new file mode 100644 index 00000000..323f296e --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/basic/BasicBatchParamsTest.kt @@ -0,0 +1,77 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.members.basic + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BasicBatchParamsTest { + + @Test + fun create() { + BasicBatchParams.builder() + .addBody( + BasicBatchParams.Body.builder() + .email("email") + .fullName("full_name") + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .password("password") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .workspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + } + + @Test + fun body() { + val params = + BasicBatchParams.builder() + .addBody( + BasicBatchParams.Body.builder() + .email("email") + .fullName("full_name") + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .password("password") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .workspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .containsExactly( + BasicBatchParams.Body.builder() + .email("email") + .fullName("full_name") + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .password("password") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .workspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + BasicBatchParams.builder() + .addBody(BasicBatchParams.Body.builder().email("email").build()) + .build() + + val body = params._body() + + assertThat(body).containsExactly(BasicBatchParams.Body.builder().email("email").build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/basic/BasicBatchResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/basic/BasicBatchResponseTest.kt new file mode 100644 index 00000000..383d8996 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/basic/BasicBatchResponseTest.kt @@ -0,0 +1,62 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.members.basic + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BasicBatchResponseTest { + + @Test + fun create() { + val basicBatchResponse = + BasicBatchResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("email") + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .avatarUrl("avatar_url") + .fullName("full_name") + .password("password") + .build() + + assertThat(basicBatchResponse.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(basicBatchResponse.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(basicBatchResponse.email()).isEqualTo("email") + assertThat(basicBatchResponse.lsUserId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(basicBatchResponse.updatedAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(basicBatchResponse.avatarUrl()).contains("avatar_url") + assertThat(basicBatchResponse.fullName()).contains("full_name") + assertThat(basicBatchResponse.password()).contains("password") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val basicBatchResponse = + BasicBatchResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("email") + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .avatarUrl("avatar_url") + .fullName("full_name") + .password("password") + .build() + + val roundtrippedBasicBatchResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(basicBatchResponse), + jacksonTypeRef<BasicBatchResponse>(), + ) + + assertThat(roundtrippedBasicBatchResponse).isEqualTo(basicBatchResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/pending/OrgPendingIdentityTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/pending/OrgPendingIdentityTest.kt new file mode 100644 index 00000000..c9302ccf --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/pending/OrgPendingIdentityTest.kt @@ -0,0 +1,94 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.members.pending + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.orgs.current.members.AccessScope +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OrgPendingIdentityTest { + + @Test + fun create() { + val orgPendingIdentity = + OrgPendingIdentity.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("email") + .accessScope(AccessScope.ORGANIZATION) + .fullName("full_name") + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgRoleName("org_role_name") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .password("password") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .roleName("role_name") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addTenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .workspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(orgPendingIdentity.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(orgPendingIdentity.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(orgPendingIdentity.email()).isEqualTo("email") + assertThat(orgPendingIdentity.accessScope()).contains(AccessScope.ORGANIZATION) + assertThat(orgPendingIdentity.fullName()).contains("full_name") + assertThat(orgPendingIdentity.orgRoleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(orgPendingIdentity.orgRoleName()).contains("org_role_name") + assertThat(orgPendingIdentity.organizationId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(orgPendingIdentity.password()).contains("password") + assertThat(orgPendingIdentity.readOnly()).contains(true) + assertThat(orgPendingIdentity.roleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(orgPendingIdentity.roleName()).contains("role_name") + assertThat(orgPendingIdentity.tenantId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(orgPendingIdentity.tenantIds().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(orgPendingIdentity.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(orgPendingIdentity.workspaceIds().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(orgPendingIdentity.workspaceRoleId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val orgPendingIdentity = + OrgPendingIdentity.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("email") + .accessScope(AccessScope.ORGANIZATION) + .fullName("full_name") + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgRoleName("org_role_name") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .password("password") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .roleName("role_name") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addTenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .workspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val roundtrippedOrgPendingIdentity = + jsonMapper.readValue( + jsonMapper.writeValueAsString(orgPendingIdentity), + jacksonTypeRef<OrgPendingIdentity>(), + ) + + assertThat(roundtrippedOrgPendingIdentity).isEqualTo(orgPendingIdentity) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/pending/PendingDeleteAllParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/pending/PendingDeleteAllParamsTest.kt new file mode 100644 index 00000000..ff516f20 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/pending/PendingDeleteAllParamsTest.kt @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.members.pending + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PendingDeleteAllParamsTest { + + @Test + fun create() { + PendingDeleteAllParams.builder().identityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + PendingDeleteAllParams.builder() + .identityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/pending/PendingDeleteAllResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/pending/PendingDeleteAllResponseTest.kt new file mode 100644 index 00000000..b4f8e1dc --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/pending/PendingDeleteAllResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.members.pending + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PendingDeleteAllResponseTest { + + @Test + fun create() { + val pendingDeleteAllResponse = PendingDeleteAllResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val pendingDeleteAllResponse = PendingDeleteAllResponse.builder().build() + + val roundtrippedPendingDeleteAllResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(pendingDeleteAllResponse), + jacksonTypeRef<PendingDeleteAllResponse>(), + ) + + assertThat(roundtrippedPendingDeleteAllResponse).isEqualTo(pendingDeleteAllResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/pending/PendingListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/pending/PendingListParamsTest.kt new file mode 100644 index 00000000..53b1b797 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/members/pending/PendingListParamsTest.kt @@ -0,0 +1,40 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.members.pending + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PendingListParamsTest { + + @Test + fun create() { + PendingListParams.builder().addEmail("string").limit(1L).offset(0L).build() + } + + @Test + fun queryParams() { + val params = PendingListParams.builder().addEmail("string").limit(1L).offset(0L).build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("emails", listOf("string").joinToString(",")) + .put("limit", "1") + .put("offset", "0") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = PendingListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/personalaccesstokens/PersonalAccessTokenDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/personalaccesstokens/PersonalAccessTokenDeleteParamsTest.kt new file mode 100644 index 00000000..c88e0b09 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/personalaccesstokens/PersonalAccessTokenDeleteParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.personalaccesstokens + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PersonalAccessTokenDeleteParamsTest { + + @Test + fun create() { + PersonalAccessTokenDeleteParams.builder() + .patId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + PersonalAccessTokenDeleteParams.builder() + .patId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/personalaccesstokens/PersonalAccessTokenPersonalAccessTokensParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/personalaccesstokens/PersonalAccessTokenPersonalAccessTokensParamsTest.kt new file mode 100644 index 00000000..e8707209 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/personalaccesstokens/PersonalAccessTokenPersonalAccessTokensParamsTest.kt @@ -0,0 +1,73 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.personalaccesstokens + +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyCreateRequest +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PersonalAccessTokenPersonalAccessTokensParamsTest { + + @Test + fun create() { + PersonalAccessTokenPersonalAccessTokensParams.builder() + .apiKeyCreateRequest( + ApiKeyCreateRequest.builder() + .defaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + } + + @Test + fun body() { + val params = + PersonalAccessTokenPersonalAccessTokensParams.builder() + .apiKeyCreateRequest( + ApiKeyCreateRequest.builder() + .defaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + ApiKeyCreateRequest.builder() + .defaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + PersonalAccessTokenPersonalAccessTokensParams.builder() + .apiKeyCreateRequest(ApiKeyCreateRequest.builder().build()) + .build() + + val body = params._body() + + assertThat(body).isEqualTo(ApiKeyCreateRequest.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/personalaccesstokens/PersonalAccessTokenRetrievePersonalAccessTokensParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/personalaccesstokens/PersonalAccessTokenRetrievePersonalAccessTokensParamsTest.kt new file mode 100644 index 00000000..7aae5b3e --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/personalaccesstokens/PersonalAccessTokenRetrievePersonalAccessTokensParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.personalaccesstokens + +import org.junit.jupiter.api.Test + +internal class PersonalAccessTokenRetrievePersonalAccessTokensParamsTest { + + @Test + fun create() { + PersonalAccessTokenRetrievePersonalAccessTokensParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/RoleCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/RoleCreateParamsTest.kt new file mode 100644 index 00000000..1e4b539d --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/RoleCreateParamsTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.roles + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RoleCreateParamsTest { + + @Test + fun create() { + RoleCreateParams.builder() + .description("description") + .displayName("display_name") + .addPermission("string") + .build() + } + + @Test + fun body() { + val params = + RoleCreateParams.builder() + .description("description") + .displayName("display_name") + .addPermission("string") + .build() + + val body = params._body() + + assertThat(body.description()).isEqualTo("description") + assertThat(body.displayName()).isEqualTo("display_name") + assertThat(body.permissions()).containsExactly("string") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/RoleDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/RoleDeleteParamsTest.kt new file mode 100644 index 00000000..52ff368a --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/RoleDeleteParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.roles + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RoleDeleteParamsTest { + + @Test + fun create() { + RoleDeleteParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + RoleDeleteParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/RoleListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/RoleListParamsTest.kt new file mode 100644 index 00000000..cff9df70 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/RoleListParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.roles + +import org.junit.jupiter.api.Test + +internal class RoleListParamsTest { + + @Test + fun create() { + RoleListParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/RoleTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/RoleTest.kt new file mode 100644 index 00000000..8345f1d3 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/RoleTest.kt @@ -0,0 +1,54 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.roles + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.orgs.current.members.AccessScope +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RoleTest { + + @Test + fun create() { + val role = + Role.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .displayName("display_name") + .name("name") + .addPermission("string") + .accessScope(AccessScope.ORGANIZATION) + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(role.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(role.description()).isEqualTo("description") + assertThat(role.displayName()).isEqualTo("display_name") + assertThat(role.name()).isEqualTo("name") + assertThat(role.permissions()).containsExactly("string") + assertThat(role.accessScope()).contains(AccessScope.ORGANIZATION) + assertThat(role.organizationId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val role = + Role.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .displayName("display_name") + .name("name") + .addPermission("string") + .accessScope(AccessScope.ORGANIZATION) + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val roundtrippedRole = + jsonMapper.readValue(jsonMapper.writeValueAsString(role), jacksonTypeRef<Role>()) + + assertThat(roundtrippedRole).isEqualTo(role) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/RoleUpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/RoleUpdateParamsTest.kt new file mode 100644 index 00000000..8db7f66f --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/roles/RoleUpdateParamsTest.kt @@ -0,0 +1,51 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.roles + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RoleUpdateParamsTest { + + @Test + fun create() { + RoleUpdateParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .displayName("display_name") + .addPermission("string") + .build() + } + + @Test + fun pathParams() { + val params = + RoleUpdateParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .displayName("display_name") + .addPermission("string") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + RoleUpdateParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .displayName("display_name") + .addPermission("string") + .build() + + val body = params._body() + + assertThat(body.description()).isEqualTo("description") + assertThat(body.displayName()).isEqualTo("display_name") + assertThat(body.permissions()).containsExactly("string") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ApiKeyCreateRequestTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ApiKeyCreateRequestTest.kt new file mode 100644 index 00000000..c340cfb1 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ApiKeyCreateRequestTest.kt @@ -0,0 +1,61 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.servicekeys + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ApiKeyCreateRequestTest { + + @Test + fun create() { + val apiKeyCreateRequest = + ApiKeyCreateRequest.builder() + .defaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(apiKeyCreateRequest.defaultWorkspaceId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(apiKeyCreateRequest.description()).contains("description") + assertThat(apiKeyCreateRequest.expiresAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(apiKeyCreateRequest.orgRoleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(apiKeyCreateRequest.readOnly()).contains(true) + assertThat(apiKeyCreateRequest.roleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(apiKeyCreateRequest.workspaces().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val apiKeyCreateRequest = + ApiKeyCreateRequest.builder() + .defaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val roundtrippedApiKeyCreateRequest = + jsonMapper.readValue( + jsonMapper.writeValueAsString(apiKeyCreateRequest), + jacksonTypeRef<ApiKeyCreateRequest>(), + ) + + assertThat(roundtrippedApiKeyCreateRequest).isEqualTo(apiKeyCreateRequest) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ApiKeyCreateResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ApiKeyCreateResponseTest.kt new file mode 100644 index 00000000..5c37d43b --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ApiKeyCreateResponseTest.kt @@ -0,0 +1,67 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.servicekeys + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ApiKeyCreateResponseTest { + + @Test + fun create() { + val apiKeyCreateResponse = + ApiKeyCreateResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .key("key") + .shortKey("short_key") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lastUsedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .readOnly(true) + .addWorkspaceName("string") + .build() + + assertThat(apiKeyCreateResponse.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(apiKeyCreateResponse.description()).isEqualTo("description") + assertThat(apiKeyCreateResponse.key()).isEqualTo("key") + assertThat(apiKeyCreateResponse.shortKey()).isEqualTo("short_key") + assertThat(apiKeyCreateResponse.createdAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(apiKeyCreateResponse.expiresAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(apiKeyCreateResponse.lastUsedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(apiKeyCreateResponse.readOnly()).contains(true) + assertThat(apiKeyCreateResponse.workspaceNames().getOrNull()).containsExactly("string") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val apiKeyCreateResponse = + ApiKeyCreateResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .key("key") + .shortKey("short_key") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lastUsedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .readOnly(true) + .addWorkspaceName("string") + .build() + + val roundtrippedApiKeyCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(apiKeyCreateResponse), + jacksonTypeRef<ApiKeyCreateResponse>(), + ) + + assertThat(roundtrippedApiKeyCreateResponse).isEqualTo(apiKeyCreateResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ApiKeyGetResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ApiKeyGetResponseTest.kt new file mode 100644 index 00000000..a04b07cd --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ApiKeyGetResponseTest.kt @@ -0,0 +1,64 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.servicekeys + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ApiKeyGetResponseTest { + + @Test + fun create() { + val apiKeyGetResponse = + ApiKeyGetResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .shortKey("short_key") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lastUsedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .readOnly(true) + .addWorkspaceName("string") + .build() + + assertThat(apiKeyGetResponse.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(apiKeyGetResponse.description()).isEqualTo("description") + assertThat(apiKeyGetResponse.shortKey()).isEqualTo("short_key") + assertThat(apiKeyGetResponse.createdAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(apiKeyGetResponse.expiresAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(apiKeyGetResponse.lastUsedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(apiKeyGetResponse.readOnly()).contains(true) + assertThat(apiKeyGetResponse.workspaceNames().getOrNull()).containsExactly("string") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val apiKeyGetResponse = + ApiKeyGetResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .shortKey("short_key") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lastUsedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .readOnly(true) + .addWorkspaceName("string") + .build() + + val roundtrippedApiKeyGetResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(apiKeyGetResponse), + jacksonTypeRef<ApiKeyGetResponse>(), + ) + + assertThat(roundtrippedApiKeyGetResponse).isEqualTo(apiKeyGetResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ServiceKeyDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ServiceKeyDeleteParamsTest.kt new file mode 100644 index 00000000..b060a628 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ServiceKeyDeleteParamsTest.kt @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.servicekeys + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ServiceKeyDeleteParamsTest { + + @Test + fun create() { + ServiceKeyDeleteParams.builder().apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + ServiceKeyDeleteParams.builder() + .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ServiceKeyRetrieveServiceKeysParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ServiceKeyRetrieveServiceKeysParamsTest.kt new file mode 100644 index 00000000..a4500f66 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ServiceKeyRetrieveServiceKeysParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.servicekeys + +import org.junit.jupiter.api.Test + +internal class ServiceKeyRetrieveServiceKeysParamsTest { + + @Test + fun create() { + ServiceKeyRetrieveServiceKeysParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ServiceKeyServiceKeysParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ServiceKeyServiceKeysParamsTest.kt new file mode 100644 index 00000000..d62ccb50 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/servicekeys/ServiceKeyServiceKeysParamsTest.kt @@ -0,0 +1,72 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.servicekeys + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ServiceKeyServiceKeysParamsTest { + + @Test + fun create() { + ServiceKeyServiceKeysParams.builder() + .apiKeyCreateRequest( + ApiKeyCreateRequest.builder() + .defaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + } + + @Test + fun body() { + val params = + ServiceKeyServiceKeysParams.builder() + .apiKeyCreateRequest( + ApiKeyCreateRequest.builder() + .defaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + ApiKeyCreateRequest.builder() + .defaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + ServiceKeyServiceKeysParams.builder() + .apiKeyCreateRequest(ApiKeyCreateRequest.builder().build()) + .build() + + val body = params._body() + + assertThat(body).isEqualTo(ApiKeyCreateRequest.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoProviderTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoProviderTest.kt new file mode 100644 index 00000000..b28354c6 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoProviderTest.kt @@ -0,0 +1,58 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.ssosettings + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SsoProviderTest { + + @Test + fun create() { + val ssoProvider = + SsoProvider.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addDefaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .defaultWorkspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .providerId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metadataUrl("metadata_url") + .metadataXml("metadata_xml") + .build() + + assertThat(ssoProvider.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(ssoProvider.defaultWorkspaceIds()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(ssoProvider.defaultWorkspaceRoleId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(ssoProvider.organizationId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(ssoProvider.providerId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(ssoProvider.metadataUrl()).contains("metadata_url") + assertThat(ssoProvider.metadataXml()).contains("metadata_xml") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val ssoProvider = + SsoProvider.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addDefaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .defaultWorkspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .providerId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metadataUrl("metadata_url") + .metadataXml("metadata_xml") + .build() + + val roundtrippedSsoProvider = + jsonMapper.readValue( + jsonMapper.writeValueAsString(ssoProvider), + jacksonTypeRef<SsoProvider>(), + ) + + assertThat(roundtrippedSsoProvider).isEqualTo(ssoProvider) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoSettingDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoSettingDeleteParamsTest.kt new file mode 100644 index 00000000..9e4267bb --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoSettingDeleteParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.ssosettings + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SsoSettingDeleteParamsTest { + + @Test + fun create() { + SsoSettingDeleteParams.builder().id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + SsoSettingDeleteParams.builder().id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoSettingRetrieveSsoSettingsParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoSettingRetrieveSsoSettingsParamsTest.kt new file mode 100644 index 00000000..72fab6e0 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoSettingRetrieveSsoSettingsParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.ssosettings + +import org.junit.jupiter.api.Test + +internal class SsoSettingRetrieveSsoSettingsParamsTest { + + @Test + fun create() { + SsoSettingRetrieveSsoSettingsParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoSettingSsoSettingsParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoSettingSsoSettingsParamsTest.kt new file mode 100644 index 00000000..b20d191c --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoSettingSsoSettingsParamsTest.kt @@ -0,0 +1,70 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.ssosettings + +import com.langsmith_api.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SsoSettingSsoSettingsParamsTest { + + @Test + fun create() { + SsoSettingSsoSettingsParams.builder() + .addDefaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .defaultWorkspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .attributeMapping( + SsoSettingSsoSettingsParams.AttributeMapping.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .metadataUrl("metadata_url") + .metadataXml("metadata_xml") + .build() + } + + @Test + fun body() { + val params = + SsoSettingSsoSettingsParams.builder() + .addDefaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .defaultWorkspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .attributeMapping( + SsoSettingSsoSettingsParams.AttributeMapping.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .metadataUrl("metadata_url") + .metadataXml("metadata_xml") + .build() + + val body = params._body() + + assertThat(body.defaultWorkspaceIds()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.defaultWorkspaceRoleId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.attributeMapping()) + .contains( + SsoSettingSsoSettingsParams.AttributeMapping.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(body.metadataUrl()).contains("metadata_url") + assertThat(body.metadataXml()).contains("metadata_xml") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + SsoSettingSsoSettingsParams.builder() + .addDefaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .defaultWorkspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + + assertThat(body.defaultWorkspaceIds()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.defaultWorkspaceRoleId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoSettingUpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoSettingUpdateParamsTest.kt new file mode 100644 index 00000000..6a969172 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/ssosettings/SsoSettingUpdateParamsTest.kt @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.ssosettings + +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SsoSettingUpdateParamsTest { + + @Test + fun create() { + SsoSettingUpdateParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addDefaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .defaultWorkspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metadataUrl("metadata_url") + .metadataXml("metadata_xml") + .build() + } + + @Test + fun pathParams() { + val params = + SsoSettingUpdateParams.builder().id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + SsoSettingUpdateParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addDefaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .defaultWorkspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metadataUrl("metadata_url") + .metadataXml("metadata_xml") + .build() + + val body = params._body() + + assertThat(body.defaultWorkspaceIds().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.defaultWorkspaceRoleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.metadataUrl()).contains("metadata_url") + assertThat(body.metadataXml()).contains("metadata_xml") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + SsoSettingUpdateParams.builder().id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + val body = params._body() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/user/ProviderUserSlimTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/user/ProviderUserSlimTest.kt new file mode 100644 index 00000000..4de5a38c --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/user/ProviderUserSlimTest.kt @@ -0,0 +1,87 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.user + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ProviderUserSlimTest { + + @Test + fun create() { + val providerUserSlim = + ProviderUserSlim.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("email") + .emailConfirmedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .firstName("first_name") + .fullName("full_name") + .isDisabled(true) + .lastName("last_name") + .provider(ProviderUserSlim.Provider.EMAIL) + .providerUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .provisioningMethod(ProviderUserSlim.ProvisioningMethod.SCIM) + .samlProviderId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .username("username") + .build() + + assertThat(providerUserSlim.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(providerUserSlim.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(providerUserSlim.lsUserId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(providerUserSlim.updatedAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(providerUserSlim.email()).contains("email") + assertThat(providerUserSlim.emailConfirmedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(providerUserSlim.firstName()).contains("first_name") + assertThat(providerUserSlim.fullName()).contains("full_name") + assertThat(providerUserSlim.isDisabled()).contains(true) + assertThat(providerUserSlim.lastName()).contains("last_name") + assertThat(providerUserSlim.provider()).contains(ProviderUserSlim.Provider.EMAIL) + assertThat(providerUserSlim.providerUserId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(providerUserSlim.provisioningMethod()) + .contains(ProviderUserSlim.ProvisioningMethod.SCIM) + assertThat(providerUserSlim.samlProviderId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(providerUserSlim.username()).contains("username") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val providerUserSlim = + ProviderUserSlim.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("email") + .emailConfirmedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .firstName("first_name") + .fullName("full_name") + .isDisabled(true) + .lastName("last_name") + .provider(ProviderUserSlim.Provider.EMAIL) + .providerUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .provisioningMethod(ProviderUserSlim.ProvisioningMethod.SCIM) + .samlProviderId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .username("username") + .build() + + val roundtrippedProviderUserSlim = + jsonMapper.readValue( + jsonMapper.writeValueAsString(providerUserSlim), + jacksonTypeRef<ProviderUserSlim>(), + ) + + assertThat(roundtrippedProviderUserSlim).isEqualTo(providerUserSlim) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/user/UserRetrieveLoginMethodsParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/user/UserRetrieveLoginMethodsParamsTest.kt new file mode 100644 index 00000000..a73cc492 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/current/user/UserRetrieveLoginMethodsParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.current.user + +import org.junit.jupiter.api.Test + +internal class UserRetrieveLoginMethodsParamsTest { + + @Test + fun create() { + UserRetrieveLoginMethodsParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/members/MemberUpdateBasicParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/members/MemberUpdateBasicParamsTest.kt new file mode 100644 index 00000000..b05aa7b9 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/members/MemberUpdateBasicParamsTest.kt @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.members + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MemberUpdateBasicParamsTest { + + @Test + fun create() { + MemberUpdateBasicParams.builder().fullName("full_name").password("password").build() + } + + @Test + fun body() { + val params = + MemberUpdateBasicParams.builder().fullName("full_name").password("password").build() + + val body = params._body() + + assertThat(body.fullName()).contains("full_name") + assertThat(body.password()).contains("password") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = MemberUpdateBasicParams.builder().build() + + val body = params._body() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/members/MemberUpdateBasicResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/members/MemberUpdateBasicResponseTest.kt new file mode 100644 index 00000000..10fd9450 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/members/MemberUpdateBasicResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.members + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MemberUpdateBasicResponseTest { + + @Test + fun create() { + val memberUpdateBasicResponse = MemberUpdateBasicResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val memberUpdateBasicResponse = MemberUpdateBasicResponse.builder().build() + + val roundtrippedMemberUpdateBasicResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(memberUpdateBasicResponse), + jacksonTypeRef<MemberUpdateBasicResponse>(), + ) + + assertThat(roundtrippedMemberUpdateBasicResponse).isEqualTo(memberUpdateBasicResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/IdentityTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/IdentityTest.kt new file mode 100644 index 00000000..025b77ee --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/IdentityTest.kt @@ -0,0 +1,67 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.pending + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.orgs.current.members.AccessScope +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class IdentityTest { + + @Test + fun create() { + val identity = + Identity.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accessScope(AccessScope.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .roleName("role_name") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(identity.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(identity.createdAt()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(identity.lsUserId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(identity.organizationId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(identity.readOnly()).isEqualTo(true) + assertThat(identity.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(identity.accessScope()).contains(AccessScope.ORGANIZATION) + assertThat(identity.roleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(identity.roleName()).contains("role_name") + assertThat(identity.tenantId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val identity = + Identity.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accessScope(AccessScope.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .roleName("role_name") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val roundtrippedIdentity = + jsonMapper.readValue( + jsonMapper.writeValueAsString(identity), + jacksonTypeRef<Identity>(), + ) + + assertThat(roundtrippedIdentity).isEqualTo(identity) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/PendingClaimParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/PendingClaimParamsTest.kt new file mode 100644 index 00000000..f7d75b1d --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/PendingClaimParamsTest.kt @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.pending + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PendingClaimParamsTest { + + @Test + fun create() { + PendingClaimParams.builder().organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + PendingClaimParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/PendingDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/PendingDeleteParamsTest.kt new file mode 100644 index 00000000..8ec81c44 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/PendingDeleteParamsTest.kt @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.pending + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PendingDeleteParamsTest { + + @Test + fun create() { + PendingDeleteParams.builder().organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + PendingDeleteParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/PendingDeleteResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/PendingDeleteResponseTest.kt new file mode 100644 index 00000000..af127042 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/PendingDeleteResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.pending + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PendingDeleteResponseTest { + + @Test + fun create() { + val pendingDeleteResponse = PendingDeleteResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val pendingDeleteResponse = PendingDeleteResponse.builder().build() + + val roundtrippedPendingDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(pendingDeleteResponse), + jacksonTypeRef<PendingDeleteResponse>(), + ) + + assertThat(roundtrippedPendingDeleteResponse).isEqualTo(pendingDeleteResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/PendingListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/PendingListParamsTest.kt new file mode 100644 index 00000000..175196bc --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/pending/PendingListParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.pending + +import org.junit.jupiter.api.Test + +internal class PendingListParamsTest { + + @Test + fun create() { + PendingListParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/ttlsettings/TtlSettingRetrieveTtlSettingsParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/ttlsettings/TtlSettingRetrieveTtlSettingsParamsTest.kt new file mode 100644 index 00000000..bd842d07 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/ttlsettings/TtlSettingRetrieveTtlSettingsParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.ttlsettings + +import org.junit.jupiter.api.Test + +internal class TtlSettingRetrieveTtlSettingsParamsTest { + + @Test + fun create() { + TtlSettingRetrieveTtlSettingsParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/ttlsettings/TtlSettingUpdateTtlSettingsParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/ttlsettings/TtlSettingUpdateTtlSettingsParamsTest.kt new file mode 100644 index 00000000..58ac27c5 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/ttlsettings/TtlSettingUpdateTtlSettingsParamsTest.kt @@ -0,0 +1,64 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.ttlsettings + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TtlSettingUpdateTtlSettingsParamsTest { + + @Test + fun create() { + TtlSettingUpdateTtlSettingsParams.builder() + .upsertTtlSettingsRequest( + UpsertTtlSettingsRequest.builder() + .defaultTraceTier(TraceTier.LONGLIVED) + .applyToAllProjects(true) + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + } + + @Test + fun body() { + val params = + TtlSettingUpdateTtlSettingsParams.builder() + .upsertTtlSettingsRequest( + UpsertTtlSettingsRequest.builder() + .defaultTraceTier(TraceTier.LONGLIVED) + .applyToAllProjects(true) + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + UpsertTtlSettingsRequest.builder() + .defaultTraceTier(TraceTier.LONGLIVED) + .applyToAllProjects(true) + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + TtlSettingUpdateTtlSettingsParams.builder() + .upsertTtlSettingsRequest( + UpsertTtlSettingsRequest.builder().defaultTraceTier(TraceTier.LONGLIVED).build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + UpsertTtlSettingsRequest.builder().defaultTraceTier(TraceTier.LONGLIVED).build() + ) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/ttlsettings/TtlSettingsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/ttlsettings/TtlSettingsTest.kt new file mode 100644 index 00000000..77140762 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/ttlsettings/TtlSettingsTest.kt @@ -0,0 +1,62 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.ttlsettings + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TtlSettingsTest { + + @Test + fun create() { + val ttlSettings = + TtlSettings.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .configuredBy(TtlSettings.ConfiguredBy.SYSTEM) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .defaultTraceTier(TraceTier.LONGLIVED) + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .applyToAllProjects(true) + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(ttlSettings.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(ttlSettings.configuredBy()).isEqualTo(TtlSettings.ConfiguredBy.SYSTEM) + assertThat(ttlSettings.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(ttlSettings.defaultTraceTier()).isEqualTo(TraceTier.LONGLIVED) + assertThat(ttlSettings.organizationId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(ttlSettings.updatedAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(ttlSettings.applyToAllProjects()).contains(true) + assertThat(ttlSettings.tenantId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val ttlSettings = + TtlSettings.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .configuredBy(TtlSettings.ConfiguredBy.SYSTEM) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .defaultTraceTier(TraceTier.LONGLIVED) + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .applyToAllProjects(true) + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val roundtrippedTtlSettings = + jsonMapper.readValue( + jsonMapper.writeValueAsString(ttlSettings), + jacksonTypeRef<TtlSettings>(), + ) + + assertThat(roundtrippedTtlSettings).isEqualTo(ttlSettings) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/ttlsettings/UpsertTtlSettingsRequestTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/ttlsettings/UpsertTtlSettingsRequestTest.kt new file mode 100644 index 00000000..349bc93f --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/orgs/ttlsettings/UpsertTtlSettingsRequestTest.kt @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.orgs.ttlsettings + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UpsertTtlSettingsRequestTest { + + @Test + fun create() { + val upsertTtlSettingsRequest = + UpsertTtlSettingsRequest.builder() + .defaultTraceTier(TraceTier.LONGLIVED) + .applyToAllProjects(true) + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(upsertTtlSettingsRequest.defaultTraceTier()).isEqualTo(TraceTier.LONGLIVED) + assertThat(upsertTtlSettingsRequest.applyToAllProjects()).contains(true) + assertThat(upsertTtlSettingsRequest.tenantId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val upsertTtlSettingsRequest = + UpsertTtlSettingsRequest.builder() + .defaultTraceTier(TraceTier.LONGLIVED) + .applyToAllProjects(true) + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val roundtrippedUpsertTtlSettingsRequest = + jsonMapper.readValue( + jsonMapper.writeValueAsString(upsertTtlSettingsRequest), + jacksonTypeRef<UpsertTtlSettingsRequest>(), + ) + + assertThat(roundtrippedUpsertTtlSettingsRequest).isEqualTo(upsertTtlSettingsRequest) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSavedOptionsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSavedOptionsTest.kt new file mode 100644 index 00000000..1d924889 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSavedOptionsTest.kt @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.playgroundsettings + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PlaygroundSavedOptionsTest { + + @Test + fun create() { + val playgroundSavedOptions = PlaygroundSavedOptions.builder().requestsPerSecond(0L).build() + + assertThat(playgroundSavedOptions.requestsPerSecond()).contains(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val playgroundSavedOptions = PlaygroundSavedOptions.builder().requestsPerSecond(0L).build() + + val roundtrippedPlaygroundSavedOptions = + jsonMapper.readValue( + jsonMapper.writeValueAsString(playgroundSavedOptions), + jacksonTypeRef<PlaygroundSavedOptions>(), + ) + + assertThat(roundtrippedPlaygroundSavedOptions).isEqualTo(playgroundSavedOptions) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingDeleteParamsTest.kt new file mode 100644 index 00000000..d3b890ff --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingDeleteParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.playgroundsettings + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PlaygroundSettingDeleteParamsTest { + + @Test + fun create() { + PlaygroundSettingDeleteParams.builder() + .playgroundSettingsId("playground_settings_id") + .build() + } + + @Test + fun pathParams() { + val params = + PlaygroundSettingDeleteParams.builder() + .playgroundSettingsId("playground_settings_id") + .build() + + assertThat(params._pathParam(0)).isEqualTo("playground_settings_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingDeleteResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingDeleteResponseTest.kt new file mode 100644 index 00000000..a0739a63 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingDeleteResponseTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.playgroundsettings + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PlaygroundSettingDeleteResponseTest { + + @Test + fun create() { + val playgroundSettingDeleteResponse = PlaygroundSettingDeleteResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val playgroundSettingDeleteResponse = PlaygroundSettingDeleteResponse.builder().build() + + val roundtrippedPlaygroundSettingDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(playgroundSettingDeleteResponse), + jacksonTypeRef<PlaygroundSettingDeleteResponse>(), + ) + + assertThat(roundtrippedPlaygroundSettingDeleteResponse) + .isEqualTo(playgroundSettingDeleteResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingPlaygroundSettingsParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingPlaygroundSettingsParamsTest.kt new file mode 100644 index 00000000..8bd2ff90 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingPlaygroundSettingsParamsTest.kt @@ -0,0 +1,51 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.playgroundsettings + +import com.langsmith_api.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PlaygroundSettingPlaygroundSettingsParamsTest { + + @Test + fun create() { + PlaygroundSettingPlaygroundSettingsParams.builder() + .settings(JsonValue.from(mapOf<String, Any>())) + .description("description") + .name("name") + .options(PlaygroundSavedOptions.builder().requestsPerSecond(0L).build()) + .build() + } + + @Test + fun body() { + val params = + PlaygroundSettingPlaygroundSettingsParams.builder() + .settings(JsonValue.from(mapOf<String, Any>())) + .description("description") + .name("name") + .options(PlaygroundSavedOptions.builder().requestsPerSecond(0L).build()) + .build() + + val body = params._body() + + assertThat(body._settings()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(body.description()).contains("description") + assertThat(body.name()).contains("name") + assertThat(body.options()) + .contains(PlaygroundSavedOptions.builder().requestsPerSecond(0L).build()) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + PlaygroundSettingPlaygroundSettingsParams.builder() + .settings(JsonValue.from(mapOf<String, Any>())) + .build() + + val body = params._body() + + assertThat(body._settings()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingRetrievePlaygroundSettingsParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingRetrievePlaygroundSettingsParamsTest.kt new file mode 100644 index 00000000..160caabe --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingRetrievePlaygroundSettingsParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.playgroundsettings + +import org.junit.jupiter.api.Test + +internal class PlaygroundSettingRetrievePlaygroundSettingsParamsTest { + + @Test + fun create() { + PlaygroundSettingRetrievePlaygroundSettingsParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingUpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingUpdateParamsTest.kt new file mode 100644 index 00000000..2ee326ec --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingUpdateParamsTest.kt @@ -0,0 +1,63 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.playgroundsettings + +import com.langsmith_api.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PlaygroundSettingUpdateParamsTest { + + @Test + fun create() { + PlaygroundSettingUpdateParams.builder() + .playgroundSettingsId("playground_settings_id") + .description("description") + .name("name") + .options(PlaygroundSavedOptions.builder().requestsPerSecond(0L).build()) + .settings(JsonValue.from(mapOf<String, Any>())) + .build() + } + + @Test + fun pathParams() { + val params = + PlaygroundSettingUpdateParams.builder() + .playgroundSettingsId("playground_settings_id") + .build() + + assertThat(params._pathParam(0)).isEqualTo("playground_settings_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + PlaygroundSettingUpdateParams.builder() + .playgroundSettingsId("playground_settings_id") + .description("description") + .name("name") + .options(PlaygroundSavedOptions.builder().requestsPerSecond(0L).build()) + .settings(JsonValue.from(mapOf<String, Any>())) + .build() + + val body = params._body() + + assertThat(body.description()).contains("description") + assertThat(body.name()).contains("name") + assertThat(body.options()) + .contains(PlaygroundSavedOptions.builder().requestsPerSecond(0L).build()) + assertThat(body._settings()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + PlaygroundSettingUpdateParams.builder() + .playgroundSettingsId("playground_settings_id") + .build() + + val body = params._body() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingsResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingsResponseTest.kt new file mode 100644 index 00000000..e815862e --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/playgroundsettings/PlaygroundSettingsResponseTest.kt @@ -0,0 +1,63 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.playgroundsettings + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PlaygroundSettingsResponseTest { + + @Test + fun create() { + val playgroundSettingsResponse = + PlaygroundSettingsResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .settings(JsonValue.from(mapOf<String, Any>())) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .name("name") + .options(PlaygroundSavedOptions.builder().requestsPerSecond(0L).build()) + .build() + + assertThat(playgroundSettingsResponse.id()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(playgroundSettingsResponse.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(playgroundSettingsResponse._settings()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(playgroundSettingsResponse.updatedAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(playgroundSettingsResponse.description()).contains("description") + assertThat(playgroundSettingsResponse.name()).contains("name") + assertThat(playgroundSettingsResponse.options()) + .contains(PlaygroundSavedOptions.builder().requestsPerSecond(0L).build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val playgroundSettingsResponse = + PlaygroundSettingsResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .settings(JsonValue.from(mapOf<String, Any>())) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .name("name") + .options(PlaygroundSavedOptions.builder().requestsPerSecond(0L).build()) + .build() + + val roundtrippedPlaygroundSettingsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(playgroundSettingsResponse), + jacksonTypeRef<PlaygroundSettingsResponse>(), + ) + + assertThat(roundtrippedPlaygroundSettingsResponse).isEqualTo(playgroundSettingsResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/prompts/InvalidToolCallTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/prompts/InvalidToolCallTest.kt new file mode 100644 index 00000000..523504a2 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/prompts/InvalidToolCallTest.kt @@ -0,0 +1,54 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.prompts + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InvalidToolCallTest { + + @Test + fun create() { + val invalidToolCall = + InvalidToolCall.builder() + .id("id") + .args("args") + .error("error") + .name("name") + .extras(JsonValue.from(mapOf<String, Any>())) + .index(0L) + .build() + + assertThat(invalidToolCall.id()).contains("id") + assertThat(invalidToolCall.args()).contains("args") + assertThat(invalidToolCall.error()).contains("error") + assertThat(invalidToolCall.name()).contains("name") + assertThat(invalidToolCall._extras()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(invalidToolCall.index()).contains(InvalidToolCall.Index.ofInteger(0L)) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val invalidToolCall = + InvalidToolCall.builder() + .id("id") + .args("args") + .error("error") + .name("name") + .extras(JsonValue.from(mapOf<String, Any>())) + .index(0L) + .build() + + val roundtrippedInvalidToolCall = + jsonMapper.readValue( + jsonMapper.writeValueAsString(invalidToolCall), + jacksonTypeRef<InvalidToolCall>(), + ) + + assertThat(roundtrippedInvalidToolCall).isEqualTo(invalidToolCall) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/prompts/PromptCanvasParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/prompts/PromptCanvasParamsTest.kt new file mode 100644 index 00000000..66a5733d --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/prompts/PromptCanvasParamsTest.kt @@ -0,0 +1,295 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.prompts + +import com.langsmith_api.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PromptCanvasParamsTest { + + @Test + fun create() { + PromptCanvasParams.builder() + .addMessage( + PromptCanvasParams.Message.AiMessage.builder() + .content("string") + .id("id") + .additionalKwargs(JsonValue.from(mapOf<String, Any>())) + .addInvalidToolCall( + InvalidToolCall.builder() + .id("id") + .args("args") + .error("error") + .name("name") + .extras(JsonValue.from(mapOf<String, Any>())) + .index(0L) + .build() + ) + .name("name") + .responseMetadata(JsonValue.from(mapOf<String, Any>())) + .addToolCall( + ToolCall.builder() + .id("id") + .args(JsonValue.from(mapOf<String, Any>())) + .name("name") + .type(ToolCall.Type.TOOL_CALL) + .build() + ) + .type(PromptCanvasParams.Message.AiMessage.Type.AI) + .usageMetadata( + UsageMetadata.builder() + .inputTokens(0L) + .outputTokens(0L) + .totalTokens(0L) + .inputTokenDetails( + UsageMetadata.InputTokenDetails.builder() + .audio(0L) + .cacheCreation(0L) + .cacheRead(0L) + .build() + ) + .outputTokenDetails( + UsageMetadata.OutputTokenDetails.builder() + .audio(0L) + .reasoning(0L) + .build() + ) + .build() + ) + .build() + ) + .secrets( + PromptCanvasParams.Secrets.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .templateFormat(PromptCanvasParams.TemplateFormat.F_STRING) + .artifact( + PromptCanvasParams.Artifact.builder() + .id("id") + .addContent( + PromptCanvasParams.Artifact.Content.builder() + .content("content") + .index(0L) + .build() + ) + .currentContentIndex(0L) + .build() + ) + .artifactLength(PromptCanvasParams.ArtifactLength.SHORTEST) + .customAction("custom_action") + .highlighted( + PromptCanvasParams.Highlighted.builder() + .highlightText("highlight_text") + .promptChunk("prompt_chunk") + .promptChunkEndIndex(0L) + .promptChunkStartIndex(0L) + .build() + ) + .readingLevel(PromptCanvasParams.ReadingLevel.CHILD) + .build() + } + + @Test + fun body() { + val params = + PromptCanvasParams.builder() + .addMessage( + PromptCanvasParams.Message.AiMessage.builder() + .content("string") + .id("id") + .additionalKwargs(JsonValue.from(mapOf<String, Any>())) + .addInvalidToolCall( + InvalidToolCall.builder() + .id("id") + .args("args") + .error("error") + .name("name") + .extras(JsonValue.from(mapOf<String, Any>())) + .index(0L) + .build() + ) + .name("name") + .responseMetadata(JsonValue.from(mapOf<String, Any>())) + .addToolCall( + ToolCall.builder() + .id("id") + .args(JsonValue.from(mapOf<String, Any>())) + .name("name") + .type(ToolCall.Type.TOOL_CALL) + .build() + ) + .type(PromptCanvasParams.Message.AiMessage.Type.AI) + .usageMetadata( + UsageMetadata.builder() + .inputTokens(0L) + .outputTokens(0L) + .totalTokens(0L) + .inputTokenDetails( + UsageMetadata.InputTokenDetails.builder() + .audio(0L) + .cacheCreation(0L) + .cacheRead(0L) + .build() + ) + .outputTokenDetails( + UsageMetadata.OutputTokenDetails.builder() + .audio(0L) + .reasoning(0L) + .build() + ) + .build() + ) + .build() + ) + .secrets( + PromptCanvasParams.Secrets.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .templateFormat(PromptCanvasParams.TemplateFormat.F_STRING) + .artifact( + PromptCanvasParams.Artifact.builder() + .id("id") + .addContent( + PromptCanvasParams.Artifact.Content.builder() + .content("content") + .index(0L) + .build() + ) + .currentContentIndex(0L) + .build() + ) + .artifactLength(PromptCanvasParams.ArtifactLength.SHORTEST) + .customAction("custom_action") + .highlighted( + PromptCanvasParams.Highlighted.builder() + .highlightText("highlight_text") + .promptChunk("prompt_chunk") + .promptChunkEndIndex(0L) + .promptChunkStartIndex(0L) + .build() + ) + .readingLevel(PromptCanvasParams.ReadingLevel.CHILD) + .build() + + val body = params._body() + + assertThat(body.messages()) + .containsExactly( + PromptCanvasParams.Message.ofAi( + PromptCanvasParams.Message.AiMessage.builder() + .content("string") + .id("id") + .additionalKwargs(JsonValue.from(mapOf<String, Any>())) + .addInvalidToolCall( + InvalidToolCall.builder() + .id("id") + .args("args") + .error("error") + .name("name") + .extras(JsonValue.from(mapOf<String, Any>())) + .index(0L) + .build() + ) + .name("name") + .responseMetadata(JsonValue.from(mapOf<String, Any>())) + .addToolCall( + ToolCall.builder() + .id("id") + .args(JsonValue.from(mapOf<String, Any>())) + .name("name") + .type(ToolCall.Type.TOOL_CALL) + .build() + ) + .type(PromptCanvasParams.Message.AiMessage.Type.AI) + .usageMetadata( + UsageMetadata.builder() + .inputTokens(0L) + .outputTokens(0L) + .totalTokens(0L) + .inputTokenDetails( + UsageMetadata.InputTokenDetails.builder() + .audio(0L) + .cacheCreation(0L) + .cacheRead(0L) + .build() + ) + .outputTokenDetails( + UsageMetadata.OutputTokenDetails.builder() + .audio(0L) + .reasoning(0L) + .build() + ) + .build() + ) + .build() + ) + ) + assertThat(body.secrets()) + .isEqualTo( + PromptCanvasParams.Secrets.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(body.templateFormat()).isEqualTo(PromptCanvasParams.TemplateFormat.F_STRING) + assertThat(body.artifact()) + .contains( + PromptCanvasParams.Artifact.builder() + .id("id") + .addContent( + PromptCanvasParams.Artifact.Content.builder() + .content("content") + .index(0L) + .build() + ) + .currentContentIndex(0L) + .build() + ) + assertThat(body.artifactLength()).contains(PromptCanvasParams.ArtifactLength.SHORTEST) + assertThat(body.customAction()).contains("custom_action") + assertThat(body.highlighted()) + .contains( + PromptCanvasParams.Highlighted.builder() + .highlightText("highlight_text") + .promptChunk("prompt_chunk") + .promptChunkEndIndex(0L) + .promptChunkStartIndex(0L) + .build() + ) + assertThat(body.readingLevel()).contains(PromptCanvasParams.ReadingLevel.CHILD) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + PromptCanvasParams.builder() + .addMessage( + PromptCanvasParams.Message.AiMessage.builder().content("string").build() + ) + .secrets( + PromptCanvasParams.Secrets.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .templateFormat(PromptCanvasParams.TemplateFormat.F_STRING) + .build() + + val body = params._body() + + assertThat(body.messages()) + .containsExactly( + PromptCanvasParams.Message.ofAi( + PromptCanvasParams.Message.AiMessage.builder().content("string").build() + ) + ) + assertThat(body.secrets()) + .isEqualTo( + PromptCanvasParams.Secrets.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(body.templateFormat()).isEqualTo(PromptCanvasParams.TemplateFormat.F_STRING) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/prompts/PromptCanvasResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/prompts/PromptCanvasResponseTest.kt new file mode 100644 index 00000000..05e800e4 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/prompts/PromptCanvasResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.prompts + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PromptCanvasResponseTest { + + @Test + fun create() { + val promptCanvasResponse = PromptCanvasResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val promptCanvasResponse = PromptCanvasResponse.builder().build() + + val roundtrippedPromptCanvasResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(promptCanvasResponse), + jacksonTypeRef<PromptCanvasResponse>(), + ) + + assertThat(roundtrippedPromptCanvasResponse).isEqualTo(promptCanvasResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/prompts/PromptInvokePromptParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/prompts/PromptInvokePromptParamsTest.kt new file mode 100644 index 00000000..ed703b52 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/prompts/PromptInvokePromptParamsTest.kt @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.prompts + +import com.langsmith_api.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PromptInvokePromptParamsTest { + + @Test + fun create() { + PromptInvokePromptParams.builder() + .inputs(JsonValue.from(mapOf<String, Any>())) + .addMessage( + listOf(JsonValue.from(mapOf<String, Any>()), JsonValue.from(mapOf<String, Any>())) + ) + .templateFormat("template_format") + .build() + } + + @Test + fun body() { + val params = + PromptInvokePromptParams.builder() + .inputs(JsonValue.from(mapOf<String, Any>())) + .addMessage( + listOf( + JsonValue.from(mapOf<String, Any>()), + JsonValue.from(mapOf<String, Any>()), + ) + ) + .templateFormat("template_format") + .build() + + val body = params._body() + + assertThat(body._inputs()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(body.messages()) + .containsExactly( + listOf(JsonValue.from(mapOf<String, Any>()), JsonValue.from(mapOf<String, Any>())) + ) + assertThat(body.templateFormat()).isEqualTo("template_format") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/prompts/PromptInvokePromptResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/prompts/PromptInvokePromptResponseTest.kt new file mode 100644 index 00000000..87a462a6 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/prompts/PromptInvokePromptResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.prompts + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PromptInvokePromptResponseTest { + + @Test + fun create() { + val promptInvokePromptResponse = PromptInvokePromptResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val promptInvokePromptResponse = PromptInvokePromptResponse.builder().build() + + val roundtrippedPromptInvokePromptResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(promptInvokePromptResponse), + jacksonTypeRef<PromptInvokePromptResponse>(), + ) + + assertThat(roundtrippedPromptInvokePromptResponse).isEqualTo(promptInvokePromptResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/prompts/ToolCallTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/prompts/ToolCallTest.kt new file mode 100644 index 00000000..ad7352ec --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/prompts/ToolCallTest.kt @@ -0,0 +1,48 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.prompts + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ToolCallTest { + + @Test + fun create() { + val toolCall = + ToolCall.builder() + .id("id") + .args(JsonValue.from(mapOf<String, Any>())) + .name("name") + .type(ToolCall.Type.TOOL_CALL) + .build() + + assertThat(toolCall.id()).contains("id") + assertThat(toolCall._args()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(toolCall.name()).isEqualTo("name") + assertThat(toolCall.type()).contains(ToolCall.Type.TOOL_CALL) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val toolCall = + ToolCall.builder() + .id("id") + .args(JsonValue.from(mapOf<String, Any>())) + .name("name") + .type(ToolCall.Type.TOOL_CALL) + .build() + + val roundtrippedToolCall = + jsonMapper.readValue( + jsonMapper.writeValueAsString(toolCall), + jacksonTypeRef<ToolCall>(), + ) + + assertThat(roundtrippedToolCall).isEqualTo(toolCall) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/prompts/UsageMetadataTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/prompts/UsageMetadataTest.kt new file mode 100644 index 00000000..e0dac896 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/prompts/UsageMetadataTest.kt @@ -0,0 +1,74 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.prompts + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UsageMetadataTest { + + @Test + fun create() { + val usageMetadata = + UsageMetadata.builder() + .inputTokens(0L) + .outputTokens(0L) + .totalTokens(0L) + .inputTokenDetails( + UsageMetadata.InputTokenDetails.builder() + .audio(0L) + .cacheCreation(0L) + .cacheRead(0L) + .build() + ) + .outputTokenDetails( + UsageMetadata.OutputTokenDetails.builder().audio(0L).reasoning(0L).build() + ) + .build() + + assertThat(usageMetadata.inputTokens()).isEqualTo(0L) + assertThat(usageMetadata.outputTokens()).isEqualTo(0L) + assertThat(usageMetadata.totalTokens()).isEqualTo(0L) + assertThat(usageMetadata.inputTokenDetails()) + .contains( + UsageMetadata.InputTokenDetails.builder() + .audio(0L) + .cacheCreation(0L) + .cacheRead(0L) + .build() + ) + assertThat(usageMetadata.outputTokenDetails()) + .contains(UsageMetadata.OutputTokenDetails.builder().audio(0L).reasoning(0L).build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val usageMetadata = + UsageMetadata.builder() + .inputTokens(0L) + .outputTokens(0L) + .totalTokens(0L) + .inputTokenDetails( + UsageMetadata.InputTokenDetails.builder() + .audio(0L) + .cacheCreation(0L) + .cacheRead(0L) + .build() + ) + .outputTokenDetails( + UsageMetadata.OutputTokenDetails.builder().audio(0L).reasoning(0L).build() + ) + .build() + + val roundtrippedUsageMetadata = + jsonMapper.readValue( + jsonMapper.writeValueAsString(usageMetadata), + jacksonTypeRef<UsageMetadata>(), + ) + + assertThat(roundtrippedUsageMetadata).isEqualTo(usageMetadata) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookDeleteParamsTest.kt new file mode 100644 index 00000000..375367af --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookDeleteParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.promptwebhooks + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PromptWebhookDeleteParamsTest { + + @Test + fun create() { + PromptWebhookDeleteParams.builder() + .webhookId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + PromptWebhookDeleteParams.builder() + .webhookId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookDeleteResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookDeleteResponseTest.kt new file mode 100644 index 00000000..f535abe4 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookDeleteResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.promptwebhooks + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PromptWebhookDeleteResponseTest { + + @Test + fun create() { + val promptWebhookDeleteResponse = PromptWebhookDeleteResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val promptWebhookDeleteResponse = PromptWebhookDeleteResponse.builder().build() + + val roundtrippedPromptWebhookDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(promptWebhookDeleteResponse), + jacksonTypeRef<PromptWebhookDeleteResponse>(), + ) + + assertThat(roundtrippedPromptWebhookDeleteResponse).isEqualTo(promptWebhookDeleteResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookPromptWebhooksParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookPromptWebhooksParamsTest.kt new file mode 100644 index 00000000..00f52ed4 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookPromptWebhooksParamsTest.kt @@ -0,0 +1,56 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.promptwebhooks + +import com.langsmith_api.api.core.JsonValue +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PromptWebhookPromptWebhooksParamsTest { + + @Test + fun create() { + PromptWebhookPromptWebhooksParams.builder() + .url("https://example.com") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addExcludePrompt("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .headers(JsonValue.from(mapOf<String, Any>())) + .addIncludePrompt("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addTrigger(EPromptWebhookTrigger.COMMIT) + .build() + } + + @Test + fun body() { + val params = + PromptWebhookPromptWebhooksParams.builder() + .url("https://example.com") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addExcludePrompt("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .headers(JsonValue.from(mapOf<String, Any>())) + .addIncludePrompt("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addTrigger(EPromptWebhookTrigger.COMMIT) + .build() + + val body = params._body() + + assertThat(body.url()).isEqualTo("https://example.com") + assertThat(body.id()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.excludePrompts().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body._headers_()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(body.includePrompts().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.triggers().getOrNull()).containsExactly(EPromptWebhookTrigger.COMMIT) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = PromptWebhookPromptWebhooksParams.builder().url("https://example.com").build() + + val body = params._body() + + assertThat(body.url()).isEqualTo("https://example.com") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookRetrieveParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookRetrieveParamsTest.kt new file mode 100644 index 00000000..c007cc2a --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookRetrieveParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.promptwebhooks + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PromptWebhookRetrieveParamsTest { + + @Test + fun create() { + PromptWebhookRetrieveParams.builder() + .webhookId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + PromptWebhookRetrieveParams.builder() + .webhookId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookRetrievePromptWebhooksParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookRetrievePromptWebhooksParamsTest.kt new file mode 100644 index 00000000..04488d0e --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookRetrievePromptWebhooksParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.promptwebhooks + +import org.junit.jupiter.api.Test + +internal class PromptWebhookRetrievePromptWebhooksParamsTest { + + @Test + fun create() { + PromptWebhookRetrievePromptWebhooksParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookTest.kt new file mode 100644 index 00000000..72989989 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookTest.kt @@ -0,0 +1,70 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.promptwebhooks + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PromptWebhookTest { + + @Test + fun create() { + val promptWebhook = + PromptWebhook.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") + .addExcludePrompt("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .headers(JsonValue.from(mapOf<String, Any>())) + .addIncludePrompt("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addTrigger(EPromptWebhookTrigger.COMMIT) + .build() + + assertThat(promptWebhook.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(promptWebhook.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(promptWebhook.tenantId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(promptWebhook.updatedAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(promptWebhook.url()).isEqualTo("https://example.com") + assertThat(promptWebhook.excludePrompts().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(promptWebhook._headers()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(promptWebhook.includePrompts().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(promptWebhook.triggers().getOrNull()) + .containsExactly(EPromptWebhookTrigger.COMMIT) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val promptWebhook = + PromptWebhook.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") + .addExcludePrompt("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .headers(JsonValue.from(mapOf<String, Any>())) + .addIncludePrompt("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addTrigger(EPromptWebhookTrigger.COMMIT) + .build() + + val roundtrippedPromptWebhook = + jsonMapper.readValue( + jsonMapper.writeValueAsString(promptWebhook), + jacksonTypeRef<PromptWebhook>(), + ) + + assertThat(roundtrippedPromptWebhook).isEqualTo(promptWebhook) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookTestParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookTestParamsTest.kt new file mode 100644 index 00000000..96654d01 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookTestParamsTest.kt @@ -0,0 +1,129 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.promptwebhooks + +import com.langsmith_api.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PromptWebhookTestParamsTest { + + @Test + fun create() { + PromptWebhookTestParams.builder() + .payload( + PromptWebhookTestParams.Payload.builder() + .commitHash("commit_hash") + .createdAt("created_at") + .createdBy("created_by") + .event(EPromptWebhookTrigger.COMMIT) + .manifest(JsonValue.from(mapOf<String, Any>())) + .promptId("prompt_id") + .promptName("prompt_name") + .tagName("tag_name") + .build() + ) + .webhook( + PromptWebhookTestParams.Webhook.builder() + .url("https://example.com") + .addExcludePrompt("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .headers(JsonValue.from(mapOf<String, Any>())) + .addIncludePrompt("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addTrigger(EPromptWebhookTrigger.COMMIT) + .build() + ) + .build() + } + + @Test + fun body() { + val params = + PromptWebhookTestParams.builder() + .payload( + PromptWebhookTestParams.Payload.builder() + .commitHash("commit_hash") + .createdAt("created_at") + .createdBy("created_by") + .event(EPromptWebhookTrigger.COMMIT) + .manifest(JsonValue.from(mapOf<String, Any>())) + .promptId("prompt_id") + .promptName("prompt_name") + .tagName("tag_name") + .build() + ) + .webhook( + PromptWebhookTestParams.Webhook.builder() + .url("https://example.com") + .addExcludePrompt("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .headers(JsonValue.from(mapOf<String, Any>())) + .addIncludePrompt("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addTrigger(EPromptWebhookTrigger.COMMIT) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.payload()) + .isEqualTo( + PromptWebhookTestParams.Payload.builder() + .commitHash("commit_hash") + .createdAt("created_at") + .createdBy("created_by") + .event(EPromptWebhookTrigger.COMMIT) + .manifest(JsonValue.from(mapOf<String, Any>())) + .promptId("prompt_id") + .promptName("prompt_name") + .tagName("tag_name") + .build() + ) + assertThat(body.webhook()) + .isEqualTo( + PromptWebhookTestParams.Webhook.builder() + .url("https://example.com") + .addExcludePrompt("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .headers(JsonValue.from(mapOf<String, Any>())) + .addIncludePrompt("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addTrigger(EPromptWebhookTrigger.COMMIT) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + PromptWebhookTestParams.builder() + .payload( + PromptWebhookTestParams.Payload.builder() + .commitHash("commit_hash") + .createdAt("created_at") + .createdBy("created_by") + .event(EPromptWebhookTrigger.COMMIT) + .manifest(JsonValue.from(mapOf<String, Any>())) + .promptId("prompt_id") + .promptName("prompt_name") + .build() + ) + .webhook( + PromptWebhookTestParams.Webhook.builder().url("https://example.com").build() + ) + .build() + + val body = params._body() + + assertThat(body.payload()) + .isEqualTo( + PromptWebhookTestParams.Payload.builder() + .commitHash("commit_hash") + .createdAt("created_at") + .createdBy("created_by") + .event(EPromptWebhookTrigger.COMMIT) + .manifest(JsonValue.from(mapOf<String, Any>())) + .promptId("prompt_id") + .promptName("prompt_name") + .build() + ) + assertThat(body.webhook()) + .isEqualTo(PromptWebhookTestParams.Webhook.builder().url("https://example.com").build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookTestResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookTestResponseTest.kt new file mode 100644 index 00000000..63edaac0 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookTestResponseTest.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.promptwebhooks + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PromptWebhookTestResponseTest { + + @Test + fun create() { + val promptWebhookTestResponse = + PromptWebhookTestResponse.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val promptWebhookTestResponse = + PromptWebhookTestResponse.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + + val roundtrippedPromptWebhookTestResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(promptWebhookTestResponse), + jacksonTypeRef<PromptWebhookTestResponse>(), + ) + + assertThat(roundtrippedPromptWebhookTestResponse).isEqualTo(promptWebhookTestResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookUpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookUpdateParamsTest.kt new file mode 100644 index 00000000..1481115b --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/promptwebhooks/PromptWebhookUpdateParamsTest.kt @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.promptwebhooks + +import com.langsmith_api.api.core.JsonValue +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PromptWebhookUpdateParamsTest { + + @Test + fun create() { + PromptWebhookUpdateParams.builder() + .webhookId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addExcludePrompt("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .headers(JsonValue.from(mapOf<String, Any>())) + .addIncludePrompt("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addTrigger(EPromptWebhookTrigger.COMMIT) + .url("https://example.com") + .build() + } + + @Test + fun pathParams() { + val params = + PromptWebhookUpdateParams.builder() + .webhookId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + PromptWebhookUpdateParams.builder() + .webhookId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addExcludePrompt("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .headers(JsonValue.from(mapOf<String, Any>())) + .addIncludePrompt("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addTrigger(EPromptWebhookTrigger.COMMIT) + .url("https://example.com") + .build() + + val body = params._body() + + assertThat(body.excludePrompts().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body._headers_()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(body.includePrompts().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.triggers().getOrNull()).containsExactly(EPromptWebhookTrigger.COMMIT) + assertThat(body.url()).contains("https://example.com") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + PromptWebhookUpdateParams.builder() + .webhookId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/PublicRetrieveFeedbacksParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/PublicRetrieveFeedbacksParamsTest.kt new file mode 100644 index 00000000..084f21e2 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/PublicRetrieveFeedbacksParamsTest.kt @@ -0,0 +1,92 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_ + +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.models.api.v1.feedback.FeedbackLevel +import com.langsmith_api.api.models.api.v1.feedback.SourceType +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PublicRetrieveFeedbacksParamsTest { + + @Test + fun create() { + PublicRetrieveFeedbacksParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .hasComment(true) + .hasScore(true) + .addKey("string") + .level(FeedbackLevel.RUN) + .limit(1L) + .offset(0L) + .addRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addSource(SourceType.API) + .addUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + PublicRetrieveFeedbacksParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + PublicRetrieveFeedbacksParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .hasComment(true) + .hasScore(true) + .addKey("string") + .level(FeedbackLevel.RUN) + .limit(1L) + .offset(0L) + .addRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addSource(SourceType.API) + .addUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("has_comment", "true") + .put("has_score", "true") + .put("key", listOf("string").joinToString(",")) + .put("level", "run") + .put("limit", "1") + .put("offset", "0") + .put("run", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").joinToString(",")) + .put( + "session", + listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").joinToString(","), + ) + .put("source", listOf("api").joinToString(",")) + .put("user", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").joinToString(",")) + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + PublicRetrieveFeedbacksParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetListParamsTest.kt new file mode 100644 index 00000000..c248fa1a --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetListParamsTest.kt @@ -0,0 +1,66 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.datasets + +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.models.api.v1.datasets.SortByDatasetColumn +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetListParamsTest { + + @Test + fun create() { + DatasetListParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .offset(0L) + .sortBy(SortByDatasetColumn.NAME) + .sortByDesc(true) + .build() + } + + @Test + fun pathParams() { + val params = + DatasetListParams.builder().shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + DatasetListParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .offset(0L) + .sortBy(SortByDatasetColumn.NAME) + .sortByDesc(true) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("limit", "1") + .put("offset", "0") + .put("sort_by", "name") + .put("sort_by_desc", "true") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + DatasetListParams.builder().shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetListResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetListResponseTest.kt new file mode 100644 index 00000000..65c0ade9 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetListResponseTest.kt @@ -0,0 +1,95 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.datasets + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.datasets.DataType +import com.langsmith_api.api.models.api.v1.datasets.DatasetTransformation +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetListResponseTest { + + @Test + fun create() { + val datasetListResponse = + DatasetListResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .exampleCount(0L) + .name("name") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dataType(DataType.KV) + .description("description") + .externallyManaged(true) + .inputsSchemaDefinition(JsonValue.from(mapOf<String, Any>())) + .outputsSchemaDefinition(JsonValue.from(mapOf<String, Any>())) + .addTransformation( + DatasetTransformation.builder() + .addPath("string") + .transformationType( + DatasetTransformation.TransformationType.CONVERT_TO_OPENAI_MESSAGE + ) + .build() + ) + .build() + + assertThat(datasetListResponse.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(datasetListResponse.exampleCount()).isEqualTo(0L) + assertThat(datasetListResponse.name()).isEqualTo("name") + assertThat(datasetListResponse.createdAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(datasetListResponse.dataType()).contains(DataType.KV) + assertThat(datasetListResponse.description()).contains("description") + assertThat(datasetListResponse.externallyManaged()).contains(true) + assertThat(datasetListResponse._inputsSchemaDefinition()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(datasetListResponse._outputsSchemaDefinition()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(datasetListResponse.transformations().getOrNull()) + .containsExactly( + DatasetTransformation.builder() + .addPath("string") + .transformationType( + DatasetTransformation.TransformationType.CONVERT_TO_OPENAI_MESSAGE + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val datasetListResponse = + DatasetListResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .exampleCount(0L) + .name("name") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dataType(DataType.KV) + .description("description") + .externallyManaged(true) + .inputsSchemaDefinition(JsonValue.from(mapOf<String, Any>())) + .outputsSchemaDefinition(JsonValue.from(mapOf<String, Any>())) + .addTransformation( + DatasetTransformation.builder() + .addPath("string") + .transformationType( + DatasetTransformation.TransformationType.CONVERT_TO_OPENAI_MESSAGE + ) + .build() + ) + .build() + + val roundtrippedDatasetListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(datasetListResponse), + jacksonTypeRef<DatasetListResponse>(), + ) + + assertThat(roundtrippedDatasetListResponse).isEqualTo(datasetListResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveComparativeParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveComparativeParamsTest.kt new file mode 100644 index 00000000..2817770a --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveComparativeParamsTest.kt @@ -0,0 +1,76 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.datasets + +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.models.api.v1.datasets.comparative.SortByComparativeExperimentColumn +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetRetrieveComparativeParamsTest { + + @Test + fun create() { + DatasetRetrieveComparativeParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .name("name") + .nameContains("name_contains") + .offset(0L) + .sortBy(SortByComparativeExperimentColumn.NAME) + .sortByDesc(true) + .build() + } + + @Test + fun pathParams() { + val params = + DatasetRetrieveComparativeParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + DatasetRetrieveComparativeParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .name("name") + .nameContains("name_contains") + .offset(0L) + .sortBy(SortByComparativeExperimentColumn.NAME) + .sortByDesc(true) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("limit", "1") + .put("name", "name") + .put("name_contains", "name_contains") + .put("offset", "0") + .put("sort_by", "name") + .put("sort_by_desc", "true") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + DatasetRetrieveComparativeParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveComparativeResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveComparativeResponseTest.kt new file mode 100644 index 00000000..2b7a839f --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveComparativeResponseTest.kt @@ -0,0 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.datasets + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.datasets.comparative.SimpleExperimentInfo +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetRetrieveComparativeResponseTest { + + @Test + fun create() { + val datasetRetrieveComparativeResponse = + DatasetRetrieveComparativeResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addExperimentsInfo( + SimpleExperimentInfo.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .build() + ) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats(JsonValue.from(mapOf<String, Any>())) + .name("name") + .build() + + assertThat(datasetRetrieveComparativeResponse.id()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(datasetRetrieveComparativeResponse.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(datasetRetrieveComparativeResponse.experimentsInfo()) + .containsExactly( + SimpleExperimentInfo.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .build() + ) + assertThat(datasetRetrieveComparativeResponse.modifiedAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(datasetRetrieveComparativeResponse.description()).contains("description") + assertThat(datasetRetrieveComparativeResponse._extra()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(datasetRetrieveComparativeResponse._feedbackStats()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(datasetRetrieveComparativeResponse.name()).contains("name") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val datasetRetrieveComparativeResponse = + DatasetRetrieveComparativeResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addExperimentsInfo( + SimpleExperimentInfo.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .build() + ) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats(JsonValue.from(mapOf<String, Any>())) + .name("name") + .build() + + val roundtrippedDatasetRetrieveComparativeResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(datasetRetrieveComparativeResponse), + jacksonTypeRef<DatasetRetrieveComparativeResponse>(), + ) + + assertThat(roundtrippedDatasetRetrieveComparativeResponse) + .isEqualTo(datasetRetrieveComparativeResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveFeedbackParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveFeedbackParamsTest.kt new file mode 100644 index 00000000..ecaa5b66 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveFeedbackParamsTest.kt @@ -0,0 +1,92 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.datasets + +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.models.api.v1.feedback.FeedbackLevel +import com.langsmith_api.api.models.api.v1.feedback.SourceType +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetRetrieveFeedbackParamsTest { + + @Test + fun create() { + DatasetRetrieveFeedbackParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .hasComment(true) + .hasScore(true) + .addKey("string") + .level(FeedbackLevel.RUN) + .limit(1L) + .offset(0L) + .addRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addSource(SourceType.API) + .addUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + DatasetRetrieveFeedbackParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + DatasetRetrieveFeedbackParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .hasComment(true) + .hasScore(true) + .addKey("string") + .level(FeedbackLevel.RUN) + .limit(1L) + .offset(0L) + .addRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addSource(SourceType.API) + .addUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("has_comment", "true") + .put("has_score", "true") + .put("key", listOf("string").joinToString(",")) + .put("level", "run") + .put("limit", "1") + .put("offset", "0") + .put("run", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").joinToString(",")) + .put( + "session", + listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").joinToString(","), + ) + .put("source", listOf("api").joinToString(",")) + .put("user", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").joinToString(",")) + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + DatasetRetrieveFeedbackParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveSessionsBulkParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveSessionsBulkParamsTest.kt new file mode 100644 index 00000000..a76fa91f --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveSessionsBulkParamsTest.kt @@ -0,0 +1,29 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.datasets + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetRetrieveSessionsBulkParamsTest { + + @Test + fun create() { + DatasetRetrieveSessionsBulkParams.builder().addShareToken("string").build() + } + + @Test + fun queryParams() { + val params = DatasetRetrieveSessionsBulkParams.builder().addShareToken("string").build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("share_tokens", listOf("string").joinToString(",")) + .build() + ) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveSessionsParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveSessionsParamsTest.kt new file mode 100644 index 00000000..bb088a41 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/DatasetRetrieveSessionsParamsTest.kt @@ -0,0 +1,126 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.datasets + +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.models.api.v1.sessions.SessionSortableColumns +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DatasetRetrieveSessionsParamsTest { + + @Test + fun create() { + DatasetRetrieveSessionsParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .facets(true) + .limit(1L) + .name("name") + .nameContains("name_contains") + .offset(0L) + .sortBy(SessionSortableColumns.NAME) + .sortByDesc(true) + .sortByFeedbackKey("sort_by_feedback_key") + .accept("accept") + .build() + } + + @Test + fun pathParams() { + val params = + DatasetRetrieveSessionsParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun headers() { + val params = + DatasetRetrieveSessionsParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .facets(true) + .limit(1L) + .name("name") + .nameContains("name_contains") + .offset(0L) + .sortBy(SessionSortableColumns.NAME) + .sortByDesc(true) + .sortByFeedbackKey("sort_by_feedback_key") + .accept("accept") + .build() + + val headers = params._headers() + + assertThat(headers).isEqualTo(Headers.builder().put("accept", "accept").build()) + } + + @Test + fun headersWithoutOptionalFields() { + val params = + DatasetRetrieveSessionsParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val headers = params._headers() + + assertThat(headers).isEqualTo(Headers.builder().build()) + } + + @Test + fun queryParams() { + val params = + DatasetRetrieveSessionsParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .facets(true) + .limit(1L) + .name("name") + .nameContains("name_contains") + .offset(0L) + .sortBy(SessionSortableColumns.NAME) + .sortByDesc(true) + .sortByFeedbackKey("sort_by_feedback_key") + .accept("accept") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").joinToString(",")) + .put("dataset_version", "dataset_version") + .put("facets", "true") + .put("limit", "1") + .put("name", "name") + .put("name_contains", "name_contains") + .put("offset", "0") + .put("sort_by", "name") + .put("sort_by_desc", "true") + .put("sort_by_feedback_key", "sort_by_feedback_key") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + DatasetRetrieveSessionsParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunDeltaParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunDeltaParamsTest.kt new file mode 100644 index 00000000..40adbc2e --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunDeltaParamsTest.kt @@ -0,0 +1,120 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.datasets.runs + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.datasets.runs.QueryFeedbackDelta +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunDeltaParamsTest { + + @Test + fun create() { + RunDeltaParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .queryFeedbackDelta( + QueryFeedbackDelta.builder() + .baselineSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addComparisonSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackKey("feedback_key") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .filters( + QueryFeedbackDelta.Filters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + ) + .limit(1L) + .offset(0L) + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + RunDeltaParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .queryFeedbackDelta( + QueryFeedbackDelta.builder() + .baselineSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addComparisonSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackKey("feedback_key") + .build() + ) + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + RunDeltaParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .queryFeedbackDelta( + QueryFeedbackDelta.builder() + .baselineSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addComparisonSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackKey("feedback_key") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .filters( + QueryFeedbackDelta.Filters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + ) + .limit(1L) + .offset(0L) + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + QueryFeedbackDelta.builder() + .baselineSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addComparisonSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackKey("feedback_key") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .filters( + QueryFeedbackDelta.Filters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + ) + .limit(1L) + .offset(0L) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + RunDeltaParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .queryFeedbackDelta( + QueryFeedbackDelta.builder() + .baselineSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addComparisonSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackKey("feedback_key") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + QueryFeedbackDelta.builder() + .baselineSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addComparisonSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackKey("feedback_key") + .build() + ) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunGenerateQueryParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunGenerateQueryParamsTest.kt new file mode 100644 index 00000000..f0386880 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunGenerateQueryParamsTest.kt @@ -0,0 +1,77 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.datasets.runs + +import com.langsmith_api.api.models.api.v1.runs.RequestBodyForRunsGenerateQuery +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunGenerateQueryParamsTest { + + @Test + fun create() { + RunGenerateQueryParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .requestBodyForRunsGenerateQuery( + RequestBodyForRunsGenerateQuery.builder() + .query("query") + .addFeedbackKey(RequestBodyForRunsGenerateQuery.FeedbackKey.USER_SCORE) + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + RunGenerateQueryParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .requestBodyForRunsGenerateQuery( + RequestBodyForRunsGenerateQuery.builder().query("query").build() + ) + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + RunGenerateQueryParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .requestBodyForRunsGenerateQuery( + RequestBodyForRunsGenerateQuery.builder() + .query("query") + .addFeedbackKey(RequestBodyForRunsGenerateQuery.FeedbackKey.USER_SCORE) + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + RequestBodyForRunsGenerateQuery.builder() + .query("query") + .addFeedbackKey(RequestBodyForRunsGenerateQuery.FeedbackKey.USER_SCORE) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + RunGenerateQueryParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .requestBodyForRunsGenerateQuery( + RequestBodyForRunsGenerateQuery.builder().query("query").build() + ) + .build() + + val body = params._body() + + assertThat(body).isEqualTo(RequestBodyForRunsGenerateQuery.builder().query("query").build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunPublicDatasetSchemaTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunPublicDatasetSchemaTest.kt new file mode 100644 index 00000000..7ea688d4 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunPublicDatasetSchemaTest.kt @@ -0,0 +1,256 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.datasets.runs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.runs.RunTypeEnum +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunPublicDatasetSchemaTest { + + @Test + fun create() { + val runPublicDatasetSchema = + RunPublicDatasetSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dottedOrder("dotted_order") + .name("name") + .runType(RunTypeEnum.TOOL) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status("status") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost("completion_cost") + .completionCostDetails( + RunPublicDatasetSchema.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .completionTokenDetails( + RunPublicDatasetSchema.CompletionTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .completionTokens(0L) + .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error("error") + .addEvent(JsonValue.from(mapOf<String, Any>())) + .executionOrder(1L) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats( + RunPublicDatasetSchema.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf<String, Any>())) + .build() + ) + .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inputs(JsonValue.from(mapOf<String, Any>())) + .inputsPreview("inputs_preview") + .inputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .outputs(JsonValue.from(mapOf<String, Any>())) + .outputsPreview("outputs_preview") + .outputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .promptCost("prompt_cost") + .promptCostDetails( + RunPublicDatasetSchema.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .promptTokenDetails( + RunPublicDatasetSchema.PromptTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .promptTokens(0L) + .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .s3Urls(JsonValue.from(mapOf<String, Any>())) + .serialized(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTag("string") + .totalCost("total_cost") + .totalTokens(0L) + .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(runPublicDatasetSchema.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runPublicDatasetSchema.dottedOrder()).isEqualTo("dotted_order") + assertThat(runPublicDatasetSchema.name()).isEqualTo("name") + assertThat(runPublicDatasetSchema.runType()).isEqualTo(RunTypeEnum.TOOL) + assertThat(runPublicDatasetSchema.sessionId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runPublicDatasetSchema.status()).isEqualTo("status") + assertThat(runPublicDatasetSchema.traceId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runPublicDatasetSchema.childRunIds().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runPublicDatasetSchema.completionCost()).contains("completion_cost") + assertThat(runPublicDatasetSchema.completionCostDetails()) + .contains( + RunPublicDatasetSchema.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(runPublicDatasetSchema.completionTokenDetails()) + .contains( + RunPublicDatasetSchema.CompletionTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + assertThat(runPublicDatasetSchema.completionTokens()).contains(0L) + assertThat(runPublicDatasetSchema.directChildRunIds().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runPublicDatasetSchema.endTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runPublicDatasetSchema.error()).contains("error") + assertThat(runPublicDatasetSchema.events().getOrNull()) + .containsExactly(JsonValue.from(mapOf<String, Any>())) + assertThat(runPublicDatasetSchema.executionOrder()).contains(1L) + assertThat(runPublicDatasetSchema._extra()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(runPublicDatasetSchema.feedbackStats()) + .contains( + RunPublicDatasetSchema.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf<String, Any>())) + .build() + ) + assertThat(runPublicDatasetSchema.firstTokenTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runPublicDatasetSchema._inputs()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(runPublicDatasetSchema.inputsPreview()).contains("inputs_preview") + assertThat(runPublicDatasetSchema._inputsS3Urls()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(runPublicDatasetSchema.manifestId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runPublicDatasetSchema.manifestS3Id()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runPublicDatasetSchema._outputs()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(runPublicDatasetSchema.outputsPreview()).contains("outputs_preview") + assertThat(runPublicDatasetSchema._outputsS3Urls()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(runPublicDatasetSchema.parentRunId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runPublicDatasetSchema.parentRunIds().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runPublicDatasetSchema.priceModelId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runPublicDatasetSchema.promptCost()).contains("prompt_cost") + assertThat(runPublicDatasetSchema.promptCostDetails()) + .contains( + RunPublicDatasetSchema.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(runPublicDatasetSchema.promptTokenDetails()) + .contains( + RunPublicDatasetSchema.PromptTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + assertThat(runPublicDatasetSchema.promptTokens()).contains(0L) + assertThat(runPublicDatasetSchema.referenceExampleId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runPublicDatasetSchema._s3Urls()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(runPublicDatasetSchema._serialized()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(runPublicDatasetSchema.startTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runPublicDatasetSchema.tags().getOrNull()).containsExactly("string") + assertThat(runPublicDatasetSchema.totalCost()).contains("total_cost") + assertThat(runPublicDatasetSchema.totalTokens()).contains(0L) + assertThat(runPublicDatasetSchema.traceMaxStartTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runPublicDatasetSchema.traceMinStartTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val runPublicDatasetSchema = + RunPublicDatasetSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dottedOrder("dotted_order") + .name("name") + .runType(RunTypeEnum.TOOL) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status("status") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost("completion_cost") + .completionCostDetails( + RunPublicDatasetSchema.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .completionTokenDetails( + RunPublicDatasetSchema.CompletionTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .completionTokens(0L) + .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error("error") + .addEvent(JsonValue.from(mapOf<String, Any>())) + .executionOrder(1L) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats( + RunPublicDatasetSchema.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf<String, Any>())) + .build() + ) + .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inputs(JsonValue.from(mapOf<String, Any>())) + .inputsPreview("inputs_preview") + .inputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .outputs(JsonValue.from(mapOf<String, Any>())) + .outputsPreview("outputs_preview") + .outputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .promptCost("prompt_cost") + .promptCostDetails( + RunPublicDatasetSchema.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .promptTokenDetails( + RunPublicDatasetSchema.PromptTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .promptTokens(0L) + .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .s3Urls(JsonValue.from(mapOf<String, Any>())) + .serialized(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTag("string") + .totalCost("total_cost") + .totalTokens(0L) + .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedRunPublicDatasetSchema = + jsonMapper.readValue( + jsonMapper.writeValueAsString(runPublicDatasetSchema), + jacksonTypeRef<RunPublicDatasetSchema>(), + ) + + assertThat(roundtrippedRunPublicDatasetSchema).isEqualTo(runPublicDatasetSchema) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunQueryParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunQueryParamsTest.kt new file mode 100644 index 00000000..ef2b4bbe --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunQueryParamsTest.kt @@ -0,0 +1,142 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.datasets.runs + +import com.langsmith_api.api.models.api.v1.runs.BodyParamsForRunSchema +import com.langsmith_api.api.models.api.v1.runs.RunTypeEnum +import com.langsmith_api.api.models.api.v1.runs.RunsFilterDataSourceTypeEnum +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunQueryParamsTest { + + @Test + fun create() { + RunQueryParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .bodyParamsForRunSchema( + BodyParamsForRunSchema.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .dataSourceType(RunsFilterDataSourceTypeEnum.CURRENT) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .executionOrder(1L) + .filter("filter") + .isRoot(true) + .limit(1L) + .order(BodyParamsForRunSchema.Order.ASC) + .parentRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .query("query") + .addReferenceExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runType(RunTypeEnum.TOOL) + .searchFilter("search_filter") + .addSelect(BodyParamsForRunSchema.Select.ID) + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .skipPagination(true) + .skipPrevCursor(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .trace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .useExperimentalSearch(true) + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + RunQueryParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .bodyParamsForRunSchema(BodyParamsForRunSchema.builder().build()) + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + RunQueryParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .bodyParamsForRunSchema( + BodyParamsForRunSchema.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .dataSourceType(RunsFilterDataSourceTypeEnum.CURRENT) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .executionOrder(1L) + .filter("filter") + .isRoot(true) + .limit(1L) + .order(BodyParamsForRunSchema.Order.ASC) + .parentRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .query("query") + .addReferenceExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runType(RunTypeEnum.TOOL) + .searchFilter("search_filter") + .addSelect(BodyParamsForRunSchema.Select.ID) + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .skipPagination(true) + .skipPrevCursor(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .trace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .useExperimentalSearch(true) + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + BodyParamsForRunSchema.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .dataSourceType(RunsFilterDataSourceTypeEnum.CURRENT) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .executionOrder(1L) + .filter("filter") + .isRoot(true) + .limit(1L) + .order(BodyParamsForRunSchema.Order.ASC) + .parentRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .query("query") + .addReferenceExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runType(RunTypeEnum.TOOL) + .searchFilter("search_filter") + .addSelect(BodyParamsForRunSchema.Select.ID) + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .skipPagination(true) + .skipPrevCursor(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .trace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .useExperimentalSearch(true) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + RunQueryParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .bodyParamsForRunSchema(BodyParamsForRunSchema.builder().build()) + .build() + + val body = params._body() + + assertThat(body).isEqualTo(BodyParamsForRunSchema.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunQueryResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunQueryResponseTest.kt new file mode 100644 index 00000000..09bf2351 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunQueryResponseTest.kt @@ -0,0 +1,262 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.datasets.runs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.runs.RunTypeEnum +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunQueryResponseTest { + + @Test + fun create() { + val runQueryResponse = + RunQueryResponse.builder() + .cursors( + RunQueryResponse.Cursors.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addRun( + RunPublicDatasetSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dottedOrder("dotted_order") + .name("name") + .runType(RunTypeEnum.TOOL) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status("status") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost("completion_cost") + .completionCostDetails( + RunPublicDatasetSchema.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .completionTokenDetails( + RunPublicDatasetSchema.CompletionTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .completionTokens(0L) + .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error("error") + .addEvent(JsonValue.from(mapOf<String, Any>())) + .executionOrder(1L) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats( + RunPublicDatasetSchema.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf<String, Any>())) + .build() + ) + .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inputs(JsonValue.from(mapOf<String, Any>())) + .inputsPreview("inputs_preview") + .inputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .outputs(JsonValue.from(mapOf<String, Any>())) + .outputsPreview("outputs_preview") + .outputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .promptCost("prompt_cost") + .promptCostDetails( + RunPublicDatasetSchema.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .promptTokenDetails( + RunPublicDatasetSchema.PromptTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .promptTokens(0L) + .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .s3Urls(JsonValue.from(mapOf<String, Any>())) + .serialized(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTag("string") + .totalCost("total_cost") + .totalTokens(0L) + .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .parsedQuery("parsed_query") + .build() + + assertThat(runQueryResponse.cursors()) + .isEqualTo( + RunQueryResponse.Cursors.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(runQueryResponse.runs()) + .containsExactly( + RunPublicDatasetSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dottedOrder("dotted_order") + .name("name") + .runType(RunTypeEnum.TOOL) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status("status") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost("completion_cost") + .completionCostDetails( + RunPublicDatasetSchema.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .completionTokenDetails( + RunPublicDatasetSchema.CompletionTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .completionTokens(0L) + .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error("error") + .addEvent(JsonValue.from(mapOf<String, Any>())) + .executionOrder(1L) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats( + RunPublicDatasetSchema.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf<String, Any>())) + .build() + ) + .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inputs(JsonValue.from(mapOf<String, Any>())) + .inputsPreview("inputs_preview") + .inputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .outputs(JsonValue.from(mapOf<String, Any>())) + .outputsPreview("outputs_preview") + .outputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .promptCost("prompt_cost") + .promptCostDetails( + RunPublicDatasetSchema.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .promptTokenDetails( + RunPublicDatasetSchema.PromptTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .promptTokens(0L) + .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .s3Urls(JsonValue.from(mapOf<String, Any>())) + .serialized(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTag("string") + .totalCost("total_cost") + .totalTokens(0L) + .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(runQueryResponse.parsedQuery()).contains("parsed_query") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val runQueryResponse = + RunQueryResponse.builder() + .cursors( + RunQueryResponse.Cursors.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addRun( + RunPublicDatasetSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dottedOrder("dotted_order") + .name("name") + .runType(RunTypeEnum.TOOL) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status("status") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost("completion_cost") + .completionCostDetails( + RunPublicDatasetSchema.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .completionTokenDetails( + RunPublicDatasetSchema.CompletionTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .completionTokens(0L) + .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error("error") + .addEvent(JsonValue.from(mapOf<String, Any>())) + .executionOrder(1L) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats( + RunPublicDatasetSchema.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf<String, Any>())) + .build() + ) + .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inputs(JsonValue.from(mapOf<String, Any>())) + .inputsPreview("inputs_preview") + .inputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .outputs(JsonValue.from(mapOf<String, Any>())) + .outputsPreview("outputs_preview") + .outputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .promptCost("prompt_cost") + .promptCostDetails( + RunPublicDatasetSchema.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .promptTokenDetails( + RunPublicDatasetSchema.PromptTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .promptTokens(0L) + .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .s3Urls(JsonValue.from(mapOf<String, Any>())) + .serialized(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTag("string") + .totalCost("total_cost") + .totalTokens(0L) + .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .parsedQuery("parsed_query") + .build() + + val roundtrippedRunQueryResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(runQueryResponse), + jacksonTypeRef<RunQueryResponse>(), + ) + + assertThat(roundtrippedRunQueryResponse).isEqualTo(runQueryResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunRetrieveParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunRetrieveParamsTest.kt new file mode 100644 index 00000000..1bc87192 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunRetrieveParamsTest.kt @@ -0,0 +1,61 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.datasets.runs + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunRetrieveParamsTest { + + @Test + fun create() { + RunRetrieveParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .excludeS3StoredAttributes(true) + .build() + } + + @Test + fun pathParams() { + val params = + RunRetrieveParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._pathParam(1)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + RunRetrieveParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .excludeS3StoredAttributes(true) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("exclude_s3_stored_attributes", "true").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + RunRetrieveParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunStatsParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunStatsParamsTest.kt new file mode 100644 index 00000000..d498e460 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunStatsParamsTest.kt @@ -0,0 +1,155 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.datasets.runs + +import com.langsmith_api.api.models.api.v1.runs.RunStatsQueryParams +import com.langsmith_api.api.models.api.v1.runs.RunTypeEnum +import com.langsmith_api.api.models.api.v1.runs.RunsFilterDataSourceTypeEnum +import com.langsmith_api.api.models.api.v1.sessions.RunStatsGroupBy +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunStatsParamsTest { + + @Test + fun create() { + RunStatsParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runStatsQueryParams( + RunStatsQueryParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dataSourceType(RunsFilterDataSourceTypeEnum.CURRENT) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .executionOrder(1L) + .filter("filter") + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .addGroup("string") + .isRoot(true) + .parentRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .query("query") + .addReferenceExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runType(RunTypeEnum.TOOL) + .searchFilter("search_filter") + .addSelect(RunStatsQueryParams.Select.RUN_COUNT) + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .skipPagination(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .trace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .useExperimentalSearch(true) + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + RunStatsParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runStatsQueryParams(RunStatsQueryParams.builder().build()) + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + RunStatsParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runStatsQueryParams( + RunStatsQueryParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dataSourceType(RunsFilterDataSourceTypeEnum.CURRENT) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .executionOrder(1L) + .filter("filter") + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .addGroup("string") + .isRoot(true) + .parentRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .query("query") + .addReferenceExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runType(RunTypeEnum.TOOL) + .searchFilter("search_filter") + .addSelect(RunStatsQueryParams.Select.RUN_COUNT) + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .skipPagination(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .trace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .useExperimentalSearch(true) + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + RunStatsQueryParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dataSourceType(RunsFilterDataSourceTypeEnum.CURRENT) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .executionOrder(1L) + .filter("filter") + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .addGroup("string") + .isRoot(true) + .parentRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .query("query") + .addReferenceExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runType(RunTypeEnum.TOOL) + .searchFilter("search_filter") + .addSelect(RunStatsQueryParams.Select.RUN_COUNT) + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .skipPagination(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .trace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .useExperimentalSearch(true) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + RunStatsParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runStatsQueryParams(RunStatsQueryParams.builder().build()) + .build() + + val body = params._body() + + assertThat(body).isEqualTo(RunStatsQueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunStatsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunStatsTest.kt new file mode 100644 index 00000000..f4592cb1 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/datasets/runs/RunStatsTest.kt @@ -0,0 +1,126 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.datasets.runs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunStatsTest { + + @Test + fun create() { + val runStats = + RunStats.builder() + .completionCost("completion_cost") + .completionCostDetails(JsonValue.from(mapOf<String, Any>())) + .completionTokenDetails(JsonValue.from(mapOf<String, Any>())) + .completionTokens(0L) + .completionTokensP50(0L) + .completionTokensP99(0L) + .costP50("cost_p50") + .costP99("cost_p99") + .errorRate(0.0) + .feedbackStats(JsonValue.from(mapOf<String, Any>())) + .firstTokenP50(0.0) + .firstTokenP99(0.0) + .lastRunStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .latencyP50(0.0) + .latencyP99(0.0) + .medianTokens(0L) + .promptCost("prompt_cost") + .promptCostDetails(JsonValue.from(mapOf<String, Any>())) + .promptTokenDetails(JsonValue.from(mapOf<String, Any>())) + .promptTokens(0L) + .promptTokensP50(0L) + .promptTokensP99(0L) + .runCount(0L) + .addRunFacet(JsonValue.from(mapOf<String, Any>())) + .streamingRate(0.0) + .tokensP99(0L) + .totalCost("total_cost") + .totalTokens(0L) + .build() + + assertThat(runStats.completionCost()).contains("completion_cost") + assertThat(runStats._completionCostDetails()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(runStats._completionTokenDetails()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(runStats.completionTokens()).contains(0L) + assertThat(runStats.completionTokensP50()).contains(0L) + assertThat(runStats.completionTokensP99()).contains(0L) + assertThat(runStats.costP50()).contains("cost_p50") + assertThat(runStats.costP99()).contains("cost_p99") + assertThat(runStats.errorRate()).contains(0.0) + assertThat(runStats._feedbackStats()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(runStats.firstTokenP50()).contains(0.0) + assertThat(runStats.firstTokenP99()).contains(0.0) + assertThat(runStats.lastRunStartTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runStats.latencyP50()).contains(0.0) + assertThat(runStats.latencyP99()).contains(0.0) + assertThat(runStats.medianTokens()).contains(0L) + assertThat(runStats.promptCost()).contains("prompt_cost") + assertThat(runStats._promptCostDetails()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(runStats._promptTokenDetails()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(runStats.promptTokens()).contains(0L) + assertThat(runStats.promptTokensP50()).contains(0L) + assertThat(runStats.promptTokensP99()).contains(0L) + assertThat(runStats.runCount()).contains(0L) + assertThat(runStats.runFacets().getOrNull()) + .containsExactly(JsonValue.from(mapOf<String, Any>())) + assertThat(runStats.streamingRate()).contains(0.0) + assertThat(runStats.tokensP99()).contains(0L) + assertThat(runStats.totalCost()).contains("total_cost") + assertThat(runStats.totalTokens()).contains(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val runStats = + RunStats.builder() + .completionCost("completion_cost") + .completionCostDetails(JsonValue.from(mapOf<String, Any>())) + .completionTokenDetails(JsonValue.from(mapOf<String, Any>())) + .completionTokens(0L) + .completionTokensP50(0L) + .completionTokensP99(0L) + .costP50("cost_p50") + .costP99("cost_p99") + .errorRate(0.0) + .feedbackStats(JsonValue.from(mapOf<String, Any>())) + .firstTokenP50(0.0) + .firstTokenP99(0.0) + .lastRunStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .latencyP50(0.0) + .latencyP99(0.0) + .medianTokens(0L) + .promptCost("prompt_cost") + .promptCostDetails(JsonValue.from(mapOf<String, Any>())) + .promptTokenDetails(JsonValue.from(mapOf<String, Any>())) + .promptTokens(0L) + .promptTokensP50(0L) + .promptTokensP99(0L) + .runCount(0L) + .addRunFacet(JsonValue.from(mapOf<String, Any>())) + .streamingRate(0.0) + .tokensP99(0L) + .totalCost("total_cost") + .totalTokens(0L) + .build() + + val roundtrippedRunStats = + jsonMapper.readValue( + jsonMapper.writeValueAsString(runStats), + jacksonTypeRef<RunStats>(), + ) + + assertThat(roundtrippedRunStats).isEqualTo(runStats) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/examples/ExampleListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/examples/ExampleListParamsTest.kt new file mode 100644 index 00000000..80a77917 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/examples/ExampleListParamsTest.kt @@ -0,0 +1,76 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.examples + +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.models.api.v1.examples.ExampleSelect +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ExampleListParamsTest { + + @Test + fun create() { + ExampleListParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .limit(1L) + .metadata("metadata") + .offset(0L) + .addSelect(ExampleSelect.ID) + .build() + } + + @Test + fun pathParams() { + val params = + ExampleListParams.builder().shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + ExampleListParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .limit(1L) + .metadata("metadata") + .offset(0L) + .addSelect(ExampleSelect.ID) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").joinToString(",")) + .put("as_of", "2019-12-27T18:11:19.117Z") + .put("filter", "filter") + .put("limit", "1") + .put("metadata", "metadata") + .put("offset", "0") + .put("select", listOf("id").joinToString(",")) + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + ExampleListParams.builder().shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/examples/ExampleRetrieveCountParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/examples/ExampleRetrieveCountParamsTest.kt new file mode 100644 index 00000000..8f1ac284 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/examples/ExampleRetrieveCountParamsTest.kt @@ -0,0 +1,70 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.examples + +import com.langsmith_api.api.core.http.QueryParams +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ExampleRetrieveCountParamsTest { + + @Test + fun create() { + ExampleRetrieveCountParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .metadata("metadata") + .build() + } + + @Test + fun pathParams() { + val params = + ExampleRetrieveCountParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + ExampleRetrieveCountParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .metadata("metadata") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").joinToString(",")) + .put("as_of", "2019-12-27T18:11:19.117Z") + .put("filter", "filter") + .put("metadata", "metadata") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + ExampleRetrieveCountParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/examples/ExampleRunsParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/examples/ExampleRunsParamsTest.kt new file mode 100644 index 00000000..d67137e8 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/examples/ExampleRunsParamsTest.kt @@ -0,0 +1,132 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.examples + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.datasets.runs.QueryExampleSchemaWithRuns +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ExampleRunsParamsTest { + + @Test + fun create() { + ExampleRunsParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .queryExampleSchemaWithRuns( + QueryExampleSchemaWithRuns.builder() + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .filters( + QueryExampleSchemaWithRuns.Filters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + ) + .format(QueryExampleSchemaWithRuns.Format.CSV) + .limit(1L) + .offset(0L) + .preview(true) + .sortParams( + QueryExampleSchemaWithRuns.SortParams.builder() + .sortBy("sort_by") + .sortOrder(QueryExampleSchemaWithRuns.SortParams.SortOrder.ASC) + .build() + ) + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + ExampleRunsParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .queryExampleSchemaWithRuns( + QueryExampleSchemaWithRuns.builder() + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + ExampleRunsParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .queryExampleSchemaWithRuns( + QueryExampleSchemaWithRuns.builder() + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .filters( + QueryExampleSchemaWithRuns.Filters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + ) + .format(QueryExampleSchemaWithRuns.Format.CSV) + .limit(1L) + .offset(0L) + .preview(true) + .sortParams( + QueryExampleSchemaWithRuns.SortParams.builder() + .sortBy("sort_by") + .sortOrder(QueryExampleSchemaWithRuns.SortParams.SortOrder.ASC) + .build() + ) + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + QueryExampleSchemaWithRuns.builder() + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .filters( + QueryExampleSchemaWithRuns.Filters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + ) + .format(QueryExampleSchemaWithRuns.Format.CSV) + .limit(1L) + .offset(0L) + .preview(true) + .sortParams( + QueryExampleSchemaWithRuns.SortParams.builder() + .sortBy("sort_by") + .sortOrder(QueryExampleSchemaWithRuns.SortParams.SortOrder.ASC) + .build() + ) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + ExampleRunsParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .queryExampleSchemaWithRuns( + QueryExampleSchemaWithRuns.builder() + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + QueryExampleSchemaWithRuns.builder() + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/examples/ExampleRunsResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/examples/ExampleRunsResponseTest.kt new file mode 100644 index 00000000..d06ca770 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/examples/ExampleRunsResponseTest.kt @@ -0,0 +1,382 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.examples + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.datasets.runs.ExampleWithRunsCh +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunPublicDatasetSchema +import com.langsmith_api.api.models.api.v1.runs.RunTypeEnum +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class ExampleRunsResponseTest { + + @Test + fun ofPublicExampleWithRuns() { + val publicExampleWithRuns = + listOf( + ExampleRunsResponse.PublicExampleWithRun.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .name("name") + .addRun( + RunPublicDatasetSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dottedOrder("dotted_order") + .name("name") + .runType(RunTypeEnum.TOOL) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status("status") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost("completion_cost") + .completionCostDetails( + RunPublicDatasetSchema.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .completionTokenDetails( + RunPublicDatasetSchema.CompletionTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .completionTokens(0L) + .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error("error") + .addEvent(JsonValue.from(mapOf<String, Any>())) + .executionOrder(1L) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats( + RunPublicDatasetSchema.FeedbackStats.builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf<String, Any>()), + ) + .build() + ) + .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inputs(JsonValue.from(mapOf<String, Any>())) + .inputsPreview("inputs_preview") + .inputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .outputs(JsonValue.from(mapOf<String, Any>())) + .outputsPreview("outputs_preview") + .outputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .promptCost("prompt_cost") + .promptCostDetails( + RunPublicDatasetSchema.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .promptTokenDetails( + RunPublicDatasetSchema.PromptTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .promptTokens(0L) + .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .s3Urls(JsonValue.from(mapOf<String, Any>())) + .serialized(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTag("string") + .totalCost("total_cost") + .totalTokens(0L) + .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .attachmentUrls(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .metadata(JsonValue.from(mapOf<String, Any>())) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .outputs(JsonValue.from(mapOf<String, Any>())) + .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val exampleRunsResponse = ExampleRunsResponse.ofPublicExampleWithRuns(publicExampleWithRuns) + + assertThat(exampleRunsResponse.publicExampleWithRuns()).contains(publicExampleWithRuns) + assertThat(exampleRunsResponse.withRunsChes()).isEmpty + } + + @Test + fun ofPublicExampleWithRunsRoundtrip() { + val jsonMapper = jsonMapper() + val exampleRunsResponse = + ExampleRunsResponse.ofPublicExampleWithRuns( + listOf( + ExampleRunsResponse.PublicExampleWithRun.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .name("name") + .addRun( + RunPublicDatasetSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dottedOrder("dotted_order") + .name("name") + .runType(RunTypeEnum.TOOL) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status("status") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost("completion_cost") + .completionCostDetails( + RunPublicDatasetSchema.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .completionTokenDetails( + RunPublicDatasetSchema.CompletionTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .completionTokens(0L) + .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error("error") + .addEvent(JsonValue.from(mapOf<String, Any>())) + .executionOrder(1L) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats( + RunPublicDatasetSchema.FeedbackStats.builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf<String, Any>()), + ) + .build() + ) + .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inputs(JsonValue.from(mapOf<String, Any>())) + .inputsPreview("inputs_preview") + .inputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .outputs(JsonValue.from(mapOf<String, Any>())) + .outputsPreview("outputs_preview") + .outputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .promptCost("prompt_cost") + .promptCostDetails( + RunPublicDatasetSchema.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .promptTokenDetails( + RunPublicDatasetSchema.PromptTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .promptTokens(0L) + .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .s3Urls(JsonValue.from(mapOf<String, Any>())) + .serialized(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTag("string") + .totalCost("total_cost") + .totalTokens(0L) + .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .attachmentUrls(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .metadata(JsonValue.from(mapOf<String, Any>())) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .outputs(JsonValue.from(mapOf<String, Any>())) + .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + ) + + val roundtrippedExampleRunsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(exampleRunsResponse), + jacksonTypeRef<ExampleRunsResponse>(), + ) + + assertThat(roundtrippedExampleRunsResponse).isEqualTo(exampleRunsResponse) + } + + @Test + fun ofWithRunsChes() { + val withRunsChes = + listOf( + ExampleWithRunsCh.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .name("name") + .addRun( + ExampleWithRunsCh.Run.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .runType(RunTypeEnum.TOOL) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status("status") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .appPath("app_path") + .completionCost("completion_cost") + .completionTokens(0L) + .dottedOrder("dotted_order") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error("error") + .addEvent(JsonValue.from(mapOf<String, Any>())) + .executionOrder(1L) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats( + ExampleWithRunsCh.Run.FeedbackStats.builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf<String, Any>()), + ) + .build() + ) + .inputs(JsonValue.from(mapOf<String, Any>())) + .inputsPreview("inputs_preview") + .inputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .outputs(JsonValue.from(mapOf<String, Any>())) + .outputsPreview("outputs_preview") + .outputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .promptCost("prompt_cost") + .promptTokens(0L) + .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .s3Urls(JsonValue.from(mapOf<String, Any>())) + .serialized(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTag("string") + .totalCost("total_cost") + .totalTokens(0L) + .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .attachmentUrls(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .metadata(JsonValue.from(mapOf<String, Any>())) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .outputs(JsonValue.from(mapOf<String, Any>())) + .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val exampleRunsResponse = ExampleRunsResponse.ofWithRunsChes(withRunsChes) + + assertThat(exampleRunsResponse.publicExampleWithRuns()).isEmpty + assertThat(exampleRunsResponse.withRunsChes()).contains(withRunsChes) + } + + @Test + fun ofWithRunsChesRoundtrip() { + val jsonMapper = jsonMapper() + val exampleRunsResponse = + ExampleRunsResponse.ofWithRunsChes( + listOf( + ExampleWithRunsCh.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .name("name") + .addRun( + ExampleWithRunsCh.Run.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .runType(RunTypeEnum.TOOL) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status("status") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .appPath("app_path") + .completionCost("completion_cost") + .completionTokens(0L) + .dottedOrder("dotted_order") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error("error") + .addEvent(JsonValue.from(mapOf<String, Any>())) + .executionOrder(1L) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats( + ExampleWithRunsCh.Run.FeedbackStats.builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf<String, Any>()), + ) + .build() + ) + .inputs(JsonValue.from(mapOf<String, Any>())) + .inputsPreview("inputs_preview") + .inputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .outputs(JsonValue.from(mapOf<String, Any>())) + .outputsPreview("outputs_preview") + .outputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .promptCost("prompt_cost") + .promptTokens(0L) + .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .s3Urls(JsonValue.from(mapOf<String, Any>())) + .serialized(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTag("string") + .totalCost("total_cost") + .totalTokens(0L) + .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .attachmentUrls(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .metadata(JsonValue.from(mapOf<String, Any>())) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .outputs(JsonValue.from(mapOf<String, Any>())) + .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + ) + + val roundtrippedExampleRunsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(exampleRunsResponse), + jacksonTypeRef<ExampleRunsResponse>(), + ) + + assertThat(roundtrippedExampleRunsResponse).isEqualTo(exampleRunsResponse) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + OBJECT(JsonValue.from(mapOf("invalid" to "object"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val exampleRunsResponse = + jsonMapper().convertValue(testCase.value, jacksonTypeRef<ExampleRunsResponse>()) + + val e = assertThrows<LangsmithApiInvalidDataException> { exampleRunsResponse.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunListParamsTest.kt new file mode 100644 index 00000000..2154b0ec --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunListParamsTest.kt @@ -0,0 +1,52 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.runs + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunListParamsTest { + + @Test + fun create() { + RunListParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .excludeS3StoredAttributes(true) + .build() + } + + @Test + fun pathParams() { + val params = + RunListParams.builder().shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + RunListParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .excludeS3StoredAttributes(true) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("exclude_s3_stored_attributes", "true").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + RunListParams.builder().shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunPublicSchemaTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunPublicSchemaTest.kt new file mode 100644 index 00000000..7e4488d8 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunPublicSchemaTest.kt @@ -0,0 +1,243 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.runs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.runs.RunTypeEnum +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunPublicSchemaTest { + + @Test + fun create() { + val runPublicSchema = + RunPublicSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dottedOrder("dotted_order") + .name("name") + .runType(RunTypeEnum.TOOL) + .status("status") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost("completion_cost") + .completionCostDetails( + RunPublicSchema.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .completionTokenDetails( + RunPublicSchema.CompletionTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .completionTokens(0L) + .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error("error") + .addEvent(JsonValue.from(mapOf<String, Any>())) + .executionOrder(1L) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats( + RunPublicSchema.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf<String, Any>())) + .build() + ) + .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inputs(JsonValue.from(mapOf<String, Any>())) + .inputsPreview("inputs_preview") + .inputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .outputs(JsonValue.from(mapOf<String, Any>())) + .outputsPreview("outputs_preview") + .outputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .promptCost("prompt_cost") + .promptCostDetails( + RunPublicSchema.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .promptTokenDetails( + RunPublicSchema.PromptTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .promptTokens(0L) + .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .s3Urls(JsonValue.from(mapOf<String, Any>())) + .serialized(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTag("string") + .totalCost("total_cost") + .totalTokens(0L) + .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(runPublicSchema.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runPublicSchema.dottedOrder()).isEqualTo("dotted_order") + assertThat(runPublicSchema.name()).isEqualTo("name") + assertThat(runPublicSchema.runType()).isEqualTo(RunTypeEnum.TOOL) + assertThat(runPublicSchema.status()).isEqualTo("status") + assertThat(runPublicSchema.traceId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runPublicSchema.childRunIds().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runPublicSchema.completionCost()).contains("completion_cost") + assertThat(runPublicSchema.completionCostDetails()) + .contains( + RunPublicSchema.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(runPublicSchema.completionTokenDetails()) + .contains( + RunPublicSchema.CompletionTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + assertThat(runPublicSchema.completionTokens()).contains(0L) + assertThat(runPublicSchema.directChildRunIds().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runPublicSchema.endTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runPublicSchema.error()).contains("error") + assertThat(runPublicSchema.events().getOrNull()) + .containsExactly(JsonValue.from(mapOf<String, Any>())) + assertThat(runPublicSchema.executionOrder()).contains(1L) + assertThat(runPublicSchema._extra()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(runPublicSchema.feedbackStats()) + .contains( + RunPublicSchema.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf<String, Any>())) + .build() + ) + assertThat(runPublicSchema.firstTokenTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runPublicSchema._inputs()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(runPublicSchema.inputsPreview()).contains("inputs_preview") + assertThat(runPublicSchema._inputsS3Urls()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(runPublicSchema.manifestId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runPublicSchema.manifestS3Id()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runPublicSchema._outputs()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(runPublicSchema.outputsPreview()).contains("outputs_preview") + assertThat(runPublicSchema._outputsS3Urls()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(runPublicSchema.parentRunId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runPublicSchema.parentRunIds().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runPublicSchema.priceModelId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runPublicSchema.promptCost()).contains("prompt_cost") + assertThat(runPublicSchema.promptCostDetails()) + .contains( + RunPublicSchema.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(runPublicSchema.promptTokenDetails()) + .contains( + RunPublicSchema.PromptTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + assertThat(runPublicSchema.promptTokens()).contains(0L) + assertThat(runPublicSchema.referenceExampleId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runPublicSchema._s3Urls()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(runPublicSchema._serialized()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(runPublicSchema.startTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runPublicSchema.tags().getOrNull()).containsExactly("string") + assertThat(runPublicSchema.totalCost()).contains("total_cost") + assertThat(runPublicSchema.totalTokens()).contains(0L) + assertThat(runPublicSchema.traceMaxStartTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runPublicSchema.traceMinStartTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val runPublicSchema = + RunPublicSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dottedOrder("dotted_order") + .name("name") + .runType(RunTypeEnum.TOOL) + .status("status") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost("completion_cost") + .completionCostDetails( + RunPublicSchema.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .completionTokenDetails( + RunPublicSchema.CompletionTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .completionTokens(0L) + .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error("error") + .addEvent(JsonValue.from(mapOf<String, Any>())) + .executionOrder(1L) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats( + RunPublicSchema.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf<String, Any>())) + .build() + ) + .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inputs(JsonValue.from(mapOf<String, Any>())) + .inputsPreview("inputs_preview") + .inputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .outputs(JsonValue.from(mapOf<String, Any>())) + .outputsPreview("outputs_preview") + .outputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .promptCost("prompt_cost") + .promptCostDetails( + RunPublicSchema.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .promptTokenDetails( + RunPublicSchema.PromptTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .promptTokens(0L) + .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .s3Urls(JsonValue.from(mapOf<String, Any>())) + .serialized(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTag("string") + .totalCost("total_cost") + .totalTokens(0L) + .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedRunPublicSchema = + jsonMapper.readValue( + jsonMapper.writeValueAsString(runPublicSchema), + jacksonTypeRef<RunPublicSchema>(), + ) + + assertThat(roundtrippedRunPublicSchema).isEqualTo(runPublicSchema) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunQueryParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunQueryParamsTest.kt new file mode 100644 index 00000000..63a110fb --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunQueryParamsTest.kt @@ -0,0 +1,49 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.runs + +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunQueryParamsTest { + + @Test + fun create() { + RunQueryParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + RunQueryParams.builder().shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + RunQueryParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + + assertThat(body.id().getOrNull()).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + RunQueryParams.builder().shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + val body = params._body() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunQueryResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunQueryResponseTest.kt new file mode 100644 index 00000000..db98f10b --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunQueryResponseTest.kt @@ -0,0 +1,259 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.runs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.runs.RunTypeEnum +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunQueryResponseTest { + + @Test + fun create() { + val runQueryResponse = + RunQueryResponse.builder() + .cursors( + RunQueryResponse.Cursors.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addRun( + RunPublicSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dottedOrder("dotted_order") + .name("name") + .runType(RunTypeEnum.TOOL) + .status("status") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost("completion_cost") + .completionCostDetails( + RunPublicSchema.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .completionTokenDetails( + RunPublicSchema.CompletionTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .completionTokens(0L) + .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error("error") + .addEvent(JsonValue.from(mapOf<String, Any>())) + .executionOrder(1L) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats( + RunPublicSchema.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf<String, Any>())) + .build() + ) + .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inputs(JsonValue.from(mapOf<String, Any>())) + .inputsPreview("inputs_preview") + .inputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .outputs(JsonValue.from(mapOf<String, Any>())) + .outputsPreview("outputs_preview") + .outputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .promptCost("prompt_cost") + .promptCostDetails( + RunPublicSchema.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .promptTokenDetails( + RunPublicSchema.PromptTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .promptTokens(0L) + .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .s3Urls(JsonValue.from(mapOf<String, Any>())) + .serialized(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTag("string") + .totalCost("total_cost") + .totalTokens(0L) + .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .parsedQuery("parsed_query") + .build() + + assertThat(runQueryResponse.cursors()) + .isEqualTo( + RunQueryResponse.Cursors.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(runQueryResponse.runs()) + .containsExactly( + RunPublicSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dottedOrder("dotted_order") + .name("name") + .runType(RunTypeEnum.TOOL) + .status("status") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost("completion_cost") + .completionCostDetails( + RunPublicSchema.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .completionTokenDetails( + RunPublicSchema.CompletionTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .completionTokens(0L) + .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error("error") + .addEvent(JsonValue.from(mapOf<String, Any>())) + .executionOrder(1L) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats( + RunPublicSchema.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf<String, Any>())) + .build() + ) + .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inputs(JsonValue.from(mapOf<String, Any>())) + .inputsPreview("inputs_preview") + .inputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .outputs(JsonValue.from(mapOf<String, Any>())) + .outputsPreview("outputs_preview") + .outputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .promptCost("prompt_cost") + .promptCostDetails( + RunPublicSchema.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .promptTokenDetails( + RunPublicSchema.PromptTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .promptTokens(0L) + .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .s3Urls(JsonValue.from(mapOf<String, Any>())) + .serialized(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTag("string") + .totalCost("total_cost") + .totalTokens(0L) + .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(runQueryResponse.parsedQuery()).contains("parsed_query") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val runQueryResponse = + RunQueryResponse.builder() + .cursors( + RunQueryResponse.Cursors.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addRun( + RunPublicSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dottedOrder("dotted_order") + .name("name") + .runType(RunTypeEnum.TOOL) + .status("status") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost("completion_cost") + .completionCostDetails( + RunPublicSchema.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .completionTokenDetails( + RunPublicSchema.CompletionTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .completionTokens(0L) + .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error("error") + .addEvent(JsonValue.from(mapOf<String, Any>())) + .executionOrder(1L) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats( + RunPublicSchema.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf<String, Any>())) + .build() + ) + .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inputs(JsonValue.from(mapOf<String, Any>())) + .inputsPreview("inputs_preview") + .inputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .outputs(JsonValue.from(mapOf<String, Any>())) + .outputsPreview("outputs_preview") + .outputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .promptCost("prompt_cost") + .promptCostDetails( + RunPublicSchema.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .promptTokenDetails( + RunPublicSchema.PromptTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .promptTokens(0L) + .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .s3Urls(JsonValue.from(mapOf<String, Any>())) + .serialized(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTag("string") + .totalCost("total_cost") + .totalTokens(0L) + .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .parsedQuery("parsed_query") + .build() + + val roundtrippedRunQueryResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(runQueryResponse), + jacksonTypeRef<RunQueryResponse>(), + ) + + assertThat(roundtrippedRunQueryResponse).isEqualTo(runQueryResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunRetrieveParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunRetrieveParamsTest.kt new file mode 100644 index 00000000..150de831 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/runs/RunRetrieveParamsTest.kt @@ -0,0 +1,61 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.runs + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunRetrieveParamsTest { + + @Test + fun create() { + RunRetrieveParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .excludeS3StoredAttributes(true) + .build() + } + + @Test + fun pathParams() { + val params = + RunRetrieveParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._pathParam(1)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + RunRetrieveParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .excludeS3StoredAttributes(true) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("exclude_s3_stored_attributes", "true").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + RunRetrieveParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/schemas/SchemaRetrieveMessageJsonParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/schemas/SchemaRetrieveMessageJsonParamsTest.kt new file mode 100644 index 00000000..e7f40414 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/schemas/SchemaRetrieveMessageJsonParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.schemas + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SchemaRetrieveMessageJsonParamsTest { + + @Test + fun create() { + SchemaRetrieveMessageJsonParams.builder().version("version").build() + } + + @Test + fun pathParams() { + val params = SchemaRetrieveMessageJsonParams.builder().version("version").build() + + assertThat(params._pathParam(0)).isEqualTo("version") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/schemas/SchemaRetrieveMessageJsonResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/schemas/SchemaRetrieveMessageJsonResponseTest.kt new file mode 100644 index 00000000..a2932049 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/schemas/SchemaRetrieveMessageJsonResponseTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.schemas + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SchemaRetrieveMessageJsonResponseTest { + + @Test + fun create() { + val schemaRetrieveMessageJsonResponse = SchemaRetrieveMessageJsonResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val schemaRetrieveMessageJsonResponse = SchemaRetrieveMessageJsonResponse.builder().build() + + val roundtrippedSchemaRetrieveMessageJsonResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(schemaRetrieveMessageJsonResponse), + jacksonTypeRef<SchemaRetrieveMessageJsonResponse>(), + ) + + assertThat(roundtrippedSchemaRetrieveMessageJsonResponse) + .isEqualTo(schemaRetrieveMessageJsonResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/schemas/SchemaRetrieveTooldefJsonParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/schemas/SchemaRetrieveTooldefJsonParamsTest.kt new file mode 100644 index 00000000..31014374 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/schemas/SchemaRetrieveTooldefJsonParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.schemas + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SchemaRetrieveTooldefJsonParamsTest { + + @Test + fun create() { + SchemaRetrieveTooldefJsonParams.builder().version("version").build() + } + + @Test + fun pathParams() { + val params = SchemaRetrieveTooldefJsonParams.builder().version("version").build() + + assertThat(params._pathParam(0)).isEqualTo("version") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/schemas/SchemaRetrieveTooldefJsonResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/schemas/SchemaRetrieveTooldefJsonResponseTest.kt new file mode 100644 index 00000000..6ad058a5 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/public_/schemas/SchemaRetrieveTooldefJsonResponseTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.public_.schemas + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SchemaRetrieveTooldefJsonResponseTest { + + @Test + fun create() { + val schemaRetrieveTooldefJsonResponse = SchemaRetrieveTooldefJsonResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val schemaRetrieveTooldefJsonResponse = SchemaRetrieveTooldefJsonResponse.builder().build() + + val roundtrippedSchemaRetrieveTooldefJsonResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(schemaRetrieveTooldefJsonResponse), + jacksonTypeRef<SchemaRetrieveTooldefJsonResponse>(), + ) + + assertThat(roundtrippedSchemaRetrieveTooldefJsonResponse) + .isEqualTo(schemaRetrieveTooldefJsonResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/CreateRepoResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/CreateRepoResponseTest.kt new file mode 100644 index 00000000..16627c9c --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/CreateRepoResponseTest.kt @@ -0,0 +1,162 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.commits.CommitManifestResponse +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CreateRepoResponseTest { + + @Test + fun create() { + val createRepoResponse = + CreateRepoResponse.builder() + .repo( + RepoWithLookups.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .fullName("full_name") + .isArchived(true) + .isPublic(true) + .numCommits(0L) + .numDownloads(0L) + .numLikes(0L) + .numViews(0L) + .owner("owner") + .repoHandle("repo_handle") + .addTag("string") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .lastCommitHash("last_commit_hash") + .latestCommitManifest( + CommitManifestResponse.builder() + .commitHash("commit_hash") + .manifest(JsonValue.from(mapOf<String, Any>())) + .addExample( + CommitManifestResponse.Example.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .outputs(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + ) + .likedByAuthUser(true) + .originalRepoFullName("original_repo_full_name") + .originalRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readme("readme") + .upstreamRepoFullName("upstream_repo_full_name") + .upstreamRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + + assertThat(createRepoResponse.repo()) + .isEqualTo( + RepoWithLookups.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .fullName("full_name") + .isArchived(true) + .isPublic(true) + .numCommits(0L) + .numDownloads(0L) + .numLikes(0L) + .numViews(0L) + .owner("owner") + .repoHandle("repo_handle") + .addTag("string") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .lastCommitHash("last_commit_hash") + .latestCommitManifest( + CommitManifestResponse.builder() + .commitHash("commit_hash") + .manifest(JsonValue.from(mapOf<String, Any>())) + .addExample( + CommitManifestResponse.Example.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .outputs(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + ) + .likedByAuthUser(true) + .originalRepoFullName("original_repo_full_name") + .originalRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readme("readme") + .upstreamRepoFullName("upstream_repo_full_name") + .upstreamRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val createRepoResponse = + CreateRepoResponse.builder() + .repo( + RepoWithLookups.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .fullName("full_name") + .isArchived(true) + .isPublic(true) + .numCommits(0L) + .numDownloads(0L) + .numLikes(0L) + .numViews(0L) + .owner("owner") + .repoHandle("repo_handle") + .addTag("string") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .lastCommitHash("last_commit_hash") + .latestCommitManifest( + CommitManifestResponse.builder() + .commitHash("commit_hash") + .manifest(JsonValue.from(mapOf<String, Any>())) + .addExample( + CommitManifestResponse.Example.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .outputs(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + ) + .likedByAuthUser(true) + .originalRepoFullName("original_repo_full_name") + .originalRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readme("readme") + .upstreamRepoFullName("upstream_repo_full_name") + .upstreamRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + + val roundtrippedCreateRepoResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(createRepoResponse), + jacksonTypeRef<CreateRepoResponse>(), + ) + + assertThat(roundtrippedCreateRepoResponse).isEqualTo(createRepoResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/DemoConfigTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/DemoConfigTest.kt new file mode 100644 index 00000000..5f05bd67 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/DemoConfigTest.kt @@ -0,0 +1,48 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DemoConfigTest { + + @Test + fun create() { + val demoConfig = + DemoConfig.builder() + .addExample(JsonValue.from(mapOf<String, Any>())) + .messageIndex(0L) + .metaprompt(JsonValue.from(mapOf<String, Any>())) + .overallFeedback("overall_feedback") + .build() + + assertThat(demoConfig.examples()).containsExactly(JsonValue.from(mapOf<String, Any>())) + assertThat(demoConfig.messageIndex()).isEqualTo(0L) + assertThat(demoConfig._metaprompt()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(demoConfig.overallFeedback()).contains("overall_feedback") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val demoConfig = + DemoConfig.builder() + .addExample(JsonValue.from(mapOf<String, Any>())) + .messageIndex(0L) + .metaprompt(JsonValue.from(mapOf<String, Any>())) + .overallFeedback("overall_feedback") + .build() + + val roundtrippedDemoConfig = + jsonMapper.readValue( + jsonMapper.writeValueAsString(demoConfig), + jacksonTypeRef<DemoConfig>(), + ) + + assertThat(roundtrippedDemoConfig).isEqualTo(demoConfig) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/GetRepoResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/GetRepoResponseTest.kt new file mode 100644 index 00000000..9a43215d --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/GetRepoResponseTest.kt @@ -0,0 +1,162 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.commits.CommitManifestResponse +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class GetRepoResponseTest { + + @Test + fun create() { + val getRepoResponse = + GetRepoResponse.builder() + .repo( + RepoWithLookups.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .fullName("full_name") + .isArchived(true) + .isPublic(true) + .numCommits(0L) + .numDownloads(0L) + .numLikes(0L) + .numViews(0L) + .owner("owner") + .repoHandle("repo_handle") + .addTag("string") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .lastCommitHash("last_commit_hash") + .latestCommitManifest( + CommitManifestResponse.builder() + .commitHash("commit_hash") + .manifest(JsonValue.from(mapOf<String, Any>())) + .addExample( + CommitManifestResponse.Example.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .outputs(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + ) + .likedByAuthUser(true) + .originalRepoFullName("original_repo_full_name") + .originalRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readme("readme") + .upstreamRepoFullName("upstream_repo_full_name") + .upstreamRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + + assertThat(getRepoResponse.repo()) + .isEqualTo( + RepoWithLookups.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .fullName("full_name") + .isArchived(true) + .isPublic(true) + .numCommits(0L) + .numDownloads(0L) + .numLikes(0L) + .numViews(0L) + .owner("owner") + .repoHandle("repo_handle") + .addTag("string") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .lastCommitHash("last_commit_hash") + .latestCommitManifest( + CommitManifestResponse.builder() + .commitHash("commit_hash") + .manifest(JsonValue.from(mapOf<String, Any>())) + .addExample( + CommitManifestResponse.Example.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .outputs(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + ) + .likedByAuthUser(true) + .originalRepoFullName("original_repo_full_name") + .originalRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readme("readme") + .upstreamRepoFullName("upstream_repo_full_name") + .upstreamRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val getRepoResponse = + GetRepoResponse.builder() + .repo( + RepoWithLookups.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .fullName("full_name") + .isArchived(true) + .isPublic(true) + .numCommits(0L) + .numDownloads(0L) + .numLikes(0L) + .numViews(0L) + .owner("owner") + .repoHandle("repo_handle") + .addTag("string") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .lastCommitHash("last_commit_hash") + .latestCommitManifest( + CommitManifestResponse.builder() + .commitHash("commit_hash") + .manifest(JsonValue.from(mapOf<String, Any>())) + .addExample( + CommitManifestResponse.Example.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .outputs(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + ) + .likedByAuthUser(true) + .originalRepoFullName("original_repo_full_name") + .originalRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readme("readme") + .upstreamRepoFullName("upstream_repo_full_name") + .upstreamRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + + val roundtrippedGetRepoResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(getRepoResponse), + jacksonTypeRef<GetRepoResponse>(), + ) + + assertThat(roundtrippedGetRepoResponse).isEqualTo(getRepoResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/PromptimConfigTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/PromptimConfigTest.kt new file mode 100644 index 00000000..cd8f182d --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/PromptimConfigTest.kt @@ -0,0 +1,63 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PromptimConfigTest { + + @Test + fun create() { + val promptimConfig = + PromptimConfig.builder() + .autoCommit(true) + .datasetName("dataset_name") + .devSplit("dev_split") + .addEvaluator("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .messageIndex(0L) + .numEpochs(0L) + .taskDescription("task_description") + .testSplit("test_split") + .trainSplit("train_split") + .build() + + assertThat(promptimConfig.autoCommit()).isEqualTo(true) + assertThat(promptimConfig.datasetName()).isEqualTo("dataset_name") + assertThat(promptimConfig.devSplit()).contains("dev_split") + assertThat(promptimConfig.evaluators()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(promptimConfig.messageIndex()).isEqualTo(0L) + assertThat(promptimConfig.numEpochs()).isEqualTo(0L) + assertThat(promptimConfig.taskDescription()).isEqualTo("task_description") + assertThat(promptimConfig.testSplit()).contains("test_split") + assertThat(promptimConfig.trainSplit()).contains("train_split") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val promptimConfig = + PromptimConfig.builder() + .autoCommit(true) + .datasetName("dataset_name") + .devSplit("dev_split") + .addEvaluator("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .messageIndex(0L) + .numEpochs(0L) + .taskDescription("task_description") + .testSplit("test_split") + .trainSplit("train_split") + .build() + + val roundtrippedPromptimConfig = + jsonMapper.readValue( + jsonMapper.writeValueAsString(promptimConfig), + jacksonTypeRef<PromptimConfig>(), + ) + + assertThat(roundtrippedPromptimConfig).isEqualTo(promptimConfig) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoCreateParamsTest.kt new file mode 100644 index 00000000..60616982 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoCreateParamsTest.kt @@ -0,0 +1,51 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos + +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RepoCreateParamsTest { + + @Test + fun create() { + RepoCreateParams.builder() + .isPublic(true) + .repoHandle("repo_handle") + .description("description") + .readme("readme") + .addTag("string") + .build() + } + + @Test + fun body() { + val params = + RepoCreateParams.builder() + .isPublic(true) + .repoHandle("repo_handle") + .description("description") + .readme("readme") + .addTag("string") + .build() + + val body = params._body() + + assertThat(body.isPublic()).isEqualTo(true) + assertThat(body.repoHandle()).isEqualTo("repo_handle") + assertThat(body.description()).contains("description") + assertThat(body.readme()).contains("readme") + assertThat(body.tags().getOrNull()).containsExactly("string") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = RepoCreateParams.builder().isPublic(true).repoHandle("repo_handle").build() + + val body = params._body() + + assertThat(body.isPublic()).isEqualTo(true) + assertThat(body.repoHandle()).isEqualTo("repo_handle") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoDeleteParamsTest.kt new file mode 100644 index 00000000..5eb6544f --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoDeleteParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RepoDeleteParamsTest { + + @Test + fun create() { + RepoDeleteParams.builder().owner("owner").repo("repo").build() + } + + @Test + fun pathParams() { + val params = RepoDeleteParams.builder().owner("owner").repo("repo").build() + + assertThat(params._pathParam(0)).isEqualTo("owner") + assertThat(params._pathParam(1)).isEqualTo("repo") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoDeleteResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoDeleteResponseTest.kt new file mode 100644 index 00000000..1f8d6c88 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoDeleteResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RepoDeleteResponseTest { + + @Test + fun create() { + val repoDeleteResponse = RepoDeleteResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val repoDeleteResponse = RepoDeleteResponse.builder().build() + + val roundtrippedRepoDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(repoDeleteResponse), + jacksonTypeRef<RepoDeleteResponse>(), + ) + + assertThat(roundtrippedRepoDeleteResponse).isEqualTo(repoDeleteResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoForkParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoForkParamsTest.kt new file mode 100644 index 00000000..5883caea --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoForkParamsTest.kt @@ -0,0 +1,66 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos + +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RepoForkParamsTest { + + @Test + fun create() { + RepoForkParams.builder() + .owner("owner") + .repo("repo") + .repoHandle("repo_handle") + .description("description") + .isPublic(true) + .readme("readme") + .addTag("string") + .build() + } + + @Test + fun pathParams() { + val params = + RepoForkParams.builder().owner("owner").repo("repo").repoHandle("repo_handle").build() + + assertThat(params._pathParam(0)).isEqualTo("owner") + assertThat(params._pathParam(1)).isEqualTo("repo") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } + + @Test + fun body() { + val params = + RepoForkParams.builder() + .owner("owner") + .repo("repo") + .repoHandle("repo_handle") + .description("description") + .isPublic(true) + .readme("readme") + .addTag("string") + .build() + + val body = params._body() + + assertThat(body.repoHandle()).isEqualTo("repo_handle") + assertThat(body.description()).contains("description") + assertThat(body.isPublic()).contains(true) + assertThat(body.readme()).contains("readme") + assertThat(body.tags().getOrNull()).containsExactly("string") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + RepoForkParams.builder().owner("owner").repo("repo").repoHandle("repo_handle").build() + + val body = params._body() + + assertThat(body.repoHandle()).isEqualTo("repo_handle") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoListParamsTest.kt new file mode 100644 index 00000000..5ce4ca42 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoListParamsTest.kt @@ -0,0 +1,88 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RepoListParamsTest { + + @Test + fun create() { + RepoListParams.builder() + .hasCommits(true) + .isArchived(RepoListParams.IsArchived.TRUE) + .isPublic(RepoListParams.IsPublic.TRUE) + .limit(1L) + .offset(0L) + .query("query") + .sortDirection(RepoListParams.SortDirection.ASC) + .sortField(RepoListParams.SortField.NUM_LIKES) + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addTag("string") + .tenantHandle("tenant_handle") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .upstreamRepoHandle("upstream_repo_handle") + .upstreamRepoOwner("upstream_repo_owner") + .withLatestManifest(true) + .build() + } + + @Test + fun queryParams() { + val params = + RepoListParams.builder() + .hasCommits(true) + .isArchived(RepoListParams.IsArchived.TRUE) + .isPublic(RepoListParams.IsPublic.TRUE) + .limit(1L) + .offset(0L) + .query("query") + .sortDirection(RepoListParams.SortDirection.ASC) + .sortField(RepoListParams.SortField.NUM_LIKES) + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addTag("string") + .tenantHandle("tenant_handle") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .upstreamRepoHandle("upstream_repo_handle") + .upstreamRepoOwner("upstream_repo_owner") + .withLatestManifest(true) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("has_commits", "true") + .put("is_archived", "true") + .put("is_public", "true") + .put("limit", "1") + .put("offset", "0") + .put("query", "query") + .put("sort_direction", "asc") + .put("sort_field", "num_likes") + .put( + "tag_value_id", + listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").joinToString(","), + ) + .put("tags", listOf("string").joinToString(",")) + .put("tenant_handle", "tenant_handle") + .put("tenant_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("upstream_repo_handle", "upstream_repo_handle") + .put("upstream_repo_owner", "upstream_repo_owner") + .put("with_latest_manifest", "true") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = RepoListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoListResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoListResponseTest.kt new file mode 100644 index 00000000..49872203 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoListResponseTest.kt @@ -0,0 +1,165 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.commits.CommitManifestResponse +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RepoListResponseTest { + + @Test + fun create() { + val repoListResponse = + RepoListResponse.builder() + .addRepo( + RepoWithLookups.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .fullName("full_name") + .isArchived(true) + .isPublic(true) + .numCommits(0L) + .numDownloads(0L) + .numLikes(0L) + .numViews(0L) + .owner("owner") + .repoHandle("repo_handle") + .addTag("string") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .lastCommitHash("last_commit_hash") + .latestCommitManifest( + CommitManifestResponse.builder() + .commitHash("commit_hash") + .manifest(JsonValue.from(mapOf<String, Any>())) + .addExample( + CommitManifestResponse.Example.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .outputs(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + ) + .likedByAuthUser(true) + .originalRepoFullName("original_repo_full_name") + .originalRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readme("readme") + .upstreamRepoFullName("upstream_repo_full_name") + .upstreamRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .total(0L) + .build() + + assertThat(repoListResponse.repos()) + .containsExactly( + RepoWithLookups.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .fullName("full_name") + .isArchived(true) + .isPublic(true) + .numCommits(0L) + .numDownloads(0L) + .numLikes(0L) + .numViews(0L) + .owner("owner") + .repoHandle("repo_handle") + .addTag("string") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .lastCommitHash("last_commit_hash") + .latestCommitManifest( + CommitManifestResponse.builder() + .commitHash("commit_hash") + .manifest(JsonValue.from(mapOf<String, Any>())) + .addExample( + CommitManifestResponse.Example.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .outputs(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + ) + .likedByAuthUser(true) + .originalRepoFullName("original_repo_full_name") + .originalRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readme("readme") + .upstreamRepoFullName("upstream_repo_full_name") + .upstreamRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + assertThat(repoListResponse.total()).isEqualTo(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val repoListResponse = + RepoListResponse.builder() + .addRepo( + RepoWithLookups.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .fullName("full_name") + .isArchived(true) + .isPublic(true) + .numCommits(0L) + .numDownloads(0L) + .numLikes(0L) + .numViews(0L) + .owner("owner") + .repoHandle("repo_handle") + .addTag("string") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .lastCommitHash("last_commit_hash") + .latestCommitManifest( + CommitManifestResponse.builder() + .commitHash("commit_hash") + .manifest(JsonValue.from(mapOf<String, Any>())) + .addExample( + CommitManifestResponse.Example.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .outputs(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + ) + .likedByAuthUser(true) + .originalRepoFullName("original_repo_full_name") + .originalRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readme("readme") + .upstreamRepoFullName("upstream_repo_full_name") + .upstreamRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .total(0L) + .build() + + val roundtrippedRepoListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(repoListResponse), + jacksonTypeRef<RepoListResponse>(), + ) + + assertThat(roundtrippedRepoListResponse).isEqualTo(repoListResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoOptimizeJobParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoOptimizeJobParamsTest.kt new file mode 100644 index 00000000..b5b532c3 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoOptimizeJobParamsTest.kt @@ -0,0 +1,73 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RepoOptimizeJobParamsTest { + + @Test + fun create() { + RepoOptimizeJobParams.builder() + .algorithm(EPromptOptimizationAlgorithm.PROMPTIM) + .config( + PromptimConfig.builder() + .autoCommit(true) + .datasetName("dataset_name") + .devSplit("dev_split") + .addEvaluator("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .messageIndex(0L) + .numEpochs(0L) + .taskDescription("task_description") + .testSplit("test_split") + .trainSplit("train_split") + .build() + ) + .promptName("prompt_name") + .build() + } + + @Test + fun body() { + val params = + RepoOptimizeJobParams.builder() + .algorithm(EPromptOptimizationAlgorithm.PROMPTIM) + .config( + PromptimConfig.builder() + .autoCommit(true) + .datasetName("dataset_name") + .devSplit("dev_split") + .addEvaluator("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .messageIndex(0L) + .numEpochs(0L) + .taskDescription("task_description") + .testSplit("test_split") + .trainSplit("train_split") + .build() + ) + .promptName("prompt_name") + .build() + + val body = params._body() + + assertThat(body.algorithm()).isEqualTo(EPromptOptimizationAlgorithm.PROMPTIM) + assertThat(body.config()) + .isEqualTo( + RepoOptimizeJobParams.Config.ofPromptim( + PromptimConfig.builder() + .autoCommit(true) + .datasetName("dataset_name") + .devSplit("dev_split") + .addEvaluator("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .messageIndex(0L) + .numEpochs(0L) + .taskDescription("task_description") + .testSplit("test_split") + .trainSplit("train_split") + .build() + ) + ) + assertThat(body.promptName()).isEqualTo("prompt_name") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoOptimizeJobResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoOptimizeJobResponseTest.kt new file mode 100644 index 00000000..b4d434df --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoOptimizeJobResponseTest.kt @@ -0,0 +1,39 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RepoOptimizeJobResponseTest { + + @Test + fun create() { + val repoOptimizeJobResponse = + RepoOptimizeJobResponse.builder() + .optimizationJobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(repoOptimizeJobResponse.optimizationJobId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val repoOptimizeJobResponse = + RepoOptimizeJobResponse.builder() + .optimizationJobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val roundtrippedRepoOptimizeJobResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(repoOptimizeJobResponse), + jacksonTypeRef<RepoOptimizeJobResponse>(), + ) + + assertThat(roundtrippedRepoOptimizeJobResponse).isEqualTo(repoOptimizeJobResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoRetrieveParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoRetrieveParamsTest.kt new file mode 100644 index 00000000..0d4a0bd1 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoRetrieveParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RepoRetrieveParamsTest { + + @Test + fun create() { + RepoRetrieveParams.builder().owner("owner").repo("repo").build() + } + + @Test + fun pathParams() { + val params = RepoRetrieveParams.builder().owner("owner").repo("repo").build() + + assertThat(params._pathParam(0)).isEqualTo("owner") + assertThat(params._pathParam(1)).isEqualTo("repo") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoUpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoUpdateParamsTest.kt new file mode 100644 index 00000000..2ae245d7 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoUpdateParamsTest.kt @@ -0,0 +1,62 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos + +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RepoUpdateParamsTest { + + @Test + fun create() { + RepoUpdateParams.builder() + .owner("owner") + .repo("repo") + .description("description") + .isArchived(true) + .isPublic(true) + .readme("readme") + .addTag("string") + .build() + } + + @Test + fun pathParams() { + val params = RepoUpdateParams.builder().owner("owner").repo("repo").build() + + assertThat(params._pathParam(0)).isEqualTo("owner") + assertThat(params._pathParam(1)).isEqualTo("repo") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } + + @Test + fun body() { + val params = + RepoUpdateParams.builder() + .owner("owner") + .repo("repo") + .description("description") + .isArchived(true) + .isPublic(true) + .readme("readme") + .addTag("string") + .build() + + val body = params._body() + + assertThat(body.description()).contains("description") + assertThat(body.isArchived()).contains(true) + assertThat(body.isPublic()).contains(true) + assertThat(body.readme()).contains("readme") + assertThat(body.tags().getOrNull()).containsExactly("string") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = RepoUpdateParams.builder().owner("owner").repo("repo").build() + + val body = params._body() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoWithLookupsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoWithLookupsTest.kt new file mode 100644 index 00000000..46b83fc2 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/RepoWithLookupsTest.kt @@ -0,0 +1,154 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.commits.CommitManifestResponse +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RepoWithLookupsTest { + + @Test + fun create() { + val repoWithLookups = + RepoWithLookups.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .fullName("full_name") + .isArchived(true) + .isPublic(true) + .numCommits(0L) + .numDownloads(0L) + .numLikes(0L) + .numViews(0L) + .owner("owner") + .repoHandle("repo_handle") + .addTag("string") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .lastCommitHash("last_commit_hash") + .latestCommitManifest( + CommitManifestResponse.builder() + .commitHash("commit_hash") + .manifest(JsonValue.from(mapOf<String, Any>())) + .addExample( + CommitManifestResponse.Example.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .outputs(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + ) + .likedByAuthUser(true) + .originalRepoFullName("original_repo_full_name") + .originalRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readme("readme") + .upstreamRepoFullName("upstream_repo_full_name") + .upstreamRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(repoWithLookups.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(repoWithLookups.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(repoWithLookups.fullName()).isEqualTo("full_name") + assertThat(repoWithLookups.isArchived()).isEqualTo(true) + assertThat(repoWithLookups.isPublic()).isEqualTo(true) + assertThat(repoWithLookups.numCommits()).isEqualTo(0L) + assertThat(repoWithLookups.numDownloads()).isEqualTo(0L) + assertThat(repoWithLookups.numLikes()).isEqualTo(0L) + assertThat(repoWithLookups.numViews()).isEqualTo(0L) + assertThat(repoWithLookups.owner()).contains("owner") + assertThat(repoWithLookups.repoHandle()).isEqualTo("repo_handle") + assertThat(repoWithLookups.tags()).containsExactly("string") + assertThat(repoWithLookups.tenantId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(repoWithLookups.updatedAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(repoWithLookups.description()).contains("description") + assertThat(repoWithLookups.lastCommitHash()).contains("last_commit_hash") + assertThat(repoWithLookups.latestCommitManifest()) + .contains( + CommitManifestResponse.builder() + .commitHash("commit_hash") + .manifest(JsonValue.from(mapOf<String, Any>())) + .addExample( + CommitManifestResponse.Example.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .outputs(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + ) + assertThat(repoWithLookups.likedByAuthUser()).contains(true) + assertThat(repoWithLookups.originalRepoFullName()).contains("original_repo_full_name") + assertThat(repoWithLookups.originalRepoId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(repoWithLookups.readme()).contains("readme") + assertThat(repoWithLookups.upstreamRepoFullName()).contains("upstream_repo_full_name") + assertThat(repoWithLookups.upstreamRepoId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val repoWithLookups = + RepoWithLookups.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .fullName("full_name") + .isArchived(true) + .isPublic(true) + .numCommits(0L) + .numDownloads(0L) + .numLikes(0L) + .numViews(0L) + .owner("owner") + .repoHandle("repo_handle") + .addTag("string") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .lastCommitHash("last_commit_hash") + .latestCommitManifest( + CommitManifestResponse.builder() + .commitHash("commit_hash") + .manifest(JsonValue.from(mapOf<String, Any>())) + .addExample( + CommitManifestResponse.Example.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .outputs(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + ) + .likedByAuthUser(true) + .originalRepoFullName("original_repo_full_name") + .originalRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readme("readme") + .upstreamRepoFullName("upstream_repo_full_name") + .upstreamRepoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val roundtrippedRepoWithLookups = + jsonMapper.readValue( + jsonMapper.writeValueAsString(repoWithLookups), + jacksonTypeRef<RepoWithLookups>(), + ) + + assertThat(roundtrippedRepoWithLookups).isEqualTo(repoWithLookups) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobDeleteParamsTest.kt new file mode 100644 index 00000000..5a561342 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobDeleteParamsTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.optimizationjobs + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OptimizationJobDeleteParamsTest { + + @Test + fun create() { + OptimizationJobDeleteParams.builder() + .owner("owner") + .repo("repo") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + OptimizationJobDeleteParams.builder() + .owner("owner") + .repo("repo") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("owner") + assertThat(params._pathParam(1)).isEqualTo("repo") + assertThat(params._pathParam(2)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(3)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobDeleteResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobDeleteResponseTest.kt new file mode 100644 index 00000000..951e42fc --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobDeleteResponseTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.optimizationjobs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OptimizationJobDeleteResponseTest { + + @Test + fun create() { + val optimizationJobDeleteResponse = OptimizationJobDeleteResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val optimizationJobDeleteResponse = OptimizationJobDeleteResponse.builder().build() + + val roundtrippedOptimizationJobDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(optimizationJobDeleteResponse), + jacksonTypeRef<OptimizationJobDeleteResponse>(), + ) + + assertThat(roundtrippedOptimizationJobDeleteResponse) + .isEqualTo(optimizationJobDeleteResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobOptimizationJobsParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobOptimizationJobsParamsTest.kt new file mode 100644 index 00000000..e8da10a5 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobOptimizationJobsParamsTest.kt @@ -0,0 +1,104 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.optimizationjobs + +import com.langsmith_api.api.models.api.v1.repos.EPromptOptimizationAlgorithm +import com.langsmith_api.api.models.api.v1.repos.PromptimConfig +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OptimizationJobOptimizationJobsParamsTest { + + @Test + fun create() { + OptimizationJobOptimizationJobsParams.builder() + .owner("owner") + .repo("repo") + .algorithm(EPromptOptimizationAlgorithm.PROMPTIM) + .config( + PromptimConfig.builder() + .autoCommit(true) + .datasetName("dataset_name") + .devSplit("dev_split") + .addEvaluator("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .messageIndex(0L) + .numEpochs(0L) + .taskDescription("task_description") + .testSplit("test_split") + .trainSplit("train_split") + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + OptimizationJobOptimizationJobsParams.builder() + .owner("owner") + .repo("repo") + .algorithm(EPromptOptimizationAlgorithm.PROMPTIM) + .config( + PromptimConfig.builder() + .autoCommit(true) + .datasetName("dataset_name") + .devSplit("dev_split") + .addEvaluator("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .messageIndex(0L) + .numEpochs(0L) + .taskDescription("task_description") + .testSplit("test_split") + .trainSplit("train_split") + .build() + ) + .build() + + assertThat(params._pathParam(0)).isEqualTo("owner") + assertThat(params._pathParam(1)).isEqualTo("repo") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } + + @Test + fun body() { + val params = + OptimizationJobOptimizationJobsParams.builder() + .owner("owner") + .repo("repo") + .algorithm(EPromptOptimizationAlgorithm.PROMPTIM) + .config( + PromptimConfig.builder() + .autoCommit(true) + .datasetName("dataset_name") + .devSplit("dev_split") + .addEvaluator("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .messageIndex(0L) + .numEpochs(0L) + .taskDescription("task_description") + .testSplit("test_split") + .trainSplit("train_split") + .build() + ) + .build() + + val body = params._body() + + assertThat(body.algorithm()).isEqualTo(EPromptOptimizationAlgorithm.PROMPTIM) + assertThat(body.config()) + .isEqualTo( + OptimizationJobOptimizationJobsParams.Config.ofPromptim( + PromptimConfig.builder() + .autoCommit(true) + .datasetName("dataset_name") + .devSplit("dev_split") + .addEvaluator("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .messageIndex(0L) + .numEpochs(0L) + .taskDescription("task_description") + .testSplit("test_split") + .trainSplit("train_split") + .build() + ) + ) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobRetrieveOptimizationJobsParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobRetrieveOptimizationJobsParamsTest.kt new file mode 100644 index 00000000..e6d147ce --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobRetrieveOptimizationJobsParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.optimizationjobs + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OptimizationJobRetrieveOptimizationJobsParamsTest { + + @Test + fun create() { + OptimizationJobRetrieveOptimizationJobsParams.builder().owner("owner").repo("repo").build() + } + + @Test + fun pathParams() { + val params = + OptimizationJobRetrieveOptimizationJobsParams.builder() + .owner("owner") + .repo("repo") + .build() + + assertThat(params._pathParam(0)).isEqualTo("owner") + assertThat(params._pathParam(1)).isEqualTo("repo") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobRetrieveParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobRetrieveParamsTest.kt new file mode 100644 index 00000000..59a8ab6e --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobRetrieveParamsTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.optimizationjobs + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OptimizationJobRetrieveParamsTest { + + @Test + fun create() { + OptimizationJobRetrieveParams.builder() + .owner("owner") + .repo("repo") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + OptimizationJobRetrieveParams.builder() + .owner("owner") + .repo("repo") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("owner") + assertThat(params._pathParam(1)).isEqualTo("repo") + assertThat(params._pathParam(2)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(3)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobRetrieveResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobRetrieveResponseTest.kt new file mode 100644 index 00000000..4e8c309e --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobRetrieveResponseTest.kt @@ -0,0 +1,166 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.optimizationjobs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.repos.EPromptOptimizationAlgorithm +import com.langsmith_api.api.models.api.v1.repos.PromptimConfig +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs.EPromptOptimizationJobLogType +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs.PromptOptimizationJobLog +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OptimizationJobRetrieveResponseTest { + + @Test + fun create() { + val optimizationJobRetrieveResponse = + OptimizationJobRetrieveResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .algorithm(EPromptOptimizationAlgorithm.PROMPTIM) + .config( + PromptimConfig.builder() + .autoCommit(true) + .datasetName("dataset_name") + .devSplit("dev_split") + .addEvaluator("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .messageIndex(0L) + .numEpochs(0L) + .taskDescription("task_description") + .testSplit("test_split") + .trainSplit("train_split") + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLog( + PromptOptimizationJobLog.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .logType(EPromptOptimizationJobLogType.INFO) + .message("message") + .data(JsonValue.from(mapOf<String, Any>())) + .build() + ) + .repoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status(EPromptOptimizationJobStatus.CREATED) + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addResult( + PromptOptimizationResult.builder() + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .x(0.0) + .y(0.0) + .build() + ) + .build() + + assertThat(optimizationJobRetrieveResponse.id()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(optimizationJobRetrieveResponse.algorithm()) + .isEqualTo(EPromptOptimizationAlgorithm.PROMPTIM) + assertThat(optimizationJobRetrieveResponse.config()) + .isEqualTo( + OptimizationJobRetrieveResponse.Config.ofPromptim( + PromptimConfig.builder() + .autoCommit(true) + .datasetName("dataset_name") + .devSplit("dev_split") + .addEvaluator("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .messageIndex(0L) + .numEpochs(0L) + .taskDescription("task_description") + .testSplit("test_split") + .trainSplit("train_split") + .build() + ) + ) + assertThat(optimizationJobRetrieveResponse.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(optimizationJobRetrieveResponse.logs()) + .containsExactly( + PromptOptimizationJobLog.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .logType(EPromptOptimizationJobLogType.INFO) + .message("message") + .data(JsonValue.from(mapOf<String, Any>())) + .build() + ) + assertThat(optimizationJobRetrieveResponse.repoId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(optimizationJobRetrieveResponse.status()) + .isEqualTo(EPromptOptimizationJobStatus.CREATED) + assertThat(optimizationJobRetrieveResponse.tenantId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(optimizationJobRetrieveResponse.updatedAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(optimizationJobRetrieveResponse.results().getOrNull()) + .containsExactly( + PromptOptimizationResult.builder() + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .x(0.0) + .y(0.0) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val optimizationJobRetrieveResponse = + OptimizationJobRetrieveResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .algorithm(EPromptOptimizationAlgorithm.PROMPTIM) + .config( + PromptimConfig.builder() + .autoCommit(true) + .datasetName("dataset_name") + .devSplit("dev_split") + .addEvaluator("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .messageIndex(0L) + .numEpochs(0L) + .taskDescription("task_description") + .testSplit("test_split") + .trainSplit("train_split") + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLog( + PromptOptimizationJobLog.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .logType(EPromptOptimizationJobLogType.INFO) + .message("message") + .data(JsonValue.from(mapOf<String, Any>())) + .build() + ) + .repoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status(EPromptOptimizationJobStatus.CREATED) + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addResult( + PromptOptimizationResult.builder() + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .x(0.0) + .y(0.0) + .build() + ) + .build() + + val roundtrippedOptimizationJobRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(optimizationJobRetrieveResponse), + jacksonTypeRef<OptimizationJobRetrieveResponse>(), + ) + + assertThat(roundtrippedOptimizationJobRetrieveResponse) + .isEqualTo(optimizationJobRetrieveResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobUpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobUpdateParamsTest.kt new file mode 100644 index 00000000..db51baa0 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/OptimizationJobUpdateParamsTest.kt @@ -0,0 +1,85 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.optimizationjobs + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OptimizationJobUpdateParamsTest { + + @Test + fun create() { + OptimizationJobUpdateParams.builder() + .owner("owner") + .repo("repo") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .result( + PromptOptimizationResult.builder() + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .x(0.0) + .y(0.0) + .build() + ) + .status(EPromptOptimizationJobStatus.CREATED) + .build() + } + + @Test + fun pathParams() { + val params = + OptimizationJobUpdateParams.builder() + .owner("owner") + .repo("repo") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("owner") + assertThat(params._pathParam(1)).isEqualTo("repo") + assertThat(params._pathParam(2)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(3)).isEqualTo("") + } + + @Test + fun body() { + val params = + OptimizationJobUpdateParams.builder() + .owner("owner") + .repo("repo") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .result( + PromptOptimizationResult.builder() + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .x(0.0) + .y(0.0) + .build() + ) + .status(EPromptOptimizationJobStatus.CREATED) + .build() + + val body = params._body() + + assertThat(body.result()) + .contains( + PromptOptimizationResult.builder() + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .x(0.0) + .y(0.0) + .build() + ) + assertThat(body.status()).contains(EPromptOptimizationJobStatus.CREATED) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + OptimizationJobUpdateParams.builder() + .owner("owner") + .repo("repo") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/PromptOptimizationJobTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/PromptOptimizationJobTest.kt new file mode 100644 index 00000000..9d1639f3 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/PromptOptimizationJobTest.kt @@ -0,0 +1,128 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.optimizationjobs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.repos.EPromptOptimizationAlgorithm +import com.langsmith_api.api.models.api.v1.repos.PromptimConfig +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PromptOptimizationJobTest { + + @Test + fun create() { + val promptOptimizationJob = + PromptOptimizationJob.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .algorithm(EPromptOptimizationAlgorithm.PROMPTIM) + .config( + PromptimConfig.builder() + .autoCommit(true) + .datasetName("dataset_name") + .devSplit("dev_split") + .addEvaluator("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .messageIndex(0L) + .numEpochs(0L) + .taskDescription("task_description") + .testSplit("test_split") + .trainSplit("train_split") + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .repoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status(EPromptOptimizationJobStatus.CREATED) + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addResult( + PromptOptimizationResult.builder() + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .x(0.0) + .y(0.0) + .build() + ) + .build() + + assertThat(promptOptimizationJob.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(promptOptimizationJob.algorithm()) + .isEqualTo(EPromptOptimizationAlgorithm.PROMPTIM) + assertThat(promptOptimizationJob.config()) + .isEqualTo( + PromptOptimizationJob.Config.ofPromptim( + PromptimConfig.builder() + .autoCommit(true) + .datasetName("dataset_name") + .devSplit("dev_split") + .addEvaluator("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .messageIndex(0L) + .numEpochs(0L) + .taskDescription("task_description") + .testSplit("test_split") + .trainSplit("train_split") + .build() + ) + ) + assertThat(promptOptimizationJob.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(promptOptimizationJob.repoId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(promptOptimizationJob.status()).isEqualTo(EPromptOptimizationJobStatus.CREATED) + assertThat(promptOptimizationJob.tenantId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(promptOptimizationJob.updatedAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(promptOptimizationJob.results().getOrNull()) + .containsExactly( + PromptOptimizationResult.builder() + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .x(0.0) + .y(0.0) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val promptOptimizationJob = + PromptOptimizationJob.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .algorithm(EPromptOptimizationAlgorithm.PROMPTIM) + .config( + PromptimConfig.builder() + .autoCommit(true) + .datasetName("dataset_name") + .devSplit("dev_split") + .addEvaluator("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .messageIndex(0L) + .numEpochs(0L) + .taskDescription("task_description") + .testSplit("test_split") + .trainSplit("train_split") + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .repoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status(EPromptOptimizationJobStatus.CREATED) + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addResult( + PromptOptimizationResult.builder() + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .x(0.0) + .y(0.0) + .build() + ) + .build() + + val roundtrippedPromptOptimizationJob = + jsonMapper.readValue( + jsonMapper.writeValueAsString(promptOptimizationJob), + jacksonTypeRef<PromptOptimizationJob>(), + ) + + assertThat(roundtrippedPromptOptimizationJob).isEqualTo(promptOptimizationJob) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/PromptOptimizationResultTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/PromptOptimizationResultTest.kt new file mode 100644 index 00000000..158e08cd --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/PromptOptimizationResultTest.kt @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.optimizationjobs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PromptOptimizationResultTest { + + @Test + fun create() { + val promptOptimizationResult = + PromptOptimizationResult.builder() + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .x(0.0) + .y(0.0) + .build() + + assertThat(promptOptimizationResult.timestamp()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(promptOptimizationResult.x()).isEqualTo(0.0) + assertThat(promptOptimizationResult.y()).isEqualTo(0.0) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val promptOptimizationResult = + PromptOptimizationResult.builder() + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .x(0.0) + .y(0.0) + .build() + + val roundtrippedPromptOptimizationResult = + jsonMapper.readValue( + jsonMapper.writeValueAsString(promptOptimizationResult), + jacksonTypeRef<PromptOptimizationResult>(), + ) + + assertThat(roundtrippedPromptOptimizationResult).isEqualTo(promptOptimizationResult) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogCreateParamsTest.kt new file mode 100644 index 00000000..8efe20ea --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogCreateParamsTest.kt @@ -0,0 +1,76 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs + +import com.langsmith_api.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LogCreateParamsTest { + + @Test + fun create() { + LogCreateParams.builder() + .owner("owner") + .repo("repo") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .logType(EPromptOptimizationJobLogType.INFO) + .message("message") + .data(JsonValue.from(mapOf<String, Any>())) + .build() + } + + @Test + fun pathParams() { + val params = + LogCreateParams.builder() + .owner("owner") + .repo("repo") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .logType(EPromptOptimizationJobLogType.INFO) + .message("message") + .build() + + assertThat(params._pathParam(0)).isEqualTo("owner") + assertThat(params._pathParam(1)).isEqualTo("repo") + assertThat(params._pathParam(2)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(3)).isEqualTo("") + } + + @Test + fun body() { + val params = + LogCreateParams.builder() + .owner("owner") + .repo("repo") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .logType(EPromptOptimizationJobLogType.INFO) + .message("message") + .data(JsonValue.from(mapOf<String, Any>())) + .build() + + val body = params._body() + + assertThat(body.logType()).isEqualTo(EPromptOptimizationJobLogType.INFO) + assertThat(body.message()).isEqualTo("message") + assertThat(body._data()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + LogCreateParams.builder() + .owner("owner") + .repo("repo") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .logType(EPromptOptimizationJobLogType.INFO) + .message("message") + .build() + + val body = params._body() + + assertThat(body.logType()).isEqualTo(EPromptOptimizationJobLogType.INFO) + assertThat(body.message()).isEqualTo("message") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogDeleteParamsTest.kt new file mode 100644 index 00000000..f1e7362d --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogDeleteParamsTest.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LogDeleteParamsTest { + + @Test + fun create() { + LogDeleteParams.builder() + .owner("owner") + .repo("repo") + .jobId("job_id") + .logId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + LogDeleteParams.builder() + .owner("owner") + .repo("repo") + .jobId("job_id") + .logId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("owner") + assertThat(params._pathParam(1)).isEqualTo("repo") + assertThat(params._pathParam(2)).isEqualTo("job_id") + assertThat(params._pathParam(3)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(4)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogDeleteResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogDeleteResponseTest.kt new file mode 100644 index 00000000..da5b1888 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogDeleteResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LogDeleteResponseTest { + + @Test + fun create() { + val logDeleteResponse = LogDeleteResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val logDeleteResponse = LogDeleteResponse.builder().build() + + val roundtrippedLogDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(logDeleteResponse), + jacksonTypeRef<LogDeleteResponse>(), + ) + + assertThat(roundtrippedLogDeleteResponse).isEqualTo(logDeleteResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogListParamsTest.kt new file mode 100644 index 00000000..8b442ae2 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogListParamsTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LogListParamsTest { + + @Test + fun create() { + LogListParams.builder() + .owner("owner") + .repo("repo") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + LogListParams.builder() + .owner("owner") + .repo("repo") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("owner") + assertThat(params._pathParam(1)).isEqualTo("repo") + assertThat(params._pathParam(2)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(3)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogRetrieveParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogRetrieveParamsTest.kt new file mode 100644 index 00000000..6e2226ff --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/LogRetrieveParamsTest.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LogRetrieveParamsTest { + + @Test + fun create() { + LogRetrieveParams.builder() + .owner("owner") + .repo("repo") + .jobId("job_id") + .logId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + LogRetrieveParams.builder() + .owner("owner") + .repo("repo") + .jobId("job_id") + .logId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("owner") + assertThat(params._pathParam(1)).isEqualTo("repo") + assertThat(params._pathParam(2)).isEqualTo("job_id") + assertThat(params._pathParam(3)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(4)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/PromptOptimizationJobLogTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/PromptOptimizationJobLogTest.kt new file mode 100644 index 00000000..21aed00a --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/optimizationjobs/logs/PromptOptimizationJobLogTest.kt @@ -0,0 +1,57 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PromptOptimizationJobLogTest { + + @Test + fun create() { + val promptOptimizationJobLog = + PromptOptimizationJobLog.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .logType(EPromptOptimizationJobLogType.INFO) + .message("message") + .data(JsonValue.from(mapOf<String, Any>())) + .build() + + assertThat(promptOptimizationJobLog.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(promptOptimizationJobLog.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(promptOptimizationJobLog.jobId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(promptOptimizationJobLog.logType()).isEqualTo(EPromptOptimizationJobLogType.INFO) + assertThat(promptOptimizationJobLog.message()).isEqualTo("message") + assertThat(promptOptimizationJobLog._data()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val promptOptimizationJobLog = + PromptOptimizationJobLog.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .logType(EPromptOptimizationJobLogType.INFO) + .message("message") + .data(JsonValue.from(mapOf<String, Any>())) + .build() + + val roundtrippedPromptOptimizationJobLog = + jsonMapper.readValue( + jsonMapper.writeValueAsString(promptOptimizationJobLog), + jacksonTypeRef<PromptOptimizationJobLog>(), + ) + + assertThat(roundtrippedPromptOptimizationJobLog).isEqualTo(promptOptimizationJobLog) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/RepoTagTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/RepoTagTest.kt new file mode 100644 index 00000000..18b76482 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/RepoTagTest.kt @@ -0,0 +1,54 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.tags + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RepoTagTest { + + @Test + fun create() { + val repoTag = + RepoTag.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .commitHash("commit_hash") + .commitId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .repoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tagName("tag_name") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(repoTag.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(repoTag.commitHash()).isEqualTo("commit_hash") + assertThat(repoTag.commitId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(repoTag.createdAt()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(repoTag.repoId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(repoTag.tagName()).isEqualTo("tag_name") + assertThat(repoTag.updatedAt()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val repoTag = + RepoTag.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .commitHash("commit_hash") + .commitId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .repoId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tagName("tag_name") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedRepoTag = + jsonMapper.readValue(jsonMapper.writeValueAsString(repoTag), jacksonTypeRef<RepoTag>()) + + assertThat(roundtrippedRepoTag).isEqualTo(repoTag) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagCreateParamsTest.kt new file mode 100644 index 00000000..a8f25990 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagCreateParamsTest.kt @@ -0,0 +1,70 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.tags + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TagCreateParamsTest { + + @Test + fun create() { + TagCreateParams.builder() + .owner("owner") + .repo("repo") + .commitId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tagName("tag_name") + .skipWebhooks(true) + .build() + } + + @Test + fun pathParams() { + val params = + TagCreateParams.builder() + .owner("owner") + .repo("repo") + .commitId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tagName("tag_name") + .build() + + assertThat(params._pathParam(0)).isEqualTo("owner") + assertThat(params._pathParam(1)).isEqualTo("repo") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } + + @Test + fun body() { + val params = + TagCreateParams.builder() + .owner("owner") + .repo("repo") + .commitId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tagName("tag_name") + .skipWebhooks(true) + .build() + + val body = params._body() + + assertThat(body.commitId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.tagName()).isEqualTo("tag_name") + assertThat(body.skipWebhooks()).contains(TagCreateParams.SkipWebhooks.ofBool(true)) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + TagCreateParams.builder() + .owner("owner") + .repo("repo") + .commitId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tagName("tag_name") + .build() + + val body = params._body() + + assertThat(body.commitId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.tagName()).isEqualTo("tag_name") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagDeleteParamsTest.kt new file mode 100644 index 00000000..0d25cd68 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagDeleteParamsTest.kt @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.tags + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TagDeleteParamsTest { + + @Test + fun create() { + TagDeleteParams.builder().owner("owner").repo("repo").tagName("tag_name").build() + } + + @Test + fun pathParams() { + val params = + TagDeleteParams.builder().owner("owner").repo("repo").tagName("tag_name").build() + + assertThat(params._pathParam(0)).isEqualTo("owner") + assertThat(params._pathParam(1)).isEqualTo("repo") + assertThat(params._pathParam(2)).isEqualTo("tag_name") + // out-of-bound path param + assertThat(params._pathParam(3)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagDeleteResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagDeleteResponseTest.kt new file mode 100644 index 00000000..6d740ef7 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagDeleteResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.tags + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TagDeleteResponseTest { + + @Test + fun create() { + val tagDeleteResponse = TagDeleteResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val tagDeleteResponse = TagDeleteResponse.builder().build() + + val roundtrippedTagDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(tagDeleteResponse), + jacksonTypeRef<TagDeleteResponse>(), + ) + + assertThat(roundtrippedTagDeleteResponse).isEqualTo(tagDeleteResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagListParamsTest.kt new file mode 100644 index 00000000..04e32262 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagListParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.tags + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TagListParamsTest { + + @Test + fun create() { + TagListParams.builder().owner("owner").repo("repo").build() + } + + @Test + fun pathParams() { + val params = TagListParams.builder().owner("owner").repo("repo").build() + + assertThat(params._pathParam(0)).isEqualTo("owner") + assertThat(params._pathParam(1)).isEqualTo("repo") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagRetrieveParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagRetrieveParamsTest.kt new file mode 100644 index 00000000..91f1b8cd --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagRetrieveParamsTest.kt @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.tags + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TagRetrieveParamsTest { + + @Test + fun create() { + TagRetrieveParams.builder().owner("owner").repo("repo").tagName("tag_name").build() + } + + @Test + fun pathParams() { + val params = + TagRetrieveParams.builder().owner("owner").repo("repo").tagName("tag_name").build() + + assertThat(params._pathParam(0)).isEqualTo("owner") + assertThat(params._pathParam(1)).isEqualTo("repo") + assertThat(params._pathParam(2)).isEqualTo("tag_name") + // out-of-bound path param + assertThat(params._pathParam(3)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagUpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagUpdateParamsTest.kt new file mode 100644 index 00000000..e9de18df --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/repos/tags/TagUpdateParamsTest.kt @@ -0,0 +1,69 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.repos.tags + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TagUpdateParamsTest { + + @Test + fun create() { + TagUpdateParams.builder() + .owner("owner") + .repo("repo") + .tagName("tag_name") + .commitId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .skipWebhooks(true) + .build() + } + + @Test + fun pathParams() { + val params = + TagUpdateParams.builder() + .owner("owner") + .repo("repo") + .tagName("tag_name") + .commitId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("owner") + assertThat(params._pathParam(1)).isEqualTo("repo") + assertThat(params._pathParam(2)).isEqualTo("tag_name") + // out-of-bound path param + assertThat(params._pathParam(3)).isEqualTo("") + } + + @Test + fun body() { + val params = + TagUpdateParams.builder() + .owner("owner") + .repo("repo") + .tagName("tag_name") + .commitId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .skipWebhooks(true) + .build() + + val body = params._body() + + assertThat(body.commitId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.skipWebhooks()).contains(TagUpdateParams.SkipWebhooks.ofBool(true)) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + TagUpdateParams.builder() + .owner("owner") + .repo("repo") + .tagName("tag_name") + .commitId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + + assertThat(body.commitId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/BodyParamsForRunSchemaTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/BodyParamsForRunSchemaTest.kt new file mode 100644 index 00000000..673a8c57 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/BodyParamsForRunSchemaTest.kt @@ -0,0 +1,117 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BodyParamsForRunSchemaTest { + + @Test + fun create() { + val bodyParamsForRunSchema = + BodyParamsForRunSchema.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .dataSourceType(RunsFilterDataSourceTypeEnum.CURRENT) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .executionOrder(1L) + .filter("filter") + .isRoot(true) + .limit(1L) + .order(BodyParamsForRunSchema.Order.ASC) + .parentRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .query("query") + .addReferenceExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runType(RunTypeEnum.TOOL) + .searchFilter("search_filter") + .addSelect(BodyParamsForRunSchema.Select.ID) + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .skipPagination(true) + .skipPrevCursor(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .trace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .useExperimentalSearch(true) + .build() + + assertThat(bodyParamsForRunSchema.id().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(bodyParamsForRunSchema.cursor()).contains("cursor") + assertThat(bodyParamsForRunSchema.dataSourceType()) + .contains(RunsFilterDataSourceTypeEnum.CURRENT) + assertThat(bodyParamsForRunSchema.endTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(bodyParamsForRunSchema.error()).contains(true) + assertThat(bodyParamsForRunSchema.executionOrder()).contains(1L) + assertThat(bodyParamsForRunSchema.filter()).contains("filter") + assertThat(bodyParamsForRunSchema.isRoot()).contains(true) + assertThat(bodyParamsForRunSchema.limit()).contains(1L) + assertThat(bodyParamsForRunSchema.order()).contains(BodyParamsForRunSchema.Order.ASC) + assertThat(bodyParamsForRunSchema.parentRun()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(bodyParamsForRunSchema.query()).contains("query") + assertThat(bodyParamsForRunSchema.referenceExample().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(bodyParamsForRunSchema.runType()).contains(RunTypeEnum.TOOL) + assertThat(bodyParamsForRunSchema.searchFilter()).contains("search_filter") + assertThat(bodyParamsForRunSchema.select().getOrNull()) + .containsExactly(BodyParamsForRunSchema.Select.ID) + assertThat(bodyParamsForRunSchema.session().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(bodyParamsForRunSchema.skipPagination()).contains(true) + assertThat(bodyParamsForRunSchema.skipPrevCursor()).contains(true) + assertThat(bodyParamsForRunSchema.startTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(bodyParamsForRunSchema.trace()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(bodyParamsForRunSchema.traceFilter()).contains("trace_filter") + assertThat(bodyParamsForRunSchema.treeFilter()).contains("tree_filter") + assertThat(bodyParamsForRunSchema.useExperimentalSearch()).contains(true) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val bodyParamsForRunSchema = + BodyParamsForRunSchema.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .dataSourceType(RunsFilterDataSourceTypeEnum.CURRENT) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .executionOrder(1L) + .filter("filter") + .isRoot(true) + .limit(1L) + .order(BodyParamsForRunSchema.Order.ASC) + .parentRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .query("query") + .addReferenceExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runType(RunTypeEnum.TOOL) + .searchFilter("search_filter") + .addSelect(BodyParamsForRunSchema.Select.ID) + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .skipPagination(true) + .skipPrevCursor(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .trace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .useExperimentalSearch(true) + .build() + + val roundtrippedBodyParamsForRunSchema = + jsonMapper.readValue( + jsonMapper.writeValueAsString(bodyParamsForRunSchema), + jacksonTypeRef<BodyParamsForRunSchema>(), + ) + + assertThat(roundtrippedBodyParamsForRunSchema).isEqualTo(bodyParamsForRunSchema) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RequestBodyForRunsGenerateQueryTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RequestBodyForRunsGenerateQueryTest.kt new file mode 100644 index 00000000..0da3dcff --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RequestBodyForRunsGenerateQueryTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RequestBodyForRunsGenerateQueryTest { + + @Test + fun create() { + val requestBodyForRunsGenerateQuery = + RequestBodyForRunsGenerateQuery.builder() + .query("query") + .addFeedbackKey(RequestBodyForRunsGenerateQuery.FeedbackKey.USER_SCORE) + .build() + + assertThat(requestBodyForRunsGenerateQuery.query()).isEqualTo("query") + assertThat(requestBodyForRunsGenerateQuery.feedbackKeys().getOrNull()) + .containsExactly(RequestBodyForRunsGenerateQuery.FeedbackKey.USER_SCORE) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val requestBodyForRunsGenerateQuery = + RequestBodyForRunsGenerateQuery.builder() + .query("query") + .addFeedbackKey(RequestBodyForRunsGenerateQuery.FeedbackKey.USER_SCORE) + .build() + + val roundtrippedRequestBodyForRunsGenerateQuery = + jsonMapper.readValue( + jsonMapper.writeValueAsString(requestBodyForRunsGenerateQuery), + jacksonTypeRef<RequestBodyForRunsGenerateQuery>(), + ) + + assertThat(roundtrippedRequestBodyForRunsGenerateQuery) + .isEqualTo(requestBodyForRunsGenerateQuery) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/ResponseBodyForRunsGenerateQueryTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/ResponseBodyForRunsGenerateQueryTest.kt new file mode 100644 index 00000000..f57260f6 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/ResponseBodyForRunsGenerateQueryTest.kt @@ -0,0 +1,56 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ResponseBodyForRunsGenerateQueryTest { + + @Test + fun create() { + val responseBodyForRunsGenerateQuery = + ResponseBodyForRunsGenerateQuery.builder() + .feedbackUrls( + ResponseBodyForRunsGenerateQuery.FeedbackUrls.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .filter("filter") + .build() + + assertThat(responseBodyForRunsGenerateQuery.feedbackUrls()) + .isEqualTo( + ResponseBodyForRunsGenerateQuery.FeedbackUrls.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(responseBodyForRunsGenerateQuery.filter()).isEqualTo("filter") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val responseBodyForRunsGenerateQuery = + ResponseBodyForRunsGenerateQuery.builder() + .feedbackUrls( + ResponseBodyForRunsGenerateQuery.FeedbackUrls.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .filter("filter") + .build() + + val roundtrippedResponseBodyForRunsGenerateQuery = + jsonMapper.readValue( + jsonMapper.writeValueAsString(responseBodyForRunsGenerateQuery), + jacksonTypeRef<ResponseBodyForRunsGenerateQuery>(), + ) + + assertThat(roundtrippedResponseBodyForRunsGenerateQuery) + .isEqualTo(responseBodyForRunsGenerateQuery) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunDeleteParamsTest.kt new file mode 100644 index 00000000..c4a3422f --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunDeleteParamsTest.kt @@ -0,0 +1,57 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs + +import com.langsmith_api.api.core.JsonValue +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunDeleteParamsTest { + + @Test + fun create() { + RunDeleteParams.builder() + .metadata( + RunDeleteParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addTraceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun body() { + val params = + RunDeleteParams.builder() + .metadata( + RunDeleteParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addTraceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + + assertThat(body.metadata()) + .contains( + RunDeleteParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(body.sessionId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.traceIds().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = RunDeleteParams.builder().build() + + val body = params._body() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunDeleteResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunDeleteResponseTest.kt new file mode 100644 index 00000000..8a03728a --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunDeleteResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunDeleteResponseTest { + + @Test + fun create() { + val runDeleteResponse = RunDeleteResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val runDeleteResponse = RunDeleteResponse.builder().build() + + val roundtrippedRunDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(runDeleteResponse), + jacksonTypeRef<RunDeleteResponse>(), + ) + + assertThat(roundtrippedRunDeleteResponse).isEqualTo(runDeleteResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunGenerateQueryParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunGenerateQueryParamsTest.kt new file mode 100644 index 00000000..97753609 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunGenerateQueryParamsTest.kt @@ -0,0 +1,58 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunGenerateQueryParamsTest { + + @Test + fun create() { + RunGenerateQueryParams.builder() + .requestBodyForRunsGenerateQuery( + RequestBodyForRunsGenerateQuery.builder() + .query("query") + .addFeedbackKey(RequestBodyForRunsGenerateQuery.FeedbackKey.USER_SCORE) + .build() + ) + .build() + } + + @Test + fun body() { + val params = + RunGenerateQueryParams.builder() + .requestBodyForRunsGenerateQuery( + RequestBodyForRunsGenerateQuery.builder() + .query("query") + .addFeedbackKey(RequestBodyForRunsGenerateQuery.FeedbackKey.USER_SCORE) + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + RequestBodyForRunsGenerateQuery.builder() + .query("query") + .addFeedbackKey(RequestBodyForRunsGenerateQuery.FeedbackKey.USER_SCORE) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + RunGenerateQueryParams.builder() + .requestBodyForRunsGenerateQuery( + RequestBodyForRunsGenerateQuery.builder().query("query").build() + ) + .build() + + val body = params._body() + + assertThat(body).isEqualTo(RequestBodyForRunsGenerateQuery.builder().query("query").build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunQueryParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunQueryParamsTest.kt new file mode 100644 index 00000000..2ea3690c --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunQueryParamsTest.kt @@ -0,0 +1,123 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunQueryParamsTest { + + @Test + fun create() { + RunQueryParams.builder() + .bodyParamsForRunSchema( + BodyParamsForRunSchema.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .dataSourceType(RunsFilterDataSourceTypeEnum.CURRENT) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .executionOrder(1L) + .filter("filter") + .isRoot(true) + .limit(1L) + .order(BodyParamsForRunSchema.Order.ASC) + .parentRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .query("query") + .addReferenceExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runType(RunTypeEnum.TOOL) + .searchFilter("search_filter") + .addSelect(BodyParamsForRunSchema.Select.ID) + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .skipPagination(true) + .skipPrevCursor(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .trace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .useExperimentalSearch(true) + .build() + ) + .build() + } + + @Test + fun body() { + val params = + RunQueryParams.builder() + .bodyParamsForRunSchema( + BodyParamsForRunSchema.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .dataSourceType(RunsFilterDataSourceTypeEnum.CURRENT) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .executionOrder(1L) + .filter("filter") + .isRoot(true) + .limit(1L) + .order(BodyParamsForRunSchema.Order.ASC) + .parentRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .query("query") + .addReferenceExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runType(RunTypeEnum.TOOL) + .searchFilter("search_filter") + .addSelect(BodyParamsForRunSchema.Select.ID) + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .skipPagination(true) + .skipPrevCursor(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .trace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .useExperimentalSearch(true) + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + BodyParamsForRunSchema.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .dataSourceType(RunsFilterDataSourceTypeEnum.CURRENT) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .executionOrder(1L) + .filter("filter") + .isRoot(true) + .limit(1L) + .order(BodyParamsForRunSchema.Order.ASC) + .parentRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .query("query") + .addReferenceExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runType(RunTypeEnum.TOOL) + .searchFilter("search_filter") + .addSelect(BodyParamsForRunSchema.Select.ID) + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .skipPagination(true) + .skipPrevCursor(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .trace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .useExperimentalSearch(true) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + RunQueryParams.builder() + .bodyParamsForRunSchema(BodyParamsForRunSchema.builder().build()) + .build() + + val body = params._body() + + assertThat(body).isEqualTo(BodyParamsForRunSchema.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunQueryResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunQueryResponseTest.kt new file mode 100644 index 00000000..d4291a8b --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunQueryResponseTest.kt @@ -0,0 +1,308 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TraceTier +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunQueryResponseTest { + + @Test + fun create() { + val runQueryResponse = + RunQueryResponse.builder() + .cursors( + RunQueryResponse.Cursors.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addRun( + RunSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .appPath("app_path") + .dottedOrder("dotted_order") + .name("name") + .runType(RunTypeEnum.TOOL) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status("status") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost("completion_cost") + .completionCostDetails( + RunSchema.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .completionTokenDetails( + RunSchema.CompletionTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .completionTokens(0L) + .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error("error") + .addEvent(JsonValue.from(mapOf<String, Any>())) + .executionOrder(1L) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats( + RunSchema.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf<String, Any>())) + .build() + ) + .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inDataset(true) + .inputs(JsonValue.from(mapOf<String, Any>())) + .inputsPreview("inputs_preview") + .inputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .lastQueuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .outputs(JsonValue.from(mapOf<String, Any>())) + .outputsPreview("outputs_preview") + .outputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .promptCost("prompt_cost") + .promptCostDetails( + RunSchema.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .promptTokenDetails( + RunSchema.PromptTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .promptTokens(0L) + .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .s3Urls(JsonValue.from(mapOf<String, Any>())) + .serialized(JsonValue.from(mapOf<String, Any>())) + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTag("string") + .threadId("thread_id") + .totalCost("total_cost") + .totalTokens(0L) + .traceFirstReceivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceTier(TraceTier.LONGLIVED) + .traceUpgrade(true) + .ttlSeconds(0L) + .build() + ) + .parsedQuery("parsed_query") + .searchCursors( + RunQueryResponse.SearchCursors.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + + assertThat(runQueryResponse.cursors()) + .isEqualTo( + RunQueryResponse.Cursors.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(runQueryResponse.runs()) + .containsExactly( + RunSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .appPath("app_path") + .dottedOrder("dotted_order") + .name("name") + .runType(RunTypeEnum.TOOL) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status("status") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost("completion_cost") + .completionCostDetails( + RunSchema.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .completionTokenDetails( + RunSchema.CompletionTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .completionTokens(0L) + .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error("error") + .addEvent(JsonValue.from(mapOf<String, Any>())) + .executionOrder(1L) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats( + RunSchema.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf<String, Any>())) + .build() + ) + .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inDataset(true) + .inputs(JsonValue.from(mapOf<String, Any>())) + .inputsPreview("inputs_preview") + .inputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .lastQueuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .outputs(JsonValue.from(mapOf<String, Any>())) + .outputsPreview("outputs_preview") + .outputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .promptCost("prompt_cost") + .promptCostDetails( + RunSchema.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .promptTokenDetails( + RunSchema.PromptTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .promptTokens(0L) + .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .s3Urls(JsonValue.from(mapOf<String, Any>())) + .serialized(JsonValue.from(mapOf<String, Any>())) + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTag("string") + .threadId("thread_id") + .totalCost("total_cost") + .totalTokens(0L) + .traceFirstReceivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceTier(TraceTier.LONGLIVED) + .traceUpgrade(true) + .ttlSeconds(0L) + .build() + ) + assertThat(runQueryResponse.parsedQuery()).contains("parsed_query") + assertThat(runQueryResponse.searchCursors()) + .contains( + RunQueryResponse.SearchCursors.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val runQueryResponse = + RunQueryResponse.builder() + .cursors( + RunQueryResponse.Cursors.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addRun( + RunSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .appPath("app_path") + .dottedOrder("dotted_order") + .name("name") + .runType(RunTypeEnum.TOOL) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status("status") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost("completion_cost") + .completionCostDetails( + RunSchema.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .completionTokenDetails( + RunSchema.CompletionTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .completionTokens(0L) + .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error("error") + .addEvent(JsonValue.from(mapOf<String, Any>())) + .executionOrder(1L) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats( + RunSchema.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf<String, Any>())) + .build() + ) + .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inDataset(true) + .inputs(JsonValue.from(mapOf<String, Any>())) + .inputsPreview("inputs_preview") + .inputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .lastQueuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .outputs(JsonValue.from(mapOf<String, Any>())) + .outputsPreview("outputs_preview") + .outputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .promptCost("prompt_cost") + .promptCostDetails( + RunSchema.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .promptTokenDetails( + RunSchema.PromptTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .promptTokens(0L) + .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .s3Urls(JsonValue.from(mapOf<String, Any>())) + .serialized(JsonValue.from(mapOf<String, Any>())) + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTag("string") + .threadId("thread_id") + .totalCost("total_cost") + .totalTokens(0L) + .traceFirstReceivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceTier(TraceTier.LONGLIVED) + .traceUpgrade(true) + .ttlSeconds(0L) + .build() + ) + .parsedQuery("parsed_query") + .searchCursors( + RunQueryResponse.SearchCursors.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + + val roundtrippedRunQueryResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(runQueryResponse), + jacksonTypeRef<RunQueryResponse>(), + ) + + assertThat(roundtrippedRunQueryResponse).isEqualTo(runQueryResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunRetrieveParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunRetrieveParamsTest.kt new file mode 100644 index 00000000..e6704bb2 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunRetrieveParamsTest.kt @@ -0,0 +1,66 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs + +import com.langsmith_api.api.core.http.QueryParams +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunRetrieveParamsTest { + + @Test + fun create() { + RunRetrieveParams.builder() + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .excludeS3StoredAttributes(true) + .excludeSerialized(true) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + } + + @Test + fun pathParams() { + val params = + RunRetrieveParams.builder().runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + RunRetrieveParams.builder() + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .excludeS3StoredAttributes(true) + .excludeSerialized(true) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("exclude_s3_stored_attributes", "true") + .put("exclude_serialized", "true") + .put("session_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("start_time", "2019-12-27T18:11:19.117Z") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + RunRetrieveParams.builder().runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunSchemaTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunSchemaTest.kt new file mode 100644 index 00000000..791cfd38 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunSchemaTest.kt @@ -0,0 +1,275 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TraceTier +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunSchemaTest { + + @Test + fun create() { + val runSchema = + RunSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .appPath("app_path") + .dottedOrder("dotted_order") + .name("name") + .runType(RunTypeEnum.TOOL) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status("status") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost("completion_cost") + .completionCostDetails( + RunSchema.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .completionTokenDetails( + RunSchema.CompletionTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .completionTokens(0L) + .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error("error") + .addEvent(JsonValue.from(mapOf<String, Any>())) + .executionOrder(1L) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats( + RunSchema.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf<String, Any>())) + .build() + ) + .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inDataset(true) + .inputs(JsonValue.from(mapOf<String, Any>())) + .inputsPreview("inputs_preview") + .inputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .lastQueuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .outputs(JsonValue.from(mapOf<String, Any>())) + .outputsPreview("outputs_preview") + .outputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .promptCost("prompt_cost") + .promptCostDetails( + RunSchema.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .promptTokenDetails( + RunSchema.PromptTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .promptTokens(0L) + .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .s3Urls(JsonValue.from(mapOf<String, Any>())) + .serialized(JsonValue.from(mapOf<String, Any>())) + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTag("string") + .threadId("thread_id") + .totalCost("total_cost") + .totalTokens(0L) + .traceFirstReceivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceTier(TraceTier.LONGLIVED) + .traceUpgrade(true) + .ttlSeconds(0L) + .build() + + assertThat(runSchema.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchema.appPath()).isEqualTo("app_path") + assertThat(runSchema.dottedOrder()).isEqualTo("dotted_order") + assertThat(runSchema.name()).isEqualTo("name") + assertThat(runSchema.runType()).isEqualTo(RunTypeEnum.TOOL) + assertThat(runSchema.sessionId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchema.status()).isEqualTo("status") + assertThat(runSchema.traceId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchema.childRunIds().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchema.completionCost()).contains("completion_cost") + assertThat(runSchema.completionCostDetails()) + .contains( + RunSchema.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(runSchema.completionTokenDetails()) + .contains( + RunSchema.CompletionTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + assertThat(runSchema.completionTokens()).contains(0L) + assertThat(runSchema.directChildRunIds().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchema.endTime()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runSchema.error()).contains("error") + assertThat(runSchema.events().getOrNull()) + .containsExactly(JsonValue.from(mapOf<String, Any>())) + assertThat(runSchema.executionOrder()).contains(1L) + assertThat(runSchema._extra()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(runSchema.feedbackStats()) + .contains( + RunSchema.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf<String, Any>())) + .build() + ) + assertThat(runSchema.firstTokenTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runSchema.inDataset()).contains(true) + assertThat(runSchema._inputs()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(runSchema.inputsPreview()).contains("inputs_preview") + assertThat(runSchema._inputsS3Urls()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(runSchema.lastQueuedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runSchema.manifestId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchema.manifestS3Id()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchema._outputs()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(runSchema.outputsPreview()).contains("outputs_preview") + assertThat(runSchema._outputsS3Urls()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(runSchema.parentRunId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchema.parentRunIds().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchema.priceModelId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchema.promptCost()).contains("prompt_cost") + assertThat(runSchema.promptCostDetails()) + .contains( + RunSchema.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(runSchema.promptTokenDetails()) + .contains( + RunSchema.PromptTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + assertThat(runSchema.promptTokens()).contains(0L) + assertThat(runSchema.referenceDatasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchema.referenceExampleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchema._s3Urls()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(runSchema._serialized()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(runSchema.shareToken()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runSchema.startTime()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runSchema.tags().getOrNull()).containsExactly("string") + assertThat(runSchema.threadId()).contains("thread_id") + assertThat(runSchema.totalCost()).contains("total_cost") + assertThat(runSchema.totalTokens()).contains(0L) + assertThat(runSchema.traceFirstReceivedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runSchema.traceMaxStartTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runSchema.traceMinStartTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runSchema.traceTier()).contains(TraceTier.LONGLIVED) + assertThat(runSchema.traceUpgrade()).contains(true) + assertThat(runSchema.ttlSeconds()).contains(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val runSchema = + RunSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .appPath("app_path") + .dottedOrder("dotted_order") + .name("name") + .runType(RunTypeEnum.TOOL) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status("status") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost("completion_cost") + .completionCostDetails( + RunSchema.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .completionTokenDetails( + RunSchema.CompletionTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .completionTokens(0L) + .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error("error") + .addEvent(JsonValue.from(mapOf<String, Any>())) + .executionOrder(1L) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats( + RunSchema.FeedbackStats.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf<String, Any>())) + .build() + ) + .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inDataset(true) + .inputs(JsonValue.from(mapOf<String, Any>())) + .inputsPreview("inputs_preview") + .inputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .lastQueuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .outputs(JsonValue.from(mapOf<String, Any>())) + .outputsPreview("outputs_preview") + .outputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .promptCost("prompt_cost") + .promptCostDetails( + RunSchema.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .promptTokenDetails( + RunSchema.PromptTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .promptTokens(0L) + .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .s3Urls(JsonValue.from(mapOf<String, Any>())) + .serialized(JsonValue.from(mapOf<String, Any>())) + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTag("string") + .threadId("thread_id") + .totalCost("total_cost") + .totalTokens(0L) + .traceFirstReceivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceTier(TraceTier.LONGLIVED) + .traceUpgrade(true) + .ttlSeconds(0L) + .build() + + val roundtrippedRunSchema = + jsonMapper.readValue( + jsonMapper.writeValueAsString(runSchema), + jacksonTypeRef<RunSchema>(), + ) + + assertThat(roundtrippedRunSchema).isEqualTo(runSchema) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunStatsParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunStatsParamsTest.kt new file mode 100644 index 00000000..076881b2 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunStatsParamsTest.kt @@ -0,0 +1,136 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs + +import com.langsmith_api.api.models.api.v1.sessions.RunStatsGroupBy +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunStatsParamsTest { + + @Test + fun create() { + RunStatsParams.builder() + .runStatsQueryParams( + RunStatsQueryParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dataSourceType(RunsFilterDataSourceTypeEnum.CURRENT) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .executionOrder(1L) + .filter("filter") + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .addGroup("string") + .isRoot(true) + .parentRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .query("query") + .addReferenceExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runType(RunTypeEnum.TOOL) + .searchFilter("search_filter") + .addSelect(RunStatsQueryParams.Select.RUN_COUNT) + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .skipPagination(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .trace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .useExperimentalSearch(true) + .build() + ) + .build() + } + + @Test + fun body() { + val params = + RunStatsParams.builder() + .runStatsQueryParams( + RunStatsQueryParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dataSourceType(RunsFilterDataSourceTypeEnum.CURRENT) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .executionOrder(1L) + .filter("filter") + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .addGroup("string") + .isRoot(true) + .parentRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .query("query") + .addReferenceExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runType(RunTypeEnum.TOOL) + .searchFilter("search_filter") + .addSelect(RunStatsQueryParams.Select.RUN_COUNT) + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .skipPagination(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .trace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .useExperimentalSearch(true) + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + RunStatsQueryParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dataSourceType(RunsFilterDataSourceTypeEnum.CURRENT) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .executionOrder(1L) + .filter("filter") + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .addGroup("string") + .isRoot(true) + .parentRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .query("query") + .addReferenceExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runType(RunTypeEnum.TOOL) + .searchFilter("search_filter") + .addSelect(RunStatsQueryParams.Select.RUN_COUNT) + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .skipPagination(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .trace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .useExperimentalSearch(true) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + RunStatsParams.builder() + .runStatsQueryParams(RunStatsQueryParams.builder().build()) + .build() + + val body = params._body() + + assertThat(body).isEqualTo(RunStatsQueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunStatsQueryParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunStatsQueryParamsTest.kt new file mode 100644 index 00000000..196b9799 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunStatsQueryParamsTest.kt @@ -0,0 +1,130 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.sessions.RunStatsGroupBy +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunStatsQueryParamsTest { + + @Test + fun create() { + val runStatsQueryParams = + RunStatsQueryParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dataSourceType(RunsFilterDataSourceTypeEnum.CURRENT) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .executionOrder(1L) + .filter("filter") + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .addGroup("string") + .isRoot(true) + .parentRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .query("query") + .addReferenceExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runType(RunTypeEnum.TOOL) + .searchFilter("search_filter") + .addSelect(RunStatsQueryParams.Select.RUN_COUNT) + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .skipPagination(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .trace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .useExperimentalSearch(true) + .build() + + assertThat(runStatsQueryParams.id().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runStatsQueryParams.dataSourceType()) + .contains(RunsFilterDataSourceTypeEnum.CURRENT) + assertThat(runStatsQueryParams.endTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runStatsQueryParams.error()).contains(true) + assertThat(runStatsQueryParams.executionOrder()).contains(1L) + assertThat(runStatsQueryParams.filter()).contains("filter") + assertThat(runStatsQueryParams.groupBy()) + .contains( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + assertThat(runStatsQueryParams.groups().getOrNull()).containsExactly("string") + assertThat(runStatsQueryParams.isRoot()).contains(true) + assertThat(runStatsQueryParams.parentRun()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runStatsQueryParams.query()).contains("query") + assertThat(runStatsQueryParams.referenceExample().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runStatsQueryParams.runType()).contains(RunTypeEnum.TOOL) + assertThat(runStatsQueryParams.searchFilter()).contains("search_filter") + assertThat(runStatsQueryParams.select().getOrNull()) + .containsExactly(RunStatsQueryParams.Select.RUN_COUNT) + assertThat(runStatsQueryParams.session().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runStatsQueryParams.skipPagination()).contains(true) + assertThat(runStatsQueryParams.startTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runStatsQueryParams.trace()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runStatsQueryParams.traceFilter()).contains("trace_filter") + assertThat(runStatsQueryParams.treeFilter()).contains("tree_filter") + assertThat(runStatsQueryParams.useExperimentalSearch()).contains(true) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val runStatsQueryParams = + RunStatsQueryParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dataSourceType(RunsFilterDataSourceTypeEnum.CURRENT) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .executionOrder(1L) + .filter("filter") + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .addGroup("string") + .isRoot(true) + .parentRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .query("query") + .addReferenceExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runType(RunTypeEnum.TOOL) + .searchFilter("search_filter") + .addSelect(RunStatsQueryParams.Select.RUN_COUNT) + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .skipPagination(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .trace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .useExperimentalSearch(true) + .build() + + val roundtrippedRunStatsQueryParams = + jsonMapper.readValue( + jsonMapper.writeValueAsString(runStatsQueryParams), + jacksonTypeRef<RunStatsQueryParams>(), + ) + + assertThat(roundtrippedRunStatsQueryParams).isEqualTo(runStatsQueryParams) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunStatsResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunStatsResponseTest.kt new file mode 100644 index 00000000..c90b14d0 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunStatsResponseTest.kt @@ -0,0 +1,222 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.errors.LangsmithApiInvalidDataException +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunStats +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class RunStatsResponseTest { + + @Test + fun ofRunStats() { + val runStats = + RunStats.builder() + .completionCost("completion_cost") + .completionCostDetails(JsonValue.from(mapOf<String, Any>())) + .completionTokenDetails(JsonValue.from(mapOf<String, Any>())) + .completionTokens(0L) + .completionTokensP50(0L) + .completionTokensP99(0L) + .costP50("cost_p50") + .costP99("cost_p99") + .errorRate(0.0) + .feedbackStats(JsonValue.from(mapOf<String, Any>())) + .firstTokenP50(0.0) + .firstTokenP99(0.0) + .lastRunStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .latencyP50(0.0) + .latencyP99(0.0) + .medianTokens(0L) + .promptCost("prompt_cost") + .promptCostDetails(JsonValue.from(mapOf<String, Any>())) + .promptTokenDetails(JsonValue.from(mapOf<String, Any>())) + .promptTokens(0L) + .promptTokensP50(0L) + .promptTokensP99(0L) + .runCount(0L) + .addRunFacet(JsonValue.from(mapOf<String, Any>())) + .streamingRate(0.0) + .tokensP99(0L) + .totalCost("total_cost") + .totalTokens(0L) + .build() + + val runStatsResponse = RunStatsResponse.ofRunStats(runStats) + + assertThat(runStatsResponse.runStats()).contains(runStats) + assertThat(runStatsResponse.unionMember1()).isEmpty + } + + @Test + fun ofRunStatsRoundtrip() { + val jsonMapper = jsonMapper() + val runStatsResponse = + RunStatsResponse.ofRunStats( + RunStats.builder() + .completionCost("completion_cost") + .completionCostDetails(JsonValue.from(mapOf<String, Any>())) + .completionTokenDetails(JsonValue.from(mapOf<String, Any>())) + .completionTokens(0L) + .completionTokensP50(0L) + .completionTokensP99(0L) + .costP50("cost_p50") + .costP99("cost_p99") + .errorRate(0.0) + .feedbackStats(JsonValue.from(mapOf<String, Any>())) + .firstTokenP50(0.0) + .firstTokenP99(0.0) + .lastRunStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .latencyP50(0.0) + .latencyP99(0.0) + .medianTokens(0L) + .promptCost("prompt_cost") + .promptCostDetails(JsonValue.from(mapOf<String, Any>())) + .promptTokenDetails(JsonValue.from(mapOf<String, Any>())) + .promptTokens(0L) + .promptTokensP50(0L) + .promptTokensP99(0L) + .runCount(0L) + .addRunFacet(JsonValue.from(mapOf<String, Any>())) + .streamingRate(0.0) + .tokensP99(0L) + .totalCost("total_cost") + .totalTokens(0L) + .build() + ) + + val roundtrippedRunStatsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(runStatsResponse), + jacksonTypeRef<RunStatsResponse>(), + ) + + assertThat(roundtrippedRunStatsResponse).isEqualTo(runStatsResponse) + } + + @Test + fun ofUnionMember1() { + val unionMember1 = + RunStatsResponse.UnionMember1.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "completion_cost" to "completion_cost", + "completion_cost_details" to mapOf<String, Any>(), + "completion_token_details" to mapOf<String, Any>(), + "completion_tokens" to 0, + "completion_tokens_p50" to 0, + "completion_tokens_p99" to 0, + "cost_p50" to "cost_p50", + "cost_p99" to "cost_p99", + "error_rate" to 0, + "feedback_stats" to mapOf<String, Any>(), + "first_token_p50" to 0, + "first_token_p99" to 0, + "last_run_start_time" to "2019-12-27T18:11:19.117Z", + "latency_p50" to 0, + "latency_p99" to 0, + "median_tokens" to 0, + "prompt_cost" to "prompt_cost", + "prompt_cost_details" to mapOf<String, Any>(), + "prompt_token_details" to mapOf<String, Any>(), + "prompt_tokens" to 0, + "prompt_tokens_p50" to 0, + "prompt_tokens_p99" to 0, + "run_count" to 0, + "run_facets" to listOf(mapOf<String, Any>()), + "streaming_rate" to 0, + "tokens_p99" to 0, + "total_cost" to "total_cost", + "total_tokens" to 0, + ) + ), + ) + .build() + + val runStatsResponse = RunStatsResponse.ofUnionMember1(unionMember1) + + assertThat(runStatsResponse.runStats()).isEmpty + assertThat(runStatsResponse.unionMember1()).contains(unionMember1) + } + + @Test + fun ofUnionMember1Roundtrip() { + val jsonMapper = jsonMapper() + val runStatsResponse = + RunStatsResponse.ofUnionMember1( + RunStatsResponse.UnionMember1.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "completion_cost" to "completion_cost", + "completion_cost_details" to mapOf<String, Any>(), + "completion_token_details" to mapOf<String, Any>(), + "completion_tokens" to 0, + "completion_tokens_p50" to 0, + "completion_tokens_p99" to 0, + "cost_p50" to "cost_p50", + "cost_p99" to "cost_p99", + "error_rate" to 0, + "feedback_stats" to mapOf<String, Any>(), + "first_token_p50" to 0, + "first_token_p99" to 0, + "last_run_start_time" to "2019-12-27T18:11:19.117Z", + "latency_p50" to 0, + "latency_p99" to 0, + "median_tokens" to 0, + "prompt_cost" to "prompt_cost", + "prompt_cost_details" to mapOf<String, Any>(), + "prompt_token_details" to mapOf<String, Any>(), + "prompt_tokens" to 0, + "prompt_tokens_p50" to 0, + "prompt_tokens_p99" to 0, + "run_count" to 0, + "run_facets" to listOf(mapOf<String, Any>()), + "streaming_rate" to 0, + "tokens_p99" to 0, + "total_cost" to "total_cost", + "total_tokens" to 0, + ) + ), + ) + .build() + ) + + val roundtrippedRunStatsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(runStatsResponse), + jacksonTypeRef<RunStatsResponse>(), + ) + + assertThat(roundtrippedRunStatsResponse).isEqualTo(runStatsResponse) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val runStatsResponse = + jsonMapper().convertValue(testCase.value, jacksonTypeRef<RunStatsResponse>()) + + val e = assertThrows<LangsmithApiInvalidDataException> { runStatsResponse.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunUpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunUpdateParamsTest.kt new file mode 100644 index 00000000..0b29d66e --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunUpdateParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunUpdateParamsTest { + + @Test + fun create() { + RunUpdateParams.builder().runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = RunUpdateParams.builder().runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunUpdateResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunUpdateResponseTest.kt new file mode 100644 index 00000000..24e20445 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/RunUpdateResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunUpdateResponseTest { + + @Test + fun create() { + val runUpdateResponse = RunUpdateResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val runUpdateResponse = RunUpdateResponse.builder().build() + + val roundtrippedRunUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(runUpdateResponse), + jacksonTypeRef<RunUpdateResponse>(), + ) + + assertThat(roundtrippedRunUpdateResponse).isEqualTo(runUpdateResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/group/GroupCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/group/GroupCreateParamsTest.kt new file mode 100644 index 00000000..777a2e35 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/group/GroupCreateParamsTest.kt @@ -0,0 +1,126 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.group + +import com.langsmith_api.api.core.http.Headers +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class GroupCreateParamsTest { + + @Test + fun create() { + GroupCreateParams.builder() + .accept("accept") + .runGroupRequest( + RunGroupRequest.builder() + .groupBy(RunGroupRequest.GroupBy.CONVERSATION) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .limit(1L) + .offset(0L) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + } + + @Test + fun headers() { + val params = + GroupCreateParams.builder() + .accept("accept") + .runGroupRequest( + RunGroupRequest.builder() + .groupBy(RunGroupRequest.GroupBy.CONVERSATION) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .limit(1L) + .offset(0L) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + + val headers = params._headers() + + assertThat(headers).isEqualTo(Headers.builder().put("accept", "accept").build()) + } + + @Test + fun headersWithoutOptionalFields() { + val params = + GroupCreateParams.builder() + .runGroupRequest( + RunGroupRequest.builder() + .groupBy(RunGroupRequest.GroupBy.CONVERSATION) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + + val headers = params._headers() + + assertThat(headers).isEqualTo(Headers.builder().build()) + } + + @Test + fun body() { + val params = + GroupCreateParams.builder() + .accept("accept") + .runGroupRequest( + RunGroupRequest.builder() + .groupBy(RunGroupRequest.GroupBy.CONVERSATION) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .limit(1L) + .offset(0L) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + RunGroupRequest.builder() + .groupBy(RunGroupRequest.GroupBy.CONVERSATION) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .limit(1L) + .offset(0L) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + GroupCreateParams.builder() + .runGroupRequest( + RunGroupRequest.builder() + .groupBy(RunGroupRequest.GroupBy.CONVERSATION) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + RunGroupRequest.builder() + .groupBy(RunGroupRequest.GroupBy.CONVERSATION) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/group/GroupCreateResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/group/GroupCreateResponseTest.kt new file mode 100644 index 00000000..cbf974ca --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/group/GroupCreateResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.group + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class GroupCreateResponseTest { + + @Test + fun create() { + val groupCreateResponse = GroupCreateResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val groupCreateResponse = GroupCreateResponse.builder().build() + + val roundtrippedGroupCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(groupCreateResponse), + jacksonTypeRef<GroupCreateResponse>(), + ) + + assertThat(roundtrippedGroupCreateResponse).isEqualTo(groupCreateResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/group/GroupStatsParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/group/GroupStatsParamsTest.kt new file mode 100644 index 00000000..6daf234f --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/group/GroupStatsParamsTest.kt @@ -0,0 +1,83 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.group + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class GroupStatsParamsTest { + + @Test + fun create() { + GroupStatsParams.builder() + .runGroupRequest( + RunGroupRequest.builder() + .groupBy(RunGroupRequest.GroupBy.CONVERSATION) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .limit(1L) + .offset(0L) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + } + + @Test + fun body() { + val params = + GroupStatsParams.builder() + .runGroupRequest( + RunGroupRequest.builder() + .groupBy(RunGroupRequest.GroupBy.CONVERSATION) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .limit(1L) + .offset(0L) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + RunGroupRequest.builder() + .groupBy(RunGroupRequest.GroupBy.CONVERSATION) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .limit(1L) + .offset(0L) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + GroupStatsParams.builder() + .runGroupRequest( + RunGroupRequest.builder() + .groupBy(RunGroupRequest.GroupBy.CONVERSATION) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + RunGroupRequest.builder() + .groupBy(RunGroupRequest.GroupBy.CONVERSATION) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/group/GroupStatsResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/group/GroupStatsResponseTest.kt new file mode 100644 index 00000000..400f0e96 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/group/GroupStatsResponseTest.kt @@ -0,0 +1,132 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.group + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class GroupStatsResponseTest { + + @Test + fun create() { + val groupStatsResponse = + GroupStatsResponse.builder() + .groupCount(0L) + .completionCost("completion_cost") + .completionCostDetails(JsonValue.from(mapOf<String, Any>())) + .completionTokenDetails(JsonValue.from(mapOf<String, Any>())) + .completionTokens(0L) + .completionTokensP50(0L) + .completionTokensP99(0L) + .costP50("cost_p50") + .costP99("cost_p99") + .errorRate(0.0) + .feedbackStats(JsonValue.from(mapOf<String, Any>())) + .firstTokenP50(0.0) + .firstTokenP99(0.0) + .lastRunStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .latencyP50(0.0) + .latencyP99(0.0) + .medianTokens(0L) + .promptCost("prompt_cost") + .promptCostDetails(JsonValue.from(mapOf<String, Any>())) + .promptTokenDetails(JsonValue.from(mapOf<String, Any>())) + .promptTokens(0L) + .promptTokensP50(0L) + .promptTokensP99(0L) + .runCount(0L) + .addRunFacet(JsonValue.from(mapOf<String, Any>())) + .streamingRate(0.0) + .tokensP99(0L) + .totalCost("total_cost") + .totalTokens(0L) + .build() + + assertThat(groupStatsResponse.groupCount()).isEqualTo(0L) + assertThat(groupStatsResponse.completionCost()).contains("completion_cost") + assertThat(groupStatsResponse._completionCostDetails()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(groupStatsResponse._completionTokenDetails()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(groupStatsResponse.completionTokens()).contains(0L) + assertThat(groupStatsResponse.completionTokensP50()).contains(0L) + assertThat(groupStatsResponse.completionTokensP99()).contains(0L) + assertThat(groupStatsResponse.costP50()).contains("cost_p50") + assertThat(groupStatsResponse.costP99()).contains("cost_p99") + assertThat(groupStatsResponse.errorRate()).contains(0.0) + assertThat(groupStatsResponse._feedbackStats()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(groupStatsResponse.firstTokenP50()).contains(0.0) + assertThat(groupStatsResponse.firstTokenP99()).contains(0.0) + assertThat(groupStatsResponse.lastRunStartTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(groupStatsResponse.latencyP50()).contains(0.0) + assertThat(groupStatsResponse.latencyP99()).contains(0.0) + assertThat(groupStatsResponse.medianTokens()).contains(0L) + assertThat(groupStatsResponse.promptCost()).contains("prompt_cost") + assertThat(groupStatsResponse._promptCostDetails()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(groupStatsResponse._promptTokenDetails()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(groupStatsResponse.promptTokens()).contains(0L) + assertThat(groupStatsResponse.promptTokensP50()).contains(0L) + assertThat(groupStatsResponse.promptTokensP99()).contains(0L) + assertThat(groupStatsResponse.runCount()).contains(0L) + assertThat(groupStatsResponse.runFacets().getOrNull()) + .containsExactly(JsonValue.from(mapOf<String, Any>())) + assertThat(groupStatsResponse.streamingRate()).contains(0.0) + assertThat(groupStatsResponse.tokensP99()).contains(0L) + assertThat(groupStatsResponse.totalCost()).contains("total_cost") + assertThat(groupStatsResponse.totalTokens()).contains(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val groupStatsResponse = + GroupStatsResponse.builder() + .groupCount(0L) + .completionCost("completion_cost") + .completionCostDetails(JsonValue.from(mapOf<String, Any>())) + .completionTokenDetails(JsonValue.from(mapOf<String, Any>())) + .completionTokens(0L) + .completionTokensP50(0L) + .completionTokensP99(0L) + .costP50("cost_p50") + .costP99("cost_p99") + .errorRate(0.0) + .feedbackStats(JsonValue.from(mapOf<String, Any>())) + .firstTokenP50(0.0) + .firstTokenP99(0.0) + .lastRunStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .latencyP50(0.0) + .latencyP99(0.0) + .medianTokens(0L) + .promptCost("prompt_cost") + .promptCostDetails(JsonValue.from(mapOf<String, Any>())) + .promptTokenDetails(JsonValue.from(mapOf<String, Any>())) + .promptTokens(0L) + .promptTokensP50(0L) + .promptTokensP99(0L) + .runCount(0L) + .addRunFacet(JsonValue.from(mapOf<String, Any>())) + .streamingRate(0.0) + .tokensP99(0L) + .totalCost("total_cost") + .totalTokens(0L) + .build() + + val roundtrippedGroupStatsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(groupStatsResponse), + jacksonTypeRef<GroupStatsResponse>(), + ) + + assertThat(roundtrippedGroupStatsResponse).isEqualTo(groupStatsResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/group/RunGroupRequestTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/group/RunGroupRequestTest.kt new file mode 100644 index 00000000..9b882c1f --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/group/RunGroupRequestTest.kt @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.group + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunGroupRequestTest { + + @Test + fun create() { + val runGroupRequest = + RunGroupRequest.builder() + .groupBy(RunGroupRequest.GroupBy.CONVERSATION) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .limit(1L) + .offset(0L) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(runGroupRequest.groupBy()).isEqualTo(RunGroupRequest.GroupBy.CONVERSATION) + assertThat(runGroupRequest.sessionId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runGroupRequest.endTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runGroupRequest.filter()).contains("filter") + assertThat(runGroupRequest.limit()).contains(1L) + assertThat(runGroupRequest.offset()).contains(0L) + assertThat(runGroupRequest.startTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val runGroupRequest = + RunGroupRequest.builder() + .groupBy(RunGroupRequest.GroupBy.CONVERSATION) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .limit(1L) + .offset(0L) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedRunGroupRequest = + jsonMapper.readValue( + jsonMapper.writeValueAsString(runGroupRequest), + jacksonTypeRef<RunGroupRequest>(), + ) + + assertThat(roundtrippedRunGroupRequest).isEqualTo(runGroupRequest) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/CodeEvaluatorTopLevelTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/CodeEvaluatorTopLevelTest.kt new file mode 100644 index 00000000..e03da35b --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/CodeEvaluatorTopLevelTest.kt @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.rules + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CodeEvaluatorTopLevelTest { + + @Test + fun create() { + val codeEvaluatorTopLevel = + CodeEvaluatorTopLevel.builder() + .code("code") + .language(CodeEvaluatorTopLevel.Language.PYTHON) + .build() + + assertThat(codeEvaluatorTopLevel.code()).isEqualTo("code") + assertThat(codeEvaluatorTopLevel.language()).contains(CodeEvaluatorTopLevel.Language.PYTHON) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val codeEvaluatorTopLevel = + CodeEvaluatorTopLevel.builder() + .code("code") + .language(CodeEvaluatorTopLevel.Language.PYTHON) + .build() + + val roundtrippedCodeEvaluatorTopLevel = + jsonMapper.readValue( + jsonMapper.writeValueAsString(codeEvaluatorTopLevel), + jacksonTypeRef<CodeEvaluatorTopLevel>(), + ) + + assertThat(roundtrippedCodeEvaluatorTopLevel).isEqualTo(codeEvaluatorTopLevel) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/EvaluatorTopLevelTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/EvaluatorTopLevelTest.kt new file mode 100644 index 00000000..f68e28b5 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/EvaluatorTopLevelTest.kt @@ -0,0 +1,94 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.rules + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class EvaluatorTopLevelTest { + + @Test + fun create() { + val evaluatorTopLevel = + EvaluatorTopLevel.builder() + .structured( + EvaluatorTopLevel.Structured.builder() + .hubRef("hub_ref") + .model(JsonValue.from(mapOf<String, Any>())) + .addPrompt( + listOf( + JsonValue.from(mapOf<String, Any>()), + JsonValue.from(mapOf<String, Any>()), + ) + ) + .schema(JsonValue.from(mapOf<String, Any>())) + .templateFormat("template_format") + .variableMapping( + EvaluatorTopLevel.Structured.VariableMapping.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + .build() + + assertThat(evaluatorTopLevel.structured()) + .isEqualTo( + EvaluatorTopLevel.Structured.builder() + .hubRef("hub_ref") + .model(JsonValue.from(mapOf<String, Any>())) + .addPrompt( + listOf( + JsonValue.from(mapOf<String, Any>()), + JsonValue.from(mapOf<String, Any>()), + ) + ) + .schema(JsonValue.from(mapOf<String, Any>())) + .templateFormat("template_format") + .variableMapping( + EvaluatorTopLevel.Structured.VariableMapping.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val evaluatorTopLevel = + EvaluatorTopLevel.builder() + .structured( + EvaluatorTopLevel.Structured.builder() + .hubRef("hub_ref") + .model(JsonValue.from(mapOf<String, Any>())) + .addPrompt( + listOf( + JsonValue.from(mapOf<String, Any>()), + JsonValue.from(mapOf<String, Any>()), + ) + ) + .schema(JsonValue.from(mapOf<String, Any>())) + .templateFormat("template_format") + .variableMapping( + EvaluatorTopLevel.Structured.VariableMapping.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + .build() + + val roundtrippedEvaluatorTopLevel = + jsonMapper.readValue( + jsonMapper.writeValueAsString(evaluatorTopLevel), + jacksonTypeRef<EvaluatorTopLevel>(), + ) + + assertThat(roundtrippedEvaluatorTopLevel).isEqualTo(evaluatorTopLevel) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleCreateParamsTest.kt new file mode 100644 index 00000000..7f29adb2 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleCreateParamsTest.kt @@ -0,0 +1,244 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.rules + +import com.langsmith_api.api.core.JsonValue +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RuleCreateParamsTest { + + @Test + fun create() { + RuleCreateParams.builder() + .displayName("display_name") + .samplingRate(0.0) + .addToAnnotationQueueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addToDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addToDatasetPreferCorrection(true) + .addAlert( + RunRulesPagerdutyAlertSchema.builder() + .routingKey("routing_key") + .severity(RunRulesPagerdutyAlertSchema.Severity.CRITICAL) + .summary("summary") + .type(RunRulesPagerdutyAlertSchema.Type.PAGERDUTY) + .build() + ) + .backfillFrom(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addCodeEvaluator( + CodeEvaluatorTopLevel.builder() + .code("code") + .language(CodeEvaluatorTopLevel.Language.PYTHON) + .build() + ) + .createAlignmentQueue(true) + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .evaluatorVersion(0L) + .addEvaluator( + EvaluatorTopLevel.builder() + .structured( + EvaluatorTopLevel.Structured.builder() + .hubRef("hub_ref") + .model(JsonValue.from(mapOf<String, Any>())) + .addPrompt( + listOf( + JsonValue.from(mapOf<String, Any>()), + JsonValue.from(mapOf<String, Any>()), + ) + ) + .schema(JsonValue.from(mapOf<String, Any>())) + .templateFormat("template_format") + .variableMapping( + EvaluatorTopLevel.Structured.VariableMapping.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + .build() + ) + .extendOnly(true) + .filter("filter") + .groupBy(RuleCreateParams.GroupBy.THREAD_ID) + .includeExtendedStats(true) + .isEnabled(true) + .numFewShotExamples(0L) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .transient_(true) + .treeFilter("tree_filter") + .useCorrectionsDataset(true) + .addWebhook( + RunRulesWebhookSchema.builder() + .url("url") + .headers( + RunRulesWebhookSchema.Headers.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + .build() + } + + @Test + fun body() { + val params = + RuleCreateParams.builder() + .displayName("display_name") + .samplingRate(0.0) + .addToAnnotationQueueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addToDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addToDatasetPreferCorrection(true) + .addAlert( + RunRulesPagerdutyAlertSchema.builder() + .routingKey("routing_key") + .severity(RunRulesPagerdutyAlertSchema.Severity.CRITICAL) + .summary("summary") + .type(RunRulesPagerdutyAlertSchema.Type.PAGERDUTY) + .build() + ) + .backfillFrom(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addCodeEvaluator( + CodeEvaluatorTopLevel.builder() + .code("code") + .language(CodeEvaluatorTopLevel.Language.PYTHON) + .build() + ) + .createAlignmentQueue(true) + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .evaluatorVersion(0L) + .addEvaluator( + EvaluatorTopLevel.builder() + .structured( + EvaluatorTopLevel.Structured.builder() + .hubRef("hub_ref") + .model(JsonValue.from(mapOf<String, Any>())) + .addPrompt( + listOf( + JsonValue.from(mapOf<String, Any>()), + JsonValue.from(mapOf<String, Any>()), + ) + ) + .schema(JsonValue.from(mapOf<String, Any>())) + .templateFormat("template_format") + .variableMapping( + EvaluatorTopLevel.Structured.VariableMapping.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + .build() + ) + .extendOnly(true) + .filter("filter") + .groupBy(RuleCreateParams.GroupBy.THREAD_ID) + .includeExtendedStats(true) + .isEnabled(true) + .numFewShotExamples(0L) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .transient_(true) + .treeFilter("tree_filter") + .useCorrectionsDataset(true) + .addWebhook( + RunRulesWebhookSchema.builder() + .url("url") + .headers( + RunRulesWebhookSchema.Headers.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.displayName()).isEqualTo("display_name") + assertThat(body.samplingRate()).isEqualTo(0.0) + assertThat(body.addToAnnotationQueueId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.addToDatasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.addToDatasetPreferCorrection()).contains(true) + assertThat(body.alerts().getOrNull()) + .containsExactly( + RunRulesPagerdutyAlertSchema.builder() + .routingKey("routing_key") + .severity(RunRulesPagerdutyAlertSchema.Severity.CRITICAL) + .summary("summary") + .type(RunRulesPagerdutyAlertSchema.Type.PAGERDUTY) + .build() + ) + assertThat(body.backfillFrom()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(body.codeEvaluators().getOrNull()) + .containsExactly( + CodeEvaluatorTopLevel.builder() + .code("code") + .language(CodeEvaluatorTopLevel.Language.PYTHON) + .build() + ) + assertThat(body.createAlignmentQueue()).contains(true) + assertThat(body.datasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.evaluatorVersion()).contains(0L) + assertThat(body.evaluators().getOrNull()) + .containsExactly( + EvaluatorTopLevel.builder() + .structured( + EvaluatorTopLevel.Structured.builder() + .hubRef("hub_ref") + .model(JsonValue.from(mapOf<String, Any>())) + .addPrompt( + listOf( + JsonValue.from(mapOf<String, Any>()), + JsonValue.from(mapOf<String, Any>()), + ) + ) + .schema(JsonValue.from(mapOf<String, Any>())) + .templateFormat("template_format") + .variableMapping( + EvaluatorTopLevel.Structured.VariableMapping.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + .build() + ) + assertThat(body.extendOnly()).contains(true) + assertThat(body.filter()).contains("filter") + assertThat(body.groupBy()).contains(RuleCreateParams.GroupBy.THREAD_ID) + assertThat(body.includeExtendedStats()).contains(true) + assertThat(body.isEnabled()).contains(true) + assertThat(body.numFewShotExamples()).contains(0L) + assertThat(body.sessionId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.traceFilter()).contains("trace_filter") + assertThat(body.transient_()).contains(true) + assertThat(body.treeFilter()).contains("tree_filter") + assertThat(body.useCorrectionsDataset()).contains(true) + assertThat(body.webhooks().getOrNull()) + .containsExactly( + RunRulesWebhookSchema.builder() + .url("url") + .headers( + RunRulesWebhookSchema.Headers.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + RuleCreateParams.builder().displayName("display_name").samplingRate(0.0).build() + + val body = params._body() + + assertThat(body.displayName()).isEqualTo("display_name") + assertThat(body.samplingRate()).isEqualTo(0.0) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleDeleteParamsTest.kt new file mode 100644 index 00000000..6141c9c9 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleDeleteParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.rules + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RuleDeleteParamsTest { + + @Test + fun create() { + RuleDeleteParams.builder().ruleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + RuleDeleteParams.builder().ruleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleDeleteResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleDeleteResponseTest.kt new file mode 100644 index 00000000..891f467e --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleDeleteResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.rules + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RuleDeleteResponseTest { + + @Test + fun create() { + val ruleDeleteResponse = RuleDeleteResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val ruleDeleteResponse = RuleDeleteResponse.builder().build() + + val roundtrippedRuleDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(ruleDeleteResponse), + jacksonTypeRef<RuleDeleteResponse>(), + ) + + assertThat(roundtrippedRuleDeleteResponse).isEqualTo(ruleDeleteResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleListParamsTest.kt new file mode 100644 index 00000000..310acfe8 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleListParamsTest.kt @@ -0,0 +1,55 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.rules + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RuleListParamsTest { + + @Test + fun create() { + RuleListParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .nameContains("name_contains") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .type(RuleListParams.Type.SESSION) + .build() + } + + @Test + fun queryParams() { + val params = + RuleListParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .nameContains("name_contains") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .type(RuleListParams.Type.SESSION) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").joinToString(",")) + .put("dataset_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("name_contains", "name_contains") + .put("session_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("type", "session") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = RuleListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleLogActionResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleLogActionResponseTest.kt new file mode 100644 index 00000000..a805bcec --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleLogActionResponseTest.kt @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.rules + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RuleLogActionResponseTest { + + @Test + fun create() { + val ruleLogActionResponse = + RuleLogActionResponse.builder() + .outcome(RuleLogActionResponse.Outcome.SUCCESS) + .payload(JsonValue.from(mapOf<String, Any>())) + .build() + + assertThat(ruleLogActionResponse.outcome()).isEqualTo(RuleLogActionResponse.Outcome.SUCCESS) + assertThat(ruleLogActionResponse._payload()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val ruleLogActionResponse = + RuleLogActionResponse.builder() + .outcome(RuleLogActionResponse.Outcome.SUCCESS) + .payload(JsonValue.from(mapOf<String, Any>())) + .build() + + val roundtrippedRuleLogActionResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(ruleLogActionResponse), + jacksonTypeRef<RuleLogActionResponse>(), + ) + + assertThat(roundtrippedRuleLogActionResponse).isEqualTo(ruleLogActionResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleLogSchemaTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleLogSchemaTest.kt new file mode 100644 index 00000000..70ea00b8 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleLogSchemaTest.kt @@ -0,0 +1,162 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.rules + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RuleLogSchemaTest { + + @Test + fun create() { + val ruleLogSchema = + RuleLogSchema.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .ruleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addToAnnotationQueue( + RuleLogActionResponse.builder() + .outcome(RuleLogActionResponse.Outcome.SUCCESS) + .payload(JsonValue.from(mapOf<String, Any>())) + .build() + ) + .addToDataset( + RuleLogActionResponse.builder() + .outcome(RuleLogActionResponse.Outcome.SUCCESS) + .payload(JsonValue.from(mapOf<String, Any>())) + .build() + ) + .alerts( + RuleLogActionResponse.builder() + .outcome(RuleLogActionResponse.Outcome.SUCCESS) + .payload(JsonValue.from(mapOf<String, Any>())) + .build() + ) + .applicationTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .evaluators( + RuleLogActionResponse.builder() + .outcome(RuleLogActionResponse.Outcome.SUCCESS) + .payload(JsonValue.from(mapOf<String, Any>())) + .build() + ) + .runName("run_name") + .runSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runType("run_type") + .threadId("thread_id") + .webhooks( + RuleLogActionResponse.builder() + .outcome(RuleLogActionResponse.Outcome.SUCCESS) + .payload(JsonValue.from(mapOf<String, Any>())) + .build() + ) + .build() + + assertThat(ruleLogSchema.endTime()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(ruleLogSchema.ruleId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(ruleLogSchema.runId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(ruleLogSchema.startTime()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(ruleLogSchema.addToAnnotationQueue()) + .contains( + RuleLogActionResponse.builder() + .outcome(RuleLogActionResponse.Outcome.SUCCESS) + .payload(JsonValue.from(mapOf<String, Any>())) + .build() + ) + assertThat(ruleLogSchema.addToDataset()) + .contains( + RuleLogActionResponse.builder() + .outcome(RuleLogActionResponse.Outcome.SUCCESS) + .payload(JsonValue.from(mapOf<String, Any>())) + .build() + ) + assertThat(ruleLogSchema.alerts()) + .contains( + RuleLogActionResponse.builder() + .outcome(RuleLogActionResponse.Outcome.SUCCESS) + .payload(JsonValue.from(mapOf<String, Any>())) + .build() + ) + assertThat(ruleLogSchema.applicationTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(ruleLogSchema.evaluators()) + .contains( + RuleLogActionResponse.builder() + .outcome(RuleLogActionResponse.Outcome.SUCCESS) + .payload(JsonValue.from(mapOf<String, Any>())) + .build() + ) + assertThat(ruleLogSchema.runName()).contains("run_name") + assertThat(ruleLogSchema.runSessionId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(ruleLogSchema.runType()).contains("run_type") + assertThat(ruleLogSchema.threadId()).contains("thread_id") + assertThat(ruleLogSchema.webhooks()) + .contains( + RuleLogActionResponse.builder() + .outcome(RuleLogActionResponse.Outcome.SUCCESS) + .payload(JsonValue.from(mapOf<String, Any>())) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val ruleLogSchema = + RuleLogSchema.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .ruleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addToAnnotationQueue( + RuleLogActionResponse.builder() + .outcome(RuleLogActionResponse.Outcome.SUCCESS) + .payload(JsonValue.from(mapOf<String, Any>())) + .build() + ) + .addToDataset( + RuleLogActionResponse.builder() + .outcome(RuleLogActionResponse.Outcome.SUCCESS) + .payload(JsonValue.from(mapOf<String, Any>())) + .build() + ) + .alerts( + RuleLogActionResponse.builder() + .outcome(RuleLogActionResponse.Outcome.SUCCESS) + .payload(JsonValue.from(mapOf<String, Any>())) + .build() + ) + .applicationTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .evaluators( + RuleLogActionResponse.builder() + .outcome(RuleLogActionResponse.Outcome.SUCCESS) + .payload(JsonValue.from(mapOf<String, Any>())) + .build() + ) + .runName("run_name") + .runSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runType("run_type") + .threadId("thread_id") + .webhooks( + RuleLogActionResponse.builder() + .outcome(RuleLogActionResponse.Outcome.SUCCESS) + .payload(JsonValue.from(mapOf<String, Any>())) + .build() + ) + .build() + + val roundtrippedRuleLogSchema = + jsonMapper.readValue( + jsonMapper.writeValueAsString(ruleLogSchema), + jacksonTypeRef<RuleLogSchema>(), + ) + + assertThat(roundtrippedRuleLogSchema).isEqualTo(ruleLogSchema) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleRetrieveLastAppliedParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleRetrieveLastAppliedParamsTest.kt new file mode 100644 index 00000000..2458310f --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleRetrieveLastAppliedParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.rules + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RuleRetrieveLastAppliedParamsTest { + + @Test + fun create() { + RuleRetrieveLastAppliedParams.builder() + .ruleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + RuleRetrieveLastAppliedParams.builder() + .ruleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleRetrieveLogsParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleRetrieveLogsParamsTest.kt new file mode 100644 index 00000000..a6d87986 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleRetrieveLogsParamsTest.kt @@ -0,0 +1,66 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.rules + +import com.langsmith_api.api.core.http.QueryParams +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RuleRetrieveLogsParamsTest { + + @Test + fun create() { + RuleRetrieveLogsParams.builder() + .ruleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .limit(100L) + .offset(0L) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + } + + @Test + fun pathParams() { + val params = + RuleRetrieveLogsParams.builder().ruleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + RuleRetrieveLogsParams.builder() + .ruleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .limit(100L) + .offset(0L) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("end_time", "2019-12-27T18:11:19.117Z") + .put("limit", "100") + .put("offset", "0") + .put("start_time", "2019-12-27T18:11:19.117Z") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + RuleRetrieveLogsParams.builder().ruleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleUpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleUpdateParamsTest.kt new file mode 100644 index 00000000..9de82cd7 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RuleUpdateParamsTest.kt @@ -0,0 +1,261 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.rules + +import com.langsmith_api.api.core.JsonValue +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RuleUpdateParamsTest { + + @Test + fun create() { + RuleUpdateParams.builder() + .ruleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .displayName("display_name") + .samplingRate(0.0) + .addToAnnotationQueueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addToDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addToDatasetPreferCorrection(true) + .addAlert( + RunRulesPagerdutyAlertSchema.builder() + .routingKey("routing_key") + .severity(RunRulesPagerdutyAlertSchema.Severity.CRITICAL) + .summary("summary") + .type(RunRulesPagerdutyAlertSchema.Type.PAGERDUTY) + .build() + ) + .backfillFrom(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addCodeEvaluator( + CodeEvaluatorTopLevel.builder() + .code("code") + .language(CodeEvaluatorTopLevel.Language.PYTHON) + .build() + ) + .createAlignmentQueue(true) + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .evaluatorVersion(0L) + .addEvaluator( + EvaluatorTopLevel.builder() + .structured( + EvaluatorTopLevel.Structured.builder() + .hubRef("hub_ref") + .model(JsonValue.from(mapOf<String, Any>())) + .addPrompt( + listOf( + JsonValue.from(mapOf<String, Any>()), + JsonValue.from(mapOf<String, Any>()), + ) + ) + .schema(JsonValue.from(mapOf<String, Any>())) + .templateFormat("template_format") + .variableMapping( + EvaluatorTopLevel.Structured.VariableMapping.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + .build() + ) + .extendOnly(true) + .filter("filter") + .includeExtendedStats(true) + .isEnabled(true) + .numFewShotExamples(0L) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .transient_(true) + .treeFilter("tree_filter") + .useCorrectionsDataset(true) + .addWebhook( + RunRulesWebhookSchema.builder() + .url("url") + .headers( + RunRulesWebhookSchema.Headers.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + RuleUpdateParams.builder() + .ruleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .displayName("display_name") + .samplingRate(0.0) + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + RuleUpdateParams.builder() + .ruleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .displayName("display_name") + .samplingRate(0.0) + .addToAnnotationQueueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addToDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addToDatasetPreferCorrection(true) + .addAlert( + RunRulesPagerdutyAlertSchema.builder() + .routingKey("routing_key") + .severity(RunRulesPagerdutyAlertSchema.Severity.CRITICAL) + .summary("summary") + .type(RunRulesPagerdutyAlertSchema.Type.PAGERDUTY) + .build() + ) + .backfillFrom(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addCodeEvaluator( + CodeEvaluatorTopLevel.builder() + .code("code") + .language(CodeEvaluatorTopLevel.Language.PYTHON) + .build() + ) + .createAlignmentQueue(true) + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .evaluatorVersion(0L) + .addEvaluator( + EvaluatorTopLevel.builder() + .structured( + EvaluatorTopLevel.Structured.builder() + .hubRef("hub_ref") + .model(JsonValue.from(mapOf<String, Any>())) + .addPrompt( + listOf( + JsonValue.from(mapOf<String, Any>()), + JsonValue.from(mapOf<String, Any>()), + ) + ) + .schema(JsonValue.from(mapOf<String, Any>())) + .templateFormat("template_format") + .variableMapping( + EvaluatorTopLevel.Structured.VariableMapping.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + .build() + ) + .extendOnly(true) + .filter("filter") + .includeExtendedStats(true) + .isEnabled(true) + .numFewShotExamples(0L) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .transient_(true) + .treeFilter("tree_filter") + .useCorrectionsDataset(true) + .addWebhook( + RunRulesWebhookSchema.builder() + .url("url") + .headers( + RunRulesWebhookSchema.Headers.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.displayName()).isEqualTo("display_name") + assertThat(body.samplingRate()).isEqualTo(0.0) + assertThat(body.addToAnnotationQueueId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.addToDatasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.addToDatasetPreferCorrection()).contains(true) + assertThat(body.alerts().getOrNull()) + .containsExactly( + RunRulesPagerdutyAlertSchema.builder() + .routingKey("routing_key") + .severity(RunRulesPagerdutyAlertSchema.Severity.CRITICAL) + .summary("summary") + .type(RunRulesPagerdutyAlertSchema.Type.PAGERDUTY) + .build() + ) + assertThat(body.backfillFrom()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(body.codeEvaluators().getOrNull()) + .containsExactly( + CodeEvaluatorTopLevel.builder() + .code("code") + .language(CodeEvaluatorTopLevel.Language.PYTHON) + .build() + ) + assertThat(body.createAlignmentQueue()).contains(true) + assertThat(body.datasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.evaluatorVersion()).contains(0L) + assertThat(body.evaluators().getOrNull()) + .containsExactly( + EvaluatorTopLevel.builder() + .structured( + EvaluatorTopLevel.Structured.builder() + .hubRef("hub_ref") + .model(JsonValue.from(mapOf<String, Any>())) + .addPrompt( + listOf( + JsonValue.from(mapOf<String, Any>()), + JsonValue.from(mapOf<String, Any>()), + ) + ) + .schema(JsonValue.from(mapOf<String, Any>())) + .templateFormat("template_format") + .variableMapping( + EvaluatorTopLevel.Structured.VariableMapping.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + .build() + ) + assertThat(body.extendOnly()).contains(true) + assertThat(body.filter()).contains("filter") + assertThat(body.includeExtendedStats()).contains(true) + assertThat(body.isEnabled()).contains(true) + assertThat(body.numFewShotExamples()).contains(0L) + assertThat(body.sessionId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.traceFilter()).contains("trace_filter") + assertThat(body.transient_()).contains(true) + assertThat(body.treeFilter()).contains("tree_filter") + assertThat(body.useCorrectionsDataset()).contains(true) + assertThat(body.webhooks().getOrNull()) + .containsExactly( + RunRulesWebhookSchema.builder() + .url("url") + .headers( + RunRulesWebhookSchema.Headers.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + RuleUpdateParams.builder() + .ruleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .displayName("display_name") + .samplingRate(0.0) + .build() + + val body = params._body() + + assertThat(body.displayName()).isEqualTo("display_name") + assertThat(body.samplingRate()).isEqualTo(0.0) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RunRulesPagerdutyAlertSchemaTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RunRulesPagerdutyAlertSchemaTest.kt new file mode 100644 index 00000000..9799865a --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RunRulesPagerdutyAlertSchemaTest.kt @@ -0,0 +1,49 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.rules + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunRulesPagerdutyAlertSchemaTest { + + @Test + fun create() { + val runRulesPagerdutyAlertSchema = + RunRulesPagerdutyAlertSchema.builder() + .routingKey("routing_key") + .severity(RunRulesPagerdutyAlertSchema.Severity.CRITICAL) + .summary("summary") + .type(RunRulesPagerdutyAlertSchema.Type.PAGERDUTY) + .build() + + assertThat(runRulesPagerdutyAlertSchema.routingKey()).isEqualTo("routing_key") + assertThat(runRulesPagerdutyAlertSchema.severity()) + .contains(RunRulesPagerdutyAlertSchema.Severity.CRITICAL) + assertThat(runRulesPagerdutyAlertSchema.summary()).contains("summary") + assertThat(runRulesPagerdutyAlertSchema.type()) + .contains(RunRulesPagerdutyAlertSchema.Type.PAGERDUTY) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val runRulesPagerdutyAlertSchema = + RunRulesPagerdutyAlertSchema.builder() + .routingKey("routing_key") + .severity(RunRulesPagerdutyAlertSchema.Severity.CRITICAL) + .summary("summary") + .type(RunRulesPagerdutyAlertSchema.Type.PAGERDUTY) + .build() + + val roundtrippedRunRulesPagerdutyAlertSchema = + jsonMapper.readValue( + jsonMapper.writeValueAsString(runRulesPagerdutyAlertSchema), + jacksonTypeRef<RunRulesPagerdutyAlertSchema>(), + ) + + assertThat(roundtrippedRunRulesPagerdutyAlertSchema).isEqualTo(runRulesPagerdutyAlertSchema) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RunRulesSchemaTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RunRulesSchemaTest.kt new file mode 100644 index 00000000..1e1bc862 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RunRulesSchemaTest.kt @@ -0,0 +1,280 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.rules + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunRulesSchemaTest { + + @Test + fun create() { + val runRulesSchema = + RunRulesSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .displayName("display_name") + .evaluatorVersion(0L) + .samplingRate(0.0) + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addWebhook( + RunRulesWebhookSchema.builder() + .url("url") + .headers( + RunRulesWebhookSchema.Headers.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + .addToAnnotationQueueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addToAnnotationQueueName("add_to_annotation_queue_name") + .addToDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addToDatasetName("add_to_dataset_name") + .addToDatasetPreferCorrection(true) + .addAlert( + RunRulesPagerdutyAlertSchema.builder() + .routingKey("routing_key") + .severity(RunRulesPagerdutyAlertSchema.Severity.CRITICAL) + .summary("summary") + .type(RunRulesPagerdutyAlertSchema.Type.PAGERDUTY) + .build() + ) + .alignmentAnnotationQueueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .backfillFrom(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addCodeEvaluator( + CodeEvaluatorTopLevel.builder() + .code("code") + .language(CodeEvaluatorTopLevel.Language.PYTHON) + .build() + ) + .correctionsDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetName("dataset_name") + .evaluatorId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvaluator( + EvaluatorTopLevel.builder() + .structured( + EvaluatorTopLevel.Structured.builder() + .hubRef("hub_ref") + .model(JsonValue.from(mapOf<String, Any>())) + .addPrompt( + listOf( + JsonValue.from(mapOf<String, Any>()), + JsonValue.from(mapOf<String, Any>()), + ) + ) + .schema(JsonValue.from(mapOf<String, Any>())) + .templateFormat("template_format") + .variableMapping( + EvaluatorTopLevel.Structured.VariableMapping.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + .build() + ) + .extendOnly(true) + .filter("filter") + .groupBy(RunRulesSchema.GroupBy.THREAD_ID) + .includeExtendedStats(true) + .isEnabled(true) + .numFewShotExamples(0L) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sessionName("session_name") + .traceFilter("trace_filter") + .transient_(true) + .treeFilter("tree_filter") + .useCorrectionsDataset(true) + .build() + + assertThat(runRulesSchema.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runRulesSchema.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runRulesSchema.displayName()).isEqualTo("display_name") + assertThat(runRulesSchema.evaluatorVersion()).isEqualTo(0L) + assertThat(runRulesSchema.samplingRate()).isEqualTo(0.0) + assertThat(runRulesSchema.tenantId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runRulesSchema.updatedAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runRulesSchema.webhooks().getOrNull()) + .containsExactly( + RunRulesWebhookSchema.builder() + .url("url") + .headers( + RunRulesWebhookSchema.Headers.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + assertThat(runRulesSchema.addToAnnotationQueueId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runRulesSchema.addToAnnotationQueueName()) + .contains("add_to_annotation_queue_name") + assertThat(runRulesSchema.addToDatasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runRulesSchema.addToDatasetName()).contains("add_to_dataset_name") + assertThat(runRulesSchema.addToDatasetPreferCorrection()).contains(true) + assertThat(runRulesSchema.alerts().getOrNull()) + .containsExactly( + RunRulesPagerdutyAlertSchema.builder() + .routingKey("routing_key") + .severity(RunRulesPagerdutyAlertSchema.Severity.CRITICAL) + .summary("summary") + .type(RunRulesPagerdutyAlertSchema.Type.PAGERDUTY) + .build() + ) + assertThat(runRulesSchema.alignmentAnnotationQueueId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runRulesSchema.backfillFrom()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(runRulesSchema.codeEvaluators().getOrNull()) + .containsExactly( + CodeEvaluatorTopLevel.builder() + .code("code") + .language(CodeEvaluatorTopLevel.Language.PYTHON) + .build() + ) + assertThat(runRulesSchema.correctionsDatasetId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runRulesSchema.datasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runRulesSchema.datasetName()).contains("dataset_name") + assertThat(runRulesSchema.evaluatorId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runRulesSchema.evaluators().getOrNull()) + .containsExactly( + EvaluatorTopLevel.builder() + .structured( + EvaluatorTopLevel.Structured.builder() + .hubRef("hub_ref") + .model(JsonValue.from(mapOf<String, Any>())) + .addPrompt( + listOf( + JsonValue.from(mapOf<String, Any>()), + JsonValue.from(mapOf<String, Any>()), + ) + ) + .schema(JsonValue.from(mapOf<String, Any>())) + .templateFormat("template_format") + .variableMapping( + EvaluatorTopLevel.Structured.VariableMapping.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + .build() + ) + assertThat(runRulesSchema.extendOnly()).contains(true) + assertThat(runRulesSchema.filter()).contains("filter") + assertThat(runRulesSchema.groupBy()).contains(RunRulesSchema.GroupBy.THREAD_ID) + assertThat(runRulesSchema.includeExtendedStats()).contains(true) + assertThat(runRulesSchema.isEnabled()).contains(true) + assertThat(runRulesSchema.numFewShotExamples()).contains(0L) + assertThat(runRulesSchema.sessionId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runRulesSchema.sessionName()).contains("session_name") + assertThat(runRulesSchema.traceFilter()).contains("trace_filter") + assertThat(runRulesSchema.transient_()).contains(true) + assertThat(runRulesSchema.treeFilter()).contains("tree_filter") + assertThat(runRulesSchema.useCorrectionsDataset()).contains(true) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val runRulesSchema = + RunRulesSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .displayName("display_name") + .evaluatorVersion(0L) + .samplingRate(0.0) + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addWebhook( + RunRulesWebhookSchema.builder() + .url("url") + .headers( + RunRulesWebhookSchema.Headers.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + .addToAnnotationQueueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addToAnnotationQueueName("add_to_annotation_queue_name") + .addToDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addToDatasetName("add_to_dataset_name") + .addToDatasetPreferCorrection(true) + .addAlert( + RunRulesPagerdutyAlertSchema.builder() + .routingKey("routing_key") + .severity(RunRulesPagerdutyAlertSchema.Severity.CRITICAL) + .summary("summary") + .type(RunRulesPagerdutyAlertSchema.Type.PAGERDUTY) + .build() + ) + .alignmentAnnotationQueueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .backfillFrom(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addCodeEvaluator( + CodeEvaluatorTopLevel.builder() + .code("code") + .language(CodeEvaluatorTopLevel.Language.PYTHON) + .build() + ) + .correctionsDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetName("dataset_name") + .evaluatorId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvaluator( + EvaluatorTopLevel.builder() + .structured( + EvaluatorTopLevel.Structured.builder() + .hubRef("hub_ref") + .model(JsonValue.from(mapOf<String, Any>())) + .addPrompt( + listOf( + JsonValue.from(mapOf<String, Any>()), + JsonValue.from(mapOf<String, Any>()), + ) + ) + .schema(JsonValue.from(mapOf<String, Any>())) + .templateFormat("template_format") + .variableMapping( + EvaluatorTopLevel.Structured.VariableMapping.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + .build() + ) + .extendOnly(true) + .filter("filter") + .groupBy(RunRulesSchema.GroupBy.THREAD_ID) + .includeExtendedStats(true) + .isEnabled(true) + .numFewShotExamples(0L) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sessionName("session_name") + .traceFilter("trace_filter") + .transient_(true) + .treeFilter("tree_filter") + .useCorrectionsDataset(true) + .build() + + val roundtrippedRunRulesSchema = + jsonMapper.readValue( + jsonMapper.writeValueAsString(runRulesSchema), + jacksonTypeRef<RunRulesSchema>(), + ) + + assertThat(roundtrippedRunRulesSchema).isEqualTo(runRulesSchema) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RunRulesWebhookSchemaTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RunRulesWebhookSchemaTest.kt new file mode 100644 index 00000000..fa0c7e14 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/RunRulesWebhookSchemaTest.kt @@ -0,0 +1,55 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.rules + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunRulesWebhookSchemaTest { + + @Test + fun create() { + val runRulesWebhookSchema = + RunRulesWebhookSchema.builder() + .url("url") + .headers( + RunRulesWebhookSchema.Headers.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + + assertThat(runRulesWebhookSchema.url()).isEqualTo("url") + assertThat(runRulesWebhookSchema.headers()) + .contains( + RunRulesWebhookSchema.Headers.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val runRulesWebhookSchema = + RunRulesWebhookSchema.builder() + .url("url") + .headers( + RunRulesWebhookSchema.Headers.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + + val roundtrippedRunRulesWebhookSchema = + jsonMapper.readValue( + jsonMapper.writeValueAsString(runRulesWebhookSchema), + jacksonTypeRef<RunRulesWebhookSchema>(), + ) + + assertThat(roundtrippedRunRulesWebhookSchema).isEqualTo(runRulesWebhookSchema) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/trigger/TriggerCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/trigger/TriggerCreateParamsTest.kt new file mode 100644 index 00000000..13cd3f34 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/trigger/TriggerCreateParamsTest.kt @@ -0,0 +1,40 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.rules.trigger + +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TriggerCreateParamsTest { + + @Test + fun create() { + TriggerCreateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addRuleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun body() { + val params = + TriggerCreateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addRuleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + + assertThat(body.datasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.ruleIds().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = TriggerCreateParams.builder().build() + + val body = params._body() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/trigger/TriggerCreateResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/trigger/TriggerCreateResponseTest.kt new file mode 100644 index 00000000..9be30b0c --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/rules/trigger/TriggerCreateResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.rules.trigger + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TriggerCreateResponseTest { + + @Test + fun create() { + val triggerCreateResponse = TriggerCreateResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val triggerCreateResponse = TriggerCreateResponse.builder().build() + + val roundtrippedTriggerCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(triggerCreateResponse), + jacksonTypeRef<TriggerCreateResponse>(), + ) + + assertThat(roundtrippedTriggerCreateResponse).isEqualTo(triggerCreateResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/share/RunShareSchemaTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/share/RunShareSchemaTest.kt new file mode 100644 index 00000000..7e280ecf --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/share/RunShareSchemaTest.kt @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.share + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunShareSchemaTest { + + @Test + fun create() { + val runShareSchema = + RunShareSchema.builder() + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(runShareSchema.runId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(runShareSchema.shareToken()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val runShareSchema = + RunShareSchema.builder() + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val roundtrippedRunShareSchema = + jsonMapper.readValue( + jsonMapper.writeValueAsString(runShareSchema), + jacksonTypeRef<RunShareSchema>(), + ) + + assertThat(roundtrippedRunShareSchema).isEqualTo(runShareSchema) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/share/ShareCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/share/ShareCreateParamsTest.kt new file mode 100644 index 00000000..19c89585 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/share/ShareCreateParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.share + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ShareCreateParamsTest { + + @Test + fun create() { + ShareCreateParams.builder().runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + ShareCreateParams.builder().runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/share/ShareDeleteAllParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/share/ShareDeleteAllParamsTest.kt new file mode 100644 index 00000000..e39a95a2 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/share/ShareDeleteAllParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.share + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ShareDeleteAllParamsTest { + + @Test + fun create() { + ShareDeleteAllParams.builder().runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + ShareDeleteAllParams.builder().runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/share/ShareDeleteAllResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/share/ShareDeleteAllResponseTest.kt new file mode 100644 index 00000000..3f4370b9 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/share/ShareDeleteAllResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.share + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ShareDeleteAllResponseTest { + + @Test + fun create() { + val shareDeleteAllResponse = ShareDeleteAllResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val shareDeleteAllResponse = ShareDeleteAllResponse.builder().build() + + val roundtrippedShareDeleteAllResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(shareDeleteAllResponse), + jacksonTypeRef<ShareDeleteAllResponse>(), + ) + + assertThat(roundtrippedShareDeleteAllResponse).isEqualTo(shareDeleteAllResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/share/ShareListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/share/ShareListParamsTest.kt new file mode 100644 index 00000000..2df818fd --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/runs/share/ShareListParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.runs.share + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ShareListParamsTest { + + @Test + fun create() { + ShareListParams.builder().runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = ShareListParams.builder().runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountDeleteParamsTest.kt new file mode 100644 index 00000000..66b4e6c8 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountDeleteParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.serviceaccounts + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ServiceAccountDeleteParamsTest { + + @Test + fun create() { + ServiceAccountDeleteParams.builder() + .serviceAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + ServiceAccountDeleteParams.builder() + .serviceAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountDeleteResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountDeleteResponseTest.kt new file mode 100644 index 00000000..f8c63ed1 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountDeleteResponseTest.kt @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.serviceaccounts + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ServiceAccountDeleteResponseTest { + + @Test + fun create() { + val serviceAccountDeleteResponse = + ServiceAccountDeleteResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .defaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(serviceAccountDeleteResponse.id()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(serviceAccountDeleteResponse.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(serviceAccountDeleteResponse.defaultWorkspaceId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(serviceAccountDeleteResponse.name()).isEqualTo("name") + assertThat(serviceAccountDeleteResponse.organizationId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(serviceAccountDeleteResponse.updatedAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val serviceAccountDeleteResponse = + ServiceAccountDeleteResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .defaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedServiceAccountDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(serviceAccountDeleteResponse), + jacksonTypeRef<ServiceAccountDeleteResponse>(), + ) + + assertThat(roundtrippedServiceAccountDeleteResponse).isEqualTo(serviceAccountDeleteResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountRetrieveServiceAccountsParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountRetrieveServiceAccountsParamsTest.kt new file mode 100644 index 00000000..0d741367 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountRetrieveServiceAccountsParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.serviceaccounts + +import org.junit.jupiter.api.Test + +internal class ServiceAccountRetrieveServiceAccountsParamsTest { + + @Test + fun create() { + ServiceAccountRetrieveServiceAccountsParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountRetrieveServiceAccountsResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountRetrieveServiceAccountsResponseTest.kt new file mode 100644 index 00000000..cd965e78 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountRetrieveServiceAccountsResponseTest.kt @@ -0,0 +1,60 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.serviceaccounts + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ServiceAccountRetrieveServiceAccountsResponseTest { + + @Test + fun create() { + val serviceAccountRetrieveServiceAccountsResponse = + ServiceAccountRetrieveServiceAccountsResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .defaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(serviceAccountRetrieveServiceAccountsResponse.id()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(serviceAccountRetrieveServiceAccountsResponse.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(serviceAccountRetrieveServiceAccountsResponse.defaultWorkspaceId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(serviceAccountRetrieveServiceAccountsResponse.name()).isEqualTo("name") + assertThat(serviceAccountRetrieveServiceAccountsResponse.organizationId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(serviceAccountRetrieveServiceAccountsResponse.updatedAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val serviceAccountRetrieveServiceAccountsResponse = + ServiceAccountRetrieveServiceAccountsResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .defaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedServiceAccountRetrieveServiceAccountsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(serviceAccountRetrieveServiceAccountsResponse), + jacksonTypeRef<ServiceAccountRetrieveServiceAccountsResponse>(), + ) + + assertThat(roundtrippedServiceAccountRetrieveServiceAccountsResponse) + .isEqualTo(serviceAccountRetrieveServiceAccountsResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountServiceAccountsParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountServiceAccountsParamsTest.kt new file mode 100644 index 00000000..f300117c --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountServiceAccountsParamsTest.kt @@ -0,0 +1,57 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.serviceaccounts + +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ServiceAccountServiceAccountsParamsTest { + + @Test + fun create() { + ServiceAccountServiceAccountsParams.builder() + .name("name") + .addWorkspace( + ServiceAccountServiceAccountsParams.Workspace.builder() + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + } + + @Test + fun body() { + val params = + ServiceAccountServiceAccountsParams.builder() + .name("name") + .addWorkspace( + ServiceAccountServiceAccountsParams.Workspace.builder() + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + + val body = params._body() + + assertThat(body.name()).isEqualTo("name") + assertThat(body.workspaces().getOrNull()) + .containsExactly( + ServiceAccountServiceAccountsParams.Workspace.builder() + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = ServiceAccountServiceAccountsParams.builder().name("name").build() + + val body = params._body() + + assertThat(body.name()).isEqualTo("name") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountServiceAccountsResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountServiceAccountsResponseTest.kt new file mode 100644 index 00000000..226465c3 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/serviceaccounts/ServiceAccountServiceAccountsResponseTest.kt @@ -0,0 +1,64 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.serviceaccounts + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ServiceAccountServiceAccountsResponseTest { + + @Test + fun create() { + val serviceAccountServiceAccountsResponse = + ServiceAccountServiceAccountsResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .defaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .organizationIdentityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(serviceAccountServiceAccountsResponse.id()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(serviceAccountServiceAccountsResponse.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(serviceAccountServiceAccountsResponse.defaultWorkspaceId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(serviceAccountServiceAccountsResponse.name()).isEqualTo("name") + assertThat(serviceAccountServiceAccountsResponse.organizationId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(serviceAccountServiceAccountsResponse.organizationIdentityId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(serviceAccountServiceAccountsResponse.updatedAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val serviceAccountServiceAccountsResponse = + ServiceAccountServiceAccountsResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .defaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .organizationIdentityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedServiceAccountServiceAccountsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(serviceAccountServiceAccountsResponse), + jacksonTypeRef<ServiceAccountServiceAccountsResponse>(), + ) + + assertThat(roundtrippedServiceAccountServiceAccountsResponse) + .isEqualTo(serviceAccountServiceAccountsResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/CustomChartsSectionRequestTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/CustomChartsSectionRequestTest.kt new file mode 100644 index 00000000..a0cb3d2e --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/CustomChartsSectionRequestTest.kt @@ -0,0 +1,76 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CustomChartsSectionRequestTest { + + @Test + fun create() { + val customChartsSectionRequest = + CustomChartsSectionRequest.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride(TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build()) + .timezone("timezone") + .build() + + assertThat(customChartsSectionRequest.endTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(customChartsSectionRequest.groupBy()) + .contains( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + assertThat(customChartsSectionRequest.omitData()).contains(true) + assertThat(customChartsSectionRequest.startTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(customChartsSectionRequest.stride()) + .contains(TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build()) + assertThat(customChartsSectionRequest.timezone()).contains("timezone") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customChartsSectionRequest = + CustomChartsSectionRequest.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride(TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build()) + .timezone("timezone") + .build() + + val roundtrippedCustomChartsSectionRequest = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customChartsSectionRequest), + jacksonTypeRef<CustomChartsSectionRequest>(), + ) + + assertThat(roundtrippedCustomChartsSectionRequest).isEqualTo(customChartsSectionRequest) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/CustomChartsSectionTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/CustomChartsSectionTest.kt new file mode 100644 index 00000000..c74fb86d --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/CustomChartsSectionTest.kt @@ -0,0 +1,398 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.charts.CustomChartMetric +import com.langsmith_api.api.models.api.v1.charts.CustomChartSeries +import com.langsmith_api.api.models.api.v1.charts.CustomChartSeriesFilters +import com.langsmith_api.api.models.api.v1.charts.CustomChartType +import com.langsmith_api.api.models.api.v1.charts.CustomChartsDataPoint +import com.langsmith_api.api.models.api.v1.charts.HostProjectChartMetric +import com.langsmith_api.api.models.api.v1.charts.SingleCustomChartResponse +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CustomChartsSectionTest { + + @Test + fun create() { + val customChartsSection = + CustomChartsSection.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChart( + SingleCustomChartResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .chartType(CustomChartType.LINE) + .addData( + CustomChartsDataPoint.builder() + .seriesId("series_id") + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .value(0.0) + .group("group") + .build() + ) + .index(0L) + .addSeries( + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + CustomChartSeries.GroupBy.builder() + .attribute(CustomChartSeries.GroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .setBy(CustomChartSeries.GroupBy.SetBy.SECTION) + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .title("title") + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("description") + .metadata(JsonValue.from(mapOf<String, Any>())) + .build() + ) + .title("title") + .description("description") + .index(0L) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addSubSection( + CustomChartsSection.SubSection.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChart( + SingleCustomChartResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .chartType(CustomChartType.LINE) + .addData( + CustomChartsDataPoint.builder() + .seriesId("series_id") + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .value(0.0) + .group("group") + .build() + ) + .index(0L) + .addSeries( + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + CustomChartSeries.GroupBy.builder() + .attribute(CustomChartSeries.GroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .setBy(CustomChartSeries.GroupBy.SetBy.SECTION) + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .title("title") + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("description") + .metadata(JsonValue.from(mapOf<String, Any>())) + .build() + ) + .index(0L) + .title("title") + .description("description") + .build() + ) + .build() + + assertThat(customChartsSection.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(customChartsSection.charts()) + .containsExactly( + SingleCustomChartResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .chartType(CustomChartType.LINE) + .addData( + CustomChartsDataPoint.builder() + .seriesId("series_id") + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .value(0.0) + .group("group") + .build() + ) + .index(0L) + .addSeries( + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + CustomChartSeries.GroupBy.builder() + .attribute(CustomChartSeries.GroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .setBy(CustomChartSeries.GroupBy.SetBy.SECTION) + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .title("title") + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("description") + .metadata(JsonValue.from(mapOf<String, Any>())) + .build() + ) + assertThat(customChartsSection.title()).isEqualTo("title") + assertThat(customChartsSection.description()).contains("description") + assertThat(customChartsSection.index()).contains(0L) + assertThat(customChartsSection.sessionId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(customChartsSection.subSections().getOrNull()) + .containsExactly( + CustomChartsSection.SubSection.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChart( + SingleCustomChartResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .chartType(CustomChartType.LINE) + .addData( + CustomChartsDataPoint.builder() + .seriesId("series_id") + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .value(0.0) + .group("group") + .build() + ) + .index(0L) + .addSeries( + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + CustomChartSeries.GroupBy.builder() + .attribute(CustomChartSeries.GroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .setBy(CustomChartSeries.GroupBy.SetBy.SECTION) + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .title("title") + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("description") + .metadata(JsonValue.from(mapOf<String, Any>())) + .build() + ) + .index(0L) + .title("title") + .description("description") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customChartsSection = + CustomChartsSection.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChart( + SingleCustomChartResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .chartType(CustomChartType.LINE) + .addData( + CustomChartsDataPoint.builder() + .seriesId("series_id") + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .value(0.0) + .group("group") + .build() + ) + .index(0L) + .addSeries( + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + CustomChartSeries.GroupBy.builder() + .attribute(CustomChartSeries.GroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .setBy(CustomChartSeries.GroupBy.SetBy.SECTION) + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .title("title") + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("description") + .metadata(JsonValue.from(mapOf<String, Any>())) + .build() + ) + .title("title") + .description("description") + .index(0L) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addSubSection( + CustomChartsSection.SubSection.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChart( + SingleCustomChartResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .chartType(CustomChartType.LINE) + .addData( + CustomChartsDataPoint.builder() + .seriesId("series_id") + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .value(0.0) + .group("group") + .build() + ) + .index(0L) + .addSeries( + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + CustomChartSeries.GroupBy.builder() + .attribute(CustomChartSeries.GroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .setBy(CustomChartSeries.GroupBy.SetBy.SECTION) + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .title("title") + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("description") + .metadata(JsonValue.from(mapOf<String, Any>())) + .build() + ) + .index(0L) + .title("title") + .description("description") + .build() + ) + .build() + + val roundtrippedCustomChartsSection = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customChartsSection), + jacksonTypeRef<CustomChartsSection>(), + ) + + assertThat(roundtrippedCustomChartsSection).isEqualTo(customChartsSection) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/RunStatsGroupByTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/RunStatsGroupByTest.kt new file mode 100644 index 00000000..548b1659 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/RunStatsGroupByTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunStatsGroupByTest { + + @Test + fun create() { + val runStatsGroupBy = + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + + assertThat(runStatsGroupBy.attribute()).isEqualTo(RunStatsGroupBy.Attribute.NAME) + assertThat(runStatsGroupBy.maxGroups()).contains(0L) + assertThat(runStatsGroupBy.path()).contains("path") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val runStatsGroupBy = + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + + val roundtrippedRunStatsGroupBy = + jsonMapper.readValue( + jsonMapper.writeValueAsString(runStatsGroupBy), + jacksonTypeRef<RunStatsGroupBy>(), + ) + + assertThat(roundtrippedRunStatsGroupBy).isEqualTo(runStatsGroupBy) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionCreateParamsTest.kt new file mode 100644 index 00000000..110a8d38 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionCreateParamsTest.kt @@ -0,0 +1,95 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.http.QueryParams +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TraceTier +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SessionCreateParamsTest { + + @Test + fun create() { + SessionCreateParams.builder() + .upsert(true) + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .defaultDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .extra(JsonValue.from(mapOf<String, Any>())) + .name("name") + .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceTier(TraceTier.LONGLIVED) + .build() + } + + @Test + fun queryParams() { + val params = + SessionCreateParams.builder() + .upsert(true) + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .defaultDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .extra(JsonValue.from(mapOf<String, Any>())) + .name("name") + .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceTier(TraceTier.LONGLIVED) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().put("upsert", "true").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = SessionCreateParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } + + @Test + fun body() { + val params = + SessionCreateParams.builder() + .upsert(true) + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .defaultDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .extra(JsonValue.from(mapOf<String, Any>())) + .name("name") + .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceTier(TraceTier.LONGLIVED) + .build() + + val body = params._body() + + assertThat(body.id()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.defaultDatasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.description()).contains("description") + assertThat(body.endTime()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(body._extra()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(body.name()).contains("name") + assertThat(body.referenceDatasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.startTime()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(body.traceTier()).contains(TraceTier.LONGLIVED) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = SessionCreateParams.builder().build() + + val body = params._body() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDashboardParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDashboardParamsTest.kt new file mode 100644 index 00000000..7ef85ec0 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDashboardParamsTest.kt @@ -0,0 +1,148 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions + +import com.langsmith_api.api.core.http.Headers +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SessionDashboardParamsTest { + + @Test + fun create() { + SessionDashboardParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accept("accept") + .customChartsSectionRequest( + CustomChartsSectionRequest.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride(TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build()) + .timezone("timezone") + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + SessionDashboardParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .customChartsSectionRequest(CustomChartsSectionRequest.builder().build()) + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun headers() { + val params = + SessionDashboardParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accept("accept") + .customChartsSectionRequest( + CustomChartsSectionRequest.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride(TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build()) + .timezone("timezone") + .build() + ) + .build() + + val headers = params._headers() + + assertThat(headers).isEqualTo(Headers.builder().put("accept", "accept").build()) + } + + @Test + fun headersWithoutOptionalFields() { + val params = + SessionDashboardParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .customChartsSectionRequest(CustomChartsSectionRequest.builder().build()) + .build() + + val headers = params._headers() + + assertThat(headers).isEqualTo(Headers.builder().build()) + } + + @Test + fun body() { + val params = + SessionDashboardParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accept("accept") + .customChartsSectionRequest( + CustomChartsSectionRequest.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride(TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build()) + .timezone("timezone") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + CustomChartsSectionRequest.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride(TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build()) + .timezone("timezone") + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + SessionDashboardParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .customChartsSectionRequest(CustomChartsSectionRequest.builder().build()) + .build() + + val body = params._body() + + assertThat(body).isEqualTo(CustomChartsSectionRequest.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDeleteAllParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDeleteAllParamsTest.kt new file mode 100644 index 00000000..1040c44e --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDeleteAllParamsTest.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SessionDeleteAllParamsTest { + + @Test + fun create() { + SessionDeleteAllParams.builder() + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun queryParams() { + val params = + SessionDeleteAllParams.builder() + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put( + "session_ids", + listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").joinToString(","), + ) + .build() + ) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDeleteAllResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDeleteAllResponseTest.kt new file mode 100644 index 00000000..ec8118ad --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDeleteAllResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SessionDeleteAllResponseTest { + + @Test + fun create() { + val sessionDeleteAllResponse = SessionDeleteAllResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val sessionDeleteAllResponse = SessionDeleteAllResponse.builder().build() + + val roundtrippedSessionDeleteAllResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(sessionDeleteAllResponse), + jacksonTypeRef<SessionDeleteAllResponse>(), + ) + + assertThat(roundtrippedSessionDeleteAllResponse).isEqualTo(sessionDeleteAllResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDeleteParamsTest.kt new file mode 100644 index 00000000..43d47202 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDeleteParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SessionDeleteParamsTest { + + @Test + fun create() { + SessionDeleteParams.builder().sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + SessionDeleteParams.builder().sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDeleteResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDeleteResponseTest.kt new file mode 100644 index 00000000..c23c5d6e --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionDeleteResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SessionDeleteResponseTest { + + @Test + fun create() { + val sessionDeleteResponse = SessionDeleteResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val sessionDeleteResponse = SessionDeleteResponse.builder().build() + + val roundtrippedSessionDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(sessionDeleteResponse), + jacksonTypeRef<SessionDeleteResponse>(), + ) + + assertThat(roundtrippedSessionDeleteResponse).isEqualTo(sessionDeleteResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionListParamsTest.kt new file mode 100644 index 00000000..bc7dd5c8 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionListParamsTest.kt @@ -0,0 +1,143 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions + +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SessionListParamsTest { + + @Test + fun create() { + SessionListParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .facets(true) + .filter("filter") + .includeStats(true) + .limit(1L) + .metadata("metadata") + .name("name") + .nameContains("name_contains") + .offset(0L) + .addReferenceDataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .referenceFree(true) + .sortBy(SessionSortableColumns.NAME) + .sortByDesc(true) + .sortByFeedbackKey("sort_by_feedback_key") + .statsStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .useApproxStats(true) + .accept("accept") + .build() + } + + @Test + fun headers() { + val params = + SessionListParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .facets(true) + .filter("filter") + .includeStats(true) + .limit(1L) + .metadata("metadata") + .name("name") + .nameContains("name_contains") + .offset(0L) + .addReferenceDataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .referenceFree(true) + .sortBy(SessionSortableColumns.NAME) + .sortByDesc(true) + .sortByFeedbackKey("sort_by_feedback_key") + .statsStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .useApproxStats(true) + .accept("accept") + .build() + + val headers = params._headers() + + assertThat(headers).isEqualTo(Headers.builder().put("accept", "accept").build()) + } + + @Test + fun headersWithoutOptionalFields() { + val params = SessionListParams.builder().build() + + val headers = params._headers() + + assertThat(headers).isEqualTo(Headers.builder().build()) + } + + @Test + fun queryParams() { + val params = + SessionListParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .facets(true) + .filter("filter") + .includeStats(true) + .limit(1L) + .metadata("metadata") + .name("name") + .nameContains("name_contains") + .offset(0L) + .addReferenceDataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .referenceFree(true) + .sortBy(SessionSortableColumns.NAME) + .sortByDesc(true) + .sortByFeedbackKey("sort_by_feedback_key") + .statsStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .useApproxStats(true) + .accept("accept") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").joinToString(",")) + .put("dataset_version", "dataset_version") + .put("facets", "true") + .put("filter", "filter") + .put("include_stats", "true") + .put("limit", "1") + .put("metadata", "metadata") + .put("name", "name") + .put("name_contains", "name_contains") + .put("offset", "0") + .put( + "reference_dataset", + listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").joinToString(","), + ) + .put("reference_free", "true") + .put("sort_by", "name") + .put("sort_by_desc", "true") + .put("sort_by_feedback_key", "sort_by_feedback_key") + .put("stats_start_time", "2019-12-27T18:11:19.117Z") + .put( + "tag_value_id", + listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").joinToString(","), + ) + .put("use_approx_stats", "true") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = SessionListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionRetrieveMetadataParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionRetrieveMetadataParamsTest.kt new file mode 100644 index 00000000..62042de8 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionRetrieveMetadataParamsTest.kt @@ -0,0 +1,70 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions + +import com.langsmith_api.api.core.http.QueryParams +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SessionRetrieveMetadataParamsTest { + + @Test + fun create() { + SessionRetrieveMetadataParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .k(1L) + .addMetadataKey("string") + .rootRunsOnly(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + } + + @Test + fun pathParams() { + val params = + SessionRetrieveMetadataParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + SessionRetrieveMetadataParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .k(1L) + .addMetadataKey("string") + .rootRunsOnly(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("k", "1") + .put("metadata_keys", listOf("string").joinToString(",")) + .put("root_runs_only", "true") + .put("start_time", "2019-12-27T18:11:19.117Z") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + SessionRetrieveMetadataParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionRetrieveMetadataResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionRetrieveMetadataResponseTest.kt new file mode 100644 index 00000000..dc4737e8 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionRetrieveMetadataResponseTest.kt @@ -0,0 +1,38 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SessionRetrieveMetadataResponseTest { + + @Test + fun create() { + val sessionRetrieveMetadataResponse = + SessionRetrieveMetadataResponse.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val sessionRetrieveMetadataResponse = + SessionRetrieveMetadataResponse.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + + val roundtrippedSessionRetrieveMetadataResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(sessionRetrieveMetadataResponse), + jacksonTypeRef<SessionRetrieveMetadataResponse>(), + ) + + assertThat(roundtrippedSessionRetrieveMetadataResponse) + .isEqualTo(sessionRetrieveMetadataResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionRetrieveParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionRetrieveParamsTest.kt new file mode 100644 index 00000000..a64d0707 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionRetrieveParamsTest.kt @@ -0,0 +1,94 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions + +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.http.QueryParams +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SessionRetrieveParamsTest { + + @Test + fun create() { + SessionRetrieveParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .includeStats(true) + .statsStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .accept("accept") + .build() + } + + @Test + fun pathParams() { + val params = + SessionRetrieveParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun headers() { + val params = + SessionRetrieveParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .includeStats(true) + .statsStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .accept("accept") + .build() + + val headers = params._headers() + + assertThat(headers).isEqualTo(Headers.builder().put("accept", "accept").build()) + } + + @Test + fun headersWithoutOptionalFields() { + val params = + SessionRetrieveParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val headers = params._headers() + + assertThat(headers).isEqualTo(Headers.builder().build()) + } + + @Test + fun queryParams() { + val params = + SessionRetrieveParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .includeStats(true) + .statsStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .accept("accept") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("include_stats", "true") + .put("stats_start_time", "2019-12-27T18:11:19.117Z") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + SessionRetrieveParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionUpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionUpdateParamsTest.kt new file mode 100644 index 00000000..7d1fbb67 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/SessionUpdateParamsTest.kt @@ -0,0 +1,66 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TraceTier +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SessionUpdateParamsTest { + + @Test + fun create() { + SessionUpdateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .defaultDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .extra(JsonValue.from(mapOf<String, Any>())) + .name("name") + .traceTier(TraceTier.LONGLIVED) + .build() + } + + @Test + fun pathParams() { + val params = + SessionUpdateParams.builder().sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + SessionUpdateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .defaultDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .extra(JsonValue.from(mapOf<String, Any>())) + .name("name") + .traceTier(TraceTier.LONGLIVED) + .build() + + val body = params._body() + + assertThat(body.defaultDatasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.description()).contains("description") + assertThat(body.endTime()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(body._extra()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(body.name()).contains("name") + assertThat(body.traceTier()).contains(TraceTier.LONGLIVED) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + SessionUpdateParams.builder().sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + val body = params._body() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/TimedeltaInputTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/TimedeltaInputTest.kt new file mode 100644 index 00000000..e1b6313a --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/TimedeltaInputTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TimedeltaInputTest { + + @Test + fun create() { + val timedeltaInput = TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build() + + assertThat(timedeltaInput.days()).contains(0L) + assertThat(timedeltaInput.hours()).contains(0L) + assertThat(timedeltaInput.minutes()).contains(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val timedeltaInput = TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build() + + val roundtrippedTimedeltaInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(timedeltaInput), + jacksonTypeRef<TimedeltaInput>(), + ) + + assertThat(roundtrippedTimedeltaInput).isEqualTo(timedeltaInput) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/TracerSessionTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/TracerSessionTest.kt new file mode 100644 index 00000000..e005cb9a --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/TracerSessionTest.kt @@ -0,0 +1,134 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TraceTier +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TracerSessionTest { + + @Test + fun create() { + val tracerSession = + TracerSession.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost("completion_cost") + .completionTokens(0L) + .defaultDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .errorRate(0.0) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats(JsonValue.from(mapOf<String, Any>())) + .firstTokenP50(0.0) + .firstTokenP99(0.0) + .lastRunStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lastRunStartTimeLive(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .latencyP50(0.0) + .latencyP99(0.0) + .name("name") + .promptCost("prompt_cost") + .promptTokens(0L) + .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runCount(0L) + .addRunFacet(JsonValue.from(mapOf<String, Any>())) + .sessionFeedbackStats(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .streamingRate(0.0) + .testRunNumber(0L) + .totalCost("total_cost") + .totalTokens(0L) + .traceTier(TraceTier.LONGLIVED) + .build() + + assertThat(tracerSession.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(tracerSession.tenantId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(tracerSession.completionCost()).contains("completion_cost") + assertThat(tracerSession.completionTokens()).contains(0L) + assertThat(tracerSession.defaultDatasetId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(tracerSession.description()).contains("description") + assertThat(tracerSession.endTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(tracerSession.errorRate()).contains(0.0) + assertThat(tracerSession._extra()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(tracerSession._feedbackStats()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(tracerSession.firstTokenP50()).contains(0.0) + assertThat(tracerSession.firstTokenP99()).contains(0.0) + assertThat(tracerSession.lastRunStartTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(tracerSession.lastRunStartTimeLive()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(tracerSession.latencyP50()).contains(0.0) + assertThat(tracerSession.latencyP99()).contains(0.0) + assertThat(tracerSession.name()).contains("name") + assertThat(tracerSession.promptCost()).contains("prompt_cost") + assertThat(tracerSession.promptTokens()).contains(0L) + assertThat(tracerSession.referenceDatasetId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(tracerSession.runCount()).contains(0L) + assertThat(tracerSession.runFacets().getOrNull()) + .containsExactly(JsonValue.from(mapOf<String, Any>())) + assertThat(tracerSession._sessionFeedbackStats()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(tracerSession.startTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(tracerSession.streamingRate()).contains(0.0) + assertThat(tracerSession.testRunNumber()).contains(0L) + assertThat(tracerSession.totalCost()).contains("total_cost") + assertThat(tracerSession.totalTokens()).contains(0L) + assertThat(tracerSession.traceTier()).contains(TraceTier.LONGLIVED) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val tracerSession = + TracerSession.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost("completion_cost") + .completionTokens(0L) + .defaultDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .errorRate(0.0) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats(JsonValue.from(mapOf<String, Any>())) + .firstTokenP50(0.0) + .firstTokenP99(0.0) + .lastRunStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lastRunStartTimeLive(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .latencyP50(0.0) + .latencyP99(0.0) + .name("name") + .promptCost("prompt_cost") + .promptTokens(0L) + .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runCount(0L) + .addRunFacet(JsonValue.from(mapOf<String, Any>())) + .sessionFeedbackStats(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .streamingRate(0.0) + .testRunNumber(0L) + .totalCost("total_cost") + .totalTokens(0L) + .traceTier(TraceTier.LONGLIVED) + .build() + + val roundtrippedTracerSession = + jsonMapper.readValue( + jsonMapper.writeValueAsString(tracerSession), + jacksonTypeRef<TracerSession>(), + ) + + assertThat(roundtrippedTracerSession).isEqualTo(tracerSession) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/TracerSessionWithoutVirtualFieldsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/TracerSessionWithoutVirtualFieldsTest.kt new file mode 100644 index 00000000..df1d61c2 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/TracerSessionWithoutVirtualFieldsTest.kt @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TraceTier +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TracerSessionWithoutVirtualFieldsTest { + + @Test + fun create() { + val tracerSessionWithoutVirtualFields = + TracerSessionWithoutVirtualFields.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .defaultDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .extra(JsonValue.from(mapOf<String, Any>())) + .lastRunStartTimeLive(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceTier(TraceTier.LONGLIVED) + .build() + + assertThat(tracerSessionWithoutVirtualFields.id()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(tracerSessionWithoutVirtualFields.tenantId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(tracerSessionWithoutVirtualFields.defaultDatasetId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(tracerSessionWithoutVirtualFields.description()).contains("description") + assertThat(tracerSessionWithoutVirtualFields.endTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(tracerSessionWithoutVirtualFields._extra()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(tracerSessionWithoutVirtualFields.lastRunStartTimeLive()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(tracerSessionWithoutVirtualFields.name()).contains("name") + assertThat(tracerSessionWithoutVirtualFields.referenceDatasetId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(tracerSessionWithoutVirtualFields.startTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(tracerSessionWithoutVirtualFields.traceTier()).contains(TraceTier.LONGLIVED) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val tracerSessionWithoutVirtualFields = + TracerSessionWithoutVirtualFields.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .defaultDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .extra(JsonValue.from(mapOf<String, Any>())) + .lastRunStartTimeLive(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceTier(TraceTier.LONGLIVED) + .build() + + val roundtrippedTracerSessionWithoutVirtualFields = + jsonMapper.readValue( + jsonMapper.writeValueAsString(tracerSessionWithoutVirtualFields), + jacksonTypeRef<TracerSessionWithoutVirtualFields>(), + ) + + assertThat(roundtrippedTracerSessionWithoutVirtualFields) + .isEqualTo(tracerSessionWithoutVirtualFields) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/CreateRunClusteringJobRequestTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/CreateRunClusteringJobRequestTest.kt new file mode 100644 index 00000000..aff91234 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/CreateRunClusteringJobRequestTest.kt @@ -0,0 +1,108 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CreateRunClusteringJobRequestTest { + + @Test + fun create() { + val createRunClusteringJobRequest = + CreateRunClusteringJobRequest.builder() + .attributeSchemas(JsonValue.from(mapOf<String, Any>())) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addHierarchy(0L) + .lastNHours(0L) + .model(CreateRunClusteringJobRequest.Model.OPENAI) + .name("name") + .partitions( + CreateRunClusteringJobRequest.Partitions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .sample(0.0) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .summaryPrompt("summary_prompt") + .userContext( + CreateRunClusteringJobRequest.UserContext.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .validateModelSecrets(true) + .build() + + assertThat(createRunClusteringJobRequest._attributeSchemas()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(createRunClusteringJobRequest.endTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(createRunClusteringJobRequest.filter()).contains("filter") + assertThat(createRunClusteringJobRequest.hierarchy().getOrNull()).containsExactly(0L) + assertThat(createRunClusteringJobRequest.lastNHours()).contains(0L) + assertThat(createRunClusteringJobRequest.model()) + .contains(CreateRunClusteringJobRequest.Model.OPENAI) + assertThat(createRunClusteringJobRequest.name()).contains("name") + assertThat(createRunClusteringJobRequest.partitions()) + .contains( + CreateRunClusteringJobRequest.Partitions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(createRunClusteringJobRequest.sample()).contains(0.0) + assertThat(createRunClusteringJobRequest.startTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(createRunClusteringJobRequest.summaryPrompt()).contains("summary_prompt") + assertThat(createRunClusteringJobRequest.userContext()) + .contains( + CreateRunClusteringJobRequest.UserContext.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(createRunClusteringJobRequest.validateModelSecrets()).contains(true) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val createRunClusteringJobRequest = + CreateRunClusteringJobRequest.builder() + .attributeSchemas(JsonValue.from(mapOf<String, Any>())) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addHierarchy(0L) + .lastNHours(0L) + .model(CreateRunClusteringJobRequest.Model.OPENAI) + .name("name") + .partitions( + CreateRunClusteringJobRequest.Partitions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .sample(0.0) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .summaryPrompt("summary_prompt") + .userContext( + CreateRunClusteringJobRequest.UserContext.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .validateModelSecrets(true) + .build() + + val roundtrippedCreateRunClusteringJobRequest = + jsonMapper.readValue( + jsonMapper.writeValueAsString(createRunClusteringJobRequest), + jacksonTypeRef<CreateRunClusteringJobRequest>(), + ) + + assertThat(roundtrippedCreateRunClusteringJobRequest) + .isEqualTo(createRunClusteringJobRequest) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightCreateParamsTest.kt new file mode 100644 index 00000000..d293b298 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightCreateParamsTest.kt @@ -0,0 +1,131 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights + +import com.langsmith_api.api.core.JsonValue +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InsightCreateParamsTest { + + @Test + fun create() { + InsightCreateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createRunClusteringJobRequest( + CreateRunClusteringJobRequest.builder() + .attributeSchemas(JsonValue.from(mapOf<String, Any>())) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addHierarchy(0L) + .lastNHours(0L) + .model(CreateRunClusteringJobRequest.Model.OPENAI) + .name("name") + .partitions( + CreateRunClusteringJobRequest.Partitions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .sample(0.0) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .summaryPrompt("summary_prompt") + .userContext( + CreateRunClusteringJobRequest.UserContext.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .validateModelSecrets(true) + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + InsightCreateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createRunClusteringJobRequest(CreateRunClusteringJobRequest.builder().build()) + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + InsightCreateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createRunClusteringJobRequest( + CreateRunClusteringJobRequest.builder() + .attributeSchemas(JsonValue.from(mapOf<String, Any>())) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addHierarchy(0L) + .lastNHours(0L) + .model(CreateRunClusteringJobRequest.Model.OPENAI) + .name("name") + .partitions( + CreateRunClusteringJobRequest.Partitions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .sample(0.0) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .summaryPrompt("summary_prompt") + .userContext( + CreateRunClusteringJobRequest.UserContext.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .validateModelSecrets(true) + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + CreateRunClusteringJobRequest.builder() + .attributeSchemas(JsonValue.from(mapOf<String, Any>())) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addHierarchy(0L) + .lastNHours(0L) + .model(CreateRunClusteringJobRequest.Model.OPENAI) + .name("name") + .partitions( + CreateRunClusteringJobRequest.Partitions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .sample(0.0) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .summaryPrompt("summary_prompt") + .userContext( + CreateRunClusteringJobRequest.UserContext.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .validateModelSecrets(true) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + InsightCreateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createRunClusteringJobRequest(CreateRunClusteringJobRequest.builder().build()) + .build() + + val body = params._body() + + assertThat(body).isEqualTo(CreateRunClusteringJobRequest.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightCreateResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightCreateResponseTest.kt new file mode 100644 index 00000000..08abdaf3 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightCreateResponseTest.kt @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InsightCreateResponseTest { + + @Test + fun create() { + val insightCreateResponse = + InsightCreateResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .status("status") + .error("error") + .build() + + assertThat(insightCreateResponse.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(insightCreateResponse.name()).isEqualTo("name") + assertThat(insightCreateResponse.status()).isEqualTo("status") + assertThat(insightCreateResponse.error()).contains("error") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val insightCreateResponse = + InsightCreateResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .status("status") + .error("error") + .build() + + val roundtrippedInsightCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(insightCreateResponse), + jacksonTypeRef<InsightCreateResponse>(), + ) + + assertThat(roundtrippedInsightCreateResponse).isEqualTo(insightCreateResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightDeleteParamsTest.kt new file mode 100644 index 00000000..aed0ca27 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightDeleteParamsTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InsightDeleteParamsTest { + + @Test + fun create() { + InsightDeleteParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + InsightDeleteParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._pathParam(1)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightDeleteResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightDeleteResponseTest.kt new file mode 100644 index 00000000..f4bead8b --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightDeleteResponseTest.kt @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InsightDeleteResponseTest { + + @Test + fun create() { + val insightDeleteResponse = + InsightDeleteResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .message("message") + .build() + + assertThat(insightDeleteResponse.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(insightDeleteResponse.message()).isEqualTo("message") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val insightDeleteResponse = + InsightDeleteResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .message("message") + .build() + + val roundtrippedInsightDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(insightDeleteResponse), + jacksonTypeRef<InsightDeleteResponse>(), + ) + + assertThat(roundtrippedInsightDeleteResponse).isEqualTo(insightDeleteResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightListParamsTest.kt new file mode 100644 index 00000000..93d3de80 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightListParamsTest.kt @@ -0,0 +1,54 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InsightListParamsTest { + + @Test + fun create() { + InsightListParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .offset(0L) + .build() + } + + @Test + fun pathParams() { + val params = + InsightListParams.builder().sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + InsightListParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .offset(0L) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("limit", "1").put("offset", "0").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + InsightListParams.builder().sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightListResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightListResponseTest.kt new file mode 100644 index 00000000..07828722 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightListResponseTest.kt @@ -0,0 +1,74 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InsightListResponseTest { + + @Test + fun create() { + val insightListResponse = + InsightListResponse.builder() + .addClusteringJob( + InsightListResponse.ClusteringJob.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .status("status") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error("error") + .metadata(JsonValue.from(mapOf<String, Any>())) + .addShape(0L) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + + assertThat(insightListResponse.clusteringJobs()) + .containsExactly( + InsightListResponse.ClusteringJob.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .status("status") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error("error") + .metadata(JsonValue.from(mapOf<String, Any>())) + .addShape(0L) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val insightListResponse = + InsightListResponse.builder() + .addClusteringJob( + InsightListResponse.ClusteringJob.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .status("status") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error("error") + .metadata(JsonValue.from(mapOf<String, Any>())) + .addShape(0L) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + + val roundtrippedInsightListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(insightListResponse), + jacksonTypeRef<InsightListResponse>(), + ) + + assertThat(roundtrippedInsightListResponse).isEqualTo(insightListResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightRetrieveParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightRetrieveParamsTest.kt new file mode 100644 index 00000000..c007d2fc --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightRetrieveParamsTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InsightRetrieveParamsTest { + + @Test + fun create() { + InsightRetrieveParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .clusterId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + InsightRetrieveParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .clusterId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._pathParam(1)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._pathParam(2)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(3)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightRetrieveResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightRetrieveResponseTest.kt new file mode 100644 index 00000000..7f1a1a61 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightRetrieveResponseTest.kt @@ -0,0 +1,54 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InsightRetrieveResponseTest { + + @Test + fun create() { + val insightRetrieveResponse = + InsightRetrieveResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .level(0L) + .name("name") + .numChildren(0L) + .parentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(insightRetrieveResponse.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(insightRetrieveResponse.description()).isEqualTo("description") + assertThat(insightRetrieveResponse.level()).isEqualTo(0L) + assertThat(insightRetrieveResponse.name()).isEqualTo("name") + assertThat(insightRetrieveResponse.numChildren()).isEqualTo(0L) + assertThat(insightRetrieveResponse.parentId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val insightRetrieveResponse = + InsightRetrieveResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .level(0L) + .name("name") + .numChildren(0L) + .parentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val roundtrippedInsightRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(insightRetrieveResponse), + jacksonTypeRef<InsightRetrieveResponse>(), + ) + + assertThat(roundtrippedInsightRetrieveResponse).isEqualTo(insightRetrieveResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightRetrieveRunsParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightRetrieveRunsParamsTest.kt new file mode 100644 index 00000000..35af2797 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightRetrieveRunsParamsTest.kt @@ -0,0 +1,77 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InsightRetrieveRunsParamsTest { + + @Test + fun create() { + InsightRetrieveRunsParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .attributeSortKey("attribute_sort_key") + .attributeSortOrder(InsightRetrieveRunsParams.AttributeSortOrder.ASC) + .clusterId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .offset(0L) + .build() + } + + @Test + fun pathParams() { + val params = + InsightRetrieveRunsParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._pathParam(1)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + InsightRetrieveRunsParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .attributeSortKey("attribute_sort_key") + .attributeSortOrder(InsightRetrieveRunsParams.AttributeSortOrder.ASC) + .clusterId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .offset(0L) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("attribute_sort_key", "attribute_sort_key") + .put("attribute_sort_order", "asc") + .put("cluster_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("limit", "1") + .put("offset", "0") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + InsightRetrieveRunsParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightRetrieveRunsResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightRetrieveRunsResponseTest.kt new file mode 100644 index 00000000..23a51004 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightRetrieveRunsResponseTest.kt @@ -0,0 +1,43 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InsightRetrieveRunsResponseTest { + + @Test + fun create() { + val insightRetrieveRunsResponse = + InsightRetrieveRunsResponse.builder() + .offset(0L) + .addRun(JsonValue.from(mapOf<String, Any>())) + .build() + + assertThat(insightRetrieveRunsResponse.offset()).contains(0L) + assertThat(insightRetrieveRunsResponse.runs()) + .containsExactly(JsonValue.from(mapOf<String, Any>())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val insightRetrieveRunsResponse = + InsightRetrieveRunsResponse.builder() + .offset(0L) + .addRun(JsonValue.from(mapOf<String, Any>())) + .build() + + val roundtrippedInsightRetrieveRunsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(insightRetrieveRunsResponse), + jacksonTypeRef<InsightRetrieveRunsResponse>(), + ) + + assertThat(roundtrippedInsightRetrieveRunsResponse).isEqualTo(insightRetrieveRunsResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightUpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightUpdateParamsTest.kt new file mode 100644 index 00000000..0379f098 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightUpdateParamsTest.kt @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InsightUpdateParamsTest { + + @Test + fun create() { + InsightUpdateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .build() + } + + @Test + fun pathParams() { + val params = + InsightUpdateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._pathParam(1)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } + + @Test + fun body() { + val params = + InsightUpdateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .build() + + val body = params._body() + + assertThat(body.name()).isEqualTo("name") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightUpdateResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightUpdateResponseTest.kt new file mode 100644 index 00000000..5f8a12b6 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/InsightUpdateResponseTest.kt @@ -0,0 +1,35 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InsightUpdateResponseTest { + + @Test + fun create() { + val insightUpdateResponse = + InsightUpdateResponse.builder().name("name").status("status").build() + + assertThat(insightUpdateResponse.name()).isEqualTo("name") + assertThat(insightUpdateResponse.status()).isEqualTo("status") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val insightUpdateResponse = + InsightUpdateResponse.builder().name("name").status("status").build() + + val roundtrippedInsightUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(insightUpdateResponse), + jacksonTypeRef<InsightUpdateResponse>(), + ) + + assertThat(roundtrippedInsightUpdateResponse).isEqualTo(insightUpdateResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigCreateParamsTest.kt new file mode 100644 index 00000000..6b09bd51 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigCreateParamsTest.kt @@ -0,0 +1,141 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights.configs + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.sessions.insights.CreateRunClusteringJobRequest +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ConfigCreateParamsTest { + + @Test + fun create() { + ConfigCreateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config( + CreateRunClusteringJobRequest.builder() + .attributeSchemas(JsonValue.from(mapOf<String, Any>())) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addHierarchy(0L) + .lastNHours(0L) + .model(CreateRunClusteringJobRequest.Model.OPENAI) + .name("name") + .partitions( + CreateRunClusteringJobRequest.Partitions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .sample(0.0) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .summaryPrompt("summary_prompt") + .userContext( + CreateRunClusteringJobRequest.UserContext.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .validateModelSecrets(true) + .build() + ) + .name("name") + .description("description") + .build() + } + + @Test + fun pathParams() { + val params = + ConfigCreateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config(CreateRunClusteringJobRequest.builder().build()) + .name("name") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + ConfigCreateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config( + CreateRunClusteringJobRequest.builder() + .attributeSchemas(JsonValue.from(mapOf<String, Any>())) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addHierarchy(0L) + .lastNHours(0L) + .model(CreateRunClusteringJobRequest.Model.OPENAI) + .name("name") + .partitions( + CreateRunClusteringJobRequest.Partitions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .sample(0.0) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .summaryPrompt("summary_prompt") + .userContext( + CreateRunClusteringJobRequest.UserContext.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .validateModelSecrets(true) + .build() + ) + .name("name") + .description("description") + .build() + + val body = params._body() + + assertThat(body.config()) + .isEqualTo( + CreateRunClusteringJobRequest.builder() + .attributeSchemas(JsonValue.from(mapOf<String, Any>())) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addHierarchy(0L) + .lastNHours(0L) + .model(CreateRunClusteringJobRequest.Model.OPENAI) + .name("name") + .partitions( + CreateRunClusteringJobRequest.Partitions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .sample(0.0) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .summaryPrompt("summary_prompt") + .userContext( + CreateRunClusteringJobRequest.UserContext.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .validateModelSecrets(true) + .build() + ) + assertThat(body.name()).isEqualTo("name") + assertThat(body.description()).contains("description") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + ConfigCreateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config(CreateRunClusteringJobRequest.builder().build()) + .name("name") + .build() + + val body = params._body() + + assertThat(body.config()).isEqualTo(CreateRunClusteringJobRequest.builder().build()) + assertThat(body.name()).isEqualTo("name") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigDeleteParamsTest.kt new file mode 100644 index 00000000..65809166 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigDeleteParamsTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights.configs + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ConfigDeleteParamsTest { + + @Test + fun create() { + ConfigDeleteParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .configId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + ConfigDeleteParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .configId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._pathParam(1)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigDeleteResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigDeleteResponseTest.kt new file mode 100644 index 00000000..65b584ac --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigDeleteResponseTest.kt @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights.configs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ConfigDeleteResponseTest { + + @Test + fun create() { + val configDeleteResponse = + ConfigDeleteResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .message("message") + .build() + + assertThat(configDeleteResponse.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(configDeleteResponse.message()).isEqualTo("message") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val configDeleteResponse = + ConfigDeleteResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .message("message") + .build() + + val roundtrippedConfigDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(configDeleteResponse), + jacksonTypeRef<ConfigDeleteResponse>(), + ) + + assertThat(roundtrippedConfigDeleteResponse).isEqualTo(configDeleteResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigGenerateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigGenerateParamsTest.kt new file mode 100644 index 00000000..e731cd53 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigGenerateParamsTest.kt @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights.configs + +import com.langsmith_api.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ConfigGenerateParamsTest { + + @Test + fun create() { + ConfigGenerateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userContext( + ConfigGenerateParams.UserContext.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .model(ConfigGenerateParams.Model.OPENAI) + .build() + } + + @Test + fun pathParams() { + val params = + ConfigGenerateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userContext( + ConfigGenerateParams.UserContext.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + ConfigGenerateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userContext( + ConfigGenerateParams.UserContext.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .model(ConfigGenerateParams.Model.OPENAI) + .build() + + val body = params._body() + + assertThat(body.userContext()) + .isEqualTo( + ConfigGenerateParams.UserContext.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(body.model()).contains(ConfigGenerateParams.Model.OPENAI) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + ConfigGenerateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userContext( + ConfigGenerateParams.UserContext.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.userContext()) + .isEqualTo( + ConfigGenerateParams.UserContext.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigGenerateResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigGenerateResponseTest.kt new file mode 100644 index 00000000..3e0a35fc --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigGenerateResponseTest.kt @@ -0,0 +1,58 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights.configs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ConfigGenerateResponseTest { + + @Test + fun create() { + val configGenerateResponse = + ConfigGenerateResponse.builder() + .name("name") + .summaryPrompt("summary_prompt") + .attributeSchemas( + ConfigGenerateResponse.AttributeSchemas.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf<String, Any>())) + .build() + ) + .build() + + assertThat(configGenerateResponse.name()).isEqualTo("name") + assertThat(configGenerateResponse.summaryPrompt()).isEqualTo("summary_prompt") + assertThat(configGenerateResponse.attributeSchemas()) + .contains( + ConfigGenerateResponse.AttributeSchemas.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf<String, Any>())) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val configGenerateResponse = + ConfigGenerateResponse.builder() + .name("name") + .summaryPrompt("summary_prompt") + .attributeSchemas( + ConfigGenerateResponse.AttributeSchemas.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf<String, Any>())) + .build() + ) + .build() + + val roundtrippedConfigGenerateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(configGenerateResponse), + jacksonTypeRef<ConfigGenerateResponse>(), + ) + + assertThat(roundtrippedConfigGenerateResponse).isEqualTo(configGenerateResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigListParamsTest.kt new file mode 100644 index 00000000..59e89cc5 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigListParamsTest.kt @@ -0,0 +1,52 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights.configs + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ConfigListParamsTest { + + @Test + fun create() { + ConfigListParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .includePrebuilts(true) + .build() + } + + @Test + fun pathParams() { + val params = + ConfigListParams.builder().sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + ConfigListParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .includePrebuilts(true) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("include_prebuilts", "true").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + ConfigListParams.builder().sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigListResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigListResponseTest.kt new file mode 100644 index 00000000..f9545b35 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigListResponseTest.kt @@ -0,0 +1,112 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights.configs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ConfigListResponseTest { + + @Test + fun create() { + val configListResponse = + ConfigListResponse.builder() + .addConfig( + ConfigListResponse.Config.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config( + SavedRunClusteringJobRequest.builder() + .attributeSchemas(JsonValue.from(mapOf<String, Any>())) + .filter("filter") + .addHierarchy(0L) + .lastNHours(0L) + .model(SavedRunClusteringJobRequest.Model.OPENAI) + .name("name") + .partitions( + SavedRunClusteringJobRequest.Partitions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .sample(0.0) + .summaryPrompt("summary_prompt") + .build() + ) + .name("name") + .prebuilt(true) + .description("description") + .build() + ) + .build() + + assertThat(configListResponse.configs()) + .containsExactly( + ConfigListResponse.Config.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config( + SavedRunClusteringJobRequest.builder() + .attributeSchemas(JsonValue.from(mapOf<String, Any>())) + .filter("filter") + .addHierarchy(0L) + .lastNHours(0L) + .model(SavedRunClusteringJobRequest.Model.OPENAI) + .name("name") + .partitions( + SavedRunClusteringJobRequest.Partitions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .sample(0.0) + .summaryPrompt("summary_prompt") + .build() + ) + .name("name") + .prebuilt(true) + .description("description") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val configListResponse = + ConfigListResponse.builder() + .addConfig( + ConfigListResponse.Config.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config( + SavedRunClusteringJobRequest.builder() + .attributeSchemas(JsonValue.from(mapOf<String, Any>())) + .filter("filter") + .addHierarchy(0L) + .lastNHours(0L) + .model(SavedRunClusteringJobRequest.Model.OPENAI) + .name("name") + .partitions( + SavedRunClusteringJobRequest.Partitions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .sample(0.0) + .summaryPrompt("summary_prompt") + .build() + ) + .name("name") + .prebuilt(true) + .description("description") + .build() + ) + .build() + + val roundtrippedConfigListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(configListResponse), + jacksonTypeRef<ConfigListResponse>(), + ) + + assertThat(roundtrippedConfigListResponse).isEqualTo(configListResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigUpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigUpdateParamsTest.kt new file mode 100644 index 00000000..45f9d977 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/ConfigUpdateParamsTest.kt @@ -0,0 +1,139 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights.configs + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.sessions.insights.CreateRunClusteringJobRequest +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ConfigUpdateParamsTest { + + @Test + fun create() { + ConfigUpdateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .configId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config( + CreateRunClusteringJobRequest.builder() + .attributeSchemas(JsonValue.from(mapOf<String, Any>())) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addHierarchy(0L) + .lastNHours(0L) + .model(CreateRunClusteringJobRequest.Model.OPENAI) + .name("name") + .partitions( + CreateRunClusteringJobRequest.Partitions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .sample(0.0) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .summaryPrompt("summary_prompt") + .userContext( + CreateRunClusteringJobRequest.UserContext.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .validateModelSecrets(true) + .build() + ) + .description("description") + .name("name") + .build() + } + + @Test + fun pathParams() { + val params = + ConfigUpdateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .configId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._pathParam(1)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } + + @Test + fun body() { + val params = + ConfigUpdateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .configId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config( + CreateRunClusteringJobRequest.builder() + .attributeSchemas(JsonValue.from(mapOf<String, Any>())) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addHierarchy(0L) + .lastNHours(0L) + .model(CreateRunClusteringJobRequest.Model.OPENAI) + .name("name") + .partitions( + CreateRunClusteringJobRequest.Partitions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .sample(0.0) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .summaryPrompt("summary_prompt") + .userContext( + CreateRunClusteringJobRequest.UserContext.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .validateModelSecrets(true) + .build() + ) + .description("description") + .name("name") + .build() + + val body = params._body() + + assertThat(body.config()) + .contains( + CreateRunClusteringJobRequest.builder() + .attributeSchemas(JsonValue.from(mapOf<String, Any>())) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addHierarchy(0L) + .lastNHours(0L) + .model(CreateRunClusteringJobRequest.Model.OPENAI) + .name("name") + .partitions( + CreateRunClusteringJobRequest.Partitions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .sample(0.0) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .summaryPrompt("summary_prompt") + .userContext( + CreateRunClusteringJobRequest.UserContext.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .validateModelSecrets(true) + .build() + ) + assertThat(body.description()).contains("description") + assertThat(body.name()).contains("name") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + ConfigUpdateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .configId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/CreateClusteringJobConfigResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/CreateClusteringJobConfigResponseTest.kt new file mode 100644 index 00000000..60487201 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/CreateClusteringJobConfigResponseTest.kt @@ -0,0 +1,99 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights.configs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CreateClusteringJobConfigResponseTest { + + @Test + fun create() { + val createClusteringJobConfigResponse = + CreateClusteringJobConfigResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config( + SavedRunClusteringJobRequest.builder() + .attributeSchemas(JsonValue.from(mapOf<String, Any>())) + .filter("filter") + .addHierarchy(0L) + .lastNHours(0L) + .model(SavedRunClusteringJobRequest.Model.OPENAI) + .name("name") + .partitions( + SavedRunClusteringJobRequest.Partitions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .sample(0.0) + .summaryPrompt("summary_prompt") + .build() + ) + .description("description") + .name("name") + .build() + + assertThat(createClusteringJobConfigResponse.id()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(createClusteringJobConfigResponse.config()) + .isEqualTo( + SavedRunClusteringJobRequest.builder() + .attributeSchemas(JsonValue.from(mapOf<String, Any>())) + .filter("filter") + .addHierarchy(0L) + .lastNHours(0L) + .model(SavedRunClusteringJobRequest.Model.OPENAI) + .name("name") + .partitions( + SavedRunClusteringJobRequest.Partitions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .sample(0.0) + .summaryPrompt("summary_prompt") + .build() + ) + assertThat(createClusteringJobConfigResponse.description()).contains("description") + assertThat(createClusteringJobConfigResponse.name()).isEqualTo("name") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val createClusteringJobConfigResponse = + CreateClusteringJobConfigResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config( + SavedRunClusteringJobRequest.builder() + .attributeSchemas(JsonValue.from(mapOf<String, Any>())) + .filter("filter") + .addHierarchy(0L) + .lastNHours(0L) + .model(SavedRunClusteringJobRequest.Model.OPENAI) + .name("name") + .partitions( + SavedRunClusteringJobRequest.Partitions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .sample(0.0) + .summaryPrompt("summary_prompt") + .build() + ) + .description("description") + .name("name") + .build() + + val roundtrippedCreateClusteringJobConfigResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(createClusteringJobConfigResponse), + jacksonTypeRef<CreateClusteringJobConfigResponse>(), + ) + + assertThat(roundtrippedCreateClusteringJobConfigResponse) + .isEqualTo(createClusteringJobConfigResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/SavedRunClusteringJobRequestTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/SavedRunClusteringJobRequestTest.kt new file mode 100644 index 00000000..b58746a8 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/insights/configs/SavedRunClusteringJobRequestTest.kt @@ -0,0 +1,79 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.insights.configs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SavedRunClusteringJobRequestTest { + + @Test + fun create() { + val savedRunClusteringJobRequest = + SavedRunClusteringJobRequest.builder() + .attributeSchemas(JsonValue.from(mapOf<String, Any>())) + .filter("filter") + .addHierarchy(0L) + .lastNHours(0L) + .model(SavedRunClusteringJobRequest.Model.OPENAI) + .name("name") + .partitions( + SavedRunClusteringJobRequest.Partitions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .sample(0.0) + .summaryPrompt("summary_prompt") + .build() + + assertThat(savedRunClusteringJobRequest._attributeSchemas()) + .isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(savedRunClusteringJobRequest.filter()).contains("filter") + assertThat(savedRunClusteringJobRequest.hierarchy().getOrNull()).containsExactly(0L) + assertThat(savedRunClusteringJobRequest.lastNHours()).isEqualTo(0L) + assertThat(savedRunClusteringJobRequest.model()) + .isEqualTo(SavedRunClusteringJobRequest.Model.OPENAI) + assertThat(savedRunClusteringJobRequest.name()).isEqualTo("name") + assertThat(savedRunClusteringJobRequest.partitions()) + .contains( + SavedRunClusteringJobRequest.Partitions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(savedRunClusteringJobRequest.sample()).contains(0.0) + assertThat(savedRunClusteringJobRequest.summaryPrompt()).contains("summary_prompt") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val savedRunClusteringJobRequest = + SavedRunClusteringJobRequest.builder() + .attributeSchemas(JsonValue.from(mapOf<String, Any>())) + .filter("filter") + .addHierarchy(0L) + .lastNHours(0L) + .model(SavedRunClusteringJobRequest.Model.OPENAI) + .name("name") + .partitions( + SavedRunClusteringJobRequest.Partitions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .sample(0.0) + .summaryPrompt("summary_prompt") + .build() + + val roundtrippedSavedRunClusteringJobRequest = + jsonMapper.readValue( + jsonMapper.writeValueAsString(savedRunClusteringJobRequest), + jacksonTypeRef<SavedRunClusteringJobRequest>(), + ) + + assertThat(roundtrippedSavedRunClusteringJobRequest).isEqualTo(savedRunClusteringJobRequest) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/FilterViewTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/FilterViewTest.kt new file mode 100644 index 00000000..bf4691f5 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/FilterViewTest.kt @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.views + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FilterViewTest { + + @Test + fun create() { + val filterView = + FilterView.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .displayName("display_name") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .filterString("filter_string") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilterString("trace_filter_string") + .treeFilterString("tree_filter_string") + .type(FilterViewType.RUNS) + .build() + + assertThat(filterView.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(filterView.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(filterView.displayName()).isEqualTo("display_name") + assertThat(filterView.updatedAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(filterView.description()).contains("description") + assertThat(filterView.filterString()).contains("filter_string") + assertThat(filterView.sessionId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(filterView.traceFilterString()).contains("trace_filter_string") + assertThat(filterView.treeFilterString()).contains("tree_filter_string") + assertThat(filterView.type()).contains(FilterViewType.RUNS) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val filterView = + FilterView.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .displayName("display_name") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .filterString("filter_string") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilterString("trace_filter_string") + .treeFilterString("tree_filter_string") + .type(FilterViewType.RUNS) + .build() + + val roundtrippedFilterView = + jsonMapper.readValue( + jsonMapper.writeValueAsString(filterView), + jacksonTypeRef<FilterView>(), + ) + + assertThat(roundtrippedFilterView).isEqualTo(filterView) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewCreateParamsTest.kt new file mode 100644 index 00000000..0bed86fb --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewCreateParamsTest.kt @@ -0,0 +1,71 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.views + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ViewCreateParamsTest { + + @Test + fun create() { + ViewCreateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .displayName("display_name") + .description("description") + .filterString("filter_string") + .traceFilterString("trace_filter_string") + .treeFilterString("tree_filter_string") + .type(FilterViewType.RUNS) + .build() + } + + @Test + fun pathParams() { + val params = + ViewCreateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .displayName("display_name") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + ViewCreateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .displayName("display_name") + .description("description") + .filterString("filter_string") + .traceFilterString("trace_filter_string") + .treeFilterString("tree_filter_string") + .type(FilterViewType.RUNS) + .build() + + val body = params._body() + + assertThat(body.displayName()).isEqualTo("display_name") + assertThat(body.description()).contains("description") + assertThat(body.filterString()).contains("filter_string") + assertThat(body.traceFilterString()).contains("trace_filter_string") + assertThat(body.treeFilterString()).contains("tree_filter_string") + assertThat(body.type()).contains(FilterViewType.RUNS) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + ViewCreateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .displayName("display_name") + .build() + + val body = params._body() + + assertThat(body.displayName()).isEqualTo("display_name") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewDeleteParamsTest.kt new file mode 100644 index 00000000..8d6adfc0 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewDeleteParamsTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.views + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ViewDeleteParamsTest { + + @Test + fun create() { + ViewDeleteParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + ViewDeleteParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._pathParam(1)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewDeleteResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewDeleteResponseTest.kt new file mode 100644 index 00000000..d38586fa --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewDeleteResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.views + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ViewDeleteResponseTest { + + @Test + fun create() { + val viewDeleteResponse = ViewDeleteResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val viewDeleteResponse = ViewDeleteResponse.builder().build() + + val roundtrippedViewDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(viewDeleteResponse), + jacksonTypeRef<ViewDeleteResponse>(), + ) + + assertThat(roundtrippedViewDeleteResponse).isEqualTo(viewDeleteResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewListParamsTest.kt new file mode 100644 index 00000000..af641356 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewListParamsTest.kt @@ -0,0 +1,51 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.views + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ViewListParamsTest { + + @Test + fun create() { + ViewListParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .type(FilterViewType.RUNS) + .build() + } + + @Test + fun pathParams() { + val params = + ViewListParams.builder().sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + ViewListParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .type(FilterViewType.RUNS) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().put("type", "runs").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + ViewListParams.builder().sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewRetrieveParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewRetrieveParamsTest.kt new file mode 100644 index 00000000..8af8da6d --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewRetrieveParamsTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.views + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ViewRetrieveParamsTest { + + @Test + fun create() { + ViewRetrieveParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + ViewRetrieveParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._pathParam(1)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewUpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewUpdateParamsTest.kt new file mode 100644 index 00000000..6463ecce --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sessions/views/ViewUpdateParamsTest.kt @@ -0,0 +1,72 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sessions.views + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ViewUpdateParamsTest { + + @Test + fun create() { + ViewUpdateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .displayName("display_name") + .filterString("filter_string") + .traceFilterString("trace_filter_string") + .treeFilterString("tree_filter_string") + .type(FilterViewType.RUNS) + .build() + } + + @Test + fun pathParams() { + val params = + ViewUpdateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._pathParam(1)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } + + @Test + fun body() { + val params = + ViewUpdateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .displayName("display_name") + .filterString("filter_string") + .traceFilterString("trace_filter_string") + .treeFilterString("tree_filter_string") + .type(FilterViewType.RUNS) + .build() + + val body = params._body() + + assertThat(body.description()).contains("description") + assertThat(body.displayName()).contains("display_name") + assertThat(body.filterString()).contains("filter_string") + assertThat(body.traceFilterString()).contains("trace_filter_string") + assertThat(body.treeFilterString()).contains("tree_filter_string") + assertThat(body.type()).contains(FilterViewType.RUNS) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + ViewUpdateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/settings/AppHubCrudTenantsTenantTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/settings/AppHubCrudTenantsTenantTest.kt new file mode 100644 index 00000000..ba694f42 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/settings/AppHubCrudTenantsTenantTest.kt @@ -0,0 +1,49 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.settings + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AppHubCrudTenantsTenantTest { + + @Test + fun create() { + val appHubCrudTenantsTenant = + AppHubCrudTenantsTenant.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .displayName("display_name") + .tenantHandle("tenant_handle") + .build() + + assertThat(appHubCrudTenantsTenant.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(appHubCrudTenantsTenant.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(appHubCrudTenantsTenant.displayName()).isEqualTo("display_name") + assertThat(appHubCrudTenantsTenant.tenantHandle()).contains("tenant_handle") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val appHubCrudTenantsTenant = + AppHubCrudTenantsTenant.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .displayName("display_name") + .tenantHandle("tenant_handle") + .build() + + val roundtrippedAppHubCrudTenantsTenant = + jsonMapper.readValue( + jsonMapper.writeValueAsString(appHubCrudTenantsTenant), + jacksonTypeRef<AppHubCrudTenantsTenant>(), + ) + + assertThat(roundtrippedAppHubCrudTenantsTenant).isEqualTo(appHubCrudTenantsTenant) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/settings/SettingHandleParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/settings/SettingHandleParamsTest.kt new file mode 100644 index 00000000..1288c854 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/settings/SettingHandleParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.settings + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SettingHandleParamsTest { + + @Test + fun create() { + SettingHandleParams.builder().tenantHandle("tenant_handle").build() + } + + @Test + fun body() { + val params = SettingHandleParams.builder().tenantHandle("tenant_handle").build() + + val body = params._body() + + assertThat(body.tenantHandle()).isEqualTo("tenant_handle") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/settings/SettingListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/settings/SettingListParamsTest.kt new file mode 100644 index 00000000..42e8fedb --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/settings/SettingListParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.settings + +import org.junit.jupiter.api.Test + +internal class SettingListParamsTest { + + @Test + fun create() { + SettingListParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sso/SsoRetrieveParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sso/SsoRetrieveParamsTest.kt new file mode 100644 index 00000000..f52e9e95 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sso/SsoRetrieveParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sso + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SsoRetrieveParamsTest { + + @Test + fun create() { + SsoRetrieveParams.builder().ssoLoginSlug("sso_login_slug").build() + } + + @Test + fun pathParams() { + val params = SsoRetrieveParams.builder().ssoLoginSlug("sso_login_slug").build() + + assertThat(params._pathParam(0)).isEqualTo("sso_login_slug") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sso/SsoRetrieveResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sso/SsoRetrieveResponseTest.kt new file mode 100644 index 00000000..4830a550 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sso/SsoRetrieveResponseTest.kt @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sso + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SsoRetrieveResponseTest { + + @Test + fun create() { + val ssoRetrieveResponse = + SsoRetrieveResponse.builder() + .organizationDisplayName("organization_display_name") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .providerId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(ssoRetrieveResponse.organizationDisplayName()) + .isEqualTo("organization_display_name") + assertThat(ssoRetrieveResponse.organizationId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(ssoRetrieveResponse.providerId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val ssoRetrieveResponse = + SsoRetrieveResponse.builder() + .organizationDisplayName("organization_display_name") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .providerId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val roundtrippedSsoRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(ssoRetrieveResponse), + jacksonTypeRef<SsoRetrieveResponse>(), + ) + + assertThat(roundtrippedSsoRetrieveResponse).isEqualTo(ssoRetrieveResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationConfirmParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationConfirmParamsTest.kt new file mode 100644 index 00000000..380adff6 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationConfirmParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sso.emailverification + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class EmailVerificationConfirmParamsTest { + + @Test + fun create() { + EmailVerificationConfirmParams.builder().token("token").build() + } + + @Test + fun body() { + val params = EmailVerificationConfirmParams.builder().token("token").build() + + val body = params._body() + + assertThat(body.token()).isEqualTo("token") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationConfirmResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationConfirmResponseTest.kt new file mode 100644 index 00000000..3bae0a42 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationConfirmResponseTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sso.emailverification + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class EmailVerificationConfirmResponseTest { + + @Test + fun create() { + val emailVerificationConfirmResponse = EmailVerificationConfirmResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val emailVerificationConfirmResponse = EmailVerificationConfirmResponse.builder().build() + + val roundtrippedEmailVerificationConfirmResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(emailVerificationConfirmResponse), + jacksonTypeRef<EmailVerificationConfirmResponse>(), + ) + + assertThat(roundtrippedEmailVerificationConfirmResponse) + .isEqualTo(emailVerificationConfirmResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationSendParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationSendParamsTest.kt new file mode 100644 index 00000000..5c1b810b --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationSendParamsTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sso.emailverification + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class EmailVerificationSendParamsTest { + + @Test + fun create() { + EmailVerificationSendParams.builder() + .email("email") + .samlProviderId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun body() { + val params = + EmailVerificationSendParams.builder() + .email("email") + .samlProviderId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + + assertThat(body.email()).isEqualTo("email") + assertThat(body.samlProviderId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationSendResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationSendResponseTest.kt new file mode 100644 index 00000000..faba34b4 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationSendResponseTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sso.emailverification + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class EmailVerificationSendResponseTest { + + @Test + fun create() { + val emailVerificationSendResponse = EmailVerificationSendResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val emailVerificationSendResponse = EmailVerificationSendResponse.builder().build() + + val roundtrippedEmailVerificationSendResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(emailVerificationSendResponse), + jacksonTypeRef<EmailVerificationSendResponse>(), + ) + + assertThat(roundtrippedEmailVerificationSendResponse) + .isEqualTo(emailVerificationSendResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationStatusParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationStatusParamsTest.kt new file mode 100644 index 00000000..f1d8e030 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationStatusParamsTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sso.emailverification + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class EmailVerificationStatusParamsTest { + + @Test + fun create() { + EmailVerificationStatusParams.builder() + .email("email") + .samlProviderId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun body() { + val params = + EmailVerificationStatusParams.builder() + .email("email") + .samlProviderId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + + assertThat(body.email()).isEqualTo("email") + assertThat(body.samlProviderId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationStatusResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationStatusResponseTest.kt new file mode 100644 index 00000000..6a9c0f03 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/sso/emailverification/EmailVerificationStatusResponseTest.kt @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.sso.emailverification + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class EmailVerificationStatusResponseTest { + + @Test + fun create() { + val emailVerificationStatusResponse = + EmailVerificationStatusResponse.builder() + .emailConfirmedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(emailVerificationStatusResponse.emailConfirmedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val emailVerificationStatusResponse = + EmailVerificationStatusResponse.builder() + .emailConfirmedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedEmailVerificationStatusResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(emailVerificationStatusResponse), + jacksonTypeRef<EmailVerificationStatusResponse>(), + ) + + assertThat(roundtrippedEmailVerificationStatusResponse) + .isEqualTo(emailVerificationStatusResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/tenants/AppSchemasTenantTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/tenants/AppSchemasTenantTest.kt new file mode 100644 index 00000000..41060815 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/tenants/AppSchemasTenantTest.kt @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.tenants + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AppSchemasTenantTest { + + @Test + fun create() { + val appSchemasTenant = + AppSchemasTenant.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .displayName("display_name") + .isDeleted(true) + .isPersonal(true) + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tenantHandle("tenant_handle") + .build() + + assertThat(appSchemasTenant.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(appSchemasTenant.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(appSchemasTenant.displayName()).isEqualTo("display_name") + assertThat(appSchemasTenant.isDeleted()).isEqualTo(true) + assertThat(appSchemasTenant.isPersonal()).isEqualTo(true) + assertThat(appSchemasTenant.organizationId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(appSchemasTenant.tenantHandle()).contains("tenant_handle") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val appSchemasTenant = + AppSchemasTenant.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .displayName("display_name") + .isDeleted(true) + .isPersonal(true) + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tenantHandle("tenant_handle") + .build() + + val roundtrippedAppSchemasTenant = + jsonMapper.readValue( + jsonMapper.writeValueAsString(appSchemasTenant), + jacksonTypeRef<AppSchemasTenant>(), + ) + + assertThat(roundtrippedAppSchemasTenant).isEqualTo(appSchemasTenant) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/tenants/TenantCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/tenants/TenantCreateParamsTest.kt new file mode 100644 index 00000000..33afbe75 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/tenants/TenantCreateParamsTest.kt @@ -0,0 +1,49 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.tenants + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TenantCreateParamsTest { + + @Test + fun create() { + TenantCreateParams.builder() + .displayName("display_name") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .isPersonal(true) + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tenantHandle("tenant_handle") + .build() + } + + @Test + fun body() { + val params = + TenantCreateParams.builder() + .displayName("display_name") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .isPersonal(true) + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tenantHandle("tenant_handle") + .build() + + val body = params._body() + + assertThat(body.displayName()).isEqualTo("display_name") + assertThat(body.id()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.isPersonal()).contains(true) + assertThat(body.organizationId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.tenantHandle()).contains("tenant_handle") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = TenantCreateParams.builder().displayName("display_name").build() + + val body = params._body() + + assertThat(body.displayName()).isEqualTo("display_name") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/tenants/TenantForUserTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/tenants/TenantForUserTest.kt new file mode 100644 index 00000000..5fad1110 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/tenants/TenantForUserTest.kt @@ -0,0 +1,71 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.tenants + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TenantForUserTest { + + @Test + fun create() { + val tenantForUser = + TenantForUser.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .displayName("display_name") + .isDeleted(true) + .isPersonal(true) + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addPermission("string") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .roleName("role_name") + .tenantHandle("tenant_handle") + .build() + + assertThat(tenantForUser.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(tenantForUser.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(tenantForUser.displayName()).isEqualTo("display_name") + assertThat(tenantForUser.isDeleted()).isEqualTo(true) + assertThat(tenantForUser.isPersonal()).isEqualTo(true) + assertThat(tenantForUser.organizationId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(tenantForUser.permissions().getOrNull()).containsExactly("string") + assertThat(tenantForUser.readOnly()).contains(true) + assertThat(tenantForUser.roleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(tenantForUser.roleName()).contains("role_name") + assertThat(tenantForUser.tenantHandle()).contains("tenant_handle") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val tenantForUser = + TenantForUser.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .displayName("display_name") + .isDeleted(true) + .isPersonal(true) + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addPermission("string") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .roleName("role_name") + .tenantHandle("tenant_handle") + .build() + + val roundtrippedTenantForUser = + jsonMapper.readValue( + jsonMapper.writeValueAsString(tenantForUser), + jacksonTypeRef<TenantForUser>(), + ) + + assertThat(roundtrippedTenantForUser).isEqualTo(tenantForUser) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/tenants/TenantListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/tenants/TenantListParamsTest.kt new file mode 100644 index 00000000..30233d83 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/tenants/TenantListParamsTest.kt @@ -0,0 +1,39 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.tenants + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TenantListParamsTest { + + @Test + fun create() { + TenantListParams.builder().includeDeleted(true).skipCreate(true).build() + } + + @Test + fun queryParams() { + val params = TenantListParams.builder().includeDeleted(true).skipCreate(true).build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("include_deleted", "true") + .put("skip_create", "true") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = TenantListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/ttlsettings/TtlSettingRetrieveTtlSettingsParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/ttlsettings/TtlSettingRetrieveTtlSettingsParamsTest.kt new file mode 100644 index 00000000..4020deeb --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/ttlsettings/TtlSettingRetrieveTtlSettingsParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.ttlsettings + +import org.junit.jupiter.api.Test + +internal class TtlSettingRetrieveTtlSettingsParamsTest { + + @Test + fun create() { + TtlSettingRetrieveTtlSettingsParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/ttlsettings/TtlSettingUpdateTtlSettingsParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/ttlsettings/TtlSettingUpdateTtlSettingsParamsTest.kt new file mode 100644 index 00000000..fbe3c8e8 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/ttlsettings/TtlSettingUpdateTtlSettingsParamsTest.kt @@ -0,0 +1,66 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.ttlsettings + +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TraceTier +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.UpsertTtlSettingsRequest +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TtlSettingUpdateTtlSettingsParamsTest { + + @Test + fun create() { + TtlSettingUpdateTtlSettingsParams.builder() + .upsertTtlSettingsRequest( + UpsertTtlSettingsRequest.builder() + .defaultTraceTier(TraceTier.LONGLIVED) + .applyToAllProjects(true) + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + } + + @Test + fun body() { + val params = + TtlSettingUpdateTtlSettingsParams.builder() + .upsertTtlSettingsRequest( + UpsertTtlSettingsRequest.builder() + .defaultTraceTier(TraceTier.LONGLIVED) + .applyToAllProjects(true) + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + UpsertTtlSettingsRequest.builder() + .defaultTraceTier(TraceTier.LONGLIVED) + .applyToAllProjects(true) + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + TtlSettingUpdateTtlSettingsParams.builder() + .upsertTtlSettingsRequest( + UpsertTtlSettingsRequest.builder().defaultTraceTier(TraceTier.LONGLIVED).build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + UpsertTtlSettingsRequest.builder().defaultTraceTier(TraceTier.LONGLIVED).build() + ) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitDeleteParamsTest.kt new file mode 100644 index 00000000..8f941de7 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitDeleteParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.usagelimits + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UsageLimitDeleteParamsTest { + + @Test + fun create() { + UsageLimitDeleteParams.builder() + .usageLimitId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + UsageLimitDeleteParams.builder() + .usageLimitId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitDeleteResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitDeleteResponseTest.kt new file mode 100644 index 00000000..fcb4dc52 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitDeleteResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.usagelimits + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UsageLimitDeleteResponseTest { + + @Test + fun create() { + val usageLimitDeleteResponse = UsageLimitDeleteResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val usageLimitDeleteResponse = UsageLimitDeleteResponse.builder().build() + + val roundtrippedUsageLimitDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(usageLimitDeleteResponse), + jacksonTypeRef<UsageLimitDeleteResponse>(), + ) + + assertThat(roundtrippedUsageLimitDeleteResponse).isEqualTo(usageLimitDeleteResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitRetrieveOrgParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitRetrieveOrgParamsTest.kt new file mode 100644 index 00000000..d11797b5 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitRetrieveOrgParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.usagelimits + +import org.junit.jupiter.api.Test + +internal class UsageLimitRetrieveOrgParamsTest { + + @Test + fun create() { + UsageLimitRetrieveOrgParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitRetrieveUsageLimitsParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitRetrieveUsageLimitsParamsTest.kt new file mode 100644 index 00000000..a7a05e98 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitRetrieveUsageLimitsParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.usagelimits + +import org.junit.jupiter.api.Test + +internal class UsageLimitRetrieveUsageLimitsParamsTest { + + @Test + fun create() { + UsageLimitRetrieveUsageLimitsParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitTest.kt new file mode 100644 index 00000000..63efbcd3 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitTest.kt @@ -0,0 +1,56 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.usagelimits + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UsageLimitTest { + + @Test + fun create() { + val usageLimit = + UsageLimit.builder() + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .limitType(UsageLimitType.MONTHLY_TRACES) + .limitValue(0L) + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(usageLimit.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(usageLimit.limitType()).isEqualTo(UsageLimitType.MONTHLY_TRACES) + assertThat(usageLimit.limitValue()).isEqualTo(0L) + assertThat(usageLimit.tenantId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(usageLimit.updatedAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(usageLimit.id()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val usageLimit = + UsageLimit.builder() + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .limitType(UsageLimitType.MONTHLY_TRACES) + .limitValue(0L) + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val roundtrippedUsageLimit = + jsonMapper.readValue( + jsonMapper.writeValueAsString(usageLimit), + jacksonTypeRef<UsageLimit>(), + ) + + assertThat(roundtrippedUsageLimit).isEqualTo(usageLimit) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitUpdateUsageLimitsParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitUpdateUsageLimitsParamsTest.kt new file mode 100644 index 00000000..d0b2518f --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/usagelimits/UsageLimitUpdateUsageLimitsParamsTest.kt @@ -0,0 +1,48 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.usagelimits + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UsageLimitUpdateUsageLimitsParamsTest { + + @Test + fun create() { + UsageLimitUpdateUsageLimitsParams.builder() + .limitType(UsageLimitType.MONTHLY_TRACES) + .limitValue(0L) + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun body() { + val params = + UsageLimitUpdateUsageLimitsParams.builder() + .limitType(UsageLimitType.MONTHLY_TRACES) + .limitValue(0L) + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + + assertThat(body.limitType()).isEqualTo(UsageLimitType.MONTHLY_TRACES) + assertThat(body.limitValue()).isEqualTo(0L) + assertThat(body.id()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + UsageLimitUpdateUsageLimitsParams.builder() + .limitType(UsageLimitType.MONTHLY_TRACES) + .limitValue(0L) + .build() + + val body = params._body() + + assertThat(body.limitType()).isEqualTo(UsageLimitType.MONTHLY_TRACES) + assertThat(body.limitValue()).isEqualTo(0L) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceCreateParamsTest.kt new file mode 100644 index 00000000..d063b58a --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceCreateParamsTest.kt @@ -0,0 +1,43 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class WorkspaceCreateParamsTest { + + @Test + fun create() { + WorkspaceCreateParams.builder() + .displayName("display_name") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tenantHandle("tenant_handle") + .build() + } + + @Test + fun body() { + val params = + WorkspaceCreateParams.builder() + .displayName("display_name") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tenantHandle("tenant_handle") + .build() + + val body = params._body() + + assertThat(body.displayName()).isEqualTo("display_name") + assertThat(body.id()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.tenantHandle()).contains("tenant_handle") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = WorkspaceCreateParams.builder().displayName("display_name").build() + + val body = params._body() + + assertThat(body.displayName()).isEqualTo("display_name") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceDeleteParamsTest.kt new file mode 100644 index 00000000..75f05cbd --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceDeleteParamsTest.kt @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class WorkspaceDeleteParamsTest { + + @Test + fun create() { + WorkspaceDeleteParams.builder().workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + WorkspaceDeleteParams.builder() + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceDeleteResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceDeleteResponseTest.kt new file mode 100644 index 00000000..de32312d --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceDeleteResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class WorkspaceDeleteResponseTest { + + @Test + fun create() { + val workspaceDeleteResponse = WorkspaceDeleteResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val workspaceDeleteResponse = WorkspaceDeleteResponse.builder().build() + + val roundtrippedWorkspaceDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(workspaceDeleteResponse), + jacksonTypeRef<WorkspaceDeleteResponse>(), + ) + + assertThat(roundtrippedWorkspaceDeleteResponse).isEqualTo(workspaceDeleteResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceListParamsTest.kt new file mode 100644 index 00000000..eccdbb22 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceListParamsTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class WorkspaceListParamsTest { + + @Test + fun create() { + WorkspaceListParams.builder().includeDeleted(true).build() + } + + @Test + fun queryParams() { + val params = WorkspaceListParams.builder().includeDeleted(true).build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("include_deleted", "true").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = WorkspaceListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceUpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceUpdateParamsTest.kt new file mode 100644 index 00000000..a481d475 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/WorkspaceUpdateParamsTest.kt @@ -0,0 +1,43 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class WorkspaceUpdateParamsTest { + + @Test + fun create() { + WorkspaceUpdateParams.builder() + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .displayName("display_name") + .build() + } + + @Test + fun pathParams() { + val params = + WorkspaceUpdateParams.builder() + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .displayName("display_name") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + WorkspaceUpdateParams.builder() + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .displayName("display_name") + .build() + + val body = params._body() + + assertThat(body.displayName()).isEqualTo("display_name") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/CurrentRetrieveStatsParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/CurrentRetrieveStatsParamsTest.kt new file mode 100644 index 00000000..d27a82b2 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/CurrentRetrieveStatsParamsTest.kt @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CurrentRetrieveStatsParamsTest { + + @Test + fun create() { + CurrentRetrieveStatsParams.builder() + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun queryParams() { + val params = + CurrentRetrieveStatsParams.builder() + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put( + "tag_value_id", + listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").joinToString(","), + ) + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = CurrentRetrieveStatsParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/CurrentRetrieveStatsResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/CurrentRetrieveStatsResponseTest.kt new file mode 100644 index 00000000..02d40053 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/CurrentRetrieveStatsResponseTest.kt @@ -0,0 +1,57 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CurrentRetrieveStatsResponseTest { + + @Test + fun create() { + val currentRetrieveStatsResponse = + CurrentRetrieveStatsResponse.builder() + .annotationQueueCount(0L) + .dashboardsCount(0L) + .datasetCount(0L) + .deploymentCount(0L) + .repoCount(0L) + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tracerSessionCount(0L) + .build() + + assertThat(currentRetrieveStatsResponse.annotationQueueCount()).isEqualTo(0L) + assertThat(currentRetrieveStatsResponse.dashboardsCount()).isEqualTo(0L) + assertThat(currentRetrieveStatsResponse.datasetCount()).isEqualTo(0L) + assertThat(currentRetrieveStatsResponse.deploymentCount()).isEqualTo(0L) + assertThat(currentRetrieveStatsResponse.repoCount()).isEqualTo(0L) + assertThat(currentRetrieveStatsResponse.tenantId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(currentRetrieveStatsResponse.tracerSessionCount()).isEqualTo(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val currentRetrieveStatsResponse = + CurrentRetrieveStatsResponse.builder() + .annotationQueueCount(0L) + .dashboardsCount(0L) + .datasetCount(0L) + .deploymentCount(0L) + .repoCount(0L) + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tracerSessionCount(0L) + .build() + + val roundtrippedCurrentRetrieveStatsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(currentRetrieveStatsResponse), + jacksonTypeRef<CurrentRetrieveStatsResponse>(), + ) + + assertThat(roundtrippedCurrentRetrieveStatsResponse).isEqualTo(currentRetrieveStatsResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/CurrentRetrieveUsageLimitsParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/CurrentRetrieveUsageLimitsParamsTest.kt new file mode 100644 index 00000000..8f098ad9 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/CurrentRetrieveUsageLimitsParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current + +import org.junit.jupiter.api.Test + +internal class CurrentRetrieveUsageLimitsParamsTest { + + @Test + fun create() { + CurrentRetrieveUsageLimitsParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/CurrentRetrieveUsageLimitsResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/CurrentRetrieveUsageLimitsResponseTest.kt new file mode 100644 index 00000000..fb008c53 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/CurrentRetrieveUsageLimitsResponseTest.kt @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CurrentRetrieveUsageLimitsResponseTest { + + @Test + fun create() { + val currentRetrieveUsageLimitsResponse = + CurrentRetrieveUsageLimitsResponse.builder() + .inRejectSet(true) + .tenantLimit(0L) + .usageLimitType(CurrentRetrieveUsageLimitsResponse.UsageLimitType.PAYLOAD_SIZE) + .build() + + assertThat(currentRetrieveUsageLimitsResponse.inRejectSet()).isEqualTo(true) + assertThat(currentRetrieveUsageLimitsResponse.tenantLimit()).contains(0L) + assertThat(currentRetrieveUsageLimitsResponse.usageLimitType()) + .contains(CurrentRetrieveUsageLimitsResponse.UsageLimitType.PAYLOAD_SIZE) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val currentRetrieveUsageLimitsResponse = + CurrentRetrieveUsageLimitsResponse.builder() + .inRejectSet(true) + .tenantLimit(0L) + .usageLimitType(CurrentRetrieveUsageLimitsResponse.UsageLimitType.PAYLOAD_SIZE) + .build() + + val roundtrippedCurrentRetrieveUsageLimitsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(currentRetrieveUsageLimitsResponse), + jacksonTypeRef<CurrentRetrieveUsageLimitsResponse>(), + ) + + assertThat(roundtrippedCurrentRetrieveUsageLimitsResponse) + .isEqualTo(currentRetrieveUsageLimitsResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberBatchParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberBatchParamsTest.kt new file mode 100644 index 00000000..3679613b --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberBatchParamsTest.kt @@ -0,0 +1,72 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.members + +import com.langsmith_api.api.models.api.v1.orgs.current.members.PendingIdentityCreate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MemberBatchParamsTest { + + @Test + fun create() { + MemberBatchParams.builder() + .addBody( + PendingIdentityCreate.builder() + .email("email") + .fullName("full_name") + .password("password") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .workspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + } + + @Test + fun body() { + val params = + MemberBatchParams.builder() + .addBody( + PendingIdentityCreate.builder() + .email("email") + .fullName("full_name") + .password("password") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .workspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .containsExactly( + PendingIdentityCreate.builder() + .email("email") + .fullName("full_name") + .password("password") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .workspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + MemberBatchParams.builder() + .addBody(PendingIdentityCreate.builder().email("email").build()) + .build() + + val body = params._body() + + assertThat(body).containsExactly(PendingIdentityCreate.builder().email("email").build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberCreateParamsTest.kt new file mode 100644 index 00000000..a43060a9 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberCreateParamsTest.kt @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.members + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MemberCreateParamsTest { + + @Test + fun create() { + MemberCreateParams.builder() + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgIdentityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun body() { + val params = + MemberCreateParams.builder() + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgIdentityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + + assertThat(body.lsUserId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.orgIdentityId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.readOnly()).contains(true) + assertThat(body.roleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = MemberCreateParams.builder().build() + + val body = params._body() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberDeleteParamsTest.kt new file mode 100644 index 00000000..e7f9f7e1 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberDeleteParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.members + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MemberDeleteParamsTest { + + @Test + fun create() { + MemberDeleteParams.builder().identityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + MemberDeleteParams.builder().identityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberDeleteResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberDeleteResponseTest.kt new file mode 100644 index 00000000..f4939312 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberDeleteResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.members + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MemberDeleteResponseTest { + + @Test + fun create() { + val memberDeleteResponse = MemberDeleteResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val memberDeleteResponse = MemberDeleteResponse.builder().build() + + val roundtrippedMemberDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(memberDeleteResponse), + jacksonTypeRef<MemberDeleteResponse>(), + ) + + assertThat(roundtrippedMemberDeleteResponse).isEqualTo(memberDeleteResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberIdentityTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberIdentityTest.kt new file mode 100644 index 00000000..9455691a --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberIdentityTest.kt @@ -0,0 +1,144 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.members + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.orgs.current.members.AccessScope +import com.langsmith_api.api.models.api.v1.orgs.current.user.ProviderUserSlim +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MemberIdentityTest { + + @Test + fun create() { + val memberIdentity = + MemberIdentity.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accessScope(AccessScope.ORGANIZATION) + .avatarUrl("avatar_url") + .email("email") + .fullName("full_name") + .addLinkedLoginMethod( + ProviderUserSlim.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("email") + .emailConfirmedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .firstName("first_name") + .fullName("full_name") + .isDisabled(true) + .lastName("last_name") + .provider(ProviderUserSlim.Provider.EMAIL) + .providerUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .provisioningMethod(ProviderUserSlim.ProvisioningMethod.SCIM) + .samlProviderId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .username("username") + .build() + ) + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgRoleName("org_role_name") + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .roleName("role_name") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(memberIdentity.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(memberIdentity.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(memberIdentity.lsUserId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(memberIdentity.organizationId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(memberIdentity.readOnly()).isEqualTo(true) + assertThat(memberIdentity.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(memberIdentity.accessScope()).contains(AccessScope.ORGANIZATION) + assertThat(memberIdentity.avatarUrl()).contains("avatar_url") + assertThat(memberIdentity.email()).contains("email") + assertThat(memberIdentity.fullName()).contains("full_name") + assertThat(memberIdentity.linkedLoginMethods().getOrNull()) + .containsExactly( + ProviderUserSlim.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("email") + .emailConfirmedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .firstName("first_name") + .fullName("full_name") + .isDisabled(true) + .lastName("last_name") + .provider(ProviderUserSlim.Provider.EMAIL) + .providerUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .provisioningMethod(ProviderUserSlim.ProvisioningMethod.SCIM) + .samlProviderId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .username("username") + .build() + ) + assertThat(memberIdentity.orgRoleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(memberIdentity.orgRoleName()).contains("org_role_name") + assertThat(memberIdentity.roleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(memberIdentity.roleName()).contains("role_name") + assertThat(memberIdentity.tenantId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val memberIdentity = + MemberIdentity.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accessScope(AccessScope.ORGANIZATION) + .avatarUrl("avatar_url") + .email("email") + .fullName("full_name") + .addLinkedLoginMethod( + ProviderUserSlim.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("email") + .emailConfirmedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .firstName("first_name") + .fullName("full_name") + .isDisabled(true) + .lastName("last_name") + .provider(ProviderUserSlim.Provider.EMAIL) + .providerUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .provisioningMethod(ProviderUserSlim.ProvisioningMethod.SCIM) + .samlProviderId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .username("username") + .build() + ) + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgRoleName("org_role_name") + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .roleName("role_name") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val roundtrippedMemberIdentity = + jsonMapper.readValue( + jsonMapper.writeValueAsString(memberIdentity), + jacksonTypeRef<MemberIdentity>(), + ) + + assertThat(roundtrippedMemberIdentity).isEqualTo(memberIdentity) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberListParamsTest.kt new file mode 100644 index 00000000..f48f3bae --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberListParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.members + +import org.junit.jupiter.api.Test + +internal class MemberListParamsTest { + + @Test + fun create() { + MemberListParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberListResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberListResponseTest.kt new file mode 100644 index 00000000..dde5098d --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberListResponseTest.kt @@ -0,0 +1,218 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.members + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.orgs.current.members.AccessScope +import com.langsmith_api.api.models.api.v1.orgs.current.members.PendingIdentity +import com.langsmith_api.api.models.api.v1.orgs.current.user.ProviderUserSlim +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MemberListResponseTest { + + @Test + fun create() { + val memberListResponse = + MemberListResponse.builder() + .addMember( + MemberIdentity.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accessScope(AccessScope.ORGANIZATION) + .avatarUrl("avatar_url") + .email("email") + .fullName("full_name") + .addLinkedLoginMethod( + ProviderUserSlim.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("email") + .emailConfirmedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .firstName("first_name") + .fullName("full_name") + .isDisabled(true) + .lastName("last_name") + .provider(ProviderUserSlim.Provider.EMAIL) + .providerUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .provisioningMethod(ProviderUserSlim.ProvisioningMethod.SCIM) + .samlProviderId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .username("username") + .build() + ) + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgRoleName("org_role_name") + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .roleName("role_name") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .addPending( + PendingIdentity.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("email") + .accessScope(AccessScope.ORGANIZATION) + .fullName("full_name") + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgRoleName("org_role_name") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .password("password") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .roleName("role_name") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .workspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(memberListResponse.members()) + .containsExactly( + MemberIdentity.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accessScope(AccessScope.ORGANIZATION) + .avatarUrl("avatar_url") + .email("email") + .fullName("full_name") + .addLinkedLoginMethod( + ProviderUserSlim.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("email") + .emailConfirmedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .firstName("first_name") + .fullName("full_name") + .isDisabled(true) + .lastName("last_name") + .provider(ProviderUserSlim.Provider.EMAIL) + .providerUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .provisioningMethod(ProviderUserSlim.ProvisioningMethod.SCIM) + .samlProviderId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .username("username") + .build() + ) + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgRoleName("org_role_name") + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .roleName("role_name") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + assertThat(memberListResponse.pending()) + .containsExactly( + PendingIdentity.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("email") + .accessScope(AccessScope.ORGANIZATION) + .fullName("full_name") + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgRoleName("org_role_name") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .password("password") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .roleName("role_name") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .workspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + assertThat(memberListResponse.tenantId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val memberListResponse = + MemberListResponse.builder() + .addMember( + MemberIdentity.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accessScope(AccessScope.ORGANIZATION) + .avatarUrl("avatar_url") + .email("email") + .fullName("full_name") + .addLinkedLoginMethod( + ProviderUserSlim.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("email") + .emailConfirmedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .firstName("first_name") + .fullName("full_name") + .isDisabled(true) + .lastName("last_name") + .provider(ProviderUserSlim.Provider.EMAIL) + .providerUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .provisioningMethod(ProviderUserSlim.ProvisioningMethod.SCIM) + .samlProviderId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .username("username") + .build() + ) + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgRoleName("org_role_name") + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .roleName("role_name") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .addPending( + PendingIdentity.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("email") + .accessScope(AccessScope.ORGANIZATION) + .fullName("full_name") + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgRoleName("org_role_name") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .password("password") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .roleName("role_name") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .workspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val roundtrippedMemberListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(memberListResponse), + jacksonTypeRef<MemberListResponse>(), + ) + + assertThat(roundtrippedMemberListResponse).isEqualTo(memberListResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberRetrieveActiveParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberRetrieveActiveParamsTest.kt new file mode 100644 index 00000000..34eb4b25 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberRetrieveActiveParamsTest.kt @@ -0,0 +1,61 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.members + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MemberRetrieveActiveParamsTest { + + @Test + fun create() { + MemberRetrieveActiveParams.builder() + .addEmail("string") + .limit(1L) + .addLsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .offset(0L) + .addUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun queryParams() { + val params = + MemberRetrieveActiveParams.builder() + .addEmail("string") + .limit(1L) + .addLsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .offset(0L) + .addUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("emails", listOf("string").joinToString(",")) + .put("limit", "1") + .put( + "ls_user_ids", + listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").joinToString(","), + ) + .put("offset", "0") + .put( + "user_ids", + listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").joinToString(","), + ) + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = MemberRetrieveActiveParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberUpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberUpdateParamsTest.kt new file mode 100644 index 00000000..7f7630d3 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberUpdateParamsTest.kt @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.members + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MemberUpdateParamsTest { + + @Test + fun create() { + MemberUpdateParams.builder() + .identityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .build() + } + + @Test + fun pathParams() { + val params = + MemberUpdateParams.builder() + .identityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + MemberUpdateParams.builder() + .identityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .build() + + val body = params._body() + + assertThat(body.roleId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.readOnly()).contains(true) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + MemberUpdateParams.builder() + .identityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + + assertThat(body.roleId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberUpdateResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberUpdateResponseTest.kt new file mode 100644 index 00000000..9941653e --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/MemberUpdateResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.members + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MemberUpdateResponseTest { + + @Test + fun create() { + val memberUpdateResponse = MemberUpdateResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val memberUpdateResponse = MemberUpdateResponse.builder().build() + + val roundtrippedMemberUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(memberUpdateResponse), + jacksonTypeRef<MemberUpdateResponse>(), + ) + + assertThat(roundtrippedMemberUpdateResponse).isEqualTo(memberUpdateResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/pending/PendingDeleteAllParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/pending/PendingDeleteAllParamsTest.kt new file mode 100644 index 00000000..2ed9c907 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/pending/PendingDeleteAllParamsTest.kt @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.members.pending + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PendingDeleteAllParamsTest { + + @Test + fun create() { + PendingDeleteAllParams.builder().identityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + PendingDeleteAllParams.builder() + .identityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/pending/PendingDeleteAllResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/pending/PendingDeleteAllResponseTest.kt new file mode 100644 index 00000000..13e12711 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/pending/PendingDeleteAllResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.members.pending + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PendingDeleteAllResponseTest { + + @Test + fun create() { + val pendingDeleteAllResponse = PendingDeleteAllResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val pendingDeleteAllResponse = PendingDeleteAllResponse.builder().build() + + val roundtrippedPendingDeleteAllResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(pendingDeleteAllResponse), + jacksonTypeRef<PendingDeleteAllResponse>(), + ) + + assertThat(roundtrippedPendingDeleteAllResponse).isEqualTo(pendingDeleteAllResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/pending/PendingListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/pending/PendingListParamsTest.kt new file mode 100644 index 00000000..295fea62 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/members/pending/PendingListParamsTest.kt @@ -0,0 +1,40 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.members.pending + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PendingListParamsTest { + + @Test + fun create() { + PendingListParams.builder().addEmail("string").limit(1L).offset(0L).build() + } + + @Test + fun queryParams() { + val params = PendingListParams.builder().addEmail("string").limit(1L).offset(0L).build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("emails", listOf("string").joinToString(",")) + .put("limit", "1") + .put("offset", "0") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = PendingListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretCreateParamsTest.kt new file mode 100644 index 00000000..637d0872 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretCreateParamsTest.kt @@ -0,0 +1,29 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.secrets + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SecretCreateParamsTest { + + @Test + fun create() { + SecretCreateParams.builder() + .addBody(SecretCreateParams.Body.builder().key("key").value("value").build()) + .build() + } + + @Test + fun body() { + val params = + SecretCreateParams.builder() + .addBody(SecretCreateParams.Body.builder().key("key").value("value").build()) + .build() + + val body = params._body() + + assertThat(body) + .containsExactly(SecretCreateParams.Body.builder().key("key").value("value").build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretCreateResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretCreateResponseTest.kt new file mode 100644 index 00000000..9fa9d691 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretCreateResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.secrets + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SecretCreateResponseTest { + + @Test + fun create() { + val secretCreateResponse = SecretCreateResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val secretCreateResponse = SecretCreateResponse.builder().build() + + val roundtrippedSecretCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(secretCreateResponse), + jacksonTypeRef<SecretCreateResponse>(), + ) + + assertThat(roundtrippedSecretCreateResponse).isEqualTo(secretCreateResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretListParamsTest.kt new file mode 100644 index 00000000..382065fd --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretListParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.secrets + +import org.junit.jupiter.api.Test + +internal class SecretListParamsTest { + + @Test + fun create() { + SecretListParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretListResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretListResponseTest.kt new file mode 100644 index 00000000..fb96acb5 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretListResponseTest.kt @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.secrets + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SecretListResponseTest { + + @Test + fun create() { + val secretListResponse = SecretListResponse.builder().key("key").build() + + assertThat(secretListResponse.key()).isEqualTo("key") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val secretListResponse = SecretListResponse.builder().key("key").build() + + val roundtrippedSecretListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(secretListResponse), + jacksonTypeRef<SecretListResponse>(), + ) + + assertThat(roundtrippedSecretListResponse).isEqualTo(secretListResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretRetrieveEncryptedParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretRetrieveEncryptedParamsTest.kt new file mode 100644 index 00000000..6a98f2e5 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretRetrieveEncryptedParamsTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.secrets + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SecretRetrieveEncryptedParamsTest { + + @Test + fun create() { + SecretRetrieveEncryptedParams.builder() + .service(SecretRetrieveEncryptedParams.Service.AGENT_BUILDER) + .build() + } + + @Test + fun queryParams() { + val params = + SecretRetrieveEncryptedParams.builder() + .service(SecretRetrieveEncryptedParams.Service.AGENT_BUILDER) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("service", "agent_builder").build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretRetrieveEncryptedResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretRetrieveEncryptedResponseTest.kt new file mode 100644 index 00000000..3444f725 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/secrets/SecretRetrieveEncryptedResponseTest.kt @@ -0,0 +1,36 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.secrets + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SecretRetrieveEncryptedResponseTest { + + @Test + fun create() { + val secretRetrieveEncryptedResponse = + SecretRetrieveEncryptedResponse.builder().encryptedSecrets("encrypted_secrets").build() + + assertThat(secretRetrieveEncryptedResponse.encryptedSecrets()) + .isEqualTo("encrypted_secrets") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val secretRetrieveEncryptedResponse = + SecretRetrieveEncryptedResponse.builder().encryptedSecrets("encrypted_secrets").build() + + val roundtrippedSecretRetrieveEncryptedResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(secretRetrieveEncryptedResponse), + jacksonTypeRef<SecretRetrieveEncryptedResponse>(), + ) + + assertThat(roundtrippedSecretRetrieveEncryptedResponse) + .isEqualTo(secretRetrieveEncryptedResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/shared/SharedDeleteAllParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/shared/SharedDeleteAllParamsTest.kt new file mode 100644 index 00000000..df24d509 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/shared/SharedDeleteAllParamsTest.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.shared + +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SharedDeleteAllParamsTest { + + @Test + fun create() { + SharedDeleteAllParams.builder() + .addShareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun body() { + val params = + SharedDeleteAllParams.builder() + .addShareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + + assertThat(body.shareTokens().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = SharedDeleteAllParams.builder().build() + + val body = params._body() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/shared/SharedDeleteAllResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/shared/SharedDeleteAllResponseTest.kt new file mode 100644 index 00000000..d474fdac --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/shared/SharedDeleteAllResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.shared + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SharedDeleteAllResponseTest { + + @Test + fun create() { + val sharedDeleteAllResponse = SharedDeleteAllResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val sharedDeleteAllResponse = SharedDeleteAllResponse.builder().build() + + val roundtrippedSharedDeleteAllResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(sharedDeleteAllResponse), + jacksonTypeRef<SharedDeleteAllResponse>(), + ) + + assertThat(roundtrippedSharedDeleteAllResponse).isEqualTo(sharedDeleteAllResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/shared/SharedListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/shared/SharedListParamsTest.kt new file mode 100644 index 00000000..acc14365 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/shared/SharedListParamsTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.shared + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SharedListParamsTest { + + @Test + fun create() { + SharedListParams.builder().limit(1L).offset(0L).build() + } + + @Test + fun queryParams() { + val params = SharedListParams.builder().limit(1L).offset(0L).build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("limit", "1").put("offset", "0").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = SharedListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/shared/SharedListResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/shared/SharedListResponseTest.kt new file mode 100644 index 00000000..87a7244b --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/shared/SharedListResponseTest.kt @@ -0,0 +1,72 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.shared + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SharedListResponseTest { + + @Test + fun create() { + val sharedListResponse = + SharedListResponse.builder() + .addEntity( + SharedListResponse.Entity.Run.builder() + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .shareToken("share_token") + .runName("run_name") + .runType("run_type") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sessionName("session_name") + .build() + ) + .build() + + assertThat(sharedListResponse.entities()) + .containsExactly( + SharedListResponse.Entity.ofRun( + SharedListResponse.Entity.Run.builder() + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .shareToken("share_token") + .runName("run_name") + .runType("run_type") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sessionName("session_name") + .build() + ) + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val sharedListResponse = + SharedListResponse.builder() + .addEntity( + SharedListResponse.Entity.Run.builder() + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .shareToken("share_token") + .runName("run_name") + .runType("run_type") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sessionName("session_name") + .build() + ) + .build() + + val roundtrippedSharedListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(sharedListResponse), + jacksonTypeRef<SharedListResponse>(), + ) + + assertThat(roundtrippedSharedListResponse).isEqualTo(sharedListResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/ResourceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/ResourceTest.kt new file mode 100644 index 00000000..238b6190 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/ResourceTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.taggings + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ResourceTest { + + @Test + fun create() { + val resource = + Resource.builder() + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceName("resource_name") + .taggingId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(resource.resourceId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(resource.resourceName()).isEqualTo("resource_name") + assertThat(resource.taggingId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val resource = + Resource.builder() + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceName("resource_name") + .taggingId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val roundtrippedResource = + jsonMapper.readValue( + jsonMapper.writeValueAsString(resource), + jacksonTypeRef<Resource>(), + ) + + assertThat(roundtrippedResource).isEqualTo(resource) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingCreateParamsTest.kt new file mode 100644 index 00000000..d7e0167c --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingCreateParamsTest.kt @@ -0,0 +1,35 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.taggings + +import com.langsmith_api.api.models.api.v1.workspaces.current.tags.ResourceType +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TaggingCreateParamsTest { + + @Test + fun create() { + TaggingCreateParams.builder() + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceType(ResourceType.PROMPT) + .tagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun body() { + val params = + TaggingCreateParams.builder() + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceType(ResourceType.PROMPT) + .tagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + + assertThat(body.resourceId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.resourceType()).isEqualTo(ResourceType.PROMPT) + assertThat(body.tagValueId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingDeleteParamsTest.kt new file mode 100644 index 00000000..3899992b --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingDeleteParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.taggings + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TaggingDeleteParamsTest { + + @Test + fun create() { + TaggingDeleteParams.builder().taggingId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + TaggingDeleteParams.builder().taggingId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingDeleteResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingDeleteResponseTest.kt new file mode 100644 index 00000000..af17013c --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingDeleteResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.taggings + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TaggingDeleteResponseTest { + + @Test + fun create() { + val taggingDeleteResponse = TaggingDeleteResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val taggingDeleteResponse = TaggingDeleteResponse.builder().build() + + val roundtrippedTaggingDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(taggingDeleteResponse), + jacksonTypeRef<TaggingDeleteResponse>(), + ) + + assertThat(roundtrippedTaggingDeleteResponse).isEqualTo(taggingDeleteResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingListParamsTest.kt new file mode 100644 index 00000000..e1d9f585 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingListParamsTest.kt @@ -0,0 +1,39 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.taggings + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TaggingListParamsTest { + + @Test + fun create() { + TaggingListParams.builder().tagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun queryParams() { + val params = + TaggingListParams.builder().tagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("tag_value_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = TaggingListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingListResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingListResponseTest.kt new file mode 100644 index 00000000..29f133fa --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingListResponseTest.kt @@ -0,0 +1,208 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.taggings + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TaggingListResponseTest { + + @Test + fun create() { + val taggingListResponse = + TaggingListResponse.builder() + .resources( + TaggingListResponse.Resources.builder() + .addDashboard( + Resource.builder() + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceName("resource_name") + .taggingId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .addDataset( + Resource.builder() + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceName("resource_name") + .taggingId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .addDeployment( + Resource.builder() + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceName("resource_name") + .taggingId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .addExperiment( + Resource.builder() + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceName("resource_name") + .taggingId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .addProject( + Resource.builder() + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceName("resource_name") + .taggingId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .addPrompt( + Resource.builder() + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceName("resource_name") + .taggingId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .addQueue( + Resource.builder() + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceName("resource_name") + .taggingId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + ) + .tagKey("tag_key") + .tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tagValue("tag_value") + .tagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(taggingListResponse.resources()) + .isEqualTo( + TaggingListResponse.Resources.builder() + .addDashboard( + Resource.builder() + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceName("resource_name") + .taggingId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .addDataset( + Resource.builder() + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceName("resource_name") + .taggingId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .addDeployment( + Resource.builder() + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceName("resource_name") + .taggingId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .addExperiment( + Resource.builder() + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceName("resource_name") + .taggingId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .addProject( + Resource.builder() + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceName("resource_name") + .taggingId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .addPrompt( + Resource.builder() + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceName("resource_name") + .taggingId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .addQueue( + Resource.builder() + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceName("resource_name") + .taggingId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + ) + assertThat(taggingListResponse.tagKey()).isEqualTo("tag_key") + assertThat(taggingListResponse.tagKeyId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(taggingListResponse.tagValue()).isEqualTo("tag_value") + assertThat(taggingListResponse.tagValueId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val taggingListResponse = + TaggingListResponse.builder() + .resources( + TaggingListResponse.Resources.builder() + .addDashboard( + Resource.builder() + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceName("resource_name") + .taggingId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .addDataset( + Resource.builder() + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceName("resource_name") + .taggingId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .addDeployment( + Resource.builder() + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceName("resource_name") + .taggingId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .addExperiment( + Resource.builder() + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceName("resource_name") + .taggingId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .addProject( + Resource.builder() + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceName("resource_name") + .taggingId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .addPrompt( + Resource.builder() + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceName("resource_name") + .taggingId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .addQueue( + Resource.builder() + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceName("resource_name") + .taggingId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + ) + .tagKey("tag_key") + .tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tagValue("tag_value") + .tagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val roundtrippedTaggingListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(taggingListResponse), + jacksonTypeRef<TaggingListResponse>(), + ) + + assertThat(roundtrippedTaggingListResponse).isEqualTo(taggingListResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingTest.kt new file mode 100644 index 00000000..77329683 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/taggings/TaggingTest.kt @@ -0,0 +1,49 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.taggings + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.workspaces.current.tags.ResourceType +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TaggingTest { + + @Test + fun create() { + val tagging = + Tagging.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceType(ResourceType.PROMPT) + .tagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(tagging.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(tagging.createdAt()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(tagging.resourceId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(tagging.resourceType()).isEqualTo(ResourceType.PROMPT) + assertThat(tagging.tagValueId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val tagging = + Tagging.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceType(ResourceType.PROMPT) + .tagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val roundtrippedTagging = + jsonMapper.readValue(jsonMapper.writeValueAsString(tagging), jacksonTypeRef<Tagging>()) + + assertThat(roundtrippedTagging).isEqualTo(tagging) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyDeleteParamsTest.kt new file mode 100644 index 00000000..15f30fe2 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyDeleteParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TagKeyDeleteParamsTest { + + @Test + fun create() { + TagKeyDeleteParams.builder().tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + TagKeyDeleteParams.builder().tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyDeleteResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyDeleteResponseTest.kt new file mode 100644 index 00000000..820ddc1a --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyDeleteResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TagKeyDeleteResponseTest { + + @Test + fun create() { + val tagKeyDeleteResponse = TagKeyDeleteResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val tagKeyDeleteResponse = TagKeyDeleteResponse.builder().build() + + val roundtrippedTagKeyDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(tagKeyDeleteResponse), + jacksonTypeRef<TagKeyDeleteResponse>(), + ) + + assertThat(roundtrippedTagKeyDeleteResponse).isEqualTo(tagKeyDeleteResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyRetrieveParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyRetrieveParamsTest.kt new file mode 100644 index 00000000..8ebe8f45 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyRetrieveParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TagKeyRetrieveParamsTest { + + @Test + fun create() { + TagKeyRetrieveParams.builder().tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + TagKeyRetrieveParams.builder().tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyRetrieveTagKeysParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyRetrieveTagKeysParamsTest.kt new file mode 100644 index 00000000..342ab9b5 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyRetrieveTagKeysParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys + +import org.junit.jupiter.api.Test + +internal class TagKeyRetrieveTagKeysParamsTest { + + @Test + fun create() { + TagKeyRetrieveTagKeysParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyTagKeysParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyTagKeysParamsTest.kt new file mode 100644 index 00000000..7aadf99d --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyTagKeysParamsTest.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TagKeyTagKeysParamsTest { + + @Test + fun create() { + TagKeyTagKeysParams.builder().key("x").description("description").build() + } + + @Test + fun body() { + val params = TagKeyTagKeysParams.builder().key("x").description("description").build() + + val body = params._body() + + assertThat(body.key()).isEqualTo("x") + assertThat(body.description()).contains("description") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = TagKeyTagKeysParams.builder().key("x").build() + + val body = params._body() + + assertThat(body.key()).isEqualTo("x") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyTest.kt new file mode 100644 index 00000000..cdcaf073 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyTest.kt @@ -0,0 +1,48 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TagKeyTest { + + @Test + fun create() { + val tagKey = + TagKey.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .key("x") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .build() + + assertThat(tagKey.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(tagKey.createdAt()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(tagKey.key()).isEqualTo("x") + assertThat(tagKey.updatedAt()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(tagKey.description()).contains("description") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val tagKey = + TagKey.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .key("x") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .build() + + val roundtrippedTagKey = + jsonMapper.readValue(jsonMapper.writeValueAsString(tagKey), jacksonTypeRef<TagKey>()) + + assertThat(roundtrippedTagKey).isEqualTo(tagKey) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyUpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyUpdateParamsTest.kt new file mode 100644 index 00000000..2812f5da --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/TagKeyUpdateParamsTest.kt @@ -0,0 +1,51 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TagKeyUpdateParamsTest { + + @Test + fun create() { + TagKeyUpdateParams.builder() + .tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .key("x") + .build() + } + + @Test + fun pathParams() { + val params = + TagKeyUpdateParams.builder().tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + TagKeyUpdateParams.builder() + .tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .key("x") + .build() + + val body = params._body() + + assertThat(body.description()).contains("description") + assertThat(body.key()).contains("x") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + TagKeyUpdateParams.builder().tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + val body = params._body() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueDeleteParamsTest.kt new file mode 100644 index 00000000..45b14a05 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueDeleteParamsTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TagValueDeleteParamsTest { + + @Test + fun create() { + TagValueDeleteParams.builder() + .tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + TagValueDeleteParams.builder() + .tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._pathParam(1)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueDeleteResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueDeleteResponseTest.kt new file mode 100644 index 00000000..edcf3d41 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueDeleteResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TagValueDeleteResponseTest { + + @Test + fun create() { + val tagValueDeleteResponse = TagValueDeleteResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val tagValueDeleteResponse = TagValueDeleteResponse.builder().build() + + val roundtrippedTagValueDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(tagValueDeleteResponse), + jacksonTypeRef<TagValueDeleteResponse>(), + ) + + assertThat(roundtrippedTagValueDeleteResponse).isEqualTo(tagValueDeleteResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueRetrieveParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueRetrieveParamsTest.kt new file mode 100644 index 00000000..8ad059eb --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueRetrieveParamsTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TagValueRetrieveParamsTest { + + @Test + fun create() { + TagValueRetrieveParams.builder() + .tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + TagValueRetrieveParams.builder() + .tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._pathParam(1)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueRetrieveTagValuesParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueRetrieveTagValuesParamsTest.kt new file mode 100644 index 00000000..c1cae44e --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueRetrieveTagValuesParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TagValueRetrieveTagValuesParamsTest { + + @Test + fun create() { + TagValueRetrieveTagValuesParams.builder() + .tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + TagValueRetrieveTagValuesParams.builder() + .tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueTagValuesParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueTagValuesParamsTest.kt new file mode 100644 index 00000000..1917e944 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueTagValuesParamsTest.kt @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TagValueTagValuesParamsTest { + + @Test + fun create() { + TagValueTagValuesParams.builder() + .tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .value("x") + .description("description") + .build() + } + + @Test + fun pathParams() { + val params = + TagValueTagValuesParams.builder() + .tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .value("x") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + TagValueTagValuesParams.builder() + .tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .value("x") + .description("description") + .build() + + val body = params._body() + + assertThat(body.value()).isEqualTo("x") + assertThat(body.description()).contains("description") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + TagValueTagValuesParams.builder() + .tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .value("x") + .build() + + val body = params._body() + + assertThat(body.value()).isEqualTo("x") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueTest.kt new file mode 100644 index 00000000..c8638a4e --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueTest.kt @@ -0,0 +1,54 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TagValueTest { + + @Test + fun create() { + val tagValue = + TagValue.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .value("x") + .description("description") + .build() + + assertThat(tagValue.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(tagValue.createdAt()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(tagValue.tagKeyId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(tagValue.updatedAt()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(tagValue.value()).isEqualTo("x") + assertThat(tagValue.description()).contains("description") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val tagValue = + TagValue.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .value("x") + .description("description") + .build() + + val roundtrippedTagValue = + jsonMapper.readValue( + jsonMapper.writeValueAsString(tagValue), + jacksonTypeRef<TagValue>(), + ) + + assertThat(roundtrippedTagValue).isEqualTo(tagValue) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueUpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueUpdateParamsTest.kt new file mode 100644 index 00000000..44419e87 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tagkeys/tagvalues/TagValueUpdateParamsTest.kt @@ -0,0 +1,60 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TagValueUpdateParamsTest { + + @Test + fun create() { + TagValueUpdateParams.builder() + .tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .value("x") + .build() + } + + @Test + fun pathParams() { + val params = + TagValueUpdateParams.builder() + .tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._pathParam(1)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } + + @Test + fun body() { + val params = + TagValueUpdateParams.builder() + .tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .value("x") + .build() + + val body = params._body() + + assertThat(body.description()).contains("description") + assertThat(body.value()).contains("x") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + TagValueUpdateParams.builder() + .tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagListParamsTest.kt new file mode 100644 index 00000000..4bb16375 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagListParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tags + +import org.junit.jupiter.api.Test + +internal class TagListParamsTest { + + @Test + fun create() { + TagListParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagListResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagListResponseTest.kt new file mode 100644 index 00000000..dd5c7d46 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagListResponseTest.kt @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tags + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues.TagValue +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TagListResponseTest { + + @Test + fun create() { + val tagListResponse = + TagListResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .key("x") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .addValue( + TagValue.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .value("x") + .description("description") + .build() + ) + .build() + + assertThat(tagListResponse.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(tagListResponse.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(tagListResponse.key()).isEqualTo("x") + assertThat(tagListResponse.updatedAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(tagListResponse.description()).contains("description") + assertThat(tagListResponse.values().getOrNull()) + .containsExactly( + TagValue.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .value("x") + .description("description") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val tagListResponse = + TagListResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .key("x") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .addValue( + TagValue.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .value("x") + .description("description") + .build() + ) + .build() + + val roundtrippedTagListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(tagListResponse), + jacksonTypeRef<TagListResponse>(), + ) + + assertThat(roundtrippedTagListResponse).isEqualTo(tagListResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagResourcesParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagResourcesParamsTest.kt new file mode 100644 index 00000000..f903ab24 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagResourcesParamsTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tags + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TagResourcesParamsTest { + + @Test + fun create() { + TagResourcesParams.builder() + .addBody( + TagResourcesParams.Body.builder() + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceType(ResourceType.PROMPT) + .build() + ) + .build() + } + + @Test + fun body() { + val params = + TagResourcesParams.builder() + .addBody( + TagResourcesParams.Body.builder() + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceType(ResourceType.PROMPT) + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .containsExactly( + TagResourcesParams.Body.builder() + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceType(ResourceType.PROMPT) + .build() + ) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagResourcesResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagResourcesResponseTest.kt new file mode 100644 index 00000000..c58ee226 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagResourcesResponseTest.kt @@ -0,0 +1,111 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tags + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TagResourcesResponseTest { + + @Test + fun create() { + val tagResourcesResponse = + TagResourcesResponse.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + listOf( + mapOf( + "id" to "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "created_at" to "2019-12-27T18:11:19.117Z", + "key" to "x", + "updated_at" to "2019-12-27T18:11:19.117Z", + "description" to "description", + "values" to + listOf( + mapOf( + "id" to "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "created_at" to "2019-12-27T18:11:19.117Z", + "tag_key_id" to "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "updated_at" to "2019-12-27T18:11:19.117Z", + "value" to "x", + "description" to "description", + "taggings" to + listOf( + mapOf( + "id" to + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "created_at" to "2019-12-27T18:11:19.117Z", + "resource_id" to + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "resource_type" to "prompt", + "tag_value_id" to + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + ), + ) + ), + ) + ) + ), + ) + .build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val tagResourcesResponse = + TagResourcesResponse.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + listOf( + mapOf( + "id" to "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "created_at" to "2019-12-27T18:11:19.117Z", + "key" to "x", + "updated_at" to "2019-12-27T18:11:19.117Z", + "description" to "description", + "values" to + listOf( + mapOf( + "id" to "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "created_at" to "2019-12-27T18:11:19.117Z", + "tag_key_id" to "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "updated_at" to "2019-12-27T18:11:19.117Z", + "value" to "x", + "description" to "description", + "taggings" to + listOf( + mapOf( + "id" to + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "created_at" to "2019-12-27T18:11:19.117Z", + "resource_id" to + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "resource_type" to "prompt", + "tag_value_id" to + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + ), + ) + ), + ) + ) + ), + ) + .build() + + val roundtrippedTagResourcesResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(tagResourcesResponse), + jacksonTypeRef<TagResourcesResponse>(), + ) + + assertThat(roundtrippedTagResourcesResponse).isEqualTo(tagResourcesResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagRetrieveResourceParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagRetrieveResourceParamsTest.kt new file mode 100644 index 00000000..3c9da5d4 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagRetrieveResourceParamsTest.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tags + +import com.langsmith_api.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TagRetrieveResourceParamsTest { + + @Test + fun create() { + TagRetrieveResourceParams.builder() + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceType(ResourceType.PROMPT) + .build() + } + + @Test + fun queryParams() { + val params = + TagRetrieveResourceParams.builder() + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceType(ResourceType.PROMPT) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("resource_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("resource_type", "prompt") + .build() + ) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagRetrieveResourceResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagRetrieveResourceResponseTest.kt new file mode 100644 index 00000000..8683760d --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/current/tags/TagRetrieveResourceResponseTest.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.current.tags + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.workspaces.current.taggings.Tagging +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TagRetrieveResourceResponseTest { + + @Test + fun create() { + val tagRetrieveResourceResponse = + TagRetrieveResourceResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .key("x") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .addValue( + TagRetrieveResourceResponse.Value.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .value("x") + .description("description") + .addTagging( + Tagging.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceType(ResourceType.PROMPT) + .tagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + ) + .build() + + assertThat(tagRetrieveResourceResponse.id()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(tagRetrieveResourceResponse.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(tagRetrieveResourceResponse.key()).isEqualTo("x") + assertThat(tagRetrieveResourceResponse.updatedAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(tagRetrieveResourceResponse.description()).contains("description") + assertThat(tagRetrieveResourceResponse.values().getOrNull()) + .containsExactly( + TagRetrieveResourceResponse.Value.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .value("x") + .description("description") + .addTagging( + Tagging.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceType(ResourceType.PROMPT) + .tagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val tagRetrieveResourceResponse = + TagRetrieveResourceResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .key("x") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .addValue( + TagRetrieveResourceResponse.Value.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .value("x") + .description("description") + .addTagging( + Tagging.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceType(ResourceType.PROMPT) + .tagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + ) + .build() + + val roundtrippedTagRetrieveResourceResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(tagRetrieveResourceResponse), + jacksonTypeRef<TagRetrieveResourceResponse>(), + ) + + assertThat(roundtrippedTagRetrieveResourceResponse).isEqualTo(tagRetrieveResourceResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingClaimParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingClaimParamsTest.kt new file mode 100644 index 00000000..ce61e0ae --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingClaimParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.pending + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PendingClaimParamsTest { + + @Test + fun create() { + PendingClaimParams.builder().workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + PendingClaimParams.builder().workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingClaimResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingClaimResponseTest.kt new file mode 100644 index 00000000..dc2fec64 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingClaimResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.pending + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PendingClaimResponseTest { + + @Test + fun create() { + val pendingClaimResponse = PendingClaimResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val pendingClaimResponse = PendingClaimResponse.builder().build() + + val roundtrippedPendingClaimResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(pendingClaimResponse), + jacksonTypeRef<PendingClaimResponse>(), + ) + + assertThat(roundtrippedPendingClaimResponse).isEqualTo(pendingClaimResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingDeleteParamsTest.kt new file mode 100644 index 00000000..2c590a06 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingDeleteParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.pending + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PendingDeleteParamsTest { + + @Test + fun create() { + PendingDeleteParams.builder().id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + PendingDeleteParams.builder().id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingDeleteResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingDeleteResponseTest.kt new file mode 100644 index 00000000..8cc3511c --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingDeleteResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.pending + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PendingDeleteResponseTest { + + @Test + fun create() { + val pendingDeleteResponse = PendingDeleteResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val pendingDeleteResponse = PendingDeleteResponse.builder().build() + + val roundtrippedPendingDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(pendingDeleteResponse), + jacksonTypeRef<PendingDeleteResponse>(), + ) + + assertThat(roundtrippedPendingDeleteResponse).isEqualTo(pendingDeleteResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingListParamsTest.kt new file mode 100644 index 00000000..67ae12db --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/api/v1/workspaces/pending/PendingListParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.api.v1.workspaces.pending + +import org.junit.jupiter.api.Test + +internal class PendingListParamsTest { + + @Test + fun create() { + PendingListParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ColumnOverrideTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ColumnOverrideTest.kt new file mode 100644 index 00000000..597e0df5 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ColumnOverrideTest.kt @@ -0,0 +1,66 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.datasets.experimentviewoverrides + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ColumnOverrideTest { + + @Test + fun create() { + val columnOverride = + ColumnOverride.builder() + .column("column") + .addColorGradient(listOf(JsonValue.from(mapOf<String, Any>()))) + .colorMap( + ColumnOverride.ColorMap.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .hide(true) + .precision(1L) + .build() + + assertThat(columnOverride.column()).isEqualTo("column") + assertThat(columnOverride.colorGradient().getOrNull()) + .containsExactly(listOf(JsonValue.from(mapOf<String, Any>()))) + assertThat(columnOverride.colorMap()) + .contains( + ColumnOverride.ColorMap.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(columnOverride.hide()).contains(true) + assertThat(columnOverride.precision()).contains(1L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val columnOverride = + ColumnOverride.builder() + .column("column") + .addColorGradient(listOf(JsonValue.from(mapOf<String, Any>()))) + .colorMap( + ColumnOverride.ColorMap.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .hide(true) + .precision(1L) + .build() + + val roundtrippedColumnOverride = + jsonMapper.readValue( + jsonMapper.writeValueAsString(columnOverride), + jacksonTypeRef<ColumnOverride>(), + ) + + assertThat(roundtrippedColumnOverride).isEqualTo(columnOverride) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideCreateParamsTest.kt new file mode 100644 index 00000000..2fe7d9fb --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideCreateParamsTest.kt @@ -0,0 +1,95 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.datasets.experimentviewoverrides + +import com.langsmith_api.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ExperimentViewOverrideCreateParamsTest { + + @Test + fun create() { + ExperimentViewOverrideCreateParams.builder() + .datasetId(JsonValue.from("\"550e8400-e29b-41d4-a716-446655440000\"")) + .addColumnOverride( + ColumnOverride.builder() + .column("column") + .addColorGradient(listOf(JsonValue.from(mapOf<String, Any>()))) + .colorMap( + ColumnOverride.ColorMap.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .hide(true) + .precision(1L) + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + ExperimentViewOverrideCreateParams.builder() + .datasetId(JsonValue.from("\"550e8400-e29b-41d4-a716-446655440000\"")) + .addColumnOverride(ColumnOverride.builder().column("column").build()) + .build() + + assertThat(params._pathParam(0)).isEqualTo("\"550e8400-e29b-41d4-a716-446655440000\"") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + ExperimentViewOverrideCreateParams.builder() + .datasetId(JsonValue.from("\"550e8400-e29b-41d4-a716-446655440000\"")) + .addColumnOverride( + ColumnOverride.builder() + .column("column") + .addColorGradient(listOf(JsonValue.from(mapOf<String, Any>()))) + .colorMap( + ColumnOverride.ColorMap.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .hide(true) + .precision(1L) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.columnOverrides()) + .containsExactly( + ColumnOverride.builder() + .column("column") + .addColorGradient(listOf(JsonValue.from(mapOf<String, Any>()))) + .colorMap( + ColumnOverride.ColorMap.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .hide(true) + .precision(1L) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + ExperimentViewOverrideCreateParams.builder() + .datasetId(JsonValue.from("\"550e8400-e29b-41d4-a716-446655440000\"")) + .addColumnOverride(ColumnOverride.builder().column("column").build()) + .build() + + val body = params._body() + + assertThat(body.columnOverrides()) + .containsExactly(ColumnOverride.builder().column("column").build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideDeleteParamsTest.kt new file mode 100644 index 00000000..f80d75dc --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideDeleteParamsTest.kt @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.datasets.experimentviewoverrides + +import com.langsmith_api.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ExperimentViewOverrideDeleteParamsTest { + + @Test + fun create() { + ExperimentViewOverrideDeleteParams.builder() + .datasetId(JsonValue.from("\"550e8400-e29b-41d4-a716-446655440000\"")) + .id(JsonValue.from("\"123e4567-e89b-12d3-a456-426614174000\"")) + .build() + } + + @Test + fun pathParams() { + val params = + ExperimentViewOverrideDeleteParams.builder() + .datasetId(JsonValue.from("\"550e8400-e29b-41d4-a716-446655440000\"")) + .id(JsonValue.from("\"123e4567-e89b-12d3-a456-426614174000\"")) + .build() + + assertThat(params._pathParam(0)).isEqualTo("\"550e8400-e29b-41d4-a716-446655440000\"") + assertThat(params._pathParam(1)).isEqualTo("\"123e4567-e89b-12d3-a456-426614174000\"") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideListParamsTest.kt new file mode 100644 index 00000000..acb5016b --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideListParamsTest.kt @@ -0,0 +1,29 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.datasets.experimentviewoverrides + +import com.langsmith_api.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ExperimentViewOverrideListParamsTest { + + @Test + fun create() { + ExperimentViewOverrideListParams.builder() + .datasetId(JsonValue.from("\"550e8400-e29b-41d4-a716-446655440000\"")) + .build() + } + + @Test + fun pathParams() { + val params = + ExperimentViewOverrideListParams.builder() + .datasetId(JsonValue.from("\"550e8400-e29b-41d4-a716-446655440000\"")) + .build() + + assertThat(params._pathParam(0)).isEqualTo("\"550e8400-e29b-41d4-a716-446655440000\"") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideRetrieveParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideRetrieveParamsTest.kt new file mode 100644 index 00000000..41aaea52 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideRetrieveParamsTest.kt @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.datasets.experimentviewoverrides + +import com.langsmith_api.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ExperimentViewOverrideRetrieveParamsTest { + + @Test + fun create() { + ExperimentViewOverrideRetrieveParams.builder() + .datasetId(JsonValue.from("\"550e8400-e29b-41d4-a716-446655440000\"")) + .id(JsonValue.from("\"123e4567-e89b-12d3-a456-426614174000\"")) + .build() + } + + @Test + fun pathParams() { + val params = + ExperimentViewOverrideRetrieveParams.builder() + .datasetId(JsonValue.from("\"550e8400-e29b-41d4-a716-446655440000\"")) + .id(JsonValue.from("\"123e4567-e89b-12d3-a456-426614174000\"")) + .build() + + assertThat(params._pathParam(0)).isEqualTo("\"550e8400-e29b-41d4-a716-446655440000\"") + assertThat(params._pathParam(1)).isEqualTo("\"123e4567-e89b-12d3-a456-426614174000\"") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideTest.kt new file mode 100644 index 00000000..c8684799 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideTest.kt @@ -0,0 +1,89 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.datasets.experimentviewoverrides + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ExperimentViewOverrideTest { + + @Test + fun create() { + val experimentViewOverride = + ExperimentViewOverride.builder() + .id("id") + .addColumnOverride( + ColumnOverride.builder() + .column("column") + .addColorGradient(listOf(JsonValue.from(mapOf<String, Any>()))) + .colorMap( + ColumnOverride.ColorMap.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .hide(true) + .precision(1L) + .build() + ) + .createdAt("created_at") + .datasetId("dataset_id") + .modifiedAt("modified_at") + .build() + + assertThat(experimentViewOverride.id()).contains("id") + assertThat(experimentViewOverride.columnOverrides().getOrNull()) + .containsExactly( + ColumnOverride.builder() + .column("column") + .addColorGradient(listOf(JsonValue.from(mapOf<String, Any>()))) + .colorMap( + ColumnOverride.ColorMap.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .hide(true) + .precision(1L) + .build() + ) + assertThat(experimentViewOverride.createdAt()).contains("created_at") + assertThat(experimentViewOverride.datasetId()).contains("dataset_id") + assertThat(experimentViewOverride.modifiedAt()).contains("modified_at") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val experimentViewOverride = + ExperimentViewOverride.builder() + .id("id") + .addColumnOverride( + ColumnOverride.builder() + .column("column") + .addColorGradient(listOf(JsonValue.from(mapOf<String, Any>()))) + .colorMap( + ColumnOverride.ColorMap.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .hide(true) + .precision(1L) + .build() + ) + .createdAt("created_at") + .datasetId("dataset_id") + .modifiedAt("modified_at") + .build() + + val roundtrippedExperimentViewOverride = + jsonMapper.readValue( + jsonMapper.writeValueAsString(experimentViewOverride), + jacksonTypeRef<ExperimentViewOverride>(), + ) + + assertThat(roundtrippedExperimentViewOverride).isEqualTo(experimentViewOverride) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideUpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideUpdateParamsTest.kt new file mode 100644 index 00000000..e8fdcdcc --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/datasets/experimentviewoverrides/ExperimentViewOverrideUpdateParamsTest.kt @@ -0,0 +1,100 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.datasets.experimentviewoverrides + +import com.langsmith_api.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ExperimentViewOverrideUpdateParamsTest { + + @Test + fun create() { + ExperimentViewOverrideUpdateParams.builder() + .datasetId(JsonValue.from("\"550e8400-e29b-41d4-a716-446655440000\"")) + .id(JsonValue.from("\"123e4567-e89b-12d3-a456-426614174000\"")) + .addColumnOverride( + ColumnOverride.builder() + .column("column") + .addColorGradient(listOf(JsonValue.from(mapOf<String, Any>()))) + .colorMap( + ColumnOverride.ColorMap.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .hide(true) + .precision(1L) + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + ExperimentViewOverrideUpdateParams.builder() + .datasetId(JsonValue.from("\"550e8400-e29b-41d4-a716-446655440000\"")) + .id(JsonValue.from("\"123e4567-e89b-12d3-a456-426614174000\"")) + .addColumnOverride(ColumnOverride.builder().column("column").build()) + .build() + + assertThat(params._pathParam(0)).isEqualTo("\"550e8400-e29b-41d4-a716-446655440000\"") + assertThat(params._pathParam(1)).isEqualTo("\"123e4567-e89b-12d3-a456-426614174000\"") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } + + @Test + fun body() { + val params = + ExperimentViewOverrideUpdateParams.builder() + .datasetId(JsonValue.from("\"550e8400-e29b-41d4-a716-446655440000\"")) + .id(JsonValue.from("\"123e4567-e89b-12d3-a456-426614174000\"")) + .addColumnOverride( + ColumnOverride.builder() + .column("column") + .addColorGradient(listOf(JsonValue.from(mapOf<String, Any>()))) + .colorMap( + ColumnOverride.ColorMap.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .hide(true) + .precision(1L) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.columnOverrides()) + .containsExactly( + ColumnOverride.builder() + .column("column") + .addColorGradient(listOf(JsonValue.from(mapOf<String, Any>()))) + .colorMap( + ColumnOverride.ColorMap.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .hide(true) + .precision(1L) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + ExperimentViewOverrideUpdateParams.builder() + .datasetId(JsonValue.from("\"550e8400-e29b-41d4-a716-446655440000\"")) + .id(JsonValue.from("\"123e4567-e89b-12d3-a456-426614174000\"")) + .addColumnOverride(ColumnOverride.builder().column("column").build()) + .build() + + val body = params._body() + + assertThat(body.columnOverrides()) + .containsExactly(ColumnOverride.builder().column("column").build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/feedback/FeedbackIngestBatchParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/feedback/FeedbackIngestBatchParamsTest.kt new file mode 100644 index 00000000..7ef2f6ba --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/feedback/FeedbackIngestBatchParamsTest.kt @@ -0,0 +1,162 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.feedback + +import com.langsmith_api.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FeedbackIngestBatchParamsTest { + + @Test + fun create() { + FeedbackIngestBatchParams.builder() + .addBody( + FeedbackIngestBatchParams.Body.builder() + .id("id") + .comment("comment") + .comparativeExperimentId("comparative_experiment_id") + .correction(JsonValue.from(mapOf<String, Any>())) + .createdAt("created_at") + .error(true) + .feedbackConfig( + FeedbackIngestBatchParams.Body.FeedbackConfig.builder() + .addCategory( + FeedbackIngestBatchParams.Body.FeedbackConfig.Category.builder() + .label("x") + .value(0.0) + .build() + ) + .max(0.0) + .min(0.0) + .type(FeedbackIngestBatchParams.Body.FeedbackConfig.Type.CONTINUOUS) + .build() + ) + .feedbackGroupId("feedback_group_id") + .feedbackSource( + FeedbackIngestBatchParams.Body.FeedbackSource.builder() + .metadata( + FeedbackIngestBatchParams.Body.FeedbackSource.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .type("type") + .build() + ) + .key("key") + .modifiedAt("modified_at") + .runId("run_id") + .score(JsonValue.from(mapOf<String, Any>())) + .sessionId("session_id") + .traceId("trace_id") + .value(JsonValue.from(mapOf<String, Any>())) + .build() + ) + .build() + } + + @Test + fun body() { + val params = + FeedbackIngestBatchParams.builder() + .addBody( + FeedbackIngestBatchParams.Body.builder() + .id("id") + .comment("comment") + .comparativeExperimentId("comparative_experiment_id") + .correction(JsonValue.from(mapOf<String, Any>())) + .createdAt("created_at") + .error(true) + .feedbackConfig( + FeedbackIngestBatchParams.Body.FeedbackConfig.builder() + .addCategory( + FeedbackIngestBatchParams.Body.FeedbackConfig.Category.builder() + .label("x") + .value(0.0) + .build() + ) + .max(0.0) + .min(0.0) + .type(FeedbackIngestBatchParams.Body.FeedbackConfig.Type.CONTINUOUS) + .build() + ) + .feedbackGroupId("feedback_group_id") + .feedbackSource( + FeedbackIngestBatchParams.Body.FeedbackSource.builder() + .metadata( + FeedbackIngestBatchParams.Body.FeedbackSource.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .type("type") + .build() + ) + .key("key") + .modifiedAt("modified_at") + .runId("run_id") + .score(JsonValue.from(mapOf<String, Any>())) + .sessionId("session_id") + .traceId("trace_id") + .value(JsonValue.from(mapOf<String, Any>())) + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .containsExactly( + FeedbackIngestBatchParams.Body.builder() + .id("id") + .comment("comment") + .comparativeExperimentId("comparative_experiment_id") + .correction(JsonValue.from(mapOf<String, Any>())) + .createdAt("created_at") + .error(true) + .feedbackConfig( + FeedbackIngestBatchParams.Body.FeedbackConfig.builder() + .addCategory( + FeedbackIngestBatchParams.Body.FeedbackConfig.Category.builder() + .label("x") + .value(0.0) + .build() + ) + .max(0.0) + .min(0.0) + .type(FeedbackIngestBatchParams.Body.FeedbackConfig.Type.CONTINUOUS) + .build() + ) + .feedbackGroupId("feedback_group_id") + .feedbackSource( + FeedbackIngestBatchParams.Body.FeedbackSource.builder() + .metadata( + FeedbackIngestBatchParams.Body.FeedbackSource.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .type("type") + .build() + ) + .key("key") + .modifiedAt("modified_at") + .runId("run_id") + .score(JsonValue.from(mapOf<String, Any>())) + .sessionId("session_id") + .traceId("trace_id") + .value(JsonValue.from(mapOf<String, Any>())) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + FeedbackIngestBatchParams.builder() + .addBody(FeedbackIngestBatchParams.Body.builder().build()) + .build() + + val body = params._body() + + assertThat(body).containsExactly(FeedbackIngestBatchParams.Body.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/feedback/FeedbackIngestBatchResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/feedback/FeedbackIngestBatchResponseTest.kt new file mode 100644 index 00000000..98e69d24 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/feedback/FeedbackIngestBatchResponseTest.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.feedback + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FeedbackIngestBatchResponseTest { + + @Test + fun create() { + val feedbackIngestBatchResponse = + FeedbackIngestBatchResponse.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf("message" to "message"))) + .build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val feedbackIngestBatchResponse = + FeedbackIngestBatchResponse.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf("message" to "message"))) + .build() + + val roundtrippedFeedbackIngestBatchResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(feedbackIngestBatchResponse), + jacksonTypeRef<FeedbackIngestBatchResponse>(), + ) + + assertThat(roundtrippedFeedbackIngestBatchResponse).isEqualTo(feedbackIngestBatchResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertActionBaseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertActionBaseTest.kt new file mode 100644 index 00000000..956f50d9 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertActionBaseTest.kt @@ -0,0 +1,48 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.alerts + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AlertActionBaseTest { + + @Test + fun create() { + val alertActionBase = + AlertActionBase.builder() + .config(JsonValue.from(mapOf<String, Any>())) + .target(AlertActionBase.Target.PAGERDUTY) + .id("id") + .alertRuleId("alert_rule_id") + .build() + + assertThat(alertActionBase._config()).isEqualTo(JsonValue.from(mapOf<String, Any>())) + assertThat(alertActionBase.target()).isEqualTo(AlertActionBase.Target.PAGERDUTY) + assertThat(alertActionBase.id()).contains("id") + assertThat(alertActionBase.alertRuleId()).contains("alert_rule_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val alertActionBase = + AlertActionBase.builder() + .config(JsonValue.from(mapOf<String, Any>())) + .target(AlertActionBase.Target.PAGERDUTY) + .id("id") + .alertRuleId("alert_rule_id") + .build() + + val roundtrippedAlertActionBase = + jsonMapper.readValue( + jsonMapper.writeValueAsString(alertActionBase), + jacksonTypeRef<AlertActionBase>(), + ) + + assertThat(roundtrippedAlertActionBase).isEqualTo(alertActionBase) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertCreateParamsTest.kt new file mode 100644 index 00000000..d755a70b --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertCreateParamsTest.kt @@ -0,0 +1,181 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.alerts + +import com.langsmith_api.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AlertCreateParamsTest { + + @Test + fun create() { + AlertCreateParams.builder() + .sessionId(JsonValue.from(mapOf<String, Any>())) + .addAction( + AlertActionBase.builder() + .config(JsonValue.from(mapOf<String, Any>())) + .target(AlertActionBase.Target.PAGERDUTY) + .id("id") + .alertRuleId("alert_rule_id") + .build() + ) + .rule( + AlertRuleBase.builder() + .aggregation(AlertRuleBase.Aggregation.AVG) + .attribute(AlertRuleBase.Attribute.LATENCY) + .description("description") + .name("name") + .operator(AlertRuleBase.Operator.GTE) + .type(AlertRuleBase.Type.THRESHOLD) + .windowMinutes(15L) + .id("id") + .denominatorFilter("denominator_filter") + .filter("filter") + .threshold(0.0) + .thresholdMultiplier(0.0) + .thresholdWindowMinutes(60L) + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + AlertCreateParams.builder() + .sessionId(JsonValue.from(mapOf<String, Any>())) + .addAction( + AlertActionBase.builder() + .config(JsonValue.from(mapOf<String, Any>())) + .target(AlertActionBase.Target.PAGERDUTY) + .build() + ) + .rule( + AlertRuleBase.builder() + .aggregation(AlertRuleBase.Aggregation.AVG) + .attribute(AlertRuleBase.Attribute.LATENCY) + .description("description") + .name("name") + .operator(AlertRuleBase.Operator.GTE) + .type(AlertRuleBase.Type.THRESHOLD) + .windowMinutes(15L) + .build() + ) + .build() + + assertThat(params._pathParam(0)).isEqualTo("[object Object]") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + AlertCreateParams.builder() + .sessionId(JsonValue.from(mapOf<String, Any>())) + .addAction( + AlertActionBase.builder() + .config(JsonValue.from(mapOf<String, Any>())) + .target(AlertActionBase.Target.PAGERDUTY) + .id("id") + .alertRuleId("alert_rule_id") + .build() + ) + .rule( + AlertRuleBase.builder() + .aggregation(AlertRuleBase.Aggregation.AVG) + .attribute(AlertRuleBase.Attribute.LATENCY) + .description("description") + .name("name") + .operator(AlertRuleBase.Operator.GTE) + .type(AlertRuleBase.Type.THRESHOLD) + .windowMinutes(15L) + .id("id") + .denominatorFilter("denominator_filter") + .filter("filter") + .threshold(0.0) + .thresholdMultiplier(0.0) + .thresholdWindowMinutes(60L) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.actions()) + .containsExactly( + AlertActionBase.builder() + .config(JsonValue.from(mapOf<String, Any>())) + .target(AlertActionBase.Target.PAGERDUTY) + .id("id") + .alertRuleId("alert_rule_id") + .build() + ) + assertThat(body.rule()) + .isEqualTo( + AlertRuleBase.builder() + .aggregation(AlertRuleBase.Aggregation.AVG) + .attribute(AlertRuleBase.Attribute.LATENCY) + .description("description") + .name("name") + .operator(AlertRuleBase.Operator.GTE) + .type(AlertRuleBase.Type.THRESHOLD) + .windowMinutes(15L) + .id("id") + .denominatorFilter("denominator_filter") + .filter("filter") + .threshold(0.0) + .thresholdMultiplier(0.0) + .thresholdWindowMinutes(60L) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + AlertCreateParams.builder() + .sessionId(JsonValue.from(mapOf<String, Any>())) + .addAction( + AlertActionBase.builder() + .config(JsonValue.from(mapOf<String, Any>())) + .target(AlertActionBase.Target.PAGERDUTY) + .build() + ) + .rule( + AlertRuleBase.builder() + .aggregation(AlertRuleBase.Aggregation.AVG) + .attribute(AlertRuleBase.Attribute.LATENCY) + .description("description") + .name("name") + .operator(AlertRuleBase.Operator.GTE) + .type(AlertRuleBase.Type.THRESHOLD) + .windowMinutes(15L) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.actions()) + .containsExactly( + AlertActionBase.builder() + .config(JsonValue.from(mapOf<String, Any>())) + .target(AlertActionBase.Target.PAGERDUTY) + .build() + ) + assertThat(body.rule()) + .isEqualTo( + AlertRuleBase.builder() + .aggregation(AlertRuleBase.Aggregation.AVG) + .attribute(AlertRuleBase.Attribute.LATENCY) + .description("description") + .name("name") + .operator(AlertRuleBase.Operator.GTE) + .type(AlertRuleBase.Type.THRESHOLD) + .windowMinutes(15L) + .build() + ) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertDeleteParamsTest.kt new file mode 100644 index 00000000..443007ba --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertDeleteParamsTest.kt @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.alerts + +import com.langsmith_api.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AlertDeleteParamsTest { + + @Test + fun create() { + AlertDeleteParams.builder() + .sessionId(JsonValue.from(mapOf<String, Any>())) + .alertRuleId(JsonValue.from(mapOf<String, Any>())) + .build() + } + + @Test + fun pathParams() { + val params = + AlertDeleteParams.builder() + .sessionId(JsonValue.from(mapOf<String, Any>())) + .alertRuleId(JsonValue.from(mapOf<String, Any>())) + .build() + + assertThat(params._pathParam(0)).isEqualTo("[object Object]") + assertThat(params._pathParam(1)).isEqualTo("[object Object]") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertDeleteResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertDeleteResponseTest.kt new file mode 100644 index 00000000..dbf0b65f --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertDeleteResponseTest.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.alerts + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AlertDeleteResponseTest { + + @Test + fun create() { + val alertDeleteResponse = + AlertDeleteResponse.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf("message" to "message"))) + .build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val alertDeleteResponse = + AlertDeleteResponse.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf("message" to "message"))) + .build() + + val roundtrippedAlertDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(alertDeleteResponse), + jacksonTypeRef<AlertDeleteResponse>(), + ) + + assertThat(roundtrippedAlertDeleteResponse).isEqualTo(alertDeleteResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertRetrieveParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertRetrieveParamsTest.kt new file mode 100644 index 00000000..c9a66268 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertRetrieveParamsTest.kt @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.alerts + +import com.langsmith_api.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AlertRetrieveParamsTest { + + @Test + fun create() { + AlertRetrieveParams.builder() + .sessionId(JsonValue.from(mapOf<String, Any>())) + .alertRuleId(JsonValue.from(mapOf<String, Any>())) + .build() + } + + @Test + fun pathParams() { + val params = + AlertRetrieveParams.builder() + .sessionId(JsonValue.from(mapOf<String, Any>())) + .alertRuleId(JsonValue.from(mapOf<String, Any>())) + .build() + + assertThat(params._pathParam(0)).isEqualTo("[object Object]") + assertThat(params._pathParam(1)).isEqualTo("[object Object]") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertRuleBaseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertRuleBaseTest.kt new file mode 100644 index 00000000..86daf55e --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertRuleBaseTest.kt @@ -0,0 +1,74 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.alerts + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AlertRuleBaseTest { + + @Test + fun create() { + val alertRuleBase = + AlertRuleBase.builder() + .aggregation(AlertRuleBase.Aggregation.AVG) + .attribute(AlertRuleBase.Attribute.LATENCY) + .description("description") + .name("name") + .operator(AlertRuleBase.Operator.GTE) + .type(AlertRuleBase.Type.THRESHOLD) + .windowMinutes(15L) + .id("id") + .denominatorFilter("denominator_filter") + .filter("filter") + .threshold(0.0) + .thresholdMultiplier(0.0) + .thresholdWindowMinutes(60L) + .build() + + assertThat(alertRuleBase.aggregation()).isEqualTo(AlertRuleBase.Aggregation.AVG) + assertThat(alertRuleBase.attribute()).isEqualTo(AlertRuleBase.Attribute.LATENCY) + assertThat(alertRuleBase.description()).isEqualTo("description") + assertThat(alertRuleBase.name()).isEqualTo("name") + assertThat(alertRuleBase.operator()).isEqualTo(AlertRuleBase.Operator.GTE) + assertThat(alertRuleBase.type()).isEqualTo(AlertRuleBase.Type.THRESHOLD) + assertThat(alertRuleBase.windowMinutes()).isEqualTo(15L) + assertThat(alertRuleBase.id()).contains("id") + assertThat(alertRuleBase.denominatorFilter()).contains("denominator_filter") + assertThat(alertRuleBase.filter()).contains("filter") + assertThat(alertRuleBase.threshold()).contains(0.0) + assertThat(alertRuleBase.thresholdMultiplier()).contains(0.0) + assertThat(alertRuleBase.thresholdWindowMinutes()).contains(60L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val alertRuleBase = + AlertRuleBase.builder() + .aggregation(AlertRuleBase.Aggregation.AVG) + .attribute(AlertRuleBase.Attribute.LATENCY) + .description("description") + .name("name") + .operator(AlertRuleBase.Operator.GTE) + .type(AlertRuleBase.Type.THRESHOLD) + .windowMinutes(15L) + .id("id") + .denominatorFilter("denominator_filter") + .filter("filter") + .threshold(0.0) + .thresholdMultiplier(0.0) + .thresholdWindowMinutes(60L) + .build() + + val roundtrippedAlertRuleBase = + jsonMapper.readValue( + jsonMapper.writeValueAsString(alertRuleBase), + jacksonTypeRef<AlertRuleBase>(), + ) + + assertThat(roundtrippedAlertRuleBase).isEqualTo(alertRuleBase) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertRuleResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertRuleResponseTest.kt new file mode 100644 index 00000000..21bbc8dc --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertRuleResponseTest.kt @@ -0,0 +1,126 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.alerts + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AlertRuleResponseTest { + + @Test + fun create() { + val alertRuleResponse = + AlertRuleResponse.builder() + .addAction( + AlertRuleResponse.Action.builder() + .config(JsonValue.from(mapOf<String, Any>())) + .target(AlertRuleResponse.Action.Target.PAGERDUTY) + .id("id") + .alertRuleId("alert_rule_id") + .createdAt("created_at") + .updatedAt("updated_at") + .build() + ) + .rule( + AlertRuleResponse.Rule.builder() + .aggregation(AlertRuleResponse.Rule.Aggregation.AVG) + .attribute(AlertRuleResponse.Rule.Attribute.LATENCY) + .description("description") + .name("name") + .operator(AlertRuleResponse.Rule.Operator.GTE) + .type(AlertRuleResponse.Rule.Type.THRESHOLD) + .windowMinutes(15L) + .id("id") + .createdAt("created_at") + .denominatorFilter("denominator_filter") + .filter("filter") + .threshold(0.0) + .thresholdMultiplier(0.0) + .thresholdWindowMinutes(60L) + .updatedAt("updated_at") + .build() + ) + .build() + + assertThat(alertRuleResponse.actions().getOrNull()) + .containsExactly( + AlertRuleResponse.Action.builder() + .config(JsonValue.from(mapOf<String, Any>())) + .target(AlertRuleResponse.Action.Target.PAGERDUTY) + .id("id") + .alertRuleId("alert_rule_id") + .createdAt("created_at") + .updatedAt("updated_at") + .build() + ) + assertThat(alertRuleResponse.rule()) + .contains( + AlertRuleResponse.Rule.builder() + .aggregation(AlertRuleResponse.Rule.Aggregation.AVG) + .attribute(AlertRuleResponse.Rule.Attribute.LATENCY) + .description("description") + .name("name") + .operator(AlertRuleResponse.Rule.Operator.GTE) + .type(AlertRuleResponse.Rule.Type.THRESHOLD) + .windowMinutes(15L) + .id("id") + .createdAt("created_at") + .denominatorFilter("denominator_filter") + .filter("filter") + .threshold(0.0) + .thresholdMultiplier(0.0) + .thresholdWindowMinutes(60L) + .updatedAt("updated_at") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val alertRuleResponse = + AlertRuleResponse.builder() + .addAction( + AlertRuleResponse.Action.builder() + .config(JsonValue.from(mapOf<String, Any>())) + .target(AlertRuleResponse.Action.Target.PAGERDUTY) + .id("id") + .alertRuleId("alert_rule_id") + .createdAt("created_at") + .updatedAt("updated_at") + .build() + ) + .rule( + AlertRuleResponse.Rule.builder() + .aggregation(AlertRuleResponse.Rule.Aggregation.AVG) + .attribute(AlertRuleResponse.Rule.Attribute.LATENCY) + .description("description") + .name("name") + .operator(AlertRuleResponse.Rule.Operator.GTE) + .type(AlertRuleResponse.Rule.Type.THRESHOLD) + .windowMinutes(15L) + .id("id") + .createdAt("created_at") + .denominatorFilter("denominator_filter") + .filter("filter") + .threshold(0.0) + .thresholdMultiplier(0.0) + .thresholdWindowMinutes(60L) + .updatedAt("updated_at") + .build() + ) + .build() + + val roundtrippedAlertRuleResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(alertRuleResponse), + jacksonTypeRef<AlertRuleResponse>(), + ) + + assertThat(roundtrippedAlertRuleResponse).isEqualTo(alertRuleResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertTestParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertTestParamsTest.kt new file mode 100644 index 00000000..a926c7b3 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertTestParamsTest.kt @@ -0,0 +1,25 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.alerts + +import com.langsmith_api.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AlertTestParamsTest { + + @Test + fun create() { + AlertTestParams.builder().sessionId(JsonValue.from(mapOf<String, Any>())).build() + } + + @Test + fun pathParams() { + val params = + AlertTestParams.builder().sessionId(JsonValue.from(mapOf<String, Any>())).build() + + assertThat(params._pathParam(0)).isEqualTo("[object Object]") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertTestResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertTestResponseTest.kt new file mode 100644 index 00000000..1404d4ac --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertTestResponseTest.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.alerts + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AlertTestResponseTest { + + @Test + fun create() { + val alertTestResponse = + AlertTestResponse.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf("message" to "message"))) + .build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val alertTestResponse = + AlertTestResponse.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf("message" to "message"))) + .build() + + val roundtrippedAlertTestResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(alertTestResponse), + jacksonTypeRef<AlertTestResponse>(), + ) + + assertThat(roundtrippedAlertTestResponse).isEqualTo(alertTestResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertUpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertUpdateParamsTest.kt new file mode 100644 index 00000000..72655ef6 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertUpdateParamsTest.kt @@ -0,0 +1,186 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.alerts + +import com.langsmith_api.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AlertUpdateParamsTest { + + @Test + fun create() { + AlertUpdateParams.builder() + .sessionId(JsonValue.from(mapOf<String, Any>())) + .alertRuleId(JsonValue.from(mapOf<String, Any>())) + .addAction( + AlertActionBase.builder() + .config(JsonValue.from(mapOf<String, Any>())) + .target(AlertActionBase.Target.PAGERDUTY) + .id("id") + .alertRuleId("alert_rule_id") + .build() + ) + .rule( + AlertRuleBase.builder() + .aggregation(AlertRuleBase.Aggregation.AVG) + .attribute(AlertRuleBase.Attribute.LATENCY) + .description("description") + .name("name") + .operator(AlertRuleBase.Operator.GTE) + .type(AlertRuleBase.Type.THRESHOLD) + .windowMinutes(15L) + .id("id") + .denominatorFilter("denominator_filter") + .filter("filter") + .threshold(0.0) + .thresholdMultiplier(0.0) + .thresholdWindowMinutes(60L) + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + AlertUpdateParams.builder() + .sessionId(JsonValue.from(mapOf<String, Any>())) + .alertRuleId(JsonValue.from(mapOf<String, Any>())) + .addAction( + AlertActionBase.builder() + .config(JsonValue.from(mapOf<String, Any>())) + .target(AlertActionBase.Target.PAGERDUTY) + .build() + ) + .rule( + AlertRuleBase.builder() + .aggregation(AlertRuleBase.Aggregation.AVG) + .attribute(AlertRuleBase.Attribute.LATENCY) + .description("description") + .name("name") + .operator(AlertRuleBase.Operator.GTE) + .type(AlertRuleBase.Type.THRESHOLD) + .windowMinutes(15L) + .build() + ) + .build() + + assertThat(params._pathParam(0)).isEqualTo("[object Object]") + assertThat(params._pathParam(1)).isEqualTo("[object Object]") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } + + @Test + fun body() { + val params = + AlertUpdateParams.builder() + .sessionId(JsonValue.from(mapOf<String, Any>())) + .alertRuleId(JsonValue.from(mapOf<String, Any>())) + .addAction( + AlertActionBase.builder() + .config(JsonValue.from(mapOf<String, Any>())) + .target(AlertActionBase.Target.PAGERDUTY) + .id("id") + .alertRuleId("alert_rule_id") + .build() + ) + .rule( + AlertRuleBase.builder() + .aggregation(AlertRuleBase.Aggregation.AVG) + .attribute(AlertRuleBase.Attribute.LATENCY) + .description("description") + .name("name") + .operator(AlertRuleBase.Operator.GTE) + .type(AlertRuleBase.Type.THRESHOLD) + .windowMinutes(15L) + .id("id") + .denominatorFilter("denominator_filter") + .filter("filter") + .threshold(0.0) + .thresholdMultiplier(0.0) + .thresholdWindowMinutes(60L) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.actions()) + .containsExactly( + AlertActionBase.builder() + .config(JsonValue.from(mapOf<String, Any>())) + .target(AlertActionBase.Target.PAGERDUTY) + .id("id") + .alertRuleId("alert_rule_id") + .build() + ) + assertThat(body.rule()) + .isEqualTo( + AlertRuleBase.builder() + .aggregation(AlertRuleBase.Aggregation.AVG) + .attribute(AlertRuleBase.Attribute.LATENCY) + .description("description") + .name("name") + .operator(AlertRuleBase.Operator.GTE) + .type(AlertRuleBase.Type.THRESHOLD) + .windowMinutes(15L) + .id("id") + .denominatorFilter("denominator_filter") + .filter("filter") + .threshold(0.0) + .thresholdMultiplier(0.0) + .thresholdWindowMinutes(60L) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + AlertUpdateParams.builder() + .sessionId(JsonValue.from(mapOf<String, Any>())) + .alertRuleId(JsonValue.from(mapOf<String, Any>())) + .addAction( + AlertActionBase.builder() + .config(JsonValue.from(mapOf<String, Any>())) + .target(AlertActionBase.Target.PAGERDUTY) + .build() + ) + .rule( + AlertRuleBase.builder() + .aggregation(AlertRuleBase.Aggregation.AVG) + .attribute(AlertRuleBase.Attribute.LATENCY) + .description("description") + .name("name") + .operator(AlertRuleBase.Operator.GTE) + .type(AlertRuleBase.Type.THRESHOLD) + .windowMinutes(15L) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.actions()) + .containsExactly( + AlertActionBase.builder() + .config(JsonValue.from(mapOf<String, Any>())) + .target(AlertActionBase.Target.PAGERDUTY) + .build() + ) + assertThat(body.rule()) + .isEqualTo( + AlertRuleBase.builder() + .aggregation(AlertRuleBase.Aggregation.AVG) + .attribute(AlertRuleBase.Attribute.LATENCY) + .description("description") + .name("name") + .operator(AlertRuleBase.Operator.GTE) + .type(AlertRuleBase.Type.THRESHOLD) + .windowMinutes(15L) + .build() + ) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertUpdateResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertUpdateResponseTest.kt new file mode 100644 index 00000000..8af6eb10 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/alerts/AlertUpdateResponseTest.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.alerts + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AlertUpdateResponseTest { + + @Test + fun create() { + val alertUpdateResponse = + AlertUpdateResponse.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf("message" to "message"))) + .build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val alertUpdateResponse = + AlertUpdateResponse.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf("message" to "message"))) + .build() + + val roundtrippedAlertUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(alertUpdateResponse), + jacksonTypeRef<AlertUpdateResponse>(), + ) + + assertThat(roundtrippedAlertUpdateResponse).isEqualTo(alertUpdateResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleHardDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleHardDeleteParamsTest.kt new file mode 100644 index 00000000..3af1dc80 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleHardDeleteParamsTest.kt @@ -0,0 +1,25 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.datasets.examples + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ExampleHardDeleteParamsTest { + + @Test + fun create() { + ExampleHardDeleteParams.builder().addExampleId("string").hardDelete(true).build() + } + + @Test + fun body() { + val params = + ExampleHardDeleteParams.builder().addExampleId("string").hardDelete(true).build() + + val body = params._body() + + assertThat(body.exampleIds()).containsExactly("string") + assertThat(body.hardDelete()).isEqualTo(true) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleHardDeleteResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleHardDeleteResponseTest.kt new file mode 100644 index 00000000..71afcc21 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleHardDeleteResponseTest.kt @@ -0,0 +1,43 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.datasets.examples + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ExampleHardDeleteResponseTest { + + @Test + fun create() { + val exampleHardDeleteResponse = + ExampleHardDeleteResponse.builder() + .count(1L) + .addExampleId("[\"123e4567-e89b-12d3-a456-426614174000\"]") + .build() + + assertThat(exampleHardDeleteResponse.count()).contains(1L) + assertThat(exampleHardDeleteResponse.exampleIds().getOrNull()) + .containsExactly("[\"123e4567-e89b-12d3-a456-426614174000\"]") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val exampleHardDeleteResponse = + ExampleHardDeleteResponse.builder() + .count(1L) + .addExampleId("[\"123e4567-e89b-12d3-a456-426614174000\"]") + .build() + + val roundtrippedExampleHardDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(exampleHardDeleteResponse), + jacksonTypeRef<ExampleHardDeleteResponse>(), + ) + + assertThat(roundtrippedExampleHardDeleteResponse).isEqualTo(exampleHardDeleteResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleUpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleUpdateParamsTest.kt new file mode 100644 index 00000000..d9dc2e19 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleUpdateParamsTest.kt @@ -0,0 +1,103 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.datasets.examples + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.MultipartField +import java.io.InputStream +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ExampleUpdateParamsTest { + + @Test + fun create() { + ExampleUpdateParams.builder() + .datasetId(JsonValue.from(mapOf<String, Any>())) + .exampleId("some content".byteInputStream()) + .exampleIdAttachmentName("some content".byteInputStream()) + .exampleIdAttachmentsOperations("some content".byteInputStream()) + .exampleIdInputs("some content".byteInputStream()) + .exampleIdOutputs("some content".byteInputStream()) + .build() + } + + @Test + fun pathParams() { + val params = + ExampleUpdateParams.builder() + .datasetId(JsonValue.from(mapOf<String, Any>())) + .exampleId("some content".byteInputStream()) + .build() + + assertThat(params._pathParam(0)).isEqualTo("[object Object]") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + ExampleUpdateParams.builder() + .datasetId(JsonValue.from(mapOf<String, Any>())) + .exampleId("some content".byteInputStream()) + .exampleIdAttachmentName("some content".byteInputStream()) + .exampleIdAttachmentsOperations("some content".byteInputStream()) + .exampleIdInputs("some content".byteInputStream()) + .exampleIdOutputs("some content".byteInputStream()) + .build() + + val body = params._body() + + assertThat(body.filterValues { !it.value.isNull() }) + .usingRecursiveComparison() + // TODO(AssertJ): Replace this and the `mapValues` below with: + // https://github.com/assertj/assertj/issues/3165 + .withEqualsForType( + { a, b -> a.readBytes() contentEquals b.readBytes() }, + InputStream::class.java, + ) + .isEqualTo( + mapOf( + "{example_id}" to MultipartField.of("some content".byteInputStream()), + "{example_id}.attachment.{name}" to + MultipartField.of("some content".byteInputStream()), + "{example_id}.attachments_operations" to + MultipartField.of("some content".byteInputStream()), + "{example_id}.inputs" to + MultipartField.of("some content".byteInputStream()), + "{example_id}.outputs" to + MultipartField.of("some content".byteInputStream()), + ) + .mapValues { (_, field) -> + field.map { (it as? ByteArray)?.inputStream() ?: it } + } + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + ExampleUpdateParams.builder() + .datasetId(JsonValue.from(mapOf<String, Any>())) + .exampleId("some content".byteInputStream()) + .build() + + val body = params._body() + + assertThat(body.filterValues { !it.value.isNull() }) + .usingRecursiveComparison() + // TODO(AssertJ): Replace this and the `mapValues` below with: + // https://github.com/assertj/assertj/issues/3165 + .withEqualsForType( + { a, b -> a.readBytes() contentEquals b.readBytes() }, + InputStream::class.java, + ) + .isEqualTo( + mapOf("{example_id}" to MultipartField.of("some content".byteInputStream())) + .mapValues { (_, field) -> + field.map { (it as? ByteArray)?.inputStream() ?: it } + } + ) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleUpdateResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleUpdateResponseTest.kt new file mode 100644 index 00000000..83dbde8c --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleUpdateResponseTest.kt @@ -0,0 +1,43 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.datasets.examples + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ExampleUpdateResponseTest { + + @Test + fun create() { + val exampleUpdateResponse = + ExampleUpdateResponse.builder() + .count(1L) + .addExampleId("[\"123e4567-e89b-12d3-a456-426614174000\"]") + .build() + + assertThat(exampleUpdateResponse.count()).contains(1L) + assertThat(exampleUpdateResponse.exampleIds().getOrNull()) + .containsExactly("[\"123e4567-e89b-12d3-a456-426614174000\"]") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val exampleUpdateResponse = + ExampleUpdateResponse.builder() + .count(1L) + .addExampleId("[\"123e4567-e89b-12d3-a456-426614174000\"]") + .build() + + val roundtrippedExampleUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(exampleUpdateResponse), + jacksonTypeRef<ExampleUpdateResponse>(), + ) + + assertThat(roundtrippedExampleUpdateResponse).isEqualTo(exampleUpdateResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleUploadParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleUploadParamsTest.kt new file mode 100644 index 00000000..4910c3ca --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleUploadParamsTest.kt @@ -0,0 +1,104 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.datasets.examples + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.MultipartField +import java.io.InputStream +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ExampleUploadParamsTest { + + @Test + fun create() { + ExampleUploadParams.builder() + .datasetId(JsonValue.from(mapOf<String, Any>())) + .exampleId("some content".byteInputStream()) + .exampleIdInputs("some content".byteInputStream()) + .exampleIdAttachmentsName("some content".byteInputStream()) + .exampleIdOutputs("some content".byteInputStream()) + .build() + } + + @Test + fun pathParams() { + val params = + ExampleUploadParams.builder() + .datasetId(JsonValue.from(mapOf<String, Any>())) + .exampleId("some content".byteInputStream()) + .exampleIdInputs("some content".byteInputStream()) + .build() + + assertThat(params._pathParam(0)).isEqualTo("[object Object]") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + ExampleUploadParams.builder() + .datasetId(JsonValue.from(mapOf<String, Any>())) + .exampleId("some content".byteInputStream()) + .exampleIdInputs("some content".byteInputStream()) + .exampleIdAttachmentsName("some content".byteInputStream()) + .exampleIdOutputs("some content".byteInputStream()) + .build() + + val body = params._body() + + assertThat(body.filterValues { !it.value.isNull() }) + .usingRecursiveComparison() + // TODO(AssertJ): Replace this and the `mapValues` below with: + // https://github.com/assertj/assertj/issues/3165 + .withEqualsForType( + { a, b -> a.readBytes() contentEquals b.readBytes() }, + InputStream::class.java, + ) + .isEqualTo( + mapOf( + "{example_id}" to MultipartField.of("some content".byteInputStream()), + "{example_id}.inputs" to + MultipartField.of("some content".byteInputStream()), + "{example_id}.attachments.{name}" to + MultipartField.of("some content".byteInputStream()), + "{example_id}.outputs" to + MultipartField.of("some content".byteInputStream()), + ) + .mapValues { (_, field) -> + field.map { (it as? ByteArray)?.inputStream() ?: it } + } + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + ExampleUploadParams.builder() + .datasetId(JsonValue.from(mapOf<String, Any>())) + .exampleId("some content".byteInputStream()) + .exampleIdInputs("some content".byteInputStream()) + .build() + + val body = params._body() + + assertThat(body.filterValues { !it.value.isNull() }) + .usingRecursiveComparison() + // TODO(AssertJ): Replace this and the `mapValues` below with: + // https://github.com/assertj/assertj/issues/3165 + .withEqualsForType( + { a, b -> a.readBytes() contentEquals b.readBytes() }, + InputStream::class.java, + ) + .isEqualTo( + mapOf( + "{example_id}" to MultipartField.of("some content".byteInputStream()), + "{example_id}.inputs" to MultipartField.of("some content".byteInputStream()), + ) + .mapValues { (_, field) -> + field.map { (it as? ByteArray)?.inputStream() ?: it } + } + ) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleUploadResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleUploadResponseTest.kt new file mode 100644 index 00000000..a51a3369 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/datasets/examples/ExampleUploadResponseTest.kt @@ -0,0 +1,43 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.datasets.examples + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ExampleUploadResponseTest { + + @Test + fun create() { + val exampleUploadResponse = + ExampleUploadResponse.builder() + .count(1L) + .addExampleId("[\"123e4567-e89b-12d3-a456-426614174000\"]") + .build() + + assertThat(exampleUploadResponse.count()).contains(1L) + assertThat(exampleUploadResponse.exampleIds().getOrNull()) + .containsExactly("[\"123e4567-e89b-12d3-a456-426614174000\"]") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val exampleUploadResponse = + ExampleUploadResponse.builder() + .count(1L) + .addExampleId("[\"123e4567-e89b-12d3-a456-426614174000\"]") + .build() + + val roundtrippedExampleUploadResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(exampleUploadResponse), + jacksonTypeRef<ExampleUploadResponse>(), + ) + + assertThat(roundtrippedExampleUploadResponse).isEqualTo(exampleUploadResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyCreateParamsTest.kt new file mode 100644 index 00000000..fd2de19f --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyCreateParamsTest.kt @@ -0,0 +1,105 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.orgs.current.accesspolicies + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AccessPolicyCreateParamsTest { + + @Test + fun create() { + AccessPolicyCreateParams.builder() + .payload( + AccessPolicyCreateParams.Payload.builder() + .addConditionGroup( + ConditionGroup.builder() + .addCondition( + ConditionGroup.Condition.builder() + .attributeKey("attribute_key") + .attributeName( + ConditionGroup.Condition.AttributeName.RESOURCE_TAG_KEY + ) + .attributeValue("attribute_value") + .operator(ConditionGroup.Condition.Operator.EQUALS) + .build() + ) + .permission(ConditionGroup.Permission.ANNOTATION_QUEUES_CREATE) + .resourceType("resource_type") + .build() + ) + .description("description") + .effect("effect") + .name("name") + .addRoleId("string") + .build() + ) + .build() + } + + @Test + fun body() { + val params = + AccessPolicyCreateParams.builder() + .payload( + AccessPolicyCreateParams.Payload.builder() + .addConditionGroup( + ConditionGroup.builder() + .addCondition( + ConditionGroup.Condition.builder() + .attributeKey("attribute_key") + .attributeName( + ConditionGroup.Condition.AttributeName.RESOURCE_TAG_KEY + ) + .attributeValue("attribute_value") + .operator(ConditionGroup.Condition.Operator.EQUALS) + .build() + ) + .permission(ConditionGroup.Permission.ANNOTATION_QUEUES_CREATE) + .resourceType("resource_type") + .build() + ) + .description("description") + .effect("effect") + .name("name") + .addRoleId("string") + .build() + ) + .build() + + val body = params._body() + + assertThat(body.payload()) + .contains( + AccessPolicyCreateParams.Payload.builder() + .addConditionGroup( + ConditionGroup.builder() + .addCondition( + ConditionGroup.Condition.builder() + .attributeKey("attribute_key") + .attributeName( + ConditionGroup.Condition.AttributeName.RESOURCE_TAG_KEY + ) + .attributeValue("attribute_value") + .operator(ConditionGroup.Condition.Operator.EQUALS) + .build() + ) + .permission(ConditionGroup.Permission.ANNOTATION_QUEUES_CREATE) + .resourceType("resource_type") + .build() + ) + .description("description") + .effect("effect") + .name("name") + .addRoleId("string") + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = AccessPolicyCreateParams.builder().build() + + val body = params._body() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyCreateResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyCreateResponseTest.kt new file mode 100644 index 00000000..140bcc3c --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyCreateResponseTest.kt @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.orgs.current.accesspolicies + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AccessPolicyCreateResponseTest { + + @Test + fun create() { + val accessPolicyCreateResponse = AccessPolicyCreateResponse.builder().id("id").build() + + assertThat(accessPolicyCreateResponse.id()).contains("id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val accessPolicyCreateResponse = AccessPolicyCreateResponse.builder().id("id").build() + + val roundtrippedAccessPolicyCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(accessPolicyCreateResponse), + jacksonTypeRef<AccessPolicyCreateResponse>(), + ) + + assertThat(roundtrippedAccessPolicyCreateResponse).isEqualTo(accessPolicyCreateResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyDeleteParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyDeleteParamsTest.kt new file mode 100644 index 00000000..b57c0d37 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyDeleteParamsTest.kt @@ -0,0 +1,29 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.orgs.current.accesspolicies + +import com.langsmith_api.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AccessPolicyDeleteParamsTest { + + @Test + fun create() { + AccessPolicyDeleteParams.builder() + .accessPolicyId(JsonValue.from(mapOf<String, Any>())) + .build() + } + + @Test + fun pathParams() { + val params = + AccessPolicyDeleteParams.builder() + .accessPolicyId(JsonValue.from(mapOf<String, Any>())) + .build() + + assertThat(params._pathParam(0)).isEqualTo("[object Object]") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyListParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyListParamsTest.kt new file mode 100644 index 00000000..690aad67 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyListParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.orgs.current.accesspolicies + +import org.junit.jupiter.api.Test + +internal class AccessPolicyListParamsTest { + + @Test + fun create() { + AccessPolicyListParams.builder().build() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyListResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyListResponseTest.kt new file mode 100644 index 00000000..e328575c --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyListResponseTest.kt @@ -0,0 +1,118 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.orgs.current.accesspolicies + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AccessPolicyListResponseTest { + + @Test + fun create() { + val accessPolicyListResponse = + AccessPolicyListResponse.builder() + .addAccessPolicy( + AccessPolicy.builder() + .id("id") + .addConditionGroup( + ConditionGroup.builder() + .addCondition( + ConditionGroup.Condition.builder() + .attributeKey("attribute_key") + .attributeName( + ConditionGroup.Condition.AttributeName.RESOURCE_TAG_KEY + ) + .attributeValue("attribute_value") + .operator(ConditionGroup.Condition.Operator.EQUALS) + .build() + ) + .permission(ConditionGroup.Permission.ANNOTATION_QUEUES_CREATE) + .resourceType("resource_type") + .build() + ) + .createdAt("created_at") + .description("description") + .effect("effect") + .name("name") + .addRoleId("string") + .updatedAt("updated_at") + .build() + ) + .build() + + assertThat(accessPolicyListResponse.accessPolicies().getOrNull()) + .containsExactly( + AccessPolicy.builder() + .id("id") + .addConditionGroup( + ConditionGroup.builder() + .addCondition( + ConditionGroup.Condition.builder() + .attributeKey("attribute_key") + .attributeName( + ConditionGroup.Condition.AttributeName.RESOURCE_TAG_KEY + ) + .attributeValue("attribute_value") + .operator(ConditionGroup.Condition.Operator.EQUALS) + .build() + ) + .permission(ConditionGroup.Permission.ANNOTATION_QUEUES_CREATE) + .resourceType("resource_type") + .build() + ) + .createdAt("created_at") + .description("description") + .effect("effect") + .name("name") + .addRoleId("string") + .updatedAt("updated_at") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val accessPolicyListResponse = + AccessPolicyListResponse.builder() + .addAccessPolicy( + AccessPolicy.builder() + .id("id") + .addConditionGroup( + ConditionGroup.builder() + .addCondition( + ConditionGroup.Condition.builder() + .attributeKey("attribute_key") + .attributeName( + ConditionGroup.Condition.AttributeName.RESOURCE_TAG_KEY + ) + .attributeValue("attribute_value") + .operator(ConditionGroup.Condition.Operator.EQUALS) + .build() + ) + .permission(ConditionGroup.Permission.ANNOTATION_QUEUES_CREATE) + .resourceType("resource_type") + .build() + ) + .createdAt("created_at") + .description("description") + .effect("effect") + .name("name") + .addRoleId("string") + .updatedAt("updated_at") + .build() + ) + .build() + + val roundtrippedAccessPolicyListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(accessPolicyListResponse), + jacksonTypeRef<AccessPolicyListResponse>(), + ) + + assertThat(roundtrippedAccessPolicyListResponse).isEqualTo(accessPolicyListResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyRetrieveParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyRetrieveParamsTest.kt new file mode 100644 index 00000000..c79e6382 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyRetrieveParamsTest.kt @@ -0,0 +1,29 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.orgs.current.accesspolicies + +import com.langsmith_api.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AccessPolicyRetrieveParamsTest { + + @Test + fun create() { + AccessPolicyRetrieveParams.builder() + .accessPolicyId(JsonValue.from(mapOf<String, Any>())) + .build() + } + + @Test + fun pathParams() { + val params = + AccessPolicyRetrieveParams.builder() + .accessPolicyId(JsonValue.from(mapOf<String, Any>())) + .build() + + assertThat(params._pathParam(0)).isEqualTo("[object Object]") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyTest.kt new file mode 100644 index 00000000..da181960 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/AccessPolicyTest.kt @@ -0,0 +1,104 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.orgs.current.accesspolicies + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AccessPolicyTest { + + @Test + fun create() { + val accessPolicy = + AccessPolicy.builder() + .id("id") + .addConditionGroup( + ConditionGroup.builder() + .addCondition( + ConditionGroup.Condition.builder() + .attributeKey("attribute_key") + .attributeName( + ConditionGroup.Condition.AttributeName.RESOURCE_TAG_KEY + ) + .attributeValue("attribute_value") + .operator(ConditionGroup.Condition.Operator.EQUALS) + .build() + ) + .permission(ConditionGroup.Permission.ANNOTATION_QUEUES_CREATE) + .resourceType("resource_type") + .build() + ) + .createdAt("created_at") + .description("description") + .effect("effect") + .name("name") + .addRoleId("string") + .updatedAt("updated_at") + .build() + + assertThat(accessPolicy.id()).contains("id") + assertThat(accessPolicy.conditionGroups().getOrNull()) + .containsExactly( + ConditionGroup.builder() + .addCondition( + ConditionGroup.Condition.builder() + .attributeKey("attribute_key") + .attributeName(ConditionGroup.Condition.AttributeName.RESOURCE_TAG_KEY) + .attributeValue("attribute_value") + .operator(ConditionGroup.Condition.Operator.EQUALS) + .build() + ) + .permission(ConditionGroup.Permission.ANNOTATION_QUEUES_CREATE) + .resourceType("resource_type") + .build() + ) + assertThat(accessPolicy.createdAt()).contains("created_at") + assertThat(accessPolicy.description()).contains("description") + assertThat(accessPolicy.effect()).contains("effect") + assertThat(accessPolicy.name()).contains("name") + assertThat(accessPolicy.roleIds().getOrNull()).containsExactly("string") + assertThat(accessPolicy.updatedAt()).contains("updated_at") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val accessPolicy = + AccessPolicy.builder() + .id("id") + .addConditionGroup( + ConditionGroup.builder() + .addCondition( + ConditionGroup.Condition.builder() + .attributeKey("attribute_key") + .attributeName( + ConditionGroup.Condition.AttributeName.RESOURCE_TAG_KEY + ) + .attributeValue("attribute_value") + .operator(ConditionGroup.Condition.Operator.EQUALS) + .build() + ) + .permission(ConditionGroup.Permission.ANNOTATION_QUEUES_CREATE) + .resourceType("resource_type") + .build() + ) + .createdAt("created_at") + .description("description") + .effect("effect") + .name("name") + .addRoleId("string") + .updatedAt("updated_at") + .build() + + val roundtrippedAccessPolicy = + jsonMapper.readValue( + jsonMapper.writeValueAsString(accessPolicy), + jacksonTypeRef<AccessPolicy>(), + ) + + assertThat(roundtrippedAccessPolicy).isEqualTo(accessPolicy) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/ConditionGroupTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/ConditionGroupTest.kt new file mode 100644 index 00000000..f40f1996 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/ConditionGroupTest.kt @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.orgs.current.accesspolicies + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.jsonMapper +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ConditionGroupTest { + + @Test + fun create() { + val conditionGroup = + ConditionGroup.builder() + .addCondition( + ConditionGroup.Condition.builder() + .attributeKey("attribute_key") + .attributeName(ConditionGroup.Condition.AttributeName.RESOURCE_TAG_KEY) + .attributeValue("attribute_value") + .operator(ConditionGroup.Condition.Operator.EQUALS) + .build() + ) + .permission(ConditionGroup.Permission.ANNOTATION_QUEUES_CREATE) + .resourceType("resource_type") + .build() + + assertThat(conditionGroup.conditions().getOrNull()) + .containsExactly( + ConditionGroup.Condition.builder() + .attributeKey("attribute_key") + .attributeName(ConditionGroup.Condition.AttributeName.RESOURCE_TAG_KEY) + .attributeValue("attribute_value") + .operator(ConditionGroup.Condition.Operator.EQUALS) + .build() + ) + assertThat(conditionGroup.permission()) + .contains(ConditionGroup.Permission.ANNOTATION_QUEUES_CREATE) + assertThat(conditionGroup.resourceType()).contains("resource_type") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val conditionGroup = + ConditionGroup.builder() + .addCondition( + ConditionGroup.Condition.builder() + .attributeKey("attribute_key") + .attributeName(ConditionGroup.Condition.AttributeName.RESOURCE_TAG_KEY) + .attributeValue("attribute_value") + .operator(ConditionGroup.Condition.Operator.EQUALS) + .build() + ) + .permission(ConditionGroup.Permission.ANNOTATION_QUEUES_CREATE) + .resourceType("resource_type") + .build() + + val roundtrippedConditionGroup = + jsonMapper.readValue( + jsonMapper.writeValueAsString(conditionGroup), + jacksonTypeRef<ConditionGroup>(), + ) + + assertThat(roundtrippedConditionGroup).isEqualTo(conditionGroup) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/roles/RoleAttachParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/roles/RoleAttachParamsTest.kt new file mode 100644 index 00000000..ae674fea --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/platform/orgs/current/accesspolicies/roles/RoleAttachParamsTest.kt @@ -0,0 +1,48 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.platform.orgs.current.accesspolicies.roles + +import com.langsmith_api.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RoleAttachParamsTest { + + @Test + fun create() { + RoleAttachParams.builder() + .roleId(JsonValue.from(mapOf<String, Any>())) + .payload(RoleAttachParams.Payload.builder().addAccessPolicyId("string").build()) + .build() + } + + @Test + fun pathParams() { + val params = RoleAttachParams.builder().roleId(JsonValue.from(mapOf<String, Any>())).build() + + assertThat(params._pathParam(0)).isEqualTo("[object Object]") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + RoleAttachParams.builder() + .roleId(JsonValue.from(mapOf<String, Any>())) + .payload(RoleAttachParams.Payload.builder().addAccessPolicyId("string").build()) + .build() + + val body = params._body() + + assertThat(body.payload()) + .contains(RoleAttachParams.Payload.builder().addAccessPolicyId("string").build()) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = RoleAttachParams.builder().roleId(JsonValue.from(mapOf<String, Any>())).build() + + val body = params._body() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/runs/RunCreateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/runs/RunCreateParamsTest.kt new file mode 100644 index 00000000..2da89993 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/runs/RunCreateParamsTest.kt @@ -0,0 +1,195 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.runs + +import com.langsmith_api.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunCreateParamsTest { + + @Test + fun create() { + RunCreateParams.builder() + .run( + Run.builder() + .id("id") + .dottedOrder("dotted_order") + .endTime("end_time") + .error("error") + .addEvent( + Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extra( + Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputAttachments( + Run.InputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputs( + Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .outputAttachments( + Run.OutputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .parentRunId("parent_run_id") + .referenceExampleId("reference_example_id") + .runType(Run.RunType.TOOL) + .serialized( + Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .sessionId("session_id") + .sessionName("session_name") + .startTime("start_time") + .status("status") + .addTag("string") + .traceId("trace_id") + .build() + ) + .build() + } + + @Test + fun body() { + val params = + RunCreateParams.builder() + .run( + Run.builder() + .id("id") + .dottedOrder("dotted_order") + .endTime("end_time") + .error("error") + .addEvent( + Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extra( + Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputAttachments( + Run.InputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputs( + Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .outputAttachments( + Run.OutputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .parentRunId("parent_run_id") + .referenceExampleId("reference_example_id") + .runType(Run.RunType.TOOL) + .serialized( + Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .sessionId("session_id") + .sessionName("session_name") + .startTime("start_time") + .status("status") + .addTag("string") + .traceId("trace_id") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + Run.builder() + .id("id") + .dottedOrder("dotted_order") + .endTime("end_time") + .error("error") + .addEvent( + Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extra( + Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputAttachments( + Run.InputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputs( + Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .outputAttachments( + Run.OutputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .parentRunId("parent_run_id") + .referenceExampleId("reference_example_id") + .runType(Run.RunType.TOOL) + .serialized( + Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .sessionId("session_id") + .sessionName("session_name") + .startTime("start_time") + .status("status") + .addTag("string") + .traceId("trace_id") + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = RunCreateParams.builder().run(Run.builder().build()).build() + + val body = params._body() + + assertThat(body).isEqualTo(Run.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/runs/RunCreateResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/runs/RunCreateResponseTest.kt new file mode 100644 index 00000000..d5dd5f4c --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/runs/RunCreateResponseTest.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.runs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunCreateResponseTest { + + @Test + fun create() { + val runCreateResponse = + RunCreateResponse.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf("message" to "message"))) + .build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val runCreateResponse = + RunCreateResponse.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf("message" to "message"))) + .build() + + val roundtrippedRunCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(runCreateResponse), + jacksonTypeRef<RunCreateResponse>(), + ) + + assertThat(roundtrippedRunCreateResponse).isEqualTo(runCreateResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/runs/RunIngestBatchParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/runs/RunIngestBatchParamsTest.kt new file mode 100644 index 00000000..33d0321f --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/runs/RunIngestBatchParamsTest.kt @@ -0,0 +1,354 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.runs + +import com.langsmith_api.api.core.JsonValue +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunIngestBatchParamsTest { + + @Test + fun create() { + RunIngestBatchParams.builder() + .addPatch( + Run.builder() + .id("id") + .dottedOrder("dotted_order") + .endTime("end_time") + .error("error") + .addEvent( + Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extra( + Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputAttachments( + Run.InputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputs( + Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .outputAttachments( + Run.OutputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .parentRunId("parent_run_id") + .referenceExampleId("reference_example_id") + .runType(Run.RunType.TOOL) + .serialized( + Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .sessionId("session_id") + .sessionName("session_name") + .startTime("start_time") + .status("status") + .addTag("string") + .traceId("trace_id") + .build() + ) + .addPost( + Run.builder() + .id("id") + .dottedOrder("dotted_order") + .endTime("end_time") + .error("error") + .addEvent( + Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extra( + Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputAttachments( + Run.InputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputs( + Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .outputAttachments( + Run.OutputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .parentRunId("parent_run_id") + .referenceExampleId("reference_example_id") + .runType(Run.RunType.TOOL) + .serialized( + Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .sessionId("session_id") + .sessionName("session_name") + .startTime("start_time") + .status("status") + .addTag("string") + .traceId("trace_id") + .build() + ) + .build() + } + + @Test + fun body() { + val params = + RunIngestBatchParams.builder() + .addPatch( + Run.builder() + .id("id") + .dottedOrder("dotted_order") + .endTime("end_time") + .error("error") + .addEvent( + Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extra( + Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputAttachments( + Run.InputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputs( + Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .outputAttachments( + Run.OutputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .parentRunId("parent_run_id") + .referenceExampleId("reference_example_id") + .runType(Run.RunType.TOOL) + .serialized( + Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .sessionId("session_id") + .sessionName("session_name") + .startTime("start_time") + .status("status") + .addTag("string") + .traceId("trace_id") + .build() + ) + .addPost( + Run.builder() + .id("id") + .dottedOrder("dotted_order") + .endTime("end_time") + .error("error") + .addEvent( + Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extra( + Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputAttachments( + Run.InputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputs( + Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .outputAttachments( + Run.OutputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .parentRunId("parent_run_id") + .referenceExampleId("reference_example_id") + .runType(Run.RunType.TOOL) + .serialized( + Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .sessionId("session_id") + .sessionName("session_name") + .startTime("start_time") + .status("status") + .addTag("string") + .traceId("trace_id") + .build() + ) + .build() + + val body = params._body() + + assertThat(body.patch().getOrNull()) + .containsExactly( + Run.builder() + .id("id") + .dottedOrder("dotted_order") + .endTime("end_time") + .error("error") + .addEvent( + Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extra( + Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputAttachments( + Run.InputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputs( + Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .outputAttachments( + Run.OutputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .parentRunId("parent_run_id") + .referenceExampleId("reference_example_id") + .runType(Run.RunType.TOOL) + .serialized( + Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .sessionId("session_id") + .sessionName("session_name") + .startTime("start_time") + .status("status") + .addTag("string") + .traceId("trace_id") + .build() + ) + assertThat(body.post().getOrNull()) + .containsExactly( + Run.builder() + .id("id") + .dottedOrder("dotted_order") + .endTime("end_time") + .error("error") + .addEvent( + Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extra( + Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputAttachments( + Run.InputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputs( + Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .outputAttachments( + Run.OutputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .parentRunId("parent_run_id") + .referenceExampleId("reference_example_id") + .runType(Run.RunType.TOOL) + .serialized( + Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .sessionId("session_id") + .sessionName("session_name") + .startTime("start_time") + .status("status") + .addTag("string") + .traceId("trace_id") + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = RunIngestBatchParams.builder().build() + + val body = params._body() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/runs/RunIngestBatchResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/runs/RunIngestBatchResponseTest.kt new file mode 100644 index 00000000..9329583f --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/runs/RunIngestBatchResponseTest.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.runs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunIngestBatchResponseTest { + + @Test + fun create() { + val runIngestBatchResponse = + RunIngestBatchResponse.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf("message" to "message"))) + .build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val runIngestBatchResponse = + RunIngestBatchResponse.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf("message" to "message"))) + .build() + + val roundtrippedRunIngestBatchResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(runIngestBatchResponse), + jacksonTypeRef<RunIngestBatchResponse>(), + ) + + assertThat(roundtrippedRunIngestBatchResponse).isEqualTo(runIngestBatchResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/runs/RunIngestMultipartParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/runs/RunIngestMultipartParamsTest.kt new file mode 100644 index 00000000..bcc0b56d --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/runs/RunIngestMultipartParamsTest.kt @@ -0,0 +1,73 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.runs + +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.MultipartField +import java.io.InputStream +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunIngestMultipartParamsTest { + + @Test + fun create() { + RunIngestMultipartParams.builder() + .attachmentRunIdFilename(JsonValue.from(mapOf<String, Any>())) + .feedbackRunId("some content".byteInputStream()) + .patchRunId("some content".byteInputStream()) + .patchRunIdOutputs("some content".byteInputStream()) + .postRunId("some content".byteInputStream()) + .postRunIdInputs("some content".byteInputStream()) + .build() + } + + @Test + fun body() { + val params = + RunIngestMultipartParams.builder() + .attachmentRunIdFilename(JsonValue.from(mapOf<String, Any>())) + .feedbackRunId("some content".byteInputStream()) + .patchRunId("some content".byteInputStream()) + .patchRunIdOutputs("some content".byteInputStream()) + .postRunId("some content".byteInputStream()) + .postRunIdInputs("some content".byteInputStream()) + .build() + + val body = params._body() + + assertThat(body.filterValues { !it.value.isNull() }) + .usingRecursiveComparison() + // TODO(AssertJ): Replace this and the `mapValues` below with: + // https://github.com/assertj/assertj/issues/3165 + .withEqualsForType( + { a, b -> a.readBytes() contentEquals b.readBytes() }, + InputStream::class.java, + ) + .isEqualTo( + mapOf( + "attachment.{run_id}.{filename}" to + MultipartField.of(JsonValue.from(mapOf<String, Any>())), + "feedback.{run_id}" to MultipartField.of("some content".byteInputStream()), + "patch.{run_id}" to MultipartField.of("some content".byteInputStream()), + "patch.{run_id}.outputs" to + MultipartField.of("some content".byteInputStream()), + "post.{run_id}" to MultipartField.of("some content".byteInputStream()), + "post.{run_id}.inputs" to + MultipartField.of("some content".byteInputStream()), + ) + .mapValues { (_, field) -> + field.map { (it as? ByteArray)?.inputStream() ?: it } + } + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = RunIngestMultipartParams.builder().build() + + val body = params._body() + + assertThat(body.filterValues { !it.value.isNull() }).isEmpty() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/runs/RunIngestMultipartResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/runs/RunIngestMultipartResponseTest.kt new file mode 100644 index 00000000..e0e16c58 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/runs/RunIngestMultipartResponseTest.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.runs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunIngestMultipartResponseTest { + + @Test + fun create() { + val runIngestMultipartResponse = + RunIngestMultipartResponse.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val runIngestMultipartResponse = + RunIngestMultipartResponse.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + + val roundtrippedRunIngestMultipartResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(runIngestMultipartResponse), + jacksonTypeRef<RunIngestMultipartResponse>(), + ) + + assertThat(roundtrippedRunIngestMultipartResponse).isEqualTo(runIngestMultipartResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/runs/RunTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/runs/RunTest.kt new file mode 100644 index 00000000..28305f60 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/runs/RunTest.kt @@ -0,0 +1,166 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.runs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunTest { + + @Test + fun create() { + val run = + Run.builder() + .id("id") + .dottedOrder("dotted_order") + .endTime("end_time") + .error("error") + .addEvent( + Run.Event.builder().putAdditionalProperty("foo", JsonValue.from("bar")).build() + ) + .extra( + Run.Extra.builder().putAdditionalProperty("foo", JsonValue.from("bar")).build() + ) + .inputAttachments( + Run.InputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputs( + Run.Inputs.builder().putAdditionalProperty("foo", JsonValue.from("bar")).build() + ) + .name("name") + .outputAttachments( + Run.OutputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .parentRunId("parent_run_id") + .referenceExampleId("reference_example_id") + .runType(Run.RunType.TOOL) + .serialized( + Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .sessionId("session_id") + .sessionName("session_name") + .startTime("start_time") + .status("status") + .addTag("string") + .traceId("trace_id") + .build() + + assertThat(run.id()).contains("id") + assertThat(run.dottedOrder()).contains("dotted_order") + assertThat(run.endTime()).contains("end_time") + assertThat(run.error()).contains("error") + assertThat(run.events().getOrNull()) + .containsExactly( + Run.Event.builder().putAdditionalProperty("foo", JsonValue.from("bar")).build() + ) + assertThat(run.extra()) + .contains( + Run.Extra.builder().putAdditionalProperty("foo", JsonValue.from("bar")).build() + ) + assertThat(run.inputAttachments()) + .contains( + Run.InputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(run.inputs()) + .contains( + Run.Inputs.builder().putAdditionalProperty("foo", JsonValue.from("bar")).build() + ) + assertThat(run.name()).contains("name") + assertThat(run.outputAttachments()) + .contains( + Run.OutputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(run.outputs()) + .contains( + Run.Outputs.builder().putAdditionalProperty("foo", JsonValue.from("bar")).build() + ) + assertThat(run.parentRunId()).contains("parent_run_id") + assertThat(run.referenceExampleId()).contains("reference_example_id") + assertThat(run.runType()).contains(Run.RunType.TOOL) + assertThat(run.serialized()) + .contains( + Run.Serialized.builder().putAdditionalProperty("foo", JsonValue.from("bar")).build() + ) + assertThat(run.sessionId()).contains("session_id") + assertThat(run.sessionName()).contains("session_name") + assertThat(run.startTime()).contains("start_time") + assertThat(run.status()).contains("status") + assertThat(run.tags().getOrNull()).containsExactly("string") + assertThat(run.traceId()).contains("trace_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val run = + Run.builder() + .id("id") + .dottedOrder("dotted_order") + .endTime("end_time") + .error("error") + .addEvent( + Run.Event.builder().putAdditionalProperty("foo", JsonValue.from("bar")).build() + ) + .extra( + Run.Extra.builder().putAdditionalProperty("foo", JsonValue.from("bar")).build() + ) + .inputAttachments( + Run.InputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputs( + Run.Inputs.builder().putAdditionalProperty("foo", JsonValue.from("bar")).build() + ) + .name("name") + .outputAttachments( + Run.OutputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .parentRunId("parent_run_id") + .referenceExampleId("reference_example_id") + .runType(Run.RunType.TOOL) + .serialized( + Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .sessionId("session_id") + .sessionName("session_name") + .startTime("start_time") + .status("status") + .addTag("string") + .traceId("trace_id") + .build() + + val roundtrippedRun = + jsonMapper.readValue(jsonMapper.writeValueAsString(run), jacksonTypeRef<Run>()) + + assertThat(roundtrippedRun).isEqualTo(run) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/runs/RunUpdateParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/runs/RunUpdateParamsTest.kt new file mode 100644 index 00000000..de37b100 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/runs/RunUpdateParamsTest.kt @@ -0,0 +1,214 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.runs + +import com.langsmith_api.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunUpdateParamsTest { + + @Test + fun create() { + RunUpdateParams.builder() + .runId(JsonValue.from(mapOf<String, Any>())) + .run( + Run.builder() + .id("id") + .dottedOrder("dotted_order") + .endTime("end_time") + .error("error") + .addEvent( + Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extra( + Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputAttachments( + Run.InputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputs( + Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .outputAttachments( + Run.OutputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .parentRunId("parent_run_id") + .referenceExampleId("reference_example_id") + .runType(Run.RunType.TOOL) + .serialized( + Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .sessionId("session_id") + .sessionName("session_name") + .startTime("start_time") + .status("status") + .addTag("string") + .traceId("trace_id") + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + RunUpdateParams.builder() + .runId(JsonValue.from(mapOf<String, Any>())) + .run(Run.builder().build()) + .build() + + assertThat(params._pathParam(0)).isEqualTo("[object Object]") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + RunUpdateParams.builder() + .runId(JsonValue.from(mapOf<String, Any>())) + .run( + Run.builder() + .id("id") + .dottedOrder("dotted_order") + .endTime("end_time") + .error("error") + .addEvent( + Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extra( + Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputAttachments( + Run.InputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputs( + Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .outputAttachments( + Run.OutputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .parentRunId("parent_run_id") + .referenceExampleId("reference_example_id") + .runType(Run.RunType.TOOL) + .serialized( + Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .sessionId("session_id") + .sessionName("session_name") + .startTime("start_time") + .status("status") + .addTag("string") + .traceId("trace_id") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + Run.builder() + .id("id") + .dottedOrder("dotted_order") + .endTime("end_time") + .error("error") + .addEvent( + Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extra( + Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputAttachments( + Run.InputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputs( + Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .outputAttachments( + Run.OutputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .parentRunId("parent_run_id") + .referenceExampleId("reference_example_id") + .runType(Run.RunType.TOOL) + .serialized( + Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .sessionId("session_id") + .sessionName("session_name") + .startTime("start_time") + .status("status") + .addTag("string") + .traceId("trace_id") + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + RunUpdateParams.builder() + .runId(JsonValue.from(mapOf<String, Any>())) + .run(Run.builder().build()) + .build() + + val body = params._body() + + assertThat(body).isEqualTo(Run.builder().build()) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/runs/RunUpdateResponseTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/runs/RunUpdateResponseTest.kt new file mode 100644 index 00000000..ee2fa5a1 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/models/runs/RunUpdateResponseTest.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.models.runs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RunUpdateResponseTest { + + @Test + fun create() { + val runUpdateResponse = + RunUpdateResponse.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf("message" to "message"))) + .build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val runUpdateResponse = + RunUpdateResponse.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf("message" to "message"))) + .build() + + val roundtrippedRunUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(runUpdateResponse), + jacksonTypeRef<RunUpdateResponse>(), + ) + + assertThat(roundtrippedRunUpdateResponse).isEqualTo(runUpdateResponse) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/ErrorHandlingTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/ErrorHandlingTest.kt new file mode 100644 index 00000000..b06883d1 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/ErrorHandlingTest.kt @@ -0,0 +1,798 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services + +import com.github.tomakehurst.wiremock.client.WireMock.anyUrl +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.langsmith_api.api.client.LangsmithApiClient +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.http.Headers +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.errors.BadRequestException +import com.langsmith_api.api.errors.InternalServerException +import com.langsmith_api.api.errors.LangsmithApiException +import com.langsmith_api.api.errors.NotFoundException +import com.langsmith_api.api.errors.PermissionDeniedException +import com.langsmith_api.api.errors.RateLimitException +import com.langsmith_api.api.errors.UnauthorizedException +import com.langsmith_api.api.errors.UnexpectedStatusCodeException +import com.langsmith_api.api.errors.UnprocessableEntityException +import com.langsmith_api.api.models.api.v1.sessions.CustomChartsSectionRequest +import com.langsmith_api.api.models.api.v1.sessions.RunStatsGroupBy +import com.langsmith_api.api.models.api.v1.sessions.SessionDashboardParams +import com.langsmith_api.api.models.api.v1.sessions.TimedeltaInput +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.api.Assertions.entry +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.api.parallel.ResourceLock + +@WireMockTest +@ResourceLock("https://github.com/wiremock/wiremock/issues/169") +internal class ErrorHandlingTest { + + companion object { + + private val ERROR_JSON: JsonValue = JsonValue.from(mapOf("errorProperty" to "42")) + + private val ERROR_JSON_BYTES: ByteArray = jsonMapper().writeValueAsBytes(ERROR_JSON) + + private const val HEADER_NAME: String = "Error-Header" + + private const val HEADER_VALUE: String = "42" + + private const val NOT_JSON: String = "Not JSON" + } + + private lateinit var client: LangsmithApiClient + + @BeforeEach + fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { + client = + LangsmithApiOkHttpClient.builder() + .baseUrl(wmRuntimeInfo.httpBaseUrl) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + } + + @Test + fun sessionsDashboard400() { + val sessionService = client.api().v1().sessions() + stubFor( + post(anyUrl()) + .willReturn( + status(400).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows<BadRequestException> { + sessionService.dashboard( + SessionDashboardParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accept("accept") + .customChartsSectionRequest( + CustomChartsSectionRequest.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride( + TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build() + ) + .timezone("timezone") + .build() + ) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(400) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun sessionsDashboard400WithRawResponse() { + val sessionService = client.api().v1().sessions().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(400).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows<BadRequestException> { + sessionService.dashboard( + SessionDashboardParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accept("accept") + .customChartsSectionRequest( + CustomChartsSectionRequest.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride( + TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build() + ) + .timezone("timezone") + .build() + ) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(400) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun sessionsDashboard401() { + val sessionService = client.api().v1().sessions() + stubFor( + post(anyUrl()) + .willReturn( + status(401).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows<UnauthorizedException> { + sessionService.dashboard( + SessionDashboardParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accept("accept") + .customChartsSectionRequest( + CustomChartsSectionRequest.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride( + TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build() + ) + .timezone("timezone") + .build() + ) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(401) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun sessionsDashboard401WithRawResponse() { + val sessionService = client.api().v1().sessions().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(401).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows<UnauthorizedException> { + sessionService.dashboard( + SessionDashboardParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accept("accept") + .customChartsSectionRequest( + CustomChartsSectionRequest.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride( + TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build() + ) + .timezone("timezone") + .build() + ) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(401) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun sessionsDashboard403() { + val sessionService = client.api().v1().sessions() + stubFor( + post(anyUrl()) + .willReturn( + status(403).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows<PermissionDeniedException> { + sessionService.dashboard( + SessionDashboardParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accept("accept") + .customChartsSectionRequest( + CustomChartsSectionRequest.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride( + TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build() + ) + .timezone("timezone") + .build() + ) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(403) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun sessionsDashboard403WithRawResponse() { + val sessionService = client.api().v1().sessions().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(403).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows<PermissionDeniedException> { + sessionService.dashboard( + SessionDashboardParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accept("accept") + .customChartsSectionRequest( + CustomChartsSectionRequest.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride( + TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build() + ) + .timezone("timezone") + .build() + ) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(403) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun sessionsDashboard404() { + val sessionService = client.api().v1().sessions() + stubFor( + post(anyUrl()) + .willReturn( + status(404).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows<NotFoundException> { + sessionService.dashboard( + SessionDashboardParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accept("accept") + .customChartsSectionRequest( + CustomChartsSectionRequest.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride( + TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build() + ) + .timezone("timezone") + .build() + ) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(404) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun sessionsDashboard404WithRawResponse() { + val sessionService = client.api().v1().sessions().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(404).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows<NotFoundException> { + sessionService.dashboard( + SessionDashboardParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accept("accept") + .customChartsSectionRequest( + CustomChartsSectionRequest.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride( + TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build() + ) + .timezone("timezone") + .build() + ) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(404) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun sessionsDashboard422() { + val sessionService = client.api().v1().sessions() + stubFor( + post(anyUrl()) + .willReturn( + status(422).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows<UnprocessableEntityException> { + sessionService.dashboard( + SessionDashboardParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accept("accept") + .customChartsSectionRequest( + CustomChartsSectionRequest.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride( + TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build() + ) + .timezone("timezone") + .build() + ) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(422) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun sessionsDashboard422WithRawResponse() { + val sessionService = client.api().v1().sessions().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(422).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows<UnprocessableEntityException> { + sessionService.dashboard( + SessionDashboardParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accept("accept") + .customChartsSectionRequest( + CustomChartsSectionRequest.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride( + TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build() + ) + .timezone("timezone") + .build() + ) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(422) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun sessionsDashboard429() { + val sessionService = client.api().v1().sessions() + stubFor( + post(anyUrl()) + .willReturn( + status(429).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows<RateLimitException> { + sessionService.dashboard( + SessionDashboardParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accept("accept") + .customChartsSectionRequest( + CustomChartsSectionRequest.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride( + TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build() + ) + .timezone("timezone") + .build() + ) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(429) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun sessionsDashboard429WithRawResponse() { + val sessionService = client.api().v1().sessions().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(429).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows<RateLimitException> { + sessionService.dashboard( + SessionDashboardParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accept("accept") + .customChartsSectionRequest( + CustomChartsSectionRequest.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride( + TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build() + ) + .timezone("timezone") + .build() + ) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(429) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun sessionsDashboard500() { + val sessionService = client.api().v1().sessions() + stubFor( + post(anyUrl()) + .willReturn( + status(500).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows<InternalServerException> { + sessionService.dashboard( + SessionDashboardParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accept("accept") + .customChartsSectionRequest( + CustomChartsSectionRequest.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride( + TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build() + ) + .timezone("timezone") + .build() + ) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(500) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun sessionsDashboard500WithRawResponse() { + val sessionService = client.api().v1().sessions().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(500).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows<InternalServerException> { + sessionService.dashboard( + SessionDashboardParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accept("accept") + .customChartsSectionRequest( + CustomChartsSectionRequest.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride( + TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build() + ) + .timezone("timezone") + .build() + ) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(500) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun sessionsDashboard999() { + val sessionService = client.api().v1().sessions() + stubFor( + post(anyUrl()) + .willReturn( + status(999).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows<UnexpectedStatusCodeException> { + sessionService.dashboard( + SessionDashboardParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accept("accept") + .customChartsSectionRequest( + CustomChartsSectionRequest.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride( + TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build() + ) + .timezone("timezone") + .build() + ) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(999) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun sessionsDashboard999WithRawResponse() { + val sessionService = client.api().v1().sessions().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(999).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows<UnexpectedStatusCodeException> { + sessionService.dashboard( + SessionDashboardParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accept("accept") + .customChartsSectionRequest( + CustomChartsSectionRequest.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride( + TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build() + ) + .timezone("timezone") + .build() + ) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(999) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun sessionsDashboardInvalidJsonBody() { + val sessionService = client.api().v1().sessions() + stubFor( + post(anyUrl()) + .willReturn(status(200).withHeader(HEADER_NAME, HEADER_VALUE).withBody(NOT_JSON)) + ) + + val e = + assertThrows<LangsmithApiException> { + sessionService.dashboard( + SessionDashboardParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accept("accept") + .customChartsSectionRequest( + CustomChartsSectionRequest.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride( + TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build() + ) + .timezone("timezone") + .build() + ) + .build() + ) + } + + assertThat(e).hasMessage("Error reading response") + } + + private fun Headers.toMap(): Map<String, List<String>> = + mutableMapOf<String, List<String>>().also { map -> + names().forEach { map[it] = values(it) } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/ServiceParamsTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/ServiceParamsTest.kt new file mode 100644 index 00000000..805db5a1 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/ServiceParamsTest.kt @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services + +import com.github.tomakehurst.wiremock.client.WireMock.anyUrl +import com.github.tomakehurst.wiremock.client.WireMock.equalTo +import com.github.tomakehurst.wiremock.client.WireMock.ok +import com.github.tomakehurst.wiremock.client.WireMock.post +import com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor +import com.github.tomakehurst.wiremock.client.WireMock.stubFor +import com.github.tomakehurst.wiremock.client.WireMock.verify +import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo +import com.github.tomakehurst.wiremock.junit5.WireMockTest +import com.langsmith_api.api.client.LangsmithApiClient +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.sessions.CustomChartsSectionRequest +import com.langsmith_api.api.models.api.v1.sessions.RunStatsGroupBy +import com.langsmith_api.api.models.api.v1.sessions.SessionDashboardParams +import com.langsmith_api.api.models.api.v1.sessions.TimedeltaInput +import java.time.OffsetDateTime +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.parallel.ResourceLock + +@WireMockTest +@ResourceLock("https://github.com/wiremock/wiremock/issues/169") +internal class ServiceParamsTest { + + private lateinit var client: LangsmithApiClient + + @BeforeEach + fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { + client = + LangsmithApiOkHttpClient.builder() + .baseUrl(wmRuntimeInfo.httpBaseUrl) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + } + + @Disabled("Prism tests are disabled") + @Test + fun dashboard() { + val sessionService = client.api().v1().sessions() + stubFor(post(anyUrl()).willReturn(ok("{}"))) + + sessionService.dashboard( + SessionDashboardParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accept("accept") + .customChartsSectionRequest( + CustomChartsSectionRequest.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride(TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build()) + .timezone("timezone") + .build() + ) + .putAdditionalHeader("Secret-Header", "42") + .putAdditionalQueryParam("secret_query_param", "42") + .build() + ) + + verify( + postRequestedFor(anyUrl()) + .withHeader("Secret-Header", equalTo("42")) + .withQueryParam("secret_query_param", equalTo("42")) + ) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/FeedbackServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/FeedbackServiceAsyncTest.kt new file mode 100644 index 00000000..c7af0511 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/FeedbackServiceAsyncTest.kt @@ -0,0 +1,83 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.feedback.FeedbackIngestBatchParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class FeedbackServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun ingestBatch() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val feedbackServiceAsync = client.feedback() + + val responseFuture = + feedbackServiceAsync.ingestBatch( + FeedbackIngestBatchParams.builder() + .addBody( + FeedbackIngestBatchParams.Body.builder() + .id("id") + .comment("comment") + .comparativeExperimentId("comparative_experiment_id") + .correction(JsonValue.from(mapOf<String, Any>())) + .createdAt("created_at") + .error(true) + .feedbackConfig( + FeedbackIngestBatchParams.Body.FeedbackConfig.builder() + .addCategory( + FeedbackIngestBatchParams.Body.FeedbackConfig.Category + .builder() + .label("x") + .value(0.0) + .build() + ) + .max(0.0) + .min(0.0) + .type( + FeedbackIngestBatchParams.Body.FeedbackConfig.Type + .CONTINUOUS + ) + .build() + ) + .feedbackGroupId("feedback_group_id") + .feedbackSource( + FeedbackIngestBatchParams.Body.FeedbackSource.builder() + .metadata( + FeedbackIngestBatchParams.Body.FeedbackSource.Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .type("type") + .build() + ) + .key("key") + .modifiedAt("modified_at") + .runId("run_id") + .score(JsonValue.from(mapOf<String, Any>())) + .sessionId("session_id") + .traceId("trace_id") + .value(JsonValue.from(mapOf<String, Any>())) + .build() + ) + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/RunServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/RunServiceAsyncTest.kt new file mode 100644 index 00000000..b75ecfe9 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/RunServiceAsyncTest.kt @@ -0,0 +1,321 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.runs.Run +import com.langsmith_api.api.models.runs.RunIngestBatchParams +import com.langsmith_api.api.models.runs.RunIngestMultipartParams +import com.langsmith_api.api.models.runs.RunUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class RunServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runServiceAsync = client.runs() + + val runFuture = + runServiceAsync.create( + Run.builder() + .id("id") + .dottedOrder("dotted_order") + .endTime("end_time") + .error("error") + .addEvent( + Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extra( + Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputAttachments( + Run.InputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputs( + Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .outputAttachments( + Run.OutputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .parentRunId("parent_run_id") + .referenceExampleId("reference_example_id") + .runType(Run.RunType.TOOL) + .serialized( + Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .sessionId("session_id") + .sessionName("session_name") + .startTime("start_time") + .status("status") + .addTag("string") + .traceId("trace_id") + .build() + ) + + val run = runFuture.get() + run.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runServiceAsync = client.runs() + + val runFuture = + runServiceAsync.update( + RunUpdateParams.builder() + .runId(JsonValue.from(mapOf<String, Any>())) + .run( + Run.builder() + .id("id") + .dottedOrder("dotted_order") + .endTime("end_time") + .error("error") + .addEvent( + Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extra( + Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputAttachments( + Run.InputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputs( + Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .outputAttachments( + Run.OutputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .parentRunId("parent_run_id") + .referenceExampleId("reference_example_id") + .runType(Run.RunType.TOOL) + .serialized( + Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .sessionId("session_id") + .sessionName("session_name") + .startTime("start_time") + .status("status") + .addTag("string") + .traceId("trace_id") + .build() + ) + .build() + ) + + val run = runFuture.get() + run.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun ingestBatch() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runServiceAsync = client.runs() + + val responseFuture = + runServiceAsync.ingestBatch( + RunIngestBatchParams.builder() + .addPatch( + Run.builder() + .id("id") + .dottedOrder("dotted_order") + .endTime("end_time") + .error("error") + .addEvent( + Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extra( + Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputAttachments( + Run.InputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputs( + Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .outputAttachments( + Run.OutputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .parentRunId("parent_run_id") + .referenceExampleId("reference_example_id") + .runType(Run.RunType.TOOL) + .serialized( + Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .sessionId("session_id") + .sessionName("session_name") + .startTime("start_time") + .status("status") + .addTag("string") + .traceId("trace_id") + .build() + ) + .addPost( + Run.builder() + .id("id") + .dottedOrder("dotted_order") + .endTime("end_time") + .error("error") + .addEvent( + Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extra( + Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputAttachments( + Run.InputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputs( + Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .outputAttachments( + Run.OutputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .parentRunId("parent_run_id") + .referenceExampleId("reference_example_id") + .runType(Run.RunType.TOOL) + .serialized( + Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .sessionId("session_id") + .sessionName("session_name") + .startTime("start_time") + .status("status") + .addTag("string") + .traceId("trace_id") + .build() + ) + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun ingestMultipart() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runServiceAsync = client.runs() + + val responseFuture = + runServiceAsync.ingestMultipart( + RunIngestMultipartParams.builder() + .attachmentRunIdFilename(JsonValue.from(mapOf<String, Any>())) + .feedbackRunId("some content".byteInputStream()) + .patchRunId("some content".byteInputStream()) + .patchRunIdOutputs("some content".byteInputStream()) + .postRunId("some content".byteInputStream()) + .postRunIdInputs("some content".byteInputStream()) + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/V1ServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/V1ServiceAsyncTest.kt new file mode 100644 index 00000000..ed2edfe6 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/V1ServiceAsyncTest.kt @@ -0,0 +1,98 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.V1EventsParams +import com.langsmith_api.api.models.api.v1.V1UpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class V1ServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val v1ServiceAsync = client.api().v1() + + val v1Future = + v1ServiceAsync.update( + V1UpdateParams.builder().owner("owner").repo("repo").like(true).build() + ) + + val v1 = v1Future.get() + v1.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun events() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val v1ServiceAsync = client.api().v1() + + val responseFuture = + v1ServiceAsync.events( + V1EventsParams.builder() + .eventType(V1EventsParams.EventType.PLAYGROUND_VIEW) + .owner("owner") + .repo("repo") + .commit("commit") + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun login() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val v1ServiceAsync = client.api().v1() + + val responseFuture = v1ServiceAsync.login() + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveOk() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val v1ServiceAsync = client.api().v1() + + val responseFuture = v1ServiceAsync.retrieveOk() + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/AceServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/AceServiceAsyncTest.kt new file mode 100644 index 00000000..5db6b8a9 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/AceServiceAsyncTest.kt @@ -0,0 +1,40 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.ace.AceExecuteParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class AceServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun execute() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val aceServiceAsync = client.api().v1().ace() + + val responseFuture = + aceServiceAsync.execute( + AceExecuteParams.builder() + .addArg(JsonValue.from(mapOf<String, Any>())) + .code("code") + .language("language") + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/AnnotationQueueServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/AnnotationQueueServiceAsyncTest.kt new file mode 100644 index 00000000..3537929d --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/AnnotationQueueServiceAsyncTest.kt @@ -0,0 +1,301 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueAnnotationQueuesParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueExportParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueuePopulateParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueRetrieveAnnotationQueuesParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueRetrieveParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueRetrieveTotalArchivedParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueRubricItemSchema +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueUpdateParams +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class AnnotationQueueServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val annotationQueueServiceAsync = client.api().v1().annotationQueues() + + val runSchemaWithAnnotationQueueInfoFuture = + annotationQueueServiceAsync.retrieve( + AnnotationQueueRetrieveParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .index(0L) + .includeExtra(true) + .build() + ) + + val runSchemaWithAnnotationQueueInfo = runSchemaWithAnnotationQueueInfoFuture.get() + runSchemaWithAnnotationQueueInfo.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val annotationQueueServiceAsync = client.api().v1().annotationQueues() + + val annotationQueueFuture = + annotationQueueServiceAsync.update( + AnnotationQueueUpdateParams.builder() + .annotationQueueRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .overrideAddedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status("status") + .build() + ) + + val annotationQueue = annotationQueueFuture.get() + annotationQueue.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val annotationQueueServiceAsync = client.api().v1().annotationQueues() + + val annotationQueueFuture = + annotationQueueServiceAsync.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val annotationQueue = annotationQueueFuture.get() + annotationQueue.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun annotationQueues() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val annotationQueueServiceAsync = client.api().v1().annotationQueues() + + val annotationQueueSchemaFuture = + annotationQueueServiceAsync.annotationQueues( + AnnotationQueueAnnotationQueuesParams.builder() + .name("name") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .defaultDataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .enableReservations(true) + .numReviewersPerItem(0L) + .reservationMinutes(0L) + .rubricInstructions("rubric_instructions") + .addRubricItem( + AnnotationQueueRubricItemSchema.builder() + .feedbackKey("feedback_key") + .description("description") + .scoreDescriptions( + AnnotationQueueRubricItemSchema.ScoreDescriptions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .valueDescriptions( + AnnotationQueueRubricItemSchema.ValueDescriptions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + val annotationQueueSchema = annotationQueueSchemaFuture.get() + annotationQueueSchema.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun export() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val annotationQueueServiceAsync = client.api().v1().annotationQueues() + + val responseFuture = + annotationQueueServiceAsync.export( + AnnotationQueueExportParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun populate() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val annotationQueueServiceAsync = client.api().v1().annotationQueues() + + val responseFuture = + annotationQueueServiceAsync.populate( + AnnotationQueuePopulateParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveAnnotationQueues() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val annotationQueueServiceAsync = client.api().v1().annotationQueues() + + val responseFuture = + annotationQueueServiceAsync.retrieveAnnotationQueues( + AnnotationQueueRetrieveAnnotationQueuesParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .name("name") + .nameContains("name_contains") + .offset(0L) + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val response = responseFuture.get() + response.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveQueues() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val annotationQueueServiceAsync = client.api().v1().annotationQueues() + + val annotationQueueSchemataFuture = + annotationQueueServiceAsync.retrieveQueues("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val annotationQueueSchemata = annotationQueueSchemataFuture.get() + annotationQueueSchemata.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveSize() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val annotationQueueServiceAsync = client.api().v1().annotationQueues() + + val annotationQueueSizeSchemaFuture = + annotationQueueServiceAsync.retrieveSize("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val annotationQueueSizeSchema = annotationQueueSizeSchemaFuture.get() + annotationQueueSizeSchema.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveTotalArchived() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val annotationQueueServiceAsync = client.api().v1().annotationQueues() + + val annotationQueueSizeSchemaFuture = + annotationQueueServiceAsync.retrieveTotalArchived( + AnnotationQueueRetrieveTotalArchivedParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + val annotationQueueSizeSchema = annotationQueueSizeSchemaFuture.get() + annotationQueueSizeSchema.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveTotalSize() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val annotationQueueServiceAsync = client.api().v1().annotationQueues() + + val annotationQueueSizeSchemaFuture = + annotationQueueServiceAsync.retrieveTotalSize("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val annotationQueueSizeSchema = annotationQueueSizeSchemaFuture.get() + annotationQueueSizeSchema.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/ApiKeyServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/ApiKeyServiceAsyncTest.kt new file mode 100644 index 00000000..7d4f7b3d --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/ApiKeyServiceAsyncTest.kt @@ -0,0 +1,81 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyCreateRequest +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ApiKeyServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val apiKeyServiceAsync = client.api().v1().apiKey() + + val apiKeyGetResponseFuture = + apiKeyServiceAsync.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val apiKeyGetResponse = apiKeyGetResponseFuture.get() + apiKeyGetResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun apiKey() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val apiKeyServiceAsync = client.api().v1().apiKey() + + val apiKeyCreateResponseFuture = + apiKeyServiceAsync.apiKey( + ApiKeyCreateRequest.builder() + .defaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val apiKeyCreateResponse = apiKeyCreateResponseFuture.get() + apiKeyCreateResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveApiKey() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val apiKeyServiceAsync = client.api().v1().apiKey() + + val apiKeyGetResponsesFuture = apiKeyServiceAsync.retrieveApiKey() + + val apiKeyGetResponses = apiKeyGetResponsesFuture.get() + apiKeyGetResponses.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/BulkExportServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/BulkExportServiceAsyncTest.kt new file mode 100644 index 00000000..b3b6922e --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/BulkExportServiceAsyncTest.kt @@ -0,0 +1,102 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.bulkexports.BulkExportBulkExportsParams +import com.langsmith_api.api.models.api.v1.bulkexports.BulkExportCompression +import com.langsmith_api.api.models.api.v1.bulkexports.BulkExportFormat +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class BulkExportServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val bulkExportServiceAsync = client.api().v1().bulkExports() + + val bulkExportFuture = + bulkExportServiceAsync.retrieve("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val bulkExport = bulkExportFuture.get() + bulkExport.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val bulkExportServiceAsync = client.api().v1().bulkExports() + + val bulkExportFuture = bulkExportServiceAsync.update("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val bulkExport = bulkExportFuture.get() + bulkExport.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun bulkExports() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val bulkExportServiceAsync = client.api().v1().bulkExports() + + val bulkExportFuture = + bulkExportServiceAsync.bulkExports( + BulkExportBulkExportsParams.builder() + .bulkExportDestinationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .compression(BulkExportCompression.NONE) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .format(BulkExportFormat.PARQUET) + .intervalHours(0L) + .build() + ) + + val bulkExport = bulkExportFuture.get() + bulkExport.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveBulkExports() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val bulkExportServiceAsync = client.api().v1().bulkExports() + + val bulkExportsFuture = bulkExportServiceAsync.retrieveBulkExports() + + val bulkExports = bulkExportsFuture.get() + bulkExports.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/ChartServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/ChartServiceAsyncTest.kt new file mode 100644 index 00000000..f62c27ed --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/ChartServiceAsyncTest.kt @@ -0,0 +1,242 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.charts.ChartUpdateParams +import com.langsmith_api.api.models.api.v1.charts.CustomChartCreate +import com.langsmith_api.api.models.api.v1.charts.CustomChartMetric +import com.langsmith_api.api.models.api.v1.charts.CustomChartPreviewRequest +import com.langsmith_api.api.models.api.v1.charts.CustomChartSeries +import com.langsmith_api.api.models.api.v1.charts.CustomChartSeriesFilters +import com.langsmith_api.api.models.api.v1.charts.CustomChartType +import com.langsmith_api.api.models.api.v1.charts.CustomChartUpdate +import com.langsmith_api.api.models.api.v1.charts.HostProjectChartMetric +import com.langsmith_api.api.models.api.v1.orgcharts.section.CustomChartsRequestBase +import com.langsmith_api.api.models.api.v1.sessions.RunStatsGroupBy +import com.langsmith_api.api.models.api.v1.sessions.TimedeltaInput +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ChartServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val chartServiceAsync = client.api().v1().charts() + + val customChartResponseFuture = + chartServiceAsync.create( + CustomChartCreate.builder() + .chartType(CustomChartType.LINE) + .addSeries( + CustomChartCreate.Series.builder() + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .title("title") + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("description") + .index(0L) + .metadata(JsonValue.from(mapOf<String, Any>())) + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val customChartResponse = customChartResponseFuture.get() + customChartResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val chartServiceAsync = client.api().v1().charts() + + val customChartResponseFuture = + chartServiceAsync.update( + ChartUpdateParams.builder() + .chartId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .customChartUpdate( + CustomChartUpdate.builder() + .chartType(CustomChartType.LINE) + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("string") + .index(0L) + .metadata(JsonValue.from(mapOf<String, Any>())) + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .seriesOfCustomChartSeriesUpdates( + listOf( + CustomChartUpdate.Series.CustomChartSeriesUpdate.builder() + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + ) + .title("string") + .build() + ) + .build() + ) + + val customChartResponse = customChartResponseFuture.get() + customChartResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val chartServiceAsync = client.api().v1().charts() + + val chartFuture = chartServiceAsync.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val chart = chartFuture.get() + chart.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun preview() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val chartServiceAsync = client.api().v1().charts() + + val singleCustomChartResponseBaseFuture = + chartServiceAsync.preview( + CustomChartPreviewRequest.builder() + .bucketInfo( + CustomChartsRequestBase.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride(TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build()) + .timezone("timezone") + .build() + ) + .chart( + CustomChartPreviewRequest.Chart.builder() + .addSeries( + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + CustomChartSeries.GroupBy.builder() + .attribute(CustomChartSeries.GroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .setBy(CustomChartSeries.GroupBy.SetBy.SECTION) + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .build() + ) + .build() + ) + + val singleCustomChartResponseBase = singleCustomChartResponseBaseFuture.get() + singleCustomChartResponseBase.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/CommentServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/CommentServiceAsyncTest.kt new file mode 100644 index 00000000..1f98f31b --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/CommentServiceAsyncTest.kt @@ -0,0 +1,69 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.comments.CommentRetrieveParams +import com.langsmith_api.api.models.api.v1.comments.CommentUpdateParams +import com.langsmith_api.api.models.api.v1.comments.CreateCommentRequest +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CommentServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val commentServiceAsync = client.api().v1().comments() + + val listCommentsResponseFuture = + commentServiceAsync.retrieve( + CommentRetrieveParams.builder() + .owner("owner") + .repo("repo") + .parentCommentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .offset(0L) + .build() + ) + + val listCommentsResponse = listCommentsResponseFuture.get() + listCommentsResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val commentServiceAsync = client.api().v1().comments() + + val commentFuture = + commentServiceAsync.update( + CommentUpdateParams.builder() + .owner("owner") + .repo("repo") + .parentCommentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createCommentRequest(CreateCommentRequest.builder().content("content").build()) + .build() + ) + + val comment = commentFuture.get() + comment.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/CommitServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/CommitServiceAsyncTest.kt new file mode 100644 index 00000000..28db0a2c --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/CommitServiceAsyncTest.kt @@ -0,0 +1,72 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.commits.CommitRetrieveParams +import com.langsmith_api.api.models.api.v1.commits.CommitUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CommitServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val commitServiceAsync = client.api().v1().commits() + + val commitManifestResponseFuture = + commitServiceAsync.retrieve( + CommitRetrieveParams.builder() + .owner("owner") + .repo("repo") + .commit("commit") + .getExamples(true) + .includeModel(true) + .isView(true) + .build() + ) + + val commitManifestResponse = commitManifestResponseFuture.get() + commitManifestResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val commitServiceAsync = client.api().v1().commits() + + val commitFuture = + commitServiceAsync.update( + CommitUpdateParams.builder() + .owner("owner") + .repo("repo") + .manifest(JsonValue.from(mapOf<String, Any>())) + .addExampleRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .parentCommit("parent_commit") + .skipWebhooks(true) + .build() + ) + + val commit = commitFuture.get() + commit.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/DatasetServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/DatasetServiceAsyncTest.kt new file mode 100644 index 00000000..d527aa6a --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/DatasetServiceAsyncTest.kt @@ -0,0 +1,600 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.datasets.DataType +import com.langsmith_api.api.models.api.v1.datasets.DatasetCloneParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetCreateParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetGenerateParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetListParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveCsvParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveJsonlParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveOpenAIFtParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveOpenAIParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveVersionParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetSearchParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetStudioExperimentParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetTransformation +import com.langsmith_api.api.models.api.v1.datasets.DatasetUpdateParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetUpdateTagsParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetUploadExperimentParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetUploadParams +import com.langsmith_api.api.models.api.v1.datasets.FeedbackCreateCoreSchema +import com.langsmith_api.api.models.api.v1.datasets.SortByDatasetColumn +import com.langsmith_api.api.models.api.v1.feedback.AppFeedbackSource +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfig +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class DatasetServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetServiceAsync = client.api().v1().datasets() + + val datasetFuture = + datasetServiceAsync.create( + DatasetCreateParams.builder() + .name("name") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dataType(DataType.KV) + .description("description") + .externallyManaged(true) + .extra(JsonValue.from(mapOf<String, Any>())) + .inputsSchemaDefinition(JsonValue.from(mapOf<String, Any>())) + .outputsSchemaDefinition(JsonValue.from(mapOf<String, Any>())) + .addTransformation( + DatasetTransformation.builder() + .addPath("string") + .transformationType( + DatasetTransformation.TransformationType.CONVERT_TO_OPENAI_MESSAGE + ) + .build() + ) + .build() + ) + + val dataset = datasetFuture.get() + dataset.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetServiceAsync = client.api().v1().datasets() + + val datasetFuture = datasetServiceAsync.retrieve("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val dataset = datasetFuture.get() + dataset.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetServiceAsync = client.api().v1().datasets() + + val datasetFuture = + datasetServiceAsync.update( + DatasetUpdateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("string") + .inputsSchemaDefinition(JsonValue.from(mapOf<String, Any>())) + .metadata(JsonValue.from(mapOf<String, Any>())) + .name("string") + .outputsSchemaDefinition(JsonValue.from(mapOf<String, Any>())) + .patchExamples( + DatasetUpdateParams.PatchExamples.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "attachments_operations" to + mapOf( + "rename" to mapOf("foo" to "string"), + "retain" to listOf("string"), + ), + "dataset_id" to "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "inputs" to mapOf<String, Any>(), + "metadata" to mapOf<String, Any>(), + "outputs" to mapOf<String, Any>(), + "overwrite" to true, + "split" to listOf("string"), + ) + ), + ) + .build() + ) + .transformationsOfDataset( + listOf( + DatasetTransformation.builder() + .addPath("string") + .transformationType( + DatasetTransformation.TransformationType + .CONVERT_TO_OPENAI_MESSAGE + ) + .build() + ) + ) + .build() + ) + + val dataset = datasetFuture.get() + dataset.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetServiceAsync = client.api().v1().datasets() + + val datasetsFuture = + datasetServiceAsync.list( + DatasetListParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dataTypeOfTypes(listOf(DataType.KV)) + .excludeCorrectionsDatasets(true) + .limit(1L) + .metadata("metadata") + .name("name") + .nameContains("name_contains") + .offset(0L) + .sortBy(SortByDatasetColumn.NAME) + .sortByDesc(true) + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val datasets = datasetsFuture.get() + datasets.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetServiceAsync = client.api().v1().datasets() + + val datasetFuture = datasetServiceAsync.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val dataset = datasetFuture.get() + dataset.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun clone() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetServiceAsync = client.api().v1().datasets() + + val responseFuture = + datasetServiceAsync.clone( + DatasetCloneParams.builder() + .sourceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .targetDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val response = responseFuture.get() + response.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun generate() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetServiceAsync = client.api().v1().datasets() + + val responseFuture = + datasetServiceAsync.generate( + DatasetGenerateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .numExamples(0L) + .addExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveCsv() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetServiceAsync = client.api().v1().datasets() + + val responseFuture = + datasetServiceAsync.retrieveCsv( + DatasetRetrieveCsvParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveJsonl() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetServiceAsync = client.api().v1().datasets() + + val responseFuture = + datasetServiceAsync.retrieveJsonl( + DatasetRetrieveJsonlParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveOpenAI() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetServiceAsync = client.api().v1().datasets() + + val responseFuture = + datasetServiceAsync.retrieveOpenAI( + DatasetRetrieveOpenAIParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveOpenAIFt() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetServiceAsync = client.api().v1().datasets() + + val responseFuture = + datasetServiceAsync.retrieveOpenAIFt( + DatasetRetrieveOpenAIFtParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveVersion() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetServiceAsync = client.api().v1().datasets() + + val datasetVersionFuture = + datasetServiceAsync.retrieveVersion( + DatasetRetrieveVersionParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tag("tag") + .build() + ) + + val datasetVersion = datasetVersionFuture.get() + datasetVersion.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun search() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetServiceAsync = client.api().v1().datasets() + + val responseFuture = + datasetServiceAsync.search( + DatasetSearchParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .debug(true) + .filter("filter") + .limit(1L) + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun studioExperiment() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetServiceAsync = client.api().v1().datasets() + + val responseFuture = + datasetServiceAsync.studioExperiment( + DatasetStudioExperimentParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .addEvaluatorRule("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun updateTags() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetServiceAsync = client.api().v1().datasets() + + val datasetVersionFuture = + datasetServiceAsync.updateTags( + DatasetUpdateTagsParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tag("tag") + .build() + ) + + val datasetVersion = datasetVersionFuture.get() + datasetVersion.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun upload() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetServiceAsync = client.api().v1().datasets() + + val datasetFuture = + datasetServiceAsync.upload( + DatasetUploadParams.builder() + .file("some content".byteInputStream()) + .addInputKey("string") + .dataType(DataType.KV) + .description("description") + .inputKeyMappings("input_key_mappings") + .inputsSchemaDefinition("inputs_schema_definition") + .metadataKeyMappings("metadata_key_mappings") + .addMetadataKey("string") + .name("name") + .outputKeyMappings("output_key_mappings") + .addOutputKey("string") + .outputsSchemaDefinition("outputs_schema_definition") + .transformations("transformations") + .build() + ) + + val dataset = datasetFuture.get() + dataset.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun uploadExperiment() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetServiceAsync = client.api().v1().datasets() + + val responseFuture = + datasetServiceAsync.uploadExperiment( + DatasetUploadExperimentParams.builder() + .experimentEndTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .experimentName("experiment_name") + .experimentStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addResult( + DatasetUploadExperimentParams.Result.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inputs(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .actualOutputs(JsonValue.from(mapOf<String, Any>())) + .error("error") + .addEvaluationScore( + FeedbackCreateCoreSchema.builder() + .key("key") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .correction(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder() + .value(0.0) + .label("x") + .build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .feedbackGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackSource( + AppFeedbackSource.builder() + .metadata(JsonValue.from(mapOf<String, Any>())) + .type("type") + .build() + ) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .score(0.0) + .value(0.0) + .build() + ) + .expectedOutputs(JsonValue.from(mapOf<String, Any>())) + .rowId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runMetadata(JsonValue.from(mapOf<String, Any>())) + .runName("run_name") + .build() + ) + .datasetDescription("dataset_description") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetName("dataset_name") + .experimentDescription("experiment_description") + .experimentMetadata(JsonValue.from(mapOf<String, Any>())) + .addSummaryExperimentScore( + FeedbackCreateCoreSchema.builder() + .key("key") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .correction(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder() + .value(0.0) + .label("x") + .build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .feedbackGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackSource( + AppFeedbackSource.builder() + .metadata(JsonValue.from(mapOf<String, Any>())) + .type("type") + .build() + ) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .score(0.0) + .value(0.0) + .build() + ) + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/ExampleServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/ExampleServiceAsyncTest.kt new file mode 100644 index 00000000..3f16ba40 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/ExampleServiceAsyncTest.kt @@ -0,0 +1,193 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.examples.ExampleDeleteAllParams +import com.langsmith_api.api.models.api.v1.examples.ExampleListParams +import com.langsmith_api.api.models.api.v1.examples.ExampleRetrieveCountParams +import com.langsmith_api.api.models.api.v1.examples.ExampleRetrieveParams +import com.langsmith_api.api.models.api.v1.examples.ExampleSelect +import com.langsmith_api.api.models.api.v1.examples.ExampleUpdateParams +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ExampleServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val exampleServiceAsync = client.api().v1().examples() + + val exampleFuture = exampleServiceAsync.create() + + val example = exampleFuture.get() + example.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val exampleServiceAsync = client.api().v1().examples() + + val exampleFuture = + exampleServiceAsync.retrieve( + ExampleRetrieveParams.builder() + .exampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + val example = exampleFuture.get() + example.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val exampleServiceAsync = client.api().v1().examples() + + val examplesFuture = + exampleServiceAsync.update( + ExampleUpdateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .file("some content".byteInputStream()) + .addInputKey("string") + .addMetadataKey("string") + .addOutputKey("string") + .build() + ) + + val examples = examplesFuture.get() + examples.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val exampleServiceAsync = client.api().v1().examples() + + val examplesFuture = + exampleServiceAsync.list( + ExampleListParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .descending(true) + .filter("filter") + .addFullTextContain("string") + .limit(1L) + .metadata("metadata") + .offset(0L) + .order(ExampleListParams.Order.RECENT) + .randomSeed(0.0) + .addSelect(ExampleSelect.ID) + .addSplit("string") + .build() + ) + + val examples = examplesFuture.get() + examples.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val exampleServiceAsync = client.api().v1().examples() + + val exampleFuture = exampleServiceAsync.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val example = exampleFuture.get() + example.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun deleteAll() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val exampleServiceAsync = client.api().v1().examples() + + val responseFuture = + exampleServiceAsync.deleteAll( + ExampleDeleteAllParams.builder() + .addExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveCount() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val exampleServiceAsync = client.api().v1().examples() + + val responseFuture = + exampleServiceAsync.retrieveCount( + ExampleRetrieveCountParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .filter("filter") + .addFullTextContain("string") + .metadata("metadata") + .addSplit("string") + .build() + ) + + val response = responseFuture.get() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/FeedbackConfigServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/FeedbackConfigServiceAsyncTest.kt new file mode 100644 index 00000000..027caf72 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/FeedbackConfigServiceAsyncTest.kt @@ -0,0 +1,109 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfig +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfigFeedbackConfigsParams +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfigRetrieveFeedbackConfigsParams +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfigUpdateFeedbackConfigsParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class FeedbackConfigServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun feedbackConfigs() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val feedbackConfigServiceAsync = client.api().v1().feedbackConfigs() + + val feedbackConfigSchemaFuture = + feedbackConfigServiceAsync.feedbackConfigs( + FeedbackConfigFeedbackConfigsParams.builder() + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder().value(0.0).label("x").build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .feedbackKey("feedback_key") + .isLowerScoreBetter(true) + .build() + ) + + val feedbackConfigSchema = feedbackConfigSchemaFuture.get() + feedbackConfigSchema.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveFeedbackConfigs() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val feedbackConfigServiceAsync = client.api().v1().feedbackConfigs() + + val feedbackConfigSchemataFuture = + feedbackConfigServiceAsync.retrieveFeedbackConfigs( + FeedbackConfigRetrieveFeedbackConfigsParams.builder() + .addKey("string") + .readAfterWrite(true) + .build() + ) + + val feedbackConfigSchemata = feedbackConfigSchemataFuture.get() + feedbackConfigSchemata.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun updateFeedbackConfigs() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val feedbackConfigServiceAsync = client.api().v1().feedbackConfigs() + + val feedbackConfigSchemaFuture = + feedbackConfigServiceAsync.updateFeedbackConfigs( + FeedbackConfigUpdateFeedbackConfigsParams.builder() + .feedbackKey("feedback_key") + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder().value(0.0).label("x").build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .isLowerScoreBetter(true) + .build() + ) + + val feedbackConfigSchema = feedbackConfigSchemaFuture.get() + feedbackConfigSchema.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/FeedbackServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/FeedbackServiceAsyncTest.kt new file mode 100644 index 00000000..5d6c1224 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/FeedbackServiceAsyncTest.kt @@ -0,0 +1,241 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.feedback.AppFeedbackSource +import com.langsmith_api.api.models.api.v1.feedback.FeedbackCreateSchema +import com.langsmith_api.api.models.api.v1.feedback.FeedbackLevel +import com.langsmith_api.api.models.api.v1.feedback.FeedbackListParams +import com.langsmith_api.api.models.api.v1.feedback.FeedbackRetrieveParams +import com.langsmith_api.api.models.api.v1.feedback.FeedbackUpdateParams +import com.langsmith_api.api.models.api.v1.feedback.SourceType +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfig +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class FeedbackServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val feedbackServiceAsync = client.api().v1().feedback() + + val feedbackSchemaFuture = + feedbackServiceAsync.create( + FeedbackCreateSchema.builder() + .key("key") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .correction(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder().value(0.0).label("x").build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .feedbackGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackSource( + AppFeedbackSource.builder() + .metadata(JsonValue.from(mapOf<String, Any>())) + .type("type") + .build() + ) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .score(0.0) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .value(0.0) + .build() + ) + + val feedbackSchema = feedbackSchemaFuture.get() + feedbackSchema.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val feedbackServiceAsync = client.api().v1().feedback() + + val feedbackSchemaFuture = + feedbackServiceAsync.retrieve( + FeedbackRetrieveParams.builder() + .feedbackId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .includeUserNames(true) + .build() + ) + + val feedbackSchema = feedbackSchemaFuture.get() + feedbackSchema.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val feedbackServiceAsync = client.api().v1().feedback() + + val feedbackSchemaFuture = + feedbackServiceAsync.update( + FeedbackUpdateParams.builder() + .feedbackId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") + .correction(JsonValue.from(mapOf<String, Any>())) + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder().value(0.0).label("x").build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .score(0.0) + .value(0.0) + .build() + ) + + val feedbackSchema = feedbackSchemaFuture.get() + feedbackSchema.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val feedbackServiceAsync = client.api().v1().feedback() + + val feedbackSchemataFuture = + feedbackServiceAsync.list( + FeedbackListParams.builder() + .hasComment(true) + .hasScore(true) + .includeUserNames(true) + .addKey("string") + .level(FeedbackLevel.RUN) + .limit(1L) + .maxCreatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minCreatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .offset(0L) + .addRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addSource(SourceType.API) + .addUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val feedbackSchemata = feedbackSchemataFuture.get() + feedbackSchemata.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val feedbackServiceAsync = client.api().v1().feedback() + + val feedbackFuture = feedbackServiceAsync.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val feedback = feedbackFuture.get() + feedback.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun eager() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val feedbackServiceAsync = client.api().v1().feedback() + + val feedbackSchemaFuture = + feedbackServiceAsync.eager( + FeedbackCreateSchema.builder() + .key("key") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .correction(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder().value(0.0).label("x").build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .feedbackGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackSource( + AppFeedbackSource.builder() + .metadata(JsonValue.from(mapOf<String, Any>())) + .type("type") + .build() + ) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .score(0.0) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .value(0.0) + .build() + ) + + val feedbackSchema = feedbackSchemaFuture.get() + feedbackSchema.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/InfoServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/InfoServiceAsyncTest.kt new file mode 100644 index 00000000..14176a49 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/InfoServiceAsyncTest.kt @@ -0,0 +1,49 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class InfoServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val infoServiceAsync = client.api().v1().info() + + val infosFuture = infoServiceAsync.list() + + val infos = infosFuture.get() + infos.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveHealth() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val infoServiceAsync = client.api().v1().info() + + val responseFuture = infoServiceAsync.retrieveHealth() + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/MeServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/MeServiceAsyncTest.kt new file mode 100644 index 00000000..db11bd8f --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/MeServiceAsyncTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class MeServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieveLsUserId() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val meServiceAsync = client.api().v1().me() + + val responseFuture = meServiceAsync.retrieveLsUserId() + + val response = responseFuture.get() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/ModelPriceMapServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/ModelPriceMapServiceAsyncTest.kt new file mode 100644 index 00000000..4bd0c187 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/ModelPriceMapServiceAsyncTest.kt @@ -0,0 +1,133 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.modelpricemap.ModelPriceMapModelPriceMapParams +import com.langsmith_api.api.models.api.v1.modelpricemap.ModelPriceMapUpdateParams +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ModelPriceMapServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val modelPriceMapServiceAsync = client.api().v1().modelPriceMap() + + val modelPriceMapFuture = + modelPriceMapServiceAsync.update( + ModelPriceMapUpdateParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost(0.0) + .matchPattern("match_pattern") + .name("name") + .promptCost(0.0) + .completionCostDetails( + ModelPriceMapUpdateParams.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .addMatchPath("string") + .promptCostDetails( + ModelPriceMapUpdateParams.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .provider("provider") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + val modelPriceMap = modelPriceMapFuture.get() + modelPriceMap.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val modelPriceMapServiceAsync = client.api().v1().modelPriceMap() + + val modelPriceMapFuture = + modelPriceMapServiceAsync.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val modelPriceMap = modelPriceMapFuture.get() + modelPriceMap.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun modelPriceMap() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val modelPriceMapServiceAsync = client.api().v1().modelPriceMap() + + val responseFuture = + modelPriceMapServiceAsync.modelPriceMap( + ModelPriceMapModelPriceMapParams.builder() + .completionCost(0.0) + .matchPattern("match_pattern") + .name("name") + .promptCost(0.0) + .completionCostDetails( + ModelPriceMapModelPriceMapParams.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .addMatchPath("string") + .promptCostDetails( + ModelPriceMapModelPriceMapParams.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .provider("provider") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveModelPriceMap() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val modelPriceMapServiceAsync = client.api().v1().modelPriceMap() + + val responseFuture = modelPriceMapServiceAsync.retrieveModelPriceMap() + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/OAuthServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/OAuthServiceAsyncTest.kt new file mode 100644 index 00000000..57fe5156 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/OAuthServiceAsyncTest.kt @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.oauth.OAuthProvider +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class OAuthServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val oauthServiceAsync = client.api().v1().oauth() + + val oauthFuture = oauthServiceAsync.retrieve(OAuthProvider.CUSTOM_OIDC) + + val oauth = oauthFuture.get() + oauth.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveCallback() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val oauthServiceAsync = client.api().v1().oauth() + + val responseFuture = oauthServiceAsync.retrieveCallback(OAuthProvider.CUSTOM_OIDC) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveCurrentUser() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val oauthServiceAsync = client.api().v1().oauth() + + val responseFuture = oauthServiceAsync.retrieveCurrentUser(OAuthProvider.CUSTOM_OIDC) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveLogout() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val oauthServiceAsync = client.api().v1().oauth() + + val responseFuture = oauthServiceAsync.retrieveLogout(OAuthProvider.CUSTOM_OIDC) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/OrgChartServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/OrgChartServiceAsyncTest.kt new file mode 100644 index 00000000..b49a9504 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/OrgChartServiceAsyncTest.kt @@ -0,0 +1,272 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.charts.CustomChartCreate +import com.langsmith_api.api.models.api.v1.charts.CustomChartMetric +import com.langsmith_api.api.models.api.v1.charts.CustomChartPreviewRequest +import com.langsmith_api.api.models.api.v1.charts.CustomChartSeries +import com.langsmith_api.api.models.api.v1.charts.CustomChartSeriesFilters +import com.langsmith_api.api.models.api.v1.charts.CustomChartType +import com.langsmith_api.api.models.api.v1.charts.CustomChartUpdate +import com.langsmith_api.api.models.api.v1.charts.CustomChartsRequest +import com.langsmith_api.api.models.api.v1.charts.HostProjectChartMetric +import com.langsmith_api.api.models.api.v1.orgcharts.OrgChartUpdateParams +import com.langsmith_api.api.models.api.v1.orgcharts.section.CustomChartsRequestBase +import com.langsmith_api.api.models.api.v1.sessions.RunStatsGroupBy +import com.langsmith_api.api.models.api.v1.sessions.TimedeltaInput +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class OrgChartServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val orgChartServiceAsync = client.api().v1().orgCharts() + + val customChartResponseFuture = + orgChartServiceAsync.create( + CustomChartCreate.builder() + .chartType(CustomChartType.LINE) + .addSeries( + CustomChartCreate.Series.builder() + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .title("title") + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("description") + .index(0L) + .metadata(JsonValue.from(mapOf<String, Any>())) + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val customChartResponse = customChartResponseFuture.get() + customChartResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val orgChartServiceAsync = client.api().v1().orgCharts() + + val customChartResponseFuture = + orgChartServiceAsync.update( + OrgChartUpdateParams.builder() + .chartId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .customChartUpdate( + CustomChartUpdate.builder() + .chartType(CustomChartType.LINE) + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("string") + .index(0L) + .metadata(JsonValue.from(mapOf<String, Any>())) + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .seriesOfCustomChartSeriesUpdates( + listOf( + CustomChartUpdate.Series.CustomChartSeriesUpdate.builder() + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + ) + .title("string") + .build() + ) + .build() + ) + + val customChartResponse = customChartResponseFuture.get() + customChartResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val orgChartServiceAsync = client.api().v1().orgCharts() + + val orgChartFuture = orgChartServiceAsync.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val orgChart = orgChartFuture.get() + orgChart.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun orgCharts() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val orgChartServiceAsync = client.api().v1().orgCharts() + + val customChartsResponseFuture = + orgChartServiceAsync.orgCharts( + CustomChartsRequest.builder() + .afterIndex(0L) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride(TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build()) + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .timezone("timezone") + .build() + ) + + val customChartsResponse = customChartsResponseFuture.get() + customChartsResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun preview() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val orgChartServiceAsync = client.api().v1().orgCharts() + + val singleCustomChartResponseBaseFuture = + orgChartServiceAsync.preview( + CustomChartPreviewRequest.builder() + .bucketInfo( + CustomChartsRequestBase.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride(TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build()) + .timezone("timezone") + .build() + ) + .chart( + CustomChartPreviewRequest.Chart.builder() + .addSeries( + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + CustomChartSeries.GroupBy.builder() + .attribute(CustomChartSeries.GroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .setBy(CustomChartSeries.GroupBy.SetBy.SECTION) + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .build() + ) + .build() + ) + + val singleCustomChartResponseBase = singleCustomChartResponseBaseFuture.get() + singleCustomChartResponseBase.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/OrgServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/OrgServiceAsyncTest.kt new file mode 100644 index 00000000..e1a85f60 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/OrgServiceAsyncTest.kt @@ -0,0 +1,73 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.orgs.OrgCreateParams +import com.langsmith_api.api.models.api.v1.orgs.OrgListParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class OrgServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val orgServiceAsync = client.api().v1().orgs() + + val organizationPgSchemaSlimFuture = + orgServiceAsync.create( + OrgCreateParams.builder().displayName("display_name").isPersonal(true).build() + ) + + val organizationPgSchemaSlim = organizationPgSchemaSlimFuture.get() + organizationPgSchemaSlim.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val orgServiceAsync = client.api().v1().orgs() + + val organizationPgSchemaSlimsFuture = + orgServiceAsync.list(OrgListParams.builder().includeTier(true).skipCreate(true).build()) + + val organizationPgSchemaSlims = organizationPgSchemaSlimsFuture.get() + organizationPgSchemaSlims.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun retrievePermissions() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val orgServiceAsync = client.api().v1().orgs() + + val responseFuture = orgServiceAsync.retrievePermissions() + + val response = responseFuture.get() + response.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/PlaygroundSettingServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/PlaygroundSettingServiceAsyncTest.kt new file mode 100644 index 00000000..0c733f1c --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/PlaygroundSettingServiceAsyncTest.kt @@ -0,0 +1,107 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.playgroundsettings.PlaygroundSavedOptions +import com.langsmith_api.api.models.api.v1.playgroundsettings.PlaygroundSettingPlaygroundSettingsParams +import com.langsmith_api.api.models.api.v1.playgroundsettings.PlaygroundSettingUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class PlaygroundSettingServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val playgroundSettingServiceAsync = client.api().v1().playgroundSettings() + + val playgroundSettingsResponseFuture = + playgroundSettingServiceAsync.update( + PlaygroundSettingUpdateParams.builder() + .playgroundSettingsId("playground_settings_id") + .description("description") + .name("name") + .options(PlaygroundSavedOptions.builder().requestsPerSecond(0L).build()) + .settings(JsonValue.from(mapOf<String, Any>())) + .build() + ) + + val playgroundSettingsResponse = playgroundSettingsResponseFuture.get() + playgroundSettingsResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val playgroundSettingServiceAsync = client.api().v1().playgroundSettings() + + val playgroundSettingFuture = playgroundSettingServiceAsync.delete("playground_settings_id") + + val playgroundSetting = playgroundSettingFuture.get() + playgroundSetting.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun playgroundSettings() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val playgroundSettingServiceAsync = client.api().v1().playgroundSettings() + + val playgroundSettingsResponseFuture = + playgroundSettingServiceAsync.playgroundSettings( + PlaygroundSettingPlaygroundSettingsParams.builder() + .settings(JsonValue.from(mapOf<String, Any>())) + .description("description") + .name("name") + .options(PlaygroundSavedOptions.builder().requestsPerSecond(0L).build()) + .build() + ) + + val playgroundSettingsResponse = playgroundSettingsResponseFuture.get() + playgroundSettingsResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrievePlaygroundSettings() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val playgroundSettingServiceAsync = client.api().v1().playgroundSettings() + + val playgroundSettingsResponsesFuture = + playgroundSettingServiceAsync.retrievePlaygroundSettings() + + val playgroundSettingsResponses = playgroundSettingsResponsesFuture.get() + playgroundSettingsResponses.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/PromptServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/PromptServiceAsyncTest.kt new file mode 100644 index 00000000..f70089d5 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/PromptServiceAsyncTest.kt @@ -0,0 +1,148 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.prompts.InvalidToolCall +import com.langsmith_api.api.models.api.v1.prompts.PromptCanvasParams +import com.langsmith_api.api.models.api.v1.prompts.PromptInvokePromptParams +import com.langsmith_api.api.models.api.v1.prompts.ToolCall +import com.langsmith_api.api.models.api.v1.prompts.UsageMetadata +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class PromptServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun canvas() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val promptServiceAsync = client.api().v1().prompts() + + val responseFuture = + promptServiceAsync.canvas( + PromptCanvasParams.builder() + .addMessage( + PromptCanvasParams.Message.AiMessage.builder() + .content("string") + .id("id") + .additionalKwargs(JsonValue.from(mapOf<String, Any>())) + .addInvalidToolCall( + InvalidToolCall.builder() + .id("id") + .args("args") + .error("error") + .name("name") + .extras(JsonValue.from(mapOf<String, Any>())) + .index(0L) + .build() + ) + .name("name") + .responseMetadata(JsonValue.from(mapOf<String, Any>())) + .addToolCall( + ToolCall.builder() + .id("id") + .args(JsonValue.from(mapOf<String, Any>())) + .name("name") + .type(ToolCall.Type.TOOL_CALL) + .build() + ) + .type(PromptCanvasParams.Message.AiMessage.Type.AI) + .usageMetadata( + UsageMetadata.builder() + .inputTokens(0L) + .outputTokens(0L) + .totalTokens(0L) + .inputTokenDetails( + UsageMetadata.InputTokenDetails.builder() + .audio(0L) + .cacheCreation(0L) + .cacheRead(0L) + .build() + ) + .outputTokenDetails( + UsageMetadata.OutputTokenDetails.builder() + .audio(0L) + .reasoning(0L) + .build() + ) + .build() + ) + .build() + ) + .secrets( + PromptCanvasParams.Secrets.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .templateFormat(PromptCanvasParams.TemplateFormat.F_STRING) + .artifact( + PromptCanvasParams.Artifact.builder() + .id("id") + .addContent( + PromptCanvasParams.Artifact.Content.builder() + .content("content") + .index(0L) + .build() + ) + .currentContentIndex(0L) + .build() + ) + .artifactLength(PromptCanvasParams.ArtifactLength.SHORTEST) + .customAction("custom_action") + .highlighted( + PromptCanvasParams.Highlighted.builder() + .highlightText("highlight_text") + .promptChunk("prompt_chunk") + .promptChunkEndIndex(0L) + .promptChunkStartIndex(0L) + .build() + ) + .readingLevel(PromptCanvasParams.ReadingLevel.CHILD) + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun invokePrompt() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val promptServiceAsync = client.api().v1().prompts() + + val responseFuture = + promptServiceAsync.invokePrompt( + PromptInvokePromptParams.builder() + .inputs(JsonValue.from(mapOf<String, Any>())) + .addMessage( + listOf( + JsonValue.from(mapOf<String, Any>()), + JsonValue.from(mapOf<String, Any>()), + ) + ) + .templateFormat("template_format") + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/PromptWebhookServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/PromptWebhookServiceAsyncTest.kt new file mode 100644 index 00000000..ec6b99cf --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/PromptWebhookServiceAsyncTest.kt @@ -0,0 +1,173 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.promptwebhooks.EPromptWebhookTrigger +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhookPromptWebhooksParams +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhookTestParams +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhookUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class PromptWebhookServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val promptWebhookServiceAsync = client.api().v1().promptWebhooks() + + val promptWebhookFuture = + promptWebhookServiceAsync.retrieve("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val promptWebhook = promptWebhookFuture.get() + promptWebhook.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val promptWebhookServiceAsync = client.api().v1().promptWebhooks() + + val promptWebhookFuture = + promptWebhookServiceAsync.update( + PromptWebhookUpdateParams.builder() + .webhookId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addExcludePrompt("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .headers(JsonValue.from(mapOf<String, Any>())) + .addIncludePrompt("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addTrigger(EPromptWebhookTrigger.COMMIT) + .url("https://example.com") + .build() + ) + + val promptWebhook = promptWebhookFuture.get() + promptWebhook.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val promptWebhookServiceAsync = client.api().v1().promptWebhooks() + + val promptWebhookFuture = + promptWebhookServiceAsync.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val promptWebhook = promptWebhookFuture.get() + promptWebhook.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun promptWebhooks() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val promptWebhookServiceAsync = client.api().v1().promptWebhooks() + + val promptWebhookFuture = + promptWebhookServiceAsync.promptWebhooks( + PromptWebhookPromptWebhooksParams.builder() + .url("https://example.com") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addExcludePrompt("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .headers(JsonValue.from(mapOf<String, Any>())) + .addIncludePrompt("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addTrigger(EPromptWebhookTrigger.COMMIT) + .build() + ) + + val promptWebhook = promptWebhookFuture.get() + promptWebhook.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrievePromptWebhooks() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val promptWebhookServiceAsync = client.api().v1().promptWebhooks() + + val promptWebhooksFuture = promptWebhookServiceAsync.retrievePromptWebhooks() + + val promptWebhooks = promptWebhooksFuture.get() + promptWebhooks.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun test() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val promptWebhookServiceAsync = client.api().v1().promptWebhooks() + + val responseFuture = + promptWebhookServiceAsync.test( + PromptWebhookTestParams.builder() + .payload( + PromptWebhookTestParams.Payload.builder() + .commitHash("commit_hash") + .createdAt("created_at") + .createdBy("created_by") + .event(EPromptWebhookTrigger.COMMIT) + .manifest(JsonValue.from(mapOf<String, Any>())) + .promptId("prompt_id") + .promptName("prompt_name") + .tagName("tag_name") + .build() + ) + .webhook( + PromptWebhookTestParams.Webhook.builder() + .url("https://example.com") + .addExcludePrompt("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .headers(JsonValue.from(mapOf<String, Any>())) + .addIncludePrompt("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addTrigger(EPromptWebhookTrigger.COMMIT) + .build() + ) + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/PublicServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/PublicServiceAsyncTest.kt new file mode 100644 index 00000000..87d34105 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/PublicServiceAsyncTest.kt @@ -0,0 +1,49 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.feedback.FeedbackLevel +import com.langsmith_api.api.models.api.v1.feedback.SourceType +import com.langsmith_api.api.models.api.v1.public_.PublicRetrieveFeedbacksParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class PublicServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieveFeedbacks() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val publicServiceAsync = client.api().v1().public_() + + val feedbackSchemataFuture = + publicServiceAsync.retrieveFeedbacks( + PublicRetrieveFeedbacksParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .hasComment(true) + .hasScore(true) + .addKey("string") + .level(FeedbackLevel.RUN) + .limit(1L) + .offset(0L) + .addRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addSource(SourceType.API) + .addUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val feedbackSchemata = feedbackSchemataFuture.get() + feedbackSchemata.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/RepoServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/RepoServiceAsyncTest.kt new file mode 100644 index 00000000..9f0ac0fc --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/RepoServiceAsyncTest.kt @@ -0,0 +1,221 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.repos.EPromptOptimizationAlgorithm +import com.langsmith_api.api.models.api.v1.repos.PromptimConfig +import com.langsmith_api.api.models.api.v1.repos.RepoCreateParams +import com.langsmith_api.api.models.api.v1.repos.RepoDeleteParams +import com.langsmith_api.api.models.api.v1.repos.RepoForkParams +import com.langsmith_api.api.models.api.v1.repos.RepoListParams +import com.langsmith_api.api.models.api.v1.repos.RepoOptimizeJobParams +import com.langsmith_api.api.models.api.v1.repos.RepoRetrieveParams +import com.langsmith_api.api.models.api.v1.repos.RepoUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class RepoServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val repoServiceAsync = client.api().v1().repos() + + val createRepoResponseFuture = + repoServiceAsync.create( + RepoCreateParams.builder() + .isPublic(true) + .repoHandle("repo_handle") + .description("description") + .readme("readme") + .addTag("string") + .build() + ) + + val createRepoResponse = createRepoResponseFuture.get() + createRepoResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val repoServiceAsync = client.api().v1().repos() + + val getRepoResponseFuture = + repoServiceAsync.retrieve( + RepoRetrieveParams.builder().owner("owner").repo("repo").build() + ) + + val getRepoResponse = getRepoResponseFuture.get() + getRepoResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val repoServiceAsync = client.api().v1().repos() + + val createRepoResponseFuture = + repoServiceAsync.update( + RepoUpdateParams.builder() + .owner("owner") + .repo("repo") + .description("description") + .isArchived(true) + .isPublic(true) + .readme("readme") + .addTag("string") + .build() + ) + + val createRepoResponse = createRepoResponseFuture.get() + createRepoResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val repoServiceAsync = client.api().v1().repos() + + val reposFuture = + repoServiceAsync.list( + RepoListParams.builder() + .hasCommits(true) + .isArchived(RepoListParams.IsArchived.TRUE) + .isPublic(RepoListParams.IsPublic.TRUE) + .limit(1L) + .offset(0L) + .query("query") + .sortDirection(RepoListParams.SortDirection.ASC) + .sortField(RepoListParams.SortField.NUM_LIKES) + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addTag("string") + .tenantHandle("tenant_handle") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .upstreamRepoHandle("upstream_repo_handle") + .upstreamRepoOwner("upstream_repo_owner") + .withLatestManifest(true) + .build() + ) + + val repos = reposFuture.get() + repos.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val repoServiceAsync = client.api().v1().repos() + + val repoFuture = + repoServiceAsync.delete(RepoDeleteParams.builder().owner("owner").repo("repo").build()) + + val repo = repoFuture.get() + repo.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun fork() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val repoServiceAsync = client.api().v1().repos() + + val getRepoResponseFuture = + repoServiceAsync.fork( + RepoForkParams.builder() + .owner("owner") + .repo("repo") + .repoHandle("repo_handle") + .description("description") + .isPublic(true) + .readme("readme") + .addTag("string") + .build() + ) + + val getRepoResponse = getRepoResponseFuture.get() + getRepoResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun optimizeJob() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val repoServiceAsync = client.api().v1().repos() + + val responseFuture = + repoServiceAsync.optimizeJob( + RepoOptimizeJobParams.builder() + .algorithm(EPromptOptimizationAlgorithm.PROMPTIM) + .config( + PromptimConfig.builder() + .autoCommit(true) + .datasetName("dataset_name") + .devSplit("dev_split") + .addEvaluator("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .messageIndex(0L) + .numEpochs(0L) + .taskDescription("task_description") + .testSplit("test_split") + .trainSplit("train_split") + .build() + ) + .promptName("prompt_name") + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/RunServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/RunServiceAsyncTest.kt new file mode 100644 index 00000000..ddf108b0 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/RunServiceAsyncTest.kt @@ -0,0 +1,217 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.runs.BodyParamsForRunSchema +import com.langsmith_api.api.models.api.v1.runs.RequestBodyForRunsGenerateQuery +import com.langsmith_api.api.models.api.v1.runs.RunDeleteParams +import com.langsmith_api.api.models.api.v1.runs.RunRetrieveParams +import com.langsmith_api.api.models.api.v1.runs.RunStatsQueryParams +import com.langsmith_api.api.models.api.v1.runs.RunTypeEnum +import com.langsmith_api.api.models.api.v1.runs.RunsFilterDataSourceTypeEnum +import com.langsmith_api.api.models.api.v1.sessions.RunStatsGroupBy +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class RunServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runServiceAsync = client.api().v1().runs() + + val runSchemaFuture = + runServiceAsync.retrieve( + RunRetrieveParams.builder() + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .excludeS3StoredAttributes(true) + .excludeSerialized(true) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + val runSchema = runSchemaFuture.get() + runSchema.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runServiceAsync = client.api().v1().runs() + + val runFuture = runServiceAsync.update("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val run = runFuture.get() + run.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runServiceAsync = client.api().v1().runs() + + val runFuture = + runServiceAsync.delete( + RunDeleteParams.builder() + .metadata( + RunDeleteParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addTraceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val run = runFuture.get() + run.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun generateQuery() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runServiceAsync = client.api().v1().runs() + + val responseBodyForRunsGenerateQueryFuture = + runServiceAsync.generateQuery( + RequestBodyForRunsGenerateQuery.builder() + .query("query") + .addFeedbackKey(RequestBodyForRunsGenerateQuery.FeedbackKey.USER_SCORE) + .build() + ) + + val responseBodyForRunsGenerateQuery = responseBodyForRunsGenerateQueryFuture.get() + responseBodyForRunsGenerateQuery.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun query() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runServiceAsync = client.api().v1().runs() + + val responseFuture = + runServiceAsync.query( + BodyParamsForRunSchema.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .dataSourceType(RunsFilterDataSourceTypeEnum.CURRENT) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .executionOrder(1L) + .filter("filter") + .isRoot(true) + .limit(1L) + .order(BodyParamsForRunSchema.Order.ASC) + .parentRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .query("query") + .addReferenceExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runType(RunTypeEnum.TOOL) + .searchFilter("search_filter") + .addSelect(BodyParamsForRunSchema.Select.ID) + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .skipPagination(true) + .skipPrevCursor(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .trace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .useExperimentalSearch(true) + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun stats() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runServiceAsync = client.api().v1().runs() + + val responseFuture = + runServiceAsync.stats( + RunStatsQueryParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dataSourceType(RunsFilterDataSourceTypeEnum.CURRENT) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .executionOrder(1L) + .filter("filter") + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .addGroup("string") + .isRoot(true) + .parentRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .query("query") + .addReferenceExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runType(RunTypeEnum.TOOL) + .searchFilter("search_filter") + .addSelect(RunStatsQueryParams.Select.RUN_COUNT) + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .skipPagination(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .trace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .useExperimentalSearch(true) + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/ServiceAccountServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/ServiceAccountServiceAsyncTest.kt new file mode 100644 index 00000000..43446b14 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/ServiceAccountServiceAsyncTest.kt @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.serviceaccounts.ServiceAccountServiceAccountsParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ServiceAccountServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val serviceAccountServiceAsync = client.api().v1().serviceAccounts() + + val serviceAccountFuture = + serviceAccountServiceAsync.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val serviceAccount = serviceAccountFuture.get() + serviceAccount.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveServiceAccounts() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val serviceAccountServiceAsync = client.api().v1().serviceAccounts() + + val responseFuture = serviceAccountServiceAsync.retrieveServiceAccounts() + + val response = responseFuture.get() + response.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun serviceAccounts() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val serviceAccountServiceAsync = client.api().v1().serviceAccounts() + + val responseFuture = + serviceAccountServiceAsync.serviceAccounts( + ServiceAccountServiceAccountsParams.builder() + .name("name") + .addWorkspace( + ServiceAccountServiceAccountsParams.Workspace.builder() + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/SessionServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/SessionServiceAsyncTest.kt new file mode 100644 index 00000000..93d09fb4 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/SessionServiceAsyncTest.kt @@ -0,0 +1,263 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TraceTier +import com.langsmith_api.api.models.api.v1.sessions.CustomChartsSectionRequest +import com.langsmith_api.api.models.api.v1.sessions.RunStatsGroupBy +import com.langsmith_api.api.models.api.v1.sessions.SessionCreateParams +import com.langsmith_api.api.models.api.v1.sessions.SessionDashboardParams +import com.langsmith_api.api.models.api.v1.sessions.SessionDeleteAllParams +import com.langsmith_api.api.models.api.v1.sessions.SessionListParams +import com.langsmith_api.api.models.api.v1.sessions.SessionRetrieveMetadataParams +import com.langsmith_api.api.models.api.v1.sessions.SessionRetrieveParams +import com.langsmith_api.api.models.api.v1.sessions.SessionSortableColumns +import com.langsmith_api.api.models.api.v1.sessions.SessionUpdateParams +import com.langsmith_api.api.models.api.v1.sessions.TimedeltaInput +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class SessionServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val sessionServiceAsync = client.api().v1().sessions() + + val tracerSessionWithoutVirtualFieldsFuture = + sessionServiceAsync.create( + SessionCreateParams.builder() + .upsert(true) + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .defaultDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .extra(JsonValue.from(mapOf<String, Any>())) + .name("name") + .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceTier(TraceTier.LONGLIVED) + .build() + ) + + val tracerSessionWithoutVirtualFields = tracerSessionWithoutVirtualFieldsFuture.get() + tracerSessionWithoutVirtualFields.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val sessionServiceAsync = client.api().v1().sessions() + + val tracerSessionFuture = + sessionServiceAsync.retrieve( + SessionRetrieveParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .includeStats(true) + .statsStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .accept("accept") + .build() + ) + + val tracerSession = tracerSessionFuture.get() + tracerSession.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val sessionServiceAsync = client.api().v1().sessions() + + val tracerSessionWithoutVirtualFieldsFuture = + sessionServiceAsync.update( + SessionUpdateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .defaultDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .extra(JsonValue.from(mapOf<String, Any>())) + .name("name") + .traceTier(TraceTier.LONGLIVED) + .build() + ) + + val tracerSessionWithoutVirtualFields = tracerSessionWithoutVirtualFieldsFuture.get() + tracerSessionWithoutVirtualFields.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val sessionServiceAsync = client.api().v1().sessions() + + val tracerSessionsFuture = + sessionServiceAsync.list( + SessionListParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .facets(true) + .filter("filter") + .includeStats(true) + .limit(1L) + .metadata("metadata") + .name("name") + .nameContains("name_contains") + .offset(0L) + .addReferenceDataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .referenceFree(true) + .sortBy(SessionSortableColumns.NAME) + .sortByDesc(true) + .sortByFeedbackKey("sort_by_feedback_key") + .statsStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .useApproxStats(true) + .accept("accept") + .build() + ) + + val tracerSessions = tracerSessionsFuture.get() + tracerSessions.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val sessionServiceAsync = client.api().v1().sessions() + + val sessionFuture = sessionServiceAsync.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val session = sessionFuture.get() + session.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun dashboard() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val sessionServiceAsync = client.api().v1().sessions() + + val customChartsSectionFuture = + sessionServiceAsync.dashboard( + SessionDashboardParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accept("accept") + .customChartsSectionRequest( + CustomChartsSectionRequest.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride(TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build()) + .timezone("timezone") + .build() + ) + .build() + ) + + val customChartsSection = customChartsSectionFuture.get() + customChartsSection.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun deleteAll() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val sessionServiceAsync = client.api().v1().sessions() + + val responseFuture = + sessionServiceAsync.deleteAll( + SessionDeleteAllParams.builder() + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveMetadata() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val sessionServiceAsync = client.api().v1().sessions() + + val responseFuture = + sessionServiceAsync.retrieveMetadata( + SessionRetrieveMetadataParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .k(1L) + .addMetadataKey("string") + .rootRunsOnly(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/SettingServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/SettingServiceAsyncTest.kt new file mode 100644 index 00000000..caef5086 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/SettingServiceAsyncTest.kt @@ -0,0 +1,53 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.settings.SettingHandleParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class SettingServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val settingServiceAsync = client.api().v1().settings() + + val appHubCrudTenantsTenantFuture = settingServiceAsync.list() + + val appHubCrudTenantsTenant = appHubCrudTenantsTenantFuture.get() + appHubCrudTenantsTenant.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun handle() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val settingServiceAsync = client.api().v1().settings() + + val appHubCrudTenantsTenantFuture = + settingServiceAsync.handle( + SettingHandleParams.builder().tenantHandle("tenant_handle").build() + ) + + val appHubCrudTenantsTenant = appHubCrudTenantsTenantFuture.get() + appHubCrudTenantsTenant.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/SsoServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/SsoServiceAsyncTest.kt new file mode 100644 index 00000000..e78dd7ec --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/SsoServiceAsyncTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class SsoServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val ssoServiceAsync = client.api().v1().sso() + + val ssosFuture = ssoServiceAsync.retrieve("sso_login_slug") + + val ssos = ssosFuture.get() + ssos.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/TenantServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/TenantServiceAsyncTest.kt new file mode 100644 index 00000000..9aedcabc --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/TenantServiceAsyncTest.kt @@ -0,0 +1,63 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.tenants.TenantCreateParams +import com.langsmith_api.api.models.api.v1.tenants.TenantListParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class TenantServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tenantServiceAsync = client.api().v1().tenants() + + val appSchemasTenantFuture = + tenantServiceAsync.create( + TenantCreateParams.builder() + .displayName("display_name") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .isPersonal(true) + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tenantHandle("tenant_handle") + .build() + ) + + val appSchemasTenant = appSchemasTenantFuture.get() + appSchemasTenant.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tenantServiceAsync = client.api().v1().tenants() + + val tenantForUsersFuture = + tenantServiceAsync.list( + TenantListParams.builder().includeDeleted(true).skipCreate(true).build() + ) + + val tenantForUsers = tenantForUsersFuture.get() + tenantForUsers.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/TtlSettingServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/TtlSettingServiceAsyncTest.kt new file mode 100644 index 00000000..db5a122d --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/TtlSettingServiceAsyncTest.kt @@ -0,0 +1,58 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TraceTier +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.UpsertTtlSettingsRequest +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class TtlSettingServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieveTtlSettings() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val ttlSettingServiceAsync = client.api().v1().ttlSettings() + + val ttlSettingsFuture = ttlSettingServiceAsync.retrieveTtlSettings() + + val ttlSettings = ttlSettingsFuture.get() + ttlSettings.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun updateTtlSettings() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val ttlSettingServiceAsync = client.api().v1().ttlSettings() + + val ttlSettingsFuture = + ttlSettingServiceAsync.updateTtlSettings( + UpsertTtlSettingsRequest.builder() + .defaultTraceTier(TraceTier.LONGLIVED) + .applyToAllProjects(true) + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val ttlSettings = ttlSettingsFuture.get() + ttlSettings.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/UsageLimitServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/UsageLimitServiceAsyncTest.kt new file mode 100644 index 00000000..c666fae3 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/UsageLimitServiceAsyncTest.kt @@ -0,0 +1,94 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.usagelimits.UsageLimitType +import com.langsmith_api.api.models.api.v1.usagelimits.UsageLimitUpdateUsageLimitsParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class UsageLimitServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val usageLimitServiceAsync = client.api().v1().usageLimits() + + val usageLimitFuture = usageLimitServiceAsync.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val usageLimit = usageLimitFuture.get() + usageLimit.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveOrg() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val usageLimitServiceAsync = client.api().v1().usageLimits() + + val usageLimitsFuture = usageLimitServiceAsync.retrieveOrg() + + val usageLimits = usageLimitsFuture.get() + usageLimits.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveUsageLimits() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val usageLimitServiceAsync = client.api().v1().usageLimits() + + val usageLimitsFuture = usageLimitServiceAsync.retrieveUsageLimits() + + val usageLimits = usageLimitsFuture.get() + usageLimits.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun updateUsageLimits() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val usageLimitServiceAsync = client.api().v1().usageLimits() + + val usageLimitFuture = + usageLimitServiceAsync.updateUsageLimits( + UsageLimitUpdateUsageLimitsParams.builder() + .limitType(UsageLimitType.MONTHLY_TRACES) + .limitValue(0L) + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val usageLimit = usageLimitFuture.get() + usageLimit.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/WorkspaceServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/WorkspaceServiceAsyncTest.kt new file mode 100644 index 00000000..1c4d2264 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/WorkspaceServiceAsyncTest.kt @@ -0,0 +1,102 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.workspaces.WorkspaceCreateParams +import com.langsmith_api.api.models.api.v1.workspaces.WorkspaceListParams +import com.langsmith_api.api.models.api.v1.workspaces.WorkspaceUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class WorkspaceServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val workspaceServiceAsync = client.api().v1().workspaces() + + val appSchemasTenantFuture = + workspaceServiceAsync.create( + WorkspaceCreateParams.builder() + .displayName("display_name") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tenantHandle("tenant_handle") + .build() + ) + + val appSchemasTenant = appSchemasTenantFuture.get() + appSchemasTenant.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val workspaceServiceAsync = client.api().v1().workspaces() + + val appSchemasTenantFuture = + workspaceServiceAsync.update( + WorkspaceUpdateParams.builder() + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .displayName("display_name") + .build() + ) + + val appSchemasTenant = appSchemasTenantFuture.get() + appSchemasTenant.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val workspaceServiceAsync = client.api().v1().workspaces() + + val tenantForUsersFuture = + workspaceServiceAsync.list(WorkspaceListParams.builder().includeDeleted(true).build()) + + val tenantForUsers = tenantForUsersFuture.get() + tenantForUsers.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val workspaceServiceAsync = client.api().v1().workspaces() + + val workspaceFuture = workspaceServiceAsync.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val workspace = workspaceFuture.get() + workspace.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/annotationqueues/RunServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/annotationqueues/RunServiceAsyncTest.kt new file mode 100644 index 00000000..4d5fe883 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/annotationqueues/RunServiceAsyncTest.kt @@ -0,0 +1,121 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.annotationqueues + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.annotationqueues.runs.RunCreateParams +import com.langsmith_api.api.models.api.v1.annotationqueues.runs.RunDeleteParams +import com.langsmith_api.api.models.api.v1.annotationqueues.runs.RunListParams +import com.langsmith_api.api.models.api.v1.annotationqueues.runs.RunUpdateParams +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class RunServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runServiceAsync = client.api().v1().annotationQueues().runs() + + val runsFuture = + runServiceAsync.create( + RunCreateParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addBody("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val runs = runsFuture.get() + runs.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runServiceAsync = client.api().v1().annotationQueues().runs() + + val runFuture = + runServiceAsync.update( + RunUpdateParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .queueRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lastReviewedTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + val run = runFuture.get() + run.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runServiceAsync = client.api().v1().annotationQueues().runs() + + val runSchemaWithAnnotationQueueInfosFuture = + runServiceAsync.list( + RunListParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .archived(true) + .includeStats(true) + .limit(1L) + .offset(0L) + .build() + ) + + val runSchemaWithAnnotationQueueInfos = runSchemaWithAnnotationQueueInfosFuture.get() + runSchemaWithAnnotationQueueInfos.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runServiceAsync = client.api().v1().annotationQueues().runs() + + val runFuture = + runServiceAsync.delete( + RunDeleteParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .deleteAll(true) + .addExcludeRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val run = runFuture.get() + run.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/apikey/CurrentServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/apikey/CurrentServiceAsyncTest.kt new file mode 100644 index 00000000..8cef8fea --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/apikey/CurrentServiceAsyncTest.kt @@ -0,0 +1,81 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.apikey + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyCreateRequest +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CurrentServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val currentServiceAsync = client.api().v1().apiKey().current() + + val apiKeyCreateResponseFuture = + currentServiceAsync.create( + ApiKeyCreateRequest.builder() + .defaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val apiKeyCreateResponse = apiKeyCreateResponseFuture.get() + apiKeyCreateResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val currentServiceAsync = client.api().v1().apiKey().current() + + val apiKeyGetResponsesFuture = currentServiceAsync.list() + + val apiKeyGetResponses = apiKeyGetResponsesFuture.get() + apiKeyGetResponses.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val currentServiceAsync = client.api().v1().apiKey().current() + + val apiKeyGetResponseFuture = + currentServiceAsync.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val apiKeyGetResponse = apiKeyGetResponseFuture.get() + apiKeyGetResponse.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/bulkexports/DestinationServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/bulkexports/DestinationServiceAsyncTest.kt new file mode 100644 index 00000000..6def034f --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/bulkexports/DestinationServiceAsyncTest.kt @@ -0,0 +1,94 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.bulkexports + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.bulkexports.destinations.BulkExportDestinationS3Config +import com.langsmith_api.api.models.api.v1.bulkexports.destinations.BulkExportDestinationType +import com.langsmith_api.api.models.api.v1.bulkexports.destinations.DestinationCreateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class DestinationServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val destinationServiceAsync = client.api().v1().bulkExports().destinations() + + val bulkExportDestinationFuture = + destinationServiceAsync.create( + DestinationCreateParams.builder() + .config( + BulkExportDestinationS3Config.builder() + .bucketName("xxx") + .endpointUrl("endpoint_url") + .prefix("prefix") + .region("x") + .s3AdditionalKwargs(JsonValue.from(mapOf<String, Any>())) + .build() + ) + .displayName("display_name") + .credentials( + DestinationCreateParams.Credentials.builder() + .accessKeyId("x") + .secretAccessKey("x") + .sessionToken("session_token") + .build() + ) + .destinationType(BulkExportDestinationType.S3) + .build() + ) + + val bulkExportDestination = bulkExportDestinationFuture.get() + bulkExportDestination.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val destinationServiceAsync = client.api().v1().bulkExports().destinations() + + val bulkExportDestinationFuture = + destinationServiceAsync.retrieve("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val bulkExportDestination = bulkExportDestinationFuture.get() + bulkExportDestination.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val destinationServiceAsync = client.api().v1().bulkExports().destinations() + + val bulkExportDestinationsFuture = destinationServiceAsync.list() + + val bulkExportDestinations = bulkExportDestinationsFuture.get() + bulkExportDestinations.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/bulkexports/RunServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/bulkexports/RunServiceAsyncTest.kt new file mode 100644 index 00000000..5bf3e2ba --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/bulkexports/RunServiceAsyncTest.kt @@ -0,0 +1,56 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.bulkexports + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.bulkexports.runs.RunRetrieveParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class RunServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runServiceAsync = client.api().v1().bulkExports().runs() + + val bulkExportRunFuture = + runServiceAsync.retrieve( + RunRetrieveParams.builder() + .bulkExportId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val bulkExportRun = bulkExportRunFuture.get() + bulkExportRun.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runServiceAsync = client.api().v1().bulkExports().runs() + + val bulkExportRunsFuture = runServiceAsync.list("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val bulkExportRuns = bulkExportRunsFuture.get() + bulkExportRuns.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/charts/SectionServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/charts/SectionServiceAsyncTest.kt new file mode 100644 index 00000000..09fc734d --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/charts/SectionServiceAsyncTest.kt @@ -0,0 +1,144 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.charts + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.charts.section.CustomChartsSectionCreate +import com.langsmith_api.api.models.api.v1.charts.section.CustomChartsSectionUpdate +import com.langsmith_api.api.models.api.v1.charts.section.SectionCloneParams +import com.langsmith_api.api.models.api.v1.charts.section.SectionListParams +import com.langsmith_api.api.models.api.v1.charts.section.SectionUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class SectionServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val sectionServiceAsync = client.api().v1().charts().section() + + val customChartsSectionResponseFuture = + sectionServiceAsync.create( + CustomChartsSectionCreate.builder() + .title("title") + .description("description") + .index(0L) + .build() + ) + + val customChartsSectionResponse = customChartsSectionResponseFuture.get() + customChartsSectionResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val sectionServiceAsync = client.api().v1().charts().section() + + val customChartsSectionResponseFuture = + sectionServiceAsync.update( + SectionUpdateParams.builder() + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .customChartsSectionUpdate( + CustomChartsSectionUpdate.builder() + .description("string") + .index(0L) + .title("string") + .build() + ) + .build() + ) + + val customChartsSectionResponse = customChartsSectionResponseFuture.get() + customChartsSectionResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val sectionServiceAsync = client.api().v1().charts().section() + + val customChartsSectionResponsesFuture = + sectionServiceAsync.list( + SectionListParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .offset(0L) + .sortBy("sort_by") + .sortByDesc(true) + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .titleContains("title_contains") + .build() + ) + + val customChartsSectionResponses = customChartsSectionResponsesFuture.get() + customChartsSectionResponses.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val sectionServiceAsync = client.api().v1().charts().section() + + val sectionFuture = sectionServiceAsync.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val section = sectionFuture.get() + section.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun clone() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val sectionServiceAsync = client.api().v1().charts().section() + + val customChartsSectionResponseFuture = + sectionServiceAsync.clone( + SectionCloneParams.builder() + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val customChartsSectionResponse = customChartsSectionResponseFuture.get() + customChartsSectionResponse.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/comments/LikeServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/comments/LikeServiceAsyncTest.kt new file mode 100644 index 00000000..1e179d17 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/comments/LikeServiceAsyncTest.kt @@ -0,0 +1,65 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.comments + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.comments.like.LikeCreateParams +import com.langsmith_api.api.models.api.v1.comments.like.LikeDeleteAllParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class LikeServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val likeServiceAsync = client.api().v1().comments().like() + + val likeFuture = + likeServiceAsync.create( + LikeCreateParams.builder() + .owner("owner") + .repo("repo") + .parentCommentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val like = likeFuture.get() + like.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun deleteAll() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val likeServiceAsync = client.api().v1().comments().like() + + val responseFuture = + likeServiceAsync.deleteAll( + LikeDeleteAllParams.builder() + .owner("owner") + .repo("repo") + .parentCommentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/ComparativeServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/ComparativeServiceAsyncTest.kt new file mode 100644 index 00000000..2760c22a --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/ComparativeServiceAsyncTest.kt @@ -0,0 +1,97 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.datasets + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.datasets.comparative.ComparativeCreateParams +import com.langsmith_api.api.models.api.v1.datasets.comparative.ComparativeListParams +import com.langsmith_api.api.models.api.v1.datasets.comparative.SortByComparativeExperimentColumn +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ComparativeServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val comparativeServiceAsync = client.api().v1().datasets().comparative() + + val comparativeFuture = + comparativeServiceAsync.create( + ComparativeCreateParams.builder() + .addExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .extra(JsonValue.from(mapOf<String, Any>())) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .build() + ) + + val comparative = comparativeFuture.get() + comparative.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val comparativeServiceAsync = client.api().v1().datasets().comparative() + + val comparativesFuture = + comparativeServiceAsync.list( + ComparativeListParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .name("name") + .nameContains("name_contains") + .offset(0L) + .sortBy(SortByComparativeExperimentColumn.NAME) + .sortByDesc(true) + .build() + ) + + val comparatives = comparativesFuture.get() + comparatives.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val comparativeServiceAsync = client.api().v1().datasets().comparative() + + val comparativeFuture = + comparativeServiceAsync.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val comparative = comparativeFuture.get() + comparative.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/ExperimentServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/ExperimentServiceAsyncTest.kt new file mode 100644 index 00000000..dcd9f8cb --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/ExperimentServiceAsyncTest.kt @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.datasets + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.datasets.experiments.ExperimentGroupedParams +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ExperimentServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun grouped() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val experimentServiceAsync = client.api().v1().datasets().experiments() + + val responseFuture = + experimentServiceAsync.grouped( + ExperimentGroupedParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metadataKey("x") + .datasetVersion("dataset_version") + .experimentLimit(1L) + .filter("filter") + .nameContains("name_contains") + .statsStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .useApproxStats(true) + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/GroupServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/GroupServiceAsyncTest.kt new file mode 100644 index 00000000..8c35e2f3 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/GroupServiceAsyncTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.datasets + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.datasets.group.GroupRunsParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class GroupServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun runs() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val groupServiceAsync = client.api().v1().datasets().group() + + val responseFuture = + groupServiceAsync.runs( + GroupRunsParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupBy(GroupRunsParams.GroupBy.RUN_METADATA) + .metadataKey("metadata_key") + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .offset(0L) + .perGroupLimit(1L) + .preview(true) + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/IndexServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/IndexServiceAsyncTest.kt new file mode 100644 index 00000000..74bda57f --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/IndexServiceAsyncTest.kt @@ -0,0 +1,92 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.datasets + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.datasets.index.IndexCreateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class IndexServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val indexServiceAsync = client.api().v1().datasets().index() + + val indexFuture = + indexServiceAsync.create( + IndexCreateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tag("tag") + .build() + ) + + val index = indexFuture.get() + index.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val indexServiceAsync = client.api().v1().datasets().index() + + val indicesFuture = indexServiceAsync.list("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val indices = indicesFuture.get() + indices.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun deleteAll() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val indexServiceAsync = client.api().v1().datasets().index() + + val responseFuture = indexServiceAsync.deleteAll("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun sync() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val indexServiceAsync = client.api().v1().datasets().index() + + val responseFuture = indexServiceAsync.sync("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/PlaygroundExperimentServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/PlaygroundExperimentServiceAsyncTest.kt new file mode 100644 index 00000000..ab73f01e --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/PlaygroundExperimentServiceAsyncTest.kt @@ -0,0 +1,131 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.datasets + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.datasets.playgroundexperiment.PlaygroundExperimentBatchParams +import com.langsmith_api.api.models.api.v1.datasets.playgroundexperiment.PlaygroundExperimentStreamParams +import com.langsmith_api.api.models.api.v1.datasets.playgroundexperiment.RunnableConfig +import com.langsmith_api.api.models.api.v1.datasets.playgroundexperiment.RunnerContextEnum +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class PlaygroundExperimentServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun batch() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val playgroundExperimentServiceAsync = client.api().v1().datasets().playgroundExperiment() + + val responseFuture = + playgroundExperimentServiceAsync.batch( + PlaygroundExperimentBatchParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifest(JsonValue.from(mapOf<String, Any>())) + .options( + RunnableConfig.builder() + .callbacksOfJsonValues(listOf(JsonValue.from(mapOf<String, Any>()))) + .configurable(JsonValue.from(mapOf<String, Any>())) + .maxConcurrency(0L) + .metadata(JsonValue.from(mapOf<String, Any>())) + .recursionLimit(0L) + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runName("run_name") + .addTag("string") + .build() + ) + .projectName("project_name") + .secrets( + PlaygroundExperimentBatchParams.Secrets.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .batchSize(1L) + .commit("commit") + .addDatasetSplit("string") + .addEvaluatorRule("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .owner("owner") + .parallelToolCalls(true) + .repetitions(1L) + .repoHandle("repo_handle") + .repoId("repo_id") + .requestsPerSecond(0L) + .runId("run_id") + .runnerContext(RunnerContextEnum.LANGSMITH_UI) + .toolChoice("tool_choice") + .addTool(JsonValue.from(mapOf<String, Any>())) + .useOrFallbackToWorkspaceSecrets(true) + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun stream() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val playgroundExperimentServiceAsync = client.api().v1().datasets().playgroundExperiment() + + val responseFuture = + playgroundExperimentServiceAsync.stream( + PlaygroundExperimentStreamParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifest(JsonValue.from(mapOf<String, Any>())) + .options( + RunnableConfig.builder() + .callbacksOfJsonValues(listOf(JsonValue.from(mapOf<String, Any>()))) + .configurable(JsonValue.from(mapOf<String, Any>())) + .maxConcurrency(0L) + .metadata(JsonValue.from(mapOf<String, Any>())) + .recursionLimit(0L) + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runName("run_name") + .addTag("string") + .build() + ) + .projectName("project_name") + .secrets( + PlaygroundExperimentStreamParams.Secrets.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .commit("commit") + .addDatasetSplit("string") + .addEvaluatorRule("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .owner("owner") + .parallelToolCalls(true) + .repetitions(1L) + .repoHandle("repo_handle") + .repoId("repo_id") + .requestsPerSecond(0L) + .runId("run_id") + .runnerContext(RunnerContextEnum.LANGSMITH_UI) + .toolChoice("tool_choice") + .addTool(JsonValue.from(mapOf<String, Any>())) + .useOrFallbackToWorkspaceSecrets(true) + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/RunServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/RunServiceAsyncTest.kt new file mode 100644 index 00000000..b6ae6fd0 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/RunServiceAsyncTest.kt @@ -0,0 +1,103 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.datasets + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.datasets.runs.QueryExampleSchemaWithRuns +import com.langsmith_api.api.models.api.v1.datasets.runs.QueryFeedbackDelta +import com.langsmith_api.api.models.api.v1.datasets.runs.RunCreateParams +import com.langsmith_api.api.models.api.v1.datasets.runs.RunDeltaParams +import kotlin.jvm.optionals.getOrNull +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class RunServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runServiceAsync = client.api().v1().datasets().runs() + + val runFuture = + runServiceAsync.create( + RunCreateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .queryFormat("format") + .queryExampleSchemaWithRuns( + QueryExampleSchemaWithRuns.builder() + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .filters( + QueryExampleSchemaWithRuns.Filters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + ) + .format(QueryExampleSchemaWithRuns.Format.CSV) + .limit(1L) + .offset(0L) + .preview(true) + .sortParams( + QueryExampleSchemaWithRuns.SortParams.builder() + .sortBy("sort_by") + .sortOrder(QueryExampleSchemaWithRuns.SortParams.SortOrder.ASC) + .build() + ) + .build() + ) + .build() + ) + + val run = runFuture.get() + val unwrappedRun = run.getOrNull() + unwrappedRun?.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delta() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runServiceAsync = client.api().v1().datasets().runs() + + val sessionFeedbackDeltaFuture = + runServiceAsync.delta( + RunDeltaParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .queryFeedbackDelta( + QueryFeedbackDelta.builder() + .baselineSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addComparisonSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackKey("feedback_key") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .filters( + QueryFeedbackDelta.Filters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + ) + .limit(1L) + .offset(0L) + .build() + ) + .build() + ) + + val sessionFeedbackDelta = sessionFeedbackDeltaFuture.get() + sessionFeedbackDelta.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/ShareServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/ShareServiceAsyncTest.kt new file mode 100644 index 00000000..ed2ae82f --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/ShareServiceAsyncTest.kt @@ -0,0 +1,77 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.datasets + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.datasets.share.ShareCreateParams +import kotlin.jvm.optionals.getOrNull +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ShareServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val shareServiceAsync = client.api().v1().datasets().share() + + val datasetShareSchemaFuture = + shareServiceAsync.create( + ShareCreateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .shareProjects(true) + .build() + ) + + val datasetShareSchema = datasetShareSchemaFuture.get() + datasetShareSchema.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val shareServiceAsync = client.api().v1().datasets().share() + + val datasetShareSchemaFuture = + shareServiceAsync.list("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val datasetShareSchema = datasetShareSchemaFuture.get() + val unwrappedDatasetShareSchema = datasetShareSchema.getOrNull() + unwrappedDatasetShareSchema?.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun deleteAll() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val shareServiceAsync = client.api().v1().datasets().share() + + val responseFuture = shareServiceAsync.deleteAll("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/SplitServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/SplitServiceAsyncTest.kt new file mode 100644 index 00000000..d533ee79 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/SplitServiceAsyncTest.kt @@ -0,0 +1,64 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.datasets + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.datasets.splits.SplitCreateParams +import com.langsmith_api.api.models.api.v1.datasets.splits.SplitListParams +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class SplitServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val splitServiceAsync = client.api().v1().datasets().splits() + + val splitsFuture = + splitServiceAsync.create( + SplitCreateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .splitName("split_name") + .remove(true) + .build() + ) + + val splits = splitsFuture.get() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val splitServiceAsync = client.api().v1().datasets().splits() + + val splitsFuture = + splitServiceAsync.list( + SplitListParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + val splits = splitsFuture.get() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/VersionServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/VersionServiceAsyncTest.kt new file mode 100644 index 00000000..c45dd4a1 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/datasets/VersionServiceAsyncTest.kt @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.datasets + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.datasets.versions.VersionListParams +import com.langsmith_api.api.models.api.v1.datasets.versions.VersionRetrieveDiffParams +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class VersionServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val versionServiceAsync = client.api().v1().datasets().versions() + + val datasetVersionsFuture = + versionServiceAsync.list( + VersionListParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .example("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .offset(0L) + .search("search") + .build() + ) + + val datasetVersions = datasetVersionsFuture.get() + datasetVersions.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveDiff() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val versionServiceAsync = client.api().v1().datasets().versions() + + val responseFuture = + versionServiceAsync.retrieveDiff( + VersionRetrieveDiffParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .fromVersion(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .toVersion(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/examples/BulkServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/examples/BulkServiceAsyncTest.kt new file mode 100644 index 00000000..99fb5b69 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/examples/BulkServiceAsyncTest.kt @@ -0,0 +1,77 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.examples + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.examples.AttachmentsOperations +import com.langsmith_api.api.models.api.v1.examples.bulk.BulkPatchAllParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class BulkServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val bulkServiceAsync = client.api().v1().examples().bulk() + + val bulkFuture = bulkServiceAsync.create() + + val bulk = bulkFuture.get() + bulk.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun patchAll() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val bulkServiceAsync = client.api().v1().examples().bulk() + + val responseFuture = + bulkServiceAsync.patchAll( + BulkPatchAllParams.builder() + .addBody( + BulkPatchAllParams.Body.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .attachmentsOperations( + AttachmentsOperations.builder() + .rename( + AttachmentsOperations.Rename.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addRetain("string") + .build() + ) + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .metadata(JsonValue.from(mapOf<String, Any>())) + .outputs(JsonValue.from(mapOf<String, Any>())) + .overwrite(true) + .splitOfStrings(listOf("string")) + .build() + ) + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/examples/ValidateServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/examples/ValidateServiceAsyncTest.kt new file mode 100644 index 00000000..ec20b489 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/examples/ValidateServiceAsyncTest.kt @@ -0,0 +1,49 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.examples + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ValidateServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val validateServiceAsync = client.api().v1().examples().validate() + + val exampleValidationResultFuture = validateServiceAsync.create() + + val exampleValidationResult = exampleValidationResultFuture.get() + exampleValidationResult.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun bulk() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val validateServiceAsync = client.api().v1().examples().validate() + + val exampleValidationResultsFuture = validateServiceAsync.bulk() + + val exampleValidationResults = exampleValidationResultsFuture.get() + exampleValidationResults.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/feedback/FormulaServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/feedback/FormulaServiceAsyncTest.kt new file mode 100644 index 00000000..257bf3cc --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/feedback/FormulaServiceAsyncTest.kt @@ -0,0 +1,137 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.feedback + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.feedback.formulas.FeedbackFormulaWeightedVariable +import com.langsmith_api.api.models.api.v1.feedback.formulas.FormulaCreateParams +import com.langsmith_api.api.models.api.v1.feedback.formulas.FormulaListParams +import com.langsmith_api.api.models.api.v1.feedback.formulas.FormulaUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class FormulaServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val formulaServiceAsync = client.api().v1().feedback().formulas() + + val feedbackFormulaFuture = + formulaServiceAsync.create( + FormulaCreateParams.builder() + .aggregationType(FormulaCreateParams.AggregationType.SUM) + .feedbackKey("feedback_key") + .addFormulaPart( + FeedbackFormulaWeightedVariable.builder().key("x").weight(0.0).build() + ) + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val feedbackFormula = feedbackFormulaFuture.get() + feedbackFormula.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val formulaServiceAsync = client.api().v1().feedback().formulas() + + val feedbackFormulaFuture = + formulaServiceAsync.retrieve("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val feedbackFormula = feedbackFormulaFuture.get() + feedbackFormula.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val formulaServiceAsync = client.api().v1().feedback().formulas() + + val feedbackFormulaFuture = + formulaServiceAsync.update( + FormulaUpdateParams.builder() + .feedbackFormulaId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .aggregationType(FormulaUpdateParams.AggregationType.SUM) + .feedbackKey("feedback_key") + .addFormulaPart( + FeedbackFormulaWeightedVariable.builder().key("x").weight(0.0).build() + ) + .build() + ) + + val feedbackFormula = feedbackFormulaFuture.get() + feedbackFormula.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val formulaServiceAsync = client.api().v1().feedback().formulas() + + val feedbackFormulasFuture = + formulaServiceAsync.list( + FormulaListParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .offset(0L) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val feedbackFormulas = feedbackFormulasFuture.get() + feedbackFormulas.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val formulaServiceAsync = client.api().v1().feedback().formulas() + + val formulaFuture = formulaServiceAsync.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val formula = formulaFuture.get() + formula.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/feedback/TokenServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/feedback/TokenServiceAsyncTest.kt new file mode 100644 index 00000000..994b5f9b --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/feedback/TokenServiceAsyncTest.kt @@ -0,0 +1,143 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.feedback + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.feedback.tokens.FeedbackIngestTokenCreateSchema +import com.langsmith_api.api.models.api.v1.feedback.tokens.TokenCreateParams +import com.langsmith_api.api.models.api.v1.feedback.tokens.TokenListParams +import com.langsmith_api.api.models.api.v1.feedback.tokens.TokenRetrieveParams +import com.langsmith_api.api.models.api.v1.feedback.tokens.TokenUpdateParams +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfig +import com.langsmith_api.api.models.api.v1.sessions.TimedeltaInput +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class TokenServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tokenServiceAsync = client.api().v1().feedback().tokens() + + val tokenFuture = + tokenServiceAsync.create( + TokenCreateParams.builder() + .body( + FeedbackIngestTokenCreateSchema.builder() + .feedbackKey("feedback_key") + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiresIn( + TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build() + ) + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder() + .value(0.0) + .label("x") + .build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .build() + ) + .build() + ) + + val token = tokenFuture.get() + token.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tokenServiceAsync = client.api().v1().feedback().tokens() + + val tokenFuture = + tokenServiceAsync.retrieve( + TokenRetrieveParams.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") + .correction("correction") + .score(0.0) + .value(0.0) + .build() + ) + + val token = tokenFuture.get() + token.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tokenServiceAsync = client.api().v1().feedback().tokens() + + val tokenFuture = + tokenServiceAsync.update( + TokenUpdateParams.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") + .correction(JsonValue.from(mapOf<String, Any>())) + .metadata(JsonValue.from(mapOf<String, Any>())) + .score(0.0) + .value(0.0) + .build() + ) + + val token = tokenFuture.get() + token.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tokenServiceAsync = client.api().v1().feedback().tokens() + + val feedbackIngestTokenSchemataFuture = + tokenServiceAsync.list( + TokenListParams.builder().runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + ) + + val feedbackIngestTokenSchemata = feedbackIngestTokenSchemataFuture.get() + feedbackIngestTokenSchemata.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/me/OnboardingStateServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/me/OnboardingStateServiceAsyncTest.kt new file mode 100644 index 00000000..9ebd0a67 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/me/OnboardingStateServiceAsyncTest.kt @@ -0,0 +1,67 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.me + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class OnboardingStateServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val onboardingStateServiceAsync = client.api().v1().me().onboardingState() + + val userOnboardingStateResponseFuture = onboardingStateServiceAsync.create() + + val userOnboardingStateResponse = userOnboardingStateResponseFuture.get() + userOnboardingStateResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val onboardingStateServiceAsync = client.api().v1().me().onboardingState() + + val userOnboardingStateResponseFuture = onboardingStateServiceAsync.update("field") + + val userOnboardingStateResponse = userOnboardingStateResponseFuture.get() + userOnboardingStateResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val onboardingStateServiceAsync = client.api().v1().me().onboardingState() + + val userOnboardingStateResponseFuture = onboardingStateServiceAsync.list() + + val userOnboardingStateResponse = userOnboardingStateResponseFuture.get() + userOnboardingStateResponse.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgcharts/SectionServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgcharts/SectionServiceAsyncTest.kt new file mode 100644 index 00000000..e4ed4cb2 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgcharts/SectionServiceAsyncTest.kt @@ -0,0 +1,119 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgcharts + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.charts.section.CustomChartsSectionCreate +import com.langsmith_api.api.models.api.v1.charts.section.CustomChartsSectionUpdate +import com.langsmith_api.api.models.api.v1.orgcharts.section.SectionListParams +import com.langsmith_api.api.models.api.v1.orgcharts.section.SectionUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class SectionServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val sectionServiceAsync = client.api().v1().orgCharts().section() + + val customChartsSectionResponseFuture = + sectionServiceAsync.create( + CustomChartsSectionCreate.builder() + .title("title") + .description("description") + .index(0L) + .build() + ) + + val customChartsSectionResponse = customChartsSectionResponseFuture.get() + customChartsSectionResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val sectionServiceAsync = client.api().v1().orgCharts().section() + + val customChartsSectionResponseFuture = + sectionServiceAsync.update( + SectionUpdateParams.builder() + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .customChartsSectionUpdate( + CustomChartsSectionUpdate.builder() + .description("string") + .index(0L) + .title("string") + .build() + ) + .build() + ) + + val customChartsSectionResponse = customChartsSectionResponseFuture.get() + customChartsSectionResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val sectionServiceAsync = client.api().v1().orgCharts().section() + + val customChartsSectionResponsesFuture = + sectionServiceAsync.list( + SectionListParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .offset(0L) + .sortBy("sort_by") + .sortByDesc(true) + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .titleContains("title_contains") + .build() + ) + + val customChartsSectionResponses = customChartsSectionResponsesFuture.get() + customChartsSectionResponses.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val sectionServiceAsync = client.api().v1().orgCharts().section() + + val sectionFuture = sectionServiceAsync.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val section = sectionFuture.get() + section.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/CurrentServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/CurrentServiceAsyncTest.kt new file mode 100644 index 00000000..ac413141 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/CurrentServiceAsyncTest.kt @@ -0,0 +1,247 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentConfirmCheckoutSessionCompletionParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentPaymentMethodParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentPlanParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentRetrieveDashboardParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentStripeAccountLinksParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentStripeCheckoutSessionParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentUpdateLoginMethodsParams +import com.langsmith_api.api.models.api.v1.orgs.current.StripeCustomerAddress +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CurrentServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val currentServiceAsync = client.api().v1().orgs().current() + + val currentsFuture = currentServiceAsync.list() + + val currents = currentsFuture.get() + currents.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun confirmCheckoutSessionCompletion() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val currentServiceAsync = client.api().v1().orgs().current() + + val responseFuture = + currentServiceAsync.confirmCheckoutSessionCompletion( + CurrentConfirmCheckoutSessionCompletionParams.builder() + .stripeSessionId("stripe_session_id") + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun paymentMethod() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val currentServiceAsync = client.api().v1().orgs().current() + + val responseFuture = + currentServiceAsync.paymentMethod( + CurrentPaymentMethodParams.builder() + .billingInfo( + CurrentPaymentMethodParams.BillingInfo.builder() + .address( + StripeCustomerAddress.builder() + .city("city") + .country("country") + .line1("line1") + .postalCode("postal_code") + .line2("line2") + .state("state") + .build() + ) + .name("name") + .build() + ) + .setupIntent("setup_intent") + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun plan() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val currentServiceAsync = client.api().v1().orgs().current() + + val responseFuture = + currentServiceAsync.plan( + CurrentPlanParams.builder().tier(CurrentPlanParams.Tier.DISABLED).build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveDashboard() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val currentServiceAsync = client.api().v1().orgs().current() + + val responseFuture = + currentServiceAsync.retrieveDashboard( + CurrentRetrieveDashboardParams.builder() + .colorScheme(CurrentRetrieveDashboardParams.ColorScheme.LIGHT) + .type(CurrentRetrieveDashboardParams.Type.INVOICES) + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun setDefaultSsoProvision() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val currentServiceAsync = client.api().v1().orgs().current() + + val responseFuture = currentServiceAsync.setDefaultSsoProvision() + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun setup() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val currentServiceAsync = client.api().v1().orgs().current() + + val responseFuture = currentServiceAsync.setup() + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun stripeAccountLinks() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val currentServiceAsync = client.api().v1().orgs().current() + + val responseFuture = + currentServiceAsync.stripeAccountLinks( + CurrentStripeAccountLinksParams.builder().successPath("success_path").build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun stripeCheckoutSession() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val currentServiceAsync = client.api().v1().orgs().current() + + val responseFuture = + currentServiceAsync.stripeCheckoutSession( + CurrentStripeCheckoutSessionParams.builder() + .amountCents(0L) + .successPath("success_path") + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun updateLoginMethods() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val currentServiceAsync = client.api().v1().orgs().current() + + val responseFuture = + currentServiceAsync.updateLoginMethods( + CurrentUpdateLoginMethodsParams.builder().ssoOnly(true).build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/MemberServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/MemberServiceAsyncTest.kt new file mode 100644 index 00000000..a1faf1e7 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/MemberServiceAsyncTest.kt @@ -0,0 +1,35 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.orgs.members.MemberUpdateBasicParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class MemberServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun updateBasic() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val memberServiceAsync = client.api().v1().orgs().members() + + val responseFuture = + memberServiceAsync.updateBasic( + MemberUpdateBasicParams.builder().fullName("full_name").password("password").build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/PendingServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/PendingServiceAsyncTest.kt new file mode 100644 index 00000000..2bba7de2 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/PendingServiceAsyncTest.kt @@ -0,0 +1,67 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class PendingServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val pendingServiceAsync = client.api().v1().orgs().pending() + + val organizationPgSchemaSlimsFuture = pendingServiceAsync.list() + + val organizationPgSchemaSlims = organizationPgSchemaSlimsFuture.get() + organizationPgSchemaSlims.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val pendingServiceAsync = client.api().v1().orgs().pending() + + val pendingFuture = pendingServiceAsync.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val pending = pendingFuture.get() + pending.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun claim() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val pendingServiceAsync = client.api().v1().orgs().pending() + + val identityFuture = pendingServiceAsync.claim("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val identity = identityFuture.get() + identity.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/TtlSettingServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/TtlSettingServiceAsyncTest.kt new file mode 100644 index 00000000..42a5f169 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/TtlSettingServiceAsyncTest.kt @@ -0,0 +1,58 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TraceTier +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.UpsertTtlSettingsRequest +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class TtlSettingServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieveTtlSettings() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val ttlSettingServiceAsync = client.api().v1().orgs().ttlSettings() + + val ttlSettingsFuture = ttlSettingServiceAsync.retrieveTtlSettings() + + val ttlSettings = ttlSettingsFuture.get() + ttlSettings.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun updateTtlSettings() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val ttlSettingServiceAsync = client.api().v1().orgs().ttlSettings() + + val ttlSettingsFuture = + ttlSettingServiceAsync.updateTtlSettings( + UpsertTtlSettingsRequest.builder() + .defaultTraceTier(TraceTier.LONGLIVED) + .applyToAllProjects(true) + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val ttlSettings = ttlSettingsFuture.get() + ttlSettings.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/BillingServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/BillingServiceAsyncTest.kt new file mode 100644 index 00000000..a540997a --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/BillingServiceAsyncTest.kt @@ -0,0 +1,58 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs.current + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.orgs.current.billing.BillingRetrieveUsageParams +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class BillingServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val billingServiceAsync = client.api().v1().orgs().current().billing() + + val billingsFuture = billingServiceAsync.list() + + val billings = billingsFuture.get() + billings.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveUsage() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val billingServiceAsync = client.api().v1().orgs().current().billing() + + val responseFuture = + billingServiceAsync.retrieveUsage( + BillingRetrieveUsageParams.builder() + .endingBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startingOn(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .onCurrentPlan(true) + .build() + ) + + val response = responseFuture.get() + response.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/BusinessInfoServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/BusinessInfoServiceAsyncTest.kt new file mode 100644 index 00000000..ea0f973c --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/BusinessInfoServiceAsyncTest.kt @@ -0,0 +1,75 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs.current + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.orgs.current.StripeCustomerAddress +import com.langsmith_api.api.models.api.v1.orgs.current.businessinfo.BusinessInfoBusinessInfoParams +import com.langsmith_api.api.models.api.v1.orgs.current.businessinfo.StripeBusinessBillingInfo +import com.langsmith_api.api.models.api.v1.orgs.current.businessinfo.StripeTaxId +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class BusinessInfoServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun businessInfo() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val businessInfoServiceAsync = client.api().v1().orgs().current().businessInfo() + + val responseFuture = + businessInfoServiceAsync.businessInfo( + BusinessInfoBusinessInfoParams.builder() + .companyInfo( + StripeBusinessBillingInfo.builder() + .name("name") + .address( + StripeCustomerAddress.builder() + .city("city") + .country("country") + .line1("line1") + .postalCode("postal_code") + .line2("line2") + .state("state") + .build() + ) + .build() + ) + .invoiceEmail("invoice_email") + .isBusiness(true) + .taxId(StripeTaxId.builder().type("type").value("value").build()) + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveBusinessInfo() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val businessInfoServiceAsync = client.api().v1().orgs().current().businessInfo() + + val responseFuture = businessInfoServiceAsync.retrieveBusinessInfo() + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/InfoServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/InfoServiceAsyncTest.kt new file mode 100644 index 00000000..2ae333ea --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/InfoServiceAsyncTest.kt @@ -0,0 +1,60 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs.current + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.orgs.current.info.InfoPatchAllParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class InfoServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val infoServiceAsync = client.api().v1().orgs().current().info() + + val organizationInfoFuture = infoServiceAsync.list() + + val organizationInfo = organizationInfoFuture.get() + organizationInfo.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun patchAll() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val infoServiceAsync = client.api().v1().orgs().current().info() + + val organizationInfoFuture = + infoServiceAsync.patchAll( + InfoPatchAllParams.builder() + .displayName("display_name") + .jitProvisioningEnabled(true) + .patCreationDisabled(true) + .publicSharingDisabled(true) + .unshareAll(true) + .workspaceAdminCanInviteToOrg(true) + .build() + ) + + val organizationInfo = organizationInfoFuture.get() + organizationInfo.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/MemberServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/MemberServiceAsyncTest.kt new file mode 100644 index 00000000..5c4e6056 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/MemberServiceAsyncTest.kt @@ -0,0 +1,168 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs.current + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberBatchParams +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberRetrieveActiveParams +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberUpdateParams +import com.langsmith_api.api.models.api.v1.orgs.current.members.PendingIdentityCreate +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class MemberServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val memberServiceAsync = client.api().v1().orgs().current().members() + + val pendingIdentityFuture = + memberServiceAsync.create( + PendingIdentityCreate.builder() + .email("email") + .fullName("full_name") + .password("password") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .workspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val pendingIdentity = pendingIdentityFuture.get() + pendingIdentity.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val memberServiceAsync = client.api().v1().orgs().current().members() + + val memberFuture = + memberServiceAsync.update( + MemberUpdateParams.builder() + .identityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .fullName("full_name") + .password("password") + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val member = memberFuture.get() + member.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val memberServiceAsync = client.api().v1().orgs().current().members() + + val membersFuture = memberServiceAsync.list() + + val members = membersFuture.get() + members.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val memberServiceAsync = client.api().v1().orgs().current().members() + + val memberFuture = memberServiceAsync.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val member = memberFuture.get() + member.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun batch() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val memberServiceAsync = client.api().v1().orgs().current().members() + + val pendingIdentitiesFuture = + memberServiceAsync.batch( + MemberBatchParams.builder() + .addBody( + PendingIdentityCreate.builder() + .email("email") + .fullName("full_name") + .password("password") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .workspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + ) + + val pendingIdentities = pendingIdentitiesFuture.get() + pendingIdentities.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveActive() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val memberServiceAsync = client.api().v1().orgs().current().members() + + val orgMemberIdentitiesFuture = + memberServiceAsync.retrieveActive( + MemberRetrieveActiveParams.builder() + .addEmail("string") + .limit(1L) + .addLsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .offset(0L) + .addUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val orgMemberIdentities = orgMemberIdentitiesFuture.get() + orgMemberIdentities.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/PersonalAccessTokenServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/PersonalAccessTokenServiceAsyncTest.kt new file mode 100644 index 00000000..5c5f424e --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/PersonalAccessTokenServiceAsyncTest.kt @@ -0,0 +1,85 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs.current + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyCreateRequest +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class PersonalAccessTokenServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val personalAccessTokenServiceAsync = + client.api().v1().orgs().current().personalAccessTokens() + + val apiKeyGetResponseFuture = + personalAccessTokenServiceAsync.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val apiKeyGetResponse = apiKeyGetResponseFuture.get() + apiKeyGetResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun personalAccessTokens() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val personalAccessTokenServiceAsync = + client.api().v1().orgs().current().personalAccessTokens() + + val apiKeyCreateResponseFuture = + personalAccessTokenServiceAsync.personalAccessTokens( + ApiKeyCreateRequest.builder() + .defaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val apiKeyCreateResponse = apiKeyCreateResponseFuture.get() + apiKeyCreateResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrievePersonalAccessTokens() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val personalAccessTokenServiceAsync = + client.api().v1().orgs().current().personalAccessTokens() + + val apiKeyGetResponsesFuture = + personalAccessTokenServiceAsync.retrievePersonalAccessTokens() + + val apiKeyGetResponses = apiKeyGetResponsesFuture.get() + apiKeyGetResponses.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/RoleServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/RoleServiceAsyncTest.kt new file mode 100644 index 00000000..03f416a8 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/RoleServiceAsyncTest.kt @@ -0,0 +1,102 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs.current + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.orgs.current.roles.RoleCreateParams +import com.langsmith_api.api.models.api.v1.orgs.current.roles.RoleUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class RoleServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val roleServiceAsync = client.api().v1().orgs().current().roles() + + val roleFuture = + roleServiceAsync.create( + RoleCreateParams.builder() + .description("description") + .displayName("display_name") + .addPermission("string") + .build() + ) + + val role = roleFuture.get() + role.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val roleServiceAsync = client.api().v1().orgs().current().roles() + + val roleFuture = + roleServiceAsync.update( + RoleUpdateParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .displayName("display_name") + .addPermission("string") + .build() + ) + + val role = roleFuture.get() + role.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val roleServiceAsync = client.api().v1().orgs().current().roles() + + val rolesFuture = roleServiceAsync.list() + + val roles = rolesFuture.get() + roles.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val roleServiceAsync = client.api().v1().orgs().current().roles() + + val roleFuture = roleServiceAsync.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val role = roleFuture.get() + role.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/ServiceKeyServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/ServiceKeyServiceAsyncTest.kt new file mode 100644 index 00000000..39e86207 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/ServiceKeyServiceAsyncTest.kt @@ -0,0 +1,81 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs.current + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyCreateRequest +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ServiceKeyServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val serviceKeyServiceAsync = client.api().v1().orgs().current().serviceKeys() + + val apiKeyGetResponseFuture = + serviceKeyServiceAsync.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val apiKeyGetResponse = apiKeyGetResponseFuture.get() + apiKeyGetResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveServiceKeys() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val serviceKeyServiceAsync = client.api().v1().orgs().current().serviceKeys() + + val apiKeyGetResponsesFuture = serviceKeyServiceAsync.retrieveServiceKeys() + + val apiKeyGetResponses = apiKeyGetResponsesFuture.get() + apiKeyGetResponses.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun serviceKeys() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val serviceKeyServiceAsync = client.api().v1().orgs().current().serviceKeys() + + val apiKeyCreateResponseFuture = + serviceKeyServiceAsync.serviceKeys( + ApiKeyCreateRequest.builder() + .defaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val apiKeyCreateResponse = apiKeyCreateResponseFuture.get() + apiKeyCreateResponse.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/SsoSettingServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/SsoSettingServiceAsyncTest.kt new file mode 100644 index 00000000..f097d7b2 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/SsoSettingServiceAsyncTest.kt @@ -0,0 +1,111 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs.current + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.orgs.current.ssosettings.SsoSettingSsoSettingsParams +import com.langsmith_api.api.models.api.v1.orgs.current.ssosettings.SsoSettingUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class SsoSettingServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val ssoSettingServiceAsync = client.api().v1().orgs().current().ssoSettings() + + val ssoProviderFuture = + ssoSettingServiceAsync.update( + SsoSettingUpdateParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addDefaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .defaultWorkspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metadataUrl("metadata_url") + .metadataXml("metadata_xml") + .build() + ) + + val ssoProvider = ssoProviderFuture.get() + ssoProvider.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val ssoSettingServiceAsync = client.api().v1().orgs().current().ssoSettings() + + val ssoProviderFuture = + ssoSettingServiceAsync.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val ssoProvider = ssoProviderFuture.get() + ssoProvider.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveSsoSettings() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val ssoSettingServiceAsync = client.api().v1().orgs().current().ssoSettings() + + val ssoProvidersFuture = ssoSettingServiceAsync.retrieveSsoSettings() + + val ssoProviders = ssoProvidersFuture.get() + ssoProviders.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun ssoSettings() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val ssoSettingServiceAsync = client.api().v1().orgs().current().ssoSettings() + + val ssoProviderFuture = + ssoSettingServiceAsync.ssoSettings( + SsoSettingSsoSettingsParams.builder() + .addDefaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .defaultWorkspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .attributeMapping( + SsoSettingSsoSettingsParams.AttributeMapping.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .metadataUrl("metadata_url") + .metadataXml("metadata_xml") + .build() + ) + + val ssoProvider = ssoProviderFuture.get() + ssoProvider.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/UserServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/UserServiceAsyncTest.kt new file mode 100644 index 00000000..d135b7f3 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/UserServiceAsyncTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs.current + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class UserServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieveLoginMethods() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val userServiceAsync = client.api().v1().orgs().current().user() + + val providerUserSlimsFuture = userServiceAsync.retrieveLoginMethods() + + val providerUserSlims = providerUserSlimsFuture.get() + providerUserSlims.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/members/BasicServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/members/BasicServiceAsyncTest.kt new file mode 100644 index 00000000..38f7b7ed --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/members/BasicServiceAsyncTest.kt @@ -0,0 +1,49 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs.current.members + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.orgs.current.members.basic.BasicBatchParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class BasicServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun batch() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val basicServiceAsync = client.api().v1().orgs().current().members().basic() + + val responseFuture = + basicServiceAsync.batch( + BasicBatchParams.builder() + .addBody( + BasicBatchParams.Body.builder() + .email("email") + .fullName("full_name") + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .password("password") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .workspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + ) + + val response = responseFuture.get() + response.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/members/PendingServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/members/PendingServiceAsyncTest.kt new file mode 100644 index 00000000..6aacd8b1 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/orgs/current/members/PendingServiceAsyncTest.kt @@ -0,0 +1,53 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.orgs.current.members + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.orgs.current.members.pending.PendingListParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class PendingServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val pendingServiceAsync = client.api().v1().orgs().current().members().pending() + + val orgPendingIdentitiesFuture = + pendingServiceAsync.list( + PendingListParams.builder().addEmail("string").limit(1L).offset(0L).build() + ) + + val orgPendingIdentities = orgPendingIdentitiesFuture.get() + orgPendingIdentities.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun deleteAll() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val pendingServiceAsync = client.api().v1().orgs().current().members().pending() + + val responseFuture = pendingServiceAsync.deleteAll("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/public_/DatasetServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/public_/DatasetServiceAsyncTest.kt new file mode 100644 index 00000000..1d7a4782 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/public_/DatasetServiceAsyncTest.kt @@ -0,0 +1,167 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.public_ + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.datasets.SortByDatasetColumn +import com.langsmith_api.api.models.api.v1.datasets.comparative.SortByComparativeExperimentColumn +import com.langsmith_api.api.models.api.v1.feedback.FeedbackLevel +import com.langsmith_api.api.models.api.v1.feedback.SourceType +import com.langsmith_api.api.models.api.v1.public_.datasets.DatasetListParams +import com.langsmith_api.api.models.api.v1.public_.datasets.DatasetRetrieveComparativeParams +import com.langsmith_api.api.models.api.v1.public_.datasets.DatasetRetrieveFeedbackParams +import com.langsmith_api.api.models.api.v1.public_.datasets.DatasetRetrieveSessionsBulkParams +import com.langsmith_api.api.models.api.v1.public_.datasets.DatasetRetrieveSessionsParams +import com.langsmith_api.api.models.api.v1.sessions.SessionSortableColumns +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class DatasetServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetServiceAsync = client.api().v1().public_().datasets() + + val datasetsFuture = + datasetServiceAsync.list( + DatasetListParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .offset(0L) + .sortBy(SortByDatasetColumn.NAME) + .sortByDesc(true) + .build() + ) + + val datasets = datasetsFuture.get() + datasets.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveComparative() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetServiceAsync = client.api().v1().public_().datasets() + + val responseFuture = + datasetServiceAsync.retrieveComparative( + DatasetRetrieveComparativeParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .name("name") + .nameContains("name_contains") + .offset(0L) + .sortBy(SortByComparativeExperimentColumn.NAME) + .sortByDesc(true) + .build() + ) + + val response = responseFuture.get() + response.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveFeedback() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetServiceAsync = client.api().v1().public_().datasets() + + val feedbackSchemataFuture = + datasetServiceAsync.retrieveFeedback( + DatasetRetrieveFeedbackParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .hasComment(true) + .hasScore(true) + .addKey("string") + .level(FeedbackLevel.RUN) + .limit(1L) + .offset(0L) + .addRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addSource(SourceType.API) + .addUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val feedbackSchemata = feedbackSchemataFuture.get() + feedbackSchemata.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveSessions() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetServiceAsync = client.api().v1().public_().datasets() + + val tracerSessionsFuture = + datasetServiceAsync.retrieveSessions( + DatasetRetrieveSessionsParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .facets(true) + .limit(1L) + .name("name") + .nameContains("name_contains") + .offset(0L) + .sortBy(SessionSortableColumns.NAME) + .sortByDesc(true) + .sortByFeedbackKey("sort_by_feedback_key") + .accept("accept") + .build() + ) + + val tracerSessions = tracerSessionsFuture.get() + tracerSessions.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveSessionsBulk() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetServiceAsync = client.api().v1().public_().datasets() + + val tracerSessionsFuture = + datasetServiceAsync.retrieveSessionsBulk( + DatasetRetrieveSessionsBulkParams.builder().addShareToken("string").build() + ) + + val tracerSessions = tracerSessionsFuture.get() + tracerSessions.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/public_/ExampleServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/public_/ExampleServiceAsyncTest.kt new file mode 100644 index 00000000..83fe2e78 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/public_/ExampleServiceAsyncTest.kt @@ -0,0 +1,120 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.public_ + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.datasets.runs.QueryExampleSchemaWithRuns +import com.langsmith_api.api.models.api.v1.examples.ExampleSelect +import com.langsmith_api.api.models.api.v1.public_.examples.ExampleListParams +import com.langsmith_api.api.models.api.v1.public_.examples.ExampleRetrieveCountParams +import com.langsmith_api.api.models.api.v1.public_.examples.ExampleRunsParams +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ExampleServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val exampleServiceAsync = client.api().v1().public_().examples() + + val examplesFuture = + exampleServiceAsync.list( + ExampleListParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .limit(1L) + .metadata("metadata") + .offset(0L) + .addSelect(ExampleSelect.ID) + .build() + ) + + val examples = examplesFuture.get() + examples.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveCount() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val exampleServiceAsync = client.api().v1().public_().examples() + + val responseFuture = + exampleServiceAsync.retrieveCount( + ExampleRetrieveCountParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .metadata("metadata") + .build() + ) + + val response = responseFuture.get() + } + + @Disabled("Prism tests are disabled") + @Test + fun runs() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val exampleServiceAsync = client.api().v1().public_().examples() + + val responseFuture = + exampleServiceAsync.runs( + ExampleRunsParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .queryExampleSchemaWithRuns( + QueryExampleSchemaWithRuns.builder() + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .filters( + QueryExampleSchemaWithRuns.Filters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + ) + .format(QueryExampleSchemaWithRuns.Format.CSV) + .limit(1L) + .offset(0L) + .preview(true) + .sortParams( + QueryExampleSchemaWithRuns.SortParams.builder() + .sortBy("sort_by") + .sortOrder(QueryExampleSchemaWithRuns.SortParams.SortOrder.ASC) + .build() + ) + .build() + ) + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/public_/RunServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/public_/RunServiceAsyncTest.kt new file mode 100644 index 00000000..55a239c6 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/public_/RunServiceAsyncTest.kt @@ -0,0 +1,89 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.public_ + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.public_.runs.RunListParams +import com.langsmith_api.api.models.api.v1.public_.runs.RunQueryParams +import com.langsmith_api.api.models.api.v1.public_.runs.RunRetrieveParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class RunServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runServiceAsync = client.api().v1().public_().runs() + + val runPublicSchemaFuture = + runServiceAsync.retrieve( + RunRetrieveParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .excludeS3StoredAttributes(true) + .build() + ) + + val runPublicSchema = runPublicSchemaFuture.get() + runPublicSchema.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runServiceAsync = client.api().v1().public_().runs() + + val runPublicSchemaFuture = + runServiceAsync.list( + RunListParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .excludeS3StoredAttributes(true) + .build() + ) + + val runPublicSchema = runPublicSchemaFuture.get() + runPublicSchema.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun query() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runServiceAsync = client.api().v1().public_().runs() + + val responseFuture = + runServiceAsync.query( + RunQueryParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/public_/SchemaServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/public_/SchemaServiceAsyncTest.kt new file mode 100644 index 00000000..064745be --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/public_/SchemaServiceAsyncTest.kt @@ -0,0 +1,49 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.public_ + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class SchemaServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieveMessageJson() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val schemaServiceAsync = client.api().v1().public_().schemas() + + val responseFuture = schemaServiceAsync.retrieveMessageJson("version") + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveTooldefJson() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val schemaServiceAsync = client.api().v1().public_().schemas() + + val responseFuture = schemaServiceAsync.retrieveTooldefJson("version") + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/public_/datasets/RunServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/public_/datasets/RunServiceAsyncTest.kt new file mode 100644 index 00000000..d540e4d4 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/public_/datasets/RunServiceAsyncTest.kt @@ -0,0 +1,225 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.public_.datasets + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.datasets.runs.QueryFeedbackDelta +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunDeltaParams +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunGenerateQueryParams +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunQueryParams +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunRetrieveParams +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunStatsParams +import com.langsmith_api.api.models.api.v1.runs.BodyParamsForRunSchema +import com.langsmith_api.api.models.api.v1.runs.RequestBodyForRunsGenerateQuery +import com.langsmith_api.api.models.api.v1.runs.RunStatsQueryParams +import com.langsmith_api.api.models.api.v1.runs.RunTypeEnum +import com.langsmith_api.api.models.api.v1.runs.RunsFilterDataSourceTypeEnum +import com.langsmith_api.api.models.api.v1.sessions.RunStatsGroupBy +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class RunServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runServiceAsync = client.api().v1().public_().datasets().runs() + + val runPublicDatasetSchemaFuture = + runServiceAsync.retrieve( + RunRetrieveParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .excludeS3StoredAttributes(true) + .build() + ) + + val runPublicDatasetSchema = runPublicDatasetSchemaFuture.get() + runPublicDatasetSchema.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delta() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runServiceAsync = client.api().v1().public_().datasets().runs() + + val sessionFeedbackDeltaFuture = + runServiceAsync.delta( + RunDeltaParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .queryFeedbackDelta( + QueryFeedbackDelta.builder() + .baselineSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addComparisonSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackKey("feedback_key") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .filters( + QueryFeedbackDelta.Filters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + ) + .limit(1L) + .offset(0L) + .build() + ) + .build() + ) + + val sessionFeedbackDelta = sessionFeedbackDeltaFuture.get() + sessionFeedbackDelta.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun generateQuery() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runServiceAsync = client.api().v1().public_().datasets().runs() + + val responseBodyForRunsGenerateQueryFuture = + runServiceAsync.generateQuery( + RunGenerateQueryParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .requestBodyForRunsGenerateQuery( + RequestBodyForRunsGenerateQuery.builder() + .query("query") + .addFeedbackKey(RequestBodyForRunsGenerateQuery.FeedbackKey.USER_SCORE) + .build() + ) + .build() + ) + + val responseBodyForRunsGenerateQuery = responseBodyForRunsGenerateQueryFuture.get() + responseBodyForRunsGenerateQuery.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun query() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runServiceAsync = client.api().v1().public_().datasets().runs() + + val responseFuture = + runServiceAsync.query( + RunQueryParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .bodyParamsForRunSchema( + BodyParamsForRunSchema.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .dataSourceType(RunsFilterDataSourceTypeEnum.CURRENT) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .executionOrder(1L) + .filter("filter") + .isRoot(true) + .limit(1L) + .order(BodyParamsForRunSchema.Order.ASC) + .parentRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .query("query") + .addReferenceExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runType(RunTypeEnum.TOOL) + .searchFilter("search_filter") + .addSelect(BodyParamsForRunSchema.Select.ID) + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .skipPagination(true) + .skipPrevCursor(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .trace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .useExperimentalSearch(true) + .build() + ) + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun stats() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runServiceAsync = client.api().v1().public_().datasets().runs() + + val runStatsFuture = + runServiceAsync.stats( + RunStatsParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runStatsQueryParams( + RunStatsQueryParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dataSourceType(RunsFilterDataSourceTypeEnum.CURRENT) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .executionOrder(1L) + .filter("filter") + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .addGroup("string") + .isRoot(true) + .parentRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .query("query") + .addReferenceExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runType(RunTypeEnum.TOOL) + .searchFilter("search_filter") + .addSelect(RunStatsQueryParams.Select.RUN_COUNT) + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .skipPagination(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .trace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .useExperimentalSearch(true) + .build() + ) + .build() + ) + + val runStats = runStatsFuture.get() + runStats.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/repos/OptimizationJobServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/repos/OptimizationJobServiceAsyncTest.kt new file mode 100644 index 00000000..31238340 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/repos/OptimizationJobServiceAsyncTest.kt @@ -0,0 +1,168 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.repos + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.repos.EPromptOptimizationAlgorithm +import com.langsmith_api.api.models.api.v1.repos.PromptimConfig +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.EPromptOptimizationJobStatus +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.OptimizationJobDeleteParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.OptimizationJobOptimizationJobsParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.OptimizationJobRetrieveOptimizationJobsParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.OptimizationJobRetrieveParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.OptimizationJobUpdateParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.PromptOptimizationResult +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class OptimizationJobServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val optimizationJobServiceAsync = client.api().v1().repos().optimizationJobs() + + val optimizationJobFuture = + optimizationJobServiceAsync.retrieve( + OptimizationJobRetrieveParams.builder() + .owner("owner") + .repo("repo") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val optimizationJob = optimizationJobFuture.get() + optimizationJob.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val optimizationJobServiceAsync = client.api().v1().repos().optimizationJobs() + + val promptOptimizationJobFuture = + optimizationJobServiceAsync.update( + OptimizationJobUpdateParams.builder() + .owner("owner") + .repo("repo") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .result( + PromptOptimizationResult.builder() + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .x(0.0) + .y(0.0) + .build() + ) + .status(EPromptOptimizationJobStatus.CREATED) + .build() + ) + + val promptOptimizationJob = promptOptimizationJobFuture.get() + promptOptimizationJob.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val optimizationJobServiceAsync = client.api().v1().repos().optimizationJobs() + + val optimizationJobFuture = + optimizationJobServiceAsync.delete( + OptimizationJobDeleteParams.builder() + .owner("owner") + .repo("repo") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val optimizationJob = optimizationJobFuture.get() + optimizationJob.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun optimizationJobs() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val optimizationJobServiceAsync = client.api().v1().repos().optimizationJobs() + + val promptOptimizationJobFuture = + optimizationJobServiceAsync.optimizationJobs( + OptimizationJobOptimizationJobsParams.builder() + .owner("owner") + .repo("repo") + .algorithm(EPromptOptimizationAlgorithm.PROMPTIM) + .config( + PromptimConfig.builder() + .autoCommit(true) + .datasetName("dataset_name") + .devSplit("dev_split") + .addEvaluator("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .messageIndex(0L) + .numEpochs(0L) + .taskDescription("task_description") + .testSplit("test_split") + .trainSplit("train_split") + .build() + ) + .build() + ) + + val promptOptimizationJob = promptOptimizationJobFuture.get() + promptOptimizationJob.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveOptimizationJobs() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val optimizationJobServiceAsync = client.api().v1().repos().optimizationJobs() + + val promptOptimizationJobsFuture = + optimizationJobServiceAsync.retrieveOptimizationJobs( + OptimizationJobRetrieveOptimizationJobsParams.builder() + .owner("owner") + .repo("repo") + .build() + ) + + val promptOptimizationJobs = promptOptimizationJobsFuture.get() + promptOptimizationJobs.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/repos/TagServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/repos/TagServiceAsyncTest.kt new file mode 100644 index 00000000..40d03685 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/repos/TagServiceAsyncTest.kt @@ -0,0 +1,133 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.repos + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.repos.tags.TagCreateParams +import com.langsmith_api.api.models.api.v1.repos.tags.TagDeleteParams +import com.langsmith_api.api.models.api.v1.repos.tags.TagListParams +import com.langsmith_api.api.models.api.v1.repos.tags.TagRetrieveParams +import com.langsmith_api.api.models.api.v1.repos.tags.TagUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class TagServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tagServiceAsync = client.api().v1().repos().tags() + + val repoTagFuture = + tagServiceAsync.create( + TagCreateParams.builder() + .owner("owner") + .repo("repo") + .commitId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tagName("tag_name") + .skipWebhooks(true) + .build() + ) + + val repoTag = repoTagFuture.get() + repoTag.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tagServiceAsync = client.api().v1().repos().tags() + + val repoTagFuture = + tagServiceAsync.retrieve( + TagRetrieveParams.builder().owner("owner").repo("repo").tagName("tag_name").build() + ) + + val repoTag = repoTagFuture.get() + repoTag.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tagServiceAsync = client.api().v1().repos().tags() + + val repoTagFuture = + tagServiceAsync.update( + TagUpdateParams.builder() + .owner("owner") + .repo("repo") + .tagName("tag_name") + .commitId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .skipWebhooks(true) + .build() + ) + + val repoTag = repoTagFuture.get() + repoTag.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tagServiceAsync = client.api().v1().repos().tags() + + val repoTagsFuture = + tagServiceAsync.list(TagListParams.builder().owner("owner").repo("repo").build()) + + val repoTags = repoTagsFuture.get() + repoTags.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tagServiceAsync = client.api().v1().repos().tags() + + val tagFuture = + tagServiceAsync.delete( + TagDeleteParams.builder().owner("owner").repo("repo").tagName("tag_name").build() + ) + + val tag = tagFuture.get() + tag.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/repos/optimizationjobs/LogServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/repos/optimizationjobs/LogServiceAsyncTest.kt new file mode 100644 index 00000000..70b9d8af --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/repos/optimizationjobs/LogServiceAsyncTest.kt @@ -0,0 +1,124 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.repos.optimizationjobs + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs.EPromptOptimizationJobLogType +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs.LogCreateParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs.LogDeleteParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs.LogListParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs.LogRetrieveParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class LogServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val logServiceAsync = client.api().v1().repos().optimizationJobs().logs() + + val promptOptimizationJobLogFuture = + logServiceAsync.create( + LogCreateParams.builder() + .owner("owner") + .repo("repo") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .logType(EPromptOptimizationJobLogType.INFO) + .message("message") + .data(JsonValue.from(mapOf<String, Any>())) + .build() + ) + + val promptOptimizationJobLog = promptOptimizationJobLogFuture.get() + promptOptimizationJobLog.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val logServiceAsync = client.api().v1().repos().optimizationJobs().logs() + + val promptOptimizationJobLogFuture = + logServiceAsync.retrieve( + LogRetrieveParams.builder() + .owner("owner") + .repo("repo") + .jobId("job_id") + .logId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val promptOptimizationJobLog = promptOptimizationJobLogFuture.get() + promptOptimizationJobLog.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val logServiceAsync = client.api().v1().repos().optimizationJobs().logs() + + val promptOptimizationJobLogsFuture = + logServiceAsync.list( + LogListParams.builder() + .owner("owner") + .repo("repo") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val promptOptimizationJobLogs = promptOptimizationJobLogsFuture.get() + promptOptimizationJobLogs.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val logServiceAsync = client.api().v1().repos().optimizationJobs().logs() + + val logFuture = + logServiceAsync.delete( + LogDeleteParams.builder() + .owner("owner") + .repo("repo") + .jobId("job_id") + .logId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val log = logFuture.get() + log.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/runs/GroupServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/runs/GroupServiceAsyncTest.kt new file mode 100644 index 00000000..a48047bb --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/runs/GroupServiceAsyncTest.kt @@ -0,0 +1,79 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.runs + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.runs.group.GroupCreateParams +import com.langsmith_api.api.models.api.v1.runs.group.RunGroupRequest +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class GroupServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val groupServiceAsync = client.api().v1().runs().group() + + val groupFuture = + groupServiceAsync.create( + GroupCreateParams.builder() + .accept("accept") + .runGroupRequest( + RunGroupRequest.builder() + .groupBy(RunGroupRequest.GroupBy.CONVERSATION) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .limit(1L) + .offset(0L) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + ) + + val group = groupFuture.get() + group.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun stats() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val groupServiceAsync = client.api().v1().runs().group() + + val responseFuture = + groupServiceAsync.stats( + RunGroupRequest.builder() + .groupBy(RunGroupRequest.GroupBy.CONVERSATION) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .limit(1L) + .offset(0L) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/runs/RuleServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/runs/RuleServiceAsyncTest.kt new file mode 100644 index 00000000..19dd5ef0 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/runs/RuleServiceAsyncTest.kt @@ -0,0 +1,292 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.runs + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.runs.rules.CodeEvaluatorTopLevel +import com.langsmith_api.api.models.api.v1.runs.rules.EvaluatorTopLevel +import com.langsmith_api.api.models.api.v1.runs.rules.RuleCreateParams +import com.langsmith_api.api.models.api.v1.runs.rules.RuleListParams +import com.langsmith_api.api.models.api.v1.runs.rules.RuleRetrieveLogsParams +import com.langsmith_api.api.models.api.v1.runs.rules.RuleUpdateParams +import com.langsmith_api.api.models.api.v1.runs.rules.RunRulesPagerdutyAlertSchema +import com.langsmith_api.api.models.api.v1.runs.rules.RunRulesWebhookSchema +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class RuleServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val ruleServiceAsync = client.api().v1().runs().rules() + + val runRulesSchemaFuture = + ruleServiceAsync.create( + RuleCreateParams.builder() + .displayName("display_name") + .samplingRate(0.0) + .addToAnnotationQueueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addToDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addToDatasetPreferCorrection(true) + .addAlert( + RunRulesPagerdutyAlertSchema.builder() + .routingKey("routing_key") + .severity(RunRulesPagerdutyAlertSchema.Severity.CRITICAL) + .summary("summary") + .type(RunRulesPagerdutyAlertSchema.Type.PAGERDUTY) + .build() + ) + .backfillFrom(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addCodeEvaluator( + CodeEvaluatorTopLevel.builder() + .code("code") + .language(CodeEvaluatorTopLevel.Language.PYTHON) + .build() + ) + .createAlignmentQueue(true) + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .evaluatorVersion(0L) + .addEvaluator( + EvaluatorTopLevel.builder() + .structured( + EvaluatorTopLevel.Structured.builder() + .hubRef("hub_ref") + .model(JsonValue.from(mapOf<String, Any>())) + .addPrompt( + listOf( + JsonValue.from(mapOf<String, Any>()), + JsonValue.from(mapOf<String, Any>()), + ) + ) + .schema(JsonValue.from(mapOf<String, Any>())) + .templateFormat("template_format") + .variableMapping( + EvaluatorTopLevel.Structured.VariableMapping.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + .build() + ) + .extendOnly(true) + .filter("filter") + .groupBy(RuleCreateParams.GroupBy.THREAD_ID) + .includeExtendedStats(true) + .isEnabled(true) + .numFewShotExamples(0L) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .transient_(true) + .treeFilter("tree_filter") + .useCorrectionsDataset(true) + .addWebhook( + RunRulesWebhookSchema.builder() + .url("url") + .headers( + RunRulesWebhookSchema.Headers.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + .build() + ) + + val runRulesSchema = runRulesSchemaFuture.get() + runRulesSchema.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val ruleServiceAsync = client.api().v1().runs().rules() + + val runRulesSchemaFuture = + ruleServiceAsync.update( + RuleUpdateParams.builder() + .ruleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .displayName("display_name") + .samplingRate(0.0) + .addToAnnotationQueueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addToDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addToDatasetPreferCorrection(true) + .addAlert( + RunRulesPagerdutyAlertSchema.builder() + .routingKey("routing_key") + .severity(RunRulesPagerdutyAlertSchema.Severity.CRITICAL) + .summary("summary") + .type(RunRulesPagerdutyAlertSchema.Type.PAGERDUTY) + .build() + ) + .backfillFrom(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addCodeEvaluator( + CodeEvaluatorTopLevel.builder() + .code("code") + .language(CodeEvaluatorTopLevel.Language.PYTHON) + .build() + ) + .createAlignmentQueue(true) + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .evaluatorVersion(0L) + .addEvaluator( + EvaluatorTopLevel.builder() + .structured( + EvaluatorTopLevel.Structured.builder() + .hubRef("hub_ref") + .model(JsonValue.from(mapOf<String, Any>())) + .addPrompt( + listOf( + JsonValue.from(mapOf<String, Any>()), + JsonValue.from(mapOf<String, Any>()), + ) + ) + .schema(JsonValue.from(mapOf<String, Any>())) + .templateFormat("template_format") + .variableMapping( + EvaluatorTopLevel.Structured.VariableMapping.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + .build() + ) + .extendOnly(true) + .filter("filter") + .includeExtendedStats(true) + .isEnabled(true) + .numFewShotExamples(0L) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .transient_(true) + .treeFilter("tree_filter") + .useCorrectionsDataset(true) + .addWebhook( + RunRulesWebhookSchema.builder() + .url("url") + .headers( + RunRulesWebhookSchema.Headers.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + .build() + ) + + val runRulesSchema = runRulesSchemaFuture.get() + runRulesSchema.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val ruleServiceAsync = client.api().v1().runs().rules() + + val runRulesSchemataFuture = + ruleServiceAsync.list( + RuleListParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .nameContains("name_contains") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .type(RuleListParams.Type.SESSION) + .build() + ) + + val runRulesSchemata = runRulesSchemataFuture.get() + runRulesSchemata.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val ruleServiceAsync = client.api().v1().runs().rules() + + val ruleFuture = ruleServiceAsync.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val rule = ruleFuture.get() + rule.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveLastApplied() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val ruleServiceAsync = client.api().v1().runs().rules() + + val ruleLogSchemaFuture = + ruleServiceAsync.retrieveLastApplied("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val ruleLogSchema = ruleLogSchemaFuture.get() + ruleLogSchema.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveLogs() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val ruleServiceAsync = client.api().v1().runs().rules() + + val ruleLogSchemataFuture = + ruleServiceAsync.retrieveLogs( + RuleRetrieveLogsParams.builder() + .ruleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .limit(100L) + .offset(0L) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + val ruleLogSchemata = ruleLogSchemataFuture.get() + ruleLogSchemata.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/runs/ShareServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/runs/ShareServiceAsyncTest.kt new file mode 100644 index 00000000..11ca92c9 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/runs/ShareServiceAsyncTest.kt @@ -0,0 +1,69 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.runs + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import kotlin.jvm.optionals.getOrNull +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ShareServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val shareServiceAsync = client.api().v1().runs().share() + + val runShareSchemaFuture = shareServiceAsync.create("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val runShareSchema = runShareSchemaFuture.get() + runShareSchema.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val shareServiceAsync = client.api().v1().runs().share() + + val runShareSchemaFuture = shareServiceAsync.list("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val runShareSchema = runShareSchemaFuture.get() + val unwrappedRunShareSchema = runShareSchema.getOrNull() + unwrappedRunShareSchema?.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun deleteAll() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val shareServiceAsync = client.api().v1().runs().share() + + val responseFuture = shareServiceAsync.deleteAll("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/runs/rules/TriggerServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/runs/rules/TriggerServiceAsyncTest.kt new file mode 100644 index 00000000..e1d138d7 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/runs/rules/TriggerServiceAsyncTest.kt @@ -0,0 +1,38 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.runs.rules + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.runs.rules.trigger.TriggerCreateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class TriggerServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val triggerServiceAsync = client.api().v1().runs().rules().trigger() + + val triggerFuture = + triggerServiceAsync.create( + TriggerCreateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addRuleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val trigger = triggerFuture.get() + trigger.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/sessions/InsightServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/sessions/InsightServiceAsyncTest.kt new file mode 100644 index 00000000..80cff917 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/sessions/InsightServiceAsyncTest.kt @@ -0,0 +1,198 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.sessions + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.sessions.insights.CreateRunClusteringJobRequest +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightCreateParams +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightDeleteParams +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightListParams +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightRetrieveParams +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightRetrieveRunsParams +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightUpdateParams +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class InsightServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val insightServiceAsync = client.api().v1().sessions().insights() + + val insightFuture = + insightServiceAsync.create( + InsightCreateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createRunClusteringJobRequest( + CreateRunClusteringJobRequest.builder() + .attributeSchemas(JsonValue.from(mapOf<String, Any>())) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addHierarchy(0L) + .lastNHours(0L) + .model(CreateRunClusteringJobRequest.Model.OPENAI) + .name("name") + .partitions( + CreateRunClusteringJobRequest.Partitions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .sample(0.0) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .summaryPrompt("summary_prompt") + .userContext( + CreateRunClusteringJobRequest.UserContext.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .validateModelSecrets(true) + .build() + ) + .build() + ) + + val insight = insightFuture.get() + insight.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val insightServiceAsync = client.api().v1().sessions().insights() + + val insightFuture = + insightServiceAsync.retrieve( + InsightRetrieveParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .clusterId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val insight = insightFuture.get() + insight.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val insightServiceAsync = client.api().v1().sessions().insights() + + val insightFuture = + insightServiceAsync.update( + InsightUpdateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .build() + ) + + val insight = insightFuture.get() + insight.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val insightServiceAsync = client.api().v1().sessions().insights() + + val insightsFuture = + insightServiceAsync.list( + InsightListParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .offset(0L) + .build() + ) + + val insights = insightsFuture.get() + insights.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val insightServiceAsync = client.api().v1().sessions().insights() + + val insightFuture = + insightServiceAsync.delete( + InsightDeleteParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val insight = insightFuture.get() + insight.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveRuns() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val insightServiceAsync = client.api().v1().sessions().insights() + + val responseFuture = + insightServiceAsync.retrieveRuns( + InsightRetrieveRunsParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .attributeSortKey("attribute_sort_key") + .attributeSortOrder(InsightRetrieveRunsParams.AttributeSortOrder.ASC) + .clusterId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .offset(0L) + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/sessions/ViewServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/sessions/ViewServiceAsyncTest.kt new file mode 100644 index 00000000..328b7e7c --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/sessions/ViewServiceAsyncTest.kt @@ -0,0 +1,150 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.sessions + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.sessions.views.FilterViewType +import com.langsmith_api.api.models.api.v1.sessions.views.ViewCreateParams +import com.langsmith_api.api.models.api.v1.sessions.views.ViewDeleteParams +import com.langsmith_api.api.models.api.v1.sessions.views.ViewListParams +import com.langsmith_api.api.models.api.v1.sessions.views.ViewRetrieveParams +import com.langsmith_api.api.models.api.v1.sessions.views.ViewUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ViewServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val viewServiceAsync = client.api().v1().sessions().views() + + val filterViewFuture = + viewServiceAsync.create( + ViewCreateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .displayName("display_name") + .description("description") + .filterString("filter_string") + .traceFilterString("trace_filter_string") + .treeFilterString("tree_filter_string") + .type(FilterViewType.RUNS) + .build() + ) + + val filterView = filterViewFuture.get() + filterView.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val viewServiceAsync = client.api().v1().sessions().views() + + val filterViewFuture = + viewServiceAsync.retrieve( + ViewRetrieveParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val filterView = filterViewFuture.get() + filterView.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val viewServiceAsync = client.api().v1().sessions().views() + + val filterViewFuture = + viewServiceAsync.update( + ViewUpdateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .displayName("display_name") + .filterString("filter_string") + .traceFilterString("trace_filter_string") + .treeFilterString("tree_filter_string") + .type(FilterViewType.RUNS) + .build() + ) + + val filterView = filterViewFuture.get() + filterView.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val viewServiceAsync = client.api().v1().sessions().views() + + val filterViewsFuture = + viewServiceAsync.list( + ViewListParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .type(FilterViewType.RUNS) + .build() + ) + + val filterViews = filterViewsFuture.get() + filterViews.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val viewServiceAsync = client.api().v1().sessions().views() + + val viewFuture = + viewServiceAsync.delete( + ViewDeleteParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val view = viewFuture.get() + view.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/sessions/insights/ConfigServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/sessions/insights/ConfigServiceAsyncTest.kt new file mode 100644 index 00000000..be297280 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/sessions/insights/ConfigServiceAsyncTest.kt @@ -0,0 +1,199 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.sessions.insights + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.sessions.insights.CreateRunClusteringJobRequest +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigCreateParams +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigDeleteParams +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigGenerateParams +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigListParams +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigUpdateParams +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ConfigServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val configServiceAsync = client.api().v1().sessions().insights().configs() + + val createClusteringJobConfigResponseFuture = + configServiceAsync.create( + ConfigCreateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config( + CreateRunClusteringJobRequest.builder() + .attributeSchemas(JsonValue.from(mapOf<String, Any>())) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addHierarchy(0L) + .lastNHours(0L) + .model(CreateRunClusteringJobRequest.Model.OPENAI) + .name("name") + .partitions( + CreateRunClusteringJobRequest.Partitions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .sample(0.0) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .summaryPrompt("summary_prompt") + .userContext( + CreateRunClusteringJobRequest.UserContext.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .validateModelSecrets(true) + .build() + ) + .name("name") + .description("description") + .build() + ) + + val createClusteringJobConfigResponse = createClusteringJobConfigResponseFuture.get() + createClusteringJobConfigResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val configServiceAsync = client.api().v1().sessions().insights().configs() + + val createClusteringJobConfigResponseFuture = + configServiceAsync.update( + ConfigUpdateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .configId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config( + CreateRunClusteringJobRequest.builder() + .attributeSchemas(JsonValue.from(mapOf<String, Any>())) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addHierarchy(0L) + .lastNHours(0L) + .model(CreateRunClusteringJobRequest.Model.OPENAI) + .name("name") + .partitions( + CreateRunClusteringJobRequest.Partitions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .sample(0.0) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .summaryPrompt("summary_prompt") + .userContext( + CreateRunClusteringJobRequest.UserContext.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .validateModelSecrets(true) + .build() + ) + .description("description") + .name("name") + .build() + ) + + val createClusteringJobConfigResponse = createClusteringJobConfigResponseFuture.get() + createClusteringJobConfigResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val configServiceAsync = client.api().v1().sessions().insights().configs() + + val configsFuture = + configServiceAsync.list( + ConfigListParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .includePrebuilts(true) + .build() + ) + + val configs = configsFuture.get() + configs.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val configServiceAsync = client.api().v1().sessions().insights().configs() + + val configFuture = + configServiceAsync.delete( + ConfigDeleteParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .configId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val config = configFuture.get() + config.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun generate() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val configServiceAsync = client.api().v1().sessions().insights().configs() + + val responseFuture = + configServiceAsync.generate( + ConfigGenerateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userContext( + ConfigGenerateParams.UserContext.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .model(ConfigGenerateParams.Model.OPENAI) + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/sso/EmailVerificationServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/sso/EmailVerificationServiceAsyncTest.kt new file mode 100644 index 00000000..e92f34b0 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/sso/EmailVerificationServiceAsyncTest.kt @@ -0,0 +1,85 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.sso + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.sso.emailverification.EmailVerificationConfirmParams +import com.langsmith_api.api.models.api.v1.sso.emailverification.EmailVerificationSendParams +import com.langsmith_api.api.models.api.v1.sso.emailverification.EmailVerificationStatusParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class EmailVerificationServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun confirm() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val emailVerificationServiceAsync = client.api().v1().sso().emailVerification() + + val responseFuture = + emailVerificationServiceAsync.confirm( + EmailVerificationConfirmParams.builder().token("token").build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun send() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val emailVerificationServiceAsync = client.api().v1().sso().emailVerification() + + val responseFuture = + emailVerificationServiceAsync.send( + EmailVerificationSendParams.builder() + .email("email") + .samlProviderId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun status() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val emailVerificationServiceAsync = client.api().v1().sso().emailVerification() + + val responseFuture = + emailVerificationServiceAsync.status( + EmailVerificationStatusParams.builder() + .email("email") + .samlProviderId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/CurrentServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/CurrentServiceAsyncTest.kt new file mode 100644 index 00000000..776faa84 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/CurrentServiceAsyncTest.kt @@ -0,0 +1,55 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.workspaces + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.workspaces.current.CurrentRetrieveStatsParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CurrentServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieveStats() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val currentServiceAsync = client.api().v1().workspaces().current() + + val responseFuture = + currentServiceAsync.retrieveStats( + CurrentRetrieveStatsParams.builder() + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveUsageLimits() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val currentServiceAsync = client.api().v1().workspaces().current() + + val responseFuture = currentServiceAsync.retrieveUsageLimits() + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/PendingServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/PendingServiceAsyncTest.kt new file mode 100644 index 00000000..752448c8 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/PendingServiceAsyncTest.kt @@ -0,0 +1,67 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.workspaces + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class PendingServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val pendingServiceAsync = client.api().v1().workspaces().pending() + + val appSchemasTenantsFuture = pendingServiceAsync.list() + + val appSchemasTenants = appSchemasTenantsFuture.get() + appSchemasTenants.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val pendingServiceAsync = client.api().v1().workspaces().pending() + + val pendingFuture = pendingServiceAsync.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val pending = pendingFuture.get() + pending.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun claim() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val pendingServiceAsync = client.api().v1().workspaces().pending() + + val responseFuture = pendingServiceAsync.claim("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/MemberServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/MemberServiceAsyncTest.kt new file mode 100644 index 00000000..58b2f028 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/MemberServiceAsyncTest.kt @@ -0,0 +1,166 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.workspaces.current + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.orgs.current.members.PendingIdentityCreate +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberBatchParams +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberCreateParams +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberRetrieveActiveParams +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class MemberServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val memberServiceAsync = client.api().v1().workspaces().current().members() + + val identityFuture = + memberServiceAsync.create( + MemberCreateParams.builder() + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgIdentityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val identity = identityFuture.get() + identity.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val memberServiceAsync = client.api().v1().workspaces().current().members() + + val memberFuture = + memberServiceAsync.update( + MemberUpdateParams.builder() + .identityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .build() + ) + + val member = memberFuture.get() + member.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val memberServiceAsync = client.api().v1().workspaces().current().members() + + val membersFuture = memberServiceAsync.list() + + val members = membersFuture.get() + members.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val memberServiceAsync = client.api().v1().workspaces().current().members() + + val memberFuture = memberServiceAsync.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val member = memberFuture.get() + member.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun batch() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val memberServiceAsync = client.api().v1().workspaces().current().members() + + val pendingIdentitiesFuture = + memberServiceAsync.batch( + MemberBatchParams.builder() + .addBody( + PendingIdentityCreate.builder() + .email("email") + .fullName("full_name") + .password("password") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .workspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + ) + + val pendingIdentities = pendingIdentitiesFuture.get() + pendingIdentities.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveActive() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val memberServiceAsync = client.api().v1().workspaces().current().members() + + val memberIdentitiesFuture = + memberServiceAsync.retrieveActive( + MemberRetrieveActiveParams.builder() + .addEmail("string") + .limit(1L) + .addLsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .offset(0L) + .addUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val memberIdentities = memberIdentitiesFuture.get() + memberIdentities.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/SecretServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/SecretServiceAsyncTest.kt new file mode 100644 index 00000000..a6424b71 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/SecretServiceAsyncTest.kt @@ -0,0 +1,79 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.workspaces.current + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.workspaces.current.secrets.SecretCreateParams +import com.langsmith_api.api.models.api.v1.workspaces.current.secrets.SecretRetrieveEncryptedParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class SecretServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val secretServiceAsync = client.api().v1().workspaces().current().secrets() + + val secretFuture = + secretServiceAsync.create( + SecretCreateParams.builder() + .addBody(SecretCreateParams.Body.builder().key("key").value("value").build()) + .build() + ) + + val secret = secretFuture.get() + secret.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val secretServiceAsync = client.api().v1().workspaces().current().secrets() + + val secretsFuture = secretServiceAsync.list() + + val secrets = secretsFuture.get() + secrets.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveEncrypted() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val secretServiceAsync = client.api().v1().workspaces().current().secrets() + + val responseFuture = + secretServiceAsync.retrieveEncrypted( + SecretRetrieveEncryptedParams.builder() + .service(SecretRetrieveEncryptedParams.Service.AGENT_BUILDER) + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/SharedServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/SharedServiceAsyncTest.kt new file mode 100644 index 00000000..8784b02f --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/SharedServiceAsyncTest.kt @@ -0,0 +1,57 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.workspaces.current + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.workspaces.current.shared.SharedDeleteAllParams +import com.langsmith_api.api.models.api.v1.workspaces.current.shared.SharedListParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class SharedServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val sharedServiceAsync = client.api().v1().workspaces().current().shared() + + val sharedsFuture = + sharedServiceAsync.list(SharedListParams.builder().limit(1L).offset(0L).build()) + + val shareds = sharedsFuture.get() + shareds.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun deleteAll() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val sharedServiceAsync = client.api().v1().workspaces().current().shared() + + val responseFuture = + sharedServiceAsync.deleteAll( + SharedDeleteAllParams.builder() + .addShareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/TagKeyServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/TagKeyServiceAsyncTest.kt new file mode 100644 index 00000000..b9090dbd --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/TagKeyServiceAsyncTest.kt @@ -0,0 +1,115 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.workspaces.current + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.TagKeyTagKeysParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.TagKeyUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class TagKeyServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tagKeyServiceAsync = client.api().v1().workspaces().current().tagKeys() + + val tagKeyFuture = tagKeyServiceAsync.retrieve("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val tagKey = tagKeyFuture.get() + tagKey.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tagKeyServiceAsync = client.api().v1().workspaces().current().tagKeys() + + val tagKeyFuture = + tagKeyServiceAsync.update( + TagKeyUpdateParams.builder() + .tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .key("x") + .build() + ) + + val tagKey = tagKeyFuture.get() + tagKey.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tagKeyServiceAsync = client.api().v1().workspaces().current().tagKeys() + + val tagKeyFuture = tagKeyServiceAsync.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val tagKey = tagKeyFuture.get() + tagKey.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveTagKeys() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tagKeyServiceAsync = client.api().v1().workspaces().current().tagKeys() + + val tagKeysFuture = tagKeyServiceAsync.retrieveTagKeys() + + val tagKeys = tagKeysFuture.get() + tagKeys.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun tagKeys() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tagKeyServiceAsync = client.api().v1().workspaces().current().tagKeys() + + val tagKeyFuture = + tagKeyServiceAsync.tagKeys( + TagKeyTagKeysParams.builder().key("x").description("description").build() + ) + + val tagKey = tagKeyFuture.get() + tagKey.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/TagServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/TagServiceAsyncTest.kt new file mode 100644 index 00000000..0de7732d --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/TagServiceAsyncTest.kt @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.workspaces.current + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.workspaces.current.tags.ResourceType +import com.langsmith_api.api.models.api.v1.workspaces.current.tags.TagResourcesParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tags.TagRetrieveResourceParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class TagServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tagServiceAsync = client.api().v1().workspaces().current().tags() + + val tagsFuture = tagServiceAsync.list() + + val tags = tagsFuture.get() + tags.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun resources() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tagServiceAsync = client.api().v1().workspaces().current().tags() + + val responseFuture = + tagServiceAsync.resources( + TagResourcesParams.builder() + .addBody( + TagResourcesParams.Body.builder() + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceType(ResourceType.PROMPT) + .build() + ) + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveResource() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tagServiceAsync = client.api().v1().workspaces().current().tags() + + val responseFuture = + tagServiceAsync.retrieveResource( + TagRetrieveResourceParams.builder() + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceType(ResourceType.PROMPT) + .build() + ) + + val response = responseFuture.get() + response.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/TaggingServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/TaggingServiceAsyncTest.kt new file mode 100644 index 00000000..4e00485d --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/TaggingServiceAsyncTest.kt @@ -0,0 +1,82 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.workspaces.current + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.workspaces.current.taggings.TaggingCreateParams +import com.langsmith_api.api.models.api.v1.workspaces.current.taggings.TaggingListParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tags.ResourceType +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class TaggingServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val taggingServiceAsync = client.api().v1().workspaces().current().taggings() + + val taggingFuture = + taggingServiceAsync.create( + TaggingCreateParams.builder() + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceType(ResourceType.PROMPT) + .tagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val tagging = taggingFuture.get() + tagging.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val taggingServiceAsync = client.api().v1().workspaces().current().taggings() + + val taggingsFuture = + taggingServiceAsync.list( + TaggingListParams.builder() + .tagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val taggings = taggingsFuture.get() + taggings.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val taggingServiceAsync = client.api().v1().workspaces().current().taggings() + + val taggingFuture = taggingServiceAsync.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val tagging = taggingFuture.get() + tagging.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/members/PendingServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/members/PendingServiceAsyncTest.kt new file mode 100644 index 00000000..c6c5a436 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/members/PendingServiceAsyncTest.kt @@ -0,0 +1,53 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.workspaces.current.members + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.workspaces.current.members.pending.PendingListParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class PendingServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val pendingServiceAsync = client.api().v1().workspaces().current().members().pending() + + val pendingIdentitiesFuture = + pendingServiceAsync.list( + PendingListParams.builder().addEmail("string").limit(1L).offset(0L).build() + ) + + val pendingIdentities = pendingIdentitiesFuture.get() + pendingIdentities.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun deleteAll() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val pendingServiceAsync = client.api().v1().workspaces().current().members().pending() + + val responseFuture = pendingServiceAsync.deleteAll("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/tagkeys/TagValueServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/tagkeys/TagValueServiceAsyncTest.kt new file mode 100644 index 00000000..7c462053 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/api/v1/workspaces/current/tagkeys/TagValueServiceAsyncTest.kt @@ -0,0 +1,135 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.api.v1.workspaces.current.tagkeys + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues.TagValueDeleteParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues.TagValueRetrieveParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues.TagValueTagValuesParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues.TagValueUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class TagValueServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tagValueServiceAsync = client.api().v1().workspaces().current().tagKeys().tagValues() + + val tagValueFuture = + tagValueServiceAsync.retrieve( + TagValueRetrieveParams.builder() + .tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val tagValue = tagValueFuture.get() + tagValue.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tagValueServiceAsync = client.api().v1().workspaces().current().tagKeys().tagValues() + + val tagValueFuture = + tagValueServiceAsync.update( + TagValueUpdateParams.builder() + .tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .value("x") + .build() + ) + + val tagValue = tagValueFuture.get() + tagValue.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tagValueServiceAsync = client.api().v1().workspaces().current().tagKeys().tagValues() + + val tagValueFuture = + tagValueServiceAsync.delete( + TagValueDeleteParams.builder() + .tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val tagValue = tagValueFuture.get() + tagValue.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveTagValues() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tagValueServiceAsync = client.api().v1().workspaces().current().tagKeys().tagValues() + + val tagValuesFuture = + tagValueServiceAsync.retrieveTagValues("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val tagValues = tagValuesFuture.get() + tagValues.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun tagValues() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tagValueServiceAsync = client.api().v1().workspaces().current().tagKeys().tagValues() + + val tagValueFuture = + tagValueServiceAsync.tagValues( + TagValueTagValuesParams.builder() + .tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .value("x") + .description("description") + .build() + ) + + val tagValue = tagValueFuture.get() + tagValue.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/datasets/ExperimentViewOverrideServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/datasets/ExperimentViewOverrideServiceAsyncTest.kt new file mode 100644 index 00000000..a25d8857 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/datasets/ExperimentViewOverrideServiceAsyncTest.kt @@ -0,0 +1,160 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.datasets + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.datasets.experimentviewoverrides.ColumnOverride +import com.langsmith_api.api.models.datasets.experimentviewoverrides.ExperimentViewOverrideCreateParams +import com.langsmith_api.api.models.datasets.experimentviewoverrides.ExperimentViewOverrideDeleteParams +import com.langsmith_api.api.models.datasets.experimentviewoverrides.ExperimentViewOverrideRetrieveParams +import com.langsmith_api.api.models.datasets.experimentviewoverrides.ExperimentViewOverrideUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ExperimentViewOverrideServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val experimentViewOverrideServiceAsync = client.datasets().experimentViewOverrides() + + val experimentViewOverrideFuture = + experimentViewOverrideServiceAsync.create( + ExperimentViewOverrideCreateParams.builder() + .datasetId(JsonValue.from("\"550e8400-e29b-41d4-a716-446655440000\"")) + .addColumnOverride( + ColumnOverride.builder() + .column("column") + .addColorGradient(listOf(JsonValue.from(mapOf<String, Any>()))) + .colorMap( + ColumnOverride.ColorMap.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .hide(true) + .precision(1L) + .build() + ) + .build() + ) + + val experimentViewOverride = experimentViewOverrideFuture.get() + experimentViewOverride.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val experimentViewOverrideServiceAsync = client.datasets().experimentViewOverrides() + + val experimentViewOverrideFuture = + experimentViewOverrideServiceAsync.retrieve( + ExperimentViewOverrideRetrieveParams.builder() + .datasetId(JsonValue.from("\"550e8400-e29b-41d4-a716-446655440000\"")) + .id(JsonValue.from("\"123e4567-e89b-12d3-a456-426614174000\"")) + .build() + ) + + val experimentViewOverride = experimentViewOverrideFuture.get() + experimentViewOverride.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val experimentViewOverrideServiceAsync = client.datasets().experimentViewOverrides() + + val experimentViewOverrideFuture = + experimentViewOverrideServiceAsync.update( + ExperimentViewOverrideUpdateParams.builder() + .datasetId(JsonValue.from("\"550e8400-e29b-41d4-a716-446655440000\"")) + .id(JsonValue.from("\"123e4567-e89b-12d3-a456-426614174000\"")) + .addColumnOverride( + ColumnOverride.builder() + .column("column") + .addColorGradient(listOf(JsonValue.from(mapOf<String, Any>()))) + .colorMap( + ColumnOverride.ColorMap.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .hide(true) + .precision(1L) + .build() + ) + .build() + ) + + val experimentViewOverride = experimentViewOverrideFuture.get() + experimentViewOverride.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val experimentViewOverrideServiceAsync = client.datasets().experimentViewOverrides() + + val experimentViewOverridesFuture = + experimentViewOverrideServiceAsync.list( + JsonValue.from("\"550e8400-e29b-41d4-a716-446655440000\"") + ) + + val experimentViewOverrides = experimentViewOverridesFuture.get() + experimentViewOverrides.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val experimentViewOverrideServiceAsync = client.datasets().experimentViewOverrides() + + val future = + experimentViewOverrideServiceAsync.delete( + ExperimentViewOverrideDeleteParams.builder() + .datasetId(JsonValue.from("\"550e8400-e29b-41d4-a716-446655440000\"")) + .id(JsonValue.from("\"123e4567-e89b-12d3-a456-426614174000\"")) + .build() + ) + + val response = future.get() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/platform/AlertServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/platform/AlertServiceAsyncTest.kt new file mode 100644 index 00000000..02ec2813 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/platform/AlertServiceAsyncTest.kt @@ -0,0 +1,183 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.platform + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.platform.alerts.AlertActionBase +import com.langsmith_api.api.models.platform.alerts.AlertCreateParams +import com.langsmith_api.api.models.platform.alerts.AlertDeleteParams +import com.langsmith_api.api.models.platform.alerts.AlertRetrieveParams +import com.langsmith_api.api.models.platform.alerts.AlertRuleBase +import com.langsmith_api.api.models.platform.alerts.AlertUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class AlertServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val alertServiceAsync = client.platform().alerts() + + val alertRuleResponseFuture = + alertServiceAsync.create( + AlertCreateParams.builder() + .sessionId(JsonValue.from(mapOf<String, Any>())) + .addAction( + AlertActionBase.builder() + .config(JsonValue.from(mapOf<String, Any>())) + .target(AlertActionBase.Target.PAGERDUTY) + .id("id") + .alertRuleId("alert_rule_id") + .build() + ) + .rule( + AlertRuleBase.builder() + .aggregation(AlertRuleBase.Aggregation.AVG) + .attribute(AlertRuleBase.Attribute.LATENCY) + .description("description") + .name("name") + .operator(AlertRuleBase.Operator.GTE) + .type(AlertRuleBase.Type.THRESHOLD) + .windowMinutes(15L) + .id("id") + .denominatorFilter("denominator_filter") + .filter("filter") + .threshold(0.0) + .thresholdMultiplier(0.0) + .thresholdWindowMinutes(60L) + .build() + ) + .build() + ) + + val alertRuleResponse = alertRuleResponseFuture.get() + alertRuleResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val alertServiceAsync = client.platform().alerts() + + val alertRuleResponseFuture = + alertServiceAsync.retrieve( + AlertRetrieveParams.builder() + .sessionId(JsonValue.from(mapOf<String, Any>())) + .alertRuleId(JsonValue.from(mapOf<String, Any>())) + .build() + ) + + val alertRuleResponse = alertRuleResponseFuture.get() + alertRuleResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val alertServiceAsync = client.platform().alerts() + + val alertFuture = + alertServiceAsync.update( + AlertUpdateParams.builder() + .sessionId(JsonValue.from(mapOf<String, Any>())) + .alertRuleId(JsonValue.from(mapOf<String, Any>())) + .addAction( + AlertActionBase.builder() + .config(JsonValue.from(mapOf<String, Any>())) + .target(AlertActionBase.Target.PAGERDUTY) + .id("id") + .alertRuleId("alert_rule_id") + .build() + ) + .rule( + AlertRuleBase.builder() + .aggregation(AlertRuleBase.Aggregation.AVG) + .attribute(AlertRuleBase.Attribute.LATENCY) + .description("description") + .name("name") + .operator(AlertRuleBase.Operator.GTE) + .type(AlertRuleBase.Type.THRESHOLD) + .windowMinutes(15L) + .id("id") + .denominatorFilter("denominator_filter") + .filter("filter") + .threshold(0.0) + .thresholdMultiplier(0.0) + .thresholdWindowMinutes(60L) + .build() + ) + .build() + ) + + val alert = alertFuture.get() + alert.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val alertServiceAsync = client.platform().alerts() + + val alertFuture = + alertServiceAsync.delete( + AlertDeleteParams.builder() + .sessionId(JsonValue.from(mapOf<String, Any>())) + .alertRuleId(JsonValue.from(mapOf<String, Any>())) + .build() + ) + + val alert = alertFuture.get() + alert.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun test() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val alertServiceAsync = client.platform().alerts() + + val responseFuture = alertServiceAsync.test(JsonValue.from(mapOf<String, Any>())) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/platform/datasets/ExampleServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/platform/datasets/ExampleServiceAsyncTest.kt new file mode 100644 index 00000000..eb10e52d --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/platform/datasets/ExampleServiceAsyncTest.kt @@ -0,0 +1,93 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.platform.datasets + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.platform.datasets.examples.ExampleHardDeleteParams +import com.langsmith_api.api.models.platform.datasets.examples.ExampleUpdateParams +import com.langsmith_api.api.models.platform.datasets.examples.ExampleUploadParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ExampleServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val exampleServiceAsync = client.platform().datasets().examples() + + val exampleFuture = + exampleServiceAsync.update( + ExampleUpdateParams.builder() + .datasetId(JsonValue.from(mapOf<String, Any>())) + .exampleId("some content".byteInputStream()) + .exampleIdAttachmentName("some content".byteInputStream()) + .exampleIdAttachmentsOperations("some content".byteInputStream()) + .exampleIdInputs("some content".byteInputStream()) + .exampleIdOutputs("some content".byteInputStream()) + .build() + ) + + val example = exampleFuture.get() + example.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun hardDelete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val exampleServiceAsync = client.platform().datasets().examples() + + val responseFuture = + exampleServiceAsync.hardDelete( + ExampleHardDeleteParams.builder().addExampleId("string").hardDelete(true).build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun upload() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val exampleServiceAsync = client.platform().datasets().examples() + + val responseFuture = + exampleServiceAsync.upload( + ExampleUploadParams.builder() + .datasetId(JsonValue.from(mapOf<String, Any>())) + .exampleId("some content".byteInputStream()) + .exampleIdInputs("some content".byteInputStream()) + .exampleIdAttachmentsName("some content".byteInputStream()) + .exampleIdOutputs("some content".byteInputStream()) + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/platform/orgs/current/AccessPolicyServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/platform/orgs/current/AccessPolicyServiceAsyncTest.kt new file mode 100644 index 00000000..9f589146 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/platform/orgs/current/AccessPolicyServiceAsyncTest.kt @@ -0,0 +1,117 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.platform.orgs.current + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.platform.orgs.current.accesspolicies.AccessPolicyCreateParams +import com.langsmith_api.api.models.platform.orgs.current.accesspolicies.ConditionGroup +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class AccessPolicyServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val accessPolicyServiceAsync = client.platform().orgs().current().accessPolicies() + + val accessPolicyFuture = + accessPolicyServiceAsync.create( + AccessPolicyCreateParams.builder() + .payload( + AccessPolicyCreateParams.Payload.builder() + .addConditionGroup( + ConditionGroup.builder() + .addCondition( + ConditionGroup.Condition.builder() + .attributeKey("attribute_key") + .attributeName( + ConditionGroup.Condition.AttributeName + .RESOURCE_TAG_KEY + ) + .attributeValue("attribute_value") + .operator(ConditionGroup.Condition.Operator.EQUALS) + .build() + ) + .permission(ConditionGroup.Permission.ANNOTATION_QUEUES_CREATE) + .resourceType("resource_type") + .build() + ) + .description("description") + .effect("effect") + .name("name") + .addRoleId("string") + .build() + ) + .build() + ) + + val accessPolicy = accessPolicyFuture.get() + accessPolicy.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val accessPolicyServiceAsync = client.platform().orgs().current().accessPolicies() + + val accessPolicyFuture = + accessPolicyServiceAsync.retrieve(JsonValue.from(mapOf<String, Any>())) + + val accessPolicy = accessPolicyFuture.get() + accessPolicy.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val accessPolicyServiceAsync = client.platform().orgs().current().accessPolicies() + + val accessPoliciesFuture = accessPolicyServiceAsync.list() + + val accessPolicies = accessPoliciesFuture.get() + accessPolicies.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val accessPolicyServiceAsync = client.platform().orgs().current().accessPolicies() + + val future = accessPolicyServiceAsync.delete(JsonValue.from(mapOf<String, Any>())) + + val response = future.get() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/platform/orgs/current/accesspolicies/RoleServiceAsyncTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/platform/orgs/current/accesspolicies/RoleServiceAsyncTest.kt new file mode 100644 index 00000000..f7c7f074 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/async/platform/orgs/current/accesspolicies/RoleServiceAsyncTest.kt @@ -0,0 +1,38 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.async.platform.orgs.current.accesspolicies + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClientAsync +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.platform.orgs.current.accesspolicies.roles.RoleAttachParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class RoleServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun attach() { + val client = + LangsmithApiOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val roleServiceAsync = client.platform().orgs().current().accessPolicies().roles() + + val future = + roleServiceAsync.attach( + RoleAttachParams.builder() + .roleId(JsonValue.from(mapOf<String, Any>())) + .payload(RoleAttachParams.Payload.builder().addAccessPolicyId("string").build()) + .build() + ) + + val response = future.get() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/FeedbackServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/FeedbackServiceTest.kt new file mode 100644 index 00000000..2d580d0c --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/FeedbackServiceTest.kt @@ -0,0 +1,82 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.feedback.FeedbackIngestBatchParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class FeedbackServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun ingestBatch() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val feedbackService = client.feedback() + + val response = + feedbackService.ingestBatch( + FeedbackIngestBatchParams.builder() + .addBody( + FeedbackIngestBatchParams.Body.builder() + .id("id") + .comment("comment") + .comparativeExperimentId("comparative_experiment_id") + .correction(JsonValue.from(mapOf<String, Any>())) + .createdAt("created_at") + .error(true) + .feedbackConfig( + FeedbackIngestBatchParams.Body.FeedbackConfig.builder() + .addCategory( + FeedbackIngestBatchParams.Body.FeedbackConfig.Category + .builder() + .label("x") + .value(0.0) + .build() + ) + .max(0.0) + .min(0.0) + .type( + FeedbackIngestBatchParams.Body.FeedbackConfig.Type + .CONTINUOUS + ) + .build() + ) + .feedbackGroupId("feedback_group_id") + .feedbackSource( + FeedbackIngestBatchParams.Body.FeedbackSource.builder() + .metadata( + FeedbackIngestBatchParams.Body.FeedbackSource.Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .type("type") + .build() + ) + .key("key") + .modifiedAt("modified_at") + .runId("run_id") + .score(JsonValue.from(mapOf<String, Any>())) + .sessionId("session_id") + .traceId("trace_id") + .value(JsonValue.from(mapOf<String, Any>())) + .build() + ) + .build() + ) + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/RunServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/RunServiceTest.kt new file mode 100644 index 00000000..4564002a --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/RunServiceTest.kt @@ -0,0 +1,317 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.runs.Run +import com.langsmith_api.api.models.runs.RunIngestBatchParams +import com.langsmith_api.api.models.runs.RunIngestMultipartParams +import com.langsmith_api.api.models.runs.RunUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class RunServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runService = client.runs() + + val run = + runService.create( + Run.builder() + .id("id") + .dottedOrder("dotted_order") + .endTime("end_time") + .error("error") + .addEvent( + Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extra( + Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputAttachments( + Run.InputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputs( + Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .outputAttachments( + Run.OutputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .parentRunId("parent_run_id") + .referenceExampleId("reference_example_id") + .runType(Run.RunType.TOOL) + .serialized( + Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .sessionId("session_id") + .sessionName("session_name") + .startTime("start_time") + .status("status") + .addTag("string") + .traceId("trace_id") + .build() + ) + + run.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runService = client.runs() + + val run = + runService.update( + RunUpdateParams.builder() + .runId(JsonValue.from(mapOf<String, Any>())) + .run( + Run.builder() + .id("id") + .dottedOrder("dotted_order") + .endTime("end_time") + .error("error") + .addEvent( + Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extra( + Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputAttachments( + Run.InputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputs( + Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .outputAttachments( + Run.OutputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .parentRunId("parent_run_id") + .referenceExampleId("reference_example_id") + .runType(Run.RunType.TOOL) + .serialized( + Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .sessionId("session_id") + .sessionName("session_name") + .startTime("start_time") + .status("status") + .addTag("string") + .traceId("trace_id") + .build() + ) + .build() + ) + + run.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun ingestBatch() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runService = client.runs() + + val response = + runService.ingestBatch( + RunIngestBatchParams.builder() + .addPatch( + Run.builder() + .id("id") + .dottedOrder("dotted_order") + .endTime("end_time") + .error("error") + .addEvent( + Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extra( + Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputAttachments( + Run.InputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputs( + Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .outputAttachments( + Run.OutputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .parentRunId("parent_run_id") + .referenceExampleId("reference_example_id") + .runType(Run.RunType.TOOL) + .serialized( + Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .sessionId("session_id") + .sessionName("session_name") + .startTime("start_time") + .status("status") + .addTag("string") + .traceId("trace_id") + .build() + ) + .addPost( + Run.builder() + .id("id") + .dottedOrder("dotted_order") + .endTime("end_time") + .error("error") + .addEvent( + Run.Event.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extra( + Run.Extra.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputAttachments( + Run.InputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .inputs( + Run.Inputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .outputAttachments( + Run.OutputAttachments.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .outputs( + Run.Outputs.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .parentRunId("parent_run_id") + .referenceExampleId("reference_example_id") + .runType(Run.RunType.TOOL) + .serialized( + Run.Serialized.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .sessionId("session_id") + .sessionName("session_name") + .startTime("start_time") + .status("status") + .addTag("string") + .traceId("trace_id") + .build() + ) + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun ingestMultipart() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runService = client.runs() + + val response = + runService.ingestMultipart( + RunIngestMultipartParams.builder() + .attachmentRunIdFilename(JsonValue.from(mapOf<String, Any>())) + .feedbackRunId("some content".byteInputStream()) + .patchRunId("some content".byteInputStream()) + .patchRunIdOutputs("some content".byteInputStream()) + .postRunId("some content".byteInputStream()) + .postRunIdInputs("some content".byteInputStream()) + .build() + ) + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/V1ServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/V1ServiceTest.kt new file mode 100644 index 00000000..d3575daa --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/V1ServiceTest.kt @@ -0,0 +1,94 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.V1EventsParams +import com.langsmith_api.api.models.api.v1.V1UpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class V1ServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val v1Service = client.api().v1() + + val v1 = + v1Service.update( + V1UpdateParams.builder().owner("owner").repo("repo").like(true).build() + ) + + v1.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun events() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val v1Service = client.api().v1() + + val response = + v1Service.events( + V1EventsParams.builder() + .eventType(V1EventsParams.EventType.PLAYGROUND_VIEW) + .owner("owner") + .repo("repo") + .commit("commit") + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun login() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val v1Service = client.api().v1() + + val response = v1Service.login() + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveOk() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val v1Service = client.api().v1() + + val response = v1Service.retrieveOk() + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/AceServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/AceServiceTest.kt new file mode 100644 index 00000000..bfe4bd5f --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/AceServiceTest.kt @@ -0,0 +1,39 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.ace.AceExecuteParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class AceServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun execute() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val aceService = client.api().v1().ace() + + val response = + aceService.execute( + AceExecuteParams.builder() + .addArg(JsonValue.from(mapOf<String, Any>())) + .code("code") + .language("language") + .build() + ) + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/AnnotationQueueServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/AnnotationQueueServiceTest.kt new file mode 100644 index 00000000..7819e7cd --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/AnnotationQueueServiceTest.kt @@ -0,0 +1,289 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueAnnotationQueuesParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueExportParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueuePopulateParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueRetrieveAnnotationQueuesParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueRetrieveParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueRetrieveTotalArchivedParams +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueRubricItemSchema +import com.langsmith_api.api.models.api.v1.annotationqueues.AnnotationQueueUpdateParams +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class AnnotationQueueServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val annotationQueueService = client.api().v1().annotationQueues() + + val runSchemaWithAnnotationQueueInfo = + annotationQueueService.retrieve( + AnnotationQueueRetrieveParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .index(0L) + .includeExtra(true) + .build() + ) + + runSchemaWithAnnotationQueueInfo.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val annotationQueueService = client.api().v1().annotationQueues() + + val annotationQueue = + annotationQueueService.update( + AnnotationQueueUpdateParams.builder() + .annotationQueueRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .overrideAddedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status("status") + .build() + ) + + annotationQueue.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val annotationQueueService = client.api().v1().annotationQueues() + + val annotationQueue = annotationQueueService.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + annotationQueue.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun annotationQueues() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val annotationQueueService = client.api().v1().annotationQueues() + + val annotationQueueSchema = + annotationQueueService.annotationQueues( + AnnotationQueueAnnotationQueuesParams.builder() + .name("name") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .defaultDataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .enableReservations(true) + .numReviewersPerItem(0L) + .reservationMinutes(0L) + .rubricInstructions("rubric_instructions") + .addRubricItem( + AnnotationQueueRubricItemSchema.builder() + .feedbackKey("feedback_key") + .description("description") + .scoreDescriptions( + AnnotationQueueRubricItemSchema.ScoreDescriptions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .valueDescriptions( + AnnotationQueueRubricItemSchema.ValueDescriptions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + annotationQueueSchema.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun export() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val annotationQueueService = client.api().v1().annotationQueues() + + val response = + annotationQueueService.export( + AnnotationQueueExportParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun populate() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val annotationQueueService = client.api().v1().annotationQueues() + + val response = + annotationQueueService.populate( + AnnotationQueuePopulateParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveAnnotationQueues() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val annotationQueueService = client.api().v1().annotationQueues() + + val response = + annotationQueueService.retrieveAnnotationQueues( + AnnotationQueueRetrieveAnnotationQueuesParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .name("name") + .nameContains("name_contains") + .offset(0L) + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + response.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveQueues() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val annotationQueueService = client.api().v1().annotationQueues() + + val annotationQueueSchemata = + annotationQueueService.retrieveQueues("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + annotationQueueSchemata.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveSize() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val annotationQueueService = client.api().v1().annotationQueues() + + val annotationQueueSizeSchema = + annotationQueueService.retrieveSize("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + annotationQueueSizeSchema.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveTotalArchived() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val annotationQueueService = client.api().v1().annotationQueues() + + val annotationQueueSizeSchema = + annotationQueueService.retrieveTotalArchived( + AnnotationQueueRetrieveTotalArchivedParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + annotationQueueSizeSchema.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveTotalSize() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val annotationQueueService = client.api().v1().annotationQueues() + + val annotationQueueSizeSchema = + annotationQueueService.retrieveTotalSize("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + annotationQueueSizeSchema.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/ApiKeyServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/ApiKeyServiceTest.kt new file mode 100644 index 00000000..bb0fe5f0 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/ApiKeyServiceTest.kt @@ -0,0 +1,77 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyCreateRequest +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ApiKeyServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val apiKeyService = client.api().v1().apiKey() + + val apiKeyGetResponse = apiKeyService.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + apiKeyGetResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun apiKey() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val apiKeyService = client.api().v1().apiKey() + + val apiKeyCreateResponse = + apiKeyService.apiKey( + ApiKeyCreateRequest.builder() + .defaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + apiKeyCreateResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveApiKey() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val apiKeyService = client.api().v1().apiKey() + + val apiKeyGetResponses = apiKeyService.retrieveApiKey() + + apiKeyGetResponses.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/BulkExportServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/BulkExportServiceTest.kt new file mode 100644 index 00000000..b8bba7eb --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/BulkExportServiceTest.kt @@ -0,0 +1,97 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.bulkexports.BulkExportBulkExportsParams +import com.langsmith_api.api.models.api.v1.bulkexports.BulkExportCompression +import com.langsmith_api.api.models.api.v1.bulkexports.BulkExportFormat +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class BulkExportServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val bulkExportService = client.api().v1().bulkExports() + + val bulkExport = bulkExportService.retrieve("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + bulkExport.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val bulkExportService = client.api().v1().bulkExports() + + val bulkExport = bulkExportService.update("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + bulkExport.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun bulkExports() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val bulkExportService = client.api().v1().bulkExports() + + val bulkExport = + bulkExportService.bulkExports( + BulkExportBulkExportsParams.builder() + .bulkExportDestinationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .compression(BulkExportCompression.NONE) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .format(BulkExportFormat.PARQUET) + .intervalHours(0L) + .build() + ) + + bulkExport.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveBulkExports() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val bulkExportService = client.api().v1().bulkExports() + + val bulkExports = bulkExportService.retrieveBulkExports() + + bulkExports.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/ChartServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/ChartServiceTest.kt new file mode 100644 index 00000000..a4b7962f --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/ChartServiceTest.kt @@ -0,0 +1,238 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.charts.ChartUpdateParams +import com.langsmith_api.api.models.api.v1.charts.CustomChartCreate +import com.langsmith_api.api.models.api.v1.charts.CustomChartMetric +import com.langsmith_api.api.models.api.v1.charts.CustomChartPreviewRequest +import com.langsmith_api.api.models.api.v1.charts.CustomChartSeries +import com.langsmith_api.api.models.api.v1.charts.CustomChartSeriesFilters +import com.langsmith_api.api.models.api.v1.charts.CustomChartType +import com.langsmith_api.api.models.api.v1.charts.CustomChartUpdate +import com.langsmith_api.api.models.api.v1.charts.HostProjectChartMetric +import com.langsmith_api.api.models.api.v1.orgcharts.section.CustomChartsRequestBase +import com.langsmith_api.api.models.api.v1.sessions.RunStatsGroupBy +import com.langsmith_api.api.models.api.v1.sessions.TimedeltaInput +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ChartServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val chartService = client.api().v1().charts() + + val customChartResponse = + chartService.create( + CustomChartCreate.builder() + .chartType(CustomChartType.LINE) + .addSeries( + CustomChartCreate.Series.builder() + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .title("title") + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("description") + .index(0L) + .metadata(JsonValue.from(mapOf<String, Any>())) + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + customChartResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val chartService = client.api().v1().charts() + + val customChartResponse = + chartService.update( + ChartUpdateParams.builder() + .chartId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .customChartUpdate( + CustomChartUpdate.builder() + .chartType(CustomChartType.LINE) + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("string") + .index(0L) + .metadata(JsonValue.from(mapOf<String, Any>())) + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .seriesOfCustomChartSeriesUpdates( + listOf( + CustomChartUpdate.Series.CustomChartSeriesUpdate.builder() + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + ) + .title("string") + .build() + ) + .build() + ) + + customChartResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val chartService = client.api().v1().charts() + + val chart = chartService.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + chart.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun preview() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val chartService = client.api().v1().charts() + + val singleCustomChartResponseBase = + chartService.preview( + CustomChartPreviewRequest.builder() + .bucketInfo( + CustomChartsRequestBase.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride(TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build()) + .timezone("timezone") + .build() + ) + .chart( + CustomChartPreviewRequest.Chart.builder() + .addSeries( + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + CustomChartSeries.GroupBy.builder() + .attribute(CustomChartSeries.GroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .setBy(CustomChartSeries.GroupBy.SetBy.SECTION) + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .build() + ) + .build() + ) + + singleCustomChartResponseBase.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/CommentServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/CommentServiceTest.kt new file mode 100644 index 00000000..4a7c2b4c --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/CommentServiceTest.kt @@ -0,0 +1,67 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.comments.CommentRetrieveParams +import com.langsmith_api.api.models.api.v1.comments.CommentUpdateParams +import com.langsmith_api.api.models.api.v1.comments.CreateCommentRequest +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CommentServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val commentService = client.api().v1().comments() + + val listCommentsResponse = + commentService.retrieve( + CommentRetrieveParams.builder() + .owner("owner") + .repo("repo") + .parentCommentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .offset(0L) + .build() + ) + + listCommentsResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val commentService = client.api().v1().comments() + + val comment = + commentService.update( + CommentUpdateParams.builder() + .owner("owner") + .repo("repo") + .parentCommentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createCommentRequest(CreateCommentRequest.builder().content("content").build()) + .build() + ) + + comment.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/CommitServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/CommitServiceTest.kt new file mode 100644 index 00000000..87ec52e5 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/CommitServiceTest.kt @@ -0,0 +1,70 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.commits.CommitRetrieveParams +import com.langsmith_api.api.models.api.v1.commits.CommitUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CommitServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val commitService = client.api().v1().commits() + + val commitManifestResponse = + commitService.retrieve( + CommitRetrieveParams.builder() + .owner("owner") + .repo("repo") + .commit("commit") + .getExamples(true) + .includeModel(true) + .isView(true) + .build() + ) + + commitManifestResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val commitService = client.api().v1().commits() + + val commit = + commitService.update( + CommitUpdateParams.builder() + .owner("owner") + .repo("repo") + .manifest(JsonValue.from(mapOf<String, Any>())) + .addExampleRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .parentCommit("parent_commit") + .skipWebhooks(true) + .build() + ) + + commit.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/DatasetServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/DatasetServiceTest.kt new file mode 100644 index 00000000..78b14568 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/DatasetServiceTest.kt @@ -0,0 +1,583 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.datasets.DataType +import com.langsmith_api.api.models.api.v1.datasets.DatasetCloneParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetCreateParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetGenerateParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetListParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveCsvParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveJsonlParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveOpenAIFtParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveOpenAIParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetRetrieveVersionParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetSearchParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetStudioExperimentParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetTransformation +import com.langsmith_api.api.models.api.v1.datasets.DatasetUpdateParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetUpdateTagsParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetUploadExperimentParams +import com.langsmith_api.api.models.api.v1.datasets.DatasetUploadParams +import com.langsmith_api.api.models.api.v1.datasets.FeedbackCreateCoreSchema +import com.langsmith_api.api.models.api.v1.datasets.SortByDatasetColumn +import com.langsmith_api.api.models.api.v1.feedback.AppFeedbackSource +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfig +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class DatasetServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetService = client.api().v1().datasets() + + val dataset = + datasetService.create( + DatasetCreateParams.builder() + .name("name") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dataType(DataType.KV) + .description("description") + .externallyManaged(true) + .extra(JsonValue.from(mapOf<String, Any>())) + .inputsSchemaDefinition(JsonValue.from(mapOf<String, Any>())) + .outputsSchemaDefinition(JsonValue.from(mapOf<String, Any>())) + .addTransformation( + DatasetTransformation.builder() + .addPath("string") + .transformationType( + DatasetTransformation.TransformationType.CONVERT_TO_OPENAI_MESSAGE + ) + .build() + ) + .build() + ) + + dataset.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetService = client.api().v1().datasets() + + val dataset = datasetService.retrieve("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + dataset.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetService = client.api().v1().datasets() + + val dataset = + datasetService.update( + DatasetUpdateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("string") + .inputsSchemaDefinition(JsonValue.from(mapOf<String, Any>())) + .metadata(JsonValue.from(mapOf<String, Any>())) + .name("string") + .outputsSchemaDefinition(JsonValue.from(mapOf<String, Any>())) + .patchExamples( + DatasetUpdateParams.PatchExamples.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "attachments_operations" to + mapOf( + "rename" to mapOf("foo" to "string"), + "retain" to listOf("string"), + ), + "dataset_id" to "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "inputs" to mapOf<String, Any>(), + "metadata" to mapOf<String, Any>(), + "outputs" to mapOf<String, Any>(), + "overwrite" to true, + "split" to listOf("string"), + ) + ), + ) + .build() + ) + .transformationsOfDataset( + listOf( + DatasetTransformation.builder() + .addPath("string") + .transformationType( + DatasetTransformation.TransformationType + .CONVERT_TO_OPENAI_MESSAGE + ) + .build() + ) + ) + .build() + ) + + dataset.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetService = client.api().v1().datasets() + + val datasets = + datasetService.list( + DatasetListParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dataTypeOfTypes(listOf(DataType.KV)) + .excludeCorrectionsDatasets(true) + .limit(1L) + .metadata("metadata") + .name("name") + .nameContains("name_contains") + .offset(0L) + .sortBy(SortByDatasetColumn.NAME) + .sortByDesc(true) + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + datasets.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetService = client.api().v1().datasets() + + val dataset = datasetService.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + dataset.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun clone() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetService = client.api().v1().datasets() + + val response = + datasetService.clone( + DatasetCloneParams.builder() + .sourceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .targetDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + response.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun generate() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetService = client.api().v1().datasets() + + val response = + datasetService.generate( + DatasetGenerateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .numExamples(0L) + .addExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveCsv() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetService = client.api().v1().datasets() + + val response = + datasetService.retrieveCsv( + DatasetRetrieveCsvParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveJsonl() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetService = client.api().v1().datasets() + + val response = + datasetService.retrieveJsonl( + DatasetRetrieveJsonlParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveOpenAI() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetService = client.api().v1().datasets() + + val response = + datasetService.retrieveOpenAI( + DatasetRetrieveOpenAIParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveOpenAIFt() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetService = client.api().v1().datasets() + + val response = + datasetService.retrieveOpenAIFt( + DatasetRetrieveOpenAIFtParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveVersion() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetService = client.api().v1().datasets() + + val datasetVersion = + datasetService.retrieveVersion( + DatasetRetrieveVersionParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tag("tag") + .build() + ) + + datasetVersion.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun search() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetService = client.api().v1().datasets() + + val response = + datasetService.search( + DatasetSearchParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .debug(true) + .filter("filter") + .limit(1L) + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun studioExperiment() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetService = client.api().v1().datasets() + + val response = + datasetService.studioExperiment( + DatasetStudioExperimentParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .addEvaluatorRule("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun updateTags() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetService = client.api().v1().datasets() + + val datasetVersion = + datasetService.updateTags( + DatasetUpdateTagsParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .tag("tag") + .build() + ) + + datasetVersion.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun upload() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetService = client.api().v1().datasets() + + val dataset = + datasetService.upload( + DatasetUploadParams.builder() + .file("some content".byteInputStream()) + .addInputKey("string") + .dataType(DataType.KV) + .description("description") + .inputKeyMappings("input_key_mappings") + .inputsSchemaDefinition("inputs_schema_definition") + .metadataKeyMappings("metadata_key_mappings") + .addMetadataKey("string") + .name("name") + .outputKeyMappings("output_key_mappings") + .addOutputKey("string") + .outputsSchemaDefinition("outputs_schema_definition") + .transformations("transformations") + .build() + ) + + dataset.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun uploadExperiment() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetService = client.api().v1().datasets() + + val response = + datasetService.uploadExperiment( + DatasetUploadExperimentParams.builder() + .experimentEndTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .experimentName("experiment_name") + .experimentStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addResult( + DatasetUploadExperimentParams.Result.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inputs(JsonValue.from(mapOf<String, Any>())) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .actualOutputs(JsonValue.from(mapOf<String, Any>())) + .error("error") + .addEvaluationScore( + FeedbackCreateCoreSchema.builder() + .key("key") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .correction(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder() + .value(0.0) + .label("x") + .build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .feedbackGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackSource( + AppFeedbackSource.builder() + .metadata(JsonValue.from(mapOf<String, Any>())) + .type("type") + .build() + ) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .score(0.0) + .value(0.0) + .build() + ) + .expectedOutputs(JsonValue.from(mapOf<String, Any>())) + .rowId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runMetadata(JsonValue.from(mapOf<String, Any>())) + .runName("run_name") + .build() + ) + .datasetDescription("dataset_description") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetName("dataset_name") + .experimentDescription("experiment_description") + .experimentMetadata(JsonValue.from(mapOf<String, Any>())) + .addSummaryExperimentScore( + FeedbackCreateCoreSchema.builder() + .key("key") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .correction(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder() + .value(0.0) + .label("x") + .build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .feedbackGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackSource( + AppFeedbackSource.builder() + .metadata(JsonValue.from(mapOf<String, Any>())) + .type("type") + .build() + ) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .score(0.0) + .value(0.0) + .build() + ) + .build() + ) + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/ExampleServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/ExampleServiceTest.kt new file mode 100644 index 00000000..928e70b4 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/ExampleServiceTest.kt @@ -0,0 +1,184 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.examples.ExampleDeleteAllParams +import com.langsmith_api.api.models.api.v1.examples.ExampleListParams +import com.langsmith_api.api.models.api.v1.examples.ExampleRetrieveCountParams +import com.langsmith_api.api.models.api.v1.examples.ExampleRetrieveParams +import com.langsmith_api.api.models.api.v1.examples.ExampleSelect +import com.langsmith_api.api.models.api.v1.examples.ExampleUpdateParams +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ExampleServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val exampleService = client.api().v1().examples() + + val example = exampleService.create() + + example.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val exampleService = client.api().v1().examples() + + val example = + exampleService.retrieve( + ExampleRetrieveParams.builder() + .exampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + example.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val exampleService = client.api().v1().examples() + + val examples = + exampleService.update( + ExampleUpdateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .file("some content".byteInputStream()) + .addInputKey("string") + .addMetadataKey("string") + .addOutputKey("string") + .build() + ) + + examples.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val exampleService = client.api().v1().examples() + + val examples = + exampleService.list( + ExampleListParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .descending(true) + .filter("filter") + .addFullTextContain("string") + .limit(1L) + .metadata("metadata") + .offset(0L) + .order(ExampleListParams.Order.RECENT) + .randomSeed(0.0) + .addSelect(ExampleSelect.ID) + .addSplit("string") + .build() + ) + + examples.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val exampleService = client.api().v1().examples() + + val example = exampleService.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + example.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun deleteAll() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val exampleService = client.api().v1().examples() + + val response = + exampleService.deleteAll( + ExampleDeleteAllParams.builder() + .addExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveCount() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val exampleService = client.api().v1().examples() + + exampleService.retrieveCount( + ExampleRetrieveCountParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .filter("filter") + .addFullTextContain("string") + .metadata("metadata") + .addSplit("string") + .build() + ) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/FeedbackConfigServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/FeedbackConfigServiceTest.kt new file mode 100644 index 00000000..0e4972ee --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/FeedbackConfigServiceTest.kt @@ -0,0 +1,106 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfig +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfigFeedbackConfigsParams +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfigRetrieveFeedbackConfigsParams +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfigUpdateFeedbackConfigsParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class FeedbackConfigServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun feedbackConfigs() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val feedbackConfigService = client.api().v1().feedbackConfigs() + + val feedbackConfigSchema = + feedbackConfigService.feedbackConfigs( + FeedbackConfigFeedbackConfigsParams.builder() + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder().value(0.0).label("x").build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .feedbackKey("feedback_key") + .isLowerScoreBetter(true) + .build() + ) + + feedbackConfigSchema.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveFeedbackConfigs() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val feedbackConfigService = client.api().v1().feedbackConfigs() + + val feedbackConfigSchemata = + feedbackConfigService.retrieveFeedbackConfigs( + FeedbackConfigRetrieveFeedbackConfigsParams.builder() + .addKey("string") + .readAfterWrite(true) + .build() + ) + + feedbackConfigSchemata.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun updateFeedbackConfigs() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val feedbackConfigService = client.api().v1().feedbackConfigs() + + val feedbackConfigSchema = + feedbackConfigService.updateFeedbackConfigs( + FeedbackConfigUpdateFeedbackConfigsParams.builder() + .feedbackKey("feedback_key") + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder().value(0.0).label("x").build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .isLowerScoreBetter(true) + .build() + ) + + feedbackConfigSchema.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/FeedbackServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/FeedbackServiceTest.kt new file mode 100644 index 00000000..37ee6287 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/FeedbackServiceTest.kt @@ -0,0 +1,235 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.feedback.AppFeedbackSource +import com.langsmith_api.api.models.api.v1.feedback.FeedbackCreateSchema +import com.langsmith_api.api.models.api.v1.feedback.FeedbackLevel +import com.langsmith_api.api.models.api.v1.feedback.FeedbackListParams +import com.langsmith_api.api.models.api.v1.feedback.FeedbackRetrieveParams +import com.langsmith_api.api.models.api.v1.feedback.FeedbackUpdateParams +import com.langsmith_api.api.models.api.v1.feedback.SourceType +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfig +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class FeedbackServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val feedbackService = client.api().v1().feedback() + + val feedbackSchema = + feedbackService.create( + FeedbackCreateSchema.builder() + .key("key") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .correction(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder().value(0.0).label("x").build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .feedbackGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackSource( + AppFeedbackSource.builder() + .metadata(JsonValue.from(mapOf<String, Any>())) + .type("type") + .build() + ) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .score(0.0) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .value(0.0) + .build() + ) + + feedbackSchema.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val feedbackService = client.api().v1().feedback() + + val feedbackSchema = + feedbackService.retrieve( + FeedbackRetrieveParams.builder() + .feedbackId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .includeUserNames(true) + .build() + ) + + feedbackSchema.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val feedbackService = client.api().v1().feedback() + + val feedbackSchema = + feedbackService.update( + FeedbackUpdateParams.builder() + .feedbackId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") + .correction(JsonValue.from(mapOf<String, Any>())) + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder().value(0.0).label("x").build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .score(0.0) + .value(0.0) + .build() + ) + + feedbackSchema.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val feedbackService = client.api().v1().feedback() + + val feedbackSchemata = + feedbackService.list( + FeedbackListParams.builder() + .hasComment(true) + .hasScore(true) + .includeUserNames(true) + .addKey("string") + .level(FeedbackLevel.RUN) + .limit(1L) + .maxCreatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minCreatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .offset(0L) + .addRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addSource(SourceType.API) + .addUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + feedbackSchemata.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val feedbackService = client.api().v1().feedback() + + val feedback = feedbackService.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + feedback.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun eager() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val feedbackService = client.api().v1().feedback() + + val feedbackSchema = + feedbackService.eager( + FeedbackCreateSchema.builder() + .key("key") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .correction(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder().value(0.0).label("x").build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .feedbackGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackSource( + AppFeedbackSource.builder() + .metadata(JsonValue.from(mapOf<String, Any>())) + .type("type") + .build() + ) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .score(0.0) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .value(0.0) + .build() + ) + + feedbackSchema.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/InfoServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/InfoServiceTest.kt new file mode 100644 index 00000000..08d6a79f --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/InfoServiceTest.kt @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class InfoServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val infoService = client.api().v1().info() + + val infos = infoService.list() + + infos.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveHealth() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val infoService = client.api().v1().info() + + val response = infoService.retrieveHealth() + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/MeServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/MeServiceTest.kt new file mode 100644 index 00000000..91243e0d --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/MeServiceTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class MeServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieveLsUserId() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val meService = client.api().v1().me() + + meService.retrieveLsUserId() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/ModelPriceMapServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/ModelPriceMapServiceTest.kt new file mode 100644 index 00000000..91c5a791 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/ModelPriceMapServiceTest.kt @@ -0,0 +1,128 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.modelpricemap.ModelPriceMapModelPriceMapParams +import com.langsmith_api.api.models.api.v1.modelpricemap.ModelPriceMapUpdateParams +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ModelPriceMapServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val modelPriceMapService = client.api().v1().modelPriceMap() + + val modelPriceMap = + modelPriceMapService.update( + ModelPriceMapUpdateParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost(0.0) + .matchPattern("match_pattern") + .name("name") + .promptCost(0.0) + .completionCostDetails( + ModelPriceMapUpdateParams.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .addMatchPath("string") + .promptCostDetails( + ModelPriceMapUpdateParams.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .provider("provider") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + modelPriceMap.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val modelPriceMapService = client.api().v1().modelPriceMap() + + val modelPriceMap = modelPriceMapService.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + modelPriceMap.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun modelPriceMap() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val modelPriceMapService = client.api().v1().modelPriceMap() + + val response = + modelPriceMapService.modelPriceMap( + ModelPriceMapModelPriceMapParams.builder() + .completionCost(0.0) + .matchPattern("match_pattern") + .name("name") + .promptCost(0.0) + .completionCostDetails( + ModelPriceMapModelPriceMapParams.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .addMatchPath("string") + .promptCostDetails( + ModelPriceMapModelPriceMapParams.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .provider("provider") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveModelPriceMap() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val modelPriceMapService = client.api().v1().modelPriceMap() + + val response = modelPriceMapService.retrieveModelPriceMap() + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/OAuthServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/OAuthServiceTest.kt new file mode 100644 index 00000000..0829d35f --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/OAuthServiceTest.kt @@ -0,0 +1,82 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.oauth.OAuthProvider +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class OAuthServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val oauthService = client.api().v1().oauth() + + val oauth = oauthService.retrieve(OAuthProvider.CUSTOM_OIDC) + + oauth.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveCallback() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val oauthService = client.api().v1().oauth() + + val response = oauthService.retrieveCallback(OAuthProvider.CUSTOM_OIDC) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveCurrentUser() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val oauthService = client.api().v1().oauth() + + val response = oauthService.retrieveCurrentUser(OAuthProvider.CUSTOM_OIDC) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveLogout() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val oauthService = client.api().v1().oauth() + + val response = oauthService.retrieveLogout(OAuthProvider.CUSTOM_OIDC) + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/OrgChartServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/OrgChartServiceTest.kt new file mode 100644 index 00000000..9bf0ed85 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/OrgChartServiceTest.kt @@ -0,0 +1,267 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.charts.CustomChartCreate +import com.langsmith_api.api.models.api.v1.charts.CustomChartMetric +import com.langsmith_api.api.models.api.v1.charts.CustomChartPreviewRequest +import com.langsmith_api.api.models.api.v1.charts.CustomChartSeries +import com.langsmith_api.api.models.api.v1.charts.CustomChartSeriesFilters +import com.langsmith_api.api.models.api.v1.charts.CustomChartType +import com.langsmith_api.api.models.api.v1.charts.CustomChartUpdate +import com.langsmith_api.api.models.api.v1.charts.CustomChartsRequest +import com.langsmith_api.api.models.api.v1.charts.HostProjectChartMetric +import com.langsmith_api.api.models.api.v1.orgcharts.OrgChartUpdateParams +import com.langsmith_api.api.models.api.v1.orgcharts.section.CustomChartsRequestBase +import com.langsmith_api.api.models.api.v1.sessions.RunStatsGroupBy +import com.langsmith_api.api.models.api.v1.sessions.TimedeltaInput +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class OrgChartServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val orgChartService = client.api().v1().orgCharts() + + val customChartResponse = + orgChartService.create( + CustomChartCreate.builder() + .chartType(CustomChartType.LINE) + .addSeries( + CustomChartCreate.Series.builder() + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .title("title") + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("description") + .index(0L) + .metadata(JsonValue.from(mapOf<String, Any>())) + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + customChartResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val orgChartService = client.api().v1().orgCharts() + + val customChartResponse = + orgChartService.update( + OrgChartUpdateParams.builder() + .chartId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .customChartUpdate( + CustomChartUpdate.builder() + .chartType(CustomChartType.LINE) + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("string") + .index(0L) + .metadata(JsonValue.from(mapOf<String, Any>())) + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .seriesOfCustomChartSeriesUpdates( + listOf( + CustomChartUpdate.Series.CustomChartSeriesUpdate.builder() + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + ) + .title("string") + .build() + ) + .build() + ) + + customChartResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val orgChartService = client.api().v1().orgCharts() + + val orgChart = orgChartService.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + orgChart.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun orgCharts() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val orgChartService = client.api().v1().orgCharts() + + val customChartsResponse = + orgChartService.orgCharts( + CustomChartsRequest.builder() + .afterIndex(0L) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride(TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build()) + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .timezone("timezone") + .build() + ) + + customChartsResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun preview() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val orgChartService = client.api().v1().orgCharts() + + val singleCustomChartResponseBase = + orgChartService.preview( + CustomChartPreviewRequest.builder() + .bucketInfo( + CustomChartsRequestBase.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride(TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build()) + .timezone("timezone") + .build() + ) + .chart( + CustomChartPreviewRequest.Chart.builder() + .addSeries( + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + CustomChartSeries.GroupBy.builder() + .attribute(CustomChartSeries.GroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .setBy(CustomChartSeries.GroupBy.SetBy.SECTION) + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .build() + ) + .build() + ) + + singleCustomChartResponseBase.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/OrgServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/OrgServiceTest.kt new file mode 100644 index 00000000..0dbb6214 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/OrgServiceTest.kt @@ -0,0 +1,70 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.orgs.OrgCreateParams +import com.langsmith_api.api.models.api.v1.orgs.OrgListParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class OrgServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val orgService = client.api().v1().orgs() + + val organizationPgSchemaSlim = + orgService.create( + OrgCreateParams.builder().displayName("display_name").isPersonal(true).build() + ) + + organizationPgSchemaSlim.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val orgService = client.api().v1().orgs() + + val organizationPgSchemaSlims = + orgService.list(OrgListParams.builder().includeTier(true).skipCreate(true).build()) + + organizationPgSchemaSlims.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun retrievePermissions() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val orgService = client.api().v1().orgs() + + val response = orgService.retrievePermissions() + + response.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/PlaygroundSettingServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/PlaygroundSettingServiceTest.kt new file mode 100644 index 00000000..d38c2b7e --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/PlaygroundSettingServiceTest.kt @@ -0,0 +1,102 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.playgroundsettings.PlaygroundSavedOptions +import com.langsmith_api.api.models.api.v1.playgroundsettings.PlaygroundSettingPlaygroundSettingsParams +import com.langsmith_api.api.models.api.v1.playgroundsettings.PlaygroundSettingUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class PlaygroundSettingServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val playgroundSettingService = client.api().v1().playgroundSettings() + + val playgroundSettingsResponse = + playgroundSettingService.update( + PlaygroundSettingUpdateParams.builder() + .playgroundSettingsId("playground_settings_id") + .description("description") + .name("name") + .options(PlaygroundSavedOptions.builder().requestsPerSecond(0L).build()) + .settings(JsonValue.from(mapOf<String, Any>())) + .build() + ) + + playgroundSettingsResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val playgroundSettingService = client.api().v1().playgroundSettings() + + val playgroundSetting = playgroundSettingService.delete("playground_settings_id") + + playgroundSetting.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun playgroundSettings() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val playgroundSettingService = client.api().v1().playgroundSettings() + + val playgroundSettingsResponse = + playgroundSettingService.playgroundSettings( + PlaygroundSettingPlaygroundSettingsParams.builder() + .settings(JsonValue.from(mapOf<String, Any>())) + .description("description") + .name("name") + .options(PlaygroundSavedOptions.builder().requestsPerSecond(0L).build()) + .build() + ) + + playgroundSettingsResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrievePlaygroundSettings() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val playgroundSettingService = client.api().v1().playgroundSettings() + + val playgroundSettingsResponses = playgroundSettingService.retrievePlaygroundSettings() + + playgroundSettingsResponses.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/PromptServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/PromptServiceTest.kt new file mode 100644 index 00000000..1878aa1d --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/PromptServiceTest.kt @@ -0,0 +1,146 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.prompts.InvalidToolCall +import com.langsmith_api.api.models.api.v1.prompts.PromptCanvasParams +import com.langsmith_api.api.models.api.v1.prompts.PromptInvokePromptParams +import com.langsmith_api.api.models.api.v1.prompts.ToolCall +import com.langsmith_api.api.models.api.v1.prompts.UsageMetadata +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class PromptServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun canvas() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val promptService = client.api().v1().prompts() + + val response = + promptService.canvas( + PromptCanvasParams.builder() + .addMessage( + PromptCanvasParams.Message.AiMessage.builder() + .content("string") + .id("id") + .additionalKwargs(JsonValue.from(mapOf<String, Any>())) + .addInvalidToolCall( + InvalidToolCall.builder() + .id("id") + .args("args") + .error("error") + .name("name") + .extras(JsonValue.from(mapOf<String, Any>())) + .index(0L) + .build() + ) + .name("name") + .responseMetadata(JsonValue.from(mapOf<String, Any>())) + .addToolCall( + ToolCall.builder() + .id("id") + .args(JsonValue.from(mapOf<String, Any>())) + .name("name") + .type(ToolCall.Type.TOOL_CALL) + .build() + ) + .type(PromptCanvasParams.Message.AiMessage.Type.AI) + .usageMetadata( + UsageMetadata.builder() + .inputTokens(0L) + .outputTokens(0L) + .totalTokens(0L) + .inputTokenDetails( + UsageMetadata.InputTokenDetails.builder() + .audio(0L) + .cacheCreation(0L) + .cacheRead(0L) + .build() + ) + .outputTokenDetails( + UsageMetadata.OutputTokenDetails.builder() + .audio(0L) + .reasoning(0L) + .build() + ) + .build() + ) + .build() + ) + .secrets( + PromptCanvasParams.Secrets.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .templateFormat(PromptCanvasParams.TemplateFormat.F_STRING) + .artifact( + PromptCanvasParams.Artifact.builder() + .id("id") + .addContent( + PromptCanvasParams.Artifact.Content.builder() + .content("content") + .index(0L) + .build() + ) + .currentContentIndex(0L) + .build() + ) + .artifactLength(PromptCanvasParams.ArtifactLength.SHORTEST) + .customAction("custom_action") + .highlighted( + PromptCanvasParams.Highlighted.builder() + .highlightText("highlight_text") + .promptChunk("prompt_chunk") + .promptChunkEndIndex(0L) + .promptChunkStartIndex(0L) + .build() + ) + .readingLevel(PromptCanvasParams.ReadingLevel.CHILD) + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun invokePrompt() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val promptService = client.api().v1().prompts() + + val response = + promptService.invokePrompt( + PromptInvokePromptParams.builder() + .inputs(JsonValue.from(mapOf<String, Any>())) + .addMessage( + listOf( + JsonValue.from(mapOf<String, Any>()), + JsonValue.from(mapOf<String, Any>()), + ) + ) + .templateFormat("template_format") + .build() + ) + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/PromptWebhookServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/PromptWebhookServiceTest.kt new file mode 100644 index 00000000..7278ac1d --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/PromptWebhookServiceTest.kt @@ -0,0 +1,165 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.promptwebhooks.EPromptWebhookTrigger +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhookPromptWebhooksParams +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhookTestParams +import com.langsmith_api.api.models.api.v1.promptwebhooks.PromptWebhookUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class PromptWebhookServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val promptWebhookService = client.api().v1().promptWebhooks() + + val promptWebhook = promptWebhookService.retrieve("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + promptWebhook.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val promptWebhookService = client.api().v1().promptWebhooks() + + val promptWebhook = + promptWebhookService.update( + PromptWebhookUpdateParams.builder() + .webhookId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addExcludePrompt("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .headers(JsonValue.from(mapOf<String, Any>())) + .addIncludePrompt("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addTrigger(EPromptWebhookTrigger.COMMIT) + .url("https://example.com") + .build() + ) + + promptWebhook.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val promptWebhookService = client.api().v1().promptWebhooks() + + val promptWebhook = promptWebhookService.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + promptWebhook.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun promptWebhooks() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val promptWebhookService = client.api().v1().promptWebhooks() + + val promptWebhook = + promptWebhookService.promptWebhooks( + PromptWebhookPromptWebhooksParams.builder() + .url("https://example.com") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addExcludePrompt("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .headers(JsonValue.from(mapOf<String, Any>())) + .addIncludePrompt("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addTrigger(EPromptWebhookTrigger.COMMIT) + .build() + ) + + promptWebhook.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrievePromptWebhooks() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val promptWebhookService = client.api().v1().promptWebhooks() + + val promptWebhooks = promptWebhookService.retrievePromptWebhooks() + + promptWebhooks.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun test() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val promptWebhookService = client.api().v1().promptWebhooks() + + val response = + promptWebhookService.test( + PromptWebhookTestParams.builder() + .payload( + PromptWebhookTestParams.Payload.builder() + .commitHash("commit_hash") + .createdAt("created_at") + .createdBy("created_by") + .event(EPromptWebhookTrigger.COMMIT) + .manifest(JsonValue.from(mapOf<String, Any>())) + .promptId("prompt_id") + .promptName("prompt_name") + .tagName("tag_name") + .build() + ) + .webhook( + PromptWebhookTestParams.Webhook.builder() + .url("https://example.com") + .addExcludePrompt("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .headers(JsonValue.from(mapOf<String, Any>())) + .addIncludePrompt("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addTrigger(EPromptWebhookTrigger.COMMIT) + .build() + ) + .build() + ) + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/PublicServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/PublicServiceTest.kt new file mode 100644 index 00000000..01d41ca9 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/PublicServiceTest.kt @@ -0,0 +1,48 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.feedback.FeedbackLevel +import com.langsmith_api.api.models.api.v1.feedback.SourceType +import com.langsmith_api.api.models.api.v1.public_.PublicRetrieveFeedbacksParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class PublicServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieveFeedbacks() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val publicService = client.api().v1().public_() + + val feedbackSchemata = + publicService.retrieveFeedbacks( + PublicRetrieveFeedbacksParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .hasComment(true) + .hasScore(true) + .addKey("string") + .level(FeedbackLevel.RUN) + .limit(1L) + .offset(0L) + .addRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addSource(SourceType.API) + .addUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + feedbackSchemata.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/RepoServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/RepoServiceTest.kt new file mode 100644 index 00000000..046db87d --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/RepoServiceTest.kt @@ -0,0 +1,212 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.repos.EPromptOptimizationAlgorithm +import com.langsmith_api.api.models.api.v1.repos.PromptimConfig +import com.langsmith_api.api.models.api.v1.repos.RepoCreateParams +import com.langsmith_api.api.models.api.v1.repos.RepoDeleteParams +import com.langsmith_api.api.models.api.v1.repos.RepoForkParams +import com.langsmith_api.api.models.api.v1.repos.RepoListParams +import com.langsmith_api.api.models.api.v1.repos.RepoOptimizeJobParams +import com.langsmith_api.api.models.api.v1.repos.RepoRetrieveParams +import com.langsmith_api.api.models.api.v1.repos.RepoUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class RepoServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val repoService = client.api().v1().repos() + + val createRepoResponse = + repoService.create( + RepoCreateParams.builder() + .isPublic(true) + .repoHandle("repo_handle") + .description("description") + .readme("readme") + .addTag("string") + .build() + ) + + createRepoResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val repoService = client.api().v1().repos() + + val getRepoResponse = + repoService.retrieve(RepoRetrieveParams.builder().owner("owner").repo("repo").build()) + + getRepoResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val repoService = client.api().v1().repos() + + val createRepoResponse = + repoService.update( + RepoUpdateParams.builder() + .owner("owner") + .repo("repo") + .description("description") + .isArchived(true) + .isPublic(true) + .readme("readme") + .addTag("string") + .build() + ) + + createRepoResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val repoService = client.api().v1().repos() + + val repos = + repoService.list( + RepoListParams.builder() + .hasCommits(true) + .isArchived(RepoListParams.IsArchived.TRUE) + .isPublic(RepoListParams.IsPublic.TRUE) + .limit(1L) + .offset(0L) + .query("query") + .sortDirection(RepoListParams.SortDirection.ASC) + .sortField(RepoListParams.SortField.NUM_LIKES) + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addTag("string") + .tenantHandle("tenant_handle") + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .upstreamRepoHandle("upstream_repo_handle") + .upstreamRepoOwner("upstream_repo_owner") + .withLatestManifest(true) + .build() + ) + + repos.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val repoService = client.api().v1().repos() + + val repo = + repoService.delete(RepoDeleteParams.builder().owner("owner").repo("repo").build()) + + repo.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun fork() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val repoService = client.api().v1().repos() + + val getRepoResponse = + repoService.fork( + RepoForkParams.builder() + .owner("owner") + .repo("repo") + .repoHandle("repo_handle") + .description("description") + .isPublic(true) + .readme("readme") + .addTag("string") + .build() + ) + + getRepoResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun optimizeJob() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val repoService = client.api().v1().repos() + + val response = + repoService.optimizeJob( + RepoOptimizeJobParams.builder() + .algorithm(EPromptOptimizationAlgorithm.PROMPTIM) + .config( + PromptimConfig.builder() + .autoCommit(true) + .datasetName("dataset_name") + .devSplit("dev_split") + .addEvaluator("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .messageIndex(0L) + .numEpochs(0L) + .taskDescription("task_description") + .testSplit("test_split") + .trainSplit("train_split") + .build() + ) + .promptName("prompt_name") + .build() + ) + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/RunServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/RunServiceTest.kt new file mode 100644 index 00000000..acaee369 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/RunServiceTest.kt @@ -0,0 +1,211 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.runs.BodyParamsForRunSchema +import com.langsmith_api.api.models.api.v1.runs.RequestBodyForRunsGenerateQuery +import com.langsmith_api.api.models.api.v1.runs.RunDeleteParams +import com.langsmith_api.api.models.api.v1.runs.RunRetrieveParams +import com.langsmith_api.api.models.api.v1.runs.RunStatsQueryParams +import com.langsmith_api.api.models.api.v1.runs.RunTypeEnum +import com.langsmith_api.api.models.api.v1.runs.RunsFilterDataSourceTypeEnum +import com.langsmith_api.api.models.api.v1.sessions.RunStatsGroupBy +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class RunServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runService = client.api().v1().runs() + + val runSchema = + runService.retrieve( + RunRetrieveParams.builder() + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .excludeS3StoredAttributes(true) + .excludeSerialized(true) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + runSchema.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runService = client.api().v1().runs() + + val run = runService.update("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + run.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runService = client.api().v1().runs() + + val run = + runService.delete( + RunDeleteParams.builder() + .metadata( + RunDeleteParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addTraceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + run.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun generateQuery() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runService = client.api().v1().runs() + + val responseBodyForRunsGenerateQuery = + runService.generateQuery( + RequestBodyForRunsGenerateQuery.builder() + .query("query") + .addFeedbackKey(RequestBodyForRunsGenerateQuery.FeedbackKey.USER_SCORE) + .build() + ) + + responseBodyForRunsGenerateQuery.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun query() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runService = client.api().v1().runs() + + val response = + runService.query( + BodyParamsForRunSchema.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .dataSourceType(RunsFilterDataSourceTypeEnum.CURRENT) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .executionOrder(1L) + .filter("filter") + .isRoot(true) + .limit(1L) + .order(BodyParamsForRunSchema.Order.ASC) + .parentRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .query("query") + .addReferenceExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runType(RunTypeEnum.TOOL) + .searchFilter("search_filter") + .addSelect(BodyParamsForRunSchema.Select.ID) + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .skipPagination(true) + .skipPrevCursor(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .trace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .useExperimentalSearch(true) + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun stats() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runService = client.api().v1().runs() + + val response = + runService.stats( + RunStatsQueryParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dataSourceType(RunsFilterDataSourceTypeEnum.CURRENT) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .executionOrder(1L) + .filter("filter") + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .addGroup("string") + .isRoot(true) + .parentRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .query("query") + .addReferenceExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runType(RunTypeEnum.TOOL) + .searchFilter("search_filter") + .addSelect(RunStatsQueryParams.Select.RUN_COUNT) + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .skipPagination(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .trace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .useExperimentalSearch(true) + .build() + ) + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/ServiceAccountServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/ServiceAccountServiceTest.kt new file mode 100644 index 00000000..303e5c88 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/ServiceAccountServiceTest.kt @@ -0,0 +1,76 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.serviceaccounts.ServiceAccountServiceAccountsParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ServiceAccountServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val serviceAccountService = client.api().v1().serviceAccounts() + + val serviceAccount = serviceAccountService.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + serviceAccount.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveServiceAccounts() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val serviceAccountService = client.api().v1().serviceAccounts() + + val response = serviceAccountService.retrieveServiceAccounts() + + response.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun serviceAccounts() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val serviceAccountService = client.api().v1().serviceAccounts() + + val response = + serviceAccountService.serviceAccounts( + ServiceAccountServiceAccountsParams.builder() + .name("name") + .addWorkspace( + ServiceAccountServiceAccountsParams.Workspace.builder() + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + ) + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/SessionServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/SessionServiceTest.kt new file mode 100644 index 00000000..082b6fe9 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/SessionServiceTest.kt @@ -0,0 +1,255 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TraceTier +import com.langsmith_api.api.models.api.v1.sessions.CustomChartsSectionRequest +import com.langsmith_api.api.models.api.v1.sessions.RunStatsGroupBy +import com.langsmith_api.api.models.api.v1.sessions.SessionCreateParams +import com.langsmith_api.api.models.api.v1.sessions.SessionDashboardParams +import com.langsmith_api.api.models.api.v1.sessions.SessionDeleteAllParams +import com.langsmith_api.api.models.api.v1.sessions.SessionListParams +import com.langsmith_api.api.models.api.v1.sessions.SessionRetrieveMetadataParams +import com.langsmith_api.api.models.api.v1.sessions.SessionRetrieveParams +import com.langsmith_api.api.models.api.v1.sessions.SessionSortableColumns +import com.langsmith_api.api.models.api.v1.sessions.SessionUpdateParams +import com.langsmith_api.api.models.api.v1.sessions.TimedeltaInput +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class SessionServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val sessionService = client.api().v1().sessions() + + val tracerSessionWithoutVirtualFields = + sessionService.create( + SessionCreateParams.builder() + .upsert(true) + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .defaultDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .extra(JsonValue.from(mapOf<String, Any>())) + .name("name") + .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceTier(TraceTier.LONGLIVED) + .build() + ) + + tracerSessionWithoutVirtualFields.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val sessionService = client.api().v1().sessions() + + val tracerSession = + sessionService.retrieve( + SessionRetrieveParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .includeStats(true) + .statsStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .accept("accept") + .build() + ) + + tracerSession.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val sessionService = client.api().v1().sessions() + + val tracerSessionWithoutVirtualFields = + sessionService.update( + SessionUpdateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .defaultDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .extra(JsonValue.from(mapOf<String, Any>())) + .name("name") + .traceTier(TraceTier.LONGLIVED) + .build() + ) + + tracerSessionWithoutVirtualFields.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val sessionService = client.api().v1().sessions() + + val tracerSessions = + sessionService.list( + SessionListParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .facets(true) + .filter("filter") + .includeStats(true) + .limit(1L) + .metadata("metadata") + .name("name") + .nameContains("name_contains") + .offset(0L) + .addReferenceDataset("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .referenceFree(true) + .sortBy(SessionSortableColumns.NAME) + .sortByDesc(true) + .sortByFeedbackKey("sort_by_feedback_key") + .statsStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .useApproxStats(true) + .accept("accept") + .build() + ) + + tracerSessions.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val sessionService = client.api().v1().sessions() + + val session = sessionService.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + session.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun dashboard() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val sessionService = client.api().v1().sessions() + + val customChartsSection = + sessionService.dashboard( + SessionDashboardParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accept("accept") + .customChartsSectionRequest( + CustomChartsSectionRequest.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .omitData(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .stride(TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build()) + .timezone("timezone") + .build() + ) + .build() + ) + + customChartsSection.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun deleteAll() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val sessionService = client.api().v1().sessions() + + val response = + sessionService.deleteAll( + SessionDeleteAllParams.builder() + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveMetadata() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val sessionService = client.api().v1().sessions() + + val response = + sessionService.retrieveMetadata( + SessionRetrieveMetadataParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .k(1L) + .addMetadataKey("string") + .rootRunsOnly(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/SettingServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/SettingServiceTest.kt new file mode 100644 index 00000000..adc84341 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/SettingServiceTest.kt @@ -0,0 +1,51 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.settings.SettingHandleParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class SettingServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val settingService = client.api().v1().settings() + + val appHubCrudTenantsTenant = settingService.list() + + appHubCrudTenantsTenant.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun handle() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val settingService = client.api().v1().settings() + + val appHubCrudTenantsTenant = + settingService.handle( + SettingHandleParams.builder().tenantHandle("tenant_handle").build() + ) + + appHubCrudTenantsTenant.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/SsoServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/SsoServiceTest.kt new file mode 100644 index 00000000..29d765fd --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/SsoServiceTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class SsoServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val ssoService = client.api().v1().sso() + + val ssos = ssoService.retrieve("sso_login_slug") + + ssos.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/TenantServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/TenantServiceTest.kt new file mode 100644 index 00000000..d1c8a1d0 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/TenantServiceTest.kt @@ -0,0 +1,61 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.tenants.TenantCreateParams +import com.langsmith_api.api.models.api.v1.tenants.TenantListParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class TenantServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tenantService = client.api().v1().tenants() + + val appSchemasTenant = + tenantService.create( + TenantCreateParams.builder() + .displayName("display_name") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .isPersonal(true) + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tenantHandle("tenant_handle") + .build() + ) + + appSchemasTenant.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tenantService = client.api().v1().tenants() + + val tenantForUsers = + tenantService.list( + TenantListParams.builder().includeDeleted(true).skipCreate(true).build() + ) + + tenantForUsers.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/TtlSettingServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/TtlSettingServiceTest.kt new file mode 100644 index 00000000..60adc470 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/TtlSettingServiceTest.kt @@ -0,0 +1,56 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TraceTier +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.UpsertTtlSettingsRequest +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class TtlSettingServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieveTtlSettings() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val ttlSettingService = client.api().v1().ttlSettings() + + val ttlSettings = ttlSettingService.retrieveTtlSettings() + + ttlSettings.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun updateTtlSettings() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val ttlSettingService = client.api().v1().ttlSettings() + + val ttlSettings = + ttlSettingService.updateTtlSettings( + UpsertTtlSettingsRequest.builder() + .defaultTraceTier(TraceTier.LONGLIVED) + .applyToAllProjects(true) + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + ttlSettings.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/UsageLimitServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/UsageLimitServiceTest.kt new file mode 100644 index 00000000..22bbadfd --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/UsageLimitServiceTest.kt @@ -0,0 +1,90 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.usagelimits.UsageLimitType +import com.langsmith_api.api.models.api.v1.usagelimits.UsageLimitUpdateUsageLimitsParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class UsageLimitServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val usageLimitService = client.api().v1().usageLimits() + + val usageLimit = usageLimitService.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + usageLimit.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveOrg() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val usageLimitService = client.api().v1().usageLimits() + + val usageLimits = usageLimitService.retrieveOrg() + + usageLimits.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveUsageLimits() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val usageLimitService = client.api().v1().usageLimits() + + val usageLimits = usageLimitService.retrieveUsageLimits() + + usageLimits.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun updateUsageLimits() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val usageLimitService = client.api().v1().usageLimits() + + val usageLimit = + usageLimitService.updateUsageLimits( + UsageLimitUpdateUsageLimitsParams.builder() + .limitType(UsageLimitType.MONTHLY_TRACES) + .limitValue(0L) + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + usageLimit.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/WorkspaceServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/WorkspaceServiceTest.kt new file mode 100644 index 00000000..687c38c4 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/WorkspaceServiceTest.kt @@ -0,0 +1,98 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1 + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.workspaces.WorkspaceCreateParams +import com.langsmith_api.api.models.api.v1.workspaces.WorkspaceListParams +import com.langsmith_api.api.models.api.v1.workspaces.WorkspaceUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class WorkspaceServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val workspaceService = client.api().v1().workspaces() + + val appSchemasTenant = + workspaceService.create( + WorkspaceCreateParams.builder() + .displayName("display_name") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tenantHandle("tenant_handle") + .build() + ) + + appSchemasTenant.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val workspaceService = client.api().v1().workspaces() + + val appSchemasTenant = + workspaceService.update( + WorkspaceUpdateParams.builder() + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .displayName("display_name") + .build() + ) + + appSchemasTenant.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val workspaceService = client.api().v1().workspaces() + + val tenantForUsers = + workspaceService.list(WorkspaceListParams.builder().includeDeleted(true).build()) + + tenantForUsers.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val workspaceService = client.api().v1().workspaces() + + val workspace = workspaceService.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + workspace.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/annotationqueues/RunServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/annotationqueues/RunServiceTest.kt new file mode 100644 index 00000000..c249dcc6 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/annotationqueues/RunServiceTest.kt @@ -0,0 +1,117 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.annotationqueues + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.annotationqueues.runs.RunCreateParams +import com.langsmith_api.api.models.api.v1.annotationqueues.runs.RunDeleteParams +import com.langsmith_api.api.models.api.v1.annotationqueues.runs.RunListParams +import com.langsmith_api.api.models.api.v1.annotationqueues.runs.RunUpdateParams +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class RunServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runService = client.api().v1().annotationQueues().runs() + + val runs = + runService.create( + RunCreateParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addBody("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + runs.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runService = client.api().v1().annotationQueues().runs() + + val run = + runService.update( + RunUpdateParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .queueRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lastReviewedTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + run.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runService = client.api().v1().annotationQueues().runs() + + val runSchemaWithAnnotationQueueInfos = + runService.list( + RunListParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .archived(true) + .includeStats(true) + .limit(1L) + .offset(0L) + .build() + ) + + runSchemaWithAnnotationQueueInfos.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runService = client.api().v1().annotationQueues().runs() + + val run = + runService.delete( + RunDeleteParams.builder() + .queueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .deleteAll(true) + .addExcludeRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + run.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/apikey/CurrentServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/apikey/CurrentServiceTest.kt new file mode 100644 index 00000000..a4156c24 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/apikey/CurrentServiceTest.kt @@ -0,0 +1,77 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.apikey + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyCreateRequest +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CurrentServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val currentService = client.api().v1().apiKey().current() + + val apiKeyCreateResponse = + currentService.create( + ApiKeyCreateRequest.builder() + .defaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + apiKeyCreateResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val currentService = client.api().v1().apiKey().current() + + val apiKeyGetResponses = currentService.list() + + apiKeyGetResponses.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val currentService = client.api().v1().apiKey().current() + + val apiKeyGetResponse = currentService.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + apiKeyGetResponse.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/bulkexports/DestinationServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/bulkexports/DestinationServiceTest.kt new file mode 100644 index 00000000..3dd8b972 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/bulkexports/DestinationServiceTest.kt @@ -0,0 +1,91 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.bulkexports + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.bulkexports.destinations.BulkExportDestinationS3Config +import com.langsmith_api.api.models.api.v1.bulkexports.destinations.BulkExportDestinationType +import com.langsmith_api.api.models.api.v1.bulkexports.destinations.DestinationCreateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class DestinationServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val destinationService = client.api().v1().bulkExports().destinations() + + val bulkExportDestination = + destinationService.create( + DestinationCreateParams.builder() + .config( + BulkExportDestinationS3Config.builder() + .bucketName("xxx") + .endpointUrl("endpoint_url") + .prefix("prefix") + .region("x") + .s3AdditionalKwargs(JsonValue.from(mapOf<String, Any>())) + .build() + ) + .displayName("display_name") + .credentials( + DestinationCreateParams.Credentials.builder() + .accessKeyId("x") + .secretAccessKey("x") + .sessionToken("session_token") + .build() + ) + .destinationType(BulkExportDestinationType.S3) + .build() + ) + + bulkExportDestination.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val destinationService = client.api().v1().bulkExports().destinations() + + val bulkExportDestination = + destinationService.retrieve("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + bulkExportDestination.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val destinationService = client.api().v1().bulkExports().destinations() + + val bulkExportDestinations = destinationService.list() + + bulkExportDestinations.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/bulkexports/RunServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/bulkexports/RunServiceTest.kt new file mode 100644 index 00000000..71bc2380 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/bulkexports/RunServiceTest.kt @@ -0,0 +1,54 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.bulkexports + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.bulkexports.runs.RunRetrieveParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class RunServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runService = client.api().v1().bulkExports().runs() + + val bulkExportRun = + runService.retrieve( + RunRetrieveParams.builder() + .bulkExportId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + bulkExportRun.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runService = client.api().v1().bulkExports().runs() + + val bulkExportRuns = runService.list("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + bulkExportRuns.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/charts/SectionServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/charts/SectionServiceTest.kt new file mode 100644 index 00000000..36bb8afd --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/charts/SectionServiceTest.kt @@ -0,0 +1,139 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.charts + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.charts.section.CustomChartsSectionCreate +import com.langsmith_api.api.models.api.v1.charts.section.CustomChartsSectionUpdate +import com.langsmith_api.api.models.api.v1.charts.section.SectionCloneParams +import com.langsmith_api.api.models.api.v1.charts.section.SectionListParams +import com.langsmith_api.api.models.api.v1.charts.section.SectionUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class SectionServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val sectionService = client.api().v1().charts().section() + + val customChartsSectionResponse = + sectionService.create( + CustomChartsSectionCreate.builder() + .title("title") + .description("description") + .index(0L) + .build() + ) + + customChartsSectionResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val sectionService = client.api().v1().charts().section() + + val customChartsSectionResponse = + sectionService.update( + SectionUpdateParams.builder() + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .customChartsSectionUpdate( + CustomChartsSectionUpdate.builder() + .description("string") + .index(0L) + .title("string") + .build() + ) + .build() + ) + + customChartsSectionResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val sectionService = client.api().v1().charts().section() + + val customChartsSectionResponses = + sectionService.list( + SectionListParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .offset(0L) + .sortBy("sort_by") + .sortByDesc(true) + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .titleContains("title_contains") + .build() + ) + + customChartsSectionResponses.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val sectionService = client.api().v1().charts().section() + + val section = sectionService.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + section.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun clone() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val sectionService = client.api().v1().charts().section() + + val customChartsSectionResponse = + sectionService.clone( + SectionCloneParams.builder() + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + customChartsSectionResponse.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/comments/LikeServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/comments/LikeServiceTest.kt new file mode 100644 index 00000000..d01da5ab --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/comments/LikeServiceTest.kt @@ -0,0 +1,63 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.comments + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.comments.like.LikeCreateParams +import com.langsmith_api.api.models.api.v1.comments.like.LikeDeleteAllParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class LikeServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val likeService = client.api().v1().comments().like() + + val like = + likeService.create( + LikeCreateParams.builder() + .owner("owner") + .repo("repo") + .parentCommentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + like.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun deleteAll() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val likeService = client.api().v1().comments().like() + + val response = + likeService.deleteAll( + LikeDeleteAllParams.builder() + .owner("owner") + .repo("repo") + .parentCommentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/ComparativeServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/ComparativeServiceTest.kt new file mode 100644 index 00000000..85e367c8 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/ComparativeServiceTest.kt @@ -0,0 +1,93 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.datasets + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.datasets.comparative.ComparativeCreateParams +import com.langsmith_api.api.models.api.v1.datasets.comparative.ComparativeListParams +import com.langsmith_api.api.models.api.v1.datasets.comparative.SortByComparativeExperimentColumn +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ComparativeServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val comparativeService = client.api().v1().datasets().comparative() + + val comparative = + comparativeService.create( + ComparativeCreateParams.builder() + .addExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .extra(JsonValue.from(mapOf<String, Any>())) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .build() + ) + + comparative.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val comparativeService = client.api().v1().datasets().comparative() + + val comparatives = + comparativeService.list( + ComparativeListParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .name("name") + .nameContains("name_contains") + .offset(0L) + .sortBy(SortByComparativeExperimentColumn.NAME) + .sortByDesc(true) + .build() + ) + + comparatives.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val comparativeService = client.api().v1().datasets().comparative() + + val comparative = comparativeService.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + comparative.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/ExperimentServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/ExperimentServiceTest.kt new file mode 100644 index 00000000..8c6c918e --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/ExperimentServiceTest.kt @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.datasets + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.datasets.experiments.ExperimentGroupedParams +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ExperimentServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun grouped() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val experimentService = client.api().v1().datasets().experiments() + + val response = + experimentService.grouped( + ExperimentGroupedParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metadataKey("x") + .datasetVersion("dataset_version") + .experimentLimit(1L) + .filter("filter") + .nameContains("name_contains") + .statsStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .useApproxStats(true) + .build() + ) + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/GroupServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/GroupServiceTest.kt new file mode 100644 index 00000000..fee94c7a --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/GroupServiceTest.kt @@ -0,0 +1,43 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.datasets + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.datasets.group.GroupRunsParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class GroupServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun runs() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val groupService = client.api().v1().datasets().group() + + val response = + groupService.runs( + GroupRunsParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupBy(GroupRunsParams.GroupBy.RUN_METADATA) + .metadataKey("metadata_key") + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .offset(0L) + .perGroupLimit(1L) + .preview(true) + .build() + ) + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/IndexServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/IndexServiceTest.kt new file mode 100644 index 00000000..36b98e71 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/IndexServiceTest.kt @@ -0,0 +1,88 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.datasets + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.datasets.index.IndexCreateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class IndexServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val indexService = client.api().v1().datasets().index() + + val index = + indexService.create( + IndexCreateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tag("tag") + .build() + ) + + index.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val indexService = client.api().v1().datasets().index() + + val indices = indexService.list("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + indices.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun deleteAll() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val indexService = client.api().v1().datasets().index() + + val response = indexService.deleteAll("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun sync() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val indexService = client.api().v1().datasets().index() + + val response = indexService.sync("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/PlaygroundExperimentServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/PlaygroundExperimentServiceTest.kt new file mode 100644 index 00000000..a5675c1d --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/PlaygroundExperimentServiceTest.kt @@ -0,0 +1,129 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.datasets + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.datasets.playgroundexperiment.PlaygroundExperimentBatchParams +import com.langsmith_api.api.models.api.v1.datasets.playgroundexperiment.PlaygroundExperimentStreamParams +import com.langsmith_api.api.models.api.v1.datasets.playgroundexperiment.RunnableConfig +import com.langsmith_api.api.models.api.v1.datasets.playgroundexperiment.RunnerContextEnum +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class PlaygroundExperimentServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun batch() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val playgroundExperimentService = client.api().v1().datasets().playgroundExperiment() + + val response = + playgroundExperimentService.batch( + PlaygroundExperimentBatchParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifest(JsonValue.from(mapOf<String, Any>())) + .options( + RunnableConfig.builder() + .callbacksOfJsonValues(listOf(JsonValue.from(mapOf<String, Any>()))) + .configurable(JsonValue.from(mapOf<String, Any>())) + .maxConcurrency(0L) + .metadata(JsonValue.from(mapOf<String, Any>())) + .recursionLimit(0L) + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runName("run_name") + .addTag("string") + .build() + ) + .projectName("project_name") + .secrets( + PlaygroundExperimentBatchParams.Secrets.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .batchSize(1L) + .commit("commit") + .addDatasetSplit("string") + .addEvaluatorRule("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .owner("owner") + .parallelToolCalls(true) + .repetitions(1L) + .repoHandle("repo_handle") + .repoId("repo_id") + .requestsPerSecond(0L) + .runId("run_id") + .runnerContext(RunnerContextEnum.LANGSMITH_UI) + .toolChoice("tool_choice") + .addTool(JsonValue.from(mapOf<String, Any>())) + .useOrFallbackToWorkspaceSecrets(true) + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun stream() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val playgroundExperimentService = client.api().v1().datasets().playgroundExperiment() + + val response = + playgroundExperimentService.stream( + PlaygroundExperimentStreamParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifest(JsonValue.from(mapOf<String, Any>())) + .options( + RunnableConfig.builder() + .callbacksOfJsonValues(listOf(JsonValue.from(mapOf<String, Any>()))) + .configurable(JsonValue.from(mapOf<String, Any>())) + .maxConcurrency(0L) + .metadata(JsonValue.from(mapOf<String, Any>())) + .recursionLimit(0L) + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runName("run_name") + .addTag("string") + .build() + ) + .projectName("project_name") + .secrets( + PlaygroundExperimentStreamParams.Secrets.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .commit("commit") + .addDatasetSplit("string") + .addEvaluatorRule("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .owner("owner") + .parallelToolCalls(true) + .repetitions(1L) + .repoHandle("repo_handle") + .repoId("repo_id") + .requestsPerSecond(0L) + .runId("run_id") + .runnerContext(RunnerContextEnum.LANGSMITH_UI) + .toolChoice("tool_choice") + .addTool(JsonValue.from(mapOf<String, Any>())) + .useOrFallbackToWorkspaceSecrets(true) + .build() + ) + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/RunServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/RunServiceTest.kt new file mode 100644 index 00000000..db26f1ac --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/RunServiceTest.kt @@ -0,0 +1,101 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.datasets + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.datasets.runs.QueryExampleSchemaWithRuns +import com.langsmith_api.api.models.api.v1.datasets.runs.QueryFeedbackDelta +import com.langsmith_api.api.models.api.v1.datasets.runs.RunCreateParams +import com.langsmith_api.api.models.api.v1.datasets.runs.RunDeltaParams +import kotlin.jvm.optionals.getOrNull +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class RunServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runService = client.api().v1().datasets().runs() + + val run = + runService.create( + RunCreateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .queryFormat("format") + .queryExampleSchemaWithRuns( + QueryExampleSchemaWithRuns.builder() + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .filters( + QueryExampleSchemaWithRuns.Filters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + ) + .format(QueryExampleSchemaWithRuns.Format.CSV) + .limit(1L) + .offset(0L) + .preview(true) + .sortParams( + QueryExampleSchemaWithRuns.SortParams.builder() + .sortBy("sort_by") + .sortOrder(QueryExampleSchemaWithRuns.SortParams.SortOrder.ASC) + .build() + ) + .build() + ) + .build() + ) + + val unwrappedRun = run.getOrNull() + unwrappedRun?.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delta() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runService = client.api().v1().datasets().runs() + + val sessionFeedbackDelta = + runService.delta( + RunDeltaParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .queryFeedbackDelta( + QueryFeedbackDelta.builder() + .baselineSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addComparisonSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackKey("feedback_key") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .filters( + QueryFeedbackDelta.Filters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + ) + .limit(1L) + .offset(0L) + .build() + ) + .build() + ) + + sessionFeedbackDelta.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/ShareServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/ShareServiceTest.kt new file mode 100644 index 00000000..6a76d19b --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/ShareServiceTest.kt @@ -0,0 +1,73 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.datasets + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.datasets.share.ShareCreateParams +import kotlin.jvm.optionals.getOrNull +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ShareServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val shareService = client.api().v1().datasets().share() + + val datasetShareSchema = + shareService.create( + ShareCreateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .shareProjects(true) + .build() + ) + + datasetShareSchema.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val shareService = client.api().v1().datasets().share() + + val datasetShareSchema = shareService.list("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val unwrappedDatasetShareSchema = datasetShareSchema.getOrNull() + unwrappedDatasetShareSchema?.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun deleteAll() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val shareService = client.api().v1().datasets().share() + + val response = shareService.deleteAll("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/SplitServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/SplitServiceTest.kt new file mode 100644 index 00000000..0ee93f4e --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/SplitServiceTest.kt @@ -0,0 +1,58 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.datasets + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.datasets.splits.SplitCreateParams +import com.langsmith_api.api.models.api.v1.datasets.splits.SplitListParams +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class SplitServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val splitService = client.api().v1().datasets().splits() + + splitService.create( + SplitCreateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .splitName("split_name") + .remove(true) + .build() + ) + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val splitService = client.api().v1().datasets().splits() + + splitService.list( + SplitListParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/VersionServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/VersionServiceTest.kt new file mode 100644 index 00000000..d74d72ae --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/datasets/VersionServiceTest.kt @@ -0,0 +1,66 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.datasets + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.datasets.versions.VersionListParams +import com.langsmith_api.api.models.api.v1.datasets.versions.VersionRetrieveDiffParams +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class VersionServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val versionService = client.api().v1().datasets().versions() + + val datasetVersions = + versionService.list( + VersionListParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .example("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .offset(0L) + .search("search") + .build() + ) + + datasetVersions.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveDiff() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val versionService = client.api().v1().datasets().versions() + + val response = + versionService.retrieveDiff( + VersionRetrieveDiffParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .fromVersion(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .toVersion(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/examples/BulkServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/examples/BulkServiceTest.kt new file mode 100644 index 00000000..0b57ef2c --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/examples/BulkServiceTest.kt @@ -0,0 +1,75 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.examples + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.examples.AttachmentsOperations +import com.langsmith_api.api.models.api.v1.examples.bulk.BulkPatchAllParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class BulkServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val bulkService = client.api().v1().examples().bulk() + + val bulk = bulkService.create() + + bulk.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun patchAll() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val bulkService = client.api().v1().examples().bulk() + + val response = + bulkService.patchAll( + BulkPatchAllParams.builder() + .addBody( + BulkPatchAllParams.Body.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .attachmentsOperations( + AttachmentsOperations.builder() + .rename( + AttachmentsOperations.Rename.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addRetain("string") + .build() + ) + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .metadata(JsonValue.from(mapOf<String, Any>())) + .outputs(JsonValue.from(mapOf<String, Any>())) + .overwrite(true) + .splitOfStrings(listOf("string")) + .build() + ) + .build() + ) + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/examples/ValidateServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/examples/ValidateServiceTest.kt new file mode 100644 index 00000000..0ba52eeb --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/examples/ValidateServiceTest.kt @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.examples + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ValidateServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val validateService = client.api().v1().examples().validate() + + val exampleValidationResult = validateService.create() + + exampleValidationResult.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun bulk() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val validateService = client.api().v1().examples().validate() + + val exampleValidationResults = validateService.bulk() + + exampleValidationResults.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/feedback/FormulaServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/feedback/FormulaServiceTest.kt new file mode 100644 index 00000000..fcb658c7 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/feedback/FormulaServiceTest.kt @@ -0,0 +1,131 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.feedback + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.feedback.formulas.FeedbackFormulaWeightedVariable +import com.langsmith_api.api.models.api.v1.feedback.formulas.FormulaCreateParams +import com.langsmith_api.api.models.api.v1.feedback.formulas.FormulaListParams +import com.langsmith_api.api.models.api.v1.feedback.formulas.FormulaUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class FormulaServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val formulaService = client.api().v1().feedback().formulas() + + val feedbackFormula = + formulaService.create( + FormulaCreateParams.builder() + .aggregationType(FormulaCreateParams.AggregationType.SUM) + .feedbackKey("feedback_key") + .addFormulaPart( + FeedbackFormulaWeightedVariable.builder().key("x").weight(0.0).build() + ) + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + feedbackFormula.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val formulaService = client.api().v1().feedback().formulas() + + val feedbackFormula = formulaService.retrieve("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + feedbackFormula.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val formulaService = client.api().v1().feedback().formulas() + + val feedbackFormula = + formulaService.update( + FormulaUpdateParams.builder() + .feedbackFormulaId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .aggregationType(FormulaUpdateParams.AggregationType.SUM) + .feedbackKey("feedback_key") + .addFormulaPart( + FeedbackFormulaWeightedVariable.builder().key("x").weight(0.0).build() + ) + .build() + ) + + feedbackFormula.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val formulaService = client.api().v1().feedback().formulas() + + val feedbackFormulas = + formulaService.list( + FormulaListParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .offset(0L) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + feedbackFormulas.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val formulaService = client.api().v1().feedback().formulas() + + val formula = formulaService.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + formula.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/feedback/TokenServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/feedback/TokenServiceTest.kt new file mode 100644 index 00000000..601225c6 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/feedback/TokenServiceTest.kt @@ -0,0 +1,139 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.feedback + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.feedback.tokens.FeedbackIngestTokenCreateSchema +import com.langsmith_api.api.models.api.v1.feedback.tokens.TokenCreateParams +import com.langsmith_api.api.models.api.v1.feedback.tokens.TokenListParams +import com.langsmith_api.api.models.api.v1.feedback.tokens.TokenRetrieveParams +import com.langsmith_api.api.models.api.v1.feedback.tokens.TokenUpdateParams +import com.langsmith_api.api.models.api.v1.feedbackconfigs.FeedbackConfig +import com.langsmith_api.api.models.api.v1.sessions.TimedeltaInput +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class TokenServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tokenService = client.api().v1().feedback().tokens() + + val token = + tokenService.create( + TokenCreateParams.builder() + .body( + FeedbackIngestTokenCreateSchema.builder() + .feedbackKey("feedback_key") + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiresIn( + TimedeltaInput.builder().days(0L).hours(0L).minutes(0L).build() + ) + .feedbackConfig( + FeedbackConfig.builder() + .type(FeedbackConfig.Type.CONTINUOUS) + .addCategory( + FeedbackConfig.Category.builder() + .value(0.0) + .label("x") + .build() + ) + .max(0.0) + .min(0.0) + .build() + ) + .build() + ) + .build() + ) + + token.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tokenService = client.api().v1().feedback().tokens() + + val token = + tokenService.retrieve( + TokenRetrieveParams.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") + .correction("correction") + .score(0.0) + .value(0.0) + .build() + ) + + token.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tokenService = client.api().v1().feedback().tokens() + + val token = + tokenService.update( + TokenUpdateParams.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") + .correction(JsonValue.from(mapOf<String, Any>())) + .metadata(JsonValue.from(mapOf<String, Any>())) + .score(0.0) + .value(0.0) + .build() + ) + + token.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tokenService = client.api().v1().feedback().tokens() + + val feedbackIngestTokenSchemata = + tokenService.list( + TokenListParams.builder().runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + ) + + feedbackIngestTokenSchemata.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/me/OnboardingStateServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/me/OnboardingStateServiceTest.kt new file mode 100644 index 00000000..bbf05b72 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/me/OnboardingStateServiceTest.kt @@ -0,0 +1,64 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.me + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class OnboardingStateServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val onboardingStateService = client.api().v1().me().onboardingState() + + val userOnboardingStateResponse = onboardingStateService.create() + + userOnboardingStateResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val onboardingStateService = client.api().v1().me().onboardingState() + + val userOnboardingStateResponse = onboardingStateService.update("field") + + userOnboardingStateResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val onboardingStateService = client.api().v1().me().onboardingState() + + val userOnboardingStateResponse = onboardingStateService.list() + + userOnboardingStateResponse.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgcharts/SectionServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgcharts/SectionServiceTest.kt new file mode 100644 index 00000000..8017a96b --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgcharts/SectionServiceTest.kt @@ -0,0 +1,115 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgcharts + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.charts.section.CustomChartsSectionCreate +import com.langsmith_api.api.models.api.v1.charts.section.CustomChartsSectionUpdate +import com.langsmith_api.api.models.api.v1.orgcharts.section.SectionListParams +import com.langsmith_api.api.models.api.v1.orgcharts.section.SectionUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class SectionServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val sectionService = client.api().v1().orgCharts().section() + + val customChartsSectionResponse = + sectionService.create( + CustomChartsSectionCreate.builder() + .title("title") + .description("description") + .index(0L) + .build() + ) + + customChartsSectionResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val sectionService = client.api().v1().orgCharts().section() + + val customChartsSectionResponse = + sectionService.update( + SectionUpdateParams.builder() + .sectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .customChartsSectionUpdate( + CustomChartsSectionUpdate.builder() + .description("string") + .index(0L) + .title("string") + .build() + ) + .build() + ) + + customChartsSectionResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val sectionService = client.api().v1().orgCharts().section() + + val customChartsSectionResponses = + sectionService.list( + SectionListParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .offset(0L) + .sortBy("sort_by") + .sortByDesc(true) + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .titleContains("title_contains") + .build() + ) + + customChartsSectionResponses.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val sectionService = client.api().v1().orgCharts().section() + + val section = sectionService.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + section.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/CurrentServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/CurrentServiceTest.kt new file mode 100644 index 00000000..18f03662 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/CurrentServiceTest.kt @@ -0,0 +1,237 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentConfirmCheckoutSessionCompletionParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentPaymentMethodParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentPlanParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentRetrieveDashboardParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentStripeAccountLinksParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentStripeCheckoutSessionParams +import com.langsmith_api.api.models.api.v1.orgs.current.CurrentUpdateLoginMethodsParams +import com.langsmith_api.api.models.api.v1.orgs.current.StripeCustomerAddress +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CurrentServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val currentService = client.api().v1().orgs().current() + + val currents = currentService.list() + + currents.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun confirmCheckoutSessionCompletion() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val currentService = client.api().v1().orgs().current() + + val response = + currentService.confirmCheckoutSessionCompletion( + CurrentConfirmCheckoutSessionCompletionParams.builder() + .stripeSessionId("stripe_session_id") + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun paymentMethod() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val currentService = client.api().v1().orgs().current() + + val response = + currentService.paymentMethod( + CurrentPaymentMethodParams.builder() + .billingInfo( + CurrentPaymentMethodParams.BillingInfo.builder() + .address( + StripeCustomerAddress.builder() + .city("city") + .country("country") + .line1("line1") + .postalCode("postal_code") + .line2("line2") + .state("state") + .build() + ) + .name("name") + .build() + ) + .setupIntent("setup_intent") + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun plan() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val currentService = client.api().v1().orgs().current() + + val response = + currentService.plan( + CurrentPlanParams.builder().tier(CurrentPlanParams.Tier.DISABLED).build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveDashboard() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val currentService = client.api().v1().orgs().current() + + val response = + currentService.retrieveDashboard( + CurrentRetrieveDashboardParams.builder() + .colorScheme(CurrentRetrieveDashboardParams.ColorScheme.LIGHT) + .type(CurrentRetrieveDashboardParams.Type.INVOICES) + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun setDefaultSsoProvision() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val currentService = client.api().v1().orgs().current() + + val response = currentService.setDefaultSsoProvision() + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun setup() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val currentService = client.api().v1().orgs().current() + + val response = currentService.setup() + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun stripeAccountLinks() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val currentService = client.api().v1().orgs().current() + + val response = + currentService.stripeAccountLinks( + CurrentStripeAccountLinksParams.builder().successPath("success_path").build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun stripeCheckoutSession() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val currentService = client.api().v1().orgs().current() + + val response = + currentService.stripeCheckoutSession( + CurrentStripeCheckoutSessionParams.builder() + .amountCents(0L) + .successPath("success_path") + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun updateLoginMethods() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val currentService = client.api().v1().orgs().current() + + val response = + currentService.updateLoginMethods( + CurrentUpdateLoginMethodsParams.builder().ssoOnly(true).build() + ) + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/MemberServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/MemberServiceTest.kt new file mode 100644 index 00000000..c27b3b4d --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/MemberServiceTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.orgs.members.MemberUpdateBasicParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class MemberServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun updateBasic() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val memberService = client.api().v1().orgs().members() + + val response = + memberService.updateBasic( + MemberUpdateBasicParams.builder().fullName("full_name").password("password").build() + ) + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/PendingServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/PendingServiceTest.kt new file mode 100644 index 00000000..88c46a43 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/PendingServiceTest.kt @@ -0,0 +1,64 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class PendingServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val pendingService = client.api().v1().orgs().pending() + + val organizationPgSchemaSlims = pendingService.list() + + organizationPgSchemaSlims.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val pendingService = client.api().v1().orgs().pending() + + val pending = pendingService.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + pending.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun claim() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val pendingService = client.api().v1().orgs().pending() + + val identity = pendingService.claim("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + identity.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/TtlSettingServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/TtlSettingServiceTest.kt new file mode 100644 index 00000000..d770f6f3 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/TtlSettingServiceTest.kt @@ -0,0 +1,56 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TraceTier +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.UpsertTtlSettingsRequest +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class TtlSettingServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieveTtlSettings() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val ttlSettingService = client.api().v1().orgs().ttlSettings() + + val ttlSettings = ttlSettingService.retrieveTtlSettings() + + ttlSettings.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun updateTtlSettings() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val ttlSettingService = client.api().v1().orgs().ttlSettings() + + val ttlSettings = + ttlSettingService.updateTtlSettings( + UpsertTtlSettingsRequest.builder() + .defaultTraceTier(TraceTier.LONGLIVED) + .applyToAllProjects(true) + .tenantId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + ttlSettings.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/BillingServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/BillingServiceTest.kt new file mode 100644 index 00000000..cde8d7b7 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/BillingServiceTest.kt @@ -0,0 +1,56 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs.current + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.orgs.current.billing.BillingRetrieveUsageParams +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class BillingServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val billingService = client.api().v1().orgs().current().billing() + + val billings = billingService.list() + + billings.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveUsage() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val billingService = client.api().v1().orgs().current().billing() + + val response = + billingService.retrieveUsage( + BillingRetrieveUsageParams.builder() + .endingBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startingOn(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .onCurrentPlan(true) + .build() + ) + + response.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/BusinessInfoServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/BusinessInfoServiceTest.kt new file mode 100644 index 00000000..af5331a5 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/BusinessInfoServiceTest.kt @@ -0,0 +1,73 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs.current + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.orgs.current.StripeCustomerAddress +import com.langsmith_api.api.models.api.v1.orgs.current.businessinfo.BusinessInfoBusinessInfoParams +import com.langsmith_api.api.models.api.v1.orgs.current.businessinfo.StripeBusinessBillingInfo +import com.langsmith_api.api.models.api.v1.orgs.current.businessinfo.StripeTaxId +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class BusinessInfoServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun businessInfo() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val businessInfoService = client.api().v1().orgs().current().businessInfo() + + val response = + businessInfoService.businessInfo( + BusinessInfoBusinessInfoParams.builder() + .companyInfo( + StripeBusinessBillingInfo.builder() + .name("name") + .address( + StripeCustomerAddress.builder() + .city("city") + .country("country") + .line1("line1") + .postalCode("postal_code") + .line2("line2") + .state("state") + .build() + ) + .build() + ) + .invoiceEmail("invoice_email") + .isBusiness(true) + .taxId(StripeTaxId.builder().type("type").value("value").build()) + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveBusinessInfo() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val businessInfoService = client.api().v1().orgs().current().businessInfo() + + val response = businessInfoService.retrieveBusinessInfo() + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/InfoServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/InfoServiceTest.kt new file mode 100644 index 00000000..d8fda1b5 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/InfoServiceTest.kt @@ -0,0 +1,58 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs.current + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.orgs.current.info.InfoPatchAllParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class InfoServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val infoService = client.api().v1().orgs().current().info() + + val organizationInfo = infoService.list() + + organizationInfo.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun patchAll() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val infoService = client.api().v1().orgs().current().info() + + val organizationInfo = + infoService.patchAll( + InfoPatchAllParams.builder() + .displayName("display_name") + .jitProvisioningEnabled(true) + .patCreationDisabled(true) + .publicSharingDisabled(true) + .unshareAll(true) + .workspaceAdminCanInviteToOrg(true) + .build() + ) + + organizationInfo.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/MemberServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/MemberServiceTest.kt new file mode 100644 index 00000000..c4f462df --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/MemberServiceTest.kt @@ -0,0 +1,162 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs.current + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberBatchParams +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberRetrieveActiveParams +import com.langsmith_api.api.models.api.v1.orgs.current.members.MemberUpdateParams +import com.langsmith_api.api.models.api.v1.orgs.current.members.PendingIdentityCreate +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class MemberServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val memberService = client.api().v1().orgs().current().members() + + val pendingIdentity = + memberService.create( + PendingIdentityCreate.builder() + .email("email") + .fullName("full_name") + .password("password") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .workspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + pendingIdentity.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val memberService = client.api().v1().orgs().current().members() + + val member = + memberService.update( + MemberUpdateParams.builder() + .identityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .fullName("full_name") + .password("password") + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + member.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val memberService = client.api().v1().orgs().current().members() + + val members = memberService.list() + + members.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val memberService = client.api().v1().orgs().current().members() + + val member = memberService.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + member.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun batch() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val memberService = client.api().v1().orgs().current().members() + + val pendingIdentities = + memberService.batch( + MemberBatchParams.builder() + .addBody( + PendingIdentityCreate.builder() + .email("email") + .fullName("full_name") + .password("password") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .workspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + ) + + pendingIdentities.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveActive() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val memberService = client.api().v1().orgs().current().members() + + val orgMemberIdentities = + memberService.retrieveActive( + MemberRetrieveActiveParams.builder() + .addEmail("string") + .limit(1L) + .addLsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .offset(0L) + .addUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + orgMemberIdentities.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/PersonalAccessTokenServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/PersonalAccessTokenServiceTest.kt new file mode 100644 index 00000000..a609263f --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/PersonalAccessTokenServiceTest.kt @@ -0,0 +1,78 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs.current + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyCreateRequest +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class PersonalAccessTokenServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val personalAccessTokenService = client.api().v1().orgs().current().personalAccessTokens() + + val apiKeyGetResponse = + personalAccessTokenService.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + apiKeyGetResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun personalAccessTokens() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val personalAccessTokenService = client.api().v1().orgs().current().personalAccessTokens() + + val apiKeyCreateResponse = + personalAccessTokenService.personalAccessTokens( + ApiKeyCreateRequest.builder() + .defaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + apiKeyCreateResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrievePersonalAccessTokens() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val personalAccessTokenService = client.api().v1().orgs().current().personalAccessTokens() + + val apiKeyGetResponses = personalAccessTokenService.retrievePersonalAccessTokens() + + apiKeyGetResponses.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/RoleServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/RoleServiceTest.kt new file mode 100644 index 00000000..49d2aa29 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/RoleServiceTest.kt @@ -0,0 +1,98 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs.current + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.orgs.current.roles.RoleCreateParams +import com.langsmith_api.api.models.api.v1.orgs.current.roles.RoleUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class RoleServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val roleService = client.api().v1().orgs().current().roles() + + val role = + roleService.create( + RoleCreateParams.builder() + .description("description") + .displayName("display_name") + .addPermission("string") + .build() + ) + + role.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val roleService = client.api().v1().orgs().current().roles() + + val role = + roleService.update( + RoleUpdateParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .displayName("display_name") + .addPermission("string") + .build() + ) + + role.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val roleService = client.api().v1().orgs().current().roles() + + val roles = roleService.list() + + roles.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val roleService = client.api().v1().orgs().current().roles() + + val role = roleService.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + role.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/ServiceKeyServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/ServiceKeyServiceTest.kt new file mode 100644 index 00000000..d1453881 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/ServiceKeyServiceTest.kt @@ -0,0 +1,77 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs.current + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.orgs.current.servicekeys.ApiKeyCreateRequest +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ServiceKeyServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val serviceKeyService = client.api().v1().orgs().current().serviceKeys() + + val apiKeyGetResponse = serviceKeyService.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + apiKeyGetResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveServiceKeys() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val serviceKeyService = client.api().v1().orgs().current().serviceKeys() + + val apiKeyGetResponses = serviceKeyService.retrieveServiceKeys() + + apiKeyGetResponses.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun serviceKeys() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val serviceKeyService = client.api().v1().orgs().current().serviceKeys() + + val apiKeyCreateResponse = + serviceKeyService.serviceKeys( + ApiKeyCreateRequest.builder() + .defaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .orgRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + apiKeyCreateResponse.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/SsoSettingServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/SsoSettingServiceTest.kt new file mode 100644 index 00000000..21788b83 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/SsoSettingServiceTest.kt @@ -0,0 +1,106 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs.current + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.orgs.current.ssosettings.SsoSettingSsoSettingsParams +import com.langsmith_api.api.models.api.v1.orgs.current.ssosettings.SsoSettingUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class SsoSettingServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val ssoSettingService = client.api().v1().orgs().current().ssoSettings() + + val ssoProvider = + ssoSettingService.update( + SsoSettingUpdateParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addDefaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .defaultWorkspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metadataUrl("metadata_url") + .metadataXml("metadata_xml") + .build() + ) + + ssoProvider.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val ssoSettingService = client.api().v1().orgs().current().ssoSettings() + + val ssoProvider = ssoSettingService.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + ssoProvider.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveSsoSettings() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val ssoSettingService = client.api().v1().orgs().current().ssoSettings() + + val ssoProviders = ssoSettingService.retrieveSsoSettings() + + ssoProviders.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun ssoSettings() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val ssoSettingService = client.api().v1().orgs().current().ssoSettings() + + val ssoProvider = + ssoSettingService.ssoSettings( + SsoSettingSsoSettingsParams.builder() + .addDefaultWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .defaultWorkspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .attributeMapping( + SsoSettingSsoSettingsParams.AttributeMapping.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .metadataUrl("metadata_url") + .metadataXml("metadata_xml") + .build() + ) + + ssoProvider.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/UserServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/UserServiceTest.kt new file mode 100644 index 00000000..31012192 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/UserServiceTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs.current + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class UserServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieveLoginMethods() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val userService = client.api().v1().orgs().current().user() + + val providerUserSlims = userService.retrieveLoginMethods() + + providerUserSlims.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/members/BasicServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/members/BasicServiceTest.kt new file mode 100644 index 00000000..e5bbf96d --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/members/BasicServiceTest.kt @@ -0,0 +1,48 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs.current.members + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.orgs.current.members.basic.BasicBatchParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class BasicServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun batch() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val basicService = client.api().v1().orgs().current().members().basic() + + val response = + basicService.batch( + BasicBatchParams.builder() + .addBody( + BasicBatchParams.Body.builder() + .email("email") + .fullName("full_name") + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .password("password") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .workspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + ) + + response.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/members/PendingServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/members/PendingServiceTest.kt new file mode 100644 index 00000000..de741e1c --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/orgs/current/members/PendingServiceTest.kt @@ -0,0 +1,51 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.orgs.current.members + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.orgs.current.members.pending.PendingListParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class PendingServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val pendingService = client.api().v1().orgs().current().members().pending() + + val orgPendingIdentities = + pendingService.list( + PendingListParams.builder().addEmail("string").limit(1L).offset(0L).build() + ) + + orgPendingIdentities.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun deleteAll() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val pendingService = client.api().v1().orgs().current().members().pending() + + val response = pendingService.deleteAll("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/DatasetServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/DatasetServiceTest.kt new file mode 100644 index 00000000..b545e207 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/DatasetServiceTest.kt @@ -0,0 +1,162 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.public_ + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.datasets.SortByDatasetColumn +import com.langsmith_api.api.models.api.v1.datasets.comparative.SortByComparativeExperimentColumn +import com.langsmith_api.api.models.api.v1.feedback.FeedbackLevel +import com.langsmith_api.api.models.api.v1.feedback.SourceType +import com.langsmith_api.api.models.api.v1.public_.datasets.DatasetListParams +import com.langsmith_api.api.models.api.v1.public_.datasets.DatasetRetrieveComparativeParams +import com.langsmith_api.api.models.api.v1.public_.datasets.DatasetRetrieveFeedbackParams +import com.langsmith_api.api.models.api.v1.public_.datasets.DatasetRetrieveSessionsBulkParams +import com.langsmith_api.api.models.api.v1.public_.datasets.DatasetRetrieveSessionsParams +import com.langsmith_api.api.models.api.v1.sessions.SessionSortableColumns +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class DatasetServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetService = client.api().v1().public_().datasets() + + val datasets = + datasetService.list( + DatasetListParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .offset(0L) + .sortBy(SortByDatasetColumn.NAME) + .sortByDesc(true) + .build() + ) + + datasets.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveComparative() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetService = client.api().v1().public_().datasets() + + val response = + datasetService.retrieveComparative( + DatasetRetrieveComparativeParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .name("name") + .nameContains("name_contains") + .offset(0L) + .sortBy(SortByComparativeExperimentColumn.NAME) + .sortByDesc(true) + .build() + ) + + response.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveFeedback() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetService = client.api().v1().public_().datasets() + + val feedbackSchemata = + datasetService.retrieveFeedback( + DatasetRetrieveFeedbackParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .hasComment(true) + .hasScore(true) + .addKey("string") + .level(FeedbackLevel.RUN) + .limit(1L) + .offset(0L) + .addRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addSource(SourceType.API) + .addUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + feedbackSchemata.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveSessions() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetService = client.api().v1().public_().datasets() + + val tracerSessions = + datasetService.retrieveSessions( + DatasetRetrieveSessionsParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .facets(true) + .limit(1L) + .name("name") + .nameContains("name_contains") + .offset(0L) + .sortBy(SessionSortableColumns.NAME) + .sortByDesc(true) + .sortByFeedbackKey("sort_by_feedback_key") + .accept("accept") + .build() + ) + + tracerSessions.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveSessionsBulk() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val datasetService = client.api().v1().public_().datasets() + + val tracerSessions = + datasetService.retrieveSessionsBulk( + DatasetRetrieveSessionsBulkParams.builder().addShareToken("string").build() + ) + + tracerSessions.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/ExampleServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/ExampleServiceTest.kt new file mode 100644 index 00000000..8cbc4e02 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/ExampleServiceTest.kt @@ -0,0 +1,115 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.public_ + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.datasets.runs.QueryExampleSchemaWithRuns +import com.langsmith_api.api.models.api.v1.examples.ExampleSelect +import com.langsmith_api.api.models.api.v1.public_.examples.ExampleListParams +import com.langsmith_api.api.models.api.v1.public_.examples.ExampleRetrieveCountParams +import com.langsmith_api.api.models.api.v1.public_.examples.ExampleRunsParams +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ExampleServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val exampleService = client.api().v1().public_().examples() + + val examples = + exampleService.list( + ExampleListParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .limit(1L) + .metadata("metadata") + .offset(0L) + .addSelect(ExampleSelect.ID) + .build() + ) + + examples.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveCount() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val exampleService = client.api().v1().public_().examples() + + exampleService.retrieveCount( + ExampleRetrieveCountParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asOf(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .metadata("metadata") + .build() + ) + } + + @Disabled("Prism tests are disabled") + @Test + fun runs() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val exampleService = client.api().v1().public_().examples() + + val response = + exampleService.runs( + ExampleRunsParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .queryExampleSchemaWithRuns( + QueryExampleSchemaWithRuns.builder() + .addSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .filters( + QueryExampleSchemaWithRuns.Filters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + ) + .format(QueryExampleSchemaWithRuns.Format.CSV) + .limit(1L) + .offset(0L) + .preview(true) + .sortParams( + QueryExampleSchemaWithRuns.SortParams.builder() + .sortBy("sort_by") + .sortOrder(QueryExampleSchemaWithRuns.SortParams.SortOrder.ASC) + .build() + ) + .build() + ) + .build() + ) + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/RunServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/RunServiceTest.kt new file mode 100644 index 00000000..d1157748 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/RunServiceTest.kt @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.public_ + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.public_.runs.RunListParams +import com.langsmith_api.api.models.api.v1.public_.runs.RunQueryParams +import com.langsmith_api.api.models.api.v1.public_.runs.RunRetrieveParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class RunServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runService = client.api().v1().public_().runs() + + val runPublicSchema = + runService.retrieve( + RunRetrieveParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .excludeS3StoredAttributes(true) + .build() + ) + + runPublicSchema.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runService = client.api().v1().public_().runs() + + val runPublicSchema = + runService.list( + RunListParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .excludeS3StoredAttributes(true) + .build() + ) + + runPublicSchema.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun query() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runService = client.api().v1().public_().runs() + + val response = + runService.query( + RunQueryParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/SchemaServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/SchemaServiceTest.kt new file mode 100644 index 00000000..9b9fa469 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/SchemaServiceTest.kt @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.public_ + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class SchemaServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieveMessageJson() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val schemaService = client.api().v1().public_().schemas() + + val response = schemaService.retrieveMessageJson("version") + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveTooldefJson() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val schemaService = client.api().v1().public_().schemas() + + val response = schemaService.retrieveTooldefJson("version") + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/datasets/RunServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/datasets/RunServiceTest.kt new file mode 100644 index 00000000..b4edc08f --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/public_/datasets/RunServiceTest.kt @@ -0,0 +1,220 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.public_.datasets + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.datasets.runs.QueryFeedbackDelta +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunDeltaParams +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunGenerateQueryParams +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunQueryParams +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunRetrieveParams +import com.langsmith_api.api.models.api.v1.public_.datasets.runs.RunStatsParams +import com.langsmith_api.api.models.api.v1.runs.BodyParamsForRunSchema +import com.langsmith_api.api.models.api.v1.runs.RequestBodyForRunsGenerateQuery +import com.langsmith_api.api.models.api.v1.runs.RunStatsQueryParams +import com.langsmith_api.api.models.api.v1.runs.RunTypeEnum +import com.langsmith_api.api.models.api.v1.runs.RunsFilterDataSourceTypeEnum +import com.langsmith_api.api.models.api.v1.sessions.RunStatsGroupBy +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class RunServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runService = client.api().v1().public_().datasets().runs() + + val runPublicDatasetSchema = + runService.retrieve( + RunRetrieveParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .excludeS3StoredAttributes(true) + .build() + ) + + runPublicDatasetSchema.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delta() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runService = client.api().v1().public_().datasets().runs() + + val sessionFeedbackDelta = + runService.delta( + RunDeltaParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .queryFeedbackDelta( + QueryFeedbackDelta.builder() + .baselineSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addComparisonSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedbackKey("feedback_key") + .comparativeExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .filters( + QueryFeedbackDelta.Filters.builder() + .putAdditionalProperty("foo", JsonValue.from(listOf("string"))) + .build() + ) + .limit(1L) + .offset(0L) + .build() + ) + .build() + ) + + sessionFeedbackDelta.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun generateQuery() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runService = client.api().v1().public_().datasets().runs() + + val responseBodyForRunsGenerateQuery = + runService.generateQuery( + RunGenerateQueryParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .requestBodyForRunsGenerateQuery( + RequestBodyForRunsGenerateQuery.builder() + .query("query") + .addFeedbackKey(RequestBodyForRunsGenerateQuery.FeedbackKey.USER_SCORE) + .build() + ) + .build() + ) + + responseBodyForRunsGenerateQuery.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun query() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runService = client.api().v1().public_().datasets().runs() + + val response = + runService.query( + RunQueryParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .bodyParamsForRunSchema( + BodyParamsForRunSchema.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .dataSourceType(RunsFilterDataSourceTypeEnum.CURRENT) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .executionOrder(1L) + .filter("filter") + .isRoot(true) + .limit(1L) + .order(BodyParamsForRunSchema.Order.ASC) + .parentRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .query("query") + .addReferenceExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runType(RunTypeEnum.TOOL) + .searchFilter("search_filter") + .addSelect(BodyParamsForRunSchema.Select.ID) + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .skipPagination(true) + .skipPrevCursor(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .trace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .useExperimentalSearch(true) + .build() + ) + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun stats() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val runService = client.api().v1().public_().datasets().runs() + + val runStats = + runService.stats( + RunStatsParams.builder() + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runStatsQueryParams( + RunStatsQueryParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dataSourceType(RunsFilterDataSourceTypeEnum.CURRENT) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(true) + .executionOrder(1L) + .filter("filter") + .groupBy( + RunStatsGroupBy.builder() + .attribute(RunStatsGroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .build() + ) + .addGroup("string") + .isRoot(true) + .parentRun("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .query("query") + .addReferenceExample("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .runType(RunTypeEnum.TOOL) + .searchFilter("search_filter") + .addSelect(RunStatsQueryParams.Select.RUN_COUNT) + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .skipPagination(true) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .trace("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .useExperimentalSearch(true) + .build() + ) + .build() + ) + + runStats.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/repos/OptimizationJobServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/repos/OptimizationJobServiceTest.kt new file mode 100644 index 00000000..d8063604 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/repos/OptimizationJobServiceTest.kt @@ -0,0 +1,163 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.repos + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.repos.EPromptOptimizationAlgorithm +import com.langsmith_api.api.models.api.v1.repos.PromptimConfig +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.EPromptOptimizationJobStatus +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.OptimizationJobDeleteParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.OptimizationJobOptimizationJobsParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.OptimizationJobRetrieveOptimizationJobsParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.OptimizationJobRetrieveParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.OptimizationJobUpdateParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.PromptOptimizationResult +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class OptimizationJobServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val optimizationJobService = client.api().v1().repos().optimizationJobs() + + val optimizationJob = + optimizationJobService.retrieve( + OptimizationJobRetrieveParams.builder() + .owner("owner") + .repo("repo") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + optimizationJob.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val optimizationJobService = client.api().v1().repos().optimizationJobs() + + val promptOptimizationJob = + optimizationJobService.update( + OptimizationJobUpdateParams.builder() + .owner("owner") + .repo("repo") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .result( + PromptOptimizationResult.builder() + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .x(0.0) + .y(0.0) + .build() + ) + .status(EPromptOptimizationJobStatus.CREATED) + .build() + ) + + promptOptimizationJob.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val optimizationJobService = client.api().v1().repos().optimizationJobs() + + val optimizationJob = + optimizationJobService.delete( + OptimizationJobDeleteParams.builder() + .owner("owner") + .repo("repo") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + optimizationJob.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun optimizationJobs() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val optimizationJobService = client.api().v1().repos().optimizationJobs() + + val promptOptimizationJob = + optimizationJobService.optimizationJobs( + OptimizationJobOptimizationJobsParams.builder() + .owner("owner") + .repo("repo") + .algorithm(EPromptOptimizationAlgorithm.PROMPTIM) + .config( + PromptimConfig.builder() + .autoCommit(true) + .datasetName("dataset_name") + .devSplit("dev_split") + .addEvaluator("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .messageIndex(0L) + .numEpochs(0L) + .taskDescription("task_description") + .testSplit("test_split") + .trainSplit("train_split") + .build() + ) + .build() + ) + + promptOptimizationJob.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveOptimizationJobs() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val optimizationJobService = client.api().v1().repos().optimizationJobs() + + val promptOptimizationJobs = + optimizationJobService.retrieveOptimizationJobs( + OptimizationJobRetrieveOptimizationJobsParams.builder() + .owner("owner") + .repo("repo") + .build() + ) + + promptOptimizationJobs.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/repos/TagServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/repos/TagServiceTest.kt new file mode 100644 index 00000000..fd086ba6 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/repos/TagServiceTest.kt @@ -0,0 +1,127 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.repos + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.repos.tags.TagCreateParams +import com.langsmith_api.api.models.api.v1.repos.tags.TagDeleteParams +import com.langsmith_api.api.models.api.v1.repos.tags.TagListParams +import com.langsmith_api.api.models.api.v1.repos.tags.TagRetrieveParams +import com.langsmith_api.api.models.api.v1.repos.tags.TagUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class TagServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tagService = client.api().v1().repos().tags() + + val repoTag = + tagService.create( + TagCreateParams.builder() + .owner("owner") + .repo("repo") + .commitId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tagName("tag_name") + .skipWebhooks(true) + .build() + ) + + repoTag.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tagService = client.api().v1().repos().tags() + + val repoTag = + tagService.retrieve( + TagRetrieveParams.builder().owner("owner").repo("repo").tagName("tag_name").build() + ) + + repoTag.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tagService = client.api().v1().repos().tags() + + val repoTag = + tagService.update( + TagUpdateParams.builder() + .owner("owner") + .repo("repo") + .tagName("tag_name") + .commitId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .skipWebhooks(true) + .build() + ) + + repoTag.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tagService = client.api().v1().repos().tags() + + val repoTags = tagService.list(TagListParams.builder().owner("owner").repo("repo").build()) + + repoTags.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tagService = client.api().v1().repos().tags() + + val tag = + tagService.delete( + TagDeleteParams.builder().owner("owner").repo("repo").tagName("tag_name").build() + ) + + tag.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/repos/optimizationjobs/LogServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/repos/optimizationjobs/LogServiceTest.kt new file mode 100644 index 00000000..49c4c1d3 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/repos/optimizationjobs/LogServiceTest.kt @@ -0,0 +1,120 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.repos.optimizationjobs + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs.EPromptOptimizationJobLogType +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs.LogCreateParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs.LogDeleteParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs.LogListParams +import com.langsmith_api.api.models.api.v1.repos.optimizationjobs.logs.LogRetrieveParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class LogServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val logService = client.api().v1().repos().optimizationJobs().logs() + + val promptOptimizationJobLog = + logService.create( + LogCreateParams.builder() + .owner("owner") + .repo("repo") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .logType(EPromptOptimizationJobLogType.INFO) + .message("message") + .data(JsonValue.from(mapOf<String, Any>())) + .build() + ) + + promptOptimizationJobLog.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val logService = client.api().v1().repos().optimizationJobs().logs() + + val promptOptimizationJobLog = + logService.retrieve( + LogRetrieveParams.builder() + .owner("owner") + .repo("repo") + .jobId("job_id") + .logId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + promptOptimizationJobLog.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val logService = client.api().v1().repos().optimizationJobs().logs() + + val promptOptimizationJobLogs = + logService.list( + LogListParams.builder() + .owner("owner") + .repo("repo") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + promptOptimizationJobLogs.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val logService = client.api().v1().repos().optimizationJobs().logs() + + val log = + logService.delete( + LogDeleteParams.builder() + .owner("owner") + .repo("repo") + .jobId("job_id") + .logId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + log.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/GroupServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/GroupServiceTest.kt new file mode 100644 index 00000000..117bd37c --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/GroupServiceTest.kt @@ -0,0 +1,77 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.runs + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.runs.group.GroupCreateParams +import com.langsmith_api.api.models.api.v1.runs.group.RunGroupRequest +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class GroupServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val groupService = client.api().v1().runs().group() + + val group = + groupService.create( + GroupCreateParams.builder() + .accept("accept") + .runGroupRequest( + RunGroupRequest.builder() + .groupBy(RunGroupRequest.GroupBy.CONVERSATION) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .limit(1L) + .offset(0L) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + ) + + group.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun stats() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val groupService = client.api().v1().runs().group() + + val response = + groupService.stats( + RunGroupRequest.builder() + .groupBy(RunGroupRequest.GroupBy.CONVERSATION) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .limit(1L) + .offset(0L) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/RuleServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/RuleServiceTest.kt new file mode 100644 index 00000000..fe896ac4 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/RuleServiceTest.kt @@ -0,0 +1,285 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.runs + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.runs.rules.CodeEvaluatorTopLevel +import com.langsmith_api.api.models.api.v1.runs.rules.EvaluatorTopLevel +import com.langsmith_api.api.models.api.v1.runs.rules.RuleCreateParams +import com.langsmith_api.api.models.api.v1.runs.rules.RuleListParams +import com.langsmith_api.api.models.api.v1.runs.rules.RuleRetrieveLogsParams +import com.langsmith_api.api.models.api.v1.runs.rules.RuleUpdateParams +import com.langsmith_api.api.models.api.v1.runs.rules.RunRulesPagerdutyAlertSchema +import com.langsmith_api.api.models.api.v1.runs.rules.RunRulesWebhookSchema +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class RuleServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val ruleService = client.api().v1().runs().rules() + + val runRulesSchema = + ruleService.create( + RuleCreateParams.builder() + .displayName("display_name") + .samplingRate(0.0) + .addToAnnotationQueueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addToDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addToDatasetPreferCorrection(true) + .addAlert( + RunRulesPagerdutyAlertSchema.builder() + .routingKey("routing_key") + .severity(RunRulesPagerdutyAlertSchema.Severity.CRITICAL) + .summary("summary") + .type(RunRulesPagerdutyAlertSchema.Type.PAGERDUTY) + .build() + ) + .backfillFrom(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addCodeEvaluator( + CodeEvaluatorTopLevel.builder() + .code("code") + .language(CodeEvaluatorTopLevel.Language.PYTHON) + .build() + ) + .createAlignmentQueue(true) + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .evaluatorVersion(0L) + .addEvaluator( + EvaluatorTopLevel.builder() + .structured( + EvaluatorTopLevel.Structured.builder() + .hubRef("hub_ref") + .model(JsonValue.from(mapOf<String, Any>())) + .addPrompt( + listOf( + JsonValue.from(mapOf<String, Any>()), + JsonValue.from(mapOf<String, Any>()), + ) + ) + .schema(JsonValue.from(mapOf<String, Any>())) + .templateFormat("template_format") + .variableMapping( + EvaluatorTopLevel.Structured.VariableMapping.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + .build() + ) + .extendOnly(true) + .filter("filter") + .groupBy(RuleCreateParams.GroupBy.THREAD_ID) + .includeExtendedStats(true) + .isEnabled(true) + .numFewShotExamples(0L) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .transient_(true) + .treeFilter("tree_filter") + .useCorrectionsDataset(true) + .addWebhook( + RunRulesWebhookSchema.builder() + .url("url") + .headers( + RunRulesWebhookSchema.Headers.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + .build() + ) + + runRulesSchema.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val ruleService = client.api().v1().runs().rules() + + val runRulesSchema = + ruleService.update( + RuleUpdateParams.builder() + .ruleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .displayName("display_name") + .samplingRate(0.0) + .addToAnnotationQueueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addToDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addToDatasetPreferCorrection(true) + .addAlert( + RunRulesPagerdutyAlertSchema.builder() + .routingKey("routing_key") + .severity(RunRulesPagerdutyAlertSchema.Severity.CRITICAL) + .summary("summary") + .type(RunRulesPagerdutyAlertSchema.Type.PAGERDUTY) + .build() + ) + .backfillFrom(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addCodeEvaluator( + CodeEvaluatorTopLevel.builder() + .code("code") + .language(CodeEvaluatorTopLevel.Language.PYTHON) + .build() + ) + .createAlignmentQueue(true) + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .evaluatorVersion(0L) + .addEvaluator( + EvaluatorTopLevel.builder() + .structured( + EvaluatorTopLevel.Structured.builder() + .hubRef("hub_ref") + .model(JsonValue.from(mapOf<String, Any>())) + .addPrompt( + listOf( + JsonValue.from(mapOf<String, Any>()), + JsonValue.from(mapOf<String, Any>()), + ) + ) + .schema(JsonValue.from(mapOf<String, Any>())) + .templateFormat("template_format") + .variableMapping( + EvaluatorTopLevel.Structured.VariableMapping.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + .build() + ) + .extendOnly(true) + .filter("filter") + .includeExtendedStats(true) + .isEnabled(true) + .numFewShotExamples(0L) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .transient_(true) + .treeFilter("tree_filter") + .useCorrectionsDataset(true) + .addWebhook( + RunRulesWebhookSchema.builder() + .url("url") + .headers( + RunRulesWebhookSchema.Headers.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + .build() + ) + + runRulesSchema.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val ruleService = client.api().v1().runs().rules() + + val runRulesSchemata = + ruleService.list( + RuleListParams.builder() + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .nameContains("name_contains") + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .type(RuleListParams.Type.SESSION) + .build() + ) + + runRulesSchemata.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val ruleService = client.api().v1().runs().rules() + + val rule = ruleService.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + rule.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveLastApplied() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val ruleService = client.api().v1().runs().rules() + + val ruleLogSchema = ruleService.retrieveLastApplied("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + ruleLogSchema.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveLogs() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val ruleService = client.api().v1().runs().rules() + + val ruleLogSchemata = + ruleService.retrieveLogs( + RuleRetrieveLogsParams.builder() + .ruleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .limit(100L) + .offset(0L) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + ruleLogSchemata.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/ShareServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/ShareServiceTest.kt new file mode 100644 index 00000000..60e9c0ae --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/ShareServiceTest.kt @@ -0,0 +1,66 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.runs + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import kotlin.jvm.optionals.getOrNull +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ShareServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val shareService = client.api().v1().runs().share() + + val runShareSchema = shareService.create("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + runShareSchema.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val shareService = client.api().v1().runs().share() + + val runShareSchema = shareService.list("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val unwrappedRunShareSchema = runShareSchema.getOrNull() + unwrappedRunShareSchema?.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun deleteAll() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val shareService = client.api().v1().runs().share() + + val response = shareService.deleteAll("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/rules/TriggerServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/rules/TriggerServiceTest.kt new file mode 100644 index 00000000..b6373620 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/runs/rules/TriggerServiceTest.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.runs.rules + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.runs.rules.trigger.TriggerCreateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class TriggerServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val triggerService = client.api().v1().runs().rules().trigger() + + val trigger = + triggerService.create( + TriggerCreateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addRuleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + trigger.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/sessions/InsightServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/sessions/InsightServiceTest.kt new file mode 100644 index 00000000..17629cea --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/sessions/InsightServiceTest.kt @@ -0,0 +1,192 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.sessions + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.sessions.insights.CreateRunClusteringJobRequest +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightCreateParams +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightDeleteParams +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightListParams +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightRetrieveParams +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightRetrieveRunsParams +import com.langsmith_api.api.models.api.v1.sessions.insights.InsightUpdateParams +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class InsightServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val insightService = client.api().v1().sessions().insights() + + val insight = + insightService.create( + InsightCreateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createRunClusteringJobRequest( + CreateRunClusteringJobRequest.builder() + .attributeSchemas(JsonValue.from(mapOf<String, Any>())) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addHierarchy(0L) + .lastNHours(0L) + .model(CreateRunClusteringJobRequest.Model.OPENAI) + .name("name") + .partitions( + CreateRunClusteringJobRequest.Partitions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .sample(0.0) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .summaryPrompt("summary_prompt") + .userContext( + CreateRunClusteringJobRequest.UserContext.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .validateModelSecrets(true) + .build() + ) + .build() + ) + + insight.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val insightService = client.api().v1().sessions().insights() + + val insight = + insightService.retrieve( + InsightRetrieveParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .clusterId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + insight.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val insightService = client.api().v1().sessions().insights() + + val insight = + insightService.update( + InsightUpdateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .build() + ) + + insight.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val insightService = client.api().v1().sessions().insights() + + val insights = + insightService.list( + InsightListParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .offset(0L) + .build() + ) + + insights.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val insightService = client.api().v1().sessions().insights() + + val insight = + insightService.delete( + InsightDeleteParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + insight.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveRuns() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val insightService = client.api().v1().sessions().insights() + + val response = + insightService.retrieveRuns( + InsightRetrieveRunsParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .attributeSortKey("attribute_sort_key") + .attributeSortOrder(InsightRetrieveRunsParams.AttributeSortOrder.ASC) + .clusterId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(1L) + .offset(0L) + .build() + ) + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/sessions/ViewServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/sessions/ViewServiceTest.kt new file mode 100644 index 00000000..56acea82 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/sessions/ViewServiceTest.kt @@ -0,0 +1,145 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.sessions + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.sessions.views.FilterViewType +import com.langsmith_api.api.models.api.v1.sessions.views.ViewCreateParams +import com.langsmith_api.api.models.api.v1.sessions.views.ViewDeleteParams +import com.langsmith_api.api.models.api.v1.sessions.views.ViewListParams +import com.langsmith_api.api.models.api.v1.sessions.views.ViewRetrieveParams +import com.langsmith_api.api.models.api.v1.sessions.views.ViewUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ViewServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val viewService = client.api().v1().sessions().views() + + val filterView = + viewService.create( + ViewCreateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .displayName("display_name") + .description("description") + .filterString("filter_string") + .traceFilterString("trace_filter_string") + .treeFilterString("tree_filter_string") + .type(FilterViewType.RUNS) + .build() + ) + + filterView.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val viewService = client.api().v1().sessions().views() + + val filterView = + viewService.retrieve( + ViewRetrieveParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + filterView.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val viewService = client.api().v1().sessions().views() + + val filterView = + viewService.update( + ViewUpdateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .displayName("display_name") + .filterString("filter_string") + .traceFilterString("trace_filter_string") + .treeFilterString("tree_filter_string") + .type(FilterViewType.RUNS) + .build() + ) + + filterView.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val viewService = client.api().v1().sessions().views() + + val filterViews = + viewService.list( + ViewListParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .type(FilterViewType.RUNS) + .build() + ) + + filterViews.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val viewService = client.api().v1().sessions().views() + + val view = + viewService.delete( + ViewDeleteParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + view.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/sessions/insights/ConfigServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/sessions/insights/ConfigServiceTest.kt new file mode 100644 index 00000000..4981e643 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/sessions/insights/ConfigServiceTest.kt @@ -0,0 +1,194 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.sessions.insights + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.api.v1.sessions.insights.CreateRunClusteringJobRequest +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigCreateParams +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigDeleteParams +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigGenerateParams +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigListParams +import com.langsmith_api.api.models.api.v1.sessions.insights.configs.ConfigUpdateParams +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ConfigServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val configService = client.api().v1().sessions().insights().configs() + + val createClusteringJobConfigResponse = + configService.create( + ConfigCreateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config( + CreateRunClusteringJobRequest.builder() + .attributeSchemas(JsonValue.from(mapOf<String, Any>())) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addHierarchy(0L) + .lastNHours(0L) + .model(CreateRunClusteringJobRequest.Model.OPENAI) + .name("name") + .partitions( + CreateRunClusteringJobRequest.Partitions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .sample(0.0) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .summaryPrompt("summary_prompt") + .userContext( + CreateRunClusteringJobRequest.UserContext.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .validateModelSecrets(true) + .build() + ) + .name("name") + .description("description") + .build() + ) + + createClusteringJobConfigResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val configService = client.api().v1().sessions().insights().configs() + + val createClusteringJobConfigResponse = + configService.update( + ConfigUpdateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .configId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config( + CreateRunClusteringJobRequest.builder() + .attributeSchemas(JsonValue.from(mapOf<String, Any>())) + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addHierarchy(0L) + .lastNHours(0L) + .model(CreateRunClusteringJobRequest.Model.OPENAI) + .name("name") + .partitions( + CreateRunClusteringJobRequest.Partitions.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .sample(0.0) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .summaryPrompt("summary_prompt") + .userContext( + CreateRunClusteringJobRequest.UserContext.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .validateModelSecrets(true) + .build() + ) + .description("description") + .name("name") + .build() + ) + + createClusteringJobConfigResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val configService = client.api().v1().sessions().insights().configs() + + val configs = + configService.list( + ConfigListParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .includePrebuilts(true) + .build() + ) + + configs.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val configService = client.api().v1().sessions().insights().configs() + + val config = + configService.delete( + ConfigDeleteParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .configId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + config.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun generate() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val configService = client.api().v1().sessions().insights().configs() + + val response = + configService.generate( + ConfigGenerateParams.builder() + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userContext( + ConfigGenerateParams.UserContext.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .model(ConfigGenerateParams.Model.OPENAI) + .build() + ) + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/sso/EmailVerificationServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/sso/EmailVerificationServiceTest.kt new file mode 100644 index 00000000..de387ea5 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/sso/EmailVerificationServiceTest.kt @@ -0,0 +1,82 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.sso + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.sso.emailverification.EmailVerificationConfirmParams +import com.langsmith_api.api.models.api.v1.sso.emailverification.EmailVerificationSendParams +import com.langsmith_api.api.models.api.v1.sso.emailverification.EmailVerificationStatusParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class EmailVerificationServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun confirm() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val emailVerificationService = client.api().v1().sso().emailVerification() + + val response = + emailVerificationService.confirm( + EmailVerificationConfirmParams.builder().token("token").build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun send() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val emailVerificationService = client.api().v1().sso().emailVerification() + + val response = + emailVerificationService.send( + EmailVerificationSendParams.builder() + .email("email") + .samlProviderId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun status() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val emailVerificationService = client.api().v1().sso().emailVerification() + + val response = + emailVerificationService.status( + EmailVerificationStatusParams.builder() + .email("email") + .samlProviderId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/CurrentServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/CurrentServiceTest.kt new file mode 100644 index 00000000..216f01b7 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/CurrentServiceTest.kt @@ -0,0 +1,53 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.workspaces + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.workspaces.current.CurrentRetrieveStatsParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CurrentServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieveStats() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val currentService = client.api().v1().workspaces().current() + + val response = + currentService.retrieveStats( + CurrentRetrieveStatsParams.builder() + .addTagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveUsageLimits() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val currentService = client.api().v1().workspaces().current() + + val response = currentService.retrieveUsageLimits() + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/PendingServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/PendingServiceTest.kt new file mode 100644 index 00000000..e4a685dd --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/PendingServiceTest.kt @@ -0,0 +1,64 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.workspaces + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class PendingServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val pendingService = client.api().v1().workspaces().pending() + + val appSchemasTenants = pendingService.list() + + appSchemasTenants.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val pendingService = client.api().v1().workspaces().pending() + + val pending = pendingService.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + pending.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun claim() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val pendingService = client.api().v1().workspaces().pending() + + val response = pendingService.claim("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/MemberServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/MemberServiceTest.kt new file mode 100644 index 00000000..d49cb293 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/MemberServiceTest.kt @@ -0,0 +1,160 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.workspaces.current + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.orgs.current.members.PendingIdentityCreate +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberBatchParams +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberCreateParams +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberRetrieveActiveParams +import com.langsmith_api.api.models.api.v1.workspaces.current.members.MemberUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class MemberServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val memberService = client.api().v1().workspaces().current().members() + + val identity = + memberService.create( + MemberCreateParams.builder() + .lsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgIdentityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + identity.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val memberService = client.api().v1().workspaces().current().members() + + val member = + memberService.update( + MemberUpdateParams.builder() + .identityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .readOnly(true) + .build() + ) + + member.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val memberService = client.api().v1().workspaces().current().members() + + val members = memberService.list() + + members.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val memberService = client.api().v1().workspaces().current().members() + + val member = memberService.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + member.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun batch() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val memberService = client.api().v1().workspaces().current().members() + + val pendingIdentities = + memberService.batch( + MemberBatchParams.builder() + .addBody( + PendingIdentityCreate.builder() + .email("email") + .fullName("full_name") + .password("password") + .readOnly(true) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWorkspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .workspaceRoleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + ) + + pendingIdentities.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveActive() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val memberService = client.api().v1().workspaces().current().members() + + val memberIdentities = + memberService.retrieveActive( + MemberRetrieveActiveParams.builder() + .addEmail("string") + .limit(1L) + .addLsUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .offset(0L) + .addUserId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + memberIdentities.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/SecretServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/SecretServiceTest.kt new file mode 100644 index 00000000..952c605a --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/SecretServiceTest.kt @@ -0,0 +1,76 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.workspaces.current + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.workspaces.current.secrets.SecretCreateParams +import com.langsmith_api.api.models.api.v1.workspaces.current.secrets.SecretRetrieveEncryptedParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class SecretServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val secretService = client.api().v1().workspaces().current().secrets() + + val secret = + secretService.create( + SecretCreateParams.builder() + .addBody(SecretCreateParams.Body.builder().key("key").value("value").build()) + .build() + ) + + secret.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val secretService = client.api().v1().workspaces().current().secrets() + + val secrets = secretService.list() + + secrets.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveEncrypted() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val secretService = client.api().v1().workspaces().current().secrets() + + val response = + secretService.retrieveEncrypted( + SecretRetrieveEncryptedParams.builder() + .service(SecretRetrieveEncryptedParams.Service.AGENT_BUILDER) + .build() + ) + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/SharedServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/SharedServiceTest.kt new file mode 100644 index 00000000..de961949 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/SharedServiceTest.kt @@ -0,0 +1,54 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.workspaces.current + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.workspaces.current.shared.SharedDeleteAllParams +import com.langsmith_api.api.models.api.v1.workspaces.current.shared.SharedListParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class SharedServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val sharedService = client.api().v1().workspaces().current().shared() + + val shareds = sharedService.list(SharedListParams.builder().limit(1L).offset(0L).build()) + + shareds.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun deleteAll() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val sharedService = client.api().v1().workspaces().current().shared() + + val response = + sharedService.deleteAll( + SharedDeleteAllParams.builder() + .addShareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/TagKeyServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/TagKeyServiceTest.kt new file mode 100644 index 00000000..2882cb71 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/TagKeyServiceTest.kt @@ -0,0 +1,110 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.workspaces.current + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.TagKeyTagKeysParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.TagKeyUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class TagKeyServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tagKeyService = client.api().v1().workspaces().current().tagKeys() + + val tagKey = tagKeyService.retrieve("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + tagKey.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tagKeyService = client.api().v1().workspaces().current().tagKeys() + + val tagKey = + tagKeyService.update( + TagKeyUpdateParams.builder() + .tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .key("x") + .build() + ) + + tagKey.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tagKeyService = client.api().v1().workspaces().current().tagKeys() + + val tagKey = tagKeyService.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + tagKey.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveTagKeys() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tagKeyService = client.api().v1().workspaces().current().tagKeys() + + val tagKeys = tagKeyService.retrieveTagKeys() + + tagKeys.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun tagKeys() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tagKeyService = client.api().v1().workspaces().current().tagKeys() + + val tagKey = + tagKeyService.tagKeys( + TagKeyTagKeysParams.builder().key("x").description("description").build() + ) + + tagKey.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/TagServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/TagServiceTest.kt new file mode 100644 index 00000000..b7e73c4e --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/TagServiceTest.kt @@ -0,0 +1,83 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.workspaces.current + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.workspaces.current.tags.ResourceType +import com.langsmith_api.api.models.api.v1.workspaces.current.tags.TagResourcesParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tags.TagRetrieveResourceParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class TagServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tagService = client.api().v1().workspaces().current().tags() + + val tags = tagService.list() + + tags.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun resources() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tagService = client.api().v1().workspaces().current().tags() + + val response = + tagService.resources( + TagResourcesParams.builder() + .addBody( + TagResourcesParams.Body.builder() + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceType(ResourceType.PROMPT) + .build() + ) + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveResource() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tagService = client.api().v1().workspaces().current().tags() + + val response = + tagService.retrieveResource( + TagRetrieveResourceParams.builder() + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceType(ResourceType.PROMPT) + .build() + ) + + response.forEach { it.validate() } + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/TaggingServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/TaggingServiceTest.kt new file mode 100644 index 00000000..83b40f50 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/TaggingServiceTest.kt @@ -0,0 +1,79 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.workspaces.current + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.workspaces.current.taggings.TaggingCreateParams +import com.langsmith_api.api.models.api.v1.workspaces.current.taggings.TaggingListParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tags.ResourceType +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class TaggingServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val taggingService = client.api().v1().workspaces().current().taggings() + + val tagging = + taggingService.create( + TaggingCreateParams.builder() + .resourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .resourceType(ResourceType.PROMPT) + .tagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + tagging.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val taggingService = client.api().v1().workspaces().current().taggings() + + val taggings = + taggingService.list( + TaggingListParams.builder() + .tagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + taggings.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val taggingService = client.api().v1().workspaces().current().taggings() + + val tagging = taggingService.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + tagging.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/members/PendingServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/members/PendingServiceTest.kt new file mode 100644 index 00000000..f6a2d909 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/members/PendingServiceTest.kt @@ -0,0 +1,51 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.workspaces.current.members + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.workspaces.current.members.pending.PendingListParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class PendingServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val pendingService = client.api().v1().workspaces().current().members().pending() + + val pendingIdentities = + pendingService.list( + PendingListParams.builder().addEmail("string").limit(1L).offset(0L).build() + ) + + pendingIdentities.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun deleteAll() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val pendingService = client.api().v1().workspaces().current().members().pending() + + val response = pendingService.deleteAll("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/tagkeys/TagValueServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/tagkeys/TagValueServiceTest.kt new file mode 100644 index 00000000..77d94f39 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/api/v1/workspaces/current/tagkeys/TagValueServiceTest.kt @@ -0,0 +1,129 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.api.v1.workspaces.current.tagkeys + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues.TagValueDeleteParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues.TagValueRetrieveParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues.TagValueTagValuesParams +import com.langsmith_api.api.models.api.v1.workspaces.current.tagkeys.tagvalues.TagValueUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class TagValueServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tagValueService = client.api().v1().workspaces().current().tagKeys().tagValues() + + val tagValue = + tagValueService.retrieve( + TagValueRetrieveParams.builder() + .tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + tagValue.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tagValueService = client.api().v1().workspaces().current().tagKeys().tagValues() + + val tagValue = + tagValueService.update( + TagValueUpdateParams.builder() + .tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .value("x") + .build() + ) + + tagValue.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tagValueService = client.api().v1().workspaces().current().tagKeys().tagValues() + + val tagValue = + tagValueService.delete( + TagValueDeleteParams.builder() + .tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tagValueId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + tagValue.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveTagValues() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tagValueService = client.api().v1().workspaces().current().tagKeys().tagValues() + + val tagValues = tagValueService.retrieveTagValues("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + tagValues.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun tagValues() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val tagValueService = client.api().v1().workspaces().current().tagKeys().tagValues() + + val tagValue = + tagValueService.tagValues( + TagValueTagValuesParams.builder() + .tagKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .value("x") + .description("description") + .build() + ) + + tagValue.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/datasets/ExperimentViewOverrideServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/datasets/ExperimentViewOverrideServiceTest.kt new file mode 100644 index 00000000..60aa14f0 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/datasets/ExperimentViewOverrideServiceTest.kt @@ -0,0 +1,153 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.datasets + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.datasets.experimentviewoverrides.ColumnOverride +import com.langsmith_api.api.models.datasets.experimentviewoverrides.ExperimentViewOverrideCreateParams +import com.langsmith_api.api.models.datasets.experimentviewoverrides.ExperimentViewOverrideDeleteParams +import com.langsmith_api.api.models.datasets.experimentviewoverrides.ExperimentViewOverrideRetrieveParams +import com.langsmith_api.api.models.datasets.experimentviewoverrides.ExperimentViewOverrideUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ExperimentViewOverrideServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val experimentViewOverrideService = client.datasets().experimentViewOverrides() + + val experimentViewOverride = + experimentViewOverrideService.create( + ExperimentViewOverrideCreateParams.builder() + .datasetId(JsonValue.from("\"550e8400-e29b-41d4-a716-446655440000\"")) + .addColumnOverride( + ColumnOverride.builder() + .column("column") + .addColorGradient(listOf(JsonValue.from(mapOf<String, Any>()))) + .colorMap( + ColumnOverride.ColorMap.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .hide(true) + .precision(1L) + .build() + ) + .build() + ) + + experimentViewOverride.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val experimentViewOverrideService = client.datasets().experimentViewOverrides() + + val experimentViewOverride = + experimentViewOverrideService.retrieve( + ExperimentViewOverrideRetrieveParams.builder() + .datasetId(JsonValue.from("\"550e8400-e29b-41d4-a716-446655440000\"")) + .id(JsonValue.from("\"123e4567-e89b-12d3-a456-426614174000\"")) + .build() + ) + + experimentViewOverride.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val experimentViewOverrideService = client.datasets().experimentViewOverrides() + + val experimentViewOverride = + experimentViewOverrideService.update( + ExperimentViewOverrideUpdateParams.builder() + .datasetId(JsonValue.from("\"550e8400-e29b-41d4-a716-446655440000\"")) + .id(JsonValue.from("\"123e4567-e89b-12d3-a456-426614174000\"")) + .addColumnOverride( + ColumnOverride.builder() + .column("column") + .addColorGradient(listOf(JsonValue.from(mapOf<String, Any>()))) + .colorMap( + ColumnOverride.ColorMap.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .hide(true) + .precision(1L) + .build() + ) + .build() + ) + + experimentViewOverride.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val experimentViewOverrideService = client.datasets().experimentViewOverrides() + + val experimentViewOverrides = + experimentViewOverrideService.list( + JsonValue.from("\"550e8400-e29b-41d4-a716-446655440000\"") + ) + + experimentViewOverrides.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val experimentViewOverrideService = client.datasets().experimentViewOverrides() + + experimentViewOverrideService.delete( + ExperimentViewOverrideDeleteParams.builder() + .datasetId(JsonValue.from("\"550e8400-e29b-41d4-a716-446655440000\"")) + .id(JsonValue.from("\"123e4567-e89b-12d3-a456-426614174000\"")) + .build() + ) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/platform/AlertServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/platform/AlertServiceTest.kt new file mode 100644 index 00000000..982be5b5 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/platform/AlertServiceTest.kt @@ -0,0 +1,178 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.platform + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.platform.alerts.AlertActionBase +import com.langsmith_api.api.models.platform.alerts.AlertCreateParams +import com.langsmith_api.api.models.platform.alerts.AlertDeleteParams +import com.langsmith_api.api.models.platform.alerts.AlertRetrieveParams +import com.langsmith_api.api.models.platform.alerts.AlertRuleBase +import com.langsmith_api.api.models.platform.alerts.AlertUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class AlertServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val alertService = client.platform().alerts() + + val alertRuleResponse = + alertService.create( + AlertCreateParams.builder() + .sessionId(JsonValue.from(mapOf<String, Any>())) + .addAction( + AlertActionBase.builder() + .config(JsonValue.from(mapOf<String, Any>())) + .target(AlertActionBase.Target.PAGERDUTY) + .id("id") + .alertRuleId("alert_rule_id") + .build() + ) + .rule( + AlertRuleBase.builder() + .aggregation(AlertRuleBase.Aggregation.AVG) + .attribute(AlertRuleBase.Attribute.LATENCY) + .description("description") + .name("name") + .operator(AlertRuleBase.Operator.GTE) + .type(AlertRuleBase.Type.THRESHOLD) + .windowMinutes(15L) + .id("id") + .denominatorFilter("denominator_filter") + .filter("filter") + .threshold(0.0) + .thresholdMultiplier(0.0) + .thresholdWindowMinutes(60L) + .build() + ) + .build() + ) + + alertRuleResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val alertService = client.platform().alerts() + + val alertRuleResponse = + alertService.retrieve( + AlertRetrieveParams.builder() + .sessionId(JsonValue.from(mapOf<String, Any>())) + .alertRuleId(JsonValue.from(mapOf<String, Any>())) + .build() + ) + + alertRuleResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val alertService = client.platform().alerts() + + val alert = + alertService.update( + AlertUpdateParams.builder() + .sessionId(JsonValue.from(mapOf<String, Any>())) + .alertRuleId(JsonValue.from(mapOf<String, Any>())) + .addAction( + AlertActionBase.builder() + .config(JsonValue.from(mapOf<String, Any>())) + .target(AlertActionBase.Target.PAGERDUTY) + .id("id") + .alertRuleId("alert_rule_id") + .build() + ) + .rule( + AlertRuleBase.builder() + .aggregation(AlertRuleBase.Aggregation.AVG) + .attribute(AlertRuleBase.Attribute.LATENCY) + .description("description") + .name("name") + .operator(AlertRuleBase.Operator.GTE) + .type(AlertRuleBase.Type.THRESHOLD) + .windowMinutes(15L) + .id("id") + .denominatorFilter("denominator_filter") + .filter("filter") + .threshold(0.0) + .thresholdMultiplier(0.0) + .thresholdWindowMinutes(60L) + .build() + ) + .build() + ) + + alert.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val alertService = client.platform().alerts() + + val alert = + alertService.delete( + AlertDeleteParams.builder() + .sessionId(JsonValue.from(mapOf<String, Any>())) + .alertRuleId(JsonValue.from(mapOf<String, Any>())) + .build() + ) + + alert.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun test() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val alertService = client.platform().alerts() + + val response = alertService.test(JsonValue.from(mapOf<String, Any>())) + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/platform/datasets/ExampleServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/platform/datasets/ExampleServiceTest.kt new file mode 100644 index 00000000..f94c4a53 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/platform/datasets/ExampleServiceTest.kt @@ -0,0 +1,90 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.platform.datasets + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.platform.datasets.examples.ExampleHardDeleteParams +import com.langsmith_api.api.models.platform.datasets.examples.ExampleUpdateParams +import com.langsmith_api.api.models.platform.datasets.examples.ExampleUploadParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ExampleServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val exampleService = client.platform().datasets().examples() + + val example = + exampleService.update( + ExampleUpdateParams.builder() + .datasetId(JsonValue.from(mapOf<String, Any>())) + .exampleId("some content".byteInputStream()) + .exampleIdAttachmentName("some content".byteInputStream()) + .exampleIdAttachmentsOperations("some content".byteInputStream()) + .exampleIdInputs("some content".byteInputStream()) + .exampleIdOutputs("some content".byteInputStream()) + .build() + ) + + example.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun hardDelete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val exampleService = client.platform().datasets().examples() + + val response = + exampleService.hardDelete( + ExampleHardDeleteParams.builder().addExampleId("string").hardDelete(true).build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun upload() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val exampleService = client.platform().datasets().examples() + + val response = + exampleService.upload( + ExampleUploadParams.builder() + .datasetId(JsonValue.from(mapOf<String, Any>())) + .exampleId("some content".byteInputStream()) + .exampleIdInputs("some content".byteInputStream()) + .exampleIdAttachmentsName("some content".byteInputStream()) + .exampleIdOutputs("some content".byteInputStream()) + .build() + ) + + response.validate() + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/platform/orgs/current/AccessPolicyServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/platform/orgs/current/AccessPolicyServiceTest.kt new file mode 100644 index 00000000..48532395 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/platform/orgs/current/AccessPolicyServiceTest.kt @@ -0,0 +1,111 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.platform.orgs.current + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.platform.orgs.current.accesspolicies.AccessPolicyCreateParams +import com.langsmith_api.api.models.platform.orgs.current.accesspolicies.ConditionGroup +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class AccessPolicyServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val accessPolicyService = client.platform().orgs().current().accessPolicies() + + val accessPolicy = + accessPolicyService.create( + AccessPolicyCreateParams.builder() + .payload( + AccessPolicyCreateParams.Payload.builder() + .addConditionGroup( + ConditionGroup.builder() + .addCondition( + ConditionGroup.Condition.builder() + .attributeKey("attribute_key") + .attributeName( + ConditionGroup.Condition.AttributeName + .RESOURCE_TAG_KEY + ) + .attributeValue("attribute_value") + .operator(ConditionGroup.Condition.Operator.EQUALS) + .build() + ) + .permission(ConditionGroup.Permission.ANNOTATION_QUEUES_CREATE) + .resourceType("resource_type") + .build() + ) + .description("description") + .effect("effect") + .name("name") + .addRoleId("string") + .build() + ) + .build() + ) + + accessPolicy.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val accessPolicyService = client.platform().orgs().current().accessPolicies() + + val accessPolicy = accessPolicyService.retrieve(JsonValue.from(mapOf<String, Any>())) + + accessPolicy.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val accessPolicyService = client.platform().orgs().current().accessPolicies() + + val accessPolicies = accessPolicyService.list() + + accessPolicies.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val accessPolicyService = client.platform().orgs().current().accessPolicies() + + accessPolicyService.delete(JsonValue.from(mapOf<String, Any>())) + } +} diff --git a/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/platform/orgs/current/accesspolicies/RoleServiceTest.kt b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/platform/orgs/current/accesspolicies/RoleServiceTest.kt new file mode 100644 index 00000000..658b4204 --- /dev/null +++ b/langsmith-api-java-core/src/test/kotlin/com/langsmith_api/api/services/blocking/platform/orgs/current/accesspolicies/RoleServiceTest.kt @@ -0,0 +1,35 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.services.blocking.platform.orgs.current.accesspolicies + +import com.langsmith_api.api.TestServerExtension +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.models.platform.orgs.current.accesspolicies.roles.RoleAttachParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class RoleServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun attach() { + val client = + LangsmithApiOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + val roleService = client.platform().orgs().current().accessPolicies().roles() + + roleService.attach( + RoleAttachParams.builder() + .roleId(JsonValue.from(mapOf<String, Any>())) + .payload(RoleAttachParams.Payload.builder().addAccessPolicyId("string").build()) + .build() + ) + } +} diff --git a/langsmith-api-java-example/build.gradle.kts b/langsmith-api-java-example/build.gradle.kts new file mode 100644 index 00000000..4c15ab77 --- /dev/null +++ b/langsmith-api-java-example/build.gradle.kts @@ -0,0 +1,28 @@ +plugins { + id("langsmith-api.java") + application +} + +repositories { + mavenCentral() +} + +dependencies { + implementation(project(":langsmith-api-java")) +} + +tasks.withType<JavaCompile>().configureEach { + // Allow using more modern APIs, like `List.of` and `Map.of`, in examples. + options.release.set(9) +} + +application { + // Use `./gradlew :langsmith-api-java-example:run` to run `Main` + // Use `./gradlew :langsmith-api-java-example:run -Pexample=Something` to run `SomethingExample` + mainClass = "com.langsmith_api.api.example.${ + if (project.hasProperty("example")) + "${project.property("example")}Example" + else + "Main" + }" +} diff --git a/langsmith-api-java-lib/.keep b/langsmith-api-java-lib/.keep new file mode 100644 index 00000000..5e2c99fd --- /dev/null +++ b/langsmith-api-java-lib/.keep @@ -0,0 +1,4 @@ +File generated from our OpenAPI spec by Stainless. + +This directory can be used to store custom files to expand the SDK. +It is ignored by Stainless code generation and its content (other than this keep file) won't be touched. \ No newline at end of file diff --git a/langsmith-api-java-proguard-test/build.gradle.kts b/langsmith-api-java-proguard-test/build.gradle.kts new file mode 100644 index 00000000..cb7248fb --- /dev/null +++ b/langsmith-api-java-proguard-test/build.gradle.kts @@ -0,0 +1,101 @@ +plugins { + id("langsmith-api.kotlin") + id("com.gradleup.shadow") version "8.3.8" +} + +buildscript { + repositories { + google() + } + + dependencies { + classpath("com.guardsquare:proguard-gradle:7.4.2") + classpath("com.android.tools:r8:8.3.37") + } +} + +dependencies { + testImplementation(project(":langsmith-api-java")) + testImplementation(kotlin("test")) + testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3") + testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.13.4") +} + +tasks.shadowJar { + from(sourceSets.test.get().output) + configurations = listOf(project.configurations.testRuntimeClasspath.get()) +} + +val proguardJarPath = "${layout.buildDirectory.get()}/libs/${project.name}-${project.version}-proguard.jar" +val proguardJar by tasks.registering(proguard.gradle.ProGuardTask::class) { + group = "verification" + dependsOn(tasks.shadowJar) + notCompatibleWithConfigurationCache("ProGuard") + + injars(tasks.shadowJar) + outjars(proguardJarPath) + printmapping("${layout.buildDirectory.get()}/proguard-mapping.txt") + + val javaHome = System.getProperty("java.home") + if (System.getProperty("java.version").startsWith("1.")) { + // Before Java 9, the runtime classes were packaged in a single jar file. + libraryjars("$javaHome/lib/rt.jar") + } else { + // As of Java 9, the runtime classes are packaged in modular jmod files. + libraryjars( + // Filters must be specified first, as a map. + mapOf("jarfilter" to "!**.jar", "filter" to "!module-info.class"), + "$javaHome/jmods/java.base.jmod" + ) + } + + configuration("./test.pro") + configuration("../langsmith-api-java-core/src/main/resources/META-INF/proguard/langsmith-api-java-core.pro") +} + +val testProGuard by tasks.registering(JavaExec::class) { + group = "verification" + dependsOn(proguardJar) + notCompatibleWithConfigurationCache("ProGuard") + + mainClass.set("com.langsmith_api.api.proguard.ProGuardCompatibilityTest") + classpath = files(proguardJarPath) +} + +val r8JarPath = "${layout.buildDirectory.get()}/libs/${project.name}-${project.version}-r8.jar" +val r8Jar by tasks.registering(JavaExec::class) { + group = "verification" + dependsOn(tasks.shadowJar) + notCompatibleWithConfigurationCache("R8") + + mainClass.set("com.android.tools.r8.R8") + classpath = buildscript.configurations["classpath"] + + args = listOf( + "--release", + "--classfile", + "--output", r8JarPath, + "--lib", System.getProperty("java.home"), + "--pg-conf", "./test.pro", + "--pg-conf", "../langsmith-api-java-core/src/main/resources/META-INF/proguard/langsmith-api-java-core.pro", + "--pg-map-output", "${layout.buildDirectory.get()}/r8-mapping.txt", + tasks.shadowJar.get().archiveFile.get().asFile.absolutePath, + ) +} + +val testR8 by tasks.registering(JavaExec::class) { + group = "verification" + dependsOn(r8Jar) + notCompatibleWithConfigurationCache("R8") + + mainClass.set("com.langsmith_api.api.proguard.ProGuardCompatibilityTest") + classpath = files(r8JarPath) +} + +tasks.test { + dependsOn(testProGuard) + dependsOn(testR8) + // We defer to the tests run via the ProGuard JAR. + enabled = false +} diff --git a/langsmith-api-java-proguard-test/src/test/kotlin/com/langsmith_api/api/proguard/ProGuardCompatibilityTest.kt b/langsmith-api-java-proguard-test/src/test/kotlin/com/langsmith_api/api/proguard/ProGuardCompatibilityTest.kt new file mode 100644 index 00000000..b9761f03 --- /dev/null +++ b/langsmith-api-java-proguard-test/src/test/kotlin/com/langsmith_api/api/proguard/ProGuardCompatibilityTest.kt @@ -0,0 +1,338 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langsmith_api.api.proguard + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langsmith_api.api.client.okhttp.LangsmithApiOkHttpClient +import com.langsmith_api.api.core.JsonValue +import com.langsmith_api.api.core.jsonMapper +import com.langsmith_api.api.models.api.v1.charts.CustomChartMetric +import com.langsmith_api.api.models.api.v1.charts.CustomChartSeries +import com.langsmith_api.api.models.api.v1.charts.CustomChartSeriesFilters +import com.langsmith_api.api.models.api.v1.charts.CustomChartType +import com.langsmith_api.api.models.api.v1.charts.CustomChartsDataPoint +import com.langsmith_api.api.models.api.v1.charts.HostProjectChartMetric +import com.langsmith_api.api.models.api.v1.charts.SingleCustomChartResponse +import com.langsmith_api.api.models.api.v1.datasets.runs.ExampleWithRuns +import com.langsmith_api.api.models.api.v1.datasets.runs.RunCreateResponse +import com.langsmith_api.api.models.api.v1.orgs.ttlsettings.TraceTier +import com.langsmith_api.api.models.api.v1.runs.RunSchema +import com.langsmith_api.api.models.api.v1.runs.RunTypeEnum +import com.langsmith_api.api.models.api.v1.sessions.CustomChartsSection +import com.langsmith_api.api.models.api.v1.sessions.SessionSortableColumns +import java.time.OffsetDateTime +import kotlin.reflect.full.memberFunctions +import kotlin.reflect.jvm.javaMethod +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ProGuardCompatibilityTest { + + companion object { + + @JvmStatic + fun main(args: Array<String>) { + // To debug that we're using the right JAR. + val jarPath = this::class.java.getProtectionDomain().codeSource.location + println("JAR being used: $jarPath") + + // We have to manually run the test methods instead of using the JUnit runner because it + // seems impossible to get working with R8. + val test = ProGuardCompatibilityTest() + test::class + .memberFunctions + .asSequence() + .filter { function -> + function.javaMethod?.isAnnotationPresent(Test::class.java) == true + } + .forEach { it.call(test) } + } + } + + @Test + fun proguardRules() { + val rulesFile = + javaClass.classLoader.getResourceAsStream( + "META-INF/proguard/langsmith-api-java-core.pro" + ) + + assertThat(rulesFile).isNotNull() + } + + @Test + fun client() { + val client = + LangsmithApiOkHttpClient.builder() + .apiKey("My API Key") + .tenantId("My Tenant ID") + .organizationId("My Organization ID") + .build() + + assertThat(client).isNotNull() + assertThat(client.api()).isNotNull() + assertThat(client.datasets()).isNotNull() + assertThat(client.feedback()).isNotNull() + assertThat(client.runs()).isNotNull() + assertThat(client.platform()).isNotNull() + } + + @Test + fun customChartsSectionRoundtrip() { + val jsonMapper = jsonMapper() + val customChartsSection = + CustomChartsSection.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChart( + SingleCustomChartResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .chartType(CustomChartType.LINE) + .addData( + CustomChartsDataPoint.builder() + .seriesId("series_id") + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .value(0.0) + .group("group") + .build() + ) + .index(0L) + .addSeries( + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + CustomChartSeries.GroupBy.builder() + .attribute(CustomChartSeries.GroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .setBy(CustomChartSeries.GroupBy.SetBy.SECTION) + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .title("title") + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("description") + .metadata(JsonValue.from(mapOf<String, Any>())) + .build() + ) + .title("title") + .description("description") + .index(0L) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addSubSection( + CustomChartsSection.SubSection.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChart( + SingleCustomChartResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .chartType(CustomChartType.LINE) + .addData( + CustomChartsDataPoint.builder() + .seriesId("series_id") + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .value(0.0) + .group("group") + .build() + ) + .index(0L) + .addSeries( + CustomChartSeries.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metric(CustomChartMetric.RUN_COUNT) + .name("name") + .feedbackKey("feedback_key") + .filters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .groupBy( + CustomChartSeries.GroupBy.builder() + .attribute(CustomChartSeries.GroupBy.Attribute.NAME) + .maxGroups(0L) + .path("path") + .setBy(CustomChartSeries.GroupBy.SetBy.SECTION) + .build() + ) + .projectMetric(HostProjectChartMetric.MEMORY_USAGE) + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .title("title") + .commonFilters( + CustomChartSeriesFilters.builder() + .filter("filter") + .addSession("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .traceFilter("trace_filter") + .treeFilter("tree_filter") + .build() + ) + .description("description") + .metadata(JsonValue.from(mapOf<String, Any>())) + .build() + ) + .index(0L) + .title("title") + .description("description") + .build() + ) + .build() + + val roundtrippedCustomChartsSection = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customChartsSection), + jacksonTypeRef<CustomChartsSection>(), + ) + + assertThat(roundtrippedCustomChartsSection).isEqualTo(customChartsSection) + } + + @Test + fun runCreateResponseRoundtrip() { + val jsonMapper = jsonMapper() + val runCreateResponse = + RunCreateResponse.ofExampleWithRuns( + listOf( + ExampleWithRuns.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inputs(JsonValue.from(mapOf<String, Any>())) + .name("name") + .addRun( + RunSchema.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .appPath("app_path") + .dottedOrder("dotted_order") + .name("name") + .runType(RunTypeEnum.TOOL) + .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status("status") + .traceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .completionCost("completion_cost") + .completionCostDetails( + RunSchema.CompletionCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .completionTokenDetails( + RunSchema.CompletionTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .completionTokens(0L) + .addDirectChildRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error("error") + .addEvent(JsonValue.from(mapOf<String, Any>())) + .executionOrder(1L) + .extra(JsonValue.from(mapOf<String, Any>())) + .feedbackStats( + RunSchema.FeedbackStats.builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf<String, Any>()), + ) + .build() + ) + .firstTokenTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inDataset(true) + .inputs(JsonValue.from(mapOf<String, Any>())) + .inputsPreview("inputs_preview") + .inputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .lastQueuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .manifestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .manifestS3Id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .outputs(JsonValue.from(mapOf<String, Any>())) + .outputsPreview("outputs_preview") + .outputsS3Urls(JsonValue.from(mapOf<String, Any>())) + .parentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addParentRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .priceModelId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .promptCost("prompt_cost") + .promptCostDetails( + RunSchema.PromptCostDetails.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .promptTokenDetails( + RunSchema.PromptTokenDetails.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .promptTokens(0L) + .referenceDatasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .referenceExampleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .s3Urls(JsonValue.from(mapOf<String, Any>())) + .serialized(JsonValue.from(mapOf<String, Any>())) + .shareToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addTag("string") + .threadId("thread_id") + .totalCost("total_cost") + .totalTokens(0L) + .traceFirstReceivedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .traceMaxStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceMinStartTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceTier(TraceTier.LONGLIVED) + .traceUpgrade(true) + .ttlSeconds(0L) + .build() + ) + .attachmentUrls(JsonValue.from(mapOf<String, Any>())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .metadata(JsonValue.from(mapOf<String, Any>())) + .modifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .outputs(JsonValue.from(mapOf<String, Any>())) + .sourceRunId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + ) + + val roundtrippedRunCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(runCreateResponse), + jacksonTypeRef<RunCreateResponse>(), + ) + + assertThat(roundtrippedRunCreateResponse).isEqualTo(runCreateResponse) + } + + @Test + fun sessionSortableColumnsRoundtrip() { + val jsonMapper = jsonMapper() + val sessionSortableColumns = SessionSortableColumns.NAME + + val roundtrippedSessionSortableColumns = + jsonMapper.readValue( + jsonMapper.writeValueAsString(sessionSortableColumns), + jacksonTypeRef<SessionSortableColumns>(), + ) + + assertThat(roundtrippedSessionSortableColumns).isEqualTo(sessionSortableColumns) + } +} diff --git a/langsmith-api-java-proguard-test/test.pro b/langsmith-api-java-proguard-test/test.pro new file mode 100644 index 00000000..f558112c --- /dev/null +++ b/langsmith-api-java-proguard-test/test.pro @@ -0,0 +1,9 @@ +# Specify the entrypoint where ProGuard starts to determine what's reachable. +-keep class com.langsmith_api.api.proguard.** { *; } + +# For the testing framework. +-keep class org.junit.** { *; } + +# Many warnings don't apply for our testing purposes. +-dontnote +-dontwarn \ No newline at end of file diff --git a/langsmith-api-java/build.gradle.kts b/langsmith-api-java/build.gradle.kts new file mode 100644 index 00000000..e54f25ea --- /dev/null +++ b/langsmith-api-java/build.gradle.kts @@ -0,0 +1,29 @@ +plugins { + id("langsmith-api.kotlin") + id("langsmith-api.publish") +} + +dependencies { + api(project(":langsmith-api-java-client-okhttp")) +} + +// Redefine `dokkaJavadoc` to: +// - Depend on the root project's task for merging the docs of all the projects +// - Forward that task's output to this task's output +tasks.named("dokkaJavadoc").configure { + actions.clear() + + val dokkaJavadocCollector = rootProject.tasks["dokkaJavadocCollector"] + dependsOn(dokkaJavadocCollector) + + val outputDirectory = project.layout.buildDirectory.dir("dokka/javadoc") + doLast { + copy { + from(dokkaJavadocCollector.outputs.files) + into(outputDirectory) + duplicatesStrategy = DuplicatesStrategy.INCLUDE + } + } + + outputs.dir(outputDirectory) +} diff --git a/scripts/build b/scripts/build new file mode 100755 index 00000000..f4063482 --- /dev/null +++ b/scripts/build @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +echo "==> Building classes" +./gradlew build testClasses -x test diff --git a/scripts/fast-format b/scripts/fast-format new file mode 100755 index 00000000..1b3bc473 --- /dev/null +++ b/scripts/fast-format @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +set -euo pipefail + +echo "Script started with $# arguments" +echo "Arguments: $*" +echo "Script location: $(dirname "$0")" + +cd "$(dirname "$0")/.." +echo "Changed to directory: $(pwd)" + +if [ $# -eq 0 ]; then + echo "Usage: $0 <file-with-paths> [additional-formatter-args...]" + echo "The file should contain one file path per line" + exit 1 +fi + +FILE_LIST="$1" + +echo "Looking for file: $FILE_LIST" + +if [ ! -f "$FILE_LIST" ]; then + echo "Error: File '$FILE_LIST' not found" + exit 1 +fi + +if ! command -v ktfmt-fast-format &> /dev/null; then + echo "Error: ktfmt-fast-format not found" + exit 1 +fi + +# Process Kotlin files +echo "==> Looking for Kotlin files" +kt_files=$(grep -E '\.kt$' "$FILE_LIST" | grep -v './buildSrc/build/' || true) +echo "==> Done looking for Kotlin files" + +if [[ -n "$kt_files" ]]; then + echo "==> will format Kotlin files" + echo "$kt_files" | tr '\n' '\0' | xargs -0 ktfmt-fast-format --kotlinlang-style "$@" +else + echo "No Kotlin files to format -- expected outcome during incremental formatting" +fi + +# TODO(mbudayr): support palantir-java-format +# Process Java files +# grep -E '\.java$' "$FILE_LIST" | grep -v './buildSrc/build/' | tr '\n' '\0' | xargs -0 -r palantir-java-format --palantir --replace "$@" diff --git a/scripts/format b/scripts/format new file mode 100755 index 00000000..65db1769 --- /dev/null +++ b/scripts/format @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +if command -v ktfmt &> /dev/null; then + echo "==> Running ktfmt" + ./scripts/kotlin-format +else + echo "==> Running gradlew formatKotlin" + ./gradlew formatKotlin +fi + +if command -v palantir-java-format &> /dev/null; then + echo "==> Running palantir-java-format" + ./scripts/java-format +else + echo "==> Running gradlew formatJava" + ./gradlew formatJava +fi diff --git a/scripts/java-format b/scripts/java-format new file mode 100755 index 00000000..ad5febce --- /dev/null +++ b/scripts/java-format @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +find . -name "*.java" -not -path "./buildSrc/build/*" -print0 | xargs -0 -r palantir-java-format --palantir --replace "$@" diff --git a/scripts/kotlin-format b/scripts/kotlin-format new file mode 100755 index 00000000..3b8be9ea --- /dev/null +++ b/scripts/kotlin-format @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +find . -name "*.kt" -not -path "./buildSrc/build/*" -print0 | xargs -0 -r ktfmt --kotlinlang-style "$@" diff --git a/scripts/lint b/scripts/lint new file mode 100755 index 00000000..dbc8f776 --- /dev/null +++ b/scripts/lint @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +echo "==> Running lints" + +if command -v ktfmt &> /dev/null; then + echo "==> Checking ktfmt" + ./scripts/kotlin-format --dry-run --set-exit-if-changed +else + echo "==> Running gradlew lintKotlin" + ./gradlew lintKotlin +fi + +if command -v palantir-java-format &> /dev/null; then + echo "==> Checking palantir-java-format" + ./scripts/java-format --dry-run --set-exit-if-changed +else + echo "==> Running gradlew lintJava" + ./gradlew lintJava +fi diff --git a/scripts/mock b/scripts/mock new file mode 100755 index 00000000..0b28f6ea --- /dev/null +++ b/scripts/mock @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +if [[ -n "$1" && "$1" != '--'* ]]; then + URL="$1" + shift +else + URL="$(grep 'openapi_spec_url' .stats.yml | cut -d' ' -f2)" +fi + +# Check if the URL is empty +if [ -z "$URL" ]; then + echo "Error: No OpenAPI spec path/url provided or found in .stats.yml" + exit 1 +fi + +echo "==> Starting mock server with URL ${URL}" + +# Run prism mock on the given spec +if [ "$1" == "--daemon" ]; then + npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log & + + # Wait for server to come online + echo -n "Waiting for server" + while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do + echo -n "." + sleep 0.1 + done + + if grep -q "✖ fatal" ".prism.log"; then + cat .prism.log + exit 1 + fi + + echo +else + npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" +fi diff --git a/scripts/test b/scripts/test new file mode 100755 index 00000000..047bc1db --- /dev/null +++ b/scripts/test @@ -0,0 +1,56 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[0;33m' +NC='\033[0m' # No Color + +function prism_is_running() { + curl --silent "http://localhost:4010" >/dev/null 2>&1 +} + +kill_server_on_port() { + pids=$(lsof -t -i tcp:"$1" || echo "") + if [ "$pids" != "" ]; then + kill "$pids" + echo "Stopped $pids." + fi +} + +function is_overriding_api_base_url() { + [ -n "$TEST_API_BASE_URL" ] +} + +if ! is_overriding_api_base_url && ! prism_is_running ; then + # When we exit this script, make sure to kill the background mock server process + trap 'kill_server_on_port 4010' EXIT + + # Start the dev server + ./scripts/mock --daemon +fi + +if is_overriding_api_base_url ; then + echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}" + echo +elif ! prism_is_running ; then + echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server" + echo -e "running against your OpenAPI spec." + echo + echo -e "To run the server, pass in the path or url of your OpenAPI" + echo -e "spec to the prism command:" + echo + echo -e " \$ ${YELLOW}npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock path/to/your.openapi.yml${NC}" + echo + + exit 1 +else + echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}" + echo +fi + +echo "==> Running tests" +./gradlew test "$@" diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 00000000..e42604d3 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,14 @@ +rootProject.name = "langsmith-api-java-root" + +val projectNames = rootDir.listFiles() + ?.asSequence() + .orEmpty() + .filter { file -> + file.isDirectory && + file.name.startsWith("langsmith-api-java") && + file.listFiles()?.asSequence().orEmpty().any { it.name == "build.gradle.kts" } + } + .map { it.name } + .toList() +println("projects: $projectNames") +projectNames.forEach { include(it) }